carbon-react 106.7.0 → 107.1.1

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 (205) hide show
  1. package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +12 -0
  2. package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.js +43 -0
  3. package/esm/__internal__/click-away-wrapper/index.d.ts +2 -0
  4. package/esm/__internal__/click-away-wrapper/index.js +1 -0
  5. package/esm/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.d.ts +0 -0
  6. package/esm/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.js +0 -0
  7. package/esm/components/badge/badge.style.d.ts +1 -1
  8. package/esm/components/button/button.component.d.ts +1 -3
  9. package/esm/components/button/button.component.js +1 -12
  10. package/esm/components/button/button.style.d.ts +1 -1
  11. package/esm/components/button-toggle-group/button-toggle-group.component.js +1 -1
  12. package/esm/components/confirm/confirm.component.d.ts +1 -5
  13. package/esm/components/confirm/confirm.component.js +2 -14
  14. package/esm/components/confirm/confirm.d.ts +0 -2
  15. package/esm/components/date/date.component.js +19 -20
  16. package/esm/components/date/date.d.ts +10 -1
  17. package/esm/components/date/index.d.ts +1 -0
  18. package/esm/components/date-range/date-range.d.ts +3 -3
  19. package/esm/components/date-range/index.d.ts +1 -0
  20. package/esm/components/dialog-full-screen/content.style.js +4 -10
  21. package/esm/components/heading/heading.component.d.ts +27 -52
  22. package/esm/components/heading/heading.component.js +86 -170
  23. package/esm/components/heading/heading.d.ts +5 -3
  24. package/esm/components/i18n-provider/i18n-provider.component.d.ts +0 -9
  25. package/esm/components/i18n-provider/i18n-provider.component.js +0 -9
  26. package/esm/components/menu/__internal__/submenu/submenu.component.js +11 -17
  27. package/esm/components/menu/index.d.ts +0 -1
  28. package/esm/components/menu/index.js +0 -1
  29. package/esm/components/menu/menu-item/menu-item.component.js +0 -6
  30. package/esm/components/multi-action-button/multi-action-button.component.d.ts +1 -1
  31. package/esm/components/multi-action-button/multi-action-button.component.js +1 -11
  32. package/esm/components/navigation-bar/navigation-bar.component.d.ts +1 -6
  33. package/esm/components/navigation-bar/navigation-bar.component.js +1 -15
  34. package/esm/components/navigation-bar/navigation-bar.style.d.ts +0 -4
  35. package/esm/components/navigation-bar/navigation-bar.style.js +0 -8
  36. package/esm/components/popover-container/popover-container.component.js +16 -3
  37. package/esm/components/radio-button/radio-button-group.component.js +1 -1
  38. package/esm/components/select/select-list/select-list.component.js +2 -2
  39. package/esm/components/simple-color-picker/simple-color-picker.component.js +1 -1
  40. package/esm/components/split-button/split-button-toggle.style.d.ts +1 -1
  41. package/esm/components/split-button/split-button.component.d.ts +1 -4
  42. package/esm/components/split-button/split-button.component.js +3 -16
  43. package/esm/components/split-button/split-button.d.ts +0 -2
  44. package/esm/components/tile/tile.component.d.ts +1 -2
  45. package/esm/components/tile/tile.component.js +1 -13
  46. package/esm/components/tile/tile.d.ts +0 -2
  47. package/esm/components/tile-select/tile-select-group.component.js +1 -1
  48. package/esm/components/toast/toast.component.d.ts +1 -4
  49. package/esm/components/toast/toast.component.js +1 -13
  50. package/esm/components/toast/toast.d.ts +0 -2
  51. package/esm/locales/en-gb.js +0 -9
  52. package/esm/locales/locale.d.ts +0 -9
  53. package/esm/locales/pl-pl.js +0 -9
  54. package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +12 -0
  55. package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.js +59 -0
  56. package/lib/__internal__/click-away-wrapper/index.d.ts +2 -0
  57. package/lib/{components/menu/submenu-block → __internal__/click-away-wrapper}/index.js +2 -2
  58. package/lib/{components/scrollable-list → __internal__/click-away-wrapper}/package.json +1 -1
  59. package/lib/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.d.ts +0 -0
  60. package/lib/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.js +0 -0
  61. package/lib/components/badge/badge.style.d.ts +1 -1
  62. package/lib/components/button/button.component.d.ts +1 -3
  63. package/lib/components/button/button.component.js +1 -14
  64. package/lib/components/button/button.style.d.ts +1 -1
  65. package/lib/components/button-toggle-group/button-toggle-group.component.js +1 -1
  66. package/lib/components/confirm/confirm.component.d.ts +1 -5
  67. package/lib/components/confirm/confirm.component.js +2 -17
  68. package/lib/components/confirm/confirm.d.ts +0 -2
  69. package/lib/components/date/date.component.js +20 -20
  70. package/lib/components/date/date.d.ts +10 -1
  71. package/lib/components/date/index.d.ts +1 -0
  72. package/lib/components/date-range/date-range.d.ts +3 -3
  73. package/lib/components/date-range/index.d.ts +1 -0
  74. package/lib/components/dialog-full-screen/content.style.js +4 -10
  75. package/lib/components/heading/heading.component.d.ts +27 -52
  76. package/lib/components/heading/heading.component.js +86 -170
  77. package/lib/components/heading/heading.d.ts +5 -3
  78. package/lib/components/i18n-provider/i18n-provider.component.d.ts +0 -9
  79. package/lib/components/i18n-provider/i18n-provider.component.js +0 -9
  80. package/lib/components/menu/__internal__/submenu/submenu.component.js +12 -17
  81. package/lib/components/menu/index.d.ts +0 -1
  82. package/lib/components/menu/index.js +0 -8
  83. package/lib/components/menu/menu-item/menu-item.component.js +0 -7
  84. package/lib/components/multi-action-button/multi-action-button.component.d.ts +1 -1
  85. package/lib/components/multi-action-button/multi-action-button.component.js +1 -14
  86. package/lib/components/navigation-bar/navigation-bar.component.d.ts +1 -6
  87. package/lib/components/navigation-bar/navigation-bar.component.js +1 -18
  88. package/lib/components/navigation-bar/navigation-bar.style.d.ts +0 -4
  89. package/lib/components/navigation-bar/navigation-bar.style.js +0 -8
  90. package/lib/components/popover-container/popover-container.component.js +17 -3
  91. package/lib/components/radio-button/radio-button-group.component.js +1 -1
  92. package/lib/components/select/select-list/select-list.component.js +2 -2
  93. package/lib/components/simple-color-picker/simple-color-picker.component.js +1 -1
  94. package/lib/components/split-button/split-button-toggle.style.d.ts +1 -1
  95. package/lib/components/split-button/split-button.component.d.ts +1 -4
  96. package/lib/components/split-button/split-button.component.js +3 -18
  97. package/lib/components/split-button/split-button.d.ts +0 -2
  98. package/lib/components/tile/tile.component.d.ts +1 -2
  99. package/lib/components/tile/tile.component.js +1 -16
  100. package/lib/components/tile/tile.d.ts +0 -2
  101. package/lib/components/tile-select/tile-select-group.component.js +1 -1
  102. package/lib/components/toast/toast.component.d.ts +1 -4
  103. package/lib/components/toast/toast.component.js +1 -16
  104. package/lib/components/toast/toast.d.ts +0 -2
  105. package/lib/locales/en-gb.js +0 -9
  106. package/lib/locales/locale.d.ts +0 -9
  107. package/lib/locales/pl-pl.js +0 -9
  108. package/package.json +1 -1
  109. package/esm/components/app-wrapper/app-wrapper.component.d.ts +0 -25
  110. package/esm/components/app-wrapper/app-wrapper.component.js +0 -104
  111. package/esm/components/app-wrapper/app-wrapper.d.ts +0 -12
  112. package/esm/components/app-wrapper/app-wrapper.style.d.ts +0 -2
  113. package/esm/components/app-wrapper/app-wrapper.style.js +0 -17
  114. package/esm/components/app-wrapper/index.d.ts +0 -1
  115. package/esm/components/app-wrapper/index.js +0 -1
  116. package/esm/components/menu/submenu-block/index.d.ts +0 -2
  117. package/esm/components/menu/submenu-block/index.js +0 -1
  118. package/esm/components/menu/submenu-block/submenu-block.component.d.ts +0 -12
  119. package/esm/components/menu/submenu-block/submenu-block.component.js +0 -34
  120. package/esm/components/menu/submenu-block/submenu-block.d.ts +0 -12
  121. package/esm/components/menu/submenu-block/submenu-block.style.d.ts +0 -2
  122. package/esm/components/menu/submenu-block/submenu-block.style.js +0 -16
  123. package/esm/components/mount-in-app/__spec__.d.ts +0 -1
  124. package/esm/components/mount-in-app/__spec__.js +0 -47
  125. package/esm/components/mount-in-app/index.d.ts +0 -1
  126. package/esm/components/mount-in-app/mount-in-app.d.ts +0 -12
  127. package/esm/components/mount-in-app/mount-in-app.js +0 -90
  128. package/esm/components/mount-in-app/package.json +0 -3
  129. package/esm/components/multi-step-wizard/__spec__.d.ts +0 -1
  130. package/esm/components/multi-step-wizard/__spec__.js +0 -191
  131. package/esm/components/multi-step-wizard/multi-step-wizard.d.ts +0 -109
  132. package/esm/components/multi-step-wizard/multi-step-wizard.js +0 -383
  133. package/esm/components/multi-step-wizard/multi-step-wizard.style.d.ts +0 -2
  134. package/esm/components/multi-step-wizard/multi-step-wizard.style.js +0 -10
  135. package/esm/components/multi-step-wizard/package.json +0 -4
  136. package/esm/components/multi-step-wizard/step/__spec__.d.ts +0 -1
  137. package/esm/components/multi-step-wizard/step/__spec__.js +0 -399
  138. package/esm/components/multi-step-wizard/step/package.json +0 -4
  139. package/esm/components/multi-step-wizard/step/step.d.ts +0 -166
  140. package/esm/components/multi-step-wizard/step/step.js +0 -407
  141. package/esm/components/multi-step-wizard/step/step.style.d.ts +0 -13
  142. package/esm/components/multi-step-wizard/step/step.style.js +0 -138
  143. package/esm/components/scrollable-list/as-scrollable-list-item.wrapper.d.ts +0 -2
  144. package/esm/components/scrollable-list/as-scrollable-list-item.wrapper.js +0 -10
  145. package/esm/components/scrollable-list/index.d.ts +0 -4
  146. package/esm/components/scrollable-list/index.js +0 -4
  147. package/esm/components/scrollable-list/scrollable-list-item.component.d.ts +0 -2
  148. package/esm/components/scrollable-list/scrollable-list-item.component.js +0 -26
  149. package/esm/components/scrollable-list/scrollable-list.component.d.ts +0 -52
  150. package/esm/components/scrollable-list/scrollable-list.component.js +0 -306
  151. package/esm/components/scrollable-list/scrollable-list.context.d.ts +0 -3
  152. package/esm/components/scrollable-list/scrollable-list.context.js +0 -2
  153. package/esm/components/scrollable-list/scrollable-list.style.d.ts +0 -2
  154. package/esm/components/scrollable-list/scrollable-list.style.js +0 -30
  155. package/esm/components/scrollable-list/test-utils.d.ts +0 -2
  156. package/esm/components/scrollable-list/test-utils.js +0 -25
  157. package/lib/components/app-wrapper/app-wrapper.component.d.ts +0 -25
  158. package/lib/components/app-wrapper/app-wrapper.component.js +0 -120
  159. package/lib/components/app-wrapper/app-wrapper.d.ts +0 -12
  160. package/lib/components/app-wrapper/app-wrapper.style.d.ts +0 -2
  161. package/lib/components/app-wrapper/app-wrapper.style.js +0 -28
  162. package/lib/components/app-wrapper/index.d.ts +0 -1
  163. package/lib/components/app-wrapper/index.js +0 -15
  164. package/lib/components/app-wrapper/package.json +0 -6
  165. package/lib/components/menu/submenu-block/index.d.ts +0 -2
  166. package/lib/components/menu/submenu-block/package.json +0 -6
  167. package/lib/components/menu/submenu-block/submenu-block.component.d.ts +0 -12
  168. package/lib/components/menu/submenu-block/submenu-block.component.js +0 -53
  169. package/lib/components/menu/submenu-block/submenu-block.d.ts +0 -12
  170. package/lib/components/menu/submenu-block/submenu-block.style.d.ts +0 -2
  171. package/lib/components/menu/submenu-block/submenu-block.style.js +0 -33
  172. package/lib/components/mount-in-app/__spec__.d.ts +0 -1
  173. package/lib/components/mount-in-app/__spec__.js +0 -55
  174. package/lib/components/mount-in-app/index.d.ts +0 -1
  175. package/lib/components/mount-in-app/mount-in-app.d.ts +0 -12
  176. package/lib/components/mount-in-app/mount-in-app.js +0 -105
  177. package/lib/components/mount-in-app/package.json +0 -3
  178. package/lib/components/multi-step-wizard/__spec__.d.ts +0 -1
  179. package/lib/components/multi-step-wizard/__spec__.js +0 -202
  180. package/lib/components/multi-step-wizard/multi-step-wizard.d.ts +0 -109
  181. package/lib/components/multi-step-wizard/multi-step-wizard.js +0 -397
  182. package/lib/components/multi-step-wizard/multi-step-wizard.style.d.ts +0 -2
  183. package/lib/components/multi-step-wizard/multi-step-wizard.style.js +0 -21
  184. package/lib/components/multi-step-wizard/package.json +0 -4
  185. package/lib/components/multi-step-wizard/step/__spec__.d.ts +0 -1
  186. package/lib/components/multi-step-wizard/step/__spec__.js +0 -409
  187. package/lib/components/multi-step-wizard/step/package.json +0 -4
  188. package/lib/components/multi-step-wizard/step/step.d.ts +0 -166
  189. package/lib/components/multi-step-wizard/step/step.js +0 -421
  190. package/lib/components/multi-step-wizard/step/step.style.d.ts +0 -13
  191. package/lib/components/multi-step-wizard/step/step.style.js +0 -162
  192. package/lib/components/scrollable-list/as-scrollable-list-item.wrapper.d.ts +0 -2
  193. package/lib/components/scrollable-list/as-scrollable-list-item.wrapper.js +0 -21
  194. package/lib/components/scrollable-list/index.d.ts +0 -4
  195. package/lib/components/scrollable-list/index.js +0 -31
  196. package/lib/components/scrollable-list/scrollable-list-item.component.d.ts +0 -2
  197. package/lib/components/scrollable-list/scrollable-list-item.component.js +0 -42
  198. package/lib/components/scrollable-list/scrollable-list.component.d.ts +0 -52
  199. package/lib/components/scrollable-list/scrollable-list.component.js +0 -328
  200. package/lib/components/scrollable-list/scrollable-list.context.d.ts +0 -3
  201. package/lib/components/scrollable-list/scrollable-list.context.js +0 -14
  202. package/lib/components/scrollable-list/scrollable-list.style.d.ts +0 -2
  203. package/lib/components/scrollable-list/scrollable-list.style.js +0 -41
  204. package/lib/components/scrollable-list/test-utils.d.ts +0 -2
  205. package/lib/components/scrollable-list/test-utils.js +0 -37
@@ -11,8 +11,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
13
13
 
14
- var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
15
-
16
14
  var _heading = _interopRequireDefault(require("../heading"));
17
15
 
18
16
  var _dialog = _interopRequireDefault(require("../dialog"));
@@ -35,15 +33,12 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
35
33
 
36
34
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
37
35
 
38
- let deprecatedWarnTriggered = false;
39
-
40
36
  const Confirm = ({
41
37
  "aria-labelledby": ariaLabelledBy,
42
38
  "aria-describedby": ariaDescribedBy,
43
39
  "aria-label": ariaLabel,
44
40
  open,
45
41
  children,
46
- destructive,
47
42
  cancelButtonDestructive,
48
43
  confirmButtonDestructive,
49
44
  cancelButtonType,
@@ -64,12 +59,6 @@ const Confirm = ({
64
59
  title,
65
60
  ...rest
66
61
  }) => {
67
- if (!deprecatedWarnTriggered && destructive) {
68
- deprecatedWarnTriggered = true;
69
-
70
- _logger.default.deprecate("`destructive` prop is deprecated and will soon be removed. Please use `cancelButtonDestructive` and `confirmButtonDestructive` props.");
71
- }
72
-
73
62
  const l = (0, _useLocale.default)();
74
63
  const {
75
64
  current: titleId
@@ -97,7 +86,7 @@ const Confirm = ({
97
86
  onClick: onCancel,
98
87
  "data-element": "cancel",
99
88
  buttonType: cancelButtonType,
100
- destructive: destructive || cancelButtonDestructive,
89
+ destructive: cancelButtonDestructive,
101
90
  disabled: disableCancel,
102
91
  iconType: cancelButtonIconType,
103
92
  iconPosition: cancelButtonIconPosition
@@ -108,7 +97,7 @@ const Confirm = ({
108
97
  onClick: onConfirm,
109
98
  "data-element": "confirm",
110
99
  buttonType: confirmButtonType,
111
- destructive: destructive || confirmButtonDestructive,
100
+ destructive: confirmButtonDestructive,
112
101
  disabled: isLoadingConfirm || disableConfirm,
113
102
  ml: 2,
114
103
  iconType: confirmButtonIconType,
@@ -152,7 +141,6 @@ const Confirm = ({
152
141
  Confirm.defaultProps = {
153
142
  size: "extra-small",
154
143
  showCloseIcon: false,
155
- destructive: false,
156
144
  cancelButtonDestructive: false,
157
145
  confirmButtonDestructive: false,
158
146
  iconType: null,
@@ -220,9 +208,6 @@ Confirm.propTypes = {
220
208
  /** Customise the cancel button label */
221
209
  cancelLabel: _propTypes.default.string,
222
210
 
223
- /** Apply destructive style to the buttons */
224
- destructive: _propTypes.default.bool,
225
-
226
211
  /** Apply destructive style to the cancel button */
227
212
  cancelButtonDestructive: _propTypes.default.bool,
228
213
 
@@ -21,8 +21,6 @@ export interface ConfirmProps extends DialogProps {
21
21
  cancelLabel?: string;
22
22
  /** Customise the confirm button label */
23
23
  confirmLabel?: string;
24
- /** Apply destructive style to the buttons */
25
- destructive?: boolean;
26
24
  /** Apply destructive style to the cancel button */
27
25
  cancelButtonDestructive?: boolean;
28
26
  /** Apply destructive style to the confirm button */
@@ -29,6 +29,8 @@ var _datePicker = _interopRequireDefault(require("./__internal__/date-picker"));
29
29
 
30
30
  var _dateRange = _interopRequireDefault(require("../date-range/date-range.context"));
31
31
 
32
+ var _clickAwayWrapper = _interopRequireDefault(require("../../__internal__/click-away-wrapper"));
33
+
32
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
35
 
34
36
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -259,23 +261,6 @@ const DateInput = ({
259
261
  }
260
262
  };
261
263
 
262
- (0, _react.useEffect)(() => {
263
- const fnClosePicker = ev => {
264
- if (open && !_events.default.composedPath(ev).includes(parentRef.current) && !_events.default.composedPath(ev).includes(pickerRef.current)) {
265
- alreadyFocused.current = true;
266
- inputRef.current.focus();
267
- isBlurBlocked.current = false;
268
- inputRef.current.blur();
269
- setOpen(false);
270
- alreadyFocused.current = false;
271
- }
272
- };
273
-
274
- document.addEventListener("mousedown", fnClosePicker);
275
- return function cleanup() {
276
- document.removeEventListener("mousedown", fnClosePicker);
277
- };
278
- }, [open]);
279
264
  (0, _react.useEffect)(() => {
280
265
  const [matchedFormat, matchedValue] = (0, _utils.findMatchedFormatAndValue)(value, formats);
281
266
 
@@ -307,7 +292,22 @@ const DateInput = ({
307
292
  return value;
308
293
  };
309
294
 
310
- return /*#__PURE__*/_react.default.createElement(_date.default, _extends({
295
+ const handleClickAway = () => {
296
+ if (open) {
297
+ alreadyFocused.current = true;
298
+ inputRef.current.focus();
299
+ isBlurBlocked.current = false;
300
+ inputRef.current.blur();
301
+ setOpen(false);
302
+ alreadyFocused.current = false;
303
+ }
304
+ };
305
+
306
+ return /*#__PURE__*/_react.default.createElement(_clickAwayWrapper.default, {
307
+ handleClickAway: handleClickAway,
308
+ eventTypeId: "mousedown",
309
+ targets: [parentRef, pickerRef]
310
+ }, /*#__PURE__*/_react.default.createElement(_date.default, _extends({
311
311
  ref: wrapperRef,
312
312
  role: "presentation",
313
313
  size: size,
@@ -347,13 +347,13 @@ const DateInput = ({
347
347
  ref: pickerRef,
348
348
  pickerMouseDown: handlePickerMouseDown,
349
349
  open: open
350
- }));
350
+ })));
351
351
  };
352
352
 
353
353
  DateInput.propTypes = { ..._textbox.default.propTypes,
354
354
  ...marginPropTypes,
355
355
 
356
- /** Pass any props that match the [DayPickerProps](https://react-day-picker.js.org/api/DayPicker)
356
+ /** Pass any props that match the [DayPickerProps](https://react-day-picker-v7.netlify.app/docs/getting-started/)
357
357
  * interface to override default behaviors
358
358
  * */
359
359
  pickerProps: _propTypes.default.object,
@@ -2,6 +2,15 @@ import * as React from "react";
2
2
  import { DayPickerProps } from "react-day-picker";
3
3
  import { TextboxProps } from "../textbox/textbox";
4
4
 
5
+ export interface DateChangeEvent {
6
+ target: {
7
+ value: {
8
+ formattedValue: string;
9
+ rawValue: string;
10
+ };
11
+ };
12
+ }
13
+
5
14
  export interface DateInputProps
6
15
  extends Omit<
7
16
  TextboxProps,
@@ -31,7 +40,7 @@ export interface DateInputProps
31
40
  /** Maximum possible date YYYY-MM-DD */
32
41
  maxDate?: string;
33
42
  /** Specify a callback triggered on change */
34
- onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
43
+ onChange: (ev: DateChangeEvent) => void;
35
44
  /** The current date string */
36
45
  value: string;
37
46
  /** Pass any props that match the DayPickerProps interface to override default behaviors */
@@ -1 +1,2 @@
1
1
  export { default } from "./date";
2
+ export type { DateChangeEvent } from "./date";
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  import { DateInputProps } from "../date/date";
4
4
 
5
- interface DateRangeChangeEvent {
5
+ export interface DateRangeChangeEvent {
6
6
  target: {
7
7
  value: [
8
8
  {
@@ -19,7 +19,7 @@ interface DateRangeChangeEvent {
19
19
 
20
20
  export interface DateRangeProps extends MarginProps {
21
21
  /** Props for the child end Date component */
22
- endDateProps?: DateInputProps;
22
+ endDateProps?: Partial<DateInputProps>;
23
23
  /** Optional label for endDate field */
24
24
  endLabel?: string;
25
25
  /**
@@ -51,7 +51,7 @@ export interface DateRangeProps extends MarginProps {
51
51
  /** Specify a callback triggered on blur */
52
52
  onBlur?: (ev: DateRangeChangeEvent) => void;
53
53
  /** Props for the child start Date component */
54
- startDateProps?: DateInputProps;
54
+ startDateProps?: Partial<DateInputProps>;
55
55
  /** Optional label for startDate field */
56
56
  startLabel?: string;
57
57
  /**
@@ -1,2 +1,3 @@
1
1
  export { default } from "./date-range";
2
2
  export { default as DateRangeContext } from "./date-range-context";
3
+ export type { DateRangeChangeEvent } from "./date-range";
@@ -93,16 +93,10 @@ const StyledContent = _styledComponents.default.div`
93
93
 
94
94
  ${({
95
95
  hasHeader
96
- }) => !hasHeader && `
97
- padding-top: 0;
98
- margin-top: -25px;
99
-
100
- .carbon-app-wrapper {
101
- max-width: 100%;
102
- padding: 0;
103
- height: 70px;
104
- }
105
- `}
96
+ }) => !hasHeader && (0, _styledComponents.css)`
97
+ padding-top: 0;
98
+ margin-top: -25px;
99
+ `}
106
100
  `;
107
101
  var _default = StyledContent;
108
102
  exports.default = _default;
@@ -1,64 +1,44 @@
1
1
  export default Heading;
2
- declare class Heading extends React.Component<any, any, any> {
3
- constructor(props: any);
4
- constructor(props: any, context: any);
5
- get help(): JSX.Element | null;
6
- get back(): JSX.Element | null;
7
- get subheader(): JSX.Element | null;
8
- get separator(): JSX.Element | null;
9
- get divider(): JSX.Element | null;
10
- get pills(): JSX.Element | null;
11
- render(): JSX.Element | null;
12
- }
2
+ declare function Heading({ children, backLink, divider, help, helpAriaLabel, helpLink, pills, separator, subheader, subtitleId, title, titleId, ...rest }: {
3
+ [x: string]: any;
4
+ children: any;
5
+ backLink: any;
6
+ divider?: boolean | undefined;
7
+ help: any;
8
+ helpAriaLabel: any;
9
+ helpLink: any;
10
+ pills: any;
11
+ separator?: boolean | undefined;
12
+ subheader: any;
13
+ subtitleId: any;
14
+ title: any;
15
+ titleId: any;
16
+ }): JSX.Element | null;
13
17
  declare namespace Heading {
14
18
  const propTypes: {
15
- /**
16
- * Children elements
17
- */
19
+ /** Child elements */
18
20
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
19
- /**
20
- * Defines the title for the heading.
21
- */
21
+ /** Defines the title for the heading. */
22
22
  title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
23
- /**
24
- * Defines the title id for the heading.
25
- */
23
+ /** Defines the title id for the heading. */
26
24
  titleId: PropTypes.Requireable<string>;
27
- /**
28
- * Defines the subheader for the heading.
29
- */
25
+ /** Defines the subheader for the heading. */
30
26
  subheader: PropTypes.Requireable<PropTypes.ReactNodeLike>;
31
- /**
32
- * Defines the subtitle id for the heading.
33
- */
27
+ /** Defines the subtitle id for the heading. */
34
28
  subtitleId: PropTypes.Requireable<string>;
35
- /**
36
- * Defines the help text for the heading.
37
- */
29
+ /** Defines the help text for the heading. */
38
30
  help: PropTypes.Requireable<string>;
39
- /**
40
- * Defines the help link for the heading.
41
- */
31
+ /** Defines the help link for the heading. */
42
32
  helpLink: PropTypes.Requireable<string>;
43
- /**
44
- * Defines the a href for the back link.
45
- */
33
+ /** Defines the a href for the back link. */
46
34
  backLink: PropTypes.Requireable<string | ((...args: any[]) => any)>;
47
- /**
48
- * Adds a divider below the heading and the content.
49
- */
35
+ /** Adds a divider below the heading and the content. */
50
36
  divider: PropTypes.Requireable<boolean>;
51
- /**
52
- * Adds a separator between the title and the subheader.
53
- */
37
+ /** Adds a separator between the title and the subheader. */
54
38
  separator: PropTypes.Requireable<boolean>;
55
- /**
56
- * Pills that will be added after the title.
57
- */
39
+ /** Pills that will be added after the title. */
58
40
  pills: PropTypes.Requireable<PropTypes.ReactNodeLike>;
59
- /**
60
- * Aria label for rendered help component
61
- */
41
+ /** Aria label for rendered help component */
62
42
  helpAriaLabel: PropTypes.Requireable<string>;
63
43
  marginBottom?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
64
44
  margin?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
@@ -75,10 +55,5 @@ declare namespace Heading {
75
55
  marginY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
76
56
  my?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
77
57
  };
78
- namespace defaultProps {
79
- const divider: boolean;
80
- const separator: boolean;
81
- }
82
58
  }
83
- import React from "react";
84
59
  import PropTypes from "prop-types";
@@ -21,204 +21,120 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
21
21
 
22
22
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
23
 
24
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
-
26
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27
-
28
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
29
-
30
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
-
32
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
-
34
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
-
36
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
37
-
38
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
-
40
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
-
42
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
-
44
24
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
45
25
 
46
- let Heading = /*#__PURE__*/function (_React$Component) {
47
- _inherits(Heading, _React$Component);
48
-
49
- var _super = _createSuper(Heading);
50
-
51
- function Heading() {
52
- _classCallCheck(this, Heading);
53
-
54
- return _super.apply(this, arguments);
55
- }
56
-
57
- _createClass(Heading, [{
58
- key: "help",
59
- get: function () {
60
- if (!this.props.help && !this.props.helpLink) {
61
- return null;
62
- }
63
-
64
- return /*#__PURE__*/_react.default.createElement(_heading.StyledHeaderHelp, {
65
- "data-element": "help",
66
- tooltipPosition: "right",
67
- href: this.props.helpLink,
68
- ariaLabel: this.props.helpAriaLabel
69
- }, this.props.help);
70
- }
71
- }, {
72
- key: "back",
73
- get: function () {
74
- if (!this.props.backLink) {
75
- return null;
76
- }
77
-
78
- let props;
79
-
80
- if (typeof this.props.backLink === "string") {
81
- props = {
82
- href: this.props.backLink
83
- };
84
- } else {
85
- props = {
86
- onClick: this.props.backLink
87
- };
88
- }
89
-
90
- return /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingBackButton // this event allows an element to be focusable on click event on IE
91
- , _extends({
92
- onMouseDown: e => e.currentTarget.focus(),
93
- "data-element": "back"
94
- }, props), /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingIcon, {
95
- type: "chevron_left",
96
- divider: this.props.divider
97
- }));
98
- }
99
- }, {
100
- key: "subheader",
101
- get: function () {
102
- if (!this.props.subheader) {
103
- return null;
104
- }
105
-
106
- return /*#__PURE__*/_react.default.createElement(_heading.StyledSubHeader, {
107
- "data-element": "subtitle",
108
- id: this.props.subtitleId,
109
- hasBackLink: !!this.props.backLink,
110
- hasSeparator: this.props.separator
111
- }, this.props.subheader);
112
- }
113
- }, {
114
- key: "separator",
115
- get: function () {
116
- return this.props.separator ? /*#__PURE__*/_react.default.createElement(_heading.StyledSeparator, null) : null;
117
- }
118
- }, {
119
- key: "divider",
120
- get: function () {
121
- return this.props.divider ? /*#__PURE__*/_react.default.createElement(_heading.StyledDivider, {
122
- "data-element": "divider"
123
- }) : null;
124
- }
125
- }, {
126
- key: "pills",
127
- get: function () {
128
- return this.props.pills ? /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingPills, {
129
- "data-element": "pills"
130
- }, this.props.pills) : null;
131
- }
132
- }, {
133
- key: "render",
134
- value: function render() {
135
- if (!this.props.title) {
136
- return null;
137
- }
138
-
139
- const marginProps = (0, _utils.filterStyledSystemMarginProps)(this.props);
140
- return /*#__PURE__*/_react.default.createElement(_heading.StyledHeading, _extends({}, (0, _tags.default)("heading", this.props), marginProps), /*#__PURE__*/_react.default.createElement(_heading.StyledHeader, {
141
- "data-element": "header-container",
142
- divider: this.props.divider,
143
- subheader: this.props.subheader,
144
- hasBackLink: !!this.props.backLink
145
- }, this.back, /*#__PURE__*/_react.default.createElement(_heading.StyledHeaderContent, null, /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingTitle, {
146
- withMargin: this.props.pills || this.props.help,
147
- variant: "h1",
148
- "data-element": "title",
149
- id: this.props.titleId
150
- }, this.props.title), this.help, this.pills), this.separator, this.subheader), this.divider, this.props.children);
151
- }
152
- }]);
153
-
154
- return Heading;
155
- }(_react.default.Component);
26
+ const Heading = ({
27
+ children,
28
+ backLink,
29
+ divider = true,
30
+ help,
31
+ helpAriaLabel,
32
+ helpLink,
33
+ pills,
34
+ separator = false,
35
+ subheader,
36
+ subtitleId,
37
+ title,
38
+ titleId,
39
+ ...rest
40
+ }) => {
41
+ const getHelp = () => {
42
+ return /*#__PURE__*/_react.default.createElement(_heading.StyledHeaderHelp, {
43
+ "data-element": "help",
44
+ tooltipPosition: "right",
45
+ href: helpLink,
46
+ ariaLabel: helpAriaLabel
47
+ }, help);
48
+ };
49
+
50
+ const getBackButton = () => {
51
+ const backButtonProps = typeof backLink === "string" ? {
52
+ href: backLink
53
+ } : {
54
+ onClick: backLink
55
+ };
56
+ return /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingBackButton // this event allows an element to be focusable on click event on IE
57
+ , _extends({
58
+ onMouseDown: e => e.currentTarget.focus(),
59
+ "data-element": "back"
60
+ }, backButtonProps), /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingIcon, {
61
+ type: "chevron_left",
62
+ divider: divider
63
+ }));
64
+ };
65
+
66
+ const getSubheader = () => {
67
+ return /*#__PURE__*/_react.default.createElement(_heading.StyledSubHeader, {
68
+ "data-element": "subtitle",
69
+ id: subtitleId,
70
+ hasBackLink: !!backLink,
71
+ hasSeparator: separator
72
+ }, subheader);
73
+ };
74
+
75
+ const getPills = () => {
76
+ return /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingPills, {
77
+ "data-element": "pills"
78
+ }, pills);
79
+ };
80
+
81
+ const marginProps = (0, _utils.filterStyledSystemMarginProps)(rest);
82
+ const dataAttributes = {
83
+ "data-element": rest["data-element"],
84
+ "data-role": rest["data-role"]
85
+ };
86
+ return title ? /*#__PURE__*/_react.default.createElement(_heading.StyledHeading, _extends({}, (0, _tags.default)("heading", dataAttributes), marginProps), /*#__PURE__*/_react.default.createElement(_heading.StyledHeader, {
87
+ "data-element": "header-container",
88
+ divider: divider,
89
+ subheader: subheader,
90
+ hasBackLink: !!backLink
91
+ }, backLink && getBackButton(), /*#__PURE__*/_react.default.createElement(_heading.StyledHeaderContent, null, /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingTitle, {
92
+ withMargin: pills || help,
93
+ variant: "h1",
94
+ "data-element": "title",
95
+ id: titleId
96
+ }, title), (help || helpLink) && getHelp(), pills && getPills()), separator && /*#__PURE__*/_react.default.createElement(_heading.StyledSeparator, null), subheader && getSubheader()), divider && /*#__PURE__*/_react.default.createElement(_heading.StyledDivider, {
97
+ "data-element": "divider"
98
+ }), children) : null;
99
+ };
156
100
 
157
101
  Heading.propTypes = { ...marginPropTypes,
158
102
 
159
- /**
160
- * Children elements
161
- */
103
+ /** Child elements */
162
104
  children: _propTypes.default.node,
163
105
 
164
- /**
165
- * Defines the title for the heading.
166
- */
106
+ /** Defines the title for the heading. */
167
107
  title: _propTypes.default.node,
168
108
 
169
- /**
170
- * Defines the title id for the heading.
171
- */
109
+ /** Defines the title id for the heading. */
172
110
  titleId: _propTypes.default.string,
173
111
 
174
- /**
175
- * Defines the subheader for the heading.
176
- */
112
+ /** Defines the subheader for the heading. */
177
113
  subheader: _propTypes.default.node,
178
114
 
179
- /**
180
- * Defines the subtitle id for the heading.
181
- */
115
+ /** Defines the subtitle id for the heading. */
182
116
  subtitleId: _propTypes.default.string,
183
117
 
184
- /**
185
- * Defines the help text for the heading.
186
- */
118
+ /** Defines the help text for the heading. */
187
119
  help: _propTypes.default.string,
188
120
 
189
- /**
190
- * Defines the help link for the heading.
191
- */
121
+ /** Defines the help link for the heading. */
192
122
  helpLink: _propTypes.default.string,
193
123
 
194
- /**
195
- * Defines the a href for the back link.
196
- */
124
+ /** Defines the a href for the back link. */
197
125
  backLink: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
198
126
 
199
- /**
200
- * Adds a divider below the heading and the content.
201
- */
127
+ /** Adds a divider below the heading and the content. */
202
128
  divider: _propTypes.default.bool,
203
129
 
204
- /**
205
- * Adds a separator between the title and the subheader.
206
- */
130
+ /** Adds a separator between the title and the subheader. */
207
131
  separator: _propTypes.default.bool,
208
132
 
209
- /**
210
- * Pills that will be added after the title.
211
- */
133
+ /** Pills that will be added after the title. */
212
134
  pills: _propTypes.default.node,
213
135
 
214
- /**
215
- * Aria label for rendered help component
216
- */
136
+ /** Aria label for rendered help component */
217
137
  helpAriaLabel: _propTypes.default.string
218
138
  };
219
- Heading.defaultProps = {
220
- divider: true,
221
- separator: false
222
- };
223
139
  var _default = Heading;
224
140
  exports.default = _default;
@@ -2,8 +2,8 @@ import * as React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
 
4
4
  export interface HeadingProps extends MarginProps {
5
- /** Custom className */
6
- className?: string;
5
+ /** Child elements */
6
+ children?: React.ReactNode;
7
7
  /** Defines the title for the heading. */
8
8
  title?: React.ReactNode;
9
9
  /** Defines the title id for the heading. */
@@ -24,8 +24,10 @@ export interface HeadingProps extends MarginProps {
24
24
  separator?: boolean;
25
25
  /** Pills that will be added after the title. */
26
26
  pills?: React.ReactNode;
27
+ /** Aria label for rendered help component */
28
+ helpAriaLabel?: string;
27
29
  }
28
30
 
29
- declare class Heading extends React.Component<HeadingProps> {}
31
+ declare function Heading(props: HeadingProps): JSX.Element | null;
30
32
 
31
33
  export default Heading;