sprintify-ui 0.0.84 → 0.0.85
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/sprintify-ui.es.js +1048 -1043
- package/package.json +1 -1
- package/src/components/BaseDropdown.stories.js +1 -1
- package/src/components/BaseDropdown.vue +39 -6
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@ const Template = (args) => ({
|
|
|
26
26
|
return { args };
|
|
27
27
|
},
|
|
28
28
|
template: `
|
|
29
|
-
<div style="height: 1000px; margin-top:
|
|
29
|
+
<div style="height: 1000px; margin-top: 300px;">
|
|
30
30
|
<div style="height: 70px; overflow: hidden; position: relative; display: inline-block;">
|
|
31
31
|
<BaseDropdown v-bind="args">
|
|
32
32
|
<template #button>
|
|
@@ -93,10 +93,12 @@ function toggle() {
|
|
|
93
93
|
|
|
94
94
|
function open() {
|
|
95
95
|
activate();
|
|
96
|
-
setBoundingBoxes();
|
|
97
96
|
showDropdown.value = true;
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
nextTick(() => {
|
|
98
|
+
setBoundingBoxes();
|
|
99
|
+
disableScroll(dropdown.value);
|
|
100
|
+
emit('open');
|
|
101
|
+
});
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
function close() {
|
|
@@ -151,15 +153,43 @@ function onMouseDown(event: MouseEvent) {
|
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
const placementInternal = computed(() => {
|
|
157
|
+
const tooTallForTop =
|
|
158
|
+
buttonY.value - dropdownHeight.value - props.padding < 0;
|
|
159
|
+
const tooTallForBottom =
|
|
160
|
+
window.innerHeight - buttonY.value - buttonHeight.value - props.padding <
|
|
161
|
+
dropdownHeight.value;
|
|
162
|
+
|
|
163
|
+
if (props.placement == 'top-start' && tooTallForTop) {
|
|
164
|
+
return 'bottom-start';
|
|
165
|
+
}
|
|
166
|
+
if (props.placement == 'top-end' && tooTallForTop) {
|
|
167
|
+
return 'bottom-end';
|
|
168
|
+
}
|
|
169
|
+
if (props.placement == 'bottom-start' && tooTallForBottom) {
|
|
170
|
+
return 'top-start';
|
|
171
|
+
}
|
|
172
|
+
if (props.placement == 'bottom-end' && tooTallForBottom) {
|
|
173
|
+
return 'top-end';
|
|
174
|
+
}
|
|
175
|
+
return props.placement;
|
|
176
|
+
});
|
|
177
|
+
|
|
154
178
|
const dropdownStyles = computed((): StyleValue => {
|
|
155
179
|
let top = buttonY.value;
|
|
156
180
|
|
|
157
|
-
if (
|
|
181
|
+
if (
|
|
182
|
+
placementInternal.value == 'bottom-start' ||
|
|
183
|
+
placementInternal.value == 'bottom-end'
|
|
184
|
+
) {
|
|
158
185
|
top += buttonHeight.value;
|
|
159
186
|
top += props.padding;
|
|
160
187
|
}
|
|
161
188
|
|
|
162
|
-
if (
|
|
189
|
+
if (
|
|
190
|
+
placementInternal.value == 'top-start' ||
|
|
191
|
+
placementInternal.value == 'top-end'
|
|
192
|
+
) {
|
|
163
193
|
top -= dropdownHeight.value;
|
|
164
194
|
top -= props.padding;
|
|
165
195
|
}
|
|
@@ -169,7 +199,10 @@ const dropdownStyles = computed((): StyleValue => {
|
|
|
169
199
|
top: `${top}px`,
|
|
170
200
|
} as any;
|
|
171
201
|
|
|
172
|
-
if (
|
|
202
|
+
if (
|
|
203
|
+
placementInternal.value == 'bottom-end' ||
|
|
204
|
+
placementInternal.value == 'top-end'
|
|
205
|
+
) {
|
|
173
206
|
styles.left = `${
|
|
174
207
|
buttonX.value + buttonWidth.value - dropdownWidth.value
|
|
175
208
|
}px`;
|