@panneau/actions 4.1.1 → 5.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/dist/ActionRunner.css +84 -0
- package/dist/ActionRunner.module.js +34 -0
- package/dist/ActionRunner.module.js.map +1 -0
- package/dist/ActionRunnerProvider.d.ts +36 -0
- package/dist/ActionRunnerProvider.d.ts.map +1 -0
- package/dist/ActionRunnerProvider.js +245 -0
- package/dist/ActionRunnerProvider.js.map +1 -0
- package/dist/ActionRuns.d.ts +12 -0
- package/dist/ActionRuns.d.ts.map +1 -0
- package/dist/ActionRuns.js +128 -0
- package/dist/ActionRuns.js.map +1 -0
- package/dist/ParametersDialog.d.ts +19 -0
- package/dist/ParametersDialog.d.ts.map +1 -0
- package/dist/ParametersDialog.js +119 -0
- package/dist/ParametersDialog.js.map +1 -0
- package/dist/ResultsDialog.d.ts +10 -0
- package/dist/ResultsDialog.d.ts.map +1 -0
- package/dist/ResultsDialog.js +130 -0
- package/dist/ResultsDialog.js.map +1 -0
- package/dist/context.d.ts +10 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/context.js.map +1 -0
- package/dist/describe.d.ts +8 -0
- package/dist/describe.d.ts.map +1 -0
- package/dist/describe.js +32 -0
- package/dist/describe.js.map +1 -0
- package/dist/index.d.ts +9 -10
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -74
- package/dist/messages.d.ts +2 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +1 -0
- package/dist/request.d.ts +15 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +50 -0
- package/dist/request.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useActionRunner.d.ts +21 -0
- package/dist/useActionRunner.d.ts.map +1 -0
- package/dist/useActionRunner.js +34 -0
- package/dist/useActionRunner.js.map +1 -0
- package/package.json +29 -50
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { DataAdapter } from '@panneau/data';
|
|
3
|
+
import type { Action, ActionResult, ActionRun, ActionScope, RouteReference, Selection } from '@panneau/protocol';
|
|
4
|
+
/**
|
|
5
|
+
* What the runner needs from a backend: the action methods of a `DataAdapter`. A product with its
|
|
6
|
+
* own API implements these, and nothing else. Without `cancelActionRun()`, runs can't be cancelled.
|
|
7
|
+
*/
|
|
8
|
+
export type ActionAdapter = Pick<DataAdapter, 'runAction' | 'getActionRun'> & Partial<Pick<DataAdapter, 'cancelActionRun'>>;
|
|
9
|
+
/**
|
|
10
|
+
* An action to run, and what it applies to. A list's `ListActionEvent` is one, and so is
|
|
11
|
+
* `{ action, scope: 'item', item }` for the item of a form.
|
|
12
|
+
*/
|
|
13
|
+
export interface ActionTarget {
|
|
14
|
+
action: Action;
|
|
15
|
+
scope: ActionScope;
|
|
16
|
+
/** The item of an `item` action. */
|
|
17
|
+
item?: {
|
|
18
|
+
id: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
/** The selection of a `selection` action: ids, or every item matching a query. */
|
|
22
|
+
selection?: Selection;
|
|
23
|
+
/** How many items the action applies to. */
|
|
24
|
+
count?: number;
|
|
25
|
+
}
|
|
26
|
+
/** What running an action gave. A run that the user cancelled gives `false` instead. */
|
|
27
|
+
export type ActionOutcome = {
|
|
28
|
+
status: 'done';
|
|
29
|
+
result: ActionResult;
|
|
30
|
+
} | {
|
|
31
|
+
status: 'queued';
|
|
32
|
+
run: ActionRun;
|
|
33
|
+
} | {
|
|
34
|
+
status: 'navigated';
|
|
35
|
+
to: string | RouteReference;
|
|
36
|
+
};
|
|
37
|
+
/** The download of an action result. */
|
|
38
|
+
export type ActionDownload = NonNullable<ActionResult['download']>;
|
|
39
|
+
/** Where a result was given: the resource and the action's target. */
|
|
40
|
+
export interface ActionResultContext {
|
|
41
|
+
resource: string;
|
|
42
|
+
target: ActionTarget;
|
|
43
|
+
}
|
|
44
|
+
/** A queued run that the runner follows, until it is dismissed. */
|
|
45
|
+
export interface FollowedRun {
|
|
46
|
+
run: ActionRun;
|
|
47
|
+
resource: string;
|
|
48
|
+
target: ActionTarget;
|
|
49
|
+
}
|
|
50
|
+
/** Props of the handler of a `client` action, which a plugin registers by the action's `component`. */
|
|
51
|
+
export interface ClientActionProps {
|
|
52
|
+
action: Action;
|
|
53
|
+
resource: string;
|
|
54
|
+
target: ActionTarget;
|
|
55
|
+
/** Ends the action. With a result, the runner shows it as it shows the result of a server action. */
|
|
56
|
+
onDone: (result?: ActionResult) => void;
|
|
57
|
+
/** Ends the action without running it: a list keeps its selection. */
|
|
58
|
+
onCancel: () => void;
|
|
59
|
+
}
|
|
60
|
+
/** A handler of `client` actions. */
|
|
61
|
+
export type ClientActionHandler = ComponentType<ClientActionProps>;
|
|
62
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EACR,MAAM,EACN,YAAY,EACZ,SAAS,EACT,WAAW,EACX,cAAc,EACd,SAAS,EACZ,MAAM,mBAAmB,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,cAAc,CAAC,GACvE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,WAAW,CAAC;IACnB,oCAAoC;IACpC,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM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3
|
+
* Runs the actions of a resource through the closest `ActionRunnerProvider`. The function takes a
|
|
4
|
+
* list's `ListActionEvent`, so it is the `onAction` of a list:
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const runAction = useActionRunner('pages');
|
|
8
|
+
* <ListView list={list} items={items} actions={actions} onAction={runAction} />
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* It resolves once the action has run, has been queued or has navigated, with `false` when the
|
|
12
|
+
* user cancelled its parameters (a list then keeps its selection), and rejects when it failed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useActionRunner(resource: string): (target: ActionTarget) => Promise<ActionOutcome | false>;
|
|
15
|
+
/** The queued runs of the closest `ActionRunnerProvider`, to cancel or dismiss them. */
|
|
16
|
+
export declare function useActionRuns(): {
|
|
17
|
+
runs: readonly FollowedRun[];
|
|
18
|
+
cancel: (id: string) => Promise<void>;
|
|
19
|
+
dismiss: (id: string) => void;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=useActionRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useActionRunner.d.ts","sourceRoot":"","sources":["../src/useActionRunner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAExE;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC3B,QAAQ,EAAE,MAAM,GACjB,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAM1D;AAED,wFAAwF;AACxF,wBAAgB,aAAa,IAAI;IAC7B,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IAC7B,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAMA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ActionRunnerContext } from "./context.js";
|
|
2
|
+
import { use } from "react";
|
|
3
|
+
//#region src/useActionRunner.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runs the actions of a resource through the closest `ActionRunnerProvider`. The function takes a
|
|
6
|
+
* list's `ListActionEvent`, so it is the `onAction` of a list:
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const runAction = useActionRunner('pages');
|
|
10
|
+
* <ListView list={list} items={items} actions={actions} onAction={runAction} />
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* It resolves once the action has run, has been queued or has navigated, with `false` when the
|
|
14
|
+
* user cancelled its parameters (a list then keeps its selection), and rejects when it failed.
|
|
15
|
+
*/
|
|
16
|
+
function useActionRunner(resource) {
|
|
17
|
+
const context = use(ActionRunnerContext);
|
|
18
|
+
if (context === null) throw new Error("useActionRunner() must be used inside <ActionRunnerProvider>.");
|
|
19
|
+
return (target) => context.run(resource, target);
|
|
20
|
+
}
|
|
21
|
+
/** The queued runs of the closest `ActionRunnerProvider`, to cancel or dismiss them. */
|
|
22
|
+
function useActionRuns() {
|
|
23
|
+
const context = use(ActionRunnerContext);
|
|
24
|
+
if (context === null) throw new Error("useActionRuns() must be used inside <ActionRunnerProvider>.");
|
|
25
|
+
return {
|
|
26
|
+
runs: context.runs,
|
|
27
|
+
cancel: context.cancelRun,
|
|
28
|
+
dismiss: context.dismissRun
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { useActionRunner, useActionRuns };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=useActionRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useActionRunner.js","names":[],"sources":["../src/useActionRunner.ts"],"sourcesContent":["import { use } from 'react';\n\nimport { ActionRunnerContext } from './context';\nimport type { ActionOutcome, ActionTarget, FollowedRun } from './types';\n\n/**\n * Runs the actions of a resource through the closest `ActionRunnerProvider`. The function takes a\n * list's `ListActionEvent`, so it is the `onAction` of a list:\n *\n * ```tsx\n * const runAction = useActionRunner('pages');\n * <ListView list={list} items={items} actions={actions} onAction={runAction} />\n * ```\n *\n * It resolves once the action has run, has been queued or has navigated, with `false` when the\n * user cancelled its parameters (a list then keeps its selection), and rejects when it failed.\n */\nexport function useActionRunner(\n resource: string,\n): (target: ActionTarget) => Promise<ActionOutcome | false> {\n const context = use(ActionRunnerContext);\n if (context === null) {\n throw new Error('useActionRunner() must be used inside <ActionRunnerProvider>.');\n }\n return (target) => context.run(resource, target);\n}\n\n/** The queued runs of the closest `ActionRunnerProvider`, to cancel or dismiss them. */\nexport function useActionRuns(): {\n runs: readonly FollowedRun[];\n cancel: (id: string) => Promise<void>;\n dismiss: (id: string) => void;\n} {\n const context = use(ActionRunnerContext);\n if (context === null) {\n throw new Error('useActionRuns() must be used inside <ActionRunnerProvider>.');\n }\n return { runs: context.runs, cancel: context.cancelRun, dismiss: context.dismissRun };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAgB,gBACZ,UACwD;CACxD,MAAM,UAAU,IAAI,mBAAmB;CACvC,IAAI,YAAY,MACZ,MAAM,IAAI,MAAM,+DAA+D;CAEnF,QAAQ,WAAW,QAAQ,IAAI,UAAU,MAAM;AACnD;;AAGA,SAAgB,gBAId;CACE,MAAM,UAAU,IAAI,mBAAmB;CACvC,IAAI,YAAY,MACZ,MAAM,IAAI,MAAM,6DAA6D;CAEjF,OAAO;EAAE,MAAM,QAAQ;EAAM,QAAQ,QAAQ;EAAW,SAAS,QAAQ;CAAW;AACxF"}
|
package/package.json
CHANGED
|
@@ -1,72 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/actions",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
],
|
|
8
|
-
"homepage": "https://github.com/folkloreinc/panneau-js",
|
|
3
|
+
"version": "5.0.0-alpha.1",
|
|
4
|
+
"description": "Runs the actions of lists and forms: parameters in a dialog, the action through a data adapter, its result, and queued runs.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
9
7
|
"repository": {
|
|
10
8
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/folkloreinc/panneau-js.git"
|
|
12
|
-
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"author": {
|
|
15
|
-
"name": "Folklore",
|
|
16
|
-
"email": "info@folklore.email"
|
|
9
|
+
"url": "git+https://github.com/folkloreinc/panneau-js.git",
|
|
10
|
+
"directory": "packages/actions"
|
|
17
11
|
},
|
|
18
|
-
"contributors": [
|
|
19
|
-
{
|
|
20
|
-
"name": "David Mongeau-Petitpas",
|
|
21
|
-
"email": "dmp@folklore.email"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"name": "Nicolas Roy-Bourdages",
|
|
25
|
-
"email": "nrb@folklore.email"
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
12
|
"sideEffects": [
|
|
29
|
-
"
|
|
13
|
+
"*.css"
|
|
30
14
|
],
|
|
31
|
-
"type": "module",
|
|
32
15
|
"exports": {
|
|
33
16
|
".": {
|
|
17
|
+
"@panneau/source": "./src/index.ts",
|
|
34
18
|
"types": "./dist/index.d.ts",
|
|
35
19
|
"default": "./dist/index.js"
|
|
36
|
-
}
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
37
22
|
},
|
|
38
|
-
"module": "dist/index.js",
|
|
39
|
-
"types": "dist/index.d.ts",
|
|
40
23
|
"files": [
|
|
41
|
-
"dist"
|
|
42
|
-
"assets"
|
|
24
|
+
"dist"
|
|
43
25
|
],
|
|
44
26
|
"scripts": {
|
|
45
|
-
"build": "
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"@babel/runtime": "^7.28.6",
|
|
51
|
-
"@panneau/action-delete": "^4.1.1",
|
|
52
|
-
"@panneau/action-duplicate": "^4.1.1",
|
|
53
|
-
"@panneau/action-edit": "^4.1.1",
|
|
54
|
-
"@panneau/action-import": "^4.1.1",
|
|
55
|
-
"@panneau/action-restore": "^4.1.1",
|
|
56
|
-
"@panneau/action-show": "^4.1.1",
|
|
57
|
-
"@panneau/action-upload": "^4.1.1",
|
|
58
|
-
"@panneau/core": "^4.1.1"
|
|
27
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"api": "tsc -p tsconfig.build.json && node ../../scripts/api-report.js"
|
|
59
30
|
},
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"react-dom": "^19.0.0"
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
63
33
|
},
|
|
64
34
|
"peerDependencies": {
|
|
65
35
|
"react": "^19.2.0",
|
|
66
|
-
"react-
|
|
36
|
+
"react-aria-components": "^1.22.0",
|
|
37
|
+
"react-intl": "^12.0.0"
|
|
67
38
|
},
|
|
68
|
-
"
|
|
69
|
-
"
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@panneau/core": "5.0.0-alpha.1",
|
|
41
|
+
"@panneau/data": "5.0.0-alpha.1",
|
|
42
|
+
"@panneau/forms": "5.0.0-alpha.1",
|
|
43
|
+
"@panneau/intl": "5.0.0-alpha.1",
|
|
44
|
+
"@panneau/protocol": "5.0.0-alpha.1",
|
|
45
|
+
"@panneau/ui": "5.0.0-alpha.1",
|
|
46
|
+
"lucide-react": "^1.57.0"
|
|
70
47
|
},
|
|
71
|
-
"
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@panneau/lists": "5.0.0-alpha.1"
|
|
50
|
+
}
|
|
72
51
|
}
|