eco-vue-js 0.8.29 → 0.8.30

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"WClickOutside.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ClickOutside/WClickOutside.vue"],"names":[],"mappings":"AAyEA,iBAAS,cAAc;;yBA4BM,GAAG;;;;;WAUlB,OAAO,IAA6B;EAEjD;AAWD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;iFAQnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAKpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"WClickOutside.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ClickOutside/WClickOutside.vue"],"names":[],"mappings":"AA6EA,iBAAS,cAAc;;yBA4BM,GAAG;;;;;WAUlB,OAAO,IAA6B;EAEjD;AAWD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;iFAQnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAKpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -8,7 +8,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
8
8
  const emit = __emit;
9
9
  const element = ref();
10
10
  const clickListener = (event) => {
11
- if (element.value && event.target instanceof Element && !hasParent(element.value, event.target)) emit("click");
11
+ if (!element.value || !(event.target instanceof Element) || hasParent(element.value, event.target)) return;
12
+ emit("click");
12
13
  };
13
14
  onMounted(() => {
14
15
  if (!isClientSide) return;
@@ -69,7 +69,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
69
69
  };
70
70
  if (newItem) newData.results.splice(index, 1, newItem);
71
71
  else newData.results.splice(index, 1);
72
- setData(newData);
72
+ setData(newData, { index, newItem });
73
73
  };
74
74
  const emitRefetch = () => {
75
75
  emit("refetch");
@@ -1 +1 @@
1
- {"version":3,"file":"WList.vue.d.ts","sourceRoot":"","sources":["../../../src/components/List/WList.vue"],"names":[],"mappings":"AA8SA,OAAO,KAAK,EAAC,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAC,MAAM,SAAS,CAAA;yBAWpF,IAAI,SAAS,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,eACtF,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WA+mBxD,mBAAmB,CAAC;;;gBAvmBpB,MAAM;gBACN,MAAM;oBACF,cAAc,CAAC,IAAI,CAAC;oBACpB,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC;qBACnC,WAAW;6BACH,MAAM;wBACX,MAAM;eACf,aAAa,CAAC,WAAW,CAAC,EAAE;mBACxB,aAAa,CAAC,WAAW,CAAC,EAAE;cACjC,aAAa,CAAC,IAAI,CAAC,EAAE;yBACV,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO;oBAC5B,MAAM;2BACC,MAAM;6BACJ,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,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aAAa,CAAC,IAAI,CAAC,EAAE;yBACV,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO;oBAC5B,MAAM;2BACC,MAAM;6BACJ,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM;oBACvD,OAAO;qBACN,OAAO;mBACT,MAAM;0BACC,cAAc,CAAC,MAAM,CAAC;mBAC7B,OAAO;KA2lBmE,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;;YArDgB,GAAG;;cAniB1B,uBAAuB,SAAS,MAAM,KAAG,IAAI;;;;YA6lBP,OAAO,CAAC,OAAO,WAAW,CAAC;;AA7nBvE,wBA6nB4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -11,8 +11,8 @@ import _sfc_main$6 from './components/HeaderSettings.vue.js';
11
11
  import { filterFields, useFieldConfigMap, getFirstFieldLabel } from './use/useFieldConfigMap.js';
12
12
  import _sfc_main$8 from './components/ListCardFieldNested.vue.js';
13
13
  import _sfc_main$4 from './components/HeaderFieldNested.vue.js';
14
+ import { PAGE_LENGTH } from '../../utils/useDefaultQuery.js';
14
15
 
15
- const PAGE_LENGTH = 24;
16
16
  const _sfc_main = /* @__PURE__ */ defineComponent({
17
17
  __name: "WList",
18
18
  props: {
@@ -102,7 +102,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
102
102
  selected: unref(selected),
103
103
  reverse: unref(reverse),
104
104
  "selected-range": unref(selectedRange),
105
- "page-length": PAGE_LENGTH,
105
+ "page-length": unref(PAGE_LENGTH),
106
106
  count: _ctx.count ?? listCount.value,
107
107
  onSelect: unref(setSelected),
108
108
  onSelectReverse: unref(setSelectedReverse),
@@ -206,12 +206,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
206
206
  default: withCtx(() => [
207
207
  createVNode(_sfc_main$8, {
208
208
  fields: fieldsFiltered.value,
209
- item
209
+ item,
210
+ skeleton,
211
+ mobile: unref(isMobile)
210
212
  }, {
211
213
  default: withCtx((defaultScope) => [
212
214
  (openBlock(), createBlock(resolveDynamicComponent(defaultScope.field.component), {
213
215
  item: defaultScope.item,
214
- readonly: _ctx.readonlyGetter?.(defaultScope.item),
216
+ readonly: _ctx.readonlyGetter?.(defaultScope.item) ?? false,
215
217
  skeleton,
216
218
  mobile: unref(isMobile),
217
219
  class: normalizeClass({
@@ -230,20 +232,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
230
232
  }, null, 40, ["item", "readonly", "skeleton", "mobile", "class", "style", "onUpdate:item", "onDelete:item"]))
231
233
  ]),
232
234
  _: 2
233
- }, 1032, ["fields", "item"])
235
+ }, 1032, ["fields", "item", "skeleton", "mobile"])
234
236
  ]),
235
237
  more: withCtx(() => [
236
238
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menu, (menuItem, menuIndex) => {
237
239
  return openBlock(), createBlock(resolveDynamicComponent(menuItem), {
238
240
  key: menuIndex,
239
241
  item,
240
- readonly: _ctx.readonlyGetter?.(item),
242
+ readonly: _ctx.readonlyGetter?.(item) ?? false,
243
+ "update-item": setter,
244
+ "delete-item": () => {
245
+ setter();
246
+ refetch();
247
+ },
241
248
  "onUpdate:item": setter,
242
249
  "onDelete:item": ($event) => {
243
250
  setter();
244
251
  refetch();
245
252
  }
246
- }, null, 40, ["item", "readonly", "onUpdate:item", "onDelete:item"]);
253
+ }, null, 40, ["item", "readonly", "update-item", "delete-item", "onUpdate:item", "onDelete:item"]);
247
254
  }), 128))
248
255
  ]),
249
256
  _: 2
@@ -253,7 +260,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
253
260
  fn: withCtx(() => [
254
261
  (openBlock(), createBlock(resolveDynamicComponent(_ctx.expansion), {
255
262
  item,
256
- readonly: _ctx.readonlyGetter?.(item),
263
+ readonly: _ctx.readonlyGetter?.(item) ?? false,
257
264
  skeleton,
258
265
  mobile: unref(isMobile),
259
266
  "onUpdate:item": setter,
@@ -268,7 +275,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
268
275
  ]), 1032, ["disabled", "mobile", "card-class", "card-wrapper-class", "has-border", "more-bottom", "allow-open", "align-top"])
269
276
  ]),
270
277
  _: 3
271
- }, 8, ["use-query-fn", "query-params", "skeleton-length", "header-margin", "allow-select", "selected", "reverse", "selected-range", "count", "onSelect", "onSelectReverse", "onSelectRange"]);
278
+ }, 8, ["use-query-fn", "query-params", "skeleton-length", "header-margin", "allow-select", "selected", "reverse", "selected-range", "page-length", "count", "onSelect", "onSelectReverse", "onSelectRange"]);
272
279
  };
273
280
  }
274
281
  });
@@ -4,6 +4,8 @@ declare const _default: <Data extends DefaultData, QueryParams>(__VLS_props: Non
4
4
  fields: ListFields<Data, QueryParams>;
5
5
  item: Data;
6
6
  nested?: boolean;
7
+ skeleton: boolean;
8
+ mobile: boolean;
7
9
  }> & import('vue').PublicProps;
8
10
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
9
11
  attrs: any;
@@ -1 +1 @@
1
- {"version":3,"file":"ListCardFieldNested.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/ListCardFieldNested.vue"],"names":[],"mappings":"AAmFA,OAAO,KAAK,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,UAAU,CAAA;yBAKlC,IAAI,SAAS,WAAW,EAAE,WAAW,eACxC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WAmIxD,mBAAmB,CAAC;gBA/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OAAO;KA6HsE,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;iBA1HF,CAAC,KAAK,EAAE;YAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAAC,IAAI,EAAE,IAAI,CAAA;SAAC,KAAK,IAAI;;iBAAlE,CAAC,KAAK,EAAE;YAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAAC,IAAI,EAAE,IAAI,CAAA;SAAC,KAAK,IAAI;;UA4HpE,EAAE;;;;YAGiC,OAAO,CAAC,OAAO,WAAW,CAAC;;AA/IvE,wBA+I4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -8,7 +8,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
8
8
  props: {
9
9
  fields: {},
10
10
  item: {},
11
- nested: { type: Boolean }
11
+ nested: { type: Boolean },
12
+ skeleton: { type: Boolean },
13
+ mobile: { type: Boolean }
12
14
  },
13
15
  setup(__props) {
14
16
  return (_ctx, _cache) => {
@@ -21,7 +23,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
21
23
  "keyArray" in field || "getterArray" in field ? (openBlock(), createBlock(resolveDynamicComponent(field.componentArray ?? "div"), mergeProps({
22
24
  key: 0,
23
25
  ref_for: true
24
- }, field.componentArray ? { item: _ctx.item } : void 0, {
26
+ }, field.componentArray ? { item: _ctx.item, skeleton: _ctx.skeleton, mobile: _ctx.mobile } : void 0, {
25
27
  class: field.cssClassArray
26
28
  }), {
27
29
  default: withCtx(() => [
@@ -29,7 +31,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
29
31
  items: "keyArray" in field ? _ctx.item[field.keyArray] : field.getterArray(_ctx.item)
30
32
  }, {
31
33
  default: withCtx(({ inner, index, last, first }) => [
32
- (openBlock(), createBlock(resolveDynamicComponent(field.componentItem ?? _sfc_main$2), mergeProps({ ref_for: true }, field.componentItem ? { item: _ctx.item, index, last, first } : void 0), {
34
+ (openBlock(), createBlock(resolveDynamicComponent(field.componentItem ?? _sfc_main$2), mergeProps({ ref_for: true }, field.componentItem ? { item: _ctx.item, skeleton: _ctx.skeleton, mobile: _ctx.mobile, index, last, first } : void 0), {
33
35
  default: withCtx(() => [
34
36
  createElementVNode("div", {
35
37
  class: normalizeClass(["flex", field.cssClass])
@@ -37,13 +39,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
37
39
  createVNode(_component_ListCardFieldNested, {
38
40
  fields: field.fields,
39
41
  item: inner,
42
+ skeleton: _ctx.skeleton,
43
+ mobile: _ctx.mobile,
40
44
  nested: ""
41
45
  }, {
42
46
  default: withCtx((defaultScope) => [
43
47
  renderSlot(_ctx.$slots, "default", mergeProps({ ref_for: true }, defaultScope))
44
48
  ]),
45
49
  _: 2
46
- }, 1032, ["fields", "item"])
50
+ }, 1032, ["fields", "item", "skeleton", "mobile"])
47
51
  ], 2)
48
52
  ]),
49
53
  _: 2
@@ -60,13 +64,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
60
64
  createVNode(_component_ListCardFieldNested, {
61
65
  fields: field.fields,
62
66
  item: "keyEntity" in field ? _ctx.item[field.keyEntity] : "getterEntity" in field ? field.getterEntity(_ctx.item) : _ctx.item,
67
+ skeleton: _ctx.skeleton,
68
+ mobile: _ctx.mobile,
63
69
  nested: ""
64
70
  }, {
65
71
  default: withCtx((defaultScope) => [
66
72
  renderSlot(_ctx.$slots, "default", mergeProps({ ref_for: true }, defaultScope))
67
73
  ]),
68
74
  _: 2
69
- }, 1032, ["fields", "item"])
75
+ }, 1032, ["fields", "item", "skeleton", "mobile"])
70
76
  ], 2))
71
77
  ], 64)) : renderSlot(_ctx.$slots, "default", {
72
78
  key: 1,
@@ -1,18 +1,22 @@
1
1
  import { Component, Raw } from 'vue';
2
2
  export type FieldComponent<Data> = Component<{
3
3
  item: Data;
4
- skeleton?: boolean;
5
- readonly?: boolean;
6
- mobile?: boolean;
4
+ skeleton: boolean;
5
+ readonly: boolean;
6
+ mobile: boolean;
7
+ }>;
8
+ export type FieldComponentNested<Data> = Component<{
9
+ item: Data;
10
+ skeleton: boolean;
11
+ mobile: boolean;
7
12
  }>;
8
13
  export type FieldComponentItem<Data> = Component<{
9
14
  item: Data;
10
- skeleton?: boolean;
11
- readonly?: boolean;
12
- mobile?: boolean;
13
- index?: number;
14
- first?: boolean;
15
- last?: boolean;
15
+ skeleton: boolean;
16
+ mobile: boolean;
17
+ index: number;
18
+ first: boolean;
19
+ last: boolean;
16
20
  }>;
17
21
  export type ListField<Data, QueryParams = unknown> = {
18
22
  component: Raw<FieldComponent<Data>>;
@@ -50,7 +54,7 @@ type FieldNestedArray<Data, QueryParams = unknown, Key extends keyof PickByType<
50
54
  export interface ListFieldNestedArray<Data, QueryParams = unknown> extends FieldNestedArray<Data, QueryParams> {
51
55
  cssClass?: string;
52
56
  cssClassArray?: string;
53
- componentArray?: Raw<FieldComponent<Data>>;
57
+ componentArray?: Raw<FieldComponentNested<Data>>;
54
58
  }
55
59
  type FieldNestedArrayGetter<Data, QueryParams = unknown, Inner = unknown> = {
56
60
  getterArray: (data: Data) => Inner[];
@@ -60,17 +64,19 @@ type FieldNestedArrayGetter<Data, QueryParams = unknown, Inner = unknown> = {
60
64
  export interface ListFieldNestedArrayGetter<Data, QueryParams = unknown, Inner = unknown> extends FieldNestedArrayGetter<Data, QueryParams, Inner> {
61
65
  cssClass?: string;
62
66
  cssClassArray?: string;
63
- componentArray?: Raw<FieldComponent<Data>>;
67
+ componentArray?: Raw<FieldComponentNested<Data>>;
64
68
  }
65
69
  export type ListFields<Data, QueryParams = unknown> = (ListField<Data, QueryParams> | ListFieldNested<Data, QueryParams> | ListFieldNestedEntity<Data, QueryParams> | ListFieldNestedEntityGetter<Data, QueryParams> | ListFieldNestedArray<Data, QueryParams> | ListFieldNestedArrayGetter<Data, QueryParams>)[];
66
70
  export type MenuComponent<Data> = Component<{
67
71
  item: Data;
68
- readonly?: boolean;
72
+ readonly: boolean;
73
+ updateItem: (newItem?: Data | undefined) => void;
74
+ deleteItem: () => void;
69
75
  }>;
70
76
  export type BulkComponent<QueryParams> = Component<{
71
77
  queryParamsGetter: () => QueryParams;
72
78
  selectionCount: number;
73
- disableMessage?: string;
79
+ disableMessage: string | undefined;
74
80
  }>;
75
81
  export type FieldConfig = {
76
82
  width: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/List/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAE,GAAG,EAAC,MAAM,KAAK,CAAA;AAEvC,MAAM,MAAM,cAAc,CAAC,IAAI,IAAI,SAAS,CAAC;IAC3C,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAC,CAAA;AAEF,MAAM,MAAM,kBAAkB,CAAC,IAAI,IAAI,SAAS,CAAC;IAC/C,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAC,CAAA;AAEF,MAAM,MAAM,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,IAAI;IACnD,SAAS,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;IACpC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM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,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAA"}
package/dist/main.js CHANGED
@@ -83,7 +83,7 @@ export { SemanticType } from './utils/SemanticType.js';
83
83
  export { HorizontalAlign } from './utils/HorizontalAlign.js';
84
84
  export { Month, WeekDay, addDay, addMonth, addYear, dateFormat, dateFormatter, dateRegexp, dateToQueryString, datetimeFormat, durationHumanize, getDurationRound, getStartOfDay, getStartOfMonth, getStartOfNextDay, getStartOfWeek, isSameDate, isSameMonth, isSameYear, monthShortFormatter, parseDate, timeFormat, weekdayShortFormatter } from './utils/dateTime.js';
85
85
  export { getIsMobile, getIsTouchDevice } from './utils/mobile.js';
86
- export { useDefaultQuery } from './utils/useDefaultQuery.js';
86
+ export { PAGE_LENGTH, makeQueryPaginated, useDefaultQuery } from './utils/useDefaultQuery.js';
87
87
  export { paginatedResponseUpdater, useQueryUpdater } from './utils/useQueryUpdater.js';
88
88
  export { useCopy } from './utils/useCopy.js';
89
89
  export { debounce, genId, get, getAllScrollParents, getDefaultFieldConfigMap, getScrollParent, hasParent, isClientSide, isEqualArr, isEqualObj, isId, isIndex, isPage, numberCompactFormatter, numberFormatter, parseId, parseIndex, percentCompactFormatter, set, throttle } from './utils/utils.js';
@@ -0,0 +1,6 @@
1
+ declare module '@tanstack/query-core' {
2
+ interface SetDataOptions {
3
+ index?: number
4
+ newItem?: unknown
5
+ }
6
+ }
@@ -7,5 +7,9 @@ export declare const useDefaultQuery: <TQueryFnData = unknown, TData = TQueryFnD
7
7
  }>, TData, TQueryFnData, TQueryKey>, queryClient?: QueryClient | undefined) => UseQueryReturnType<TData, ApiError> & {
8
8
  setData: (updater: TQueryFnData, options?: Params[2]) => ReturnType<QueryClient["setQueriesData"]>;
9
9
  };
10
+ export declare const PAGE_LENGTH = 24;
11
+ export declare const makeQueryPaginated: <Data, QueryParams extends {
12
+ page?: number;
13
+ }>(key: string, getter: (queryParams: QueryParams) => Data[], setter?: (data: Data[]) => void, pageLength?: number) => UseQueryPaginated<Data, QueryParams>;
10
14
  export {};
11
15
  //# sourceMappingURL=useDefaultQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDefaultQuery.d.ts","sourceRoot":"","sources":["../../src/utils/useDefaultQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AACtH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAA;AAEnC,KAAK,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAEvD,eAAO,MAAM,eAAe,GAC1B,YAAY,YACZ,KAAK,iBACL,SAAS,SAAS,QAAQ;;;+EAEwD,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG;IACtH,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAA;CAUrG,CAAA"}
1
+ {"version":3,"file":"useDefaultQuery.d.ts","sourceRoot":"","sources":["../../src/utils/useDefaultQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AACtH,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAA;AAG9B,KAAK,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAEvD,eAAO,MAAM,eAAe,GAC1B,YAAY,YACZ,KAAK,iBACL,SAAS,SAAS,QAAQ;;;+EAEwD,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG;IACtH,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAA;CAUrG,CAAA;AAED,eAAO,MAAM,WAAW,KAAK,CAAA;AAE7B,eAAO,MAAM,kBAAkB,GAAI,IAAI,EAAE,WAAW,SAAS;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAC,OAAO,MAAM,UAAU,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,0BAA6B,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAsDvO,CAAA"}
@@ -1,4 +1,6 @@
1
1
  import { useQueryClient, useQuery } from '@tanstack/vue-query';
2
+ import { ApiError } from './api.js';
3
+ import { unref } from 'vue';
2
4
 
3
5
  const useDefaultQuery = (...args) => {
4
6
  const queryClient = args[1] ?? useQueryClient();
@@ -8,5 +10,52 @@ const useDefaultQuery = (...args) => {
8
10
  setData
9
11
  };
10
12
  };
13
+ const PAGE_LENGTH = 24;
14
+ const makeQueryPaginated = (key, getter, setter, pageLength = PAGE_LENGTH) => {
15
+ return (queryParams, options = {}) => {
16
+ const query = useDefaultQuery({
17
+ queryKey: [key, queryParams],
18
+ queryFn: () => {
19
+ return new Promise((resolve, reject) => {
20
+ const currentList = getter(unref(queryParams));
21
+ const current = Math.max(unref(queryParams).page ?? 1, 1);
22
+ const pages_count = Math.floor(currentList.length / pageLength) + 1;
23
+ if (current > pages_count) reject(new ApiError({ status: 404 }));
24
+ else resolve({
25
+ count: currentList.length,
26
+ pages_count,
27
+ current,
28
+ next: pages_count > current ? current + 1 : null,
29
+ previous: current !== 1 ? current - 1 : null,
30
+ results: currentList.slice(pageLength * (current - 1), pageLength * current)
31
+ });
32
+ });
33
+ },
34
+ ...options
35
+ });
36
+ return {
37
+ ...query,
38
+ setData: (data, options2) => {
39
+ if (setter && unref(options2)?.index !== void 0) {
40
+ const index = unref(unref(options2)?.index);
41
+ if (index !== void 0) {
42
+ const newList = getter({}).slice();
43
+ const oldItem = query.data.value?.results[index];
44
+ if (oldItem !== void 0) {
45
+ const itemIndex = newList.findIndex((item) => item.id === oldItem.id);
46
+ const newItem = unref(unref(options2)?.newItem);
47
+ if (index !== -1) {
48
+ if (newItem === void 0) newList.splice(itemIndex, 1);
49
+ else newList.splice(itemIndex, 1, newItem);
50
+ setter(newList);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ return query.setData(data, options2);
56
+ }
57
+ };
58
+ };
59
+ };
11
60
 
12
- export { useDefaultQuery };
61
+ export { PAGE_LENGTH, makeQueryPaginated, useDefaultQuery };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/rsmple/eco-vue-js.git"
6
6
  },
7
- "version": "0.8.29",
7
+ "version": "0.8.30",
8
8
  "scripts": {
9
9
  "dev": "vite",
10
10
  "build": "run-p type-check build-only",