fancy-ui-vue 0.4.0 → 0.5.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.
Files changed (83) hide show
  1. package/README.md +12 -12
  2. package/dist/components/animated-testimonials/AnimatedTestimonials.vue.js +23 -12
  3. package/dist/components/bg-falling-stars/FallingStarsBg.vue.js +10 -1
  4. package/dist/components/bg-falling-stars/bg-falling-stars-core.d.ts +6 -0
  5. package/dist/components/bg-falling-stars/bg-falling-stars-core.js +24 -2
  6. package/dist/components/bg-stars/StarsBackground.vue.js +1 -1
  7. package/dist/components/bg-stars/StarsBackground.vue2.js +13 -1
  8. package/dist/components/bg-stars/bg-stars-core.d.ts +6 -0
  9. package/dist/components/bg-stars/bg-stars-core.js +21 -1
  10. package/dist/components/book/Book.vue.js +5 -83
  11. package/dist/components/book/Book.vue2.js +82 -1
  12. package/dist/components/box-reveal/BoxReveal.vue.js +5 -47
  13. package/dist/components/box-reveal/BoxReveal.vue2.js +48 -1
  14. package/dist/components/compare/StarField.vue.js +1 -1
  15. package/dist/components/container-text-flip/ContainerTextFlip.vue.js +1 -1
  16. package/dist/components/container-text-flip/ContainerTextFlip.vue2.js +14 -5
  17. package/dist/components/flickering-grid/FlickeringGrid.vue.js +19 -1
  18. package/dist/components/flickering-grid/flickering-grid-core.d.ts +6 -0
  19. package/dist/components/flickering-grid/flickering-grid-core.js +30 -1
  20. package/dist/components/flip-words/FlipWords.vue.js +1 -1
  21. package/dist/components/flip-words/FlipWords.vue2.js +14 -7
  22. package/dist/components/frost-glass/FrostGlass.vue.d.ts +31 -0
  23. package/dist/components/frost-glass/FrostGlass.vue.js +90 -0
  24. package/dist/components/frost-glass/FrostGlass.vue2.js +4 -0
  25. package/dist/components/frost-glass/frost-glass-core.d.ts +155 -0
  26. package/dist/components/frost-glass/frost-glass-core.js +820 -0
  27. package/dist/components/frost-glass/index.d.ts +2 -0
  28. package/dist/components/gift-reveal/GiftReveal.vue.d.ts +50 -0
  29. package/dist/components/gift-reveal/GiftReveal.vue.js +7 -0
  30. package/dist/components/gift-reveal/GiftReveal.vue2.js +177 -0
  31. package/dist/components/gift-reveal/gift-reveal-core.d.ts +109 -0
  32. package/dist/components/gift-reveal/gift-reveal-core.js +116 -0
  33. package/dist/components/gift-reveal/index.d.ts +2 -0
  34. package/dist/components/hyper-text/HyperText.vue.js +6 -97
  35. package/dist/components/hyper-text/HyperText.vue2.js +101 -0
  36. package/dist/components/letter-pullup/LetterPullup.vue.js +6 -38
  37. package/dist/components/letter-pullup/LetterPullup.vue2.js +40 -0
  38. package/dist/components/logo-cloud/AnimatedLogoCloud.vue.js +1 -1
  39. package/dist/components/matrix-rain/MatrixRain.vue.js +20 -1
  40. package/dist/components/matrix-rain/matrix-rain-core.d.ts +6 -0
  41. package/dist/components/matrix-rain/matrix-rain-core.js +28 -6
  42. package/dist/components/noise-reveal/NoiseReveal.vue.js +7 -0
  43. package/dist/components/noise-reveal/noise-reveal-core.js +23 -7
  44. package/dist/components/ornament/Ornament.vue.d.ts +29 -0
  45. package/dist/components/ornament/Ornament.vue.js +112 -0
  46. package/dist/components/ornament/Ornament.vue2.js +4 -0
  47. package/dist/components/ornament/index.d.ts +2 -0
  48. package/dist/components/ornament/ornament-core.d.ts +177 -0
  49. package/dist/components/ornament/ornament-core.js +861 -0
  50. package/dist/components/ripple/Ripple.vue.js +1 -1
  51. package/dist/components/ripple/Ripple.vue2.js +6 -1
  52. package/dist/components/snowfall/Snowfall.vue.d.ts +29 -0
  53. package/dist/components/snowfall/Snowfall.vue.js +81 -0
  54. package/dist/components/snowfall/Snowfall.vue2.js +4 -0
  55. package/dist/components/snowfall/index.d.ts +2 -0
  56. package/dist/components/snowfall/snowfall-core.d.ts +119 -0
  57. package/dist/components/snowfall/snowfall-core.js +483 -0
  58. package/dist/components/sparkles/Sparkles.vue.js +10 -1
  59. package/dist/components/sparkles/sparkles-core.d.ts +6 -0
  60. package/dist/components/sparkles/sparkles-core.js +26 -2
  61. package/dist/components/sparkles-text/SparklesText.vue.js +6 -88
  62. package/dist/components/sparkles-text/SparklesText.vue2.js +100 -0
  63. package/dist/components/string-lights/StringLights.vue.d.ts +35 -0
  64. package/dist/components/string-lights/StringLights.vue.js +7 -0
  65. package/dist/components/string-lights/StringLights.vue2.js +98 -0
  66. package/dist/components/string-lights/index.d.ts +2 -0
  67. package/dist/components/string-lights/string-lights-core.d.ts +157 -0
  68. package/dist/components/string-lights/string-lights-core.js +228 -0
  69. package/dist/components/terminal-text/TerminalText.vue.js +1 -1
  70. package/dist/components/terminal-text/TerminalText.vue2.js +36 -4
  71. package/dist/components/text-generate-effect/TextGenerateEffect.vue.js +5 -72
  72. package/dist/components/text-generate-effect/TextGenerateEffect.vue2.js +74 -1
  73. package/dist/components/text-reveal-card/TextRevealCard.vue.js +5 -101
  74. package/dist/components/text-reveal-card/TextRevealCard.vue2.js +98 -1
  75. package/dist/components/text-reveal-card/TextRevealStars.vue.js +1 -1
  76. package/dist/components/text-reveal-card/TextRevealStars.vue2.js +29 -12
  77. package/dist/index.d.ts +5 -0
  78. package/dist/index.js +393 -386
  79. package/dist/styles.css +1669 -185
  80. package/package.json +2 -2
  81. package/dist/components/hyper-text/HyperText.vue3.js +0 -5
  82. package/dist/components/letter-pullup/LetterPullup.vue3.js +0 -5
  83. package/dist/components/sparkles-text/SparklesText.vue3.js +0 -5
@@ -0,0 +1,2 @@
1
+ export { default as FrostGlass } from "./FrostGlass.vue";
2
+ export type { FrostGlassProps } from "./FrostGlass.vue";
@@ -0,0 +1,50 @@
1
+ import type { HTMLAttributes } from "vue";
2
+ export type GiftRevealTrigger = "click" | "manual";
3
+ export interface GiftRevealProps {
4
+ /**
5
+ * What opens the box. `click` (default): the box is a button (click, tap,
6
+ * Enter or Space). `manual`: only the `open` model does.
7
+ */
8
+ trigger?: GiftRevealTrigger;
9
+ /** Once opened, a press cannot close it again (`v-model:open` still can). */
10
+ once?: boolean;
11
+ /** Wrapping paper colour, `#rgb` or `#rrggbb` */
12
+ color?: string;
13
+ /** Ribbon and bow colour, `#rgb` or `#rrggbb` */
14
+ ribbonColor?: string;
15
+ /** Colour of the light that rises out of the box, `#rgb` or `#rrggbb` */
16
+ glowColor?: string;
17
+ /** Box width in pixels. The component is 1.8 × this wide and 2.1 × tall. */
18
+ size?: number;
19
+ /** Playback speed multiplier: 2 plays twice as fast */
20
+ speed?: number;
21
+ /** Accessible name of the box button */
22
+ label?: string;
23
+ /** Called when the box starts to open, whatever opened it (`@open`) */
24
+ onOpen?: (() => void) | (() => void)[];
25
+ /** Called when the box starts to close, whatever closed it (`@close`) */
26
+ onClose?: (() => void) | (() => void)[];
27
+ /** Additional CSS classes on the root */
28
+ class?: HTMLAttributes["class"];
29
+ }
30
+ declare const _default: typeof __VLS_export;
31
+ export default _default;
32
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<GiftRevealProps & {
33
+ /** Whether the box is open (`v-model:open`). */
34
+ open?: boolean;
35
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
36
+ "update:open": (value: boolean) => any;
37
+ }, string, import("vue").PublicProps, Readonly<GiftRevealProps & {
38
+ /** Whether the box is open (`v-model:open`). */
39
+ open?: boolean;
40
+ }> & Readonly<{
41
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
42
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
43
+ /** The revealed content */
44
+ default?(): unknown;
45
+ }>;
46
+ type __VLS_WithSlots<T, S> = T & {
47
+ new (): {
48
+ $slots: S;
49
+ };
50
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./GiftReveal.vue2.js";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
+ const GiftReveal = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f28780c3"]]);
5
+ export {
6
+ GiftReveal as default
7
+ };
@@ -0,0 +1,177 @@
1
+ import { defineComponent, mergeModels, useModel, computed, ref, watch, createElementBlock, openBlock, mergeProps, unref, createElementVNode, createStaticVNode, Fragment, renderList, normalizeClass, renderSlot } from "vue";
2
+ import { cn } from "../../utils.js";
3
+ import { callListener } from "../../internals/call-listener.js";
4
+ import { useReducedMotion } from "../../internals/motion/use-media-query.js";
5
+ import { useFancyId } from "../../internals/use-id.js";
6
+ import { giftRevealVars, GIFT_REVEAL_DEFAULTS, nextOpenOnPress } from "./gift-reveal-core.js";
7
+ const _hoisted_1 = ["data-open", "data-animate", "data-motion", "data-trigger"];
8
+ const _hoisted_2 = ["aria-expanded", "aria-label", "aria-disabled"];
9
+ const _hoisted_3 = { class: "gr-box" };
10
+ const _hoisted_4 = { class: "gr-camera" };
11
+ const _hoisted_5 = { class: "gr-sinker" };
12
+ const _hoisted_6 = { class: "gr-wiggle" };
13
+ const _hoisted_7 = { class: "gr-body" };
14
+ const _hoisted_8 = {
15
+ key: 0,
16
+ class: "gr-face gr-floor"
17
+ };
18
+ const _hoisted_9 = { class: "gr-lid-hint" };
19
+ const _hoisted_10 = { class: "gr-lid-lift" };
20
+ const _hoisted_11 = { class: "gr-lid" };
21
+ const _hoisted_12 = { class: "gr-face gr-face--out gr-lid-top" };
22
+ const _hoisted_13 = {
23
+ class: "gr-burst",
24
+ "aria-hidden": "true"
25
+ };
26
+ const _hoisted_14 = { class: "gr-motes" };
27
+ const _hoisted_15 = { class: "gr-emerge" };
28
+ const _hoisted_16 = ["aria-hidden", "inert"];
29
+ const _sfc_main = /* @__PURE__ */ defineComponent({
30
+ ...{ name: "GiftReveal", inheritAttrs: false },
31
+ __name: "GiftReveal",
32
+ props: /* @__PURE__ */ mergeModels({
33
+ trigger: { default: () => GIFT_REVEAL_DEFAULTS.trigger },
34
+ once: { type: Boolean, default: () => GIFT_REVEAL_DEFAULTS.once },
35
+ color: { default: () => GIFT_REVEAL_DEFAULTS.color },
36
+ ribbonColor: { default: () => GIFT_REVEAL_DEFAULTS.ribbonColor },
37
+ glowColor: { default: () => GIFT_REVEAL_DEFAULTS.glowColor },
38
+ size: { default: () => GIFT_REVEAL_DEFAULTS.size },
39
+ speed: { default: () => GIFT_REVEAL_DEFAULTS.speed },
40
+ label: { default: () => GIFT_REVEAL_DEFAULTS.label },
41
+ onOpen: { type: [Function, Array] },
42
+ onClose: { type: [Function, Array] },
43
+ class: { type: [Boolean, null, String, Object, Array], default: "" }
44
+ }, {
45
+ "open": { type: Boolean, ...{ default: false } },
46
+ "openModifiers": {}
47
+ }),
48
+ emits: ["update:open"],
49
+ setup(__props) {
50
+ const open = useModel(__props, "open");
51
+ const reduced = useReducedMotion();
52
+ const contentId = `gift-reveal-${useFancyId()}`;
53
+ const style = computed(
54
+ () => giftRevealVars({ color: __props.color, ribbonColor: __props.ribbonColor, glowColor: __props.glowColor, size: __props.size, speed: __props.speed, reducedMotion: reduced.value })
55
+ );
56
+ const animate = ref(false);
57
+ const shown = ref(open.value);
58
+ watch(open, (want) => {
59
+ if (want === shown.value) return;
60
+ shown.value = want;
61
+ animate.value = true;
62
+ if (want) callListener(__props.onOpen);
63
+ else callListener(__props.onClose);
64
+ });
65
+ function press() {
66
+ const next = nextOpenOnPress(open.value, { trigger: __props.trigger, once: __props.once });
67
+ if (next !== null) open.value = next;
68
+ }
69
+ const locked = computed(() => __props.trigger === "manual" || __props.once && shown.value);
70
+ const BODY = ["back", "left", "floor", "right", "front"];
71
+ const LID_SIDES = ["back", "left", "right", "front"];
72
+ const ARMS = ["n", "s", "w", "e"];
73
+ const MOTES = [0, 1, 2, 3, 4, 5, 6, 7];
74
+ return (_ctx, _cache) => {
75
+ return openBlock(), createElementBlock("div", mergeProps({
76
+ class: unref(cn)("ft-gift-reveal", __props.class),
77
+ "data-open": shown.value ? "" : void 0,
78
+ "data-animate": animate.value ? "" : void 0,
79
+ "data-motion": unref(reduced) ? "reduced" : void 0,
80
+ "data-trigger": __props.trigger,
81
+ style: style.value
82
+ }, _ctx.$attrs), [
83
+ _cache[11] || (_cache[11] = createElementVNode("span", {
84
+ class: "gr-spill",
85
+ "aria-hidden": "true"
86
+ }, null, -1)),
87
+ createElementVNode("button", {
88
+ type: "button",
89
+ class: "gr-button",
90
+ "aria-expanded": shown.value,
91
+ "aria-controls": contentId,
92
+ "aria-label": __props.label,
93
+ "aria-disabled": locked.value ? "true" : void 0,
94
+ onClick: press
95
+ }, [
96
+ _cache[5] || (_cache[5] = createElementVNode("span", { class: "gr-groundglow" }, null, -1)),
97
+ _cache[6] || (_cache[6] = createElementVNode("span", { class: "gr-shadow" }, null, -1)),
98
+ createElementVNode("span", _hoisted_3, [
99
+ createElementVNode("span", _hoisted_4, [
100
+ createElementVNode("span", _hoisted_5, [
101
+ createElementVNode("span", _hoisted_6, [
102
+ createElementVNode("span", _hoisted_7, [
103
+ (openBlock(), createElementBlock(Fragment, null, renderList(BODY, (side) => {
104
+ return openBlock(), createElementBlock(Fragment, { key: side }, [
105
+ side === "floor" ? (openBlock(), createElementBlock("span", _hoisted_8, [..._cache[0] || (_cache[0] = [
106
+ createElementVNode("span", { class: "gr-inlight" }, null, -1)
107
+ ])])) : (openBlock(), createElementBlock("span", {
108
+ key: 1,
109
+ class: normalizeClass(`gr-wall gr-wall--${side}`)
110
+ }, [..._cache[1] || (_cache[1] = [
111
+ createStaticVNode('<span class="gr-face gr-face--out" data-v-f28780c3><span class="gr-band gr-band--v" data-v-f28780c3></span><span class="gr-shade" data-v-f28780c3></span><span class="gr-sheen" data-v-f28780c3></span></span><span class="gr-face gr-face--in" data-v-f28780c3><span class="gr-shade" data-v-f28780c3></span><span class="gr-inlight" data-v-f28780c3></span></span>', 2)
112
+ ])], 2))
113
+ ], 64);
114
+ }), 64))
115
+ ]),
116
+ createElementVNode("span", _hoisted_9, [
117
+ createElementVNode("span", _hoisted_10, [
118
+ createElementVNode("span", _hoisted_11, [
119
+ _cache[4] || (_cache[4] = createElementVNode("span", { class: "gr-face gr-lid-under" }, null, -1)),
120
+ (openBlock(), createElementBlock(Fragment, null, renderList(LID_SIDES, (side) => {
121
+ return createElementVNode("span", {
122
+ key: side,
123
+ class: normalizeClass(`gr-face gr-face--out gr-lid-side gr-lid-side--${side}`)
124
+ }, [..._cache[2] || (_cache[2] = [
125
+ createElementVNode("span", { class: "gr-band gr-band--v" }, null, -1),
126
+ createElementVNode("span", { class: "gr-shade" }, null, -1),
127
+ createElementVNode("span", { class: "gr-sheen" }, null, -1)
128
+ ])], 2);
129
+ }), 64)),
130
+ createElementVNode("span", _hoisted_12, [
131
+ (openBlock(), createElementBlock(Fragment, null, renderList(ARMS, (arm) => {
132
+ return createElementVNode("span", {
133
+ key: arm,
134
+ class: normalizeClass(`gr-band gr-band--${arm}`)
135
+ }, null, 2);
136
+ }), 64)),
137
+ _cache[3] || (_cache[3] = createElementVNode("span", { class: "gr-sheen" }, null, -1))
138
+ ])
139
+ ])
140
+ ])
141
+ ])
142
+ ])
143
+ ])
144
+ ])
145
+ ]),
146
+ _cache[7] || (_cache[7] = createStaticVNode('<span class="gr-bow" data-v-f28780c3><span class="gr-bow-wiggle" data-v-f28780c3><span class="gr-bow-hint" data-v-f28780c3><span class="gr-bow-shadow" data-v-f28780c3></span><span class="gr-tail gr-tail--l" data-v-f28780c3></span><span class="gr-tail gr-tail--r" data-v-f28780c3></span><span class="gr-loop gr-loop--l" data-v-f28780c3></span><span class="gr-loop gr-loop--r" data-v-f28780c3></span><span class="gr-knot" data-v-f28780c3></span></span></span></span>', 1))
147
+ ], 8, _hoisted_2),
148
+ createElementVNode("span", _hoisted_13, [
149
+ _cache[8] || (_cache[8] = createElementVNode("span", { class: "gr-column" }, null, -1)),
150
+ _cache[9] || (_cache[9] = createElementVNode("span", { class: "gr-bloom" }, null, -1)),
151
+ _cache[10] || (_cache[10] = createElementVNode("span", { class: "gr-flash" }, null, -1)),
152
+ createElementVNode("span", _hoisted_14, [
153
+ (openBlock(), createElementBlock(Fragment, null, renderList(MOTES, (i) => {
154
+ return createElementVNode("span", {
155
+ key: i,
156
+ class: "gr-mote"
157
+ });
158
+ }), 64))
159
+ ])
160
+ ]),
161
+ createElementVNode("div", _hoisted_15, [
162
+ createElementVNode("div", {
163
+ id: contentId,
164
+ class: "gr-content",
165
+ "aria-hidden": shown.value ? void 0 : "true",
166
+ inert: !shown.value || void 0
167
+ }, [
168
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
169
+ ], 8, _hoisted_16)
170
+ ])
171
+ ], 16, _hoisted_1);
172
+ };
173
+ }
174
+ });
175
+ export {
176
+ _sfc_main as default
177
+ };
@@ -0,0 +1,109 @@
1
+ /**
2
+ * GiftReveal core: the opening and closing timeline of a wrapped box, and the
3
+ * CSS custom properties the wrappers write on the root so the stylesheet can
4
+ * play it.
5
+ *
6
+ * Framework-free and shared byte-for-byte by the Svelte, React and Vue
7
+ * wrappers (see shared-cores.json). It has no imports and never touches the
8
+ * DOM: every export is a pure function or a constant, safe during SSR.
9
+ *
10
+ * The box is drawn and moved by CSS only (3D transforms, transitions and
11
+ * keyframes). What this file decides is WHEN each part moves. The opening is
12
+ * five overlapping phases:
13
+ *
14
+ * anticipate the box squashes and wiggles, as if something inside stirs
15
+ * untie the bow loosens and the ribbon slides off
16
+ * lid the lid lifts, tilts back and drifts away
17
+ * burst warm light rises out of the box and spills around it
18
+ * reveal the content rises out and settles; the box sinks back
19
+ *
20
+ * Closing plays a shorter reverse. Each phase becomes a pair of custom
21
+ * properties per direction (`--gr-o-lid-delay`, `--gr-o-lid-dur` for opening,
22
+ * `--gr-c-lid-delay`, `--gr-c-lid-dur` for closing). Both directions are
23
+ * written at once, because a CSS transition takes its timing from the state
24
+ * it is heading TO: the open rule reads the `-o-` set, the closed rule the
25
+ * `-c-` set.
26
+ */
27
+ /**
28
+ * The motion tokens this timeline is built from, in milliseconds. Copied from
29
+ * `_internals/motion/tokens.ts` (DURATIONS) because a shared core may not
30
+ * import outside its folder; keep the two in sync by hand.
31
+ */
32
+ export declare const GIFT_REVEAL_TOKENS: {
33
+ readonly micro: 80;
34
+ readonly fast: 150;
35
+ readonly base: 300;
36
+ readonly exit: 200;
37
+ readonly entrance: 600;
38
+ };
39
+ export type GiftRevealPhaseName = "anticipate" | "untie" | "lid" | "burst" | "reveal";
40
+ /** Every phase, in the order it starts when the box opens. */
41
+ export declare const GIFT_REVEAL_PHASE_NAMES: readonly GiftRevealPhaseName[];
42
+ export interface GiftRevealPhase {
43
+ name: GiftRevealPhaseName;
44
+ /** Milliseconds from the start of the sequence. */
45
+ start: number;
46
+ /** Milliseconds. */
47
+ duration: number;
48
+ }
49
+ export interface GiftRevealTimeline {
50
+ direction: "open" | "close";
51
+ phases: readonly GiftRevealPhase[];
52
+ /** Milliseconds until the last phase ends. */
53
+ total: number;
54
+ }
55
+ export declare const GIFT_REVEAL_DEFAULTS: {
56
+ readonly open: false;
57
+ readonly trigger: "click" | "manual";
58
+ readonly once: false;
59
+ /** Wrapping paper. A deep ink blue: reads as premium, not seasonal. */
60
+ readonly color: "#26324d";
61
+ /** Ribbon. Champagne, so it catches the light against the dark paper. */
62
+ readonly ribbonColor: "#e9d6ad";
63
+ /** The light that rises out of the box. */
64
+ readonly glowColor: "#ffd28a";
65
+ /** Box width in pixels. */
66
+ readonly size: 160;
67
+ /** Playback speed multiplier. 2 is twice as fast. */
68
+ readonly speed: 1;
69
+ /** Accessible name of the closed box. */
70
+ readonly label: "Open";
71
+ };
72
+ /** Slowest and fastest speed accepted, so a stray 0 never freezes the box. */
73
+ export declare const GIFT_REVEAL_SPEED_RANGE: {
74
+ readonly min: 0.1;
75
+ readonly max: 10;
76
+ };
77
+ /** Clamp a speed multiplier; anything not finite falls back to 1. */
78
+ export declare function clampSpeed(speed: number | undefined): number;
79
+ /** The timeline for one direction, scaled by `speed` (phases are rounded to whole ms). */
80
+ export declare function giftRevealTimeline(direction: "open" | "close", options?: {
81
+ speed?: number;
82
+ reducedMotion?: boolean;
83
+ }): GiftRevealTimeline;
84
+ /** `#rgb` or `#rrggbb`, lower-cased and expanded; anything else gives `fallback`. */
85
+ export declare function normalizeHex(value: string | undefined, fallback: string): string;
86
+ export interface GiftRevealStyleOptions {
87
+ color?: string;
88
+ ribbonColor?: string;
89
+ glowColor?: string;
90
+ size?: number;
91
+ speed?: number;
92
+ reducedMotion?: boolean;
93
+ }
94
+ /**
95
+ * Every custom property the wrappers set on the root: colours, size and both
96
+ * timelines. The stylesheet derives lighter and darker shades of each colour
97
+ * itself with `color-mix()`.
98
+ */
99
+ export declare function giftRevealVars(options?: GiftRevealStyleOptions): Record<string, string>;
100
+ /** The same properties as one inline `style` string, for wrappers that template it. */
101
+ export declare function giftRevealStyle(options?: GiftRevealStyleOptions): string;
102
+ /**
103
+ * What a press of the box does. `null` means nothing changes: the trigger is
104
+ * manual, or the box was opened with `once` and stays open.
105
+ */
106
+ export declare function nextOpenOnPress(open: boolean, options?: {
107
+ trigger?: "click" | "manual";
108
+ once?: boolean;
109
+ }): boolean | null;
@@ -0,0 +1,116 @@
1
+ const GIFT_REVEAL_TOKENS = {
2
+ fast: 150,
3
+ base: 300,
4
+ exit: 200,
5
+ entrance: 600
6
+ };
7
+ const T = GIFT_REVEAL_TOKENS;
8
+ const GIFT_REVEAL_PHASE_NAMES = [
9
+ "anticipate",
10
+ "untie",
11
+ "lid",
12
+ "burst",
13
+ "reveal"
14
+ ];
15
+ const OPEN = [
16
+ { name: "anticipate", start: 0, duration: T.base + T.fast },
17
+ // the ribbon gives as the wiggle settles: bow, then the arms on the lid,
18
+ // then the bands down the sides
19
+ { name: "untie", start: T.base, duration: T.entrance },
20
+ // the lid goes once the ribbon is off
21
+ { name: "lid", start: T.base * 3, duration: T.entrance + T.base },
22
+ // light follows the lid out
23
+ { name: "burst", start: T.base * 3 + T.fast, duration: T.entrance + T.base },
24
+ // the content rides the light up
25
+ { name: "reveal", start: T.base * 4, duration: T.entrance + T.base }
26
+ ];
27
+ const CLOSE = [
28
+ { name: "reveal", start: 0, duration: T.exit },
29
+ { name: "burst", start: 0, duration: T.exit },
30
+ { name: "lid", start: T.fast, duration: T.base + T.fast },
31
+ { name: "untie", start: T.base + T.fast, duration: T.base },
32
+ { name: "anticipate", start: 0, duration: 0 }
33
+ ];
34
+ const REDUCED = GIFT_REVEAL_PHASE_NAMES.map((name) => ({
35
+ name,
36
+ start: 0,
37
+ duration: T.base
38
+ }));
39
+ const GIFT_REVEAL_DEFAULTS = {
40
+ trigger: "click",
41
+ once: false,
42
+ /** Wrapping paper. A deep ink blue: reads as premium, not seasonal. */
43
+ color: "#26324d",
44
+ /** Ribbon. Champagne, so it catches the light against the dark paper. */
45
+ ribbonColor: "#e9d6ad",
46
+ /** The light that rises out of the box. */
47
+ glowColor: "#ffd28a",
48
+ /** Box width in pixels. */
49
+ size: 160,
50
+ /** Playback speed multiplier. 2 is twice as fast. */
51
+ speed: 1,
52
+ /** Accessible name of the closed box. */
53
+ label: "Open"
54
+ };
55
+ const GIFT_REVEAL_SPEED_RANGE = { min: 0.1, max: 10 };
56
+ function clampSpeed(speed) {
57
+ if (speed === void 0 || !Number.isFinite(speed)) return GIFT_REVEAL_DEFAULTS.speed;
58
+ return Math.min(GIFT_REVEAL_SPEED_RANGE.max, Math.max(GIFT_REVEAL_SPEED_RANGE.min, speed));
59
+ }
60
+ function giftRevealTimeline(direction, options = {}) {
61
+ const speed = clampSpeed(options.speed);
62
+ const source = options.reducedMotion ? REDUCED : direction === "open" ? OPEN : CLOSE;
63
+ const phases = source.map((p) => ({
64
+ name: p.name,
65
+ start: Math.round(p.start / speed),
66
+ duration: Math.round(p.duration / speed)
67
+ }));
68
+ const total = phases.reduce((end, p) => Math.max(end, p.start + p.duration), 0);
69
+ return { direction, phases, total };
70
+ }
71
+ function normalizeHex(value, fallback) {
72
+ if (typeof value !== "string") return fallback;
73
+ const v = value.trim().toLowerCase();
74
+ if (/^#[0-9a-f]{6}$/.test(v)) return v;
75
+ if (/^#[0-9a-f]{3}$/.test(v)) {
76
+ const [, r = "0", g = "0", b = "0"] = v;
77
+ return `#${r}${r}${g}${g}${b}${b}`;
78
+ }
79
+ return fallback;
80
+ }
81
+ function giftRevealVars(options = {}) {
82
+ const d = GIFT_REVEAL_DEFAULTS;
83
+ const size = typeof options.size === "number" && Number.isFinite(options.size) && options.size > 0 ? options.size : d.size;
84
+ const vars = {
85
+ "--gr-color": normalizeHex(options.color, d.color),
86
+ "--gr-ribbon": normalizeHex(options.ribbonColor, d.ribbonColor),
87
+ "--gr-glow": normalizeHex(options.glowColor, d.glowColor),
88
+ "--gr-size": `${size}px`
89
+ };
90
+ for (const direction of ["open", "close"]) {
91
+ const key = direction === "open" ? "o" : "c";
92
+ const timeline = giftRevealTimeline(direction, options);
93
+ for (const p of timeline.phases) {
94
+ vars[`--gr-${key}-${p.name}-delay`] = `${p.start}ms`;
95
+ vars[`--gr-${key}-${p.name}-dur`] = `${p.duration}ms`;
96
+ }
97
+ vars[`--gr-${key}-total`] = `${timeline.total}ms`;
98
+ }
99
+ return vars;
100
+ }
101
+ function nextOpenOnPress(open, options = {}) {
102
+ if ((options.trigger ?? GIFT_REVEAL_DEFAULTS.trigger) === "manual") return null;
103
+ if (open && options.once) return null;
104
+ return !open;
105
+ }
106
+ export {
107
+ GIFT_REVEAL_DEFAULTS,
108
+ GIFT_REVEAL_PHASE_NAMES,
109
+ GIFT_REVEAL_SPEED_RANGE,
110
+ GIFT_REVEAL_TOKENS,
111
+ clampSpeed,
112
+ giftRevealTimeline,
113
+ giftRevealVars,
114
+ nextOpenOnPress,
115
+ normalizeHex
116
+ };
@@ -0,0 +1,2 @@
1
+ export { default as GiftReveal } from "./GiftReveal.vue";
2
+ export type { GiftRevealProps, GiftRevealTrigger } from "./GiftReveal.vue";
@@ -1,99 +1,8 @@
1
- import { defineComponent, computed, ref, watch, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, unref, createElementVNode, Fragment, renderList, normalizeStyle, toDisplayString } from "vue";
2
- import { cn } from "../../utils.js";
3
- const _hoisted_1 = { class: "flex" };
4
- const _sfc_main = /* @__PURE__ */ defineComponent({
5
- ...{ name: "HyperText", inheritAttrs: false },
6
- __name: "HyperText",
7
- props: {
8
- text: {},
9
- duration: { default: 800 },
10
- animateOnLoad: { type: Boolean, default: false },
11
- seed: { default: 1 },
12
- class: { type: [Boolean, null, String, Object, Array] }
13
- },
14
- setup(__props) {
15
- const ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
16
- function mulberry32(seedValue) {
17
- let state = seedValue >>> 0;
18
- return () => {
19
- state = state + 1831565813 >>> 0;
20
- let t = state;
21
- t = Math.imul(t ^ t >>> 15, t | 1);
22
- t ^= t + Math.imul(t ^ t >>> 7, t | 61);
23
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
24
- };
25
- }
26
- const displayChars = computed(() => __props.text.split(""));
27
- const displayText = ref(displayChars.value);
28
- let intervalId = null;
29
- let iterations = 0;
30
- watch(
31
- displayChars,
32
- (next) => {
33
- displayText.value = next;
34
- },
35
- { flush: "post" }
36
- );
37
- function getRandomLetter(random) {
38
- return ALPHABETS[Math.floor(random() * ALPHABETS.length)] ?? "A";
39
- }
40
- function stopAnimation() {
41
- if (intervalId) {
42
- clearInterval(intervalId);
43
- intervalId = null;
44
- }
45
- }
46
- function startAnimation() {
47
- stopAnimation();
48
- iterations = 0;
49
- const intervalMs = __props.duration / (__props.text.length * 10);
50
- const random = mulberry32(__props.seed);
51
- intervalId = setInterval(() => {
52
- const target = __props.text;
53
- if (iterations < target.length) {
54
- displayText.value = displayText.value.map(
55
- (l, i) => l === " " ? l : i <= iterations ? target[i] ?? l : getRandomLetter(random)
56
- );
57
- iterations += 0.1;
58
- } else {
59
- stopAnimation();
60
- displayText.value = target.split("");
61
- }
62
- }, intervalMs);
63
- }
64
- function triggerAnimation() {
65
- iterations = 0;
66
- startAnimation();
67
- }
68
- onMounted(() => {
69
- if (__props.animateOnLoad) {
70
- triggerAnimation();
71
- }
72
- });
73
- onBeforeUnmount(stopAnimation);
74
- return (_ctx, _cache) => {
75
- return openBlock(), createElementBlock("div", {
76
- class: normalizeClass(unref(cn)("hyper-text flex scale-100 cursor-default overflow-hidden py-2", __props.class)),
77
- onMouseenter: triggerAnimation,
78
- role: "presentation"
79
- }, [
80
- createElementVNode("div", _hoisted_1, [
81
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayText.value, (letter, i) => {
82
- return openBlock(), createElementBlock("span", {
83
- key: i,
84
- class: normalizeClass(unref(cn)("hyper-text-char inline-block font-mono", letter === " " ? "w-3" : "")),
85
- style: normalizeStyle({
86
- animation: "hyperFadeIn 0.3s ease forwards",
87
- animationDelay: `${i * (__props.duration / (__props.text.length * 10))}ms`,
88
- opacity: 0
89
- })
90
- }, toDisplayString(letter.toUpperCase()), 7);
91
- }), 128))
92
- ])
93
- ], 34);
94
- };
95
- }
96
- });
1
+ import _sfc_main from "./HyperText.vue2.js";
2
+ /* empty css */
3
+ /* empty css */
4
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
5
+ const HyperText = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f520f7e3"]]);
97
6
  export {
98
- _sfc_main as default
7
+ HyperText as default
99
8
  };
@@ -0,0 +1,101 @@
1
+ import { defineComponent, computed, ref, watch, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, unref, createElementVNode, Fragment, renderList, normalizeStyle, toDisplayString } from "vue";
2
+ import { cn } from "../../utils.js";
3
+ import { prefersReducedMotion } from "../../internals/motion/anchored.js";
4
+ const _hoisted_1 = { class: "flex" };
5
+ const _sfc_main = /* @__PURE__ */ defineComponent({
6
+ ...{ name: "HyperText", inheritAttrs: false },
7
+ __name: "HyperText",
8
+ props: {
9
+ text: {},
10
+ duration: { default: 800 },
11
+ animateOnLoad: { type: Boolean, default: false },
12
+ seed: { default: 1 },
13
+ class: { type: [Boolean, null, String, Object, Array] }
14
+ },
15
+ setup(__props) {
16
+ const ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
17
+ function mulberry32(seedValue) {
18
+ let state = seedValue >>> 0;
19
+ return () => {
20
+ state = state + 1831565813 >>> 0;
21
+ let t = state;
22
+ t = Math.imul(t ^ t >>> 15, t | 1);
23
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
24
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
25
+ };
26
+ }
27
+ const displayChars = computed(() => __props.text.split(""));
28
+ const displayText = ref(displayChars.value);
29
+ let intervalId = null;
30
+ let iterations = 0;
31
+ watch(
32
+ displayChars,
33
+ (next) => {
34
+ displayText.value = next;
35
+ },
36
+ { flush: "post" }
37
+ );
38
+ function getRandomLetter(random) {
39
+ return ALPHABETS[Math.floor(random() * ALPHABETS.length)] ?? "A";
40
+ }
41
+ function stopAnimation() {
42
+ if (intervalId) {
43
+ clearInterval(intervalId);
44
+ intervalId = null;
45
+ }
46
+ }
47
+ function startAnimation() {
48
+ stopAnimation();
49
+ iterations = 0;
50
+ const intervalMs = __props.duration / (__props.text.length * 10);
51
+ const random = mulberry32(__props.seed);
52
+ intervalId = setInterval(() => {
53
+ const target = __props.text;
54
+ if (iterations < target.length) {
55
+ displayText.value = displayText.value.map(
56
+ (l, i) => l === " " ? l : i <= iterations ? target[i] ?? l : getRandomLetter(random)
57
+ );
58
+ iterations += 0.1;
59
+ } else {
60
+ stopAnimation();
61
+ displayText.value = target.split("");
62
+ }
63
+ }, intervalMs);
64
+ }
65
+ function triggerAnimation() {
66
+ iterations = 0;
67
+ if (prefersReducedMotion()) {
68
+ stopAnimation();
69
+ displayText.value = __props.text.split("");
70
+ return;
71
+ }
72
+ startAnimation();
73
+ }
74
+ onMounted(() => {
75
+ if (__props.animateOnLoad) {
76
+ triggerAnimation();
77
+ }
78
+ });
79
+ onBeforeUnmount(stopAnimation);
80
+ return (_ctx, _cache) => {
81
+ return openBlock(), createElementBlock("div", {
82
+ class: normalizeClass(unref(cn)("hyper-text flex scale-100 cursor-default overflow-hidden py-2", __props.class)),
83
+ onMouseenter: triggerAnimation,
84
+ role: "presentation"
85
+ }, [
86
+ createElementVNode("div", _hoisted_1, [
87
+ (openBlock(true), createElementBlock(Fragment, null, renderList(displayText.value, (letter, i) => {
88
+ return openBlock(), createElementBlock("span", {
89
+ key: i,
90
+ class: normalizeClass(unref(cn)("hyper-text-char inline-block font-mono", letter === " " ? "w-3" : "")),
91
+ style: normalizeStyle({ "--hyper-text-delay": `${i * (__props.duration / (__props.text.length * 10))}ms` })
92
+ }, toDisplayString(letter.toUpperCase()), 7);
93
+ }), 128))
94
+ ])
95
+ ], 34);
96
+ };
97
+ }
98
+ });
99
+ export {
100
+ _sfc_main as default
101
+ };