orc-shared 5.10.1-dev.8 → 5.10.1-dev.9

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 (133) hide show
  1. package/dist/components/Authenticate.js +41 -17
  2. package/dist/components/ErrorPlaceholder.js +8 -24
  3. package/dist/components/{Icon.js → Form/Inputs/MultiSelector.js} +33 -20
  4. package/dist/components/Form/Inputs/index.js +1 -1
  5. package/dist/components/LoadingIcon.js +6 -16
  6. package/dist/components/MaterialUI/Inputs/Select.js +10 -0
  7. package/dist/components/MaterialUI/Inputs/SelectProps.js +3 -1
  8. package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
  9. package/dist/components/Provision.js +30 -13
  10. package/dist/components/Routing/SegmentPage.js +115 -56
  11. package/dist/components/Scope/ScopeNode.js +68 -45
  12. package/dist/components/Sidepanel.js +57 -23
  13. package/dist/components/Spritesheet.js +33 -17
  14. package/dist/components/Text.js +1 -60
  15. package/dist/components/Treeview/Branch.js +82 -20
  16. package/dist/components/Treeview/Label.js +108 -31
  17. package/dist/components/Treeview/Leaf.js +56 -12
  18. package/dist/components/Treeview/Node.js +22 -9
  19. package/dist/components/Treeview/index.js +7 -1
  20. package/dist/components/Treeview/settings.js +7 -5
  21. package/dist/utils/index.js +0 -4
  22. package/dist/utils/testUtils.js +1 -12
  23. package/package.json +1 -1
  24. package/src/components/ApplicationModuleLoader.test.js +14 -27
  25. package/src/components/Authenticate.js +29 -21
  26. package/src/components/Authenticate.test.js +18 -27
  27. package/src/components/ErrorPlaceholder.js +4 -21
  28. package/src/components/ErrorPlaceholder.test.js +7 -14
  29. package/src/components/Form/InputField.test.js +2 -1
  30. package/src/components/Form/Inputs/MultiSelector.js +23 -0
  31. package/src/components/Form/Inputs/MultiSelector.test.js +112 -0
  32. package/src/components/Form/Inputs/index.js +1 -1
  33. package/src/components/Loader.test.js +21 -33
  34. package/src/components/LoadingIcon.js +2 -15
  35. package/src/components/LoadingIcon.test.js +2 -20
  36. package/src/components/MaterialUI/DataDisplay/Table.test.js +1 -1
  37. package/src/components/MaterialUI/Inputs/Select.js +7 -0
  38. package/src/components/MaterialUI/Inputs/Select.test.js +45 -0
  39. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  40. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  41. package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
  42. package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
  43. package/src/components/Navigation/Navigation.test.js +0 -5
  44. package/src/components/Navigation/useNavigationState.test.js +79 -222
  45. package/src/components/Provision.js +36 -42
  46. package/src/components/Provision.test.js +10 -26
  47. package/src/components/Routing/SegmentPage.js +68 -52
  48. package/src/components/Routing/SegmentPage.test.js +4 -12
  49. package/src/components/Scope/ScopeNode.js +61 -54
  50. package/src/components/Scope/ScopeNode.test.js +61 -154
  51. package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
  52. package/src/components/Sidepanel.js +38 -32
  53. package/src/components/Sidepanel.test.js +49 -27
  54. package/src/components/Spritesheet.js +23 -21
  55. package/src/components/Spritesheet.test.js +10 -10
  56. package/src/components/Text.js +0 -49
  57. package/src/components/Treeview/Branch.js +63 -45
  58. package/src/components/Treeview/Branch.test.js +21 -24
  59. package/src/components/Treeview/Label.js +66 -52
  60. package/src/components/Treeview/Label.test.js +42 -60
  61. package/src/components/Treeview/Leaf.js +41 -22
  62. package/src/components/Treeview/Leaf.test.js +15 -10
  63. package/src/components/Treeview/Node.js +16 -9
  64. package/src/components/Treeview/Node.test.js +269 -200
  65. package/src/components/Treeview/Treeview.test.js +248 -248
  66. package/src/components/Treeview/index.js +6 -0
  67. package/src/components/Treeview/settings.js +7 -6
  68. package/src/utils/index.js +0 -4
  69. package/src/utils/testUtils.js +0 -10
  70. package/src/utils/testUtils.test.js +0 -68
  71. package/dist/components/Button.js +0 -70
  72. package/dist/components/Checkbox.js +0 -103
  73. package/dist/components/IconButton.js +0 -80
  74. package/dist/components/Input.js +0 -101
  75. package/dist/components/Modal/Background.js +0 -55
  76. package/dist/components/Modal/Dialog.js +0 -75
  77. package/dist/components/Modal/Wrapper.js +0 -69
  78. package/dist/components/Modal/index.js +0 -86
  79. package/dist/components/MultiSelector.js +0 -187
  80. package/dist/components/Navigation/Bar.js +0 -293
  81. package/dist/components/Navigation/Tab.js +0 -182
  82. package/dist/components/Placeholder.js +0 -114
  83. package/dist/components/Scope/Selector.js +0 -123
  84. package/dist/components/Selector.js +0 -185
  85. package/dist/components/Switch.js +0 -128
  86. package/dist/components/Toolbar.js +0 -227
  87. package/dist/components/Tooltip.js +0 -66
  88. package/dist/getTheme.js +0 -153
  89. package/dist/getThemeOverrides.js +0 -93
  90. package/dist/hocs/withAuthentication.js +0 -72
  91. package/dist/utils/styledPropFuncs.js +0 -88
  92. package/src/components/Button.js +0 -90
  93. package/src/components/Button.test.js +0 -49
  94. package/src/components/Checkbox.js +0 -63
  95. package/src/components/Checkbox.test.js +0 -122
  96. package/src/components/Icon.js +0 -18
  97. package/src/components/IconButton.js +0 -30
  98. package/src/components/IconButton.test.js +0 -61
  99. package/src/components/Input.js +0 -35
  100. package/src/components/Input.test.js +0 -34
  101. package/src/components/Modal/Background.js +0 -10
  102. package/src/components/Modal/Dialog.js +0 -27
  103. package/src/components/Modal/Dialog.test.js +0 -20
  104. package/src/components/Modal/Modal.test.js +0 -52
  105. package/src/components/Modal/Wrapper.js +0 -32
  106. package/src/components/Modal/Wrapper.test.js +0 -55
  107. package/src/components/Modal/index.js +0 -22
  108. package/src/components/MultiSelector.js +0 -104
  109. package/src/components/MultiSelector.test.js +0 -348
  110. package/src/components/Navigation/Bar.js +0 -212
  111. package/src/components/Navigation/Bar.test.js +0 -552
  112. package/src/components/Navigation/Tab.js +0 -156
  113. package/src/components/Navigation/Tab.test.js +0 -404
  114. package/src/components/Placeholder.js +0 -61
  115. package/src/components/Placeholder.test.js +0 -106
  116. package/src/components/Scope/Selector.js +0 -70
  117. package/src/components/Scope/Selector.test.js +0 -138
  118. package/src/components/Selector.js +0 -191
  119. package/src/components/Selector.test.js +0 -157
  120. package/src/components/Switch.js +0 -112
  121. package/src/components/Switch.test.js +0 -130
  122. package/src/components/Text.test.js +0 -132
  123. package/src/components/Toolbar.js +0 -178
  124. package/src/components/Toolbar.test.js +0 -478
  125. package/src/components/Tooltip.js +0 -51
  126. package/src/components/Tooltip.test.js +0 -21
  127. package/src/getTheme.js +0 -98
  128. package/src/getTheme.test.js +0 -92
  129. package/src/getThemeOverrides.js +0 -27
  130. package/src/hocs/withAuthentication.js +0 -18
  131. package/src/hocs/withAuthentication.test.js +0 -120
  132. package/src/utils/styledPropFuncs.js +0 -20
  133. package/src/utils/styledPropFuncs.test.js +0 -166
@@ -1,212 +0,0 @@
1
- import React, { useRef, useEffect, useState, useCallback } from "react";
2
- import styled from "styled-components";
3
- import { useHistory } from "react-router-dom";
4
- import { ifFlag, getThemeProp, safeGet } from "../../utils";
5
- import DropMenu from "../DropMenu";
6
- import IconButton from "../IconButton";
7
- import Tab from "./Tab";
8
-
9
- export const TabBar = styled.div`
10
- flex: 0 0 10px;
11
- max-height: 0px;
12
- padding: 0 0 0 10px;
13
- margin: 0 200px 0 0;
14
- display: flex;
15
- align-items: flex-end;
16
- width: calc(100% - 210px);
17
- font-family: ${getThemeProp(["fonts", "header"], "sans-serif")};
18
- font-size: 13px;
19
- text-transform: uppercase;
20
- `;
21
-
22
- export const InnerBar = styled.div`
23
- position: relative;
24
- flex: 0 1 100%;
25
- margin-left: -10px;
26
- padding-left: 10px;
27
- z-index: 0;
28
- overflow: hidden;
29
- min-width: 0;
30
- box-sizing: border-box;
31
- height: 50px;
32
- display: flex;
33
- align-items: flex-end;
34
- scroll-behavior: smooth;
35
- `;
36
-
37
- const Fade = styled.div`
38
- position: absolute;
39
- left: 0;
40
- bottom: 11px;
41
- height: 38px;
42
- width: 10px;
43
- z-index: 1;
44
- background-color: red;
45
- box-shadow: 0px 0 5px 5px #fff;
46
- clip-path: polygon(-10px 0, -10px 100%, 30px 100%, 30px 0);
47
- visibility: ${ifFlag("scroll", "visible", "hidden")};
48
- `;
49
-
50
- export const ScrollableBar = React.forwardRef(({ children }, ref) => {
51
- return (
52
- <>
53
- <Fade scroll={0} />
54
- <InnerBar id="navigationPageTabs" ref={ref}>
55
- {children}
56
- </InnerBar>
57
- </>
58
- );
59
- });
60
-
61
- const getTabEdges = (pages, tabRefs) => {
62
- let lastWidth = 0;
63
- return pages.map(({ href }) => {
64
- const tabWidth = safeGet(tabRefs, href, "offsetWidth") || 0;
65
- lastWidth += tabWidth;
66
- return lastWidth;
67
- });
68
- };
69
-
70
- export const useTabScroll = (pages, debug = false, refs) => {
71
- let barRef = useRef(null);
72
- let tabRefs = useRef({});
73
- if (debug) {
74
- barRef = refs.barRef;
75
- tabRefs = refs.tabRefs;
76
- }
77
- const [barWidth, setBarWidth] = useState(0);
78
- const [tabEdges, setTabEdges] = useState([]);
79
- const setWidthOfBar = useCallback(() => {
80
- setBarWidth(safeGet(barRef, "current", "offsetWidth") || 0);
81
- }, [barRef, setBarWidth]);
82
- const setEdgesOfTabs = useCallback(() => {
83
- setTabEdges(getTabEdges(pages, tabRefs.current));
84
- }, [pages, tabRefs, setTabEdges]);
85
- useEffect(() => {
86
- setWidthOfBar();
87
- window.addEventListener("resize", setWidthOfBar);
88
- return () => window.removeEventListener("resize", setWidthOfBar);
89
- }, [pages, setWidthOfBar]);
90
- useEffect(() => {
91
- setEdgesOfTabs(pages);
92
- window.addEventListener("resize", setEdgesOfTabs);
93
- return () => window.removeEventListener("resize", setEdgesOfTabs);
94
- }, [pages, setEdgesOfTabs]);
95
-
96
- const lastActiveIndex = useRef(-1);
97
- let activeIndex = pages.findIndex(page => page.active);
98
- if (activeIndex === -1) {
99
- activeIndex = lastActiveIndex.current;
100
- } else {
101
- lastActiveIndex.current = activeIndex;
102
- }
103
- const [lastShownTab, setLastShown] = useState(pages.length);
104
- useEffect(() => {
105
- const barElem = barRef.current;
106
- /* istanbul ignore if */
107
- if (!barElem) return;
108
- const activeEdge = tabEdges[activeIndex + 1] || tabEdges[activeIndex] || 0;
109
- let scrollEdge = Math.max(activeEdge - barWidth + 7, 0);
110
- barElem.scrollLeft = scrollEdge;
111
- const edgeIndex = tabEdges.findIndex(edge => edge > barWidth + barElem.scrollLeft - 10) - 1;
112
- if (tabEdges[tabEdges.length - 1] <= barWidth) {
113
- setLastShown(pages.length);
114
- } else if (edgeIndex > activeIndex) {
115
- setLastShown(edgeIndex);
116
- } else {
117
- setLastShown(activeIndex + 1);
118
- }
119
- }, [setLastShown, pages, barRef, barWidth, tabEdges, activeIndex]);
120
- const history = useHistory();
121
- return {
122
- ...(debug ? { barWidth, tabEdges } : {}),
123
- hiddenTabs: barWidth < tabEdges[tabEdges.length - 1],
124
- lastShownTab,
125
- tabMenuItems: pages.map(({ label, href }) => ({
126
- id: href,
127
- label,
128
- handler: () => {
129
- history.push(href);
130
- },
131
- })),
132
- getTabRef: useCallback(
133
- node => {
134
- /* istanbul ignore else */
135
- if (node) {
136
- const href = safeGet(node, "dataset", "href");
137
- tabRefs.current[href] = node;
138
- }
139
- },
140
- [tabRefs],
141
- ),
142
- getBarRef: useCallback(
143
- node => {
144
- /* istanbul ignore else */
145
- if (node && node !== barRef.current) {
146
- barRef.current = node;
147
- }
148
- },
149
- [barRef],
150
- ),
151
- };
152
- };
153
-
154
- export const StyledMenu = styled(DropMenu).attrs(() => ({ alignRight: true }))`
155
- position: absolute;
156
- top: 10px;
157
- right: 140px;
158
- text-transform: none;
159
- `;
160
-
161
- export const MenuButton = styled(IconButton).attrs(props => ({
162
- icon: ifFlag(
163
- "open",
164
- getThemeProp(["icons", "indicators", "more"], "arrow-more"),
165
- getThemeProp(["icons", "indicators", "more"], "arrow-more"),
166
- )(props),
167
- }))``;
168
-
169
- const Bar = ({ module, pages }) => {
170
- const { hiddenTabs, tabMenuItems, lastShownTab, getTabRef, getBarRef } = useTabScroll(pages);
171
- return (
172
- <TabBar>
173
- <Tab
174
- module
175
- icon={module.icon}
176
- href={module.href}
177
- mappedFrom={module.mappedFrom}
178
- label={module.label}
179
- active={module.active}
180
- />
181
- <ScrollableBar ref={getBarRef}>
182
- {pages.map(
183
- ({ href, mappedFrom, label, mustTruncate, active, icon, outsideScope, scopeNotSupported, close }, index) => {
184
- return (
185
- <Tab
186
- ref={getTabRef}
187
- key={href}
188
- icon={icon}
189
- href={href}
190
- mappedFrom={mappedFrom}
191
- label={label}
192
- mustTruncate={mustTruncate}
193
- active={active}
194
- close={close}
195
- outsideScope={outsideScope}
196
- scopeNotSupported={scopeNotSupported}
197
- hide={index > lastShownTab}
198
- />
199
- );
200
- },
201
- )}
202
- </ScrollableBar>
203
- {hiddenTabs ? (
204
- <StyledMenu id="navigationTabs" menuItems={tabMenuItems}>
205
- <MenuButton />
206
- </StyledMenu>
207
- ) : null}
208
- </TabBar>
209
- );
210
- };
211
-
212
- export default Bar;