@instructure/ui-top-nav-bar 8.55.1 → 8.56.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [8.56.0](https://github.com/instructure/instructure-ui/compare/v8.55.1...v8.56.0) (2024-05-06)
7
+
8
+
9
+ ### Features
10
+
11
+ * **ui-top-nav-bar:** add onclick prop for hidden menu item ([7228ae1](https://github.com/instructure/instructure-ui/commit/7228ae160a449939f0427222b009b747b0daf926))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [8.55.1](https://github.com/instructure/instructure-ui/compare/v8.55.0...v8.55.1) (2024-04-30)
7
18
 
8
19
 
@@ -52,6 +52,7 @@ const propTypes = {
52
52
  renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
53
53
  href: PropTypes.string,
54
54
  onClick: PropTypes.func,
55
+ onHiddenClick: PropTypes.func,
55
56
  onSubmenuToggle: PropTypes.func,
56
57
  onMouseOver: PropTypes.func,
57
58
  onMouseOut: PropTypes.func,
@@ -63,5 +64,5 @@ const propTypes = {
63
64
  itemRef: PropTypes.func,
64
65
  shouldCloseOnClick: PropTypes.oneOf(['auto', 'always', 'never'])
65
66
  };
66
- const allowedProps = ['id', 'as', 'children', 'variant', 'status', 'renderSubmenu', 'showSubmenuChevron', 'customPopoverConfig', 'tooltip', 'renderAvatar', 'renderIcon', 'href', 'onClick', 'onSubmenuToggle', 'onMouseOver', 'onMouseOut', 'onFocus', 'onBlur', 'onKeyDown', 'onKeyUp', 'elementRef', 'itemRef', 'shouldCloseOnClick'];
67
+ const allowedProps = ['id', 'as', 'children', 'variant', 'status', 'renderSubmenu', 'showSubmenuChevron', 'customPopoverConfig', 'tooltip', 'renderAvatar', 'renderIcon', 'href', 'onClick', 'onHiddenClick', 'onSubmenuToggle', 'onMouseOver', 'onMouseOut', 'onFocus', 'onBlur', 'onKeyDown', 'onKeyUp', 'elementRef', 'itemRef', 'shouldCloseOnClick'];
67
68
  export { propTypes, allowedProps, topNavBarItemTooltipPropType };
@@ -123,7 +123,13 @@ const renderMappedItemDrilldownSubpages = mappedItems => {
123
123
  };
124
124
  const renderMappedItemsAsDrilldownOptions = mappedItems => {
125
125
  return mappedItems.map(mappedItem => {
126
- const optionData = mappedItem.optionData;
126
+ const optionData = mappedItem.optionData,
127
+ originalItem = mappedItem.item;
128
+ const onHiddenClick = originalItem.props.onHiddenClick;
129
+ if (onHiddenClick) {
130
+ // if the `onHiddenClick` prop is provided for the MenuItem it should overwrite the `onClick` prop if there is any
131
+ optionData.onOptionClick = onHiddenClick;
132
+ }
127
133
  return /*#__PURE__*/React.createElement(Drilldown.Option, Object.assign({}, optionData, {
128
134
  key: optionData.id,
129
135
  afterLabelContentVAlign: "center"
@@ -59,6 +59,7 @@ const propTypes = exports.propTypes = {
59
59
  renderIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
60
60
  href: _propTypes.default.string,
61
61
  onClick: _propTypes.default.func,
62
+ onHiddenClick: _propTypes.default.func,
62
63
  onSubmenuToggle: _propTypes.default.func,
63
64
  onMouseOver: _propTypes.default.func,
64
65
  onMouseOut: _propTypes.default.func,
@@ -70,4 +71,4 @@ const propTypes = exports.propTypes = {
70
71
  itemRef: _propTypes.default.func,
71
72
  shouldCloseOnClick: _propTypes.default.oneOf(['auto', 'always', 'never'])
72
73
  };
73
- const allowedProps = exports.allowedProps = ['id', 'as', 'children', 'variant', 'status', 'renderSubmenu', 'showSubmenuChevron', 'customPopoverConfig', 'tooltip', 'renderAvatar', 'renderIcon', 'href', 'onClick', 'onSubmenuToggle', 'onMouseOver', 'onMouseOut', 'onFocus', 'onBlur', 'onKeyDown', 'onKeyUp', 'elementRef', 'itemRef', 'shouldCloseOnClick'];
74
+ const allowedProps = exports.allowedProps = ['id', 'as', 'children', 'variant', 'status', 'renderSubmenu', 'showSubmenuChevron', 'customPopoverConfig', 'tooltip', 'renderAvatar', 'renderIcon', 'href', 'onClick', 'onHiddenClick', 'onSubmenuToggle', 'onMouseOver', 'onMouseOut', 'onFocus', 'onBlur', 'onKeyDown', 'onKeyUp', 'elementRef', 'itemRef', 'shouldCloseOnClick'];
@@ -133,7 +133,13 @@ const renderMappedItemDrilldownSubpages = mappedItems => {
133
133
  exports.renderMappedItemDrilldownSubpages = renderMappedItemDrilldownSubpages;
134
134
  const renderMappedItemsAsDrilldownOptions = mappedItems => {
135
135
  return mappedItems.map(mappedItem => {
136
- const optionData = mappedItem.optionData;
136
+ const optionData = mappedItem.optionData,
137
+ originalItem = mappedItem.item;
138
+ const onHiddenClick = originalItem.props.onHiddenClick;
139
+ if (onHiddenClick) {
140
+ // if the `onHiddenClick` prop is provided for the MenuItem it should overwrite the `onClick` prop if there is any
141
+ optionData.onOptionClick = onHiddenClick;
142
+ }
137
143
  return /*#__PURE__*/_react.default.createElement(_Drilldown.Drilldown.Option, Object.assign({}, optionData, {
138
144
  key: optionData.id,
139
145
  afterLabelContentVAlign: "center"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-top-nav-bar",
3
- "version": "8.55.1",
3
+ "version": "8.56.0",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,38 +24,38 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.23.2",
27
- "@instructure/console": "8.55.1",
28
- "@instructure/emotion": "8.55.1",
29
- "@instructure/shared-types": "8.55.1",
30
- "@instructure/ui-a11y-content": "8.55.1",
31
- "@instructure/ui-avatar": "8.55.1",
32
- "@instructure/ui-breadcrumb": "8.55.1",
33
- "@instructure/ui-buttons": "8.55.1",
34
- "@instructure/ui-dialog": "8.55.1",
35
- "@instructure/ui-dom-utils": "8.55.1",
36
- "@instructure/ui-drilldown": "8.55.1",
37
- "@instructure/ui-icons": "8.55.1",
38
- "@instructure/ui-link": "8.55.1",
39
- "@instructure/ui-popover": "8.55.1",
40
- "@instructure/ui-prop-types": "8.55.1",
41
- "@instructure/ui-react-utils": "8.55.1",
42
- "@instructure/ui-responsive": "8.55.1",
43
- "@instructure/ui-testable": "8.55.1",
44
- "@instructure/ui-tooltip": "8.55.1",
45
- "@instructure/ui-tray": "8.55.1",
46
- "@instructure/ui-truncate-list": "8.55.1",
47
- "@instructure/ui-utils": "8.55.1",
48
- "@instructure/ui-view": "8.55.1",
27
+ "@instructure/console": "8.56.0",
28
+ "@instructure/emotion": "8.56.0",
29
+ "@instructure/shared-types": "8.56.0",
30
+ "@instructure/ui-a11y-content": "8.56.0",
31
+ "@instructure/ui-avatar": "8.56.0",
32
+ "@instructure/ui-breadcrumb": "8.56.0",
33
+ "@instructure/ui-buttons": "8.56.0",
34
+ "@instructure/ui-dialog": "8.56.0",
35
+ "@instructure/ui-dom-utils": "8.56.0",
36
+ "@instructure/ui-drilldown": "8.56.0",
37
+ "@instructure/ui-icons": "8.56.0",
38
+ "@instructure/ui-link": "8.56.0",
39
+ "@instructure/ui-popover": "8.56.0",
40
+ "@instructure/ui-prop-types": "8.56.0",
41
+ "@instructure/ui-react-utils": "8.56.0",
42
+ "@instructure/ui-responsive": "8.56.0",
43
+ "@instructure/ui-testable": "8.56.0",
44
+ "@instructure/ui-tooltip": "8.56.0",
45
+ "@instructure/ui-tray": "8.56.0",
46
+ "@instructure/ui-truncate-list": "8.56.0",
47
+ "@instructure/ui-utils": "8.56.0",
48
+ "@instructure/ui-view": "8.56.0",
49
49
  "prop-types": "^15.8.1"
50
50
  },
51
51
  "devDependencies": {
52
- "@instructure/ui-axe-check": "8.55.1",
53
- "@instructure/ui-babel-preset": "8.55.1",
54
- "@instructure/ui-color-utils": "8.55.1",
55
- "@instructure/ui-scripts": "8.55.1",
56
- "@instructure/ui-test-locator": "8.55.1",
57
- "@instructure/ui-test-utils": "8.55.1",
58
- "@instructure/ui-themes": "8.55.1",
52
+ "@instructure/ui-axe-check": "8.56.0",
53
+ "@instructure/ui-babel-preset": "8.56.0",
54
+ "@instructure/ui-color-utils": "8.56.0",
55
+ "@instructure/ui-scripts": "8.56.0",
56
+ "@instructure/ui-test-locator": "8.56.0",
57
+ "@instructure/ui-test-utils": "8.56.0",
58
+ "@instructure/ui-themes": "8.56.0",
59
59
  "@testing-library/jest-dom": "^6.1.4",
60
60
  "@testing-library/react": "^14.1.2",
61
61
  "@testing-library/user-event": "^14.5.1"
@@ -198,6 +198,13 @@ type TopNavBarItemOwnProps = {
198
198
  event: React.MouseEvent<ViewOwnProps> | React.KeyboardEvent<ViewOwnProps>
199
199
  ) => void
200
200
 
201
+ /**
202
+ * Only fires when the item is hidden because of truncation or mobile view. Intended to be used for navigation when the item would otherwise be a link.
203
+ */
204
+ onHiddenClick?: (
205
+ event: React.MouseEvent<ViewOwnProps> | React.KeyboardEvent<ViewOwnProps>
206
+ ) => void
207
+
201
208
  /**
202
209
  * __In desktop mode__, the callback fired when the item's submenu ([Drilldown](#Drilldown)) is toggled open/closed.
203
210
  */
@@ -298,6 +305,7 @@ const propTypes: PropValidators<PropKeys> = {
298
305
  renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
299
306
  href: PropTypes.string,
300
307
  onClick: PropTypes.func,
308
+ onHiddenClick: PropTypes.func,
301
309
  onSubmenuToggle: PropTypes.func,
302
310
  onMouseOver: PropTypes.func,
303
311
  onMouseOut: PropTypes.func,
@@ -324,6 +332,7 @@ const allowedProps: AllowedPropKeys = [
324
332
  'renderIcon',
325
333
  'href',
326
334
  'onClick',
335
+ 'onHiddenClick',
327
336
  'onSubmenuToggle',
328
337
  'onMouseOver',
329
338
  'onMouseOut',
@@ -206,7 +206,13 @@ const renderMappedItemsAsDrilldownOptions = (
206
206
  mappedItems: ItemMappedForDrilldownOption[]
207
207
  ) => {
208
208
  return mappedItems.map<DrilldownOptionChild>((mappedItem) => {
209
- const { optionData } = mappedItem
209
+ const { optionData, item: originalItem } = mappedItem
210
+ const onHiddenClick = originalItem.props.onHiddenClick
211
+
212
+ if (onHiddenClick) {
213
+ // if the `onHiddenClick` prop is provided for the MenuItem it should overwrite the `onClick` prop if there is any
214
+ optionData.onOptionClick = onHiddenClick as any
215
+ }
210
216
 
211
217
  return (
212
218
  <Drilldown.Option