@deephaven/components 0.19.2-beta.5 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BasicModal.d.ts.map +1 -1
- package/dist/BasicModal.js +5 -6
- package/dist/BasicModal.js.map +1 -1
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +12 -0
- package/dist/Button.js.map +1 -1
- package/dist/HierarchicalCheckboxMenu.d.ts.map +1 -1
- package/dist/HierarchicalCheckboxMenu.js +5 -6
- package/dist/HierarchicalCheckboxMenu.js.map +1 -1
- package/dist/context-actions/ContextActionUtils.d.ts +3 -3
- package/dist/context-actions/ContextActionUtils.js +3 -3
- package/dist/context-actions/ContextActionUtils.js.map +1 -1
- package/dist/context-actions/ContextActions.d.ts.map +1 -1
- package/dist/context-actions/ContextActions.js +2 -2
- package/dist/context-actions/ContextActions.js.map +1 -1
- package/dist/navigation/Page.d.ts.map +1 -1
- package/dist/navigation/Page.js +13 -14
- package/dist/navigation/Page.js.map +1 -1
- package/package.json +8 -8
package/dist/BasicModal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicModal.d.ts","sourceRoot":"","sources":["../src/BasicModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,UAAU,eAAe;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"BasicModal.d.ts","sourceRoot":"","sources":["../src/BasicModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,UAAU,eAAe;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA8GzC,CAAC;AA4BF,eAAe,UAAU,CAAC"}
|
package/dist/BasicModal.js
CHANGED
|
@@ -69,15 +69,14 @@ var BasicModal = props => {
|
|
|
69
69
|
}), /*#__PURE__*/React.createElement("label", {
|
|
70
70
|
className: "custom-control-label",
|
|
71
71
|
htmlFor: "move-confirmation-checkbox"
|
|
72
|
-
}, "Don't ask me again")), onDiscard && /*#__PURE__*/React.createElement(
|
|
73
|
-
|
|
74
|
-
className: "
|
|
72
|
+
}, "Don't ask me again")), onDiscard && /*#__PURE__*/React.createElement(Button, {
|
|
73
|
+
kind: "secondary",
|
|
74
|
+
className: "mr-auto",
|
|
75
75
|
"data-dismiss": "modal",
|
|
76
76
|
onClick: onDiscard,
|
|
77
77
|
"data-testid": dataTestId !== undefined ? "".concat(dataTestId, "-btn-discard") : undefined
|
|
78
|
-
}, discardButtonText), onCancel && /*#__PURE__*/React.createElement(
|
|
79
|
-
|
|
80
|
-
className: "btn btn-outline-primary",
|
|
78
|
+
}, discardButtonText), onCancel && /*#__PURE__*/React.createElement(Button, {
|
|
79
|
+
kind: "secondary",
|
|
81
80
|
"data-dismiss": "modal",
|
|
82
81
|
onClick: onCancel,
|
|
83
82
|
"data-testid": dataTestId !== undefined ? "".concat(dataTestId, "-btn-cancel") : undefined
|
package/dist/BasicModal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicModal.js","names":["React","useRef","useCallback","PropTypes","ButtonGroup","Button","Modal","ModalBody","ModalFooter","ModalHeader","BasicModal","props","isOpen","headerText","bodyText","onCancel","onConfirm","onDiscard","onModalDisable","cancelButtonText","confirmButtonText","discardButtonText","children","dataTestId","confirmButton","disableModalCheckbox","onConfirmClicked","current","checked","modalBody","focus","undefined","propTypes","bool","isRequired","string","oneOfType","func","node","defaultProps"],"sources":["../src/BasicModal.tsx"],"sourcesContent":["import React, { useRef, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport ButtonGroup from './ButtonGroup';\nimport Button from './Button';\nimport { Modal, ModalBody, ModalFooter, ModalHeader } from './modal';\n\ninterface BasicModalProps {\n isOpen: boolean;\n headerText: string;\n bodyText: string | (() => string);\n onCancel?: () => void;\n onConfirm: () => void;\n onDiscard?: () => void;\n onModalDisable?: () => void;\n cancelButtonText?: string;\n confirmButtonText?: string;\n discardButtonText?: string;\n children?: React.ReactNode;\n 'data-testid'?: string;\n}\n\n/**\n * A basic modal dialog with two buttons: cancel / confirm.\n *\n * @param isOpen indicates if the modal dialog is open\n * @param headerText text displayed in the modal header\n * @param bodyText text displayed in the modal body\n * @param onCancel callback for the cancel button; if not provided, button not shown\n * @param onConfirm callback for the confirm button\n * @param onDiscard callback for the discard button; if not provided, button not shown\n * @param cancelButtonText optional text for the cancel button, defaults to 'Cancel'\n * @param confirmButtonText optional text for the confirm button, defaults to 'Okay'\n * @param discardButtonText optional text for the discard button, defaults to 'Discard'\n */\nconst BasicModal: React.FC<BasicModalProps> = props => {\n const {\n isOpen,\n headerText,\n bodyText,\n onCancel,\n onConfirm,\n onDiscard,\n onModalDisable,\n cancelButtonText = 'Cancel',\n confirmButtonText = 'Okay',\n discardButtonText = 'Discard',\n children,\n 'data-testid': dataTestId,\n } = props;\n\n const confirmButton = useRef<HTMLButtonElement>(null);\n\n const disableModalCheckbox = useRef<HTMLInputElement>(null);\n\n const onConfirmClicked = useCallback(() => {\n if (\n disableModalCheckbox.current !== null &&\n disableModalCheckbox.current.checked &&\n onModalDisable\n ) {\n onModalDisable();\n }\n onConfirm();\n }, [onConfirm, onModalDisable]);\n\n let modalBody = '';\n if (isOpen) {\n modalBody = typeof bodyText === 'function' ? bodyText() : bodyText;\n }\n\n return (\n <Modal\n isOpen={isOpen}\n className=\"theme-bg-light\"\n onOpened={() => {\n confirmButton.current?.focus();\n }}\n >\n <ModalHeader closeButton={false}>{headerText}</ModalHeader>\n <ModalBody>{modalBody}</ModalBody>\n <ModalFooter>\n {onModalDisable && (\n <div className=\"custom-control custom-checkbox form-group mr-auto\">\n <input\n type=\"checkbox\"\n className=\"custom-control-input\"\n id=\"move-confirmation-checkbox\"\n defaultChecked={false}\n ref={disableModalCheckbox}\n data-testid={\n dataTestId !== undefined\n ? `${dataTestId}-checkbox-confirm`\n : undefined\n }\n />\n <label\n className=\"custom-control-label\"\n htmlFor=\"move-confirmation-checkbox\"\n >\n Don't ask me again\n </label>\n </div>\n )}\n {onDiscard && (\n <
|
|
1
|
+
{"version":3,"file":"BasicModal.js","names":["React","useRef","useCallback","PropTypes","ButtonGroup","Button","Modal","ModalBody","ModalFooter","ModalHeader","BasicModal","props","isOpen","headerText","bodyText","onCancel","onConfirm","onDiscard","onModalDisable","cancelButtonText","confirmButtonText","discardButtonText","children","dataTestId","confirmButton","disableModalCheckbox","onConfirmClicked","current","checked","modalBody","focus","undefined","propTypes","bool","isRequired","string","oneOfType","func","node","defaultProps"],"sources":["../src/BasicModal.tsx"],"sourcesContent":["import React, { useRef, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport ButtonGroup from './ButtonGroup';\nimport Button from './Button';\nimport { Modal, ModalBody, ModalFooter, ModalHeader } from './modal';\n\ninterface BasicModalProps {\n isOpen: boolean;\n headerText: string;\n bodyText: string | (() => string);\n onCancel?: () => void;\n onConfirm: () => void;\n onDiscard?: () => void;\n onModalDisable?: () => void;\n cancelButtonText?: string;\n confirmButtonText?: string;\n discardButtonText?: string;\n children?: React.ReactNode;\n 'data-testid'?: string;\n}\n\n/**\n * A basic modal dialog with two buttons: cancel / confirm.\n *\n * @param isOpen indicates if the modal dialog is open\n * @param headerText text displayed in the modal header\n * @param bodyText text displayed in the modal body\n * @param onCancel callback for the cancel button; if not provided, button not shown\n * @param onConfirm callback for the confirm button\n * @param onDiscard callback for the discard button; if not provided, button not shown\n * @param cancelButtonText optional text for the cancel button, defaults to 'Cancel'\n * @param confirmButtonText optional text for the confirm button, defaults to 'Okay'\n * @param discardButtonText optional text for the discard button, defaults to 'Discard'\n */\nconst BasicModal: React.FC<BasicModalProps> = props => {\n const {\n isOpen,\n headerText,\n bodyText,\n onCancel,\n onConfirm,\n onDiscard,\n onModalDisable,\n cancelButtonText = 'Cancel',\n confirmButtonText = 'Okay',\n discardButtonText = 'Discard',\n children,\n 'data-testid': dataTestId,\n } = props;\n\n const confirmButton = useRef<HTMLButtonElement>(null);\n\n const disableModalCheckbox = useRef<HTMLInputElement>(null);\n\n const onConfirmClicked = useCallback(() => {\n if (\n disableModalCheckbox.current !== null &&\n disableModalCheckbox.current.checked &&\n onModalDisable\n ) {\n onModalDisable();\n }\n onConfirm();\n }, [onConfirm, onModalDisable]);\n\n let modalBody = '';\n if (isOpen) {\n modalBody = typeof bodyText === 'function' ? bodyText() : bodyText;\n }\n\n return (\n <Modal\n isOpen={isOpen}\n className=\"theme-bg-light\"\n onOpened={() => {\n confirmButton.current?.focus();\n }}\n >\n <ModalHeader closeButton={false}>{headerText}</ModalHeader>\n <ModalBody>{modalBody}</ModalBody>\n <ModalFooter>\n {onModalDisable && (\n <div className=\"custom-control custom-checkbox form-group mr-auto\">\n <input\n type=\"checkbox\"\n className=\"custom-control-input\"\n id=\"move-confirmation-checkbox\"\n defaultChecked={false}\n ref={disableModalCheckbox}\n data-testid={\n dataTestId !== undefined\n ? `${dataTestId}-checkbox-confirm`\n : undefined\n }\n />\n <label\n className=\"custom-control-label\"\n htmlFor=\"move-confirmation-checkbox\"\n >\n Don't ask me again\n </label>\n </div>\n )}\n {onDiscard && (\n <Button\n kind=\"secondary\"\n className=\"mr-auto\"\n data-dismiss=\"modal\"\n onClick={onDiscard}\n data-testid={\n dataTestId !== undefined ? `${dataTestId}-btn-discard` : undefined\n }\n >\n {discardButtonText}\n </Button>\n )}\n {onCancel && (\n <Button\n kind=\"secondary\"\n data-dismiss=\"modal\"\n onClick={onCancel}\n data-testid={\n dataTestId !== undefined ? `${dataTestId}-btn-cancel` : undefined\n }\n >\n {cancelButtonText}\n </Button>\n )}\n <ButtonGroup>\n <Button\n kind=\"primary\"\n onClick={onConfirmClicked}\n ref={confirmButton}\n data-testid={\n dataTestId !== undefined ? `${dataTestId}-btn-confirm` : undefined\n }\n >\n {confirmButtonText}\n </Button>\n {children}\n </ButtonGroup>\n </ModalFooter>\n </Modal>\n );\n};\n\nBasicModal.propTypes = {\n isOpen: PropTypes.bool.isRequired,\n headerText: PropTypes.string.isRequired,\n bodyText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired,\n onCancel: PropTypes.func,\n onConfirm: PropTypes.func.isRequired,\n onDiscard: PropTypes.func,\n onModalDisable: PropTypes.func,\n cancelButtonText: PropTypes.string,\n confirmButtonText: PropTypes.string,\n discardButtonText: PropTypes.string,\n children: PropTypes.node,\n 'data-testid': PropTypes.string,\n};\n\nBasicModal.defaultProps = {\n children: undefined,\n cancelButtonText: 'Cancel',\n confirmButtonText: 'Okay',\n discardButtonText: 'Discard',\n onCancel: undefined,\n onDiscard: undefined,\n onModalDisable: undefined,\n 'data-testid': undefined,\n};\n\nexport default BasicModal;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,MAAhB,EAAwBC,WAAxB,QAA2C,OAA3C;AACA,OAAOC,SAAP,MAAsB,YAAtB;OACOC,W;OACAC,M;SACEC,K,EAAOC,S,EAAWC,W,EAAaC,W;;AAiBxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,UAAqC,GAAGC,KAAK,IAAI;EACrD,IAAM;IACJC,MADI;IAEJC,UAFI;IAGJC,QAHI;IAIJC,QAJI;IAKJC,SALI;IAMJC,SANI;IAOJC,cAPI;IAQJC,gBAAgB,GAAG,QARf;IASJC,iBAAiB,GAAG,MAThB;IAUJC,iBAAiB,GAAG,SAVhB;IAWJC,QAXI;IAYJ,eAAeC;EAZX,IAaFZ,KAbJ;EAeA,IAAMa,aAAa,GAAGvB,MAAM,CAAoB,IAApB,CAA5B;EAEA,IAAMwB,oBAAoB,GAAGxB,MAAM,CAAmB,IAAnB,CAAnC;EAEA,IAAMyB,gBAAgB,GAAGxB,WAAW,CAAC,MAAM;IACzC,IACEuB,oBAAoB,CAACE,OAArB,KAAiC,IAAjC,IACAF,oBAAoB,CAACE,OAArB,CAA6BC,OAD7B,IAEAV,cAHF,EAIE;MACAA,cAAc;IACf;;IACDF,SAAS;EACV,CATmC,EASjC,CAACA,SAAD,EAAYE,cAAZ,CATiC,CAApC;EAWA,IAAIW,SAAS,GAAG,EAAhB;;EACA,IAAIjB,MAAJ,EAAY;IACViB,SAAS,GAAG,OAAOf,Q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AAE,GAAG,CAAC,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC;IACnC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAmCF,QAAA,MAAM,MAAM,4wcAiGX,CAAC;AAuEF,eAAe,MAAM,CAAC"}
|
package/dist/Button.js
CHANGED
|
@@ -51,9 +51,12 @@ var Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
51
51
|
disabled,
|
|
52
52
|
active,
|
|
53
53
|
onClick,
|
|
54
|
+
onMouseDown,
|
|
55
|
+
onMouseUp,
|
|
54
56
|
className,
|
|
55
57
|
style,
|
|
56
58
|
children,
|
|
59
|
+
tabIndex,
|
|
57
60
|
'data-testid': dataTestId,
|
|
58
61
|
'aria-label': ariaLabel
|
|
59
62
|
} = props;
|
|
@@ -96,8 +99,11 @@ var Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
96
99
|
active
|
|
97
100
|
}, className),
|
|
98
101
|
onClick: onClick,
|
|
102
|
+
onMouseUp: onMouseUp,
|
|
103
|
+
onMouseDown: onMouseDown,
|
|
99
104
|
style: style,
|
|
100
105
|
disabled: disabled,
|
|
106
|
+
tabIndex: tabIndex,
|
|
101
107
|
"aria-label": ariaLabelString
|
|
102
108
|
}, icon && iconElem, children, tooltip != null && (disabled === undefined || !disabled) && tooltipElem); // disabled buttons tooltips need a wrapped element to receive pointer events
|
|
103
109
|
// https://jakearchibald.com/2017/events-and-disabled-form-fields/
|
|
@@ -163,6 +169,9 @@ Button.propTypes = {
|
|
|
163
169
|
return null;
|
|
164
170
|
},
|
|
165
171
|
|
|
172
|
+
onMouseUp: PropTypes.func,
|
|
173
|
+
onMouseDown: PropTypes.func,
|
|
174
|
+
tabIndex: PropTypes.number,
|
|
166
175
|
children: PropTypes.node,
|
|
167
176
|
className: PropTypes.string,
|
|
168
177
|
style: PropTypes.object,
|
|
@@ -171,11 +180,14 @@ Button.propTypes = {
|
|
|
171
180
|
Button.defaultProps = {
|
|
172
181
|
type: 'button',
|
|
173
182
|
onClick: undefined,
|
|
183
|
+
onMouseUp: undefined,
|
|
184
|
+
onMouseDown: undefined,
|
|
174
185
|
variant: undefined,
|
|
175
186
|
tooltip: undefined,
|
|
176
187
|
icon: undefined,
|
|
177
188
|
disabled: false,
|
|
178
189
|
active: undefined,
|
|
190
|
+
tabIndex: undefined,
|
|
179
191
|
children: undefined,
|
|
180
192
|
className: undefined,
|
|
181
193
|
style: {},
|
package/dist/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["React","PropTypes","classNames","FontAwesomeIcon","Tooltip","BUTTON_KINDS","VARIANT_KINDS","getClassName","kind","iconOnly","getVariantClasses","Button","forwardRef","props","ref","variant","type","tooltip","icon","disabled","active","onClick","className","style","children","dataTestId","ariaLabel","Boolean","btnClassName","variantClassName","iconElem","isValidElement","tooltipElem","undefined","ariaLabelString","button","displayName","propTypes","oneOf","isRequired","Error","iconName","bool","node","string","object","defaultProps"],"sources":["../src/Button.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { IconDefinition } from '@fortawesome/fontawesome-svg-core';\nimport { Tooltip } from './popper';\n\nconst BUTTON_KINDS = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'success',\n 'danger',\n 'inline',\n 'ghost',\n] as const;\ntype ButtonTuple = typeof BUTTON_KINDS;\ntype ButtonKind = ButtonTuple[number];\n\nconst VARIANT_KINDS = ['group-end'] as const;\ntype VariantTuple = typeof VARIANT_KINDS;\ntype VariantKind = VariantTuple[number];\n\ntype ButtonTypes = 'submit' | 'reset' | 'button';\n\ninterface BaseButtonProps extends React.ComponentPropsWithRef<'button'> {\n kind: ButtonKind;\n type?: ButtonTypes;\n variant?: VariantKind;\n tooltip?: string | JSX.Element;\n icon?: IconDefinition | JSX.Element;\n active?: boolean;\n 'data-testid'?: string;\n 'aria-label'?: string;\n}\n\ntype ButtonWithChildren = BaseButtonProps & {\n children: React.ReactNode;\n};\n\ntype IconOnlyButtonStringTooltip = BaseButtonProps & {\n tooltip: string;\n icon: IconDefinition | JSX.Element;\n children?: undefined;\n};\n\ntype IconOnlyButtonJsxTooltip = BaseButtonProps & {\n tooltip: JSX.Element;\n 'aria-label': string;\n icon: IconDefinition | JSX.Element;\n children?: undefined;\n};\n\ntype IconOnlyButton = IconOnlyButtonStringTooltip | IconOnlyButtonJsxTooltip;\n\ntype ButtonProps = IconOnlyButton | ButtonWithChildren;\n\nfunction getClassName(kind: ButtonKind, iconOnly: boolean): string {\n switch (kind) {\n case 'primary':\n return 'btn-primary';\n case 'secondary':\n return 'btn-outline-primary';\n case 'tertiary':\n return 'btn-secondary';\n case 'success':\n return 'btn-success';\n case 'danger':\n return 'btn-danger';\n case 'inline':\n return 'btn-inline';\n case 'ghost':\n return classNames('btn-link', {\n 'btn-link-icon': iconOnly,\n 'btn-link-icon-only': iconOnly,\n });\n }\n}\n\nfunction getVariantClasses(kind: VariantKind): string {\n switch (kind) {\n case 'group-end':\n return classNames('pl-2', 'pr-3');\n }\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (props: ButtonProps, ref) => {\n const {\n kind,\n variant,\n type,\n tooltip,\n icon,\n disabled,\n active,\n onClick,\n className,\n style,\n children,\n 'data-testid': dataTestId,\n 'aria-label': ariaLabel,\n } = props;\n\n const iconOnly = Boolean(icon && children == null);\n const btnClassName = getClassName(kind, iconOnly);\n\n let variantClassName;\n if (variant) {\n variantClassName = getVariantClasses(variant);\n }\n\n let iconElem: JSX.Element | undefined;\n if (icon) {\n iconElem = React.isValidElement(icon) ? (\n icon\n ) : (\n <FontAwesomeIcon icon={icon as IconDefinition} />\n );\n }\n\n let tooltipElem: JSX.Element | undefined;\n if (tooltip !== undefined) {\n tooltipElem =\n typeof tooltip === 'string' ? <Tooltip>{tooltip}</Tooltip> : tooltip;\n }\n\n // use tooltip as arial-label for iconOnly buttons only\n // if tooltip is also a string and aria-label is not set\n let ariaLabelString = ariaLabel;\n if (\n ariaLabel === undefined &&\n iconOnly &&\n tooltip != null &&\n typeof tooltip === 'string'\n ) {\n ariaLabelString = tooltip;\n }\n\n const button = (\n <button\n data-testid={dataTestId}\n ref={ref}\n // eslint-disable-next-line react/button-has-type\n type={type}\n className={classNames(\n 'btn',\n btnClassName,\n variantClassName,\n { active },\n className\n )}\n onClick={onClick}\n style={style}\n disabled={disabled}\n aria-label={ariaLabelString}\n >\n {icon && iconElem}\n {children}\n {tooltip != null &&\n (disabled === undefined || !disabled) &&\n tooltipElem}\n </button>\n );\n\n // disabled buttons tooltips need a wrapped element to receive pointer events\n // https://jakearchibald.com/2017/events-and-disabled-form-fields/\n\n return disabled !== undefined && disabled ? (\n <span className=\"btn-disabled-wrapper\">\n {button}\n {tooltip !== undefined && tooltipElem}\n </span>\n ) : (\n button\n );\n }\n);\n\nButton.displayName = 'Button';\n\nButton.propTypes = {\n kind: PropTypes.oneOf(BUTTON_KINDS).isRequired,\n variant: PropTypes.oneOf(VARIANT_KINDS),\n type: PropTypes.oneOf<ButtonTypes>(['submit', 'reset', 'button']),\n tooltip(props) {\n const { tooltip, icon, children } = props;\n if (tooltip === undefined && icon != null && children == null) {\n return new Error('Tooltip is required for icon only buttons');\n }\n return null;\n },\n icon(props) {\n const { children, icon } = props;\n if (icon == null && children == null) {\n return new Error('Icon is required if no children are provided');\n }\n\n if (\n children == null &&\n !React.isValidElement(icon) &&\n (icon == null || icon.iconName === '' || icon.iconName == null)\n ) {\n return new Error(\n 'Icon must be react element or fontawesome IconDefinition'\n );\n }\n\n return null;\n },\n disabled: PropTypes.bool,\n active: PropTypes.bool,\n onClick(props) {\n const { onClick, type } = props;\n if (type === 'button' && typeof onClick !== 'function') {\n return new Error('type button requires an onClick function');\n }\n if (onClick !== undefined && typeof onClick !== 'function') {\n return new Error('onClick must be a function');\n }\n return null;\n },\n children: PropTypes.node,\n className: PropTypes.string,\n style: PropTypes.object,\n 'data-testid': PropTypes.string,\n};\n\nButton.defaultProps = {\n type: 'button',\n onClick: undefined,\n variant: undefined,\n tooltip: undefined,\n icon: undefined,\n disabled: false,\n active: undefined,\n children: undefined,\n className: undefined,\n style: {},\n 'data-testid': undefined,\n};\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,eAAT,QAAgC,gCAAhC;SAESC,O;AAET,IAAMC,YAAY,GAAG,CACnB,SADmB,EAEnB,WAFmB,EAGnB,UAHmB,EAInB,SAJmB,EAKnB,QALmB,EAMnB,QANmB,EAOnB,OAPmB,CAArB;AAYA,IAAMC,aAAa,GAAG,CAAC,WAAD,CAAtB;;AAsCA,SAASC,YAAT,CAAsBC,IAAtB,EAAwCC,QAAxC,EAAmE;EACjE,QAAQD,IAAR;IACE,KAAK,SAAL;MACE,OAAO,aAAP;;IACF,KAAK,WAAL;MACE,OAAO,qBAAP;;IACF,KAAK,UAAL;MACE,OAAO,eAAP;;IACF,KAAK,SAAL;MACE,OAAO,aAAP;;IACF,KAAK,QAAL;MACE,OAAO,YAAP;;IACF,KAAK,QAAL;MACE,OAAO,YAAP;;IACF,KAAK,OAAL;MACE,OAAON,UAAU,CAAC,UAAD,EAAa;QAC5B,iBAAiBO,QADW;QAE5B,sBAAsBA;MAFM,CAAb,CAAjB;EAdJ;AAmBD;;AAED,SAASC,iBAAT,CAA2BF,IAA3B,EAAsD;EACpD,QAAQA,IAAR;IACE,KAAK,WAAL;MACE,OAAON,UAAU,CAAC,MAAD,EAAS,MAAT,CAAjB;EAFJ;AAID;;AAED,IAAMS,MAAM,gBAAGX,KAAK,CAACY,UAAN,CACb,CAACC,KAAD,EAAqBC,GAArB,KAA6B;EAC3B,IAAM;IACJN,IADI;IAEJO,OAF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eAAeU;AAXK,CAAtB;AAcA,eAAetB,MAAf"}
|
|
1
|
+
{"version":3,"file":"Button.js","names":["React","PropTypes","classNames","FontAwesomeIcon","Tooltip","BUTTON_KINDS","VARIANT_KINDS","getClassName","kind","iconOnly","getVariantClasses","Button","forwardRef","props","ref","variant","type","tooltip","icon","disabled","active","onClick","onMouseDown","onMouseUp","className","style","children","tabIndex","dataTestId","ariaLabel","Boolean","btnClassName","variantClassName","iconElem","isValidElement","tooltipElem","undefined","ariaLabelString","button","displayName","propTypes","oneOf","isRequired","Error","iconName","bool","func","number","node","string","object","defaultProps"],"sources":["../src/Button.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { IconDefinition } from '@fortawesome/fontawesome-svg-core';\nimport { Tooltip } from './popper';\n\nconst BUTTON_KINDS = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'success',\n 'danger',\n 'inline',\n 'ghost',\n] as const;\ntype ButtonTuple = typeof BUTTON_KINDS;\ntype ButtonKind = ButtonTuple[number];\n\nconst VARIANT_KINDS = ['group-end'] as const;\ntype VariantTuple = typeof VARIANT_KINDS;\ntype VariantKind = VariantTuple[number];\n\ntype ButtonTypes = 'submit' | 'reset' | 'button';\n\ninterface BaseButtonProps extends React.ComponentPropsWithRef<'button'> {\n kind: ButtonKind;\n type?: ButtonTypes;\n variant?: VariantKind;\n tooltip?: string | JSX.Element;\n icon?: IconDefinition | JSX.Element;\n active?: boolean;\n 'data-testid'?: string;\n 'aria-label'?: string;\n}\n\ntype ButtonWithChildren = BaseButtonProps & {\n children: React.ReactNode;\n};\n\ntype IconOnlyButtonStringTooltip = BaseButtonProps & {\n tooltip: string;\n icon: IconDefinition | JSX.Element;\n children?: undefined;\n};\n\ntype IconOnlyButtonJsxTooltip = BaseButtonProps & {\n tooltip: JSX.Element;\n 'aria-label': string;\n icon: IconDefinition | JSX.Element;\n children?: undefined;\n};\n\ntype IconOnlyButton = IconOnlyButtonStringTooltip | IconOnlyButtonJsxTooltip;\n\ntype ButtonProps = IconOnlyButton | ButtonWithChildren;\n\nfunction getClassName(kind: ButtonKind, iconOnly: boolean): string {\n switch (kind) {\n case 'primary':\n return 'btn-primary';\n case 'secondary':\n return 'btn-outline-primary';\n case 'tertiary':\n return 'btn-secondary';\n case 'success':\n return 'btn-success';\n case 'danger':\n return 'btn-danger';\n case 'inline':\n return 'btn-inline';\n case 'ghost':\n return classNames('btn-link', {\n 'btn-link-icon': iconOnly,\n 'btn-link-icon-only': iconOnly,\n });\n }\n}\n\nfunction getVariantClasses(kind: VariantKind): string {\n switch (kind) {\n case 'group-end':\n return classNames('pl-2', 'pr-3');\n }\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (props: ButtonProps, ref) => {\n const {\n kind,\n variant,\n type,\n tooltip,\n icon,\n disabled,\n active,\n onClick,\n onMouseDown,\n onMouseUp,\n className,\n style,\n children,\n tabIndex,\n 'data-testid': dataTestId,\n 'aria-label': ariaLabel,\n } = props;\n\n const iconOnly = Boolean(icon && children == null);\n const btnClassName = getClassName(kind, iconOnly);\n\n let variantClassName;\n if (variant) {\n variantClassName = getVariantClasses(variant);\n }\n\n let iconElem: JSX.Element | undefined;\n if (icon) {\n iconElem = React.isValidElement(icon) ? (\n icon\n ) : (\n <FontAwesomeIcon icon={icon as IconDefinition} />\n );\n }\n\n let tooltipElem: JSX.Element | undefined;\n if (tooltip !== undefined) {\n tooltipElem =\n typeof tooltip === 'string' ? <Tooltip>{tooltip}</Tooltip> : tooltip;\n }\n\n // use tooltip as arial-label for iconOnly buttons only\n // if tooltip is also a string and aria-label is not set\n let ariaLabelString = ariaLabel;\n if (\n ariaLabel === undefined &&\n iconOnly &&\n tooltip != null &&\n typeof tooltip === 'string'\n ) {\n ariaLabelString = tooltip;\n }\n\n const button = (\n <button\n data-testid={dataTestId}\n ref={ref}\n // eslint-disable-next-line react/button-has-type\n type={type}\n className={classNames(\n 'btn',\n btnClassName,\n variantClassName,\n { active },\n className\n )}\n onClick={onClick}\n onMouseUp={onMouseUp}\n onMouseDown={onMouseDown}\n style={style}\n disabled={disabled}\n tabIndex={tabIndex}\n aria-label={ariaLabelString}\n >\n {icon && iconElem}\n {children}\n {tooltip != null &&\n (disabled === undefined || !disabled) &&\n tooltipElem}\n </button>\n );\n\n // disabled buttons tooltips need a wrapped element to receive pointer events\n // https://jakearchibald.com/2017/events-and-disabled-form-fields/\n\n return disabled !== undefined && disabled ? (\n <span className=\"btn-disabled-wrapper\">\n {button}\n {tooltip !== undefined && tooltipElem}\n </span>\n ) : (\n button\n );\n }\n);\n\nButton.displayName = 'Button';\n\nButton.propTypes = {\n kind: PropTypes.oneOf(BUTTON_KINDS).isRequired,\n variant: PropTypes.oneOf(VARIANT_KINDS),\n type: PropTypes.oneOf<ButtonTypes>(['submit', 'reset', 'button']),\n tooltip(props) {\n const { tooltip, icon, children } = props;\n if (tooltip === undefined && icon != null && children == null) {\n return new Error('Tooltip is required for icon only buttons');\n }\n return null;\n },\n icon(props) {\n const { children, icon } = props;\n if (icon == null && children == null) {\n return new Error('Icon is required if no children are provided');\n }\n\n if (\n children == null &&\n !React.isValidElement(icon) &&\n (icon == null || icon.iconName === '' || icon.iconName == null)\n ) {\n return new Error(\n 'Icon must be react element or fontawesome IconDefinition'\n );\n }\n\n return null;\n },\n disabled: PropTypes.bool,\n active: PropTypes.bool,\n onClick(props) {\n const { onClick, type } = props;\n if (type === 'button' && typeof onClick !== 'function') {\n return new Error('type button requires an onClick function');\n }\n if (onClick !== undefined && typeof onClick !== 'function') {\n return new Error('onClick must be a function');\n }\n return null;\n },\n onMouseUp: PropTypes.func,\n onMouseDown: PropTypes.func,\n tabIndex: PropTypes.number,\n children: PropTypes.node,\n className: PropTypes.string,\n style: PropTypes.object,\n 'data-testid': PropTypes.string,\n};\n\nButton.defaultProps = {\n type: 'button',\n onClick: undefined,\n onMouseUp: undefined,\n onMouseDown: undefined,\n variant: undefined,\n tooltip: undefined,\n icon: undefined,\n disabled: false,\n active: undefined,\n tabIndex: undefined,\n children: undefined,\n className: undefined,\n style: {},\n 'data-testid': undefined,\n};\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,eAAT,QAAgC,gCAAhC;SAESC,O;AAET,IAAMC,YAAY,GAAG,CACnB,SADmB,EAEnB,WAFmB,EAGnB,UAHmB,EAInB,SAJmB,EAKnB,QALmB,EAMnB,QANmB,EAOnB,OAPmB,CAArB;AAYA,IAAMC,aAAa,GAAG,CAAC,WAAD,CAAtB;;AAsCA,SAASC,YAAT,CAAsBC,IAAtB,EAAwCC,QAAxC,EAAmE;EACjE,QAAQD,IAAR;IACE,KAAK,SAAL;MACE,OAAO,aAAP;;IACF,KAAK,WAAL;MACE,OAAO,qBAAP;;IACF,KAAK,UAAL;MACE,OAAO,eAAP;;IACF,KAAK,SAAL;MACE,OAAO,aAAP;;IACF,KAAK,QAAL;MACE,OAAO,YAAP;;IACF,KAAK,QAAL;MACE,OAAO,YAAP;;IACF,KAAK,OAAL;MACE,OAAON,UAAU,CAAC,UAAD,EAAa;QAC5B,iBAAiBO,QADW;QAE5B,sBAAsBA;MAFM,CAAb,CAAjB;EAdJ;AAmBD;;AAED,SAASC,iBAAT,CAA2BF,IAA3B,EAAsD;EACpD,QAAQA,IAAR;IACE,KAAK,WAAL;MACE,OAAON,UAAU,CAAC,MAAD,EAAS,MAAT,CAAjB;EAFJ;AAID;;AAED,IAAMS,MAAM,gBAAGX,KAAK,CAACY,UAAN,CACb,CAACC,KAAD,EAAqBC,GAArB,KAA6B;EAC3B,IAAM;IACJN,IADI;IAEJO,OAFI;IAGJC,IAHI;IAIJC,OAJI;IAKJC,IALI;IAMJC,QANI;IAOJC,MAPI;IAQJC,OARI;IASJC,WATI;IAUJC,SAVI;IAWJC,SAXI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W,EAAEc,SAJO;EAKpBrB,OAAO,EAAEqB,SALW;EAMpBnB,OAAO,EAAEmB,SANW;EAOpBlB,IAAI,EAAEkB,SAPc;EAQpBjB,QAAQ,EAAE,KARU;EASpBC,MAAM,EAAEgB,SATY;EAUpBT,QAAQ,EAAES,SAVU;EAWpBV,QAAQ,EAAEU,SAXU;EAYpBZ,SAAS,EAAEY,SAZS;EAapBX,KAAK,EAAE,EAba;EAcpB,eAAeW;AAdK,CAAtB;AAiBA,eAAezB,MAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchicalCheckboxMenu.d.ts","sourceRoot":"","sources":["../src/HierarchicalCheckboxMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAU,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAI1D,OAAO,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"HierarchicalCheckboxMenu.d.ts","sourceRoot":"","sources":["../src/HierarchicalCheckboxMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAU,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAI1D,OAAO,iCAAiC,CAAC;AAGzC,oBAAY,4BAA4B,GAAG,GAAG,CAC5C,MAAM,EACN,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAC/B,CAAC;AAEF,aAAK,6BAA6B,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,4BAA4B,CAAC;IACvC,gBAAgB,CAAC,GAAG,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAC1D,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,aAAK,6BAA6B,GAAG;IACnC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,cAAM,wBAAyB,SAAQ,SAAS,CAC9C,6BAA6B,EAC7B,6BAA6B,CAC9B;IACC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAKzD;IAEF,MAAM,CAAC,gBAAgB,CACrB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,4BAA4B,GACrC,OAAO,GAAG,IAAI;gBAkBL,KAAK,EAAE,6BAA6B;IAahD,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAS5D,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IA6CpD,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAkBlC,SAAS,IAAI,IAAI;IAIjB,KAAK,IAAI,IAAI;IAIb,iBAAiB,IAAI,KAAK,CAAC,SAAS;IAsDpC,MAAM,IAAI,GAAG,CAAC,OAAO;CAqCtB;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -7,6 +7,7 @@ import classNames from 'classnames';
|
|
|
7
7
|
import Checkbox from "./Checkbox.js";
|
|
8
8
|
import Popper from "./popper/Popper.js";
|
|
9
9
|
import "./HierarchicalCheckboxMenu.css";
|
|
10
|
+
import Button from "./Button.js";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* A pull down menu that displays a hierarchy of checkboxes.
|
|
@@ -175,14 +176,12 @@ class HierarchicalCheckboxMenu extends Component {
|
|
|
175
176
|
onChange: () => this.toggleValueFor(parent, child)
|
|
176
177
|
}, child);
|
|
177
178
|
}));
|
|
178
|
-
}), /*#__PURE__*/React.createElement(
|
|
179
|
-
|
|
180
|
-
className: "btn btn-link",
|
|
179
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
180
|
+
kind: "ghost",
|
|
181
181
|
onClick: this.selectAll,
|
|
182
182
|
"data-testid": dataTestId !== undefined ? "".concat(dataTestId, "-btn-select-all") : undefined
|
|
183
|
-
}, "Select All"), /*#__PURE__*/React.createElement(
|
|
184
|
-
|
|
185
|
-
className: "btn btn-link",
|
|
183
|
+
}, "Select All"), /*#__PURE__*/React.createElement(Button, {
|
|
184
|
+
kind: "ghost",
|
|
186
185
|
onClick: this.clear,
|
|
187
186
|
"data-testid": dataTestId !== undefined ? "".concat(dataTestId, "-btn-clear") : undefined
|
|
188
187
|
}, "Clear"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchicalCheckboxMenu.js","names":["React","Component","FontAwesomeIcon","dhSort","classNames","Checkbox","Popper","HierarchicalCheckboxMenu","isParentSelected","parent","valueMap","children","get","undefined","includesTrue","Array","from","values","includes","includesFalse","constructor","props","toggleMenu","bind","toggleValueFor","selectAll","clear","state","menuIsOpen","event","stopPropagation","preventDefault","setState","child","onUpdateValueMap","map","Map","newChildren","set","parentSelected","newChildValue","forEach","_","key","currentChildren","setAllValues","value","copy","renderMenuElement","dataTestId","entries","render","menuText","className","icon","id","placement"],"sources":["../src/HierarchicalCheckboxMenu.tsx"],"sourcesContent":["import React, { Component } from 'react';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { dhSort, IconDefinition } from '@deephaven/icons';\nimport classNames from 'classnames';\nimport Checkbox from './Checkbox';\nimport Popper from './popper/Popper';\nimport './HierarchicalCheckboxMenu.scss';\n\nexport type HierarchicalCheckboxValueMap = Map<\n string,\n boolean | Map<string, boolean>\n>;\n\ntype HierarchicalCheckboxMenuProps = {\n className: string;\n menuText: string;\n valueMap: HierarchicalCheckboxValueMap;\n onUpdateValueMap(map: HierarchicalCheckboxValueMap): void;\n icon: IconDefinition | null;\n id: string;\n 'data-testid'?: string;\n};\n\ntype HierarchicalCheckboxMenuState = {\n menuIsOpen: boolean;\n};\n\n/**\n * A pull down menu that displays a hierarchy of checkboxes.\n *\n * Currently supports only two levels of check boxes. The input should be a Map\n * where the keys are the parent names. The values can a boolean if the parent\n * has no children or another Map where keys are child names and values are booleans.\n *\n * Here is an example:\n * const INITIAL_TYPE_MAP = new Map([\n * ['Queries', new Map([['Live', true], ['Batch', true]])],\n * [\n * 'DBA Queries',\n * new Map([\n * ['Data Merge', true],\n * ['Data Validation', true],\n * ['Imports', true],\n * ['Data Services', true],\n * ]),\n * ],\n * ['Helper Queries', true],\n * ]);\n *\n * When a checkbox is changed, this component will make a deep copy of the Map\n * with the appropriate booleans changed. It will then call onUpdateValueMap\n * with the new Map.\n */\nclass HierarchicalCheckboxMenu extends Component<\n HierarchicalCheckboxMenuProps,\n HierarchicalCheckboxMenuState\n> {\n static defaultProps: Partial<HierarchicalCheckboxMenuProps> = {\n className: '',\n icon: null,\n id: '',\n 'data-testid': undefined,\n };\n\n static isParentSelected(\n parent: string,\n valueMap: HierarchicalCheckboxValueMap\n ): boolean | null {\n const children = valueMap.get(parent);\n if (children === undefined) {\n return false;\n }\n if (typeof children === 'boolean') {\n // This parent has no children\n return children;\n }\n const includesTrue = Array.from(children.values()).includes(true);\n const includesFalse = Array.from(children.values()).includes(false);\n if (includesTrue && includesFalse) {\n // Indeterminate\n return null;\n }\n return includesTrue;\n }\n\n constructor(props: HierarchicalCheckboxMenuProps) {\n super(props);\n\n this.toggleMenu = this.toggleMenu.bind(this);\n this.toggleValueFor = this.toggleValueFor.bind(this);\n this.selectAll = this.selectAll.bind(this);\n this.clear = this.clear.bind(this);\n\n this.state = {\n menuIsOpen: false,\n };\n }\n\n toggleMenu(event: React.MouseEvent<HTMLButtonElement>): void {\n event.stopPropagation();\n event.preventDefault();\n this.setState(state => {\n const { menuIsOpen } = state;\n return { menuIsOpen: !menuIsOpen };\n });\n }\n\n toggleValueFor(parent: string, child?: string): void {\n const { valueMap, onUpdateValueMap } = this.props;\n\n // Make a deep copy of the Map and toggle the boolean for parent / child\n const map = new Map(valueMap);\n const children = map.get(parent);\n if (children instanceof Map) {\n const newChildren = new Map(children);\n if (child != null) {\n newChildren.set(child, children.get(child) === undefined);\n } else {\n const parentSelected = HierarchicalCheckboxMenu.isParentSelected(\n parent,\n map\n );\n const newChildValue = parentSelected == null || !parentSelected;\n children.forEach((_, key) => newChildren.set(key, newChildValue));\n }\n map.set(parent, newChildren);\n } else {\n map.set(parent, children == null || !children);\n }\n\n // The parent was clicked so all children must be toggled\n const currentChildren = map.get(parent);\n if (\n child === undefined &&\n currentChildren !== undefined &&\n typeof currentChildren !== 'boolean'\n ) {\n const parentSelected = HierarchicalCheckboxMenu.isParentSelected(\n parent,\n valueMap\n );\n if (parentSelected != null && parentSelected) {\n currentChildren.forEach((_, key) => currentChildren.set(key, false));\n } else {\n // for parent selection of false or null (indeterminate), select everything\n currentChildren.forEach((_, key) => currentChildren.set(key, true));\n }\n }\n\n onUpdateValueMap(map);\n }\n\n setAllValues(value: boolean): void {\n const { valueMap, onUpdateValueMap } = this.props;\n\n // Make a deep copy of the Map and set everything\n const copy = new Map();\n valueMap.forEach((child, parent) => {\n if (typeof child === 'boolean') {\n copy.set(parent, value);\n } else {\n const children = new Map();\n child.forEach((_, key) => children.set(key, value));\n copy.set(parent, children);\n }\n });\n\n onUpdateValueMap(copy);\n }\n\n selectAll(): void {\n this.setAllValues(true);\n }\n\n clear(): void {\n this.setAllValues(false);\n }\n\n renderMenuElement(): React.ReactNode {\n const { valueMap, 'data-testid': dataTestId } = this.props;\n return (\n <div className=\"hcm-menu-container\">\n {Array.from(valueMap.entries()).map(([parent, children]) => (\n <div key={parent}>\n <Checkbox\n className=\"hcm-parent\"\n checked={HierarchicalCheckboxMenu.isParentSelected(\n parent,\n valueMap\n )}\n onChange={() => this.toggleValueFor(parent)}\n >\n {parent}\n </Checkbox>\n {children !== undefined &&\n typeof children !== 'boolean' &&\n Array.from(children.entries()).map(([child, value]) => (\n <Checkbox\n className=\"hcm-child\"\n key={child}\n checked={value}\n onChange={() => this.toggleValueFor(parent, child)}\n >\n {child}\n </Checkbox>\n ))}\n </div>\n ))}\n <button\n type=\"button\"\n className=\"btn btn-link\"\n onClick={this.selectAll}\n data-testid={\n dataTestId !== undefined\n ? `${dataTestId}-btn-select-all`\n : undefined\n }\n >\n Select All\n </button>\n <button\n type=\"button\"\n className=\"btn btn-link\"\n onClick={this.clear}\n data-testid={\n dataTestId !== undefined ? `${dataTestId}-btn-clear` : undefined\n }\n >\n Clear\n </button>\n </div>\n );\n }\n\n render(): JSX.Element {\n const {\n menuText,\n className,\n icon,\n id,\n 'data-testid': dataTestId,\n } = this.props;\n const { menuIsOpen } = this.state;\n\n return (\n <button\n type=\"button\"\n className={classNames('btn hcm-btn', className)}\n onClick={this.toggleMenu}\n id={id}\n data-testid={dataTestId}\n >\n <span>\n {icon && <FontAwesomeIcon icon={icon} className=\"hcm-icon mr-1\" />}\n {menuText}\n </span>\n <FontAwesomeIcon icon={dhSort} className=\"hcm-icon ml-1\" />\n <Popper\n options={{ placement: 'bottom' }}\n isShown={menuIsOpen}\n onExited={() => {\n this.setState({ menuIsOpen: false });\n }}\n closeOnBlur\n interactive\n >\n {this.renderMenuElement()}\n </Popper>\n </button>\n );\n }\n}\n\nexport default HierarchicalCheckboxMenu;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,MAAT,QAAuC,kBAAvC;AACA,OAAOC,UAAP,MAAuB,YAAvB;OACOC,Q;OACAC,M;;;AAsBP;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,wBAAN,SAAuCN,SAAvC,CAGE;EAQuB,OAAhBO,gBAAgB,CACrBC,MADqB,EAErBC,QAFqB,EAGL;IAChB,IAAMC,QAAQ,GAAGD,QAAQ,CAACE,GAAT,C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ADP;MAEE,SAAS,EAAEvB,UAAU,CAAC,aAAD,EAAgBiD,SAAhB,CAFvB;MAGE,OAAO,EAAE,KAAK/B,UAHhB;MAIE,EAAE,EAAEiC,EAJN;MAKE,eAAaN;IALf,gBAOE,kCACGK,IAAI,iBAAI,oBAAC,eAAD;MAAiB,IAAI,EAAEA,IAAvB;MAA6B,SAAS,EAAC;IAAvC,EADX,EAEGF,QAFH,CAPF,eAWE,oBAAC,eAAD;MAAiB,IAAI,EAAEjD,MAAvB;MAA+B,SAAS,EAAC;IAAzC,EAXF,eAYE,oBAAC,MAAD;MACE,OAAO,EAAE;QAAEqD,SAAS,EAAE;MAAb,CADX;MAEE,OAAO,EAAE5B,UAFX;MAGE,QAAQ,EAAE,MAAM;QACd,KAAKI,QAAL,CAAc;UAAEJ,UAAU,EAAE;QAAd,CAAd;MACD,CALH;MAME,WAAW,MANb;MAOE,WAAW;IAPb,GASG,KAAKoB,iBAAL,EATH,CAZF,CADF;EA0BD;;AAtND;;gBAHIzC,wB,kBAI0D;EAC5D8C,SAAS,EAAE,EADiD;EAE5DC,IAAI,EAAE,IAFsD;EAG5DC,EAAE,EAAE,EAHwD;EAI5D,eAAe1C;AAJ6C,C;;AAwNhE,eAAeN,wBAAf"}
|
|
1
|
+
{"version":3,"file":"HierarchicalCheckboxMenu.js","names":["React","Component","FontAwesomeIcon","dhSort","classNames","Checkbox","Popper","Button","HierarchicalCheckboxMenu","isParentSelected","parent","valueMap","children","get","undefined","includesTrue","Array","from","values","includes","includesFalse","constructor","props","toggleMenu","bind","toggleValueFor","selectAll","clear","state","menuIsOpen","event","stopPropagation","preventDefault","setState","child","onUpdateValueMap","map","Map","newChildren","set","parentSelected","newChildValue","forEach","_","key","currentChildren","setAllValues","value","copy","renderMenuElement","dataTestId","entries","render","menuText","className","icon","id","placement"],"sources":["../src/HierarchicalCheckboxMenu.tsx"],"sourcesContent":["import React, { Component } from 'react';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { dhSort, IconDefinition } from '@deephaven/icons';\nimport classNames from 'classnames';\nimport Checkbox from './Checkbox';\nimport Popper from './popper/Popper';\nimport './HierarchicalCheckboxMenu.scss';\nimport Button from './Button';\n\nexport type HierarchicalCheckboxValueMap = Map<\n string,\n boolean | Map<string, boolean>\n>;\n\ntype HierarchicalCheckboxMenuProps = {\n className: string;\n menuText: string;\n valueMap: HierarchicalCheckboxValueMap;\n onUpdateValueMap(map: HierarchicalCheckboxValueMap): void;\n icon: IconDefinition | null;\n id: string;\n 'data-testid'?: string;\n};\n\ntype HierarchicalCheckboxMenuState = {\n menuIsOpen: boolean;\n};\n\n/**\n * A pull down menu that displays a hierarchy of checkboxes.\n *\n * Currently supports only two levels of check boxes. The input should be a Map\n * where the keys are the parent names. The values can a boolean if the parent\n * has no children or another Map where keys are child names and values are booleans.\n *\n * Here is an example:\n * const INITIAL_TYPE_MAP = new Map([\n * ['Queries', new Map([['Live', true], ['Batch', true]])],\n * [\n * 'DBA Queries',\n * new Map([\n * ['Data Merge', true],\n * ['Data Validation', true],\n * ['Imports', true],\n * ['Data Services', true],\n * ]),\n * ],\n * ['Helper Queries', true],\n * ]);\n *\n * When a checkbox is changed, this component will make a deep copy of the Map\n * with the appropriate booleans changed. It will then call onUpdateValueMap\n * with the new Map.\n */\nclass HierarchicalCheckboxMenu extends Component<\n HierarchicalCheckboxMenuProps,\n HierarchicalCheckboxMenuState\n> {\n static defaultProps: Partial<HierarchicalCheckboxMenuProps> = {\n className: '',\n icon: null,\n id: '',\n 'data-testid': undefined,\n };\n\n static isParentSelected(\n parent: string,\n valueMap: HierarchicalCheckboxValueMap\n ): boolean | null {\n const children = valueMap.get(parent);\n if (children === undefined) {\n return false;\n }\n if (typeof children === 'boolean') {\n // This parent has no children\n return children;\n }\n const includesTrue = Array.from(children.values()).includes(true);\n const includesFalse = Array.from(children.values()).includes(false);\n if (includesTrue && includesFalse) {\n // Indeterminate\n return null;\n }\n return includesTrue;\n }\n\n constructor(props: HierarchicalCheckboxMenuProps) {\n super(props);\n\n this.toggleMenu = this.toggleMenu.bind(this);\n this.toggleValueFor = this.toggleValueFor.bind(this);\n this.selectAll = this.selectAll.bind(this);\n this.clear = this.clear.bind(this);\n\n this.state = {\n menuIsOpen: false,\n };\n }\n\n toggleMenu(event: React.MouseEvent<HTMLButtonElement>): void {\n event.stopPropagation();\n event.preventDefault();\n this.setState(state => {\n const { menuIsOpen } = state;\n return { menuIsOpen: !menuIsOpen };\n });\n }\n\n toggleValueFor(parent: string, child?: string): void {\n const { valueMap, onUpdateValueMap } = this.props;\n\n // Make a deep copy of the Map and toggle the boolean for parent / child\n const map = new Map(valueMap);\n const children = map.get(parent);\n if (children instanceof Map) {\n const newChildren = new Map(children);\n if (child != null) {\n newChildren.set(child, children.get(child) === undefined);\n } else {\n const parentSelected = HierarchicalCheckboxMenu.isParentSelected(\n parent,\n map\n );\n const newChildValue = parentSelected == null || !parentSelected;\n children.forEach((_, key) => newChildren.set(key, newChildValue));\n }\n map.set(parent, newChildren);\n } else {\n map.set(parent, children == null || !children);\n }\n\n // The parent was clicked so all children must be toggled\n const currentChildren = map.get(parent);\n if (\n child === undefined &&\n currentChildren !== undefined &&\n typeof currentChildren !== 'boolean'\n ) {\n const parentSelected = HierarchicalCheckboxMenu.isParentSelected(\n parent,\n valueMap\n );\n if (parentSelected != null && parentSelected) {\n currentChildren.forEach((_, key) => currentChildren.set(key, false));\n } else {\n // for parent selection of false or null (indeterminate), select everything\n currentChildren.forEach((_, key) => currentChildren.set(key, true));\n }\n }\n\n onUpdateValueMap(map);\n }\n\n setAllValues(value: boolean): void {\n const { valueMap, onUpdateValueMap } = this.props;\n\n // Make a deep copy of the Map and set everything\n const copy = new Map();\n valueMap.forEach((child, parent) => {\n if (typeof child === 'boolean') {\n copy.set(parent, value);\n } else {\n const children = new Map();\n child.forEach((_, key) => children.set(key, value));\n copy.set(parent, children);\n }\n });\n\n onUpdateValueMap(copy);\n }\n\n selectAll(): void {\n this.setAllValues(true);\n }\n\n clear(): void {\n this.setAllValues(false);\n }\n\n renderMenuElement(): React.ReactNode {\n const { valueMap, 'data-testid': dataTestId } = this.props;\n return (\n <div className=\"hcm-menu-container\">\n {Array.from(valueMap.entries()).map(([parent, children]) => (\n <div key={parent}>\n <Checkbox\n className=\"hcm-parent\"\n checked={HierarchicalCheckboxMenu.isParentSelected(\n parent,\n valueMap\n )}\n onChange={() => this.toggleValueFor(parent)}\n >\n {parent}\n </Checkbox>\n {children !== undefined &&\n typeof children !== 'boolean' &&\n Array.from(children.entries()).map(([child, value]) => (\n <Checkbox\n className=\"hcm-child\"\n key={child}\n checked={value}\n onChange={() => this.toggleValueFor(parent, child)}\n >\n {child}\n </Checkbox>\n ))}\n </div>\n ))}\n <Button\n kind=\"ghost\"\n onClick={this.selectAll}\n data-testid={\n dataTestId !== undefined\n ? `${dataTestId}-btn-select-all`\n : undefined\n }\n >\n Select All\n </Button>\n <Button\n kind=\"ghost\"\n onClick={this.clear}\n data-testid={\n dataTestId !== undefined ? `${dataTestId}-btn-clear` : undefined\n }\n >\n Clear\n </Button>\n </div>\n );\n }\n\n render(): JSX.Element {\n const {\n menuText,\n className,\n icon,\n id,\n 'data-testid': dataTestId,\n } = this.props;\n const { menuIsOpen } = this.state;\n\n return (\n <button\n type=\"button\"\n className={classNames('btn hcm-btn', className)}\n onClick={this.toggleMenu}\n id={id}\n data-testid={dataTestId}\n >\n <span>\n {icon && <FontAwesomeIcon icon={icon} className=\"hcm-icon mr-1\" />}\n {menuText}\n </span>\n <FontAwesomeIcon icon={dhSort} className=\"hcm-icon ml-1\" />\n <Popper\n options={{ placement: 'bottom' }}\n isShown={menuIsOpen}\n onExited={() => {\n this.setState({ menuIsOpen: false });\n }}\n closeOnBlur\n interactive\n >\n {this.renderMenuElement()}\n </Popper>\n </button>\n );\n }\n}\n\nexport default HierarchicalCheckboxMenu;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,eAAT,QAAgC,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
46
|
/**
|
|
47
|
-
* Returns true if the modifier key for the current platform is
|
|
47
|
+
* Returns true if the modifier key for the current platform is down for the event (Ctrl for windows/linux, Command (meta) for mac)
|
|
48
48
|
* @param event The event to get the meta key status from
|
|
49
49
|
*/
|
|
50
50
|
static isModifierKeyDown(event: KeyboardEvent | MouseEvent | React.KeyboardEvent | React.MouseEvent): boolean;
|
|
51
51
|
/**
|
|
52
|
-
* Copy the
|
|
52
|
+
* Copy the passed in text to the clipboard.
|
|
53
53
|
* @param text The text to copy
|
|
54
54
|
* @returns Promise Resolved on success, rejected on failure
|
|
55
55
|
*/
|
|
@@ -61,7 +61,7 @@ declare class ContextActionUtils {
|
|
|
61
61
|
*/
|
|
62
62
|
static copyToClipboardExecCommand(text: string): void;
|
|
63
63
|
/**
|
|
64
|
-
* Returns the menu items for the provided context actions, or empty array if none
|
|
64
|
+
* Returns the menu items for the provided context actions, or empty array if none found.
|
|
65
65
|
* @param actionsParam The actions to get menu items for
|
|
66
66
|
* @param includePromises Whether or not to include promises in the returned menu items
|
|
67
67
|
*/
|
|
@@ -83,7 +83,7 @@ class ContextActionUtils {
|
|
|
83
83
|
return 'ctrlKey';
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
* Returns true if the modifier key for the current platform is
|
|
86
|
+
* Returns true if the modifier key for the current platform is down for the event (Ctrl for windows/linux, Command (meta) for mac)
|
|
87
87
|
* @param event The event to get the meta key status from
|
|
88
88
|
*/
|
|
89
89
|
|
|
@@ -93,7 +93,7 @@ class ContextActionUtils {
|
|
|
93
93
|
return event[modifierKey];
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
|
-
* Copy the
|
|
96
|
+
* Copy the passed in text to the clipboard.
|
|
97
97
|
* @param text The text to copy
|
|
98
98
|
* @returns Promise Resolved on success, rejected on failure
|
|
99
99
|
*/
|
|
@@ -139,7 +139,7 @@ class ContextActionUtils {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* Returns the menu items for the provided context actions, or empty array if none
|
|
142
|
+
* Returns the menu items for the provided context actions, or empty array if none found.
|
|
143
143
|
* @param actionsParam The actions to get menu items for
|
|
144
144
|
* @param includePromises Whether or not to include promises in the returned menu items
|
|
145
145
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextActionUtils.js","names":["isPromise","value","then","undefined","ContextActionUtils","disableAllActions","actionsDisabled","enableAllActions","isContextActionEvent","e","Array","isArray","contextActions","compareActions","a","b","group","order","title","sortActions","actions","sortedActions","slice","sort","isMacPlatform","platform","window","navigator","startsWith","getModifierKey","isModifierKeyDown","event","modifierKey","copyToClipboard","text","clipboard","copyToClipboardExecCommand","Promise","resolve","writeText","catch","oldFocus","document","activeElement","textArea","createElement","body","appendChild","focus","select","execCommand","Error","removeChild","HTMLElement","getMenuItems","actionsParam","includePromises","menuItems","i","length","action","newMenuItems","push","concat","filter","menuElement","getNextMenuItem","startIndex","delta","firstIndex","menuIndex","item","disabled"],"sources":["../../src/context-actions/ContextActionUtils.ts"],"sourcesContent":["import { IconDefinition } from '@deephaven/icons';\nimport React from 'react';\nimport type { Shortcut } from '../shortcuts';\n\nexport type ResolvableContextAction =\n | ContextAction\n | Promise<ContextAction[]>\n | (() => Promise<ContextAction[]> | ContextAction[] | ContextAction);\n\nexport type MenuItem = ContextAction | Promise<ContextAction[]>;\n\nexport interface ContextAction {\n title?: string;\n description?: string;\n action?(event?: KeyboardEvent): void;\n actions?: ResolvableContextAction[];\n icon?: IconDefinition | React.ReactElement;\n iconColor?: string;\n shortcut?: Shortcut;\n isGlobal?: boolean;\n group?: number;\n order?: number;\n disabled?: boolean;\n menuElement?: React.ReactElement;\n iconOutline?: boolean;\n}\n\nexport interface ContextActionEvent extends MouseEvent {\n contextActions: ResolvableContextAction[];\n}\n\nexport function isPromise<A, T>(value: A | Promise<T>): value is Promise<T> {\n return (value as Promise<T>).then !== undefined;\n}\n\nclass ContextActionUtils {\n static actionsDisabled = false;\n\n static disableAllActions(): void {\n ContextActionUtils.actionsDisabled = true;\n }\n\n static enableAllActions(): void {\n ContextActionUtils.actionsDisabled = false;\n }\n\n static isContextActionEvent(e: MouseEvent): e is ContextActionEvent {\n return Array.isArray((e as ContextActionEvent).contextActions);\n }\n\n /**\n * Compare two action items. Useful in Array.sort\n * @param a First context action to compare\n * @param b Second context action to compare\n */\n static compareActions(a: ContextAction, b: ContextAction): number {\n if (a.group !== b.group) {\n return (a.group ?? 0) > (b.group ?? 0) ? 1 : -1;\n }\n\n if (a.order !== b.order) {\n return (a.order ?? 0) > (b.order ?? 0) ? 1 : -1;\n }\n\n if (a.title !== b.title) {\n return (a.title ?? '') > (b.title ?? '') ? 1 : -1;\n }\n\n if (a !== b) {\n return a > b ? 1 : -1;\n }\n\n return 0;\n }\n\n /**\n *\n * @param actions The array of actions to sort\n */\n static sortActions(actions: ContextAction[]): ContextAction[] {\n if (actions == null || !Array.isArray(actions)) {\n return [];\n }\n\n const sortedActions = actions.slice();\n sortedActions.sort(ContextActionUtils.compareActions);\n return sortedActions;\n }\n\n static isMacPlatform(): boolean {\n const { platform } = window.navigator;\n return platform.startsWith('Mac');\n }\n\n /**\n * Retrieve the preferred modifier key based on the current platform\n */\n static getModifierKey(): 'metaKey' | 'ctrlKey' {\n if (ContextActionUtils.isMacPlatform()) {\n return 'metaKey';\n }\n\n return 'ctrlKey';\n }\n\n /**\n * Returns true if the modifier key for the current platform is down for the event (Ctrl for windows/linux, Command (meta) for mac)\n * @param event The event to get the meta key status from\n */\n static isModifierKeyDown(\n event: KeyboardEvent | MouseEvent | React.KeyboardEvent | React.MouseEvent\n ): boolean {\n const modifierKey = ContextActionUtils.getModifierKey();\n return event[modifierKey];\n }\n\n /**\n * Copy the p assed in text to the clipboard.\n * @param text The text to copy\n * @returns Promise Resolved on success, rejected on failure\n */\n static copyToClipboard(text: string): Promise<void> {\n const { clipboard } = navigator;\n if (clipboard === undefined) {\n ContextActionUtils.copyToClipboardExecCommand(text);\n return Promise.resolve();\n }\n return navigator.clipboard.writeText(text).catch(() => {\n ContextActionUtils.copyToClipboardExecCommand(text);\n });\n }\n\n /**\n * Copy the passed in text to the clipboard using the `execCommand` functionality\n * Throws on error/failure\n * @param text The text to copy\n */\n static copyToClipboardExecCommand(text: string): void {\n const oldFocus = document.activeElement;\n const textArea = document.createElement('textarea');\n textArea.value = text;\n document.body.appendChild(textArea);\n textArea.focus();\n textArea.select();\n\n if (!document.execCommand('copy')) {\n throw new Error('Unable to execute copy command');\n }\n\n document.body.removeChild(textArea);\n\n if (oldFocus instanceof HTMLElement) {\n oldFocus.focus();\n }\n }\n\n /**\n * Returns the menu items for the provided context actions, or empty array if none foun d.\n * @param actionsParam The actions to get menu items for\n * @param includePromises Whether or not to include promises in the returned menu items\n */\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises?: true\n ): MenuItem[];\n\n // If ignoring promises, then the return type is narrowed\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises: false\n ): ContextAction[];\n\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises = true\n ): MenuItem[] {\n let menuItems: MenuItem[] = [];\n let actions = actionsParam;\n if (!Array.isArray(actions)) {\n actions = [actions];\n }\n\n for (let i = 0; i < actions.length; i += 1) {\n const action = actions[i];\n let newMenuItems:\n | ContextAction\n | ContextAction[]\n | Promise<ContextAction[]>;\n if (typeof action === 'function') {\n newMenuItems = action();\n } else {\n newMenuItems = action;\n }\n\n if (newMenuItems != null) {\n if (newMenuItems instanceof Promise) {\n if (includePromises) {\n menuItems.push(newMenuItems);\n }\n } else if (Array.isArray(newMenuItems)) {\n menuItems = menuItems.concat(newMenuItems);\n } else {\n menuItems.push(newMenuItems);\n }\n }\n }\n\n menuItems = menuItems.filter(\n action =>\n (action as ContextAction).title !== undefined ||\n (action as Promise<ContextAction[]>).then ||\n (action as ContextAction).menuElement\n );\n\n return menuItems;\n }\n\n /**\n * Returns the index of the next menu item in a list that doesn't have a disabled=true prop\n * @param startIndex the starting position for the iteration\n * @param delta the direction of travel, -1 or 1\n * @param menuItems an array of menuItems\n */\n static getNextMenuItem(\n startIndex: number,\n delta: -1 | 1,\n menuItems: MenuItem[]\n ): number {\n let firstIndex = startIndex;\n if (firstIndex < 0 && delta < 0) {\n // if menu index is -1 and delta -1 manually set start point\n firstIndex = menuItems.length;\n }\n // find the next non disabled menu option, iterating the list only once\n for (let i = 1; i < menuItems.length + 1; i += 1) {\n const menuIndex =\n (firstIndex + delta * i + menuItems.length) % menuItems.length;\n const item = menuItems[menuIndex];\n if (!(item instanceof Promise) && item.disabled !== true) {\n return menuIndex;\n }\n }\n return startIndex;\n }\n}\n\nexport default ContextActionUtils;\n"],"mappings":";;AA+BA,OAAO,SAASA,SAAT,CAAyBC,KAAzB,EAAqE;EAC1E,OAAQA,KAAD,CAAsBC,IAAtB,KAA+BC,SAAtC;AACD;;AAED,MAAMC,kBAAN,CAAyB;EAGC,OAAjBC,iBAAiB,GAAS;IAC/BD,kBAAkB,CAACE,eAAnB,GAAqC,IAArC;EACD;;EAEsB,OAAhBC,gBAAgB,GAAS;IAC9BH,kBAAkB,CAACE,eAAnB,GAAqC,KAArC;EACD;;EAE0B,OAApBE,oBAAoB,CAACC,CAAD,EAAyC;IAClE,OAAOC,KAAK,CAACC,OAAN,CAAeF,CAAD,CAA0BG,cAAxC,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACuB,OAAdC,cAAc,CAACC,CAAD,EAAmBC,CAAnB,EAA6C;IAChE,IAAID,CAAC,CAACE,KAAF,KAAYD,CAAC,CAACC,KAAlB,EAAyB;MAAA;;MACvB,OAAO,aAACF,CAAC,CAACE,KAAH,+CAAY,CAAZ,iBAAkBD,CAAC,CAACC,KAApB,+CAA6B,CAA7B,IAAkC,CAAlC,GAAsC,CAAC,CAA9C;IACD;;IAED,IAAIF,CAAC,CAACG,KAAF,KAAYF,CAAC,CAACE,KAAlB,EAAyB;MAAA;;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,EAA0CD,CAAC,IAAI,CAA/C,EAAkD;MAChD,IAAMY,SAAS,GACb,CAACD,UAAU,GAAGD,KAAK,GAAGV,CAArB,GAAyBD,SAAS,CAACE,MAApC,IAA8CF,SAAS,CAACE,MAD1D;MAEA,IAAMY,IAAI,GAAGd,SAAS,CAACa,SAAD,CAAtB;;MACA,IAAI,EAAEC,IAAI,YAAYlC,OAAlB,KAA8BkC,IAAI,CAACC,QAAL,KAAkB,IAApD,EAA0D;QACxD,OAAOF,SAAP;MACD;IACF;;IACD,OAAOH,UAAP;EACD;;AAhNsB;;gBAAnB/D,kB,qBACqB,K;;AAkN3B,eAAeA,kBAAf"}
|
|
1
|
+
{"version":3,"file":"ContextActionUtils.js","names":["isPromise","value","then","undefined","ContextActionUtils","disableAllActions","actionsDisabled","enableAllActions","isContextActionEvent","e","Array","isArray","contextActions","compareActions","a","b","group","order","title","sortActions","actions","sortedActions","slice","sort","isMacPlatform","platform","window","navigator","startsWith","getModifierKey","isModifierKeyDown","event","modifierKey","copyToClipboard","text","clipboard","copyToClipboardExecCommand","Promise","resolve","writeText","catch","oldFocus","document","activeElement","textArea","createElement","body","appendChild","focus","select","execCommand","Error","removeChild","HTMLElement","getMenuItems","actionsParam","includePromises","menuItems","i","length","action","newMenuItems","push","concat","filter","menuElement","getNextMenuItem","startIndex","delta","firstIndex","menuIndex","item","disabled"],"sources":["../../src/context-actions/ContextActionUtils.ts"],"sourcesContent":["import { IconDefinition } from '@deephaven/icons';\nimport React from 'react';\nimport type { Shortcut } from '../shortcuts';\n\nexport type ResolvableContextAction =\n | ContextAction\n | Promise<ContextAction[]>\n | (() => Promise<ContextAction[]> | ContextAction[] | ContextAction);\n\nexport type MenuItem = ContextAction | Promise<ContextAction[]>;\n\nexport interface ContextAction {\n title?: string;\n description?: string;\n action?(event?: KeyboardEvent): void;\n actions?: ResolvableContextAction[];\n icon?: IconDefinition | React.ReactElement;\n iconColor?: string;\n shortcut?: Shortcut;\n isGlobal?: boolean;\n group?: number;\n order?: number;\n disabled?: boolean;\n menuElement?: React.ReactElement;\n iconOutline?: boolean;\n}\n\nexport interface ContextActionEvent extends MouseEvent {\n contextActions: ResolvableContextAction[];\n}\n\nexport function isPromise<A, T>(value: A | Promise<T>): value is Promise<T> {\n return (value as Promise<T>).then !== undefined;\n}\n\nclass ContextActionUtils {\n static actionsDisabled = false;\n\n static disableAllActions(): void {\n ContextActionUtils.actionsDisabled = true;\n }\n\n static enableAllActions(): void {\n ContextActionUtils.actionsDisabled = false;\n }\n\n static isContextActionEvent(e: MouseEvent): e is ContextActionEvent {\n return Array.isArray((e as ContextActionEvent).contextActions);\n }\n\n /**\n * Compare two action items. Useful in Array.sort\n * @param a First context action to compare\n * @param b Second context action to compare\n */\n static compareActions(a: ContextAction, b: ContextAction): number {\n if (a.group !== b.group) {\n return (a.group ?? 0) > (b.group ?? 0) ? 1 : -1;\n }\n\n if (a.order !== b.order) {\n return (a.order ?? 0) > (b.order ?? 0) ? 1 : -1;\n }\n\n if (a.title !== b.title) {\n return (a.title ?? '') > (b.title ?? '') ? 1 : -1;\n }\n\n if (a !== b) {\n return a > b ? 1 : -1;\n }\n\n return 0;\n }\n\n /**\n *\n * @param actions The array of actions to sort\n */\n static sortActions(actions: ContextAction[]): ContextAction[] {\n if (actions == null || !Array.isArray(actions)) {\n return [];\n }\n\n const sortedActions = actions.slice();\n sortedActions.sort(ContextActionUtils.compareActions);\n return sortedActions;\n }\n\n static isMacPlatform(): boolean {\n const { platform } = window.navigator;\n return platform.startsWith('Mac');\n }\n\n /**\n * Retrieve the preferred modifier key based on the current platform\n */\n static getModifierKey(): 'metaKey' | 'ctrlKey' {\n if (ContextActionUtils.isMacPlatform()) {\n return 'metaKey';\n }\n\n return 'ctrlKey';\n }\n\n /**\n * Returns true if the modifier key for the current platform is down for the event (Ctrl for windows/linux, Command (meta) for mac)\n * @param event The event to get the meta key status from\n */\n static isModifierKeyDown(\n event: KeyboardEvent | MouseEvent | React.KeyboardEvent | React.MouseEvent\n ): boolean {\n const modifierKey = ContextActionUtils.getModifierKey();\n return event[modifierKey];\n }\n\n /**\n * Copy the passed in text to the clipboard.\n * @param text The text to copy\n * @returns Promise Resolved on success, rejected on failure\n */\n static copyToClipboard(text: string): Promise<void> {\n const { clipboard } = navigator;\n if (clipboard === undefined) {\n ContextActionUtils.copyToClipboardExecCommand(text);\n return Promise.resolve();\n }\n return navigator.clipboard.writeText(text).catch(() => {\n ContextActionUtils.copyToClipboardExecCommand(text);\n });\n }\n\n /**\n * Copy the passed in text to the clipboard using the `execCommand` functionality\n * Throws on error/failure\n * @param text The text to copy\n */\n static copyToClipboardExecCommand(text: string): void {\n const oldFocus = document.activeElement;\n const textArea = document.createElement('textarea');\n textArea.value = text;\n document.body.appendChild(textArea);\n textArea.focus();\n textArea.select();\n\n if (!document.execCommand('copy')) {\n throw new Error('Unable to execute copy command');\n }\n\n document.body.removeChild(textArea);\n\n if (oldFocus instanceof HTMLElement) {\n oldFocus.focus();\n }\n }\n\n /**\n * Returns the menu items for the provided context actions, or empty array if none found.\n * @param actionsParam The actions to get menu items for\n * @param includePromises Whether or not to include promises in the returned menu items\n */\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises?: true\n ): MenuItem[];\n\n // If ignoring promises, then the return type is narrowed\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises: false\n ): ContextAction[];\n\n static getMenuItems(\n actionsParam: ResolvableContextAction | ResolvableContextAction[],\n includePromises = true\n ): MenuItem[] {\n let menuItems: MenuItem[] = [];\n let actions = actionsParam;\n if (!Array.isArray(actions)) {\n actions = [actions];\n }\n\n for (let i = 0; i < actions.length; i += 1) {\n const action = actions[i];\n let newMenuItems:\n | ContextAction\n | ContextAction[]\n | Promise<ContextAction[]>;\n if (typeof action === 'function') {\n newMenuItems = action();\n } else {\n newMenuItems = action;\n }\n\n if (newMenuItems != null) {\n if (newMenuItems instanceof Promise) {\n if (includePromises) {\n menuItems.push(newMenuItems);\n }\n } else if (Array.isArray(newMenuItems)) {\n menuItems = menuItems.concat(newMenuItems);\n } else {\n menuItems.push(newMenuItems);\n }\n }\n }\n\n menuItems = menuItems.filter(\n action =>\n (action as ContextAction).title !== undefined ||\n (action as Promise<ContextAction[]>).then ||\n (action as ContextAction).menuElement\n );\n\n return menuItems;\n }\n\n /**\n * Returns the index of the next menu item in a list that doesn't have a disabled=true prop\n * @param startIndex the starting position for the iteration\n * @param delta the direction of travel, -1 or 1\n * @param menuItems an array of menuItems\n */\n static getNextMenuItem(\n startIndex: number,\n delta: -1 | 1,\n menuItems: MenuItem[]\n ): number {\n let firstIndex = startIndex;\n if (firstIndex < 0 && delta < 0) {\n // if menu index is -1 and delta -1 manually set start point\n firstIndex = menuItems.length;\n }\n // find the next non disabled menu option, iterating the list only once\n for (let i = 1; i < menuItems.length + 1; i += 1) {\n const menuIndex =\n (firstIndex + delta * i + menuItems.length) % menuItems.length;\n const item = menuItems[menuIndex];\n if (!(item instanceof Promise) && item.disabled !== true) {\n return menuIndex;\n }\n }\n return startIndex;\n }\n}\n\nexport default ContextActionUtils;\n"],"mappings":";;AA+BA,OAAO,SAASA,SAAT,CAAyBC,KAAzB,EAAqE;EAC1E,OAAQA,KAAD,CAAsBC,IAAtB,KAA+BC,SAAtC;AACD;;AAED,MAAMC,kBAAN,CAAyB;EAGC,OAAjBC,iBAAiB,GAAS;IAC/BD,kBAAkB,CAACE,eAAnB,GAAqC,IAArC;EACD;;EAEsB,OAAhBC,gBAAgB,GAAS;IAC9BH,kBAAkB,CAACE,eAAnB,GAAqC,KAArC;EACD;;EAE0B,OAApBE,oBAAoB,CAACC,CAAD,EAAyC;IAClE,OAAOC,KAAK,CAACC,OAAN,CAAeF,CAAD,CAA0BG,cAAxC,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACuB,OAAdC,cAAc,CAACC,CAAD,EAAmBC,CAAnB,EAA6C;IAChE,IAAID,CAAC,CAACE,KAAF,KAAYD,CAAC,CAACC,KAA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AjB;;IACA,IAAIE,UAAU,GAAG,CAAb,IAAkBD,KAAK,GAAG,CAA9B,EAAiC;MAC/B;MACAC,UAAU,GAAGZ,SAAS,CAACE,MAAvB;IACD,CALO,CAMR;;;IACA,KAAK,IAAID,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,SAAS,CAACE,MAAV,GAAmB,CAAvC,EAA0CD,CAAC,IAAI,CAA/C,EAAkD;MAChD,IAAMY,SAAS,GACb,CAACD,UAAU,GAAGD,KAAK,GAAGV,CAArB,GAAyBD,SAAS,CAACE,MAApC,IAA8CF,SAAS,CAACE,MAD1D;MAEA,IAAMY,IAAI,GAAGd,SAAS,CAACa,SAAD,CAAtB;;MACA,IAAI,EAAEC,IAAI,YAAYlC,OAAlB,KAA8BkC,IAAI,CAACC,QAAL,KAAkB,IAApD,EAA0D;QACxD,OAAOF,SAAP;MACD;IACF;;IACD,OAAOH,UAAP;EACD;;AAhNsB;;gBAAnB/D,kB,qBACqB,K;;AAkN3B,eAAeA,kBAAf"}
|
|
@@ -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,uBAAuB,EAExB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,sBAAsB,CAAC;AAE9E,OAAO,uBAAuB,CAAC;AAI/B,UAAU,mBAAmB;IAC3B,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,EAAE,CAAC;IAC7D,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;;;;;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E,GACvB,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"}
|
|
@@ -81,7 +81,7 @@ class ContextActions extends Component {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
var globalActions = props.actions.filter(action => !isPromise(action) && typeof action !== 'function' && action.isGlobal);
|
|
84
|
-
var keyboardActions = props.actions.filter(action => !isPromise(action) && typeof action !== 'function' && action.isGlobal
|
|
84
|
+
var keyboardActions = props.actions.filter(action => !isPromise(action) && typeof action !== 'function' && (action.isGlobal === undefined || !action.isGlobal) && action.shortcut != null);
|
|
85
85
|
return {
|
|
86
86
|
globalActions,
|
|
87
87
|
keyboardActions
|
|
@@ -153,7 +153,7 @@ class ContextActions extends Component {
|
|
|
153
153
|
var contextActions = actions;
|
|
154
154
|
|
|
155
155
|
if (Array.isArray(contextActions)) {
|
|
156
|
-
contextActions = contextActions.filter(action => isPromise(action) || typeof action === 'function' || action.isGlobal === undefined || action.isGlobal);
|
|
156
|
+
contextActions = contextActions.filter(action => isPromise(action) || typeof action === 'function' || action.isGlobal === undefined || !action.isGlobal);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
e.contextActions = e.contextActions.concat(contextActions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextActions.js","names":["React","Component","Log","ContextActionUtils","isPromise","GlobalContextActions","log","module","ContextActions","triggerMenu","element","clientX","clientY","actions","length","mouseEvent","MouseEvent","bubbles","cancelable","contextActions","dispatchEvent","constructor","props","handleContextMenu","bind","handleKeyDown","container","createRef","state","globalActions","keyboardActions","getDerivedStateFromProps","Array","isArray","filter","action","isGlobal","undefined","shortcut","componentDidMount","current","parentElement","addEventListener","componentWillUnmount","removeEventListener","e","ignoreClassNames","el","target","classList","ignoredClassName","find","className","contains","debug2","isContextActionEvent","concat","debug","i","keyboardAction","actionsDisabled","matchesEvent","stopPropagation","preventDefault","render","dataTestId","default","high","medium","low","global","edit"],"sources":["../../src/context-actions/ContextActions.tsx"],"sourcesContent":["/**\n * Just a simple utility class for displaying a popup menu.\n */\nimport React, { Component } from 'react';\nimport Log from '@deephaven/log';\nimport ContextActionUtils, {\n ResolvableContextAction,\n isPromise,\n} from './ContextActionUtils';\nimport type { ContextAction, ContextActionEvent } from './ContextActionUtils';\nimport GlobalContextActions from './GlobalContextActions';\nimport './ContextActions.scss';\n\nconst log = Log.module('ContextActions');\n\ninterface ContextActionsProps {\n actions: ResolvableContextAction | ResolvableContextAction[];\n ignoreClassNames?: string[];\n 'data-testid'?: string;\n}\n\ninterface ContextActionsState {\n globalActions: ContextAction[];\n keyboardActions: ContextAction[];\n}\n\n/**\n * ContextActions that you add onto any component.\n *\n * Usage:\n * let actions = [{\n * title: 'My Action', // Omit the title to hide it from the context menu\n * action: () => { alert('My Action Clicked!') }\n * actions: [] // Submenu of actions\n * icon: faPrint, // Limited to FontAwesome icons for now.\n * iconColor: '#ff0000, // Color to use for the icon\n * shortcut: Shortcut, // Defaults to null\n * isGlobal: false, // Global context action. Defaults to false.\n * group: ContextActions.groups.default, // What group to group the context action with\n * order: null, // Int where to order within group\n * disabled: true // disable action\n * menuElement: null // Custom menu element for displaying in context menu. When null, creates a default menu item based on title\n * }];\n *\n * <div>\n * Right click in this container\n * <ContextActions actions={actions}/>\n * </div>\n *\n * Right clicking the container will then build the context menu, bubbling up until an element with a ContextMenuRoot is on it.\n * You should generally have a ContextMenuRoot on the root node of your document.\n */\nclass ContextActions extends Component<\n ContextActionsProps,\n ContextActionsState\n> {\n /**\n * Group you can assign to context menu actions to group them together.\n * Lower group IDs appear at the top of the list.\n * Groups are separated by a separator item.\n * Items within groups are ordered by their order property, then by their title.\n */\n static groups = {\n default: null,\n high: 100,\n medium: 5000,\n low: 10000,\n global: 100000,\n\n edit: 100,\n };\n\n static triggerMenu(\n element: Element,\n clientX: number,\n clientY: number,\n actions: ContextAction[]\n ): void {\n if (actions.length === 0) {\n return;\n }\n\n const mouseEvent: Partial<ContextActionEvent> = new MouseEvent(\n 'contextmenu',\n {\n clientX,\n clientY,\n bubbles: true,\n cancelable: true,\n }\n );\n mouseEvent.contextActions = actions;\n\n element.dispatchEvent(mouseEvent as ContextActionEvent);\n }\n\n constructor(props: ContextActionsProps) {\n super(props);\n\n this.handleContextMenu = this.handleContextMenu.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.container = React.createRef();\n\n this.state = { globalActions: [], keyboardActions: [] };\n }\n\n static getDerivedStateFromProps(\n props: ContextActionsProps\n ): ContextActionsState {\n if (props.actions == null || !Array.isArray(props.actions)) {\n return { globalActions: [], keyboardActions: [] };\n }\n const globalActions = props.actions.filter(\n action =>\n !isPromise(action) && typeof action !== 'function' && action.isGlobal\n ) as ContextAction[];\n const keyboardActions = props.actions.filter(\n action =>\n !isPromise(action) &&\n typeof action !== 'function' &&\n action.isGlobal !== undefined &&\n !action.isGlobal &&\n action.shortcut != null\n ) as ContextAction[];\n\n return { globalActions, keyboardActions };\n }\n\n componentDidMount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.addEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n this.container.current.parentElement.addEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n }\n\n componentWillUnmount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.removeEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n this.container.current.parentElement.removeEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n handleContextMenu(e: MouseEvent): void {\n const { ignoreClassNames = [] } = this.props;\n if (ignoreClassNames.length > 0) {\n let el = e.target as Element | null;\n while (el != null) {\n const { classList } = el;\n const ignoredClassName = ignoreClassNames.find(className =>\n classList.contains(className)\n );\n if (ignoredClassName !== undefined) {\n log.debug2(\n `Contextmenu event ignored based on the target className \"${ignoredClassName}\"`\n );\n return;\n }\n el = el.parentElement;\n }\n }\n if (!ContextActionUtils.isContextActionEvent(e)) {\n (e as ContextActionEvent).contextActions = [];\n }\n\n if (!ContextActionUtils.isContextActionEvent(e)) {\n return;\n }\n\n const { actions } = this.props;\n if (actions != null) {\n let contextActions = actions;\n if (Array.isArray(contextActions)) {\n contextActions = contextActions.filter(\n action =>\n isPromise(action) ||\n typeof action === 'function' ||\n action.isGlobal === undefined ||\n action.isGlobal\n );\n }\n\n e.contextActions = e.contextActions.concat(contextActions);\n }\n\n log.debug(\n 'Received context menu event! Menu items are now: ',\n e.contextActions\n );\n }\n\n handleKeyDown(e: KeyboardEvent): void {\n const { keyboardActions } = this.state;\n for (let i = 0; i < keyboardActions.length; i += 1) {\n const keyboardAction = keyboardActions[i];\n if (\n !ContextActionUtils.actionsDisabled &&\n keyboardAction.shortcut != null &&\n keyboardAction.shortcut.matchesEvent(e)\n ) {\n log.debug('Context hotkey matched!', e);\n\n keyboardAction.action?.(e);\n\n e.stopPropagation();\n e.preventDefault();\n\n log.debug2('Matched hotkey returned false, key event not consumed');\n }\n }\n }\n\n render(): JSX.Element {\n const { 'data-testid': dataTestId } = this.props;\n const { globalActions } = this.state;\n return (\n <div\n className=\"context-actions-listener\"\n ref={this.container}\n data-testid={dataTestId}\n >\n <GlobalContextActions actions={globalActions} />\n </div>\n );\n }\n}\n\nexport default ContextActions;\n"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,kB,I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AEEZ,CAAC,CAAC1B,cAFJ;EAID;;EAEDM,aAAa,CAACoB,CAAD,EAAyB;IACpC,IAAM;MAAEf;IAAF,IAAsB,KAAKF,KAAjC;;IACA,KAAK,IAAI8B,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG5B,eAAe,CAAChB,MAApC,EAA4C4C,CAAC,IAAI,CAAjD,EAAoD;MAClD,IAAMC,cAAc,GAAG7B,eAAe,CAAC4B,CAAD,CAAtC;;MACA,IACE,CAACvD,kBAAkB,CAACyD,eAApB,IACAD,cAAc,CAACrB,QAAf,IAA2B,IAD3B,IAEAqB,cAAc,CAACrB,QAAf,CAAwBuB,YAAxB,CAAqChB,CAArC,CAHF,EAIE;QAAA;;QACAvC,GAAG,CAACmD,KAAJ,CAAU,yBAAV,EAAqCZ,CAArC;QAEA,yBAAAc,cAAc,CAACxB,MAAf,qFAAAwB,cAAc,EAAUd,CAAV,CAAd;QAEAA,CAAC,CAACiB,eAAF;QACAjB,CAAC,CAACkB,cAAF;QAEAzD,GAAG,CAACgD,MAAJ,CAAW,uDAAX;MACD;IACF;EACF;;EAEDU,MAAM,GAAgB;IACpB,IAAM;MAAE,eAAeC;IAAjB,IAAgC,KAAK3C,KAA3C;IACA,IAAM;MAAEO;IAAF,IAAoB,KAAKD,KAA/B;IACA,oBACE;MACE,SAAS,EAAC,0BADZ;MAEE,GAAG,EAAE,KAAKF,SAFZ;MAGE,eAAauC;IAHf,gBAKE,oBAAC,oBAAD;MAAsB,OAAO,EAAEpC;IAA/B,EALF,CADF;EASD;;AAvLD;;gBAHIrB,c,YAUY;EACd0D,OAAO,EAAE,IADK;EAEdC,IAAI,EAAE,GAFQ;EAGdC,MAAM,EAAE,IAHM;EAIdC,GAAG,EAAE,KAJS;EAKdC,MAAM,EAAE,MALM;EAOdC,IAAI,EAAE;AAPQ,C;;AAmLlB,eAAe/D,cAAf"}
|
|
1
|
+
{"version":3,"file":"ContextActions.js","names":["React","Component","Log","ContextActionUtils","isPromise","GlobalContextActions","log","module","ContextActions","triggerMenu","element","clientX","clientY","actions","length","mouseEvent","MouseEvent","bubbles","cancelable","contextActions","dispatchEvent","constructor","props","handleContextMenu","bind","handleKeyDown","container","createRef","state","globalActions","keyboardActions","getDerivedStateFromProps","Array","isArray","filter","action","isGlobal","undefined","shortcut","componentDidMount","current","parentElement","addEventListener","componentWillUnmount","removeEventListener","e","ignoreClassNames","el","target","classList","ignoredClassName","find","className","contains","debug2","isContextActionEvent","concat","debug","i","keyboardAction","actionsDisabled","matchesEvent","stopPropagation","preventDefault","render","dataTestId","default","high","medium","low","global","edit"],"sources":["../../src/context-actions/ContextActions.tsx"],"sourcesContent":["/**\n * Just a simple utility class for displaying a popup menu.\n */\nimport React, { Component } from 'react';\nimport Log from '@deephaven/log';\nimport ContextActionUtils, {\n ResolvableContextAction,\n isPromise,\n} from './ContextActionUtils';\nimport type { ContextAction, ContextActionEvent } from './ContextActionUtils';\nimport GlobalContextActions from './GlobalContextActions';\nimport './ContextActions.scss';\n\nconst log = Log.module('ContextActions');\n\ninterface ContextActionsProps {\n actions: ResolvableContextAction | ResolvableContextAction[];\n ignoreClassNames?: string[];\n 'data-testid'?: string;\n}\n\ninterface ContextActionsState {\n globalActions: ContextAction[];\n keyboardActions: ContextAction[];\n}\n\n/**\n * ContextActions that you add onto any component.\n *\n * Usage:\n * let actions = [{\n * title: 'My Action', // Omit the title to hide it from the context menu\n * action: () => { alert('My Action Clicked!') }\n * actions: [] // Submenu of actions\n * icon: faPrint, // Limited to FontAwesome icons for now.\n * iconColor: '#ff0000, // Color to use for the icon\n * shortcut: Shortcut, // Defaults to null\n * isGlobal: false, // Global context action. Defaults to false.\n * group: ContextActions.groups.default, // What group to group the context action with\n * order: null, // Int where to order within group\n * disabled: true // disable action\n * menuElement: null // Custom menu element for displaying in context menu. When null, creates a default menu item based on title\n * }];\n *\n * <div>\n * Right click in this container\n * <ContextActions actions={actions}/>\n * </div>\n *\n * Right clicking the container will then build the context menu, bubbling up until an element with a ContextMenuRoot is on it.\n * You should generally have a ContextMenuRoot on the root node of your document.\n */\nclass ContextActions extends Component<\n ContextActionsProps,\n ContextActionsState\n> {\n /**\n * Group you can assign to context menu actions to group them together.\n * Lower group IDs appear at the top of the list.\n * Groups are separated by a separator item.\n * Items within groups are ordered by their order property, then by their title.\n */\n static groups = {\n default: null,\n high: 100,\n medium: 5000,\n low: 10000,\n global: 100000,\n\n edit: 100,\n };\n\n static triggerMenu(\n element: Element,\n clientX: number,\n clientY: number,\n actions: ContextAction[]\n ): void {\n if (actions.length === 0) {\n return;\n }\n\n const mouseEvent: Partial<ContextActionEvent> = new MouseEvent(\n 'contextmenu',\n {\n clientX,\n clientY,\n bubbles: true,\n cancelable: true,\n }\n );\n mouseEvent.contextActions = actions;\n\n element.dispatchEvent(mouseEvent as ContextActionEvent);\n }\n\n constructor(props: ContextActionsProps) {\n super(props);\n\n this.handleContextMenu = this.handleContextMenu.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.container = React.createRef();\n\n this.state = { globalActions: [], keyboardActions: [] };\n }\n\n static getDerivedStateFromProps(\n props: ContextActionsProps\n ): ContextActionsState {\n if (props.actions == null || !Array.isArray(props.actions)) {\n return { globalActions: [], keyboardActions: [] };\n }\n const globalActions = props.actions.filter(\n action =>\n !isPromise(action) && typeof action !== 'function' && action.isGlobal\n ) as ContextAction[];\n const keyboardActions = props.actions.filter(\n action =>\n !isPromise(action) &&\n typeof action !== 'function' &&\n (action.isGlobal === undefined || !action.isGlobal) &&\n action.shortcut != null\n ) as ContextAction[];\n\n return { globalActions, keyboardActions };\n }\n\n componentDidMount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.addEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n this.container.current.parentElement.addEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n }\n\n componentWillUnmount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.removeEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n this.container.current.parentElement.removeEventListener(\n 'keydown',\n this.handleKeyDown\n );\n }\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n handleContextMenu(e: MouseEvent): void {\n const { ignoreClassNames = [] } = this.props;\n if (ignoreClassNames.length > 0) {\n let el = e.target as Element | null;\n while (el != null) {\n const { classList } = el;\n const ignoredClassName = ignoreClassNames.find(className =>\n classList.contains(className)\n );\n if (ignoredClassName !== undefined) {\n log.debug2(\n `Contextmenu event ignored based on the target className \"${ignoredClassName}\"`\n );\n return;\n }\n el = el.parentElement;\n }\n }\n if (!ContextActionUtils.isContextActionEvent(e)) {\n (e as ContextActionEvent).contextActions = [];\n }\n\n if (!ContextActionUtils.isContextActionEvent(e)) {\n return;\n }\n\n const { actions } = this.props;\n if (actions != null) {\n let contextActions = actions;\n if (Array.isArray(contextActions)) {\n contextActions = contextActions.filter(\n action =>\n isPromise(action) ||\n typeof action === 'function' ||\n action.isGlobal === undefined ||\n !action.isGlobal\n );\n }\n\n e.contextActions = e.contextActions.concat(contextActions);\n }\n\n log.debug(\n 'Received context menu event! Menu items are now: ',\n e.contextActions\n );\n }\n\n handleKeyDown(e: KeyboardEvent): void {\n const { keyboardActions } = this.state;\n for (let i = 0; i < keyboardActions.length; i += 1) {\n const keyboardAction = keyboardActions[i];\n if (\n !ContextActionUtils.actionsDisabled &&\n keyboardAction.shortcut != null &&\n keyboardAction.shortcut.matchesEvent(e)\n ) {\n log.debug('Context hotkey matched!', e);\n\n keyboardAction.action?.(e);\n\n e.stopPropagation();\n e.preventDefault();\n\n log.debug2('Matched hotkey returned false, key event not consumed');\n }\n }\n }\n\n render(): JSX.Element {\n const { 'data-testid': dataTestId } = this.props;\n const { globalActions } = this.state;\n return (\n <div\n className=\"context-actions-listener\"\n ref={this.container}\n data-testid={dataTestId}\n >\n <GlobalContextActions actions={globalActions} />\n </div>\n );\n }\n}\n\nexport default ContextActions;\n"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/navigation/Page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/navigation/Page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,aAAa,CAAC;AAGrB,oBAAY,SAAS,GAAG;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,IAAI,qEAMd,SAAS,KAAG,WAgCd,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/dist/navigation/Page.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
2
|
import { vsClose, vsChevronLeft } from '@deephaven/icons';
|
|
4
3
|
import "./Page.css";
|
|
4
|
+
import Button from "../Button.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A page view with a back button in the bottom left, a title at the top, and a close button in the top right.
|
|
@@ -22,25 +22,24 @@ export var Page = _ref => {
|
|
|
22
22
|
className: "navigation-title-bar"
|
|
23
23
|
}, /*#__PURE__*/React.createElement("div", {
|
|
24
24
|
className: "navigation-left-buttons"
|
|
25
|
-
}, onBack !== undefined && /*#__PURE__*/React.createElement(
|
|
26
|
-
|
|
25
|
+
}, onBack !== undefined && /*#__PURE__*/React.createElement(Button, {
|
|
26
|
+
kind: "ghost",
|
|
27
|
+
className: "btn-back",
|
|
27
28
|
"data-testid": "btn-page-back",
|
|
28
|
-
|
|
29
|
-
onClick: onBack
|
|
30
|
-
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
29
|
+
onClick: onBack,
|
|
31
30
|
icon: vsChevronLeft
|
|
32
|
-
}
|
|
31
|
+
}, "Back")), /*#__PURE__*/React.createElement("div", {
|
|
33
32
|
className: "navigation-title"
|
|
34
33
|
}, title), /*#__PURE__*/React.createElement("div", {
|
|
35
34
|
className: "navigation-right-buttons"
|
|
36
|
-
}, onClose !== undefined && /*#__PURE__*/React.createElement(
|
|
37
|
-
|
|
35
|
+
}, onClose !== undefined && /*#__PURE__*/React.createElement(Button, {
|
|
36
|
+
kind: "ghost",
|
|
37
|
+
className: "btn-close px-2 m-1",
|
|
38
38
|
"data-testid": "btn-page-close",
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})))), /*#__PURE__*/React.createElement("div", {
|
|
39
|
+
onClick: onClose,
|
|
40
|
+
icon: vsClose,
|
|
41
|
+
tooltip: "Close"
|
|
42
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
44
43
|
className: "navigation-content"
|
|
45
44
|
}, children));
|
|
46
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Page.js","names":["React","
|
|
1
|
+
{"version":3,"file":"Page.js","names":["React","vsClose","vsChevronLeft","Button","Page","children","onBack","onClose","title","dataTestId","undefined"],"sources":["../../src/navigation/Page.tsx"],"sourcesContent":["import React from 'react';\nimport { vsClose, vsChevronLeft } from '@deephaven/icons';\nimport './Page.scss';\nimport Button from '../Button';\n\nexport type PageProps = {\n children: React.ReactNode;\n onBack?: () => void;\n onClose?: () => void;\n title: string;\n 'data-testid'?: string;\n};\n\n/**\n * A page view with a back button in the bottom left, a title at the top, and a close button in the top right.\n * Back and close buttons will only appear if `onBack` and/or `onClose` callbacks are set.\n */\nexport const Page = ({\n children,\n onBack,\n onClose,\n title,\n 'data-testid': dataTestId,\n}: PageProps): JSX.Element => (\n <div className=\"navigation-page\" data-testid={dataTestId}>\n <div className=\"navigation-title-bar\">\n <div className=\"navigation-left-buttons\">\n {onBack !== undefined && (\n <Button\n kind=\"ghost\"\n className=\"btn-back\"\n data-testid=\"btn-page-back\"\n onClick={onBack}\n icon={vsChevronLeft}\n >\n Back\n </Button>\n )}\n </div>\n <div className=\"navigation-title\">{title}</div>\n <div className=\"navigation-right-buttons\">\n {onClose !== undefined && (\n <Button\n kind=\"ghost\"\n className=\"btn-close px-2 m-1\"\n data-testid=\"btn-page-close\"\n onClick={onClose}\n icon={vsClose}\n tooltip=\"Close\"\n />\n )}\n </div>\n </div>\n <div className=\"navigation-content\">{children}</div>\n </div>\n);\n\nexport default Page;\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,OAAT,EAAkBC,aAAlB,QAAuC,kBAAvC;;OAEOC,M;;AAUP;AACA;AACA;AACA;AACA,OAAO,IAAMC,IAAI,GAAG;EAAA,IAAC;IACnBC,QADmB;IAEnBC,MAFmB;IAGnBC,OAHmB;IAInBC,KAJmB;IAKnB,eAAeC;EALI,CAAD;EAAA,oBAOlB;IAAK,SAAS,EAAC,iBAAf;IAAiC,eAAaA;EAA9C,gBACE;IAAK,SAAS,EAAC;EAAf,gBACE;IAAK,SAAS,EAAC;EAAf,GACGH,MAAM,KAAKI,SAAX,iBACC,oBAAC,MAAD;IACE,IAAI,EAAC,OADP;IAEE,SAAS,EAAC,UAFZ;IAGE,eAAY,eAHd;IAIE,OAAO,EAAEJ,MAJX;IAKE,IAAI,EAAEJ;EALR,UAFJ,CADF,eAcE;IAAK,SAAS,EAAC;EAAf,GAAmCM,KAAnC,CAdF,eAeE;IAAK,SAAS,EAAC;EAAf,GACGD,OAAO,KAAKG,SAAZ,iBACC,oBAAC,MAAD;IACE,IAAI,EAAC,OADP;IAEE,SAAS,EAAC,oBAFZ;IAGE,eAAY,gBAHd;IAIE,OAAO,EAAEH,OAJX;IAKE,IAAI,EAAEN,OALR;IAME,OAAO,EAAC;EANV,EAFJ,CAfF,CADF,eA6BE;IAAK,SAAS,EAAC;EAAf,GAAqCI,QAArC,CA7BF,CAPkB;AAAA,CAAb;AAwCP,eAAeD,IAAf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Deephaven React component library",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"start": "cross-env NODE_ENV=development npm run watch"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@deephaven/icons": "^0.
|
|
35
|
-
"@deephaven/log": "^0.
|
|
36
|
-
"@deephaven/react-hooks": "^0.
|
|
37
|
-
"@deephaven/utils": "^0.
|
|
34
|
+
"@deephaven/icons": "^0.20.0",
|
|
35
|
+
"@deephaven/log": "^0.20.0",
|
|
36
|
+
"@deephaven/react-hooks": "^0.20.0",
|
|
37
|
+
"@deephaven/utils": "^0.20.0",
|
|
38
38
|
"@fortawesome/fontawesome-svg-core": "^6.1.1",
|
|
39
39
|
"@fortawesome/react-fontawesome": "^0.1.18",
|
|
40
40
|
"bootstrap": "4.6.2",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"react-dom": "^17.x"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@deephaven/mocks": "^0.
|
|
61
|
-
"@deephaven/tsconfig": "^0.
|
|
60
|
+
"@deephaven/mocks": "^0.20.0",
|
|
61
|
+
"@deephaven/tsconfig": "^0.20.0"
|
|
62
62
|
},
|
|
63
63
|
"files": [
|
|
64
64
|
"dist",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "f1df977c5cc020a300015265ab20ad4c67ba51eb"
|
|
74
74
|
}
|