@joewinke/jatui 0.1.31 → 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/collapse.js +29 -15
- package/dist/actions/floating.d.ts +53 -0
- package/dist/actions/floating.js +158 -0
- package/dist/actions/listNav.js +137 -108
- package/dist/actions/railNav.js +89 -72
- 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/markup.js +62 -59
- 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/session-nav/transcriptModel.js +66 -49
- 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/data/emojis.js +4 -4
- package/dist/dnd/autoScroll.js +12 -10
- package/dist/dnd/createDndBoard.svelte.js +110 -76
- package/dist/dnd/createDndBoard.test.js +161 -85
- package/dist/dnd/draggable.js +23 -15
- package/dist/dnd/dropTarget.js +29 -15
- package/dist/dnd/index.d.ts +0 -1
- package/dist/dnd/index.js +0 -1
- package/dist/dnd/types.d.ts +0 -9
- package/dist/dnd/types.js +14 -2
- package/dist/index.d.ts +60 -6
- package/dist/index.js +73 -6
- 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/confirmDialog.svelte.js +5 -5
- package/dist/stores/inputDialog.svelte.js +5 -5
- 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/types/booking.js +4 -4
- package/dist/types/comments.js +2 -2
- package/dist/types/messaging.js +3 -3
- package/dist/types/pipeline.js +2 -2
- package/dist/utils/currency.js +4 -2
- package/dist/utils/daisyuiColors.js +27 -25
- package/dist/utils/dateFormatters.d.ts +20 -0
- package/dist/utils/dateFormatters.js +65 -44
- package/dist/utils/googleMapsLoader.js +100 -46
- package/dist/utils/mentionParser.js +30 -30
- package/dist/utils/phone.js +27 -21
- package/dist/utils/phoneFormat.js +9 -9
- 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/taskUtils.js +1 -1
- 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 +56 -4
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* routing via the `urlGenerator` parameter or by setting a default.
|
|
9
9
|
*/
|
|
10
10
|
// Regex to match mention pattern: [@Display Name](type:id)
|
|
11
|
-
|
|
11
|
+
var MENTION_REGEX = /\[@([^\]]+)\]\(([^:]+):([^)]+)\)/g;
|
|
12
12
|
// Default URL generator (apps can override)
|
|
13
|
-
|
|
13
|
+
var defaultUrlGenerator = function (type, id) { return "#".concat(type, "/").concat(id); };
|
|
14
14
|
/**
|
|
15
15
|
* Set the default URL generator for mentions.
|
|
16
16
|
* Call this once at app startup to configure mention link routing.
|
|
@@ -22,20 +22,20 @@ export function setMentionUrlGenerator(generator) {
|
|
|
22
22
|
* Parse message content and extract all mentions
|
|
23
23
|
*/
|
|
24
24
|
export function parseMentions(content, urlGenerator) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
var mentions = [];
|
|
26
|
+
var gen = urlGenerator !== null && urlGenerator !== void 0 ? urlGenerator : defaultUrlGenerator;
|
|
27
|
+
var match;
|
|
28
28
|
MENTION_REGEX.lastIndex = 0;
|
|
29
29
|
while ((match = MENTION_REGEX.exec(content)) !== null) {
|
|
30
|
-
|
|
30
|
+
var fullMatch = match[0], displayName = match[1], type = match[2], id = match[3];
|
|
31
31
|
mentions.push({
|
|
32
|
-
type,
|
|
33
|
-
id,
|
|
34
|
-
displayName,
|
|
32
|
+
type: type,
|
|
33
|
+
id: id,
|
|
34
|
+
displayName: displayName,
|
|
35
35
|
url: gen(type, id),
|
|
36
36
|
startIndex: match.index,
|
|
37
37
|
endIndex: match.index + fullMatch.length,
|
|
38
|
-
fullMatch
|
|
38
|
+
fullMatch: fullMatch
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
return mentions;
|
|
@@ -44,15 +44,15 @@ export function parseMentions(content, urlGenerator) {
|
|
|
44
44
|
* Convert message content with mentions to HTML
|
|
45
45
|
*/
|
|
46
46
|
export function renderMentionsAsHTML(content, urlGenerator) {
|
|
47
|
-
|
|
47
|
+
var mentions = parseMentions(content, urlGenerator);
|
|
48
48
|
if (mentions.length === 0) {
|
|
49
49
|
return escapeHTML(content);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
mentions.forEach((mention)
|
|
51
|
+
var result = '';
|
|
52
|
+
var lastIndex = 0;
|
|
53
|
+
mentions.forEach(function (mention) {
|
|
54
54
|
result += escapeHTML(content.substring(lastIndex, mention.startIndex));
|
|
55
|
-
result +=
|
|
55
|
+
result += "<a href=\"".concat(mention.url, "\" class=\"mention-link mention-").concat(mention.type, "\" data-mention-type=\"").concat(mention.type, "\" data-mention-id=\"").concat(mention.id, "\">@").concat(escapeHTML(mention.displayName), "</a>");
|
|
56
56
|
lastIndex = mention.endIndex;
|
|
57
57
|
});
|
|
58
58
|
result += escapeHTML(content.substring(lastIndex));
|
|
@@ -62,7 +62,7 @@ export function renderMentionsAsHTML(content, urlGenerator) {
|
|
|
62
62
|
* Create a mention string for insertion into message input
|
|
63
63
|
*/
|
|
64
64
|
export function createMentionString(type, id, displayName) {
|
|
65
|
-
return
|
|
65
|
+
return "[@".concat(displayName, "](").concat(type, ":").concat(id, ")");
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Extract plain text from message content (remove mention markup)
|
|
@@ -75,18 +75,18 @@ export function extractPlainText(content) {
|
|
|
75
75
|
* Check if cursor is inside a mention
|
|
76
76
|
*/
|
|
77
77
|
export function findMentionAtCursor(content, cursorPosition) {
|
|
78
|
-
|
|
79
|
-
return (mentions.find((mention)
|
|
78
|
+
var mentions = parseMentions(content);
|
|
79
|
+
return (mentions.find(function (mention) { return cursorPosition >= mention.startIndex && cursorPosition <= mention.endIndex; }) || null);
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Find @ symbol and following text that could be a mention being typed.
|
|
83
83
|
* Supported symbols: @ $ # ! ~ / +
|
|
84
84
|
*/
|
|
85
85
|
export function findPartialMention(content, cursorPosition) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
for (
|
|
89
|
-
|
|
86
|
+
var mentionSymbols = ['@', '$', '#', '!', '~', '/', '+'];
|
|
87
|
+
var symbolIndex = -1;
|
|
88
|
+
for (var i = cursorPosition - 1; i >= 0; i--) {
|
|
89
|
+
var char = content[i];
|
|
90
90
|
if (mentionSymbols.includes(char)) {
|
|
91
91
|
symbolIndex = i;
|
|
92
92
|
break;
|
|
@@ -97,21 +97,21 @@ export function findPartialMention(content, cursorPosition) {
|
|
|
97
97
|
}
|
|
98
98
|
if (symbolIndex === -1)
|
|
99
99
|
return null;
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
var query = content.substring(symbolIndex + 1, cursorPosition).trim();
|
|
101
|
+
var existingMention = findMentionAtCursor(content, symbolIndex);
|
|
102
102
|
if (existingMention)
|
|
103
103
|
return null;
|
|
104
|
-
return { start: symbolIndex, query };
|
|
104
|
+
return { start: symbolIndex, query: query };
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
107
|
* Replace partial mention with complete mention string
|
|
108
108
|
*/
|
|
109
109
|
export function replaceMentionInContent(content, startIndex, endIndex, mentionString) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return { newContent, newCursorPosition };
|
|
110
|
+
var before = content.substring(0, startIndex);
|
|
111
|
+
var after = content.substring(endIndex);
|
|
112
|
+
var newContent = before + mentionString + after;
|
|
113
|
+
var newCursorPosition = startIndex + mentionString.length;
|
|
114
|
+
return { newContent: newContent, newCursorPosition: newCursorPosition };
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Simple HTML escape function
|
package/dist/utils/phone.js
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
import { parsePhoneNumberFromString, getCountries, getCountryCallingCode, } from "libphonenumber-js";
|
|
2
|
-
export
|
|
3
|
-
export function toE164(raw, defaultCountry
|
|
2
|
+
export var DEFAULT_COUNTRY = "US";
|
|
3
|
+
export function toE164(raw, defaultCountry) {
|
|
4
|
+
if (defaultCountry === void 0) { defaultCountry = DEFAULT_COUNTRY; }
|
|
4
5
|
if (!raw)
|
|
5
6
|
return null;
|
|
6
|
-
|
|
7
|
+
var trimmed = raw.trim();
|
|
7
8
|
if (!trimmed)
|
|
8
9
|
return null;
|
|
9
|
-
|
|
10
|
-
if (parsed
|
|
10
|
+
var parsed = parsePhoneNumberFromString(trimmed, defaultCountry);
|
|
11
|
+
if (parsed === null || parsed === void 0 ? void 0 : parsed.isValid())
|
|
11
12
|
return parsed.number;
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
15
|
export function formatPhoneForDisplay(e164) {
|
|
15
16
|
if (!e164)
|
|
16
17
|
return "";
|
|
17
|
-
|
|
18
|
+
var parsed = parsePhoneNumberFromString(e164);
|
|
18
19
|
if (!parsed)
|
|
19
20
|
return e164;
|
|
20
21
|
return parsed.country === DEFAULT_COUNTRY ? parsed.formatNational() : parsed.formatInternational();
|
|
21
22
|
}
|
|
22
|
-
export function isValidPhone(raw, defaultCountry
|
|
23
|
+
export function isValidPhone(raw, defaultCountry) {
|
|
24
|
+
var _a;
|
|
25
|
+
if (defaultCountry === void 0) { defaultCountry = DEFAULT_COUNTRY; }
|
|
23
26
|
if (!raw)
|
|
24
27
|
return false;
|
|
25
|
-
|
|
26
|
-
return parsed
|
|
28
|
+
var parsed = parsePhoneNumberFromString(raw.trim(), defaultCountry);
|
|
29
|
+
return (_a = parsed === null || parsed === void 0 ? void 0 : parsed.isValid()) !== null && _a !== void 0 ? _a : false;
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
var COUNTRY_NAMES = {
|
|
29
32
|
US: "United States", CA: "Canada", GB: "United Kingdom", AU: "Australia", NZ: "New Zealand",
|
|
30
33
|
IE: "Ireland", DE: "Germany", FR: "France", ES: "Spain", IT: "Italy", NL: "Netherlands",
|
|
31
34
|
BE: "Belgium", CH: "Switzerland", AT: "Austria", SE: "Sweden", NO: "Norway", DK: "Denmark",
|
|
@@ -40,22 +43,25 @@ function flagEmoji(code) {
|
|
|
40
43
|
return code
|
|
41
44
|
.toUpperCase()
|
|
42
45
|
.split("")
|
|
43
|
-
.map((c)
|
|
46
|
+
.map(function (c) { return String.fromCodePoint(127397 + c.charCodeAt(0)); })
|
|
44
47
|
.join("");
|
|
45
48
|
}
|
|
46
|
-
|
|
49
|
+
var countriesCache = null;
|
|
47
50
|
export function listCountries() {
|
|
48
51
|
if (countriesCache)
|
|
49
52
|
return countriesCache;
|
|
50
|
-
|
|
51
|
-
.map((code)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
var all = getCountries()
|
|
54
|
+
.map(function (code) {
|
|
55
|
+
var _a;
|
|
56
|
+
return ({
|
|
57
|
+
code: code,
|
|
58
|
+
name: (_a = COUNTRY_NAMES[code]) !== null && _a !== void 0 ? _a : code,
|
|
59
|
+
dialCode: "+".concat(getCountryCallingCode(code)),
|
|
60
|
+
flag: flagEmoji(code),
|
|
61
|
+
});
|
|
62
|
+
})
|
|
63
|
+
.sort(function (a, b) { return a.name.localeCompare(b.name); });
|
|
58
64
|
countriesCache = all;
|
|
59
65
|
return all;
|
|
60
66
|
}
|
|
61
|
-
export
|
|
67
|
+
export var PRIORITY_COUNTRIES = ["US", "CA", "GB", "AU", "MX"];
|
|
@@ -14,19 +14,19 @@ export function stripPhoneNumber(value) {
|
|
|
14
14
|
* Formats a phone number to (xxx) xxx-xxxx format
|
|
15
15
|
*/
|
|
16
16
|
export function formatPhoneNumber(value) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
var digits = stripPhoneNumber(value);
|
|
18
|
+
var limitedDigits = digits.slice(0, 10);
|
|
19
19
|
if (limitedDigits.length === 0) {
|
|
20
20
|
return '';
|
|
21
21
|
}
|
|
22
22
|
else if (limitedDigits.length <= 3) {
|
|
23
|
-
return
|
|
23
|
+
return "(".concat(limitedDigits);
|
|
24
24
|
}
|
|
25
25
|
else if (limitedDigits.length <= 6) {
|
|
26
|
-
return
|
|
26
|
+
return "(".concat(limitedDigits.slice(0, 3), ") ").concat(limitedDigits.slice(3));
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
return
|
|
29
|
+
return "(".concat(limitedDigits.slice(0, 3), ") ").concat(limitedDigits.slice(3, 6), "-").concat(limitedDigits.slice(6));
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
@@ -45,11 +45,11 @@ export function isValidPhoneNumber(value) {
|
|
|
45
45
|
* Handles input formatting with cursor position preservation
|
|
46
46
|
*/
|
|
47
47
|
export function updatePhoneInput(input, newValue, oldValue) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
var cursorPosition = input.selectionStart || 0;
|
|
49
|
+
var oldLength = oldValue.length;
|
|
50
|
+
var newLength = newValue.length;
|
|
51
51
|
input.value = newValue;
|
|
52
|
-
|
|
52
|
+
var newCursorPosition = cursorPosition;
|
|
53
53
|
if (newLength > oldLength) {
|
|
54
54
|
newCursorPosition = cursorPosition + (newLength - oldLength);
|
|
55
55
|
}
|
|
@@ -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;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Pattern after Splitting.js (MIT) — https://github.com/shshaw/Splitting
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
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 function splitText(node, options) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
var by = options.by;
|
|
28
|
+
// Capture original text and restore any previous split.
|
|
29
|
+
var originalText = (_b = (_a = node.getAttribute('data-split-original')) !== null && _a !== void 0 ? _a : node.textContent) !== null && _b !== void 0 ? _b : '';
|
|
30
|
+
restoreNode(node, originalText);
|
|
31
|
+
// Set accessibility label so the unsplit text is announced.
|
|
32
|
+
node.setAttribute('aria-label', originalText);
|
|
33
|
+
node.setAttribute('data-split-original', originalText);
|
|
34
|
+
node.setAttribute('data-split-by', by);
|
|
35
|
+
var count = 0;
|
|
36
|
+
if (by === 'char') {
|
|
37
|
+
var chars = __spreadArray([], originalText, true); // Unicode-aware
|
|
38
|
+
count = chars.length;
|
|
39
|
+
node.innerHTML = '';
|
|
40
|
+
for (var i = 0; i < chars.length; i++) {
|
|
41
|
+
node.appendChild(makeSpan(chars[i], '--char-index', i, '--char-total', count));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (by === 'word') {
|
|
45
|
+
// Split preserving whitespace tokens so spaces render correctly.
|
|
46
|
+
var tokens = originalText.split(/(\s+)/);
|
|
47
|
+
var words = tokens.filter(function (t) { return !/^\s+$/.test(t); });
|
|
48
|
+
count = words.length;
|
|
49
|
+
node.innerHTML = '';
|
|
50
|
+
var wordIdx = 0;
|
|
51
|
+
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
52
|
+
var token = tokens_1[_i];
|
|
53
|
+
if (/^\s+$/.test(token)) {
|
|
54
|
+
var space = document.createElement('span');
|
|
55
|
+
space.setAttribute('aria-hidden', 'true');
|
|
56
|
+
space.style.whiteSpace = 'pre';
|
|
57
|
+
space.textContent = token;
|
|
58
|
+
node.appendChild(space);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
node.appendChild(makeSpan(token, '--word-index', wordIdx++, '--word-total', count));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// 'line' — split by newline characters in the original text.
|
|
67
|
+
var lines = originalText.split('\n');
|
|
68
|
+
count = lines.length;
|
|
69
|
+
node.innerHTML = '';
|
|
70
|
+
for (var i = 0; i < lines.length; i++) {
|
|
71
|
+
if (i > 0)
|
|
72
|
+
node.appendChild(document.createTextNode('\n'));
|
|
73
|
+
node.appendChild(makeSpan(lines[i], '--line-index', i, '--line-total', count));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
count: count,
|
|
78
|
+
cleanup: function () { return restoreNode(node, originalText); }
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function makeSpan(text, indexVar, index, totalVar, total) {
|
|
82
|
+
var span = document.createElement('span');
|
|
83
|
+
span.setAttribute('aria-hidden', 'true');
|
|
84
|
+
span.style.setProperty(indexVar, String(index));
|
|
85
|
+
span.style.setProperty(totalVar, String(total));
|
|
86
|
+
span.textContent = text;
|
|
87
|
+
return span;
|
|
88
|
+
}
|
|
89
|
+
function restoreNode(node, originalText) {
|
|
90
|
+
node.textContent = originalText;
|
|
91
|
+
node.removeAttribute('aria-label');
|
|
92
|
+
node.removeAttribute('data-split-original');
|
|
93
|
+
node.removeAttribute('data-split-by');
|
|
94
|
+
}
|
package/dist/utils/taskUtils.js
CHANGED
|
@@ -67,5 +67,5 @@ export function typeIcon(type) {
|
|
|
67
67
|
* "in_progress" → "In Progress"
|
|
68
68
|
*/
|
|
69
69
|
export function statusLabel(status) {
|
|
70
|
-
return status.replace(/_/g, ' ').replace(/\b\w/g, (c)
|
|
70
|
+
return status.replace(/_/g, ' ').replace(/\b\w/g, function (c) { return c.toUpperCase(); });
|
|
71
71
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* themeWipe — circular View Transition reveal from a click origin.
|
|
3
|
+
*
|
|
4
|
+
* Wraps document.startViewTransition, computes a covering radius from the
|
|
5
|
+
* click point, and animates ::view-transition-new(root) with a clip-path
|
|
6
|
+
* circle via WAAPI (~500ms, var(--motion-glide)).
|
|
7
|
+
*
|
|
8
|
+
* Falls back gracefully: if startViewTransition is unsupported or
|
|
9
|
+
* prefers-reduced-motion is set, applyTheme() runs synchronously with no
|
|
10
|
+
* animation.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @param event - The click (or pointer) event that triggered the theme toggle.
|
|
14
|
+
* Used to anchor the reveal circle. Pass null to default to
|
|
15
|
+
* screen center.
|
|
16
|
+
* @param applyTheme - Callback that performs the actual theme mutation
|
|
17
|
+
* (e.g. set data-theme, update localStorage). Called
|
|
18
|
+
* inside the startViewTransition callback so the snapshot
|
|
19
|
+
* captures the old state and the new DOM is recorded after.
|
|
20
|
+
*/
|
|
21
|
+
export declare function themeWipe(event: MouseEvent | PointerEvent | null, applyTheme: () => void): Promise<void>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* themeWipe — circular View Transition reveal from a click origin.
|
|
3
|
+
*
|
|
4
|
+
* Wraps document.startViewTransition, computes a covering radius from the
|
|
5
|
+
* click point, and animates ::view-transition-new(root) with a clip-path
|
|
6
|
+
* circle via WAAPI (~500ms, var(--motion-glide)).
|
|
7
|
+
*
|
|
8
|
+
* Falls back gracefully: if startViewTransition is unsupported or
|
|
9
|
+
* prefers-reduced-motion is set, applyTheme() runs synchronously with no
|
|
10
|
+
* animation.
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
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);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var DURATION = 500;
|
|
49
|
+
var EASING = 'cubic-bezier(0.16, 1, 0.3, 1)'; // --motion-glide fallback
|
|
50
|
+
/**
|
|
51
|
+
* @param event - The click (or pointer) event that triggered the theme toggle.
|
|
52
|
+
* Used to anchor the reveal circle. Pass null to default to
|
|
53
|
+
* screen center.
|
|
54
|
+
* @param applyTheme - Callback that performs the actual theme mutation
|
|
55
|
+
* (e.g. set data-theme, update localStorage). Called
|
|
56
|
+
* inside the startViewTransition callback so the snapshot
|
|
57
|
+
* captures the old state and the new DOM is recorded after.
|
|
58
|
+
*/
|
|
59
|
+
export function themeWipe(event, applyTheme) {
|
|
60
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
61
|
+
var prefersReduced, x, y, endRadius, transition, resolvedEasing;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
switch (_a.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
prefersReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
66
|
+
if (prefersReduced || !document.startViewTransition) {
|
|
67
|
+
applyTheme();
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
x = event ? event.clientX : window.innerWidth / 2;
|
|
71
|
+
y = event ? event.clientY : window.innerHeight / 2;
|
|
72
|
+
endRadius = Math.hypot(Math.max(x, window.innerWidth - x), Math.max(y, window.innerHeight - y));
|
|
73
|
+
transition = document.startViewTransition(applyTheme);
|
|
74
|
+
// Wait until both snapshots are captured before animating
|
|
75
|
+
return [4 /*yield*/, transition.ready];
|
|
76
|
+
case 1:
|
|
77
|
+
// Wait until both snapshots are captured before animating
|
|
78
|
+
_a.sent();
|
|
79
|
+
resolvedEasing = getComputedStyle(document.documentElement)
|
|
80
|
+
.getPropertyValue('--motion-glide')
|
|
81
|
+
.trim() || EASING;
|
|
82
|
+
document.documentElement.animate([
|
|
83
|
+
{ clipPath: "circle(0px at ".concat(x, "px ").concat(y, "px)") },
|
|
84
|
+
{ clipPath: "circle(".concat(endRadius, "px at ").concat(x, "px ").concat(y, "px)") }
|
|
85
|
+
], {
|
|
86
|
+
duration: DURATION,
|
|
87
|
+
easing: resolvedEasing,
|
|
88
|
+
pseudoElement: '::view-transition-new(root)'
|
|
89
|
+
});
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* viewTransition — SvelteKit onNavigate helper.
|
|
3
|
+
*
|
|
4
|
+
* Drop this into +layout.svelte to wrap each client-side navigation with
|
|
5
|
+
* document.startViewTransition, giving the browser a chance to animate
|
|
6
|
+
* between pages using the View Transitions API.
|
|
7
|
+
*
|
|
8
|
+
* Usage in +layout.svelte:
|
|
9
|
+
* <script>
|
|
10
|
+
* import { onNavigate } from '$app/navigation';
|
|
11
|
+
* import { viewTransition } from '../../../dist';
|
|
12
|
+
* viewTransition(onNavigate);
|
|
13
|
+
* </script>
|
|
14
|
+
*
|
|
15
|
+
* Falls back silently: if startViewTransition is unsupported, the navigation
|
|
16
|
+
* proceeds normally. prefers-reduced-motion is honoured automatically by the
|
|
17
|
+
* browser's View Transitions implementation; no extra guard is needed here.
|
|
18
|
+
*/
|
|
19
|
+
type OnNavigateCallback = (callback: (navigation: {
|
|
20
|
+
complete: Promise<void>;
|
|
21
|
+
}) => void | (() => void) | Promise<void | (() => void)>) => void;
|
|
22
|
+
export declare function viewTransition(onNavigate: OnNavigateCallback): void;
|
|
23
|
+
export {};
|