@juspay/svelte-ui-components 2.38.0 → 2.39.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.
|
@@ -1,21 +1,60 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { AccordionProperties } from './properties';
|
|
3
3
|
|
|
4
|
-
let {
|
|
4
|
+
let {
|
|
5
|
+
expand = $bindable(false),
|
|
6
|
+
children,
|
|
7
|
+
trigger,
|
|
8
|
+
ontoggle,
|
|
9
|
+
triggerClasses,
|
|
10
|
+
classes,
|
|
11
|
+
testId
|
|
12
|
+
}: AccordionProperties = $props();
|
|
13
|
+
|
|
14
|
+
function handleTriggerClick(): void {
|
|
15
|
+
expand = !expand;
|
|
16
|
+
ontoggle?.(expand);
|
|
17
|
+
}
|
|
5
18
|
</script>
|
|
6
19
|
|
|
7
|
-
|
|
20
|
+
{#if trigger}
|
|
21
|
+
<div
|
|
22
|
+
class="accordion-trigger {triggerClasses ?? ''}"
|
|
23
|
+
role="button"
|
|
24
|
+
tabindex="0"
|
|
25
|
+
aria-expanded={expand}
|
|
26
|
+
onclick={handleTriggerClick}
|
|
27
|
+
onkeydown={(event) => {
|
|
28
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
handleTriggerClick();
|
|
31
|
+
}
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{@render trigger({ expanded: expand })}
|
|
35
|
+
</div>
|
|
36
|
+
{/if}
|
|
37
|
+
|
|
38
|
+
<div
|
|
39
|
+
class="accordion {classes ?? ''}"
|
|
40
|
+
class:expanded={expand}
|
|
41
|
+
data-pw={typeof testId === 'string' ? testId : null}
|
|
42
|
+
>
|
|
8
43
|
<div class="accordion-content">
|
|
9
44
|
{@render children?.()}
|
|
10
45
|
</div>
|
|
11
46
|
</div>
|
|
12
47
|
|
|
13
48
|
<style>
|
|
49
|
+
.accordion-trigger {
|
|
50
|
+
cursor: var(--accordion-trigger-cursor, pointer);
|
|
51
|
+
}
|
|
52
|
+
|
|
14
53
|
.accordion {
|
|
15
54
|
display: grid;
|
|
16
55
|
grid-template-rows: 0fr;
|
|
17
56
|
overflow: hidden;
|
|
18
|
-
transition: grid-template-rows 0.2s ease-out;
|
|
57
|
+
transition: grid-template-rows var(--accordion-transition, 0.2s ease-out);
|
|
19
58
|
}
|
|
20
59
|
|
|
21
60
|
.accordion.expanded {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AccordionProperties } from './properties';
|
|
2
|
-
declare const Accordion: import("svelte").Component<AccordionProperties, {}, "">;
|
|
2
|
+
declare const Accordion: import("svelte").Component<AccordionProperties, {}, "expand">;
|
|
3
3
|
type Accordion = ReturnType<typeof Accordion>;
|
|
4
4
|
export default Accordion;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
export type AccordionProperties =
|
|
2
|
+
export type AccordionProperties = OptionalAccordionProperties & AccordionEventProperties;
|
|
3
|
+
export type OptionalAccordionProperties = {
|
|
3
4
|
expand?: boolean;
|
|
4
5
|
children?: Snippet;
|
|
6
|
+
trigger?: Snippet<[{
|
|
7
|
+
expanded: boolean;
|
|
8
|
+
}]>;
|
|
9
|
+
triggerClasses?: string;
|
|
5
10
|
classes?: string;
|
|
11
|
+
testId?: string;
|
|
12
|
+
};
|
|
13
|
+
export type AccordionEventProperties = {
|
|
14
|
+
ontoggle?: (expanded: boolean) => void;
|
|
6
15
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export type * from './Toolbar/properties';
|
|
|
78
78
|
export type * from './Carousel/properties';
|
|
79
79
|
export type * from './Badge/properties';
|
|
80
80
|
export type * from './Banner/properties';
|
|
81
|
+
export type * from './Accordion/properties';
|
|
81
82
|
export type * from './Table/properties';
|
|
82
83
|
export type * from './Stepper/properties';
|
|
83
84
|
export type * from './Toast/properties';
|