@webitel/ui-datalist 1.1.13 → 1.1.15

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": "@webitel/ui-datalist",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "Toolkit for building data lists in webitel ui system",
5
5
  "scripts": {
6
6
  "make-all": "npm version patch --git-tag-version false && ( npm run lint:fix || true) && (npm run build:types || true) && npm run utils:publish",
@@ -1,6 +1,6 @@
1
1
  import { refDebounced } from '@vueuse/core';
2
2
  import { StoreDefinition, storeToRefs } from 'pinia';
3
- import { onUnmounted } from 'vue';
3
+ import { onUnmounted, watch } from 'vue';
4
4
 
5
5
  import { useCardAnyFieldEditedWatcher } from './useCardAnyFieldEditedWatcher';
6
6
  import { useCardIsNew } from './useCardIsNew';
@@ -11,8 +11,10 @@ import { useItemCardSaveText } from './useItemCardSaveText';
11
11
 
12
12
  export const useCardComponent = <CardEntity>({
13
13
  useCardStore,
14
+ onLoadErrorHandler,
14
15
  }: {
15
16
  useCardStore: StoreDefinition;
17
+ onLoadErrorHandler?: (err: any) => void;
16
18
  }) => {
17
19
  const cardStore = useCardStore();
18
20
 
@@ -22,7 +24,7 @@ export const useCardComponent = <CardEntity>({
22
24
  validationSchema,
23
25
  isLoading,
24
26
  // isSaving, // todo: use me
25
- // error, // todo: use me
27
+ error,
26
28
  } = storeToRefs(cardStore);
27
29
 
28
30
  const { initialize, saveItem, $reset } = cardStore;
@@ -63,6 +65,10 @@ export const useCardComponent = <CardEntity>({
63
65
 
64
66
  onUnmounted($reset);
65
67
 
68
+ watch(error, (err) => {
69
+ if (onLoadErrorHandler) onLoadErrorHandler(err);
70
+ });
71
+
66
72
  return {
67
73
  // models
68
74
  modelValue,
@@ -70,6 +76,7 @@ export const useCardComponent = <CardEntity>({
70
76
  // state
71
77
  debouncedIsLoading,
72
78
  originalItemInstance,
79
+ error,
73
80
 
74
81
  // computed
75
82
  isNew,
@@ -74,7 +74,7 @@ const restoreLocalSearchValue = (searchMode: string) => {
74
74
  };
75
75
 
76
76
  const hasSearchModes = computed(() => {
77
- return props.searchModeOptions && props.searchModeOptions.length > 0;
77
+ return props.searchModeOptions && props.searchModeOptions.length > 1;
78
78
  });
79
79
 
80
80
  const currentSearchName = computed(() => {
@@ -94,7 +94,9 @@ const inputValue = (value: string) => {
94
94
  name: currentSearchName.value,
95
95
  });
96
96
  }
97
- return;
97
+ if (hasSearchModes.value) {
98
+ searchMode.value = props.searchModeOptions[0].value;
99
+ }
98
100
  }
99
101
  };
100
102
 
@@ -127,12 +129,12 @@ const updateSearchMode = (
127
129
  };
128
130
 
129
131
  const initialize = () => {
130
- if (hasSearchModes.value) {
131
- if (!searchMode.value) {
132
- searchMode.value = props.searchModeOptions[0].value;
133
- }
134
- restoreLocalSearchValue(searchMode.value);
132
+ if (!hasSearchModes.value) return;
133
+
134
+ if (!searchMode.value) {
135
+ searchMode.value = props.searchModeOptions[0].value;
135
136
  }
137
+ restoreLocalSearchValue(searchMode.value);
136
138
  };
137
139
  /**
138
140
  * @description
@@ -154,14 +156,16 @@ watch(
154
156
  const searchModes = [
155
157
  defaultSearchName,
156
158
  ];
157
- if (hasSearchModes.value) {
159
+ if (hasSearchModes.value && !searchMode.value) {
158
160
  searchMode.value =
159
161
  props.searchModeOptions?.map((option) => option.value)[0] || '';
160
162
  }
161
163
 
162
164
  for (const mode of searchModes) {
163
165
  if (hasFilter(mode)) {
164
- searchMode.value = mode;
166
+ if (hasSearchModes.value) {
167
+ searchMode.value = mode;
168
+ }
165
169
  restoreLocalSearchValue(mode);
166
170
  break;
167
171
  }
@@ -1,10 +1,12 @@
1
1
  import { StoreDefinition } from 'pinia';
2
- export declare const useCardComponent: <CardEntity>({ useCardStore, }: {
2
+ export declare const useCardComponent: <CardEntity>({ useCardStore, onLoadErrorHandler, }: {
3
3
  useCardStore: StoreDefinition;
4
+ onLoadErrorHandler?: (err: any) => void;
4
5
  }) => {
5
6
  modelValue: import("vue").ComputedRef<unknown>;
6
7
  debouncedIsLoading: Readonly<import("vue").Ref<any, any>>;
7
8
  originalItemInstance: import("vue").Ref<any, any> & import("vue").ComputedRef<any>;
9
+ error: import("vue").Ref<any, any> & import("vue").ComputedRef<any>;
8
10
  isNew: import("vue").ComputedRef<boolean>;
9
11
  saveText: import("vue").ComputedRef<any>;
10
12
  hasValidationErrors: import("vue").ComputedRef<boolean>;