@xy-planning-network/trees 0.6.2-rc-7 → 0.6.2
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 +12 -22
- package/dist/trees.umd.js +6 -6
- package/package.json +2 -1
- package/src/lib-components/forms/RadioCards.vue +2 -2
- package/src/lib-components/lists/Table.vue +2 -2
- package/types/api/base.d.ts +2 -10
- package/types/api/client.d.ts +69 -41
- package/types/composables/useBaseAPI.d.ts +6 -6
- package/types/entry.d.ts +4 -4
- package/types/api/url.d.ts +0 -1
- package/types/composables/usePopper.d.ts +0 -19
- package/types/types/lists.d.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xy-planning-network/trees",
|
|
3
|
-
"version": "0.6.2
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:xy-planning-network/trees",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"typecheck:docs": "vue-tsc -p dev --noEmit"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"@point-hub/vue-highlight": "^0.1.4",
|
|
36
37
|
"@tailwindcss/forms": "^0.5.3",
|
|
37
38
|
"@tailwindcss/line-clamp": "^0.4.2",
|
|
38
39
|
"@tailwindcss/typography": "^0.5.7",
|
|
@@ -114,11 +114,11 @@ const nameAttr = computed(() => {
|
|
|
114
114
|
v-slot="{ active, checked, disabled }"
|
|
115
115
|
>
|
|
116
116
|
<div
|
|
117
|
+
class="relative bg-white border rounded-lg shadow-sm p-4 flex cursor-pointer focus:outline-none"
|
|
117
118
|
:class="[
|
|
118
119
|
checked ? 'border-transparent' : 'border-gray-300',
|
|
119
120
|
active ? 'border-blue-500 ring-2 ring-blue-500' : '',
|
|
120
|
-
|
|
121
|
-
disabled ? 'opacity-75' : '',
|
|
121
|
+
disabled ? 'cursor-not-allowed opacity-75' : '',
|
|
122
122
|
]"
|
|
123
123
|
>
|
|
124
124
|
<div class="flex-1 flex pr-1">
|
|
@@ -11,7 +11,7 @@ import Paginator from "../navigation/Paginator.vue"
|
|
|
11
11
|
import BaseAPI from "../../api/base"
|
|
12
12
|
import * as TableTypes from "@/composables/table"
|
|
13
13
|
import { useAppFlasher } from "@/composables/useFlashes"
|
|
14
|
-
import {
|
|
14
|
+
import { TrailsRespPaged } from "@/api/client"
|
|
15
15
|
|
|
16
16
|
const props = withDefaults(
|
|
17
17
|
defineProps<{
|
|
@@ -96,7 +96,7 @@ const loadAndRender = (): void => {
|
|
|
96
96
|
q: query.value,
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
BaseAPI.get<
|
|
99
|
+
BaseAPI.get<TrailsRespPaged<unknown>>(
|
|
100
100
|
props.tableData.url,
|
|
101
101
|
{ skipLoader: !props.loader },
|
|
102
102
|
params
|
package/types/api/base.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from "axios";
|
|
2
|
-
import { HttpClient, HttpError, HttpPromise,
|
|
3
|
-
export declare const httpRequest: <T = any>(config: AxiosRequestConfig, opts:
|
|
2
|
+
import { HttpClient, HttpError, HttpPromise, ReqOptions } from "./client";
|
|
3
|
+
export declare const httpRequest: <T = any>(config: AxiosRequestConfig, opts: ReqOptions) => HttpPromise<T>;
|
|
4
4
|
declare const BaseAPI: HttpClient;
|
|
5
5
|
export default BaseAPI;
|
|
6
|
-
/**
|
|
7
|
-
* A convenience method for checking if a variable in a failed request has an http status code.
|
|
8
|
-
* This is most useful for checking for specific http status codes in error callbacks.
|
|
9
|
-
* @param err unknown
|
|
10
|
-
* @param codes number | number[]
|
|
11
|
-
* @returns boolean
|
|
12
|
-
*/
|
|
13
|
-
export declare const hasHttpErrStatus: (err: unknown, codes: number | number[]) => boolean;
|
|
14
6
|
/**
|
|
15
7
|
* A type guard for checking if a variable is in the shape of a HttpError
|
|
16
8
|
* @param err unknown
|
package/types/api/client.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ReqMethod
|
|
3
3
|
* The HTTP request methods that our http client supports.
|
|
4
4
|
*/
|
|
5
|
-
export declare type
|
|
5
|
+
export declare type ReqMethod = "DELETE" | "delete" | "GET" | "get" | "PATCH" | "patch" | "POST" | "post" | "PUT" | "put";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* ReqOptions
|
|
8
8
|
* The set of options available for any http client request.
|
|
9
9
|
*/
|
|
10
|
-
export interface
|
|
10
|
+
export interface ReqOptions {
|
|
11
11
|
/**
|
|
12
12
|
* Disable the full screen loading interface during the request when true.
|
|
13
13
|
*/
|
|
@@ -17,21 +17,21 @@ export interface RequestOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
withDelay?: number;
|
|
19
19
|
}
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
20
|
+
export declare const HTTP_ERR = "HttpError";
|
|
21
|
+
export declare const HTTP_ERR_CANCEL = "HttpErrorCanceled";
|
|
22
22
|
/**
|
|
23
23
|
* HttpError
|
|
24
24
|
* An http client error when the request is rejected.
|
|
25
25
|
*/
|
|
26
26
|
export declare class HttpError<T = unknown> extends Error {
|
|
27
|
-
/**
|
|
28
|
-
* The http response status code.
|
|
29
|
-
*/
|
|
30
|
-
status: number;
|
|
31
27
|
/**
|
|
32
28
|
* The http response body.
|
|
33
29
|
*/
|
|
34
30
|
response?: T;
|
|
31
|
+
/**
|
|
32
|
+
* The http response status code.
|
|
33
|
+
*/
|
|
34
|
+
status: number;
|
|
35
35
|
constructor(message?: string, status?: number, response?: T, name?: string);
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
@@ -43,17 +43,45 @@ export interface HttpPromise<T = any> extends Promise<T> {
|
|
|
43
43
|
/**
|
|
44
44
|
* TrailsPromise
|
|
45
45
|
* The successfully resolved interface of an http client request returned by @xy-planning-network/Trails.
|
|
46
|
+
*
|
|
47
|
+
* Example Usage:
|
|
48
|
+
* interface User {
|
|
49
|
+
* id: number
|
|
50
|
+
* email: string
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* const UsersAPI = {
|
|
54
|
+
* update(
|
|
55
|
+
* id: number,
|
|
56
|
+
* data: ReqPayload,
|
|
57
|
+
* opts?: ReqOptions
|
|
58
|
+
* ): TrailsPromise<User> {
|
|
59
|
+
* return BaseAPI.put<TrailsResp<User>>(`/users/${id}`, data, opts)
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
46
62
|
*/
|
|
47
|
-
export interface TrailsPromise<T = any> extends Promise<
|
|
63
|
+
export interface TrailsPromise<T = any> extends Promise<TrailsResp<T>> {
|
|
48
64
|
}
|
|
49
65
|
/**
|
|
50
66
|
* TrailsPromisePaged
|
|
51
67
|
* The successfully resolved interface of a paged http client request returned by @xy-planning-network/Trails.
|
|
68
|
+
*
|
|
69
|
+
* Example Usage:
|
|
70
|
+
* interface User {
|
|
71
|
+
* id: number
|
|
72
|
+
* email: string
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* const UsersAPI = {
|
|
76
|
+
* index(opts?: ReqOptions, params?: QueryParams): TrailsPromisePaged<User> {
|
|
77
|
+
* return BaseAPI.get<TrailsRespPaged<User>>("/users", opts, params)
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
52
80
|
*/
|
|
53
|
-
export interface TrailsPromisePaged<T = any> extends Promise<
|
|
81
|
+
export interface TrailsPromisePaged<T = any> extends Promise<TrailsRespPaged<T>> {
|
|
54
82
|
}
|
|
55
83
|
/**
|
|
56
|
-
*
|
|
84
|
+
* TrailsResp
|
|
57
85
|
* A convenience interface to represent the shape of a Trails delivered API response.
|
|
58
86
|
*
|
|
59
87
|
* Example Usage:
|
|
@@ -62,18 +90,18 @@ export interface TrailsPromisePaged<T = any> extends Promise<TrailsResponsePaged
|
|
|
62
90
|
* email: string
|
|
63
91
|
* }
|
|
64
92
|
*
|
|
65
|
-
* BaseAPI.get<
|
|
66
|
-
* .then(result => {
|
|
93
|
+
* BaseAPI.get<TrailsResp<User>>(`/user/${id}`)
|
|
94
|
+
* .then((result) => {
|
|
67
95
|
* const id = result.data.id
|
|
68
96
|
* const email = result.data.email
|
|
69
|
-
* const user =
|
|
97
|
+
* const user = result.data
|
|
70
98
|
* })
|
|
71
99
|
*/
|
|
72
|
-
export interface
|
|
100
|
+
export interface TrailsResp<T = any> {
|
|
73
101
|
data: T;
|
|
74
102
|
}
|
|
75
103
|
/**
|
|
76
|
-
*
|
|
104
|
+
* TrailsRespPaged
|
|
77
105
|
* A convenience interface to represent the shape of a paginated Trails delivered API response.
|
|
78
106
|
*
|
|
79
107
|
* Example Usage:
|
|
@@ -82,17 +110,17 @@ export interface TrailsResponse<T = any> {
|
|
|
82
110
|
* email: string
|
|
83
111
|
* }
|
|
84
112
|
*
|
|
85
|
-
* BaseAPI.get<
|
|
86
|
-
* .then(result => {
|
|
113
|
+
* BaseAPI.get<TrailsRespPaged<User>>(`/users`)
|
|
114
|
+
* .then((result) => {
|
|
87
115
|
* const currentPage = result.data.page
|
|
88
|
-
* const users =
|
|
116
|
+
* const users = result.data.items
|
|
89
117
|
*
|
|
90
|
-
*
|
|
118
|
+
* users.forEach((u) => {
|
|
91
119
|
* console.log(u.id)
|
|
92
120
|
* })
|
|
93
121
|
* })
|
|
94
122
|
*/
|
|
95
|
-
export interface
|
|
123
|
+
export interface TrailsRespPaged<T = any> {
|
|
96
124
|
data: {
|
|
97
125
|
items: T[];
|
|
98
126
|
page: number;
|
|
@@ -107,49 +135,49 @@ export interface TrailsResponsePaged<T = any> {
|
|
|
107
135
|
*/
|
|
108
136
|
export declare type QueryParams = Record<string, any>;
|
|
109
137
|
/**
|
|
110
|
-
*
|
|
138
|
+
* ReqPayload
|
|
111
139
|
* Http POST and PUT payloads.
|
|
112
140
|
*/
|
|
113
|
-
export declare type
|
|
141
|
+
export declare type ReqPayload = Record<string, any> | FormData;
|
|
114
142
|
/**
|
|
115
143
|
* HttpClient
|
|
116
144
|
* The http client interface the BaseAPI implements.
|
|
117
145
|
*/
|
|
118
146
|
export interface HttpClient {
|
|
119
147
|
/**
|
|
120
|
-
* The method to make an http
|
|
148
|
+
* The method to make an http DELETE request.
|
|
121
149
|
* @param path string
|
|
122
|
-
* @param opts
|
|
123
|
-
* @param params QueryParams
|
|
150
|
+
* @param opts ReqOptions
|
|
124
151
|
* @returns HttpPromise<T>
|
|
125
152
|
*/
|
|
126
|
-
|
|
153
|
+
delete<T>(path: string, opts?: ReqOptions): HttpPromise<T>;
|
|
127
154
|
/**
|
|
128
|
-
* The method to make an http
|
|
155
|
+
* The method to make an http GET request.
|
|
129
156
|
* @param path string
|
|
130
|
-
* @param opts
|
|
157
|
+
* @param opts ReqOptions
|
|
158
|
+
* @param params QueryParams
|
|
131
159
|
* @returns HttpPromise<T>
|
|
132
160
|
*/
|
|
133
|
-
|
|
161
|
+
get<T>(path: string, opts?: ReqOptions, params?: QueryParams): HttpPromise<T>;
|
|
134
162
|
/**
|
|
135
163
|
* The method to make an http PATCH request.
|
|
136
164
|
* @param path string
|
|
137
|
-
* @param data
|
|
138
|
-
* @param opts
|
|
165
|
+
* @param data ReqPayload
|
|
166
|
+
* @param opts ReqOptions
|
|
139
167
|
*/
|
|
140
|
-
patch<T>(path: string, data?:
|
|
168
|
+
patch<T>(path: string, data?: ReqPayload, opts?: ReqOptions): HttpPromise<T>;
|
|
141
169
|
/**
|
|
142
170
|
* The method to make an http POST request.
|
|
143
171
|
* @param path string
|
|
144
|
-
* @param data
|
|
145
|
-
* @param opts
|
|
172
|
+
* @param data ReqPayload
|
|
173
|
+
* @param opts ReqOptions
|
|
146
174
|
*/
|
|
147
|
-
post<T>(path: string, data?:
|
|
175
|
+
post<T>(path: string, data?: ReqPayload, opts?: ReqOptions): HttpPromise<T>;
|
|
148
176
|
/**
|
|
149
177
|
* The method to make an http PUT request.
|
|
150
178
|
* @param path string
|
|
151
|
-
* @param data
|
|
152
|
-
* @param opts
|
|
179
|
+
* @param data ReqPayload
|
|
180
|
+
* @param opts ReqOptions
|
|
153
181
|
*/
|
|
154
|
-
put<T>(path: string, data?:
|
|
182
|
+
put<T>(path: string, data?: ReqPayload, opts?: ReqOptions): HttpPromise<T>;
|
|
155
183
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Ref, ShallowRef } from "vue";
|
|
2
|
-
import type { HttpPromise, HttpError,
|
|
2
|
+
import type { HttpPromise, HttpError, ReqMethod, ReqOptions, ReqPayload } from "../api/client";
|
|
3
3
|
/**
|
|
4
|
-
* UseBaseAPIOptions extends Trees/
|
|
4
|
+
* UseBaseAPIOptions extends Trees/ReqOptions
|
|
5
5
|
* these options are used only in the instantiation
|
|
6
6
|
* of a new UseBaseAPI composable
|
|
7
7
|
*/
|
|
8
|
-
export interface UseBaseAPIOptions extends
|
|
8
|
+
export interface UseBaseAPIOptions extends ReqOptions {
|
|
9
9
|
/**
|
|
10
10
|
* Whether to immediately fire the execute function during instantiation
|
|
11
11
|
*/
|
|
@@ -50,17 +50,17 @@ export interface UseBaseAPI<T> {
|
|
|
50
50
|
* Manually call the axios request
|
|
51
51
|
* can be used multiple times
|
|
52
52
|
*/
|
|
53
|
-
execute: (
|
|
53
|
+
execute: (payload?: ReqPayload, opts?: ReqOptions) => HttpPromise<T>;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* useBaseAPI is a composable wrapper of BaseAPI
|
|
57
57
|
* @param path {string} the api path or full url for the
|
|
58
|
-
* @param method {
|
|
58
|
+
* @param method {ReqMethod} the initial request type
|
|
59
59
|
* @param initOpts {UseBaseAPIOptions}
|
|
60
60
|
* @param initConfig {AxiosRequestConfig}
|
|
61
61
|
* @returns {UseBaseAPI<T>}
|
|
62
62
|
*/
|
|
63
|
-
export default function useBaseAPI<T = any>(path: string, method?:
|
|
63
|
+
export default function useBaseAPI<T = any>(path: string, method?: ReqMethod, initOpts?: UseBaseAPIOptions): UseBaseAPI<T>;
|
|
64
64
|
/**
|
|
65
65
|
* useBaseAPIGet is a convenience function for useBaseAPI
|
|
66
66
|
* @param path {string} the api path or full url for the
|
package/types/entry.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Plugin } from "vue";
|
|
2
|
-
import BaseAPI, {
|
|
3
|
-
import type { HttpPromise, HttpError, QueryParams,
|
|
2
|
+
import BaseAPI, { isHttpCancel, isHttpError } from "./api/base";
|
|
3
|
+
import type { HttpPromise, HttpError, QueryParams, ReqOptions, ReqPayload, TrailsPromise, TrailsPromisePaged, TrailsResp, TrailsRespPaged } from "./api/client";
|
|
4
4
|
declare const install: Exclude<Plugin["install"], undefined>;
|
|
5
5
|
export default install;
|
|
6
6
|
export * from "./composables/index";
|
|
7
7
|
export * from "./lib-components/index";
|
|
8
|
-
export { BaseAPI,
|
|
9
|
-
export type { HttpPromise, HttpError, QueryParams,
|
|
8
|
+
export { BaseAPI, isHttpCancel, isHttpError };
|
|
9
|
+
export type { HttpPromise, HttpError, QueryParams, ReqOptions, ReqPayload, TrailsPromise, TrailsPromisePaged, TrailsResp, TrailsRespPaged, };
|
package/types/api/url.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getBaseUrl(): string;
|
|
@@ -1,19 +0,0 @@
|
|
|
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/types/lists.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}
|