@verikit/vue 0.24.3 → 0.25.0
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/README.md +5 -1
- package/dist/components/combobox.d.ts +163 -0
- package/dist/components/combobox.d.ts.map +1 -0
- package/dist/components/combobox.js +179 -0
- package/dist/layout/render-schema-node.d.ts.map +1 -1
- package/dist/layout/render-schema-node.js +6 -3
- package/dist/layout/types.d.ts +5 -0
- package/dist/layout/types.d.ts.map +1 -1
- package/dist/query/use-resource-table.d.ts +7 -2
- package/dist/query/use-resource-table.d.ts.map +1 -1
- package/dist/query/use-resource-table.js +27 -8
- package/dist/relationships/belongs-to-field.d.ts +39 -2
- package/dist/relationships/belongs-to-field.d.ts.map +1 -1
- package/dist/relationships/belongs-to-field.js +92 -41
- package/dist/relationships/use-relationship-picker.d.ts +41 -0
- package/dist/relationships/use-relationship-picker.d.ts.map +1 -0
- package/dist/relationships/use-relationship-picker.js +92 -0
- package/dist/resource/resource-detail.d.ts +41 -2
- package/dist/resource/resource-detail.d.ts.map +1 -1
- package/dist/resource/resource-detail.js +65 -20
- package/dist/resource/resource-form.d.ts.map +1 -1
- package/dist/resource/resource-form.js +1 -0
- package/dist/resource/resource-table.d.ts +46 -0
- package/dist/resource/resource-table.d.ts.map +1 -1
- package/dist/resource/resource-table.js +65 -8
- package/package.json +23 -13
- package/tailwind-sources.css +3 -0
package/README.md
CHANGED
|
@@ -4,7 +4,11 @@ Vue UI bindings for VeriKit resource workflows.
|
|
|
4
4
|
|
|
5
5
|
See the [VeriKit documentation](https://verikit.dev) for setup and usage.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Production
|
|
8
|
+
|
|
9
|
+
You don't need this to get started. Read it before you deploy.
|
|
10
|
+
|
|
11
|
+
### Cache identity
|
|
8
12
|
|
|
9
13
|
Queries, mutations, and optimistic updates are isolated by client. Keep the client
|
|
10
14
|
stable during a session; replace it when the account, tenant, or access identity
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* shadcn-compatible combobox root built on Reka UI. `value` is the selected
|
|
4
|
+
* item (`null` for none) and `open` the popup's state; both are controlled.
|
|
5
|
+
* Clearing (see {@link ComboboxInput}'s `showClear`) reports `null`. Other
|
|
6
|
+
* Reka `ComboboxRoot` props, such as `ignoreFilter`, pass through.
|
|
7
|
+
*/
|
|
8
|
+
export declare const Combobox: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
9
|
+
value: {
|
|
10
|
+
type: PropType<string | null | undefined>;
|
|
11
|
+
default: undefined;
|
|
12
|
+
};
|
|
13
|
+
open: {
|
|
14
|
+
type: BooleanConstructor;
|
|
15
|
+
default: boolean;
|
|
16
|
+
};
|
|
17
|
+
disabled: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
default: boolean;
|
|
20
|
+
};
|
|
21
|
+
name: {
|
|
22
|
+
type: PropType<string | undefined>;
|
|
23
|
+
default: undefined;
|
|
24
|
+
};
|
|
25
|
+
onValueChange: {
|
|
26
|
+
type: PropType<(value: string | null) => void>;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
onOpenChange: {
|
|
30
|
+
type: PropType<(open: boolean) => void>;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
36
|
+
value: {
|
|
37
|
+
type: PropType<string | null | undefined>;
|
|
38
|
+
default: undefined;
|
|
39
|
+
};
|
|
40
|
+
open: {
|
|
41
|
+
type: BooleanConstructor;
|
|
42
|
+
default: boolean;
|
|
43
|
+
};
|
|
44
|
+
disabled: {
|
|
45
|
+
type: BooleanConstructor;
|
|
46
|
+
default: boolean;
|
|
47
|
+
};
|
|
48
|
+
name: {
|
|
49
|
+
type: PropType<string | undefined>;
|
|
50
|
+
default: undefined;
|
|
51
|
+
};
|
|
52
|
+
onValueChange: {
|
|
53
|
+
type: PropType<(value: string | null) => void>;
|
|
54
|
+
default: undefined;
|
|
55
|
+
};
|
|
56
|
+
onOpenChange: {
|
|
57
|
+
type: PropType<(open: boolean) => void>;
|
|
58
|
+
default: undefined;
|
|
59
|
+
};
|
|
60
|
+
}>> & Readonly<{}>, {
|
|
61
|
+
name: string | undefined;
|
|
62
|
+
value: string | null | undefined;
|
|
63
|
+
disabled: boolean;
|
|
64
|
+
onValueChange: (value: string | null) => void;
|
|
65
|
+
open: boolean;
|
|
66
|
+
onOpenChange: (open: boolean) => void;
|
|
67
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
68
|
+
/**
|
|
69
|
+
* The combobox's text input, with a toggle and an optional clear button. The
|
|
70
|
+
* input's text is controlled by `value`; `onInputValueChange` reports only
|
|
71
|
+
* what's typed, not the label Reka writes back after a selection.
|
|
72
|
+
*/
|
|
73
|
+
export declare const ComboboxInput: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
74
|
+
value: {
|
|
75
|
+
type: StringConstructor;
|
|
76
|
+
default: string;
|
|
77
|
+
};
|
|
78
|
+
showClear: {
|
|
79
|
+
type: BooleanConstructor;
|
|
80
|
+
default: boolean;
|
|
81
|
+
};
|
|
82
|
+
readOnly: {
|
|
83
|
+
type: BooleanConstructor;
|
|
84
|
+
default: boolean;
|
|
85
|
+
};
|
|
86
|
+
onInputValueChange: {
|
|
87
|
+
type: PropType<(value: string) => void>;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
93
|
+
value: {
|
|
94
|
+
type: StringConstructor;
|
|
95
|
+
default: string;
|
|
96
|
+
};
|
|
97
|
+
showClear: {
|
|
98
|
+
type: BooleanConstructor;
|
|
99
|
+
default: boolean;
|
|
100
|
+
};
|
|
101
|
+
readOnly: {
|
|
102
|
+
type: BooleanConstructor;
|
|
103
|
+
default: boolean;
|
|
104
|
+
};
|
|
105
|
+
onInputValueChange: {
|
|
106
|
+
type: PropType<(value: string) => void>;
|
|
107
|
+
default: undefined;
|
|
108
|
+
};
|
|
109
|
+
}>> & Readonly<{}>, {
|
|
110
|
+
value: string;
|
|
111
|
+
readOnly: boolean;
|
|
112
|
+
showClear: boolean;
|
|
113
|
+
onInputValueChange: (value: string) => void;
|
|
114
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
115
|
+
/** Renders the combobox popup, positioned under its input. */
|
|
116
|
+
export declare const ComboboxContent: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
117
|
+
sideOffset: {
|
|
118
|
+
type: NumberConstructor;
|
|
119
|
+
default: number;
|
|
120
|
+
};
|
|
121
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
122
|
+
[key: string]: any;
|
|
123
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
124
|
+
sideOffset: {
|
|
125
|
+
type: NumberConstructor;
|
|
126
|
+
default: number;
|
|
127
|
+
};
|
|
128
|
+
}>> & Readonly<{}>, {
|
|
129
|
+
sideOffset: number;
|
|
130
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
131
|
+
/** Lists the combobox's items. */
|
|
132
|
+
export declare const ComboboxList: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
133
|
+
[key: string]: any;
|
|
134
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
135
|
+
/** Renders a selectable item, with a check when it's the current value. */
|
|
136
|
+
export declare const ComboboxItem: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
137
|
+
value: {
|
|
138
|
+
type: StringConstructor;
|
|
139
|
+
required: true;
|
|
140
|
+
};
|
|
141
|
+
disabled: {
|
|
142
|
+
type: BooleanConstructor;
|
|
143
|
+
default: boolean;
|
|
144
|
+
};
|
|
145
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
146
|
+
[key: string]: any;
|
|
147
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
148
|
+
value: {
|
|
149
|
+
type: StringConstructor;
|
|
150
|
+
required: true;
|
|
151
|
+
};
|
|
152
|
+
disabled: {
|
|
153
|
+
type: BooleanConstructor;
|
|
154
|
+
default: boolean;
|
|
155
|
+
};
|
|
156
|
+
}>> & Readonly<{}>, {
|
|
157
|
+
disabled: boolean;
|
|
158
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
159
|
+
/** Shown in place of the list when it has no items. */
|
|
160
|
+
export declare const ComboboxEmpty: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
161
|
+
[key: string]: any;
|
|
162
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
163
|
+
//# sourceMappingURL=combobox.d.ts.map
|
|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;;;;;;;;;;;;;;;;;;4EAsCvB,CAAC;AAEH,uDAAuD;AACvD,eAAO,MAAM,aAAa;;2OAoBxB,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { CheckIcon, ChevronDownIcon, XIcon } from "lucide-vue-next";
|
|
2
|
+
import { ComboboxAnchor, ComboboxCancel, ComboboxContent as RekaComboboxContent, ComboboxEmpty as RekaComboboxEmpty, ComboboxInput as RekaComboboxInput, ComboboxItem as RekaComboboxItem, ComboboxItemIndicator, ComboboxPortal, ComboboxRoot, ComboboxTrigger, ComboboxViewport, } from "reka-ui";
|
|
3
|
+
import { defineComponent, h } from "vue";
|
|
4
|
+
import { cn } from "#lib/utils";
|
|
5
|
+
/**
|
|
6
|
+
* shadcn-compatible combobox root built on Reka UI. `value` is the selected
|
|
7
|
+
* item (`null` for none) and `open` the popup's state; both are controlled.
|
|
8
|
+
* Clearing (see {@link ComboboxInput}'s `showClear`) reports `null`. Other
|
|
9
|
+
* Reka `ComboboxRoot` props, such as `ignoreFilter`, pass through.
|
|
10
|
+
*/
|
|
11
|
+
export const Combobox = defineComponent({
|
|
12
|
+
name: "Combobox",
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
props: {
|
|
15
|
+
value: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: undefined,
|
|
18
|
+
},
|
|
19
|
+
open: { type: Boolean, default: false },
|
|
20
|
+
disabled: { type: Boolean, default: false },
|
|
21
|
+
name: { type: String, default: undefined },
|
|
22
|
+
onValueChange: {
|
|
23
|
+
type: Function,
|
|
24
|
+
default: undefined,
|
|
25
|
+
},
|
|
26
|
+
onOpenChange: {
|
|
27
|
+
type: Function,
|
|
28
|
+
default: undefined,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
setup(props, { slots, attrs }) {
|
|
32
|
+
return () => h(ComboboxRoot, {
|
|
33
|
+
"data-slot": "combobox",
|
|
34
|
+
modelValue: props.value ?? null,
|
|
35
|
+
open: props.open,
|
|
36
|
+
disabled: props.disabled,
|
|
37
|
+
name: props.name,
|
|
38
|
+
resetModelValueOnClear: true,
|
|
39
|
+
"onUpdate:modelValue": (value) => props.onValueChange?.(value ?? null),
|
|
40
|
+
"onUpdate:open": (open) => props.onOpenChange?.(open),
|
|
41
|
+
...attrs,
|
|
42
|
+
}, slots);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* The combobox's text input, with a toggle and an optional clear button. The
|
|
47
|
+
* input's text is controlled by `value`; `onInputValueChange` reports only
|
|
48
|
+
* what's typed, not the label Reka writes back after a selection.
|
|
49
|
+
*/
|
|
50
|
+
export const ComboboxInput = defineComponent({
|
|
51
|
+
name: "ComboboxInput",
|
|
52
|
+
inheritAttrs: false,
|
|
53
|
+
props: {
|
|
54
|
+
value: { type: String, default: "" },
|
|
55
|
+
showClear: { type: Boolean, default: false },
|
|
56
|
+
readOnly: { type: Boolean, default: false },
|
|
57
|
+
onInputValueChange: {
|
|
58
|
+
type: Function,
|
|
59
|
+
default: undefined,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
setup(props, { attrs }) {
|
|
63
|
+
return () => {
|
|
64
|
+
const { class: className, ...rest } = attrs;
|
|
65
|
+
return h(ComboboxAnchor, {
|
|
66
|
+
"data-slot": "combobox-input-group",
|
|
67
|
+
class: "relative flex w-full items-center",
|
|
68
|
+
}, {
|
|
69
|
+
default: () => [
|
|
70
|
+
h(RekaComboboxInput, {
|
|
71
|
+
"data-slot": "combobox-input",
|
|
72
|
+
class: cn("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent py-1 pr-14 pl-2.5 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
|
|
73
|
+
modelValue: props.value,
|
|
74
|
+
readonly: props.readOnly || undefined,
|
|
75
|
+
onInput: (event) => props.onInputValueChange?.(event.target.value),
|
|
76
|
+
...rest,
|
|
77
|
+
}),
|
|
78
|
+
h("div", {
|
|
79
|
+
class: "absolute right-1 flex items-center gap-0.5 text-muted-foreground",
|
|
80
|
+
}, [
|
|
81
|
+
props.showClear
|
|
82
|
+
? h(ComboboxCancel, {
|
|
83
|
+
"data-slot": "combobox-clear",
|
|
84
|
+
"aria-label": "Clear",
|
|
85
|
+
class: "flex size-6 items-center justify-center rounded-md hover:text-foreground",
|
|
86
|
+
}, { default: () => h(XIcon, { class: "size-3.5" }) })
|
|
87
|
+
: null,
|
|
88
|
+
h(ComboboxTrigger, {
|
|
89
|
+
"data-slot": "combobox-trigger",
|
|
90
|
+
"aria-label": "Show options",
|
|
91
|
+
disabled: props.readOnly,
|
|
92
|
+
class: "flex size-6 items-center justify-center rounded-md hover:text-foreground disabled:pointer-events-none",
|
|
93
|
+
}, { default: () => h(ChevronDownIcon, { class: "size-4" }) }),
|
|
94
|
+
]),
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
/** Renders the combobox popup, positioned under its input. */
|
|
101
|
+
export const ComboboxContent = defineComponent({
|
|
102
|
+
name: "ComboboxContent",
|
|
103
|
+
inheritAttrs: false,
|
|
104
|
+
props: {
|
|
105
|
+
sideOffset: { type: Number, default: 4 },
|
|
106
|
+
},
|
|
107
|
+
setup(props, { slots, attrs }) {
|
|
108
|
+
return () => {
|
|
109
|
+
const { class: className, ...rest } = attrs;
|
|
110
|
+
return h(ComboboxPortal, {}, {
|
|
111
|
+
default: () => h(RekaComboboxContent, {
|
|
112
|
+
"data-slot": "combobox-content",
|
|
113
|
+
position: "popper",
|
|
114
|
+
sideOffset: props.sideOffset,
|
|
115
|
+
class: cn("isolate z-50 max-h-(--reka-combobox-content-available-height) w-(--reka-combobox-trigger-width) min-w-36 origin-(--reka-combobox-content-transform-origin) overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95", className),
|
|
116
|
+
...rest,
|
|
117
|
+
}, slots),
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
/** Lists the combobox's items. */
|
|
123
|
+
export const ComboboxList = defineComponent({
|
|
124
|
+
name: "ComboboxList",
|
|
125
|
+
inheritAttrs: false,
|
|
126
|
+
setup(_props, { slots, attrs }) {
|
|
127
|
+
return () => {
|
|
128
|
+
const { class: className, ...rest } = attrs;
|
|
129
|
+
return h(ComboboxViewport, {
|
|
130
|
+
"data-slot": "combobox-list",
|
|
131
|
+
class: cn("outline-none", className),
|
|
132
|
+
...rest,
|
|
133
|
+
}, slots);
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
/** Renders a selectable item, with a check when it's the current value. */
|
|
138
|
+
export const ComboboxItem = defineComponent({
|
|
139
|
+
name: "ComboboxItem",
|
|
140
|
+
inheritAttrs: false,
|
|
141
|
+
props: {
|
|
142
|
+
value: { type: String, required: true },
|
|
143
|
+
disabled: { type: Boolean, default: false },
|
|
144
|
+
},
|
|
145
|
+
setup(props, { slots, attrs }) {
|
|
146
|
+
return () => {
|
|
147
|
+
const { class: className, ...rest } = attrs;
|
|
148
|
+
return h(RekaComboboxItem, {
|
|
149
|
+
"data-slot": "combobox-item",
|
|
150
|
+
value: props.value,
|
|
151
|
+
disabled: props.disabled,
|
|
152
|
+
class: cn("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground", className),
|
|
153
|
+
...rest,
|
|
154
|
+
}, {
|
|
155
|
+
default: () => [
|
|
156
|
+
slots.default?.(),
|
|
157
|
+
h(ComboboxItemIndicator, {
|
|
158
|
+
class: "pointer-events-none absolute right-2 flex size-4 items-center justify-center",
|
|
159
|
+
}, { default: () => h(CheckIcon, { class: "size-4" }) }),
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
/** Shown in place of the list when it has no items. */
|
|
166
|
+
export const ComboboxEmpty = defineComponent({
|
|
167
|
+
name: "ComboboxEmpty",
|
|
168
|
+
inheritAttrs: false,
|
|
169
|
+
setup(_props, { slots, attrs }) {
|
|
170
|
+
return () => {
|
|
171
|
+
const { class: className, ...rest } = attrs;
|
|
172
|
+
return h(RekaComboboxEmpty, {
|
|
173
|
+
"data-slot": "combobox-empty",
|
|
174
|
+
class: cn("px-1.5 py-1 text-sm text-muted-foreground", className),
|
|
175
|
+
...rest,
|
|
176
|
+
}, slots);
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-schema-node.d.ts","sourceRoot":"","sources":["../../src/layout/render-schema-node.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAU/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"render-schema-node.d.ts","sourceRoot":"","sources":["../../src/layout/render-schema-node.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAU/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AA2W/E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,UAAU,CAsBzE;AAED,8CAA8C;AAC9C,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,GAAG,IAAI,EACR,EAAE,qBAAqB,GAAG,KAAK,EAAE,CAMjC"}
|
|
@@ -90,6 +90,7 @@ function renderRelationshipNode(node, props, path) {
|
|
|
90
90
|
const foreignKeyPath = [...path, foreignKeyName];
|
|
91
91
|
return h(BelongsToRelationshipField, {
|
|
92
92
|
relationship: node,
|
|
93
|
+
resourceName: props.resourceName,
|
|
93
94
|
className: props.className,
|
|
94
95
|
value: getValueAtPath(props.values, foreignKeyPath),
|
|
95
96
|
error: props.errors?.[pathKey(foreignKeyPath)],
|
|
@@ -110,9 +111,11 @@ function renderSectionNode(node, props, path) {
|
|
|
110
111
|
]);
|
|
111
112
|
}
|
|
112
113
|
function renderGridNode(node, props, path) {
|
|
113
|
-
return h("div",
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
return h("div",
|
|
115
|
+
// Stacks to one column on narrow screens; `node.columns` applies from `sm` up.
|
|
116
|
+
{
|
|
117
|
+
class: cn("grid grid-cols-1 gap-4 sm:grid-cols-[repeat(var(--vk-grid-columns),minmax(0,1fr))]", props.className),
|
|
118
|
+
style: { "--vk-grid-columns": node.columns },
|
|
116
119
|
}, [
|
|
117
120
|
RenderSchemaTree({
|
|
118
121
|
...schemaRenderProps(props),
|
package/dist/layout/types.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ export type SchemaActionRegistry = Partial<Record<string, SchemaActionSource>>;
|
|
|
16
16
|
export interface SchemaRenderProps {
|
|
17
17
|
/** Current form values. */
|
|
18
18
|
values: Record<string, unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* Name of the resource this tree belongs to. `belongsTo` pickers load
|
|
21
|
+
* their options from that resource's `/relationships/:name` route.
|
|
22
|
+
*/
|
|
23
|
+
resourceName?: string;
|
|
19
24
|
/** Path prefix for nested schema nodes. */
|
|
20
25
|
path?: SchemaPath;
|
|
21
26
|
/** Error content keyed by sch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vue-query";
|
|
3
|
-
import type { ListActionAvailability, ListParams, ListResponse } from "@verikit/client";
|
|
3
|
+
import type { ListActionAvailability, ListParams, ListResponse, RelationshipLabels } from "@verikit/client";
|
|
4
4
|
import type { FieldSchema, Resource, ResourceSchema } from "@verikit/core";
|
|
5
5
|
import { type ComputedRef, type Ref } from "vue";
|
|
6
6
|
declare const resourceTableFeatures: {
|
|
@@ -44,10 +44,15 @@ export interface UseResourceTableResult<TRecord extends RowData = Record<string,
|
|
|
44
44
|
setFilters: (filters: ResourceTableFilters) => void;
|
|
45
45
|
/** The actions the actor can't run on the current page, when requested with `includeActions`. */
|
|
46
46
|
actions: ComputedRef<ListActionAvailability | undefined>;
|
|
47
|
+
/** Display labels for the current page's `belongsTo` relationships, when the resource has any to show. */
|
|
48
|
+
relationships: ComputedRef<RelationshipLabels | undefined>;
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Creates a TanStack Table from a resource's schema, with automatic columns
|
|
50
|
-
* and server-side pagination, sorting, and search.
|
|
52
|
+
* and server-side pagination, sorting, and search. A `belongsTo`
|
|
53
|
+
* relationship gets a column in place of its foreign-key field, showing the
|
|
54
|
+
* related record's `displayField` (fetched with the page, one query per
|
|
55
|
+
* relationship on the server), or the raw key when there's no label.
|
|
51
56
|
*/
|
|
52
57
|
export declare function useResourceTable<TRecord extends RowData = Record<string, unknown>>(resource: UseResourceTableSource, { pageSize, includeActions }?: UseResourceTableOptions): UseResourceTableResult<TRecord>;
|
|
53
58
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-resource-table.d.ts","sourceRoot":"","sources":["../../src/query/use-resource-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,KAAK,OAAO,EAGZ,KAAK,KAAK,EACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAY,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,YAAY,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AC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC;IAC3E,sDAAsD;IACtD,KAAK,EAAE,kBAAkB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;IACjE;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,2DAA2D;IAC3D,OAAO,EAAE,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACnC,uDAAuD;IACvD,UAAU,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACpD,iGAAiG;IACjG,OAAO,EAAE,WAAW,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAAC;IACzD,0GAA0G;IAC1G,aAAa,EAAE,WAAW,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CAC5D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,SAAS,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEjD,QAAQ,EAAE,sBAAsB,EAChC,EAAE,QAAa,EAAE,cAAsB,EAAE,GAAE,uBAA4B,GACtE,sBAAsB,CAAC,OAAO,CAAC,CAyHjC"}
|
|
@@ -2,6 +2,7 @@ import { columnFilteringFeature, functionalUpdate, globalFilteringFeature, rowPa
|
|
|
2
2
|
import { useQuery } from "@tanstack/vue-query";
|
|
3
3
|
import { recordId } from "@verikit/ui-core/query/optimistic";
|
|
4
4
|
import { resolveVerikitFields } from "@verikit/ui-core/form/resolve-fields";
|
|
5
|
+
import { needsRelationshipLabels, relationshipCellText, resourceColumnSpecs, } from "@verikit/ui-core/layout/table-columns";
|
|
5
6
|
import { resourceQueryKeys } from "@verikit/ui-core/query/query-keys";
|
|
6
7
|
import { computed, ref } from "vue";
|
|
7
8
|
import { useVerikitClient } from "../client/use-verikit-client.js";
|
|
@@ -16,18 +17,16 @@ const resourceTableFeatures = tableFeatures({
|
|
|
16
17
|
});
|
|
17
18
|
/**
|
|
18
19
|
* Creates a TanStack Table from a resource's schema, with automatic columns
|
|
19
|
-
* and server-side pagination, sorting, and search.
|
|
20
|
+
* and server-side pagination, sorting, and search. A `belongsTo`
|
|
21
|
+
* relationship gets a column in place of its foreign-key field, showing the
|
|
22
|
+
* related record's `displayField` (fetched with the page, one query per
|
|
23
|
+
* relationship on the server), or the raw key when there's no label.
|
|
20
24
|
*/
|
|
21
25
|
export function useResourceTable(resource, { pageSize = 25, includeActions = false } = {}) {
|
|
22
26
|
const client = useVerikitClient();
|
|
23
27
|
const fields = resolveVerikitFields(resource);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
.map((field) => ({
|
|
27
|
-
accessorKey: field.name,
|
|
28
|
-
header: field.label ?? field.name,
|
|
29
|
-
enableSorting: field.sortable ?? false,
|
|
30
|
-
})));
|
|
28
|
+
const columnSpecs = resourceColumnSpecs(resource);
|
|
29
|
+
const includeRelationships = needsRelationshipLabels(resource);
|
|
31
30
|
const sorting = ref([]);
|
|
32
31
|
const pagination = ref({ pageIndex: 0, pageSize });
|
|
33
32
|
const globalFilter = ref("");
|
|
@@ -59,6 +58,7 @@ export function useResourceTable(resource, { pageSize = 25, includeActions = fal
|
|
|
59
58
|
: undefined,
|
|
60
59
|
...(hasFilters ? { filters: filters.value } : {}),
|
|
61
60
|
...(includeActions ? { includeActions } : {}),
|
|
61
|
+
...(includeRelationships ? { includeRelationships } : {}),
|
|
62
62
|
};
|
|
63
63
|
});
|
|
64
64
|
const list = useQuery({
|
|
@@ -67,6 +67,24 @@ export function useResourceTable(resource, { pageSize = 25, includeActions = fal
|
|
|
67
67
|
.resource(resource.name)
|
|
68
68
|
.list(listParams.value, { signal }),
|
|
69
69
|
});
|
|
70
|
+
const relationships = computed(() => list.data.value?.relationships);
|
|
71
|
+
const columns = computed(() => {
|
|
72
|
+
const labels = relationships.value;
|
|
73
|
+
return columnSpecs.map((spec) => spec.kind === "field"
|
|
74
|
+
? {
|
|
75
|
+
accessorKey: spec.field.name,
|
|
76
|
+
header: spec.field.label ?? spec.field.name,
|
|
77
|
+
enableSorting: spec.field.sortable ?? false,
|
|
78
|
+
}
|
|
79
|
+
: {
|
|
80
|
+
id: spec.name,
|
|
81
|
+
// Records are plain field maps at runtime (see `ResourceTable`).
|
|
82
|
+
accessorFn: (record) => relationshipCellText(labels, spec, record),
|
|
83
|
+
header: spec.label,
|
|
84
|
+
// Sorting by a foreign key wouldn't follow the labels shown.
|
|
85
|
+
enableSorting: false,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
70
88
|
const table = useTable({
|
|
71
89
|
features: resourceTableFeatures,
|
|
72
90
|
columns,
|
|
@@ -102,5 +120,6 @@ export function useResourceTable(resource, { pageSize = 25, includeActions = fal
|
|
|
102
120
|
filters,
|
|
103
121
|
setFilters: handleFiltersChange,
|
|
104
122
|
actions: computed(() => list.data.value?.actions),
|
|
123
|
+
relationships,
|
|
105
124
|
};
|
|
106
125
|
}
|
|
@@ -1,42 +1,62 @@
|
|
|
1
1
|
import type { BelongsToRelationshipSchema } from "@verikit/core";
|
|
2
2
|
import { type PropType, type VNodeChild } from "vue";
|
|
3
3
|
/**
|
|
4
|
-
* Renders a `belongsTo` relationship as a permission-aware
|
|
5
|
-
* reading and writing the related record's ID through its `.via()`
|
|
4
|
+
* Renders a `belongsTo` relationship as a permission-aware, searchable
|
|
5
|
+
* combobox, reading and writing the related record's ID through its `.via()`
|
|
6
|
+
* field. Typing searches the server (the target's `displayField` and
|
|
7
|
+
* `.searchable()` fields), options load 25 at a time with "Load more", and the
|
|
8
|
+
* selected record's label is shown even when it isn't among the loaded
|
|
9
|
+
* options.
|
|
6
10
|
*/
|
|
7
11
|
export declare const BelongsToRelationshipField: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
12
|
relationship: {
|
|
9
13
|
type: PropType<BelongsToRelationshipSchema>;
|
|
10
14
|
required: true;
|
|
11
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Name of the resource that owns the relationship (the one being edited).
|
|
18
|
+
* Options come from its `/relationships/:name` route. Defaults to the
|
|
19
|
+
* target resource, which only matches for a self-referencing relationship.
|
|
20
|
+
*/
|
|
21
|
+
resourceName: {
|
|
22
|
+
type: PropType<string | undefined>;
|
|
23
|
+
default: undefined;
|
|
24
|
+
};
|
|
12
25
|
id: {
|
|
13
26
|
type: PropType<string | undefined>;
|
|
14
27
|
default: undefined;
|
|
15
28
|
};
|
|
29
|
+
/** Current foreign-key value (the selected record's id), if any. */
|
|
16
30
|
value: {
|
|
17
31
|
type: PropType<unknown>;
|
|
18
32
|
required: false;
|
|
19
33
|
};
|
|
34
|
+
/** Error content shown below the picker and linked with ARIA. */
|
|
20
35
|
error: {
|
|
21
36
|
type: PropType<VNodeChild>;
|
|
22
37
|
required: false;
|
|
23
38
|
};
|
|
39
|
+
/** Disables the picker. */
|
|
24
40
|
disabled: {
|
|
25
41
|
type: PropType<boolean | undefined>;
|
|
26
42
|
default: undefined;
|
|
27
43
|
};
|
|
44
|
+
/** Marks the picker as read-only. */
|
|
28
45
|
readOnly: {
|
|
29
46
|
type: PropType<boolean | undefined>;
|
|
30
47
|
default: undefined;
|
|
31
48
|
};
|
|
49
|
+
/** Class name applied to the outer wrapper. */
|
|
32
50
|
className: {
|
|
33
51
|
type: PropType<string | undefined>;
|
|
34
52
|
default: undefined;
|
|
35
53
|
};
|
|
54
|
+
/** Called with the next foreign-key value (or `null` when cleared). */
|
|
36
55
|
onValueChange: {
|
|
37
56
|
type: PropType<((value: string | null) => void) | undefined>;
|
|
38
57
|
default: undefined;
|
|
39
58
|
};
|
|
59
|
+
/** Called when the picker's input loses focus. */
|
|
40
60
|
onBlur: {
|
|
41
61
|
type: PropType<(() => void) | undefined>;
|
|
42
62
|
default: undefined;
|
|
@@ -48,34 +68,50 @@ export declare const BelongsToRelationshipField: import("vue").DefineComponent<i
|
|
|
48
68
|
type: PropType<BelongsToRelationshipSchema>;
|
|
49
69
|
required: true;
|
|
50
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Name of the resource that owns the relationship (the one being edited).
|
|
73
|
+
* Options come from its `/relationships/:name` route. Defaults to the
|
|
74
|
+
* target resource, which only matches for a self-referencing relationship.
|
|
75
|
+
*/
|
|
76
|
+
resourceName: {
|
|
77
|
+
type: PropType<string | undefined>;
|
|
78
|
+
default: undefined;
|
|
79
|
+
};
|
|
51
80
|
id: {
|
|
52
81
|
type: PropType<string | undefined>;
|
|
53
82
|
default: undefined;
|
|
54
83
|
};
|
|
84
|
+
/** Current foreign-key value (the selected record's id), if any. */
|
|
55
85
|
value: {
|
|
56
86
|
type: PropType<unknown>;
|
|
57
87
|
required: false;
|
|
58
88
|
};
|
|
89
|
+
/** Error content shown below the picker and linked with ARIA. */
|
|
59
90
|
error: {
|
|
60
91
|
type: PropType<VNodeChild>;
|
|
61
92
|
required: false;
|
|
62
93
|
};
|
|
94
|
+
/** Disables the picker. */
|
|
63
95
|
disabled: {
|
|
64
96
|
type: PropType<boolean | undefined>;
|
|
65
97
|
default: undefined;
|
|
66
98
|
};
|
|
99
|
+
/** Marks the picker as read-only. */
|
|
67
100
|
readOnly: {
|
|
68
101
|
type: PropType<boolean | undefined>;
|
|
69
102
|
default: undefined;
|
|
70
103
|
};
|
|
104
|
+
/** Class name applied to the outer wrapper. */
|
|
71
105
|
className: {
|
|
72
106
|
type: PropType<string | undefined>;
|
|
73
107
|
default: undefined;
|
|
74
108
|
};
|
|
109
|
+
/** Called with the next foreign-key value (or `null` when cleared). */
|
|
75
110
|
onValueChange: {
|
|
76
111
|
type: PropType<((value: string | null) => void) | undefined>;
|
|
77
112
|
default: undefined;
|
|
78
113
|
};
|
|
114
|
+
/** Called when the picker's input loses focus. */
|
|
79
115
|
onBlur: {
|
|
80
116
|
type: PropType<(() => void) | undefined>;
|
|
81
117
|
default: undefined;
|
|
@@ -87,5 +123,6 @@ export declare const BelongsToRelationshipField: import("vue").DefineComponent<i
|
|
|
87
123
|
disabled: boolean | undefined;
|
|
88
124
|
onValueChange: ((value: string | null) => void) | undefined;
|
|
89
125
|
readOnly: boolean | undefined;
|
|
126
|
+
resourceName: string | undefined;
|
|
90
127
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
91
128
|
//# sourceMappingURL=belongs-to-field.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"belongs-to-field.d.ts","sourceRoot":"","sources":["../../src/relationships/belongs-to-field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"belongs-to-field.d.ts","sourceRoot":"","sources":["../../src/relationships/belongs-to-field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAA2B,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAiB9E;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B;;cAIjB,QAAQ,CAAC,2BAA2B,CAAC;;;IAGvD;;;;OAIG;;cAEe,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;;cAGxB,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;IAClD,oEAAoE;;cAClC,QAAQ,CAAC,OAAO,CAAC;;;IACnD,iEAAiE;;cAC/B,QAAQ,CAAC,UAAU,CAAC;;;IACtD,2BAA2B;;cAER,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC;;;IAGhD,qCAAqC;;cAElB,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC;;;IAGhD,+CAA+C;;cAE7B,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;IAG9C,uEAAuE;;cAEnD,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;;;IAG1E,kDAAkD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