@coyalabs/bts-style 1.1.12545 → 1.1.125456
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/Components/Dropdown.svelte +41 -20
- package/package.json +1 -1
|
@@ -64,9 +64,27 @@
|
|
|
64
64
|
* @type {HTMLDivElement}
|
|
65
65
|
*/
|
|
66
66
|
let dropdownRef;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @type {HTMLDivElement}
|
|
70
|
+
*/
|
|
71
|
+
let buttonRef;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @type {{top: number, left: number, width: number}}
|
|
75
|
+
*/
|
|
76
|
+
let menuPosition = { top: 0, left: 0, width: 0 };
|
|
67
77
|
|
|
68
78
|
function toggleDropdown() {
|
|
69
79
|
isOpen = !isOpen;
|
|
80
|
+
if (isOpen && buttonRef) {
|
|
81
|
+
const rect = buttonRef.getBoundingClientRect();
|
|
82
|
+
menuPosition = {
|
|
83
|
+
top: rect.bottom + 4,
|
|
84
|
+
left: rect.left,
|
|
85
|
+
width: rect.width
|
|
86
|
+
};
|
|
87
|
+
}
|
|
70
88
|
}
|
|
71
89
|
|
|
72
90
|
/**
|
|
@@ -94,23 +112,29 @@
|
|
|
94
112
|
<svelte:window on:click={handleClickOutside} />
|
|
95
113
|
|
|
96
114
|
<div class="dropdown-container" bind:this={dropdownRef} style="width: {width};">
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
<div bind:this={buttonRef}>
|
|
116
|
+
<Button
|
|
117
|
+
{theme}
|
|
118
|
+
{icon}
|
|
119
|
+
actionIcon={icons.icon_expand}
|
|
120
|
+
actionIconSize="12px"
|
|
121
|
+
actionIconRotation={isOpen ? 180 : 0}
|
|
122
|
+
{borderRadiusTopLeft}
|
|
123
|
+
{borderRadiusTopRight}
|
|
124
|
+
{borderRadiusBottomLeft}
|
|
125
|
+
{borderRadiusBottomRight}
|
|
126
|
+
on:click={toggleDropdown}
|
|
127
|
+
>
|
|
128
|
+
<span class="button-label">{displayLabel}</span>
|
|
129
|
+
</Button>
|
|
130
|
+
</div>
|
|
111
131
|
|
|
112
132
|
{#if isOpen}
|
|
113
|
-
<div
|
|
133
|
+
<div
|
|
134
|
+
class="dropdown-menu"
|
|
135
|
+
transition:slide={{ duration: 150 }}
|
|
136
|
+
style="top: {menuPosition.top}px; left: {menuPosition.left}px; width: {menuPosition.width}px;"
|
|
137
|
+
>
|
|
114
138
|
<ContextMenu items={options} selectedValue={value} onSelect={selectOption} />
|
|
115
139
|
</div>
|
|
116
140
|
{/if}
|
|
@@ -134,10 +158,7 @@
|
|
|
134
158
|
}
|
|
135
159
|
|
|
136
160
|
.dropdown-menu {
|
|
137
|
-
position:
|
|
138
|
-
|
|
139
|
-
left: 0;
|
|
140
|
-
right: 0;
|
|
141
|
-
z-index: 1000;
|
|
161
|
+
position: fixed;
|
|
162
|
+
z-index: 10000;
|
|
142
163
|
}
|
|
143
164
|
</style>
|