@verikit/react 0.24.2 → 0.24.4

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.
Files changed (30) hide show
  1. package/dist/form/use-verikit-schema-tree-form.d.ts +3 -1
  2. package/dist/form/use-verikit-schema-tree-form.d.ts.map +1 -1
  3. package/dist/form/use-verikit-schema-tree-form.js +8 -1
  4. package/dist/query/index.d.ts +2 -2
  5. package/dist/query/index.d.ts.map +1 -1
  6. package/dist/query/index.js +1 -1
  7. package/dist/query/use-resource-mutations.d.ts.map +1 -1
  8. package/dist/query/use-resource-mutations.js +1 -0
  9. package/dist/query/use-resource-queries.d.ts +6 -1
  10. package/dist/query/use-resource-queries.d.ts.map +1 -1
  11. package/dist/query/use-resource-queries.js +11 -0
  12. package/dist/query/use-resource-table.d.ts +8 -2
  13. package/dist/query/use-resource-table.d.ts.map +1 -1
  14. package/dist/query/use-resource-table.js +3 -1
  15. package/dist/resource/declared-action-button.d.ts +14 -0
  16. package/dist/resource/declared-action-button.d.ts.map +1 -0
  17. package/dist/resource/declared-action-button.js +14 -0
  18. package/dist/resource/index.d.ts +4 -0
  19. package/dist/resource/index.d.ts.map +1 -1
  20. package/dist/resource/index.js +2 -0
  21. package/dist/resource/resource-action-dialog.d.ts +46 -0
  22. package/dist/resource/resource-action-dialog.d.ts.map +1 -0
  23. package/dist/resource/resource-action-dialog.js +101 -0
  24. package/dist/resource/resource-detail.d.ts +38 -0
  25. package/dist/resource/resource-detail.d.ts.map +1 -0
  26. package/dist/resource/resource-detail.js +100 -0
  27. package/dist/resource/resource-table.d.ts +5 -1
  28. package/dist/resource/resource-table.d.ts.map +1 -1
  29. package/dist/resource/resource-table.js +65 -30
  30. package/package.json +8 -8
@@ -9,7 +9,9 @@ export type VerikitSchemaTreeSource = Resource | ResourceSchema;
9
9
  export interface UseVerikitSchemaTreeFormOptions<TResult = unknown> {
10
10
  /** Resource builder or schema containing the tree to render. */
11
11
  resource: VerikitSchemaTreeSource;
12
- /** Runtime actions whose forms should render for matching action nodes. */
12
+ /**
13
+ * Runtime actions whose forms should render for matching action nodes. Merged over the actions the resource declares via `defineResource({ actions })`, which are used by default.
14
+ */
13
15
  actions?: SchemaActionRegistry;
14
16
  /** Initial values passed to TanStack Form. */
15
17
  defaultValues?: VerikitFormValues;
@@ -1 +1 @@
1
- {"version":3,"file":"use-verikit-schema-tree-form.d.ts","sourceRoot":"","sources":["../../src/form/use-verikit-schema-tree-form.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,2BAA2B,EACjC,MAAM,kCAAkC,CAAC;AAE1C,oDAAoD;AACpD,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,cAAc,CAAC;AAEhE,6DAA6D;AAC7D,MAAM,WAAW,+BAA+B,CAAC,OAAO,GAAG,OAAO;IAChE,gEAAgE;IAChE,QAAQ,EAAE,uBAAuB,CAAC;IAClC,2EAA2E;IAC3E,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,8CAA8C;IAC9C,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtE;AAED;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC7C,iBAAiB,EACf,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,eAAe,GACf,aAAa,GACb,eAAe,GACf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SAAS,CAAC,CAAC,CAAC;IACrD,6CAA6C;IAC7C,MAAM,EAAE,CACN,MAAM,CAAC,EAAE,iBAAiB,KACvB,OAAO,CAAC,2BAA2B,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/D,yDAAyD;IACzD,aAAa,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,GAAG,SAAS,CAAC;IACxD,iEAAiE;IACjE,SAAS,EAAE,4BAA4B,CAAC;CACzC;AAiBD,gEAAgE;AAChE,wBAAgB,wBAAwB,CAAC,OAAO,GAAG,OAAO,EAAE,EAC1D,QAAQ,EACR,OAAO,EACP,aAAkB,EAClB,QAAQ,GACT,EAAE,+BAA+B,CAAC,OAAO,CAAC,GAAG,8BAA8B,CAAC,OAAO,CAAC,CAwIpF"}
@@ -7,9 +7,16 @@ import { firstFieldError, firstFieldErrors, omitFieldError, } from "@verikit/ui-
7
7
  function resolveVerikitTree(source) {
8
8
  return isResource(source) ? source.toSchema().tree : source.tree;
9
9
  }
10
+ function resolveActionRegistry(source, overrides) {
11
+ const declared = isResource(source)
12
+ ? source.toSchema().actions
13
+ : source.actions;
14
+ return declared ? { ...declared, ...overrides } : overrides;
15
+ }
10
16
  /** Creates a TanStack-backed form for a Verikit schema tree. */
11
17
  export function useVerikitSchemaTreeForm({ resource, actions, defaultValues = {}, onSubmit, }) {
12
18
  const tree = useMemo(() => resolveVerikitTree(resource), [resource]);
19
+ const actionRegistry = useMemo(() => resolveActionRegistry(resource, actions), [resource, actions]);
13
20
  const [fieldErrors, setFieldErrors] = useState({});
14
21
  // Stable per-row ids for repeater rows, keyed by the repeater's own path. Grown
15
22
  // lazily (per index, as `getRepeaterRowKey` is called during render) to cover rows
@@ -83,7 +90,7 @@ export function useVerikitSchemaTreeForm({ resource, actions, defaultValues = {}
83
90
  treeProps: {
84
91
  values: form.state.values,
85
92
  errors,
86
- actions,
93
+ actions: actionRegistry,
87
94
  onFieldChange,
88
95
  onFieldBlur,
89
96
  onRepeaterAdd,
@@ -1,5 +1,5 @@
1
- export { useListResource, useResourceFind, useResourceRelationship, } from "./use-resource-queries.js";
2
- export type { UseListResourceOptions, UseFindResourceOptions, UseResourceRelationshipOptions, } from "./use-resource-queries.js";
1
+ export { useListResource, useResourceFind, useResourceFindWithActions, useResourceRelationship, } from "./use-resource-queries.js";
2
+ export type { UseListResourceOptions, UseFindResourceOptions, UseFindWithActionsResourceOptions, UseResourceRelationshipOptions, } from "./use-resource-queries.js";
3
3
  export { useCreateResource, useUpdateResource, useDeleteResource, useActionResource, } from "./use-resource-mutations.js";
4
4
  export type { UseCreateResourceOptions, UpdateResourceVariables, UseUpdateResourceOptions, UseDeleteResourceOptions, ActionResourceVariables, UseActionResourceOptions, } from "./use-resource-mutations.js";
5
5
  export { resourceQueryKeys } from "@verikit/ui-core/query/query-keys";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EACf,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,YAAY,EACV,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,YAAY,EACV,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC"}
@@ -1,4 +1,4 @@
1
- export { useListResource, useResourceFind, useResourceRelationship, } from "./use-resource-queries.js";
1
+ export { useListResource, useResourceFind, useResourceFindWithActions, useResourceRelationship, } from "./use-resource-queries.js";
2
2
  export { useCreateResource, useUpdateResource, useDeleteResource, useActionResource, } from "./use-resource-mutations.js";
3
3
  export { resourceQueryKeys } from "@verikit/ui-core/query/query-keys";
4
4
  export { useResourceForm } from "./use-resource-form.js";
@@ -1 +1 @@
1
- {"version":3,"file":"use-resource-mutations.d.ts","sourceRoot":"","sources":["../../src/query/use-resource-mutations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAYnE,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,MAAM,IAAI,IAAI,CACjE,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC3D,YAAY,CACb,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEhD,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,wBAAwB,CAAC,OAAO,CAAC,GAC1C,iBAAiB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAc5D;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,MAAM,IAAI,IAAI,CACjE,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,uBAAuB,CAAC,EAC3D,YAAY,CACb,CAAC;AAOF;;GAEG;AACH,wBAAgB,iBAA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AM,WAAW,uBAAwB,SAAQ,aAAa;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,MAAM,wBAAwB,CAAC,OAAO,IAAI,IAAI,CAClD,kBAAkB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,uBAAuB,CAAC,EACzE,YAAY,CACb,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAG,OAAO,EACjD,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,wBAAwB,CAAC,OAAO,CAAC,GAC1C,iBAAiB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAc1E"}
@@ -80,6 +80,7 @@ export function useDeleteResource(name, options) {
80
80
  },
81
81
  onSuccess: (data, id, ...rest) => {
82
82
  queryClient.removeQueries({ queryKey: keys.find(id) });
83
+ queryClient.removeQueries({ queryKey: keys.findWithActions(id) });
83
84
  return options?.onSuccess?.(data, id, ...rest);
84
85
  },
85
86
  // Always refetch after deletion to reconcile optimistic state with the server.
@@ -1,11 +1,16 @@
1
1
  import type { UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
2
- import type { ListParams, ListResponse } from "@verikit/client";
2
+ import type { ListParams, ListResponse, FindWithActionsResponse } from "@verikit/client";
3
3
  export type UseListResourceOptions<TRecord extends object> = Omit<UseQueryOptions<ListResponse<TRecord>, Error>, "queryKey" | "queryFn">;
4
4
  /** Lists a resource's records, cached per resource name + params. */
5
5
  export declare function useListResource<TRecord extends object = Record<string, unknown>>(name: string, params?: ListParams<TRecord>, options?: UseListResourceOptions<TRecord>): UseQueryResult<ListResponse<TRecord>, Error>;
6
6
  export type UseFindResourceOptions<TRecord extends object> = Omit<UseQueryOptions<TRecord, Error>, "queryKey" | "queryFn">;
7
7
  /** Fetches a single resource record by id, cached per resource name + id. */
8
8
  export declare function useResourceFind<TRecord extends object = Record<string, unknown>>(name: string, id: string, options?: UseFindResourceOptions<TRecord>): UseQueryResult<TRecord, Error>;
9
+ export type UseFindWithActionsResourceOptions<TRecord extends object> = Omit<UseQueryOptions<FindWithActionsResponse<TRecord>, Error>, "queryKey" | "queryFn">;
10
+ /**
11
+ * Fetches a single record by id along with the record-scoped actions the caller can't run on it, cached per resource name + id.
12
+ */
13
+ export declare function useResourceFindWithActions<TRecord extends object = Record<string, unknown>>(name: string, id: string, options?: UseFindWithActionsResourceOptions<TRecord>): UseQueryResult<FindWithActionsResponse<TRecord>, Error>;
9
14
  export type UseResourceRelationshipOptions<TTarget extends object> = Omit<UseQueryOptions<ListResponse<TTarget>, Error>, "queryKey" | "queryFn">;
10
15
  /**
11
16
  * Lists selectable records for a `belongsTo` relationship, cached by
@@ -1 +1 @@
1
- {"version":3,"file":"use-resource-queries.d.ts","sourceRoot":"","sources":["../../src/query/use-resource-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIhE,MAAM,MAAM,sBAAsB,CAAC,OAAO,SAAS,MAAM,IAAI,IAAI,CAC/D,eAAe,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,EAC7C,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF,qEAAqE;AACrE,wBAAgB,eAAe,CAC7B,OAAO,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEhD,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,UAAU,CAAC,OAAO,CAAM,EAChC,OAAO,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,GACxC,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAS9C;AAED,MAAM,MAAM,sBAAsB,CAAC,OAAO,SAAS,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GAAG,SAAS,CACvB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEhD,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,EACxB,MAAM,GAAE,UAAU,CAAC,OAAO,CAAM,EAChC,OAAO,CAAC,EAAE,8BAA8B,CAAC,OAAO,CAAC,GAChD,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAc9C"}
@@ -19,6 +19,17 @@ export function useResourceFind(name, id, options) {
19
19
  ...options,
20
20
  });
21
21
  }
22
+ /**
23
+ * Fetches a single record by id along with the record-scoped actions the caller can't run on it, cached per resource name + id.
24
+ */
25
+ export function useResourceFindWithActions(name, id, options) {
26
+ const client = useVerikitClient();
27
+ return useQuery({
28
+ queryKey: resourceQueryKeys(name, client).findWithActions(id),
29
+ queryFn: ({ signal }) => client.resource(name).findWithActions(id, { signal }),
30
+ ...options,
31
+ });
32
+ }
22
33
  /**
23
34
  * Lists selectable records for a `belongsTo` relationship, cached by
24
35
  * resource, relationship, and params. Server-side permissions and scopes apply.
@@ -1,5 +1,5 @@
1
1
  import { type RowData, type Table } from "@tanstack/react-table";
2
- import type { ListParams } from "@verikit/client";
2
+ import type { ListActionAvailability, ListParams } from "@verikit/client";
3
3
  import type { FieldSchema, Resource, ResourceSchema } from "@verikit/core";
4
4
  declare const resourceTableFeatures: {
5
5
  rowSortingFeature: import("@tanstack/react-table").TableFeature;
@@ -17,6 +17,10 @@ export type ResourceTableFilters = NonNullable<ListParams["filters"]>;
17
17
  export interface UseResourceTableOptions {
18
18
  /** Initial page size, before the user (or caller) changes it. Defaults to 25. */
19
19
  pageSize?: number;
20
+ /**
21
+ * Also asks the server which actions the actor can't run on each page, returned as `actions`. Each action's permissions and availability guard run per record, so only set this when the actions are shown.
22
+ */
23
+ includeActions?: boolean;
20
24
  }
21
25
  /** State and helpers returned by {@link useResourceTable}. */
22
26
  export interface UseResourceTableResult<TRecord extends RowData = Record<string, unknown>> {
@@ -36,11 +40,13 @@ export interface UseResourceTableResult<TRecord extends RowData = Record<string,
36
40
  filters: ResourceTableFilters;
37
41
  /** Replaces the active per-field filters wholesale. */
38
42
  setFilters: (filters: ResourceTableFilters) => void;
43
+ /** The actions the actor can't run on the current page, when requested with `includeActions`. */
44
+ actions: ListActionAvailability | undefined;
39
45
  }
40
46
  /**
41
47
  * Creates a TanStack Table from a resource's schema, with automatic columns
42
48
  * and server-side pagination, sorting, and search.
43
49
  */
44
- export declare function useResourceTable<TRecord extends RowData = Record<string, unknown>>(resource: UseResourceTableSource, { pageSize }?: UseResourceTableOptions): UseResourceTableResult<TRecord>;
50
+ export declare function useResourceTable<TRecord extends RowData = Record<string, unknown>>(resource: UseResourceTableSource, { pageSize, includeActions }?: UseResourceTableOptions): UseResourceTableResult<TRecord>;
45
51
  export {};
46
52
  //# sourceMappingURL=use-resource-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-resource-table.d.ts","sourceRoot":"","sources":["../../src/query/use-resource-table.ts"],"names":[],"mappings":"AACA,OAAO,EAYL,KAAK,OAAO,EAGZ,KAAK,KAAK,EACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAO3E,QAAA,MAAM,qBAAqB;;;;;;CAMzB,CAAC;AAEH,KAAK,qBAAqB,GAAG,OAAO,qBAAqB,CAAC;AAE1D,+EAA+E;AAC/E,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,cAAc,CAAC;AAE/D,8GAA8G;AAC9G,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AAEtE,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC,i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MAAM,sBAAsB,GAAG,QAAQ,GAAG,cAAc,CAAC;AAE/D,8GAA8G;AAC9G,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AAEtE,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,8DAA8D;AAC9D,MAAM,WAAW,sBAAsB,CACrC,OAAO,SAAS,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEjD,6EAA6E;IAC7E,KAAK,EAAE,KAAK,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;IAC7C,mEAAmE;IACnE,SAAS,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,UAAU,EAAE,OAAO,CAAC;IACpB,sDAAsD;IACtD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,2DAA2D;IAC3D,OAAO,EAAE,oBAAoB,CAAC;IAC9B,uDAAuD;IACvD,UAAU,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACpD,iGAAiG;IACjG,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAAC;CAC7C;AAED;;;GAGG;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,CAgFjC"}
@@ -16,7 +16,7 @@ const resourceTableFeatures = tableFeatures({
16
16
  * Creates a TanStack Table from a resource's schema, with automatic columns
17
17
  * and server-side pagination, sorting, and search.
18
18
  */
19
- export function useResourceTable(resource, { pageSize = 25 } = {}) {
19
+ export function useResourceTable(resource, { pageSize = 25, includeActions = false } = {}) {
20
20
  const fields = resolveVerikitFields(resource);
21
21
  const columns = useMemo(() => Object.values(fields)
22
22
  .filter((field) => !field.hidden && !field.tableHidden)
@@ -53,6 +53,7 @@ export function useResourceTable(resource, { pageSize = 25 } = {}) {
53
53
  ? { field: activeSort.id, direction: activeSort.desc ? "desc" : "asc" }
54
54
  : undefined,
55
55
  ...(hasFilters ? { filters } : {}),
56
+ ...(includeActions ? { includeActions } : {}),
56
57
  });
57
58
  const table = useTable({
58
59
  features: resourceTableFeatures,
@@ -77,5 +78,6 @@ export function useResourceTable(resource, { pageSize = 25 } = {}) {
77
78
  fields,
78
79
  filters,
79
80
  setFilters: handleFiltersChange,
81
+ actions: list.data?.actions,
80
82
  };
81
83
  }
@@ -0,0 +1,14 @@
1
+ import type { ReactElement } from "react";
2
+ import type { UnavailableAction } from "@verikit/client";
3
+ import type { ActionSchemaLike } from "@verikit/core";
4
+ /**
5
+ * A declared action's button. Hidden when the server reports the actor may not run it; disabled, with the reason as a tooltip, when it can't run right now.
6
+ */
7
+ export declare function DeclaredActionButton({ action, unavailable, variant, disabled, onClick, }: {
8
+ action: ActionSchemaLike;
9
+ unavailable: UnavailableAction | undefined;
10
+ variant: "destructive" | "ghost" | "outline";
11
+ disabled: boolean;
12
+ onClick: () => void;
13
+ }): ReactElement | null;
14
+ //# sourceMappingURL=declared-action-button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declared-action-button.d.ts","sourceRoot":"","sources":["../../src/resource/declared-action-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,WAAW,EACX,OAAO,EACP,QAAQ,EACR,OAAO,GACR,EAAE;IACD,MAAM,EAAE,gBAAgB,CAAC;IACzB,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,OAAO,EAAE,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;IAC7C,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,GAAG,YAAY,GAAG,IAAI,CAyBtB"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Button } from "#components/button";
3
+ import { actionLabel } from "@verikit/ui-core/actions/resource-actions";
4
+ /**
5
+ * A declared action's button. Hidden when the server reports the actor may not run it; disabled, with the reason as a tooltip, when it can't run right now.
6
+ */
7
+ export function DeclaredActionButton({ action, unavailable, variant, disabled, onClick, }) {
8
+ if (unavailable?.reason === "forbidden") {
9
+ return null;
10
+ }
11
+ const button = (_jsx(Button, { type: "button", variant: variant, size: "sm", disabled: disabled || unavailable !== undefined, onClick: onClick, children: actionLabel(action) }));
12
+ // Disabled buttons ignore pointer events, so the tooltip sits on a wrapper.
13
+ return unavailable ? (_jsx("span", { className: "inline-flex", title: unavailable.message, children: button })) : (button);
14
+ }
@@ -1,5 +1,9 @@
1
+ export { ResourceDetail } from "./resource-detail.js";
2
+ export type { ResourceDetailProps } from "./resource-detail.js";
1
3
  export { ResourceForm } from "./resource-form.js";
2
4
  export type { ResourceFormProps } from "./resource-form.js";
3
5
  export { ResourceTable } from "./resource-table.js";
4
6
  export type { ResourceTableProps } from "./resource-table.js";
7
+ export { ResourceActionDialog, useRunResourceAction, } from "./resource-action-dialog.js";
8
+ export type { ResourceActionDialogProps, RunResourceActionVariables, } from "./resource-action-dialog.js";
5
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC"}
@@ -1,2 +1,4 @@
1
+ export { ResourceDetail } from "./resource-detail.js";
1
2
  export { ResourceForm } from "./resource-form.js";
2
3
  export { ResourceTable } from "./resource-table.js";
4
+ export { ResourceActionDialog, useRunResourceAction, } from "./resource-action-dialog.js";
@@ -0,0 +1,46 @@
1
+ import type { ReactElement } from "react";
2
+ import type { UseMutationResult } from "@tanstack/react-query";
3
+ import type { ActionSchemaLike } from "@verikit/core";
4
+ import { type ActionResult } from "@verikit/client";
5
+ import type { VerikitFieldRegistry } from "../fields/types.js";
6
+ /** True for an error whose `status` matches, duck-typed like `ResourceTable`. */
7
+ export declare function hasStatus(error: unknown, status: number): boolean;
8
+ /** True for an error whose `status` is 403, duck-typed like `ResourceTable`. */
9
+ export declare function isPermissionDenied(error: unknown): boolean;
10
+ /**
11
+ * True when the server denied running an action. The server denies record actions with 404 rather than 403 so it never reveals whether the record exists; the caller already holds that record, so a 404 there means the action can't run on it (denied, or the record is gone).
12
+ */
13
+ export declare function isActionDenied(error: unknown, recordId: string | undefined): boolean;
14
+ /** Variables for {@link useRunResourceAction}. */
15
+ export interface RunResourceActionVariables {
16
+ action: ActionSchemaLike;
17
+ recordId?: string;
18
+ input?: Record<string, unknown>;
19
+ }
20
+ /**
21
+ * Runs any declared action of a resource over `@verikit/client`, invalidating the resource's queries on success, or when the server reports the action unavailable. Sends `confirmed: true` for actions that declare a confirmation, since callers only run those after the user accepted it.
22
+ */
23
+ export declare function useRunResourceAction(resourceName: string, options?: {
24
+ onSuccess?: () => void;
25
+ onError?: (error: Error, variables: RunResourceActionVariables) => void;
26
+ }): UseMutationResult<ActionResult<unknown>, Error, RunResourceActionVariables>;
27
+ /** Props for {@link ResourceActionDialog}. */
28
+ export interface ResourceActionDialogProps {
29
+ /** Resource the action belongs to. */
30
+ resourceName: string;
31
+ /** Declared action to run; the dialog is open while this is set. */
32
+ action: ActionSchemaLike | null;
33
+ /** Record the action targets, for record-scoped actions. */
34
+ recordId?: string;
35
+ /** Called when the dialog closes, after success or cancel. */
36
+ onClose: () => void;
37
+ /** Called when the server denies the action (403, or 404 for a record action); the dialog then closes. */
38
+ onDenied?: (action: ActionSchemaLike) => void;
39
+ /** Optional renderer overrides for the action's form fields. */
40
+ registry?: Partial<VerikitFieldRegistry>;
41
+ }
42
+ /**
43
+ * Confirms and collects input for a declared resource action, then runs it over `@verikit/client`. Labels, confirmation copy, and form fields all come from the action's declaration in `defineResource({ actions })`.
44
+ */
45
+ export declare function ResourceActionDialog(props: ResourceActionDialogProps): ReactElement;
46
+ //# sourceMappingURL=resource-action-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-action-dialog.d.ts","sourceRoot":"","sources":["../../src/resource/resource-action-dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,YAAY,EAAE,MAAM,OAAO,CAAC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,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,0GAA0G;IAC1G,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC9C,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC1C;AAiFD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,yBAAyB,GAC/B,YAAY,CAuBd"}
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { VerikitClientError } from "@verikit/client";
4
+ import { Button } from "#components/button";
5
+ import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "#components/dialog";
6
+ import { actionLabel } from "@verikit/ui-core/actions/resource-actions";
7
+ import { resourceQueryKeys } from "@verikit/ui-core/query/query-keys";
8
+ import { validationIssuesToFieldErrors } from "@verikit/ui-core/form/submission";
9
+ import { useVerikitClient } from "../client/use-verikit-client.js";
10
+ import { RenderField } from "../fields/index.js";
11
+ import { useVerikitForm } from "../form/use-verikit-form.js";
12
+ /** True for an error whose `status` matches, duck-typed like `ResourceTable`. */
13
+ export function hasStatus(error, status) {
14
+ return (typeof error === "object" &&
15
+ error !== null &&
16
+ "status" in error &&
17
+ error.status === status);
18
+ }
19
+ /** True for an error whose `status` is 403, duck-typed like `ResourceTable`. */
20
+ export function isPermissionDenied(error) {
21
+ return hasStatus(error, 403);
22
+ }
23
+ function isActionUnavailable(error) {
24
+ return (typeof error === "object" &&
25
+ error !== null &&
26
+ "code" in error &&
27
+ error.code === "ACTION_UNAVAILABLE");
28
+ }
29
+ /**
30
+ * True when the server denied running an action. The server denies record actions with 404 rather than 403 so it never reveals whether the record exists; the caller already holds that record, so a 404 there means the action can't run on it (denied, or the record is gone).
31
+ */
32
+ export function isActionDenied(error, recordId) {
33
+ return (isPermissionDenied(error) ||
34
+ (recordId !== undefined && hasStatus(error, 404)));
35
+ }
36
+ /**
37
+ * Runs any declared action of a resource over `@verikit/client`, invalidating the resource's queries on success, or when the server reports the action unavailable. Sends `confirmed: true` for actions that declare a confirmation, since callers only run those after the user accepted it.
38
+ */
39
+ export function useRunResourceAction(resourceName, options = {}) {
40
+ const client = useVerikitClient();
41
+ const queryClient = useQueryClient();
42
+ const keys = resourceQueryKeys(resourceName, client);
43
+ return useMutation({
44
+ mutationFn: ({ action, recordId, input }) => client.resource(resourceName).action(action.name, input, {
45
+ recordId,
46
+ confirmed: action.confirmation ? true : undefined,
47
+ }),
48
+ onSuccess: () => {
49
+ void queryClient.invalidateQueries({ queryKey: keys.all });
50
+ options.onSuccess?.();
51
+ },
52
+ onError: (error, variables) => {
53
+ // The list's action availability is stale: refetch it so the action
54
+ // shows as unavailable.
55
+ if (isActionUnavailable(error)) {
56
+ void queryClient.invalidateQueries({ queryKey: keys.all });
57
+ }
58
+ options.onError?.(error, variables);
59
+ },
60
+ });
61
+ }
62
+ function ActionDialogBody({ resourceName, action, recordId, onClose, onDenied, registry, }) {
63
+ const fields = action.form ?? {};
64
+ const run = useRunResourceAction(resourceName, {
65
+ onSuccess: onClose,
66
+ onError: (error) => {
67
+ if (isActionDenied(error, recordId)) {
68
+ onDenied?.(action);
69
+ onClose();
70
+ }
71
+ else if (error instanceof VerikitClientError && error.issues) {
72
+ form.setFieldErrors(validationIssuesToFieldErrors(error.issues));
73
+ }
74
+ },
75
+ });
76
+ const form = useVerikitForm({
77
+ fields,
78
+ onSubmit: (input) => run.mutateAsync({ action, recordId, input }),
79
+ });
80
+ const description = action.confirmation?.message ?? action.description;
81
+ const handleSubmit = (event) => {
82
+ event.preventDefault();
83
+ event.stopPropagation();
84
+ // `run.error` already surfaces mutation failures; suppress the rejection here.
85
+ form.submit().catch(() => { });
86
+ };
87
+ return (_jsxs(_Fragment, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: action.confirmation?.title ?? actionLabel(action) }), description ? (_jsx(DialogDescription, { children: description })) : null] }), _jsxs("form", { className: "grid gap-4", onSubmit: handleSubmit, noValidate: true, children: [Object.keys(fields).map((name) => (_jsx(RenderField, { registry: registry, ...form.getFieldProps(name) }, name))), run.error && !isActionDenied(run.error, recordId) ? (_jsx("p", { role: "alert", className: "text-sm text-destructive", children: run.error.message })) : null, _jsxs(DialogFooter, { children: [_jsx(DialogClose, { render: _jsx(Button, { type: "button", variant: "outline", children: action.confirmation?.cancelLabel ?? "Cancel" }) }), _jsx(Button, { type: "submit", variant: action.variant === "danger" ? "destructive" : "default", disabled: run.isPending, children: run.isPending
88
+ ? "Running…"
89
+ : (action.confirmation?.confirmLabel ?? actionLabel(action)) })] })] })] }));
90
+ }
91
+ /**
92
+ * Confirms and collects input for a declared resource action, then runs it over `@verikit/client`. Labels, confirmation copy, and form fields all come from the action's declaration in `defineResource({ actions })`.
93
+ */
94
+ export function ResourceActionDialog(props) {
95
+ const { action, onClose } = props;
96
+ return (_jsx(Dialog, { open: action !== null, onOpenChange: (open) => {
97
+ if (!open) {
98
+ onClose();
99
+ }
100
+ }, children: _jsx(DialogContent, { children: action ? (_jsx(ActionDialogBody, { ...props, action: action }, `${action.name}:${props.recordId ?? ""}`)) : null }) }));
101
+ }
@@ -0,0 +1,38 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ import type { Resource, ResourceSchema } from "@verikit/core";
3
+ /** Props for {@link ResourceDetail}. */
4
+ export interface ResourceDetailProps<TRecord extends Record<string, unknown> = Record<string, unknown>> {
5
+ /** The resource (or its schema) whose fields and actions the page shows. */
6
+ resource: Resource | ResourceSchema;
7
+ /** Id of the record to show. */
8
+ id: string;
9
+ /**
10
+ * Renders the built-in Edit and Delete actions, and the default for `editAction`, `deleteAction`, and `resourceActions`.
11
+ */
12
+ actions?: boolean;
13
+ /**
14
+ * Renders the built-in Edit action, which opens a `ResourceForm` dialog pre-filled from the record. Hidden when the server reports the actor can't update the record, or when an update is denied (403 or 404) for the rest of this component's lifetime. Defaults to `actions`.
15
+ */
16
+ editAction?: boolean;
17
+ /**
18
+ * Renders the built-in Delete action, which opens a confirmation dialog. Hidden when the server reports the actor can't delete the record, or when a delete is denied (403 or 404) for the rest of this component's lifetime. Defaults to `actions`.
19
+ */
20
+ deleteAction?: boolean;
21
+ /**
22
+ * Renders the record-scoped actions declared on the resource via `defineResource({ actions })`. The page asks the server which of them the actor can't run on this record: 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) is hidden for the rest of this component's lifetime. Defaults to `actions`.
23
+ */
24
+ resourceActions?: boolean;
25
+ /** Renders extra actions alongside the built-in and declared ones. */
26
+ renderActions?: (record: TRecord) => ReactNode;
27
+ /**
28
+ * Called after the record is deleted through the built-in Delete action, e.g. to navigate away. The page shows a "deleted" message until then.
29
+ */
30
+ onDeleted?: (record: TRecord) => void;
31
+ /** Class name applied to the outer container. */
32
+ className?: string;
33
+ }
34
+ /**
35
+ * Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Edit and Delete are hidden up front when the server reports the actor can't update or delete the record. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
36
+ */
37
+ export declare function ResourceDetail<TRecord extends Record<string, unknown> = Record<string, unknown>>({ resource, id, actions, editAction, deleteAction, resourceActions, renderActions, onDeleted, className, }: ResourceDetailProps<TRecord>): ReactElement;
38
+ //# sourceMappingURL=resource-detail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-detail.d.ts","sourceRoot":"","sources":["../../src/resource/resource-detail.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAapE,OAAO,KAAK,EAAoB,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAkBhF,wCAAwC;AACxC,MAAM,WAAW,mBAAmB,CAClC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEjE,4EAA4E;IAC5E,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAAC;IACpC,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sEAAsE;IACtE,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,SAAS,CAAC;IAC/C;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,EACA,QAAQ,EACR,EAAE,EACF,OAAe,EACf,UAAoB,EACpB,YAAsB,EACtB,eAAyB,EACzB,aAAa,EACb,SAAS,EACT,SAAS,GACV,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,YAAY,CAoP7C"}
@@ -0,0 +1,100 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { PencilIcon, Trash2Icon } from "lucide-react";
4
+ import { Button } from "#components/button";
5
+ import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "#components/dialog";
6
+ import { cn } from "#lib/utils";
7
+ import { actionNeedsDialog, resourceActionSchemas, } from "@verikit/ui-core/actions/resource-actions";
8
+ import { resolveVerikitFields } from "@verikit/ui-core/form/resolve-fields";
9
+ import { formatFieldValue } from "@verikit/ui-core/layout/format-value";
10
+ import { useDeleteResource } from "../query/use-resource-mutations.js";
11
+ import { useResourceFindWithActions } from "../query/use-resource-queries.js";
12
+ import { DeclaredActionButton } from "./declared-action-button.js";
13
+ import { hasStatus, isActionDenied, ResourceActionDialog, useRunResourceAction, } from "./resource-action-dialog.js";
14
+ import { ResourceForm } from "./resource-form.js";
15
+ /**
16
+ * Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Edit and Delete are hidden up front when the server reports the actor can't update or delete the record. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
17
+ */
18
+ export function ResourceDetail({ resource, id, actions = false, editAction = actions, deleteAction = actions, resourceActions = actions, renderActions, onDeleted, className, }) {
19
+ const [deleted, setDeleted] = useState(false);
20
+ const query = useResourceFindWithActions(resource.name, id, {
21
+ enabled: !deleted,
22
+ });
23
+ const fields = resolveVerikitFields(resource);
24
+ const recordActions = resourceActions
25
+ ? resourceActionSchemas(resource, "record")
26
+ : [];
27
+ const [editOpen, setEditOpen] = useState(false);
28
+ const [deleteOpen, setDeleteOpen] = useState(false);
29
+ const [denied, setDenied] = useState({ actions: {} });
30
+ const [activeAction, setActiveAction] = useState(null);
31
+ const [actionError, setActionError] = useState(null);
32
+ function denyAction(action) {
33
+ setDenied((current) => ({
34
+ ...current,
35
+ actions: { ...current.actions, [action.name]: true },
36
+ }));
37
+ }
38
+ const directAction = useRunResourceAction(resource.name, {
39
+ onSuccess: () => setActionError(null),
40
+ onError: (mutationError, variables) => {
41
+ if (isActionDenied(mutationError, variables.recordId)) {
42
+ denyAction(variables.action);
43
+ }
44
+ else {
45
+ setActionError(mutationError.message);
46
+ }
47
+ },
48
+ });
49
+ function startAction(action) {
50
+ setActionError(null);
51
+ if (actionNeedsDialog(action)) {
52
+ setActiveAction(action);
53
+ }
54
+ else {
55
+ directAction.mutate({ action, recordId: id });
56
+ }
57
+ }
58
+ const deleteMutation = useDeleteResource(resource.name, {
59
+ onError: (mutationError) => {
60
+ // The server answers a denied delete with 404 so as not to reveal
61
+ // whether the record exists, the same as a denied record action.
62
+ if (isActionDenied(mutationError, id)) {
63
+ setDenied((current) => ({ ...current, delete: true }));
64
+ setDeleteOpen(false);
65
+ }
66
+ },
67
+ onSuccess: () => {
68
+ setDeleteOpen(false);
69
+ setDeleted(true);
70
+ onDeleted?.(query.data.record);
71
+ },
72
+ });
73
+ if (deleted) {
74
+ return (_jsxs("p", { role: "status", className: cn("text-sm text-muted-foreground", className), children: ["This ", resource.name, " was deleted."] }));
75
+ }
76
+ if (query.isPending) {
77
+ return (_jsx("p", { className: cn("text-sm text-muted-foreground", className), children: "Loading\u2026" }));
78
+ }
79
+ if (query.isError) {
80
+ return hasStatus(query.error, 404) ? (_jsxs("p", { role: "status", className: cn("text-sm text-muted-foreground", className), children: ["This ", resource.name, " doesn't exist or you can't view it."] })) : (_jsx("p", { role: "alert", className: cn("text-sm text-destructive", className), children: query.error.message }));
81
+ }
82
+ const { record, actions: unavailable, operations } = query.data;
83
+ const showEdit = editAction && !denied.update && !operations.update;
84
+ const showDelete = deleteAction && !denied.delete && !operations.delete;
85
+ const visibleFields = Object.values(fields).filter((field) => !field.hidden && Object.hasOwn(record, field.name));
86
+ const hasActions = showEdit ||
87
+ showDelete ||
88
+ recordActions.length > 0 ||
89
+ Boolean(renderActions);
90
+ return (_jsxs("div", { className: cn("w-full", className), children: [hasActions ? (_jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2 pb-3", children: [recordActions.map((action) => denied.actions[action.name] ? null : (_jsx(DeclaredActionButton, { action: action, unavailable: unavailable[action.name], variant: action.variant === "danger" ? "destructive" : "outline", disabled: directAction.isPending, onClick: () => startAction(action) }, action.name))), showEdit ? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: [_jsx(PencilIcon, {}), "Edit"] })) : null, showDelete ? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: () => {
91
+ deleteMutation.reset();
92
+ setDeleteOpen(true);
93
+ }, children: [_jsx(Trash2Icon, {}), "Delete"] })) : null, renderActions ? renderActions(record) : null] })) : null, actionError ? (_jsx("p", { role: "alert", className: "pb-3 text-sm text-destructive", children: actionError })) : null, _jsx("dl", { className: "grid gap-x-6 gap-y-3 rounded-lg border border-border p-4 sm:grid-cols-[minmax(8rem,max-content)_1fr]", children: visibleFields.map((field) => (_jsxs("div", { className: "contents", children: [_jsx("dt", { className: "text-sm font-medium text-muted-foreground", children: field.label ?? field.name }), _jsx("dd", { className: "text-sm wrap-break-word", children: formatFieldValue(record[field.name]) })] }, field.name))) }), recordActions.length > 0 ? (_jsx(ResourceActionDialog, { resourceName: resource.name, action: activeAction, recordId: id, onClose: () => setActiveAction(null), onDenied: denyAction })) : null, editAction ? (_jsx(Dialog, { open: editOpen, onOpenChange: setEditOpen, children: _jsxs(DialogContent, { children: [_jsx(DialogHeader, { children: _jsxs(DialogTitle, { children: ["Edit ", resource.name] }) }), _jsx(ResourceForm, { resource: resource, id: id, defaultValues: record, onSuccess: () => setEditOpen(false), onError: (mutationError) => {
94
+ if (isActionDenied(mutationError, id)) {
95
+ setDenied((current) => ({ ...current, update: true }));
96
+ setEditOpen(false);
97
+ }
98
+ }, submitLabel: "Save changes" })] }) })) : null, deleteAction ? (_jsx(Dialog, { open: deleteOpen, onOpenChange: setDeleteOpen, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: ["Delete this ", resource.name, "?"] }), _jsx(DialogDescription, { children: "This can't be undone." })] }), deleteMutation.error &&
99
+ !isActionDenied(deleteMutation.error, id) ? (_jsx("p", { role: "alert", className: "text-sm text-destructive", children: deleteMutation.error.message })) : null, _jsxs(DialogFooter, { children: [_jsx(DialogClose, { render: _jsx(Button, { type: "button", variant: "outline", children: "Cancel" }) }), _jsx(Button, { type: "button", variant: "destructive", disabled: deleteMutation.isPending, onClick: () => deleteMutation.mutate(id), children: deleteMutation.isPending ? "Deleting…" : "Delete" })] })] }) })) : null] }));
100
+ }
@@ -18,6 +18,10 @@ export interface ResourceTableProps<TRecord extends RowData = Record<string, unk
18
18
  * component's lifetime rather than shown as a dead end.
19
19
  */
20
20
  actions?: boolean;
21
+ /**
22
+ * 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`.
23
+ */
24
+ resourceActions?: boolean;
21
25
  /**
22
26
  * Renders per-row actions (e.g. custom edit/delete buttons). Composed
23
27
  * alongside the built-in actions when `actions` is also set, not in place
@@ -41,5 +45,5 @@ export interface ResourceTableProps<TRecord extends RowData = Record<string, unk
41
45
  * A responsive resource table with search, sorting, pagination, and a
42
46
  * mobile card layout. Standard CRUD actions and custom row actions are opt-in.
43
47
  */
44
- export declare function ResourceTable<TRecord extends RowData = Record<string, unknown>>({ resource, pageSize, actions, renderActions, renderBulkActions, emptyState, className, }: ResourceTableProps<TRecord>): ReactElement;
48
+ export declare function ResourceTable<TRecord extends RowData = Record<string, unknown>>({ resource, pageSize, actions, resourceActions, renderActions, renderBulkActions, emptyState, className, }: ResourceTableProps<TRecord>): ReactElement;
45
49
  //# sourceMappingURL=resource-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource-table.d.ts","sourceRoot":"","sources":["../../src/resource/resource-table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAYpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAgBrD,OAAO,EAEL,KAAK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CAAC,MAAM,EAAE,OAAO,CAAC,CACjD,SAAQ,uBAAuB;IAC/B,oFAAoF;IACpF,QAAQ,EAAE,sBAAsB,CAAC;IACjC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,SAAS,CAAC;IAC/C;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,CAClB,OAAO,EAAE,OAAO,EAAE,EAClB,cAAc,EAAE,MAAM,IAAI,KACvB,SAAS,CAAC;IACf,0FAA0F;IAC1F,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAuBD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,OAAO,SAAS,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjD,EACA,QAAQ,EACR,QAAQ,EACR,OAAe,EACf,eAAyB,EACzB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,SAAS,GACV,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAAG,YAAY,CAkpB5C"}
@@ -6,40 +6,21 @@ import { Checkbox } from "#components/checkbox";
6
6
  import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "#components/dialog";
7
7
  import { Input } from "#components/input";
8
8
  import { cn } from "#lib/utils";
9
+ import { actionNeedsDialog, resourceActionSchemas, unavailableAction, } from "@verikit/ui-core/actions/resource-actions";
10
+ import { formatFieldValue } from "@verikit/ui-core/layout/format-value";
9
11
  import { recordId } from "@verikit/ui-core/query/optimistic";
10
12
  import { useDeleteResource } from "../query/use-resource-mutations.js";
11
13
  import { useResourceTable, } from "../query/use-resource-table.js";
14
+ import { isActionDenied, isPermissionDenied, ResourceActionDialog, useRunResourceAction, } from "./resource-action-dialog.js";
15
+ import { DeclaredActionButton } from "./declared-action-button.js";
12
16
  import { ResourceForm } from "./resource-form.js";
13
17
  import { filterableFields, ResourceTableFilterPanel, } from "./resource-table-filters.js";
14
- /**
15
- * True for an error whose `status` is 403 (permission denied). Duck-typed on
16
- * `status`, not `instanceof VerikitClientError` the same convention that
17
- * class's own doc comment specifies, for callers distinguishing error cases.
18
- */
19
- function isPermissionDenied(error) {
20
- return (typeof error === "object" &&
21
- error !== null &&
22
- "status" in error &&
23
- error.status === 403);
24
- }
25
18
  // `useResourceTable` always sets `header` to `field.label` (a required,
26
19
  // non-empty string field on every `FieldSchema`), so this always reads a
27
20
  // plain string back no function-header or missing-header case to guard.
28
21
  function headerText(header) {
29
22
  return header.column.columnDef.header;
30
23
  }
31
- function cellText(value) {
32
- if (value === null || value === undefined) {
33
- return "";
34
- }
35
- if (value instanceof Date) {
36
- return value.toLocaleString();
37
- }
38
- if (typeof value === "boolean") {
39
- return value ? "Yes" : "No";
40
- }
41
- return String(value);
42
- }
43
24
  function SortIcon({ direction }) {
44
25
  if (direction === "asc") {
45
26
  return _jsx(ArrowUpIcon, { className: "size-3.5" });
@@ -53,8 +34,17 @@ function SortIcon({ direction }) {
53
34
  * A responsive resource table with search, sorting, pagination, and a
54
35
  * mobile card layout. Standard CRUD actions and custom row actions are opt-in.
55
36
  */
56
- export function ResourceTable({ resource, pageSize, actions = false, renderActions, renderBulkActions, emptyState, className, }) {
57
- const { table, isLoading, error, fields, filters, setFilters } = useResourceTable(resource, { pageSize });
37
+ export function ResourceTable({ resource, pageSize, actions = false, resourceActions = actions, renderActions, renderBulkActions, emptyState, className, }) {
38
+ const recordActions = resourceActions
39
+ ? resourceActionSchemas(resource, "record")
40
+ : [];
41
+ const collectionActions = resourceActions
42
+ ? resourceActionSchemas(resource, "collection")
43
+ : [];
44
+ const { table, isLoading, error, fields, filters, setFilters, actions: actionAvailability, } = useResourceTable(resource, {
45
+ pageSize,
46
+ includeActions: recordActions.length > 0 || collectionActions.length > 0,
47
+ });
58
48
  const [createOpen, setCreateOpen] = useState(false);
59
49
  const [createDenied, setCreateDenied] = useState(false);
60
50
  const [editRecord, setEditRecord] = useState(null);
@@ -64,6 +54,45 @@ export function ResourceTable({ resource, pageSize, actions = false, renderActio
64
54
  const [bulkDeleteOpen, setBulkDeleteOpen] = useState(false);
65
55
  const [bulkDeleteError, setBulkDeleteError] = useState(null);
66
56
  const [bulkDeleting, setBulkDeleting] = useState(false);
57
+ const [activeAction, setActiveAction] = useState(null);
58
+ const [deniedCollectionActions, setDeniedCollectionActions] = useState({});
59
+ const [actionError, setActionError] = useState(null);
60
+ function denyAction(action, id) {
61
+ if (id === undefined) {
62
+ setDeniedCollectionActions((current) => ({
63
+ ...current,
64
+ [action.name]: true,
65
+ }));
66
+ return;
67
+ }
68
+ setDeniedRows((current) => ({
69
+ ...current,
70
+ [id]: {
71
+ ...current[id],
72
+ actions: { ...current[id]?.actions, [action.name]: true },
73
+ },
74
+ }));
75
+ }
76
+ const directAction = useRunResourceAction(resource.name, {
77
+ onSuccess: () => setActionError(null),
78
+ onError: (mutationError, variables) => {
79
+ if (isActionDenied(mutationError, variables.recordId)) {
80
+ denyAction(variables.action, variables.recordId);
81
+ }
82
+ else {
83
+ setActionError(mutationError.message);
84
+ }
85
+ },
86
+ });
87
+ function startAction(action, id) {
88
+ setActionError(null);
89
+ if (actionNeedsDialog(action)) {
90
+ setActiveAction({ action, recordId: id });
91
+ }
92
+ else {
93
+ directAction.mutate({ action, recordId: id });
94
+ }
95
+ }
67
96
  const deleteMutation = useDeleteResource(resource.name, {
68
97
  onError: (mutationError, id) => {
69
98
  if (isPermissionDenied(mutationError)) {
@@ -128,14 +157,20 @@ export function ResourceTable({ resource, pageSize, actions = false, renderActio
128
157
  const denied = deniedRows[id];
129
158
  return (_jsxs(_Fragment, { children: [denied?.update ? null : (_jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": "Edit", onClick: () => setEditRecord(record), children: _jsx(PencilIcon, {}) })), denied?.delete ? null : (_jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": "Delete", onClick: () => openDeleteDialog(record), children: _jsx(Trash2Icon, {}) }))] }));
130
159
  }
160
+ function declaredRowActions(record) {
161
+ // Same contract-guaranteed id as `builtInRowActions`.
162
+ const id = recordId(record);
163
+ const denied = deniedRows[id]?.actions;
164
+ return recordActions.map((action) => denied?.[action.name] ? null : (_jsx(DeclaredActionButton, { action: action, unavailable: unavailableAction(actionAvailability, action.name, id), variant: action.variant === "danger" ? "destructive" : "ghost", disabled: directAction.isPending, onClick: () => startAction(action, id) }, action.name)));
165
+ }
131
166
  // Only called from a `hasActionsColumn ? ... : null` branch below, so
132
- // `actions`/`renderActions` being both unset here can't happen.
167
+ // `actions`/`renderActions`/record actions being all unset here can't happen.
133
168
  function rowActions(record) {
134
- return (_jsxs("div", { className: "flex items-center justify-end gap-1", children: [actions ? builtInRowActions(record) : null, renderActions ? renderActions(record) : null] }));
169
+ return (_jsxs("div", { className: "flex items-center justify-end gap-1", children: [declaredRowActions(record), actions ? builtInRowActions(record) : null, renderActions ? renderActions(record) : null] }));
135
170
  }
136
171
  const editId = editRecord ? recordId(editRecord) : undefined;
137
172
  const deleteId = deleteRecord ? recordId(deleteRecord) : undefined;
138
- const hasActionsColumn = actions || Boolean(renderActions);
173
+ const hasActionsColumn = actions || Boolean(renderActions) || recordActions.length > 0;
139
174
  const hasSelectionColumn = actions || Boolean(renderBulkActions);
140
175
  const hasFilterableFields = filterableFields(fields).length > 0;
141
176
  const activeFilterCount = Object.keys(filters).length;
@@ -151,10 +186,10 @@ export function ResourceTable({ resource, pageSize, actions = false, renderActio
151
186
  return (_jsxs("div", { className: cn("w-full", className), children: [_jsxs("div", { className: "flex items-center justify-between gap-2 pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { type: "search", placeholder: "Search...",
152
187
  // `useResourceTable` seeds this state via `useState("")`, so
153
188
  // it's always a string, never nullish.
154
- value: table.store.state.globalFilter, onChange: (event) => table.setGlobalFilter(event.currentTarget.value), className: "max-w-xs" }), hasFilterableFields ? (_jsxs(Button, { type: "button", variant: activeFilterCount > 0 ? "secondary" : "outline", size: "sm", onClick: () => setFiltersOpen((open) => !open), "aria-expanded": filtersOpen, children: [_jsx(SlidersHorizontalIcon, {}), "Filters", activeFilterCount > 0 ? ` (${activeFilterCount})` : ""] })) : null, activeFilterCount > 0 ? (_jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => setFilters({}), children: "Clear filters" })) : null] }), actions && !createDenied ? (_jsxs(Button, { type: "button", size: "sm", onClick: () => setCreateOpen(true), children: [_jsx(PlusIcon, {}), "New"] })) : null] }), filtersOpen && hasFilterableFields ? (_jsx("div", { className: "pb-3", children: _jsx(ResourceTableFilterPanel, { fields: fields, filters: filters, onFiltersChange: setFilters }) })) : null, selectedCount > 0 ? (_jsxs("div", { className: "mb-3 flex items-center justify-between gap-2 rounded-lg border border-border bg-muted/50 px-3 py-2", children: [_jsxs("span", { className: "text-sm text-muted-foreground", children: [selectedCount, " selected"] }), _jsxs("div", { className: "flex items-center gap-2", children: [renderBulkActions
189
+ value: table.store.state.globalFilter, onChange: (event) => table.setGlobalFilter(event.currentTarget.value), className: "max-w-xs" }), hasFilterableFields ? (_jsxs(Button, { type: "button", variant: activeFilterCount > 0 ? "secondary" : "outline", size: "sm", onClick: () => setFiltersOpen((open) => !open), "aria-expanded": filtersOpen, children: [_jsx(SlidersHorizontalIcon, {}), "Filters", activeFilterCount > 0 ? ` (${activeFilterCount})` : ""] })) : null, activeFilterCount > 0 ? (_jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => setFilters({}), children: "Clear filters" })) : null] }), _jsxs("div", { className: "flex items-center gap-2", children: [collectionActions.map((action) => deniedCollectionActions[action.name] ? null : (_jsx(DeclaredActionButton, { action: action, unavailable: unavailableAction(actionAvailability, action.name), variant: action.variant === "danger" ? "destructive" : "outline", disabled: directAction.isPending, onClick: () => startAction(action) }, action.name))), actions && !createDenied ? (_jsxs(Button, { type: "button", size: "sm", onClick: () => setCreateOpen(true), children: [_jsx(PlusIcon, {}), "New"] })) : null] })] }), actionError ? (_jsx("p", { role: "alert", className: "pb-3 text-sm text-destructive", children: actionError })) : null, filtersOpen && hasFilterableFields ? (_jsx("div", { className: "pb-3", children: _jsx(ResourceTableFilterPanel, { fields: fields, filters: filters, onFiltersChange: setFilters }) })) : null, selectedCount > 0 ? (_jsxs("div", { className: "mb-3 flex items-center justify-between gap-2 rounded-lg border border-border bg-muted/50 px-3 py-2", children: [_jsxs("span", { className: "text-sm text-muted-foreground", children: [selectedCount, " selected"] }), _jsxs("div", { className: "flex items-center gap-2", children: [renderBulkActions
155
190
  ? renderBulkActions(selectedRecords, clearSelection)
156
191
  : null, actions ? (_jsxs(Button, { type: "button", variant: "destructive", size: "sm", onClick: openBulkDeleteDialog, children: [_jsx(Trash2Icon, {}), "Delete selected"] })) : null, _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: clearSelection, children: "Clear" })] })] })) : null, error ? (_jsx("p", { role: "alert", className: "pb-3 text-sm text-destructive", children: error.message })) : null, _jsx("div", { className: "hidden overflow-x-auto rounded-lg border border-border md:block", children: _jsxs("table", { className: "w-full text-left text-sm", children: [_jsx("thead", { className: "bg-muted/50 text-muted-foreground", children: _jsxs("tr", { children: [hasSelectionColumn ? (_jsx("th", { className: "w-8 px-3 py-2", children: _jsx(Checkbox, { "aria-label": "Select all rows", checked: rows.length > 0 && table.getIsAllPageRowsSelected(), indeterminate: !table.getIsAllPageRowsSelected() &&
157
- table.getIsSomePageRowsSelected(), onCheckedChange: (checked) => table.toggleAllPageRowsSelected(checked === true) }) })) : null, headerGroup.headers.map((header) => (_jsx("th", { className: "px-3 py-2 font-medium", children: header.column.getCanSort() ? (_jsxs("button", { type: "button", className: "inline-flex items-center gap-1 hover:text-foreground", onClick: header.column.getToggleSortingHandler(), children: [headerText(header), _jsx(SortIcon, { direction: header.column.getIsSorted() })] })) : (headerText(header)) }, header.id))), hasActionsColumn ? _jsx("th", { className: "px-3 py-2" }) : null] }) }), _jsx("tbody", { children: isLoading ? (_jsx("tr", { children: _jsx("td", { colSpan: columnCount, className: "px-3 py-6 text-center text-muted-foreground", children: "Loading\u2026" }) })) : rows.length === 0 ? (_jsx("tr", { children: _jsx("td", { colSpan: columnCount, className: "px-3 py-6 text-center text-muted-foreground", children: resolvedEmptyState }) })) : (rows.map((row) => (_jsxs("tr", { className: "border-t border-border", children: [hasSelectionColumn ? (_jsx("td", { className: "px-3 py-2", children: _jsx(Checkbox, { "aria-label": "Select row", checked: row.getIsSelected(), onCheckedChange: (checked) => row.toggleSelected(checked === true) }) })) : null, row.getAllCells().map((cell) => (_jsx("td", { className: "px-3 py-2", children: cellText(cell.getValue()) }, cell.id))), hasActionsColumn ? (_jsx("td", { className: "px-3 py-2 text-right", children: rowActions(row.original) })) : null] }, row.id)))) })] }) }), _jsx("div", { className: "grid gap-2 md:hidden", children: isLoading ? (_jsx("p", { className: "py-6 text-center text-sm text-muted-foreground", children: "Loading\u2026" })) : rows.length === 0 ? (_jsx("p", { className: "py-6 text-center text-sm text-muted-foreground", children: resolvedEmptyState })) : (rows.map((row) => (_jsxs("div", { className: "rounded-lg border border-border p-3", children: [hasSelectionColumn ? (_jsx("div", { className: "flex justify-end pb-2", children: _jsx(Checkbox, { "aria-label": "Select row", checked: row.getIsSelected(), onCheckedChange: (checked) => row.toggleSelected(checked === true) }) })) : null, row.getAllCells().map((cell) => (_jsxs("div", { className: "flex items-center justify-between gap-2 py-1 text-sm", children: [_jsx("span", { className: "text-muted-foreground", children: headerText({ column: cell.column }) }), _jsx("span", { className: "text-right", children: cellText(cell.getValue()) })] }, cell.id))), hasActionsColumn ? (_jsx("div", { className: "flex justify-end gap-2 pt-2", children: rowActions(row.original) })) : null] }, row.id)))) }), _jsxs("div", { className: "flex items-center justify-between pt-3 text-sm text-muted-foreground", children: [_jsxs("span", { children: ["Page ", table.store.state.pagination.pageIndex + 1, " of", " ", Math.max(1, table.getPageCount()), " \u00B7 ", table.getRowCount(), " total"] }), _jsxs("div", { className: "flex gap-1", children: [_jsx(Button, { type: "button", variant: "outline", size: "icon-sm", disabled: !table.getCanPreviousPage(), onClick: () => table.previousPage(), "aria-label": "Previous page", children: _jsx(ChevronLeftIcon, {}) }), _jsx(Button, { type: "button", variant: "outline", size: "icon-sm", disabled: !table.getCanNextPage(), onClick: () => table.nextPage(), "aria-label": "Next page", children: _jsx(ChevronRightIcon, {}) })] })] }), actions ? (_jsx(Dialog, { open: createOpen, onOpenChange: setCreateOpen, children: _jsxs(DialogContent, { children: [_jsx(DialogHeader, { children: _jsxs(DialogTitle, { children: ["New ", resource.name] }) }), _jsx(ResourceForm, { resource: resource, onSuccess: () => setCreateOpen(false), onError: handleCreateError, submitLabel: "Create" })] }) })) : null, actions ? (_jsx(Dialog, { open: editRecord !== null, onOpenChange: (open) => {
192
+ table.getIsSomePageRowsSelected(), onCheckedChange: (checked) => table.toggleAllPageRowsSelected(checked === true) }) })) : null, headerGroup.headers.map((header) => (_jsx("th", { className: "px-3 py-2 font-medium", children: header.column.getCanSort() ? (_jsxs("button", { type: "button", className: "inline-flex items-center gap-1 hover:text-foreground", onClick: header.column.getToggleSortingHandler(), children: [headerText(header), _jsx(SortIcon, { direction: header.column.getIsSorted() })] })) : (headerText(header)) }, header.id))), hasActionsColumn ? _jsx("th", { className: "px-3 py-2" }) : null] }) }), _jsx("tbody", { children: isLoading ? (_jsx("tr", { children: _jsx("td", { colSpan: columnCount, className: "px-3 py-6 text-center text-muted-foreground", children: "Loading\u2026" }) })) : rows.length === 0 ? (_jsx("tr", { children: _jsx("td", { colSpan: columnCount, className: "px-3 py-6 text-center text-muted-foreground", children: resolvedEmptyState }) })) : (rows.map((row) => (_jsxs("tr", { className: "border-t border-border", children: [hasSelectionColumn ? (_jsx("td", { className: "px-3 py-2", children: _jsx(Checkbox, { "aria-label": "Select row", checked: row.getIsSelected(), onCheckedChange: (checked) => row.toggleSelected(checked === true) }) })) : null, row.getAllCells().map((cell) => (_jsx("td", { className: "px-3 py-2", children: formatFieldValue(cell.getValue()) }, cell.id))), hasActionsColumn ? (_jsx("td", { className: "px-3 py-2 text-right", children: rowActions(row.original) })) : null] }, row.id)))) })] }) }), _jsx("div", { className: "grid gap-2 md:hidden", children: isLoading ? (_jsx("p", { className: "py-6 text-center text-sm text-muted-foreground", children: "Loading\u2026" })) : rows.length === 0 ? (_jsx("p", { className: "py-6 text-center text-sm text-muted-foreground", children: resolvedEmptyState })) : (rows.map((row) => (_jsxs("div", { className: "rounded-lg border border-border p-3", children: [hasSelectionColumn ? (_jsx("div", { className: "flex justify-end pb-2", children: _jsx(Checkbox, { "aria-label": "Select row", checked: row.getIsSelected(), onCheckedChange: (checked) => row.toggleSelected(checked === true) }) })) : null, row.getAllCells().map((cell) => (_jsxs("div", { className: "flex items-center justify-between gap-2 py-1 text-sm", children: [_jsx("span", { className: "text-muted-foreground", children: headerText({ column: cell.column }) }), _jsx("span", { className: "text-right", children: formatFieldValue(cell.getValue()) })] }, cell.id))), hasActionsColumn ? (_jsx("div", { className: "flex justify-end gap-2 pt-2", children: rowActions(row.original) })) : null] }, row.id)))) }), _jsxs("div", { className: "flex items-center justify-between pt-3 text-sm text-muted-foreground", children: [_jsxs("span", { children: ["Page ", table.store.state.pagination.pageIndex + 1, " of", " ", Math.max(1, table.getPageCount()), " \u00B7 ", table.getRowCount(), " total"] }), _jsxs("div", { className: "flex gap-1", children: [_jsx(Button, { type: "button", variant: "outline", size: "icon-sm", disabled: !table.getCanPreviousPage(), onClick: () => table.previousPage(), "aria-label": "Previous page", children: _jsx(ChevronLeftIcon, {}) }), _jsx(Button, { type: "button", variant: "outline", size: "icon-sm", disabled: !table.getCanNextPage(), onClick: () => table.nextPage(), "aria-label": "Next page", children: _jsx(ChevronRightIcon, {}) })] })] }), recordActions.length > 0 || collectionActions.length > 0 ? (_jsx(ResourceActionDialog, { resourceName: resource.name, action: activeAction?.action ?? null, recordId: activeAction?.recordId, onClose: () => setActiveAction(null), onDenied: (action) => denyAction(action, activeAction?.recordId) })) : null, actions ? (_jsx(Dialog, { open: createOpen, onOpenChange: setCreateOpen, children: _jsxs(DialogContent, { children: [_jsx(DialogHeader, { children: _jsxs(DialogTitle, { children: ["New ", resource.name] }) }), _jsx(ResourceForm, { resource: resource, onSuccess: () => setCreateOpen(false), onError: handleCreateError, submitLabel: "Create" })] }) })) : null, actions ? (_jsx(Dialog, { open: editRecord !== null, onOpenChange: (open) => {
158
193
  if (!open) {
159
194
  setEditRecord(null);
160
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verikit/react",
3
- "version": "0.24.2",
3
+ "version": "0.24.4",
4
4
  "description": "React UI bindings for Verikit resource workflows.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -57,11 +57,11 @@
57
57
  "clsx": "^2.1.1",
58
58
  "lucide-react": "^1.26.0",
59
59
  "tailwind-merge": "^3.6.0",
60
- "@verikit/core": "0.24.2",
61
- "@verikit/client": "0.24.2",
62
- "@verikit/ui-core": "0.24.2",
63
- "@verikit/runtime": "0.24.2",
64
- "@verikit/theme": "0.24.2"
60
+ "@verikit/client": "0.24.4",
61
+ "@verikit/core": "0.24.4",
62
+ "@verikit/runtime": "0.24.4",
63
+ "@verikit/theme": "0.24.4",
64
+ "@verikit/ui-core": "0.24.4"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@base-ui/react": "^1.6.0",
@@ -70,10 +70,10 @@
70
70
  "@tanstack/react-table": "^9.0.0",
71
71
  "@types/jsdom": "^28.0.3",
72
72
  "@types/node": "^26.1.1",
73
- "@types/react": "^19.2.2",
73
+ "@types/react": "^19.2.17",
74
74
  "@types/react-dom": "^19.2.3",
75
75
  "jsdom": "^30.0.1",
76
- "react": "^19.2.0",
76
+ "react": "^19.2.8",
77
77
  "react-dom": "^19.2.8",
78
78
  "typescript": "^6.0.3"
79
79
  },