@juspay/svelte-ui-components 4.33.3 → 4.34.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/Accordion/Accordion.svelte +26 -2
- package/dist/Accordion/properties.d.ts +7 -0
- package/dist/ArmedButton/ArmedButton.svelte +147 -0
- package/dist/ArmedButton/ArmedButton.svelte.d.ts +4 -0
- package/dist/ArmedButton/properties.d.ts +24 -0
- package/dist/ArmedButton/properties.js +1 -0
- package/dist/Banner/Banner.svelte +13 -8
- package/dist/Banner/properties.d.ts +8 -1
- package/dist/Button/Button.svelte +26 -0
- package/dist/Button/properties.d.ts +17 -0
- package/dist/ChatComposer/ChatComposer.svelte +314 -1
- package/dist/ChatComposer/properties.d.ts +42 -0
- package/dist/ChatMessageList/ChatMessageList.svelte +22 -2
- package/dist/ChatMessageList/ChatMessageList.svelte.d.ts +1 -1
- package/dist/CommandMenu/CommandMenu.svelte +53 -20
- package/dist/CommandMenu/properties.d.ts +24 -0
- package/dist/DiffViewer/DiffViewer.svelte +210 -0
- package/dist/DiffViewer/DiffViewer.svelte.d.ts +4 -0
- package/dist/DiffViewer/properties.d.ts +25 -0
- package/dist/DiffViewer/properties.js +1 -0
- package/dist/EmptyState/EmptyState.svelte +22 -3
- package/dist/EmptyState/properties.d.ts +9 -0
- package/dist/HITL/HITL.svelte +318 -49
- package/dist/HITL/properties.d.ts +113 -11
- package/dist/Input/Input.svelte +45 -1
- package/dist/Input/properties.d.ts +15 -0
- package/dist/KeyValue/KeyValue.svelte +16 -3
- package/dist/KeyValue/properties.d.ts +2 -0
- package/dist/Progress/Progress.svelte +96 -41
- package/dist/Progress/properties.d.ts +19 -0
- package/dist/Snippet/Snippet.svelte +45 -1
- package/dist/Snippet/properties.d.ts +8 -0
- package/dist/Tabs/Tabs.svelte +75 -16
- package/dist/Tabs/properties.d.ts +21 -0
- package/dist/ThinkingIndicator/ThinkingIndicator.svelte.d.ts +1 -1
- package/dist/Toolbar/Toolbar.svelte +81 -3
- package/dist/Toolbar/properties.d.ts +37 -0
- package/dist/WindowedList/WindowedList.svelte +129 -0
- package/dist/WindowedList/WindowedList.svelte.d.ts +25 -0
- package/dist/WindowedList/properties.d.ts +38 -0
- package/dist/WindowedList/properties.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/styles/theme-dark.css +42 -0
- package/dist-wc/index.js +2637 -1642
- package/package.json +2 -1
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Accordion from '../Accordion/Accordion.svelte';
|
|
3
|
+
import Badge from '../Badge/Badge.svelte';
|
|
4
|
+
import Button from '../Button/Button.svelte';
|
|
5
|
+
import type { DiffViewerProperties } from './properties';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
path,
|
|
9
|
+
hunks,
|
|
10
|
+
additions,
|
|
11
|
+
deletions,
|
|
12
|
+
created = false,
|
|
13
|
+
collapseThreshold = 40,
|
|
14
|
+
classes,
|
|
15
|
+
testId
|
|
16
|
+
}: DiffViewerProperties = $props();
|
|
17
|
+
|
|
18
|
+
const total = $derived(hunks.reduce((sum, hunk) => sum + hunk.lines.length, 0));
|
|
19
|
+
const resetKey = $derived(`${total}:${collapseThreshold}`);
|
|
20
|
+
let openOverride = $state<{ key: string; value: boolean } | null>(null);
|
|
21
|
+
const open = $derived(
|
|
22
|
+
openOverride?.key === resetKey ? openOverride.value : total <= collapseThreshold
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
// A function binding keeps the user's current toggle while these inputs are
|
|
26
|
+
// unchanged. A new total or threshold gets a new key and immediately falls
|
|
27
|
+
// back to the documented threshold rule, without a synchronization effect.
|
|
28
|
+
function setOpen(value: boolean): void {
|
|
29
|
+
openOverride = { key: resetKey, value };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const filename = $derived(path.split('/').pop() ?? path);
|
|
33
|
+
const directory = $derived(path.slice(0, path.length - filename.length));
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div class="diff-viewer {classes ?? ''}">
|
|
37
|
+
<Accordion bind:expand={() => open, setOpen} lazy triggerClasses="diff-trigger" {testId}>
|
|
38
|
+
{#snippet trigger({ expanded })}
|
|
39
|
+
<span class="path">
|
|
40
|
+
<span class="chevron" class:open={expanded}>›</span>
|
|
41
|
+
<span class="directory">{directory}</span><span class="name">{filename}</span>
|
|
42
|
+
{#if created}<Badge value="new" classes="diff-new-badge" />{/if}
|
|
43
|
+
</span>
|
|
44
|
+
<span class="counts">
|
|
45
|
+
{#if additions}<span class="add">+{additions}</span>{/if}
|
|
46
|
+
{#if deletions}<span class="del">−{deletions}</span>{/if}
|
|
47
|
+
</span>
|
|
48
|
+
{/snippet}
|
|
49
|
+
<!-- Mounted once on first expand (Accordion's `lazy`), then kept mounted and
|
|
50
|
+
merely CSS-hidden/inert on later collapses -- a plain {#if open} here
|
|
51
|
+
would destroy and recreate this DOM on every toggle, resetting the
|
|
52
|
+
.diff-body horizontal scroll position each time it reopens. -->
|
|
53
|
+
<div class="diff-body">
|
|
54
|
+
{#each hunks as hunk, index (index)}
|
|
55
|
+
{#if index > 0 || hunk.header}
|
|
56
|
+
<div class="hunk-sep">{hunk.header ?? '⋯'}</div>
|
|
57
|
+
{/if}
|
|
58
|
+
{#each hunk.lines as line, lineIndex (lineIndex)}
|
|
59
|
+
<div class="diff-line" data-kind={line.kind}>
|
|
60
|
+
<span class="num">{line.oldLine ?? ''}</span>
|
|
61
|
+
<span class="num">{line.newLine ?? ''}</span>
|
|
62
|
+
<span class="content"
|
|
63
|
+
>{line.kind === 'add' ? '+' : line.kind === 'remove' ? '-' : ' '}{line.text}</span
|
|
64
|
+
>
|
|
65
|
+
</div>
|
|
66
|
+
{/each}
|
|
67
|
+
{/each}
|
|
68
|
+
</div>
|
|
69
|
+
</Accordion>
|
|
70
|
+
|
|
71
|
+
{#if !open}
|
|
72
|
+
<Button text="{total} lines — show" classes="diff-show" onclick={() => setOpen(true)} />
|
|
73
|
+
{/if}
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<style>
|
|
77
|
+
.diff-viewer {
|
|
78
|
+
font-family: var(--diff-font-family, ui-monospace, monospace);
|
|
79
|
+
font-size: var(--diff-font-size, 13px);
|
|
80
|
+
line-height: var(--diff-line-height, 1.4);
|
|
81
|
+
background: var(--diff-background, #ffffff);
|
|
82
|
+
border: var(--diff-border, 1px solid #d1d5db);
|
|
83
|
+
border-radius: var(--diff-border-radius, 4px);
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.diff-viewer :global(.diff-trigger) {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: flex-start;
|
|
90
|
+
justify-content: space-between;
|
|
91
|
+
gap: var(--diff-gap, 12px);
|
|
92
|
+
padding: var(--diff-trigger-padding, 8px 12px);
|
|
93
|
+
background: var(--diff-header-background, #f9fafb);
|
|
94
|
+
border-bottom: var(--diff-border, 1px solid #d1d5db);
|
|
95
|
+
font-size: var(--diff-header-font-size, 12px);
|
|
96
|
+
color: var(--diff-color, #374151);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.path {
|
|
100
|
+
min-width: 0;
|
|
101
|
+
overflow-wrap: anywhere;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.path :global(.diff-new-badge) {
|
|
105
|
+
margin-left: var(--diff-small-gap, 8px);
|
|
106
|
+
--badge-background: var(--diff-created-background, #dcfce7);
|
|
107
|
+
--badge-color: var(--diff-created-color, #166534);
|
|
108
|
+
--badge-font-size: var(--diff-header-font-size, 12px);
|
|
109
|
+
--badge-padding: var(--diff-created-padding, 2px 8px);
|
|
110
|
+
--badge-border: none;
|
|
111
|
+
--badge-min-width: 0;
|
|
112
|
+
--badge-min-height: 0;
|
|
113
|
+
font-weight: var(--diff-created-font-weight, 500);
|
|
114
|
+
letter-spacing: var(--diff-created-letter-spacing, 0.04em);
|
|
115
|
+
text-transform: var(--diff-created-text-transform, uppercase);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.name {
|
|
119
|
+
color: var(--diff-filename-color, #111827);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.directory {
|
|
123
|
+
color: var(--diff-gutter-color, #6b7280);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.chevron {
|
|
127
|
+
display: inline-block;
|
|
128
|
+
margin-right: var(--diff-small-gap, 8px);
|
|
129
|
+
transition: transform var(--diff-chevron-transition, 120ms ease);
|
|
130
|
+
color: var(--diff-gutter-color, #6b7280);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.chevron.open {
|
|
134
|
+
transform: rotate(90deg);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.counts {
|
|
138
|
+
display: flex;
|
|
139
|
+
gap: var(--diff-small-gap, 8px);
|
|
140
|
+
font-variant-numeric: tabular-nums;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.add {
|
|
144
|
+
color: var(--diff-add-color, #166534);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.del {
|
|
148
|
+
color: var(--diff-remove-color, #991b1b);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.hunk-sep {
|
|
152
|
+
padding: var(--diff-hunk-padding, 4px 12px);
|
|
153
|
+
background: var(--diff-header-background, #f9fafb);
|
|
154
|
+
color: var(--diff-gutter-color, #6b7280);
|
|
155
|
+
font-size: var(--diff-header-font-size, 12px);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.diff-body {
|
|
159
|
+
overflow-x: auto;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.diff-line {
|
|
163
|
+
display: grid;
|
|
164
|
+
grid-template-columns: var(--diff-gutter-width, 44px) var(--diff-gutter-width, 44px) 1fr;
|
|
165
|
+
white-space: pre;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.num {
|
|
169
|
+
padding: var(--diff-gutter-padding, 0 8px);
|
|
170
|
+
text-align: right;
|
|
171
|
+
color: var(--diff-gutter-color, #6b7280);
|
|
172
|
+
user-select: none;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.content {
|
|
176
|
+
padding: var(--diff-content-padding, 0 12px);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.diff-line[data-kind='add'] {
|
|
180
|
+
background: var(--diff-add-background, #f0fdf4);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.diff-line[data-kind='add'] > .content {
|
|
184
|
+
color: var(--diff-add-color, #166534);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.diff-line[data-kind='remove'] {
|
|
188
|
+
background: var(--diff-remove-background, #fef2f2);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.diff-line[data-kind='remove'] > .content {
|
|
192
|
+
color: var(--diff-remove-color, #991b1b);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.diff-line[data-kind='context'] > .content {
|
|
196
|
+
color: var(--diff-color, #374151);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.diff-viewer :global(.diff-show) {
|
|
200
|
+
--button-width: 100%;
|
|
201
|
+
--button-padding: var(--diff-show-padding, 12px);
|
|
202
|
+
--button-color: transparent;
|
|
203
|
+
--button-hover-color: var(--diff-header-background, #f9fafb);
|
|
204
|
+
--button-text-color: var(--diff-color, #374151);
|
|
205
|
+
--button-hover-text-color: var(--diff-filename-color, #111827);
|
|
206
|
+
--button-border: none;
|
|
207
|
+
--button-border-radius: 0;
|
|
208
|
+
--button-font-size: var(--diff-font-size, 13px);
|
|
209
|
+
}
|
|
210
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type DiffViewerLine = {
|
|
2
|
+
kind: 'add' | 'remove' | 'context';
|
|
3
|
+
oldLine?: number;
|
|
4
|
+
newLine?: number;
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
export type DiffViewerHunk = {
|
|
8
|
+
header?: string;
|
|
9
|
+
lines: DiffViewerLine[];
|
|
10
|
+
};
|
|
11
|
+
export type DiffViewerProperties = MandatoryDiffViewerProperties & OptionalDiffViewerProperties;
|
|
12
|
+
export type MandatoryDiffViewerProperties = {
|
|
13
|
+
path: string;
|
|
14
|
+
hunks: DiffViewerHunk[];
|
|
15
|
+
additions: number;
|
|
16
|
+
deletions: number;
|
|
17
|
+
};
|
|
18
|
+
export type OptionalDiffViewerProperties = {
|
|
19
|
+
created?: boolean;
|
|
20
|
+
/** Diffs with more lines start collapsed. Updates to the total reset this state. */
|
|
21
|
+
collapseThreshold?: number;
|
|
22
|
+
classes?: string;
|
|
23
|
+
/** Value for `data-pw` on the trigger/header (forwarded to Accordion's own root). */
|
|
24
|
+
testId?: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,8 +10,19 @@
|
|
|
10
10
|
testId,
|
|
11
11
|
titleSnippet,
|
|
12
12
|
descriptionSnippet,
|
|
13
|
-
density
|
|
13
|
+
density,
|
|
14
|
+
headingLevel
|
|
14
15
|
}: EmptyStateProperties = $props();
|
|
16
|
+
|
|
17
|
+
// Only a real level renders a heading; anything else keeps the plain div.
|
|
18
|
+
const headingTag = $derived(
|
|
19
|
+
typeof headingLevel === 'number' &&
|
|
20
|
+
Number.isInteger(headingLevel) &&
|
|
21
|
+
headingLevel >= 1 &&
|
|
22
|
+
headingLevel <= 6
|
|
23
|
+
? `h${headingLevel}`
|
|
24
|
+
: 'div'
|
|
25
|
+
);
|
|
15
26
|
</script>
|
|
16
27
|
|
|
17
28
|
<div
|
|
@@ -25,7 +36,8 @@
|
|
|
25
36
|
{@render icon()}
|
|
26
37
|
</div>
|
|
27
38
|
{/if}
|
|
28
|
-
<
|
|
39
|
+
<svelte:element
|
|
40
|
+
this={headingTag}
|
|
29
41
|
class="empty-state-title"
|
|
30
42
|
data-pw={typeof testId === 'string' ? `${testId}-title` : null}
|
|
31
43
|
testID={typeof testId === 'string' ? `${testId}-title` : null}
|
|
@@ -35,7 +47,7 @@
|
|
|
35
47
|
{:else}
|
|
36
48
|
{title}
|
|
37
49
|
{/if}
|
|
38
|
-
</
|
|
50
|
+
</svelte:element>
|
|
39
51
|
{#if typeof descriptionSnippet === 'function'}
|
|
40
52
|
<div
|
|
41
53
|
class="empty-state-description"
|
|
@@ -108,6 +120,13 @@
|
|
|
108
120
|
color: var(--empty-state-title-color, inherit);
|
|
109
121
|
}
|
|
110
122
|
|
|
123
|
+
/* A div inherited its line-height already; as a heading it must not take a global
|
|
124
|
+
h1..h6 line-height instead. Only a title that is not a div matches, so the default
|
|
125
|
+
title is not touched. */
|
|
126
|
+
.empty-state-title:not(div) {
|
|
127
|
+
line-height: var(--empty-state-title-line-height, inherit);
|
|
128
|
+
}
|
|
129
|
+
|
|
111
130
|
.empty-state-description {
|
|
112
131
|
font-size: var(--empty-state-description-font-size, 14px);
|
|
113
132
|
color: var(--empty-state-description-color, inherit);
|
|
@@ -26,6 +26,15 @@ export type OptionalEmptyStateProperties = {
|
|
|
26
26
|
* `--empty-state-padding` / `--empty-state-gap`, which always take priority.
|
|
27
27
|
*/
|
|
28
28
|
density?: 'page' | 'panel';
|
|
29
|
+
/**
|
|
30
|
+
* Renders the title as a real heading, `<h1>`-`<h6>`, for a page outline.
|
|
31
|
+
* Omitted -- or anything but an integer 1-6, e.g. from a web-component
|
|
32
|
+
* attribute -- keeps the plain `<div>` title every version before this
|
|
33
|
+
* rendered. The heading keeps the title's own size, weight, colour and
|
|
34
|
+
* (via `--empty-state-title-line-height`, default `inherit`) line height,
|
|
35
|
+
* so a global `h1..h6` rule doesn't restyle it.
|
|
36
|
+
*/
|
|
37
|
+
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
29
38
|
/**
|
|
30
39
|
* Optional snippet that replaces the `title` string at render time.
|
|
31
40
|
* When provided, the mandatory `title` prop is still required for backward-compatibility
|