@xy-planning-network/trees 0.6.2-rc-1 → 0.6.2-rc-3

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/trees.es.js CHANGED
@@ -1,49 +1,4 @@
1
- import { ref, cloneVNode, h, inject, provide, watchEffect, defineComponent, onUnmounted, Teleport, reactive, onUpdated, computed, unref, onMounted, nextTick, toRaw, watch, openBlock, createBlock, createVNode, withCtx, Transition, createElementVNode, createElementBlock, Fragment, renderList, normalizeClass, toDisplayString, createCommentVNode, renderSlot, resolveDynamicComponent, mergeProps, createTextVNode, normalizeProps, useAttrs, shallowRef, withModifiers, TransitionGroup, withDirectives, vShow, normalizeStyle, getCurrentInstance, vModelText, resolveComponent, Comment as Comment$1, Text, useSlots } from "vue";
2
- function useSpinnerDisplay() {
3
- const idx = ref(0);
4
- const loading = ref(false);
5
- const maxIdx = ref(0);
6
- const messages = ref([]);
7
- const msg = ref("");
8
- const showMsg = ref(false);
9
- const show = (spinMessages = []) => {
10
- if (spinMessages) {
11
- messages.value = spinMessages;
12
- maxIdx.value = spinMessages.length - 1;
13
- msg.value = messages.value[idx.value];
14
- showMsg.value = true;
15
- }
16
- loading.value = true;
17
- };
18
- const hide = () => {
19
- idx.value = 0;
20
- maxIdx.value = 0;
21
- messages.value = [];
22
- msg.value = "";
23
- loading.value = false;
24
- };
25
- return {
26
- idx,
27
- loading,
28
- maxIdx,
29
- messages,
30
- msg,
31
- showMsg,
32
- show,
33
- hide
34
- };
35
- }
36
- let appSpinner = void 0;
37
- function useAppSpinnerDisplay() {
38
- if (appSpinner === void 0) {
39
- appSpinner = useSpinnerDisplay();
40
- }
41
- return appSpinner;
42
- }
43
- const useAppSpinner = (() => {
44
- const { show, hide } = useAppSpinnerDisplay();
45
- return { show, hide };
46
- })();
1
+ import { ref, cloneVNode, h, inject, watchEffect, provide, defineComponent, onUnmounted, Teleport, reactive, onUpdated, computed, unref, onMounted, nextTick, toRaw, watch, openBlock, createBlock, createVNode, withCtx, Transition, createElementVNode, createElementBlock, Fragment, renderList, normalizeClass, toDisplayString, createCommentVNode, renderSlot, resolveDynamicComponent, mergeProps, createTextVNode, normalizeProps, useAttrs, shallowRef, withModifiers, TransitionGroup, withDirectives, vShow, normalizeStyle, getCurrentInstance, vModelText, resolveComponent, Comment as Comment$1, Text, useSlots } from "vue";
47
2
  var axios$2 = { exports: {} };
48
3
  var bind$2 = function bind(fn, thisArg) {
49
4
  return function wrap() {
@@ -1304,11 +1259,66 @@ axios$1.isAxiosError = isAxiosError;
1304
1259
  axios$2.exports = axios$1;
1305
1260
  axios$2.exports.default = axios$1;
1306
1261
  var axios = axios$2.exports;
1307
- const apiDelayResponseIntercept = (result) => {
1308
- const delay = result.config.withDelay || 0;
1262
+ const HTTP_ERROR = "HttpError";
1263
+ const HTTP_CANCELLED_ERROR = "HttpCanceledError";
1264
+ class HttpError extends Error {
1265
+ constructor(message, status, response, name) {
1266
+ super(message || "");
1267
+ this.name = name || HTTP_ERROR;
1268
+ this.status = status || 0;
1269
+ this.response = response;
1270
+ }
1271
+ }
1272
+ function useSpinnerDisplay() {
1273
+ const idx = ref(0);
1274
+ const loading = ref(false);
1275
+ const maxIdx = ref(0);
1276
+ const messages = ref([]);
1277
+ const msg = ref("");
1278
+ const showMsg = ref(false);
1279
+ const show = (spinMessages = []) => {
1280
+ if (spinMessages) {
1281
+ messages.value = spinMessages;
1282
+ maxIdx.value = spinMessages.length - 1;
1283
+ msg.value = messages.value[idx.value];
1284
+ showMsg.value = true;
1285
+ }
1286
+ loading.value = true;
1287
+ };
1288
+ const hide = () => {
1289
+ idx.value = 0;
1290
+ maxIdx.value = 0;
1291
+ messages.value = [];
1292
+ msg.value = "";
1293
+ loading.value = false;
1294
+ };
1295
+ return {
1296
+ idx,
1297
+ loading,
1298
+ maxIdx,
1299
+ messages,
1300
+ msg,
1301
+ showMsg,
1302
+ show,
1303
+ hide
1304
+ };
1305
+ }
1306
+ let appSpinner = void 0;
1307
+ function useAppSpinnerDisplay() {
1308
+ if (appSpinner === void 0) {
1309
+ appSpinner = useSpinnerDisplay();
1310
+ }
1311
+ return appSpinner;
1312
+ }
1313
+ const useAppSpinner = (() => {
1314
+ const { show, hide } = useAppSpinnerDisplay();
1315
+ return { show, hide };
1316
+ })();
1317
+ const apiDelayReqIntercept = (config) => {
1318
+ const delay = config.withDelay || 0;
1309
1319
  return new Promise((resolve) => {
1310
1320
  setTimeout(() => {
1311
- resolve(result);
1321
+ resolve(config);
1312
1322
  }, Math.max(delay, 0));
1313
1323
  });
1314
1324
  };
@@ -1317,43 +1327,77 @@ const apiAxiosInstance = axios.create({
1317
1327
  responseType: "json",
1318
1328
  withCredentials: true
1319
1329
  });
1320
- apiAxiosInstance.interceptors.response.use(apiDelayResponseIntercept);
1330
+ apiAxiosInstance.interceptors.request.use(apiDelayReqIntercept);
1331
+ const httpRequest = (config, opts) => {
1332
+ const options = {
1333
+ skipLoader: false,
1334
+ withDelay: 0,
1335
+ ...opts
1336
+ };
1337
+ const wait = window.setTimeout(() => {
1338
+ if (options.skipLoader !== true) {
1339
+ useAppSpinner.show();
1340
+ }
1341
+ }, 200);
1342
+ return apiAxiosInstance({ ...config, ...opts }).then((success) => {
1343
+ return success.data;
1344
+ }).catch((err) => {
1345
+ var _a, _b;
1346
+ if (axios.isAxiosError(err)) {
1347
+ throw new HttpError(
1348
+ err.message,
1349
+ (_a = err.response) == null ? void 0 : _a.status,
1350
+ (_b = err.response) == null ? void 0 : _b.data,
1351
+ axios.isCancel(err) ? "HttpCanceledError" : void 0
1352
+ );
1353
+ }
1354
+ if (err instanceof Error) {
1355
+ throw new HttpError(err.message, 0);
1356
+ }
1357
+ throw new HttpError("An unknown error has occurred.", 0);
1358
+ }).finally(() => {
1359
+ if (options.skipLoader !== true) {
1360
+ useAppSpinner.hide();
1361
+ }
1362
+ window.clearTimeout(wait);
1363
+ });
1364
+ };
1321
1365
  const BaseAPI = {
1322
- makeRequest(config, opts) {
1323
- const wait = window.setTimeout(() => {
1324
- if (!opts.skipLoader) {
1325
- useAppSpinner.show();
1326
- }
1327
- }, 200);
1328
- return apiAxiosInstance({ ...config, ...opts }).then((success) => {
1329
- var _a;
1330
- return {
1331
- data: ((_a = success.data) == null ? void 0 : _a.data) || {},
1332
- status: success.status
1333
- };
1334
- }).finally(() => {
1335
- if (!opts.skipLoader)
1336
- useAppSpinner.hide();
1337
- window.clearTimeout(wait);
1338
- });
1339
- },
1340
1366
  get(path, opts, params) {
1341
- return this.makeRequest({ url: path, method: "GET", params }, opts);
1367
+ return httpRequest({ url: path, method: "GET", params }, opts || {});
1342
1368
  },
1343
1369
  delete(path, opts) {
1344
- return this.makeRequest({ url: path, method: "DELETE" }, opts);
1370
+ return httpRequest({ url: path, method: "DELETE" }, opts || {});
1371
+ },
1372
+ hasErrStatus(err, codes) {
1373
+ if (typeof codes === "number") {
1374
+ codes = [codes];
1375
+ }
1376
+ if (this.isHttpError(err)) {
1377
+ return codes.includes(err.status);
1378
+ }
1379
+ return false;
1380
+ },
1381
+ isHttpCancel(err) {
1382
+ return this.isHttpError(err) && err.name === HTTP_CANCELLED_ERROR;
1383
+ },
1384
+ isHttpError(err) {
1385
+ return err instanceof HttpError;
1386
+ },
1387
+ patch(path, data2, opts) {
1388
+ return httpRequest({ url: path, data: data2, method: "PATCH" }, opts || {});
1345
1389
  },
1346
1390
  post(path, data2, opts) {
1347
- return this.makeRequest({ url: path, data: data2, method: "POST" }, opts);
1391
+ return httpRequest({ url: path, data: data2, method: "POST" }, opts || {});
1348
1392
  },
1349
1393
  put(path, data2, opts) {
1350
- return this.makeRequest(
1394
+ return httpRequest(
1351
1395
  {
1352
1396
  url: path,
1353
1397
  data: data2,
1354
1398
  method: "PUT"
1355
1399
  },
1356
- opts
1400
+ opts || {}
1357
1401
  );
1358
1402
  }
1359
1403
  };
@@ -4996,7 +5040,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
4996
5040
  createVNode(unref(Dialog), {
4997
5041
  as: "div",
4998
5042
  static: "",
4999
- class: "fixed z-10 inset-0 overflow-y-auto",
5043
+ class: "fixed z-30 inset-0 overflow-y-auto",
5000
5044
  onClose: _cache[1] || (_cache[1] = ($event) => updateModelValue3(false)),
5001
5045
  open: __props.modelValue
5002
5046
  }, {
@@ -7434,7 +7478,6 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
7434
7478
  });
7435
7479
  function useBaseAPI(path, method = "GET", initOpts = {}) {
7436
7480
  const result = ref();
7437
- const status = ref();
7438
7481
  const error = shallowRef();
7439
7482
  const hasFetched = ref(false);
7440
7483
  const isFinished = ref(false);
@@ -7455,30 +7498,24 @@ function useBaseAPI(path, method = "GET", initOpts = {}) {
7455
7498
  isFinished.value = false;
7456
7499
  isLoading.value = true;
7457
7500
  const requestConfig = {
7458
- data: ["POST", "post", "PUT", "put"].includes(method) ? data2 : {},
7501
+ data: ["PATCH", "patch", "POST", "post", "PUT", "put"].includes(method) ? data2 : {},
7459
7502
  method,
7460
7503
  params: ["GET", "get"].includes(method) ? data2 : {},
7461
7504
  signal: controller.signal,
7462
7505
  url: path
7463
7506
  };
7464
- return BaseAPI.makeRequest(requestConfig, { ...initOpts, ...opts }).then(
7507
+ return httpRequest(requestConfig, { ...initOpts, ...opts }).then(
7465
7508
  (success) => {
7466
- result.value = success.data;
7467
- status.value = success.status;
7509
+ result.value = success;
7468
7510
  error.value = void 0;
7469
7511
  isAborted.value = false;
7470
7512
  return success;
7471
7513
  },
7472
7514
  (err) => {
7473
- var _a;
7474
7515
  error.value = err;
7475
- status.value = 0;
7476
- if (axios.isCancel(err)) {
7516
+ if (BaseAPI.isHttpCancel(err)) {
7477
7517
  isAborted.value = true;
7478
7518
  }
7479
- if (axios.isAxiosError(err)) {
7480
- status.value = ((_a = err.response) == null ? void 0 : _a.status) || 0;
7481
- }
7482
7519
  throw err;
7483
7520
  }
7484
7521
  ).finally(() => {
@@ -7494,7 +7531,6 @@ function useBaseAPI(path, method = "GET", initOpts = {}) {
7494
7531
  }
7495
7532
  return {
7496
7533
  result,
7497
- status,
7498
7534
  error,
7499
7535
  isFinished,
7500
7536
  isLoading,
@@ -7855,7 +7891,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
7855
7891
  }
7856
7892
  });
7857
7893
  var Flash_vue_vue_type_style_index_0_lang = "";
7858
- const _hoisted_1$j = { class: "fixed inset-0 flex flex-col items-end justify-end px-4 py-6 pointer-events-none sm:p-6 z-40" };
7894
+ const _hoisted_1$j = { class: "fixed inset-0 flex flex-col items-end justify-end px-4 py-6 pointer-events-none sm:p-6 z-[45]" };
7859
7895
  const _hoisted_2$g = { class: "rounded-lg ring-1 ring-black ring-opacity-5 overflow-hidden" };
7860
7896
  const _hoisted_3$f = { class: "p-4" };
7861
7897
  const _hoisted_4$d = { class: "flex items-center" };
@@ -7896,47 +7932,52 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
7896
7932
  loadWindowFlashes(flasher);
7897
7933
  });
7898
7934
  return (_ctx, _cache) => {
7899
- return openBlock(), createElementBlock("div", _hoisted_1$j, [
7900
- createVNode(TransitionGroup, {
7901
- tag: "div",
7902
- class: "max-w-sm space-y-2 w-full",
7903
- "enter-active-class": "ease-out duration-300",
7904
- "enter-from-class": "translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2",
7905
- "enter-to-class": "translate-y-0 opacity-100 sm:translate-x-0",
7906
- "leave-active-class": "ease-in duration-100",
7907
- "leave-from-class": "opacity-100",
7908
- "leave-to-class": "opacity-0"
7909
- }, {
7910
- default: withCtx(() => [
7911
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(flashes), ([id2, flash]) => {
7912
- return openBlock(), createElementBlock("div", {
7913
- key: flash.message,
7914
- class: normalizeClass(["bg-white shadow-lg rounded-lg pointer-events-auto border-t-4 transform", [getFlashClass(flash.type)]])
7915
- }, [
7916
- createElementVNode("div", _hoisted_2$g, [
7917
- createElementVNode("div", _hoisted_3$f, [
7918
- createElementVNode("div", _hoisted_4$d, [
7919
- createElementVNode("div", _hoisted_5$c, [
7920
- createElementVNode("p", {
7921
- class: "w-0 flex-1 text-sm leading-5 font-medium text-gray-900",
7922
- innerHTML: flash.message
7923
- }, null, 8, _hoisted_6$a)
7924
- ]),
7925
- createElementVNode("div", _hoisted_7$9, [
7926
- createElementVNode("button", {
7927
- onClick: ($event) => unref(flasher).remove(id2),
7928
- class: "inline-flex text-gray-400 focus:outline-none focus:text-gray-500 transition ease-in-out duration-150"
7929
- }, _hoisted_10$7, 8, _hoisted_8$7)
7935
+ return openBlock(), createBlock(unref(Portal), null, {
7936
+ default: withCtx(() => [
7937
+ createElementVNode("div", _hoisted_1$j, [
7938
+ createVNode(TransitionGroup, {
7939
+ tag: "div",
7940
+ class: "max-w-sm space-y-2 w-full",
7941
+ "enter-active-class": "ease-out duration-300",
7942
+ "enter-from-class": "translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2",
7943
+ "enter-to-class": "translate-y-0 opacity-100 sm:translate-x-0",
7944
+ "leave-active-class": "ease-in duration-100",
7945
+ "leave-from-class": "opacity-100",
7946
+ "leave-to-class": "opacity-0"
7947
+ }, {
7948
+ default: withCtx(() => [
7949
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(flashes), ([id2, flash]) => {
7950
+ return openBlock(), createElementBlock("div", {
7951
+ key: flash.message,
7952
+ class: normalizeClass(["bg-white shadow-lg rounded-lg pointer-events-auto border-t-4 transform z-10", [getFlashClass(flash.type)]])
7953
+ }, [
7954
+ createElementVNode("div", _hoisted_2$g, [
7955
+ createElementVNode("div", _hoisted_3$f, [
7956
+ createElementVNode("div", _hoisted_4$d, [
7957
+ createElementVNode("div", _hoisted_5$c, [
7958
+ createElementVNode("p", {
7959
+ class: "w-0 flex-1 text-sm leading-5 font-medium text-gray-900",
7960
+ innerHTML: flash.message
7961
+ }, null, 8, _hoisted_6$a)
7962
+ ]),
7963
+ createElementVNode("div", _hoisted_7$9, [
7964
+ createElementVNode("button", {
7965
+ onClick: ($event) => unref(flasher).remove(id2),
7966
+ class: "inline-flex text-gray-400 focus:outline-none focus:text-gray-500 transition ease-in-out duration-150"
7967
+ }, _hoisted_10$7, 8, _hoisted_8$7)
7968
+ ])
7969
+ ])
7930
7970
  ])
7931
7971
  ])
7932
- ])
7933
- ])
7934
- ], 2);
7935
- }), 128))
7936
- ]),
7937
- _: 1
7938
- })
7939
- ]);
7972
+ ], 2);
7973
+ }), 128))
7974
+ ]),
7975
+ _: 1
7976
+ })
7977
+ ])
7978
+ ]),
7979
+ _: 1
7980
+ });
7940
7981
  };
7941
7982
  }
7942
7983
  });
@@ -8061,7 +8102,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
8061
8102
  createVNode(unref(Dialog), {
8062
8103
  as: "div",
8063
8104
  static: "",
8064
- class: "fixed z-10 inset-0 overflow-y-auto",
8105
+ class: "fixed z-30 inset-0 overflow-y-auto",
8065
8106
  onClose: _cache[3] || (_cache[3] = ($event) => updateModelValue3(false)),
8066
8107
  open: __props.modelValue
8067
8108
  }, {
@@ -8151,7 +8192,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
8151
8192
  const _hoisted_1$h = { class: "aspect-square overflow-hidden" };
8152
8193
  const _hoisted_2$e = { class: "flex justify-center relative" };
8153
8194
  const _hoisted_3$d = { class: "sr-only" };
8154
- const _hoisted_4$b = /* @__PURE__ */ createElementVNode("div", { class: "animate-spin-gear" }, [
8195
+ const _hoisted_4$b = /* @__PURE__ */ createElementVNode("div", { class: "animate-spin-gear drop-shadow-md" }, [
8155
8196
  /* @__PURE__ */ createElementVNode("svg", {
8156
8197
  width: "100%",
8157
8198
  height: "100%",
@@ -8247,7 +8288,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
8247
8288
  });
8248
8289
  const _hoisted_1$g = {
8249
8290
  key: 0,
8250
- class: "fixed top-0 left-0 flex flex-col items-center justify-center w-full h-full cursor-not-allowed z-50 bg-gray-50 bg-opacity-50"
8291
+ class: "fixed top-0 left-0 flex flex-col items-center justify-center w-full h-full cursor-not-allowed z-40 bg-gray-50 bg-opacity-50"
8251
8292
  };
8252
8293
  const _hoisted_2$d = { class: "mt-2" };
8253
8294
  const _sfc_main$i = /* @__PURE__ */ defineComponent({
@@ -8269,31 +8310,36 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
8269
8310
  }, 2500);
8270
8311
  };
8271
8312
  return (_ctx, _cache) => {
8272
- return unref(loading) ? (openBlock(), createElementBlock("div", _hoisted_1$g, [
8273
- createVNode(_sfc_main$j, { class: "w-32 h-32" }),
8274
- withDirectives(createElementVNode("div", _hoisted_2$d, [
8275
- createVNode(Transition, {
8276
- appear: "",
8277
- "enter-active-class": "ease-out duration-1000",
8278
- "enter-from-class": "opacity-0",
8279
- "enter-to-class": "opacity-100",
8280
- "leave-active-class": "ease-in duration-500",
8281
- "leave-from-class": "opacity-100",
8282
- "leave-to-class": "opacity-0",
8283
- onAfterEnter: fadeOut,
8284
- onAfterLeave: fadeIn
8285
- }, {
8286
- default: withCtx(() => [
8287
- withDirectives(createElementVNode("div", { class: "container font-medium text-lg leading-snug text-center transition-opacity" }, toDisplayString(unref(msg)), 513), [
8288
- [vShow, unref(showMsg)]
8289
- ])
8290
- ]),
8291
- _: 1
8292
- })
8293
- ], 512), [
8294
- [vShow, unref(messages)]
8295
- ])
8296
- ])) : createCommentVNode("", true);
8313
+ return openBlock(), createBlock(unref(Portal), null, {
8314
+ default: withCtx(() => [
8315
+ unref(loading) ? (openBlock(), createElementBlock("div", _hoisted_1$g, [
8316
+ createVNode(_sfc_main$j, { class: "w-32 h-32" }),
8317
+ withDirectives(createElementVNode("div", _hoisted_2$d, [
8318
+ createVNode(Transition, {
8319
+ appear: "",
8320
+ "enter-active-class": "ease-out duration-1000",
8321
+ "enter-from-class": "opacity-0",
8322
+ "enter-to-class": "opacity-100",
8323
+ "leave-active-class": "ease-in duration-500",
8324
+ "leave-from-class": "opacity-100",
8325
+ "leave-to-class": "opacity-0",
8326
+ onAfterEnter: fadeOut,
8327
+ onAfterLeave: fadeIn
8328
+ }, {
8329
+ default: withCtx(() => [
8330
+ withDirectives(createElementVNode("div", { class: "container font-medium text-lg leading-snug text-center transition-opacity" }, toDisplayString(unref(msg)), 513), [
8331
+ [vShow, unref(showMsg)]
8332
+ ])
8333
+ ]),
8334
+ _: 1
8335
+ })
8336
+ ], 512), [
8337
+ [vShow, unref(messages)]
8338
+ ])
8339
+ ])) : createCommentVNode("", true)
8340
+ ]),
8341
+ _: 1
8342
+ });
8297
8343
  };
8298
8344
  }
8299
8345
  });
@@ -8353,7 +8399,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8353
8399
  createVNode(unref(Dialog), {
8354
8400
  as: "div",
8355
8401
  static: "",
8356
- class: "fixed inset-0 flex z-40 md:hidden",
8402
+ class: "fixed inset-0 flex z-10 md:hidden",
8357
8403
  onClose: _cache[1] || (_cache[1] = ($event) => sidebarOpen.value = false),
8358
8404
  open: sidebarOpen.value
8359
8405
  }, {
@@ -8824,7 +8870,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
8824
8870
  createVNode(unref(Dialog), {
8825
8871
  as: "div",
8826
8872
  static: "",
8827
- class: "fixed inset-0 z-40 overflow-hidden bg-black bg-opacity-50",
8873
+ class: "fixed inset-0 z-20 overflow-hidden bg-black bg-opacity-50",
8828
8874
  onClose: _cache[1] || (_cache[1] = ($event) => close2()),
8829
8875
  open: __props.modelValue
8830
8876
  }, {
@@ -9440,7 +9486,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
9440
9486
  sortDir: currentSortDirection.value,
9441
9487
  q: query.value
9442
9488
  };
9443
- BaseAPI.get(props.tableData.url, { skipLoader: !props.loader }, params).then(
9489
+ BaseAPI.get(
9490
+ props.tableData.url,
9491
+ { skipLoader: !props.loader },
9492
+ params
9493
+ ).then(
9444
9494
  (success) => {
9445
9495
  pagination.value = {
9446
9496
  page: success.data.page,