@elliemae/ds-global-header 2.3.0-alpha.8 → 2.3.0-next.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 (182) hide show
  1. package/cjs/GlobalHeader.js +37 -0
  2. package/cjs/GlobalHeaderContainer.js +24 -0
  3. package/cjs/GlobalHeaderContext.js +20 -0
  4. package/cjs/GlobalHeaderTypes.js +2 -0
  5. package/cjs/components/Breadcrumb/GlobalHeaderBreadcrumb.js +85 -0
  6. package/cjs/components/Breadcrumb/PureBreadcrumb.js +60 -0
  7. package/cjs/components/Breadcrumb/styles.js +59 -0
  8. package/cjs/components/Title/GlobalHeaderTitle.js +29 -0
  9. package/cjs/components/Toolbar/GlobalHeaderToolbar.js +30 -0
  10. package/cjs/components/Toolbar/ToolbarItems.js +107 -0
  11. package/cjs/components/Toolbar/styles.js +25 -0
  12. package/cjs/config/useGetPropsWithDefaults.js +31 -0
  13. package/cjs/config/useGlobalHeader.js +39 -0
  14. package/cjs/config/useValidateProps.js +92 -0
  15. package/cjs/config/validateHelpers.js +57 -0
  16. package/cjs/defaultProps.js +14 -0
  17. package/cjs/index.js +11 -0
  18. package/cjs/outOfTheBox/AppPicker/AppPicker.js +117 -0
  19. package/cjs/outOfTheBox/PopupMenu/PopupMenu.js +101 -0
  20. package/cjs/outOfTheBox/PopupMenu/PopupMenuContent.js +96 -0
  21. package/cjs/outOfTheBox/PopupMenu/styles.js +32 -0
  22. package/cjs/outOfTheBox/SearchToggle/SearchToggle.js +113 -0
  23. package/cjs/outOfTheBox/SearchToggle/styles.js +15 -0
  24. package/cjs/outOfTheBox/index.js +13 -0
  25. package/cjs/propTypes.js +29 -0
  26. package/cjs/styles.js +21 -0
  27. package/esm/GlobalHeader.js +28 -0
  28. package/esm/GlobalHeaderContainer.js +16 -0
  29. package/esm/GlobalHeaderContext.js +16 -0
  30. package/esm/GlobalHeaderTypes.js +1 -0
  31. package/esm/components/Breadcrumb/GlobalHeaderBreadcrumb.js +75 -0
  32. package/esm/components/Breadcrumb/PureBreadcrumb.js +49 -0
  33. package/esm/components/Breadcrumb/styles.js +48 -0
  34. package/esm/components/Title/GlobalHeaderTitle.js +21 -0
  35. package/esm/components/Toolbar/GlobalHeaderToolbar.js +22 -0
  36. package/esm/components/Toolbar/ToolbarItems.js +97 -0
  37. package/esm/components/Toolbar/styles.js +17 -0
  38. package/esm/config/useGetPropsWithDefaults.js +23 -0
  39. package/esm/config/useGlobalHeader.js +31 -0
  40. package/esm/config/useValidateProps.js +88 -0
  41. package/esm/config/validateHelpers.js +44 -0
  42. package/{dist/esm → esm}/defaultProps.js +3 -5
  43. package/esm/index.js +1 -0
  44. package/esm/outOfTheBox/AppPicker/AppPicker.js +107 -0
  45. package/esm/outOfTheBox/PopupMenu/PopupMenu.js +91 -0
  46. package/esm/outOfTheBox/PopupMenu/PopupMenuContent.js +86 -0
  47. package/esm/outOfTheBox/PopupMenu/styles.js +21 -0
  48. package/esm/outOfTheBox/SearchToggle/SearchToggle.js +103 -0
  49. package/esm/outOfTheBox/SearchToggle/styles.js +7 -0
  50. package/esm/outOfTheBox/index.js +3 -0
  51. package/esm/propTypes.js +23 -0
  52. package/esm/styles.js +13 -0
  53. package/package.json +72 -76
  54. package/types/GlobalHeader.d.ts +39 -0
  55. package/types/GlobalHeaderContainer.d.ts +3 -0
  56. package/types/GlobalHeaderContext.d.ts +3 -0
  57. package/types/GlobalHeaderTypes.d.ts +85 -0
  58. package/types/components/Breadcrumb/GlobalHeaderBreadcrumb.d.ts +2 -0
  59. package/types/components/Breadcrumb/PureBreadcrumb.d.ts +3 -0
  60. package/types/components/Breadcrumb/styles.d.ts +5 -0
  61. package/types/components/Title/GlobalHeaderTitle.d.ts +2 -0
  62. package/types/components/Toolbar/GlobalHeaderToolbar.d.ts +2 -0
  63. package/types/components/Toolbar/ToolbarItems.d.ts +2 -0
  64. package/types/components/Toolbar/styles.d.ts +1 -0
  65. package/types/config/useGetPropsWithDefaults.d.ts +2 -0
  66. package/types/config/useGlobalHeader.d.ts +2 -0
  67. package/types/config/useValidateProps.d.ts +2 -0
  68. package/types/config/validateHelpers.d.ts +27 -0
  69. package/types/defaultProps.d.ts +2 -0
  70. package/types/index.d.ts +2 -0
  71. package/types/outOfTheBox/AppPicker/AppPicker.d.ts +8 -0
  72. package/types/outOfTheBox/PopupMenu/PopupMenu.d.ts +3 -0
  73. package/types/outOfTheBox/PopupMenu/PopupMenuContent.d.ts +3 -0
  74. package/types/outOfTheBox/PopupMenu/styles.d.ts +4 -0
  75. package/types/outOfTheBox/SearchToggle/SearchToggle.d.ts +2 -0
  76. package/types/outOfTheBox/SearchToggle/styles.d.ts +1 -0
  77. package/types/outOfTheBox/index.d.ts +3 -0
  78. package/types/propTypes.d.ts +29 -0
  79. package/types/styles.d.ts +2 -0
  80. package/dist/cjs/GlobalHeader.js +0 -57
  81. package/dist/cjs/GlobalHeader.js.map +0 -7
  82. package/dist/cjs/GlobalHeaderContainer.js +0 -41
  83. package/dist/cjs/GlobalHeaderContainer.js.map +0 -7
  84. package/dist/cjs/GlobalHeaderContext.js +0 -46
  85. package/dist/cjs/GlobalHeaderContext.js.map +0 -7
  86. package/dist/cjs/GlobalHeaderTypes.js +0 -27
  87. package/dist/cjs/GlobalHeaderTypes.js.map +0 -7
  88. package/dist/cjs/components/Breadcrumb/GlobalHeaderBreadcrumb.js +0 -85
  89. package/dist/cjs/components/Breadcrumb/GlobalHeaderBreadcrumb.js.map +0 -7
  90. package/dist/cjs/components/Breadcrumb/PureBreadcrumb.js +0 -51
  91. package/dist/cjs/components/Breadcrumb/PureBreadcrumb.js.map +0 -7
  92. package/dist/cjs/components/Breadcrumb/styles.js +0 -83
  93. package/dist/cjs/components/Breadcrumb/styles.js.map +0 -7
  94. package/dist/cjs/components/Title/GlobalHeaderTitle.js +0 -48
  95. package/dist/cjs/components/Title/GlobalHeaderTitle.js.map +0 -7
  96. package/dist/cjs/components/Toolbar/GlobalHeaderToolbar.js +0 -49
  97. package/dist/cjs/components/Toolbar/GlobalHeaderToolbar.js.map +0 -7
  98. package/dist/cjs/components/Toolbar/ToolbarItems.js +0 -96
  99. package/dist/cjs/components/Toolbar/ToolbarItems.js.map +0 -7
  100. package/dist/cjs/components/Toolbar/styles.js +0 -61
  101. package/dist/cjs/components/Toolbar/styles.js.map +0 -7
  102. package/dist/cjs/config/useGetPropsWithDefaults.js +0 -43
  103. package/dist/cjs/config/useGetPropsWithDefaults.js.map +0 -7
  104. package/dist/cjs/config/useGlobalHeader.js +0 -53
  105. package/dist/cjs/config/useGlobalHeader.js.map +0 -7
  106. package/dist/cjs/config/useValidateProps.js +0 -109
  107. package/dist/cjs/config/useValidateProps.js.map +0 -7
  108. package/dist/cjs/config/validateHelpers.js +0 -111
  109. package/dist/cjs/config/validateHelpers.js.map +0 -7
  110. package/dist/cjs/defaultProps.js +0 -41
  111. package/dist/cjs/defaultProps.js.map +0 -7
  112. package/dist/cjs/index.js +0 -36
  113. package/dist/cjs/index.js.map +0 -7
  114. package/dist/cjs/outOfTheBox/AppPicker/AppPicker.js +0 -110
  115. package/dist/cjs/outOfTheBox/AppPicker/AppPicker.js.map +0 -7
  116. package/dist/cjs/outOfTheBox/PopupMenu/PopupMenu.js +0 -96
  117. package/dist/cjs/outOfTheBox/PopupMenu/PopupMenu.js.map +0 -7
  118. package/dist/cjs/outOfTheBox/PopupMenu/PopupMenuContent.js +0 -89
  119. package/dist/cjs/outOfTheBox/PopupMenu/PopupMenuContent.js.map +0 -7
  120. package/dist/cjs/outOfTheBox/PopupMenu/styles.js +0 -67
  121. package/dist/cjs/outOfTheBox/PopupMenu/styles.js.map +0 -7
  122. package/dist/cjs/outOfTheBox/SearchToggle/SearchToggle.js +0 -108
  123. package/dist/cjs/outOfTheBox/SearchToggle/SearchToggle.js.map +0 -7
  124. package/dist/cjs/outOfTheBox/SearchToggle/styles.js +0 -82
  125. package/dist/cjs/outOfTheBox/SearchToggle/styles.js.map +0 -7
  126. package/dist/cjs/outOfTheBox/index.js +0 -30
  127. package/dist/cjs/outOfTheBox/index.js.map +0 -7
  128. package/dist/cjs/propTypes.js +0 -56
  129. package/dist/cjs/propTypes.js.map +0 -7
  130. package/dist/cjs/styles.js +0 -43
  131. package/dist/cjs/styles.js.map +0 -7
  132. package/dist/esm/GlobalHeader.js +0 -28
  133. package/dist/esm/GlobalHeader.js.map +0 -7
  134. package/dist/esm/GlobalHeaderContainer.js +0 -12
  135. package/dist/esm/GlobalHeaderContainer.js.map +0 -7
  136. package/dist/esm/GlobalHeaderContext.js +0 -17
  137. package/dist/esm/GlobalHeaderContext.js.map +0 -7
  138. package/dist/esm/GlobalHeaderTypes.js +0 -2
  139. package/dist/esm/GlobalHeaderTypes.js.map +0 -7
  140. package/dist/esm/components/Breadcrumb/GlobalHeaderBreadcrumb.js +0 -56
  141. package/dist/esm/components/Breadcrumb/GlobalHeaderBreadcrumb.js.map +0 -7
  142. package/dist/esm/components/Breadcrumb/PureBreadcrumb.js +0 -22
  143. package/dist/esm/components/Breadcrumb/PureBreadcrumb.js.map +0 -7
  144. package/dist/esm/components/Breadcrumb/styles.js +0 -54
  145. package/dist/esm/components/Breadcrumb/styles.js.map +0 -7
  146. package/dist/esm/components/Title/GlobalHeaderTitle.js +0 -19
  147. package/dist/esm/components/Title/GlobalHeaderTitle.js.map +0 -7
  148. package/dist/esm/components/Toolbar/GlobalHeaderToolbar.js +0 -20
  149. package/dist/esm/components/Toolbar/GlobalHeaderToolbar.js.map +0 -7
  150. package/dist/esm/components/Toolbar/ToolbarItems.js +0 -67
  151. package/dist/esm/components/Toolbar/ToolbarItems.js.map +0 -7
  152. package/dist/esm/components/Toolbar/styles.js +0 -32
  153. package/dist/esm/components/Toolbar/styles.js.map +0 -7
  154. package/dist/esm/config/useGetPropsWithDefaults.js +0 -14
  155. package/dist/esm/config/useGetPropsWithDefaults.js.map +0 -7
  156. package/dist/esm/config/useGlobalHeader.js +0 -24
  157. package/dist/esm/config/useGlobalHeader.js.map +0 -7
  158. package/dist/esm/config/useValidateProps.js +0 -88
  159. package/dist/esm/config/useValidateProps.js.map +0 -7
  160. package/dist/esm/config/validateHelpers.js +0 -82
  161. package/dist/esm/config/validateHelpers.js.map +0 -7
  162. package/dist/esm/defaultProps.js.map +0 -7
  163. package/dist/esm/index.js +0 -7
  164. package/dist/esm/index.js.map +0 -7
  165. package/dist/esm/outOfTheBox/AppPicker/AppPicker.js +0 -81
  166. package/dist/esm/outOfTheBox/AppPicker/AppPicker.js.map +0 -7
  167. package/dist/esm/outOfTheBox/PopupMenu/PopupMenu.js +0 -67
  168. package/dist/esm/outOfTheBox/PopupMenu/PopupMenu.js.map +0 -7
  169. package/dist/esm/outOfTheBox/PopupMenu/PopupMenuContent.js +0 -60
  170. package/dist/esm/outOfTheBox/PopupMenu/PopupMenuContent.js.map +0 -7
  171. package/dist/esm/outOfTheBox/PopupMenu/styles.js +0 -38
  172. package/dist/esm/outOfTheBox/PopupMenu/styles.js.map +0 -7
  173. package/dist/esm/outOfTheBox/SearchToggle/SearchToggle.js +0 -79
  174. package/dist/esm/outOfTheBox/SearchToggle/SearchToggle.js.map +0 -7
  175. package/dist/esm/outOfTheBox/SearchToggle/styles.js +0 -53
  176. package/dist/esm/outOfTheBox/SearchToggle/styles.js.map +0 -7
  177. package/dist/esm/outOfTheBox/index.js +0 -5
  178. package/dist/esm/outOfTheBox/index.js.map +0 -7
  179. package/dist/esm/propTypes.js +0 -27
  180. package/dist/esm/propTypes.js.map +0 -7
  181. package/dist/esm/styles.js +0 -14
  182. package/dist/esm/styles.js.map +0 -7
@@ -0,0 +1,16 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+ import { Wrapper } from './styles.js';
4
+
5
+ const GlobalHeaderContainer = _ref => {
6
+ let {
7
+ children
8
+ } = _ref;
9
+ return /*#__PURE__*/_jsx("header", {
10
+ "data-testid": "ds-global-header"
11
+ }, void 0, /*#__PURE__*/_jsx(Wrapper, {
12
+ cols: ['auto', '1fr', 'auto']
13
+ }, void 0, children));
14
+ };
15
+
16
+ export { GlobalHeaderContainer };
@@ -0,0 +1,16 @@
1
+ import { createContext } from 'react';
2
+ import { defaultProps } from './defaultProps.js';
3
+
4
+ const noop = () => null;
5
+
6
+ const defaultContext = {
7
+ props: defaultProps,
8
+ showIconOnly: false,
9
+ setShowIconOnly: noop,
10
+ instanceUID: '',
11
+ globalHeaderToolbarGrid: [],
12
+ globalHeaderBreadcrumbGrid: []
13
+ };
14
+ const GlobalHeaderContext = /*#__PURE__*/createContext(defaultContext);
15
+
16
+ export { GlobalHeaderContext };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,75 @@
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
3
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
4
+ import 'core-js/modules/esnext.async-iterator.map.js';
5
+ import 'core-js/modules/esnext.iterator.map.js';
6
+ import 'core-js/modules/esnext.async-iterator.filter.js';
7
+ import 'core-js/modules/esnext.iterator.constructor.js';
8
+ import 'core-js/modules/esnext.iterator.filter.js';
9
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
10
+ import 'core-js/modules/esnext.iterator.for-each.js';
11
+ import { useContext, useRef, useEffect } from 'react';
12
+ import { Grid } from '@elliemae/ds-grid';
13
+ import { Pipe } from './styles.js';
14
+ import { GlobalHeaderContext } from '../../GlobalHeaderContext.js';
15
+ import { PureBreadcrumb } from './PureBreadcrumb.js';
16
+ import { jsx } from 'react/jsx-runtime';
17
+
18
+ const _excluded = ["label"];
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+ const GlobalHeaderBreadcrumb = () => {
24
+ const {
25
+ props: {
26
+ breadcrumb
27
+ },
28
+ instanceUID,
29
+ showIconOnly,
30
+ setShowIconOnly,
31
+ globalHeaderBreadcrumbGrid
32
+ } = useContext(GlobalHeaderContext);
33
+ const breakpoint = useRef(null);
34
+ const flexRegion = useRef(null);
35
+ useEffect(() => {
36
+ const evaluateShowIconOnly = () => {
37
+ if (flexRegion && flexRegion.current && (flexRegion === null || flexRegion === void 0 ? void 0 : flexRegion.current.offsetWidth) <= 0 && !breakpoint.current) {
38
+ setShowIconOnly(true);
39
+ breakpoint.current = window.innerWidth;
40
+ } else if (breakpoint && breakpoint.current !== null && window.innerWidth >= breakpoint.current) {
41
+ setShowIconOnly(false);
42
+ breakpoint.current = null;
43
+ }
44
+ };
45
+
46
+ evaluateShowIconOnly();
47
+ window.addEventListener('resize', evaluateShowIconOnly);
48
+ return () => window.removeEventListener('resize', evaluateShowIconOnly);
49
+ }, [breakpoint, flexRegion, setShowIconOnly]);
50
+ return /*#__PURE__*/_jsx(Grid, {
51
+ height: "100%",
52
+ alignItems: "center",
53
+ justifyContent: "flex-start",
54
+ "aria-label": "breadcrumbs",
55
+ cols: globalHeaderBreadcrumbGrid,
56
+ role: "navigation"
57
+ }, void 0, /*#__PURE__*/_jsx(Pipe, {
58
+ showIconOnly: showIconOnly
59
+ }), breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.map(item => {
60
+ const {
61
+ label
62
+ } = item,
63
+ rest = _objectWithoutProperties(item, _excluded);
64
+
65
+ return /*#__PURE__*/jsx(PureBreadcrumb, _objectSpread({
66
+ label: label,
67
+ length: breadcrumb.length
68
+ }, rest), "".concat(instanceUID, "-breadcrumb-item-").concat(label));
69
+ }), /*#__PURE__*/jsx("div", {
70
+ id: "global-header-flex-region",
71
+ ref: flexRegion
72
+ }));
73
+ };
74
+
75
+ export { GlobalHeaderBreadcrumb };
@@ -0,0 +1,49 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
8
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
9
+ import React from 'react';
10
+ import { ChevronSmallRight } from '@elliemae/ds-icons';
11
+ import { getDataProps } from '@elliemae/ds-props-helpers';
12
+ import { BreadcrumbItem, LabelButton, Label } from './styles.js';
13
+ import { jsx } from 'react/jsx-runtime';
14
+
15
+ var _ChevronSmallRight;
16
+
17
+ const _excluded = ["onClick", "isSelected", "length", "label", "hasNext", "id"];
18
+
19
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
+
21
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
22
+ const PureBreadcrumb = /*#__PURE__*/React.memo(_ref => {
23
+ let {
24
+ onClick,
25
+ isSelected,
26
+ length,
27
+ label,
28
+ hasNext,
29
+ id
30
+ } = _ref,
31
+ rest = _objectWithoutProperties(_ref, _excluded);
32
+
33
+ return /*#__PURE__*/_jsx(BreadcrumbItem, {}, void 0, /*#__PURE__*/jsx(LabelButton, _objectSpread(_objectSpread({
34
+ onClick: onClick,
35
+ "aria-selected": isSelected,
36
+ "data-testid": "gh-breadcrumb-btn",
37
+ id: id
38
+ }, getDataProps(rest)), {}, {
39
+ children: /*#__PURE__*/_jsx(Label, {
40
+ isSelected: !!isSelected,
41
+ isOnlyItem: length === 1
42
+ }, void 0, label)
43
+ })), hasNext && (_ChevronSmallRight || (_ChevronSmallRight = /*#__PURE__*/_jsx(ChevronSmallRight, {
44
+ size: "m",
45
+ fill: "#FFF"
46
+ }))));
47
+ });
48
+
49
+ export { PureBreadcrumb };
@@ -0,0 +1,48 @@
1
+ import styled from 'styled-components';
2
+
3
+ const Pipe = /*#__PURE__*/styled.span.withConfig({
4
+ componentId: "sc-1n5l527-0"
5
+ })(["margin:0 7px 0 0;border-left:", ";height:20px;"], _ref => {
6
+ let {
7
+ showIconOnly
8
+ } = _ref;
9
+ return showIconOnly ? 'none' : '1px solid #fff';
10
+ });
11
+ const BreadcrumbItem = /*#__PURE__*/styled.div.withConfig({
12
+ componentId: "sc-1n5l527-1"
13
+ })(["display:flex;align-items:center;height:100%;"]);
14
+ const LabelButton = /*#__PURE__*/styled.button.withConfig({
15
+ componentId: "sc-1n5l527-2"
16
+ })(["width:fit-content;height:100%;margin:0;padding:0;border:1px solid transparent;background-color:transparent;outline:none;cursor:pointer;position:relative;&:focus{:before{content:'';position:absolute;z-index:2;top:2px;left:-5px;width:calc(100% + 10px);height:calc(100% - 4px);border:2px solid ", ";border-radius:4px;}}"], _ref2 => {
17
+ let {
18
+ theme
19
+ } = _ref2;
20
+ return theme.colors.neutral['000'];
21
+ });
22
+ const Label = /*#__PURE__*/styled.p.withConfig({
23
+ componentId: "sc-1n5l527-3"
24
+ })(["color:", ";", ";font-size:16px;text-transform:uppercase;border-bottom:", ";margin:3px 5px 0 5px;:hover{", ";}"], _ref3 => {
25
+ let {
26
+ theme
27
+ } = _ref3;
28
+ return theme.colors.neutral['000'];
29
+ }, _ref4 => {
30
+ let {
31
+ theme,
32
+ isSelected
33
+ } = _ref4;
34
+ return "-webkit-text-stroke: 0.4px ".concat(isSelected ? theme.colors.neutral['000'] : 'transparent');
35
+ }, _ref5 => {
36
+ let {
37
+ isSelected,
38
+ isOnlyItem
39
+ } = _ref5;
40
+ return "2px solid ".concat(isSelected && !isOnlyItem ? '#FFF' : 'transparent');
41
+ }, _ref6 => {
42
+ let {
43
+ theme
44
+ } = _ref6;
45
+ return "-webkit-text-stroke: 0.4px ".concat(theme.colors.neutral['000']);
46
+ });
47
+
48
+ export { BreadcrumbItem, Label, LabelButton, Pipe };
@@ -0,0 +1,21 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { useContext } from 'react';
3
+ import { Grid } from '@elliemae/ds-grid';
4
+ import { GlobalHeaderContext } from '../../GlobalHeaderContext.js';
5
+
6
+ const GlobalHeaderTitle = () => {
7
+ const {
8
+ props: {
9
+ Logo,
10
+ LogoWithBrand
11
+ },
12
+ showIconOnly
13
+ } = useContext(GlobalHeaderContext);
14
+ return /*#__PURE__*/_jsx(Grid, {
15
+ alignItems: "center",
16
+ pr: showIconOnly ? '0px' : '36px',
17
+ cols: showIconOnly ? ['auto'] : ['auto', '1fr']
18
+ }, void 0, Logo && showIconOnly && /*#__PURE__*/_jsx(Logo, {}), LogoWithBrand && !showIconOnly && /*#__PURE__*/_jsx(LogoWithBrand, {}));
19
+ };
20
+
21
+ export { GlobalHeaderTitle };
@@ -0,0 +1,22 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { useContext } from 'react';
3
+ import { Grid } from '@elliemae/ds-grid';
4
+ import { ToolbarItems } from './ToolbarItems.js';
5
+ import { GlobalHeaderContext } from '../../GlobalHeaderContext.js';
6
+
7
+ var _ToolbarItems;
8
+ const GlobalHeaderToolbar = () => {
9
+ const {
10
+ globalHeaderToolbarGrid
11
+ } = useContext(GlobalHeaderContext);
12
+ return /*#__PURE__*/_jsx(Grid, {
13
+ height: "100%",
14
+ alignItems: "center",
15
+ justifyContent: "center",
16
+ gutter: "xxs",
17
+ cols: globalHeaderToolbarGrid,
18
+ role: "toolbar"
19
+ }, void 0, _ToolbarItems || (_ToolbarItems = /*#__PURE__*/_jsx(ToolbarItems, {})));
20
+ };
21
+
22
+ export { GlobalHeaderToolbar };
@@ -0,0 +1,97 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
4
+ import 'core-js/modules/esnext.async-iterator.map.js';
5
+ import 'core-js/modules/esnext.iterator.map.js';
6
+ import 'core-js/modules/esnext.async-iterator.filter.js';
7
+ import 'core-js/modules/esnext.iterator.constructor.js';
8
+ import 'core-js/modules/esnext.iterator.filter.js';
9
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
10
+ import 'core-js/modules/esnext.iterator.for-each.js';
11
+ import { useContext, useMemo } from 'react';
12
+ import { AppPicker } from '../../outOfTheBox/AppPicker/AppPicker.js';
13
+ import { PopupMenu } from '../../outOfTheBox/PopupMenu/PopupMenu.js';
14
+ import { SearchToggle } from '../../outOfTheBox/SearchToggle/SearchToggle.js';
15
+ import { Button } from './styles.js';
16
+ import { GlobalHeaderContext } from '../../GlobalHeaderContext.js';
17
+ import { getDataProps } from '@elliemae/ds-props-helpers';
18
+ import { jsx, Fragment } from 'react/jsx-runtime';
19
+
20
+ const _excluded = ["Icon", "type", "onClick", "componentProps", "label", "onKeyPress", "id", "CustomComponent"];
21
+
22
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
+
24
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
+ const ToolbarItems = () => {
26
+ const {
27
+ props: {
28
+ toolbar
29
+ },
30
+ instanceUID
31
+ } = useContext(GlobalHeaderContext);
32
+ const itemsList = useMemo(() => toolbar === null || toolbar === void 0 ? void 0 : toolbar.map(item => {
33
+ var _Icon;
34
+
35
+ const {
36
+ Icon,
37
+ type,
38
+ onClick,
39
+ componentProps,
40
+ label,
41
+ onKeyPress,
42
+ id,
43
+ CustomComponent
44
+ } = item,
45
+ otherProps = _objectWithoutProperties(item, _excluded);
46
+
47
+ switch (type) {
48
+ case 'ds-popup-menu':
49
+ return /*#__PURE__*/jsx(PopupMenu, _objectSpread(_objectSpread({
50
+ title: label,
51
+ Icon: Icon,
52
+ onClick: onClick,
53
+ onKeyPress: onKeyPress,
54
+ id: id
55
+ }, otherProps), {}, {
56
+ componentProps: componentProps
57
+ }), "".concat(instanceUID, "-ds-popup-menu-").concat(label));
58
+
59
+ case 'ds-app-picker':
60
+ return /*#__PURE__*/jsx(AppPicker, _objectSpread({
61
+ label: label,
62
+ id: id,
63
+ componentProps: componentProps
64
+ }, otherProps), "".concat(instanceUID, "-ds-app-picker-").concat(label));
65
+
66
+ case 'ds-search-toggle':
67
+ return /*#__PURE__*/jsx(SearchToggle, _objectSpread({
68
+ id: id,
69
+ componentProps: componentProps
70
+ }, otherProps), "".concat(instanceUID, "-ds-search-toggle-").concat(id));
71
+
72
+ case 'custom':
73
+ if (CustomComponent) return /*#__PURE__*/_jsx(CustomComponent, {
74
+ item: item
75
+ });
76
+ return null;
77
+
78
+ default:
79
+ return /*#__PURE__*/jsx(Button, _objectSpread(_objectSpread({
80
+ onClick: onClick,
81
+ title: label,
82
+ "data-testid": "gh-toolbar-item",
83
+ id: id
84
+ }, getDataProps(otherProps)), {}, {
85
+ children: _Icon || (_Icon = /*#__PURE__*/_jsx(Icon, {
86
+ fill: "#FFF",
87
+ size: "m"
88
+ }))
89
+ }), "".concat(instanceUID, "-ds-toolbar-button-").concat(label));
90
+ }
91
+ }), [toolbar, instanceUID]);
92
+ return /*#__PURE__*/jsx(Fragment, {
93
+ children: itemsList
94
+ });
95
+ };
96
+
97
+ export { ToolbarItems };
@@ -0,0 +1,17 @@
1
+ import styled from 'styled-components';
2
+
3
+ const Button = /*#__PURE__*/styled.button.withConfig({
4
+ componentId: "sc-1gqj0i3-0"
5
+ })(["height:40px;width:40px;border:none;background-color:transparent;cursor:pointer;position:relative;outline:none;&:hover:not(:focus){background-color:", ";outline:none;}&:focus{:before{content:'';position:absolute;z-index:2;top:2px;left:2px;width:calc(100% - 4px);height:calc(100% - 4px);border:2px solid ", ";border-radius:4px;}}"], _ref => {
6
+ let {
7
+ theme
8
+ } = _ref;
9
+ return theme.colors.brand[700];
10
+ }, _ref2 => {
11
+ let {
12
+ theme
13
+ } = _ref2;
14
+ return theme.colors.neutral['000'];
15
+ });
16
+
17
+ export { Button };
@@ -0,0 +1,23 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import { useMemo } from 'react';
8
+ import { defaultProps } from '../defaultProps.js';
9
+
10
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
+
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
+ const useGetPropsWithDefaults = props => {
14
+ const {
15
+ toolbar,
16
+ breadcrumb,
17
+ Logo,
18
+ LogoWithBrand
19
+ } = props;
20
+ return useMemo(() => _objectSpread(_objectSpread({}, defaultProps), props), [toolbar, breadcrumb, Logo, LogoWithBrand]);
21
+ };
22
+
23
+ export { useGetPropsWithDefaults };
@@ -0,0 +1,31 @@
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
2
+ import React, { useState, useMemo } from 'react';
3
+ import { uid } from 'uid';
4
+ import { useGetPropsWithDefaults } from './useGetPropsWithDefaults.js';
5
+
6
+ const useGlobalHeader = props => {
7
+ const [showIconOnly, setShowIconOnly] = useState(false);
8
+ const instanceUID = useMemo(() => uid(5), []);
9
+ const globalHeaderToolbarGrid = useMemo(() => {
10
+ var _props$toolbar$length, _props$toolbar;
11
+
12
+ return new Array((_props$toolbar$length = props === null || props === void 0 ? void 0 : (_props$toolbar = props.toolbar) === null || _props$toolbar === void 0 ? void 0 : _props$toolbar.length) !== null && _props$toolbar$length !== void 0 ? _props$toolbar$length : 0).fill('auto');
13
+ }, [props.toolbar]);
14
+ const globalHeaderBreadcrumbGrid = useMemo(() => {
15
+ var _props$breadcrumb$len, _props$breadcrumb;
16
+
17
+ return ['auto', ...new Array((_props$breadcrumb$len = props === null || props === void 0 ? void 0 : (_props$breadcrumb = props.breadcrumb) === null || _props$breadcrumb === void 0 ? void 0 : _props$breadcrumb.length) !== null && _props$breadcrumb$len !== void 0 ? _props$breadcrumb$len : 0).fill('auto'), '1fr'];
18
+ }, [props.breadcrumb]);
19
+ const propsWithDefaults = useGetPropsWithDefaults(props);
20
+ const ctx = React.useMemo(() => ({
21
+ props: propsWithDefaults,
22
+ showIconOnly,
23
+ setShowIconOnly,
24
+ instanceUID,
25
+ globalHeaderToolbarGrid,
26
+ globalHeaderBreadcrumbGrid
27
+ }), [propsWithDefaults, showIconOnly, instanceUID, globalHeaderToolbarGrid, globalHeaderBreadcrumbGrid]);
28
+ return ctx;
29
+ };
30
+
31
+ export { useGlobalHeader };
@@ -0,0 +1,88 @@
1
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.for-each.js';
4
+ import { throwLogoError, throwBreadcrumbItemError, isValidToolbarType, throwToolbarItemGenericError, isObject, throwToolbarPopupItemError, throwToolbarAppPickerItemError } from './validateHelpers.js';
5
+
6
+ const validatePopupItem = componentProps => {
7
+ if (componentProps.options && !Array.isArray(componentProps.options)) {
8
+ throwToolbarPopupItemError('options', componentProps.options);
9
+ }
10
+
11
+ if (componentProps.closeOnClick && typeof componentProps.closeOnClick !== 'boolean') {
12
+ throwToolbarPopupItemError('closeOnClick', componentProps.closeOnClick);
13
+ }
14
+ };
15
+
16
+ const validateAppPickerItem = componentProps => {
17
+ if (componentProps.apps && !Array.isArray(componentProps.apps)) {
18
+ throwToolbarAppPickerItemError('apps', componentProps.apps);
19
+ }
20
+
21
+ if (componentProps.customApps && !Array.isArray(componentProps.customApps)) {
22
+ throwToolbarAppPickerItemError('customApps', componentProps.customApps);
23
+ }
24
+
25
+ if (componentProps.sectionTitle && typeof componentProps.sectionTitle !== 'string') {
26
+ throwToolbarAppPickerItemError('sectionTitle', componentProps.sectionTitle);
27
+ }
28
+
29
+ if (componentProps.customSectionTitle && typeof componentProps.customSectionTitle !== 'string') {
30
+ throwToolbarAppPickerItemError('customSectionTitle', componentProps.customSectionTitle);
31
+ }
32
+ };
33
+
34
+ const useValidateProps = props => {
35
+ const {
36
+ breadcrumb,
37
+ toolbar,
38
+ Logo,
39
+ LogoWithBrand
40
+ } = props;
41
+
42
+ if (Logo && typeof Logo !== 'function') {
43
+ throwLogoError('Logo', Logo);
44
+ }
45
+
46
+ if (LogoWithBrand && typeof LogoWithBrand !== 'function') {
47
+ throwLogoError('LogoWithBrand', LogoWithBrand);
48
+ }
49
+
50
+ breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.forEach(breadcrumbItem => {
51
+ if (breadcrumbItem.label && typeof breadcrumbItem.label !== 'string') {
52
+ throwBreadcrumbItemError('label', breadcrumbItem.label);
53
+ }
54
+
55
+ if (breadcrumbItem.onClick && typeof breadcrumbItem.onClick !== 'function') {
56
+ throwBreadcrumbItemError('onClick', breadcrumbItem.onClick);
57
+ }
58
+
59
+ if (breadcrumbItem.hasNext && typeof breadcrumbItem.hasNext !== 'boolean') {
60
+ throwBreadcrumbItemError('hasNext', breadcrumbItem.hasNext);
61
+ }
62
+
63
+ if (breadcrumbItem.isSelected && typeof breadcrumbItem.isSelected !== 'boolean') {
64
+ throwBreadcrumbItemError('isSelected', breadcrumbItem.isSelected);
65
+ }
66
+ });
67
+ toolbar === null || toolbar === void 0 ? void 0 : toolbar.forEach(toolbarItem => {
68
+ if (toolbarItem.type) {
69
+ if (!isValidToolbarType(toolbarItem.type)) {
70
+ throwToolbarItemGenericError('type', toolbarItem.type);
71
+ }
72
+
73
+ if (toolbarItem.componentProps && !isObject(toolbarItem.componentProps)) {
74
+ throwToolbarItemGenericError('componentProps', toolbarItem.componentProps);
75
+ }
76
+
77
+ if (toolbarItem.type === 'ds-popup-menu') {
78
+ validatePopupItem(toolbarItem.componentProps);
79
+ }
80
+
81
+ if (toolbarItem.type === 'ds-app-picker') {
82
+ validateAppPickerItem(toolbarItem.componentProps);
83
+ }
84
+ }
85
+ });
86
+ };
87
+
88
+ export { useValidateProps };
@@ -0,0 +1,44 @@
1
+ const breadcrumbProps = {
2
+ label: 'string',
3
+ onClick: 'function',
4
+ hasNext: 'boolean',
5
+ isSelected: 'boolean'
6
+ };
7
+ const toolbarProps = {
8
+ label: 'string',
9
+ type: '"ds-app-picker" or "ds-popup-menu" or "ds-search-toggle"',
10
+ componentProps: 'object',
11
+ Icon: 'react component',
12
+ onClick: 'function',
13
+ options: 'array',
14
+ closeOnClick: 'boolean',
15
+ apps: 'array',
16
+ customApps: 'array',
17
+ sectionTitle: 'string',
18
+ customSectionTitle: 'string'
19
+ };
20
+ const isObject = obj => typeof obj === 'object' && !!obj && !Array.isArray(obj);
21
+ const getVariableType = arg => {
22
+ if (Array.isArray(arg)) return 'array';
23
+ if (arg === null) return 'null';
24
+ if (arg === undefined) return 'undefined';
25
+ return typeof arg;
26
+ };
27
+ const isValidToolbarType = string => string === 'ds-app-picker' || string === 'ds-popup-menu' || string === 'ds-search-toggle' || string === 'custom';
28
+ const throwBreadcrumbItemError = (validPropKey, invalidProp) => {
29
+ throw new Error("You are trying to pass a not valid \"".concat(validPropKey, "\" property for a breadcrumb item, please provide a valid type.\n\n Received: ").concat(invalidProp, " (").concat(typeof invalidProp, ")\n Expected: (").concat(breadcrumbProps[validPropKey], ")\n "));
30
+ };
31
+ const throwToolbarPopupItemError = (validPropKey, invalidProp) => {
32
+ throw new Error("You are trying to pass a not valid \"".concat(validPropKey, "\" property inside componentProps for a ds-popup-menu \n toolbar item, please provide a valid type.\n\n Received: ").concat(invalidProp, " (").concat(getVariableType(invalidProp), ")\n Expected: (").concat(toolbarProps[validPropKey], ")\n "));
33
+ };
34
+ const throwToolbarAppPickerItemError = (validPropKey, invalidProp) => {
35
+ throw new Error("You are trying to pass a not valid \"".concat(validPropKey, "\" property inside componentProps for a ds-app-picker \n toolbar item, please provide a valid type.\n\n Received: ").concat(invalidProp, " (").concat(getVariableType(invalidProp), ")\n Expected: (").concat(toolbarProps[validPropKey], ")\n "));
36
+ };
37
+ const throwToolbarItemGenericError = (validPropKey, invalidProp) => {
38
+ throw new Error("You are trying to pass a not valid \"".concat(validPropKey, "\" property for a toolbar item, please provide a valid type.\n\n Received: ").concat(invalidProp, " (").concat(getVariableType(invalidProp), ")\n Expected: (").concat(toolbarProps[validPropKey], ")\n "));
39
+ };
40
+ const throwLogoError = (validPropKey, invalidProp) => {
41
+ throw new Error("You are trying to pass a not valid \"".concat(validPropKey, "\" property for a global header, \n remember to provide both Logo and LogoWithBrand properties with a valid type.\n\n Received: ").concat(invalidProp, " (").concat(getVariableType(invalidProp), ").\n Expected: (react component).\n "));
42
+ };
43
+
44
+ export { breadcrumbProps, getVariableType, isObject, isValidToolbarType, throwBreadcrumbItemError, throwLogoError, throwToolbarAppPickerItemError, throwToolbarItemGenericError, throwToolbarPopupItemError, toolbarProps };
@@ -1,12 +1,10 @@
1
- import * as React from "react";
2
1
  const emptyComp = () => null;
2
+
3
3
  const defaultProps = {
4
4
  breadcrumb: [],
5
5
  toolbar: [],
6
6
  LogoWithBrand: emptyComp,
7
7
  Logo: emptyComp
8
8
  };
9
- export {
10
- defaultProps
11
- };
12
- //# sourceMappingURL=defaultProps.js.map
9
+
10
+ export { defaultProps };
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ export { GlobalHeader, GlobalHeaderWithSchema, GlobalHeader as default } from './GlobalHeader.js';