@panneau/actions 5.0.0-alpha.5 → 5.0.0-alpha.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ParametersDialog.js","names":["onCancel","confirmLabel","_c","styles"],"sources":["../src/ParametersDialog.tsx"],"sourcesContent":["import { Form } from '@panneau/forms';\nimport type { Action } from '@panneau/protocol';\nimport { Button, Dialog, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './ActionRunner.module.css';\nimport { messages } from './messages';\nimport type { ActionOutcome } from './types';\n\nexport interface ParametersDialogProps {\n action: Action;\n /** How many items the action applies to, for the confirm label. */\n count?: number | undefined;\n locales?: readonly string[] | undefined;\n /** Runs the action with the values. A validation error (`422`) shows on the fields. */\n onSubmit: (values: Record<string, unknown>) => Promise<ActionOutcome>;\n onDone: (outcome: ActionOutcome) => void;\n onCancel: () => void;\n}\n\n/**\n * The parameters of an action (`fields`, in its `layout`), in a dialog, with the client validation\n * of forms. The action runs when the form is submitted; errors of the action endpoint (`422`, keyed\n * by paths inside `values`) show on the fields, and other errors in the form.\n */\nexport function ParametersDialog({\n action,\n locales,\n onSubmit,\n onDone,\n onCancel,\n}: ParametersDialogProps) {\n const intl = usePanneauIntl();\n const confirmLabel =\n typeof action.confirm === 'object' && action.confirm.confirmLabel !== undefined\n ? action.confirm.confirmLabel\n : action.label;\n return (\n <Dialog\n isOpen\n onOpenChange={(open) => {\n if (!open) {\n onCancel();\n }\n }}\n title={action.label}\n size=\"md\"\n >\n <Form\n fields={action.fields ?? []}\n layout={action.layout ?? []}\n {...(locales !== undefined ? { locales } : {})}\n aria-label={action.label}\n submitLabel={confirmLabel}\n actions={\n <Button variant=\"secondary\" onPress={onCancel}>\n {intl.formatMessage(messages.cancel)}\n </Button>\n }\n onSubmit={(values) => onSubmit(values)}\n onSubmitted={(outcome) => onDone(outcome as ActionOutcome)}\n guardUnsavedChanges={false}\n showSavedToast={false}\n className={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ector","Form","useFormContext","useLeaveConfirmation","getActionLabel","Action","Button","Dialog","usePanneauIntl","styles","messages","ActionOutcome","ParametersDialogProps","action","count","locales","onSubmit","values","Record","Promise","onDone","outcome","onCancel","CancelButton","t0","$","_c","closeRef","intl","form","dirty","_temp","leave","t1","confirmLeave","then","confirmed","request","t2","current","t3","formatMessage","cancel","t4","t5","dialog","state","ParametersDialog","close","confirm","confirmLabel","undefined","open","fields","layout","t6","t7","t8","t9","t10","t11","parameters","t12","_c","_Fragment","styles"],"sources":["../src/ParametersDialog.tsx"],"sourcesContent":["import { type RefObject, useEffect, useRef } from 'react';\n\nimport { useFormSelector } from '@panneau/core';\nimport { Form, useFormContext, useLeaveConfirmation } from '@panneau/forms';\nimport { getActionLabel } from '@panneau/intl';\nimport type { Action } from '@panneau/protocol';\nimport { Button, Dialog, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './ActionRunner.module.css';\nimport { messages } from './messages';\nimport type { ActionOutcome } from './types';\n\nexport interface ParametersDialogProps {\n action: Action;\n /** How many items the action applies to, for the confirm label. */\n count?: number | undefined;\n locales?: readonly string[] | undefined;\n /** Runs the action with the values. A validation error (`422`) shows on the fields. */\n onSubmit: (values: Record<string, unknown>) => Promise<ActionOutcome>;\n onDone: (outcome: ActionOutcome) => void;\n onCancel: () => void;\n}\n\n/**\n * Cancel, inside the form: with changed values, it asks first, as leaving a form page does. The\n * dialog asks it to close (Escape, a click outside) through `closeRef`.\n */\nfunction CancelButton({\n closeRef,\n onCancel,\n}: {\n closeRef: RefObject<(() => void) | null>;\n onCancel: () => void;\n}) {\n const intl = usePanneauIntl();\n const form = useFormContext();\n const dirty = useFormSelector(form, (state) => state.dirty);\n const leave = useLeaveConfirmation(dirty);\n const request = () => {\n void leave.confirmLeave().then((confirmed) => {\n if (confirmed) {\n onCancel();\n }\n });\n };\n useEffect(() => {\n closeRef.current = request;\n });\n return (\n <>\n <Button onPress={request}>{intl.formatMessage(messages.cancel)}</Button>\n {leave.dialog}\n </>\n );\n}\n\n/**\n * The parameters of an action (`fields`, in its `layout`), in a dialog, with the client validation\n * of forms. The action runs when the form is submitted; errors of the action endpoint (`422`, keyed\n * by paths inside `values`) show on the fields, and other errors in the form.\n *\n * Closing the dialog with changed values (Escape, a click outside, Cancel) asks first, as leaving\n * a form page does.\n */\nexport function ParametersDialog({\n action,\n locales,\n onSubmit,\n onDone,\n onCancel,\n}: ParametersDialogProps) {\n const intl = usePanneauIntl();\n const close = useRef<(() => void) | null>(null);\n const confirmLabel =\n typeof action.confirm === 'object' && action.confirm.confirmLabel !== undefined\n ? action.confirm.confirmLabel\n : getActionLabel(action, intl);\n return (\n <Dialog\n isOpen\n onOpenChange={(open) => {\n if (!open) {\n (close.current ?? onCancel)();\n }\n }}\n title={getActionLabel(action, intl)}\n size=\"md\"\n >\n <Form\n fields={action.fields ?? []}\n layout={action.layout ?? []}\n {...(locales !== undefined ? { locales } : {})}\n aria-label={getActionLabel(action, intl)}\n submitLabel={confirmLabel}\n actions={<CancelButton closeRef={close} onCancel={onCancel} />}\n onSubmit={(values) => onSubmit(values)}\n onSubmitted={(outcome) => onDone(outcome as ActionOutcome)}\n showSavedToast={false}\n className={styles.parameters}\n />\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,SAAA0B,aAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAsB,MAAA,EAAAC,UAAAL,aAAAE;CAOlB,MAAAI,OAAapB,eAAe;CAC5B,MAAAqB,OAAa3B,eAAe;CAC5B,MAAA4B,QAAc9B,gBAAgB6B,MAAME,KAAsB;CAC1D,MAAAC,QAAc7B,qBAAqB2B,KAAK;CAAE,IAAAG;CAAA,IAAAR,EAAA,OAAAO,SAAAP,EAAA,OAAAH,UAAA;EAC1BW,WAAA;GACPD,MAAKE,aAAc,CAAC,CAAAC,MAAMC,cAAA;IAC3B,IAAIA,WACAd,SAAS;GACZ,CACJ;EAAC;EACLG,EAAA,KAAAO;EAAAP,EAAA,KAAAH;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EAAA,MAAAiC;EAAAjC,EAAA,MAAAmC;CAAA,OAAAA,MAAAnC,EAAA;CAAA,IAAAqC;CAAA,IAAArC,EAAA,QAAAmC,OAAAnC,EAAA,QAAAa,MAAAb,EAAA,QAAAe,IAAA;EArBNsB,MAAA,oBAAC,QAAD;GACI,QAAA;GACc,cAAAxB;GAKP,OAAAE;GACF,MAAA;GAELoB,UAAAA;EAVG,CAAA;EAsBEnC,EAAA,MAAAmC;EAAAnC,EAAA,MAAAa;EAAAb,EAAA,MAAAe;EAAAf,EAAA,MAAAqC;CAAA,OAAAA,MAAArC,EAAA;CAAA,OAtBTqC;AAsBS"}
@@ -1 +1 @@
1
- {"version":3,"file":"ResultsDialog.d.ts","sourceRoot":"","sources":["../src/ResultsDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOtD,MAAM,WAAW,kBAAkB;IAC/B,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,+BA2C3E"}
1
+ {"version":3,"file":"ResultsDialog.d.ts","sourceRoot":"","sources":["../src/ResultsDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOtD,MAAM,WAAW,kBAAkB;IAC/B,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,+BAuC3E"}
@@ -1,8 +1,8 @@
1
1
  import ActionRunner_module_default from "./ActionRunner.module.js";
2
2
  import { messages } from "./messages.js";
3
3
  import { describeItemResult, describeResult } from "./describe.js";
4
- import { Badge, Button, Dialog, usePanneauIntl } from "@panneau/ui";
5
4
  import { c } from "react/compiler-runtime";
5
+ import { Badge, Button, Dialog, usePanneauIntl } from "@panneau/ui";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  //#region src/ResultsDialog.tsx
8
8
  /** The items of a result that didn't succeed, with why: failed with a message, or skipped. */
@@ -43,7 +43,6 @@ function ResultsDialog(t0) {
43
43
  let t5;
44
44
  if ($[11] !== onClose || $[12] !== t4) {
45
45
  t5 = /* @__PURE__ */ jsx(Button, {
46
- variant: "secondary",
47
46
  onPress: onClose,
48
47
  children: t4
49
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ResultsDialog.js","names":["onClose","_c","styles"],"sources":["../src/ResultsDialog.tsx"],"sourcesContent":["import type { ActionResult } from '@panneau/protocol';\nimport { Badge, Button, Dialog, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './ActionRunner.module.css';\nimport { describeItemResult, describeResult } from './describe';\nimport { messages } from './messages';\n\nexport interface ResultsDialogProps {\n /** The label of the action. */\n label: string;\n result: ActionResult;\n onClose: () => void;\n}\n\n/** The items of a result that didn't succeed, with why: failed with a message, or skipped. */\nexport function ResultsDialog({ label, result, onClose }: ResultsDialogProps) {\n const intl = usePanneauIntl();\n const summary = describeResult(result, label, intl);\n return (\n <Dialog\n isOpen\n onOpenChange={(open) => {\n if (!open) {\n onClose();\n }\n }}\n title={intl.formatMessage(messages.resultsTitle, { action: label })}\n footer={\n <Button variant=\"secondary\" onPress={onClose}>\n {intl.formatMessage(messages.close)}\n </Button>\n }\n >\n <p className={styles.summary}>\n {summary.title}\n {summary.description !== undefined ? ` ${summary.description}` : null}\n </p>\n <ul className={styles.results}>\n {(result.results ?? []).map((entry) => (\n <li key={entry.id} className={styles.result}>\n <span className={styles.resultItem}>\n {intl.formatMessage(messages.item, { id: entry.id })}\n </span>\n <Badge tone={entry.status === 'failed' ? 'danger' : 'neutral'}>\n {intl.formatMessage(\n entry.status === 'failed'\n ? messages.statusFailed\n : messages.statusSkipped,\n )}\n </Badge>\n <span className={styles.resultReason}>\n {describeItemResult(entry, intl)}\n </span>\n </li>\n ))}\n </ul>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;AAeA,SAAO,cAAA,IAAA;CAAA,MAAA,IAAAC,EAAA,EAAA;CAAuB,MAAA,EAAA,OAAA,QAAA,YAAA;CAC1B,MAAA,OAAa,eAAe;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,QAAA,EAAA,OAAA,SAAA,EAAA,OAAA,QAAA;EACd,KAAA,eAAe,QAAQ,OAAO,IAAI;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAnD,MAAA,UAAgB;CAAoC,IAAA;CAAA,IAAA,EAAA,OAAA,SAAA;EAI9B,MAAA,SAAA;GACV,IAAI,CAAC,MACD,QAAQ;EACX;EACJ,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,QAAA,EAAA,OAAA,OAAA;EACM,KAAA,KAAI,cAAe,SAAQ,cAAe,EAAA,QAAU,MAAM,CAAC;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,MAAA;EAG1D,KAAA,KAAI,cAAe,SAAQ,KAAM;EAAC,EAAA,KAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,WAAA,EAAA,QAAA,IAAA;EADvC,KAAA,oBAAC,QAAD;GAAgB,SAAA;GAAqBD,SAAA;GAChC,UAAA;EADE,CAAA;EAEE,EAAA,MAAA;EAAA,EAAA,MA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AA;EAjBN,MAAA,oBAAA,MAAA;GAAe,WAAAA,4BAAM;GAChB,UAAA;EAiBA,CAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,MAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,OAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,IAAA;EApCT,MAAA,qBAAC,QAAD;GACI,QAAA;GACc,cAAA;GAKP,OAAA;GAEH,QAAA;GATR,UAAA,CAcI,IAIA,GAlBG;;EAqCE,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,MAAA,EAAA;CAAA,OArCT;AAqCS"}
1
+ {"version":3,"file":"ResultsDialog.js","names":["ActionResult","Badge","Button","Dialog","usePanneauIntl","styles","describeItemResult","describeResult","messages","ResultsDialogProps","label","result","onClose","ResultsDialog","t0","$","_c","intl","t1","summary","t2","open","t3","formatMessage","resultsTitle","action","t4","close","t5","t6","description","undefined","t7","title","t8","results","t9","t10","entry","id","resultItem","item","status","statusFailed","statusSkipped","resultReason","map","t11","_c","styles"],"sources":["../src/ResultsDialog.tsx"],"sourcesContent":["import type { ActionResult } from '@panneau/protocol';\nimport { Badge, Button, Dialog, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './ActionRunner.module.css';\nimport { describeItemResult, describeResult } from './describe';\nimport { messages } from './messages';\n\nexport interface ResultsDialogProps {\n /** The label of the action. */\n label: string;\n result: ActionResult;\n onClose: () => void;\n}\n\n/** The items of a result that didn't succeed, with why: failed with a message, or skipped. */\nexport function ResultsDialog({ label, result, onClose }: ResultsDialogProps) {\n const intl = usePanneauIntl();\n const summary = describeResult(result, label, intl);\n return (\n <Dialog\n isOpen\n onOpenChange={(open) => {\n if (!open) {\n onClose();\n }\n }}\n title={intl.formatMessage(messages.resultsTitle, { action: label })}\n footer={<Button onPress={onClose}>{intl.formatMessage(messages.close)}</Button>}\n >\n <p className={styles.summary}>\n {summary.title}\n {summary.description !== undefined ? ` ${summary.description}` : null}\n </p>\n <ul className={styles.results}>\n {(result.results ?? []).map((entry) => (\n <li key={entry.id} className={styles.result}>\n <span className={styles.resultItem}>\n {intl.formatMessage(messages.item, { id: entry.id })}\n </span>\n <Badge tone={entry.status === 'failed' ? 'danger' : 'neutral'}>\n {intl.formatMessage(\n entry.status === 'failed'\n ? messages.statusFailed\n : messages.statusSkipped,\n )}\n </Badge>\n <span className={styles.resultReason}>\n {describeItemResult(entry, intl)}\n </span>\n </li>\n ))}\n </ul>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;AAeA,SAAOa,cAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAuB,MAAA,EAAAN,OAAAC,QAAAC,YAAAE;CAC1B,MAAAG,OAAab,eAAe;CAAE,IAAAc;CAAA,IAAAH,EAAA,OAAAE,QAAAF,EAAA,OAAAL,SAAAK,EAAA,OAAAJ,QAAA;EACdO,KAAAX,eAAeI,QAAQD,OAAOO,IAAI;EAACF,EAAA,KAAAE;EAAAF,EAAA,KAAAL;EAAAK,EAAA,KAAAJ;EAAAI,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAnD,MAAAI,UAAgBD;CAAoC,IAAAE;CAAA,IAAAL,EAAA,OAAAH,SAAA;EAI9BQ,MAAAC,SAAA;GACV,IAAI,CAACA,MACDT,QAAQ;EACX;EACJG,EAAA,KAAAH;EAAAG,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAE,QAAAF,EAAA,OAAAL,OAAA;EACMY,KAAAL,KAAIM,cAAef,SAAQgB,cAAe,EAAAC,QAAUf,MAAM,CAAC;EAACK,EAAA,KAAAE;EAAAF,EAAA,KAAAL;EAAAK,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,IAAAW;C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,MAAKI,WAAY,WAAjB,WAAA;MACRzB,UAAAA,KAAIM,cACDe,MAAKI,WAAY,WACXlC,SAAQmC,eACRnC,SAAQoC,aAClB;KALE,CAAA;KAON,oBAAA,QAAA;MAAiB,WAAAvC,4BAAMwC;MAClBvC,UAAAA,mBAAmBgC,OAAOrB,IAAI;KAC5B,CAAA;IACN;GAdIqB,GAAAA,MAAKC,EAcT;GACRxB,EAAA,MAAAE;GAAAF,EAAA,MAAAsB;EAAA,OAAAA,MAAAtB,EAAA;EAhBAqB,KAACF,GAAoBY,IAAMT,GAgB3B;EAACtB,EAAA,MAAAE;EAAAF,EAAA,MAAAmB;EAAAnB,EAAA,MAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,IAAAsB;CAAA,IAAAtB,EAAA,QAAAqB,IAAA;EAjBNC,MAAA,oBAAA,MAAA;GAAe,WAAAhC,4BAAM8B;GAChBC,UAAAA;EAiBA,CAAA;EAAArB,EAAA,MAAAqB;EAAArB,EAAA,MAAAsB;CAAA,OAAAA,MAAAtB,EAAA;CAAA,IAAAgC;CAAA,IAAAhC,EAAA,QAAAsB,OAAAtB,EAAA,QAAAK,MAAAL,EAAA,QAAAO,MAAAP,EAAA,QAAAa,MAAAb,EAAA,QAAAiB,IAAA;EAhCTe,MAAA,qBAAC,QAAD;GACI,QAAA;GACc,cAAA3B;GAKP,OAAAE;GACC,QAAAM;GARZ,UAAA,CAUII,IAIAK,GAdG;;EAiCEtB,EAAA,MAAAsB;EAAAtB,EAAA,MAAAK;EAAAL,EAAA,MAAAO;EAAAP,EAAA,MAAAa;EAAAb,EAAA,MAAAiB;EAAAjB,EAAA,MAAAgC;CAAA,OAAAA,MAAAhC,EAAA;CAAA,OAjCTgC;AAiCS"}
package/dist/context.d.ts CHANGED
@@ -1,10 +1,15 @@
1
- import type { ActionAdapter, ActionOutcome, ActionTarget, FollowedRun } from './types';
1
+ import type { ActionAdapter, ActionOutcome, ActionTarget, FollowedRun } from './types.js';
2
2
  export interface ActionRunnerContextValue {
3
3
  adapter: ActionAdapter;
4
4
  run: (resource: string, target: ActionTarget) => Promise<ActionOutcome | false>;
5
5
  runs: readonly FollowedRun[];
6
6
  cancelRun: (id: string) => Promise<void>;
7
7
  dismissRun: (id: string) => void;
8
+ /**
9
+ * Says that a list of the runs is on screen, until the function it returns is called: a run
10
+ * that ends there needs no toast.
11
+ */
12
+ watchRuns: () => () => void;
8
13
  }
9
14
  export declare const ActionRunnerContext: import("react").Context<ActionRunnerContextValue | null>;
10
15
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvF,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;IAChF,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IAC7B,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,mBAAmB,0DAAuD,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvF,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;IAChF,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IAC7B,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC;;;OAGG;IACH,SAAS,EAAE,MAAM,MAAM,IAAI,CAAC;CAC/B;AAED,eAAO,MAAM,mBAAmB,0DAAuD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport type { ActionAdapter, ActionOutcome, ActionTarget, FollowedRun } from './types';\n\nexport interface ActionRunnerContextValue {\n adapter: ActionAdapter;\n run: (resource: string, target: ActionTarget) => Promise<ActionOutcome | false>;\n runs: readonly FollowedRun[];\n cancelRun: (id: string) => Promise<void>;\n dismissRun: (id: string) => void;\n}\n\nexport const ActionRunnerContext = createContext<ActionRunnerContextValue | null>(null);\n"],"mappings":";;AAYA,IAAa,sBAAsB,cAA+C,IAAI"}
1
+ {"version":3,"file":"context.js","names":["createContext","ActionAdapter","ActionOutcome","ActionTarget","FollowedRun","ActionRunnerContextValue","adapter","run","resource","target","Promise","runs","cancelRun","id","dismissRun","watchRuns","ActionRunnerContext"],"sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport type { ActionAdapter, ActionOutcome, ActionTarget, FollowedRun } from './types';\n\nexport interface ActionRunnerContextValue {\n adapter: ActionAdapter;\n run: (resource: string, target: ActionTarget) => Promise<ActionOutcome | false>;\n runs: readonly FollowedRun[];\n cancelRun: (id: string) => Promise<void>;\n dismissRun: (id: string) => void;\n /**\n * Says that a list of the runs is on screen, until the function it returns is called: a run\n * that ends there needs no toast.\n */\n watchRuns: () => () => void;\n}\n\nexport const ActionRunnerContext = createContext<ActionRunnerContextValue | null>(null);\n"],"mappings":";;AAiBA,IAAagB,sBAAsBhB,cAA+C,IAAI"}
@@ -1,8 +1,39 @@
1
1
  import type { IntlShape } from 'react-intl';
2
- import type { ActionItemResult, ActionResult } from '@panneau/protocol';
2
+ import type { ActionItemResult, ActionResult, Item, Resource } from '@panneau/protocol';
3
3
  import type { ToastContent } from '@panneau/ui';
4
- /** The toast of a result: its message, or "done", the counts, and a tone that says how it went. */
5
- export declare function describeResult(result: ActionResult, actionLabel: string, intl: IntlShape): Omit<ToastContent, 'action'>;
6
- /** Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`). */
4
+ import type { ActionTarget } from './types.js';
5
+ /**
6
+ * The title of an item: the value of the resource's `itemTitle` field, in the locale when it is
7
+ * localized. `null` without one.
8
+ */
9
+ export declare function getItemTitle(item: Partial<Item> | undefined, itemTitle: string | undefined, locale: string): string | null;
10
+ /**
11
+ * What an action applied to, for its toast: the item by its title ("“Spring contest”"), or the
12
+ * count of items with the resource's labels ("3 entries"). `null` when there is nothing to name:
13
+ * an item without a title, a selection without a count, or a resource the definition doesn't
14
+ * have.
15
+ */
16
+ export declare function describeSubject(target: ActionTarget, resource: Pick<Resource, 'label' | 'itemTitle'> | undefined, intl: IntlShape, count?: number | null): string | null;
17
+ /** Whether an item of a result was skipped because something else uses it (`in_use`). */
18
+ export declare function isInUse(entry: ActionItemResult): boolean;
19
+ /**
20
+ * The toast of a result: its message, or "done" with what it was done to (`subject`), the counts,
21
+ * and a tone that says how it went. Items skipped as `in_use` are explained, by the title of the
22
+ * item (`itemTitle`) when it is the only one: when every item is, that is the title of the toast.
23
+ */
24
+ export declare function describeResult(result: ActionResult, actionLabel: string, intl: IntlShape, subject?: string | null, itemTitle?: string | null): Omit<ToastContent, 'action'>;
25
+ /**
26
+ * Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`,
27
+ * `in_use`).
28
+ */
7
29
  export declare function describeItemResult(entry: ActionItemResult, intl: IntlShape): string;
30
+ /**
31
+ * The items a run changed, for "Show" in its toast (decision 0069): those of a selection by ids,
32
+ * without those its `results` list (they failed or were skipped), or the `items` of its `undo`.
33
+ * `null` for an item action, whose toast names the item, for a `delete`, whose items are gone, for
34
+ * a query selection without `undo`,
35
+ * whose items the client doesn't know, and when the run changed none or more than
36
+ * `IDS_FILTER_LIMIT`.
37
+ */
38
+ export declare function getChangedItems(target: ActionTarget, result: ActionResult): string[] | null;
8
39
  //# sourceMappingURL=describe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,mGAAmG;AACnG,wBAAgB,cAAc,CAC1B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,SAAS,GAChB,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAmB9B;AAED,sGAAsG;AACtG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAgBnF"}
1
+ {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAExF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,CAWf;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,WAAW,CAAC,GAAG,SAAS,EAC3D,IAAI,EAAE,SAAS,EACf,KAAK,GAAE,MAAM,GAAG,IAAW,GAC5B,MAAM,GAAG,IAAI,CAoBf;AAED,yFAAyF;AACzF,wBAAgB,OAAO,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAExD;AAeD;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,SAAS,EACf,OAAO,GAAE,MAAM,GAAG,IAAW,EAC7B,SAAS,GAAE,MAAM,GAAG,IAAW,GAChC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAiC9B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAkBnF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,EAAE,GAAG,IAAI,CAc3F"}
package/dist/describe.js CHANGED
@@ -1,32 +1,114 @@
1
1
  import { messages } from "./messages.js";
2
2
  import { getResultCounts } from "./request.js";
3
+ import { IDS_FILTER_LIMIT } from "@panneau/protocol/runtime";
3
4
  //#region src/describe.ts
4
- /** The toast of a result: its message, or "done", the counts, and a tone that says how it went. */
5
- function describeResult(result, actionLabel, intl) {
5
+ /**
6
+ * The title of an item: the value of the resource's `itemTitle` field, in the locale when it is
7
+ * localized. `null` without one.
8
+ */
9
+ function getItemTitle(item, itemTitle, locale) {
10
+ const value = itemTitle !== void 0 ? item?.[itemTitle] : void 0;
11
+ if (typeof value === "string") return value;
12
+ if (value !== null && typeof value === "object") {
13
+ const first = value[locale] ?? Object.values(value)[0];
14
+ return typeof first === "string" ? first : null;
15
+ }
16
+ return null;
17
+ }
18
+ /**
19
+ * What an action applied to, for its toast: the item by its title ("“Spring contest”"), or the
20
+ * count of items with the resource's labels ("3 entries"). `null` when there is nothing to name:
21
+ * an item without a title, a selection without a count, or a resource the definition doesn't
22
+ * have.
23
+ */
24
+ function describeSubject(target, resource, intl, count = null) {
25
+ if (target.scope === "item" || target.item !== void 0) {
26
+ const title = getItemTitle(target.item, resource?.itemTitle, intl.locale);
27
+ return title !== null && title !== "" ? intl.formatMessage(messages.subjectItem, { title }) : null;
28
+ }
29
+ const total = count ?? target.count ?? null;
30
+ if (resource === void 0 || total === null) return null;
31
+ return intl.formatMessage(messages.subjectCount, {
32
+ count: total,
33
+ singular: resource.label.singular,
34
+ plural: resource.label.plural
35
+ });
36
+ }
37
+ /** Whether an item of a result was skipped because something else uses it (`in_use`). */
38
+ function isInUse(entry) {
39
+ return entry.status === "skipped" && entry.reason === "in_use";
40
+ }
41
+ /**
42
+ * What the toast says of the items skipped as `in_use`: the item by its title when it is the only
43
+ * one and `itemTitle` is known, or their count. `null` when there are none.
44
+ */
45
+ function describeInUse(count, intl, itemTitle) {
46
+ if (count === 0) return null;
47
+ return count === 1 && itemTitle !== null && itemTitle !== "" ? intl.formatMessage(messages.inUseItem, { title: itemTitle }) : intl.formatMessage(messages.inUseCount, { count });
48
+ }
49
+ /**
50
+ * The toast of a result: its message, or "done" with what it was done to (`subject`), the counts,
51
+ * and a tone that says how it went. Items skipped as `in_use` are explained, by the title of the
52
+ * item (`itemTitle`) when it is the only one: when every item is, that is the title of the toast.
53
+ */
54
+ function describeResult(result, actionLabel, intl, subject = null, itemTitle = null) {
6
55
  const { succeeded, failed, skipped } = getResultCounts(result);
56
+ const inUse = Math.min(skipped, (result.results ?? []).filter(isInUse).length);
57
+ const inUseText = describeInUse(inUse, intl, itemTitle);
58
+ if (inUseText !== null && (succeeded ?? 0) === 0 && failed === 0 && skipped === inUse) return {
59
+ title: inUseText,
60
+ tone: "warning"
61
+ };
7
62
  const parts = [
8
63
  ...succeeded !== null && (failed > 0 || skipped > 0) ? [intl.formatMessage(messages.succeededCount, { count: succeeded })] : [],
9
64
  ...failed > 0 ? [intl.formatMessage(messages.failedCount, { count: failed })] : [],
10
- ...skipped > 0 ? [intl.formatMessage(messages.skippedCount, { count: skipped })] : []
65
+ ...skipped > inUse ? [intl.formatMessage(messages.skippedCount, { count: skipped - inUse })] : []
11
66
  ];
67
+ const description = [...parts.length > 0 ? [intl.formatList(parts, { type: "unit" })] : [], ...inUseText !== null ? [inUseText] : []].join(". ");
12
68
  const tone = failed > 0 ? succeeded === 0 ? "danger" : "warning" : skipped > 0 ? "warning" : "success";
13
69
  return {
14
- title: result.message !== void 0 && result.message !== "" ? result.message : intl.formatMessage(messages.done, { action: actionLabel }),
15
- ...parts.length > 0 ? { description: intl.formatList(parts, { type: "unit" }) } : {},
70
+ title: result.message !== void 0 && result.message !== "" ? result.message : subject !== null ? intl.formatMessage(messages.doneFor, {
71
+ action: actionLabel,
72
+ subject
73
+ }) : intl.formatMessage(messages.done, { action: actionLabel }),
74
+ ...description !== "" ? { description } : {},
16
75
  tone
17
76
  };
18
77
  }
19
- /** Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`). */
78
+ /**
79
+ * Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`,
80
+ * `in_use`).
81
+ */
20
82
  function describeItemResult(entry, intl) {
21
83
  if (entry.message !== void 0 && entry.message !== "") return entry.message;
22
84
  switch (entry.reason) {
23
85
  case "forbidden": return intl.formatMessage(messages.reasonForbidden);
24
86
  case "not_found": return intl.formatMessage(messages.reasonNotFound);
25
87
  case "unchanged": return intl.formatMessage(messages.reasonUnchanged);
88
+ case "in_use": return intl.formatMessage(messages.reasonInUse);
26
89
  default: return intl.formatMessage(entry.status === "failed" ? messages.statusFailed : messages.statusSkipped);
27
90
  }
28
91
  }
92
+ /**
93
+ * The items a run changed, for "Show" in its toast (decision 0069): those of a selection by ids,
94
+ * without those its `results` list (they failed or were skipped), or the `items` of its `undo`.
95
+ * `null` for an item action, whose toast names the item, for a `delete`, whose items are gone, for
96
+ * a query selection without `undo`,
97
+ * whose items the client doesn't know, and when the run changed none or more than
98
+ * `IDS_FILTER_LIMIT`.
99
+ */
100
+ function getChangedItems(target, result) {
101
+ if (target.scope === "item" || target.action.id === "delete") return null;
102
+ const selection = target.selection;
103
+ let ids = null;
104
+ if (result.undo !== void 0) ids = [...result.undo.items];
105
+ else if (selection !== void 0 && "ids" in selection) {
106
+ const left = new Set((result.results ?? []).map((entry) => entry.id));
107
+ ids = selection.ids.filter((id) => !left.has(id));
108
+ }
109
+ return ids !== null && ids.length > 0 && ids.length <= IDS_FILTER_LIMIT ? ids : null;
110
+ }
29
111
  //#endregion
30
- export { describeItemResult, describeResult };
112
+ export { describeItemResult, describeResult, describeSubject, getChangedItems, getItemTitle, isInUse };
31
113
 
32
114
  //# sourceMappingURL=describe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"describe.js","names":[],"sources":["../src/describe.ts"],"sourcesContent":["import type { IntlShape } from 'react-intl';\n\nimport type { ActionItemResult, ActionResult } from '@panneau/protocol';\nimport type { ToastContent } from '@panneau/ui';\n\nimport { messages } from './messages';\nimport { getResultCounts } from './request';\n\n/** The toast of a result: its message, or \"done\", the counts, and a tone that says how it went. */\nexport function describeResult(\n result: ActionResult,\n actionLabel: string,\n intl: IntlShape,\n): Omit<ToastContent, 'action'> {\n const { succeeded, failed, skipped } = getResultCounts(result);\n const parts = [\n ...(succeeded !== null && (failed > 0 || skipped > 0)\n ? [intl.formatMessage(messages.succeededCount, { count: succeeded })]\n : []),\n ...(failed > 0 ? [intl.formatMessage(messages.failedCount, { count: failed })] : []),\n ...(skipped > 0 ? [intl.formatMessage(messages.skippedCount, { count: skipped })] : []),\n ];\n const tone: ToastContent['tone'] =\n failed > 0 ? (succeeded === 0 ? 'danger' : 'warning') : skipped > 0 ? 'warning' : 'success';\n return {\n title:\n result.message !== undefined && result.message !== ''\n ? result.message\n : intl.formatMessage(messages.done, { action: actionLabel }),\n ...(parts.length > 0 ? { description: intl.formatList(parts, { type: 'unit' }) } : {}),\n tone,\n };\n}\n\n/** Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`). */\nexport function describeItemResult(entry: ActionItemResult, intl: IntlShape): string {\n if (entry.message !== undefined && entry.message !== '') {\n return entry.message;\n }\n switch (entry.reason) {\n case 'forbidden':\n return intl.formatMessage(messages.reasonForbidden);\n case 'not_found':\n return intl.formatMessage(messages.reasonNotFound);\n case 'unchanged':\n return intl.formatMessage(messages.reasonUnchanged);\n default:\n return intl.formatMessage(\n entry.status === 'failed' ? messages.statusFailed : messages.statusSkipped,\n );\n }\n}\n"],"mappings":";;;;AASA,SAAgB,eACZ,QACA,aACA,MAC4B;CAC5B,MAAM,EAAE,WAAW,QAAQ,YAAY,gBAAgB,MAAM;CAC7D,MAAM,QAAQ;EACV,GAAI,cAAc,SAAS,SAAS,KAAK,UAAU,KAC7C,CAAC,KAAK,cAAc,SAAS,gBAAgB,EAAE,OAAO,UAAU,CAAC,CAAC,IAClE,CAAA;EACN,GAAI,SAAS,IAAI,CAAC,KAAK,cAAc,SAAS,aAAa,EAAE,OAAO,OAAO,CAAC,CAAC,IAAI,CAAA;EACjF,GAAI,UAAU,IAAI,CAAC,KAAK,cAAc,SAAS,cAAc,EAAE,OAAO,QAAQ,CAAC,CAAC,IAAI,CAAA;CAAG;CAE3F,MAAM,OACF,SAAS,IAAK,cAAc,IAAI,WAAW,YAAa,UAAU,IAAI,YAAY;CACtF,OAAO;EACH,OACI,OAAO,YAAY,KAAA,KAAa,OAAO,YAAY,KAC7C,OAAO,UACP,KAAK,cAAc,SAAS,MAAM,EAAE,QAAQ,YAAY,CAAC;EACnE,GAAI,MAAM,SAAS,IAAI,EAAE,aAAa,KAAK,WAAW,OAAO,EAAE,MAAM,OAAO,CAAC,EAAE,IAAI,CAAC;EACpF;CACJ;AACJ;;AAGA,SAAgB,mBAAmB,OAAyB,MAAyB;CACjF,IAAI,MAAM,YAAY,KAAA,KAAa,MAAM,YAAY,IACjD,OAAO,MAAM;CAEjB,QAAQ,MAAM,QAAd;EACI,KAAK,aACD,OAAO,KAAK,cAAc,SAAS,eAAe;EACtD,KAAK,aACD,OAAO,KAAK,cAAc,SAAS,cAAc;EACrD,KAAK,aACD,OAAO,KAAK,cAAc,SAAS,eAAe;EACtD,SACI,OAAO,KAAK,cACR,MAAM,WAAW,WAAW,SAAS,eAAe,SAAS,aACjE;CACR;AACJ"}
1
+ {"version":3,"file":"describe.js","names":["IntlShape","ActionItemResult","ActionResult","Item","Resource","IDS_FILTER_LIMIT","ToastContent","messages","getResultCounts","ActionTarget","getItemTitle","item","Partial","itemTitle","locale","value","undefined","localized","Record","first","Object","values","describeSubject","target","resource","Pick","intl","count","scope","title","formatMessage","subjectItem","total","subjectCount","singular","label","plural","isInUse","entry","status","reason","describeInUse","inUseItem","inUseCount","describeResult","result","actionLabel","subject","Omit","succeeded","failed","skipped","inUse","Math","min","results","filter","length","inUseText","tone","parts","succeededCount","failedCount","skippedCount","description","formatList","type","join","message","doneFor","action","done","describeItemResult","reasonForbidden","reasonNotFound","reasonUnchanged","reasonInUse","statusFailed","statusSkipped","getChangedItems","id","selection","ids","undo","items","left","Set","map","has"],"sources":["../src/describe.ts"],"sourcesContent":["import type { IntlShape } from 'react-intl';\n\nimport type { ActionItemResult, ActionResult, Item, Resource } from '@panneau/protocol';\nimport { IDS_FILTER_LIMIT } from '@panneau/protocol/runtime';\nimport type { ToastContent } from '@panneau/ui';\n\nimport { messages } from './messages';\nimport { getResultCounts } from './request';\nimport type { ActionTarget } from './types';\n\n/**\n * The title of an item: the value of the resource's `itemTitle` field, in the locale when it is\n * localized. `null` without one.\n */\nexport function getItemTitle(\n item: Partial<Item> | undefined,\n itemTitle: string | undefined,\n locale: string,\n): string | null {\n const value = itemTitle !== undefined ? item?.[itemTitle] : undefined;\n if (typeof value === 'string') {\n return value;\n }\n if (value !== null && typeof value === 'object') {\n const localized = (value as Record<string, unknown>)[locale];\n const first = localized ?? Object.values(value)[0];\n return typeof first === 'string' ? first : null;\n }\n return null;\n}\n\n/**\n * What an action applied to, for its toast: the item by its title (\"“Spring contest”\"), or the\n * count of items with the resource's labels (\"3 entries\"). `null` when there is nothing to name:\n * an item without a title, a selection without a count, or a resource the definition doesn't\n * have.\n */\nexport function describeSubject(\n target: ActionTarget,\n resource: Pick<Resource, 'label' | 'itemTitle'> | undefined,\n intl: IntlShape,\n count: number | null = null,\n): string | null {\n if (target.scope === 'item' || target.item !== undefined) {\n const title = getItemTitle(\n target.item as Partial<Item> | undefined,\n resource?.itemTitle,\n intl.locale,\n );\n return title !== null && title !== ''\n ? intl.formatMessage(messages.subjectItem, { title })\n : null;\n }\n const total = count ?? target.count ?? null;\n if (resource === undefined || total === null) {\n return null;\n }\n return intl.formatMessage(messages.subjectCount, {\n count: total,\n singular: resource.label.singular,\n plural: resource.label.plural,\n });\n}\n\n/** Whether an item of a result was skipped because something else uses it (`in_use`). */\nexport function isInUse(entry: ActionItemResult): boolean {\n return entry.status === 'skipped' && entry.reason === 'in_use';\n}\n\n/**\n * What the toast says of the items skipped as `in_use`: the item by its title when it is the only\n * one and `itemTitle` is known, or their count. `null` when there are none.\n */\nfunction describeInUse(count: number, intl: IntlShape, itemTitle: string | null): string | null {\n if (count === 0) {\n return null;\n }\n return count === 1 && itemTitle !== null && itemTitle !== ''\n ? intl.formatMessage(messages.inUseItem, { title: itemTitle })\n : intl.formatMessage(messages.inUseCount, { count });\n}\n\n/**\n * The toast of a result: its message, or \"done\" with what it was done to (`subject`), the counts,\n * and a tone that says how it went. Items skipped as `in_use` are explained, by the title of the\n * item (`itemTitle`) when it is the only one: when every item is, that is the title of the toast.\n */\nexport function describeResult(\n result: ActionResult,\n actionLabel: string,\n intl: IntlShape,\n subject: string | null = null,\n itemTitle: string | null = null,\n): Omit<ToastContent, 'action'> {\n const { succeeded, failed, skipped } = getResultCounts(result);\n const inUse = Math.min(skipped, (result.results ?? []).filter(isInUse).length);\n const inUseText = describeInUse(inUse, intl, itemTitle);\n if (inUseText !== null && (succeeded ?? 0) === 0 && failed === 0 && skipped === inUse) {\n // Nothing was done: the toast says why.\n return { title: inUseText, tone: 'warning' };\n }\n const parts = [\n ...(succeeded !== null && (failed > 0 || skipped > 0)\n ? [intl.formatMessage(messages.succeededCount, { count: succeeded })]\n : []),\n ...(failed > 0 ? [intl.formatMessage(messages.failedCount, { count: failed })] : []),\n ...(skipped > inUse\n ? [intl.formatMessage(messages.skippedCount, { count: skipped - inUse })]\n : []),\n ];\n const description = [\n ...(parts.length > 0 ? [intl.formatList(parts, { type: 'unit' })] : []),\n ...(inUseText !== null ? [inUseText] : []),\n ].join('. ');\n const tone: ToastContent['tone'] =\n failed > 0 ? (succeeded === 0 ? 'danger' : 'warning') : skipped > 0 ? 'warning' : 'success';\n return {\n title:\n result.message !== undefined && result.message !== ''\n ? result.message\n : subject !== null\n ? intl.formatMessage(messages.doneFor, { action: actionLabel, subject })\n : intl.formatMessage(messages.done, { action: actionLabel }),\n ...(description !== '' ? { description } : {}),\n tone,\n };\n}\n\n/**\n * Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`,\n * `in_use`).\n */\nexport function describeItemResult(entry: ActionItemResult, intl: IntlShape): string {\n if (entry.message !== undefined && entry.message !== '') {\n return entry.message;\n }\n switch (entry.reason) {\n case 'forbidden':\n return intl.formatMessage(messages.reasonForbidden);\n case 'not_found':\n return intl.formatMessage(messages.reasonNotFound);\n case 'unchanged':\n return intl.formatMessage(messages.reasonUnchanged);\n case 'in_use':\n return intl.formatMessage(messages.reasonInUse);\n default:\n return intl.formatMessage(\n entry.status === 'failed' ? messages.statusFailed : messages.statusSkipped,\n );\n }\n}\n\n/**\n * The items a run changed, for \"Show\" in its toast (decision 0069): those of a selection by ids,\n * without those its `results` list (they failed or were skipped), or the `items` of its `undo`.\n * `null` for an item action, whose toast names the item, for a `delete`, whose items are gone, for\n * a query selection without `undo`,\n * whose items the client doesn't know, and when the run changed none or more than\n * `IDS_FILTER_LIMIT`.\n */\nexport function getChangedItems(target: ActionTarget, result: ActionResult): string[] | null {\n // A deleted item isn't in its list any more: its \"Undo\" brings it back, when there is one.\n if (target.scope === 'item' || target.action.id === 'delete') {\n return null;\n }\n const selection = target.selection;\n let ids: string[] | null = null;\n if (result.undo !== undefined) {\n ids = [...result.undo.items];\n } else if (selection !== undefined && 'ids' in selection) {\n const left = new Set((result.results ?? []).map((entry) => entry.id));\n ids = (selection.ids as string[]).filter((id) => !left.has(id));\n }\n return ids !== null && ids.length > 0 && ids.length <= IDS_FILTER_LIMIT ? ids : null;\n}\n"],"mappings":";;;;;;;;AAcA,SAAgBU,aACZC,MACAE,WACAC,QACa;CACb,MAAMC,QAAQF,cAAcG,KAAAA,IAAYL,OAAOE,aAAaG,KAAAA;CAC5D,IAAI,OAAOD,UAAU,UACjB,OAAOA;CAEX,IAAIA,UAAU,QAAQ,OAAOA,UAAU,UAAU;EAE7C,MAAMI,QADaJ,MAAkCD,WAC1BM,OAAOC,OAAON,KAAK,CAAC,CAAC;EAChD,OAAO,OAAOI,UAAU,WAAWA,QAAQ;CAC/C;CACA,OAAO;AACX;;;;;;;AAQA,SAAgBG,gBACZC,QACAC,UACAE,MACAC,QAAuB,MACV;CACb,IAAIJ,OAAOK,UAAU,UAAUL,OAAOZ,SAASK,KAAAA,GAAW;EACtD,MAAMa,QAAQnB,aACVa,OAAOZ,MACPa,UAAUX,WACVa,KAAKZ,MACT;EACA,OAAOe,UAAU,QAAQA,UAAU,KAC7BH,KAAKI,cAAcvB,SAASwB,aAAa,EAAEF,MAAM,CAAC,IAClD;CACV;CACA,MAAMG,QAAQL,SAASJ,OAAOI,SAAS;CACvC,IAAIH,aAAaR,KAAAA,KAAagB,UAAU,MACpC,OAAO;CAEX,OAAON,KAAKI,cAAcvB,SAAS0B,cAAc;EAC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IrC,OAAOsC,SAASnE,KAAAA,GAChBkE,MAAM,CAAC,GAAGrC,OAAOsC,KAAKC,KAAK;MACxB,IAAIH,cAAcjE,KAAAA,KAAa,SAASiE,WAAW;EACtD,MAAMI,OAAO,IAAIC,KAAKzC,OAAOU,WAAW,CAAA,EAAA,CAAIgC,KAAKjD,UAAUA,MAAM0C,EAAE,CAAC;EACpEE,MAAOD,UAAUC,IAAiB1B,QAAQwB,OAAO,CAACK,KAAKG,IAAIR,EAAE,CAAC;CAClE;CACA,OAAOE,QAAQ,QAAQA,IAAIzB,SAAS,KAAKyB,IAAIzB,UAAUpD,mBAAmB6E,MAAM;AACpF"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { ActionRunnerProvider, type ActionRunnerProviderProps } from './ActionRunnerProvider';
2
- export { ActionRuns, type ActionRunsProps } from './ActionRuns';
3
- export { ParametersDialog, type ParametersDialogProps } from './ParametersDialog';
4
- export { ResultsDialog, type ResultsDialogProps } from './ResultsDialog';
5
- export { describeItemResult, describeResult } from './describe';
6
- export { type ActionPreview, canPreviewAction, previewAction } from './preview';
7
- export { buildActionRequest, getLinkTarget, getResultCounts } from './request';
8
- export type { ActionAdapter, ActionDownload, ActionOutcome, ActionResultContext, ActionTarget, ClientActionHandler, ClientActionProps, FollowedRun, } from './types';
9
- export { useActionPreview, useActionRunner, useActionRuns } from './useActionRunner';
1
+ export { ActionRunnerProvider, type ActionRunnerProviderProps } from './ActionRunnerProvider.js';
2
+ export { ActionRuns, type ActionRunsProps } from './ActionRuns.js';
3
+ export { ParametersDialog, type ParametersDialogProps } from './ParametersDialog.js';
4
+ export { ResultsDialog, type ResultsDialogProps } from './ResultsDialog.js';
5
+ export { describeItemResult, describeResult } from './describe.js';
6
+ export { type ActionPreview, canPreviewAction, previewAction } from './preview.js';
7
+ export { buildActionRequest, getLinkTarget, getResultCounts } from './request.js';
8
+ export type { ActionAdapter, ActionDownload, ActionOutcome, ActionResultContext, ActionTarget, ClientActionHandler, ClientActionProps, FollowedRun, } from './types.js';
9
+ export { useActionPreview, useActionRunner, useActionRuns } from './useActionRunner.js';
10
10
  //# sourceMappingURL=index.d.ts.map
package/dist/preview.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ActionAdapter, ActionTarget } from './types';
1
+ import type { ActionAdapter, ActionTarget } from './types.js';
2
2
  /** What a dry run of an action told: how many items it would apply to, and skip. */
3
3
  export interface ActionPreview {
4
4
  succeeded: number;
@@ -1 +1 @@
1
- {"version":3,"file":"preview.js","names":[],"sources":["../src/preview.ts"],"sourcesContent":["import type { ActionAdapter, ActionTarget } from './types';\n\n/** What a dry run of an action told: how many items it would apply to, and skip. */\nexport interface ActionPreview {\n succeeded: number;\n skipped: number;\n}\n\n/**\n * Whether the backend can say what an action would do before it runs: a `server` action with\n * `dryRun`, on every item matching a query. Selected ids need no dry run, since the list knows\n * their abilities.\n */\nexport function canPreviewAction(target: ActionTarget): boolean {\n const { action, selection } = target;\n return (\n action.dryRun === true &&\n action.kind === 'server' &&\n selection !== undefined &&\n 'query' in selection\n );\n}\n\n/**\n * Asks the backend what an action would do on a query selection, without running it (a dry run,\n * `\"dryRun\": true` in the request), and resolves with the counts of its summary, or with `null`\n * for an action that can't be previewed (`canPreviewAction()`).\n */\nexport async function previewAction(\n adapter: Pick<ActionAdapter, 'runAction'>,\n resource: string,\n target: ActionTarget,\n options: { signal?: AbortSignal } = {},\n): Promise<ActionPreview | null> {\n if (!canPreviewAction(target)) {\n return null;\n }\n const response = await adapter.runAction(\n resource,\n target.action.id,\n { selection: target.selection, dryRun: true },\n options,\n );\n const summary = response.result?.summary;\n return summary !== undefined\n ? { succeeded: summary.succeeded, skipped: summary.skipped }\n : null;\n}\n"],"mappings":";;;;;;AAaA,SAAgB,iBAAiB,QAA+B;CAC5D,MAAM,EAAE,QAAQ,cAAc;CAC9B,OACI,OAAO,WAAW,QAClB,OAAO,SAAS,YAChB,cAAc,KAAA,KACd,WAAW;AAEnB;;;;;;AAOA,eAAsB,cAClB,SACA,UACA,QACA,UAAoC,CAAC,GACR;CAC7B,IAAI,CAAC,iBAAiB,MAAM,GACxB,OAAO;CAQX,MAAM,WAAU,MANO,QAAQ,UAC3B,UACA,OAAO,OAAO,IACd;EAAE,WAAW,OAAO;EAAW,QAAQ;CAAK,GAC5C,OACJ,EAAA,CACyB,QAAQ;CACjC,OAAO,YAAY,KAAA,IACb;EAAE,WAAW,QAAQ;EAAW,SAAS,QAAQ;CAAQ,IACzD;AACV"}
1
+ {"version":3,"file":"preview.js","names":["ActionAdapter","ActionTarget","ActionPreview","succeeded","skipped","canPreviewAction","target","action","selection","dryRun","kind","undefined","previewAction","adapter","Pick","resource","options","signal","AbortSignal","Promise","response","runAction","id","summary","result"],"sources":["../src/preview.ts"],"sourcesContent":["import type { ActionAdapter, ActionTarget } from './types';\n\n/** What a dry run of an action told: how many items it would apply to, and skip. */\nexport interface ActionPreview {\n succeeded: number;\n skipped: number;\n}\n\n/**\n * Whether the backend can say what an action would do before it runs: a `server` action with\n * `dryRun`, on every item matching a query. Selected ids need no dry run, since the list knows\n * their abilities.\n */\nexport function canPreviewAction(target: ActionTarget): boolean {\n const { action, selection } = target;\n return (\n action.dryRun === true &&\n action.kind === 'server' &&\n selection !== undefined &&\n 'query' in selection\n );\n}\n\n/**\n * Asks the backend what an action would do on a query selection, without running it (a dry run,\n * `\"dryRun\": true` in the request), and resolves with the counts of its summary, or with `null`\n * for an action that can't be previewed (`canPreviewAction()`).\n */\nexport async function previewAction(\n adapter: Pick<ActionAdapter, 'runAction'>,\n resource: string,\n target: ActionTarget,\n options: { signal?: AbortSignal } = {},\n): Promise<ActionPreview | null> {\n if (!canPreviewAction(target)) {\n return null;\n }\n const response = await adapter.runAction(\n resource,\n target.action.id,\n { selection: target.selection, dryRun: true },\n options,\n );\n const summary = response.result?.summary;\n return summary !== undefined\n ? { succeeded: summary.succeeded, skipped: summary.skipped }\n : null;\n}\n"],"mappings":";;;;;;AAaA,SAAgBK,iBAAiBC,QAA+B;CAC5D,MAAM,EAAEC,QAAQC,cAAcF;CAC9B,OACIC,OAAOE,WAAW,QAClBF,OAAOG,SAAS,YAChBF,cAAcG,KAAAA,KACd,WAAWH;AAEnB;;;;;;AAOA,eAAsBI,cAClBC,SACAE,UACAT,QACAU,UAAoC,CAAC,GACR;CAC7B,IAAI,CAACX,iBAAiBC,MAAM,GACxB,OAAO;CAQX,MAAMiB,WAAUH,MANOP,QAAQQ,UAC3BN,UACAT,OAAOC,OAAOe,IACd;EAAEd,WAAWF,OAAOE;EAAWC,QAAQ;CAAK,GAC5CO,OACJ,EAAA,CACyBQ,QAAQD;CACjC,OAAOA,YAAYZ,KAAAA,IACb;EAAER,WAAWoB,QAAQpB;EAAWC,SAASmB,QAAQnB;CAAQ,IACzD;AACV"}
package/dist/request.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ActionRequest, ActionResult, RouteReference } from '@panneau/protocol';
2
- import type { ActionTarget } from './types';
2
+ import type { ActionTarget } from './types.js';
3
3
  /** The request of an action: its selection (none for the resource), and its parameter values. */
4
4
  export declare function buildActionRequest(target: ActionTarget, values?: Record<string, unknown>): ActionRequest;
5
5
  /** Where a `link` action goes: its `url` with `{id}` replaced, or its `route` with the item's id. */
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","names":[],"sources":["../src/request.ts"],"sourcesContent":["import type { ActionRequest, ActionResult, RouteReference } from '@panneau/protocol';\n\nimport type { ActionTarget } from './types';\n\n/** The request of an action: its selection (none for the resource), and its parameter values. */\nexport function buildActionRequest(\n target: ActionTarget,\n values: Record<string, unknown> = {},\n): ActionRequest {\n if (target.scope === 'item' && target.item !== undefined) {\n return { selection: { ids: [target.item.id] }, values };\n }\n if (target.scope === 'selection' && target.selection !== undefined) {\n return { selection: target.selection, values };\n }\n return { values };\n}\n\n/** Where a `link` action goes: its `url` with `{id}` replaced, or its `route` with the item's id. */\nexport function getLinkTarget(target: ActionTarget): string | RouteReference | null {\n const { action, item } = target;\n if (action.url !== undefined) {\n if (action.url.includes('{id}') && item === undefined) {\n return null;\n }\n return item !== undefined\n ? action.url.replaceAll('{id}', encodeURIComponent(item.id))\n : action.url;\n }\n if (action.route !== undefined) {\n return { route: action.route, params: item !== undefined ? { id: item.id } : {} };\n }\n return null;\n}\n\nconst FINISHED = new Set(['succeeded', 'partial', 'failed', 'cancelled']);\n\n/** Whether a run has finished, successfully or not. */\nexport function isFinished(status: string): boolean {\n return FINISHED.has(status);\n}\n\n/** The counts of a result, from its summary or, without one, from its per-item results. */\nexport function getResultCounts(result: ActionResult): {\n succeeded: number | null;\n failed: number;\n skipped: number;\n} {\n if (result.summary !== undefined) {\n return result.summary;\n }\n const results = result.results ?? [];\n return {\n succeeded: null,\n failed: results.filter((entry) => entry.status === 'failed').length,\n skipped: results.filter((entry) => entry.status === 'skipped').length,\n };\n}\n"],"mappings":";;AAKA,SAAgB,mBACZ,QACA,SAAkC,CAAC,GACtB;CACb,IAAI,OAAO,UAAU,UAAU,OAAO,SAAS,KAAA,GAC3C,OAAO;EAAE,WAAW,EAAE,KAAK,CAAC,OAAO,KAAK,EAAE,EAAE;EAAG;CAAO;CAE1D,IAAI,OAAO,UAAU,eAAe,OAAO,cAAc,KAAA,GACrD,OAAO;EAAE,WAAW,OAAO;EAAW;CAAO;CAEjD,OAAO,EAAE,OAAO;AACpB;;AAGA,SAAgB,cAAc,QAAsD;CAChF,MAAM,EAAE,QAAQ,SAAS;CACzB,IAAI,OAAO,QAAQ,KAAA,GAAW;EAC1B,IAAI,OAAO,IAAI,SAAS,MAAM,KAAK,SAAS,KAAA,GACxC,OAAO;EAEX,OAAO,SAAS,KAAA,IACV,OAAO,IAAI,WAAW,QAAQ,mBAAmB,KAAK,EAAE,CAAC,IACzD,OAAO;CACjB;CACA,IAAI,OAAO,UAAU,KAAA,GACjB,OAAO;EAAE,OAAO,OAAO;EAAO,QAAQ,SAAS,KAAA,IAAY,EAAE,IAAI,KAAK,GAAG,IAAI,CAAC;CAAE;CAEpF,OAAO;AACX;AAEA,IAAM,2BAAW,IAAI,IAAI;CAAC;CAAa;CAAW;CAAU;AAAW,CAAC;;AAGxE,SAAgB,WAAW,QAAyB;CAChD,OAAO,SAAS,IAAI,MAAM;AAC9B;;AAGA,SAAgB,gBAAgB,QAI9B;CACE,IAAI,OAAO,YAAY,KAAA,GACnB,OAAO,OAAO;CAElB,MAAM,UAAU,OAAO,WAAW,CAAA;CAClC,OAAO;EACH,WAAW;EACX,QAAQ,QAAQ,QAAQ,UAAU,MAAM,WAAW,QAAQ,CAAC,CAAC;EAC7D,SAAS,QAAQ,QAAQ,UAAU,MAAM,WAAW,SAAS,CAAC,CAAC;CACnE;AACJ"}
1
+ {"version":3,"file":"request.js","names":["ActionRequest","ActionResult","RouteReference","ActionTarget","buildActionRequest","target","values","Record","scope","item","undefined","selection","ids","id","getLinkTarget","action","url","includes","replaceAll","encodeURIComponent","route","params","FINISHED","Set","isFinished","status","has","getResultCounts","result","succeeded","failed","skipped","summary","results","filter","entry","length"],"sources":["../src/request.ts"],"sourcesContent":["import type { ActionRequest, ActionResult, RouteReference } from '@panneau/protocol';\n\nimport type { ActionTarget } from './types';\n\n/** The request of an action: its selection (none for the resource), and its parameter values. */\nexport function buildActionRequest(\n target: ActionTarget,\n values: Record<string, unknown> = {},\n): ActionRequest {\n if (target.scope === 'item' && target.item !== undefined) {\n return { selection: { ids: [target.item.id] }, values };\n }\n if (target.scope === 'selection' && target.selection !== undefined) {\n return { selection: target.selection, values };\n }\n return { values };\n}\n\n/** Where a `link` action goes: its `url` with `{id}` replaced, or its `route` with the item's id. */\nexport function getLinkTarget(target: ActionTarget): string | RouteReference | null {\n const { action, item } = target;\n if (action.url !== undefined) {\n if (action.url.includes('{id}') && item === undefined) {\n return null;\n }\n return item !== undefined\n ? action.url.replaceAll('{id}', encodeURIComponent(item.id))\n : action.url;\n }\n if (action.route !== undefined) {\n return { route: action.route, params: item !== undefined ? { id: item.id } : {} };\n }\n return null;\n}\n\nconst FINISHED = new Set(['succeeded', 'partial', 'failed', 'cancelled']);\n\n/** Whether a run has finished, successfully or not. */\nexport function isFinished(status: string): boolean {\n return FINISHED.has(status);\n}\n\n/** The counts of a result, from its summary or, without one, from its per-item results. */\nexport function getResultCounts(result: ActionResult): {\n succeeded: number | null;\n failed: number;\n skipped: number;\n} {\n if (result.summary !== undefined) {\n return result.summary;\n }\n const results = result.results ?? [];\n return {\n succeeded: null,\n failed: results.filter((entry) => entry.status === 'failed').length,\n skipped: results.filter((entry) => entry.status === 'skipped').length,\n };\n}\n"],"mappings":";;AAKA,SAAgBI,mBACZC,QACAC,SAAkC,CAAC,GACtB;CACb,IAAID,OAAOG,UAAU,UAAUH,OAAOI,SAASC,KAAAA,GAC3C,OAAO;EAAEC,WAAW,EAAEC,KAAK,CAACP,OAAOI,KAAKI,EAAE,EAAE;EAAGP;CAAO;CAE1D,IAAID,OAAOG,UAAU,eAAeH,OAAOM,cAAcD,KAAAA,GACrD,OAAO;EAAEC,WAAWN,OAAOM;EAAWL;CAAO;CAEjD,OAAO,EAAEA,OAAO;AACpB;;AAGA,SAAgBQ,cAAcT,QAAsD;CAChF,MAAM,EAAEU,QAAQN,SAASJ;CACzB,IAAIU,OAAOC,QAAQN,KAAAA,GAAW;EAC1B,IAAIK,OAAOC,IAAIC,SAAS,MAAM,KAAKR,SAASC,KAAAA,GACxC,OAAO;EAEX,OAAOD,SAASC,KAAAA,IACVK,OAAOC,IAAIE,WAAW,QAAQC,mBAAmBV,KAAKI,EAAE,CAAC,IACzDE,OAAOC;CACjB;CACA,IAAID,OAAOK,UAAUV,KAAAA,GACjB,OAAO;EAAEU,OAAOL,OAAOK;EAAOC,QAAQZ,SAASC,KAAAA,IAAY,EAAEG,IAAIJ,KAAKI,GAAG,IAAI,CAAC;CAAE;CAEpF,OAAO;AACX;AAEA,IAAMS,2BAAW,IAAIC,IAAI;CAAC;CAAa;CAAW;CAAU;AAAW,CAAC;;AAGxE,SAAgBC,WAAWC,QAAyB;CAChD,OAAOH,SAASI,IAAID,MAAM;AAC9B;;AAGA,SAAgBE,gBAAgBC,QAI9B;CACE,IAAIA,OAAOI,YAAYtB,KAAAA,GACnB,OAAOkB,OAAOI;CAElB,MAAMC,UAAUL,OAAOK,WAAW,CAAA;CAClC,OAAO;EACHJ,WAAW;EACXC,QAAQG,QAAQC,QAAQC,UAAUA,MAAMV,WAAW,QAAQ,CAAC,CAACW;EAC7DL,SAASE,QAAQC,QAAQC,UAAUA,MAAMV,WAAW,SAAS,CAAC,CAACW;CACnE;AACJ"}
package/dist/types.d.ts CHANGED
@@ -59,4 +59,10 @@ export interface ClientActionProps {
59
59
  }
60
60
  /** A handler of `client` actions. */
61
61
  export type ClientActionHandler = ComponentType<ClientActionProps>;
62
+ declare module '@panneau/core' {
63
+ interface PluginKinds {
64
+ /** Handlers of `client` actions, by the action's `component`. */
65
+ actions: ClientActionHandler;
66
+ }
67
+ }
62
68
  //# sourceMappingURL=types.d.ts.map
@@ -1 +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,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,G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,EAAE,YAAY,CAAC;CACxB;AAED,uGAAuG;AACvG,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;IACrB,qGAAqG;IACrG,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,sEAAsE;IACtE,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,qCAAqC;AACrC,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAEnE,OAAO,QAAQ,eAAe,CAAC;IAC3B,UAAU,WAAW;QACjB,iEAAiE;QACjE,OAAO,EAAE,mBAAmB,CAAC;KAChC;CACJ"}
@@ -1,5 +1,5 @@
1
- import { type ActionPreview } from './preview';
2
- import type { ActionOutcome, ActionTarget, FollowedRun } from './types';
1
+ import { type ActionPreview } from './preview.js';
2
+ import type { ActionOutcome, ActionTarget, FollowedRun } from './types.js';
3
3
  /**
4
4
  * Runs the actions of a resource through the closest `ActionRunnerProvider`. The function takes a
5
5
  * list's `ListActionEvent`, so it is the `onAction` of a list:
@@ -1 +1 @@
1
- {"version":3,"file":"useActionRunner.js","names":[],"sources":["../src/useActionRunner.ts"],"sourcesContent":["import { use } from 'react';\n\nimport { ActionRunnerContext } from './context';\nimport { type ActionPreview, previewAction } from './preview';\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/**\n * Asks the backend how many items of a query selection an action would skip, before the list\n * confirms it (a dry run, for actions with `dryRun`). It is the `previewAction` of a list:\n *\n * ```tsx\n * <ListView onAction={useActionRunner('pages')} previewAction={useActionPreview('pages')} … />\n * ```\n */\nexport function useActionPreview(\n resource: string,\n): (target: ActionTarget) => Promise<ActionPreview | null> {\n const context = use(ActionRunnerContext);\n if (context === null) {\n throw new Error('useActionPreview() must be used inside <ActionRunnerProvider>.');\n }\n return (target) => previewAction(context.adapter, 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":";;;;;;;;;;;;;;;;AAkBA,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;;;;;;;;;AAUA,SAAgB,iBACZ,UACuD;CACvD,MAAM,UAAU,IAAI,mBAAmB;CACvC,IAAI,YAAY,MACZ,MAAM,IAAI,MAAM,gEAAgE;CAEpF,QAAQ,WAAW,cAAc,QAAQ,SAAS,UAAU,MAAM;AACtE;;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"}
1
+ {"version":3,"file":"useActionRunner.js","names":["use","ActionRunnerContext","ActionPreview","previewAction","ActionOutcome","ActionTarget","FollowedRun","useActionRunner","resource","target","Promise","context","Error","run","useActionPreview","adapter","useActionRuns","runs","cancel","id","dismiss","cancelRun","dismissRun"],"sources":["../src/useActionRunner.ts"],"sourcesContent":["import { use } from 'react';\n\nimport { ActionRunnerContext } from './context';\nimport { type ActionPreview, previewAction } from './preview';\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/**\n * Asks the backend how many items of a query selection an action would skip, before the list\n * confirms it (a dry run, for actions with `dryRun`). It is the `previewAction` of a list:\n *\n * ```tsx\n * <ListView onAction={useActionRunner('pages')} previewAction={useActionPreview('pages')} … />\n * ```\n */\nexport function useActionPreview(\n resource: string,\n): (target: ActionTarget) => Promise<ActionPreview | null> {\n const context = use(ActionRunnerContext);\n if (context === null) {\n throw new Error('useActionPreview() must be used inside <ActionRunnerProvider>.');\n }\n return (target) => previewAction(context.adapter, 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":";;;;;;;;;;;;;;;;AAkBA,SAAgBO,gBACZC,UACwD;CACxD,MAAMG,UAAUX,IAAIC,mBAAmB;CACvC,IAAIU,YAAY,MACZ,MAAM,IAAIC,MAAM,+DAA+D;CAEnF,QAAQH,WAAWE,QAAQE,IAAIL,UAAUC,MAAM;AACnD;;;;;;;;;AAUA,SAAgBK,iBACZN,UACuD;CACvD,MAAMG,UAAUX,IAAIC,mBAAmB;CACvC,IAAIU,YAAY,MACZ,MAAM,IAAIC,MAAM,gEAAgE;CAEpF,QAAQH,WAAWN,cAAcQ,QAAQI,SAASP,UAAUC,MAAM;AACtE;;AAGA,SAAgBO,gBAId;CACE,MAAML,UAAUX,IAAIC,mBAAmB;CACvC,IAAIU,YAAY,MACZ,MAAM,IAAIC,MAAM,6DAA6D;CAEjF,OAAO;EAAEK,MAAMN,QAAQM;EAAMC,QAAQP,QAAQU;EAAWD,SAAST,QAAQW;CAAW;AACxF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/actions",
3
- "version": "5.0.0-alpha.5",
3
+ "version": "5.0.0-alpha.51",
4
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
5
  "type": "module",
6
6
  "license": "MIT",
@@ -24,9 +24,9 @@
24
24
  "dist"
25
25
  ],
26
26
  "scripts": {
27
- "build": "vite build && tsc -p tsconfig.build.json",
27
+ "build": "vite build && node ../../scripts/declarations.js",
28
28
  "typecheck": "tsc --noEmit",
29
- "api": "tsc -p tsconfig.build.json && node ../../scripts/api-report.js"
29
+ "api": "node ../../scripts/declarations.js && node ../../scripts/api-report.js"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"
@@ -37,15 +37,15 @@
37
37
  "react-intl": "^12.0.0"
38
38
  },
39
39
  "dependencies": {
40
- "@panneau/core": "5.0.0-alpha.5",
41
- "@panneau/data": "5.0.0-alpha.5",
42
- "@panneau/forms": "5.0.0-alpha.5",
43
- "@panneau/intl": "5.0.0-alpha.5",
44
- "@panneau/protocol": "5.0.0-alpha.5",
45
- "@panneau/ui": "5.0.0-alpha.5",
40
+ "@panneau/core": "5.0.0-alpha.51",
41
+ "@panneau/data": "5.0.0-alpha.51",
42
+ "@panneau/forms": "5.0.0-alpha.51",
43
+ "@panneau/intl": "5.0.0-alpha.51",
44
+ "@panneau/protocol": "5.0.0-alpha.51",
45
+ "@panneau/ui": "5.0.0-alpha.51",
46
46
  "lucide-react": "^1.57.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@panneau/lists": "5.0.0-alpha.5"
49
+ "@panneau/lists": "5.0.0-alpha.51"
50
50
  }
51
51
  }