@modusoperandi/licit 0.1.9 → 0.13.2
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/.github/workflows/build.yml +1 -7
- package/.github/workflows/lint.yml +1 -1
- package/README.md +1 -1
- package/babel.config.json +54 -0
- package/dist/BlockquoteNodeSpec.js +2 -2
- package/dist/CZIProseMirror.js +4 -4
- package/dist/CodeBlockCommand.js +2 -2
- package/dist/CodeBlockCommand.js.flow +1 -1
- package/dist/CursorPlaceholderPlugin.js +2 -2
- package/dist/DocLayoutCommand.js +2 -4
- package/dist/DocLayoutCommand.js.flow +1 -1
- package/dist/DocNodeSpec.js +1 -1
- package/dist/EditorCommands.js +23 -35
- package/dist/EditorCommands.js.flow +7 -7
- package/dist/EditorKeyMap.js +3 -3
- package/dist/FontTypeMarkSpec.js +1 -1
- package/dist/HeadingNodeSpec.js +2 -2
- package/dist/ImageSourceCommand.js +2 -4
- package/dist/ImageSourceCommand.js.flow +1 -1
- package/dist/ImageUploadPlaceholderPlugin.js +1 -1
- package/dist/LinkSetURLCommand.js +4 -8
- package/dist/LinkSetURLCommand.js.flow +3 -3
- package/dist/LinkTooltipPlugin.js +9 -15
- package/dist/LinkTooltipPlugin.js.flow +5 -5
- package/dist/ListToggleCommand.js +5 -11
- package/dist/ListToggleCommand.js.flow +3 -3
- package/dist/MarkNames.js +1 -1
- package/dist/MarksClearCommand.js +3 -3
- package/dist/MarksClearCommand.js.flow +1 -1
- package/dist/MathEditCommand.js +2 -2
- package/dist/MathEditCommand.js.flow +1 -1
- package/dist/ParagraphNodeSpec.js +3 -4
- package/dist/ParagraphNodeSpec.js.flow +2 -6
- package/dist/ParagraphSpacingCommand.js +3 -3
- package/dist/SelectionPlaceholderPlugin.js +2 -2
- package/dist/SpacerMarkSpec.js +1 -1
- package/dist/TableBackgroundColorCommand.js +3 -7
- package/dist/TableBackgroundColorCommand.js.flow +3 -3
- package/dist/TableBorderColorCommand.js +3 -7
- package/dist/TableBorderColorCommand.js.flow +3 -3
- package/dist/TableCellColorCommand.js +3 -7
- package/dist/TableCellColorCommand.js.flow +3 -3
- package/dist/TableCellMenuPlugin.js +4 -6
- package/dist/TableCellMenuPlugin.js.flow +3 -3
- package/dist/TableInsertCommand.js +3 -5
- package/dist/TableInsertCommand.js.flow +2 -2
- package/dist/TableResizePlugin.js +2 -2
- package/dist/TextInsertTabSpaceCommand.js +2 -4
- package/dist/TextInsertTabSpaceCommand.js.flow +1 -1
- package/dist/Types.js +1 -1
- package/dist/bom.xml +4970 -4167
- package/dist/client/CollabConnector.js +17 -2
- package/dist/client/CollabConnector.js.flow +17 -2
- package/dist/client/EditorConnection.js +15 -4
- package/dist/client/EditorConnection.js.flow +14 -3
- package/dist/client/Licit.js +73 -58
- package/dist/client/Licit.js.flow +101 -85
- package/dist/client/Licit.test.js +18 -17
- package/dist/client/Licit.test.js.flow +13 -11
- package/dist/client/SimpleConnector.js +4 -2
- package/dist/client/SimpleConnector.js.flow +3 -1
- package/dist/client/http.js +3 -3
- package/dist/convertToCSSPTValue.js +1 -1
- package/dist/createEmptyEditorState.js +1 -1
- package/dist/index.js +16 -16
- package/dist/joinListNode.js +2 -2
- package/dist/joinListNode.js.flow +1 -1
- package/dist/keymaps.js +2 -2
- package/dist/patchStyleElements.js +3 -3
- package/dist/patchStyleElements.js.flow +1 -1
- package/dist/splitListItem.js +2 -2
- package/dist/styles.css +2 -2
- package/dist/styles0.css +3 -3
- package/dist/toggleBlockquote.js +6 -14
- package/dist/toggleBlockquote.js.flow +4 -4
- package/dist/toggleCodeBlock.js +4 -10
- package/dist/toggleCodeBlock.js.flow +3 -3
- package/dist/ui/AlertInfo.js +2 -2
- package/dist/ui/CommandButton.js +2 -4
- package/dist/ui/CommandButton.js.flow +1 -1
- package/dist/ui/CommandMenuButton.js +5 -7
- package/dist/ui/CommandMenuButton.js.flow +2 -2
- package/dist/ui/CustomMenuItem.js +3 -5
- package/dist/ui/CustomMenuItem.js.flow +1 -1
- package/dist/ui/CustomNodeView.js +3 -3
- package/dist/ui/CustomRadioButton.js +8 -6
- package/dist/ui/CustomRadioButton.js.flow +3 -3
- package/dist/ui/DocLayoutEditor.js +5 -7
- package/dist/ui/DocLayoutEditor.js.flow +2 -2
- package/dist/ui/Editor.js +1 -2
- package/dist/ui/Editor.js.flow +1 -2
- package/dist/ui/EditorFrameset.js +1 -1
- package/dist/ui/EditorToolbar.js +4 -4
- package/dist/ui/EditorToolbar.js.flow +1 -1
- package/dist/ui/EditorToolbarConfig.js +1 -1
- package/dist/ui/FontSizeCommandMenuButton.js +3 -3
- package/dist/ui/FontSizeCommandMenuButton.js.flow +1 -1
- package/dist/ui/FontTypeCommandMenuButton.js +3 -3
- package/dist/ui/FontTypeCommandMenuButton.js.flow +1 -1
- package/dist/ui/ImageAlignEditor.js +5 -5
- package/dist/ui/ImageAlignEditor.js.flow +1 -1
- package/dist/ui/ImageInlineEditor.js +5 -5
- package/dist/ui/ImageInlineEditor.js.flow +1 -1
- package/dist/ui/ImageNodeView.js +5 -7
- package/dist/ui/ImageNodeView.js.flow +2 -2
- package/dist/ui/ImageResizeBox.js +4 -4
- package/dist/ui/ImageResizeBox.js.flow +1 -1
- package/dist/ui/ImageURLEditor.js +6 -8
- package/dist/ui/ImageURLEditor.js.flow +2 -2
- package/dist/ui/ImageUploadEditor.js +3 -5
- package/dist/ui/ImageUploadEditor.js.flow +2 -2
- package/dist/ui/LinkTooltip.js +4 -4
- package/dist/ui/LinkTooltip.js.flow +1 -1
- package/dist/ui/LinkURLEditor.js +4 -6
- package/dist/ui/LinkURLEditor.js.flow +2 -2
- package/dist/ui/ListTypeButton.js +5 -7
- package/dist/ui/ListTypeButton.js.flow +2 -2
- package/dist/ui/MathEditor.js +4 -6
- package/dist/ui/MathEditor.js.flow +2 -2
- package/dist/ui/MathInlineEditor.js +7 -9
- package/dist/ui/MathInlineEditor.js.flow +2 -2
- package/dist/ui/MathNodeView.js +5 -7
- package/dist/ui/MathNodeView.js.flow +2 -2
- package/dist/ui/ResizeObserver.js +1 -1
- package/dist/ui/TableGridSizeEditor.js +7 -9
- package/dist/ui/TableGridSizeEditor.js.flow +2 -2
- package/dist/ui/czi-link-tooltip.css +1 -1
- package/dist/ui/czi-vars.css +1 -45
- package/dist/ui/findActiveFontType.js +1 -1
- package/dist/ui/htmlElementToRect.js +1 -1
- package/dist/ui/isElementFullyVisible.js +2 -2
- package/dist/ui/isElementFullyVisible.js.flow +1 -1
- package/dist/ui/mathquill-editor/MathQuillEditorSymbols.js +1 -1
- package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +2 -2
- package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js.flow +1 -1
- package/dist/ui/resolveImage.js +3 -3
- package/dist/ui/toCSSColor.js +1 -1
- package/dist/ui/toCSSLineSpacing.js +1 -36
- package/dist/ui/toCSSLineSpacing.js.flow +0 -27
- package/flow-typed/@modusoperandilicit-ui-commands.js +5 -0
- package/jest.config.js +207 -0
- package/lint.sh +0 -0
- package/node_modules/prosemirror-utils/LICENSE +13 -0
- package/{dist/ui/PopUpTypes.js.flow → node_modules/prosemirror-utils/README.md} +0 -0
- package/node_modules/prosemirror-utils/dist/helpers.js +119 -0
- package/node_modules/prosemirror-utils/dist/index.js +17 -0
- package/node_modules/prosemirror-utils/dist/index.js.map +1 -0
- package/node_modules/prosemirror-utils/dist/node.js +106 -0
- package/node_modules/prosemirror-utils/dist/selection.js +168 -0
- package/node_modules/prosemirror-utils/dist/transforms.js +257 -0
- package/node_modules/prosemirror-utils/package.json +81 -0
- package/node_modules/prosemirror-utils/typings.d.ts +79 -0
- package/package.json +14 -8
- package/scripts/build_bin.py +0 -0
- package/scripts/ci_check_dist.sh +0 -0
- package/src/CodeBlockCommand.js +1 -1
- package/src/DocLayoutCommand.js +1 -1
- package/src/EditorCommands.js +7 -7
- package/src/ImageSourceCommand.js +1 -1
- package/src/LinkSetURLCommand.js +3 -3
- package/src/LinkTooltipPlugin.js +5 -5
- package/src/ListToggleCommand.js +3 -3
- package/src/MarksClearCommand.js +1 -1
- package/src/MathEditCommand.js +1 -1
- package/src/ParagraphNodeSpec.js +2 -6
- package/src/TableBackgroundColorCommand.js +3 -3
- package/src/TableBorderColorCommand.js +3 -3
- package/src/TableCellColorCommand.js +3 -3
- package/src/TableCellMenuPlugin.js +3 -3
- package/src/TableInsertCommand.js +2 -2
- package/src/TextInsertTabSpaceCommand.js +1 -1
- package/src/client/CollabConnector.js +17 -2
- package/src/client/EditorConnection.js +14 -3
- package/src/client/Licit.js +101 -85
- package/src/client/Licit.test.js +13 -11
- package/src/client/SimpleConnector.js +3 -1
- package/src/joinListNode.js +1 -1
- package/src/patchStyleElements.js +1 -1
- package/src/styles.css +2 -2
- package/src/styles0.css +3 -3
- package/src/toggleBlockquote.js +4 -4
- package/src/toggleCodeBlock.js +3 -3
- package/src/ui/CommandButton.js +1 -1
- package/src/ui/CommandMenuButton.js +2 -2
- package/src/ui/CustomMenuItem.js +1 -1
- package/src/ui/CustomRadioButton.js +3 -3
- package/src/ui/DocLayoutEditor.js +2 -2
- package/src/ui/Editor.js +1 -2
- package/src/ui/EditorToolbar.js +1 -1
- package/src/ui/FontSizeCommandMenuButton.js +1 -1
- package/src/ui/FontTypeCommandMenuButton.js +1 -1
- package/src/ui/ImageAlignEditor.js +1 -1
- package/src/ui/ImageInlineEditor.js +1 -1
- package/src/ui/ImageNodeView.js +2 -2
- package/src/ui/ImageResizeBox.js +1 -1
- package/src/ui/ImageURLEditor.js +2 -2
- package/src/ui/ImageUploadEditor.js +2 -2
- package/src/ui/LinkTooltip.js +1 -1
- package/src/ui/LinkURLEditor.js +2 -2
- package/src/ui/ListTypeButton.js +2 -2
- package/src/ui/MathEditor.js +2 -2
- package/src/ui/MathInlineEditor.js +2 -2
- package/src/ui/MathNodeView.js +2 -2
- package/src/ui/TableGridSizeEditor.js +2 -2
- package/src/ui/czi-link-tooltip.css +1 -1
- package/src/ui/czi-vars.css +1 -45
- package/src/ui/isElementFullyVisible.js +1 -1
- package/src/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +1 -1
- package/src/ui/toCSSLineSpacing.js +0 -27
- package/build_customstyle_server.py +0 -7
- package/dist/FontSizeCommand.js +0 -80
- package/dist/FontSizeCommand.js.flow +0 -57
- package/dist/FontTypeCommand.js +0 -137
- package/dist/FontTypeCommand.js.flow +0 -100
- package/dist/HeadingCommand.js +0 -65
- package/dist/HeadingCommand.js.flow +0 -51
- package/dist/IndentCommand.js +0 -57
- package/dist/IndentCommand.js.flow +0 -41
- package/dist/MarkToggleCommand.js +0 -90
- package/dist/MarkToggleCommand.js.flow +0 -66
- package/dist/TextAlignCommand.js +0 -151
- package/dist/TextAlignCommand.js.flow +0 -122
- package/dist/TextColorCommand.js +0 -114
- package/dist/TextColorCommand.js.flow +0 -87
- package/dist/TextHighlightCommand.js +0 -118
- package/dist/TextHighlightCommand.js.flow +0 -91
- package/dist/TextLineSpacingCommand.js +0 -177
- package/dist/TextLineSpacingCommand.js.flow +0 -157
- package/dist/applyMark.js +0 -84
- package/dist/applyMark.js.flow +0 -61
- package/dist/clearMarks.js +0 -160
- package/dist/clearMarks.js.flow +0 -128
- package/dist/compareNumber.js +0 -18
- package/dist/compareNumber.js.flow +0 -11
- package/dist/consolidateListNodes.js +0 -291
- package/dist/consolidateListNodes.js.flow +0 -281
- package/dist/coverage/lcov-report/block-navigation.js +0 -77
- package/dist/coverage/lcov-report/block-navigation.js.flow +0 -79
- package/dist/coverage/lcov-report/prettify.js +0 -994
- package/dist/coverage/lcov-report/prettify.js.flow +0 -2
- package/dist/coverage/lcov-report/sorter.js +0 -187
- package/dist/coverage/lcov-report/sorter.js.flow +0 -170
- package/dist/findNodesWithSameMark.js +0 -89
- package/dist/findNodesWithSameMark.js.flow +0 -89
- package/dist/isBulletListNode.js +0 -14
- package/dist/isBulletListNode.js.flow +0 -9
- package/dist/isInsideListItem.js +0 -19
- package/dist/isInsideListItem.js.flow +0 -13
- package/dist/isListNode.js +0 -22
- package/dist/isListNode.js.flow +0 -13
- package/dist/isNodeSelectionForNodeType.js +0 -19
- package/dist/isNodeSelectionForNodeType.js.flow +0 -15
- package/dist/isOrderedListNode.js +0 -14
- package/dist/isOrderedListNode.js.flow +0 -9
- package/dist/isTextStyleMarkCommandEnabled.js +0 -59
- package/dist/isTextStyleMarkCommandEnabled.js.flow +0 -49
- package/dist/noop.js +0 -11
- package/dist/noop.js.flow +0 -5
- package/dist/toggleHeading.js +0 -135
- package/dist/toggleHeading.js.flow +0 -113
- package/dist/toggleList.js +0 -431
- package/dist/toggleList.js.flow +0 -450
- package/dist/transformAndPreserveTextSelection.js +0 -173
- package/dist/transformAndPreserveTextSelection.js.flow +0 -151
- package/dist/ui/ColorEditor.js +0 -118
- package/dist/ui/ColorEditor.js.flow +0 -101
- package/dist/ui/CustomButton.js +0 -62
- package/dist/ui/CustomButton.js.flow +0 -33
- package/dist/ui/PointerSurface.js +0 -173
- package/dist/ui/PointerSurface.js.flow +0 -141
- package/dist/ui/PopUp.js +0 -129
- package/dist/ui/PopUp.js.flow +0 -77
- package/dist/ui/PopUpManager.js +0 -266
- package/dist/ui/PopUpManager.js.flow +0 -213
- package/dist/ui/PopUpPosition.js +0 -156
- package/dist/ui/PopUpPosition.js.flow +0 -104
- package/dist/ui/PopUpTypes.js +0 -1
- package/dist/ui/TooltipSurface.js +0 -99
- package/dist/ui/TooltipSurface.js.flow +0 -76
- package/dist/ui/clamp.js +0 -18
- package/dist/ui/clamp.js.flow +0 -11
- package/dist/ui/createPopUp.js +0 -199
- package/dist/ui/createPopUp.js.flow +0 -205
- package/dist/ui/czi-animations.css +0 -15
- package/dist/ui/czi-color-editor.css +0 -56
- package/dist/ui/czi-custom-button.css +0 -93
- package/dist/ui/czi-pop-up.css +0 -32
- package/dist/ui/czi-tooltip-surface.css +0 -45
- package/dist/ui/preventEventDefault.js +0 -10
- package/dist/ui/preventEventDefault.js.flow +0 -5
- package/dist/ui/rects.js +0 -58
- package/dist/ui/rects.js.flow +0 -47
- package/dist/updateIndentLevel.js +0 -232
- package/dist/updateIndentLevel.js.flow +0 -211
- package/flow-typed/@molicit-citation.js +0 -5
- package/licit/server/customstyles/start.js +0 -184
- package/run_customstyle_server.py +0 -20
- package/src/FontSizeCommand.js +0 -57
- package/src/FontTypeCommand.js +0 -100
- package/src/HeadingCommand.js +0 -51
- package/src/IndentCommand.js +0 -41
- package/src/MarkToggleCommand.js +0 -66
- package/src/TextAlignCommand.js +0 -122
- package/src/TextColorCommand.js +0 -87
- package/src/TextHighlightCommand.js +0 -91
- package/src/TextLineSpacingCommand.js +0 -157
- package/src/applyMark.js +0 -61
- package/src/clearMarks.js +0 -128
- package/src/compareNumber.js +0 -11
- package/src/consolidateListNodes.js +0 -281
- package/src/findNodesWithSameMark.js +0 -89
- package/src/isBulletListNode.js +0 -9
- package/src/isInsideListItem.js +0 -13
- package/src/isListNode.js +0 -13
- package/src/isNodeSelectionForNodeType.js +0 -15
- package/src/isOrderedListNode.js +0 -9
- package/src/isTextStyleMarkCommandEnabled.js +0 -49
- package/src/noop.js +0 -5
- package/src/toggleHeading.js +0 -113
- package/src/toggleList.js +0 -450
- package/src/transformAndPreserveTextSelection.js +0 -151
- package/src/ui/ColorEditor.js +0 -101
- package/src/ui/CustomButton.js +0 -33
- package/src/ui/PointerSurface.js +0 -141
- package/src/ui/PopUp.js +0 -77
- package/src/ui/PopUpManager.js +0 -213
- package/src/ui/PopUpPosition.js +0 -104
- package/src/ui/PopUpTypes.js +0 -0
- package/src/ui/TooltipSurface.js +0 -76
- package/src/ui/clamp.js +0 -11
- package/src/ui/createPopUp.js +0 -205
- package/src/ui/czi-animations.css +0 -15
- package/src/ui/czi-color-editor.css +0 -56
- package/src/ui/czi-custom-button.css +0 -93
- package/src/ui/czi-pop-up.css +0 -32
- package/src/ui/czi-tooltip-surface.css +0 -45
- package/src/ui/preventEventDefault.js +0 -5
- package/src/ui/rects.js +0 -47
- package/src/updateIndentLevel.js +0 -211
- package/utils/build_customstyle_server.js +0 -72
package/src/ui/CustomButton.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import './czi-custom-button.css';
|
|
4
|
-
import PointerSurface from './PointerSurface';
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
import TooltipSurface from './TooltipSurface';
|
|
7
|
-
import cx from 'classnames';
|
|
8
|
-
|
|
9
|
-
import type { PointerSurfaceProps } from './PointerSurface';
|
|
10
|
-
|
|
11
|
-
class CustomButton extends React.PureComponent<any, any> {
|
|
12
|
-
props: PointerSurfaceProps & {
|
|
13
|
-
icon?: string | React.Element<any> | null,
|
|
14
|
-
label?: string | React.Element<any> | null,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
render(): React.Element<any> {
|
|
18
|
-
const { icon, label, className, title, ...pointerProps } = this.props;
|
|
19
|
-
const klass = cx(className, 'czi-custom-button', {
|
|
20
|
-
'use-icon': !!icon,
|
|
21
|
-
});
|
|
22
|
-
return (
|
|
23
|
-
<TooltipSurface tooltip={title}>
|
|
24
|
-
<PointerSurface {...pointerProps} className={klass}>
|
|
25
|
-
{icon}
|
|
26
|
-
{label}
|
|
27
|
-
</PointerSurface>
|
|
28
|
-
</TooltipSurface>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default CustomButton;
|
package/src/ui/PointerSurface.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
|
|
6
|
-
import preventEventDefault from './preventEventDefault';
|
|
7
|
-
|
|
8
|
-
export type PointerSurfaceProps = {
|
|
9
|
-
active?: ?boolean,
|
|
10
|
-
children?: any,
|
|
11
|
-
className?: ?string,
|
|
12
|
-
disabled?: ?boolean,
|
|
13
|
-
id?: ?string,
|
|
14
|
-
onClick?: ?(val: any, e: SyntheticEvent<>) => void,
|
|
15
|
-
onMouseEnter?: ?(val: any, e: SyntheticEvent<>) => void,
|
|
16
|
-
style?: ?Object,
|
|
17
|
-
title?: ?string,
|
|
18
|
-
value?: any,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
class PointerSurface extends React.PureComponent<any, any> {
|
|
22
|
-
props: PointerSurfaceProps;
|
|
23
|
-
|
|
24
|
-
_clicked = false;
|
|
25
|
-
_mul = false;
|
|
26
|
-
_pressedTarget = null;
|
|
27
|
-
_unmounted = false;
|
|
28
|
-
|
|
29
|
-
state = { pressed: false };
|
|
30
|
-
|
|
31
|
-
render(): React.Element<any> {
|
|
32
|
-
const {
|
|
33
|
-
className,
|
|
34
|
-
disabled,
|
|
35
|
-
active,
|
|
36
|
-
id,
|
|
37
|
-
style,
|
|
38
|
-
title,
|
|
39
|
-
children,
|
|
40
|
-
} = this.props;
|
|
41
|
-
const { pressed } = this.state;
|
|
42
|
-
|
|
43
|
-
const buttonClassName = cx(className, {
|
|
44
|
-
active: active,
|
|
45
|
-
disabled: disabled,
|
|
46
|
-
pressed: pressed,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<span
|
|
51
|
-
aria-disabled={disabled}
|
|
52
|
-
aria-pressed={pressed}
|
|
53
|
-
className={buttonClassName}
|
|
54
|
-
disabled={disabled}
|
|
55
|
-
id={id}
|
|
56
|
-
onKeyPress={disabled ? preventEventDefault : this._onMouseUp}
|
|
57
|
-
onMouseDown={disabled ? preventEventDefault : this._onMouseDown}
|
|
58
|
-
onMouseEnter={disabled ? preventEventDefault : this._onMouseEnter}
|
|
59
|
-
onMouseLeave={disabled ? null : this._onMouseLeave}
|
|
60
|
-
onMouseUp={disabled ? preventEventDefault : this._onMouseUp}
|
|
61
|
-
role="button"
|
|
62
|
-
style={style}
|
|
63
|
-
tabIndex={disabled ? null : 0}
|
|
64
|
-
title={title}
|
|
65
|
-
>
|
|
66
|
-
{children}
|
|
67
|
-
</span>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
componentWillUnmount(): void {
|
|
72
|
-
this._unmounted = true;
|
|
73
|
-
if (this._mul) {
|
|
74
|
-
this._mul = false;
|
|
75
|
-
document.removeEventListener('mouseup', this._onMouseUpCapture, true);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
_onMouseEnter = (e: SyntheticEvent<*>): void => {
|
|
80
|
-
this._pressedTarget = null;
|
|
81
|
-
e.preventDefault();
|
|
82
|
-
const { onMouseEnter, value } = this.props;
|
|
83
|
-
onMouseEnter && onMouseEnter(value, e);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
_onMouseLeave = (e: SyntheticEvent<*>): void => {
|
|
87
|
-
this._pressedTarget = null;
|
|
88
|
-
const mouseUpEvent: any = e;
|
|
89
|
-
this._onMouseUpCapture(mouseUpEvent);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
_onMouseDown = (e: any): void => {
|
|
93
|
-
e.preventDefault();
|
|
94
|
-
|
|
95
|
-
this._pressedTarget = null;
|
|
96
|
-
this._clicked = false;
|
|
97
|
-
|
|
98
|
-
if (e.which === 3 || e.button == 2) {
|
|
99
|
-
// right click.
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
this.setState({ pressed: true });
|
|
104
|
-
this._pressedTarget = e.currentTarget;
|
|
105
|
-
this._clicked = false;
|
|
106
|
-
|
|
107
|
-
if (!this._mul) {
|
|
108
|
-
document.addEventListener('mouseup', this._onMouseUpCapture, true);
|
|
109
|
-
this._mul = true;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
_onMouseUp = (e: SyntheticEvent<*>): void => {
|
|
114
|
-
e.preventDefault();
|
|
115
|
-
|
|
116
|
-
if (this._clicked || e.type === 'keypress') {
|
|
117
|
-
const { onClick, value, disabled } = this.props;
|
|
118
|
-
!disabled && onClick && onClick(value, e);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
this._pressedTarget = null;
|
|
122
|
-
this._clicked = false;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
_onMouseUpCapture = (e: MouseEvent): void => {
|
|
126
|
-
if (this._mul) {
|
|
127
|
-
this._mul = false;
|
|
128
|
-
document.removeEventListener('mouseup', this._onMouseUpCapture, true);
|
|
129
|
-
}
|
|
130
|
-
const target = e.target;
|
|
131
|
-
this._clicked =
|
|
132
|
-
this._pressedTarget instanceof HTMLElement &&
|
|
133
|
-
target instanceof HTMLElement &&
|
|
134
|
-
(target === this._pressedTarget ||
|
|
135
|
-
target.contains(this._pressedTarget) ||
|
|
136
|
-
this._pressedTarget.contains(target));
|
|
137
|
-
this.setState({ pressed: false });
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export default PointerSurface;
|
package/src/ui/PopUp.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
|
|
5
|
-
import PopUpManager from './PopUpManager';
|
|
6
|
-
import { atAnchorBottomLeft, atViewportCenter } from './PopUpPosition';
|
|
7
|
-
import uuid from './uuid';
|
|
8
|
-
|
|
9
|
-
import type { PopUpDetails } from './PopUpManager';
|
|
10
|
-
import type { Rect } from './rects';
|
|
11
|
-
|
|
12
|
-
type PositionHandler = (anchorRect: ?Rect, bodyRect: ?Rect) => Rect;
|
|
13
|
-
|
|
14
|
-
export type ViewProps = Object;
|
|
15
|
-
|
|
16
|
-
export type PopUpParams = {
|
|
17
|
-
anchor?: any,
|
|
18
|
-
autoDismiss?: ?boolean,
|
|
19
|
-
container?: ?Element,
|
|
20
|
-
modal?: ?boolean,
|
|
21
|
-
onClose?: ?(val: any) => void,
|
|
22
|
-
position?: ?PositionHandler,
|
|
23
|
-
IsChildDialog?: boolean,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type PopUpProps = {
|
|
27
|
-
View: Function,
|
|
28
|
-
close: Function,
|
|
29
|
-
popUpParams: PopUpParams,
|
|
30
|
-
viewProps: Object,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type PopUpHandle = {
|
|
34
|
-
close: (val: any) => void,
|
|
35
|
-
update: (props: Object) => void,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
class PopUp extends React.PureComponent<any, any> {
|
|
39
|
-
props: PopUpProps;
|
|
40
|
-
|
|
41
|
-
_bridge = null;
|
|
42
|
-
_id = uuid();
|
|
43
|
-
|
|
44
|
-
render(): React.Element<any> {
|
|
45
|
-
const dummy = {};
|
|
46
|
-
const { View, viewProps, close } = this.props;
|
|
47
|
-
return (
|
|
48
|
-
<div data-pop-up-id={this._id} id={this._id}>
|
|
49
|
-
<View {...(viewProps || dummy)} close={close} />
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
componentDidMount(): void {
|
|
55
|
-
this._bridge = { getDetails: this._getDetails };
|
|
56
|
-
PopUpManager.register(this._bridge);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
componentWillUnmount(): void {
|
|
60
|
-
this._bridge && PopUpManager.unregister(this._bridge);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
_getDetails = (): PopUpDetails => {
|
|
64
|
-
const { close, popUpParams } = this.props;
|
|
65
|
-
const { anchor, autoDismiss, position, modal } = popUpParams;
|
|
66
|
-
return {
|
|
67
|
-
anchor,
|
|
68
|
-
autoDismiss: autoDismiss === false ? false : true,
|
|
69
|
-
body: document.getElementById(this._id),
|
|
70
|
-
close,
|
|
71
|
-
modal: modal === true,
|
|
72
|
-
position: position || (modal ? atViewportCenter : atAnchorBottomLeft),
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export default PopUp;
|
package/src/ui/PopUpManager.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import clamp from './clamp';
|
|
4
|
-
import { fromHTMlElement, fromXY, isIntersected } from './rects';
|
|
5
|
-
|
|
6
|
-
import type { PositionHandler } from './PopUpPosition';
|
|
7
|
-
import type { Rect } from './rects';
|
|
8
|
-
|
|
9
|
-
export type PopUpDetails = {
|
|
10
|
-
anchor: ?HTMLElement,
|
|
11
|
-
anchorRect?: ?Rect,
|
|
12
|
-
autoDismiss: boolean,
|
|
13
|
-
body: ?HTMLElement,
|
|
14
|
-
bodyRect?: ?Rect,
|
|
15
|
-
close: (val: any) => void,
|
|
16
|
-
modal: boolean,
|
|
17
|
-
position: PositionHandler,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type PopUpBridge = {
|
|
21
|
-
getDetails: () => PopUpDetails,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const CLICK_INTERVAL = 350;
|
|
25
|
-
const DUMMY_RECT = { x: -10000, y: -10000, w: 0, h: 0 };
|
|
26
|
-
|
|
27
|
-
class PopUpManager {
|
|
28
|
-
_bridges = new Map<any, any>();
|
|
29
|
-
_positions = new Map<any, any>();
|
|
30
|
-
|
|
31
|
-
_mx = 0;
|
|
32
|
-
_my = 0;
|
|
33
|
-
_rafID = 0;
|
|
34
|
-
|
|
35
|
-
register(bridge: PopUpBridge): void {
|
|
36
|
-
this._bridges.set(bridge, Date.now());
|
|
37
|
-
this._positions.set(bridge, null);
|
|
38
|
-
if (this._bridges.size === 1) {
|
|
39
|
-
this._observe();
|
|
40
|
-
}
|
|
41
|
-
this._rafID = requestAnimationFrame(this._syncPosition);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
unregister(bridge: PopUpBridge): void {
|
|
45
|
-
this._bridges.delete(bridge);
|
|
46
|
-
this._positions.delete(bridge);
|
|
47
|
-
if (this._bridges.size === 0) {
|
|
48
|
-
this._unobserve();
|
|
49
|
-
}
|
|
50
|
-
this._rafID && cancelAnimationFrame(this._rafID);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
_observe(): void {
|
|
54
|
-
document.addEventListener('mousemove', this._onMouseChange, false);
|
|
55
|
-
document.addEventListener('mouseup', this._onMouseChange, false);
|
|
56
|
-
document.addEventListener('click', this._onClick, false);
|
|
57
|
-
window.addEventListener('scroll', this._onScroll, true);
|
|
58
|
-
window.addEventListener('resize', this._onResize, true);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
_unobserve(): void {
|
|
62
|
-
document.removeEventListener('mousemove', this._onMouseChange, false);
|
|
63
|
-
document.removeEventListener('mouseup', this._onMouseChange, false);
|
|
64
|
-
document.removeEventListener('click', this._onClick, false);
|
|
65
|
-
window.removeEventListener('scroll', this._onScroll, true);
|
|
66
|
-
window.removeEventListener('resize', this._onResize, true);
|
|
67
|
-
this._rafID && cancelAnimationFrame(this._rafID);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
_onScroll = (e: Event): void => {
|
|
71
|
-
this._rafID && cancelAnimationFrame(this._rafID);
|
|
72
|
-
this._rafID = requestAnimationFrame(this._syncPosition);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
_onResize = (e: Event): void => {
|
|
76
|
-
this._rafID && cancelAnimationFrame(this._rafID);
|
|
77
|
-
this._rafID = requestAnimationFrame(this._syncPosition);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
_onMouseChange = (e: MouseEvent): void => {
|
|
81
|
-
this._mx = Math.round(e.clientX);
|
|
82
|
-
this._my = Math.round(e.clientY);
|
|
83
|
-
this._rafID && cancelAnimationFrame(this._rafID);
|
|
84
|
-
this._rafID = requestAnimationFrame(this._syncPosition);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
_onClick = (e: MouseEvent): void => {
|
|
88
|
-
const now = Date.now();
|
|
89
|
-
let detailsWithModalToDismiss;
|
|
90
|
-
for (const [bridge, registeredAt] of this._bridges) {
|
|
91
|
-
if (now - registeredAt > CLICK_INTERVAL) {
|
|
92
|
-
const details = bridge.getDetails();
|
|
93
|
-
if (details.modal && details.autoDismiss) {
|
|
94
|
-
detailsWithModalToDismiss = details;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (!detailsWithModalToDismiss) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const { body, close } = detailsWithModalToDismiss;
|
|
102
|
-
const pointer = fromXY(e.clientX, e.clientY, 1);
|
|
103
|
-
const bodyRect = body ? fromHTMlElement(body) : null;
|
|
104
|
-
if (!bodyRect || !isIntersected(pointer, bodyRect)) {
|
|
105
|
-
close();
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
_syncPosition = (): void => {
|
|
110
|
-
this._rafID = 0;
|
|
111
|
-
|
|
112
|
-
const bridgeToDetails = new Map<any, any>();
|
|
113
|
-
for (const [
|
|
114
|
-
bridge,
|
|
115
|
-
// eslint-disable-next-line no-unused-vars
|
|
116
|
-
registeredAt,
|
|
117
|
-
] of this._bridges) {
|
|
118
|
-
const details = bridge.getDetails();
|
|
119
|
-
bridgeToDetails.set(bridge, details);
|
|
120
|
-
const { anchor, body } = details;
|
|
121
|
-
if (body instanceof HTMLElement) {
|
|
122
|
-
details.bodyRect = fromHTMlElement(body);
|
|
123
|
-
}
|
|
124
|
-
if (anchor instanceof HTMLElement) {
|
|
125
|
-
details.anchorRect = fromHTMlElement(anchor);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const pointer = fromXY(this._mx, this._my, 2);
|
|
130
|
-
const hoveredAnchors = new Set();
|
|
131
|
-
for (const [bridge, details] of bridgeToDetails) {
|
|
132
|
-
const { anchor, bodyRect, anchorRect, position, body } = details;
|
|
133
|
-
if (!bodyRect && !anchorRect) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const { x, y } = position(anchorRect, bodyRect);
|
|
138
|
-
const positionKey = `${x}-${y}`;
|
|
139
|
-
|
|
140
|
-
if (body && bodyRect && this._positions.get(bridge) !== positionKey) {
|
|
141
|
-
const ax = anchorRect
|
|
142
|
-
? clamp(
|
|
143
|
-
0,
|
|
144
|
-
anchorRect.x - x + anchorRect.w / 2,
|
|
145
|
-
bodyRect.w - anchorRect.w / 2
|
|
146
|
-
)
|
|
147
|
-
: 0;
|
|
148
|
-
this._positions.set(bridge, positionKey);
|
|
149
|
-
const bodyStyle = body.style;
|
|
150
|
-
bodyStyle.position = 'absolute';
|
|
151
|
-
bodyStyle.left = `${x}px`;
|
|
152
|
-
bodyStyle.top = `${y}px`;
|
|
153
|
-
bodyStyle.setProperty('--czi-pop-up-anchor-offset-left', `${ax}px`);
|
|
154
|
-
bodyRect.x = x;
|
|
155
|
-
bodyRect.y = y;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (
|
|
159
|
-
isIntersected(pointer, bodyRect || DUMMY_RECT, 0) ||
|
|
160
|
-
isIntersected(pointer, anchorRect || DUMMY_RECT, 0)
|
|
161
|
-
) {
|
|
162
|
-
if (anchor) {
|
|
163
|
-
hoveredAnchors.add(anchor);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
while (true) {
|
|
169
|
-
const size = hoveredAnchors.size;
|
|
170
|
-
for (const [
|
|
171
|
-
// eslint-disable-next-line no-unused-vars
|
|
172
|
-
bridge,
|
|
173
|
-
details,
|
|
174
|
-
] of bridgeToDetails) {
|
|
175
|
-
const { anchor, body } = details;
|
|
176
|
-
for (const ha of hoveredAnchors) {
|
|
177
|
-
if (
|
|
178
|
-
anchor &&
|
|
179
|
-
body &&
|
|
180
|
-
!hoveredAnchors.has(anchor) &&
|
|
181
|
-
body.contains(ha)
|
|
182
|
-
) {
|
|
183
|
-
hoveredAnchors.add(anchor);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (hoveredAnchors.size === size) {
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const now = Date.now();
|
|
193
|
-
for (const [bridge, registeredAt] of this._bridges) {
|
|
194
|
-
const details = bridgeToDetails.get(bridge);
|
|
195
|
-
if (details) {
|
|
196
|
-
const { autoDismiss, anchor, close, modal } = details;
|
|
197
|
-
if (
|
|
198
|
-
autoDismiss &&
|
|
199
|
-
// Modal is handled separately at `onClick`
|
|
200
|
-
!modal &&
|
|
201
|
-
now - registeredAt > CLICK_INTERVAL &&
|
|
202
|
-
!hoveredAnchors.has(anchor)
|
|
203
|
-
) {
|
|
204
|
-
close();
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const instance = new PopUpManager();
|
|
212
|
-
|
|
213
|
-
export default instance;
|
package/src/ui/PopUpPosition.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import { isCollapsed } from './rects';
|
|
4
|
-
|
|
5
|
-
import type { Rect } from './rects';
|
|
6
|
-
|
|
7
|
-
export type PositionHandler = (anchorRect: ?Rect, bodyRect: ?Rect) => Rect;
|
|
8
|
-
|
|
9
|
-
export function atAnchorBottomLeft(anchorRect: ?Rect, bodyRect: ?Rect): Rect {
|
|
10
|
-
const rect = { x: 0, y: 0, w: 0, h: 0 };
|
|
11
|
-
if (anchorRect && bodyRect) {
|
|
12
|
-
rect.x = anchorRect.x;
|
|
13
|
-
rect.y = anchorRect.y + anchorRect.h;
|
|
14
|
-
|
|
15
|
-
const viewportWidth = window.innerWidth;
|
|
16
|
-
const viewportHeight = window.innerHeight;
|
|
17
|
-
if (rect.x + bodyRect.w > viewportWidth) {
|
|
18
|
-
rect.x = anchorRect.x - bodyRect.w + anchorRect.w;
|
|
19
|
-
}
|
|
20
|
-
if (rect.y + bodyRect.h > viewportHeight) {
|
|
21
|
-
rect.y = Math.max(anchorRect.y - bodyRect.h, 2);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!anchorRect || isCollapsed(anchorRect)) {
|
|
26
|
-
rect.x = -10000;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return rect;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function atAnchorBottomCenter(anchorRect: ?Rect, bodyRect: ?Rect): Rect {
|
|
33
|
-
const rect = { x: 0, y: 0, w: 0, h: 0 };
|
|
34
|
-
if (anchorRect && bodyRect) {
|
|
35
|
-
rect.x = Math.max(anchorRect.x - (bodyRect.w - anchorRect.w) / 2, 10);
|
|
36
|
-
rect.y = anchorRect.y + anchorRect.h;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!anchorRect || isCollapsed(anchorRect)) {
|
|
40
|
-
rect.x = -10000;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return rect;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function atAnchorRight(anchorRect: ?Rect, bodyRect: ?Rect): Rect {
|
|
47
|
-
const rect = { x: 0, y: 0, w: 0, h: 0 };
|
|
48
|
-
if (anchorRect && bodyRect) {
|
|
49
|
-
rect.x = anchorRect.x + anchorRect.w + 1;
|
|
50
|
-
rect.y = anchorRect.y;
|
|
51
|
-
const viewportWidth = window.innerWidth;
|
|
52
|
-
if (rect.x + bodyRect.w > viewportWidth) {
|
|
53
|
-
rect.x = Math.max(2, anchorRect.x - bodyRect.w);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!anchorRect || isCollapsed(anchorRect)) {
|
|
58
|
-
rect.x = -10000;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return rect;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function atViewportCenter(anchorRect: ?Rect, bodyRect: ?Rect): Rect {
|
|
65
|
-
const rect = { x: 0, y: 0, w: 0, h: 0 };
|
|
66
|
-
if (bodyRect) {
|
|
67
|
-
rect.x = (window.innerWidth - bodyRect.w) / 2;
|
|
68
|
-
rect.y = (window.innerHeight - bodyRect.h) / 2;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!bodyRect || isCollapsed(bodyRect)) {
|
|
72
|
-
rect.x = -10000;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return rect;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function atAnchorTopRight(anchorRect: ?Rect, bodyRect: ?Rect): Rect {
|
|
79
|
-
const rect = { x: 0, y: 0, w: 0, h: 0 };
|
|
80
|
-
if (anchorRect && bodyRect) {
|
|
81
|
-
rect.x = anchorRect.x + anchorRect.w + 1 - bodyRect.w;
|
|
82
|
-
rect.y = anchorRect.y;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!anchorRect || isCollapsed(anchorRect)) {
|
|
86
|
-
rect.x = -10000;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return rect;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function atAnchorTopCenter(anchorRect: ?Rect, bodyRect: ?Rect): Rect {
|
|
93
|
-
const rect = { x: 0, y: 0, w: 0, h: 0 };
|
|
94
|
-
if (anchorRect && bodyRect) {
|
|
95
|
-
rect.x = anchorRect.x + (anchorRect.w - bodyRect.w) / 2;
|
|
96
|
-
rect.y = anchorRect.y;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (!anchorRect || isCollapsed(anchorRect)) {
|
|
100
|
-
rect.x = -10000;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return rect;
|
|
104
|
-
}
|
package/src/ui/PopUpTypes.js
DELETED
|
File without changes
|
package/src/ui/TooltipSurface.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import './czi-tooltip-surface.css';
|
|
4
|
-
import './czi-animations.css';
|
|
5
|
-
|
|
6
|
-
import * as React from 'react';
|
|
7
|
-
import createPopUp from './createPopUp';
|
|
8
|
-
import { atAnchorBottomCenter } from './PopUpPosition';
|
|
9
|
-
import uuid from './uuid';
|
|
10
|
-
|
|
11
|
-
class TooltipView extends React.PureComponent<any, any> {
|
|
12
|
-
render(): React.Element<any> {
|
|
13
|
-
const { tooltip } = this.props;
|
|
14
|
-
return (
|
|
15
|
-
<div className="czi-tooltip-view czi-animation-fade-in">{tooltip}</div>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
class TooltipSurface extends React.PureComponent<any, any> {
|
|
21
|
-
_id = uuid();
|
|
22
|
-
_popUp = null;
|
|
23
|
-
|
|
24
|
-
props: {
|
|
25
|
-
tooltip: string,
|
|
26
|
-
children?: any,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
componentWillUnmount(): void {
|
|
30
|
-
this._popUp && this._popUp.close();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
render(): React.Element<any> {
|
|
34
|
-
const { tooltip, children } = this.props;
|
|
35
|
-
return (
|
|
36
|
-
<span
|
|
37
|
-
aria-label={tooltip}
|
|
38
|
-
className="czi-tooltip-surface"
|
|
39
|
-
data-tooltip={tooltip}
|
|
40
|
-
id={this._id}
|
|
41
|
-
onMouseDown={tooltip && this._onMouseLeave}
|
|
42
|
-
onMouseEnter={tooltip && this._onMouseEnter}
|
|
43
|
-
onMouseLeave={tooltip && this._onMouseLeave}
|
|
44
|
-
role="tooltip"
|
|
45
|
-
>
|
|
46
|
-
{children}
|
|
47
|
-
</span>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
_onMouseEnter = (): void => {
|
|
52
|
-
if (!this._popUp) {
|
|
53
|
-
const { tooltip } = this.props;
|
|
54
|
-
this._popUp = createPopUp(
|
|
55
|
-
TooltipView,
|
|
56
|
-
{ tooltip },
|
|
57
|
-
{
|
|
58
|
-
anchor: document.getElementById(this._id),
|
|
59
|
-
onClose: this._onClose,
|
|
60
|
-
position: atAnchorBottomCenter,
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
_onMouseLeave = (): void => {
|
|
67
|
-
this._popUp && this._popUp.close();
|
|
68
|
-
this._popUp = null;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
_onClose = (): void => {
|
|
72
|
-
this._popUp = null;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default TooltipSurface;
|