@panneau/lists 5.0.0-alpha.16 → 5.0.0-alpha.18

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 (68) hide show
  1. package/README.md +14 -14
  2. package/dist/ListSkeleton.d.ts +3 -1
  3. package/dist/ListSkeleton.d.ts.map +1 -1
  4. package/dist/ListSkeleton.js +34 -30
  5. package/dist/ListSkeleton.js.map +1 -1
  6. package/dist/ListView.d.ts +10 -3
  7. package/dist/ListView.d.ts.map +1 -1
  8. package/dist/ListView.js +44 -35
  9. package/dist/ListView.js.map +1 -1
  10. package/dist/actions/ActionButton.d.ts +7 -1
  11. package/dist/actions/ActionButton.d.ts.map +1 -1
  12. package/dist/actions/ActionButton.js +74 -72
  13. package/dist/actions/ActionButton.js.map +1 -1
  14. package/dist/actions/Actions.css +12 -0
  15. package/dist/actions/Actions.module.js +6 -2
  16. package/dist/actions/Actions.module.js.map +1 -1
  17. package/dist/actions/ConfirmDialog.d.ts +5 -1
  18. package/dist/actions/ConfirmDialog.d.ts.map +1 -1
  19. package/dist/actions/ConfirmDialog.js +7 -3
  20. package/dist/actions/ConfirmDialog.js.map +1 -1
  21. package/dist/actions/RowActions.d.ts +21 -4
  22. package/dist/actions/RowActions.d.ts.map +1 -1
  23. package/dist/actions/RowActions.js +149 -84
  24. package/dist/actions/RowActions.js.map +1 -1
  25. package/dist/actions/fit.d.ts +25 -0
  26. package/dist/actions/fit.d.ts.map +1 -0
  27. package/dist/actions/fit.js +197 -0
  28. package/dist/actions/fit.js.map +1 -0
  29. package/dist/actions/icons.d.ts +5 -0
  30. package/dist/actions/icons.d.ts.map +1 -1
  31. package/dist/actions/icons.js +15 -1
  32. package/dist/actions/icons.js.map +1 -1
  33. package/dist/displays/Displays.css +12 -1
  34. package/dist/displays/Displays.module.js +6 -2
  35. package/dist/displays/Displays.module.js.map +1 -1
  36. package/dist/displays/displays.d.ts +12 -3
  37. package/dist/displays/displays.d.ts.map +1 -1
  38. package/dist/displays/displays.js +223 -66
  39. package/dist/displays/displays.js.map +1 -1
  40. package/dist/images.d.ts +3 -2
  41. package/dist/images.d.ts.map +1 -1
  42. package/dist/images.js +24 -3
  43. package/dist/images.js.map +1 -1
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +3 -3
  47. package/dist/inline/InlineCell.d.ts +3 -1
  48. package/dist/inline/InlineCell.d.ts.map +1 -1
  49. package/dist/inline/InlineCell.js +153 -134
  50. package/dist/inline/InlineCell.js.map +1 -1
  51. package/dist/layouts/CardsLayout.d.ts.map +1 -1
  52. package/dist/layouts/CardsLayout.js +90 -93
  53. package/dist/layouts/CardsLayout.js.map +1 -1
  54. package/dist/layouts/GalleryLayout.css +7 -0
  55. package/dist/layouts/GalleryLayout.d.ts.map +1 -1
  56. package/dist/layouts/GalleryLayout.js +76 -53
  57. package/dist/layouts/GalleryLayout.js.map +1 -1
  58. package/dist/layouts/GalleryLayout.module.js.map +1 -1
  59. package/dist/layouts/TableLayout.css +31 -0
  60. package/dist/layouts/TableLayout.d.ts +4 -3
  61. package/dist/layouts/TableLayout.d.ts.map +1 -1
  62. package/dist/layouts/TableLayout.js +158 -98
  63. package/dist/layouts/TableLayout.js.map +1 -1
  64. package/dist/layouts/TableLayout.module.js +5 -1
  65. package/dist/layouts/TableLayout.module.js.map +1 -1
  66. package/dist/types.d.ts +4 -1
  67. package/dist/types.d.ts.map +1 -1
  68. package/package.json +7 -7
@@ -1,5 +1,6 @@
1
1
  import { messages } from "../messages.js";
2
2
  import Actions_module_default from "./Actions.module.js";
3
+ import { asksConfirmation } from "@panneau/core";
3
4
  import { c } from "react/compiler-runtime";
4
5
  import { getActionLabel } from "@panneau/intl";
5
6
  import { Button, Dialog, Spinner, usePanneauIntl } from "@panneau/ui";
@@ -13,10 +14,13 @@ function formatDefinitionMessage(intl, message, values) {
13
14
  return message;
14
15
  }
15
16
  }
16
- /** Whether an action needs a confirmation: it asks for one, or some selected items are skipped. */
17
+ /**
18
+ * Whether an action needs a confirmation: it asks for one, or it is undoable but runs on more items
19
+ * than an undo can put back (`asksConfirmation()`, decision 0063), or some selected items are
20
+ * skipped.
21
+ */
17
22
  function needsConfirmation(event) {
18
- const { confirm } = event.action;
19
- return confirm !== void 0 && confirm !== false || event.skipped.length > 0;
23
+ return asksConfirmation(event.action, event.count) || event.skipped.length > 0;
20
24
  }
21
25
  /**
22
26
  * Asks before running an action (decision 0017): the action's `confirm` title and message (an ICU
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmDialog.js","names":["IntlShape","getActionLabel","Button","Dialog","Spinner","usePanneauIntl","messages","ListActionEvent","ListActionPreview","styles","formatDefinitionMessage","intl","message","values","Record","String","formatters","getMessageFormat","locale","format","needsConfirmation","event","confirm","action","undefined","skipped","length","ConfirmPreview","status","ConfirmDialogProps","preview","onConfirm","onCancel","ConfirmDialog","t0","$","_c","t1","count","loading","T0","t10","t2","t3","t4","t5","t6","t7","t8","t9","label","open","title","formatMessage","confirmTitle","t11","cancelLabel","cancel","destructive","confirmLabel","confirmMessage","t12","confirmChecking","confirmSkipped","t13","_c","_Fragment","styles"],"sources":["../../src/actions/ConfirmDialog.tsx"],"sourcesContent":["import type { IntlShape } from 'react-intl';\n\nimport { getActionLabel } from '@panneau/intl';\nimport { Button, Dialog, Spinner, usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from '../messages';\nimport type { ListActionEvent, ListActionPreview } from '../types';\nimport styles from './Actions.module.css';\n\n/** Formats an ICU message of the definition (`{count, plural, …}`) in the locale. */\nfunction formatDefinitionMessage(\n intl: IntlShape,\n message: string,\n values: Record<string, unknown>,\n) {\n try {\n return String(\n intl.formatters\n .getMessageFormat(message, intl.locale)\n .format(values as Record<string, string | number>),\n );\n } catch {\n return message;\n }\n}\n\n/** Whether an action needs a confirmation: it asks for one, or some selected items are skipped. */\nexport function needsConfirmation(event: ListActionEvent): boolean {\n const { confirm } = event.action;\n return (confirm !== undefined && confirm !== false) || event.skipped.length > 0;\n}\n\n/** The dry run of a query selection: in progress, or done with the backend's count. */\nexport type ConfirmPreview = { status: 'loading' } | ({ status: 'done' } & ListActionPreview);\n\nexport interface ConfirmDialogProps {\n /** The action to confirm, or `null` when the dialog is closed. */\n event: ListActionEvent | null;\n /**\n * What the backend told about a query selection. Its count of skipped items replaces the\n * count of the current page; while it loads, the dialog says so and can't be confirmed.\n */\n preview?: ConfirmPreview | null;\n onConfirm: (event: ListActionEvent) => void;\n onCancel: () => void;\n}\n\n/**\n * Asks before running an action (decision 0017): the action's `confirm` title and message (an ICU\n * message with `{count}`), or default ones, and how many selected items will be skipped: those of\n * the current page that don't allow it, or the backend's count for every item matching a query.\n */\nexport function ConfirmDialog({ event, preview = null, onConfirm, onCancel }: ConfirmDialogProps) {\n const intl = usePanneauIntl();\n if (event === null) {\n return null;\n }\n const { action, count } = event;\n const loading = preview?.status === 'loading';\n const skipped = preview?.status === 'done' ? preview.skipped : event.skipped.length;\n const confirm = typeof action.confirm === 'object' ? action.confirm : {};\n const label = getActionLabel(action, intl);\n const values = { count, action: label };\n return (\n <Dialog\n isOpen\n onOpenChange={(open) => {\n if (!open) {\n onCancel();\n }\n }}\n role=\"alertdialog\"\n isDismissable={false}\n size=\"sm\"\n title={\n confirm.title !== undefined\n ? formatDefinitionMessage(intl, confirm.title, values)\n : intl.formatMessage(messages.confirmTitle, { action: label })\n }\n footer={\n <>\n <Button variant=\"ghost\" onPress={onCancel}>\n {confirm.cancelLabel ?? intl.formatMessage(messages.cancel)}\n </Button>\n <Button\n variant={action.destructive === true ? 'danger' : 'primary'}\n autoFocus\n isDisabled={loading}\n onPress={() => onConfirm(event)}\n >\n {confirm.confirmLabel ?? label}\n </Button>\n </>\n }\n >\n <p className={styles.message}>\n {confirm.message !== undefined\n ? formatDefinitionMessage(intl, confirm.message, values)\n : intl.formatMessage(messages.confirmMessage, values)}\n </p>\n {loading ? (\n <div className={styles.skipped}>\n <Spinner\n size=\"sm\"\n label={intl.formatMessage(messages.confirmChecking)}\n showLabel\n />\n </div>\n ) : skipped > 0 ? (\n <p className={styles.skipped}>\n {intl.formatMessage(messages.confirmSkipped, { count: skipped })}\n </p>\n ) : null}\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAASU,wBACLC,MACAC,SACAC,QACF;CACE,IAAI;EACA,OAAOE,OACHJ,KAAKK,WACAC,iBAAiBL,SAASD,KAAKO,MAAM,CAAC,CACtCC,OAAON,MAAyC,CACzD;CACJ,QAAQ;EACJ,OAAOD;CACX;AACJ;;AAGA,SAAgBQ,kBAAkBC,OAAiC;CAC/D,MAAM,EAAEC,YAAYD,MAAME;CAC1B,OAAQD,YAAYE,KAAAA,KAAaF,YAAY,SAAUD,MAAMI,QAAQC,SAAS;AAClF;;;;;;AAsBA,SAAOO,cAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAuB,MAAA,EAAAf,OAAAS,SAAAO,IAAAN,WAAAC,aAAAE;CAAS,MAAAJ,UAAAO,OAAAb,KAAAA,IAAA,OAAAa;CACnC,MAAA1B,OAAaN,eAAe;CAC5B,IAAIgB,UAAU,MAAI,OACP;CAEX,MAAA,EAAAE,QAAAe,UAA0BjB;CAC1B,MAAAkB,UAAgBT,SAAOF,WAAa;CACpC,MAAAH,UAAgBK,SAAOF,WAAa,SAASE,QAAOL,UAAWJ,MAAKI,QAAQC;CAAQ,IAAAc;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAd,EAAA,OAAAZ,UAAAY,EAAA,OAAAG,SAAAH,EAAA,OAAAd,SAAAc,EAAA,OAAAxB,QAAAwB,EAAA,OAAAI,WAAAJ,EAAA,OAAAH,YAAAG,EAAA,OAAAJ,WAAA;EACpF,MAAAT,UAAgB,OAAOC,OAAMD,YAAa,WAAWC,OAAMD,UAA3C,CAAuD;EACvE,MAAA4B,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,IAAA6B;CAAA,IAAA7B,EAAA,QAAAK,MAAAL,EAAA,QAAAM,OAAAN,EAAA,QAAAoB,OAAApB,EAAA,QAAA0B,OAAA1B,EAAA,QAAAS,MAAAT,EAAA,QAAAU,MAAAV,EAAA,QAAAW,MAAAX,EAAA,QAAAY,MAAAZ,EAAA,QAAAa,MAAAb,EAAA,QAAAc,IAAA;EAhDZe,MAAA,qBAAC,IAAD;GACI,QAAApB;GACc,cAAAC;GAKT,MAAAC;GACU,eAAAC;GACV,MAAAC;GAED,OAAAC;GAKA,QAAAR;GAhBR,UAAA,CA+BIc,KAKCM,GApCE;;EAiDE1B,EAAA,MAAAK;EAAAL,EAAA,MAAAM;EAAAN,EAAA,MAAAoB;EAAApB,EAAA,MAAA0B;EAAA1B,EAAA,MAAAS;EAAAT,EAAA,MAAAU;EAAAV,EAAA,MAAAW;EAAAX,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;EAAAb,EAAA,MAAAc;EAAAd,EAAA,MAAA6B;CAAA,OAAAA,MAAA7B,EAAA;CAAA,OAjDT6B;AAiDS"}
1
+ {"version":3,"file":"ConfirmDialog.js","names":["IntlShape","asksConfirmation","getActionLabel","Button","Dialog","Spinner","usePanneauIntl","messages","ListActionEvent","ListActionPreview","styles","formatDefinitionMessage","intl","message","values","Record","String","formatters","getMessageFormat","locale","format","needsConfirmation","event","action","count","skipped","length","ConfirmPreview","status","ConfirmDialogProps","preview","onConfirm","onCancel","ConfirmDialog","t0","$","_c","t1","undefined","loading","T0","t10","t2","t3","t4","t5","t6","t7","t8","t9","confirm","label","open","title","formatMessage","confirmTitle","t11","cancelLabel","cancel","destructive","confirmLabel","confirmMessage","t12","confirmChecking","confirmSkipped","t13","_c","_Fragment","styles"],"sources":["../../src/actions/ConfirmDialog.tsx"],"sourcesContent":["import type { IntlShape } from 'react-intl';\n\nimport { asksConfirmation } from '@panneau/core';\nimport { getActionLabel } from '@panneau/intl';\nimport { Button, Dialog, Spinner, usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from '../messages';\nimport type { ListActionEvent, ListActionPreview } from '../types';\nimport styles from './Actions.module.css';\n\n/** Formats an ICU message of the definition (`{count, plural, …}`) in the locale. */\nfunction formatDefinitionMessage(\n intl: IntlShape,\n message: string,\n values: Record<string, unknown>,\n) {\n try {\n return String(\n intl.formatters\n .getMessageFormat(message, intl.locale)\n .format(values as Record<string, string | number>),\n );\n } catch {\n return message;\n }\n}\n\n/**\n * Whether an action needs a confirmation: it asks for one, or it is undoable but runs on more items\n * than an undo can put back (`asksConfirmation()`, decision 0063), or some selected items are\n * skipped.\n */\nexport function needsConfirmation(event: ListActionEvent): boolean {\n return asksConfirmation(event.action, event.count) || event.skipped.length > 0;\n}\n\n/** The dry run of a query selection: in progress, or done with the backend's count. */\nexport type ConfirmPreview = { status: 'loading' } | ({ status: 'done' } & ListActionPreview);\n\nexport interface ConfirmDialogProps {\n /** The action to confirm, or `null` when the dialog is closed. */\n event: ListActionEvent | null;\n /**\n * What the backend told about a query selection. Its count of skipped items replaces the\n * count of the current page; while it loads, the dialog says so and can't be confirmed.\n */\n preview?: ConfirmPreview | null;\n onConfirm: (event: ListActionEvent) => void;\n onCancel: () => void;\n}\n\n/**\n * Asks before running an action (decision 0017): the action's `confirm` title and message (an ICU\n * message with `{count}`), or default ones, and how many selected items will be skipped: those of\n * the current page that don't allow it, or the backend's count for every item matching a query.\n */\nexport function ConfirmDialog({ event, preview = null, onConfirm, onCancel }: ConfirmDialogProps) {\n const intl = usePanneauIntl();\n if (event === null) {\n return null;\n }\n const { action, count } = event;\n const loading = preview?.status === 'loading';\n const skipped = preview?.status === 'done' ? preview.skipped : event.skipped.length;\n const confirm = typeof action.confirm === 'object' ? action.confirm : {};\n const label = getActionLabel(action, intl);\n const values = { count, action: label };\n return (\n <Dialog\n isOpen\n onOpenChange={(open) => {\n if (!open) {\n onCancel();\n }\n }}\n role=\"alertdialog\"\n isDismissable={false}\n size=\"sm\"\n title={\n confirm.title !== undefined\n ? formatDefinitionMessage(intl, confirm.title, values)\n : intl.formatMessage(messages.confirmTitle, { action: label })\n }\n footer={\n <>\n <Button variant=\"ghost\" onPress={onCancel}>\n {confirm.cancelLabel ?? intl.formatMessage(messages.cancel)}\n </Button>\n <Button\n variant={action.destructive === true ? 'danger' : 'primary'}\n autoFocus\n isDisabled={loading}\n onPress={() => onConfirm(event)}\n >\n {confirm.confirmLabel ?? label}\n </Button>\n </>\n }\n >\n <p className={styles.message}>\n {confirm.message !== undefined\n ? formatDefinitionMessage(intl, confirm.message, values)\n : intl.formatMessage(messages.confirmMessage, values)}\n </p>\n {loading ? (\n <div className={styles.skipped}>\n <Spinner\n size=\"sm\"\n label={intl.formatMessage(messages.confirmChecking)}\n showLabel\n />\n </div>\n ) : skipped > 0 ? (\n <p className={styles.skipped}>\n {intl.formatMessage(messages.confirmSkipped, { count: skipped })}\n </p>\n ) : null}\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,SAASW,wBACLC,MACAC,SACAC,QACF;CACE,IAAI;EACA,OAAOE,OACHJ,KAAKK,WACAC,iBAAiBL,SAASD,KAAKO,MAAM,CAAC,CACtCC,OAAON,MAAyC,CACzD;CACJ,QAAQ;EACJ,OAAOD;CACX;AACJ;;;;;;AAOA,SAAgBQ,kBAAkBC,OAAiC;CAC/D,OAAOrB,iBAAiBqB,MAAMC,QAAQD,MAAME,KAAK,KAAKF,MAAMG,QAAQC,SAAS;AACjF;;;;;;AAsBA,SAAOO,cAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAuB,MAAA,EAAAd,OAAAQ,SAAAO,IAAAN,WAAAC,aAAAE;CAAS,MAAAJ,UAAAO,OAAAC,KAAAA,IAAA,OAAAD;CACnC,MAAAzB,OAAaN,eAAe;CAC5B,IAAIgB,UAAU,MAAI,OACP;CAEX,MAAA,EAAAC,QAAAC,UAA0BF;CAC1B,MAAAiB,UAAgBT,SAAOF,WAAa;CACpC,MAAAH,UAAgBK,SAAOF,WAAa,SAASE,QA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AAgB,WAAA7B,uBAAMe;GAClB,UAAA,oBAAC,SAAD;IACS,MAAA;IACE,OAAAb,KAAI0C,cAAe/C,SAAQwD,eAAgB;IAClD,WAAA;GAAS,CAAA;EAEX,CAAA,IACNtC,UAAU,IACV,oBAAA,KAAA;GAAc,WAAAf,uBAAMe;GACfb,UAAAA,KAAI0C,cAAe/C,SAAQyD,gBAAiB,EAAAxC,OAASC,QAAQ,CAAC;EAC/D,CAAA,IAHJ;EAIIU,EAAA,MAAAvB;EAAAuB,EAAA,MAAAI;EAAAJ,EAAA,MAAAV;EAAAU,EAAA,MAAA2B;CAAA,OAAAA,MAAA3B,EAAA;CAAA,IAAA8B;CAAA,IAAA9B,EAAA,QAAAK,MAAAL,EAAA,QAAAM,OAAAN,EAAA,QAAAqB,OAAArB,EAAA,QAAA2B,OAAA3B,EAAA,QAAAS,MAAAT,EAAA,QAAAU,MAAAV,EAAA,QAAAW,MAAAX,EAAA,QAAAY,MAAAZ,EAAA,QAAAa,MAAAb,EAAA,QAAAc,IAAA;EAhDZgB,MAAA,qBAAC,IAAD;GACI,QAAArB;GACc,cAAAC;GAKT,MAAAC;GACU,eAAAC;GACV,MAAAC;GAED,OAAAC;GAKA,QAAAR;GAhBR,UAAA,CA+BIe,KAKCM,GApCE;;EAiDE3B,EAAA,MAAAK;EAAAL,EAAA,MAAAM;EAAAN,EAAA,MAAAqB;EAAArB,EAAA,MAAA2B;EAAA3B,EAAA,MAAAS;EAAAT,EAAA,MAAAU;EAAAV,EAAA,MAAAW;EAAAX,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;EAAAb,EAAA,MAAAc;EAAAd,EAAA,MAAA8B;CAAA,OAAAA,MAAA9B,EAAA;CAAA,OAjDT8B;AAiDS"}
@@ -4,16 +4,33 @@ import { type ActionIcons } from './icons.js';
4
4
  export interface RowActionsProps {
5
5
  /** The label of the item, for the accessible names of its actions. */
6
6
  itemLabel: string;
7
- /** Actions shown as buttons, with their links (`getItemActions()` of `@panneau/core`). */
7
+ /** Actions placed in `row`, with their links (`selectItemActions()` of `@panneau/core`). */
8
8
  actions: readonly ItemAction[];
9
- /** Actions in the overflow menu. */
9
+ /** Actions placed in `menu`: icons too while they fit, the first to go in the menu. */
10
10
  menu: readonly ItemAction[];
11
11
  /** Id of the action that is running on this item, if any. */
12
12
  pending: string | null;
13
13
  onRun: (action: Action) => void;
14
14
  /** Icons of actions by id, over the icon the action names. */
15
15
  icons?: ActionIcons | undefined;
16
+ /**
17
+ * The actions of every row of the list, in order (`orderRowActions()`): a row keeps the place
18
+ * of those it doesn't have, so the actions of the rows line up. Without it, its own.
19
+ */
20
+ slots?: readonly ItemAction[] | undefined;
21
+ /** The id of the main action of rows, which keeps its label (`show` or `edit`). */
22
+ primary?: string | null | undefined;
16
23
  }
17
- /** The actions of a row: buttons, then an overflow menu. */
18
- export declare function RowActions({ itemLabel, actions, menu, pending, onRun, icons }: RowActionsProps): import("react").JSX.Element;
24
+ /**
25
+ * The actions of a row in their order: those placed in `row`, then those placed in `menu`, and
26
+ * those that destroy last. The last ones are the first to go in the menu.
27
+ */
28
+ export declare function orderRowActions(actions: readonly ItemAction[], menu: readonly ItemAction[]): ItemAction[];
29
+ /**
30
+ * The actions of a row (decision 0060): their icons, in their colors, with their labels as names
31
+ * and tooltips, but the main action, which keeps its label while the row has room; and when the
32
+ * icons don't fit, the last ones in an overflow menu, which never holds a single action. How they fit is the same for every row of the list (`RowActionsFit`), and a
33
+ * row keeps the place of the actions of other rows that it doesn't have, so they line up.
34
+ */
35
+ export declare function RowActions({ itemLabel, actions, menu, pending, onRun, icons, slots, primary, }: RowActionsProps): import("react").JSX.Element;
19
36
  //# sourceMappingURL=RowActions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RowActions.d.ts","sourceRoot":"","sources":["../../src/actions/RowActions.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,MAAM,EAAE,M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AK,CAAC,EAAE,SAAS,UAAU,EAAE,GAAG,SAAS,CAAC;IAC1C,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACvC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC3B,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,IAAI,EAAE,SAAS,UAAU,EAAE,GAC5B,UAAU,EAAE,CASd;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACvB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,EACP,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAc,GACjB,EAAE,eAAe,+BA0FjB"}
@@ -1,105 +1,170 @@
1
1
  import { messages } from "../messages.js";
2
2
  import Actions_module_default from "./Actions.module.js";
3
3
  import { getActionIcon } from "./icons.js";
4
+ import { RowActionsFit } from "./fit.js";
4
5
  import { ActionButton } from "./ActionButton.js";
5
6
  import { c } from "react/compiler-runtime";
6
7
  import { getActionLabel } from "@panneau/intl";
7
8
  import { IconButton, Menu, MenuItem, MenuTrigger, usePanneauIntl } from "@panneau/ui";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
10
  import { Ellipsis } from "lucide-react";
11
+ import { use } from "react";
10
12
  //#region src/actions/RowActions.tsx
11
- /** The actions of a row: buttons, then an overflow menu. */
13
+ /**
14
+ * The actions of a row in their order: those placed in `row`, then those placed in `menu`, and
15
+ * those that destroy last. The last ones are the first to go in the menu.
16
+ */
17
+ function orderRowActions(actions, menu) {
18
+ const all = [...actions, ...menu].filter((entry, index, list) => list.findIndex((other) => other.action.id === entry.action.id) === index);
19
+ return [...all.filter(({ action }) => action.destructive !== true), ...all.filter(({ action }) => action.destructive === true)];
20
+ }
21
+ /**
22
+ * The actions of a row (decision 0060): their icons, in their colors, with their labels as names
23
+ * and tooltips, but the main action, which keeps its label while the row has room; and when the
24
+ * icons don't fit, the last ones in an overflow menu, which never holds a single action. How they fit is the same for every row of the list (`RowActionsFit`), and a
25
+ * row keeps the place of the actions of other rows that it doesn't have, so they line up.
26
+ */
12
27
  function RowActions(t0) {
13
- const $ = c(23);
14
- const { itemLabel, actions, menu, pending, onRun, icons } = t0;
28
+ const $ = c(30);
29
+ const { itemLabel, actions, menu, pending, onRun, icons, slots, primary: t1 } = t0;
30
+ const primary = t1 === void 0 ? null : t1;
15
31
  const intl = usePanneauIntl();
16
- let t1;
17
- if ($[0] !== actions || $[1] !== icons || $[2] !== intl || $[3] !== itemLabel || $[4] !== onRun || $[5] !== pending) {
18
- let t2;
19
- if ($[7] !== icons || $[8] !== intl || $[9] !== itemLabel || $[10] !== onRun || $[11] !== pending) {
20
- t2 = (t3) => {
21
- const { action, href } = t3;
22
- return /* @__PURE__ */ jsx(ActionButton, {
23
- action,
24
- icons,
25
- href,
26
- isPending: pending === action.id,
27
- isDisabled: pending !== null && pending !== action.id,
28
- "aria-label": intl.formatMessage(messages.actionOnItem, {
29
- action: getActionLabel(action, intl),
30
- item: itemLabel
31
- }),
32
- onPress: () => onRun(action)
33
- }, action.id);
32
+ const level = use(RowActionsFit);
33
+ let t2;
34
+ if ($[0] !== actions || $[1] !== icons || $[2] !== intl || $[3] !== itemLabel || $[4] !== level || $[5] !== menu || $[6] !== onRun || $[7] !== pending || $[8] !== primary || $[9] !== slots) {
35
+ const own = orderRowActions(actions, menu);
36
+ let t3;
37
+ if ($[11] !== slots) {
38
+ t3 = (t4) => {
39
+ const { action } = t4;
40
+ return slots?.some((slot) => slot.action.id === action.id) !== true;
34
41
  };
35
- $[7] = icons;
36
- $[8] = intl;
37
- $[9] = itemLabel;
38
- $[10] = onRun;
39
- $[11] = pending;
40
- $[12] = t2;
41
- } else t2 = $[12];
42
- t1 = actions.map(t2);
42
+ $[11] = slots;
43
+ $[12] = t3;
44
+ } else t3 = $[12];
45
+ const all = [...slots ?? [], ...own.filter(t3)];
46
+ const find = (slot_0) => own.find((t4) => {
47
+ const { action: action_0 } = t4;
48
+ return action_0.id === slot_0.action.id;
49
+ });
50
+ const inMenu = level >= 2 && all.length >= 2 ? Math.min(level, all.length) : 0;
51
+ const shown = all.slice(0, all.length - inMenu);
52
+ const overflow = all.slice(all.length - inMenu).flatMap((slot_1) => find(slot_1) ?? []);
53
+ let t5;
54
+ if ($[13] !== intl || $[14] !== itemLabel) {
55
+ t5 = (action_1) => intl.formatMessage(messages.actionOnItem, {
56
+ action: getActionLabel(action_1, intl),
57
+ item: itemLabel
58
+ });
59
+ $[13] = intl;
60
+ $[14] = itemLabel;
61
+ $[15] = t5;
62
+ } else t5 = $[15];
63
+ const name = t5;
64
+ let t6;
65
+ if ($[16] !== icons || $[17] !== level || $[18] !== name || $[19] !== onRun || $[20] !== pending || $[21] !== primary) {
66
+ t6 = (entry) => /* @__PURE__ */ jsx(ActionButton, {
67
+ action: entry.action,
68
+ icons,
69
+ href: entry.href,
70
+ iconOnly: level >= 1 || entry.action.id !== primary,
71
+ isPending: pending === entry.action.id,
72
+ isDisabled: pending !== null && pending !== entry.action.id,
73
+ "aria-label": name(entry.action),
74
+ onPress: () => onRun(entry.action)
75
+ }, entry.action.id);
76
+ $[16] = icons;
77
+ $[17] = level;
78
+ $[18] = name;
79
+ $[19] = onRun;
80
+ $[20] = pending;
81
+ $[21] = primary;
82
+ $[22] = t6;
83
+ } else t6 = $[22];
84
+ const button = t6;
85
+ const placeholder = _temp;
86
+ let t7;
87
+ if ($[23] !== intl || $[24] !== itemLabel) {
88
+ t7 = intl.formatMessage(messages.itemActions, { item: itemLabel });
89
+ $[23] = intl;
90
+ $[24] = itemLabel;
91
+ $[25] = t7;
92
+ } else t7 = $[25];
93
+ const t8 = overflow.length >= 2;
94
+ const t9 = pending !== null && overflow.some((t10) => {
95
+ const { action: action_2 } = t10;
96
+ return action_2.id === pending;
97
+ });
98
+ let t11;
99
+ if ($[26] !== t7 || $[27] !== t8 || $[28] !== t9) {
100
+ t11 = /* @__PURE__ */ jsx(IconButton, {
101
+ icon: Ellipsis,
102
+ size: "sm",
103
+ appearance: "subtle",
104
+ label: t7,
105
+ showTooltip: t8,
106
+ isPending: t9
107
+ });
108
+ $[26] = t7;
109
+ $[27] = t8;
110
+ $[28] = t9;
111
+ $[29] = t11;
112
+ } else t11 = $[29];
113
+ const menuButton = t11;
114
+ t2 = /* @__PURE__ */ jsxs("div", {
115
+ className: Actions_module_default.row,
116
+ "data-row-actions": all.length,
117
+ children: [shown.map((slot_2) => {
118
+ const entry_0 = find(slot_2);
119
+ return entry_0 !== void 0 ? button(entry_0) : placeholder(slot_2.action.id, button({
120
+ ...slot_2,
121
+ href: null
122
+ }));
123
+ }), overflow.length >= 2 ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [menuButton, /* @__PURE__ */ jsx(Menu, {
124
+ placement: "bottom end",
125
+ onAction: (key_0) => {
126
+ const entry_1 = overflow.find((t12) => {
127
+ const { action: action_3 } = t12;
128
+ return action_3.id === key_0;
129
+ });
130
+ if (entry_1 !== void 0 && entry_1.href === null) onRun(entry_1.action);
131
+ },
132
+ children: overflow.map((t13) => {
133
+ const { action: action_4, href } = t13;
134
+ const icon = getActionIcon(action_4, icons);
135
+ return /* @__PURE__ */ jsx(MenuItem, {
136
+ id: action_4.id,
137
+ isDanger: action_4.destructive === true,
138
+ ...icon !== void 0 ? { icon } : {},
139
+ ...href !== null ? { href } : {},
140
+ children: getActionLabel(action_4, intl)
141
+ }, action_4.id);
142
+ })
143
+ })] }) : overflow.length === 1 && overflow[0] !== void 0 ? button(overflow[0]) : inMenu > 0 ? placeholder("menu", menuButton) : null]
144
+ });
43
145
  $[0] = actions;
44
146
  $[1] = icons;
45
147
  $[2] = intl;
46
148
  $[3] = itemLabel;
47
- $[4] = onRun;
48
- $[5] = pending;
49
- $[6] = t1;
50
- } else t1 = $[6];
51
- let t2;
52
- if ($[13] !== icons || $[14] !== intl || $[15] !== itemLabel || $[16] !== menu || $[17] !== onRun || $[18] !== pending) {
53
- t2 = menu.length > 0 ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [/* @__PURE__ */ jsx(IconButton, {
54
- icon: Ellipsis,
55
- size: "sm",
56
- label: intl.formatMessage(messages.itemActions, { item: itemLabel }),
57
- isPending: pending !== null && menu.some((t3) => {
58
- const { action: action_0 } = t3;
59
- return action_0.id === pending;
60
- })
61
- }), /* @__PURE__ */ jsx(Menu, {
62
- placement: "bottom end",
63
- onAction: (key) => {
64
- const entry = menu.find((t4) => {
65
- const { action: action_1 } = t4;
66
- return action_1.id === key;
67
- });
68
- if (entry !== void 0 && entry.href === null) onRun(entry.action);
69
- },
70
- children: menu.map((t5) => {
71
- const { action: action_2, href: href_0 } = t5;
72
- const icon = getActionIcon(action_2, icons);
73
- return /* @__PURE__ */ jsx(MenuItem, {
74
- id: action_2.id,
75
- isDanger: action_2.destructive === true,
76
- ...icon !== void 0 ? { icon } : {},
77
- ...href_0 !== null ? { href: href_0 } : {},
78
- children: getActionLabel(action_2, intl)
79
- }, action_2.id);
80
- })
81
- })] }) : null;
82
- $[13] = icons;
83
- $[14] = intl;
84
- $[15] = itemLabel;
85
- $[16] = menu;
86
- $[17] = onRun;
87
- $[18] = pending;
88
- $[19] = t2;
89
- } else t2 = $[19];
90
- let t3;
91
- if ($[20] !== t1 || $[21] !== t2) {
92
- t3 = /* @__PURE__ */ jsxs("div", {
93
- className: Actions_module_default.row,
94
- children: [t1, t2]
95
- });
96
- $[20] = t1;
97
- $[21] = t2;
98
- $[22] = t3;
99
- } else t3 = $[22];
100
- return t3;
149
+ $[4] = level;
150
+ $[5] = menu;
151
+ $[6] = onRun;
152
+ $[7] = pending;
153
+ $[8] = primary;
154
+ $[9] = slots;
155
+ $[10] = t2;
156
+ } else t2 = $[10];
157
+ return t2;
158
+ }
159
+ function _temp(key, content) {
160
+ return /* @__PURE__ */ jsx("span", {
161
+ className: Actions_module_default.placeholder,
162
+ "aria-hidden": "true",
163
+ inert: true,
164
+ children: content
165
+ }, key);
101
166
  }
102
167
  //#endregion
103
- export { RowActions };
168
+ export { RowActions, orderRowActions };
104
169
 
105
170
  //# sourceMappingURL=RowActions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RowActions.js","names":["Ellipsis","ItemAction","getActionLabel","Action","IconButton","Menu","MenuItem","MenuTrigger","usePanneauIntl","messages","ActionButton","styles","ActionIcons","getActionIcon","RowActionsProps","itemLabel","actions","menu","pending","onRun","action","icons","RowActions","t0","$","_c","intl","t1","t2","t3","href","id","formatMessage","actionOnItem","item","map","length","itemActions","some","action_0","key","entry","find","t4","action_1","undefined","t5","action_2","href_0","icon","destructive","row","_c","styles"],"sources":["../../src/actions/RowActions.tsx"],"sourcesContent":["import { Ellipsis } from 'lucide-react';\n\nimport type { ItemAction } from '@panneau/core';\nimport { getActionLabel } from '@panneau/intl';\nimport type { Action } from '@panneau/protocol';\nimport { IconButton, Menu, MenuItem, MenuTrigger, usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from '../messages';\nimport { ActionButton } from './ActionButton';\nimport styles from './Actions.module.css';\nimport { type ActionIcons, getActionIcon } from './icons';\n\nexport interface RowActionsProps {\n /** The label of the item, for the accessible names of its actions. */\n itemLabel: string;\n /** Actions shown as buttons, with their links (`getItemActions()` of `@panneau/core`). */\n actions: readonly ItemAction[];\n /** Actions in the overflow menu. */\n menu: readonly ItemAction[];\n /** Id of the action that is running on this item, if any. */\n pending: string | null;\n onRun: (action: Action) => void;\n /** Icons of actions by id, over the icon the action names. */\n icons?: ActionIcons | undefined;\n}\n\n/** The actions of a row: buttons, then an overflow menu. */\nexport function RowActions({ itemLabel, actions, menu, pending, onRun, icons }: RowActionsProps) {\n const intl = usePanneauIntl();\n return (\n <div className={styles.row}>\n {actions.map(({ action, href }) => (\n <ActionButton\n key={action.id}\n action={action}\n icons={icons}\n href={href}\n isPending={pending === action.id}\n isDisabled={pending !== null && pending !== action.id}\n aria-label={intl.formatMessage(messages.actionOnItem, {\n action: getActionLabel(action, intl),\n item: itemLabel,\n })}\n onPress={() => onRun(action)}\n />\n ))}\n {menu.length > 0 ? (\n <MenuTrigger>\n <IconButton\n icon={Ellipsis}\n size=\"sm\"\n label={intl.formatMessage(messages.itemActions, { item: itemLabel })}\n isPending={\n pending !== null && menu.some(({ action }) => action.id === pending)\n }\n />\n <Menu\n placement=\"bottom end\"\n onAction={(key) => {\n const entry = menu.find(({ action }) => action.id === key);\n if (entry !== undefined && entry.href === null) {\n onRun(entry.action);\n }\n }}\n >\n {menu.map(({ action, href }) => {\n const icon = getActionIcon(action, icons);\n return (\n <MenuItem\n key={action.id}\n id={action.id}\n isDanger={action.destructive === true}\n {...(icon !== undefined ? { icon } : {})}\n {...(href !== null ? { href } : {})}\n >\n {getActionLabel(action, intl)}\n </MenuItem>\n );\n })}\n </Menu>\n </MenuTrigger>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AA2BA,SAAOsB,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAoB,MAAA,EAAAV,WAAAC,SAAAC,MAAAC,SAAAC,OAAAE,UAAAE;CACvB,MAAAG,OAAalB,eAAe;CAAE,IAAAmB;CAAA,IAAAH,EAAA,OAAAR,WAAAQ,EAAA,OAAAH,SAAAG,EAAA,OAAAE,QAAAF,EAAA,OAAAT,aAAAS,EAAA,OAAAL,SAAAK,EAAA,OAAAN,SAAA;EAAA,IAAAU;EAAA,IAAAJ,EAAA,OAAAH,SAAAG,EAAA,OAAAE,QAAAF,EAAA,OAAAT,aAAAS,EAAA,QAAAL,SAAAK,EAAA,QAAAN,SAAA;GAGTU,MAAAC,OAAA;IAAC,MAAA,EAAAT,QAAAU,SAAAD;IAAgB,OAC1B,oBAAC,cAAD;KAEYT;KACDC;KACDS;KACK,WAAAZ,YAAYE,OAAMW;KACjB,YAAAb,YAAY,QAAQA,YAAYE,OAAMW;KACtC,cAAAL,KAAIM,cAAevB,SAAQwB,cAAe;MAAAb,QAC1ClB,eAAekB,QAAQM,IAAI;MAACQ,MAC9BnB;KACV,CAAC;KACQ,eAAMI,MAAMC,MAAM;IAAC,GAVvBA,OA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AAC,UAAD;KAEQ,IAAAD,SAAMW;KACA,UAAAX,SAAM8B,gBAAiB;KAAI,GAChCD,SAASJ,KAAAA,IAAT,EAAAI,KAAiC,IAAjC,CAAiC;KAAC,GAClCnB,WAAS,OAAT,EAAAA,MAAkBA,OAAU,IAA5B,CAA4B;KAEhC5B,UAAAA,eAAekB,UAAQM,IAAI;IAPvB,GACAN,SAAMW,EADN;GAQE,CAElB;EAtBA,CAAA,CATG,EAAA,CAAA,IADf;EAmCOP,EAAA,MAAAH;EAAAG,EAAA,MAAAE;EAAAF,EAAA,MAAAT;EAAAS,EAAA,MAAAP;EAAAO,EAAA,MAAAL;EAAAK,EAAA,MAAAN;EAAAM,EAAA,MAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,QAAAG,MAAAH,EAAA,QAAAI,IAAA;EAnDZC,KAAA,qBAAA,OAAA;GAAgB,WAAAlB,uBAAMwC;GAAtB,UAAA,CACKxB,IAeAC,EAoCC;;EAAAJ,EAAA,MAAAG;EAAAH,EAAA,MAAAI;EAAAJ,EAAA,MAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OApDNK;AAoDM"}
1
+ {"version":3,"file":"RowActions.js","names":["Ellipsis","ReactNode","use","ItemAction","getActionLabel","Action","IconButton","Menu","MenuItem","MenuTrigger","usePanneauIntl","messages","ActionButton","styles","RowActionsFit","ActionIcons","getActionIcon","RowActionsProps","itemLabel","actions","menu","pending","onRun","action","icons","slots","primary","orderRowActions","all","filter","entry","index","list","findIndex","other","id","destructive","RowActions","t0","$","_c","t1","undefined","intl","level","t2","own","t3","t4","some","slot","find","slot_0","action_0","inMenu","length","Math","min","shown","slice","overflow","flatMap","slot_1","t5","action_1","formatMessage","actionOnItem","item","name","t6","href","button","placeholder","_temp","t7","itemActions","t8","t9","t10","action_2","t11","menuButton","row","map","slot_2","entry_0","key_0","entry_1","t12","action_3","key","t13","action_4","icon","content","_c","styles"],"sources":["../../src/actions/RowActions.tsx"],"sourcesContent":["import { Ellipsis } from 'lucide-react';\nimport { type ReactNode, use } from 'react';\n\nimport type { ItemAction } from '@panneau/core';\nimport { getActionLabel } from '@panneau/intl';\nimport type { Action } from '@panneau/protocol';\nimport { IconButton, Menu, MenuItem, MenuTrigger, usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from '../messages';\nimport { ActionButton } from './ActionButton';\nimport styles from './Actions.module.css';\nimport { RowActionsFit } from './fit';\nimport { type ActionIcons, getActionIcon } from './icons';\n\nexport interface RowActionsProps {\n /** The label of the item, for the accessible names of its actions. */\n itemLabel: string;\n /** Actions placed in `row`, with their links (`selectItemActions()` of `@panneau/core`). */\n actions: readonly ItemAction[];\n /** Actions placed in `menu`: icons too while they fit, the first to go in the menu. */\n menu: readonly ItemAction[];\n /** Id of the action that is running on this item, if any. */\n pending: string | null;\n onRun: (action: Action) => void;\n /** Icons of actions by id, over the icon the action names. */\n icons?: ActionIcons | undefined;\n /**\n * The actions of every row of the list, in order (`orderRowActions()`): a row keeps the place\n * of those it doesn't have, so the actions of the rows line up. Without it, its own.\n */\n slots?: readonly ItemAction[] | undefined;\n /** The id of the main action of rows, which keeps its label (`show` or `edit`). */\n primary?: string | null | undefined;\n}\n\n/**\n * The actions of a row in their order: those placed in `row`, then those placed in `menu`, and\n * those that destroy last. The last ones are the first to go in the menu.\n */\nexport function orderRowActions(\n actions: readonly ItemAction[],\n menu: readonly ItemAction[],\n): ItemAction[] {\n const all = [...actions, ...menu].filter(\n (entry, index, list) =>\n list.findIndex((other) => other.action.id === entry.action.id) === index,\n );\n return [\n ...all.filter(({ action }) => action.destructive !== true),\n ...all.filter(({ action }) => action.destructive === true),\n ];\n}\n\n/**\n * The actions of a row (decision 0060): their icons, in their colors, with their labels as names\n * and tooltips, but the main action, which keeps its label while the row has room; and when the\n * icons don't fit, the last ones in an overflow menu, which never holds a single action. How they fit is the same for every row of the list (`RowActionsFit`), and a\n * row keeps the place of the actions of other rows that it doesn't have, so they line up.\n */\nexport function RowActions({\n itemLabel,\n actions,\n menu,\n pending,\n onRun,\n icons,\n slots,\n primary = null,\n}: RowActionsProps) {\n const intl = usePanneauIntl();\n const level = use(RowActionsFit);\n const own = orderRowActions(actions, menu);\n const all = [\n ...(slots ?? []),\n ...own.filter(({ action }) => slots?.some((slot) => slot.action.id === action.id) !== true),\n ];\n const find = (slot: ItemAction) => own.find(({ action }) => action.id === slot.action.id);\n const inMenu = level >= 2 && all.length >= 2 ? Math.min(level, all.length) : 0;\n const shown = all.slice(0, all.length - inMenu);\n const overflow = all.slice(all.length - inMenu).flatMap((slot) => find(slot) ?? []);\n const name = (action: Action) =>\n intl.formatMessage(messages.actionOnItem, {\n action: getActionLabel(action, intl),\n item: itemLabel,\n });\n const button = (entry: ItemAction) => (\n <ActionButton\n key={entry.action.id}\n action={entry.action}\n icons={icons}\n href={entry.href}\n iconOnly={level >= 1 || entry.action.id !== primary}\n isPending={pending === entry.action.id}\n isDisabled={pending !== null && pending !== entry.action.id}\n aria-label={name(entry.action)}\n onPress={() => onRun(entry.action)}\n />\n );\n // The place of an action of other rows: the same button, unseen and out of reach\n const placeholder = (key: string, content: ReactNode) => (\n <span key={key} className={styles.placeholder} aria-hidden=\"true\" inert>\n {content}\n </span>\n );\n const menuButton = (\n <IconButton\n icon={Ellipsis}\n size=\"sm\"\n appearance=\"subtle\"\n label={intl.formatMessage(messages.itemActions, { item: itemLabel })}\n showTooltip={overflow.length >= 2}\n isPending={pending !== null && overflow.some(({ action }) => action.id === pending)}\n />\n );\n return (\n <div className={styles.row} data-row-actions={all.length}>\n {shown.map((slot) => {\n const entry = find(slot);\n return entry !== undefined\n ? button(entry)\n : placeholder(slot.action.id, button({ ...slot, href: null }));\n })}\n {overflow.length >= 2 ? (\n <MenuTrigger>\n {menuButton}\n <Menu\n placement=\"bottom end\"\n onAction={(key) => {\n const entry = overflow.find(({ action }) => action.id === key);\n if (entry !== undefined && entry.href === null) {\n onRun(entry.action);\n }\n }}\n >\n {overflow.map(({ action, href }) => {\n const icon = getActionIcon(action, icons);\n return (\n <MenuItem\n key={action.id}\n id={action.id}\n isDanger={action.destructive === true}\n {...(icon !== undefined ? { icon } : {})}\n {...(href !== null ? { href } : {})}\n >\n {getActionLabel(action, intl)}\n </MenuItem>\n );\n })}\n </Menu>\n </MenuTrigger>\n ) : overflow.length === 1 && overflow[0] !== undefined ? (\n // A single action is no menu: its button, in the menu's place\n button(overflow[0])\n ) : inMenu > 0 ? (\n placeholder('menu', menuButton)\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,SAAgB2B,gBACZR,SACAC,MACY;CACZ,MAAMQ,MAAM,CAAC,GAAGT,SAAS,GAAGC,IAAI,CAAC,CAACS,QAC7BC,OAAOC,OAAOC,SACXA,KAAKC,WAAWC,UAAUA,MAAMX,OAAOY,OAAOL,MAAMP,OAAOY,EAAE,MAAMJ,KAC3E;CACA,OAAO,CACH,GAAGH,IAAIC,QAAQ,EAAEN,aAAaA,OAAOa,gBAAgB,IAAI,GACzD,GAAGR,IAAIC,QAAQ,EAAEN,aAAaA,OAAOa,gBAAgB,IAAI,CAAC;AAElE;;;;;;;AAQA,SAAOC,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAoB,MAAA,EAAAtB,WAAAC,SAAAC,MAAAC,SAAAC,OAAAE,OAAAC,OAAAC,SAAAe,OAAAH;CAQvB,MAAAZ,UAAAe,OAAAC,KAAAA,IAAA,OAAAD;CAEA,MAAAE,OAAajC,eAAe;CAC5B,MAAAkC,QAAc1C,IAAIY,aAAa;CAAE,IAAA+B;CAAA,IAAAN,EAAA,OAAApB,WAAAoB,EAAA,OAAAf,SAAAe,EAAA,OAAAI,QAAAJ,EAAA,OAAArB,aAAAqB,EAAA,OAAAK,SAAAL,EAAA,OAAAnB,QAAAmB,EAAA,OAAAjB,SAAAiB,EAAA,OAAAlB,WAAAkB,EAAA,OAAAb,WAAAa,EAAA,OAAAd,OAAA;EACjC,MAAAqB,M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FHN,SAAS,IACTkB,YAAY,QAAQS,UACjB,IAFH,IAGF;;EAAA1C,EAAA,KAAApB;EAAAoB,EAAA,KAAAf;EAAAe,EAAA,KAAAI;EAAAJ,EAAA,KAAArB;EAAAqB,EAAA,KAAAK;EAAAL,EAAA,KAAAnB;EAAAmB,EAAA,KAAAjB;EAAAiB,EAAA,KAAAlB;EAAAkB,EAAA,KAAAb;EAAAa,EAAA,KAAAd;EAAAc,EAAA,MAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,OAzCNM;AAyCM;AAjGP,SAAA4B,MAAAiB,KAAAI,SAAA;CAAA,OAyCC,oBAAA,QAAA;EAA2B,WAAAjF,uBAAM2D;EAA0B,eAAA;EAAO,OAAA;EAC7DsB,UAAAA;CACE,GAFIJ,GAEJ;AAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * How the actions of rows fit (decision 0060), the same for every row of a list: `0`, every
3
+ * action as an icon but the main one, with its label; `1`, every action as an icon; `n` from 2,
4
+ * the last `n` actions of each row in its menu.
5
+ */
6
+ export declare const RowActionsFit: import("react").Context<number>;
7
+ /** What the fit of a list depends on, besides its width: its items and its columns. */
8
+ export declare function fitContent(items: readonly {
9
+ id: string;
10
+ }[], columns: readonly {
11
+ id: string;
12
+ }[]): string;
13
+ /**
14
+ * Fits the actions of the rows of a list in the room they have (decision 0060). It draws each
15
+ * level in turn, from every action as an icon but the main one, labelled, then the main one as an
16
+ * icon too, then a menu of two actions, three…, while the next one may help, and keeps the best:
17
+ * where the actions crowd least (the list overflows, the actions of a row wrap or take more than
18
+ * 40% of it), then, on rows of five actions or more, where the rows are shortest (their content
19
+ * wraps or is cut less), then the fewest actions in the menu.
20
+ *
21
+ * @returns the level, and a callback ref for the element to measure: the list, which holds the
22
+ * actions.
23
+ */
24
+ export declare function useRowActionsFit(content: string): [level: number, measure: (element: HTMLElement | null) => void];
25
+ //# sourceMappingURL=fit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fit.d.ts","sourceRoot":"","sources":["../../src/actions/fit.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,aAAa,iCAAmB,CAAC;AAE9C,uFAAuF;AACvF,wBAAgB,UAAU,CACtB,KAAK,EAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,EAChC,OAAO,EAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,GACnC,MAAM,CAER;AAgKD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,EAAE,MAAM,GAChB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC,CA8BjE"}