classcard-ui 0.2.331 → 0.2.334

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.331",
3
+ "version": "0.2.334",
4
4
  "main": "dist/classcard-ui.common.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -79,8 +79,9 @@ export default {
79
79
 
80
80
  .ql-editor {
81
81
  @apply text-sm text-gray-900;
82
+ max-height: 150px;
82
83
  }
83
84
  .ql-editor.ql-blank::before {
84
- @apply text-gray-500 not-italic;
85
+ @apply not-italic text-gray-500;
85
86
  }
86
87
  </style>
@@ -23,6 +23,8 @@
23
23
  :label="optionLabel"
24
24
  :clearable="clearable"
25
25
  :loading="loading"
26
+ @open="onOpen"
27
+ @close="onClose"
26
28
  >
27
29
  <template #open-indicator="{ attributes }">
28
30
  <span v-bind="attributes">
@@ -92,6 +94,31 @@
92
94
  <p>{{ option[optionLabel] }}</p>
93
95
  </div>
94
96
  </template>
97
+ <template #list-footer>
98
+ <li ref="load" class="loader" v-show="hasNextPage">
99
+ <svg
100
+ class="h-5 w-5 animate-spin text-gray-400"
101
+ xmlns="http://www.w3.org/2000/svg"
102
+ fill="none"
103
+ viewBox="0 0 24 24"
104
+ v-if="loading"
105
+ >
106
+ <circle
107
+ class="opacity-25"
108
+ cx="12"
109
+ cy="12"
110
+ r="10"
111
+ stroke="currentColor"
112
+ stroke-width="4"
113
+ ></circle>
114
+ <path
115
+ class="opacity-75"
116
+ fill="currentColor"
117
+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
118
+ ></path>
119
+ </svg>
120
+ </li>
121
+ </template>
95
122
  </v-select>
96
123
  <p v-if="!isValidate" class="mt-2 text-sm text-red-600">
97
124
  {{ errorMessage }}
@@ -174,6 +201,10 @@ export default {
174
201
  type: Boolean,
175
202
  default: false,
176
203
  },
204
+ hasNextPage: {
205
+ type: Boolean,
206
+ default: false,
207
+ },
177
208
  },
178
209
  computed: {},
179
210
  data() {
@@ -183,27 +214,50 @@ export default {
183
214
  this.optionsSelected && this.optionsSelected.length
184
215
  ? this.optionsSelected
185
216
  : [],
186
- localSearch: "",
217
+ observer: null,
187
218
  };
188
219
  },
189
220
  methods: {
190
221
  fetchOptions(search, loaderSearching) {
191
- this.$emit("getOptions", search, loaderSearching);
192
- this.emitSearch(search);
222
+ this.emitGetOptions(search, loaderSearching);
193
223
  },
194
- emitSearch: debounce(function (search) {
195
- this.$emit("search", search);
196
- }, 500),
224
+ emitGetOptions: debounce(function (search, loaderSearching) {
225
+ this.$emit("getOptions", search, loaderSearching);
226
+ }, 300),
197
227
  setSelectedOptions(params) {
198
228
  this.value = params;
199
229
  this.$emit("onSelectOptions", params);
200
230
  },
231
+ async onOpen() {
232
+ if (this.hasNextPage) {
233
+ await this.$nextTick();
234
+ this.observer.observe(this.$refs.load);
235
+ }
236
+ },
237
+ onClose() {
238
+ this.observer.disconnect();
239
+ },
240
+ async infiniteScroll([{ isIntersecting, target }]) {
241
+ if (isIntersecting) {
242
+ const ul = target.offsetParent;
243
+ const scrollTop = target.offsetParent.scrollTop;
244
+ this.emitLoadNextPage();
245
+ await this.$nextTick();
246
+ ul.scrollTop = scrollTop;
247
+ }
248
+ },
249
+ emitLoadNextPage: debounce(function () {
250
+ this.$emit("loadNextPage");
251
+ }, 300),
201
252
  },
202
253
  watch: {
203
254
  optionsSelected() {
204
255
  this.value = this.optionsSelected;
205
256
  },
206
257
  },
258
+ mounted() {
259
+ this.observer = new IntersectionObserver(this.infiniteScroll);
260
+ },
207
261
  };
208
262
  </script>
209
263
  <style>