@karta.io/utils 1.0.0-alpha.4 → 1.0.0-alpha.5

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/index.cjs CHANGED
@@ -9,6 +9,7 @@ const core = require('@vueuse/core');
9
9
  const vueQuery = require('@tanstack/vue-query');
10
10
  const get = require('lodash/get.js');
11
11
  const has = require('lodash/has.js');
12
+ const union = require('lodash/union.js');
12
13
  const logdown = require('logdown');
13
14
  const dayjs = require('dayjs');
14
15
  const utc = require('dayjs/plugin/utc.js');
@@ -26,6 +27,7 @@ const camelCase__default = /*#__PURE__*/_interopDefaultCompat(camelCase);
26
27
  const snakeCase__default = /*#__PURE__*/_interopDefaultCompat(snakeCase);
27
28
  const get__default = /*#__PURE__*/_interopDefaultCompat(get);
28
29
  const has__default = /*#__PURE__*/_interopDefaultCompat(has);
30
+ const union__default = /*#__PURE__*/_interopDefaultCompat(union);
29
31
  const logdown__default = /*#__PURE__*/_interopDefaultCompat(logdown);
30
32
  const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
31
33
  const utc__default = /*#__PURE__*/_interopDefaultCompat(utc);
@@ -380,12 +382,17 @@ function useAsyncMultiselect({
380
382
  });
381
383
  const search = vue.ref("");
382
384
  const { call, abort } = useAbortController(apiMethod);
383
- const loadWAC = () => call({
384
- page: reactiveData.page,
385
- search: reactiveData.search,
386
- ...reactiveData.selectedValues?.length && { includedIds: reactiveData.selectedValues },
387
- ...reactiveData.params && { ...JSON.parse(reactiveData.params) }
388
- });
385
+ const loadWAC = () => {
386
+ const includedIdsBySelectedValues = reactiveData.selectedValues ?? [];
387
+ const includedIdsByParams = JSON.parse(reactiveData.params)?.includedIds ?? [];
388
+ const includedIds = union__default(includedIdsBySelectedValues, includedIdsByParams);
389
+ return call({
390
+ page: reactiveData.page,
391
+ search: reactiveData.search,
392
+ ...reactiveData.params && { ...JSON.parse(reactiveData.params) },
393
+ ...includedIds.length && { includedIds }
394
+ });
395
+ };
389
396
  const { data, isFetching, isLoading } = vueQuery.useQuery({
390
397
  queryKey: [queryKey, reactiveData],
391
398
  queryFn: loadWAC
package/dist/index.mjs CHANGED
@@ -7,6 +7,7 @@ import { toValue, useDebounceFn, useBreakpoints } from '@vueuse/core';
7
7
  import { useQuery, useQueryClient } from '@tanstack/vue-query';
8
8
  import get from 'lodash/get.js';
9
9
  import has from 'lodash/has.js';
10
+ import union from 'lodash/union.js';
10
11
  import logdown from 'logdown';
11
12
  import dayjs from 'dayjs';
12
13
  import utc from 'dayjs/plugin/utc.js';
@@ -363,12 +364,17 @@ function useAsyncMultiselect({
363
364
  });
364
365
  const search = ref("");
365
366
  const { call, abort } = useAbortController(apiMethod);
366
- const loadWAC = () => call({
367
- page: reactiveData.page,
368
- search: reactiveData.search,
369
- ...reactiveData.selectedValues?.length && { includedIds: reactiveData.selectedValues },
370
- ...reactiveData.params && { ...JSON.parse(reactiveData.params) }
371
- });
367
+ const loadWAC = () => {
368
+ const includedIdsBySelectedValues = reactiveData.selectedValues ?? [];
369
+ const includedIdsByParams = JSON.parse(reactiveData.params)?.includedIds ?? [];
370
+ const includedIds = union(includedIdsBySelectedValues, includedIdsByParams);
371
+ return call({
372
+ page: reactiveData.page,
373
+ search: reactiveData.search,
374
+ ...reactiveData.params && { ...JSON.parse(reactiveData.params) },
375
+ ...includedIds.length && { includedIds }
376
+ });
377
+ };
372
378
  const { data, isFetching, isLoading } = useQuery({
373
379
  queryKey: [queryKey, reactiveData],
374
380
  queryFn: loadWAC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karta.io/utils",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.5",
4
4
  "description": "karta.io utils for admin and application",
5
5
  "author": "Vitaly Blokhin <karambafe@gmail.com>",
6
6
  "homepage": "",
@@ -24,7 +24,7 @@
24
24
  "vue": "3.3.x"
25
25
  },
26
26
  "dependencies": {
27
- "@karta.io/common-data": "^1.0.0-alpha.4",
27
+ "@karta.io/common-data": "^1.0.0-alpha.5",
28
28
  "@tanstack/vue-query": "4.33.1",
29
29
  "@vueuse/core": "10.3.0",
30
30
  "async-validator": "4.2.5",