@juspay/svelte-ui-components 2.115.0 → 2.116.1

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.
@@ -1,13 +1,14 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
  import { fly, fade } from 'svelte/transition';
4
- import type { ModalAlign } from '../Modal/properties';
4
+ import type { ModalAlign, ModalEntryAnimation } from '../Modal/properties';
5
5
  import type { ModalTransition } from '../types';
6
6
 
7
7
  type Props = {
8
8
  enable?: boolean;
9
9
  align?: ModalAlign;
10
10
  transitionType?: ModalTransition;
11
+ entryAnimation?: ModalEntryAnimation;
11
12
  children?: Snippet;
12
13
  testId?: string;
13
14
  };
@@ -16,6 +17,7 @@
16
17
  enable = true,
17
18
  align = 'bottom',
18
19
  transitionType = 'ALL',
20
+ entryAnimation,
19
21
  children,
20
22
  testId
21
23
  }: Props = $props();
@@ -23,6 +25,16 @@
23
25
  let flyAnimationProperties = $derived.by(() => {
24
26
  const base = { x: 0, y: 0, duration: 380 };
25
27
 
28
+ // entryAnimation, when set, overrides the align-based default below —
29
+ // e.g. a centered modal (which normally fades) can opt into the same
30
+ // fly distances top/bottom alignment already use.
31
+ if (entryAnimation === 'slide-up') {
32
+ return { ...base, y: 300 };
33
+ }
34
+ if (entryAnimation === 'slide-down') {
35
+ return { ...base, y: -30 };
36
+ }
37
+
26
38
  switch (align) {
27
39
  case 'top':
28
40
  return { ...base, y: -30 };
@@ -35,7 +47,9 @@
35
47
 
36
48
  let fadeAnimationProperties = { duration: 300 };
37
49
 
38
- let useFlyAnimation = $derived(align === 'top' || align === 'bottom');
50
+ let useFlyAnimation = $derived(
51
+ entryAnimation != null ? entryAnimation !== 'fade' : align === 'top' || align === 'bottom'
52
+ );
39
53
  let useOutTransition = $derived(transitionType === 'ALL');
40
54
  </script>
41
55
 
@@ -1,10 +1,11 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { ModalAlign } from '../Modal/properties';
2
+ import type { ModalAlign, ModalEntryAnimation } from '../Modal/properties';
3
3
  import type { ModalTransition } from '../types';
4
4
  type Props = {
5
5
  enable?: boolean;
6
6
  align?: ModalAlign;
7
7
  transitionType?: ModalTransition;
8
+ entryAnimation?: ModalEntryAnimation;
8
9
  children?: Snippet;
9
10
  testId?: string;
10
11
  };
@@ -5,15 +5,28 @@
5
5
  type Props = {
6
6
  children?: Snippet;
7
7
  testId?: string;
8
+ /** When true, fades in on mount (same 350ms duration as the existing fade-out). Default false preserves the current instant-appear behavior. */
9
+ fadeIn?: boolean;
8
10
  };
9
11
 
10
- let { children, testId }: Props = $props();
12
+ let { children, testId, fadeIn = false }: Props = $props();
11
13
  </script>
12
14
 
13
- <div
14
- out:fade={{ duration: 350 }}
15
- data-pw={typeof testId === 'string' ? testId : null}
16
- testID={typeof testId === 'string' ? testId : null}
17
- >
18
- {@render children?.()}
19
- </div>
15
+ {#if fadeIn}
16
+ <div
17
+ in:fade={{ duration: 350 }}
18
+ out:fade={{ duration: 350 }}
19
+ data-pw={typeof testId === 'string' ? testId : null}
20
+ testID={typeof testId === 'string' ? testId : null}
21
+ >
22
+ {@render children?.()}
23
+ </div>
24
+ {:else}
25
+ <div
26
+ out:fade={{ duration: 350 }}
27
+ data-pw={typeof testId === 'string' ? testId : null}
28
+ testID={typeof testId === 'string' ? testId : null}
29
+ >
30
+ {@render children?.()}
31
+ </div>
32
+ {/if}
@@ -2,6 +2,8 @@ import type { Snippet } from 'svelte';
2
2
  type Props = {
3
3
  children?: Snippet;
4
4
  testId?: string;
5
+ /** When true, fades in on mount (same 350ms duration as the existing fade-out). Default false preserves the current instant-appear behavior. */
6
+ fadeIn?: boolean;
5
7
  };
6
8
  declare const OverlayAnimation: import("svelte").Component<Props, {}, "">;
7
9
  type OverlayAnimation = ReturnType<typeof OverlayAnimation>;
@@ -88,6 +88,19 @@
88
88
  justify-content: var(--chip-input-justify-content, flex-start);
89
89
  gap: var(--chip-input-gap, 6px);
90
90
  width: var(--chip-input-width, 100%);
91
+
92
+ /* Capture the surrounding cascade's Pill and Input values under distinct names, so the
93
+ per-token mappings below can fall back to them. This has to happen HERE, on the root, where
94
+ --pill-* and --input-* have not yet been re-declared: reading them in the same declaration
95
+ that sets them would be a custom-property cycle and would compute to invalid. Consumers that
96
+ theme Pill/Input app-wide get chips that match the rest of their UI, instead of the library's
97
+ hardcoded light-theme hexes overriding their theme. */
98
+ --chip-input-pill-background-default: var(--pill-background, #e0e0e0);
99
+ --chip-input-pill-color-default: var(--pill-color, #333333);
100
+ --chip-input-pill-dismiss-color-default: var(--pill-dismiss-color, currentColor);
101
+ --chip-input-draft-border-default: var(--input-border, 1px solid transparent);
102
+ --chip-input-draft-focus-border-default: var(--input-focus-border, 1px solid transparent);
103
+ --chip-input-draft-radius-default: var(--input-radius, 4px);
91
104
  }
92
105
 
93
106
  .chip-input-draft-wrap {
@@ -96,8 +109,8 @@
96
109
 
97
110
  .chip-input :global(.chip-input-pill) {
98
111
  --pill-gap: var(--chip-input-pill-gap, 4px);
99
- --pill-background: var(--chip-input-pill-background, #e0e0e0);
100
- --pill-color: var(--chip-input-pill-color, #333333);
112
+ --pill-background: var(--chip-input-pill-background, var(--chip-input-pill-background-default));
113
+ --pill-color: var(--chip-input-pill-color, var(--chip-input-pill-color-default));
101
114
  --pill-font-size: var(--chip-input-pill-font-size, 13px);
102
115
  --pill-font-weight: var(--chip-input-pill-font-weight, 500);
103
116
  --pill-padding: var(--chip-input-pill-padding, 6px 10px);
@@ -105,15 +118,21 @@
105
118
  --pill-border: var(--chip-input-pill-border, none);
106
119
  --pill-max-width: var(--chip-input-pill-max-width);
107
120
  --pill-dismiss-size: var(--chip-input-pill-dismiss-size, 14px);
108
- --pill-dismiss-color: var(--chip-input-pill-dismiss-color, currentColor);
121
+ --pill-dismiss-color: var(
122
+ --chip-input-pill-dismiss-color,
123
+ var(--chip-input-pill-dismiss-color-default)
124
+ );
109
125
  }
110
126
 
111
127
  .chip-input-draft-wrap :global(.chip-input-draft) {
112
128
  --input-width: var(--chip-input-draft-width, 90px);
113
129
  --input-height: var(--chip-input-draft-height, 28px);
114
- --input-border: var(--chip-input-draft-border, 1px solid transparent);
115
- --input-radius: var(--chip-input-draft-radius, 4px);
116
- --input-focus-border: var(--chip-input-draft-focus-border, 1px solid transparent);
130
+ --input-border: var(--chip-input-draft-border, var(--chip-input-draft-border-default));
131
+ --input-radius: var(--chip-input-draft-radius, var(--chip-input-draft-radius-default));
132
+ --input-focus-border: var(
133
+ --chip-input-draft-focus-border,
134
+ var(--chip-input-draft-focus-border-default)
135
+ );
117
136
  --input-padding: var(--chip-input-draft-padding, 0 2px);
118
137
  --input-margin: 0;
119
138
  --input-font-size: var(--chip-input-draft-font-size, 13px);
@@ -17,6 +17,7 @@
17
17
  supportHardwareBackPress = false,
18
18
  enableTransition = true,
19
19
  transitionType = 'ALL',
20
+ entryAnimation,
20
21
  header = {},
21
22
  footer,
22
23
  debounceTime = 700,
@@ -34,6 +35,7 @@
34
35
  onkeydown,
35
36
  classes,
36
37
  overlayBackdropFilter,
38
+ overlayFadeIn = false,
37
39
  usePortal = false
38
40
  }: ModalProperties = $props();
39
41
 
@@ -138,7 +140,7 @@
138
140
  <svelte:window onkeydown={handleKeyDown} />
139
141
 
140
142
  {#if typeof content === 'function'}
141
- <OverlayAnimation>
143
+ <OverlayAnimation fadeIn={overlayFadeIn}>
142
144
  <div
143
145
  bind:this={overlayDiv}
144
146
  use:portalAction={{ usePortal }}
@@ -153,7 +155,7 @@
153
155
  data-pw={testId}
154
156
  testID={testId}
155
157
  >
156
- <ModalAnimation enable={enableTransition} {align} {transitionType}>
158
+ <ModalAnimation enable={enableTransition} {align} {transitionType} {entryAnimation}>
157
159
  <div class="modal-content {size}">
158
160
  {#if (typeof header?.leftImage === 'string' && header.leftImage.length > 0) || (typeof header?.text === 'string' && header.text.length > 0) || (typeof header?.rightImage === 'string' && header.rightImage.length > 0)}
159
161
  <div class="header">
@@ -3,6 +3,14 @@ import type { ModalTransition } from '../types';
3
3
  import type { Snippet } from 'svelte';
4
4
  export type ModalSize = 'large' | 'medium' | 'small' | 'fit-content';
5
5
  export type ModalAlign = 'top' | 'center' | 'bottom';
6
+ /**
7
+ * Overrides ModalAnimation's default per-align entry transition ('top'/'bottom'
8
+ * fly, 'center' fade). 'slide-up' and 'slide-down' reuse the same fly
9
+ * distance/duration constants as bottom/top alignment respectively, so e.g. a
10
+ * centered modal can slide up like a bottom sheet instead of just fading in.
11
+ * Leave unset to keep the existing per-align default.
12
+ */
13
+ export type ModalEntryAnimation = 'fade' | 'slide-up' | 'slide-down';
6
14
  export type ModalProperties = OptionalModalProperties & ModalEventProperties;
7
15
  export type OptionalModalProperties = {
8
16
  size?: ModalSize;
@@ -11,6 +19,8 @@ export type OptionalModalProperties = {
11
19
  supportHardwareBackPress?: boolean;
12
20
  enableTransition?: boolean;
13
21
  transitionType?: ModalTransition;
22
+ /** Overrides the default per-align entry transition. See ModalEntryAnimation. Default: unset (per-align behavior). */
23
+ entryAnimation?: ModalEntryAnimation;
14
24
  header?: {
15
25
  leftImage?: string;
16
26
  rightImage?: string;
@@ -34,6 +44,8 @@ export type OptionalModalProperties = {
34
44
  classes?: string;
35
45
  /** CSS value applied to backdrop-filter on the overlay (e.g. "blur(6px)"). Exposed as --modal-overlay-backdrop-filter CSS var. Default: none (no blur). */
36
46
  overlayBackdropFilter?: string;
47
+ /** When true, the overlay backdrop fades in on mount instead of appearing instantly. Pairs well with entryAnimation="slide-up" for a softer combined entrance. Default: false (current instant-appear behavior). */
48
+ overlayFadeIn?: boolean;
37
49
  /** When true, mounts the overlay at document.body to escape clipping/stacking contexts. Default: false. */
38
50
  usePortal?: boolean;
39
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "2.115.0",
3
+ "version": "2.116.1",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",