@verikit/ui-core 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.
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/actions/resource-actions.d.ts +19 -0
- package/dist/actions/resource-actions.d.ts.map +1 -0
- package/dist/actions/resource-actions.js +34 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/layout/format-value.d.ts +5 -0
- package/dist/layout/format-value.d.ts.map +1 -0
- package/dist/layout/format-value.js +15 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +1 -0
- package/dist/query/query-keys.d.ts +2 -0
- package/dist/query/query-keys.d.ts.map +1 -1
- package/dist/query/query-keys.js +1 -0
- package/package.json +8 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { actionLabel, actionNeedsDialog, resourceActionSchemas, unavailableAction, } from "./resource-actions.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ListActionAvailability, UnavailableAction } from "@verikit/client";
|
|
2
|
+
import type { ActionSchemaLike, Resource, ResourceSchema } from "@verikit/core";
|
|
3
|
+
/** Resource builder or schema whose declared actions a UI renders. */
|
|
4
|
+
export type ResourceActionSource = Resource | ResourceSchema;
|
|
5
|
+
/** Where an action renders: per record (row) or once for the collection (toolbar). */
|
|
6
|
+
export type ResourceActionScope = NonNullable<ActionSchemaLike["scope"]>;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the actions declared on a resource via `defineResource({ actions })`, in declaration order, optionally limited to one scope. Actions without an explicit scope count as `"record"`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resourceActionSchemas(source: ResourceActionSource, scope?: ResourceActionScope): ActionSchemaLike[];
|
|
11
|
+
/** True when running an action needs a dialog: a confirmation to accept or form input to collect. */
|
|
12
|
+
export declare function actionNeedsDialog(action: ActionSchemaLike): boolean;
|
|
13
|
+
/** Display label for an action, falling back to its name. */
|
|
14
|
+
export declare function actionLabel(action: ActionSchemaLike): string;
|
|
15
|
+
/**
|
|
16
|
+
* Looks up why an action can't run, from a list's `actions` (requested with `includeActions: true`): pass the record id for a record-scoped action, none for a collection-scoped one. Returns `undefined` when the action can run, or when the list didn't report availability.
|
|
17
|
+
*/
|
|
18
|
+
export declare function unavailableAction(availability: ListActionAvailability | undefined, actionName: string, recordId?: string): UnavailableAction | undefined;
|
|
19
|
+
//# sourceMappingURL=resource-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-actions.d.ts","sourceRoot":"","sources":["../../src/actions/resource-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEhF,sEAAsE;AACtE,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,cAAc,CAAC;AAE7D,sFAAsF;AACtF,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAMzE;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,oBAAoB,EAC5B,KAAK,CAAC,EAAE,mBAAmB,GAC1B,gBAAgB,EAAE,CAQpB;AAED,qGAAqG;AACrG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAKnE;AAED,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,sBAAsB,GAAG,SAAS,EAChD,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,iBAAiB,GAAG,SAAS,CAQ/B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function isResource(source) {
|
|
2
|
+
return typeof source.toSchema === "function";
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Returns the actions declared on a resource via `defineResource({ actions })`, in declaration order, optionally limited to one scope. Actions without an explicit scope count as `"record"`.
|
|
6
|
+
*/
|
|
7
|
+
export function resourceActionSchemas(source, scope) {
|
|
8
|
+
const actions = isResource(source)
|
|
9
|
+
? source.actions.map((declaration) => declaration.toSchema())
|
|
10
|
+
: Object.values(source.actions ?? {});
|
|
11
|
+
return scope
|
|
12
|
+
? actions.filter((action) => (action.scope ?? "record") === scope)
|
|
13
|
+
: actions;
|
|
14
|
+
}
|
|
15
|
+
/** True when running an action needs a dialog: a confirmation to accept or form input to collect. */
|
|
16
|
+
export function actionNeedsDialog(action) {
|
|
17
|
+
return (action.confirmation !== undefined ||
|
|
18
|
+
Object.keys(action.form ?? {}).length > 0);
|
|
19
|
+
}
|
|
20
|
+
/** Display label for an action, falling back to its name. */
|
|
21
|
+
export function actionLabel(action) {
|
|
22
|
+
return action.label ?? action.name;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Looks up why an action can't run, from a list's `actions` (requested with `includeActions: true`): pass the record id for a record-scoped action, none for a collection-scoped one. Returns `undefined` when the action can run, or when the list didn't report availability.
|
|
26
|
+
*/
|
|
27
|
+
export function unavailableAction(availability, actionName, recordId) {
|
|
28
|
+
if (!availability) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return recordId === undefined
|
|
32
|
+
? availability.collection[actionName]
|
|
33
|
+
: availability.records[recordId]?.[actionName];
|
|
34
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a record's field value as display text: empty for `null`/`undefined`, the locale string for a `Date`, "Yes"/"No" for a boolean, and `String(value)` otherwise.
|
|
3
|
+
*/
|
|
4
|
+
export declare function formatFieldValue(value: unknown): string;
|
|
5
|
+
//# sourceMappingURL=format-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-value.d.ts","sourceRoot":"","sources":["../../src/layout/format-value.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAcvD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a record's field value as display text: empty for `null`/`undefined`, the locale string for a `Date`, "Yes"/"No" for a boolean, and `String(value)` otherwise.
|
|
3
|
+
*/
|
|
4
|
+
export function formatFieldValue(value) {
|
|
5
|
+
if (value === null || value === undefined) {
|
|
6
|
+
return "";
|
|
7
|
+
}
|
|
8
|
+
if (value instanceof Date) {
|
|
9
|
+
return value.toLocaleString();
|
|
10
|
+
}
|
|
11
|
+
if (typeof value === "boolean") {
|
|
12
|
+
return value ? "Yes" : "No";
|
|
13
|
+
}
|
|
14
|
+
return String(value);
|
|
15
|
+
}
|
package/dist/layout/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,OAAO,EACP,cAAc,EACd,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,OAAO,EACP,cAAc,EACd,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/layout/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export interface ResourceQueryKeys {
|
|
|
3
3
|
all: readonly [string, string, string];
|
|
4
4
|
list: (params?: ListParams) => readonly [string, string, string, "list", ListParams];
|
|
5
5
|
find: (id: string) => readonly [string, string, string, "find", string];
|
|
6
|
+
/** Kept apart from `find` because its cached data has a different shape. */
|
|
7
|
+
findWithActions: (id: string) => readonly [string, string, string, "findWithActions", string];
|
|
6
8
|
relationship: (relationshipName: string, params?: ListParams) => readonly [string, string, string, "relationship", string, ListParams];
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-keys.d.ts","sourceRoot":"","sources":["../../src/query/query-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IA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AAM,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAClE,YAAY,EAAE,CACZ,gBAAgB,EAAE,MAAM,EACxB,MAAM,CAAC,EAAE,UAAU,KAChB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;CAC5E;AAID;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,GAAG,MAAM,GAC7B,iBAAiB,CA4BnB"}
|
package/dist/query/query-keys.js
CHANGED
|
@@ -20,6 +20,7 @@ export function resourceQueryKeys(name, client) {
|
|
|
20
20
|
all: ["verikit", namespace, name],
|
|
21
21
|
list: (params = {}) => ["verikit", namespace, name, "list", params],
|
|
22
22
|
find: (id) => ["verikit", namespace, name, "find", id],
|
|
23
|
+
findWithActions: (id) => ["verikit", namespace, name, "findWithActions", id],
|
|
23
24
|
relationship: (relationshipName, params = {}) => [
|
|
24
25
|
"verikit",
|
|
25
26
|
namespace,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verikit/ui-core",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.4",
|
|
4
4
|
"description": "Framework-neutral form, layout, and query logic shared by Verikit UI bindings.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
31
|
"default": "./dist/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./actions/*": {
|
|
34
|
+
"types": "./dist/actions/*.d.ts",
|
|
35
|
+
"default": "./dist/actions/*.js"
|
|
36
|
+
},
|
|
33
37
|
"./form/*": {
|
|
34
38
|
"types": "./dist/form/*.d.ts",
|
|
35
39
|
"default": "./dist/form/*.js"
|
|
@@ -48,9 +52,9 @@
|
|
|
48
52
|
],
|
|
49
53
|
"dependencies": {
|
|
50
54
|
"@tanstack/query-core": "^5.101.4",
|
|
51
|
-
"@verikit/core": "0.24.
|
|
52
|
-
"@verikit/
|
|
53
|
-
"@verikit/
|
|
55
|
+
"@verikit/core": "0.24.4",
|
|
56
|
+
"@verikit/runtime": "0.24.4",
|
|
57
|
+
"@verikit/client": "0.24.4"
|
|
54
58
|
},
|
|
55
59
|
"devDependencies": {
|
|
56
60
|
"@types/node": "^26.1.1",
|