classcard-ui 0.2.1488 → 0.2.1489

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": "classcard-ui",
3
- "version": "0.2.1488",
3
+ "version": "0.2.1489",
4
4
  "main": "dist/classcard-ui.umd.min.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
package/src/.DS_Store ADDED
Binary file
@@ -14,7 +14,7 @@
14
14
  <!-- asterisk sign to render if field is required -->
15
15
  <p v-if="isRequired" class="ml-1 text-red-600">*</p>
16
16
  </div>
17
- <div class="relative mt-1">
17
+ <div class="relative mt-1" ref="inputContainer">
18
18
  <div class="relative">
19
19
  <input
20
20
  type="text"
@@ -98,7 +98,10 @@
98
98
  -->
99
99
  <div
100
100
  v-if="showDropDown"
101
- class="absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
101
+ :class="[
102
+ shouldOpenAbove ? 'bottom-full mb-1' : 'top-full mt-1',
103
+ 'absolute z-10 max-h-60 w-full',
104
+ ]"
102
105
  >
103
106
  <ul
104
107
  tabindex="-1"
@@ -106,6 +109,7 @@
106
109
  aria-labelledby="listbox-label"
107
110
  aria-activedescendant="listbox-option-3"
108
111
  v-if="options.length > 0"
112
+ class="max-h-60 overflow-auto overscroll-contain rounded-md bg-white py-1 text-base ring-1 ring-black ring-opacity-5 shadow-lg focus:outline-none sm:text-sm"
109
113
  >
110
114
  <!--
111
115
  Select option, manage highlight styles based on mouseenter/mouseleave and keyboard navigation.
@@ -247,9 +251,11 @@
247
251
  </template>
248
252
  </li>
249
253
  </span>
250
-
251
254
  </ul>
252
- <p v-else class="text-center">
255
+ <p
256
+ v-else
257
+ class="rounded-md bg-white py-2 text-center text-sm ring-1 ring-black ring-opacity-5 shadow-lg"
258
+ >
253
259
  No match found. Try a different search.
254
260
  </p>
255
261
  </div>
@@ -304,9 +310,24 @@ export default {
304
310
  return {
305
311
  showDropDown: false,
306
312
  inputValue: "",
313
+ shouldOpenAbove: false,
307
314
  };
308
315
  },
309
316
  methods: {
317
+ updateDropdownPlacement() {
318
+ if (!this.$refs.inputContainer) {
319
+ this.shouldOpenAbove = false;
320
+ return;
321
+ }
322
+
323
+ const rect = this.$refs.inputContainer.getBoundingClientRect();
324
+ const dropdownMaxHeight = 240; // max height of the dropdown in pixels - max-h-60
325
+ const bottomSpace = window.innerHeight - rect.bottom;
326
+ const topSpace = rect.top;
327
+
328
+ this.shouldOpenAbove =
329
+ bottomSpace < dropdownMaxHeight && topSpace > bottomSpace;
330
+ },
310
331
  handleCrossClick(event) {
311
332
  event.preventDefault();
312
333
  this.$emit("hide-grouped-select-dropdown");
@@ -352,6 +373,11 @@ export default {
352
373
  value(newValue) {
353
374
  this.inputValue = newValue.label;
354
375
  },
376
+ showDropDown(newValue) {
377
+ if (newValue) {
378
+ this.$nextTick(this.updateDropdownPlacement);
379
+ }
380
+ },
355
381
  },
356
382
  mounted() {
357
383
  this.inputValue = this.value.label;