@tmagic/form 1.2.4 → 1.2.6

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,5 +1,5 @@
1
1
  {
2
- "version": "1.2.4",
2
+ "version": "1.2.6",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -36,8 +36,8 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@element-plus/icons-vue": "^2.0.9",
39
- "@tmagic/design": "1.2.4",
40
- "@tmagic/utils": "1.2.4",
39
+ "@tmagic/design": "1.2.6",
40
+ "@tmagic/utils": "1.2.6",
41
41
  "lodash-es": "^4.17.21",
42
42
  "sortablejs": "^1.14.0",
43
43
  "vue": "^3.2.37"
@@ -26,7 +26,7 @@
26
26
  </template>
27
27
 
28
28
  <script lang="ts" setup name="MFormSelect">
29
- import { inject, nextTick, onBeforeMount, onMounted, Ref, ref, watchEffect } from 'vue';
29
+ import { inject, onBeforeMount, Ref, ref, watch, watchEffect } from 'vue';
30
30
 
31
31
  import { TMagicSelect } from '@tmagic/design';
32
32
 
@@ -331,26 +331,36 @@ if (typeof props.config.options === 'function') {
331
331
  });
332
332
  }
333
333
 
334
- props.config.remote &&
335
- onMounted(async () => {
336
- await nextTick();
337
- tMagicSelect.value?.scrollbarWrap?.addEventListener('scroll', async (e: Event) => {
338
- const el = e.currentTarget as HTMLDivElement;
339
- if (moreLoadingVisible.value) {
334
+ if (props.config.remote) {
335
+ const unWacth = watch(
336
+ () => tMagicSelect.value?.scrollbarWrap,
337
+ (scrollbarWrap) => {
338
+ if (!scrollbarWrap) {
340
339
  return;
341
340
  }
342
- if (el.scrollHeight - el.clientHeight - el.scrollTop > 1) {
343
- return;
344
- }
345
- if (total.value <= options.value.length) {
346
- return;
347
- }
348
- moreLoadingVisible.value = true;
349
- pgIndex.value += 1;
350
- options.value = await getOptions();
351
- moreLoadingVisible.value = false;
352
- });
353
- });
341
+ scrollbarWrap.addEventListener('scroll', async (e: Event) => {
342
+ const el = e.currentTarget as HTMLDivElement;
343
+ if (moreLoadingVisible.value) {
344
+ return;
345
+ }
346
+ if (el.scrollHeight - el.clientHeight - el.scrollTop > 1) {
347
+ return;
348
+ }
349
+ if (total.value <= options.value.length) {
350
+ return;
351
+ }
352
+ moreLoadingVisible.value = true;
353
+ pgIndex.value += 1;
354
+ options.value = await getOptions();
355
+ moreLoadingVisible.value = false;
356
+ });
357
+ unWacth();
358
+ },
359
+ {
360
+ immediate: true,
361
+ },
362
+ );
363
+ }
354
364
 
355
365
  const popperClass = mForm?.popperClass;
356
366