@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/dist/trees.es.js +20 -14
- package/dist/trees.umd.js +6 -6
- package/package.json +4 -2
- package/src/lib-components/indicators/XYSpinner.vue +1 -1
- package/src/lib-components/layout/SidebarLayout.vue +1 -1
- package/src/lib-components/lists/Table.vue +7 -3
- package/src/lib-components/overlays/ContentModal.vue +1 -1
- package/src/lib-components/overlays/Flash.vue +49 -42
- package/src/lib-components/overlays/Modal.vue +1 -1
- package/src/lib-components/overlays/Slideover.vue +1 -1
- package/src/lib-components/overlays/Spinner.vue +27 -24
- package/types/api/base.d.ts +21 -9
- package/types/api/url.d.ts +1 -0
- package/types/composables/useBaseAPI.d.ts +12 -6
- package/types/composables/usePopper.d.ts +19 -0
- package/types/entry.d.ts +3 -2
- package/types/types/lists.d.ts +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xy-planning-network/trees",
|
|
3
|
-
"version": "0.6.
|
|
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": "
|
|
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",
|
|
@@ -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(
|
|
100
|
-
|
|
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,
|
|
@@ -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
|
-
<
|
|
32
|
-
|
|
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
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class="
|
|
48
|
-
|
|
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
|
-
|
|
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
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
</
|
|
79
|
-
</
|
|
80
|
-
</
|
|
85
|
+
</transition-group>
|
|
86
|
+
</div>
|
|
87
|
+
</Portal>
|
|
81
88
|
</template>
|
|
82
89
|
|
|
83
90
|
<style>
|
|
@@ -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
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
</
|
|
53
|
+
</Portal>
|
|
51
54
|
</template>
|
package/types/api/base.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
import { Pagination } from "../composables/nav";
|
|
1
2
|
import { AxiosRequestConfig } from "axios";
|
|
2
|
-
export
|
|
3
|
-
|
|
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
|
-
*
|
|
12
|
+
* http status code
|
|
6
13
|
*/
|
|
7
|
-
|
|
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):
|
|
19
|
-
get<T_1 = any>(path: string, opts: RequestOptions, params?: Record<string, unknown> | undefined):
|
|
20
|
-
delete<T_2 = any>(path: string, opts: RequestOptions):
|
|
21
|
-
post<T_3 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions):
|
|
22
|
-
put<T_4 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions):
|
|
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
|
-
*
|
|
23
|
+
* Promise response data
|
|
23
24
|
*/
|
|
24
25
|
result: Ref<T | undefined>;
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
+
* Promise response http status code
|
|
27
28
|
*/
|
|
28
|
-
|
|
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) =>
|
|
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
|
-
|
|
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) =>
|
|
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
|
+
}
|