@deephaven/components 1.7.2-beta.1 → 1.7.2-react-18-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AutoCompleteInput.d.ts +0 -17
- package/dist/AutoCompleteInput.d.ts.map +1 -1
- package/dist/AutoCompleteInput.js +12 -31
- package/dist/AutoCompleteInput.js.map +1 -1
- package/dist/AutoResizeTextarea.d.ts +0 -23
- package/dist/AutoResizeTextarea.d.ts.map +1 -1
- package/dist/AutoResizeTextarea.js +0 -21
- package/dist/AutoResizeTextarea.js.map +1 -1
- package/dist/BasicModal.d.ts +0 -27
- package/dist/BasicModal.d.ts.map +1 -1
- package/dist/BasicModal.js +2 -28
- package/dist/BasicModal.js.map +1 -1
- package/dist/BulkActionBar.js.map +1 -1
- package/dist/Button.d.ts +1 -1
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +2 -79
- package/dist/Button.js.map +1 -1
- package/dist/CardFlip.d.ts.map +1 -1
- package/dist/CardFlip.js +1 -2
- package/dist/CardFlip.js.map +1 -1
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +3 -45
- package/dist/Checkbox.js.map +1 -1
- package/dist/Collapse.d.ts +0 -8
- package/dist/Collapse.d.ts.map +1 -1
- package/dist/Collapse.js +0 -8
- package/dist/Collapse.js.map +1 -1
- package/dist/ComponentUtils.js.map +1 -1
- package/dist/CopyButton.js.map +1 -1
- package/dist/CustomTimeSelect.js +14 -15
- package/dist/CustomTimeSelect.js.map +1 -1
- package/dist/DateInput.js.map +1 -1
- package/dist/DateInputUtils.js.map +1 -1
- package/dist/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput.js +0 -8
- package/dist/DateTimeInput.js.map +1 -1
- package/dist/DateTimeInputUtils.js.map +1 -1
- package/dist/DebouncedSearchInput.js +1 -1
- package/dist/DebouncedSearchInput.js.map +1 -1
- package/dist/DragUtils.js.map +1 -1
- package/dist/DraggableItemList.d.ts +2 -2
- package/dist/DraggableItemList.d.ts.map +1 -1
- package/dist/DraggableItemList.js +8 -7
- package/dist/DraggableItemList.js.map +1 -1
- package/dist/EditableItemList.js +1 -2
- package/dist/EditableItemList.js.map +1 -1
- package/dist/ErrorBoundary.js +1 -1
- package/dist/ErrorBoundary.js.map +1 -1
- package/dist/ErrorView.js +1 -2
- package/dist/ErrorView.js.map +1 -1
- package/dist/HierarchicalCheckboxMenu.d.ts +1 -1
- package/dist/HierarchicalCheckboxMenu.d.ts.map +1 -1
- package/dist/HierarchicalCheckboxMenu.js +1 -2
- package/dist/HierarchicalCheckboxMenu.js.map +1 -1
- package/dist/ItemList.d.ts +1 -1
- package/dist/ItemList.d.ts.map +1 -1
- package/dist/ItemList.js +14 -14
- package/dist/ItemList.js.map +1 -1
- package/dist/ItemListItem.js.map +1 -1
- package/dist/LoadingOverlay.js +1 -2
- package/dist/LoadingOverlay.js.map +1 -1
- package/dist/LoadingSpinner.js.map +1 -1
- package/dist/MaskedInput.d.ts.map +1 -1
- package/dist/MaskedInput.js +11 -31
- package/dist/MaskedInput.js.map +1 -1
- package/dist/MaskedInputUtils.js.map +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/RadioGroup.js +1 -2
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioItem.d.ts.map +1 -1
- package/dist/RadioItem.js +1 -13
- package/dist/RadioItem.js.map +1 -1
- package/dist/RandomAreaPlotAnimation.d.ts +1 -1
- package/dist/RandomAreaPlotAnimation.d.ts.map +1 -1
- package/dist/RandomAreaPlotAnimation.js +5 -8
- package/dist/RandomAreaPlotAnimation.js.map +1 -1
- package/dist/SearchInput.js +3 -5
- package/dist/SearchInput.js.map +1 -1
- package/dist/SearchableCombobox.js.map +1 -1
- package/dist/Select.d.ts +1 -1
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js.map +1 -1
- package/dist/SelectValueList.js +9 -9
- package/dist/SelectValueList.js.map +1 -1
- package/dist/SocketedButton.d.ts +4 -4
- package/dist/SocketedButton.d.ts.map +1 -1
- package/dist/SocketedButton.js +5 -20
- package/dist/SocketedButton.js.map +1 -1
- package/dist/SplitButtonGroup.d.ts +2 -18
- package/dist/SplitButtonGroup.d.ts.map +1 -1
- package/dist/SplitButtonGroup.js +0 -13
- package/dist/SplitButtonGroup.js.map +1 -1
- package/dist/TableViewEmptyState.js +1 -2
- package/dist/TableViewEmptyState.js.map +1 -1
- package/dist/TextWithTooltip.js +1 -3
- package/dist/TextWithTooltip.js.map +1 -1
- package/dist/ThemeExport.js.map +1 -1
- package/dist/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput.js +7 -17
- package/dist/TimeInput.js.map +1 -1
- package/dist/TimeSlider.js +3 -6
- package/dist/TimeSlider.js.map +1 -1
- package/dist/ToastNotification.d.ts +1 -2
- package/dist/ToastNotification.d.ts.map +1 -1
- package/dist/ToastNotification.js +1 -2
- package/dist/ToastNotification.js.map +1 -1
- package/dist/UIConstants.js.map +1 -1
- package/dist/UISwitch.d.ts.map +1 -1
- package/dist/UISwitch.js +18 -14
- package/dist/UISwitch.js.map +1 -1
- package/dist/XComponent.d.ts +1 -1
- package/dist/XComponent.d.ts.map +1 -1
- package/dist/XComponent.js.map +1 -1
- package/dist/XComponentMap.d.ts +2 -2
- package/dist/XComponentMap.d.ts.map +1 -1
- package/dist/XComponentMap.js.map +1 -1
- package/dist/actions/ConfirmActionButton.js.map +1 -1
- package/dist/actions/IconActionButton.js +1 -2
- package/dist/actions/IconActionButton.js.map +1 -1
- package/dist/actions/index.js.map +1 -1
- package/dist/context-actions/ContextActionUtils.js.map +1 -1
- package/dist/context-actions/ContextActions.d.ts +1 -2
- package/dist/context-actions/ContextActions.d.ts.map +1 -1
- package/dist/context-actions/ContextActions.js +22 -22
- package/dist/context-actions/ContextActions.js.map +1 -1
- package/dist/context-actions/ContextMenu.js +5 -7
- package/dist/context-actions/ContextMenu.js.map +1 -1
- package/dist/context-actions/ContextMenuItem.d.ts.map +1 -1
- package/dist/context-actions/ContextMenuItem.js +21 -43
- package/dist/context-actions/ContextMenuItem.js.map +1 -1
- package/dist/context-actions/ContextMenuRoot.js +1 -1
- package/dist/context-actions/ContextMenuRoot.js.map +1 -1
- package/dist/context-actions/GlobalContextAction.js +1 -1
- package/dist/context-actions/GlobalContextAction.js.map +1 -1
- package/dist/context-actions/GlobalContextActions.js.map +1 -1
- package/dist/context-actions/index.js.map +1 -1
- package/dist/declaration.d.js.map +1 -1
- package/dist/dialogs/ActionButtonDialogTrigger.js +1 -2
- package/dist/dialogs/ActionButtonDialogTrigger.js.map +1 -1
- package/dist/dialogs/ConfirmationDialog.js +1 -2
- package/dist/dialogs/ConfirmationDialog.js.map +1 -1
- package/dist/dialogs/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/menu-actions/DropdownMenu.js +2 -2
- package/dist/menu-actions/DropdownMenu.js.map +1 -1
- package/dist/menu-actions/Menu.js +4 -6
- package/dist/menu-actions/Menu.js.map +1 -1
- package/dist/menu-actions/index.js.map +1 -1
- package/dist/modal/DebouncedModal.js +1 -3
- package/dist/modal/DebouncedModal.js.map +1 -1
- package/dist/modal/InfoModal.js +1 -2
- package/dist/modal/InfoModal.js.map +1 -1
- package/dist/modal/Modal.js +2 -3
- package/dist/modal/Modal.js.map +1 -1
- package/dist/modal/ModalBody.js.map +1 -1
- package/dist/modal/ModalFooter.js.map +1 -1
- package/dist/modal/ModalHeader.js +1 -2
- package/dist/modal/ModalHeader.js.map +1 -1
- package/dist/modal/index.js.map +1 -1
- package/dist/navigation/DashboardList.js +3 -4
- package/dist/navigation/DashboardList.js.map +1 -1
- package/dist/navigation/Menu.js.map +1 -1
- package/dist/navigation/MenuItem.js +1 -2
- package/dist/navigation/MenuItem.js.map +1 -1
- package/dist/navigation/NavTab.d.ts +1 -1
- package/dist/navigation/NavTab.d.ts.map +1 -1
- package/dist/navigation/NavTab.js +4 -5
- package/dist/navigation/NavTab.js.map +1 -1
- package/dist/navigation/NavTabList.js +4 -5
- package/dist/navigation/NavTabList.js.map +1 -1
- package/dist/navigation/Page.js +1 -2
- package/dist/navigation/Page.js.map +1 -1
- package/dist/navigation/Stack.js +1 -3
- package/dist/navigation/Stack.js.map +1 -1
- package/dist/navigation/index.js.map +1 -1
- package/dist/popper/Popper.d.ts +1 -14
- package/dist/popper/Popper.d.ts.map +1 -1
- package/dist/popper/Popper.js +18 -29
- package/dist/popper/Popper.js.map +1 -1
- package/dist/popper/Tooltip.d.ts.map +1 -1
- package/dist/popper/Tooltip.js +18 -12
- package/dist/popper/Tooltip.js.map +1 -1
- package/dist/popper/index.js.map +1 -1
- package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
- package/dist/shortcuts/NavigationShortcuts.js.map +1 -1
- package/dist/shortcuts/Shortcut.js +11 -13
- package/dist/shortcuts/Shortcut.js.map +1 -1
- package/dist/shortcuts/ShortcutRegistry.js +1 -1
- package/dist/shortcuts/ShortcutRegistry.js.map +1 -1
- package/dist/shortcuts/index.js.map +1 -1
- package/dist/spectrum/ActionGroup.js.map +1 -1
- package/dist/spectrum/ActionMenu.js.map +1 -1
- package/dist/spectrum/CheckboxGroup.js.map +1 -1
- package/dist/spectrum/Heading.js.map +1 -1
- package/dist/spectrum/ItemContent.js +2 -4
- package/dist/spectrum/ItemContent.js.map +1 -1
- package/dist/spectrum/ItemTooltip.js.map +1 -1
- package/dist/spectrum/ListActionGroup.js.map +1 -1
- package/dist/spectrum/ListActionMenu.js.map +1 -1
- package/dist/spectrum/TabPanels.d.ts.map +1 -1
- package/dist/spectrum/TabPanels.js +8 -5
- package/dist/spectrum/TabPanels.js.map +1 -1
- package/dist/spectrum/Text.js.map +1 -1
- package/dist/spectrum/View.js.map +1 -1
- package/dist/spectrum/buttons.js.map +1 -1
- package/dist/spectrum/collections.js.map +1 -1
- package/dist/spectrum/comboBox/ComboBox.js.map +1 -1
- package/dist/spectrum/comboBox/ComboBoxNormalized.js.map +1 -1
- package/dist/spectrum/comboBox/index.js.map +1 -1
- package/dist/spectrum/content.js.map +1 -1
- package/dist/spectrum/dateAndTime.js.map +1 -1
- package/dist/spectrum/forms.js.map +1 -1
- package/dist/spectrum/icons.js.map +1 -1
- package/dist/spectrum/index.js.map +1 -1
- package/dist/spectrum/layout.js.map +1 -1
- package/dist/spectrum/listView/ListView.js.map +1 -1
- package/dist/spectrum/listView/ListViewNormalized.js +1 -2
- package/dist/spectrum/listView/ListViewNormalized.js.map +1 -1
- package/dist/spectrum/listView/ListViewWrapper.js.map +1 -1
- package/dist/spectrum/listView/index.js.map +1 -1
- package/dist/spectrum/navigation.js.map +1 -1
- package/dist/spectrum/overlays.js.map +1 -1
- package/dist/spectrum/picker/Picker.js.map +1 -1
- package/dist/spectrum/picker/PickerNormalized.js.map +1 -1
- package/dist/spectrum/picker/PickerProps.js.map +1 -1
- package/dist/spectrum/picker/index.js.map +1 -1
- package/dist/spectrum/picker/usePickerItemScale.js.map +1 -1
- package/dist/spectrum/picker/usePickerNormalizedProps.d.ts +1 -2
- package/dist/spectrum/picker/usePickerNormalizedProps.d.ts.map +1 -1
- package/dist/spectrum/picker/usePickerNormalizedProps.js.map +1 -1
- package/dist/spectrum/picker/usePickerProps.js.map +1 -1
- package/dist/spectrum/picker/usePickerScrollOnOpen.js +1 -1
- package/dist/spectrum/picker/usePickerScrollOnOpen.js.map +1 -1
- package/dist/spectrum/shared.js.map +1 -1
- package/dist/spectrum/status.js.map +1 -1
- package/dist/spectrum/utils/index.js.map +1 -1
- package/dist/spectrum/utils/itemUtils.d.ts +2 -2
- package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
- package/dist/spectrum/utils/itemUtils.js +5 -1
- package/dist/spectrum/utils/itemUtils.js.map +1 -1
- package/dist/spectrum/utils/itemWrapperUtils.js +3 -4
- package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -1
- package/dist/spectrum/utils/propsUtils.js.map +1 -1
- package/dist/spectrum/utils/themeUtils.js.map +1 -1
- package/dist/spectrum/utils/useOnChangeTrackUncontrolled.js +1 -1
- package/dist/spectrum/utils/useOnChangeTrackUncontrolled.js.map +1 -1
- package/dist/spectrum/utils/useRenderNormalizedItem.js +1 -2
- package/dist/spectrum/utils/useRenderNormalizedItem.js.map +1 -1
- package/dist/spectrum/utils/useStaticItemInitialScrollPosition.js +1 -1
- package/dist/spectrum/utils/useStaticItemInitialScrollPosition.js.map +1 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts +1 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts.map +1 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.js.map +1 -1
- package/dist/spectrum/utils/useStringifiedSelection.d.ts +1 -1
- package/dist/spectrum/utils/useStringifiedSelection.d.ts.map +1 -1
- package/dist/spectrum/utils/useStringifiedSelection.js.map +1 -1
- package/dist/theme/Logo.js.map +1 -1
- package/dist/theme/SpectrumThemeProvider.js.map +1 -1
- package/dist/theme/ThemeModel.js +1 -0
- package/dist/theme/ThemeModel.js.map +1 -1
- package/dist/theme/ThemePicker.d.ts.map +1 -1
- package/dist/theme/ThemePicker.js +3 -1
- package/dist/theme/ThemePicker.js.map +1 -1
- package/dist/theme/ThemeProvider.js +1 -3
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/ThemeUtils.js.map +1 -1
- package/dist/theme/colorUtils.js.map +1 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/theme-dark/index.js.map +1 -1
- package/dist/theme/theme-light/index.js.map +1 -1
- package/dist/theme/theme-spectrum/index.js.map +1 -1
- package/dist/theme/useExternalTheme.js.map +1 -1
- package/dist/theme/useSpectrumThemeProvider.js.map +1 -1
- package/dist/theme/useTheme.js.map +1 -1
- package/dist/transitions/FadeTransition.js.map +1 -1
- package/dist/transitions/SlideTransition.js.map +1 -1
- package/dist/transitions/index.js.map +1 -1
- package/package.json +12 -13
package/dist/UISwitch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UISwitch.js","names":["React","classNames","jsx","_jsx","UISwitch","_ref","on","id","className","isInvalid","disabled","onClick","dataTestId","type","active","children"],"sources":["../src/UISwitch.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport './UISwitch.scss';\n\nexport type UISwitchProps = {\n on: boolean;\n onClick: React.MouseEventHandler<HTMLButtonElement>;\n id?: string;\n className?: string;\n isInvalid?: boolean;\n disabled?: boolean;\n 'data-testid'?: string;\n};\n\nfunction UISwitch({\n on,\n id,\n className,\n isInvalid,\n disabled = false,\n onClick,\n 'data-testid': dataTestId,\n}: UISwitchProps): JSX.Element {\n return (\n <button\n type=\"button\"\n className={classNames(\n 'btn',\n 'btn-switch',\n className,\n { active: on },\n { 'is-invalid': isInvalid }\n )}\n id={id}\n onClick={onClick}\n disabled={disabled}\n data-testid={dataTestId}\n >\n <div className=\"handle\" />\n </button>\n );\n}\n\nexport default UISwitch;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAAC;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAapC,SAASC,QAAQA,CAAAC,IAAA,EAQc;EAAA,IARb;IAChBC,EAAE;IACFC,EAAE;IACFC,SAAS;IACTC,SAAS;IACTC,QAAQ,GAAG,KAAK;IAChBC,OAAO;IACP,aAAa,EAAEC;EACF,CAAC,GAAAP,IAAA;EACd,
|
|
1
|
+
{"version":3,"file":"UISwitch.js","names":["React","classNames","jsx","_jsx","UISwitch","_ref","on","id","className","isInvalid","disabled","onClick","dataTestId","type","active","children"],"sources":["../src/UISwitch.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport './UISwitch.scss';\n\nexport type UISwitchProps = {\n on: boolean;\n onClick: React.MouseEventHandler<HTMLButtonElement>;\n id?: string;\n className?: string;\n isInvalid?: boolean;\n disabled?: boolean;\n 'data-testid'?: string;\n};\n\nfunction UISwitch({\n on,\n id,\n className,\n isInvalid,\n disabled = false,\n onClick,\n 'data-testid': dataTestId,\n}: UISwitchProps): JSX.Element {\n return (\n // eslint-disable-next-line jsx-a11y/control-has-associated-label\n <button\n type=\"button\"\n className={classNames(\n 'btn',\n 'btn-switch',\n className,\n { active: on },\n { 'is-invalid': isInvalid }\n )}\n id={id}\n onClick={onClick}\n disabled={disabled}\n data-testid={dataTestId}\n >\n <div className=\"handle\" />\n </button>\n );\n}\n\nexport default UISwitch;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAAC;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAapC,SAASC,QAAQA,CAAAC,IAAA,EAQc;EAAA,IARb;IAChBC,EAAE;IACFC,EAAE;IACFC,SAAS;IACTC,SAAS;IACTC,QAAQ,GAAG,KAAK;IAChBC,OAAO;IACP,aAAa,EAAEC;EACF,CAAC,GAAAP,IAAA;EACd;IAAA;IACE;IACAF,IAAA;MACEU,IAAI,EAAC,QAAQ;MACbL,SAAS,EAAEP,UAAU,CACnB,KAAK,EACL,YAAY,EACZO,SAAS,EACT;QAAEM,MAAM,EAAER;MAAG,CAAC,EACd;QAAE,YAAY,EAAEG;MAAU,CAC5B,CAAE;MACFF,EAAE,EAAEA,EAAG;MACPI,OAAO,EAAEA,OAAQ;MACjBD,QAAQ,EAAEA,QAAS;MACnB,eAAaE,UAAW;MAAAG,QAAA,eAExBZ,IAAA;QAAKK,SAAS,EAAC;MAAQ,CAAE;IAAC,CACpB;EAAC;AAEb;AAEA,eAAeJ,QAAQ","ignoreList":[]}
|
package/dist/XComponent.d.ts
CHANGED
|
@@ -33,6 +33,6 @@ import { type XComponentType } from './XComponentMap';
|
|
|
33
33
|
* @param Component The component to wrap
|
|
34
34
|
* @returns The wrapped component
|
|
35
35
|
*/
|
|
36
|
-
export declare function createXComponent<P extends Record<string, unknown>>(Component: React.ComponentType<P
|
|
36
|
+
export declare function createXComponent<P extends Record<string, unknown>>(Component: React.ComponentType<React.PropsWithoutRef<P>>): XComponentType<P>;
|
|
37
37
|
export default createXComponent;
|
|
38
38
|
//# sourceMappingURL=XComponent.d.ts.map
|
package/dist/XComponent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XComponent.d.ts","sourceRoot":"","sources":["../src/XComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"XComponent.d.ts","sourceRoot":"","sources":["../src/XComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GACvD,cAAc,CAAC,CAAC,CAAC,CA6BnB;AAED,eAAe,gBAAgB,CAAC"}
|
package/dist/XComponent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XComponent.js","names":["React","forwardRef","canHaveRef","useXComponent","jsx","_jsx","createXComponent","Component","_Component$displayNam","forwardedRefComponent","XComponent","props","ref","ReplacementComponent","_objectSpread","displayName","concat","name","Original","isXComponent"],"sources":["../src/XComponent.tsx"],"sourcesContent":["import React, { type ComponentType, forwardRef } from 'react';\nimport { canHaveRef } from './ComponentUtils';\nimport { useXComponent, type XComponentType } from './XComponentMap';\n\n/**\n * Helper function that will wrap the provided component, and return an ExtendableComponent type.\n * Whenever that ExtendableComponent is used, it will check if there is a replacement component for the provided component on the context.\n * If there is, it will use that component instead of the provided component.\n * This is a similar concept to how swizzling is done in Docusaurus or obj-c, but for any React component.\n *\n * Usage:\n *\n * ```tsx\n * function MyComponent() {\n * return <div>MyComponent</div>;\n * }\n *\n * const XMyComponent = extendableComponent(MyComponent);\n *\n * function MyReplacementComponent() {\n * return <div>MyReplacementComponent</div>;\n * }\n *\n * <XMyComponent /> // Will render MyComponent\n *\n * <XComponentMapProvider value={new Map([[XMyComponent, MyReplacementComponent]])}>\n * <XMyComponent /> // Will render MyReplacementComponent\n * </XComponentMapProvider>\n *\n * ```\n *\n * Is useful in cases where we have a component deep down in the component tree that we want to replace with a different component, but don't want to\n * have to provide props at the top level just to hook into that.\n *\n * @param Component The component to wrap\n * @returns The wrapped component\n */\nexport function createXComponent<P extends Record<string, unknown>>(\n Component: React.ComponentType<P
|
|
1
|
+
{"version":3,"file":"XComponent.js","names":["React","forwardRef","canHaveRef","useXComponent","jsx","_jsx","createXComponent","Component","_Component$displayNam","forwardedRefComponent","XComponent","props","ref","ReplacementComponent","_objectSpread","displayName","concat","name","Original","isXComponent"],"sources":["../src/XComponent.tsx"],"sourcesContent":["import React, { type ComponentType, forwardRef } from 'react';\nimport { canHaveRef } from './ComponentUtils';\nimport { useXComponent, type XComponentType } from './XComponentMap';\n\n/**\n * Helper function that will wrap the provided component, and return an ExtendableComponent type.\n * Whenever that ExtendableComponent is used, it will check if there is a replacement component for the provided component on the context.\n * If there is, it will use that component instead of the provided component.\n * This is a similar concept to how swizzling is done in Docusaurus or obj-c, but for any React component.\n *\n * Usage:\n *\n * ```tsx\n * function MyComponent() {\n * return <div>MyComponent</div>;\n * }\n *\n * const XMyComponent = extendableComponent(MyComponent);\n *\n * function MyReplacementComponent() {\n * return <div>MyReplacementComponent</div>;\n * }\n *\n * <XMyComponent /> // Will render MyComponent\n *\n * <XComponentMapProvider value={new Map([[XMyComponent, MyReplacementComponent]])}>\n * <XMyComponent /> // Will render MyReplacementComponent\n * </XComponentMapProvider>\n *\n * ```\n *\n * Is useful in cases where we have a component deep down in the component tree that we want to replace with a different component, but don't want to\n * have to provide props at the top level just to hook into that.\n *\n * @param Component The component to wrap\n * @returns The wrapped component\n */\nexport function createXComponent<P extends Record<string, unknown>>(\n Component: React.ComponentType<React.PropsWithoutRef<P>>\n): XComponentType<P> {\n let forwardedRefComponent: XComponentType<P>;\n function XComponent(\n props: React.PropsWithoutRef<P>,\n ref: React.ForwardedRef<ComponentType<P>>\n ): JSX.Element {\n const ReplacementComponent = useXComponent<P>(forwardedRefComponent);\n return canHaveRef(Component) ? (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <ReplacementComponent {...props} ref={ref} />\n ) : (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <ReplacementComponent {...props} />\n );\n }\n\n // Add the display name so this appears as a tag in the React DevTools\n // Need to add it here, and then when it's wrapped with the `forwardRef` it will automatically get the display name of the original component\n XComponent.displayName = `XComponent(${\n Component.displayName ?? Component.name\n })`;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwardedRefComponent = forwardRef(XComponent) as XComponentType<P>;\n\n forwardedRefComponent.Original = Component;\n forwardedRefComponent.isXComponent = true;\n\n return forwardedRefComponent;\n}\n\nexport default createXComponent;\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,IAAwBC,UAAU,QAAQ,OAAO;AAAC,SACrDC,UAAU;AAAA,SACVC,aAAa;AAEtB;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;AACA;AACA;AACA;AACA;AACA;AACA;AAhCA,SAAAC,GAAA,IAAAC,IAAA;AAiCA,OAAO,SAASC,gBAAgBA,CAC9BC,SAAwD,EACrC;EAAA,IAAAC,qBAAA;EACnB,IAAIC,qBAAwC;EAC5C,SAASC,UAAUA,CACjBC,KAA+B,EAC/BC,GAAyC,EAC5B;IACb,IAAMC,oBAAoB,GAAGV,aAAa,CAAIM,qBAAqB,CAAC;IACpE,OAAOP,UAAU,CAACK,SAAS,CAAC;IAAA;IAC1B;IACAF,IAAA,CAACQ,oBAAoB,EAAAC,aAAA,CAAAA,aAAA,KAAKH,KAAK;MAAEC,GAAG,EAAEA;IAAI,EAAE,CAAC;IAAA;IAE7C;IACAP,IAAA,CAACQ,oBAAoB,EAAAC,aAAA,KAAKH,KAAK,CAAG,CACnC;EACH;;EAEA;EACA;EACAD,UAAU,CAACK,WAAW,iBAAAC,MAAA,EAAAR,qBAAA,GACpBD,SAAS,CAACQ,WAAW,cAAAP,qBAAA,cAAAA,qBAAA,GAAID,SAAS,CAACU,IAAI,MACtC;;EAEH;EACAR,qBAAqB,gBAAGR,UAAU,CAACS,UAAU,CAAsB;EAEnED,qBAAqB,CAACS,QAAQ,GAAGX,SAAS;EAC1CE,qBAAqB,CAACU,YAAY,GAAG,IAAI;EAEzC,OAAOV,qBAAqB;AAC9B;AAEA,eAAeH,gBAAgB","ignoreList":[]}
|
package/dist/XComponentMap.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
/** Type for an extended component. Can fetch the original component using `.Original` */
|
|
3
3
|
export type XComponentType<P extends Record<string, unknown>> = React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<unknown>> & {
|
|
4
|
-
Original: React.ComponentType<P
|
|
4
|
+
Original: React.ComponentType<React.PropsWithoutRef<P>>;
|
|
5
5
|
isXComponent: boolean;
|
|
6
6
|
};
|
|
7
7
|
export declare const XComponentMapContext: React.Context<Map<React.ComponentType<any>, React.ComponentType<any>>>;
|
|
@@ -11,5 +11,5 @@ export declare const XComponentMapProvider: React.Provider<Map<React.ComponentTy
|
|
|
11
11
|
* @param Component Component to check if there's a replacement for
|
|
12
12
|
* @returns The replacement component if it exists, otherwise the original component
|
|
13
13
|
*/
|
|
14
|
-
export declare function useXComponent<P extends Record<string, unknown>>(Component: XComponentType<P>): React.ComponentType<P
|
|
14
|
+
export declare function useXComponent<P extends Record<string, unknown>>(Component: XComponentType<P>): React.ComponentType<React.PropsWithoutRef<P>>;
|
|
15
15
|
//# sourceMappingURL=XComponentMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XComponentMap.d.ts","sourceRoot":"","sources":["../src/XComponentMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,yFAAyF;AACzF,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC1D,KAAK,CAAC,yBAAyB,CAC7B,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CACxD,GAAG;IACF,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"XComponentMap.d.ts","sourceRoot":"","sources":["../src/XComponentMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,yFAAyF;AACzF,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC1D,KAAK,CAAC,yBAAyB,CAC7B,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CACxD,GAAG;IACF,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEJ,eAAO,MAAM,oBAAoB,wEAGhC,CAAC;AAGF,eAAO,MAAM,qBAAqB,yEAAgC,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,GAC3B,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAG/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XComponentMap.js","names":["React","useContext","XComponentMapContext","createContext","Map","displayName","XComponentMapProvider","Provider","useXComponent","Component","_ctx$get","ctx","get","Original"],"sources":["../src/XComponentMap.ts"],"sourcesContent":["import React, { useContext } from 'react';\n\n/** Type for an extended component. Can fetch the original component using `.Original` */\nexport type XComponentType<P extends Record<string, unknown>> =\n React.ForwardRefExoticComponent<\n React.PropsWithoutRef<P> & React.RefAttributes<unknown>\n > & {\n Original: React.ComponentType<P
|
|
1
|
+
{"version":3,"file":"XComponentMap.js","names":["React","useContext","XComponentMapContext","createContext","Map","displayName","XComponentMapProvider","Provider","useXComponent","Component","_ctx$get","ctx","get","Original"],"sources":["../src/XComponentMap.ts"],"sourcesContent":["import React, { useContext } from 'react';\n\n/** Type for an extended component. Can fetch the original component using `.Original` */\nexport type XComponentType<P extends Record<string, unknown>> =\n React.ForwardRefExoticComponent<\n React.PropsWithoutRef<P> & React.RefAttributes<unknown>\n > & {\n Original: React.ComponentType<React.PropsWithoutRef<P>>;\n isXComponent: boolean;\n };\n\nexport const XComponentMapContext = React.createContext(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new Map<React.ComponentType<any>, React.ComponentType<any>>()\n);\nXComponentMapContext.displayName = 'XComponentMapContext';\n\nexport const XComponentMapProvider = XComponentMapContext.Provider;\n\n/**\n * Use the replacement component for the provided component if it exists, or just return the provided component.\n * @param Component Component to check if there's a replacement for\n * @returns The replacement component if it exists, otherwise the original component\n */\nexport function useXComponent<P extends Record<string, unknown>>(\n Component: XComponentType<P>\n): React.ComponentType<React.PropsWithoutRef<P>> {\n const ctx = useContext(XComponentMapContext);\n return ctx.get(Component) ?? Component.Original;\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;;AAEzC;;AASA,OAAO,IAAMC,oBAAoB,gBAAGF,KAAK,CAACG,aAAa;AACrD;AACA,IAAIC,GAAG,CAAqD,CAC9D,CAAC;AACDF,oBAAoB,CAACG,WAAW,GAAG,sBAAsB;AAEzD,OAAO,IAAMC,qBAAqB,GAAGJ,oBAAoB,CAACK,QAAQ;;AAElE;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BC,SAA4B,EACmB;EAAA,IAAAC,QAAA;EAC/C,IAAMC,GAAG,GAAGV,UAAU,CAACC,oBAAoB,CAAC;EAC5C,QAAAQ,QAAA,GAAOC,GAAG,CAACC,GAAG,CAACH,SAAS,CAAC,cAAAC,QAAA,cAAAA,QAAA,GAAID,SAAS,CAACI,QAAQ;AACjD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmActionButton.js","names":["useCallback","vsTrash","ActionButtonDialogTrigger","ConfirmationDialog","ACTION_ICON_HEIGHT","jsx","_jsx","ConfirmActionButton","_ref","ariaLabel","heading","confirmationButtonLabel","isHidden","children","tooltip","onConfirm","renderDialog","close","onCancel","icon","isQuiet","height"],"sources":["../../src/actions/ConfirmActionButton.tsx"],"sourcesContent":["import { type ReactElement, type ReactNode, useCallback } from 'react';\nimport type { SpectrumLabelableProps } from '@react-types/shared';\nimport { vsTrash } from '@deephaven/icons';\nimport { ActionButtonDialogTrigger, ConfirmationDialog } from '../dialogs';\nimport { ACTION_ICON_HEIGHT } from '../UIConstants';\n\nexport interface ConfirmActionButtonProps {\n ariaLabel: string;\n heading: ReactNode;\n confirmationButtonLabel: string;\n children:\n | ReactElement<SpectrumLabelableProps>\n | ReactElement<SpectrumLabelableProps>[];\n isHidden?: boolean;\n tooltip?: string;\n onConfirm: () => void;\n}\n\nexport function ConfirmActionButton({\n ariaLabel,\n heading,\n confirmationButtonLabel,\n isHidden,\n children,\n tooltip,\n onConfirm,\n}: ConfirmActionButtonProps): JSX.Element {\n const renderDialog = useCallback(\n close => (\n <ConfirmationDialog\n heading={heading}\n confirmationButtonLabel={confirmationButtonLabel}\n onCancel={close}\n onConfirm={() => {\n close();\n onConfirm();\n }}\n >\n {children}\n </ConfirmationDialog>\n ),\n [children, confirmationButtonLabel, heading, onConfirm]\n );\n\n return (\n <ActionButtonDialogTrigger\n ariaLabel={ariaLabel}\n icon={vsTrash}\n isHidden={isHidden}\n isQuiet\n height={ACTION_ICON_HEIGHT}\n tooltip={tooltip}\n >\n {renderDialog}\n </ActionButtonDialogTrigger>\n );\n}\n\nexport default ConfirmActionButton;\n"],"mappings":"AAAA,SAA4CA,WAAW,QAAQ,OAAO;AAEtE,SAASC,OAAO,QAAQ,kBAAkB;AAAC,SAClCC,yBAAyB,EAAEC,kBAAkB;AAAA,SAC7CC,kBAAkB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAc3B,OAAO,SAASC,mBAAmBA,CAAAC,IAAA,EAQO;EAAA,IARN;IAClCC,SAAS;IACTC,OAAO;IACPC,uBAAuB;IACvBC,QAAQ;IACRC,QAAQ;IACRC,OAAO;IACPC,SAAS,EAATA;EACwB,CAAC,GAAAP,IAAA;EACzB,IAAMQ,YAAY,GAAGhB,WAAW,
|
|
1
|
+
{"version":3,"file":"ConfirmActionButton.js","names":["useCallback","vsTrash","ActionButtonDialogTrigger","ConfirmationDialog","ACTION_ICON_HEIGHT","jsx","_jsx","ConfirmActionButton","_ref","ariaLabel","heading","confirmationButtonLabel","isHidden","children","tooltip","onConfirm","renderDialog","close","onCancel","icon","isQuiet","height"],"sources":["../../src/actions/ConfirmActionButton.tsx"],"sourcesContent":["import { type ReactElement, type ReactNode, useCallback } from 'react';\nimport type { SpectrumLabelableProps } from '@react-types/shared';\nimport { vsTrash } from '@deephaven/icons';\nimport { ActionButtonDialogTrigger, ConfirmationDialog } from '../dialogs';\nimport { ACTION_ICON_HEIGHT } from '../UIConstants';\n\nexport interface ConfirmActionButtonProps {\n ariaLabel: string;\n heading: ReactNode;\n confirmationButtonLabel: string;\n children:\n | ReactElement<SpectrumLabelableProps>\n | ReactElement<SpectrumLabelableProps>[];\n isHidden?: boolean;\n tooltip?: string;\n onConfirm: () => void;\n}\n\nexport function ConfirmActionButton({\n ariaLabel,\n heading,\n confirmationButtonLabel,\n isHidden,\n children,\n tooltip,\n onConfirm,\n}: ConfirmActionButtonProps): JSX.Element {\n const renderDialog = useCallback(\n (close: () => void) => (\n <ConfirmationDialog\n heading={heading}\n confirmationButtonLabel={confirmationButtonLabel}\n onCancel={close}\n onConfirm={() => {\n close();\n onConfirm();\n }}\n >\n {children}\n </ConfirmationDialog>\n ),\n [children, confirmationButtonLabel, heading, onConfirm]\n );\n\n return (\n <ActionButtonDialogTrigger\n ariaLabel={ariaLabel}\n icon={vsTrash}\n isHidden={isHidden}\n isQuiet\n height={ACTION_ICON_HEIGHT}\n tooltip={tooltip}\n >\n {renderDialog}\n </ActionButtonDialogTrigger>\n );\n}\n\nexport default ConfirmActionButton;\n"],"mappings":"AAAA,SAA4CA,WAAW,QAAQ,OAAO;AAEtE,SAASC,OAAO,QAAQ,kBAAkB;AAAC,SAClCC,yBAAyB,EAAEC,kBAAkB;AAAA,SAC7CC,kBAAkB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAc3B,OAAO,SAASC,mBAAmBA,CAAAC,IAAA,EAQO;EAAA,IARN;IAClCC,SAAS;IACTC,OAAO;IACPC,uBAAuB;IACvBC,QAAQ;IACRC,QAAQ;IACRC,OAAO;IACPC,SAAS,EAATA;EACwB,CAAC,GAAAP,IAAA;EACzB,IAAMQ,YAAY,GAAGhB,WAAW,CAC7BiB,KAAiB,iBAChBX,IAAA,CAACH,kBAAkB;IACjBO,OAAO,EAAEA,OAAQ;IACjBC,uBAAuB,EAAEA,uBAAwB;IACjDO,QAAQ,EAAED,KAAM;IAChBF,SAAS,EAAEA,CAAA,KAAM;MACfE,KAAK,CAAC,CAAC;MACPF,UAAS,CAAC,CAAC;IACb,CAAE;IAAAF,QAAA,EAEDA;EAAQ,CACS,CACrB,EACD,CAACA,QAAQ,EAAEF,uBAAuB,EAAED,OAAO,EAAEK,UAAS,CACxD,CAAC;EAED,oBACET,IAAA,CAACJ,yBAAyB;IACxBO,SAAS,EAAEA,SAAU;IACrBU,IAAI,EAAElB,OAAQ;IACdW,QAAQ,EAAEA,QAAS;IACnBQ,OAAO;IACPC,MAAM,EAAEjB,kBAAmB;IAC3BU,OAAO,EAAEA,OAAQ;IAAAD,QAAA,EAEhBG;EAAY,CACY,CAAC;AAEhC;AAEA,eAAeT,mBAAmB","ignoreList":[]}
|
|
@@ -11,8 +11,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
11
11
|
import { ActionButton, Icon } from "../spectrum/index.js";
|
|
12
12
|
import { Tooltip } from "../popper/index.js";
|
|
13
13
|
import { ACTION_ICON_HEIGHT } from "../UIConstants.js";
|
|
14
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
15
|
export function IconActionButton(_ref) {
|
|
17
16
|
var {
|
|
18
17
|
icon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconActionButton.js","names":["FontAwesomeIcon","ActionButton","Icon","Tooltip","ACTION_ICON_HEIGHT","jsx","_jsx","jsxs","_jsxs","IconActionButton","_ref","icon","label","tooltip","props","_objectWithoutProperties","_excluded","_objectSpread","isQuiet","height","children","UNSAFE_className","undefined","displayName"],"sources":["../../src/actions/IconActionButton.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport type { IconProp } from '@fortawesome/fontawesome-svg-core';\nimport { ActionButton, Icon, type ActionButtonProps } from '../spectrum';\nimport { Tooltip } from '../popper';\nimport { ACTION_ICON_HEIGHT } from '../UIConstants';\n\nexport interface IconActionButtonProps\n extends Omit<ActionButtonProps, 'aria-label' | 'isQuiet' | 'height'> {\n icon: IconProp;\n label: string;\n tooltip?: string;\n}\n\nexport function IconActionButton({\n icon,\n label,\n tooltip,\n ...props\n}: IconActionButtonProps): JSX.Element {\n return (\n <ActionButton\n {...props}\n aria-label={label}\n isQuiet\n height={ACTION_ICON_HEIGHT}\n >\n <Icon\n UNSAFE_className={\n tooltip == null ? undefined : 'action-button-icon-with-tooltip'\n }\n >\n <FontAwesomeIcon icon={icon} />\n </Icon>\n {tooltip == null ? null : <Tooltip>{tooltip}</Tooltip>}\n </ActionButton>\n );\n}\nIconActionButton.displayName = 'IconActionButton';\n\nexport default IconActionButton;\n"],"mappings":";;;;;;;;AAAA;AACA,SAASA,eAAe,QAAQ,gCAAgC;AAAC,SAExDC,YAAY,EAAEC,IAAI;AAAA,SAClBC,OAAO;AAAA,SACPC,kBAAkB;AAAA,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"file":"IconActionButton.js","names":["FontAwesomeIcon","ActionButton","Icon","Tooltip","ACTION_ICON_HEIGHT","jsx","_jsx","jsxs","_jsxs","IconActionButton","_ref","icon","label","tooltip","props","_objectWithoutProperties","_excluded","_objectSpread","isQuiet","height","children","UNSAFE_className","undefined","displayName"],"sources":["../../src/actions/IconActionButton.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport type { IconProp } from '@fortawesome/fontawesome-svg-core';\nimport { ActionButton, Icon, type ActionButtonProps } from '../spectrum';\nimport { Tooltip } from '../popper';\nimport { ACTION_ICON_HEIGHT } from '../UIConstants';\n\nexport interface IconActionButtonProps\n extends Omit<ActionButtonProps, 'aria-label' | 'isQuiet' | 'height'> {\n icon: IconProp;\n label: string;\n tooltip?: string;\n}\n\nexport function IconActionButton({\n icon,\n label,\n tooltip,\n ...props\n}: IconActionButtonProps): JSX.Element {\n return (\n <ActionButton\n {...props}\n aria-label={label}\n isQuiet\n height={ACTION_ICON_HEIGHT}\n >\n <Icon\n UNSAFE_className={\n tooltip == null ? undefined : 'action-button-icon-with-tooltip'\n }\n >\n <FontAwesomeIcon icon={icon} />\n </Icon>\n {tooltip == null ? null : <Tooltip>{tooltip}</Tooltip>}\n </ActionButton>\n );\n}\nIconActionButton.displayName = 'IconActionButton';\n\nexport default IconActionButton;\n"],"mappings":";;;;;;;;AAAA;AACA,SAASA,eAAe,QAAQ,gCAAgC;AAAC,SAExDC,YAAY,EAAEC,IAAI;AAAA,SAClBC,OAAO;AAAA,SACPC,kBAAkB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAS3B,OAAO,SAASC,gBAAgBA,CAAAC,IAAA,EAKO;EAAA,IALN;MAC/BC,IAAI;MACJC,KAAK;MACLC;IAEqB,CAAC,GAAAH,IAAA;IADnBI,KAAK,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EAER,oBACER,KAAA,CAACP,YAAY,EAAAgB,aAAA,CAAAA,aAAA,KACPH,KAAK;IACT,cAAYF,KAAM;IAClBM,OAAO;IACPC,MAAM,EAAEf,kBAAmB;IAAAgB,QAAA,gBAE3Bd,IAAA,CAACJ,IAAI;MACHmB,gBAAgB,EACdR,OAAO,IAAI,IAAI,GAAGS,SAAS,GAAG,iCAC/B;MAAAF,QAAA,eAEDd,IAAA,CAACN,eAAe;QAACW,IAAI,EAAEA;MAAK,CAAE;IAAC,CAC3B,CAAC,EACNE,OAAO,IAAI,IAAI,GAAG,IAAI,gBAAGP,IAAA,CAACH,OAAO;MAAAiB,QAAA,EAAEP;IAAO,CAAU,CAAC;EAAA,EAC1C,CAAC;AAEnB;AACAJ,gBAAgB,CAACc,WAAW,GAAG,kBAAkB;AAEjD,eAAed,gBAAgB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/actions/index.ts"],"sourcesContent":["export * from './ConfirmActionButton';\nexport * from './IconActionButton';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/actions/index.ts"],"sourcesContent":["export * from './ConfirmActionButton';\nexport * from './IconActionButton';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -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","_a$group","_b$group","order","_a$order","_b$order","title","_a$title","_b$title","sortActions","actions","sortedActions","slice","sort","isMacPlatform","platform","window","navigator","startsWith","getModifierKey","isModifierKeyDown","event","modifierKey","getMenuItems","actionsParam","includePromises","arguments","length","menuItems","i","action","newMenuItems","Promise","push","concat","filter","menuElement","getNextMenuItem","startIndex","delta","firstIndex","menuIndex","item","disabled","_defineProperty"],"sources":["../../src/context-actions/ContextActionUtils.ts"],"sourcesContent":["import { type IconDefinition } from '@deephaven/icons';\nimport type 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 | JSX.Element;\n description?: string;\n action?: (event: Event) => void;\n actions?: ResolvableContextAction[];\n icon?: IconDefinition | React.ReactElement<unknown>;\n iconColor?: string;\n shortcut?: Shortcut;\n\n /* Display text for the shortcut if the shortcut is not wired up through the Shortcut class */\n shortcutText?: string;\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":";;;AAkCA,OAAO,SA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AC,EAAE;MAC/B;MACAC,UAAU,GAAGZ,SAAS,CAACD,MAAM;IAC/B;IACA;IACA,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,SAAS,CAACD,MAAM,GAAG,CAAC,EAAEE,CAAC,IAAI,CAAC,EAAE;MAChD,IAAMY,SAAS,GACb,CAACD,UAAU,GAAGD,KAAK,GAAGV,CAAC,GAAGD,SAAS,CAACD,MAAM,IAAIC,SAAS,CAACD,MAAM;MAChE,IAAMe,IAAI,GAAGd,SAAS,CAACa,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;AAACM,eAAA,CAzKKxD,kBAAkB,qBACG,KAAK;AA0KhC,eAAeA,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"ContextActionUtils.js","names":["isPromise","value","then","undefined","ContextActionUtils","disableAllActions","actionsDisabled","enableAllActions","isContextActionEvent","e","Array","isArray","contextActions","compareActions","a","b","group","_a$group","_b$group","order","_a$order","_b$order","title","_a$title","_b$title","sortActions","actions","sortedActions","slice","sort","isMacPlatform","platform","window","navigator","startsWith","getModifierKey","isModifierKeyDown","event","modifierKey","getMenuItems","actionsParam","includePromises","arguments","length","menuItems","i","action","newMenuItems","Promise","push","concat","filter","menuElement","getNextMenuItem","startIndex","delta","firstIndex","menuIndex","item","disabled","_defineProperty"],"sources":["../../src/context-actions/ContextActionUtils.ts"],"sourcesContent":["import { type IconDefinition } from '@deephaven/icons';\nimport type 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 | JSX.Element;\n description?: string;\n action?: (event: Event) => void;\n actions?: ResolvableContextAction[];\n icon?: IconDefinition | React.ReactElement<unknown>;\n iconColor?: string;\n shortcut?: Shortcut;\n\n /* Display text for the shortcut if the shortcut is not wired up through the Shortcut class */\n shortcutText?: string;\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":";;;AAkCA,OAAO,SAASA,SAASA,CAAOC,KAAqB,EAAuB;EAC1E,OAAQA,KAAK,CAAgBC,IAAI,KAAKC,SAAS;AACjD;AAEA,MAAMC,kBAAkB,CAAC;EAGvB,OAAOC,iBAAiBA,CAAA,EAAS;IAC/BD,kBAAkB,CAACE,eAAe,GAAG,IAAI;EAC3C;EAEA,OAAOC,gBAAgBA,CAAA,EAAS;IAC9BH,kBAAkB,CAACE,eAAe,GAAG,KAAK;EAC5C;EAEA,OAAOE,oBAAoBA,CAACC,CAAa,EAA2B;IAClE,OAAOC,KAAK,CAACC,OAAO,CAAEF,CAAC,CAAwBG,cAAc,CAAC;EAChE;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,cAAcA,CAACC,CAAgB,EAAEC,CAAgB,EAAU;IAChE,IAAID,CAAC,CAACE,KAAK,KAAKD,CAAC,CAACC,KAAK,EAAE;MAAA,IAAAC,QAAA,EAAAC,QAAA;MACvB,OAAO,EAAAD,QAAA,GAACH,CAAC,CAACE,KAAK,cAAAC,QAAA,cAAAA,QAAA,GAAI,CAAC,MAAAC,QAAA,GAAKH,CAAC,CAACC,KAAK,cAAAE,QAAA,cAAAA,QAAA,GAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjD;IAEA,IAAIJ,CAAC,CAACK,KAAK,KAAKJ,CAAC,CAACI,KAAK,EAAE;MAAA,IAAAC,QAAA,EAAAC,QAAA;MACvB,OAAO,EAAAD,QAAA,GAACN,CAAC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ACHA,MAAM,CAAmBxB,KAAK,KAAKnB,SAAS,IAC5C2C,MAAM,CAA8B5C,IAAI,IAAI,IAAI,IAChD4C,MAAM,CAAmBM,WAC9B,CAAC;IAED,OAAOR,SAAS;EAClB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOS,eAAeA,CACpBC,UAAkB,EAClBC,KAAa,EACbX,SAAqB,EACb;IACR,IAAIY,UAAU,GAAGF,UAAU;IAC3B,IAAIE,UAAU,GAAG,CAAC,IAAID,KAAK,GAAG,CAAC,EAAE;MAC/B;MACAC,UAAU,GAAGZ,SAAS,CAACD,MAAM;IAC/B;IACA;IACA,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,SAAS,CAACD,MAAM,GAAG,CAAC,EAAEE,CAAC,IAAI,CAAC,EAAE;MAChD,IAAMY,SAAS,GACb,CAACD,UAAU,GAAGD,KAAK,GAAGV,CAAC,GAAGD,SAAS,CAACD,MAAM,IAAIC,SAAS,CAACD,MAAM;MAChE,IAAMe,IAAI,GAAGd,SAAS,CAACa,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;AAACM,eAAA,CAzKKxD,kBAAkB,qBACG,KAAK;AA0KhC,eAAeA,kBAAkB","ignoreList":[]}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Just a simple utility class for displaying a popup menu.
|
|
3
3
|
*/
|
|
4
4
|
import React, { Component } from 'react';
|
|
5
|
-
import { type ResolvableContextAction } from './ContextActionUtils';
|
|
6
|
-
import type { ContextAction } from './ContextActionUtils';
|
|
5
|
+
import { type ResolvableContextAction, type ContextAction } from './ContextActionUtils';
|
|
7
6
|
import './ContextActions.scss';
|
|
8
7
|
interface ContextActionsProps {
|
|
9
8
|
actions?: ResolvableContextAction | ResolvableContextAction[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextActions.d.ts","sourceRoot":"","sources":["../../src/context-actions/ContextActions.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAA2B,EACzB,KAAK,uBAAuB,
|
|
1
|
+
{"version":3,"file":"ContextActions.d.ts","sourceRoot":"","sources":["../../src/context-actions/ContextActions.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAA2B,EACzB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAGnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,uBAAuB,CAAC;AAI/B,UAAU,mBAAmB;IAC3B,OAAO,CAAC,EAAE,uBAAuB,GAAG,uBAAuB,EAAE,CAAC;IAC9D,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,mBAAmB;IAC3B,aAAa,EAAE,aAAa,EAAE,CAAC;IAC/B,eAAe,EAAE,aAAa,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,cAAM,cAAe,SAAQ,SAAS,CACpC,mBAAmB,EACnB,mBAAmB,CACpB;IACC;;;;;OAKG;IACH,MAAM,CAAC,MAAM;;;;;;;MAQX;IAEF,MAAM,CAAC,WAAW,CAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,uBAAuB,EAAE,GACjC,IAAI;gBAmBK,KAAK,EAAE,mBAAmB;IAWtC,MAAM,CAAC,wBAAwB,CAC7B,KAAK,EAAE,mBAAmB,GACzB,mBAAmB;IAmBtB,iBAAiB,IAAI,IAAI;IAazB,oBAAoB,IAAI,IAAI;IAa5B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAE3C,iBAAiB,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;IAgDtC,aAAa,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI;IAqBrC,MAAM,IAAI,GAAG,CAAC,OAAO;CAatB;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -38,13 +38,6 @@ var log = Log.module('ContextActions');
|
|
|
38
38
|
* You should generally have a ContextMenuRoot on the root node of your document.
|
|
39
39
|
*/
|
|
40
40
|
class ContextActions extends Component {
|
|
41
|
-
/**
|
|
42
|
-
* Group you can assign to context menu actions to group them together.
|
|
43
|
-
* Lower group IDs appear at the top of the list.
|
|
44
|
-
* Groups are separated by a separator item.
|
|
45
|
-
* Items within groups are ordered by their order property, then by their title.
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
41
|
static triggerMenu(element, clientX, clientY, actions) {
|
|
49
42
|
if (actions.length === 0) {
|
|
50
43
|
return;
|
|
@@ -104,21 +97,22 @@ class ContextActions extends Component {
|
|
|
104
97
|
if (ignoreClassNames.length > 0) {
|
|
105
98
|
var el = e.target;
|
|
106
99
|
var _loop = function _loop() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
100
|
+
var {
|
|
101
|
+
classList
|
|
102
|
+
} = el;
|
|
103
|
+
var ignoredClassName = ignoreClassNames.find(className => classList.contains(className));
|
|
104
|
+
if (ignoredClassName !== undefined) {
|
|
105
|
+
log.debug2("Contextmenu event ignored based on the target className \"".concat(ignoredClassName, "\""));
|
|
106
|
+
return {
|
|
107
|
+
v: void 0
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
el = el.parentElement;
|
|
111
|
+
},
|
|
112
|
+
_ret;
|
|
119
113
|
while (el != null) {
|
|
120
|
-
|
|
121
|
-
if (
|
|
114
|
+
_ret = _loop();
|
|
115
|
+
if (_ret) return _ret.v;
|
|
122
116
|
}
|
|
123
117
|
}
|
|
124
118
|
if (!ContextActionUtils.isContextActionEvent(e)) {
|
|
@@ -148,7 +142,7 @@ class ContextActions extends Component {
|
|
|
148
142
|
if (!ContextActionUtils.actionsDisabled && keyboardAction.shortcut != null && keyboardAction.shortcut.matchesEvent(e)) {
|
|
149
143
|
var _keyboardAction$actio;
|
|
150
144
|
log.debug('Context hotkey matched!', e);
|
|
151
|
-
(_keyboardAction$actio = keyboardAction.action) === null || _keyboardAction$actio === void 0
|
|
145
|
+
(_keyboardAction$actio = keyboardAction.action) === null || _keyboardAction$actio === void 0 || _keyboardAction$actio.call(keyboardAction, e);
|
|
152
146
|
e.stopPropagation();
|
|
153
147
|
e.preventDefault();
|
|
154
148
|
log.debug2('Matched hotkey returned false, key event not consumed');
|
|
@@ -172,6 +166,12 @@ class ContextActions extends Component {
|
|
|
172
166
|
});
|
|
173
167
|
}
|
|
174
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Group you can assign to context menu actions to group them together.
|
|
171
|
+
* Lower group IDs appear at the top of the list.
|
|
172
|
+
* Groups are separated by a separator item.
|
|
173
|
+
* Items within groups are ordered by their order property, then by their title.
|
|
174
|
+
*/
|
|
175
175
|
_defineProperty(ContextActions, "groups", {
|
|
176
176
|
default: undefined,
|
|
177
177
|
high: 100,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextActions.js","names":["React","Component","Log","ContextActionUtils","isPromise","GlobalContextActions","jsx","_jsx","log","module","ContextActions","triggerMenu","element","clientX","clientY","actions","length","mouseEvent","MouseEvent","bubbles","cancelable","contextActions","dispatchEvent","constructor","props","_defineProperty","handleContextMenu","bind","handleKeyDown","container","createRef","state","globalActions","keyboardActions","getDerivedStateFromProps","Array","isArray","filter","action","isGlobal","undefined","shortcut","componentDidMount","_this$container$curre","current","parentElement","addEventListener","componentWillUnmount","_this$container$curre2","removeEventListener","e","ignoreClassNames","el","target","_loop","classList","ignoredClassName","find","className","contains","debug2","concat","v","_ret","isContextActionEvent","debug","i","keyboardAction","actionsDisabled","matchesEvent","_keyboardAction$actio","call","stopPropagation","preventDefault","render","dataTestId","ref","children","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 type 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: undefined,\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: ResolvableContextAction[]\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;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAG3B,IAAMC,GAAG,GAAGN,GAAG,CAACO,MAAM,CAAC,g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/C,SAAU;MACpB,eAAa8C,UAAW;MAAAE,QAAA,eAExBtE,IAAA,CAACF,oBAAoB;QAACU,OAAO,EAAEiB;MAAc,CAAE;IAAC,CAC7C,CAAC;EAEV;AACF;AAACP,eAAA,CA1LKf,cAAc,YAUF;EACdoE,OAAO,EAAEtC,SAAS;EAClBuC,IAAI,EAAE,GAAG;EACTC,MAAM,EAAE,IAAI;EACZC,GAAG,EAAE,KAAK;EACVC,MAAM,EAAE,MAAM;EAEdC,IAAI,EAAE;AACR,CAAC;AA0KH,eAAezE,cAAc"}
|
|
1
|
+
{"version":3,"file":"ContextActions.js","names":["React","Component","Log","ContextActionUtils","isPromise","GlobalContextActions","jsx","_jsx","log","module","ContextActions","triggerMenu","element","clientX","clientY","actions","length","mouseEvent","MouseEvent","bubbles","cancelable","contextActions","dispatchEvent","constructor","props","_defineProperty","handleContextMenu","bind","handleKeyDown","container","createRef","state","globalActions","keyboardActions","getDerivedStateFromProps","Array","isArray","filter","action","isGlobal","undefined","shortcut","componentDidMount","_this$container$curre","current","parentElement","addEventListener","componentWillUnmount","_this$container$curre2","removeEventListener","e","ignoreClassNames","el","target","_loop","classList","ignoredClassName","find","className","contains","debug2","concat","v","_ret","isContextActionEvent","debug","i","keyboardAction","actionsDisabled","matchesEvent","_keyboardAction$actio","call","stopPropagation","preventDefault","render","dataTestId","ref","children","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 type ResolvableContextAction,\n type ContextAction,\n type ContextActionEvent,\n isPromise,\n} 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: undefined,\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: ResolvableContextAction[]\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,IAIvBC,SAAS;AAAA,OAEJC,oBAAoB;AAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAG3B,IAAMC,GAAG,GAAGN,GAAG,CAACO,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,SAAST,SAAS,CAGpC;EAiBA,OAAOU,WAAWA,CAChBC,OAAgB,EAChBC,OAAe,EACfC,OAAe,EACfC,OAAkC,EAC5B;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,CACF,CAAC;IACDH,UAAU,CAACI,cAAc,GAAGN,OAAO;IAEnCH,OAAO,CAACU,aAAa,CAACL,UAAgC,CAAC;EACzD;EAEAM,W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C/B0B,cAAc,CAAC1B,QAAQ,CAAC4B,YAAY,CAACnB,CAAC,CAAC,EACvC;QAAA,IAAAoB,qBAAA;QACA9D,GAAG,CAACyD,KAAK,CAAC,yBAAyB,EAAEf,CAAC,CAAC;QAEvC,CAAAoB,qBAAA,GAAAH,cAAc,CAAC7B,MAAM,cAAAgC,qBAAA,eAArBA,qBAAA,CAAAC,IAAA,CAAAJ,cAAc,EAAUjB,CAAC,CAAC;QAE1BA,CAAC,CAACsB,eAAe,CAAC,CAAC;QACnBtB,CAAC,CAACuB,cAAc,CAAC,CAAC;QAElBjE,GAAG,CAACoD,MAAM,CAAC,uDAAuD,CAAC;MACrE;IACF;EACF;EAEAc,MAAMA,CAAA,EAAgB;IACpB,IAAM;MAAE,aAAa,EAAEC;IAAW,CAAC,GAAG,IAAI,CAACnD,KAAK;IAChD,IAAM;MAAEQ;IAAc,CAAC,GAAG,IAAI,CAACD,KAAK;IACpC,oBACExB,IAAA;MACEmD,SAAS,EAAC,0BAA0B;MACpCkB,GAAG,EAAE,IAAI,CAAC/C,SAAU;MACpB,eAAa8C,UAAW;MAAAE,QAAA,eAExBtE,IAAA,CAACF,oBAAoB;QAACU,OAAO,EAAEiB;MAAc,CAAE;IAAC,CAC7C,CAAC;EAEV;AACF;AAtLE;AACF;AACA;AACA;AACA;AACA;AALEP,eAAA,CAJIf,cAAc,YAUF;EACdoE,OAAO,EAAEtC,SAAS;EAClBuC,IAAI,EAAE,GAAG;EACTC,MAAM,EAAE,IAAI;EACZC,GAAG,EAAE,KAAK;EACVC,MAAM,EAAE,MAAM;EAEdC,IAAI,EAAE;AACR,CAAC;AA0KH,eAAezE,cAAc","ignoreList":[]}
|
|
@@ -10,9 +10,7 @@ import { PromiseUtils } from '@deephaven/utils';
|
|
|
10
10
|
import ContextActionUtils from "./ContextActionUtils.js";
|
|
11
11
|
import ContextMenuItem from "./ContextMenuItem.js";
|
|
12
12
|
import LoadingSpinner from "../LoadingSpinner.js";
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
14
|
var log = Log.module('ContextMenu');
|
|
17
15
|
/** Do not use this class directly. Use ContextMenuRoot and ContextActions instead. */
|
|
18
16
|
class ContextMenu extends PureComponent {
|
|
@@ -72,7 +70,7 @@ class ContextMenu extends PureComponent {
|
|
|
72
70
|
// async rAF finishes, so it is cancelled in willUnmount()
|
|
73
71
|
this.rAF = window.requestAnimationFrame(() => {
|
|
74
72
|
var _this$container$curre;
|
|
75
|
-
(_this$container$curre = this.container.current) === null || _this$container$curre === void 0
|
|
73
|
+
(_this$container$curre = this.container.current) === null || _this$container$curre === void 0 || _this$container$curre.focus();
|
|
76
74
|
var {
|
|
77
75
|
onMenuOpened
|
|
78
76
|
} = this.props;
|
|
@@ -90,7 +88,7 @@ class ContextMenu extends PureComponent {
|
|
|
90
88
|
if (activeSubMenu == null) {
|
|
91
89
|
var _this$container$curre2;
|
|
92
90
|
// close sub menu, refocus parent menu
|
|
93
|
-
(_this$container$curre2 = this.container.current) === null || _this$container$curre2 === void 0
|
|
91
|
+
(_this$container$curre2 = this.container.current) === null || _this$container$curre2 === void 0 || _this$container$curre2.focus();
|
|
94
92
|
} else {
|
|
95
93
|
// open sub menu, set its initial position
|
|
96
94
|
this.setActiveSubMenuPosition();
|
|
@@ -100,7 +98,7 @@ class ContextMenu extends PureComponent {
|
|
|
100
98
|
this.initMenu();
|
|
101
99
|
if (this.container.current == null || !this.container.current.contains(document.activeElement)) {
|
|
102
100
|
var _this$container$curre3;
|
|
103
|
-
(_this$container$curre3 = this.container.current) === null || _this$container$curre3 === void 0
|
|
101
|
+
(_this$container$curre3 = this.container.current) === null || _this$container$curre3 === void 0 || _this$container$curre3.focus();
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
this.verifyPosition();
|
|
@@ -478,7 +476,7 @@ class ContextMenu extends PureComponent {
|
|
|
478
476
|
for (var i = 0; i < menuItems.length; i += 1) {
|
|
479
477
|
var menuItem = menuItems[i];
|
|
480
478
|
if (i > 0 && menuItem.group !== menuItems[i - 1].group) {
|
|
481
|
-
menuItemElements.push(
|
|
479
|
+
menuItemElements.push(/*#__PURE__*/_jsx("hr", {}, "".concat(i, ".separator")));
|
|
482
480
|
}
|
|
483
481
|
var menuItemElement = /*#__PURE__*/_jsx(ContextMenuItem, {
|
|
484
482
|
ref: activeSubMenu === i ? this.activeSubMenuRef : null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","names":["React","PureComponent","classNames","Log","PromiseUtils","ContextActionUtils","ContextMenuItem","LoadingSpinner","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","log","module","ContextMenu","handleContextMenu","e","metaKey","stopPropagation","preventDefault","constructor","props","_defineProperty","handleBlur","bind","handleCloseSubMenu","handleKeyDown","handleMenuItemClick","handleMenuItemContextMenu","handleMenuItemMouseMove","handleMouseLeave","handleWindowResize","container","createRef","oldFocus","document","activeElement","activeSubMenuRef","subMenuTimer","rAF","initialPosition","top","left","state","menuItems","pendingItems","activeSubMenu","hasOverflow","subMenuTop","subMenuLeft","subMenuParentWidth","subMenuParentHeight","keyboardIndex","mouseIndex","componentDidMount","initMenu","verifyPosition","window","addEventListener","requestAnimationFrame","_this$container$curre","current","focus","onMenuOpened","componentDidUpdate","prevProps","prevState","actions","_this$container$curre2","setActiveSubMenuPosition","contains","_this$container$curre3","componentWillUnmount","cancelPromises","removeEventListener","cancelAnimationFrame","getKeyboardIndex","options","separateKeyboardMouse","undefined","getMouseIndex","setKeyboardIndex","index","setState","setMouseIndex","initialKeyboardIndex","getMenuItems","nonPromiseItems","i","length","menuItem","Promise","initMenuPromise","push","sortActions","promise","cancellablePromise","makeCancelable","concat","then","resolvedMenuItems","indexOf","slice","splice","error","isCanceled","map","item","cancel","parentRect","getBoundingClientRect","right","height","width","_this$container$curre4","_this$container$curre5","_this$container$curre6","_this$container$curre7","updatePosition","oldTop","oldLeft","doNotVerifyPosition","scrollHeight","innerHeight","innerWidth","closeMenu","warn","relatedTarget","element","isContextMenuChild","hasAttribute","parentElement","isEscapeKey","key","newFocus","openSubMenu","shiftKey","getNextMenuItem","HTMLElement","newSubMenu","closeAll","arguments","onMenuClosed","closeSubMenu","closeAllMenus","disabled","action","nativeEvent","focusIndex","render","menuItemElements","group","menuItemElement","ref","isKeyboardSelected","isMouseSelected","onMenuItemClick","onMenuItemMouseMove","onMenuItemContextMenu","pendingElement","className","children","menuStyle","dataTestId","showSubmenu","style","_objectSpread","onBlur","onKeyDown","onMouseLeave","onContextMenu","role","tabIndex","verifiedTop","verifiedLeft"],"sources":["../../src/context-actions/ContextMenu.tsx"],"sourcesContent":["import React, { PureComponent } from 'react';\nimport classNames from 'classnames';\nimport Log from '@deephaven/log';\nimport { PromiseUtils, type CancelablePromise } from '@deephaven/utils';\nimport ContextActionUtils, {\n type ContextAction,\n type ResolvableContextAction,\n} from './ContextActionUtils';\nimport ContextMenuItem from './ContextMenuItem';\nimport LoadingSpinner from '../LoadingSpinner';\n\nconst log = Log.module('ContextMenu');\n\ninterface ContextMenuProps {\n top: number;\n left: number;\n updatePosition: (top: number, left: number) => void;\n // only submenus will have these, defaults to 0 otherwise\n // represents the width height of the parent menu item\n subMenuParentWidth: number;\n subMenuParentHeight: number;\n actions: ResolvableContextAction[];\n closeMenu: (closeAll: boolean) => void;\n onMenuClosed: (menu: ContextMenu) => void;\n onMenuOpened: (menu: ContextMenu) => void;\n options: {\n doNotVerifyPosition?: boolean;\n separateKeyboardMouse?: boolean;\n initialKeyboardIndex?: number;\n };\n menuStyle: React.CSSProperties;\n 'data-testid'?: string;\n}\n\ninterface ContextMenuState {\n menuItems: ContextAction[];\n pendingItems: CancelablePromise<ContextAction[]>[];\n activeSubMenu: number | null;\n hasOverflow: boolean;\n subMenuTop: number | null;\n subMenuLeft: number | null;\n subMenuParentWidth: number;\n subMenuParentHeight: number;\n keyboardIndex: number;\n mouseIndex: number;\n}\n\n/** Do not use this class directly. Use ContextMenuRoot and ContextActions instead. */\nclass ContextMenu extends PureComponent<ContextMenuProps, ContextMenuState> {\n static defaultProps = {\n subMenuParentWidth: 0,\n subMenuParentHeight: 0,\n closeMenu(): void {\n // no-op\n },\n onMenuOpened(): void {\n // no-op\n },\n onMenuClosed(): void {\n // no-op\n },\n options: {},\n menuStyle: {},\n 'data-testid': undefined,\n };\n\n static handleContextMenu(e: React.MouseEvent): void {\n if (e.metaKey) {\n return;\n }\n\n e.stopPropagation();\n e.preventDefault();\n }\n\n constructor(props: ContextMenuProps) {\n super(props);\n\n this.handleBlur = this.handleBlur.bind(this);\n this.handleCloseSubMenu = this.handleCloseSubMenu.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleMenuItemClick = this.handleMenuItemClick.bind(this);\n this.handleMenuItemContextMenu = this.handleMenuItemContextMenu.bind(this);\n this.handleMenuItemMouseMove = this.handleMenuItemMouseMove.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleWindowResize = this.handleWindowResize.bind(this);\n\n this.container = React.createRef();\n this.oldFocus = document.activeElement;\n this.activeSubMenuRef = React.createRef();\n this.subMenuTimer = 0;\n this.rAF = 0;\n\n this.initialPosition = { top: props.top, left: props.left };\n\n this.state = {\n menuItems: [],\n pendingItems: [],\n activeSubMenu: null,\n hasOverflow: false,\n subMenuTop: null,\n subMenuLeft: null,\n subMenuParentWidth: 0,\n subMenuParentHeight: 0,\n keyboardIndex: -1,\n mouseIndex: -1,\n };\n }\n\n componentDidMount(): void {\n this.initMenu();\n\n this.verifyPosition();\n\n window.addEventListener('resize', this.handleWindowResize);\n\n // rAF is needed to wait for a submenus popper to be created before\n // attempting to set focus, however on a quick mount/unmount when\n // mousing past an item, the submenu could be unmounted before the\n // async rAF finishes, so it is cancelled in willUnmount()\n this.rAF = window.requestAnimationFrame(() => {\n this.container.current?.focus();\n\n const { onMenuOpened } = this.props;\n onMenuOpened(this);\n });\n }\n\n componentDidUpdate(\n prevProps: ContextMenuProps,\n prevState: ContextMenuState\n ): void {\n const { actions } = this.props;\n const { activeSubMenu } = this.state;\n\n if (activeSubMenu !== prevState.activeSubMenu) {\n if (activeSubMenu == null) {\n // close sub menu, refocus parent menu\n this.container.current?.focus();\n } else {\n // open sub menu, set its initial position\n this.setActiveSubMenuPosition();\n }\n }\n\n if (prevProps.actions !== actions) {\n this.initMenu();\n\n if (\n this.container.current == null ||\n !this.container.current.contains(document.activeElement)\n ) {\n this.container.current?.focus();\n }\n }\n\n this.verifyPosition();\n }\n\n componentWillUnmount(): void {\n this.cancelPromises();\n window.removeEventListener('resize', this.handleWindowResize);\n cancelAnimationFrame(this.rAF);\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n oldFocus: Element | null;\n\n activeSubMenuRef: React.RefObject<HTMLDivElement>;\n\n subMenuTimer: number;\n\n rAF: number;\n\n initialPosition: { top: number; left: number };\n\n getKeyboardIndex(): number {\n const { options } = this.props;\n if (\n options.separateKeyboardMouse !== undefined &&\n options.separateKeyboardMouse\n ) {\n const { keyboardIndex } = this.state;\n return keyboardIndex;\n }\n\n return this.getMouseIndex();\n }\n\n setKeyboardIndex(index: number): void {\n const { options } = this.props;\n if (\n options.separateKeyboardMouse !== undefined &&\n options.separateKeyboardMouse\n ) {\n this.setState({ keyboardIndex: index });\n } else {\n this.setMouseIndex(index);\n }\n }\n\n getMouseIndex(): number {\n const { mouseIndex } = this.state;\n return mouseIndex;\n }\n\n setMouseIndex(index: number): void {\n this.setState({ mouseIndex: index });\n }\n\n initMenu(): void {\n // cancel any pending close and promises\n this.cancelPromises();\n cancelAnimationFrame(this.rAF);\n\n const { options } = this.props;\n let keyboardIndex = options.initialKeyboardIndex;\n if (keyboardIndex === undefined) {\n keyboardIndex = -1;\n }\n\n const { actions } = this.props;\n const menuItems = ContextActionUtils.getMenuItems(actions);\n const nonPromiseItems: ContextAction[] = [];\n for (let i = menuItems.length - 1; i >= 0; i -= 1) {\n const menuItem = menuItems[i];\n if (menuItem instanceof Promise) {\n this.initMenuPromise(menuItem as Promise<ContextAction[]>);\n } else {\n nonPromiseItems.push(menuItem as ContextAction);\n }\n }\n\n this.setState({\n mouseIndex: -1,\n keyboardIndex,\n activeSubMenu: null,\n menuItems: ContextActionUtils.sortActions(nonPromiseItems),\n });\n }\n\n initMenuPromise(promise: Promise<ContextAction[]>): void {\n // make all promises cancellable\n const cancellablePromise = PromiseUtils.makeCancelable(promise);\n\n this.setState(state => ({\n pendingItems: state.pendingItems.concat(cancellablePromise),\n }));\n\n cancellablePromise.then(\n resolvedMenuItems => {\n this.setState(state => {\n const index = state.pendingItems.indexOf(cancellablePromise);\n if (index >= 0) {\n const pendingItems = state.pendingItems.slice();\n pendingItems.splice(index, 1);\n\n return {\n menuItems: ContextActionUtils.sortActions(\n state.menuItems.concat(resolvedMenuItems)\n ),\n pendingItems,\n };\n }\n // This item is stale, don't update the menu\n return null;\n });\n },\n error => {\n if (PromiseUtils.isCanceled(error)) {\n return; // Canceled promise is ignored\n }\n\n // remove failed item from pending list\n this.setState(state => {\n const index = state.pendingItems.indexOf(cancellablePromise);\n if (index >= 0) {\n const pendingItems = state.pendingItems.slice();\n pendingItems.splice(index, 1);\n return {\n pendingItems,\n };\n }\n return null;\n });\n\n // Log the error\n log.error(error);\n }\n );\n }\n\n cancelPromises(): void {\n const { pendingItems } = this.state;\n pendingItems.map(item => item.cancel());\n }\n\n /**\n * Sets the unverfied start position of a submenu. Submenu then self-verfies\n * its own position and potentially reports back a new position.\n */\n setActiveSubMenuPosition(): void {\n if (this.activeSubMenuRef.current === null) return;\n const parentRect = this.activeSubMenuRef.current.getBoundingClientRect();\n\n // intentionally rect.right, we want the sub menu to start at the right edge of the current menu\n this.setState({\n subMenuTop: parentRect.top,\n subMenuLeft: parentRect.right,\n subMenuParentHeight: parentRect.height,\n subMenuParentWidth: parentRect.width,\n });\n }\n\n /**\n * Verifies the position of this menu in relation to the parent to make sure it's on screen.\n * Will update the top left state (updatePosition) if necessary (causing a re-render)\n * By default it tries to top-align with parent, at the right side of the parent.\n * Because we aren't a native context menu and can't escape window bounds, we also do\n * somethings to better fit on screen, such as the \"nudge\" offset position, and further\n * allow overflow scrolling for large menus in a small window.\n */\n verifyPosition(): void {\n const {\n options,\n updatePosition,\n subMenuParentWidth,\n subMenuParentHeight,\n top: oldTop,\n left: oldLeft,\n } = this.props;\n\n if (\n !this.container.current ||\n (options.doNotVerifyPosition != null && options.doNotVerifyPosition)\n ) {\n return;\n }\n\n // initial position is used rather than current position,\n // as the number of menu items can change (actions can bubble)\n // and menu should always be positioned relative to spawn point\n let { top, left } = this.initialPosition;\n const { width, height } =\n this.container.current?.getBoundingClientRect() ?? {\n width: 0,\n height: 0,\n };\n const hasOverflow =\n (this.container.current?.scrollHeight ?? 0) > window.innerHeight;\n\n if (height === 0 || width === 0) {\n // We don't have a height or width yet, don't bother doing anything\n return;\n }\n\n // does it fit below?\n if (top + height > window.innerHeight) {\n // can it be flipped to above? include offset if submenu (defaults to 0 if not submenu)\n if (top - height - subMenuParentHeight > 0) {\n // flip like a native menu would\n top -= height - subMenuParentHeight;\n } else {\n // still doesnt fit? okay, position at bottom edge\n top = window.innerHeight - height;\n }\n }\n\n if (left + width > window.innerWidth) {\n // less picky about left right positioning, just keep it going off to right\n left = left - width - subMenuParentWidth;\n }\n\n if (oldLeft !== left || oldTop !== top) {\n // parent owns positioning as single source of truth, ask to update props\n this.setState({ hasOverflow });\n updatePosition(top, left);\n }\n }\n\n // since window resize doesn't trigger blur, listen and close the menu\n handleWindowResize(): void {\n if (!this.container.current) {\n return;\n }\n this.closeMenu(true);\n }\n\n handleBlur(e: React.FocusEvent<HTMLDivElement>): void {\n if (!this.container.current) {\n log.warn('Container is null!');\n return;\n }\n\n if (!this.container.current.contains(e.relatedTarget as Node)) {\n let element: HTMLElement | null = e.relatedTarget as HTMLElement;\n let isContextMenuChild = false;\n while (element && !isContextMenuChild) {\n isContextMenuChild = element.hasAttribute('data-dh-context-menu');\n element = element.parentElement;\n }\n\n if (!isContextMenuChild) {\n // close all submenus on blur\n this.closeMenu(true);\n }\n }\n }\n\n /** Returns whether the specified key should remove the menu. Depends on the side the parent is on. */\n isEscapeKey(key: string): boolean {\n const { left } = this.props;\n return (\n key === 'Escape' ||\n (left < 0 && key === 'ArrowRight') ||\n key === 'ArrowLeft'\n );\n }\n\n handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>): void {\n const { menuItems } = this.state;\n const oldFocus = this.getKeyboardIndex();\n let newFocus: number | null = oldFocus;\n let openSubMenu = false;\n\n if (e.key === 'Enter' || e.key === ' ') {\n if (oldFocus >= 0 && oldFocus < menuItems.length) {\n this.handleMenuItemClick(\n menuItems[oldFocus],\n e as React.SyntheticEvent as React.MouseEvent\n );\n }\n return;\n }\n\n if (e.key === 'ArrowRight') {\n if (oldFocus >= 0 && oldFocus <= menuItems.length) {\n openSubMenu = true;\n } else {\n newFocus = 0;\n }\n } else if (this.isEscapeKey(e.key)) {\n newFocus = null;\n } else if (e.key === 'ArrowUp' || (e.shiftKey && e.key === 'Tab')) {\n newFocus = ContextActionUtils.getNextMenuItem(newFocus, -1, menuItems);\n } else if (e.key === 'ArrowDown' || e.key === 'Tab') {\n newFocus = ContextActionUtils.getNextMenuItem(newFocus, 1, menuItems);\n }\n\n if (openSubMenu) {\n this.openSubMenu(oldFocus);\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n\n if (oldFocus !== newFocus) {\n if (newFocus !== null) {\n this.setKeyboardIndex(newFocus);\n } else {\n this.closeMenu();\n if (this.oldFocus instanceof HTMLElement) {\n this.oldFocus.focus();\n }\n }\n\n e.preventDefault();\n e.stopPropagation();\n }\n }\n\n openSubMenu(index: number): void {\n const { menuItems, activeSubMenu } = this.state;\n const newSubMenu = menuItems[index].actions ? index : null;\n if (activeSubMenu === newSubMenu) return;\n this.setState({\n activeSubMenu: newSubMenu,\n subMenuTop: null,\n subMenuLeft: null,\n });\n }\n\n closeMenu(closeAll = false): void {\n const { closeMenu, onMenuClosed } = this.props;\n cancelAnimationFrame(this.rAF);\n this.rAF = window.requestAnimationFrame(() => {\n closeMenu(closeAll);\n onMenuClosed(this);\n });\n }\n\n closeSubMenu(): void {\n this.setState({\n activeSubMenu: null,\n });\n }\n\n handleCloseSubMenu(closeAllMenus: boolean): void {\n if (closeAllMenus) {\n this.closeMenu(true);\n } else {\n this.closeSubMenu();\n }\n }\n\n handleMenuItemClick(menuItem: ContextAction, e: React.MouseEvent): void {\n e.preventDefault();\n e.stopPropagation();\n\n const { menuItems } = this.state;\n if (\n menuItem != null &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n if (menuItem.actions != null) {\n this.openSubMenu(menuItems.indexOf(menuItem));\n } else if (menuItem.action != null) {\n menuItem.action(e.nativeEvent);\n this.closeMenu(true);\n }\n }\n }\n\n handleMenuItemContextMenu(\n menuItem: ContextAction,\n e: React.MouseEvent\n ): void {\n if (e.metaKey) {\n return;\n }\n\n this.handleMenuItemClick(menuItem, e);\n }\n\n handleMenuItemMouseMove(menuItem: ContextAction): void {\n const { menuItems } = this.state;\n const focusIndex = menuItems.indexOf(menuItem);\n this.setMouseIndex(focusIndex);\n\n if (\n focusIndex >= 0 &&\n focusIndex < menuItems.length &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n this.openSubMenu(focusIndex);\n }\n }\n\n handleMouseLeave(): void {\n this.setMouseIndex(-1);\n }\n\n render(): JSX.Element {\n const menuItemElements = [];\n const { top, left } = this.props;\n const {\n activeSubMenu,\n hasOverflow,\n keyboardIndex,\n menuItems,\n mouseIndex,\n pendingItems,\n subMenuTop,\n subMenuLeft,\n subMenuParentWidth,\n subMenuParentHeight,\n } = this.state;\n for (let i = 0; i < menuItems.length; i += 1) {\n const menuItem = menuItems[i];\n\n if (i > 0 && menuItem.group !== menuItems[i - 1].group) {\n menuItemElements.push(<hr key={`${i}.separator`} />);\n }\n\n const menuItemElement = (\n <ContextMenuItem\n key={i}\n ref={activeSubMenu === i ? this.activeSubMenuRef : null}\n isKeyboardSelected={keyboardIndex === i}\n isMouseSelected={mouseIndex === i}\n menuItem={menuItem}\n closeMenu={this.handleCloseSubMenu}\n onMenuItemClick={this.handleMenuItemClick}\n onMenuItemMouseMove={this.handleMenuItemMouseMove}\n onMenuItemContextMenu={this.handleMenuItemContextMenu}\n />\n );\n\n menuItemElements.push(menuItemElement);\n }\n\n let pendingElement = null;\n if (pendingItems.length > 0) {\n pendingElement = (\n <div className=\"loading\">\n <LoadingSpinner className=\"loading-spinner-vertical-align\" />\n </div>\n );\n }\n\n const { menuStyle, 'data-testid': dataTestId } = this.props;\n\n // don't show submenu until it has an position initialized\n const showSubmenu =\n activeSubMenu !== null && subMenuTop !== null && subMenuLeft !== null;\n\n return (\n <>\n <div\n className={classNames(\n { 'has-overflow': hasOverflow },\n 'context-menu-container'\n )}\n style={{ top, left, ...menuStyle }}\n ref={this.container}\n data-dh-context-menu\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeyDown}\n onMouseLeave={this.handleMouseLeave}\n onContextMenu={ContextMenu.handleContextMenu}\n role=\"menuitem\"\n tabIndex={0}\n data-testid={dataTestId}\n >\n {menuItemElements}\n {pendingElement}\n </div>\n {showSubmenu &&\n activeSubMenu !== null &&\n subMenuTop !== null &&\n subMenuLeft !== null && (\n <ContextMenu\n key={`sub-${activeSubMenu}`}\n actions={menuItems[activeSubMenu].actions || []}\n closeMenu={this.handleCloseSubMenu}\n top={subMenuTop}\n left={subMenuLeft}\n updatePosition={(verifiedTop, verifiedLeft) => {\n this.setState({\n subMenuTop: verifiedTop,\n subMenuLeft: verifiedLeft,\n });\n }}\n subMenuParentWidth={subMenuParentWidth}\n subMenuParentHeight={subMenuParentHeight}\n />\n )}\n </>\n );\n }\n}\n\nexport default ContextMenu;\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,IAAIC,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AAC,CAAC;EACXqF,SAAS,EAAE,CAAC,CAAC;EACb,aAAa,EAAEnF;AACjB,CAAC;AA6kBH,eAAejE,WAAW"}
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","names":["React","PureComponent","classNames","Log","PromiseUtils","ContextActionUtils","ContextMenuItem","LoadingSpinner","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","log","module","ContextMenu","handleContextMenu","e","metaKey","stopPropagation","preventDefault","constructor","props","_defineProperty","handleBlur","bind","handleCloseSubMenu","handleKeyDown","handleMenuItemClick","handleMenuItemContextMenu","handleMenuItemMouseMove","handleMouseLeave","handleWindowResize","container","createRef","oldFocus","document","activeElement","activeSubMenuRef","subMenuTimer","rAF","initialPosition","top","left","state","menuItems","pendingItems","activeSubMenu","hasOverflow","subMenuTop","subMenuLeft","subMenuParentWidth","subMenuParentHeight","keyboardIndex","mouseIndex","componentDidMount","initMenu","verifyPosition","window","addEventListener","requestAnimationFrame","_this$container$curre","current","focus","onMenuOpened","componentDidUpdate","prevProps","prevState","actions","_this$container$curre2","setActiveSubMenuPosition","contains","_this$container$curre3","componentWillUnmount","cancelPromises","removeEventListener","cancelAnimationFrame","getKeyboardIndex","options","separateKeyboardMouse","undefined","getMouseIndex","setKeyboardIndex","index","setState","setMouseIndex","initialKeyboardIndex","getMenuItems","nonPromiseItems","i","length","menuItem","Promise","initMenuPromise","push","sortActions","promise","cancellablePromise","makeCancelable","concat","then","resolvedMenuItems","indexOf","slice","splice","error","isCanceled","map","item","cancel","parentRect","getBoundingClientRect","right","height","width","_this$container$curre4","_this$container$curre5","_this$container$curre6","_this$container$curre7","updatePosition","oldTop","oldLeft","doNotVerifyPosition","scrollHeight","innerHeight","innerWidth","closeMenu","warn","relatedTarget","element","isContextMenuChild","hasAttribute","parentElement","isEscapeKey","key","newFocus","openSubMenu","shiftKey","getNextMenuItem","HTMLElement","newSubMenu","closeAll","arguments","onMenuClosed","closeSubMenu","closeAllMenus","disabled","action","nativeEvent","focusIndex","render","menuItemElements","group","menuItemElement","ref","isKeyboardSelected","isMouseSelected","onMenuItemClick","onMenuItemMouseMove","onMenuItemContextMenu","pendingElement","className","children","menuStyle","dataTestId","showSubmenu","style","_objectSpread","onBlur","onKeyDown","onMouseLeave","onContextMenu","role","tabIndex","verifiedTop","verifiedLeft"],"sources":["../../src/context-actions/ContextMenu.tsx"],"sourcesContent":["import React, { PureComponent } from 'react';\nimport classNames from 'classnames';\nimport Log from '@deephaven/log';\nimport { PromiseUtils, type CancelablePromise } from '@deephaven/utils';\nimport ContextActionUtils, {\n type ContextAction,\n type ResolvableContextAction,\n} from './ContextActionUtils';\nimport ContextMenuItem from './ContextMenuItem';\nimport LoadingSpinner from '../LoadingSpinner';\n\nconst log = Log.module('ContextMenu');\n\ninterface ContextMenuProps {\n top: number;\n left: number;\n updatePosition: (top: number, left: number) => void;\n // only submenus will have these, defaults to 0 otherwise\n // represents the width height of the parent menu item\n subMenuParentWidth: number;\n subMenuParentHeight: number;\n actions: ResolvableContextAction[];\n closeMenu: (closeAll: boolean) => void;\n onMenuClosed: (menu: ContextMenu) => void;\n onMenuOpened: (menu: ContextMenu) => void;\n options: {\n doNotVerifyPosition?: boolean;\n separateKeyboardMouse?: boolean;\n initialKeyboardIndex?: number;\n };\n menuStyle: React.CSSProperties;\n 'data-testid'?: string;\n}\n\ninterface ContextMenuState {\n menuItems: ContextAction[];\n pendingItems: CancelablePromise<ContextAction[]>[];\n activeSubMenu: number | null;\n hasOverflow: boolean;\n subMenuTop: number | null;\n subMenuLeft: number | null;\n subMenuParentWidth: number;\n subMenuParentHeight: number;\n keyboardIndex: number;\n mouseIndex: number;\n}\n\n/** Do not use this class directly. Use ContextMenuRoot and ContextActions instead. */\nclass ContextMenu extends PureComponent<ContextMenuProps, ContextMenuState> {\n static defaultProps = {\n subMenuParentWidth: 0,\n subMenuParentHeight: 0,\n closeMenu(): void {\n // no-op\n },\n onMenuOpened(): void {\n // no-op\n },\n onMenuClosed(): void {\n // no-op\n },\n options: {},\n menuStyle: {},\n 'data-testid': undefined,\n };\n\n static handleContextMenu(e: React.MouseEvent): void {\n if (e.metaKey) {\n return;\n }\n\n e.stopPropagation();\n e.preventDefault();\n }\n\n constructor(props: ContextMenuProps) {\n super(props);\n\n this.handleBlur = this.handleBlur.bind(this);\n this.handleCloseSubMenu = this.handleCloseSubMenu.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleMenuItemClick = this.handleMenuItemClick.bind(this);\n this.handleMenuItemContextMenu = this.handleMenuItemContextMenu.bind(this);\n this.handleMenuItemMouseMove = this.handleMenuItemMouseMove.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleWindowResize = this.handleWindowResize.bind(this);\n\n this.container = React.createRef();\n this.oldFocus = document.activeElement;\n this.activeSubMenuRef = React.createRef();\n this.subMenuTimer = 0;\n this.rAF = 0;\n\n this.initialPosition = { top: props.top, left: props.left };\n\n this.state = {\n menuItems: [],\n pendingItems: [],\n activeSubMenu: null,\n hasOverflow: false,\n subMenuTop: null,\n subMenuLeft: null,\n subMenuParentWidth: 0,\n subMenuParentHeight: 0,\n keyboardIndex: -1,\n mouseIndex: -1,\n };\n }\n\n componentDidMount(): void {\n this.initMenu();\n\n this.verifyPosition();\n\n window.addEventListener('resize', this.handleWindowResize);\n\n // rAF is needed to wait for a submenus popper to be created before\n // attempting to set focus, however on a quick mount/unmount when\n // mousing past an item, the submenu could be unmounted before the\n // async rAF finishes, so it is cancelled in willUnmount()\n this.rAF = window.requestAnimationFrame(() => {\n this.container.current?.focus();\n\n const { onMenuOpened } = this.props;\n onMenuOpened(this);\n });\n }\n\n componentDidUpdate(\n prevProps: ContextMenuProps,\n prevState: ContextMenuState\n ): void {\n const { actions } = this.props;\n const { activeSubMenu } = this.state;\n\n if (activeSubMenu !== prevState.activeSubMenu) {\n if (activeSubMenu == null) {\n // close sub menu, refocus parent menu\n this.container.current?.focus();\n } else {\n // open sub menu, set its initial position\n this.setActiveSubMenuPosition();\n }\n }\n\n if (prevProps.actions !== actions) {\n this.initMenu();\n\n if (\n this.container.current == null ||\n !this.container.current.contains(document.activeElement)\n ) {\n this.container.current?.focus();\n }\n }\n\n this.verifyPosition();\n }\n\n componentWillUnmount(): void {\n this.cancelPromises();\n window.removeEventListener('resize', this.handleWindowResize);\n cancelAnimationFrame(this.rAF);\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n oldFocus: Element | null;\n\n activeSubMenuRef: React.RefObject<HTMLDivElement>;\n\n subMenuTimer: number;\n\n rAF: number;\n\n initialPosition: { top: number; left: number };\n\n getKeyboardIndex(): number {\n const { options } = this.props;\n if (\n options.separateKeyboardMouse !== undefined &&\n options.separateKeyboardMouse\n ) {\n const { keyboardIndex } = this.state;\n return keyboardIndex;\n }\n\n return this.getMouseIndex();\n }\n\n setKeyboardIndex(index: number): void {\n const { options } = this.props;\n if (\n options.separateKeyboardMouse !== undefined &&\n options.separateKeyboardMouse\n ) {\n this.setState({ keyboardIndex: index });\n } else {\n this.setMouseIndex(index);\n }\n }\n\n getMouseIndex(): number {\n const { mouseIndex } = this.state;\n return mouseIndex;\n }\n\n setMouseIndex(index: number): void {\n this.setState({ mouseIndex: index });\n }\n\n initMenu(): void {\n // cancel any pending close and promises\n this.cancelPromises();\n cancelAnimationFrame(this.rAF);\n\n const { options } = this.props;\n let keyboardIndex = options.initialKeyboardIndex;\n if (keyboardIndex === undefined) {\n keyboardIndex = -1;\n }\n\n const { actions } = this.props;\n const menuItems = ContextActionUtils.getMenuItems(actions);\n const nonPromiseItems: ContextAction[] = [];\n for (let i = menuItems.length - 1; i >= 0; i -= 1) {\n const menuItem = menuItems[i];\n if (menuItem instanceof Promise) {\n this.initMenuPromise(menuItem as Promise<ContextAction[]>);\n } else {\n nonPromiseItems.push(menuItem as ContextAction);\n }\n }\n\n this.setState({\n mouseIndex: -1,\n keyboardIndex,\n activeSubMenu: null,\n menuItems: ContextActionUtils.sortActions(nonPromiseItems),\n });\n }\n\n initMenuPromise(promise: Promise<ContextAction[]>): void {\n // make all promises cancellable\n const cancellablePromise = PromiseUtils.makeCancelable(promise);\n\n this.setState(state => ({\n pendingItems: state.pendingItems.concat(cancellablePromise),\n }));\n\n cancellablePromise.then(\n resolvedMenuItems => {\n this.setState(state => {\n const index = state.pendingItems.indexOf(cancellablePromise);\n if (index >= 0) {\n const pendingItems = state.pendingItems.slice();\n pendingItems.splice(index, 1);\n\n return {\n menuItems: ContextActionUtils.sortActions(\n state.menuItems.concat(resolvedMenuItems)\n ),\n pendingItems,\n };\n }\n // This item is stale, don't update the menu\n return null;\n });\n },\n error => {\n if (PromiseUtils.isCanceled(error)) {\n return; // Canceled promise is ignored\n }\n\n // remove failed item from pending list\n this.setState(state => {\n const index = state.pendingItems.indexOf(cancellablePromise);\n if (index >= 0) {\n const pendingItems = state.pendingItems.slice();\n pendingItems.splice(index, 1);\n return {\n pendingItems,\n };\n }\n return null;\n });\n\n // Log the error\n log.error(error);\n }\n );\n }\n\n cancelPromises(): void {\n const { pendingItems } = this.state;\n pendingItems.map(item => item.cancel());\n }\n\n /**\n * Sets the unverfied start position of a submenu. Submenu then self-verfies\n * its own position and potentially reports back a new position.\n */\n setActiveSubMenuPosition(): void {\n if (this.activeSubMenuRef.current === null) return;\n const parentRect = this.activeSubMenuRef.current.getBoundingClientRect();\n\n // intentionally rect.right, we want the sub menu to start at the right edge of the current menu\n this.setState({\n subMenuTop: parentRect.top,\n subMenuLeft: parentRect.right,\n subMenuParentHeight: parentRect.height,\n subMenuParentWidth: parentRect.width,\n });\n }\n\n /**\n * Verifies the position of this menu in relation to the parent to make sure it's on screen.\n * Will update the top left state (updatePosition) if necessary (causing a re-render)\n * By default it tries to top-align with parent, at the right side of the parent.\n * Because we aren't a native context menu and can't escape window bounds, we also do\n * somethings to better fit on screen, such as the \"nudge\" offset position, and further\n * allow overflow scrolling for large menus in a small window.\n */\n verifyPosition(): void {\n const {\n options,\n updatePosition,\n subMenuParentWidth,\n subMenuParentHeight,\n top: oldTop,\n left: oldLeft,\n } = this.props;\n\n if (\n !this.container.current ||\n (options.doNotVerifyPosition != null && options.doNotVerifyPosition)\n ) {\n return;\n }\n\n // initial position is used rather than current position,\n // as the number of menu items can change (actions can bubble)\n // and menu should always be positioned relative to spawn point\n let { top, left } = this.initialPosition;\n const { width, height } =\n this.container.current?.getBoundingClientRect() ?? {\n width: 0,\n height: 0,\n };\n const hasOverflow =\n (this.container.current?.scrollHeight ?? 0) > window.innerHeight;\n\n if (height === 0 || width === 0) {\n // We don't have a height or width yet, don't bother doing anything\n return;\n }\n\n // does it fit below?\n if (top + height > window.innerHeight) {\n // can it be flipped to above? include offset if submenu (defaults to 0 if not submenu)\n if (top - height - subMenuParentHeight > 0) {\n // flip like a native menu would\n top -= height - subMenuParentHeight;\n } else {\n // still doesnt fit? okay, position at bottom edge\n top = window.innerHeight - height;\n }\n }\n\n if (left + width > window.innerWidth) {\n // less picky about left right positioning, just keep it going off to right\n left = left - width - subMenuParentWidth;\n }\n\n if (oldLeft !== left || oldTop !== top) {\n // parent owns positioning as single source of truth, ask to update props\n this.setState({ hasOverflow });\n updatePosition(top, left);\n }\n }\n\n // since window resize doesn't trigger blur, listen and close the menu\n handleWindowResize(): void {\n if (!this.container.current) {\n return;\n }\n this.closeMenu(true);\n }\n\n handleBlur(e: React.FocusEvent<HTMLDivElement>): void {\n if (!this.container.current) {\n log.warn('Container is null!');\n return;\n }\n\n if (!this.container.current.contains(e.relatedTarget as Node)) {\n let element: HTMLElement | null = e.relatedTarget as HTMLElement;\n let isContextMenuChild = false;\n while (element && !isContextMenuChild) {\n isContextMenuChild = element.hasAttribute('data-dh-context-menu');\n element = element.parentElement;\n }\n\n if (!isContextMenuChild) {\n // close all submenus on blur\n this.closeMenu(true);\n }\n }\n }\n\n /** Returns whether the specified key should remove the menu. Depends on the side the parent is on. */\n isEscapeKey(key: string): boolean {\n const { left } = this.props;\n return (\n key === 'Escape' ||\n (left < 0 && key === 'ArrowRight') ||\n key === 'ArrowLeft'\n );\n }\n\n handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>): void {\n const { menuItems } = this.state;\n const oldFocus = this.getKeyboardIndex();\n let newFocus: number | null = oldFocus;\n let openSubMenu = false;\n\n if (e.key === 'Enter' || e.key === ' ') {\n if (oldFocus >= 0 && oldFocus < menuItems.length) {\n this.handleMenuItemClick(\n menuItems[oldFocus],\n e as React.SyntheticEvent as React.MouseEvent\n );\n }\n return;\n }\n\n if (e.key === 'ArrowRight') {\n if (oldFocus >= 0 && oldFocus <= menuItems.length) {\n openSubMenu = true;\n } else {\n newFocus = 0;\n }\n } else if (this.isEscapeKey(e.key)) {\n newFocus = null;\n } else if (e.key === 'ArrowUp' || (e.shiftKey && e.key === 'Tab')) {\n newFocus = ContextActionUtils.getNextMenuItem(newFocus, -1, menuItems);\n } else if (e.key === 'ArrowDown' || e.key === 'Tab') {\n newFocus = ContextActionUtils.getNextMenuItem(newFocus, 1, menuItems);\n }\n\n if (openSubMenu) {\n this.openSubMenu(oldFocus);\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n\n if (oldFocus !== newFocus) {\n if (newFocus !== null) {\n this.setKeyboardIndex(newFocus);\n } else {\n this.closeMenu();\n if (this.oldFocus instanceof HTMLElement) {\n this.oldFocus.focus();\n }\n }\n\n e.preventDefault();\n e.stopPropagation();\n }\n }\n\n openSubMenu(index: number): void {\n const { menuItems, activeSubMenu } = this.state;\n const newSubMenu = menuItems[index].actions ? index : null;\n if (activeSubMenu === newSubMenu) return;\n this.setState({\n activeSubMenu: newSubMenu,\n subMenuTop: null,\n subMenuLeft: null,\n });\n }\n\n closeMenu(closeAll = false): void {\n const { closeMenu, onMenuClosed } = this.props;\n cancelAnimationFrame(this.rAF);\n this.rAF = window.requestAnimationFrame(() => {\n closeMenu(closeAll);\n onMenuClosed(this);\n });\n }\n\n closeSubMenu(): void {\n this.setState({\n activeSubMenu: null,\n });\n }\n\n handleCloseSubMenu(closeAllMenus: boolean): void {\n if (closeAllMenus) {\n this.closeMenu(true);\n } else {\n this.closeSubMenu();\n }\n }\n\n handleMenuItemClick(menuItem: ContextAction, e: React.MouseEvent): void {\n e.preventDefault();\n e.stopPropagation();\n\n const { menuItems } = this.state;\n if (\n menuItem != null &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n if (menuItem.actions != null) {\n this.openSubMenu(menuItems.indexOf(menuItem));\n } else if (menuItem.action != null) {\n menuItem.action(e.nativeEvent);\n this.closeMenu(true);\n }\n }\n }\n\n handleMenuItemContextMenu(\n menuItem: ContextAction,\n e: React.MouseEvent\n ): void {\n if (e.metaKey) {\n return;\n }\n\n this.handleMenuItemClick(menuItem, e);\n }\n\n handleMenuItemMouseMove(menuItem: ContextAction): void {\n const { menuItems } = this.state;\n const focusIndex = menuItems.indexOf(menuItem);\n this.setMouseIndex(focusIndex);\n\n if (\n focusIndex >= 0 &&\n focusIndex < menuItems.length &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n this.openSubMenu(focusIndex);\n }\n }\n\n handleMouseLeave(): void {\n this.setMouseIndex(-1);\n }\n\n render(): JSX.Element {\n const menuItemElements = [];\n const { top, left } = this.props;\n const {\n activeSubMenu,\n hasOverflow,\n keyboardIndex,\n menuItems,\n mouseIndex,\n pendingItems,\n subMenuTop,\n subMenuLeft,\n subMenuParentWidth,\n subMenuParentHeight,\n } = this.state;\n for (let i = 0; i < menuItems.length; i += 1) {\n const menuItem = menuItems[i];\n\n if (i > 0 && menuItem.group !== menuItems[i - 1].group) {\n menuItemElements.push(<hr key={`${i}.separator`} />);\n }\n\n const menuItemElement = (\n <ContextMenuItem\n key={i}\n ref={activeSubMenu === i ? this.activeSubMenuRef : null}\n isKeyboardSelected={keyboardIndex === i}\n isMouseSelected={mouseIndex === i}\n menuItem={menuItem}\n closeMenu={this.handleCloseSubMenu}\n onMenuItemClick={this.handleMenuItemClick}\n onMenuItemMouseMove={this.handleMenuItemMouseMove}\n onMenuItemContextMenu={this.handleMenuItemContextMenu}\n />\n );\n\n menuItemElements.push(menuItemElement);\n }\n\n let pendingElement = null;\n if (pendingItems.length > 0) {\n pendingElement = (\n <div className=\"loading\">\n <LoadingSpinner className=\"loading-spinner-vertical-align\" />\n </div>\n );\n }\n\n const { menuStyle, 'data-testid': dataTestId } = this.props;\n\n // don't show submenu until it has an position initialized\n const showSubmenu =\n activeSubMenu !== null && subMenuTop !== null && subMenuLeft !== null;\n\n return (\n <>\n <div\n className={classNames(\n { 'has-overflow': hasOverflow },\n 'context-menu-container'\n )}\n style={{ top, left, ...menuStyle }}\n ref={this.container}\n data-dh-context-menu\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeyDown}\n onMouseLeave={this.handleMouseLeave}\n onContextMenu={ContextMenu.handleContextMenu}\n role=\"menuitem\"\n tabIndex={0}\n data-testid={dataTestId}\n >\n {menuItemElements}\n {pendingElement}\n </div>\n {showSubmenu &&\n activeSubMenu !== null &&\n subMenuTop !== null &&\n subMenuLeft !== null && (\n <ContextMenu\n key={`sub-${activeSubMenu}`}\n actions={menuItems[activeSubMenu].actions || []}\n closeMenu={this.handleCloseSubMenu}\n top={subMenuTop}\n left={subMenuLeft}\n updatePosition={(verifiedTop, verifiedLeft) => {\n this.setState({\n subMenuTop: verifiedTop,\n subMenuLeft: verifiedLeft,\n });\n }}\n subMenuParentWidth={subMenuParentWidth}\n subMenuParentHeight={subMenuParentHeight}\n />\n )}\n </>\n );\n }\n}\n\nexport default ContextMenu;\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,IAAIC,aAAa,QAAQ,OAAO;AAC5C,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,YAAY,QAAgC,kBAAkB;AAAC,OACjEC,kBAAkB;AAAA,OAIlBC,eAAe;AAAA,OACfC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAErB,IAAMC,GAAG,GAAGX,GAAG,CAACY,MAAM,CAAC,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