@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.
Files changed (340) hide show
  1. package/.github/workflows/build.yml +1 -7
  2. package/.github/workflows/lint.yml +1 -1
  3. package/README.md +1 -1
  4. package/babel.config.json +54 -0
  5. package/dist/BlockquoteNodeSpec.js +2 -2
  6. package/dist/CZIProseMirror.js +4 -4
  7. package/dist/CodeBlockCommand.js +2 -2
  8. package/dist/CodeBlockCommand.js.flow +1 -1
  9. package/dist/CursorPlaceholderPlugin.js +2 -2
  10. package/dist/DocLayoutCommand.js +2 -4
  11. package/dist/DocLayoutCommand.js.flow +1 -1
  12. package/dist/DocNodeSpec.js +1 -1
  13. package/dist/EditorCommands.js +23 -35
  14. package/dist/EditorCommands.js.flow +7 -7
  15. package/dist/EditorKeyMap.js +3 -3
  16. package/dist/FontTypeMarkSpec.js +1 -1
  17. package/dist/HeadingNodeSpec.js +2 -2
  18. package/dist/ImageSourceCommand.js +2 -4
  19. package/dist/ImageSourceCommand.js.flow +1 -1
  20. package/dist/ImageUploadPlaceholderPlugin.js +1 -1
  21. package/dist/LinkSetURLCommand.js +4 -8
  22. package/dist/LinkSetURLCommand.js.flow +3 -3
  23. package/dist/LinkTooltipPlugin.js +9 -15
  24. package/dist/LinkTooltipPlugin.js.flow +5 -5
  25. package/dist/ListToggleCommand.js +5 -11
  26. package/dist/ListToggleCommand.js.flow +3 -3
  27. package/dist/MarkNames.js +1 -1
  28. package/dist/MarksClearCommand.js +3 -3
  29. package/dist/MarksClearCommand.js.flow +1 -1
  30. package/dist/MathEditCommand.js +2 -2
  31. package/dist/MathEditCommand.js.flow +1 -1
  32. package/dist/ParagraphNodeSpec.js +3 -4
  33. package/dist/ParagraphNodeSpec.js.flow +2 -6
  34. package/dist/ParagraphSpacingCommand.js +3 -3
  35. package/dist/SelectionPlaceholderPlugin.js +2 -2
  36. package/dist/SpacerMarkSpec.js +1 -1
  37. package/dist/TableBackgroundColorCommand.js +3 -7
  38. package/dist/TableBackgroundColorCommand.js.flow +3 -3
  39. package/dist/TableBorderColorCommand.js +3 -7
  40. package/dist/TableBorderColorCommand.js.flow +3 -3
  41. package/dist/TableCellColorCommand.js +3 -7
  42. package/dist/TableCellColorCommand.js.flow +3 -3
  43. package/dist/TableCellMenuPlugin.js +4 -6
  44. package/dist/TableCellMenuPlugin.js.flow +3 -3
  45. package/dist/TableInsertCommand.js +3 -5
  46. package/dist/TableInsertCommand.js.flow +2 -2
  47. package/dist/TableResizePlugin.js +2 -2
  48. package/dist/TextInsertTabSpaceCommand.js +2 -4
  49. package/dist/TextInsertTabSpaceCommand.js.flow +1 -1
  50. package/dist/Types.js +1 -1
  51. package/dist/bom.xml +4970 -4167
  52. package/dist/client/CollabConnector.js +17 -2
  53. package/dist/client/CollabConnector.js.flow +17 -2
  54. package/dist/client/EditorConnection.js +15 -4
  55. package/dist/client/EditorConnection.js.flow +14 -3
  56. package/dist/client/Licit.js +73 -58
  57. package/dist/client/Licit.js.flow +101 -85
  58. package/dist/client/Licit.test.js +18 -17
  59. package/dist/client/Licit.test.js.flow +13 -11
  60. package/dist/client/SimpleConnector.js +4 -2
  61. package/dist/client/SimpleConnector.js.flow +3 -1
  62. package/dist/client/http.js +3 -3
  63. package/dist/convertToCSSPTValue.js +1 -1
  64. package/dist/createEmptyEditorState.js +1 -1
  65. package/dist/index.js +16 -16
  66. package/dist/joinListNode.js +2 -2
  67. package/dist/joinListNode.js.flow +1 -1
  68. package/dist/keymaps.js +2 -2
  69. package/dist/patchStyleElements.js +3 -3
  70. package/dist/patchStyleElements.js.flow +1 -1
  71. package/dist/splitListItem.js +2 -2
  72. package/dist/styles.css +2 -2
  73. package/dist/styles0.css +3 -3
  74. package/dist/toggleBlockquote.js +6 -14
  75. package/dist/toggleBlockquote.js.flow +4 -4
  76. package/dist/toggleCodeBlock.js +4 -10
  77. package/dist/toggleCodeBlock.js.flow +3 -3
  78. package/dist/ui/AlertInfo.js +2 -2
  79. package/dist/ui/CommandButton.js +2 -4
  80. package/dist/ui/CommandButton.js.flow +1 -1
  81. package/dist/ui/CommandMenuButton.js +5 -7
  82. package/dist/ui/CommandMenuButton.js.flow +2 -2
  83. package/dist/ui/CustomMenuItem.js +3 -5
  84. package/dist/ui/CustomMenuItem.js.flow +1 -1
  85. package/dist/ui/CustomNodeView.js +3 -3
  86. package/dist/ui/CustomRadioButton.js +8 -6
  87. package/dist/ui/CustomRadioButton.js.flow +3 -3
  88. package/dist/ui/DocLayoutEditor.js +5 -7
  89. package/dist/ui/DocLayoutEditor.js.flow +2 -2
  90. package/dist/ui/Editor.js +1 -2
  91. package/dist/ui/Editor.js.flow +1 -2
  92. package/dist/ui/EditorFrameset.js +1 -1
  93. package/dist/ui/EditorToolbar.js +4 -4
  94. package/dist/ui/EditorToolbar.js.flow +1 -1
  95. package/dist/ui/EditorToolbarConfig.js +1 -1
  96. package/dist/ui/FontSizeCommandMenuButton.js +3 -3
  97. package/dist/ui/FontSizeCommandMenuButton.js.flow +1 -1
  98. package/dist/ui/FontTypeCommandMenuButton.js +3 -3
  99. package/dist/ui/FontTypeCommandMenuButton.js.flow +1 -1
  100. package/dist/ui/ImageAlignEditor.js +5 -5
  101. package/dist/ui/ImageAlignEditor.js.flow +1 -1
  102. package/dist/ui/ImageInlineEditor.js +5 -5
  103. package/dist/ui/ImageInlineEditor.js.flow +1 -1
  104. package/dist/ui/ImageNodeView.js +5 -7
  105. package/dist/ui/ImageNodeView.js.flow +2 -2
  106. package/dist/ui/ImageResizeBox.js +4 -4
  107. package/dist/ui/ImageResizeBox.js.flow +1 -1
  108. package/dist/ui/ImageURLEditor.js +6 -8
  109. package/dist/ui/ImageURLEditor.js.flow +2 -2
  110. package/dist/ui/ImageUploadEditor.js +3 -5
  111. package/dist/ui/ImageUploadEditor.js.flow +2 -2
  112. package/dist/ui/LinkTooltip.js +4 -4
  113. package/dist/ui/LinkTooltip.js.flow +1 -1
  114. package/dist/ui/LinkURLEditor.js +4 -6
  115. package/dist/ui/LinkURLEditor.js.flow +2 -2
  116. package/dist/ui/ListTypeButton.js +5 -7
  117. package/dist/ui/ListTypeButton.js.flow +2 -2
  118. package/dist/ui/MathEditor.js +4 -6
  119. package/dist/ui/MathEditor.js.flow +2 -2
  120. package/dist/ui/MathInlineEditor.js +7 -9
  121. package/dist/ui/MathInlineEditor.js.flow +2 -2
  122. package/dist/ui/MathNodeView.js +5 -7
  123. package/dist/ui/MathNodeView.js.flow +2 -2
  124. package/dist/ui/ResizeObserver.js +1 -1
  125. package/dist/ui/TableGridSizeEditor.js +7 -9
  126. package/dist/ui/TableGridSizeEditor.js.flow +2 -2
  127. package/dist/ui/czi-link-tooltip.css +1 -1
  128. package/dist/ui/czi-vars.css +1 -45
  129. package/dist/ui/findActiveFontType.js +1 -1
  130. package/dist/ui/htmlElementToRect.js +1 -1
  131. package/dist/ui/isElementFullyVisible.js +2 -2
  132. package/dist/ui/isElementFullyVisible.js.flow +1 -1
  133. package/dist/ui/mathquill-editor/MathQuillEditorSymbols.js +1 -1
  134. package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +2 -2
  135. package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js.flow +1 -1
  136. package/dist/ui/resolveImage.js +3 -3
  137. package/dist/ui/toCSSColor.js +1 -1
  138. package/dist/ui/toCSSLineSpacing.js +1 -36
  139. package/dist/ui/toCSSLineSpacing.js.flow +0 -27
  140. package/flow-typed/@modusoperandilicit-ui-commands.js +5 -0
  141. package/jest.config.js +207 -0
  142. package/lint.sh +0 -0
  143. package/node_modules/prosemirror-utils/LICENSE +13 -0
  144. package/{dist/ui/PopUpTypes.js.flow → node_modules/prosemirror-utils/README.md} +0 -0
  145. package/node_modules/prosemirror-utils/dist/helpers.js +119 -0
  146. package/node_modules/prosemirror-utils/dist/index.js +17 -0
  147. package/node_modules/prosemirror-utils/dist/index.js.map +1 -0
  148. package/node_modules/prosemirror-utils/dist/node.js +106 -0
  149. package/node_modules/prosemirror-utils/dist/selection.js +168 -0
  150. package/node_modules/prosemirror-utils/dist/transforms.js +257 -0
  151. package/node_modules/prosemirror-utils/package.json +81 -0
  152. package/node_modules/prosemirror-utils/typings.d.ts +79 -0
  153. package/package.json +14 -8
  154. package/scripts/build_bin.py +0 -0
  155. package/scripts/ci_check_dist.sh +0 -0
  156. package/src/CodeBlockCommand.js +1 -1
  157. package/src/DocLayoutCommand.js +1 -1
  158. package/src/EditorCommands.js +7 -7
  159. package/src/ImageSourceCommand.js +1 -1
  160. package/src/LinkSetURLCommand.js +3 -3
  161. package/src/LinkTooltipPlugin.js +5 -5
  162. package/src/ListToggleCommand.js +3 -3
  163. package/src/MarksClearCommand.js +1 -1
  164. package/src/MathEditCommand.js +1 -1
  165. package/src/ParagraphNodeSpec.js +2 -6
  166. package/src/TableBackgroundColorCommand.js +3 -3
  167. package/src/TableBorderColorCommand.js +3 -3
  168. package/src/TableCellColorCommand.js +3 -3
  169. package/src/TableCellMenuPlugin.js +3 -3
  170. package/src/TableInsertCommand.js +2 -2
  171. package/src/TextInsertTabSpaceCommand.js +1 -1
  172. package/src/client/CollabConnector.js +17 -2
  173. package/src/client/EditorConnection.js +14 -3
  174. package/src/client/Licit.js +101 -85
  175. package/src/client/Licit.test.js +13 -11
  176. package/src/client/SimpleConnector.js +3 -1
  177. package/src/joinListNode.js +1 -1
  178. package/src/patchStyleElements.js +1 -1
  179. package/src/styles.css +2 -2
  180. package/src/styles0.css +3 -3
  181. package/src/toggleBlockquote.js +4 -4
  182. package/src/toggleCodeBlock.js +3 -3
  183. package/src/ui/CommandButton.js +1 -1
  184. package/src/ui/CommandMenuButton.js +2 -2
  185. package/src/ui/CustomMenuItem.js +1 -1
  186. package/src/ui/CustomRadioButton.js +3 -3
  187. package/src/ui/DocLayoutEditor.js +2 -2
  188. package/src/ui/Editor.js +1 -2
  189. package/src/ui/EditorToolbar.js +1 -1
  190. package/src/ui/FontSizeCommandMenuButton.js +1 -1
  191. package/src/ui/FontTypeCommandMenuButton.js +1 -1
  192. package/src/ui/ImageAlignEditor.js +1 -1
  193. package/src/ui/ImageInlineEditor.js +1 -1
  194. package/src/ui/ImageNodeView.js +2 -2
  195. package/src/ui/ImageResizeBox.js +1 -1
  196. package/src/ui/ImageURLEditor.js +2 -2
  197. package/src/ui/ImageUploadEditor.js +2 -2
  198. package/src/ui/LinkTooltip.js +1 -1
  199. package/src/ui/LinkURLEditor.js +2 -2
  200. package/src/ui/ListTypeButton.js +2 -2
  201. package/src/ui/MathEditor.js +2 -2
  202. package/src/ui/MathInlineEditor.js +2 -2
  203. package/src/ui/MathNodeView.js +2 -2
  204. package/src/ui/TableGridSizeEditor.js +2 -2
  205. package/src/ui/czi-link-tooltip.css +1 -1
  206. package/src/ui/czi-vars.css +1 -45
  207. package/src/ui/isElementFullyVisible.js +1 -1
  208. package/src/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +1 -1
  209. package/src/ui/toCSSLineSpacing.js +0 -27
  210. package/build_customstyle_server.py +0 -7
  211. package/dist/FontSizeCommand.js +0 -80
  212. package/dist/FontSizeCommand.js.flow +0 -57
  213. package/dist/FontTypeCommand.js +0 -137
  214. package/dist/FontTypeCommand.js.flow +0 -100
  215. package/dist/HeadingCommand.js +0 -65
  216. package/dist/HeadingCommand.js.flow +0 -51
  217. package/dist/IndentCommand.js +0 -57
  218. package/dist/IndentCommand.js.flow +0 -41
  219. package/dist/MarkToggleCommand.js +0 -90
  220. package/dist/MarkToggleCommand.js.flow +0 -66
  221. package/dist/TextAlignCommand.js +0 -151
  222. package/dist/TextAlignCommand.js.flow +0 -122
  223. package/dist/TextColorCommand.js +0 -114
  224. package/dist/TextColorCommand.js.flow +0 -87
  225. package/dist/TextHighlightCommand.js +0 -118
  226. package/dist/TextHighlightCommand.js.flow +0 -91
  227. package/dist/TextLineSpacingCommand.js +0 -177
  228. package/dist/TextLineSpacingCommand.js.flow +0 -157
  229. package/dist/applyMark.js +0 -84
  230. package/dist/applyMark.js.flow +0 -61
  231. package/dist/clearMarks.js +0 -160
  232. package/dist/clearMarks.js.flow +0 -128
  233. package/dist/compareNumber.js +0 -18
  234. package/dist/compareNumber.js.flow +0 -11
  235. package/dist/consolidateListNodes.js +0 -291
  236. package/dist/consolidateListNodes.js.flow +0 -281
  237. package/dist/coverage/lcov-report/block-navigation.js +0 -77
  238. package/dist/coverage/lcov-report/block-navigation.js.flow +0 -79
  239. package/dist/coverage/lcov-report/prettify.js +0 -994
  240. package/dist/coverage/lcov-report/prettify.js.flow +0 -2
  241. package/dist/coverage/lcov-report/sorter.js +0 -187
  242. package/dist/coverage/lcov-report/sorter.js.flow +0 -170
  243. package/dist/findNodesWithSameMark.js +0 -89
  244. package/dist/findNodesWithSameMark.js.flow +0 -89
  245. package/dist/isBulletListNode.js +0 -14
  246. package/dist/isBulletListNode.js.flow +0 -9
  247. package/dist/isInsideListItem.js +0 -19
  248. package/dist/isInsideListItem.js.flow +0 -13
  249. package/dist/isListNode.js +0 -22
  250. package/dist/isListNode.js.flow +0 -13
  251. package/dist/isNodeSelectionForNodeType.js +0 -19
  252. package/dist/isNodeSelectionForNodeType.js.flow +0 -15
  253. package/dist/isOrderedListNode.js +0 -14
  254. package/dist/isOrderedListNode.js.flow +0 -9
  255. package/dist/isTextStyleMarkCommandEnabled.js +0 -59
  256. package/dist/isTextStyleMarkCommandEnabled.js.flow +0 -49
  257. package/dist/noop.js +0 -11
  258. package/dist/noop.js.flow +0 -5
  259. package/dist/toggleHeading.js +0 -135
  260. package/dist/toggleHeading.js.flow +0 -113
  261. package/dist/toggleList.js +0 -431
  262. package/dist/toggleList.js.flow +0 -450
  263. package/dist/transformAndPreserveTextSelection.js +0 -173
  264. package/dist/transformAndPreserveTextSelection.js.flow +0 -151
  265. package/dist/ui/ColorEditor.js +0 -118
  266. package/dist/ui/ColorEditor.js.flow +0 -101
  267. package/dist/ui/CustomButton.js +0 -62
  268. package/dist/ui/CustomButton.js.flow +0 -33
  269. package/dist/ui/PointerSurface.js +0 -173
  270. package/dist/ui/PointerSurface.js.flow +0 -141
  271. package/dist/ui/PopUp.js +0 -129
  272. package/dist/ui/PopUp.js.flow +0 -77
  273. package/dist/ui/PopUpManager.js +0 -266
  274. package/dist/ui/PopUpManager.js.flow +0 -213
  275. package/dist/ui/PopUpPosition.js +0 -156
  276. package/dist/ui/PopUpPosition.js.flow +0 -104
  277. package/dist/ui/PopUpTypes.js +0 -1
  278. package/dist/ui/TooltipSurface.js +0 -99
  279. package/dist/ui/TooltipSurface.js.flow +0 -76
  280. package/dist/ui/clamp.js +0 -18
  281. package/dist/ui/clamp.js.flow +0 -11
  282. package/dist/ui/createPopUp.js +0 -199
  283. package/dist/ui/createPopUp.js.flow +0 -205
  284. package/dist/ui/czi-animations.css +0 -15
  285. package/dist/ui/czi-color-editor.css +0 -56
  286. package/dist/ui/czi-custom-button.css +0 -93
  287. package/dist/ui/czi-pop-up.css +0 -32
  288. package/dist/ui/czi-tooltip-surface.css +0 -45
  289. package/dist/ui/preventEventDefault.js +0 -10
  290. package/dist/ui/preventEventDefault.js.flow +0 -5
  291. package/dist/ui/rects.js +0 -58
  292. package/dist/ui/rects.js.flow +0 -47
  293. package/dist/updateIndentLevel.js +0 -232
  294. package/dist/updateIndentLevel.js.flow +0 -211
  295. package/flow-typed/@molicit-citation.js +0 -5
  296. package/licit/server/customstyles/start.js +0 -184
  297. package/run_customstyle_server.py +0 -20
  298. package/src/FontSizeCommand.js +0 -57
  299. package/src/FontTypeCommand.js +0 -100
  300. package/src/HeadingCommand.js +0 -51
  301. package/src/IndentCommand.js +0 -41
  302. package/src/MarkToggleCommand.js +0 -66
  303. package/src/TextAlignCommand.js +0 -122
  304. package/src/TextColorCommand.js +0 -87
  305. package/src/TextHighlightCommand.js +0 -91
  306. package/src/TextLineSpacingCommand.js +0 -157
  307. package/src/applyMark.js +0 -61
  308. package/src/clearMarks.js +0 -128
  309. package/src/compareNumber.js +0 -11
  310. package/src/consolidateListNodes.js +0 -281
  311. package/src/findNodesWithSameMark.js +0 -89
  312. package/src/isBulletListNode.js +0 -9
  313. package/src/isInsideListItem.js +0 -13
  314. package/src/isListNode.js +0 -13
  315. package/src/isNodeSelectionForNodeType.js +0 -15
  316. package/src/isOrderedListNode.js +0 -9
  317. package/src/isTextStyleMarkCommandEnabled.js +0 -49
  318. package/src/noop.js +0 -5
  319. package/src/toggleHeading.js +0 -113
  320. package/src/toggleList.js +0 -450
  321. package/src/transformAndPreserveTextSelection.js +0 -151
  322. package/src/ui/ColorEditor.js +0 -101
  323. package/src/ui/CustomButton.js +0 -33
  324. package/src/ui/PointerSurface.js +0 -141
  325. package/src/ui/PopUp.js +0 -77
  326. package/src/ui/PopUpManager.js +0 -213
  327. package/src/ui/PopUpPosition.js +0 -104
  328. package/src/ui/PopUpTypes.js +0 -0
  329. package/src/ui/TooltipSurface.js +0 -76
  330. package/src/ui/clamp.js +0 -11
  331. package/src/ui/createPopUp.js +0 -205
  332. package/src/ui/czi-animations.css +0 -15
  333. package/src/ui/czi-color-editor.css +0 -56
  334. package/src/ui/czi-custom-button.css +0 -93
  335. package/src/ui/czi-pop-up.css +0 -32
  336. package/src/ui/czi-tooltip-surface.css +0 -45
  337. package/src/ui/preventEventDefault.js +0 -5
  338. package/src/ui/rects.js +0 -47
  339. package/src/updateIndentLevel.js +0 -211
  340. package/utils/build_customstyle_server.js +0 -72
@@ -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/dist/ui/PopUp.js DELETED
@@ -1,129 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.bpfrpt_proptype_PopUpHandle = exports.bpfrpt_proptype_PopUpProps = exports.bpfrpt_proptype_PopUpParams = exports.bpfrpt_proptype_ViewProps = exports.default = void 0;
7
-
8
- var React = _interopRequireWildcard(require("react"));
9
-
10
- var _PopUpManager = _interopRequireWildcard(require("./PopUpManager"));
11
-
12
- var _PopUpPosition = require("./PopUpPosition");
13
-
14
- var _uuid = _interopRequireDefault(require("./uuid"));
15
-
16
- var _rects = require("./rects");
17
-
18
- var _propTypes = _interopRequireDefault(require("prop-types"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
-
26
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
27
-
28
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
-
30
- var bpfrpt_proptype_ViewProps = _propTypes.default.object;
31
- exports.bpfrpt_proptype_ViewProps = bpfrpt_proptype_ViewProps;
32
- var bpfrpt_proptype_PopUpParams = {
33
- "anchor": _propTypes.default.any,
34
- "autoDismiss": _propTypes.default.bool,
35
- "container": function () {
36
- return (typeof Element === "function" ? _propTypes.default.instanceOf(Element) : _propTypes.default.any).apply(this, arguments);
37
- },
38
- "modal": _propTypes.default.bool,
39
- "onClose": _propTypes.default.func,
40
- "position": _propTypes.default.func,
41
- "IsChildDialog": _propTypes.default.bool
42
- };
43
- exports.bpfrpt_proptype_PopUpParams = bpfrpt_proptype_PopUpParams;
44
- var bpfrpt_proptype_PopUpProps = {
45
- "View": _propTypes.default.func.isRequired,
46
- "close": _propTypes.default.func.isRequired,
47
- "popUpParams": _propTypes.default.shape({
48
- anchor: _propTypes.default.any,
49
- autoDismiss: _propTypes.default.bool,
50
- container: function () {
51
- return (typeof Element === "function" ? _propTypes.default.instanceOf(Element) : _propTypes.default.any).apply(this, arguments);
52
- },
53
- modal: _propTypes.default.bool,
54
- onClose: _propTypes.default.func,
55
- position: _propTypes.default.func,
56
- IsChildDialog: _propTypes.default.bool
57
- }).isRequired,
58
- "viewProps": _propTypes.default.object.isRequired
59
- };
60
- exports.bpfrpt_proptype_PopUpProps = bpfrpt_proptype_PopUpProps;
61
- var bpfrpt_proptype_PopUpHandle = {
62
- "close": _propTypes.default.func.isRequired,
63
- "update": _propTypes.default.func.isRequired
64
- };
65
- exports.bpfrpt_proptype_PopUpHandle = bpfrpt_proptype_PopUpHandle;
66
-
67
- class PopUp extends React.PureComponent {
68
- constructor() {
69
- super(...arguments);
70
-
71
- _defineProperty(this, "props", void 0);
72
-
73
- _defineProperty(this, "_bridge", null);
74
-
75
- _defineProperty(this, "_id", (0, _uuid.default)());
76
-
77
- _defineProperty(this, "_getDetails", () => {
78
- const {
79
- close,
80
- popUpParams
81
- } = this.props;
82
- const {
83
- anchor,
84
- autoDismiss,
85
- position,
86
- modal
87
- } = popUpParams;
88
- return {
89
- anchor,
90
- autoDismiss: autoDismiss === false ? false : true,
91
- body: document.getElementById(this._id),
92
- close,
93
- modal: modal === true,
94
- position: position || (modal ? _PopUpPosition.atViewportCenter : _PopUpPosition.atAnchorBottomLeft)
95
- };
96
- });
97
- }
98
-
99
- render() {
100
- const dummy = {};
101
- const {
102
- View,
103
- viewProps,
104
- close
105
- } = this.props;
106
- return /*#__PURE__*/React.createElement("div", {
107
- "data-pop-up-id": this._id,
108
- id: this._id
109
- }, /*#__PURE__*/React.createElement(View, _extends({}, viewProps || dummy, {
110
- close: close
111
- })));
112
- }
113
-
114
- componentDidMount() {
115
- this._bridge = {
116
- getDetails: this._getDetails
117
- };
118
-
119
- _PopUpManager.default.register(this._bridge);
120
- }
121
-
122
- componentWillUnmount() {
123
- this._bridge && _PopUpManager.default.unregister(this._bridge);
124
- }
125
-
126
- }
127
-
128
- var _default = PopUp;
129
- exports.default = _default;
@@ -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;
@@ -1,266 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.bpfrpt_proptype_PopUpBridge = exports.bpfrpt_proptype_PopUpDetails = exports.default = void 0;
7
-
8
- var _clamp = _interopRequireDefault(require("./clamp"));
9
-
10
- var _rects = require("./rects");
11
-
12
- var _PopUpPosition = require("./PopUpPosition");
13
-
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
20
- var bpfrpt_proptype_PopUpDetails = {
21
- "anchor": function () {
22
- return (typeof HTMLElement === "function" ? _propTypes.default.instanceOf(HTMLElement) : _propTypes.default.any).apply(this, arguments);
23
- },
24
- "anchorRect": function () {
25
- return (typeof _rects.bpfrpt_proptype_Rect === "function" ? _rects.bpfrpt_proptype_Rect : _propTypes.default.shape(_rects.bpfrpt_proptype_Rect)).apply(this, arguments);
26
- },
27
- "autoDismiss": _propTypes.default.bool.isRequired,
28
- "body": function () {
29
- return (typeof HTMLElement === "function" ? _propTypes.default.instanceOf(HTMLElement) : _propTypes.default.any).apply(this, arguments);
30
- },
31
- "bodyRect": function () {
32
- return (typeof _rects.bpfrpt_proptype_Rect === "function" ? _rects.bpfrpt_proptype_Rect : _propTypes.default.shape(_rects.bpfrpt_proptype_Rect)).apply(this, arguments);
33
- },
34
- "close": _propTypes.default.func.isRequired,
35
- "modal": _propTypes.default.bool.isRequired,
36
- "position": function () {
37
- return (typeof _PopUpPosition.bpfrpt_proptype_PositionHandler === "function" ? _PopUpPosition.bpfrpt_proptype_PositionHandler.isRequired ? _PopUpPosition.bpfrpt_proptype_PositionHandler.isRequired : _PopUpPosition.bpfrpt_proptype_PositionHandler : _propTypes.default.shape(_PopUpPosition.bpfrpt_proptype_PositionHandler).isRequired).apply(this, arguments);
38
- }
39
- };
40
- exports.bpfrpt_proptype_PopUpDetails = bpfrpt_proptype_PopUpDetails;
41
- var bpfrpt_proptype_PopUpBridge = {
42
- "getDetails": _propTypes.default.func.isRequired
43
- };
44
- exports.bpfrpt_proptype_PopUpBridge = bpfrpt_proptype_PopUpBridge;
45
- const CLICK_INTERVAL = 350;
46
- const DUMMY_RECT = {
47
- x: -10000,
48
- y: -10000,
49
- w: 0,
50
- h: 0
51
- };
52
-
53
- class PopUpManager {
54
- constructor() {
55
- _defineProperty(this, "_bridges", new Map());
56
-
57
- _defineProperty(this, "_positions", new Map());
58
-
59
- _defineProperty(this, "_mx", 0);
60
-
61
- _defineProperty(this, "_my", 0);
62
-
63
- _defineProperty(this, "_rafID", 0);
64
-
65
- _defineProperty(this, "_onScroll", e => {
66
- this._rafID && cancelAnimationFrame(this._rafID);
67
- this._rafID = requestAnimationFrame(this._syncPosition);
68
- });
69
-
70
- _defineProperty(this, "_onResize", e => {
71
- this._rafID && cancelAnimationFrame(this._rafID);
72
- this._rafID = requestAnimationFrame(this._syncPosition);
73
- });
74
-
75
- _defineProperty(this, "_onMouseChange", e => {
76
- this._mx = Math.round(e.clientX);
77
- this._my = Math.round(e.clientY);
78
- this._rafID && cancelAnimationFrame(this._rafID);
79
- this._rafID = requestAnimationFrame(this._syncPosition);
80
- });
81
-
82
- _defineProperty(this, "_onClick", e => {
83
- const now = Date.now();
84
- let detailsWithModalToDismiss;
85
-
86
- for (const [bridge, registeredAt] of this._bridges) {
87
- if (now - registeredAt > CLICK_INTERVAL) {
88
- const details = bridge.getDetails();
89
-
90
- if (details.modal && details.autoDismiss) {
91
- detailsWithModalToDismiss = details;
92
- }
93
- }
94
- }
95
-
96
- if (!detailsWithModalToDismiss) {
97
- return;
98
- }
99
-
100
- const {
101
- body,
102
- close
103
- } = detailsWithModalToDismiss;
104
- const pointer = (0, _rects.fromXY)(e.clientX, e.clientY, 1);
105
- const bodyRect = body ? (0, _rects.fromHTMlElement)(body) : null;
106
-
107
- if (!bodyRect || !(0, _rects.isIntersected)(pointer, bodyRect)) {
108
- close();
109
- }
110
- });
111
-
112
- _defineProperty(this, "_syncPosition", () => {
113
- this._rafID = 0;
114
- const bridgeToDetails = new Map();
115
-
116
- for (const [bridge, // eslint-disable-next-line no-unused-vars
117
- registeredAt] of this._bridges) {
118
- const details = bridge.getDetails();
119
- bridgeToDetails.set(bridge, details);
120
- const {
121
- anchor,
122
- body
123
- } = details;
124
-
125
- if (body instanceof HTMLElement) {
126
- details.bodyRect = (0, _rects.fromHTMlElement)(body);
127
- }
128
-
129
- if (anchor instanceof HTMLElement) {
130
- details.anchorRect = (0, _rects.fromHTMlElement)(anchor);
131
- }
132
- }
133
-
134
- const pointer = (0, _rects.fromXY)(this._mx, this._my, 2);
135
- const hoveredAnchors = new Set();
136
-
137
- for (const [bridge, details] of bridgeToDetails) {
138
- const {
139
- anchor,
140
- bodyRect,
141
- anchorRect,
142
- position,
143
- body
144
- } = details;
145
-
146
- if (!bodyRect && !anchorRect) {
147
- continue;
148
- }
149
-
150
- const {
151
- x,
152
- y
153
- } = position(anchorRect, bodyRect);
154
- const positionKey = `${x}-${y}`;
155
-
156
- if (body && bodyRect && this._positions.get(bridge) !== positionKey) {
157
- const ax = anchorRect ? (0, _clamp.default)(0, anchorRect.x - x + anchorRect.w / 2, bodyRect.w - anchorRect.w / 2) : 0;
158
-
159
- this._positions.set(bridge, positionKey);
160
-
161
- const bodyStyle = body.style;
162
- bodyStyle.position = 'absolute';
163
- bodyStyle.left = `${x}px`;
164
- bodyStyle.top = `${y}px`;
165
- bodyStyle.setProperty('--czi-pop-up-anchor-offset-left', `${ax}px`);
166
- bodyRect.x = x;
167
- bodyRect.y = y;
168
- }
169
-
170
- if ((0, _rects.isIntersected)(pointer, bodyRect || DUMMY_RECT, 0) || (0, _rects.isIntersected)(pointer, anchorRect || DUMMY_RECT, 0)) {
171
- if (anchor) {
172
- hoveredAnchors.add(anchor);
173
- }
174
- }
175
- }
176
-
177
- while (true) {
178
- const size = hoveredAnchors.size;
179
-
180
- for (const [// eslint-disable-next-line no-unused-vars
181
- bridge, details] of bridgeToDetails) {
182
- const {
183
- anchor,
184
- body
185
- } = details;
186
-
187
- for (const ha of hoveredAnchors) {
188
- if (anchor && body && !hoveredAnchors.has(anchor) && body.contains(ha)) {
189
- hoveredAnchors.add(anchor);
190
- }
191
- }
192
- }
193
-
194
- if (hoveredAnchors.size === size) {
195
- break;
196
- }
197
- }
198
-
199
- const now = Date.now();
200
-
201
- for (const [bridge, registeredAt] of this._bridges) {
202
- const details = bridgeToDetails.get(bridge);
203
-
204
- if (details) {
205
- const {
206
- autoDismiss,
207
- anchor,
208
- close,
209
- modal
210
- } = details;
211
-
212
- if (autoDismiss && // Modal is handled separately at `onClick`
213
- !modal && now - registeredAt > CLICK_INTERVAL && !hoveredAnchors.has(anchor)) {
214
- close();
215
- }
216
- }
217
- }
218
- });
219
- }
220
-
221
- register(bridge) {
222
- this._bridges.set(bridge, Date.now());
223
-
224
- this._positions.set(bridge, null);
225
-
226
- if (this._bridges.size === 1) {
227
- this._observe();
228
- }
229
-
230
- this._rafID = requestAnimationFrame(this._syncPosition);
231
- }
232
-
233
- unregister(bridge) {
234
- this._bridges.delete(bridge);
235
-
236
- this._positions.delete(bridge);
237
-
238
- if (this._bridges.size === 0) {
239
- this._unobserve();
240
- }
241
-
242
- this._rafID && cancelAnimationFrame(this._rafID);
243
- }
244
-
245
- _observe() {
246
- document.addEventListener('mousemove', this._onMouseChange, false);
247
- document.addEventListener('mouseup', this._onMouseChange, false);
248
- document.addEventListener('click', this._onClick, false);
249
- window.addEventListener('scroll', this._onScroll, true);
250
- window.addEventListener('resize', this._onResize, true);
251
- }
252
-
253
- _unobserve() {
254
- document.removeEventListener('mousemove', this._onMouseChange, false);
255
- document.removeEventListener('mouseup', this._onMouseChange, false);
256
- document.removeEventListener('click', this._onClick, false);
257
- window.removeEventListener('scroll', this._onScroll, true);
258
- window.removeEventListener('resize', this._onResize, true);
259
- this._rafID && cancelAnimationFrame(this._rafID);
260
- }
261
-
262
- }
263
-
264
- const instance = new PopUpManager();
265
- var _default = instance;
266
- exports.default = _default;