@94ai/nf-search-form 3.2.40 → 3.2.44

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.
@@ -472,7 +472,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
472
472
  columnCheckDrawer: import("vue-demi").Ref<any>;
473
473
  configNfSearchItemVisibleDialog: import("vue-demi").Ref<boolean>;
474
474
  syncCookiesToSearchFormItemOptions: (readCached?: boolean) => void;
475
- onResize: () => void;
475
+ onResize: (params?: Record<string, any>) => void;
476
476
  visibleChange: () => void;
477
477
  }, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
478
478
  onChange: (event: Record<string, any>) => void;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="nf-search-form">
2
+ <div class="nf-search-form" ref="topDom">
3
3
  <nf-form ref="nfSearchFormRef"
4
4
  :model="nfSearchFormModel"
5
5
  :inline="inline"
@@ -273,6 +273,7 @@ export default defineComponent({
273
273
  import SearchFormItem from './nf-search-form-item.vue'
274
274
  import ColumnCheckDialog from './nf-column-check-dialog.vue'
275
275
  import ColumnCheckDrawer from './nf-column-check-drawer.vue'
276
+ import ResizeObserver from 'resize-observer-polyfill';
276
277
 
277
278
  import {
278
279
  createUniqueString,
@@ -286,6 +287,7 @@ import {
286
287
  watch,
287
288
  onBeforeMount,
288
289
  onMounted,
290
+ onBeforeUnmount,
289
291
  onUnmounted,
290
292
  nextTick
291
293
  } from 'vue-demi'
@@ -814,19 +816,27 @@ onBeforeMount(() => {
814
816
  const isCollapseChange = async (val: boolean) => {
815
817
  emit('isCollapseChange', val)
816
818
  await nextTick()
817
- onResize()
819
+ refreshLabel()
818
820
  }
819
821
 
820
-
821
- const onResize = () => {
822
+ const domWidth = ref()
823
+ const topDom = ref()
824
+ const refreshLabel = () => {
822
825
  if (props.btnModel === 'inline' && !props.btnBoxLabel && props.labelPosition === 'top') {
823
826
  if (nfSearchFormRef.value.$el.getBoundingClientRect().left === defaultButtonSlot.value.$el.getBoundingClientRect().left) {
824
827
  showBtnBoxLabel.value = ''
825
828
  } else {
826
- showBtnBoxLabel.value = '...'
829
+ showBtnBoxLabel.value = '.'
827
830
  }
828
831
  }
829
832
  }
833
+ const onResize = (params: Record<string, any> = {}) => {
834
+ const { width } = (params?.[0].contentRect || {})
835
+ if (width && domWidth.value && width === domWidth.value) {
836
+ return
837
+ }
838
+ refreshLabel()
839
+ }
830
840
 
831
841
  const calcColumns = () => {
832
842
  if (props.columns) {
@@ -846,20 +856,18 @@ const calcColumns = () => {
846
856
  newColumns.value = count
847
857
  }
848
858
 
849
- const debounceResize = debounce(onResize, 100, false)
850
- const debounceCalcColumns = debounce(calcColumns, 100, false)
851
-
859
+ const observer = ref()
852
860
  onMounted(async () => {
853
- window.addEventListener('resize', debounceResize)
854
- window.addEventListener('resize', debounceCalcColumns)
855
861
  await nextTick()
856
- onResize()
857
862
  calcColumns()
863
+ await nextTick()
864
+ observer.value = new ResizeObserver(onResize)
865
+ observer.value.observe(topDom.value, { box: "border-box" });
866
+ domWidth.value = topDom.value.offsetWidth;
858
867
  })
859
868
 
860
- onUnmounted(() => {
861
- window.removeEventListener('resize', debounceResize)
862
- window.removeEventListener('resize', debounceCalcColumns)
869
+ onBeforeUnmount(() => {
870
+ observer.value?.unobserve(topDom.value)
863
871
  })
864
872
 
865
873
  /**
@@ -911,7 +919,7 @@ const hiddenNfSearchFormItemOptionField = async (prop) => {
911
919
  syncCookiesToSearchFormItemOptions()
912
920
  refreshNfSearchFormModel()
913
921
  await nextTick()
914
- onResize()
922
+ refreshLabel()
915
923
  }
916
924
  }
917
925
 
@@ -952,7 +960,7 @@ const columnCheckConfirm = async (cb, error) => {
952
960
  syncCookiesToSearchFormItemOptions()
953
961
  refreshNfSearchFormModel()
954
962
  await nextTick()
955
- onResize()
963
+ refreshLabel()
956
964
  cb()
957
965
  } catch (e) {
958
966
  error()
@@ -969,7 +977,7 @@ const nfSearchFormItemOptionFieldsSave = async (value) => {
969
977
  syncCookiesToSearchFormItemOptions()
970
978
  refreshNfSearchFormModel()
971
979
  await nextTick()
972
- onResize()
980
+ refreshLabel()
973
981
  }
974
982
 
975
983
  defineExpose({
@@ -1046,7 +1054,7 @@ defineExpose({
1046
1054
  */
1047
1055
  syncCookiesToSearchFormItemOptions,
1048
1056
  onResize,
1049
- visibleChange: onResize
1057
+ visibleChange: refreshLabel
1050
1058
  })
1051
1059
 
1052
1060
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-search-form",
3
- "version": "3.2.40",
3
+ "version": "3.2.44",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,20 +14,21 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-action": "^3.2.40",
18
- "@94ai/nf-double-half-year": "^3.2.40",
19
- "@94ai/nf-double-quarter": "^3.2.40",
20
- "@94ai/nf-double-week": "^3.2.40",
21
- "@94ai/nf-double-year": "^3.2.40",
22
- "@94ai/nf-drawer": "^3.2.40",
23
- "@94ai/nf-form": "^3.2.40",
24
- "@94ai/nf-form-item": "^3.2.40",
25
- "@94ai/nf-half-year-picker": "^3.2.40",
26
- "@94ai/nf-message": "^3.2.40",
27
- "@94ai/nf-quarter-picker": "^3.2.40",
28
- "@94ai/nf-select-transfer": "^3.2.40",
29
- "@94ai/nf-theme-chalk": "^3.2.40",
30
- "@94ai/nf-virtual-select": "^3.2.40",
17
+ "@94ai/nf-action": "^3.2.44",
18
+ "@94ai/nf-double-half-year": "^3.2.44",
19
+ "@94ai/nf-double-quarter": "^3.2.44",
20
+ "@94ai/nf-double-week": "^3.2.44",
21
+ "@94ai/nf-double-year": "^3.2.44",
22
+ "@94ai/nf-drawer": "^3.2.44",
23
+ "@94ai/nf-form": "^3.2.44",
24
+ "@94ai/nf-form-item": "^3.2.44",
25
+ "@94ai/nf-half-year-picker": "^3.2.44",
26
+ "@94ai/nf-message": "^3.2.44",
27
+ "@94ai/nf-quarter-picker": "^3.2.44",
28
+ "@94ai/nf-select-transfer": "^3.2.44",
29
+ "@94ai/nf-theme-chalk": "^3.2.44",
30
+ "@94ai/nf-virtual-select": "^3.2.44",
31
+ "resize-observer-polyfill": "^1.5.1",
31
32
  "vue-cookies": "^1.8.3",
32
33
  "vue-demi": "^0.14.5",
33
34
  "vuedraggable": "^2.24.3"
@@ -45,5 +46,5 @@
45
46
  "types": "lib/index.d.ts",
46
47
  "main": "lib/nf-search-form.cjs.js",
47
48
  "module": "lib/nf-search-form.esm-bundler.js",
48
- "gitHead": "e25ee874298743417519987f8c773aeb4a35b8d8"
49
+ "gitHead": "baed79e5f2059e6d9f8151a0e62c63d92e3d0ef0"
49
50
  }