@xy-planning-network/trees 0.4.5 → 0.4.8-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 +723 -514
- package/dist/trees.umd.js +7 -7
- package/package.json +2 -2
- package/src/lib-components/forms/MultiCheckboxes.vue +50 -44
- package/src/lib-components/forms/Radio.vue +54 -50
- package/types/api/base.d.ts +8 -6
- package/types/composables/index.d.ts +4 -0
- package/types/composables/useBaseAPI.d.ts +105 -0
- package/types/entry.d.ts +1 -0
- package/types/helpers/Debounce.d.ts +1 -0
- 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.4.
|
|
3
|
+
"version": "0.4.8-rc-1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:xy-planning-network/trees",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@headlessui/vue": "^1.4.2",
|
|
60
60
|
"@heroicons/vue": "^1.0.5",
|
|
61
|
-
"axios": "^0.
|
|
61
|
+
"axios": "^0.27.2",
|
|
62
62
|
"flatpickr": "^4.6.9"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
@@ -62,54 +62,60 @@ const onChange = (checked: boolean, val: CheckboxValue) => {
|
|
|
62
62
|
</FieldsetLegend>
|
|
63
63
|
<InputHelp tag="p" :text="help" :id="`${uuid}-help`" />
|
|
64
64
|
</div>
|
|
65
|
-
<div
|
|
66
|
-
class="grid gap-4"
|
|
67
|
-
:class="{
|
|
68
|
-
'sm:grid sm:gap-y-4 sm:gap-x-5 sm:space-y-0': columns !== undefined,
|
|
69
|
-
'sm:grid-cols-2': columns === 2,
|
|
70
|
-
'sm:grid-cols-3': columns === 3,
|
|
71
|
-
'sm:grid-cols-4': columns === 4,
|
|
72
|
-
}"
|
|
73
|
-
>
|
|
65
|
+
<div class="flex">
|
|
74
66
|
<div
|
|
75
|
-
|
|
76
|
-
:
|
|
77
|
-
|
|
67
|
+
class="grid gap-4"
|
|
68
|
+
:class="{
|
|
69
|
+
'sm:grid sm:gap-y-4 sm:gap-x-5 sm:space-y-0': columns !== undefined,
|
|
70
|
+
'sm:grid-cols-2': columns === 2,
|
|
71
|
+
'sm:grid-cols-3': columns === 3,
|
|
72
|
+
'sm:grid-cols-4': columns === 4,
|
|
73
|
+
}"
|
|
78
74
|
>
|
|
79
|
-
<div
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
75
|
+
<div
|
|
76
|
+
v-for="(option, index) in options"
|
|
77
|
+
:key="option.value"
|
|
78
|
+
class="flex items-start"
|
|
79
|
+
>
|
|
80
|
+
<div class="flex items-center h-5">
|
|
81
|
+
<input
|
|
82
|
+
:id="`${uuid}-${index}`"
|
|
83
|
+
:aria-labelledby="`${uuid}-${index}-label`"
|
|
84
|
+
:aria-describedby="
|
|
85
|
+
option?.help && option.help
|
|
86
|
+
? `${uuid}-${index}-help`
|
|
87
|
+
: undefined
|
|
88
|
+
"
|
|
89
|
+
:checked="modelValue.includes(option.value)"
|
|
90
|
+
:disabled="option.disabled === true ? true : undefined"
|
|
91
|
+
class="focus:ring-blue-500 h-4 w-4 text-blue-500 border-gray-600 rounded disabled:opacity-50 disabled:cursor-not-allowed"
|
|
92
|
+
type="checkbox"
|
|
93
|
+
v-bind="{
|
|
94
|
+
onChange: ($event) => {
|
|
95
|
+
onChange(($event.target as HTMLInputElement).checked, option.value)
|
|
96
|
+
},
|
|
92
97
|
...$attrs,
|
|
93
98
|
}"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
<div class="ml-3">
|
|
102
|
+
<InputLabel
|
|
103
|
+
class="mt-auto"
|
|
104
|
+
:disabled="
|
|
105
|
+
($attrs.hasOwnProperty('disabled') &&
|
|
106
|
+
$attrs.disabled !== false) ||
|
|
107
|
+
option.disabled === true
|
|
108
|
+
"
|
|
109
|
+
:id="`${uuid}-${index}-label`"
|
|
110
|
+
:for="`${uuid}-${index}`"
|
|
111
|
+
:label="option.label"
|
|
112
|
+
/>
|
|
113
|
+
<InputHelp
|
|
114
|
+
class="-mt-1"
|
|
115
|
+
:id="`${uuid}-${index}-help`"
|
|
116
|
+
:text="option.help"
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
113
119
|
</div>
|
|
114
120
|
</div>
|
|
115
121
|
</div>
|
|
@@ -46,58 +46,62 @@ const hasLegend = computed(() => {
|
|
|
46
46
|
</FieldsetLegend>
|
|
47
47
|
<InputHelp tag="p" :text="help" :id="`${uuid}-help`" />
|
|
48
48
|
</div>
|
|
49
|
-
<div
|
|
50
|
-
class="grid gap-4"
|
|
51
|
-
:class="{
|
|
52
|
-
'sm:grid sm:gap-y-4 sm:gap-x-5 sm:space-y-0': columns !== undefined,
|
|
53
|
-
'sm:grid-cols-2': columns === 2,
|
|
54
|
-
'sm:grid-cols-3': columns === 3,
|
|
55
|
-
'sm:grid-cols-4': columns === 4,
|
|
56
|
-
}"
|
|
57
|
-
>
|
|
49
|
+
<div class="">
|
|
58
50
|
<div
|
|
59
|
-
|
|
60
|
-
:
|
|
61
|
-
|
|
51
|
+
class="grid gap-4"
|
|
52
|
+
:class="{
|
|
53
|
+
'sm:grid sm:gap-y-4 sm:gap-x-5 sm:space-y-0': columns !== undefined,
|
|
54
|
+
'sm:grid-cols-2': columns === 2,
|
|
55
|
+
'sm:grid-cols-3': columns === 3,
|
|
56
|
+
'sm:grid-cols-4': columns === 4,
|
|
57
|
+
}"
|
|
62
58
|
>
|
|
63
|
-
<div
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
59
|
+
<div
|
|
60
|
+
v-for="(option, index) in options"
|
|
61
|
+
:key="option.value"
|
|
62
|
+
class="flex items-start"
|
|
63
|
+
>
|
|
64
|
+
<div class="flex items-center h-5">
|
|
65
|
+
<input
|
|
66
|
+
:aria-describedby="
|
|
67
|
+
option?.help && option.help
|
|
68
|
+
? `${uuid}-${index}-help`
|
|
69
|
+
: undefined
|
|
70
|
+
"
|
|
71
|
+
:aria-labelledby="`${uuid}-${index}-label`"
|
|
72
|
+
:checked="modelValue === option.value"
|
|
73
|
+
class="w-4 h-4 border-gray-600 focus:ring-blue-500 text-xy-blue disabled:opacity-50 disabled:cursor-not-allowed"
|
|
74
|
+
:disabled="option.disabled === true ? true : undefined"
|
|
75
|
+
:id="`${uuid}-${index}`"
|
|
76
|
+
:name="uuid"
|
|
77
|
+
type="radio"
|
|
78
|
+
:value="option.value"
|
|
79
|
+
v-bind="{
|
|
80
|
+
onChange: () => {
|
|
81
|
+
emits('update:modelValue', option.value)
|
|
82
|
+
},
|
|
83
|
+
...$attrs,
|
|
84
|
+
}"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
<div class="ml-3">
|
|
88
|
+
<InputLabel
|
|
89
|
+
class="mt-auto"
|
|
90
|
+
:disabled="
|
|
91
|
+
($attrs.hasOwnProperty('disabled') &&
|
|
92
|
+
$attrs.disabled !== false) ||
|
|
93
|
+
option.disabled === true
|
|
94
|
+
"
|
|
95
|
+
:id="`${uuid}-${index}-label`"
|
|
96
|
+
:for="`${uuid}-${index}`"
|
|
97
|
+
:label="option.label"
|
|
98
|
+
/>
|
|
99
|
+
<InputHelp
|
|
100
|
+
class="-mt-1"
|
|
101
|
+
:id="`${uuid}-${index}-help`"
|
|
102
|
+
:text="option.help"
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
101
105
|
</div>
|
|
102
106
|
</div>
|
|
103
107
|
</div>
|
package/types/api/base.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosRequestConfig } from "axios";
|
|
2
|
+
export declare type RequestMethod = "GET" | "get" | "PUT" | "put" | "POST" | "post" | "DELETE" | "delete";
|
|
2
3
|
export interface RequestOptions {
|
|
3
4
|
skipLoader?: boolean;
|
|
5
|
+
withDelay?: number;
|
|
4
6
|
}
|
|
5
7
|
declare const BaseAPI: {
|
|
6
|
-
makeRequest(config: AxiosRequestConfig, opts: RequestOptions):
|
|
7
|
-
get(path: string, opts: RequestOptions, params?: Record<string, unknown> | undefined):
|
|
8
|
-
delete(path: string, opts: RequestOptions):
|
|
9
|
-
post(path: string, data: Record<string, unknown>, opts: RequestOptions):
|
|
10
|
-
put(path: string, data: Record<string, unknown>, opts: RequestOptions):
|
|
8
|
+
makeRequest<T = any>(config: AxiosRequestConfig, opts: RequestOptions): Promise<T>;
|
|
9
|
+
get<T_1 = any>(path: string, opts: RequestOptions, params?: Record<string, unknown> | undefined): Promise<T_1>;
|
|
10
|
+
delete<T_2 = any>(path: string, opts: RequestOptions): Promise<T_2>;
|
|
11
|
+
post<T_3 = any>(path: string, data: Record<string, unknown>, opts: RequestOptions): Promise<T_3>;
|
|
12
|
+
put<T_4 = any>(path: string, data: Record<string, unknown>, opts: RequestOptions): Promise<T_4>;
|
|
11
13
|
};
|
|
12
14
|
export default BaseAPI;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as useBaseAPI, useBaseAPIGet, useBaseAPIPut, useBaseAPIPost, useBaseAPIDelete } from "./useBaseAPI";
|
|
2
|
+
import type { UseBaseAPIOptions, UseBaseAPI } from "./useBaseAPI";
|
|
3
|
+
export type { UseBaseAPIOptions, UseBaseAPI };
|
|
4
|
+
export { useBaseAPI, useBaseAPIGet, useBaseAPIPut, useBaseAPIPost, useBaseAPIDelete, };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { AxiosError, AxiosRequestConfig } from "axios";
|
|
2
|
+
import { Ref, ShallowRef } from "vue";
|
|
3
|
+
import type { RequestMethod, RequestOptions } from "../api/base";
|
|
4
|
+
/**
|
|
5
|
+
* UseBaseAPIOptions extends Trees/RequestOptions
|
|
6
|
+
* these options are used only in the instantiation
|
|
7
|
+
* of a new UseBaseAPI composable
|
|
8
|
+
*/
|
|
9
|
+
export interface UseBaseAPIOptions extends RequestOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Whether to immediately fire the execute function during instantiation
|
|
12
|
+
*/
|
|
13
|
+
immediate?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* UseBaseAPI is a composable the wraps up the
|
|
17
|
+
* usage of Trees/BaseAPI and returns reactive
|
|
18
|
+
* state variables along with reusaable execute and abort functions
|
|
19
|
+
*/
|
|
20
|
+
export interface UseBaseAPI<T> {
|
|
21
|
+
/**
|
|
22
|
+
* Axios response data
|
|
23
|
+
*/
|
|
24
|
+
result: Ref<T | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Any errors that may have occurred
|
|
27
|
+
*/
|
|
28
|
+
error: ShallowRef<Error | AxiosError<T> | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Indicates if the request has finished
|
|
31
|
+
*/
|
|
32
|
+
isFinished: Ref<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Indicates if the request is currently loading
|
|
35
|
+
*/
|
|
36
|
+
isLoading: Ref<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Indicates if the request was canceled
|
|
39
|
+
*/
|
|
40
|
+
isAborted: Ref<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Indicates if a first request has completed
|
|
43
|
+
*/
|
|
44
|
+
hasFetched: Ref<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Aborts the current request
|
|
47
|
+
* can be used multiple times
|
|
48
|
+
*/
|
|
49
|
+
abort: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Manually call the axios request
|
|
52
|
+
* can be used multiple times
|
|
53
|
+
*/
|
|
54
|
+
execute: (data?: Record<string, unknown>, opts?: RequestOptions, config?: AxiosRequestConfig) => Promise<T>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* useBaseAPI is a composable wrapper of BaseAPI
|
|
58
|
+
* @param path {string} the api path or full url for the
|
|
59
|
+
* @param method {RequestMethod} the initial request type
|
|
60
|
+
* @param initOpts {UseBaseAPIOptions}
|
|
61
|
+
* @param initConfig {AxiosRequestConfig}
|
|
62
|
+
* @returns {UseBaseAPI<T>}
|
|
63
|
+
*/
|
|
64
|
+
export default function useBaseAPI<T = any>(path: string, method?: RequestMethod, initOpts?: UseBaseAPIOptions, initConfig?: AxiosRequestConfig): {
|
|
65
|
+
result: Ref<T | undefined>;
|
|
66
|
+
error: ShallowRef<Error | AxiosError<T, any> | undefined>;
|
|
67
|
+
isFinished: Ref<boolean>;
|
|
68
|
+
isLoading: Ref<boolean>;
|
|
69
|
+
isAborted: Ref<boolean>;
|
|
70
|
+
hasFetched: Ref<boolean>;
|
|
71
|
+
abort: () => void;
|
|
72
|
+
execute: (data?: Record<string, unknown>, execOpts?: RequestOptions, execConfig?: AxiosRequestConfig) => Promise<T>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* useBaseAPIGet is a convenience function for useBaseAPI
|
|
76
|
+
* @param path {string} the api path or full url for the
|
|
77
|
+
* @param initOpts {UseBaseAPIOptions}
|
|
78
|
+
* @param initConfig {AxiosRequestConfig}
|
|
79
|
+
* @returns {UseBaseAPI<T>}
|
|
80
|
+
*/
|
|
81
|
+
export declare function useBaseAPIGet<T = any>(url: string, initOpts?: UseBaseAPIOptions, initConfig?: AxiosRequestConfig): UseBaseAPI<T>;
|
|
82
|
+
/**
|
|
83
|
+
* useBaseAPIDelete is a convenience function for useBaseAPI
|
|
84
|
+
* @param path {string} the api path or full url for the
|
|
85
|
+
* @param initOpts {UseBaseAPIOptions}
|
|
86
|
+
* @param initConfig {AxiosRequestConfig}
|
|
87
|
+
* @returns {UseBaseAPI<T>}
|
|
88
|
+
*/
|
|
89
|
+
export declare function useBaseAPIDelete<T = any>(url: string, initOpts?: UseBaseAPIOptions, initConfig?: AxiosRequestConfig): UseBaseAPI<T>;
|
|
90
|
+
/**
|
|
91
|
+
* useBaseAPIPost is a convenience function for useBaseAPI
|
|
92
|
+
* @param path {string} the api path or full url for the
|
|
93
|
+
* @param initOpts {UseBaseAPIOptions}
|
|
94
|
+
* @param initConfig {AxiosRequestConfig}
|
|
95
|
+
* @returns {UseBaseAPI<T>}
|
|
96
|
+
*/
|
|
97
|
+
export declare function useBaseAPIPost<T = any>(url: string, initOpts?: UseBaseAPIOptions, initConfig?: AxiosRequestConfig): UseBaseAPI<T>;
|
|
98
|
+
/**
|
|
99
|
+
* useBaseAPIPut is a convenience function for useBaseAPI
|
|
100
|
+
* @param path {string} the api path or full url for the
|
|
101
|
+
* @param initOpts {UseBaseAPIOptions}
|
|
102
|
+
* @param initConfig {AxiosRequestConfig}
|
|
103
|
+
* @returns {UseBaseAPI<T>}
|
|
104
|
+
*/
|
|
105
|
+
export declare function useBaseAPIPut<T = any>(url: string, initOpts?: UseBaseAPIOptions, initConfig?: AxiosRequestConfig): UseBaseAPI<T>;
|
package/types/entry.d.ts
CHANGED
|
@@ -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
|
+
}
|