@djcali570/component-lib 0.1.3 → 0.1.5
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/README.md +2 -0
- package/dist/Accordion5.svelte +48 -14
- package/dist/Accordion5.svelte.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -230,6 +230,8 @@ onUpdate={(v) => dialogUpdated(v)}
|
|
|
230
230
|
|
|
231
231
|
|
|
232
232
|
# Updates
|
|
233
|
+
#### 0.1.5 - Fixed issue where Accordion did not handle dynamic content.
|
|
234
|
+
#### 0.1.4 - Updated Accordion component to add innerPadding prop.
|
|
233
235
|
#### 0.1.3 - Updated Time Picker to allow binding to timeText.
|
|
234
236
|
#### 0.1.2 - Fixed some minor styling issues with Dialog component.
|
|
235
237
|
#### 0.1.1 - Added Bottom Sheet component & Dialog component.
|
package/dist/Accordion5.svelte
CHANGED
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
title,
|
|
9
9
|
panel,
|
|
10
10
|
iconWidth = '1.2rem',
|
|
11
|
-
iconHeight = '1.2rem'
|
|
11
|
+
iconHeight = '1.2rem',
|
|
12
|
+
innerPadding = '0.5rem'
|
|
12
13
|
}: {
|
|
13
14
|
colorScheme?: Partial<Accordion5ColorScheme>;
|
|
14
15
|
title?: Snippet;
|
|
15
16
|
panel: Snippet;
|
|
16
17
|
iconWidth?: string;
|
|
17
18
|
iconHeight?: string;
|
|
19
|
+
innerPadding?: string;
|
|
18
20
|
} = $props();
|
|
19
21
|
|
|
20
22
|
// Default colorScheme
|
|
@@ -32,22 +34,53 @@
|
|
|
32
34
|
let panelHeight = $state('0px'); // Store dynamic height
|
|
33
35
|
let panelRef: HTMLDivElement | undefined = $state(); // Reference to inner panel
|
|
34
36
|
|
|
35
|
-
//
|
|
36
|
-
function
|
|
37
|
-
|
|
37
|
+
// Debounce utility to limit frequent updates
|
|
38
|
+
function debounce<T extends (...args: any[]) => void>(fn: T, delay: number) {
|
|
39
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
40
|
+
return (...args: Parameters<T>) => {
|
|
41
|
+
clearTimeout(timeout);
|
|
42
|
+
timeout = setTimeout(() => fn(...args), delay);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Update panel height
|
|
47
|
+
const updateHeight = () => {
|
|
38
48
|
if (status && panelRef) {
|
|
39
|
-
// Set max-height to content height when opening
|
|
40
49
|
panelHeight = `${panelRef.scrollHeight}px`;
|
|
41
50
|
} else {
|
|
42
|
-
// Reset to 0 when closing
|
|
43
51
|
panelHeight = '0px';
|
|
44
52
|
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Debounced height update
|
|
56
|
+
const debouncedUpdateHeight = debounce(updateHeight, 100);
|
|
57
|
+
|
|
58
|
+
// Toggle panel and update height
|
|
59
|
+
function showPanel() {
|
|
60
|
+
status = !status;
|
|
61
|
+
requestAnimationFrame(updateHeight); // Update height after status change
|
|
45
62
|
}
|
|
46
63
|
|
|
47
|
-
//
|
|
64
|
+
// Observe panel content size changes
|
|
65
|
+
$effect(() => {
|
|
66
|
+
if (!panelRef) return;
|
|
67
|
+
|
|
68
|
+
const observer = new ResizeObserver(() => {
|
|
69
|
+
debouncedUpdateHeight();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
observer.observe(panelRef);
|
|
73
|
+
|
|
74
|
+
// Cleanup observer on component destroy
|
|
75
|
+
return () => {
|
|
76
|
+
observer.disconnect();
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Update height when status changes
|
|
48
81
|
$effect(() => {
|
|
49
82
|
if (status && panelRef) {
|
|
50
|
-
|
|
83
|
+
debouncedUpdateHeight();
|
|
51
84
|
}
|
|
52
85
|
});
|
|
53
86
|
</script>
|
|
@@ -58,9 +91,10 @@
|
|
|
58
91
|
--acc5-bgColor: {colorScheme.bgColor};
|
|
59
92
|
--acc5-textColor: {colorScheme.textColor};
|
|
60
93
|
--acc5-triggerColor: {colorScheme.triggerColor};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
94
|
+
--acc5-panelBgColor: {colorScheme.panelBgColor};
|
|
95
|
+
--acc5-IconWidth: {iconWidth};
|
|
96
|
+
--acc5-IconHeight: {iconHeight};
|
|
97
|
+
--acc5-InnerPadding: {innerPadding}
|
|
64
98
|
"
|
|
65
99
|
>
|
|
66
100
|
<button onclick={showPanel}>
|
|
@@ -95,7 +129,6 @@
|
|
|
95
129
|
<style>
|
|
96
130
|
.accordion5 {
|
|
97
131
|
width: 100%;
|
|
98
|
-
max-width: 600px;
|
|
99
132
|
margin: 0 auto;
|
|
100
133
|
border-radius: 0.5rem;
|
|
101
134
|
overflow: hidden;
|
|
@@ -103,7 +136,7 @@
|
|
|
103
136
|
|
|
104
137
|
button {
|
|
105
138
|
width: 100%;
|
|
106
|
-
padding
|
|
139
|
+
padding: var(--acc5-InnerPadding);
|
|
107
140
|
font-size: 1rem;
|
|
108
141
|
cursor: pointer;
|
|
109
142
|
border: none;
|
|
@@ -146,11 +179,12 @@
|
|
|
146
179
|
background-color: var(--acc5-panelBgColor);
|
|
147
180
|
transition: max-height 400ms ease-in-out;
|
|
148
181
|
}
|
|
182
|
+
|
|
149
183
|
.panel-head-icon.open {
|
|
150
184
|
transform: rotate(180deg);
|
|
151
185
|
}
|
|
152
186
|
|
|
153
187
|
.accPanel-inner {
|
|
154
|
-
padding-block: 0.5rem;
|
|
188
|
+
padding-block: 0.5rem;
|
|
155
189
|
}
|
|
156
190
|
</style>
|