@verikit/vue 0.24.4 → 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.
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, h, ref } from "vue";
2
- import { ArrowDownIcon, ArrowUpIcon, ChevronLeftIcon, ChevronRightIcon, ChevronsUpDownIcon, PencilIcon, PlusIcon, 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.4",
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/client": "0.24.4",
65
- "@verikit/runtime": "0.24.4",
66
- "@verikit/theme": "0.24.4",
67
- "@verikit/ui-core": "0.24.4",
68
- "@verikit/core": "0.24.4"
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";