@deephaven/components 0.22.3-deep-bot-test.14 → 0.23.0

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 (220) hide show
  1. package/dist/AutoCompleteInput.js +12 -85
  2. package/dist/AutoCompleteInput.js.map +1 -1
  3. package/dist/AutoResizeTextarea.d.ts +5 -5
  4. package/dist/AutoResizeTextarea.d.ts.map +1 -1
  5. package/dist/AutoResizeTextarea.js +8 -23
  6. package/dist/AutoResizeTextarea.js.map +1 -1
  7. package/dist/BasicModal.d.ts +28 -1
  8. package/dist/BasicModal.d.ts.map +1 -1
  9. package/dist/BasicModal.js +2 -8
  10. package/dist/BasicModal.js.map +1 -1
  11. package/dist/Button.d.ts +9 -9
  12. package/dist/Button.d.ts.map +1 -1
  13. package/dist/Button.js +8 -34
  14. package/dist/Button.js.map +1 -1
  15. package/dist/ButtonGroup.d.ts +7 -7
  16. package/dist/ButtonGroup.d.ts.map +1 -1
  17. package/dist/ButtonGroup.js +2 -4
  18. package/dist/ButtonGroup.js.map +1 -1
  19. package/dist/ButtonOld.js.map +1 -1
  20. package/dist/CardFlip.d.ts +2 -2
  21. package/dist/CardFlip.d.ts.map +1 -1
  22. package/dist/CardFlip.js +2 -7
  23. package/dist/CardFlip.js.map +1 -1
  24. package/dist/Checkbox.js +3 -14
  25. package/dist/Checkbox.js.map +1 -1
  26. package/dist/Collapse.d.ts +1 -1
  27. package/dist/Collapse.js +0 -15
  28. package/dist/Collapse.js.map +1 -1
  29. package/dist/ComboBox.js +4 -83
  30. package/dist/ComboBox.js.map +1 -1
  31. package/dist/CopyButton.d.ts +2 -2
  32. package/dist/CopyButton.d.ts.map +1 -1
  33. package/dist/CopyButton.js +2 -4
  34. package/dist/CopyButton.js.map +1 -1
  35. package/dist/CustomTimeSelect.d.ts +3 -3
  36. package/dist/CustomTimeSelect.d.ts.map +1 -1
  37. package/dist/CustomTimeSelect.js +2 -86
  38. package/dist/CustomTimeSelect.js.map +1 -1
  39. package/dist/DateInput.d.ts +1 -1
  40. package/dist/DateInput.d.ts.map +1 -1
  41. package/dist/DateInput.js.map +1 -1
  42. package/dist/DateInputUtils.js +0 -7
  43. package/dist/DateInputUtils.js.map +1 -1
  44. package/dist/DateTimeInput.d.ts +1 -1
  45. package/dist/DateTimeInput.d.ts.map +1 -1
  46. package/dist/DateTimeInput.js +7 -10
  47. package/dist/DateTimeInput.js.map +1 -1
  48. package/dist/DebouncedSearchInput.js +0 -14
  49. package/dist/DebouncedSearchInput.js.map +1 -1
  50. package/dist/DragUtils.d.ts +1 -1
  51. package/dist/DragUtils.d.ts.map +1 -1
  52. package/dist/DragUtils.js +4 -16
  53. package/dist/DragUtils.js.map +1 -1
  54. package/dist/DraggableItemList.d.ts +4 -4
  55. package/dist/DraggableItemList.d.ts.map +1 -1
  56. package/dist/DraggableItemList.js +22 -44
  57. package/dist/DraggableItemList.js.map +1 -1
  58. package/dist/EditableItemList.d.ts +1 -1
  59. package/dist/EditableItemList.d.ts.map +1 -1
  60. package/dist/EditableItemList.js +2 -6
  61. package/dist/EditableItemList.js.map +1 -1
  62. package/dist/HierarchicalCheckboxMenu.d.ts +3 -3
  63. package/dist/HierarchicalCheckboxMenu.d.ts.map +1 -1
  64. package/dist/HierarchicalCheckboxMenu.js +6 -28
  65. package/dist/HierarchicalCheckboxMenu.js.map +1 -1
  66. package/dist/ItemList.d.ts +5 -5
  67. package/dist/ItemList.d.ts.map +1 -1
  68. package/dist/ItemList.js +22 -115
  69. package/dist/ItemList.js.map +1 -1
  70. package/dist/ItemListItem.d.ts +0 -1
  71. package/dist/ItemListItem.d.ts.map +1 -1
  72. package/dist/ItemListItem.js +26 -50
  73. package/dist/ItemListItem.js.map +1 -1
  74. package/dist/LoadingOverlay.d.ts +2 -2
  75. package/dist/LoadingOverlay.d.ts.map +1 -1
  76. package/dist/LoadingOverlay.js +3 -5
  77. package/dist/LoadingOverlay.js.map +1 -1
  78. package/dist/LoadingSpinner.d.ts +2 -2
  79. package/dist/LoadingSpinner.d.ts.map +1 -1
  80. package/dist/LoadingSpinner.js +2 -4
  81. package/dist/LoadingSpinner.js.map +1 -1
  82. package/dist/MaskedInput.d.ts +2 -2
  83. package/dist/MaskedInput.d.ts.map +1 -1
  84. package/dist/MaskedInput.js +26 -85
  85. package/dist/MaskedInput.js.map +1 -1
  86. package/dist/Option.d.ts +2 -2
  87. package/dist/Option.d.ts.map +1 -1
  88. package/dist/Option.js +2 -4
  89. package/dist/Option.js.map +1 -1
  90. package/dist/RadioGroup.d.ts +2 -2
  91. package/dist/RadioGroup.d.ts.map +1 -1
  92. package/dist/RadioGroup.js +4 -6
  93. package/dist/RadioGroup.js.map +1 -1
  94. package/dist/RadioItem.d.ts +1 -1
  95. package/dist/RadioItem.d.ts.map +1 -1
  96. package/dist/RadioItem.js +0 -1
  97. package/dist/RadioItem.js.map +1 -1
  98. package/dist/SearchInput.js +2 -13
  99. package/dist/SearchInput.js.map +1 -1
  100. package/dist/Select.d.ts +2 -2
  101. package/dist/Select.d.ts.map +1 -1
  102. package/dist/Select.js +2 -4
  103. package/dist/Select.js.map +1 -1
  104. package/dist/SelectValueList.d.ts +1 -1
  105. package/dist/SelectValueList.d.ts.map +1 -1
  106. package/dist/SelectValueList.js +0 -28
  107. package/dist/SelectValueList.js.map +1 -1
  108. package/dist/SocketedButton.d.ts +1 -1
  109. package/dist/SocketedButton.d.ts.map +1 -1
  110. package/dist/SocketedButton.js.map +1 -1
  111. package/dist/ThemeExport.d.ts +4 -4
  112. package/dist/ThemeExport.js +0 -4
  113. package/dist/ThemeExport.js.map +1 -1
  114. package/dist/TimeInput.d.ts +2 -2
  115. package/dist/TimeInput.d.ts.map +1 -1
  116. package/dist/TimeInput.js +2 -12
  117. package/dist/TimeInput.js.map +1 -1
  118. package/dist/TimeSlider.d.ts +2 -2
  119. package/dist/TimeSlider.d.ts.map +1 -1
  120. package/dist/TimeSlider.js +19 -33
  121. package/dist/TimeSlider.js.map +1 -1
  122. package/dist/ToastNotification.d.ts +6 -6
  123. package/dist/ToastNotification.d.ts.map +1 -1
  124. package/dist/ToastNotification.js +2 -4
  125. package/dist/ToastNotification.js.map +1 -1
  126. package/dist/UISwitch.d.ts +2 -2
  127. package/dist/UISwitch.d.ts.map +1 -1
  128. package/dist/UISwitch.js +2 -4
  129. package/dist/UISwitch.js.map +1 -1
  130. package/dist/ValidateLabelInput.d.ts +1 -1
  131. package/dist/ValidateLabelInput.d.ts.map +1 -1
  132. package/dist/ValidateLabelInput.js +3 -3
  133. package/dist/ValidateLabelInput.js.map +1 -1
  134. package/dist/context-actions/ContextActionUtils.d.ts +3 -3
  135. package/dist/context-actions/ContextActionUtils.d.ts.map +1 -1
  136. package/dist/context-actions/ContextActionUtils.js +9 -40
  137. package/dist/context-actions/ContextActionUtils.js.map +1 -1
  138. package/dist/context-actions/ContextActions.js +1 -34
  139. package/dist/context-actions/ContextActions.js.map +1 -1
  140. package/dist/context-actions/ContextMenu.js +29 -110
  141. package/dist/context-actions/ContextMenu.js.map +1 -1
  142. package/dist/context-actions/ContextMenuItem.d.ts.map +1 -1
  143. package/dist/context-actions/ContextMenuItem.js +3 -19
  144. package/dist/context-actions/ContextMenuItem.js.map +1 -1
  145. package/dist/context-actions/ContextMenuRoot.d.ts +1 -1
  146. package/dist/context-actions/ContextMenuRoot.d.ts.map +1 -1
  147. package/dist/context-actions/ContextMenuRoot.js +7 -26
  148. package/dist/context-actions/ContextMenuRoot.js.map +1 -1
  149. package/dist/context-actions/GlobalContextAction.js +0 -15
  150. package/dist/context-actions/GlobalContextAction.js.map +1 -1
  151. package/dist/context-actions/GlobalContextActions.js +0 -6
  152. package/dist/context-actions/GlobalContextActions.js.map +1 -1
  153. package/dist/context-actions/index.js.map +1 -1
  154. package/dist/index.js.map +1 -1
  155. package/dist/menu-actions/DropdownMenu.d.ts +3 -3
  156. package/dist/menu-actions/DropdownMenu.d.ts.map +1 -1
  157. package/dist/menu-actions/DropdownMenu.js +4 -32
  158. package/dist/menu-actions/DropdownMenu.js.map +1 -1
  159. package/dist/menu-actions/Menu.d.ts +3 -3
  160. package/dist/menu-actions/Menu.d.ts.map +1 -1
  161. package/dist/menu-actions/Menu.js +7 -52
  162. package/dist/menu-actions/Menu.js.map +1 -1
  163. package/dist/menu-actions/index.d.ts +2 -1
  164. package/dist/menu-actions/index.d.ts.map +1 -1
  165. package/dist/menu-actions/index.js +2 -2
  166. package/dist/menu-actions/index.js.map +1 -1
  167. package/dist/modal/Modal.d.ts +2 -2
  168. package/dist/modal/Modal.d.ts.map +1 -1
  169. package/dist/modal/Modal.js +3 -9
  170. package/dist/modal/Modal.js.map +1 -1
  171. package/dist/modal/ModalBody.d.ts +1 -1
  172. package/dist/modal/ModalBody.d.ts.map +1 -1
  173. package/dist/modal/ModalBody.js +2 -4
  174. package/dist/modal/ModalBody.js.map +1 -1
  175. package/dist/modal/ModalFooter.d.ts +1 -1
  176. package/dist/modal/ModalFooter.d.ts.map +1 -1
  177. package/dist/modal/ModalFooter.js +2 -4
  178. package/dist/modal/ModalFooter.js.map +1 -1
  179. package/dist/modal/ModalHeader.d.ts +1 -1
  180. package/dist/modal/ModalHeader.d.ts.map +1 -1
  181. package/dist/modal/ModalHeader.js +2 -4
  182. package/dist/modal/ModalHeader.js.map +1 -1
  183. package/dist/modal/index.js.map +1 -1
  184. package/dist/navigation/Menu.d.ts +3 -3
  185. package/dist/navigation/Menu.d.ts.map +1 -1
  186. package/dist/navigation/Menu.js +2 -2
  187. package/dist/navigation/Menu.js.map +1 -1
  188. package/dist/navigation/MenuItem.d.ts +4 -4
  189. package/dist/navigation/MenuItem.d.ts.map +1 -1
  190. package/dist/navigation/MenuItem.js +4 -7
  191. package/dist/navigation/MenuItem.js.map +1 -1
  192. package/dist/navigation/Page.d.ts +2 -2
  193. package/dist/navigation/Page.d.ts.map +1 -1
  194. package/dist/navigation/Page.js +2 -3
  195. package/dist/navigation/Page.js.map +1 -1
  196. package/dist/navigation/Stack.d.ts +2 -2
  197. package/dist/navigation/Stack.d.ts.map +1 -1
  198. package/dist/navigation/Stack.js +3 -6
  199. package/dist/navigation/Stack.js.map +1 -1
  200. package/dist/navigation/index.js.map +1 -1
  201. package/dist/popper/Popper.d.ts +2 -2
  202. package/dist/popper/Popper.d.ts.map +1 -1
  203. package/dist/popper/Popper.js +13 -46
  204. package/dist/popper/Popper.js.map +1 -1
  205. package/dist/popper/Tooltip.d.ts +1 -1
  206. package/dist/popper/Tooltip.d.ts.map +1 -1
  207. package/dist/popper/Tooltip.js +0 -56
  208. package/dist/popper/Tooltip.js.map +1 -1
  209. package/dist/popper/index.js.map +1 -1
  210. package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
  211. package/dist/shortcuts/Shortcut.d.ts +2 -2
  212. package/dist/shortcuts/Shortcut.d.ts.map +1 -1
  213. package/dist/shortcuts/Shortcut.js +19 -76
  214. package/dist/shortcuts/Shortcut.js.map +1 -1
  215. package/dist/shortcuts/ShortcutRegistry.d.ts +1 -1
  216. package/dist/shortcuts/ShortcutRegistry.d.ts.map +1 -1
  217. package/dist/shortcuts/ShortcutRegistry.js +3 -18
  218. package/dist/shortcuts/ShortcutRegistry.js.map +1 -1
  219. package/dist/shortcuts/index.js.map +1 -1
  220. package/package.json +8 -8
@@ -2,7 +2,6 @@ import React, { useRef } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import shortid from 'shortid';
4
4
  import "./ValidateLabelInput.css";
5
-
6
5
  /**
7
6
  * Takes a child and add a label and validaton error
8
7
  */
@@ -29,12 +28,13 @@ export function ValidateLabelInput(props) {
29
28
  "data-testid": dataTestId
30
29
  }, labelText), React.Children.toArray(children).map(child => {
31
30
  if (! /*#__PURE__*/React.isValidElement(child)) {
31
+ // eslint-disable-next-line react/jsx-key
32
32
  return /*#__PURE__*/React.createElement("div", {
33
33
  className: classNames(className)
34
34
  }, child);
35
- } // toArray strips null children
36
-
35
+ }
37
36
 
37
+ // toArray strips null children
38
38
  return /*#__PURE__*/React.cloneElement(child, {
39
39
  className: classNames(child.props.className, {
40
40
  'is-invalid': validationError
@@ -1 +1 @@
1
- {"version":3,"file":"ValidateLabelInput.js","names":["React","useRef","classNames","shortid","ValidateLabelInput","props","children","className","labelText","hintText","isModified","validationError","showValidationError","dataTestId","id","idProp","current","modified","Children","toArray","map","child","isValidElement","cloneElement","undefined"],"sources":["../src/ValidateLabelInput.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport classNames from 'classnames';\nimport shortid from 'shortid';\nimport './ValidateLabelInput.scss';\n\nexport type ValidateLabelInputProps = {\n /** Element to add label to */\n children: React.ReactNode;\n\n /** Any classnames to add */\n className?: string | string[];\n\n /** Text for this validation label */\n labelText?: string;\n\n /** Small hint text next to the main label */\n hintText?: string;\n\n /** Show a modified state. Defaults to false. */\n isModified?: boolean;\n\n /** Validation error that has occurred */\n validationError?: string;\n\n /** Show the validation error if it exists. Default to true. */\n showValidationError?: boolean;\n\n /** ID to use. Auto-generates if not provided */\n id?: string;\n\n /** data-testid to apply to the label */\n 'data-testid'?: string;\n};\n\n/**\n * Takes a child and add a label and validaton error\n */\nexport function ValidateLabelInput(\n props: ValidateLabelInputProps\n): React.ReactElement {\n const {\n children,\n className,\n labelText,\n hintText,\n isModified,\n validationError,\n showValidationError = true,\n 'data-testid': dataTestId,\n id: idProp,\n } = props;\n\n const { current: id } = useRef(idProp ?? shortid());\n\n return (\n <>\n <label\n className={classNames('validate-label', className, {\n modified: isModified,\n })}\n htmlFor={id}\n data-testid={dataTestId}\n >\n {labelText}\n </label>\n {React.Children.toArray(children).map(child => {\n if (!React.isValidElement(child)) {\n return <div className={classNames(className)}>{child}</div>;\n }\n\n // toArray strips null children\n return React.cloneElement(child, {\n className: classNames(child.props.className, {\n 'is-invalid': validationError,\n }),\n });\n })}\n {hintText !== undefined && (\n <small className=\"form-text text-muted\">{hintText}</small>\n )}\n {validationError !== undefined && showValidationError && (\n <p className=\"validate-label-error text-danger\">{validationError}</p>\n )}\n </>\n );\n}\n\nexport default ValidateLabelInput;\n"],"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AAjC,iBACC;IAAG,SAAS,EAAC;EAAb,GAAiDD,eAAjD,CA1BJ,CADF;AA+BD;AAED,eAAeP,kBAAf"}
1
+ {"version":3,"file":"ValidateLabelInput.js","names":["React","useRef","classNames","shortid","ValidateLabelInput","props","children","className","labelText","hintText","isModified","validationError","showValidationError","dataTestId","id","idProp","current","modified","Children","toArray","map","child","isValidElement","cloneElement","undefined"],"sources":["../src/ValidateLabelInput.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport classNames from 'classnames';\nimport shortid from 'shortid';\nimport './ValidateLabelInput.scss';\n\nexport type ValidateLabelInputProps = {\n /** Element to add label to */\n children: React.ReactNode;\n\n /** Any classnames to add */\n className?: string | string[];\n\n /** Text for this validation label */\n labelText?: string;\n\n /** Small hint text next to the main label */\n hintText?: string;\n\n /** Show a modified state. Defaults to false. */\n isModified?: boolean;\n\n /** Validation error that has occurred */\n validationError?: string;\n\n /** Show the validation error if it exists. Default to true. */\n showValidationError?: boolean;\n\n /** ID to use. Auto-generates if not provided */\n id?: string;\n\n /** data-testid to apply to the label */\n 'data-testid'?: string;\n};\n\n/**\n * Takes a child and add a label and validaton error\n */\nexport function ValidateLabelInput(\n props: ValidateLabelInputProps\n): React.ReactElement {\n const {\n children,\n className,\n labelText,\n hintText,\n isModified,\n validationError,\n showValidationError = true,\n 'data-testid': dataTestId,\n id: idProp,\n } = props;\n\n const { current: id } = useRef(idProp ?? shortid());\n\n return (\n <>\n <label\n className={classNames('validate-label', className, {\n modified: isModified,\n })}\n htmlFor={id}\n data-testid={dataTestId}\n >\n {labelText}\n </label>\n {React.Children.toArray(children).map(child => {\n if (!React.isValidElement<React.HTMLAttributes<HTMLElement>>(child)) {\n // eslint-disable-next-line react/jsx-key\n return <div className={classNames(className)}>{child}</div>;\n }\n\n // toArray strips null children\n return React.cloneElement(child, {\n className: classNames(child.props.className, {\n 'is-invalid': validationError,\n }),\n });\n })}\n {hintText !== undefined && (\n <small className=\"form-text text-muted\">{hintText}</small>\n )}\n {validationError !== undefined && showValidationError && (\n <p className=\"validate-label-error text-danger\">{validationError}</p>\n )}\n </>\n );\n}\n\nexport default ValidateLabelInput;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;AACrC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,OAAO,MAAM,SAAS;AAAC;AAgC9B;AACA;AACA;AACA,OAAO,SAASC,kBAAkB,CAChCC,KAA8B,EACV;EACpB,IAAM;IACJC,QAAQ;IACRC,SAAS;IACTC,SAAS;IACTC,QAAQ;IACRC,UAAU;IACVC,eAAe;IACfC,mBAAmB,GAAG,IAAI;IAC1B,aAAa,EAAEC,UAAU;IACzBC,EAAE,EAAEC;EACN,CAAC,GAAGV,KAAK;EAET,IAAM;IAAEW,OAAO,EAAEF;EAAG,CAAC,GAAGb,MAAM,CAACc,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIZ,OAAO,EAAE,CAAC;EAEnD,oBACE,uDACE;IACE,SAAS,EAAED,UAAU,CAAC,gBAAgB,EAAEK,SAAS,EAAE;MACjDU,QAAQ,EAAEP;IACZ,CAAC,CAAE;IACH,OAAO,EAAEI,EAAG;IACZ,eAAaD;EAAW,GAEvBL,SAAS,CACJ,EACPR,KAAK,CAACkB,QAAQ,CAACC,OAAO,CAACb,QAAQ,CAAC,CAACc,GAAG,CAACC,KAAK,IAAI;IAC7C,IAAI,eAACrB,KAAK,CAACsB,cAAc,CAAoCD,KAAK,CAAC,EAAE;MACnE;MACA,oBAAO;QAAK,SAAS,EAAEnB,UAAU,CAACK,SAAS;MAAE,GAAEc,KAAK,CAAO;IAC7D;;IAEA;IACA,oBAAOrB,KAAK,CAACuB,YAAY,CAACF,KAAK,EAAE;MAC/Bd,SAAS,EAAEL,UAAU,CAACmB,KAAK,CAAChB,KAAK,CAACE,SAAS,EAAE;QAC3C,YAAY,EAAEI;MAChB,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC,EACDF,QAAQ,KAAKe,SAAS,iBACrB;IAAO,SAAS,EAAC;EAAsB,GAAEf,QAAQ,CAClD,EACAE,eAAe,KAAKa,SAAS,IAAIZ,mBAAmB,iBACnD;IAAG,SAAS,EAAC;EAAkC,GAAED,eAAe,CACjE,CACA;AAEP;AAEA,eAAeP,kBAAkB"}
@@ -1,12 +1,12 @@
1
1
  import { IconDefinition } from '@deephaven/icons';
2
2
  import React from 'react';
3
3
  import type { Shortcut } from '../shortcuts';
4
- export declare type ResolvableContextAction = ContextAction | Promise<ContextAction[]> | (() => Promise<ContextAction[]> | ContextAction[] | ContextAction);
5
- export declare type MenuItem = ContextAction | Promise<ContextAction[]>;
4
+ export type ResolvableContextAction = ContextAction | Promise<ContextAction[]> | (() => Promise<ContextAction[]> | ContextAction[] | ContextAction);
5
+ export type MenuItem = ContextAction | Promise<ContextAction[]>;
6
6
  export interface ContextAction {
7
7
  title?: string;
8
8
  description?: string;
9
- action?(event?: KeyboardEvent): void;
9
+ action?(event?: Event): void;
10
10
  actions?: ResolvableContextAction[];
11
11
  icon?: IconDefinition | React.ReactElement;
12
12
  iconColor?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ContextActionUtils.d.ts","sourceRoot":"","sources":["../../src/context-actions/ContextActionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,oBAAY,uBAAuB,GAC/B,aAAa,GACb,OAAO,CAAC,aAAa,EAAE,CAAC,GACxB,CAAC,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,GAAG,aAAa,EAAE,GAAG,aAAa,CAAC,CAAC;AAEvE,oBAAY,QAAQ,GAAG,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;AAEhE,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,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CAAC,UAAU,GACzE,OAAO;IAKV;;;;OAIG;IACH,MAAM,CAAC,YAAY,CACjB,YAAY,EAAE,uBAAuB,GAAG,uBAAuB,EAAE,EACjE,eAAe,CAAC,EAAE,IAAI,GACrB,QAAQ,EAAE;IAGb,MAAM,CAAC,YAAY,CACjB,YAAY,EAAE,uBAAuB,GAAG,uBAAuB,EAAE,EACjE,eAAe,EAAE,KAAK,GACrB,aAAa,EAAE;IA+ClB;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CACpB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,EACb,SAAS,EAAE,QAAQ,EAAE,GACpB,MAAM;CAiBV;AAED,eAAe,kBAAkB,CAAC"}
@@ -1,123 +1,101 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
2
  export function isPromise(value) {
4
3
  return value.then !== undefined;
5
4
  }
6
-
7
5
  class ContextActionUtils {
8
6
  static disableAllActions() {
9
7
  ContextActionUtils.actionsDisabled = true;
10
8
  }
11
-
12
9
  static enableAllActions() {
13
10
  ContextActionUtils.actionsDisabled = false;
14
11
  }
15
-
16
12
  static isContextActionEvent(e) {
17
13
  return Array.isArray(e.contextActions);
18
14
  }
15
+
19
16
  /**
20
17
  * Compare two action items. Useful in Array.sort
21
18
  * @param a First context action to compare
22
19
  * @param b Second context action to compare
23
20
  */
24
-
25
-
26
21
  static compareActions(a, b) {
27
22
  if (a.group !== b.group) {
28
23
  var _a$group, _b$group;
29
-
30
24
  return ((_a$group = a.group) !== null && _a$group !== void 0 ? _a$group : 0) > ((_b$group = b.group) !== null && _b$group !== void 0 ? _b$group : 0) ? 1 : -1;
31
25
  }
32
-
33
26
  if (a.order !== b.order) {
34
27
  var _a$order, _b$order;
35
-
36
28
  return ((_a$order = a.order) !== null && _a$order !== void 0 ? _a$order : 0) > ((_b$order = b.order) !== null && _b$order !== void 0 ? _b$order : 0) ? 1 : -1;
37
29
  }
38
-
39
30
  if (a.title !== b.title) {
40
31
  var _a$title, _b$title;
41
-
42
32
  return ((_a$title = a.title) !== null && _a$title !== void 0 ? _a$title : '') > ((_b$title = b.title) !== null && _b$title !== void 0 ? _b$title : '') ? 1 : -1;
43
33
  }
44
-
45
34
  if (a !== b) {
46
35
  return a > b ? 1 : -1;
47
36
  }
48
-
49
37
  return 0;
50
38
  }
39
+
51
40
  /**
52
41
  *
53
42
  * @param actions The array of actions to sort
54
43
  */
55
-
56
-
57
44
  static sortActions(actions) {
58
45
  if (actions == null || !Array.isArray(actions)) {
59
46
  return [];
60
47
  }
61
-
62
48
  var sortedActions = actions.slice();
63
49
  sortedActions.sort(ContextActionUtils.compareActions);
64
50
  return sortedActions;
65
51
  }
66
-
67
52
  static isMacPlatform() {
68
53
  var {
69
54
  platform
70
55
  } = window.navigator;
71
56
  return platform.startsWith('Mac');
72
57
  }
58
+
73
59
  /**
74
60
  * Retrieve the preferred modifier key based on the current platform
75
61
  */
76
-
77
-
78
62
  static getModifierKey() {
79
63
  if (ContextActionUtils.isMacPlatform()) {
80
64
  return 'metaKey';
81
65
  }
82
-
83
66
  return 'ctrlKey';
84
67
  }
68
+
85
69
  /**
86
70
  * Returns true if the modifier key for the current platform is down for the event (Ctrl for windows/linux, Command (meta) for mac)
87
71
  * @param event The event to get the meta key status from
88
72
  */
89
-
90
-
91
73
  static isModifierKeyDown(event) {
92
74
  var modifierKey = ContextActionUtils.getModifierKey();
93
75
  return event[modifierKey];
94
76
  }
77
+
95
78
  /**
96
79
  * Returns the menu items for the provided context actions, or empty array if none found.
97
80
  * @param actionsParam The actions to get menu items for
98
81
  * @param includePromises Whether or not to include promises in the returned menu items
99
82
  */
100
83
 
101
-
102
84
  static getMenuItems(actionsParam) {
103
85
  var includePromises = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
104
86
  var menuItems = [];
105
87
  var actions = actionsParam;
106
-
107
88
  if (!Array.isArray(actions)) {
108
89
  actions = [actions];
109
90
  }
110
-
111
91
  for (var i = 0; i < actions.length; i += 1) {
112
92
  var _action = actions[i];
113
93
  var newMenuItems = void 0;
114
-
115
94
  if (typeof _action === 'function') {
116
95
  newMenuItems = _action();
117
96
  } else {
118
97
  newMenuItems = _action;
119
98
  }
120
-
121
99
  if (newMenuItems != null) {
122
100
  if (newMenuItems instanceof Promise) {
123
101
  if (includePromises) {
@@ -130,42 +108,33 @@ class ContextActionUtils {
130
108
  }
131
109
  }
132
110
  }
133
-
134
- menuItems = menuItems.filter(action => action.title !== undefined || action.then || action.menuElement);
111
+ menuItems = menuItems.filter(action => action.title !== undefined || action.then != null || action.menuElement);
135
112
  return menuItems;
136
113
  }
114
+
137
115
  /**
138
116
  * Returns the index of the next menu item in a list that doesn't have a disabled=true prop
139
117
  * @param startIndex the starting position for the iteration
140
118
  * @param delta the direction of travel, -1 or 1
141
119
  * @param menuItems an array of menuItems
142
120
  */
143
-
144
-
145
121
  static getNextMenuItem(startIndex, delta, menuItems) {
146
122
  var firstIndex = startIndex;
147
-
148
123
  if (firstIndex < 0 && delta < 0) {
149
124
  // if menu index is -1 and delta -1 manually set start point
150
125
  firstIndex = menuItems.length;
151
- } // find the next non disabled menu option, iterating the list only once
152
-
153
-
126
+ }
127
+ // find the next non disabled menu option, iterating the list only once
154
128
  for (var i = 1; i < menuItems.length + 1; i += 1) {
155
129
  var menuIndex = (firstIndex + delta * i + menuItems.length) % menuItems.length;
156
130
  var item = menuItems[menuIndex];
157
-
158
131
  if (!(item instanceof Promise) && item.disabled !== true) {
159
132
  return menuIndex;
160
133
  }
161
134
  }
162
-
163
135
  return startIndex;
164
136
  }
165
-
166
137
  }
167
-
168
138
  _defineProperty(ContextActionUtils, "actionsDisabled", false);
169
-
170
139
  export default ContextActionUtils;
171
140
  //# sourceMappingURL=ContextActionUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextActionUtils.js","names":["isPromise","value","then","undefined","ContextActionUtils","disableAllActions","actionsDisabled","enableAllActions","isContextActionEvent","e","Array","isArray","contextActions","compareActions","a","b","group","order","title","sortActions","actions","sortedActions","slice","sort","isMacPlatform","platform","window","navigator","startsWith","getModifierKey","isModifierKeyDown","event","modifierKey","getMenuItems","actionsParam","includePromises","menuItems","i","length","action","newMenuItems","Promise","push","concat","filter","menuElement","getNextMenuItem","startIndex","delta","firstIndex","menuIndex","item","disabled"],"sources":["../../src/context-actions/ContextActionUtils.ts"],"sourcesContent":["import { IconDefinition } from '@deephaven/icons';\nimport React from 'react';\nimport type { Shortcut } from '../shortcuts';\n\nexport type ResolvableContextAction =\n | ContextAction\n | Promise<ContextAction[]>\n | (() => Promise<ContextAction[]> | ContextAction[] | ContextAction);\n\nexport type MenuItem = ContextAction | Promise<ContextAction[]>;\n\nexport interface ContextAction {\n title?: string;\n description?: string;\n action?(event?: KeyboardEvent): void;\n actions?: ResolvableContextAction[];\n icon?: IconDefinition | React.ReactElement;\n iconColor?: string;\n shortcut?: Shortcut;\n isGlobal?: boolean;\n group?: number;\n order?: number;\n disabled?: boolean;\n menuElement?: React.ReactElement;\n iconOutline?: boolean;\n}\n\nexport interface ContextActionEvent extends MouseEvent {\n contextActions: ResolvableContextAction[];\n}\n\nexport function isPromise<A, T>(value: A | Promise<T>): value is Promise<T> {\n return (value as Promise<T>).then !== undefined;\n}\n\nclass ContextActionUtils {\n static actionsDisabled = false;\n\n static disableAllActions(): void {\n ContextActionUtils.actionsDisabled = true;\n }\n\n static enableAllActions(): void {\n ContextActionUtils.actionsDisabled = false;\n }\n\n static isContextActionEvent(e: MouseEvent): e is ContextActionEvent {\n return Array.isArray((e as ContextActionEvent).contextActions);\n }\n\n /**\n * Compare two action items. Useful in Array.sort\n * @param a First context action to compare\n * @param b Second context action to compare\n */\n static compareActions(a: ContextAction, b: ContextAction): number {\n if (a.group !== b.group) {\n return (a.group ?? 0) > (b.group ?? 0) ? 1 : -1;\n }\n\n if (a.order !== b.order) {\n return (a.order ?? 0) > (b.order ?? 0) ? 1 : -1;\n }\n\n if (a.title !== b.title) {\n return (a.title ?? '') > (b.title ?? '') ? 1 : -1;\n }\n\n if (a !== b) {\n return a > b ? 1 : -1;\n }\n\n return 0;\n }\n\n /**\n *\n * @param actions The array of actions to sort\n */\n static sortActions(actions: ContextAction[]): ContextAction[] {\n if (actions == null || !Array.isArray(actions)) {\n return [];\n }\n\n const sortedActions = actions.slice();\n sortedActions.sort(ContextActionUtils.compareActions);\n return sortedActions;\n }\n\n static isMacPlatform(): boolean {\n const { platform } = window.navigator;\n return platform.startsWith('Mac');\n }\n\n /**\n * Retrieve the preferred modifier key based on the current platform\n */\n static getModifierKey(): 'metaKey' | 'ctrlKey' {\n if (ContextActionUtils.isMacPlatform()) {\n return 'metaKey';\n }\n\n return 'ctrlKey';\n }\n\n /**\n * Returns true if the modifier key for the current platform is down for the event (Ctrl for windows/linux, Command (meta) for mac)\n * @param event The event to get the meta key status from\n */\n static isModifierKeyDown(\n event: KeyboardEvent | MouseEvent | React.KeyboardEvent | React.MouseEvent\n ): boolean {\n const modifierKey = ContextActionUtils.getModifierKey();\n return event[modifierKey];\n }\n\n /**\n * Returns the menu items for the provided context actions, or empty array if none found.\n * @param actionsParam The actions to get menu items for\n * @param includePromises Whether or not to include promises in the returned menu items\n */\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises?: true\n ): MenuItem[];\n\n // If ignoring promises, then the return type is narrowed\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises: false\n ): ContextAction[];\n\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises = true\n ): MenuItem[] {\n let menuItems: MenuItem[] = [];\n let actions = actionsParam;\n if (!Array.isArray(actions)) {\n actions = [actions];\n }\n\n for (let i = 0; i < actions.length; i += 1) {\n const action = actions[i];\n let newMenuItems:\n | ContextAction\n | ContextAction[]\n | Promise<ContextAction[]>;\n if (typeof action === 'function') {\n newMenuItems = action();\n } else {\n newMenuItems = action;\n }\n\n if (newMenuItems != null) {\n if (newMenuItems instanceof Promise) {\n if (includePromises) {\n menuItems.push(newMenuItems);\n }\n } else if (Array.isArray(newMenuItems)) {\n menuItems = menuItems.concat(newMenuItems);\n } else {\n menuItems.push(newMenuItems);\n }\n }\n }\n\n menuItems = menuItems.filter(\n action =>\n (action as ContextAction).title !== undefined ||\n (action as Promise<ContextAction[]>).then ||\n (action as ContextAction).menuElement\n );\n\n return menuItems;\n }\n\n /**\n * Returns the index of the next menu item in a list that doesn't have a disabled=true prop\n * @param startIndex the starting position for the iteration\n * @param delta the direction of travel, -1 or 1\n * @param menuItems an array of menuItems\n */\n static getNextMenuItem(\n startIndex: number,\n delta: -1 | 1,\n menuItems: MenuItem[]\n ): number {\n let firstIndex = startIndex;\n if (firstIndex < 0 && delta < 0) {\n // if menu index is -1 and delta -1 manually set start point\n firstIndex = menuItems.length;\n }\n // find the next non disabled menu option, iterating the list only once\n for (let i = 1; i < menuItems.length + 1; i += 1) {\n const menuIndex =\n (firstIndex + delta * i + menuItems.length) % menuItems.length;\n const item = menuItems[menuIndex];\n if (!(item instanceof Promise) && item.disabled !== true) {\n return menuIndex;\n }\n }\n return startIndex;\n }\n}\n\nexport default ContextActionUtils;\n"],"mappings":";;AA+BA,OAAO,SAASA,SAAT,CAAyBC,KAAzB,EAAqE;EAC1E,OAAQA,KAAD,CAAsBC,IAAtB,KAA+BC,SAAtC;AACD;;AAED,MAAMC,kBAAN,CAAyB;EAGC,OAAjBC,iBAAiB,GAAS;IAC/BD,kBAAkB,CAACE,eAAnB,GAAqC,IAArC;EACD;;EAEsB,OAAhBC,gBAAgB,GAAS;IAC9BH,kBAAkB,CAACE,eAAnB,GAAqC,KAArC;EACD;;EAE0B,OAApBE,oBAAoB,CAACC,CAAD,EAAyC;IAClE,OAAOC,KAAK,CAACC,OAAN,CAAeF,CAAD,CAA0BG,cAAxC,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACuB,O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eF,YAAf;QACD;MACF;IACF;;IAEDJ,SAAS,GAAGA,SAAS,CAACQ,MAAV,CACVL,MAAM,IACHA,MAAD,CAA0BrB,KAA1B,KAAoCf,SAApC,IACCoC,MAAD,CAAqCrC,IADrC,IAECqC,MAAD,CAA0BM,WAJlB,CAAZ;IAOA,OAAOT,SAAP;EACD;EAED;AACF;AACA;AACA;AACA;AACA;;;EACwB,OAAfU,eAAe,CACpBC,UADoB,EAEpBC,KAFoB,EAGpBZ,SAHoB,EAIZ;IACR,IAAIa,UAAU,GAAGF,UAAjB;;IACA,IAAIE,UAAU,GAAG,CAAb,IAAkBD,KAAK,GAAG,CAA9B,EAAiC;MAC/B;MACAC,UAAU,GAAGb,SAAS,CAACE,MAAvB;IACD,CALO,CAMR;;;IACA,KAAK,IAAID,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,SAAS,CAACE,MAAV,GAAmB,CAAvC,EAA0CD,CAAC,IAAI,CAA/C,EAAkD;MAChD,IAAMa,SAAS,GACb,CAACD,UAAU,GAAGD,KAAK,GAAGX,CAArB,GAAyBD,SAAS,CAACE,MAApC,IAA8CF,SAAS,CAACE,MAD1D;MAEA,IAAMa,IAAI,GAAGf,SAAS,CAACc,SAAD,CAAtB;;MACA,IAAI,EAAEC,IAAI,YAAYV,OAAlB,KAA8BU,IAAI,CAACC,QAAL,KAAkB,IAApD,EAA0D;QACxD,OAAOF,SAAP;MACD;IACF;;IACD,OAAOH,UAAP;EACD;;AAxKsB;;gBAAnB3C,kB,qBACqB,K;;AA0K3B,eAAeA,kBAAf"}
1
+ {"version":3,"file":"ContextActionUtils.js","names":["isPromise","value","then","undefined","ContextActionUtils","disableAllActions","actionsDisabled","enableAllActions","isContextActionEvent","e","Array","isArray","contextActions","compareActions","a","b","group","order","title","sortActions","actions","sortedActions","slice","sort","isMacPlatform","platform","window","navigator","startsWith","getModifierKey","isModifierKeyDown","event","modifierKey","getMenuItems","actionsParam","includePromises","menuItems","i","length","action","newMenuItems","Promise","push","concat","filter","menuElement","getNextMenuItem","startIndex","delta","firstIndex","menuIndex","item","disabled"],"sources":["../../src/context-actions/ContextActionUtils.ts"],"sourcesContent":["import { IconDefinition } from '@deephaven/icons';\nimport React from 'react';\nimport type { Shortcut } from '../shortcuts';\n\nexport type ResolvableContextAction =\n | ContextAction\n | Promise<ContextAction[]>\n | (() => Promise<ContextAction[]> | ContextAction[] | ContextAction);\n\nexport type MenuItem = ContextAction | Promise<ContextAction[]>;\n\nexport interface ContextAction {\n title?: string;\n description?: string;\n action?(event?: Event): void;\n actions?: ResolvableContextAction[];\n icon?: IconDefinition | React.ReactElement;\n iconColor?: string;\n shortcut?: Shortcut;\n isGlobal?: boolean;\n group?: number;\n order?: number;\n disabled?: boolean;\n menuElement?: React.ReactElement;\n iconOutline?: boolean;\n}\n\nexport interface ContextActionEvent extends MouseEvent {\n contextActions: ResolvableContextAction[];\n}\n\nexport function isPromise<A, T>(value: A | Promise<T>): value is Promise<T> {\n return (value as Promise<T>).then !== undefined;\n}\n\nclass ContextActionUtils {\n static actionsDisabled = false;\n\n static disableAllActions(): void {\n ContextActionUtils.actionsDisabled = true;\n }\n\n static enableAllActions(): void {\n ContextActionUtils.actionsDisabled = false;\n }\n\n static isContextActionEvent(e: MouseEvent): e is ContextActionEvent {\n return Array.isArray((e as ContextActionEvent).contextActions);\n }\n\n /**\n * Compare two action items. Useful in Array.sort\n * @param a First context action to compare\n * @param b Second context action to compare\n */\n static compareActions(a: ContextAction, b: ContextAction): number {\n if (a.group !== b.group) {\n return (a.group ?? 0) > (b.group ?? 0) ? 1 : -1;\n }\n\n if (a.order !== b.order) {\n return (a.order ?? 0) > (b.order ?? 0) ? 1 : -1;\n }\n\n if (a.title !== b.title) {\n return (a.title ?? '') > (b.title ?? '') ? 1 : -1;\n }\n\n if (a !== b) {\n return a > b ? 1 : -1;\n }\n\n return 0;\n }\n\n /**\n *\n * @param actions The array of actions to sort\n */\n static sortActions(actions: ContextAction[]): ContextAction[] {\n if (actions == null || !Array.isArray(actions)) {\n return [];\n }\n\n const sortedActions = actions.slice();\n sortedActions.sort(ContextActionUtils.compareActions);\n return sortedActions;\n }\n\n static isMacPlatform(): boolean {\n const { platform } = window.navigator;\n return platform.startsWith('Mac');\n }\n\n /**\n * Retrieve the preferred modifier key based on the current platform\n */\n static getModifierKey(): 'metaKey' | 'ctrlKey' {\n if (ContextActionUtils.isMacPlatform()) {\n return 'metaKey';\n }\n\n return 'ctrlKey';\n }\n\n /**\n * Returns true if the modifier key for the current platform is down for the event (Ctrl for windows/linux, Command (meta) for mac)\n * @param event The event to get the meta key status from\n */\n static isModifierKeyDown(\n event: KeyboardEvent | MouseEvent | React.KeyboardEvent | React.MouseEvent\n ): boolean {\n const modifierKey = ContextActionUtils.getModifierKey();\n return event[modifierKey];\n }\n\n /**\n * Returns the menu items for the provided context actions, or empty array if none found.\n * @param actionsParam The actions to get menu items for\n * @param includePromises Whether or not to include promises in the returned menu items\n */\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises?: true\n ): MenuItem[];\n\n // If ignoring promises, then the return type is narrowed\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises: false\n ): ContextAction[];\n\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises = true\n ): MenuItem[] {\n let menuItems: MenuItem[] = [];\n let actions = actionsParam;\n if (!Array.isArray(actions)) {\n actions = [actions];\n }\n\n for (let i = 0; i < actions.length; i += 1) {\n const action = actions[i];\n let newMenuItems:\n | ContextAction\n | ContextAction[]\n | Promise<ContextAction[]>;\n if (typeof action === 'function') {\n newMenuItems = action();\n } else {\n newMenuItems = action;\n }\n\n if (newMenuItems != null) {\n if (newMenuItems instanceof Promise) {\n if (includePromises) {\n menuItems.push(newMenuItems);\n }\n } else if (Array.isArray(newMenuItems)) {\n menuItems = menuItems.concat(newMenuItems);\n } else {\n menuItems.push(newMenuItems);\n }\n }\n }\n\n menuItems = menuItems.filter(\n action =>\n (action as ContextAction).title !== undefined ||\n (action as Promise<ContextAction[]>).then != null ||\n (action as ContextAction).menuElement\n );\n\n return menuItems;\n }\n\n /**\n * Returns the index of the next menu item in a list that doesn't have a disabled=true prop\n * @param startIndex the starting position for the iteration\n * @param delta the direction of travel, -1 or 1\n * @param menuItems an array of menuItems\n */\n static getNextMenuItem(\n startIndex: number,\n delta: -1 | 1,\n menuItems: MenuItem[]\n ): number {\n let firstIndex = startIndex;\n if (firstIndex < 0 && delta < 0) {\n // if menu index is -1 and delta -1 manually set start point\n firstIndex = menuItems.length;\n }\n // find the next non disabled menu option, iterating the list only once\n for (let i = 1; i < menuItems.length + 1; i += 1) {\n const menuIndex =\n (firstIndex + delta * i + menuItems.length) % menuItems.length;\n const item = menuItems[menuIndex];\n if (!(item instanceof Promise) && item.disabled !== true) {\n return menuIndex;\n }\n }\n return startIndex;\n }\n}\n\nexport default ContextActionUtils;\n"],"mappings":";AA+BA,OAAO,SAASA,SAAS,CAAOC,KAAqB,EAAuB;EAC1E,OAAQA,KAAK,CAAgBC,IAAI,KAAKC,SAAS;AACjD;AAEA,MAAMC,kBAAkB,CAAC;EAGvB,OAAOC,iBAAiB,GAAS;IAC/BD,kBAAkB,CAACE,eAAe,GAAG,IAAI;EAC3C;EAEA,OAAOC,gBAAgB,GAAS;IAC9BH,kBAAkB,CAACE,eAAe,GAAG,KAAK;EAC5C;EAEA,OAAOE,oBAAoB,CAACC,CAAa,EAA2B;IAClE,OAAOC,KAAK,CAACC,OAAO,CAAEF,CAAC,CAAwBG,cAAc,CAAC;EAChE;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,cAAc,CAACC,CAAgB,EAAEC,CAAgB,EAAU;IAChE,IAAID,CAAC,CAACE,KAAK,KAAKD,CAAC,CAACC,KAAK,EAAE;MAAA;MACvB,OAAO,aAACF,CAAC,CAACE,KAAK,+CAAI,CAAC,iBAAKD,CAAC,CAACC,KAAK,+CAAI,CAAC,CAAC,GAAG,CAAC,GAAG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AACA;EACE,OAAOU,eAAe,CACpBC,UAAkB,EAClBC,KAAa,EACbZ,SAAqB,EACb;IACR,IAAIa,UAAU,GAAGF,UAAU;IAC3B,IAAIE,UAAU,GAAG,CAAC,IAAID,KAAK,GAAG,CAAC,EAAE;MAC/B;MACAC,UAAU,GAAGb,SAAS,CAACE,MAAM;IAC/B;IACA;IACA,KAAK,IAAID,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,SAAS,CAACE,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAE;MAChD,IAAMa,SAAS,GACb,CAACD,UAAU,GAAGD,KAAK,GAAGX,CAAC,GAAGD,SAAS,CAACE,MAAM,IAAIF,SAAS,CAACE,MAAM;MAChE,IAAMa,IAAI,GAAGf,SAAS,CAACc,SAAS,CAAC;MACjC,IAAI,EAAEC,IAAI,YAAYV,OAAO,CAAC,IAAIU,IAAI,CAACC,QAAQ,KAAK,IAAI,EAAE;QACxD,OAAOF,SAAS;MAClB;IACF;IACA,OAAOH,UAAU;EACnB;AACF;AAAC,gBAzKK3C,kBAAkB,qBACG,KAAK;AA0KhC,eAAeA,kBAAkB"}
@@ -1,5 +1,4 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
2
  /**
4
3
  * Just a simple utility class for displaying a popup menu.
5
4
  */
@@ -9,7 +8,6 @@ import ContextActionUtils, { isPromise } from "./ContextActionUtils.js";
9
8
  import GlobalContextActions from "./GlobalContextActions.js";
10
9
  import "./ContextActions.css";
11
10
  var log = Log.module('ContextActions');
12
-
13
11
  /**
14
12
  * ContextActions that you add onto any component.
15
13
  *
@@ -43,11 +41,11 @@ class ContextActions extends Component {
43
41
  * Groups are separated by a separator item.
44
42
  * Items within groups are ordered by their order property, then by their title.
45
43
  */
44
+
46
45
  static triggerMenu(element, clientX, clientY, actions) {
47
46
  if (actions.length === 0) {
48
47
  return;
49
48
  }
50
-
51
49
  var mouseEvent = new MouseEvent('contextmenu', {
52
50
  clientX,
53
51
  clientY,
@@ -57,12 +55,9 @@ class ContextActions extends Component {
57
55
  mouseEvent.contextActions = actions;
58
56
  element.dispatchEvent(mouseEvent);
59
57
  }
60
-
61
58
  constructor(props) {
62
59
  super(props);
63
-
64
60
  _defineProperty(this, "container", void 0);
65
-
66
61
  this.handleContextMenu = this.handleContextMenu.bind(this);
67
62
  this.handleKeyDown = this.handleKeyDown.bind(this);
68
63
  this.container = /*#__PURE__*/React.createRef();
@@ -71,7 +66,6 @@ class ContextActions extends Component {
71
66
  keyboardActions: []
72
67
  };
73
68
  }
74
-
75
69
  static getDerivedStateFromProps(props) {
76
70
  if (props.actions == null || !Array.isArray(props.actions)) {
77
71
  return {
@@ -79,7 +73,6 @@ class ContextActions extends Component {
79
73
  keyboardActions: []
80
74
  };
81
75
  }
82
-
83
76
  var globalActions = props.actions.filter(action => !isPromise(action) && typeof action !== 'function' && action.isGlobal);
84
77
  var keyboardActions = props.actions.filter(action => !isPromise(action) && typeof action !== 'function' && (action.isGlobal === undefined || !action.isGlobal) && action.shortcut != null);
85
78
  return {
@@ -87,92 +80,70 @@ class ContextActions extends Component {
87
80
  keyboardActions
88
81
  };
89
82
  }
90
-
91
83
  componentDidMount() {
92
84
  var _this$container$curre;
93
-
94
85
  if ((_this$container$curre = this.container.current) !== null && _this$container$curre !== void 0 && _this$container$curre.parentElement) {
95
86
  this.container.current.parentElement.addEventListener('contextmenu', this.handleContextMenu);
96
87
  this.container.current.parentElement.addEventListener('keydown', this.handleKeyDown);
97
88
  }
98
89
  }
99
-
100
90
  componentWillUnmount() {
101
91
  var _this$container$curre2;
102
-
103
92
  if ((_this$container$curre2 = this.container.current) !== null && _this$container$curre2 !== void 0 && _this$container$curre2.parentElement) {
104
93
  this.container.current.parentElement.removeEventListener('contextmenu', this.handleContextMenu);
105
94
  this.container.current.parentElement.removeEventListener('keydown', this.handleKeyDown);
106
95
  }
107
96
  }
108
-
109
97
  handleContextMenu(e) {
110
98
  var {
111
99
  ignoreClassNames = []
112
100
  } = this.props;
113
-
114
101
  if (ignoreClassNames.length > 0) {
115
102
  var el = e.target;
116
-
117
103
  var _loop = function _loop() {
118
104
  var {
119
105
  classList
120
106
  } = el;
121
107
  var ignoredClassName = ignoreClassNames.find(className => classList.contains(className));
122
-
123
108
  if (ignoredClassName !== undefined) {
124
109
  log.debug2("Contextmenu event ignored based on the target className \"".concat(ignoredClassName, "\""));
125
110
  return {
126
111
  v: void 0
127
112
  };
128
113
  }
129
-
130
114
  el = el.parentElement;
131
115
  };
132
-
133
116
  while (el != null) {
134
117
  var _ret = _loop();
135
-
136
118
  if (typeof _ret === "object") return _ret.v;
137
119
  }
138
120
  }
139
-
140
121
  if (!ContextActionUtils.isContextActionEvent(e)) {
141
122
  e.contextActions = [];
142
123
  }
143
-
144
124
  if (!ContextActionUtils.isContextActionEvent(e)) {
145
125
  return;
146
126
  }
147
-
148
127
  var {
149
128
  actions
150
129
  } = this.props;
151
-
152
130
  if (actions != null) {
153
131
  var contextActions = actions;
154
-
155
132
  if (Array.isArray(contextActions)) {
156
133
  contextActions = contextActions.filter(action => isPromise(action) || typeof action === 'function' || action.isGlobal === undefined || !action.isGlobal);
157
134
  }
158
-
159
135
  e.contextActions = e.contextActions.concat(contextActions);
160
136
  }
161
-
162
137
  log.debug('Received context menu event! Menu items are now: ', e.contextActions);
163
138
  }
164
-
165
139
  handleKeyDown(e) {
166
140
  var {
167
141
  keyboardActions
168
142
  } = this.state;
169
-
170
143
  for (var i = 0; i < keyboardActions.length; i += 1) {
171
144
  var keyboardAction = keyboardActions[i];
172
-
173
145
  if (!ContextActionUtils.actionsDisabled && keyboardAction.shortcut != null && keyboardAction.shortcut.matchesEvent(e)) {
174
146
  var _keyboardAction$actio;
175
-
176
147
  log.debug('Context hotkey matched!', e);
177
148
  (_keyboardAction$actio = keyboardAction.action) === null || _keyboardAction$actio === void 0 ? void 0 : _keyboardAction$actio.call(keyboardAction, e);
178
149
  e.stopPropagation();
@@ -181,7 +152,6 @@ class ContextActions extends Component {
181
152
  }
182
153
  }
183
154
  }
184
-
185
155
  render() {
186
156
  var {
187
157
  'data-testid': dataTestId
@@ -197,9 +167,7 @@ class ContextActions extends Component {
197
167
  actions: globalActions
198
168
  }));
199
169
  }
200
-
201
170
  }
202
-
203
171
  _defineProperty(ContextActions, "groups", {
204
172
  default: null,
205
173
  high: 100,
@@ -208,6 +176,5 @@ _defineProperty(ContextActions, "groups", {
208
176
  global: 100000,
209
177
  edit: 100
210
178
  });
211
-
212
179
  export default ContextActions;
213
180
  //# sourceMappingURL=ContextActions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextActions.js","names":["React","Component","Log","ContextActionUtils","isPromise","GlobalContextActions","log","module","ContextActions","triggerMenu","element","clientX","clientY","actions","length","mouseEvent","MouseEvent","bubbles","cancelable","contextActions","dispatchEvent","constructor","props","handleContextMenu","bind","handleKeyDown","container","createRef","state","globalActions","keyboardActions","getDerivedStateFromProps","Array","isArray","filter","action","isGlobal","undefined","shortcut","componentDidMount","current","parentElement","addEventListener","componentWillUnmount","removeEventListener","e","ignoreClassNames","el","target","classList","ignoredClassName","find","className","contains","debug2","isContextActionEvent","concat","debug","i","keyboardAction","actionsDisabled","matchesEvent","stopPropagation","preventDefault","render","dataTestId","default","high","medium","low","global","edit"],"sources":["../../src/context-actions/ContextActions.tsx"],"sourcesContent":["/**\n * Just a simple utility class for displaying a popup menu.\n */\nimport React, { Component } from 'react';\nimport Log from '@deephaven/log';\nimport ContextActionUtils, {\n ResolvableContextAction,\n isPromise,\n} from './ContextActionUtils';\nimport type { ContextAction, ContextActionEvent } from './ContextActionUtils';\nimport GlobalContextActions from './GlobalContextActions';\nimport './ContextActions.scss';\n\nconst log = Log.module('ContextActions');\n\ninterface ContextActionsProps {\n actions: ResolvableContextAction | ResolvableContextAction[];\n ignoreClassNames?: string[];\n 'data-testid'?: string;\n}\n\ninterface ContextActionsState {\n globalActions: ContextAction[];\n keyboardActions: ContextAction[];\n}\n\n/**\n * ContextActions that you add onto any component.\n *\n * Usage:\n * let actions = [{\n * title: 'My Action', // Omit the title to hide it from the context menu\n * action: () => { alert('My Action Clicked!') }\n * actions: [] // Submenu of actions\n * icon: faPrint, // Limited to FontAwesome icons for now.\n * iconColor: '#ff0000, // Color to use for the icon\n * shortcut: Shortcut, // Defaults to null\n * isGlobal: false, // Global context action. Defaults to false.\n * group: ContextActions.groups.default, // What group to group the context action with\n * order: null, // Int where to order within group\n * disabled: true // disable action\n * menuElement: null // Custom menu element for displaying in context menu. When null, creates a default menu item based on title\n * }];\n *\n * <div>\n * Right click in this container\n * <ContextActions actions={actions}/>\n * </div>\n *\n * Right clicking the container will then build the context menu, bubbling up until an element with a ContextMenuRoot is on it.\n * You should generally have a ContextMenuRoot on the root node of your document.\n */\nclass ContextActions extends Component<\n ContextActionsProps,\n ContextActionsState\n> {\n /**\n * Group you can assign to context menu actions to group them together.\n * Lower group IDs appear at the top of the list.\n * Groups are separated by a separator item.\n * Items within groups are ordered by their order property, then by their title.\n */\n static groups = {\n default: null,\n high: 100,\n medium: 5000,\n low: 10000,\n global: 100000,\n\n edit: 100,\n };\n\n static triggerMenu(\n element: Element,\n clientX: number,\n clientY: number,\n actions: ContextAction[]\n ): void {\n if (actions.length === 0) {\n return;\n }\n\n const mouseEvent: Partial<ContextActionEvent> = new MouseEvent(\n 'contextmenu',\n {\n clientX,\n clientY,\n bubbles: true,\n cancelable: true,\n }\n );\n mouseEvent.contextActions = actions;\n\n element.dispatchEvent(mouseEvent as ContextActionEvent);\n }\n\n constructor(props: ContextActionsProps) {\n super(props);\n\n this.handleContextMenu = this.handleContextMenu.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.container = React.createRef();\n\n this.state = { globalActions: [], keyboardActions: [] };\n }\n\n static getDerivedStateFromProps(\n props: ContextActionsProps\n ): ContextActionsState {\n if (props.actions == null || !Array.isArray(props.actions)) {\n return { globalActions: [], keyboardActions: [] };\n }\n const globalActions = props.actions.filter(\n action =>\n !isPromise(action) && typeof action !== 'function' && action.isGlobal\n ) as ContextAction[];\n const keyboardActions = props.actions.filter(\n action =>\n !isPromise(action) &&\n typeof action !== 'function' &&\n (action.isGlobal === undefined || !action.isGlobal) &&\n action.shortcut != null\n ) as ContextAction[];\n\n return { globalActions, keyboardActions };\n }\n\n componentDidMount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.addEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n this.container.current.parentElement.addEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n }\n\n componentWillUnmount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.removeEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n this.container.current.parentElement.removeEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n handleContextMenu(e: MouseEvent): void {\n const { ignoreClassNames = [] } = this.props;\n if (ignoreClassNames.length > 0) {\n let el = e.target as Element | null;\n while (el != null) {\n const { classList } = el;\n const ignoredClassName = ignoreClassNames.find(className =>\n classList.contains(className)\n );\n if (ignoredClassName !== undefined) {\n log.debug2(\n `Contextmenu event ignored based on the target className \"${ignoredClassName}\"`\n );\n return;\n }\n el = el.parentElement;\n }\n }\n if (!ContextActionUtils.isContextActionEvent(e)) {\n (e as ContextActionEvent).contextActions = [];\n }\n\n if (!ContextActionUtils.isContextActionEvent(e)) {\n return;\n }\n\n const { actions } = this.props;\n if (actions != null) {\n let contextActions = actions;\n if (Array.isArray(contextActions)) {\n contextActions = contextActions.filter(\n action =>\n isPromise(action) ||\n typeof action === 'function' ||\n action.isGlobal === undefined ||\n !action.isGlobal\n );\n }\n\n e.contextActions = e.contextActions.concat(contextActions);\n }\n\n log.debug(\n 'Received context menu event! Menu items are now: ',\n e.contextActions\n );\n }\n\n handleKeyDown(e: KeyboardEvent): void {\n const { keyboardActions } = this.state;\n for (let i = 0; i < keyboardActions.length; i += 1) {\n const keyboardAction = keyboardActions[i];\n if (\n !ContextActionUtils.actionsDisabled &&\n keyboardAction.shortcut != null &&\n keyboardAction.shortcut.matchesEvent(e)\n ) {\n log.debug('Context hotkey matched!', e);\n\n keyboardAction.action?.(e);\n\n e.stopPropagation();\n e.preventDefault();\n\n log.debug2('Matched hotkey returned false, key event not consumed');\n }\n }\n }\n\n render(): JSX.Element {\n const { 'data-testid': dataTestId } = this.props;\n const { globalActions } = this.state;\n return (\n <div\n className=\"context-actions-listener\"\n ref={this.container}\n data-testid={dataTestId}\n >\n <GlobalContextActions actions={globalActions} />\n </div>\n );\n }\n}\n\nexport default ContextActions;\n"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,kB,IAELC,S;OAGKC,oB;;AAGP,IAAMC,GAAG,GAAGJ,GAAG,CAACK,MAAJ,CAAW,gBAAX,CAAZ;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAN,SAA6BP,SAA7B,CAGE;EACA;AACF;AACA;AACA;AACA;AACA;EAWoB,OAAXQ,WAAW,CAChBC,OADgB,EAEhBC,OAFgB,EAGhBC,OAHgB,EAIhBC,OAJgB,EAKV;IACN,IAAIA,OAAO,CAACC,MAAR,KAAmB,CAAvB,EAA0B;MACxB;IACD;;IAED,IAAMC,UAAuC,GAAG,IAAIC,UAAJ,CAC9C,aAD8C,EAE9C;MACEL,OADF;MAEEC,OAFF;MAGEK,OAAO,EAAE,IAHX;MAIEC,UAAU,EAAE;IAJd,CAF8C,CAAhD;IASAH,UAAU,CAACI,cAAX,GAA4BN,OAA5B;IAEAH,OAAO,CAACU,aAAR,CAAsBL,UAAtB;EACD;;EAEDM,WAAW,CAACC,KAAD,E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M,GAAgB;IACpB,IAAM;MAAE,eAAeC;IAAjB,IAAgC,KAAK3C,KAA3C;IACA,IAAM;MAAEO;IAAF,IAAoB,KAAKD,KAA/B;IACA,oBACE;MACE,SAAS,EAAC,0BADZ;MAEE,GAAG,EAAE,KAAKF,SAFZ;MAGE,eAAauC;IAHf,gBAKE,oBAAC,oBAAD;MAAsB,OAAO,EAAEpC;IAA/B,EALF,CADF;EASD;;AAtLD;;gBAHIrB,c,YAUY;EACd0D,OAAO,EAAE,IADK;EAEdC,IAAI,EAAE,GAFQ;EAGdC,MAAM,EAAE,IAHM;EAIdC,GAAG,EAAE,KAJS;EAKdC,MAAM,EAAE,MALM;EAOdC,IAAI,EAAE;AAPQ,C;;AAkLlB,eAAe/D,cAAf"}
1
+ {"version":3,"file":"ContextActions.js","names":["React","Component","Log","ContextActionUtils","isPromise","GlobalContextActions","log","module","ContextActions","triggerMenu","element","clientX","clientY","actions","length","mouseEvent","MouseEvent","bubbles","cancelable","contextActions","dispatchEvent","constructor","props","handleContextMenu","bind","handleKeyDown","container","createRef","state","globalActions","keyboardActions","getDerivedStateFromProps","Array","isArray","filter","action","isGlobal","undefined","shortcut","componentDidMount","current","parentElement","addEventListener","componentWillUnmount","removeEventListener","e","ignoreClassNames","el","target","classList","ignoredClassName","find","className","contains","debug2","isContextActionEvent","concat","debug","i","keyboardAction","actionsDisabled","matchesEvent","stopPropagation","preventDefault","render","dataTestId","default","high","medium","low","global","edit"],"sources":["../../src/context-actions/ContextActions.tsx"],"sourcesContent":["/**\n * Just a simple utility class for displaying a popup menu.\n */\nimport React, { Component } from 'react';\nimport Log from '@deephaven/log';\nimport ContextActionUtils, {\n ResolvableContextAction,\n isPromise,\n} from './ContextActionUtils';\nimport type { ContextAction, ContextActionEvent } from './ContextActionUtils';\nimport GlobalContextActions from './GlobalContextActions';\nimport './ContextActions.scss';\n\nconst log = Log.module('ContextActions');\n\ninterface ContextActionsProps {\n actions: ResolvableContextAction | ResolvableContextAction[];\n ignoreClassNames?: string[];\n 'data-testid'?: string;\n}\n\ninterface ContextActionsState {\n globalActions: ContextAction[];\n keyboardActions: ContextAction[];\n}\n\n/**\n * ContextActions that you add onto any component.\n *\n * Usage:\n * let actions = [{\n * title: 'My Action', // Omit the title to hide it from the context menu\n * action: () => { alert('My Action Clicked!') }\n * actions: [] // Submenu of actions\n * icon: faPrint, // Limited to FontAwesome icons for now.\n * iconColor: '#ff0000, // Color to use for the icon\n * shortcut: Shortcut, // Defaults to null\n * isGlobal: false, // Global context action. Defaults to false.\n * group: ContextActions.groups.default, // What group to group the context action with\n * order: null, // Int where to order within group\n * disabled: true // disable action\n * menuElement: null // Custom menu element for displaying in context menu. When null, creates a default menu item based on title\n * }];\n *\n * <div>\n * Right click in this container\n * <ContextActions actions={actions}/>\n * </div>\n *\n * Right clicking the container will then build the context menu, bubbling up until an element with a ContextMenuRoot is on it.\n * You should generally have a ContextMenuRoot on the root node of your document.\n */\nclass ContextActions extends Component<\n ContextActionsProps,\n ContextActionsState\n> {\n /**\n * Group you can assign to context menu actions to group them together.\n * Lower group IDs appear at the top of the list.\n * Groups are separated by a separator item.\n * Items within groups are ordered by their order property, then by their title.\n */\n static groups = {\n default: null,\n high: 100,\n medium: 5000,\n low: 10000,\n global: 100000,\n\n edit: 100,\n };\n\n static triggerMenu(\n element: Element,\n clientX: number,\n clientY: number,\n actions: ContextAction[]\n ): void {\n if (actions.length === 0) {\n return;\n }\n\n const mouseEvent: Partial<ContextActionEvent> = new MouseEvent(\n 'contextmenu',\n {\n clientX,\n clientY,\n bubbles: true,\n cancelable: true,\n }\n );\n mouseEvent.contextActions = actions;\n\n element.dispatchEvent(mouseEvent as ContextActionEvent);\n }\n\n constructor(props: ContextActionsProps) {\n super(props);\n\n this.handleContextMenu = this.handleContextMenu.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.container = React.createRef();\n\n this.state = { globalActions: [], keyboardActions: [] };\n }\n\n static getDerivedStateFromProps(\n props: ContextActionsProps\n ): ContextActionsState {\n if (props.actions == null || !Array.isArray(props.actions)) {\n return { globalActions: [], keyboardActions: [] };\n }\n const globalActions = props.actions.filter(\n action =>\n !isPromise(action) && typeof action !== 'function' && action.isGlobal\n ) as ContextAction[];\n const keyboardActions = props.actions.filter(\n action =>\n !isPromise(action) &&\n typeof action !== 'function' &&\n (action.isGlobal === undefined || !action.isGlobal) &&\n action.shortcut != null\n ) as ContextAction[];\n\n return { globalActions, keyboardActions };\n }\n\n componentDidMount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.addEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n this.container.current.parentElement.addEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n }\n\n componentWillUnmount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.removeEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n this.container.current.parentElement.removeEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n handleContextMenu(e: MouseEvent): void {\n const { ignoreClassNames = [] } = this.props;\n if (ignoreClassNames.length > 0) {\n let el = e.target as Element | null;\n while (el != null) {\n const { classList } = el;\n const ignoredClassName = ignoreClassNames.find(className =>\n classList.contains(className)\n );\n if (ignoredClassName !== undefined) {\n log.debug2(\n `Contextmenu event ignored based on the target className \"${ignoredClassName}\"`\n );\n return;\n }\n el = el.parentElement;\n }\n }\n if (!ContextActionUtils.isContextActionEvent(e)) {\n (e as ContextActionEvent).contextActions = [];\n }\n\n if (!ContextActionUtils.isContextActionEvent(e)) {\n return;\n }\n\n const { actions } = this.props;\n if (actions != null) {\n let contextActions = actions;\n if (Array.isArray(contextActions)) {\n contextActions = contextActions.filter(\n action =>\n isPromise(action) ||\n typeof action === 'function' ||\n action.isGlobal === undefined ||\n !action.isGlobal\n );\n }\n\n e.contextActions = e.contextActions.concat(contextActions);\n }\n\n log.debug(\n 'Received context menu event! Menu items are now: ',\n e.contextActions\n );\n }\n\n handleKeyDown(e: KeyboardEvent): void {\n const { keyboardActions } = this.state;\n for (let i = 0; i < keyboardActions.length; i += 1) {\n const keyboardAction = keyboardActions[i];\n if (\n !ContextActionUtils.actionsDisabled &&\n keyboardAction.shortcut != null &&\n keyboardAction.shortcut.matchesEvent(e)\n ) {\n log.debug('Context hotkey matched!', e);\n\n keyboardAction.action?.(e);\n\n e.stopPropagation();\n e.preventDefault();\n\n log.debug2('Matched hotkey returned false, key event not consumed');\n }\n }\n }\n\n render(): JSX.Element {\n const { 'data-testid': dataTestId } = this.props;\n const { globalActions } = this.state;\n return (\n <div\n className=\"context-actions-listener\"\n ref={this.container}\n data-testid={dataTestId}\n >\n <GlobalContextActions actions={globalActions} />\n </div>\n );\n }\n}\n\nexport default ContextActions;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,OAAOC,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,kBAAkB,IAEvBC,SAAS;AAAA,OAGJC,oBAAoB;AAAA;AAG3B,IAAMC,GAAG,GAAGJ,GAAG,CAACK,MAAM,CAAC,gBAAgB,CAAC;AAaxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,SAASP,SAAS,CAGpC;EACA;AACF;AACA;AACA;AACA;AACA;;EAWE,OAAOQ,WAAW,CAChBC,OAAgB,EAChBC,OAAe,EACfC,OAAe,EACfC,OAAwB,EAClB;IACN,IAAIA,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;MACxB;IACF;IAEA,IAAMC,UAAuC,GAAG,IAAIC,UAAU,CAC5D,aAAa,EACb;MACEL,OAAO;MACPC,OAAO;MACPK,OAAO,EAAE,IAAI;MACbC,UAAU,EAAE;IACd,CAAC,CACF;IACDH,UAAU,CAACI,cAAc,GAAGN,OAAO;IAEnCH,OAAO,CAACU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