@splunk/react-ui 4.5.2 → 4.7.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.
Files changed (145) hide show
  1. package/Accordion.js +10 -9
  2. package/Anchor.js +2 -2
  3. package/Animation.js +2 -2
  4. package/AnimationToggle.js +2 -2
  5. package/Box.js +2 -2
  6. package/Button.js +13 -13
  7. package/ButtonGroup.js +4 -4
  8. package/ButtonSimple.js +6 -6
  9. package/CHANGELOG.md +42 -1
  10. package/Calendar.js +16 -16
  11. package/Card.js +48 -53
  12. package/CardLayout.js +4 -4
  13. package/Chip.js +10 -10
  14. package/Clickable.js +41 -15
  15. package/CloseButton.js +8 -8
  16. package/Code.js +8 -7
  17. package/CollapsiblePanel.js +11 -14
  18. package/Color.js +48 -48
  19. package/ColumnLayout.js +4 -4
  20. package/ComboBox.js +8 -8
  21. package/Concertina.js +15 -15
  22. package/ControlGroup.js +30 -37
  23. package/Date.js +10 -10
  24. package/DefinitionList.js +2 -2
  25. package/Dropdown.js +4 -4
  26. package/EventListener.js +4 -4
  27. package/FetchOptions.js +8 -8
  28. package/File.js +27 -27
  29. package/FormRows.js +21 -23
  30. package/Heading.js +2 -2
  31. package/Image.js +14 -14
  32. package/JSONTree.js +4 -4
  33. package/Layer.js +10 -10
  34. package/Link.js +6 -6
  35. package/List.js +2 -2
  36. package/Markdown.js +28 -16
  37. package/Menu.js +135 -70
  38. package/Message.js +246 -305
  39. package/MessageBar.d.ts +2 -0
  40. package/MessageBar.js +789 -0
  41. package/Modal.js +95 -61
  42. package/ModalLayer.js +5 -4
  43. package/Monogram.js +4 -4
  44. package/Multiselect.js +293 -42
  45. package/Number.js +8 -8
  46. package/Paginator.js +24 -24
  47. package/Paragraph.js +2 -2
  48. package/Popover.js +12 -12
  49. package/Progress.js +6 -6
  50. package/RadioBar.js +4 -4
  51. package/RadioList.js +2 -2
  52. package/Resize.js +8 -8
  53. package/ResultsMenu.js +25 -23
  54. package/ScreenReaderContent.js +2 -2
  55. package/Scroll.js +6 -6
  56. package/ScrollContainerContext.js +2 -2
  57. package/Search.js +14 -14
  58. package/Select.js +286 -36
  59. package/SidePanel.js +6 -6
  60. package/Slider.js +20 -14
  61. package/SlidingPanels.js +4 -4
  62. package/StaticContent.js +2 -2
  63. package/StepBar.js +18 -18
  64. package/Switch.js +17 -31
  65. package/TabBar.js +60 -46
  66. package/TabLayout.js +4 -4
  67. package/Table.js +63 -55
  68. package/Text.js +163 -146
  69. package/Tooltip.js +14 -14
  70. package/TransitionOpen.js +69 -44
  71. package/WaitSpinner.js +2 -2
  72. package/cypress/plugins/index.ts +15 -0
  73. package/cypress/support/commands.ts +1 -0
  74. package/cypress/support/index.ts +10 -0
  75. package/cypress.json +12 -0
  76. package/package.json +18 -5
  77. package/types/src/Animation/Animation.d.ts +0 -1
  78. package/types/src/Calendar/DateTable.d.ts +0 -1
  79. package/types/src/Clickable/Clickable.d.ts +12 -2
  80. package/types/src/Clickable/NavigationProvider.d.ts +12 -2
  81. package/types/src/Color/Color.d.ts +3 -3
  82. package/types/src/Date/Date.d.ts +3 -3
  83. package/types/src/Date/Icon.d.ts +0 -1
  84. package/types/src/File/Icon.d.ts +0 -1
  85. package/types/src/File/IconCloud.d.ts +0 -1
  86. package/types/src/File/PaperClip.d.ts +0 -1
  87. package/types/src/File/Retry.d.ts +0 -1
  88. package/types/src/File/Trash.d.ts +0 -1
  89. package/types/src/Markdown/renderers/MarkdownCode.d.ts +0 -1
  90. package/types/src/Markdown/renderers/MarkdownCodeBlock.d.ts +0 -1
  91. package/types/src/Markdown/renderers/MarkdownImage.d.ts +0 -1
  92. package/types/src/Menu/Divider.d.ts +0 -1
  93. package/types/src/Message/Link.d.ts +2 -0
  94. package/types/src/Message/Message.d.ts +6 -1
  95. package/types/src/MessageBar/MessageBar.d.ts +28 -0
  96. package/types/src/MessageBar/index.d.ts +2 -0
  97. package/types/src/Modal/Modal.d.ts +3 -0
  98. package/types/src/Modal/ModalContext.d.ts +6 -0
  99. package/types/src/Monogram/Monogram.d.ts +2 -2
  100. package/types/src/Multiselect/Multiselect.d.ts +1 -0
  101. package/types/src/Number/IncrementIcon.d.ts +0 -1
  102. package/types/src/Number/Number.d.ts +3 -3
  103. package/types/src/Paginator/PageSeparator.d.ts +0 -1
  104. package/types/src/Popover/Popover.d.ts +1 -2
  105. package/types/src/RadioBar/RadioBar.d.ts +3 -3
  106. package/types/src/Select/Select.d.ts +8 -3
  107. package/types/src/Select/SelectBase.d.ts +17 -5
  108. package/types/src/Select/matchUtils.d.ts +12 -0
  109. package/types/src/Slider/Slider.d.ts +3 -3
  110. package/types/src/Switch/CheckIcon.d.ts +0 -1
  111. package/types/src/Switch/Switch.d.ts +7 -7
  112. package/types/src/Table/DragHandle.d.ts +0 -1
  113. package/types/src/Table/HeadExpandRowsIcon.d.ts +0 -1
  114. package/types/src/Table/Toggle.d.ts +0 -1
  115. package/types/src/Text/IconOutlinedHide.d.ts +0 -1
  116. package/types/src/Text/IconOutlinedView.d.ts +0 -1
  117. package/types/src/Text/Text.d.ts +12 -5
  118. package/types/src/Tooltip/InfoIcon.d.ts +0 -1
  119. package/types/src/TransitionOpen/TransitionOpen.d.ts +1 -0
  120. package/types/src/icons/Alert.d.ts +0 -1
  121. package/types/src/icons/AlertFilled.d.ts +0 -1
  122. package/types/src/icons/CaretDown.d.ts +0 -1
  123. package/types/src/icons/CaretRight.d.ts +0 -1
  124. package/types/src/icons/Check.d.ts +0 -1
  125. package/types/src/icons/ChevronDown.d.ts +0 -1
  126. package/types/src/icons/ChevronLeft.d.ts +0 -1
  127. package/types/src/icons/ChevronRight.d.ts +0 -1
  128. package/types/src/icons/CrossMark.d.ts +0 -1
  129. package/types/src/icons/External.d.ts +0 -1
  130. package/types/src/icons/InfoFilled.d.ts +0 -1
  131. package/types/src/icons/More.d.ts +0 -1
  132. package/types/src/icons/MoreVertical.d.ts +0 -1
  133. package/types/src/icons/Plus.d.ts +0 -1
  134. package/types/src/icons/SVG.d.ts +0 -1
  135. package/types/src/icons/Search.d.ts +0 -1
  136. package/types/src/icons/Sort.d.ts +0 -1
  137. package/types/src/icons/SortedDown.d.ts +0 -1
  138. package/types/src/icons/SortedUp.d.ts +0 -1
  139. package/types/src/icons/Success.d.ts +0 -1
  140. package/types/src/icons/SuccessFilled.d.ts +0 -1
  141. package/types/src/icons/WarningFilled.d.ts +0 -1
  142. package/types/src/utils/types.d.ts +0 -1
  143. package/unit-test-setup-testing-library.ts +9 -0
  144. package/usePrevious.js +2 -2
  145. package/types/src/Message/Banner.d.ts +0 -8
package/TransitionOpen.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 167);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 175);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -101,7 +101,7 @@ module.exports = require("prop-types");
101
101
 
102
102
  /***/ }),
103
103
 
104
- /***/ 167:
104
+ /***/ 175:
105
105
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
106
106
 
107
107
  "use strict";
@@ -126,10 +126,10 @@ var external_lodash_ = __webpack_require__(4);
126
126
  var Animation_ = __webpack_require__(30);
127
127
 
128
128
  // EXTERNAL MODULE: external "@splunk/ui-utils/focus"
129
- var focus_ = __webpack_require__(25);
129
+ var focus_ = __webpack_require__(26);
130
130
 
131
131
  // EXTERNAL MODULE: external "@splunk/ui-utils/style"
132
- var style_ = __webpack_require__(39);
132
+ var style_ = __webpack_require__(40);
133
133
 
134
134
  // EXTERNAL MODULE: external "react-spring"
135
135
  var external_react_spring_ = __webpack_require__(18);
@@ -291,7 +291,8 @@ var TransitionOpen_TransitionOpen = /*#__PURE__*/function (_Component) {
291
291
  });
292
292
 
293
293
  _defineProperty(_assertThisInitialized(_this), "internalRender", function (_ref) {
294
- var value = _ref.value;
294
+ var value = _ref.value,
295
+ transform = _ref.transform;
295
296
  var _this$props2 = _this.props,
296
297
  animation = _this$props2.animation,
297
298
  className = _this$props2.className,
@@ -304,37 +305,19 @@ var TransitionOpen_TransitionOpen = /*#__PURE__*/function (_Component) {
304
305
  outerId = _this$props2.outerId,
305
306
  outerStyle = _this$props2.outerStyle;
306
307
  var animating = _this.state.animating;
307
- var offset = value.to(function (v) {
308
- return _this.state.value || 0 - v;
309
- });
310
- var transform;
311
308
  var dimension;
312
309
 
313
310
  if (animating) {
314
311
  switch (animation) {
315
312
  case 'slideFromTop':
316
- transform = "translateY(-".concat(offset, "px)");
317
- dimension = 'height';
318
- break;
319
-
320
313
  case 'slideFromBottom':
314
+ case 'expandHeight':
321
315
  case 'none':
322
316
  dimension = 'height';
323
317
  break;
324
318
 
325
319
  case 'slideFromLeft':
326
- transform = "translateX(".concat(-offset, "px)");
327
- dimension = 'width';
328
- break;
329
-
330
320
  case 'slideFromRight':
331
- dimension = 'width';
332
- break;
333
-
334
- case 'expandHeight':
335
- dimension = 'height';
336
- break;
337
-
338
321
  case 'expandWidth':
339
322
  dimension = 'width';
340
323
  break;
@@ -365,6 +348,58 @@ var TransitionOpen_TransitionOpen = /*#__PURE__*/function (_Component) {
365
348
  }), children));
366
349
  });
367
350
 
351
+ _defineProperty(_assertThisInitialized(_this), "getSpringTransition", function () {
352
+ var _this$props3 = _this.props,
353
+ open = _this$props3.open,
354
+ animation = _this$props3.animation;
355
+ var value = _this.state.value;
356
+ var toValue = {
357
+ value: open ? value : 0
358
+ };
359
+ var fromValue = {
360
+ value: open ? 0 : value
361
+ };
362
+ var config = {
363
+ precision: 1
364
+ }; // Only use precision when not using transform, otherwise transform animation will break
365
+ // Expansion doesn't require a valid value; the subsequent render animates it.
366
+
367
+ if (animation === 'expandWidth' || animation === 'expandHeight' || animation === 'none') {
368
+ return {
369
+ to: toValue,
370
+ config: config
371
+ };
372
+ } // Slide transitions require a valid value, render without transition first.
373
+
374
+
375
+ if (!value) {
376
+ return null;
377
+ }
378
+
379
+ if (animation !== 'slideFromTop' && animation !== 'slideFromLeft') {
380
+ // Return the standard transition if not using a transform.
381
+ return {
382
+ to: toValue,
383
+ from: fromValue,
384
+ config: config
385
+ };
386
+ } // The top and left directions require an additional transform of their inner content to match the outer dimension animation.
387
+ // This is needed to achieve a clipping effect from the outer div, rather than the consumer providing their own.
388
+
389
+
390
+ var orientation = animation === 'slideFromTop' ? 'Y' : 'X';
391
+ var toTransform = "translate".concat(orientation, "(").concat(open ? 0 : -value, "px)");
392
+ var fromTransform = "translate".concat(orientation, "(").concat(open ? -value : 0, "px)");
393
+ return {
394
+ to: _objectSpread({
395
+ transform: toTransform
396
+ }, toValue),
397
+ from: _objectSpread({
398
+ transform: fromTransform
399
+ }, fromValue)
400
+ };
401
+ });
402
+
368
403
  _this.state = {
369
404
  animating: props.animateOnMount ? props.open : false,
370
405
  innerEl: null,
@@ -379,7 +414,7 @@ var TransitionOpen_TransitionOpen = /*#__PURE__*/function (_Component) {
379
414
  value: function componentDidUpdate() {
380
415
  var value = this.getValue(this.state.innerEl);
381
416
 
382
- if (this.state.value !== value) {
417
+ if (this.state.value !== value && !this.state.animating) {
383
418
  this.setState({
384
419
  value: value
385
420
  }); // eslint-disable-line react/no-did-update-set-state
@@ -388,21 +423,11 @@ var TransitionOpen_TransitionOpen = /*#__PURE__*/function (_Component) {
388
423
  }, {
389
424
  key: "render",
390
425
  value: function render() {
391
- var _this$props3 = this.props,
392
- open = _this$props3.open,
393
- animation = _this$props3.animation;
394
- var value = this.state.value;
395
- var animateTo = open ? value : 0;
396
- return /*#__PURE__*/external_react_default.a.createElement(Animation_["Spring"], {
397
- to: {
398
- value: animateTo || 0
399
- },
426
+ var animation = this.props.animation;
427
+ return /*#__PURE__*/external_react_default.a.createElement(Animation_["Spring"], _extends({}, this.getSpringTransition(), {
400
428
  immediate: animation === 'none',
401
- onRest: this.handleRest,
402
- config: {
403
- precision: 1
404
- }
405
- }, // eslint-disable-next-line @typescript-eslint/no-explicit-any
429
+ onRest: this.handleRest
430
+ }), // eslint-disable-next-line @typescript-eslint/no-explicit-any
406
431
  this.internalRender);
407
432
  }
408
433
  }]);
@@ -445,7 +470,7 @@ module.exports = require("react");
445
470
 
446
471
  /***/ }),
447
472
 
448
- /***/ 25:
473
+ /***/ 26:
449
474
  /***/ (function(module, exports) {
450
475
 
451
476
  module.exports = require("@splunk/ui-utils/focus");
@@ -466,17 +491,17 @@ module.exports = require("@splunk/react-ui/Animation");
466
491
 
467
492
  /***/ }),
468
493
 
469
- /***/ 39:
494
+ /***/ 4:
470
495
  /***/ (function(module, exports) {
471
496
 
472
- module.exports = require("@splunk/ui-utils/style");
497
+ module.exports = require("lodash");
473
498
 
474
499
  /***/ }),
475
500
 
476
- /***/ 4:
501
+ /***/ 40:
477
502
  /***/ (function(module, exports) {
478
503
 
479
- module.exports = require("lodash");
504
+ module.exports = require("@splunk/ui-utils/style");
480
505
 
481
506
  /***/ })
482
507
 
package/WaitSpinner.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 168);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 176);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -101,7 +101,7 @@ module.exports = require("prop-types");
101
101
 
102
102
  /***/ }),
103
103
 
104
- /***/ 168:
104
+ /***/ 176:
105
105
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
106
106
 
107
107
  "use strict";
@@ -0,0 +1,15 @@
1
+ /* eslint-env node */
2
+
3
+ import { startDevServer } from '@cypress/webpack-dev-server';
4
+ import webpackConfig from '../../webpack.test.config';
5
+
6
+ /**
7
+ * @type {Cypress.PluginConfig}
8
+ */
9
+ module.exports = (on, config) => {
10
+ if (config.testingType === 'component') {
11
+ on('dev-server:start', (options) => startDevServer({ options, webpackConfig }));
12
+ }
13
+
14
+ return config;
15
+ };
@@ -0,0 +1 @@
1
+ import '@testing-library/cypress/add-commands';
@@ -0,0 +1,10 @@
1
+ import { setGlobalConfig } from '@storybook/testing-react';
2
+ import { configure } from '@testing-library/cypress';
3
+ import 'cypress-real-events/support';
4
+
5
+ import './commands';
6
+ import * as sbPreview from '../../.storybook/preview';
7
+
8
+ configure({ testIdAttribute: 'data-test' });
9
+
10
+ setGlobalConfig(sbPreview);
package/cypress.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "baseUrl": "http://localhost:8080",
3
+ "env": {},
4
+ "defaultCommandTimeout": 1000,
5
+ "fixturesFolder": false,
6
+ "video": false,
7
+ "videoUploadOnPasses": false,
8
+ "component": {
9
+ "componentFolder": "src",
10
+ "testFiles": "**/**/tests/*.spec.tsx"
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splunk/react-ui",
3
- "version": "4.5.2",
3
+ "version": "4.7.0",
4
4
  "description": "Library of React components that implement the Splunk design language",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Splunk Inc.",
@@ -22,6 +22,8 @@
22
22
  "test:functional:coverage": "cross-env NODE_ENV=test-coverage splunk-wdio-functional-test-runner functional.local.conf.js --coverage",
23
23
  "test:functional:ci": "cross-env NODE_ENV=test-coverage splunk-wdio-functional-test-runner functional.ci.conf.js --coverage-maps",
24
24
  "test:functional:cloud": "splunk-wdio-functional-test-runner functional.cloud.conf.js",
25
+ "test:cypress": "yarn cypress open-ct",
26
+ "test:cypress:ci": "yarn cypress run-ct",
25
27
  "test:visual:cloud": "splunk-wdio-functional-test-runner functional.visual.conf.js",
26
28
  "types:build": "tsc --emitDeclarationOnly --declaration --declarationDir ./types && node ./scripts/pruneTypes.js",
27
29
  "types:start": "tsc --emitDeclarationOnly --declaration --declarationDir ./types --watch"
@@ -29,11 +31,11 @@
29
31
  "peerDependencies": {
30
32
  "react": "^16.8",
31
33
  "react-dom": "^16.8",
32
- "styled-components": "^5.1"
34
+ "styled-components": "5.1.1"
33
35
  },
34
36
  "dependencies": {
35
- "@splunk/react-icons": "^3.1.0",
36
- "@splunk/themes": "^0.10.0",
37
+ "@splunk/react-icons": "^3.2.0",
38
+ "@splunk/themes": "^0.11.0",
37
39
  "@splunk/ui-utils": "^1.4.0",
38
40
  "@types/commonmark": "^0.27.0",
39
41
  "@types/lodash": "^4.14.156",
@@ -56,6 +58,8 @@
56
58
  },
57
59
  "devDependencies": {
58
60
  "@babel/core": "^7.2.0",
61
+ "@cypress/react": "^5.12.4",
62
+ "@cypress/webpack-dev-server": "^1.8.2",
59
63
  "@splunk/babel-preset": "^3.0.0",
60
64
  "@splunk/eslint-config": "^4.0.0",
61
65
  "@splunk/stylelint-config": "^4.0.0",
@@ -66,6 +70,11 @@
66
70
  "@storybook/addon-essentials": "^6.3.0",
67
71
  "@storybook/csf": "^0.0.1",
68
72
  "@storybook/react": "^6.3.0",
73
+ "@storybook/testing-react": "^1.2.3",
74
+ "@testing-library/cypress": "^8.0.2",
75
+ "@testing-library/jest-dom": "^5.16.1",
76
+ "@testing-library/react": "^12.1.2",
77
+ "@testing-library/react-hooks": "^7.0.2",
69
78
  "@types/chai": "^3.5.2",
70
79
  "@types/enzyme": "^3.10.5",
71
80
  "@types/jest": "^25.2.1",
@@ -83,12 +92,15 @@
83
92
  "chai": "^3.5.0",
84
93
  "core-js": "^3.6.4",
85
94
  "cross-env": "^6.0.3",
95
+ "cypress": "^9.5.1",
96
+ "cypress-real-events": "^1.7.0",
86
97
  "enzyme": "^3.11.0",
87
98
  "enzyme-adapter-react-16": "^1.15.2",
88
99
  "eslint": "^7.14.0",
89
100
  "eslint-config-airbnb": "^18.2.1",
90
101
  "eslint-config-prettier": "^6.15.0",
91
102
  "eslint-import-resolver-webpack": "^0.13.0",
103
+ "eslint-plugin-cypress": "^2.12.1",
92
104
  "eslint-plugin-import": "^2.22.1",
93
105
  "eslint-plugin-jsx-a11y": "^6.4.1",
94
106
  "eslint-plugin-react": "^7.21.5",
@@ -105,7 +117,7 @@
105
117
  "raw-loader": "^0.5.1",
106
118
  "react": "^16.12.0",
107
119
  "react-dom": "^16.12.0",
108
- "react-test-renderer": "^16.12.0",
120
+ "react-test-renderer": "^16.13.1",
109
121
  "sinon": "^2.1.0",
110
122
  "styled-components": "5.1.1",
111
123
  "stylelint": "^13.0.0",
@@ -114,6 +126,7 @@
114
126
  "wdio-image-comparison-service": "^1.9.0",
115
127
  "webpack": "^4.16.2",
116
128
  "webpack-cli": "^3.1.0",
129
+ "webpack-dev-server": "^4.7.4",
117
130
  "webpack-merge": "^4.1.3"
118
131
  },
119
132
  "engines": {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { SpringComponentProps as RSSpringComponentProps, TransitionComponentProps as RSTransitionComponentProps } from 'react-spring';
3
2
  /**
4
3
  * Wrappers to use in place of `Spring` and `Transition` from `react-spring`.
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import PropTypes from 'prop-types';
3
2
  import { DayClickHandler } from './Day';
4
3
  import { ComponentProps } from '../utils/types';
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
2
2
  import { legacyRefMode } from '@splunk/react-ui/Dropdown';
3
3
  import { NavigationProviderClickHandler } from './NavigationProvider';
4
4
  import { ClassComponentProps } from '../utils/types';
5
- export declare const isInternalLink: (to: string) => boolean;
5
+ export declare const isInternalLink: (to: string | undefined) => boolean;
6
6
  interface ClickablePropsBase {
7
7
  children?: React.ReactNode;
8
8
  /**
@@ -25,6 +25,13 @@ interface ClickablePropsBase {
25
25
  * Ignored if not in link mode.
26
26
  */
27
27
  openInNewContext?: boolean;
28
+ /**
29
+ * The text representation of the navigational link.
30
+ * This should be provided if child content is not a string.
31
+ *
32
+ * Ignored if not in link mode.
33
+ */
34
+ navigationLabel?: string;
28
35
  /**
29
36
  * A URL for a link. If set and not disabled, an `a` element is used instead
30
37
  * of a `button` element (link mode).
@@ -41,7 +48,10 @@ declare type ClickableProps = ClickableButtonProps | ClickableLinkProps;
41
48
  */
42
49
  declare class Clickable extends Component<ClickableProps> {
43
50
  private el;
44
- static contextType: React.Context<NavigationProviderClickHandler | undefined>;
51
+ static contextType: React.Context<{
52
+ onClick?: NavigationProviderClickHandler | undefined;
53
+ prefix?: string | undefined;
54
+ }>;
45
55
  static propTypes: React.WeakValidationMap<ClassComponentProps<ClickablePropsBase, Required<Pick<ClickablePropsBase, "disabled" | "openInNewContext">>, "button", never>> | React.WeakValidationMap<ClassComponentProps<ClickablePropsBase, Required<Pick<ClickablePropsBase, "disabled" | "openInNewContext">>, "a", "href">>;
46
56
  static defaultProps: Required<Pick<ClickablePropsBase, "disabled" | "openInNewContext">>;
47
57
  static [legacyRefMode]: boolean;
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
4
4
  declare type NavigationProviderClickHandler = (event: React.MouseEvent<HTMLAnchorElement>, data: {
5
5
  openInNewContext?: boolean;
6
6
  to: string;
7
+ label?: string;
7
8
  }) => void;
8
9
  interface NavigationProviderProps {
9
10
  children?: React.ReactNode;
@@ -12,17 +13,26 @@ interface NavigationProviderProps {
12
13
  * The function takes the event and an options argument with `to` and `openInNewContext`
13
14
  */
14
15
  onClick?: NavigationProviderClickHandler;
16
+ /**
17
+ * If set, all links that use the NavigationProvider's context will have this prepended to them.
18
+ */
19
+ prefix?: string;
15
20
  }
16
- declare const NavigationContext: React.Context<NavigationProviderClickHandler | undefined>;
21
+ declare type NavigationContextValue = {
22
+ onClick?: NavigationProviderClickHandler;
23
+ prefix?: string;
24
+ };
25
+ declare const NavigationContext: React.Context<NavigationContextValue>;
17
26
  /**
18
27
  * Used to provide an override for the `onClick` for links for single page applications so that
19
28
  * internal links can navigate without a page reload.
20
29
  */
21
- declare function NavigationProvider({ children, onClick }: NavigationProviderProps): JSX.Element;
30
+ declare function NavigationProvider({ children, onClick, prefix }: NavigationProviderProps): JSX.Element;
22
31
  declare namespace NavigationProvider {
23
32
  var propTypes: {
24
33
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
25
34
  onClick: PropTypes.Requireable<(...args: any[]) => any>;
35
+ prefix: PropTypes.Requireable<string>;
26
36
  };
27
37
  }
28
38
  export { NavigationContext, NavigationProvider, NavigationProviderClickHandler };