tantee-nuxt-commons 0.0.175 → 0.0.176

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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.0.175",
7
+ "version": "0.0.176",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -53,6 +53,7 @@ const module = defineNuxtModule({
53
53
  _nuxt.options.vite.optimizeDeps.include.push("print-js");
54
54
  _nuxt.options.vite.optimizeDeps.include.push("gql-query-builder");
55
55
  _nuxt.options.vite.optimizeDeps.include.push("exif-rotate-js");
56
+ _nuxt.options.vite.optimizeDeps.include.push("localstorage-slim");
56
57
  }
57
58
  });
58
59
 
@@ -203,7 +203,8 @@ defineExpose({
203
203
  reset: ()=>inputRef.value?.reset(),
204
204
  resetValidation : ()=>inputRef.value?.resetValidation(),
205
205
  validate : ()=>inputRef.value?.validate(),
206
- operation
206
+ operation,
207
+ items
207
208
  })
208
209
  </script>
209
210
 
@@ -135,7 +135,7 @@ watch(()=>props.search,()=>{
135
135
  search.value = props.search
136
136
  },{immediate:true})
137
137
 
138
- defineExpose({ reload,operation })
138
+ defineExpose({ reload,operation,items })
139
139
  </script>
140
140
 
141
141
  <template>
@@ -4,6 +4,7 @@ import { useAlert } from "./alert.js";
4
4
  import { buildRequiredInputFields } from "./graphqlOperation.js";
5
5
  import { useGraphqlModelOperation } from "./graphqlModelOperation.js";
6
6
  import pLimit from "p-limit";
7
+ import { arrayWrap } from "../utils/array.js";
7
8
  export function useGraphqlModel(props) {
8
9
  const alert = useAlert();
9
10
  const items = ref([]);
@@ -130,6 +131,8 @@ export function useGraphqlModel(props) {
130
131
  items.value = result.data;
131
132
  itemsLength.value = result.meta.totalItems;
132
133
  }).catch((error) => {
134
+ items.value = [];
135
+ itemsLength.value = 0;
133
136
  alert?.addAlert({ alertType: "error", message: error });
134
137
  }).finally(() => {
135
138
  isLoading.value = false;
@@ -142,8 +145,9 @@ export function useGraphqlModel(props) {
142
145
  } else {
143
146
  isLoading.value = true;
144
147
  operationRead.value?.call(fields.value, props.modelBy).then((result) => {
145
- items.value = result;
148
+ items.value = arrayWrap(result);
146
149
  }).catch((error) => {
150
+ items.value = [];
147
151
  alert?.addAlert({ alertType: "error", message: error });
148
152
  }).finally(() => {
149
153
  isLoading.value = false;
@@ -0,0 +1 @@
1
+ export declare function arrayWrap<T>(value: T | T[] | null | undefined): T[];
@@ -0,0 +1,4 @@
1
+ export function arrayWrap(value) {
2
+ if (value === null || value === void 0) return [];
3
+ return Array.isArray(value) ? value : [value];
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tantee-nuxt-commons",
3
- "version": "0.0.175",
3
+ "version": "0.0.176",
4
4
  "description": "Ramathibodi Nuxt modules for common components",
5
5
  "repository": {
6
6
  "type": "git",