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

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": "@xy-planning-network/trees",
3
- "version": "0.6.0",
3
+ "version": "0.6.2-rc-1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "github:xy-planning-network/trees",
@@ -28,7 +28,9 @@
28
28
  "lint": "eslint --ext .js,.ts,.vue src",
29
29
  "lint:fix": "eslint --fix --ext .js,.ts,.vue src dev && prettier -w -u src dev",
30
30
  "preview": "vite preview --config vite.docs.config.ts",
31
- "typecheck": "vue-tsc -p src --noEmit"
31
+ "typecheck": "npm run typecheck:src && npm run typecheck:docs",
32
+ "typecheck:src": "vue-tsc -p src --noEmit",
33
+ "typecheck:docs": "vue-tsc -p dev --noEmit"
32
34
  },
33
35
  "devDependencies": {
34
36
  "@tailwindcss/forms": "^0.5.3",
@@ -15,7 +15,7 @@ const attrs = useAttrs()
15
15
  <p class="sr-only">
16
16
  <slot></slot>
17
17
  </p>
18
- <div class="animate-spin-gear">
18
+ <div class="animate-spin-gear drop-shadow-md">
19
19
  <svg
20
20
  width="100%"
21
21
  height="100%"
@@ -40,7 +40,7 @@ const isActive = (url: string): boolean => {
40
40
  <Dialog
41
41
  as="div"
42
42
  static
43
- class="fixed inset-0 flex z-40 md:hidden"
43
+ class="fixed inset-0 flex z-10 md:hidden"
44
44
  @close="sidebarOpen = false"
45
45
  :open="sidebarOpen"
46
46
  >
@@ -1,5 +1,4 @@
1
1
  <script setup lang="ts">
2
- import { AxiosResponse } from "axios"
3
2
  import {
4
3
  ComponentPublicInstance,
5
4
  computed,
@@ -12,6 +11,7 @@ import Paginator from "../navigation/Paginator.vue"
12
11
  import BaseAPI from "../../api/base"
13
12
  import * as TableTypes from "@/composables/table"
14
13
  import { useAppFlasher } from "@/composables/useFlashes"
14
+ import { TrailsResponsePaged } from "@/api/client"
15
15
 
16
16
  const props = withDefaults(
17
17
  defineProps<{
@@ -96,8 +96,12 @@ const loadAndRender = (): void => {
96
96
  q: query.value,
97
97
  }
98
98
 
99
- BaseAPI.get(props.tableData.url, { skipLoader: !props.loader }, params).then(
100
- (success: AxiosResponse) => {
99
+ BaseAPI.get<TrailsResponsePaged<unknown>>(
100
+ props.tableData.url,
101
+ { skipLoader: !props.loader },
102
+ params
103
+ ).then(
104
+ (success) => {
101
105
  pagination.value = {
102
106
  page: success.data.page,
103
107
  perPage: success.data.perPage,
@@ -30,7 +30,7 @@ const updateModelValue = (value: boolean) => {
30
30
  <Dialog
31
31
  as="div"
32
32
  static
33
- class="fixed z-10 inset-0 overflow-y-auto"
33
+ class="fixed z-30 inset-0 overflow-y-auto"
34
34
  @close="updateModelValue(false)"
35
35
  :open="modelValue"
36
36
  >
@@ -5,6 +5,7 @@ import {
5
5
  loadWindowFlashes,
6
6
  } from "@/composables/useFlashes"
7
7
  import { onMounted } from "vue"
8
+ import { Portal } from "@headlessui/vue"
8
9
 
9
10
  const { flasher, flashes } = useAppFlashes()
10
11
 
@@ -28,56 +29,62 @@ onMounted(() => {
28
29
  })
29
30
  </script>
30
31
  <template>
31
- <div
32
- class="fixed inset-0 flex flex-col items-end justify-end px-4 py-6 pointer-events-none sm:p-6 z-40"
33
- >
34
- <transition-group
35
- tag="div"
36
- class="max-w-sm space-y-2 w-full"
37
- enter-active-class="ease-out duration-300"
38
- enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
39
- enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
40
- leave-active-class="ease-in duration-100"
41
- leave-from-class="opacity-100"
42
- leave-to-class="opacity-0"
32
+ <Portal>
33
+ <div
34
+ class="fixed inset-0 flex flex-col items-end justify-end px-4 py-6 pointer-events-none sm:p-6 z-[45]"
43
35
  >
44
- <div
45
- v-for="[id, flash] in flashes"
46
- :key="flash.message"
47
- class="bg-white shadow-lg rounded-lg pointer-events-auto border-t-4 transform"
48
- :class="[getFlashClass(flash.type)]"
36
+ <transition-group
37
+ tag="div"
38
+ class="max-w-sm space-y-2 w-full"
39
+ enter-active-class="ease-out duration-300"
40
+ enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
41
+ enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
42
+ leave-active-class="ease-in duration-100"
43
+ leave-from-class="opacity-100"
44
+ leave-to-class="opacity-0"
49
45
  >
50
46
  <div
51
- class="rounded-lg ring-1 ring-black ring-opacity-5 overflow-hidden"
47
+ v-for="[id, flash] in flashes"
48
+ :key="flash.message"
49
+ class="bg-white shadow-lg rounded-lg pointer-events-auto border-t-4 transform z-10"
50
+ :class="[getFlashClass(flash.type)]"
52
51
  >
53
- <div class="p-4">
54
- <div class="flex items-center">
55
- <div class="w-0 flex-1 flex justify-between">
56
- <p
57
- class="w-0 flex-1 text-sm leading-5 font-medium text-gray-900"
58
- v-html="flash.message"
59
- ></p>
60
- </div>
61
- <div class="ml-4 shrink-0 flex">
62
- <button
63
- @click="flasher.remove(id)"
64
- class="inline-flex text-gray-400 focus:outline-none focus:text-gray-500 transition ease-in-out duration-150"
65
- >
66
- <svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
67
- <path
68
- fill-rule="evenodd"
69
- d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
70
- clip-rule="evenodd"
71
- />
72
- </svg>
73
- </button>
52
+ <div
53
+ class="rounded-lg ring-1 ring-black ring-opacity-5 overflow-hidden"
54
+ >
55
+ <div class="p-4">
56
+ <div class="flex items-center">
57
+ <div class="w-0 flex-1 flex justify-between">
58
+ <p
59
+ class="w-0 flex-1 text-sm leading-5 font-medium text-gray-900"
60
+ v-html="flash.message"
61
+ ></p>
62
+ </div>
63
+ <div class="ml-4 shrink-0 flex">
64
+ <button
65
+ @click="flasher.remove(id)"
66
+ class="inline-flex text-gray-400 focus:outline-none focus:text-gray-500 transition ease-in-out duration-150"
67
+ >
68
+ <svg
69
+ class="h-5 w-5"
70
+ viewBox="0 0 20 20"
71
+ fill="currentColor"
72
+ >
73
+ <path
74
+ fill-rule="evenodd"
75
+ d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
76
+ clip-rule="evenodd"
77
+ />
78
+ </svg>
79
+ </button>
80
+ </div>
74
81
  </div>
75
82
  </div>
76
83
  </div>
77
84
  </div>
78
- </div>
79
- </transition-group>
80
- </div>
85
+ </transition-group>
86
+ </div>
87
+ </Portal>
81
88
  </template>
82
89
 
83
90
  <style>
@@ -42,7 +42,7 @@ const updateModelValue = (value: boolean) => {
42
42
  <Dialog
43
43
  as="div"
44
44
  static
45
- class="fixed z-10 inset-0 overflow-y-auto"
45
+ class="fixed z-30 inset-0 overflow-y-auto"
46
46
  @close="updateModelValue(false)"
47
47
  :open="modelValue"
48
48
  >
@@ -33,7 +33,7 @@ const close = () => {
33
33
  <Dialog
34
34
  as="div"
35
35
  static
36
- class="fixed inset-0 z-40 overflow-hidden bg-black bg-opacity-50"
36
+ class="fixed inset-0 z-20 overflow-hidden bg-black bg-opacity-50"
37
37
  @close="close()"
38
38
  :open="modelValue"
39
39
  >
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { Portal } from "@headlessui/vue"
2
3
  import XYSpinner from "../indicators/XYSpinner.vue"
3
4
  import { useAppSpinnerDisplay } from "@/composables/useSpinner"
4
5
 
@@ -22,30 +23,32 @@ const fadeOut = (): void => {
22
23
  }
23
24
  </script>
24
25
  <template>
25
- <div
26
- 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"
27
- v-if="loading"
28
- >
29
- <XYSpinner class="w-32 h-32" />
30
- <div class="mt-2" v-show="messages">
31
- <transition
32
- appear
33
- enter-active-class="ease-out duration-1000"
34
- enter-from-class="opacity-0"
35
- enter-to-class="opacity-100"
36
- leave-active-class="ease-in duration-500"
37
- leave-from-class="opacity-100"
38
- leave-to-class="opacity-0"
39
- @after-enter="fadeOut"
40
- @after-leave="fadeIn"
41
- >
42
- <div
43
- class="container font-medium text-lg leading-snug text-center transition-opacity"
44
- v-show="showMsg"
26
+ <Portal>
27
+ <div
28
+ 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"
29
+ v-if="loading"
30
+ >
31
+ <XYSpinner class="w-32 h-32" />
32
+ <div class="mt-2" v-show="messages">
33
+ <transition
34
+ appear
35
+ enter-active-class="ease-out duration-1000"
36
+ enter-from-class="opacity-0"
37
+ enter-to-class="opacity-100"
38
+ leave-active-class="ease-in duration-500"
39
+ leave-from-class="opacity-100"
40
+ leave-to-class="opacity-0"
41
+ @after-enter="fadeOut"
42
+ @after-leave="fadeIn"
45
43
  >
46
- {{ msg }}
47
- </div>
48
- </transition>
44
+ <div
45
+ class="container font-medium text-lg leading-snug text-center transition-opacity"
46
+ v-show="showMsg"
47
+ >
48
+ {{ msg }}
49
+ </div>
50
+ </transition>
51
+ </div>
49
52
  </div>
50
- </div>
53
+ </Portal>
51
54
  </template>
@@ -1,10 +1,22 @@
1
+ import { Pagination } from "../composables/nav";
1
2
  import { AxiosRequestConfig } from "axios";
2
- export declare type RequestMethod = "GET" | "get" | "PUT" | "put" | "POST" | "post" | "DELETE" | "delete";
3
- export interface RequestOptions {
3
+ export interface Paginated<T> extends Pagination {
4
+ items: T[];
5
+ }
6
+ export interface TreesResponse<T = any> {
7
+ /**
8
+ * response data as T
9
+ */
10
+ data: T;
4
11
  /**
5
- * returns the nested data key inside the AxiosResponse data when true
12
+ * http status code
6
13
  */
7
- dataIntercept?: boolean;
14
+ status: number;
15
+ }
16
+ export interface TreesPromise<T = any> extends Promise<TreesResponse<T>> {
17
+ }
18
+ export declare type RequestMethod = "GET" | "get" | "PUT" | "put" | "POST" | "post" | "DELETE" | "delete";
19
+ export interface RequestOptions {
8
20
  /**
9
21
  * disables the full screen loading interface during the request when true
10
22
  */
@@ -15,10 +27,10 @@ export interface RequestOptions {
15
27
  withDelay?: number;
16
28
  }
17
29
  declare const BaseAPI: {
18
- makeRequest<T = any>(config: AxiosRequestConfig, opts: RequestOptions): Promise<T>;
19
- get<T_1 = any>(path: string, opts: RequestOptions, params?: Record<string, unknown> | undefined): Promise<T_1>;
20
- delete<T_2 = any>(path: string, opts: RequestOptions): Promise<T_2>;
21
- post<T_3 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions): Promise<T_3>;
22
- put<T_4 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions): Promise<T_4>;
30
+ makeRequest<T = any>(config: AxiosRequestConfig, opts: RequestOptions): TreesPromise<T>;
31
+ get<T_1 = any>(path: string, opts: RequestOptions, params?: Record<string, unknown> | undefined): TreesPromise<T_1>;
32
+ delete<T_2 = any>(path: string, opts: RequestOptions): TreesPromise<T_2>;
33
+ post<T_3 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions): TreesPromise<T_3>;
34
+ put<T_4 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions): TreesPromise<T_4>;
23
35
  };
24
36
  export default BaseAPI;
@@ -0,0 +1 @@
1
+ export declare function getBaseUrl(): string;
@@ -1,5 +1,6 @@
1
1
  import { AxiosError } from "axios";
2
2
  import { Ref, ShallowRef } from "vue";
3
+ import { TreesPromise } from "../api/base";
3
4
  import type { RequestMethod, RequestOptions } from "../api/base";
4
5
  /**
5
6
  * UseBaseAPIOptions extends Trees/RequestOptions
@@ -19,13 +20,17 @@ export interface UseBaseAPIOptions extends RequestOptions {
19
20
  */
20
21
  export interface UseBaseAPI<T> {
21
22
  /**
22
- * Axios response data
23
+ * Promise response data
23
24
  */
24
25
  result: Ref<T | undefined>;
25
26
  /**
26
- * Any errors that may have occurred
27
+ * Promise response http status code
27
28
  */
28
- error: ShallowRef<Error | AxiosError<T> | undefined>;
29
+ status: Ref<number | undefined>;
30
+ /**
31
+ * Any errors or rejections that may have occurred
32
+ */
33
+ error: ShallowRef<AxiosError | Error | undefined>;
29
34
  /**
30
35
  * Indicates if the request has finished
31
36
  */
@@ -51,7 +56,7 @@ export interface UseBaseAPI<T> {
51
56
  * Manually call the axios request
52
57
  * can be used multiple times
53
58
  */
54
- execute: (data?: Record<string, unknown> | FormData, opts?: RequestOptions) => Promise<T>;
59
+ execute: (data?: Record<string, unknown> | FormData, opts?: RequestOptions) => TreesPromise<T>;
55
60
  }
56
61
  /**
57
62
  * useBaseAPI is a composable wrapper of BaseAPI
@@ -63,13 +68,14 @@ export interface UseBaseAPI<T> {
63
68
  */
64
69
  export default function useBaseAPI<T = any>(path: string, method?: RequestMethod, initOpts?: UseBaseAPIOptions): {
65
70
  result: Ref<T | undefined>;
66
- error: ShallowRef<Error | AxiosError<T, any> | undefined>;
71
+ status: Ref<number | undefined>;
72
+ error: ShallowRef<AxiosError<unknown, any> | Error | undefined>;
67
73
  isFinished: Ref<boolean>;
68
74
  isLoading: Ref<boolean>;
69
75
  isAborted: Ref<boolean>;
70
76
  hasFetched: Ref<boolean>;
71
77
  abort: () => void;
72
- execute: (data?: Record<string, unknown> | FormData, opts?: RequestOptions) => Promise<T>;
78
+ execute: (data?: Record<string, unknown> | FormData, opts?: RequestOptions) => TreesPromise<T>;
73
79
  };
74
80
  /**
75
81
  * useBaseAPIGet is a convenience function for useBaseAPI
@@ -0,0 +1,19 @@
1
+ import { VNode } from "vue";
2
+ import { Options, Placement } from "@popperjs/core";
3
+ export declare type PopperPosition = Placement;
4
+ export declare const offsetModifier: (skidding: number, distance: number) => {
5
+ options: {
6
+ offset: () => number[];
7
+ };
8
+ name: "offset";
9
+ enabled: boolean;
10
+ phase: import("@popperjs/core").ModifierPhases;
11
+ requires?: string[] | undefined;
12
+ requiresIfExists?: string[] | undefined;
13
+ fn: (arg0: import("@popperjs/core").ModifierArguments<import("@popperjs/core/lib/modifiers/offset").Options>) => void | import("@popperjs/core").State;
14
+ effect?: ((arg0: import("@popperjs/core").ModifierArguments<import("@popperjs/core/lib/modifiers/offset").Options>) => void | (() => void)) | undefined;
15
+ data?: import("@popperjs/core").Obj | undefined;
16
+ };
17
+ export declare function usePopper(opts: Partial<Options>): import("vue").Ref<VNode<import("vue").RendererNode, import("vue").RendererElement, {
18
+ [key: string]: any;
19
+ }> | HTMLElement | undefined>[];
package/types/entry.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Plugin } from "vue";
2
2
  import BaseAPI from "./api/base";
3
- import type { RequestOptions } from "./api/base";
3
+ import type { Paginated, RequestOptions, TreesPromise, TreesResponse } from "./api/base";
4
+ import type { Pagination } from "./composables/nav";
4
5
  declare const install: Exclude<Plugin["install"], undefined>;
5
6
  export default install;
6
7
  export * from "./composables/index";
7
8
  export * from "./lib-components/index";
8
9
  export { BaseAPI };
9
- export type { RequestOptions };
10
+ export type { Paginated, Pagination, RequestOptions, TreesPromise, TreesResponse, };
@@ -0,0 +1,12 @@
1
+ export interface Pagination {
2
+ page: number;
3
+ perPage: number;
4
+ totalItems: number;
5
+ totalPages: number;
6
+ }
7
+ export interface PaginationItems<T = any> {
8
+ items: T[];
9
+ }
10
+ export interface PaginationData<T = any> {
11
+ data: Pagination & PaginationItems<T>;
12
+ }