@juspay/svelte-ui-components 2.126.0 → 2.128.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/dist/AttachmentChipRow/AttachmentChipRow.svelte +354 -0
- package/dist/AttachmentChipRow/AttachmentChipRow.svelte.d.ts +4 -0
- package/dist/AttachmentChipRow/properties.d.ts +47 -0
- package/dist/AttachmentChipRow/properties.js +1 -0
- package/dist/ChatBubble/ChatBubble.svelte.d.ts +1 -1
- package/dist/ChatComposer/ChatComposer.svelte +96 -10
- package/dist/ChatComposer/properties.d.ts +76 -0
- package/dist/ChatSuggestions/ChatSuggestions.svelte +118 -11
- package/dist/ChatSuggestions/properties.d.ts +42 -0
- package/dist/HITL/HITL.svelte +576 -0
- package/dist/HITL/HITL.svelte.d.ts +4 -0
- package/dist/HITL/properties.d.ts +71 -0
- package/dist/HITL/properties.js +1 -0
- package/dist/HITL/timers.d.ts +6 -0
- package/dist/HITL/timers.js +7 -0
- package/dist/Pill/Pill.svelte +6 -0
- package/dist/SpeechToText/controller.svelte.d.ts +51 -0
- package/dist/SpeechToText/controller.svelte.js +314 -0
- package/dist/SpeechToText/types.d.ts +75 -0
- package/dist/SpeechToText/types.js +1 -0
- package/dist/ThinkingIndicator/ThinkingIndicator.svelte +217 -0
- package/dist/ThinkingIndicator/ThinkingIndicator.svelte.d.ts +4 -0
- package/dist/ThinkingIndicator/properties.d.ts +30 -0
- package/dist/ThinkingIndicator/properties.js +1 -0
- package/dist/Tooltip/tooltip-action.js +5 -0
- package/dist/TypewriterText/TypewriterText.svelte +110 -0
- package/dist/TypewriterText/TypewriterText.svelte.d.ts +4 -0
- package/dist/TypewriterText/properties.d.ts +21 -0
- package/dist/TypewriterText/properties.js +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -174,6 +174,11 @@ export const tooltip = (node, options) => {
|
|
|
174
174
|
if (bubbleEl !== null || delayTimer !== null) {
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
|
+
// An empty text renders a degenerate stub bubble (arrow + sliver) that reads as a
|
|
178
|
+
// clipped artifact — consumers legitimately pass '' to mean "no tooltip here".
|
|
179
|
+
if (currentOptions.text.trim().length === 0) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
177
182
|
const doShow = () => {
|
|
178
183
|
// Re-check after the delay: hide() may have been called while the timer was pending.
|
|
179
184
|
if (bubbleEl !== null) {
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy, untrack } from 'svelte';
|
|
3
|
+
import type { TypewriterTextProperties } from './properties';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
text,
|
|
7
|
+
speed = 15,
|
|
8
|
+
isStreaming = false,
|
|
9
|
+
renderText,
|
|
10
|
+
testId,
|
|
11
|
+
classes
|
|
12
|
+
}: TypewriterTextProperties = $props();
|
|
13
|
+
|
|
14
|
+
let displayedText = $state('');
|
|
15
|
+
let currentIndex = $state(0);
|
|
16
|
+
let timeoutId = $state<ReturnType<typeof setTimeout> | null>(null);
|
|
17
|
+
|
|
18
|
+
// Where typing left off, so newly streamed-in text continues rather than restarts.
|
|
19
|
+
let previousTextLength = $state(0);
|
|
20
|
+
|
|
21
|
+
const typeNextCharacter = (): void => {
|
|
22
|
+
if (currentIndex < text.length) {
|
|
23
|
+
displayedText = text.substring(0, currentIndex + 1);
|
|
24
|
+
currentIndex++;
|
|
25
|
+
timeoutId = setTimeout(typeNextCharacter, speed);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// A reactive timer cannot be a $derived — same escape the chart components use.
|
|
30
|
+
// Internal typing state is read untracked so the effect re-runs only when the
|
|
31
|
+
// `text` prop itself changes, never on our own per-character writes.
|
|
32
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
33
|
+
$effect(() => {
|
|
34
|
+
const nextText = text;
|
|
35
|
+
untrack(() => {
|
|
36
|
+
// Streamed text CONTINUES what is already displayed. Anything else — a
|
|
37
|
+
// shorter string, or one that no longer starts with what was typed — is a
|
|
38
|
+
// replacement: stop the timer and retype from the start, instead of
|
|
39
|
+
// leaving stale characters on screen.
|
|
40
|
+
const isContinuation =
|
|
41
|
+
nextText.length >= previousTextLength && nextText.startsWith(displayedText);
|
|
42
|
+
if (!isContinuation) {
|
|
43
|
+
if (timeoutId !== null) {
|
|
44
|
+
clearTimeout(timeoutId);
|
|
45
|
+
timeoutId = null;
|
|
46
|
+
}
|
|
47
|
+
displayedText = '';
|
|
48
|
+
currentIndex = 0;
|
|
49
|
+
previousTextLength = 0;
|
|
50
|
+
}
|
|
51
|
+
if (nextText.length > 0 && nextText.length > previousTextLength) {
|
|
52
|
+
if (currentIndex >= previousTextLength) {
|
|
53
|
+
if (timeoutId !== null) {
|
|
54
|
+
clearTimeout(timeoutId);
|
|
55
|
+
}
|
|
56
|
+
typeNextCharacter();
|
|
57
|
+
}
|
|
58
|
+
previousTextLength = nextText.length;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
64
|
+
$effect(() => {
|
|
65
|
+
if (!isStreaming && text.length > 0) {
|
|
66
|
+
if (timeoutId !== null) {
|
|
67
|
+
clearTimeout(timeoutId);
|
|
68
|
+
}
|
|
69
|
+
displayedText = text;
|
|
70
|
+
currentIndex = text.length;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
onMount(() => {
|
|
75
|
+
if (text.length > 0) {
|
|
76
|
+
previousTextLength = text.length;
|
|
77
|
+
typeNextCharacter();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
onDestroy(() => {
|
|
82
|
+
if (timeoutId !== null) {
|
|
83
|
+
clearTimeout(timeoutId);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<div
|
|
89
|
+
class="typewriter-text {classes ?? ''}"
|
|
90
|
+
class:plain={typeof renderText !== 'function'}
|
|
91
|
+
data-pw={typeof testId === 'string' ? testId : null}
|
|
92
|
+
testID={typeof testId === 'string' ? testId : null}
|
|
93
|
+
>
|
|
94
|
+
{#if typeof renderText === 'function'}
|
|
95
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
96
|
+
{@html renderText(displayedText)}
|
|
97
|
+
{:else}
|
|
98
|
+
{displayedText}
|
|
99
|
+
{/if}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<style>
|
|
103
|
+
.typewriter-text {
|
|
104
|
+
max-width: var(--typewriter-text-max-width, 100%);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.plain {
|
|
108
|
+
white-space: var(--typewriter-text-white-space, pre-wrap);
|
|
109
|
+
}
|
|
110
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type TypewriterTextProperties = OptionalTypewriterTextProperties & MandatoryTypewriterTextProperties;
|
|
2
|
+
export type MandatoryTypewriterTextProperties = {
|
|
3
|
+
text: string;
|
|
4
|
+
};
|
|
5
|
+
export type OptionalTypewriterTextProperties = {
|
|
6
|
+
/** Milliseconds between characters. */
|
|
7
|
+
speed?: number;
|
|
8
|
+
/**
|
|
9
|
+
* While `true`, text revealed so far stays and new text keeps typing as `text` grows.
|
|
10
|
+
* The moment it turns `false`, all remaining text is shown at once.
|
|
11
|
+
*/
|
|
12
|
+
isStreaming?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Renders the revealed text as HTML — pass a markdown renderer to type rich text.
|
|
15
|
+
* The component trusts the returned string, so sanitise inside the renderer if the
|
|
16
|
+
* text can contain untrusted input. When omitted, the text renders as plain text.
|
|
17
|
+
*/
|
|
18
|
+
renderText?: (text: string) => string;
|
|
19
|
+
testId?: string;
|
|
20
|
+
classes?: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export { default as Tabs } from './Tabs/Tabs.svelte';
|
|
|
34
34
|
export { default as Choicebox } from './Choicebox/Choicebox.svelte';
|
|
35
35
|
export { default as Slider } from './Slider/Slider.svelte';
|
|
36
36
|
export { default as Tooltip } from './Tooltip/Tooltip.svelte';
|
|
37
|
+
export { default as TypewriterText } from './TypewriterText/TypewriterText.svelte';
|
|
37
38
|
export { tooltip } from './Tooltip/tooltip-action';
|
|
38
39
|
export { default as Shimmer } from './Shimmer/Shimmer.svelte';
|
|
39
40
|
export { default as Progress } from './Progress/Progress.svelte';
|
|
@@ -52,6 +53,7 @@ export { default as ContextMenu } from './ContextMenu/ContextMenu.svelte';
|
|
|
52
53
|
export { default as Calendar } from './Calendar/Calendar.svelte';
|
|
53
54
|
export { default as RelativeTime } from './RelativeTime/RelativeTime.svelte';
|
|
54
55
|
export { default as ThemeSwitcher } from './ThemeSwitcher/ThemeSwitcher.svelte';
|
|
56
|
+
export { default as ThinkingIndicator } from './ThinkingIndicator/ThinkingIndicator.svelte';
|
|
55
57
|
export { default as Book } from './Book/Book.svelte';
|
|
56
58
|
export { default as Browser } from './Browser/Browser.svelte';
|
|
57
59
|
export { default as Phone } from './Phone/Phone.svelte';
|
|
@@ -66,6 +68,7 @@ export { default as DateRangePicker } from './DateRangePicker/DateRangePicker.sv
|
|
|
66
68
|
export { default as Breadcrumb } from './Breadcrumb/Breadcrumb.svelte';
|
|
67
69
|
export { default as LineChart } from './LineChart/LineChart.svelte';
|
|
68
70
|
export { default as AreaChart } from './AreaChart/AreaChart.svelte';
|
|
71
|
+
export { default as AttachmentChipRow } from './AttachmentChipRow/AttachmentChipRow.svelte';
|
|
69
72
|
export { default as BarChart } from './BarChart/BarChart.svelte';
|
|
70
73
|
export { default as PieChart } from './PieChart/PieChart.svelte';
|
|
71
74
|
export { default as SankeyChart } from './SankeyChart/SankeyChart.svelte';
|
|
@@ -85,9 +88,12 @@ export { default as ChatComposer } from './ChatComposer/ChatComposer.svelte';
|
|
|
85
88
|
export { default as ChatSuggestions } from './ChatSuggestions/ChatSuggestions.svelte';
|
|
86
89
|
export { default as ChatToolStatus } from './ChatToolStatus/ChatToolStatus.svelte';
|
|
87
90
|
export { default as ChatBubble } from './ChatBubble/ChatBubble.svelte';
|
|
91
|
+
export { default as HITL } from './HITL/HITL.svelte';
|
|
92
|
+
export { pauseAllConfirmationTimers } from './HITL/timers';
|
|
88
93
|
export { default as Resizable } from './Resizable/Resizable.svelte';
|
|
89
94
|
export { ChatController } from './Chat/controller.svelte';
|
|
90
95
|
export { partyOf } from './Chat/roles';
|
|
96
|
+
export { SpeechToTextController } from './SpeechToText/controller.svelte';
|
|
91
97
|
export type * from './Button/properties';
|
|
92
98
|
export type * from './Modal/properties';
|
|
93
99
|
export type * from './Input/properties';
|
|
@@ -118,6 +124,7 @@ export type * from './Tabs/properties';
|
|
|
118
124
|
export type * from './Choicebox/properties';
|
|
119
125
|
export type * from './Slider/properties';
|
|
120
126
|
export type * from './Tooltip/properties';
|
|
127
|
+
export type * from './TypewriterText/properties';
|
|
121
128
|
export type * from './Shimmer/properties';
|
|
122
129
|
export type * from './Progress/properties';
|
|
123
130
|
export type * from './Pill/properties';
|
|
@@ -135,6 +142,7 @@ export type * from './ContextMenu/properties';
|
|
|
135
142
|
export type * from './Calendar/properties';
|
|
136
143
|
export type * from './RelativeTime/properties';
|
|
137
144
|
export type * from './ThemeSwitcher/properties';
|
|
145
|
+
export type * from './ThinkingIndicator/properties';
|
|
138
146
|
export type * from './Book/properties';
|
|
139
147
|
export type * from './Browser/properties';
|
|
140
148
|
export type * from './Phone/properties';
|
|
@@ -150,6 +158,7 @@ export type * from './DateRangePicker/properties';
|
|
|
150
158
|
export type * from './Breadcrumb/properties';
|
|
151
159
|
export type * from './LineChart/properties';
|
|
152
160
|
export type * from './AreaChart/properties';
|
|
161
|
+
export type * from './AttachmentChipRow/properties';
|
|
153
162
|
export type * from './BarChart/properties';
|
|
154
163
|
export type * from './PieChart/properties';
|
|
155
164
|
export type * from './SankeyChart/properties';
|
|
@@ -164,6 +173,7 @@ export type * from './FileDropzoneTrigger/properties';
|
|
|
164
173
|
export type * from './_chart/highlight';
|
|
165
174
|
export type * from './Chat/properties';
|
|
166
175
|
export type * from './Chat/types';
|
|
176
|
+
export type * from './SpeechToText/types';
|
|
167
177
|
export type * from './ChatHeader/properties';
|
|
168
178
|
export type * from './ChatMessage/properties';
|
|
169
179
|
export type * from './ChatMessageList/properties';
|
|
@@ -171,6 +181,7 @@ export type * from './ChatComposer/properties';
|
|
|
171
181
|
export type * from './ChatSuggestions/properties';
|
|
172
182
|
export type * from './ChatToolStatus/properties';
|
|
173
183
|
export type * from './ChatBubble/properties';
|
|
184
|
+
export type * from './HITL/properties';
|
|
174
185
|
export type * from './Resizable/properties';
|
|
175
186
|
export { validateInput } from './utils';
|
|
176
187
|
export { formatNumberIndian } from './_chart/format';
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ export { default as Tabs } from './Tabs/Tabs.svelte';
|
|
|
34
34
|
export { default as Choicebox } from './Choicebox/Choicebox.svelte';
|
|
35
35
|
export { default as Slider } from './Slider/Slider.svelte';
|
|
36
36
|
export { default as Tooltip } from './Tooltip/Tooltip.svelte';
|
|
37
|
+
export { default as TypewriterText } from './TypewriterText/TypewriterText.svelte';
|
|
37
38
|
export { tooltip } from './Tooltip/tooltip-action';
|
|
38
39
|
export { default as Shimmer } from './Shimmer/Shimmer.svelte';
|
|
39
40
|
export { default as Progress } from './Progress/Progress.svelte';
|
|
@@ -52,6 +53,7 @@ export { default as ContextMenu } from './ContextMenu/ContextMenu.svelte';
|
|
|
52
53
|
export { default as Calendar } from './Calendar/Calendar.svelte';
|
|
53
54
|
export { default as RelativeTime } from './RelativeTime/RelativeTime.svelte';
|
|
54
55
|
export { default as ThemeSwitcher } from './ThemeSwitcher/ThemeSwitcher.svelte';
|
|
56
|
+
export { default as ThinkingIndicator } from './ThinkingIndicator/ThinkingIndicator.svelte';
|
|
55
57
|
export { default as Book } from './Book/Book.svelte';
|
|
56
58
|
export { default as Browser } from './Browser/Browser.svelte';
|
|
57
59
|
export { default as Phone } from './Phone/Phone.svelte';
|
|
@@ -66,6 +68,7 @@ export { default as DateRangePicker } from './DateRangePicker/DateRangePicker.sv
|
|
|
66
68
|
export { default as Breadcrumb } from './Breadcrumb/Breadcrumb.svelte';
|
|
67
69
|
export { default as LineChart } from './LineChart/LineChart.svelte';
|
|
68
70
|
export { default as AreaChart } from './AreaChart/AreaChart.svelte';
|
|
71
|
+
export { default as AttachmentChipRow } from './AttachmentChipRow/AttachmentChipRow.svelte';
|
|
69
72
|
export { default as BarChart } from './BarChart/BarChart.svelte';
|
|
70
73
|
export { default as PieChart } from './PieChart/PieChart.svelte';
|
|
71
74
|
export { default as SankeyChart } from './SankeyChart/SankeyChart.svelte';
|
|
@@ -85,8 +88,11 @@ export { default as ChatComposer } from './ChatComposer/ChatComposer.svelte';
|
|
|
85
88
|
export { default as ChatSuggestions } from './ChatSuggestions/ChatSuggestions.svelte';
|
|
86
89
|
export { default as ChatToolStatus } from './ChatToolStatus/ChatToolStatus.svelte';
|
|
87
90
|
export { default as ChatBubble } from './ChatBubble/ChatBubble.svelte';
|
|
91
|
+
export { default as HITL } from './HITL/HITL.svelte';
|
|
92
|
+
export { pauseAllConfirmationTimers } from './HITL/timers';
|
|
88
93
|
export { default as Resizable } from './Resizable/Resizable.svelte';
|
|
89
94
|
export { ChatController } from './Chat/controller.svelte';
|
|
90
95
|
export { partyOf } from './Chat/roles';
|
|
96
|
+
export { SpeechToTextController } from './SpeechToText/controller.svelte';
|
|
91
97
|
export { validateInput } from './utils';
|
|
92
98
|
export { formatNumberIndian } from './_chart/format';
|