@nice-digital/global-nav 4.1.730-GN-169-Dropdown-open → 4.1.735-GN-169-Dropdown-open

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -436,10 +436,6 @@ var global_nav_config = {
436
436
  - Type: `String`, `Function`
437
437
  - Default: `null`
438
438
 
439
- Function parameters:
440
-
441
- - `query` (`String`) the query term used in the search
442
-
443
439
  Pass an `onDropdownClose` property to enable callback when dropdown is closed.
444
440
  Pass either a function, or the name of a function defined on `window`. E.g.:
445
441
 
@@ -165,7 +165,7 @@ function Account(props) {
165
165
  "aria-labelledby": "my-account-button",
166
166
  onKeyDown: handleKeyDown,
167
167
  ref: myAccountMenu
168
- }, accountsData.links && Object.keys(accountsData.links).map(function (text, i) {
168
+ }, doesUseIdAM && accountsData.display_name && /*#__PURE__*/_react["default"].createElement("li", null, /*#__PURE__*/_react["default"].createElement("span", null, accountsData.display_name)), accountsData.links && Object.keys(accountsData.links).map(function (text, i) {
169
169
  return /*#__PURE__*/_react["default"].createElement("li", {
170
170
  key: i,
171
171
  role: "presentation"
@@ -106,10 +106,14 @@
106
106
  margin: 0;
107
107
  }
108
108
 
109
+ span,
109
110
  a {
110
- color: $nds-colour-link;
111
111
  display: block;
112
112
  padding: rem($nds-spacing-small $nds-spacing-medium);
113
+ }
114
+
115
+ a {
116
+ color: $nds-colour-link;
113
117
  text-decoration: none;
114
118
  white-space: nowrap;
115
119
 
@@ -103,31 +103,29 @@ var Header = /*#__PURE__*/function (_Component) {
103
103
  }
104
104
  };
105
105
 
106
+ _proto.checkForFunctionOrFunctionName = function checkForFunctionOrFunctionName(funcParam) {
107
+ return typeof funcParam === "function" ? funcParam : window[funcParam];
108
+ };
109
+
106
110
  _proto.dropdownToggleHandler = function dropdownToggleHandler(idOfOpenDropdown) {
107
111
  // If we've got an onDropdownOpen or onDropdownClose prop call the onDropdownOpen or onDropdownClose callback based on idOfOpenDropdown.
108
112
  var _this$props = this.props,
109
113
  onDropdownOpen = _this$props.onDropdownOpen,
110
114
  onDropdownClose = _this$props.onDropdownClose;
111
115
 
112
- if (onDropdownOpen) {
113
- var onDropdownOpenCallback = typeof onDropdownOpen === "function" ? onDropdownOpen : window[onDropdownOpen];
114
-
115
- if (idOfOpenDropdown !== null && typeof onDropdownOpenCallback === "function") {
116
- onDropdownOpenCallback();
116
+ if (onDropdownOpen && idOfOpenDropdown !== null) {
117
+ if (typeof this.checkForFunctionOrFunctionName(onDropdownOpen) === "function") {
118
+ onDropdownOpen();
117
119
  return true;
118
120
  }
119
121
  }
120
122
 
121
- if (onDropdownClose) {
122
- var onDropdownCloseCallback = typeof onDropdownClose === "function" ? onDropdownClose : window[onDropdownClose];
123
-
124
- if (idOfOpenDropdown == null && typeof onDropdownCloseCallback === "function") {
125
- onDropdownCloseCallback();
123
+ if (onDropdownClose && idOfOpenDropdown == null) {
124
+ if (typeof this.checkForFunctionOrFunctionName(onDropdownClose) === "function") {
125
+ onDropdownClose();
126
126
  return true;
127
127
  }
128
128
  }
129
-
130
- return false;
131
129
  };
132
130
 
133
131
  _proto.render = function render() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/global-nav",
3
- "version": "4.1.730-GN-169-Dropdown-open",
3
+ "version": "4.1.735-GN-169-Dropdown-open",
4
4
  "description": "Global header and footer components for NICE digital services",
5
5
  "main": "lib/index.js",
6
6
  "types": "./types.d.ts",
package/types.d.ts CHANGED
@@ -72,6 +72,8 @@ declare module "@nice-digital/global-nav" {
72
72
  skipLinkId?: string;
73
73
  search?: false | SearchProps;
74
74
  auth?: NiceAccountsProviderProps | IdamProviderProps | false;
75
+ onDropdownOpen?: string | OnDropdownOpenCallback;
76
+ onDropdownClose?: string | OnDropdownCloseCallback;
75
77
  onNavigating?: string | OnNavigatingCallback;
76
78
  additionalSubMenuItems?: Array<AdditionalSubMenuItem>;
77
79
  };