@xy-planning-network/trees 0.9.1 → 0.9.2-rc2

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.9.1",
3
+ "version": "0.9.2-rc2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "github:xy-planning-network/trees",
@@ -7,5 +7,9 @@ import { useFlashes, useAppFlashes, useAppFlasher } from "./useFlashes";
7
7
  import type { FlashMessage, FlashType, FlashStore, Flasher } from "./useFlashes";
8
8
  export type { FlashMessage, FlashType, FlashStore, Flasher };
9
9
  export { useFlashes, useAppFlashes, useAppFlasher };
10
+ import type { URLParams, URLParamValue, UseTabHistoryOpts } from "./nav";
11
+ export type { URLParams, URLParamValue, UseTabHistoryOpts };
12
+ import { useUrlSearchParams, useTabHistory } from "./nav";
13
+ export { useUrlSearchParams, useTabHistory };
10
14
  import { useSpinnerDisplay, useAppSpinner } from "./useSpinner";
11
15
  export { useSpinnerDisplay, useAppSpinner };
@@ -1,4 +1,4 @@
1
- import type { Component, FunctionalComponent, RenderFunction } from "vue";
1
+ import { Component, FunctionalComponent, MaybeRef, Ref, RenderFunction } from "vue";
2
2
  export interface Item {
3
3
  icon?: Component | RenderFunction;
4
4
  name: string;
@@ -18,3 +18,140 @@ export interface ActionItem {
18
18
  label: string;
19
19
  show?: boolean | ((...args: any[]) => boolean);
20
20
  }
21
+ export interface UseTabHistoryOpts {
22
+ /**
23
+ * The initial value of activeTab.
24
+ * The default value is tabs[0].value.
25
+ *
26
+ * When a valid tab value is found on window.location.search
27
+ * it will replace the initial value.
28
+ */
29
+ initial?: string;
30
+ /**
31
+ * The param name to use on window.location.search.
32
+ * The default is "tab".
33
+ */
34
+ paramName?: string;
35
+ }
36
+ /**
37
+ * UseTabHistory is a convenience composable for adding history
38
+ * support to tab based navigation.
39
+ */
40
+ export interface UseTabHistory {
41
+ /**
42
+ * activeTab is a ref of currently visible tab.
43
+ * The value typically should be one of tabs[number].value.
44
+ */
45
+ activeTab: Ref<string>;
46
+ /**
47
+ * isActiveTab is a helper method for determining if a string value
48
+ * is the currently active tab. This is useful in templates where
49
+ * content is conditionally displayed based on the activeTab.
50
+ *
51
+ * @param tab string typically should be one of tabs[number].value.
52
+ * @return boolean
53
+ */
54
+ isActiveTab: (tab: string) => boolean;
55
+ /**
56
+ * tabs is the Ref of initialized tabs.
57
+ */
58
+ tabs: Ref<{
59
+ label: string;
60
+ value: string;
61
+ }[]>;
62
+ }
63
+ /**
64
+ * useTabHistory
65
+ *
66
+ * Example Usage:
67
+ *
68
+ * const {activeTab, isActiveTab, tabs} = useTabHistory([{label: "Tab One", value: "tab-1"}, {label: "Tab Two", value: "tab-2"}]})
69
+ *
70
+ * <Tabs v-model="activeTab" :tabs="tabs" />
71
+ *
72
+ * <div v-if="isActiveTab('tab-1')">Tab 1 Content</div>
73
+ * <div v-if="isActiveTab('tab-2')">Tab 2 Content</div>
74
+ *
75
+ * @param opts UseTabHistoryOpts
76
+ * @return UseTabHistory
77
+ */
78
+ export declare const useTabHistory: (initialTabs: MaybeRef<{
79
+ label: string;
80
+ value: string;
81
+ }[]>, opts?: UseTabHistoryOpts) => UseTabHistory;
82
+ /**
83
+ * URLParamValue is the set of value types that are
84
+ * currently spec'd to be parsed into a query string.
85
+ */
86
+ export type URLParamValue = string | number | boolean | null | undefined | string[] | number[];
87
+ /**
88
+ * URLParams generic serves as a type constraint ensuring that
89
+ * the search params record used only contains fields that are
90
+ * currently spec'd to be parsed into a query string. See: URLParamValue
91
+ *
92
+ * Example:
93
+ *
94
+ * interface SearchParams {
95
+ * // All Good!
96
+ * q: string
97
+ * count: number
98
+ * isActive: boolean
99
+ * terms: string[]
100
+ * bucketOfNumbers: number[]
101
+ *
102
+ * // Nope!
103
+ * nested: {
104
+ * qTwo: string
105
+ * }
106
+ * }
107
+ */
108
+ export type URLParams<T> = {
109
+ [P in keyof T]: T[P] extends URLParamValue ? T[P] : never;
110
+ };
111
+ /**
112
+ * useUrlSearchParams accepts an initial set of search query params
113
+ * in the shape of Record<string, URLParamValue> and tracks the values
114
+ * of each param on window.location.search.
115
+ *
116
+ * This is a one-way sync where non-nullish, non-falsey values are popped
117
+ * onto window.location.search as they are mutated. The initial values are not read
118
+ * from an existing query string on window.location.search as each values
119
+ * type cannot be inferred safely.
120
+ *
121
+ * This composable ignores query params that may already exist on window.location.search
122
+ * leaving the intact as much as possible, since it's not possible to determine where they
123
+ * came from or what function they may serve.
124
+ *
125
+ * The return value is a ref of the initial set of params.
126
+ *
127
+ * Example Usage:
128
+ * interface SearchParams {
129
+ * q: string
130
+ * isActive: boolean
131
+ * }
132
+ *
133
+ * // NOTE: initial params values should come from the
134
+ * // server in the form of a page prop. Though some
135
+ * // exceptions may exist.
136
+ * const props = defineProps<{
137
+ * initialParams: SearchParams
138
+ * }>
139
+ *
140
+ * const searchParams = useUrlSearchParams(props.initialParam)
141
+ *
142
+ * <BaseInput v-model="searchParams.q" label="Search" type="search" />
143
+ * <Checkbox v-model="searchParams.isActive" label="Is Active" />
144
+ *
145
+ * When q = "jimothy bobbitz" and isActive = false
146
+ * /path?q=jimothy+bobbitz
147
+ *
148
+ * When q = "jimothy bobbitz" and isActive = true
149
+ * /path?q=jimothy+bobbitz&isActive=true
150
+ *
151
+ * * When q = "" and isActive = false
152
+ * /path
153
+ *
154
+ * @param initial any Record<string, URLParamValue> like interface
155
+ * @return Ref<T>
156
+ */
157
+ export declare const useUrlSearchParams: <T>(initial: URLParams<T>) => Ref<import("vue").UnwrapRef<URLParams<T>>>;
@@ -0,0 +1,2 @@
1
+ import { Slot } from "vue";
2
+ export declare function hasSlotContent(slot: Slot | undefined, slotProps?: {}): boolean;
@@ -0,0 +1,21 @@
1
+ import type { TableColumn, TableRow } from "../../composables/table";
2
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
3
+ columns: TableColumn<TableRow>[];
4
+ rows: TableRow[];
5
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
6
+ columns?: unknown;
7
+ rows?: unknown;
8
+ } & {
9
+ columns: TableColumn<TableRow>[];
10
+ rows: TableRow[];
11
+ } & {}>, {}>;
12
+ export default _default;
13
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
14
+ type __VLS_TypePropsToRuntimeProps<T> = {
15
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
16
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
17
+ } : {
18
+ type: import('vue').PropType<T[K]>;
19
+ required: true;
20
+ };
21
+ };
@@ -0,0 +1,27 @@
1
+ import * as TableTypes from "../../composables/table";
2
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
3
+ tableData: Omit<TableTypes.Static, "currentUser">;
4
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
5
+ tableData?: unknown;
6
+ } & {
7
+ tableData: Omit<TableTypes.Static, "currentUser">;
8
+ } & {}>, {}>, {
9
+ actions: (_: {
10
+ row: Record<string, unknown>;
11
+ }) => any;
12
+ }>;
13
+ export default _default;
14
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
15
+ type __VLS_TypePropsToRuntimeProps<T> = {
16
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
17
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
18
+ } : {
19
+ type: import('vue').PropType<T[K]>;
20
+ required: true;
21
+ };
22
+ };
23
+ type __VLS_WithTemplateSlots<T, S> = T & {
24
+ new (): {
25
+ $slots: S;
26
+ };
27
+ };
@@ -0,0 +1,39 @@
1
+ import * as TableTypes from "../../composables/table";
2
+ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ clickable?: boolean | undefined;
4
+ loader?: boolean | undefined;
5
+ tableData: TableTypes.Dynamic;
6
+ }>, {
7
+ clickable: boolean;
8
+ loader: boolean;
9
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ handleClick: (v: any) => void;
11
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
12
+ tableData?: unknown;
13
+ clickable?: unknown;
14
+ loader?: unknown;
15
+ } & {
16
+ tableData: TableTypes.Dynamic;
17
+ clickable: boolean;
18
+ loader: boolean;
19
+ } & {}> & {
20
+ onHandleClick?: ((v: any) => any) | undefined;
21
+ }, {
22
+ clickable: boolean;
23
+ loader: boolean;
24
+ }>;
25
+ export default _default;
26
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
27
+ type __VLS_TypePropsToRuntimeProps<T> = {
28
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
29
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
30
+ } : {
31
+ type: import('vue').PropType<T[K]>;
32
+ required: true;
33
+ };
34
+ };
35
+ type __VLS_WithDefaults<P, D> = {
36
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
37
+ default: D[K];
38
+ } : P[K];
39
+ };
@@ -0,0 +1,18 @@
1
+ import type { ActionMenuItemCallback } from "../../composables/nav";
2
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
3
+ items: ActionMenuItemCallback[];
4
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
5
+ items?: unknown;
6
+ } & {
7
+ items: ActionMenuItemCallback[];
8
+ } & {}>, {}>;
9
+ export default _default;
10
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
11
+ type __VLS_TypePropsToRuntimeProps<T> = {
12
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
13
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
14
+ } : {
15
+ type: import('vue').PropType<T[K]>;
16
+ required: true;
17
+ };
18
+ };
@@ -0,0 +1,22 @@
1
+ import type { ActionMenuEmit } from "../../composables/nav";
2
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
3
+ items: ActionMenuEmit[];
4
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
+ click: (v: string) => void;
6
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
7
+ items?: unknown;
8
+ } & {
9
+ items: ActionMenuEmit[];
10
+ } & {}> & {
11
+ onClick?: ((v: string) => any) | undefined;
12
+ }, {}>;
13
+ export default _default;
14
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
15
+ type __VLS_TypePropsToRuntimeProps<T> = {
16
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
17
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
18
+ } : {
19
+ type: import('vue').PropType<T[K]>;
20
+ required: true;
21
+ };
22
+ };