@manuscripts/style-guide 1.5.0-LEAN-2992 → 1.5.0-LEAN-3180-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/cjs/components/Dialog.js +3 -3
  2. package/dist/cjs/components/References/BibliographyItemSource.js +91 -0
  3. package/dist/cjs/components/References/CitationEditor.js +146 -0
  4. package/dist/cjs/components/References/CitationViewer.js +69 -0
  5. package/dist/cjs/components/References/ReferenceForm.js +415 -0
  6. package/dist/cjs/components/References/ReferenceLine.js +52 -0
  7. package/dist/cjs/components/References/ReferenceSearch.js +124 -0
  8. package/dist/cjs/components/References/ReferenceSearchResults.js +68 -0
  9. package/dist/cjs/components/References/ReferenceSearchResultsPlaceholder.js +43 -0
  10. package/dist/cjs/components/References/ReferenceSearchSection.js +118 -0
  11. package/dist/cjs/components/References/ReferencesModal.js +219 -0
  12. package/dist/cjs/components/References/SearchInput.js +103 -0
  13. package/dist/cjs/components/{Menus → References}/index.js +4 -1
  14. package/dist/cjs/components/SelectField.js +25 -0
  15. package/dist/cjs/components/Sidebar.js +44 -0
  16. package/dist/cjs/components/StyledModal.js +80 -3
  17. package/dist/cjs/components/icons/delete-icon.js +15 -0
  18. package/dist/cjs/components/icons/link-icon.js +11 -0
  19. package/dist/cjs/components/icons/template-icon.js +11 -0
  20. package/dist/cjs/hooks/use-scroll-detection.js +53 -0
  21. package/dist/cjs/index.js +1 -4
  22. package/dist/es/components/Dialog.js +2 -2
  23. package/dist/es/components/References/BibliographyItemSource.js +64 -0
  24. package/dist/es/components/References/CitationEditor.js +116 -0
  25. package/dist/es/components/References/CitationViewer.js +39 -0
  26. package/dist/es/components/References/ReferenceForm.js +385 -0
  27. package/dist/es/components/References/ReferenceLine.js +42 -0
  28. package/dist/es/components/References/ReferenceSearch.js +94 -0
  29. package/dist/es/components/References/ReferenceSearchResults.js +61 -0
  30. package/dist/es/components/References/ReferenceSearchResultsPlaceholder.js +36 -0
  31. package/dist/es/components/References/ReferenceSearchSection.js +88 -0
  32. package/dist/es/components/References/ReferencesModal.js +188 -0
  33. package/dist/es/components/References/SearchInput.js +73 -0
  34. package/dist/es/components/References/index.js +4 -0
  35. package/dist/es/components/SelectField.js +18 -0
  36. package/dist/es/components/Sidebar.js +18 -0
  37. package/dist/es/components/StyledModal.js +81 -3
  38. package/dist/es/components/icons/delete-icon.js +8 -0
  39. package/dist/es/components/icons/link-icon.js +4 -0
  40. package/dist/es/components/icons/template-icon.js +4 -0
  41. package/dist/es/hooks/use-scroll-detection.js +49 -0
  42. package/dist/es/index.js +1 -4
  43. package/dist/types/components/Dialog.d.ts +1 -1
  44. package/dist/types/components/References/BibliographyItemSource.d.ts +38 -0
  45. package/dist/types/components/References/CitationEditor.d.ts +18 -0
  46. package/dist/types/components/{Menus/Submenu.d.ts → References/CitationViewer.d.ts} +8 -9
  47. package/dist/types/components/References/ReferenceForm.d.ts +35 -0
  48. package/dist/types/components/References/ReferenceLine.d.ts +10 -0
  49. package/dist/types/components/{Menus/Shortcut.d.ts → References/ReferenceSearch.d.ts} +11 -8
  50. package/dist/types/components/References/ReferenceSearchResults.d.ts +26 -0
  51. package/dist/types/components/References/ReferenceSearchResultsPlaceholder.d.ts +2 -0
  52. package/dist/types/components/References/ReferenceSearchSection.d.ts +25 -0
  53. package/dist/types/components/References/ReferencesModal.d.ts +14 -0
  54. package/dist/types/components/{Menus/Menus.d.ts → References/SearchInput.d.ts} +4 -10
  55. package/dist/types/components/References/index.d.ts +4 -0
  56. package/dist/{cjs/lib/menus.js → types/components/SelectField.d.ts} +11 -6
  57. package/dist/types/components/Sidebar.d.ts +2 -0
  58. package/dist/types/components/StyledModal.d.ts +26 -4
  59. package/dist/types/components/icons/delete-icon.d.ts +2 -0
  60. package/dist/types/components/icons/link-icon.d.ts +2 -0
  61. package/dist/types/components/icons/template-icon.d.ts +2 -0
  62. package/dist/{es/lib/menus.js → types/hooks/use-scroll-detection.d.ts} +7 -3
  63. package/dist/types/index.d.ts +1 -4
  64. package/package.json +2 -1
  65. package/dist/cjs/components/Menus/Menus.js +0 -62
  66. package/dist/cjs/components/Menus/Shortcut.js +0 -64
  67. package/dist/cjs/components/Menus/Submenu.js +0 -119
  68. package/dist/cjs/components/SimpleModal.js +0 -95
  69. package/dist/cjs/hooks/use-menus.js +0 -89
  70. package/dist/es/components/Menus/Menus.js +0 -55
  71. package/dist/es/components/Menus/Shortcut.js +0 -57
  72. package/dist/es/components/Menus/Submenu.js +0 -112
  73. package/dist/es/components/Menus/index.js +0 -1
  74. package/dist/es/components/SimpleModal.js +0 -88
  75. package/dist/es/hooks/use-menus.js +0 -85
  76. package/dist/types/components/Menus/index.d.ts +0 -1
  77. package/dist/types/components/SimpleModal.d.ts +0 -41
  78. package/dist/types/hooks/use-menus.d.ts +0 -7
  79. package/dist/types/lib/menus.d.ts +0 -38
@@ -1,95 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.SimpleModal = exports.ModalMain = exports.CloseButton = exports.ModalHeader = exports.ModalContainer = void 0;
22
- const react_1 = __importDefault(require("react"));
23
- const react_modal_1 = __importDefault(require("react-modal"));
24
- const styled_components_1 = __importDefault(require("styled-components"));
25
- const Button_1 = require("./Button");
26
- exports.ModalContainer = styled_components_1.default.div `
27
- background: ${(props) => props.theme.colors.background.primary};
28
- border-radius: ${(props) => props.theme.grid.radius.default};
29
- box-shadow: ${(props) => props.theme.shadow.dropShadow};
30
- font-family: ${(props) => props.theme.font.family.sans};
31
- overflow: hidden;
32
- margin: ${(props) => props.theme.grid.unit * 3}px;
33
- `;
34
- exports.ModalHeader = styled_components_1.default.div `
35
- position: absolute;
36
- right: 0;
37
- top: 0;
38
- z-index: 1;
39
- `;
40
- exports.CloseButton = (0, styled_components_1.default)(Button_1.RoundIconButton) `
41
- box-shadow: none;
42
- text-indent: -99999px;
43
-
44
- ::before,
45
- ::after {
46
- background-color: ${(props) => props.theme.colors.text.secondary};
47
- border-radius: 2px;
48
- content: ' ';
49
- display: block;
50
- height: 14px;
51
- transform: rotate(-45deg);
52
- width: 2px;
53
- position: absolute;
54
- top: calc(50% - 7px);
55
- left: calc(50% - 1px);
56
- }
57
- ::after {
58
- transform: rotate(45deg);
59
- }
60
- `;
61
- exports.ModalMain = styled_components_1.default.div `
62
- padding: ${(props) => props.theme.grid.unit * 4}px;
63
- `;
64
- const SimpleModal = ({ children, closeWithOverlay, handleClose, width = 'auto', }) => (react_1.default.createElement(react_modal_1.default, { isOpen: true, onRequestClose: handleClose, shouldCloseOnOverlayClick: closeWithOverlay, appElement: document.getElementById('root'), style: {
65
- overlay: {
66
- alignItems: 'center',
67
- backgroundColor: 'rgba(0,0,0,0.5)',
68
- bottom: 0,
69
- display: 'flex',
70
- justifyContent: 'center',
71
- left: 0,
72
- position: 'fixed',
73
- right: 0,
74
- top: 0,
75
- },
76
- content: {
77
- background: 'transparent',
78
- border: 'none',
79
- bottom: 0,
80
- left: 0,
81
- margin: 'auto',
82
- maxHeight: '70vh',
83
- maxWidth: '70vw',
84
- padding: 0,
85
- position: 'relative',
86
- right: 0,
87
- top: 0,
88
- width,
89
- },
90
- } },
91
- react_1.default.createElement(exports.ModalContainer, null,
92
- react_1.default.createElement(exports.ModalHeader, null,
93
- react_1.default.createElement(exports.CloseButton, { onClick: handleClose })),
94
- react_1.default.createElement(exports.ModalMain, null, children))));
95
- exports.SimpleModal = SimpleModal;
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMenus = void 0;
4
- const react_1 = require("react");
5
- const menus_1 = require("../lib/menus");
6
- const initialPointer = [-1, -1, -1];
7
- const transformPointer = (depth, index) => (pointer) => pointer.map((pointerPart, i) => {
8
- if (i === depth) {
9
- return index;
10
- }
11
- if (i > depth) {
12
- return -1;
13
- }
14
- return pointerPart;
15
- });
16
- const isPart = (pointer, position) => {
17
- const limit = position.length < 3 ? position.length : 3;
18
- for (let i = 0; i < limit; i++) {
19
- if (position[i] !== pointer[i]) {
20
- return false;
21
- }
22
- }
23
- return true;
24
- };
25
- const getSubmenuState = (specs, pointer, position) => {
26
- return specs.map((spec, index) => {
27
- if ((0, menus_1.isMenuSeparator)(spec)) {
28
- return spec;
29
- }
30
- const current = [...position, index];
31
- return Object.assign(Object.assign({}, spec), { submenu: spec.submenu && getSubmenuState(spec.submenu, pointer, current), isOpen: isPart(pointer, current) });
32
- });
33
- };
34
- const getMenuState = (specs, pointer) => {
35
- return specs.map((spec, index) => {
36
- const position = [index];
37
- return Object.assign(Object.assign({}, spec), { submenu: spec.submenu && getSubmenuState(spec.submenu, pointer, position), isOpen: isPart(pointer, position) });
38
- });
39
- };
40
- const getMenuAt = (state, position) => {
41
- const [head, ...tail] = position.filter((i) => i !== -1);
42
- const menu = state[head];
43
- if ((0, menus_1.isMenuSeparator)(menu)) {
44
- return;
45
- }
46
- if (!tail.length) {
47
- return menu;
48
- }
49
- else if (menu.submenu) {
50
- return getMenuAt(menu.submenu, tail);
51
- }
52
- };
53
- const useMenus = (menus) => {
54
- const [pointer, setPointer] = (0, react_1.useState)(initialPointer);
55
- const state = getMenuState(menus, pointer);
56
- const handleClick = (0, react_1.useCallback)((indices) => {
57
- const menu = getMenuAt(state, indices);
58
- if (!menu || !menu.isEnabled) {
59
- return;
60
- }
61
- if (menu.run) {
62
- menu.run();
63
- setPointer([-1, -1, -1]);
64
- }
65
- else if (menu.submenu) {
66
- const depth = indices.length - 1;
67
- const index = indices[depth];
68
- setPointer(transformPointer(depth, index));
69
- }
70
- }, [state]);
71
- const ref = (0, react_1.useRef)(null);
72
- (0, react_1.useEffect)(() => {
73
- const handleClickOutside = (event) => {
74
- if (ref.current && !ref.current.contains(event.target)) {
75
- setPointer([-1, -1, -1]);
76
- }
77
- };
78
- document.addEventListener('click', handleClickOutside);
79
- return () => {
80
- document.removeEventListener('click', handleClickOutside);
81
- };
82
- }, []);
83
- return {
84
- menus: state,
85
- handleClick,
86
- ref,
87
- };
88
- };
89
- exports.useMenus = useMenus;
@@ -1,55 +0,0 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import React from 'react';
17
- import Modal from 'react-modal';
18
- import styled from 'styled-components';
19
- import { Submenu, SubmenusContainer, Text } from './Submenu';
20
- Modal.setAppElement('#root');
21
- const MenusContainer = styled.div `
22
- display: flex;
23
- font-size: 14px;
24
- `;
25
- const MenuHeading = styled.div `
26
- padding: 4px 8px;
27
- cursor: pointer;
28
- border: 1px solid transparent;
29
- border-bottom: none;
30
- `;
31
- const MenuContainer = styled.div `
32
- position: relative;
33
-
34
- & ${MenuHeading} {
35
- background-color: #fff;
36
- color: ${(props) => (props.isEnabled ? '#353535' : '#e2e2e2')};
37
-
38
- &:hover {
39
- background-color: ${(props) => (props.isEnabled ? '#f2fbfc' : '#fff')};
40
- }
41
- }
42
- `;
43
- export const Menus = ({ menus, innerRef, handleClick, }) => {
44
- return (React.createElement(MenusContainer, { ref: innerRef }, menus.map((menu, index) => {
45
- return (React.createElement(MenuContainer, { key: `menu-${index}`, isEnabled: menu.isEnabled },
46
- React.createElement(MenuHeading, { onMouseDown: (e) => {
47
- e.preventDefault();
48
- handleClick([index]);
49
- }, isOpen: menu.isOpen },
50
- React.createElement(Text, null, menu.label)),
51
- menu.isEnabled && menu.isOpen && menu.submenu && (React.createElement(SubmenusContainer, null, menu.submenu.map((submenu, sindex) => {
52
- return (React.createElement(Submenu, { key: `${index}-${sindex}`, menu: submenu, handleClick: (i) => handleClick([index, sindex, ...i]) }));
53
- })))));
54
- })));
55
- };
@@ -1,57 +0,0 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import React from 'react';
17
- import styled from 'styled-components';
18
- const isMac = /Mac/.test(window.navigator.platform);
19
- export const ShortcutContainer = styled.div `
20
- display: inline-flex;
21
- color: #6e6e6e;
22
- margin-left: 16px;
23
- flex-shrink: 0;
24
- justify-content: flex-end;
25
- `;
26
- const macModifiers = {
27
- Option: '⌥',
28
- CommandOrControl: '⌘',
29
- Shift: '⇧',
30
- };
31
- const pcModifiers = {
32
- Option: 'Alt',
33
- CommandOrControl: 'Ctrl',
34
- Shift: 'Shift',
35
- };
36
- const modifiers = isMac ? macModifiers : pcModifiers;
37
- const system = isMac ? 'mac' : 'pc';
38
- const separator = isMac ? '' : '-';
39
- const Character = styled.span `
40
- display: inline-block;
41
- min-width: 1ch;
42
- `;
43
- const parts = (shortcut) => {
44
- const nodes = [];
45
- for (const part of shortcut[system].split('+')) {
46
- const modifier = modifiers[part];
47
- if (modifier) {
48
- nodes.push(modifier);
49
- nodes.push(separator);
50
- }
51
- else {
52
- nodes.push(React.createElement(Character, { key: part }, part));
53
- }
54
- }
55
- return nodes;
56
- };
57
- export const Shortcut = ({ shortcut }) => (React.createElement(ShortcutContainer, null, parts(shortcut)));
@@ -1,112 +0,0 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import TriangleCollapsed from '@manuscripts/assets/react/TriangleCollapsed';
17
- import React from 'react';
18
- import styled from 'styled-components';
19
- import { isMenuSeparator } from '../../lib/menus';
20
- import { Shortcut } from './Shortcut';
21
- export const Text = styled.div `
22
- flex: 1 0 auto;
23
- `;
24
- const SubmenuContainer = styled.div `
25
- position: relative;
26
- `;
27
- export const SubmenusContainer = styled.div `
28
- background: #fff;
29
- border: 1px solid #e2e2e2;
30
- border-radius: 4px;
31
- box-shadow: 0 4px 9px 0 rgba(84, 83, 83, 0.3);
32
- color: #353535;
33
- min-width: 150px;
34
- max-height: 70vh;
35
- overflow-y: auto;
36
- padding: 4px 0;
37
- white-space: nowrap;
38
- width: auto;
39
- z-index: 10;
40
-
41
- position: absolute;
42
-
43
- &[data-placement='bottom-start'] {
44
- border-top-left-radius: 0;
45
- border-top-right-radius: 0;
46
- }
47
-
48
- &[data-placement='right-start'] {
49
- top: 8px;
50
- }
51
- `;
52
- const NestedSubmenusContainer = styled(SubmenusContainer) `
53
- top: 0;
54
- left: 100%;
55
- `;
56
- const Separator = styled.div `
57
- height: 0;
58
- border-bottom: 1px solid #e2e2e2;
59
- margin: 4px 0;
60
- `;
61
- const Active = styled.div `
62
- width: 16px;
63
- display: inline-flex;
64
- flex-shrink: 0;
65
- justify-content: center;
66
- align-items: center;
67
- `;
68
- const Arrow = styled(TriangleCollapsed) `
69
- margin-left: 8px;
70
- `;
71
- const Container = styled.div `
72
- align-items: center;
73
- cursor: pointer;
74
- display: flex;
75
- padding: 8px 16px 8px 4px;
76
- position: relative;
77
- ${(props) => props.isOpen && 'background: #f2fbfc;'}
78
-
79
- &:hover {
80
- background: #f2fbfc;
81
- }
82
-
83
- &.disabled {
84
- cursor: default;
85
- opacity: 0.4;
86
- }
87
- `;
88
- const activeContent = (menu) => (menu.isActive ? '✓' : '');
89
- export const Submenu = ({ menu, handleClick }) => {
90
- if (isMenuSeparator(menu)) {
91
- return React.createElement(Separator, null);
92
- }
93
- if (!menu.submenu) {
94
- return (React.createElement(Container, { isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled', onMouseDown: (e) => {
95
- e.preventDefault();
96
- handleClick([]);
97
- } },
98
- React.createElement(Active, null, activeContent(menu)),
99
- React.createElement(Text, null, menu.label),
100
- menu.shortcut && React.createElement(Shortcut, { shortcut: menu.shortcut })));
101
- }
102
- return (React.createElement(SubmenuContainer, null,
103
- React.createElement(Container, { onMouseDown: (e) => {
104
- e.preventDefault();
105
- handleClick([]);
106
- }, isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled' },
107
- React.createElement(Active, null, activeContent(menu)),
108
- React.createElement(Text, null, menu.label),
109
- menu.submenu && React.createElement(Arrow, null),
110
- menu.shortcut && React.createElement(Shortcut, { shortcut: menu.shortcut })),
111
- menu.submenu && menu.isOpen && (React.createElement(NestedSubmenusContainer, null, menu.submenu.map((submenu, index) => (React.createElement(Submenu, { key: `menu-${index}`, menu: submenu, handleClick: (i) => handleClick([index, ...i]) })))))));
112
- };
@@ -1 +0,0 @@
1
- export * from './Menus';
@@ -1,88 +0,0 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import React from 'react';
17
- import Modal from 'react-modal';
18
- import styled from 'styled-components';
19
- import { RoundIconButton } from './Button';
20
- export const ModalContainer = styled.div `
21
- background: ${(props) => props.theme.colors.background.primary};
22
- border-radius: ${(props) => props.theme.grid.radius.default};
23
- box-shadow: ${(props) => props.theme.shadow.dropShadow};
24
- font-family: ${(props) => props.theme.font.family.sans};
25
- overflow: hidden;
26
- margin: ${(props) => props.theme.grid.unit * 3}px;
27
- `;
28
- export const ModalHeader = styled.div `
29
- position: absolute;
30
- right: 0;
31
- top: 0;
32
- z-index: 1;
33
- `;
34
- export const CloseButton = styled(RoundIconButton) `
35
- box-shadow: none;
36
- text-indent: -99999px;
37
-
38
- ::before,
39
- ::after {
40
- background-color: ${(props) => props.theme.colors.text.secondary};
41
- border-radius: 2px;
42
- content: ' ';
43
- display: block;
44
- height: 14px;
45
- transform: rotate(-45deg);
46
- width: 2px;
47
- position: absolute;
48
- top: calc(50% - 7px);
49
- left: calc(50% - 1px);
50
- }
51
- ::after {
52
- transform: rotate(45deg);
53
- }
54
- `;
55
- export const ModalMain = styled.div `
56
- padding: ${(props) => props.theme.grid.unit * 4}px;
57
- `;
58
- export const SimpleModal = ({ children, closeWithOverlay, handleClose, width = 'auto', }) => (React.createElement(Modal, { isOpen: true, onRequestClose: handleClose, shouldCloseOnOverlayClick: closeWithOverlay, appElement: document.getElementById('root'), style: {
59
- overlay: {
60
- alignItems: 'center',
61
- backgroundColor: 'rgba(0,0,0,0.5)',
62
- bottom: 0,
63
- display: 'flex',
64
- justifyContent: 'center',
65
- left: 0,
66
- position: 'fixed',
67
- right: 0,
68
- top: 0,
69
- },
70
- content: {
71
- background: 'transparent',
72
- border: 'none',
73
- bottom: 0,
74
- left: 0,
75
- margin: 'auto',
76
- maxHeight: '70vh',
77
- maxWidth: '70vw',
78
- padding: 0,
79
- position: 'relative',
80
- right: 0,
81
- top: 0,
82
- width,
83
- },
84
- } },
85
- React.createElement(ModalContainer, null,
86
- React.createElement(ModalHeader, null,
87
- React.createElement(CloseButton, { onClick: handleClose })),
88
- React.createElement(ModalMain, null, children))));
@@ -1,85 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from 'react';
2
- import { isMenuSeparator, } from '../lib/menus';
3
- const initialPointer = [-1, -1, -1];
4
- const transformPointer = (depth, index) => (pointer) => pointer.map((pointerPart, i) => {
5
- if (i === depth) {
6
- return index;
7
- }
8
- if (i > depth) {
9
- return -1;
10
- }
11
- return pointerPart;
12
- });
13
- const isPart = (pointer, position) => {
14
- const limit = position.length < 3 ? position.length : 3;
15
- for (let i = 0; i < limit; i++) {
16
- if (position[i] !== pointer[i]) {
17
- return false;
18
- }
19
- }
20
- return true;
21
- };
22
- const getSubmenuState = (specs, pointer, position) => {
23
- return specs.map((spec, index) => {
24
- if (isMenuSeparator(spec)) {
25
- return spec;
26
- }
27
- const current = [...position, index];
28
- return Object.assign(Object.assign({}, spec), { submenu: spec.submenu && getSubmenuState(spec.submenu, pointer, current), isOpen: isPart(pointer, current) });
29
- });
30
- };
31
- const getMenuState = (specs, pointer) => {
32
- return specs.map((spec, index) => {
33
- const position = [index];
34
- return Object.assign(Object.assign({}, spec), { submenu: spec.submenu && getSubmenuState(spec.submenu, pointer, position), isOpen: isPart(pointer, position) });
35
- });
36
- };
37
- const getMenuAt = (state, position) => {
38
- const [head, ...tail] = position.filter((i) => i !== -1);
39
- const menu = state[head];
40
- if (isMenuSeparator(menu)) {
41
- return;
42
- }
43
- if (!tail.length) {
44
- return menu;
45
- }
46
- else if (menu.submenu) {
47
- return getMenuAt(menu.submenu, tail);
48
- }
49
- };
50
- export const useMenus = (menus) => {
51
- const [pointer, setPointer] = useState(initialPointer);
52
- const state = getMenuState(menus, pointer);
53
- const handleClick = useCallback((indices) => {
54
- const menu = getMenuAt(state, indices);
55
- if (!menu || !menu.isEnabled) {
56
- return;
57
- }
58
- if (menu.run) {
59
- menu.run();
60
- setPointer([-1, -1, -1]);
61
- }
62
- else if (menu.submenu) {
63
- const depth = indices.length - 1;
64
- const index = indices[depth];
65
- setPointer(transformPointer(depth, index));
66
- }
67
- }, [state]);
68
- const ref = useRef(null);
69
- useEffect(() => {
70
- const handleClickOutside = (event) => {
71
- if (ref.current && !ref.current.contains(event.target)) {
72
- setPointer([-1, -1, -1]);
73
- }
74
- };
75
- document.addEventListener('click', handleClickOutside);
76
- return () => {
77
- document.removeEventListener('click', handleClickOutside);
78
- };
79
- }, []);
80
- return {
81
- menus: state,
82
- handleClick,
83
- ref,
84
- };
85
- };
@@ -1 +0,0 @@
1
- export * from './Menus';
@@ -1,41 +0,0 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import React from 'react';
17
- export declare const ModalContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
18
- export declare const ModalHeader: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
19
- export declare const CloseButton: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {
20
- type: "button" | "reset" | "submit";
21
- } & {
22
- danger?: boolean | undefined;
23
- disabled?: boolean | undefined;
24
- mini?: boolean | undefined;
25
- } & {
26
- defaultColor?: boolean | undefined;
27
- size?: number | undefined;
28
- iconColor?: string | undefined;
29
- } & {
30
- defaultColor: boolean;
31
- } & {
32
- size?: number | undefined;
33
- }, "type" | "defaultColor">;
34
- export declare const ModalMain: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
35
- interface Props {
36
- handleClose: () => void;
37
- closeWithOverlay: boolean;
38
- width?: string;
39
- }
40
- export declare const SimpleModal: React.FunctionComponent<Props>;
41
- export {};
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { Menu, MenuSpec } from '../lib/menus';
3
- export declare const useMenus: (menus: MenuSpec[]) => {
4
- menus: Menu[];
5
- handleClick: (indices: number[]) => void;
6
- ref: import("react").RefObject<HTMLDivElement>;
7
- };
@@ -1,38 +0,0 @@
1
- /*!
2
- * © 2024 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export interface MenuShortcut {
17
- mac: string;
18
- pc: string;
19
- }
20
- export interface MenuSpec {
21
- id: string;
22
- label: string;
23
- role?: string;
24
- shortcut?: MenuShortcut;
25
- isActive?: boolean;
26
- isEnabled: boolean;
27
- run?: () => void;
28
- submenu?: (MenuSpec | MenuSeparator)[];
29
- }
30
- export interface Menu extends MenuSpec {
31
- isOpen: boolean;
32
- submenu?: (Menu | MenuSeparator)[];
33
- }
34
- export type MenuSeparator = {
35
- role: 'separator';
36
- };
37
- export declare const isMenuSeparator: (menu: any) => menu is MenuSeparator;
38
- export type MenuPointer = [number, number, number];