@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.
@@ -10,6 +10,25 @@ export interface ResourceTableProps<TRecord extends RowData = Record<string, unk
10
10
  * Edit/Delete row actions.
11
11
  */
12
12
  actions?: boolean;
13
+ /**
14
+ * Replaces the built-in create dialog: the New button calls this instead
15
+ * (for example, to navigate to a create page). Only used with `actions`.
16
+ * Bind it as a prop (`:on-create`) or a listener (`@create`).
17
+ */
18
+ onCreate?: () => void;
19
+ /**
20
+ * Replaces the built-in edit dialog: each row's Edit button calls this with
21
+ * its record instead (for example, to navigate to an edit page). Only used
22
+ * with `actions`. Bind it as a prop (`:on-edit`) or a listener (`@edit`).
23
+ */
24
+ onEdit?: (record: TRecord) => void;
25
+ /**
26
+ * Opens a record (for example, to navigate to its page): adds a View
27
+ * button to each row, and clicking a row anywhere other than its controls
28
+ * calls this too. Independent of `actions`. Bind it as a prop (`:on-view`)
29
+ * or a listener (`@view`).
30
+ */
31
+ onView?: (record: TRecord) => void;
13
32
  /**
14
33
  * Renders the actions declared on the resource via `defineResource({ actions })`: record-scoped ones per row, collection-scoped ones in the toolbar. Labels, confirmations, and input forms come from each declaration; actions with neither a confirmation nor a form run on click. The table asks the server which of them the actor can't run on each page: those it may not run are hidden, and those that can't run right now are disabled, with the reason as a tooltip. An action denied when run (403, or 404 for a record action, which the server returns so as not to reveal whether the record exists) is hidden for the rest of this component's lifetime. Defaults to `actions`.
15
34
  */
@@ -40,6 +59,18 @@ export declare const ResourceTable: import("vue").DefineComponent<import("vue").
40
59
  type: BooleanConstructor;
41
60
  default: boolean;
42
61
  };
62
+ onCreate: {
63
+ type: PropType<ResourceTableProps["onCreate"]>;
64
+ default: undefined;
65
+ };
66
+ onEdit: {
67
+ type: PropType<ResourceTableProps["onEdit"]>;
68
+ default: undefined;
69
+ };
70
+ onView: {
71
+ type: PropType<ResourceTableProps["onView"]>;
72
+ default: undefined;
73
+ };
43
74
  resourceActions: {
44
75
  type: PropType<boolean | undefined>;
45
76
  default: undefined;
@@ -75,6 +106,18 @@ export declare const ResourceTable: import("vue").DefineComponent<import("vue").
75
106
  type: BooleanConstructor;
76
107
  default: boolean;
77
108
  };
109
+ onCreate: {
110
+ type: PropType<ResourceTableProps["onCreate"]>;
111
+ default: undefined;
112
+ };
113
+ onEdit: {
114
+ type: PropType<ResourceTableProps["onEdit"]>;
115
+ default: undefined;
116
+ };
117
+ onView: {
118
+ type: PropType<ResourceTableProps["onView"]>;
119
+ default: undefined;
120
+ };
78
121
  resourceActions: {
79
122
  type: PropType<boolean | undefined>;
80
123
  default: undefined;
@@ -100,7 +143,10 @@ export declare const ResourceTable: import("vue").DefineComponent<import("vue").
100
143
  actions: boolean;
101
144
  pageSize: number | undefined;
102
145
  renderActions: ((record: Record<string, unknown>) => VNodeChild) | undefined;
146
+ onEdit: ((record: Record<string, unknown>) => void) | undefined;
103
147
  resourceActions: boolean | undefined;
148
+ onCreate: (() => void) | undefined;
149
+ onView: ((record: Record<string, unknown>) => void) | undefined;
104
150
  renderBulkActions: ((records: Record<string, unknown>[], clearSelection: () => void) => VNodeChild) | undefined;
105
151
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
106
152
  //# sourceMappingURL=resource-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource-table.d.ts","sourceRoot":"","sources":["../../src/resource/resource-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAY9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAuBnD,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,gCAAgC,CAAC;AA0BxC,uCAAuC;AACvC,MAAM,WAAW,kBAAkB,CACjC,OAAO,SAAS,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAA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SlidersHorizontalIcon, Trash2Icon, } from "lucide-vue-next";
2
+ import { ArrowDownIcon, ArrowUpIcon, ChevronLeftIcon, ChevronRightIcon, ChevronsUpDownIcon, EyeIcon, PencilIcon, PlusIcon, SlidersHorizontalIcon, Trash2Icon, } from "lucide-vue-next";
3
3
  import { Button } from "#components/button";
4
4
  import { Checkbox } from "#components/checkbox";
5
5
  import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "#components/dialog";
@@ -43,6 +43,21 @@ export const ResourceTable = defineComponent({
43
43
  default: undefined,
44
44
  },
45
45
  actions: { type: Boolean, default: false },
46
+ // Declared as props rather than emits so the table can tell whether a
47
+ // parent handles them and skip its built-in dialogs (or, for `onView`,
48
+ // make rows clickable); `@create`/`@edit`/`@view` still bind here.
49
+ onCreate: {
50
+ type: Function,
51
+ default: undefined,
52
+ },
53
+ onEdit: {
54
+ type: Function,
55
+ default: undefined,
56
+ },
57
+ onView: {
58
+ type: Function,
59
+ default: undefined,
60
+ },
46
61
  resourceActions: {
47
62
  type: Boolean,
48
63
  default: undefined,
@@ -210,7 +225,12 @@ export const ResourceTable = defineComponent({
210
225
  size: "icon-sm",
211
226
  "aria-label": "Edit",
212
227
  onClick: () => {
213
- editRecord.value = record;
228
+ if (props.onEdit) {
229
+ props.onEdit(record);
230
+ }
231
+ else {
232
+ editRecord.value = record;
233
+ }
214
234
  },
215
235
  }, { default: () => h(PencilIcon) }),
216
236
  denied?.delete
@@ -225,12 +245,35 @@ export const ResourceTable = defineComponent({
225
245
  ];
226
246
  }
227
247
  function rowActions(record) {
248
+ const onView = props.onView;
228
249
  return h("div", { class: "flex items-center justify-end gap-1" }, [
250
+ onView
251
+ ? h(Button, {
252
+ type: "button",
253
+ variant: "ghost",
254
+ size: "icon-sm",
255
+ "aria-label": "View",
256
+ onClick: () => onView(record),
257
+ }, { default: () => h(EyeIcon) })
258
+ : null,
229
259
  declaredRowActions(record),
230
260
  props.actions ? builtInRowActions(record) : null,
231
261
  props.renderActions ? props.renderActions(record) : null,
232
262
  ]);
233
263
  }
264
+ // A row click opens the record, unless it landed on one of the row's own
265
+ // controls (its checkbox, action buttons, or links).
266
+ function rowClickHandler(record) {
267
+ const onView = props.onView;
268
+ return onView
269
+ ? (event) => {
270
+ const target = event.target;
271
+ if (!target.closest("button, a, input, label, [role='checkbox'], [role='dialog']")) {
272
+ onView(record);
273
+ }
274
+ }
275
+ : undefined;
276
+ }
234
277
  return () => {
235
278
  const selectedRows = table.getSelectedRowModel().rows;
236
279
  const selectedRecords = selectedRows.map((row) => row.original);
@@ -241,7 +284,11 @@ export const ResourceTable = defineComponent({
241
284
  : undefined;
242
285
  const hasActionsColumn = props.actions ||
243
286
  Boolean(props.renderActions) ||
287
+ Boolean(props.onView) ||
244
288
  recordActions.length > 0;
289
+ const clickableRowClass = props.onView
290
+ ? "cursor-pointer hover:bg-muted/50"
291
+ : "";
245
292
  const hasSelectionColumn = props.actions || Boolean(props.renderBulkActions);
246
293
  const hasFilterableFields = filterableFields(fields).length > 0;
247
294
  const activeFilterCount = Object.keys(filters.value).length;
@@ -298,7 +345,12 @@ export const ResourceTable = defineComponent({
298
345
  type: "button",
299
346
  size: "sm",
300
347
  onClick: () => {
301
- createOpen.value = true;
348
+ if (props.onCreate) {
349
+ props.onCreate();
350
+ }
351
+ else {
352
+ createOpen.value = true;
353
+ }
302
354
  },
303
355
  }, { default: () => [h(PlusIcon), "New"] })
304
356
  : null,
@@ -392,7 +444,11 @@ export const ResourceTable = defineComponent({
392
444
  class: "px-3 py-6 text-center text-muted-foreground",
393
445
  }, resolvedEmptyState),
394
446
  ])
395
- : rows.map((row) => h("tr", { key: row.id, class: "border-t border-border" }, [
447
+ : rows.map((row) => h("tr", {
448
+ key: row.id,
449
+ class: cn("border-t border-border", clickableRowClass),
450
+ onClick: rowClickHandler(row.original),
451
+ }, [
396
452
  hasSelectionColumn
397
453
  ? h("td", { class: "px-3 py-2" }, [
398
454
  h(Checkbox, {
@@ -418,10 +474,11 @@ export const ResourceTable = defineComponent({
418
474
  isLoading.value
419
475
  ? h("p", { class: "py-6 text-center text-sm text-muted-foreground" }, "Loading…")
420
476
  : rows.length === 0
421
- ? h("p", { class: "py-6 text-center text-sm text-muted-foreground" }, resolvedEmptyState)
477
+ ? h("div", { class: "py-6 text-center text-sm text-muted-foreground" }, resolvedEmptyState)
422
478
  : rows.map((row) => h("div", {
423
479
  key: row.id,
424
- class: "rounded-lg border border-border p-3",
480
+ class: cn("rounded-lg border border-border p-3", clickableRowClass),
481
+ onClick: rowClickHandler(row.original),
425
482
  }, [
426
483
  hasSelectionColumn
427
484
  ? h("div", { class: "flex justify-end pb-2" }, [
@@ -480,7 +537,7 @@ export const ResourceTable = defineComponent({
480
537
  onDenied: (action) => denyAction(action, activeAction.value?.recordId),
481
538
  })
482
539
  : null,
483
- props.actions
540
+ props.actions && !props.onCreate
484
541
  ? h(Dialog, {
485
542
  open: createOpen.value,
486
543
  onOpenChange: (open) => {
@@ -504,7 +561,7 @@ export const ResourceTable = defineComponent({
504
561
  }),
505
562
  })
506
563
  : null,
507
- props.actions
564
+ props.actions && !props.onEdit
508
565
  ? h(Dialog, {
509
566
  open: editRecord.value !== null,
510
567
  onOpenChange: (open) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verikit/vue",
3
- "version": "0.24.3",
3
+ "version": "0.25.0",
4
4
  "description": "Vue UI bindings for Verikit resource workflows.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,8 @@
37
37
  "./lib/*": {
38
38
  "types": "./dist/lib/*.d.ts",
39
39
  "default": "./dist/lib/*.js"
40
- }
40
+ },
41
+ "./tailwind-sources.css": "./tailwind-sources.css"
41
42
  },
42
43
  "imports": {
43
44
  "#components/*": {
@@ -50,38 +51,47 @@
50
51
  }
51
52
  },
52
53
  "files": [
53
- "dist"
54
+ "dist",
55
+ "tailwind-sources.css"
54
56
  ],
55
57
  "dependencies": {
56
58
  "@tanstack/vue-form": "^1.33.5",
57
- "@tanstack/vue-query": "^5.101.4",
58
59
  "@tanstack/vue-table": "^9.1.2",
59
60
  "class-variance-authority": "^0.7.1",
60
61
  "clsx": "^2.1.1",
61
62
  "lucide-vue-next": "^1.0.0",
62
63
  "reka-ui": "^2.10.3",
63
64
  "tailwind-merge": "^3.6.0",
64
- "@verikit/core": "0.24.3",
65
- "@verikit/runtime": "0.24.3",
66
- "@verikit/theme": "0.24.3",
67
- "@verikit/ui-core": "0.24.3",
68
- "@verikit/client": "0.24.3"
65
+ "@verikit/client": "0.25.0",
66
+ "@verikit/core": "0.25.0",
67
+ "@verikit/theme": "0.25.0",
68
+ "@verikit/runtime": "0.25.0",
69
+ "@verikit/ui-core": "0.25.0"
69
70
  },
70
71
  "devDependencies": {
72
+ "@tanstack/vue-query": "^5.101.4",
71
73
  "@types/jsdom": "^28.0.3",
72
74
  "@types/node": "^26.1.1",
73
75
  "@vue/test-utils": "^2.4.11",
74
76
  "jsdom": "^30.0.1",
75
77
  "typescript": "^6.0.3",
76
- "vue": "^3.5.41"
78
+ "vue": "^3.5.46"
77
79
  },
78
80
  "peerDependencies": {
79
- "@tanstack/vue-form": "^1.33.5",
80
81
  "@tanstack/vue-query": "^5.101.4",
81
- "@tanstack/vue-table": "^9.1.2",
82
- "reka-ui": "^2.10.3",
83
82
  "vue": "^3.5.0"
84
83
  },
84
+ "peerDependenciesMeta": {
85
+ "@tanstack/vue-query": {
86
+ "optional": true
87
+ },
88
+ "vue": {
89
+ "optional": true
90
+ }
91
+ },
92
+ "sideEffects": [
93
+ "*.css"
94
+ ],
85
95
  "scripts": {
86
96
  "clean": "rm -rf dist tsconfig.tsbuildinfo",
87
97
  "build": "pnpm clean && tsc -b",
@@ -0,0 +1,3 @@
1
+ /* Lets Tailwind find the classes @verikit/vue's components use:
2
+ @import "@verikit/vue/tailwind-sources.css"; */
3
+ @source "./dist";