sprintify-ui 0.0.84 → 0.0.86

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.0.84",
3
+ "version": "0.0.86",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -95,7 +95,7 @@
95
95
  <slot
96
96
  name="option"
97
97
  :option="option.option"
98
- :selected="isSelected(option)"
98
+ :selected="computed(() => isSelected(option)).value"
99
99
  :active="optionActive && optionActive.value == option.value"
100
100
  >
101
101
  <div
@@ -152,7 +152,7 @@
152
152
 
153
153
  <script lang="ts" setup>
154
154
  import { get } from 'lodash';
155
- import { PropType, Ref, ComputedRef } from 'vue';
155
+ import { PropType, Ref, ComputedRef, computed } from 'vue';
156
156
  import { NormalizedOption, Option } from '@/types';
157
157
  import { useInfiniteScroll } from '@vueuse/core';
158
158
  import BaseSkeleton from '@/components/BaseSkeleton.vue';
@@ -26,7 +26,7 @@ const Template = (args) => ({
26
26
  return { args };
27
27
  },
28
28
  template: `
29
- <div style="height: 1000px; margin-top: 100px;">
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
- disableScroll(dropdown.value);
99
- emit('open');
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 (props.placement == 'bottom-start' || props.placement == 'bottom-end') {
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 (props.placement == 'top-start' || props.placement == 'top-end') {
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 (props.placement == 'bottom-end' || props.placement == 'top-end') {
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`;