@joewinke/jatui 0.1.33 → 0.2.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/CLAUDE.md +22 -0
- package/dist/actions/attention.d.ts +24 -0
- package/dist/actions/attention.js +94 -0
- package/dist/actions/floating.d.ts +53 -0
- package/dist/actions/floating.js +158 -0
- package/dist/actions/staggerEntrance.d.ts +28 -0
- package/dist/actions/staggerEntrance.js +71 -0
- package/dist/actions/tooltip.d.ts +28 -0
- package/dist/actions/tooltip.js +186 -0
- package/dist/assets/sounds/README.md +47 -0
- package/dist/assets/sounds/error.d.ts +1 -0
- package/dist/assets/sounds/error.js +4 -0
- package/dist/assets/sounds/notify.d.ts +1 -0
- package/dist/assets/sounds/notify.js +4 -0
- package/dist/assets/sounds/pop.d.ts +1 -0
- package/dist/assets/sounds/pop.js +4 -0
- package/dist/assets/sounds/send.d.ts +1 -0
- package/dist/assets/sounds/send.js +4 -0
- package/dist/assets/sounds/success.d.ts +1 -0
- package/dist/assets/sounds/success.js +4 -0
- package/dist/assets/sounds/toggle.d.ts +1 -0
- package/dist/assets/sounds/toggle.js +4 -0
- package/dist/components/AnimatedNumber.svelte +112 -0
- package/dist/components/AnimatedNumber.svelte.d.ts +8 -0
- package/dist/components/Badge.svelte +75 -4
- package/dist/components/Badge.svelte.d.ts +6 -1
- package/dist/components/Button.svelte +196 -21
- package/dist/components/Button.svelte.d.ts +10 -1
- package/dist/components/Carousel.svelte +265 -0
- package/dist/components/Carousel.svelte.d.ts +21 -0
- package/dist/components/ChipInput.svelte +63 -3
- package/dist/components/Collapse.svelte +70 -14
- package/dist/components/Collapse.svelte.d.ts +11 -0
- package/dist/components/ColorSelector.svelte +21 -24
- package/dist/components/CommandPalette.svelte +475 -0
- package/dist/components/CommandPalette.svelte.d.ts +3 -0
- package/dist/components/ContextMenu.svelte +9 -73
- package/dist/components/CopyButton.svelte +156 -0
- package/dist/components/CopyButton.svelte.d.ts +12 -0
- package/dist/components/HoldToConfirm.svelte +183 -0
- package/dist/components/HoldToConfirm.svelte.d.ts +11 -0
- package/dist/components/KeyboardShortcutsOverlay.svelte +54 -8
- package/dist/components/KeyboardShortcutsOverlay.svelte.d.ts +3 -0
- package/dist/components/PasswordMeter.svelte +87 -0
- package/dist/components/PasswordMeter.svelte.d.ts +8 -0
- package/dist/components/PinInput.svelte +186 -0
- package/dist/components/PinInput.svelte.d.ts +13 -0
- package/dist/components/QuantityStepper.svelte +185 -0
- package/dist/components/QuantityStepper.svelte.d.ts +12 -0
- package/dist/components/Skeleton.svelte +123 -0
- package/dist/components/Skeleton.svelte.d.ts +12 -0
- package/dist/components/SpeechForm.svelte +37 -0
- package/dist/components/StatusBadge.svelte +31 -3
- package/dist/components/StatusBadge.svelte.d.ts +0 -5
- package/dist/components/Tabs.svelte +270 -0
- package/dist/components/Tabs.svelte.d.ts +15 -0
- package/dist/components/TextInput.svelte +138 -38
- package/dist/components/TextInput.svelte.d.ts +9 -1
- package/dist/components/VoicePlayer.svelte +51 -0
- package/dist/components/basic/Alert.svelte +36 -0
- package/dist/components/basic/Alert.svelte.d.ts +9 -0
- package/dist/components/basic/Breadcrumb.svelte +27 -0
- package/dist/components/basic/Breadcrumb.svelte.d.ts +11 -0
- package/dist/components/basic/ButtonGroup.svelte +15 -0
- package/dist/components/basic/ButtonGroup.svelte.d.ts +8 -0
- package/dist/components/basic/Checkbox.svelte +85 -0
- package/dist/components/basic/Checkbox.svelte.d.ts +15 -0
- package/dist/components/basic/Empty.svelte +17 -0
- package/dist/components/basic/Empty.svelte.d.ts +8 -0
- package/dist/components/basic/Kbd.svelte +16 -0
- package/dist/components/basic/Kbd.svelte.d.ts +8 -0
- package/dist/components/basic/Pagination.svelte +104 -0
- package/dist/components/basic/Pagination.svelte.d.ts +12 -0
- package/dist/components/basic/RadioGroup.svelte +71 -0
- package/dist/components/basic/RadioGroup.svelte.d.ts +18 -0
- package/dist/components/basic/Separator.svelte +19 -0
- package/dist/components/basic/Separator.svelte.d.ts +8 -0
- package/dist/components/basic/Slider.svelte +72 -0
- package/dist/components/basic/Slider.svelte.d.ts +17 -0
- package/dist/components/basic/Switch.svelte +88 -0
- package/dist/components/basic/Switch.svelte.d.ts +14 -0
- package/dist/components/basic/Toggle.svelte +43 -0
- package/dist/components/basic/Toggle.svelte.d.ts +14 -0
- package/dist/components/graph/GraphCanvas.svelte +103 -0
- package/dist/components/graph/GraphCanvas.svelte.d.ts +22 -0
- package/dist/components/graph/JatuiNode.svelte +128 -0
- package/dist/components/graph/JatuiNode.svelte.d.ts +14 -0
- package/dist/components/graph/theme.d.ts +27 -0
- package/dist/components/graph/theme.js +136 -0
- package/dist/components/messaging/MessageItem.svelte +92 -0
- package/dist/components/messaging/MessageItem.svelte.d.ts +5 -0
- package/dist/components/messaging/TypingIndicator.svelte +63 -0
- package/dist/components/messaging/TypingIndicator.svelte.d.ts +7 -0
- package/dist/components/pipeline/PipelineColumn.svelte +44 -3
- package/dist/components/progress/ProgressBar.svelte +189 -0
- package/dist/components/progress/ProgressBar.svelte.d.ts +17 -0
- package/dist/components/progress/ProgressRing.svelte +138 -0
- package/dist/components/progress/ProgressRing.svelte.d.ts +12 -0
- package/dist/components/progress/Steps.svelte +195 -0
- package/dist/components/progress/Steps.svelte.d.ts +14 -0
- package/dist/components/shell/NavigationMenu.svelte +422 -0
- package/dist/components/shell/NavigationMenu.svelte.d.ts +43 -0
- package/dist/components/shell/Sidebar.svelte +276 -0
- package/dist/components/shell/Sidebar.svelte.d.ts +32 -0
- package/dist/components/shell/SidebarGroup.svelte +180 -0
- package/dist/components/shell/SidebarGroup.svelte.d.ts +19 -0
- package/dist/components/shell/SidebarItem.svelte +170 -0
- package/dist/components/shell/SidebarItem.svelte.d.ts +24 -0
- package/dist/components/shell/shell.d.ts +30 -0
- package/dist/components/shell/shell.js +65 -0
- package/dist/components/table/DataTable.svelte +364 -0
- package/dist/components/table/DataTable.svelte.d.ts +4 -0
- package/dist/components/table/flexRender.d.ts +31 -0
- package/dist/components/table/flexRender.js +32 -0
- package/dist/components/table/types.d.ts +28 -0
- package/dist/components/table/types.js +1 -0
- package/dist/components/toast/ToastHost.svelte +21 -0
- package/dist/components/toast/ToastHost.svelte.d.ts +3 -0
- package/dist/components/toast/ToastItem.svelte +287 -0
- package/dist/components/toast/ToastItem.svelte.d.ts +9 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +67 -0
- package/dist/showcase/AnimatedBeam.svelte +183 -0
- package/dist/showcase/AnimatedBeam.svelte.d.ts +26 -0
- package/dist/showcase/AuroraDrift.svelte +74 -0
- package/dist/showcase/AuroraDrift.svelte.d.ts +9 -0
- package/dist/showcase/BentoCard.svelte +50 -0
- package/dist/showcase/BentoCard.svelte.d.ts +14 -0
- package/dist/showcase/BentoGrid.svelte +43 -0
- package/dist/showcase/BentoGrid.svelte.d.ts +12 -0
- package/dist/showcase/BorderBeam.svelte +79 -0
- package/dist/showcase/BorderBeam.svelte.d.ts +12 -0
- package/dist/showcase/ClipWipe.svelte +82 -0
- package/dist/showcase/ClipWipe.svelte.d.ts +12 -0
- package/dist/showcase/Confetti.svelte +71 -0
- package/dist/showcase/Confetti.svelte.d.ts +10 -0
- package/dist/showcase/CursorSpotlight.svelte +85 -0
- package/dist/showcase/CursorSpotlight.svelte.d.ts +9 -0
- package/dist/showcase/DeviceMock.svelte +186 -0
- package/dist/showcase/DeviceMock.svelte.d.ts +11 -0
- package/dist/showcase/Dock.svelte +123 -0
- package/dist/showcase/Dock.svelte.d.ts +17 -0
- package/dist/showcase/FlipCard.svelte +103 -0
- package/dist/showcase/FlipCard.svelte.d.ts +10 -0
- package/dist/showcase/FocusReveal.svelte +83 -0
- package/dist/showcase/FocusReveal.svelte.d.ts +11 -0
- package/dist/showcase/Globe.svelte +202 -0
- package/dist/showcase/Globe.svelte.d.ts +16 -0
- package/dist/showcase/KenBurns.svelte +105 -0
- package/dist/showcase/KenBurns.svelte.d.ts +13 -0
- package/dist/showcase/Marquee.svelte +89 -0
- package/dist/showcase/Marquee.svelte.d.ts +9 -0
- package/dist/showcase/ParallaxTilt.svelte +98 -0
- package/dist/showcase/ParallaxTilt.svelte.d.ts +10 -0
- package/dist/showcase/ScrambleText.svelte +98 -0
- package/dist/showcase/ScrambleText.svelte.d.ts +11 -0
- package/dist/showcase/ShineSweep.svelte +81 -0
- package/dist/showcase/ShineSweep.svelte.d.ts +9 -0
- package/dist/showcase/Terminal.svelte +230 -0
- package/dist/showcase/Terminal.svelte.d.ts +18 -0
- package/dist/showcase/TextSplitReveal.svelte +146 -0
- package/dist/showcase/TextSplitReveal.svelte.d.ts +13 -0
- package/dist/showcase/TextWave.svelte +55 -0
- package/dist/showcase/TextWave.svelte.d.ts +8 -0
- package/dist/showcase/TypewriterText.svelte +130 -0
- package/dist/showcase/TypewriterText.svelte.d.ts +9 -0
- package/dist/showcase/backdrop/GrainGradient.svelte +126 -0
- package/dist/showcase/backdrop/GrainGradient.svelte.d.ts +23 -0
- package/dist/showcase/backdrop/MeshGradient.svelte +104 -0
- package/dist/showcase/backdrop/MeshGradient.svelte.d.ts +20 -0
- package/dist/showcase/backdrop/Metaballs.svelte +116 -0
- package/dist/showcase/backdrop/Metaballs.svelte.d.ts +18 -0
- package/dist/showcase/backdrop/NeuroNoise.svelte +115 -0
- package/dist/showcase/backdrop/NeuroNoise.svelte.d.ts +20 -0
- package/dist/showcase/backdrop/ShowcaseBackdrop.svelte +48 -0
- package/dist/showcase/backdrop/ShowcaseBackdrop.svelte.d.ts +12 -0
- package/dist/showcase/generative/GenerativeBackdrop.svelte +234 -0
- package/dist/showcase/generative/GenerativeBackdrop.svelte.d.ts +9 -0
- package/dist/showcase/generative/intent.d.ts +7 -0
- package/dist/showcase/generative/intent.js +67 -0
- package/dist/showcase/generative/manifest.d.ts +9 -0
- package/dist/showcase/generative/manifest.js +97 -0
- package/dist/showcase/generative/types.d.ts +48 -0
- package/dist/showcase/generative/types.js +8 -0
- package/dist/showcase/index.d.ts +36 -0
- package/dist/showcase/index.js +46 -0
- package/dist/showcase/scroll/SmoothScroll.svelte +49 -0
- package/dist/showcase/scroll/SmoothScroll.svelte.d.ts +12 -0
- package/dist/showcase/scroll/scrollProgress.d.ts +24 -0
- package/dist/showcase/scroll/scrollProgress.js +65 -0
- package/dist/showcase/scroll/scrollReveal.d.ts +30 -0
- package/dist/showcase/scroll/scrollReveal.js +70 -0
- package/dist/stores/commandPalette.svelte.d.ts +24 -0
- package/dist/stores/commandPalette.svelte.js +82 -0
- package/dist/stores/toast.svelte.d.ts +28 -0
- package/dist/stores/toast.svelte.js +33 -0
- package/dist/styles/motion.css +46 -0
- package/dist/styles/tokens.css +31 -0
- package/dist/transitions/glide.d.ts +31 -0
- package/dist/transitions/glide.js +58 -0
- package/dist/utils/sound.d.ts +6 -0
- package/dist/utils/sound.js +113 -0
- package/dist/utils/splitText.d.ts +25 -0
- package/dist/utils/splitText.js +94 -0
- package/dist/utils/themeWipe.d.ts +21 -0
- package/dist/utils/themeWipe.js +94 -0
- package/dist/utils/viewTransition.d.ts +23 -0
- package/dist/utils/viewTransition.js +75 -0
- package/package.json +50 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { scroll, supportsScrollTimeline } from 'motion';
|
|
2
|
+
/**
|
|
3
|
+
* Svelte action: binds a CSS custom property (default --scroll-progress, 0..1)
|
|
4
|
+
* to the page scroll position via motion scroll(). Uses native ScrollTimeline
|
|
5
|
+
* where available for compositor-thread performance.
|
|
6
|
+
*
|
|
7
|
+
* Reduced-motion: no-ops (leaves var unset / at whatever CSS default).
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* <div use:scrollProgress style="width: calc(var(--scroll-progress) * 100%)">
|
|
11
|
+
* <div use:scrollProgress={{ varName: '--depth', container: panelEl }}>
|
|
12
|
+
*/
|
|
13
|
+
export function scrollProgress(node, opts) {
|
|
14
|
+
if (opts === void 0) { opts = {}; }
|
|
15
|
+
var reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
16
|
+
if (reduced)
|
|
17
|
+
return {};
|
|
18
|
+
var _a = opts.varName, varName = _a === void 0 ? '--scroll-progress' : _a, container = opts.container, _b = opts.axis, axis = _b === void 0 ? 'y' : _b;
|
|
19
|
+
// Prefer native ScrollTimeline for compositor-thread perf when available
|
|
20
|
+
if (supportsScrollTimeline() && !container) {
|
|
21
|
+
try {
|
|
22
|
+
// @ts-ignore — ScrollTimeline is not in lib.dom yet
|
|
23
|
+
var timeline = new ScrollTimeline({ source: document.documentElement, axis: axis });
|
|
24
|
+
// Animate a dummy MotionValue-style target via WAAPI
|
|
25
|
+
node.style.setProperty(varName, '0');
|
|
26
|
+
var anim_1 = node.animate({ '--jatui-scroll-noop': ['0', '1'] }, {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
timeline: timeline,
|
|
29
|
+
fill: 'both'
|
|
30
|
+
});
|
|
31
|
+
// Mirror progress via rAF while ScrollTimeline doesn't yet expose a direct hook
|
|
32
|
+
var rafId_1;
|
|
33
|
+
var tick_1 = function () {
|
|
34
|
+
var _a;
|
|
35
|
+
if (anim_1.currentTime != null) {
|
|
36
|
+
var effect = anim_1.effect;
|
|
37
|
+
var t = effect ? ((_a = effect.getComputedTiming().progress) !== null && _a !== void 0 ? _a : 0) : 0;
|
|
38
|
+
node.style.setProperty(varName, String(t));
|
|
39
|
+
}
|
|
40
|
+
rafId_1 = requestAnimationFrame(tick_1);
|
|
41
|
+
};
|
|
42
|
+
rafId_1 = requestAnimationFrame(tick_1);
|
|
43
|
+
return {
|
|
44
|
+
destroy: function () {
|
|
45
|
+
cancelAnimationFrame(rafId_1);
|
|
46
|
+
anim_1.cancel();
|
|
47
|
+
node.style.removeProperty(varName);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch (_c) {
|
|
52
|
+
// fall through to motion scroll()
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Fallback: motion scroll() — JS-thread but cross-browser
|
|
56
|
+
var stop = scroll(function (progress) {
|
|
57
|
+
node.style.setProperty(varName, String(progress));
|
|
58
|
+
}, container ? { container: container, axis: axis } : { axis: axis });
|
|
59
|
+
return {
|
|
60
|
+
destroy: function () {
|
|
61
|
+
stop();
|
|
62
|
+
node.style.removeProperty(varName);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface ScrollRevealOptions {
|
|
2
|
+
/** Translate distance in px (default 16) */
|
|
3
|
+
y?: number;
|
|
4
|
+
/** Duration token override in ms (default: var(--motion-enter) = 200ms) */
|
|
5
|
+
duration?: number;
|
|
6
|
+
/** Run once on first enter (default true) */
|
|
7
|
+
once?: boolean;
|
|
8
|
+
/** IntersectionObserver threshold amount (default 0.15) */
|
|
9
|
+
amount?: number;
|
|
10
|
+
/** Root margin for early trigger (default '-10px') */
|
|
11
|
+
margin?: string;
|
|
12
|
+
/** Stagger delay between children in ms; when set, animates children instead of host */
|
|
13
|
+
stagger?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Svelte action: reveals the element (or its children when stagger > 0) when
|
|
17
|
+
* scrolled into view. Composes with the staggerEntrance ethos — same
|
|
18
|
+
* opacity + translateY arc, same motion tokens.
|
|
19
|
+
*
|
|
20
|
+
* Reduced-motion: jumps to the final (visible) state instantly.
|
|
21
|
+
*
|
|
22
|
+
* Usage:
|
|
23
|
+
* <div use:scrollReveal>…</div>
|
|
24
|
+
* <ul use:scrollReveal={{ stagger: 60 }}>…</ul>
|
|
25
|
+
*/
|
|
26
|
+
export declare function scrollReveal(node: HTMLElement, opts?: ScrollRevealOptions): {
|
|
27
|
+
destroy?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
destroy(): void;
|
|
30
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { animateMini, inView } from 'motion';
|
|
2
|
+
import { cubicBezier } from 'motion-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Svelte action: reveals the element (or its children when stagger > 0) when
|
|
5
|
+
* scrolled into view. Composes with the staggerEntrance ethos — same
|
|
6
|
+
* opacity + translateY arc, same motion tokens.
|
|
7
|
+
*
|
|
8
|
+
* Reduced-motion: jumps to the final (visible) state instantly.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* <div use:scrollReveal>…</div>
|
|
12
|
+
* <ul use:scrollReveal={{ stagger: 60 }}>…</ul>
|
|
13
|
+
*/
|
|
14
|
+
export function scrollReveal(node, opts) {
|
|
15
|
+
if (opts === void 0) { opts = {}; }
|
|
16
|
+
var _a = opts.y, y = _a === void 0 ? 16 : _a, _b = opts.once, once = _b === void 0 ? true : _b, _c = opts.amount, amount = _c === void 0 ? 0.15 : _c, _d = opts.margin, margin = _d === void 0 ? '-10px' : _d, staggerMs = opts.stagger;
|
|
17
|
+
var reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
18
|
+
var targets = staggerMs != null ? Array.from(node.children) : [node];
|
|
19
|
+
if (reduced) {
|
|
20
|
+
for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
|
|
21
|
+
var t = targets_1[_i];
|
|
22
|
+
t.style.opacity = '1';
|
|
23
|
+
t.style.transform = 'none';
|
|
24
|
+
}
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
// Prime targets to start state
|
|
28
|
+
for (var _e = 0, targets_2 = targets; _e < targets_2.length; _e++) {
|
|
29
|
+
var t = targets_2[_e];
|
|
30
|
+
t.style.opacity = '0';
|
|
31
|
+
t.style.transform = "translateY(".concat(y, "px)");
|
|
32
|
+
}
|
|
33
|
+
var enterDuration = parseDuration(opts.duration != null
|
|
34
|
+
? "".concat(opts.duration, "ms")
|
|
35
|
+
: getComputedStyle(document.documentElement).getPropertyValue('--motion-enter').trim() || '200ms');
|
|
36
|
+
var glide = parseGlide(getComputedStyle(document.documentElement)
|
|
37
|
+
.getPropertyValue('--motion-glide')
|
|
38
|
+
.trim());
|
|
39
|
+
var stop = inView(node, function () {
|
|
40
|
+
targets.forEach(function (t, i) {
|
|
41
|
+
animateMini(t, { opacity: [0, 1], transform: ["translateY(".concat(y, "px)"), 'translateY(0px)'] }, {
|
|
42
|
+
duration: enterDuration / 1000,
|
|
43
|
+
ease: glide,
|
|
44
|
+
delay: staggerMs != null ? (i * staggerMs) / 1000 : 0
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
if (once)
|
|
48
|
+
stop();
|
|
49
|
+
}, { amount: amount, margin: margin });
|
|
50
|
+
return {
|
|
51
|
+
destroy: function () {
|
|
52
|
+
stop();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function parseDuration(value) {
|
|
57
|
+
if (value.endsWith('ms'))
|
|
58
|
+
return parseFloat(value);
|
|
59
|
+
if (value.endsWith('s'))
|
|
60
|
+
return parseFloat(value) * 1000;
|
|
61
|
+
return 200;
|
|
62
|
+
}
|
|
63
|
+
function parseGlide(css) {
|
|
64
|
+
var m = css.match(/cubic-bezier\(([^)]+)\)/);
|
|
65
|
+
if (m) {
|
|
66
|
+
var _a = m[1].split(',').map(Number), x1 = _a[0], y1 = _a[1], x2 = _a[2], y2 = _a[3];
|
|
67
|
+
return cubicBezier(x1, y1, x2, y2);
|
|
68
|
+
}
|
|
69
|
+
return cubicBezier(0.16, 1, 0.3, 1); // --motion-glide fallback
|
|
70
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type CommandItem = {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
group?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
keywords?: string[];
|
|
7
|
+
shortcut?: string[];
|
|
8
|
+
action: () => void;
|
|
9
|
+
};
|
|
10
|
+
type CommandGroup = {
|
|
11
|
+
label: string;
|
|
12
|
+
items: CommandItem[];
|
|
13
|
+
};
|
|
14
|
+
export declare const commandPalette: {
|
|
15
|
+
readonly open: boolean;
|
|
16
|
+
readonly groups: CommandGroup[];
|
|
17
|
+
readonly recentIds: string[];
|
|
18
|
+
registerCommands(groupLabel: string, items: CommandItem[]): void;
|
|
19
|
+
openPalette(): void;
|
|
20
|
+
closePalette(): void;
|
|
21
|
+
runCommand(item: CommandItem): void;
|
|
22
|
+
getRecentItems(): CommandItem[];
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
var RECENT_KEY = 'jatui:cmd-palette:recent';
|
|
11
|
+
var MAX_RECENT = 8;
|
|
12
|
+
function createCommandPaletteStore() {
|
|
13
|
+
var open = $state(false);
|
|
14
|
+
var groups = $state([]);
|
|
15
|
+
var recentIds = $state([]);
|
|
16
|
+
// Load recent from localStorage on first access
|
|
17
|
+
function loadRecent() {
|
|
18
|
+
if (typeof localStorage === 'undefined')
|
|
19
|
+
return;
|
|
20
|
+
try {
|
|
21
|
+
var raw = localStorage.getItem(RECENT_KEY);
|
|
22
|
+
recentIds = raw ? JSON.parse(raw) : [];
|
|
23
|
+
}
|
|
24
|
+
catch (_a) {
|
|
25
|
+
recentIds = [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function saveRecent(ids) {
|
|
29
|
+
if (typeof localStorage === 'undefined')
|
|
30
|
+
return;
|
|
31
|
+
try {
|
|
32
|
+
localStorage.setItem(RECENT_KEY, JSON.stringify(ids));
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
35
|
+
// ignore storage errors
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function recordRecent(id) {
|
|
39
|
+
var updated = __spreadArray([id], recentIds.filter(function (r) { return r !== id; }), true).slice(0, MAX_RECENT);
|
|
40
|
+
recentIds = updated;
|
|
41
|
+
saveRecent(updated);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
get open() {
|
|
45
|
+
return open;
|
|
46
|
+
},
|
|
47
|
+
get groups() {
|
|
48
|
+
return groups;
|
|
49
|
+
},
|
|
50
|
+
get recentIds() {
|
|
51
|
+
return recentIds;
|
|
52
|
+
},
|
|
53
|
+
registerCommands: function (groupLabel, items) {
|
|
54
|
+
var existing = groups.find(function (g) { return g.label === groupLabel; });
|
|
55
|
+
if (existing) {
|
|
56
|
+
existing.items = items;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
groups = __spreadArray(__spreadArray([], groups, true), [{ label: groupLabel, items: items }], false);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
openPalette: function () {
|
|
63
|
+
loadRecent();
|
|
64
|
+
open = true;
|
|
65
|
+
},
|
|
66
|
+
closePalette: function () {
|
|
67
|
+
open = false;
|
|
68
|
+
},
|
|
69
|
+
runCommand: function (item) {
|
|
70
|
+
recordRecent(item.id);
|
|
71
|
+
open = false;
|
|
72
|
+
item.action();
|
|
73
|
+
},
|
|
74
|
+
getRecentItems: function () {
|
|
75
|
+
var allItems = groups.flatMap(function (g) { return g.items; });
|
|
76
|
+
return recentIds
|
|
77
|
+
.map(function (id) { return allItems.find(function (i) { return i.id === id; }); })
|
|
78
|
+
.filter(function (i) { return !!i; });
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export var commandPalette = createCommandPaletteStore();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type ToastType = 'info' | 'success' | 'warning' | 'error';
|
|
2
|
+
export type ToastOptions = {
|
|
3
|
+
type?: ToastType;
|
|
4
|
+
message: string;
|
|
5
|
+
action?: {
|
|
6
|
+
label: string;
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
};
|
|
9
|
+
durationMs?: number;
|
|
10
|
+
onUndo?: () => void;
|
|
11
|
+
};
|
|
12
|
+
export type Toast = {
|
|
13
|
+
id: number;
|
|
14
|
+
type: ToastType;
|
|
15
|
+
message: string;
|
|
16
|
+
action?: {
|
|
17
|
+
label: string;
|
|
18
|
+
onClick: () => void;
|
|
19
|
+
};
|
|
20
|
+
durationMs: number;
|
|
21
|
+
onUndo?: () => void;
|
|
22
|
+
};
|
|
23
|
+
export type DismissHandle = {
|
|
24
|
+
dismiss: () => void;
|
|
25
|
+
};
|
|
26
|
+
export declare function getToasts(): Toast[];
|
|
27
|
+
export declare function showToast(options: ToastOptions): DismissHandle;
|
|
28
|
+
export declare function dismissToast(id: number): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
var nextId = 0;
|
|
11
|
+
var toasts = $state([]);
|
|
12
|
+
export function getToasts() {
|
|
13
|
+
return toasts;
|
|
14
|
+
}
|
|
15
|
+
export function showToast(options) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
var id = ++nextId;
|
|
18
|
+
var toast = {
|
|
19
|
+
id: id,
|
|
20
|
+
type: (_a = options.type) !== null && _a !== void 0 ? _a : 'info',
|
|
21
|
+
message: options.message,
|
|
22
|
+
action: options.action,
|
|
23
|
+
durationMs: (_b = options.durationMs) !== null && _b !== void 0 ? _b : 5000,
|
|
24
|
+
onUndo: options.onUndo
|
|
25
|
+
};
|
|
26
|
+
toasts = __spreadArray(__spreadArray([], toasts, true), [toast], false);
|
|
27
|
+
return {
|
|
28
|
+
dismiss: function () { return dismissToast(id); }
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function dismissToast(id) {
|
|
32
|
+
toasts = toasts.filter(function (t) { return t.id !== id; });
|
|
33
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jatui motion tokens — the single source for durations and easing curves.
|
|
3
|
+
*
|
|
4
|
+
* Two curves, one rule:
|
|
5
|
+
* --motion-glide the default for everything: entrances, exits, hovers,
|
|
6
|
+
* containers (modals, drawers, panels), color/opacity.
|
|
7
|
+
* --motion-spring single-overshoot (~6%). ONLY for state-confirmation and
|
|
8
|
+
* gesture-release on small elements — toggle settle, chip
|
|
9
|
+
* add/remove, drop settle, toast entrance. Never on hover
|
|
10
|
+
* or other high-frequency interactions, never on
|
|
11
|
+
* containers, never multi-oscillation.
|
|
12
|
+
*
|
|
13
|
+
* Curves adapted from kinetics (https://kinetics.colorion.co, MIT).
|
|
14
|
+
* Policy: shared/craft/animation-discipline.md in the jat repo
|
|
15
|
+
* ("Curve vs spring" + "Surfaces" sections).
|
|
16
|
+
*/
|
|
17
|
+
:root {
|
|
18
|
+
/* Easing */
|
|
19
|
+
--motion-glide: cubic-bezier(0.16, 1, 0.3, 1); /* ease-out-expo family; default */
|
|
20
|
+
--motion-spring: cubic-bezier(0.34, 1.56, 0.64, 1); /* single overshoot; confirmation only */
|
|
21
|
+
--motion-standard: cubic-bezier(0.2, 0, 0, 1); /* M3 standard; symmetric moves */
|
|
22
|
+
|
|
23
|
+
/* Duration */
|
|
24
|
+
--motion-instant: 80ms; /* press/hover micro-feedback (50–100ms band) */
|
|
25
|
+
--motion-fast: 150ms; /* default state-confirmation */
|
|
26
|
+
--motion-enter: 200ms; /* entering UI: modals, sheets, dropdowns, toasts */
|
|
27
|
+
--motion-move: 300ms; /* container morphs, cross-panel moves */
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* Global reduced-motion floor: strip motion, keep end states visible.
|
|
32
|
+
* Components should still pair every animation with a static affordance
|
|
33
|
+
* (color, position, label) so the state change survives without motion.
|
|
34
|
+
* Component-local guards remain good practice — not every consumer loads
|
|
35
|
+
* this file — but this is the backstop.
|
|
36
|
+
*/
|
|
37
|
+
@media (prefers-reduced-motion: reduce) {
|
|
38
|
+
*,
|
|
39
|
+
*::before,
|
|
40
|
+
*::after {
|
|
41
|
+
animation-duration: 0.01ms !important;
|
|
42
|
+
animation-iteration-count: 1 !important;
|
|
43
|
+
transition-duration: 0.01ms !important;
|
|
44
|
+
scroll-behavior: auto !important;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jatui design tokens — radius, spacing, border.
|
|
3
|
+
*
|
|
4
|
+
* Sibling of motion.css: jatui owns the token layer; DaisyUI theme
|
|
5
|
+
* variables FEED INTO it (never the other way around). Components use
|
|
6
|
+
* --jatui-* vars, so swapping or dropping the underlying theme system
|
|
7
|
+
* is a change to this file, not to every component.
|
|
8
|
+
*
|
|
9
|
+
* Scale source: DESIGN.md (jat repo) `rounded:` / `spacing:` blocks.
|
|
10
|
+
* DaisyUI 5 per-theme radius vars are honored when present; the
|
|
11
|
+
* DESIGN.md values are the fallback.
|
|
12
|
+
*/
|
|
13
|
+
:root {
|
|
14
|
+
/* Radius — DESIGN.md rounded scale */
|
|
15
|
+
--jatui-radius-field: var(--radius-field, 0.25rem); /* inputs, buttons */
|
|
16
|
+
--jatui-radius-selector: var(--radius-selector, 0.375rem); /* badges, chips, pills */
|
|
17
|
+
--jatui-radius-box: var(--radius-box, 0.5rem); /* cards, modals, panels */
|
|
18
|
+
|
|
19
|
+
/* Spacing rhythm — DESIGN.md spacing scale */
|
|
20
|
+
--jatui-space-xs: 2px;
|
|
21
|
+
--jatui-space-sm: 4px;
|
|
22
|
+
--jatui-space-md: 6px;
|
|
23
|
+
--jatui-space-base: 8px;
|
|
24
|
+
--jatui-space-lg: 12px;
|
|
25
|
+
--jatui-space-xl: 16px;
|
|
26
|
+
--jatui-space-2xl: 24px;
|
|
27
|
+
--jatui-space-3xl: 32px;
|
|
28
|
+
|
|
29
|
+
/* Border — depth comes from tonal surfaces + 1px borders, not shadows */
|
|
30
|
+
--jatui-border-w: 1px;
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type GlideOrigin = 'center' | 'top' | 'tr' | 'right' | 'br' | 'bottom' | 'bl' | 'left' | 'tl';
|
|
2
|
+
export interface GlideParams {
|
|
3
|
+
/** Direction the element slides in from. Default 'bottom'. */
|
|
4
|
+
from?: GlideOrigin;
|
|
5
|
+
/** Travel distance in px. Default 16. */
|
|
6
|
+
distance?: number;
|
|
7
|
+
/** Scale factor at the start of the enter (e.g. 0.95). Omit = no scale. */
|
|
8
|
+
scale?: number;
|
|
9
|
+
/** Add motion-blur (blur filter) during travel. Default false. */
|
|
10
|
+
blur?: boolean;
|
|
11
|
+
/** Duration in ms. Default 200. */
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** Delay in ms. Default 0. */
|
|
14
|
+
delay?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parameterized directional enter/exit transition.
|
|
18
|
+
*
|
|
19
|
+
* One factory replaces ~54 animista keyframe permutations.
|
|
20
|
+
* Works as both `in:` and `out:` — Svelte mirrors the exit automatically.
|
|
21
|
+
*
|
|
22
|
+
* <div in:glide={{ from: 'bottom' }} out:glide={{ from: 'bottom' }}>…</div>
|
|
23
|
+
*
|
|
24
|
+
* Reduced-motion: opacity fade only (no translate, scale, or blur).
|
|
25
|
+
*/
|
|
26
|
+
export declare function glide(node: HTMLElement, params?: GlideParams): {
|
|
27
|
+
delay: number;
|
|
28
|
+
duration: number;
|
|
29
|
+
easing: (t: number) => number;
|
|
30
|
+
css(t: number): string;
|
|
31
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// direction taxonomy after animista.net (Ana Travas, BSD-2-Clause site license); keyframes re-authored on jatui motion tokens
|
|
2
|
+
/** Map from direction → [dx, dy] unit vector for the entrance travel. */
|
|
3
|
+
var ORIGIN_VECTOR = {
|
|
4
|
+
center: [0, 0],
|
|
5
|
+
top: [0, -1],
|
|
6
|
+
tr: [1, -1],
|
|
7
|
+
right: [1, 0],
|
|
8
|
+
br: [1, 1],
|
|
9
|
+
bottom: [0, 1],
|
|
10
|
+
bl: [-1, 1],
|
|
11
|
+
left: [-1, 0],
|
|
12
|
+
tl: [-1, -1],
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Parameterized directional enter/exit transition.
|
|
16
|
+
*
|
|
17
|
+
* One factory replaces ~54 animista keyframe permutations.
|
|
18
|
+
* Works as both `in:` and `out:` — Svelte mirrors the exit automatically.
|
|
19
|
+
*
|
|
20
|
+
* <div in:glide={{ from: 'bottom' }} out:glide={{ from: 'bottom' }}>…</div>
|
|
21
|
+
*
|
|
22
|
+
* Reduced-motion: opacity fade only (no translate, scale, or blur).
|
|
23
|
+
*/
|
|
24
|
+
export function glide(node, params) {
|
|
25
|
+
if (params === void 0) { params = {}; }
|
|
26
|
+
var _a = params.from, from = _a === void 0 ? 'bottom' : _a, _b = params.distance, distance = _b === void 0 ? 16 : _b, scale = params.scale, _c = params.blur, blur = _c === void 0 ? false : _c, _d = params.duration, duration = _d === void 0 ? 200 : _d, _e = params.delay, delay = _e === void 0 ? 0 : _e;
|
|
27
|
+
var prefersReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
28
|
+
var _f = ORIGIN_VECTOR[from], ux = _f[0], uy = _f[1];
|
|
29
|
+
// Entrance start state — element travels FROM this position TO its natural position
|
|
30
|
+
var tx = prefersReduced ? 0 : ux * distance;
|
|
31
|
+
var ty = prefersReduced ? 0 : uy * distance;
|
|
32
|
+
var s = (!prefersReduced && scale !== undefined) ? scale : 1;
|
|
33
|
+
var blurPx = (!prefersReduced && blur) ? 4 : 0;
|
|
34
|
+
function buildTransform(progress) {
|
|
35
|
+
// progress goes 0 → 1 on enter; Svelte reverses for exit
|
|
36
|
+
var invP = 1 - progress;
|
|
37
|
+
var x = tx * invP;
|
|
38
|
+
var y = ty * invP;
|
|
39
|
+
var sc = 1 - (1 - s) * invP;
|
|
40
|
+
var b = blurPx * invP;
|
|
41
|
+
var t = "translate(".concat(x, "px, ").concat(y, "px)");
|
|
42
|
+
if (s !== 1)
|
|
43
|
+
t += " scale(".concat(sc, ")");
|
|
44
|
+
var filter = b > 0 ? "blur(".concat(b.toFixed(1), "px)") : '';
|
|
45
|
+
return { transform: t, filter: filter };
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
delay: delay,
|
|
49
|
+
duration: duration,
|
|
50
|
+
easing: function (t) { return t; }, // easing applied via CSS var below
|
|
51
|
+
css: function (t) {
|
|
52
|
+
// t: 0 = start, 1 = end (for `in:`; Svelte inverts for `out:`)
|
|
53
|
+
var _a = buildTransform(t), transform = _a.transform, filter = _a.filter;
|
|
54
|
+
// Apply the glide easing via CSS transition so the CSS var is honored
|
|
55
|
+
return "\n\t\t\t\topacity: ".concat(t, ";\n\t\t\t\ttransform: ").concat(transform, ";\n\t\t\t\t").concat(filter ? "filter: ".concat(filter, ";") : '', "\n\t\t\t\ttransition-timing-function: var(--motion-glide, cubic-bezier(0.16, 1, 0.3, 1));\n\t\t\t");
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function isSoundEnabled(): boolean;
|
|
2
|
+
export declare function setSoundEnabled(enabled: boolean): void;
|
|
3
|
+
export declare function registerSound(name: string, dataUri: string): Promise<void>;
|
|
4
|
+
export declare function play(name: string, options?: {
|
|
5
|
+
volume?: number;
|
|
6
|
+
}): void;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var ctx = null;
|
|
38
|
+
var buffers = new Map();
|
|
39
|
+
var STORAGE_KEY = 'jatui-sound-enabled';
|
|
40
|
+
function getContext() {
|
|
41
|
+
if (ctx)
|
|
42
|
+
return ctx;
|
|
43
|
+
try {
|
|
44
|
+
ctx = new AudioContext();
|
|
45
|
+
return ctx;
|
|
46
|
+
}
|
|
47
|
+
catch (_a) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function isSoundEnabled() {
|
|
52
|
+
if (typeof localStorage === 'undefined')
|
|
53
|
+
return false;
|
|
54
|
+
return localStorage.getItem(STORAGE_KEY) === 'true';
|
|
55
|
+
}
|
|
56
|
+
export function setSoundEnabled(enabled) {
|
|
57
|
+
if (typeof localStorage === 'undefined')
|
|
58
|
+
return;
|
|
59
|
+
localStorage.setItem(STORAGE_KEY, String(enabled));
|
|
60
|
+
}
|
|
61
|
+
export function registerSound(name, dataUri) {
|
|
62
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
63
|
+
var audioCtx, base64, binary, bytes, i, buffer, _a;
|
|
64
|
+
return __generator(this, function (_b) {
|
|
65
|
+
switch (_b.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
audioCtx = getContext();
|
|
68
|
+
if (!audioCtx)
|
|
69
|
+
return [2 /*return*/];
|
|
70
|
+
_b.label = 1;
|
|
71
|
+
case 1:
|
|
72
|
+
_b.trys.push([1, 3, , 4]);
|
|
73
|
+
base64 = dataUri.split(',')[1];
|
|
74
|
+
binary = atob(base64);
|
|
75
|
+
bytes = new Uint8Array(binary.length);
|
|
76
|
+
for (i = 0; i < binary.length; i++)
|
|
77
|
+
bytes[i] = binary.charCodeAt(i);
|
|
78
|
+
return [4 /*yield*/, audioCtx.decodeAudioData(bytes.buffer)];
|
|
79
|
+
case 2:
|
|
80
|
+
buffer = _b.sent();
|
|
81
|
+
buffers.set(name, buffer);
|
|
82
|
+
return [3 /*break*/, 4];
|
|
83
|
+
case 3:
|
|
84
|
+
_a = _b.sent();
|
|
85
|
+
return [3 /*break*/, 4];
|
|
86
|
+
case 4: return [2 /*return*/];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export function play(name, options) {
|
|
92
|
+
var _a;
|
|
93
|
+
if (options === void 0) { options = {}; }
|
|
94
|
+
if (!isSoundEnabled())
|
|
95
|
+
return;
|
|
96
|
+
var audioCtx = getContext();
|
|
97
|
+
if (!audioCtx)
|
|
98
|
+
return;
|
|
99
|
+
var buffer = buffers.get(name);
|
|
100
|
+
if (!buffer)
|
|
101
|
+
return;
|
|
102
|
+
// Resume suspended context (browser autoplay policy requires user gesture first)
|
|
103
|
+
if (audioCtx.state === 'suspended') {
|
|
104
|
+
audioCtx.resume().catch(function () { });
|
|
105
|
+
}
|
|
106
|
+
var source = audioCtx.createBufferSource();
|
|
107
|
+
var gain = audioCtx.createGain();
|
|
108
|
+
gain.gain.value = (_a = options.volume) !== null && _a !== void 0 ? _a : 0.15;
|
|
109
|
+
source.buffer = buffer;
|
|
110
|
+
source.connect(gain);
|
|
111
|
+
gain.connect(audioCtx.destination);
|
|
112
|
+
source.start();
|
|
113
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type SplitBy = 'char' | 'word' | 'line';
|
|
2
|
+
export interface SplitTextOptions {
|
|
3
|
+
by: SplitBy;
|
|
4
|
+
}
|
|
5
|
+
export interface SplitTextResult {
|
|
6
|
+
/** Total number of split units (chars, words, or lines). */
|
|
7
|
+
count: number;
|
|
8
|
+
/** Call to restore original DOM content and remove data attributes. */
|
|
9
|
+
cleanup: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Wraps text content of `node` into `<span>` elements and stamps CSS custom
|
|
13
|
+
* properties so pure-CSS animations can stagger by index.
|
|
14
|
+
*
|
|
15
|
+
* For `by: 'char'`: sets `--char-index` (0-based) and `--char-total`.
|
|
16
|
+
* For `by: 'word'`: sets `--word-index` (0-based) and `--word-total`.
|
|
17
|
+
* For `by: 'line'`: sets `--line-index` (0-based) and `--line-total`.
|
|
18
|
+
*
|
|
19
|
+
* Accessibility: stamps `aria-label` with the original text on `node` and
|
|
20
|
+
* marks every injected span as `aria-hidden="true"`.
|
|
21
|
+
*
|
|
22
|
+
* Re-splitting a node that has already been split is safe — previous spans
|
|
23
|
+
* are flattened back to text before the new split.
|
|
24
|
+
*/
|
|
25
|
+
export declare function splitText(node: HTMLElement, options: SplitTextOptions): SplitTextResult;
|