@juspay/svelte-ui-components 4.55.4 → 4.57.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 +66 -34
- package/dist/Accordion/Accordion.svelte.d.ts +1 -1
- package/dist/Accordion/properties.d.ts +11 -0
- package/dist/Avatar/Avatar.svelte +20 -6
- package/dist/Button/Button.svelte +34 -19
- package/dist/Button/Button.svelte.d.ts +1 -1
- package/dist/Button/properties.d.ts +10 -0
- package/dist/Card/Card.svelte +31 -18
- package/dist/Card/properties.d.ts +7 -0
- package/dist/Dialog/Dialog.svelte +186 -0
- package/dist/Dialog/Dialog.svelte.d.ts +4 -0
- package/dist/Dialog/properties.d.ts +23 -0
- package/dist/Dialog/properties.js +1 -0
- package/dist/DockPanel/DockPanel.svelte.d.ts +1 -1
- package/dist/EmptyState/EmptyState.svelte +58 -33
- package/dist/EmptyState/properties.d.ts +4 -0
- package/dist/FileInput/FileInput.svelte +130 -31
- package/dist/FileInput/FileInput.svelte.d.ts +1 -1
- package/dist/FileInput/properties.d.ts +9 -0
- package/dist/Icon/Icon.svelte +99 -21
- package/dist/Icon/properties.d.ts +8 -0
- package/dist/IframeViewer/IframeViewer.svelte +29 -5
- package/dist/IframeViewer/IframeViewer.svelte.d.ts +1 -1
- package/dist/IframeViewer/properties.d.ts +9 -0
- package/dist/Img/Img.svelte +31 -11
- package/dist/Img/Img.svelte.d.ts +1 -1
- package/dist/Img/properties.d.ts +13 -0
- package/dist/Input/Input.svelte +260 -170
- package/dist/Input/Input.svelte.d.ts +1 -1
- package/dist/Input/properties.d.ts +10 -0
- package/dist/Link/Link.svelte +33 -0
- package/dist/Link/Link.svelte.d.ts +4 -0
- package/dist/Link/properties.d.ts +14 -0
- package/dist/Link/properties.js +1 -0
- package/dist/Loader/Loader.svelte +50 -5
- package/dist/Loader/properties.d.ts +4 -0
- package/dist/MediaPlayer/MediaPlayer.svelte +223 -161
- package/dist/MediaPlayer/MediaPlayer.svelte.d.ts +1 -1
- package/dist/MediaPlayer/properties.d.ts +13 -0
- package/dist/Modal/Modal.svelte +52 -3
- package/dist/Modal/properties.d.ts +11 -0
- package/dist/NativeFileInput/NativeFileInput.svelte +52 -0
- package/dist/NativeFileInput/NativeFileInput.svelte.d.ts +6 -0
- package/dist/NativeFileInput/properties.d.ts +6 -0
- package/dist/NativeFileInput/properties.js +1 -0
- package/dist/Pill/Pill.svelte +7 -3
- package/dist/Pill/properties.d.ts +4 -0
- package/dist/Progress/Progress.svelte +46 -7
- package/dist/Progress/properties.d.ts +4 -0
- package/dist/Resizable/Resizable.svelte.d.ts +1 -1
- package/dist/Select/Select.svelte +535 -354
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/Select/dropdownPosition.d.ts +2 -0
- package/dist/Select/dropdownPosition.js +3 -2
- package/dist/Select/properties.d.ts +11 -0
- package/dist/ThemeSwitcher/ThemeSwitcher.svelte +5 -0
- package/dist/_chart/ChartContainer.svelte.d.ts +1 -1
- package/dist/_field/form-reset.d.ts +2 -0
- package/dist/_field/form-reset.js +34 -0
- package/dist/_interaction/dismissal.d.ts +2 -0
- package/dist/_interaction/dismissal.js +7 -1
- package/dist/_interaction/focus.d.ts +1 -1
- package/dist/_interaction/focus.js +66 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/styles/theme-dark.css +4 -0
- package/dist-codemod/codemod/migration-assets/legacy-display.css +5 -2
- package/dist-codemod/codemod/migration-assets/legacy-palette.css +4 -1
- package/dist-codemod/codemod/migration-assets/wc-display.json +15 -0
- package/dist-wc/index.js +5301 -3252
- package/package.json +2 -2
package/dist/Modal/Modal.svelte
CHANGED
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
import OverlayAnimation from '../Animations/OverlayAnimation.svelte';
|
|
6
6
|
import { createDebouncer, acquireScrollLock, resolveScrollContainer } from '../utils';
|
|
7
7
|
import { focusEntryPoint, focusTrapTabTarget, getActiveElement } from '../_interaction/focus';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
registerDismissible,
|
|
10
|
+
isTopmostDismissible,
|
|
11
|
+
eventHitsInside
|
|
12
|
+
} from '../_interaction/dismissal';
|
|
9
13
|
import Button from '../Button/Button.svelte';
|
|
10
14
|
import Img from '../Img/Img.svelte';
|
|
11
15
|
|
|
@@ -17,8 +21,12 @@
|
|
|
17
21
|
// Not $state: it's read-once bookkeeping for the mount/destroy pair, not
|
|
18
22
|
// something the template reacts to.
|
|
19
23
|
let previouslyFocusedElement: HTMLElement | null = null;
|
|
24
|
+
let mountedRestoreFocusTo: ModalProperties['restoreFocusTo'];
|
|
25
|
+
let restoreFocusDocument: Document | null = null;
|
|
20
26
|
|
|
21
27
|
let {
|
|
28
|
+
restoreFocusTo,
|
|
29
|
+
containFocus = false,
|
|
22
30
|
size = 'fit-content',
|
|
23
31
|
align = 'center',
|
|
24
32
|
showOverlay = true,
|
|
@@ -213,8 +221,25 @@
|
|
|
213
221
|
// matters generally: a stale layer left registered after unmount would
|
|
214
222
|
// swallow every later Escape in the app, and would never come back).
|
|
215
223
|
let releaseDismissible: (() => void) | null = null;
|
|
224
|
+
let releaseFocusGuard: (() => void) | null = null;
|
|
225
|
+
const handleFocusIn = (event: FocusEvent): void => {
|
|
226
|
+
if (
|
|
227
|
+
containFocus &&
|
|
228
|
+
modalContent &&
|
|
229
|
+
isTopmostDismissible(modalContent) &&
|
|
230
|
+
!eventHitsInside(modalContent, event)
|
|
231
|
+
) {
|
|
232
|
+
focusEntryPoint(modalContent);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
216
235
|
|
|
217
236
|
onMount(() => {
|
|
237
|
+
const ownerDocument = modalContent?.ownerDocument ?? document;
|
|
238
|
+
// Keep this open instance's option, not a newer presentation's prop.
|
|
239
|
+
mountedRestoreFocusTo = restoreFocusTo;
|
|
240
|
+
restoreFocusDocument = ownerDocument;
|
|
241
|
+
ownerDocument.addEventListener('focusin', handleFocusIn, true);
|
|
242
|
+
releaseFocusGuard = () => ownerDocument.removeEventListener('focusin', handleFocusIn, true);
|
|
218
243
|
releaseDismissible = registerDismissible({
|
|
219
244
|
element: () => modalContent,
|
|
220
245
|
onEscape: handleEscape
|
|
@@ -244,6 +269,8 @@
|
|
|
244
269
|
});
|
|
245
270
|
|
|
246
271
|
onDestroy(() => {
|
|
272
|
+
releaseFocusGuard?.();
|
|
273
|
+
releaseFocusGuard = null;
|
|
247
274
|
releaseDismissible?.();
|
|
248
275
|
releaseDismissible = null;
|
|
249
276
|
if (dismissTimer !== null) {
|
|
@@ -263,8 +290,30 @@
|
|
|
263
290
|
// isConnected: the trigger can have been unmounted while the modal was
|
|
264
291
|
// open (e.g. the page navigated), and .focus() on a detached element is
|
|
265
292
|
// a silent no-op at best.
|
|
266
|
-
if (
|
|
267
|
-
previouslyFocusedElement.
|
|
293
|
+
if (typeof mountedRestoreFocusTo === 'undefined') {
|
|
294
|
+
if (previouslyFocusedElement !== null && previouslyFocusedElement.isConnected) {
|
|
295
|
+
previouslyFocusedElement.focus();
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
try {
|
|
299
|
+
const target =
|
|
300
|
+
typeof mountedRestoreFocusTo === 'function'
|
|
301
|
+
? mountedRestoreFocusTo()
|
|
302
|
+
: mountedRestoreFocusTo;
|
|
303
|
+
const OwnerNode = restoreFocusDocument?.defaultView?.Node;
|
|
304
|
+
if (
|
|
305
|
+
target !== null &&
|
|
306
|
+
target.ownerDocument === restoreFocusDocument &&
|
|
307
|
+
target.namespaceURI === 'http://www.w3.org/1999/xhtml' &&
|
|
308
|
+
target.isConnected &&
|
|
309
|
+
typeof OwnerNode === 'function' &&
|
|
310
|
+
OwnerNode.prototype.getRootNode.call(target, { composed: true }) === restoreFocusDocument
|
|
311
|
+
) {
|
|
312
|
+
target.focus();
|
|
313
|
+
}
|
|
314
|
+
} catch {
|
|
315
|
+
// An explicit owner can withdraw its target; never restore the old opener instead.
|
|
316
|
+
}
|
|
268
317
|
}
|
|
269
318
|
});
|
|
270
319
|
</script>
|
|
@@ -20,6 +20,17 @@ export type ModalEntryAnimation = 'fade' | 'slide-up' | 'slide-down';
|
|
|
20
20
|
export type ModalRole = 'dialog' | 'alertdialog';
|
|
21
21
|
export type ModalProperties = OptionalModalProperties & ModalEventProperties;
|
|
22
22
|
export type OptionalModalProperties = {
|
|
23
|
+
/**
|
|
24
|
+
* Focus destination snapshotted once per mounted open. Omit to restore the
|
|
25
|
+
* previously focused element unchanged. A getter resolves once at actual
|
|
26
|
+
* teardown, after dismissal/scroll cleanup; it must only return a target.
|
|
27
|
+
* Explicit null, a null/throwing getter, or a disconnected/foreign-document
|
|
28
|
+
* element skips restoration without falling back. Changes while mounted
|
|
29
|
+
* apply to the next mount. Custom elements accept property assignment only.
|
|
30
|
+
*/
|
|
31
|
+
restoreFocusTo?: HTMLElement | (() => HTMLElement | null) | null;
|
|
32
|
+
/** Pull programmatic/background focus back into this modal while it owns the foreground. */
|
|
33
|
+
containFocus?: boolean;
|
|
23
34
|
/** Scroll owner, resolved once per open span. Omit for the overlay's ownerDocument.body.
|
|
24
35
|
* Supply the embedded scroll element or a getter; explicit null means no lock.
|
|
25
36
|
* Changing ownership while open takes effect on the next open, and teardown
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import FileInput from '../FileInput/FileInput.svelte';
|
|
3
|
+
import type { NativeFileInputProperties } from './properties';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
element = $bindable<HTMLInputElement | null>(),
|
|
7
|
+
onfileerror,
|
|
8
|
+
name,
|
|
9
|
+
required,
|
|
10
|
+
nativeAttrs,
|
|
11
|
+
accept,
|
|
12
|
+
multiple,
|
|
13
|
+
maxSizeBytes,
|
|
14
|
+
disabled,
|
|
15
|
+
testId,
|
|
16
|
+
classes,
|
|
17
|
+
errorMessage,
|
|
18
|
+
infoMessage,
|
|
19
|
+
invalid,
|
|
20
|
+
onfiles,
|
|
21
|
+
...props
|
|
22
|
+
}: NativeFileInputProperties = $props();
|
|
23
|
+
let control = $state<{ openFilePicker: () => void }>();
|
|
24
|
+
|
|
25
|
+
export function openFilePicker(): void {
|
|
26
|
+
control?.openFilePicker();
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
{#snippet emptyTrigger()}{/snippet}
|
|
31
|
+
|
|
32
|
+
<FileInput
|
|
33
|
+
{...props}
|
|
34
|
+
native
|
|
35
|
+
{name}
|
|
36
|
+
{required}
|
|
37
|
+
{nativeAttrs}
|
|
38
|
+
{accept}
|
|
39
|
+
{multiple}
|
|
40
|
+
{maxSizeBytes}
|
|
41
|
+
{disabled}
|
|
42
|
+
{testId}
|
|
43
|
+
{classes}
|
|
44
|
+
{errorMessage}
|
|
45
|
+
{infoMessage}
|
|
46
|
+
{invalid}
|
|
47
|
+
{onfiles}
|
|
48
|
+
onerror={onfileerror}
|
|
49
|
+
trigger={emptyTrigger}
|
|
50
|
+
bind:element
|
|
51
|
+
bind:this={control}
|
|
52
|
+
/>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NativeFileInputProperties } from './properties';
|
|
2
|
+
declare const NativeFileInput: import("svelte").Component<NativeFileInputProperties, {
|
|
3
|
+
openFilePicker: () => void;
|
|
4
|
+
}, "element">;
|
|
5
|
+
type NativeFileInput = ReturnType<typeof NativeFileInput>;
|
|
6
|
+
export default NativeFileInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FileInputProperties } from '../FileInput/properties';
|
|
2
|
+
/** Explicit native picker adoption; legacy FileInput keeps its required trigger. */
|
|
3
|
+
export type NativeFileInputProperties = Omit<FileInputProperties, 'trigger' | 'native' | 'onerror' | 'activation'> & {
|
|
4
|
+
/** File validation error; avoids the HTMLElement.onerror event contract. */
|
|
5
|
+
onfileerror?: FileInputProperties['onerror'];
|
|
6
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/Pill/Pill.svelte
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
import { pillToneClass } from './pillTone';
|
|
7
7
|
|
|
8
8
|
let {
|
|
9
|
+
unstyled = false,
|
|
10
|
+
inline = false,
|
|
9
11
|
text,
|
|
10
12
|
dismissible = false,
|
|
11
13
|
disabled = false,
|
|
@@ -56,7 +58,9 @@
|
|
|
56
58
|
// controls. A neutral div holds independent primary and dismiss buttons when
|
|
57
59
|
// both actions are present, preserving native activation for each action.
|
|
58
60
|
const isButtonRoot = $derived(as === 'button' && !dismissible);
|
|
59
|
-
const rootTag = $derived(
|
|
61
|
+
const rootTag = $derived(
|
|
62
|
+
isButtonRoot ? 'button' : inline && !(interactive && dismissible) ? 'span' : 'div'
|
|
63
|
+
);
|
|
60
64
|
const hasSeparateAction = $derived(interactive && dismissible);
|
|
61
65
|
const rootAttrs = $derived(
|
|
62
66
|
hasSeparateAction
|
|
@@ -113,7 +117,7 @@
|
|
|
113
117
|
<svelte:element
|
|
114
118
|
this={rootTag}
|
|
115
119
|
{...rootAttrs ?? {}}
|
|
116
|
-
class=
|
|
120
|
+
class={unstyled ? (classes ?? '') : `pill ${pillToneClass(tone)} ${classes ?? ''}`}
|
|
117
121
|
class:disabled
|
|
118
122
|
class:separate-action={hasSeparateAction}
|
|
119
123
|
type={isButtonRoot ? 'button' : null}
|
|
@@ -147,7 +151,7 @@
|
|
|
147
151
|
{#if typeof leadingIcon === 'function'}
|
|
148
152
|
<span class="pill-leading-icon">{@render leadingIcon()}</span>
|
|
149
153
|
{/if}
|
|
150
|
-
<span class="pill-text">{text}</span>
|
|
154
|
+
{#if unstyled}{text}{:else}<span class="pill-text">{text}</span>{/if}
|
|
151
155
|
{#if dismissible}
|
|
152
156
|
<div class="pill-dismiss">
|
|
153
157
|
<!-- A dismiss action is a bare icon, not a primary call to action. -->
|
|
@@ -73,6 +73,10 @@ export type PillTone = 'accent' | 'ok' | 'warn' | 'danger' | 'muted';
|
|
|
73
73
|
*/
|
|
74
74
|
export type PillRootTag = 'div' | 'button';
|
|
75
75
|
export type OptionalPillProperties = {
|
|
76
|
+
/** Opt-in inline root without widening the released as discriminator. */
|
|
77
|
+
inline?: boolean;
|
|
78
|
+
/** Retain host-authored tag/control appearance without default pill styling. */
|
|
79
|
+
unstyled?: boolean;
|
|
76
80
|
dismissible?: boolean;
|
|
77
81
|
disabled?: boolean;
|
|
78
82
|
/**
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
value,
|
|
7
7
|
max = 100,
|
|
8
8
|
leadingLabel,
|
|
9
|
+
trailingLabel,
|
|
10
|
+
segments,
|
|
9
11
|
showLabel = false,
|
|
10
12
|
animateValue = false,
|
|
11
13
|
ariaLabel,
|
|
@@ -42,6 +44,13 @@
|
|
|
42
44
|
// Gauge's labelText convention. "Loading" matches the aria-label
|
|
43
45
|
// LoadingDots already uses for its own indeterminate role="status" element.
|
|
44
46
|
let labelText = $derived(isIndeterminate ? 'Loading' : `${Math.round(percentage)}%`);
|
|
47
|
+
const segmentCount = $derived(
|
|
48
|
+
typeof segments === 'number' && Number.isFinite(segments) && segments > 0
|
|
49
|
+
? Math.min(1000, Math.floor(segments))
|
|
50
|
+
: 0
|
|
51
|
+
);
|
|
52
|
+
const segmented = $derived(!isIndeterminate && segmentCount > 0);
|
|
53
|
+
const filledSegments = $derived(Math.ceil((percentage / 100) * segmentCount));
|
|
45
54
|
</script>
|
|
46
55
|
|
|
47
56
|
<!-- The bar itself. Rendered bare, exactly as it always was, unless a header
|
|
@@ -62,14 +71,20 @@
|
|
|
62
71
|
{#if typeof leadingLabel === 'function'}
|
|
63
72
|
{@render leadingLabel()}
|
|
64
73
|
{/if}
|
|
65
|
-
<div class="track">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
<div class="track" class:segmented>
|
|
75
|
+
{#if segmented}
|
|
76
|
+
{#each Array(segmentCount) as _, index (index)}
|
|
77
|
+
<div class="segment" class:filled={index < filledSegments}></div>
|
|
78
|
+
{/each}
|
|
79
|
+
{:else}<div
|
|
80
|
+
class="bar"
|
|
81
|
+
class:indeterminate={isIndeterminate}
|
|
82
|
+
style:width={isIndeterminate ? null : `${percentage}%`}
|
|
83
|
+
></div>{/if}
|
|
71
84
|
</div>
|
|
72
|
-
{#if
|
|
85
|
+
{#if typeof trailingLabel === 'function'}
|
|
86
|
+
{@render trailingLabel()}
|
|
87
|
+
{:else if showLabel && !isIndeterminate}
|
|
73
88
|
<div class="label">
|
|
74
89
|
{#if animateValue}
|
|
75
90
|
<!-- The rounded percentage is already the display value labelText
|
|
@@ -161,6 +176,27 @@
|
|
|
161
176
|
transition: var(--progress-bar-transition, width 0.3s ease);
|
|
162
177
|
}
|
|
163
178
|
|
|
179
|
+
.track.segmented {
|
|
180
|
+
box-sizing: border-box;
|
|
181
|
+
display: flex;
|
|
182
|
+
align-items: center;
|
|
183
|
+
gap: var(--progress-segment-gap, 4px);
|
|
184
|
+
padding: var(--progress-segment-padding, 0);
|
|
185
|
+
background: transparent;
|
|
186
|
+
border-radius: 0;
|
|
187
|
+
overflow: visible;
|
|
188
|
+
}
|
|
189
|
+
.segment {
|
|
190
|
+
flex: 1;
|
|
191
|
+
height: var(--progress-segment-height, var(--progress-track-height, 8px));
|
|
192
|
+
background: var(--progress-track-background, #e0e0e0);
|
|
193
|
+
border-radius: var(--progress-segment-border-radius, var(--radius, 4px));
|
|
194
|
+
transition: var(--progress-segment-transition, background-color 0.3s ease);
|
|
195
|
+
}
|
|
196
|
+
.segment.filled {
|
|
197
|
+
background: var(--progress-bar-background, #2196f3);
|
|
198
|
+
}
|
|
199
|
+
|
|
164
200
|
.bar.indeterminate {
|
|
165
201
|
width: 30%;
|
|
166
202
|
animation: indeterminate var(--progress-indeterminate-duration, 1.5s) ease-in-out infinite;
|
|
@@ -190,6 +226,9 @@
|
|
|
190
226
|
<style> because that is the only stylesheet that reaches inside the shadow
|
|
191
227
|
root a custom-element consumer gets. */
|
|
192
228
|
@media (prefers-reduced-motion: reduce) {
|
|
229
|
+
.segment {
|
|
230
|
+
transition: none;
|
|
231
|
+
}
|
|
193
232
|
.bar.indeterminate {
|
|
194
233
|
/* `animation: none` alone would strand a 30%-wide bar at the left of the
|
|
195
234
|
track, which is indistinguishable from determinate 30% progress -- the
|
|
@@ -4,6 +4,10 @@ export type MandatoryProgressProperties = {
|
|
|
4
4
|
value: number;
|
|
5
5
|
};
|
|
6
6
|
export type OptionalProgressProperties = {
|
|
7
|
+
/** Opt-in segmented track; positive integers, capped at 1,000. Indeterminate mode stays continuous. */
|
|
8
|
+
segments?: number;
|
|
9
|
+
/** Custom trailing content in place of the built-in percentage label. */
|
|
10
|
+
trailingLabel?: Snippet;
|
|
7
11
|
/**
|
|
8
12
|
* The maximum value representing 100% completion. Must be a finite,
|
|
9
13
|
* positive number for the percentage to be meaningful. A zero, negative,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ResizableProperties } from './properties';
|
|
2
|
-
declare const Resizable: import("svelte").Component<ResizableProperties, {}, "
|
|
2
|
+
declare const Resizable: import("svelte").Component<ResizableProperties, {}, "height" | "width">;
|
|
3
3
|
type Resizable = ReturnType<typeof Resizable>;
|
|
4
4
|
export default Resizable;
|