carbon-react 105.1.2 → 106.0.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 (212) hide show
  1. package/esm/__internal__/tooltip-provider/index.d.ts +19 -24
  2. package/esm/__internal__/tooltip-provider/index.js +1 -11
  3. package/esm/__internal__/utils/helpers/browser/index.d.ts +15 -1
  4. package/esm/__internal__/utils/helpers/browser/index.js +33 -1
  5. package/esm/__internal__/utils/helpers/browser-type-check/index.d.ts +7 -1
  6. package/esm/__internal__/utils/helpers/browser-type-check/index.js +8 -1
  7. package/esm/__internal__/utils/helpers/events/composedPath.d.ts +1 -1
  8. package/esm/__internal__/utils/helpers/events/events.d.ts +132 -31
  9. package/esm/__internal__/utils/helpers/events/events.js +10 -125
  10. package/esm/__internal__/utils/helpers/guid/index.d.ts +5 -0
  11. package/esm/__internal__/utils/helpers/guid/{guid.js → index.js} +0 -2
  12. package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +4 -2
  13. package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +2 -1
  14. package/esm/__internal__/utils/helpers/tags/tags.d.ts +10 -6
  15. package/esm/__internal__/utils/helpers/tags/tags.js +2 -6
  16. package/esm/__internal__/utils/helpers/useUniqueId/index.d.ts +2 -0
  17. package/esm/__internal__/utils/helpers/useUniqueId/index.js +7 -0
  18. package/esm/__internal__/utils/logger/index.d.ts +5 -1
  19. package/esm/__internal__/utils/logger/index.js +25 -1
  20. package/esm/components/app-wrapper/app-wrapper.component.d.ts +4 -0
  21. package/esm/components/app-wrapper/app-wrapper.component.js +5 -3
  22. package/esm/components/badge/badge.style.d.ts +4 -2
  23. package/esm/components/button/button-types.style.d.ts +1 -2
  24. package/esm/components/button/button-types.style.js +3 -1
  25. package/esm/components/button/button.component.d.ts +67 -36
  26. package/esm/components/button/button.component.js +3314 -165
  27. package/esm/components/button/button.config.d.ts +4 -3
  28. package/esm/components/button/button.style.d.ts +6 -8
  29. package/esm/components/button/button.style.js +51 -95
  30. package/esm/components/button/index.d.ts +2 -2
  31. package/esm/components/confirm/confirm.component.js +1 -1
  32. package/esm/components/dialog/dialog.component.js +1 -1
  33. package/esm/components/dialog-full-screen/dialog-full-screen.component.js +1 -1
  34. package/esm/components/duelling-picklist/picklist-group/picklist-group.style.d.ts +1 -2
  35. package/esm/components/duelling-picklist/picklist-item/picklist-item.style.d.ts +1 -2
  36. package/esm/components/fieldset/fieldset.component.d.ts +6 -1
  37. package/esm/components/fieldset/fieldset.component.js +14 -15
  38. package/esm/components/heading/heading.component.d.ts +5 -0
  39. package/esm/components/icon/index.d.ts +1 -0
  40. package/esm/components/multi-action-button/multi-action-button.component.d.ts +3 -1
  41. package/esm/components/multi-action-button/multi-action-button.component.js +7 -5
  42. package/esm/components/multi-action-button/multi-action-button.d.ts +4 -2
  43. package/esm/components/multi-step-wizard/multi-step-wizard.d.ts +22 -0
  44. package/esm/components/multi-step-wizard/step/step.d.ts +6 -0
  45. package/esm/components/multi-step-wizard/step/step.style.d.ts +4 -2
  46. package/esm/components/portrait/portrait-initials.component.js +1 -1
  47. package/esm/components/radio-button/radio-button-svg.component.js +29 -16
  48. package/esm/components/scrollable-list/scrollable-list.component.d.ts +8 -0
  49. package/esm/components/select/select-list/select-list.component.js +1 -1
  50. package/esm/components/select/select-textbox/select-textbox.component.js +1 -1
  51. package/esm/components/split-button/split-button-toggle.style.d.ts +2 -6
  52. package/esm/components/split-button/split-button.component.d.ts +3 -1
  53. package/esm/components/split-button/split-button.component.js +7 -4
  54. package/esm/components/split-button/split-button.d.ts +5 -2
  55. package/esm/components/tabs/__internal__/tab-title/tab-title.style.js +3 -5
  56. package/esm/components/textbox/textbox.component.d.ts +1 -2
  57. package/esm/components/textbox/textbox.component.js +7 -6
  58. package/esm/components/tooltip/index.d.ts +2 -1
  59. package/esm/components/tooltip/tooltip-pointer.style.d.ts +10 -1
  60. package/esm/components/tooltip/tooltip-pointer.style.js +5 -12
  61. package/esm/components/tooltip/tooltip.component.d.ts +33 -2
  62. package/esm/components/tooltip/tooltip.component.js +255 -110
  63. package/esm/components/tooltip/tooltip.config.d.ts +2 -1
  64. package/esm/components/tooltip/tooltip.style.d.ts +7 -2
  65. package/esm/components/tooltip/tooltip.style.js +7 -21
  66. package/esm/components/typography/typography.component.d.ts +1 -1
  67. package/esm/locales/en-gb.d.ts +3 -5
  68. package/esm/locales/en-gb.js +5 -4
  69. package/esm/locales/index.d.ts +1 -1
  70. package/esm/locales/index.js +2 -0
  71. package/esm/locales/locale.d.ts +99 -105
  72. package/esm/locales/locale.js +1 -0
  73. package/esm/locales/pl-pl.d.ts +3 -5
  74. package/esm/locales/pl-pl.js +5 -4
  75. package/esm/style/{fonts → assets}/carbon-icons-webfont.woff +0 -0
  76. package/esm/style/fonts.css +30 -0
  77. package/esm/style/global-style.js +1 -1
  78. package/esm/style/themes/base/base-theme.config.d.ts +17 -8
  79. package/esm/style/themes/sage/index.d.ts +17 -8
  80. package/lib/__internal__/tooltip-provider/index.d.ts +19 -24
  81. package/lib/__internal__/tooltip-provider/index.js +2 -13
  82. package/lib/__internal__/utils/helpers/browser/index.d.ts +15 -1
  83. package/lib/__internal__/utils/helpers/browser/index.js +33 -8
  84. package/lib/__internal__/utils/helpers/browser-type-check/index.d.ts +7 -1
  85. package/lib/__internal__/utils/helpers/browser-type-check/index.js +10 -21
  86. package/lib/__internal__/utils/helpers/events/composedPath.d.ts +1 -1
  87. package/lib/__internal__/utils/helpers/events/events.d.ts +132 -31
  88. package/lib/__internal__/utils/helpers/events/events.js +10 -125
  89. package/lib/__internal__/utils/helpers/guid/index.d.ts +5 -0
  90. package/lib/__internal__/utils/helpers/guid/{guid.js → index.js} +0 -2
  91. package/lib/__internal__/utils/helpers/guid/package.json +5 -2
  92. package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +4 -2
  93. package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +2 -1
  94. package/lib/__internal__/utils/helpers/tags/tags.d.ts +10 -6
  95. package/lib/__internal__/utils/helpers/tags/tags.js +2 -6
  96. package/lib/__internal__/utils/helpers/useUniqueId/index.d.ts +2 -0
  97. package/lib/__internal__/utils/helpers/useUniqueId/index.js +20 -0
  98. package/lib/__internal__/utils/helpers/useUniqueId/package.json +6 -0
  99. package/lib/__internal__/utils/logger/index.d.ts +5 -1
  100. package/lib/__internal__/utils/logger/index.js +26 -8
  101. package/lib/components/app-wrapper/app-wrapper.component.d.ts +4 -0
  102. package/lib/components/app-wrapper/app-wrapper.component.js +5 -4
  103. package/lib/components/badge/badge.style.d.ts +4 -2
  104. package/lib/components/button/button-types.style.d.ts +1 -2
  105. package/lib/components/button/button-types.style.js +0 -1
  106. package/lib/components/button/button.component.d.ts +67 -36
  107. package/lib/components/button/button.component.js +3381 -172
  108. package/lib/components/button/button.config.d.ts +4 -3
  109. package/lib/components/button/button.style.d.ts +6 -8
  110. package/lib/components/button/button.style.js +52 -101
  111. package/lib/components/button/index.d.ts +2 -2
  112. package/lib/components/confirm/confirm.component.js +1 -1
  113. package/lib/components/dialog/dialog.component.js +1 -1
  114. package/lib/components/dialog-full-screen/dialog-full-screen.component.js +1 -1
  115. package/lib/components/duelling-picklist/picklist-group/picklist-group.style.d.ts +1 -2
  116. package/lib/components/duelling-picklist/picklist-item/picklist-item.style.d.ts +1 -2
  117. package/lib/components/fieldset/fieldset.component.d.ts +6 -1
  118. package/lib/components/fieldset/fieldset.component.js +14 -16
  119. package/lib/components/heading/heading.component.d.ts +5 -0
  120. package/lib/components/icon/index.d.ts +1 -0
  121. package/lib/components/multi-action-button/multi-action-button.component.d.ts +3 -1
  122. package/lib/components/multi-action-button/multi-action-button.component.js +6 -4
  123. package/lib/components/multi-action-button/multi-action-button.d.ts +4 -2
  124. package/lib/components/multi-step-wizard/multi-step-wizard.d.ts +22 -0
  125. package/lib/components/multi-step-wizard/step/step.d.ts +6 -0
  126. package/lib/components/multi-step-wizard/step/step.style.d.ts +4 -2
  127. package/lib/components/portrait/portrait-initials.component.js +1 -1
  128. package/lib/components/radio-button/radio-button-svg.component.js +38 -20
  129. package/lib/components/scrollable-list/scrollable-list.component.d.ts +8 -0
  130. package/lib/components/select/select-list/select-list.component.js +1 -1
  131. package/lib/components/select/select-textbox/select-textbox.component.js +1 -1
  132. package/lib/components/split-button/split-button-toggle.style.d.ts +2 -6
  133. package/lib/components/split-button/split-button.component.d.ts +3 -1
  134. package/lib/components/split-button/split-button.component.js +6 -3
  135. package/lib/components/split-button/split-button.d.ts +5 -2
  136. package/lib/components/tabs/__internal__/tab-title/tab-title.style.js +3 -5
  137. package/lib/components/textbox/textbox.component.d.ts +1 -2
  138. package/lib/components/textbox/textbox.component.js +7 -8
  139. package/lib/components/tooltip/index.d.ts +2 -1
  140. package/lib/components/tooltip/tooltip-pointer.style.d.ts +10 -1
  141. package/lib/components/tooltip/tooltip-pointer.style.js +7 -15
  142. package/lib/components/tooltip/tooltip.component.d.ts +33 -2
  143. package/lib/components/tooltip/tooltip.component.js +221 -130
  144. package/lib/components/tooltip/tooltip.config.d.ts +2 -1
  145. package/lib/components/tooltip/tooltip.style.d.ts +7 -2
  146. package/lib/components/tooltip/tooltip.style.js +7 -22
  147. package/lib/components/typography/typography.component.d.ts +1 -1
  148. package/lib/locales/en-gb.d.ts +3 -5
  149. package/lib/locales/en-gb.js +2 -1
  150. package/lib/locales/index.d.ts +1 -1
  151. package/lib/locales/index.js +23 -0
  152. package/lib/locales/locale.d.ts +99 -105
  153. package/lib/locales/locale.js +5 -0
  154. package/lib/{__internal__/utils/ether → locales}/package.json +1 -1
  155. package/lib/locales/pl-pl.d.ts +3 -5
  156. package/lib/locales/pl-pl.js +2 -1
  157. package/lib/style/{fonts → assets}/carbon-icons-webfont.woff +0 -0
  158. package/lib/style/fonts.css +30 -0
  159. package/lib/style/global-style.js +1 -1
  160. package/lib/style/themes/base/base-theme.config.d.ts +17 -8
  161. package/lib/style/themes/sage/index.d.ts +17 -8
  162. package/package.json +10 -5
  163. package/esm/__internal__/utils/ether/ether.d.ts +0 -19
  164. package/esm/__internal__/utils/ether/ether.js +0 -29
  165. package/esm/__internal__/utils/ether/index.d.ts +0 -1
  166. package/esm/__internal__/utils/ether/index.js +0 -1
  167. package/esm/__internal__/utils/helpers/browser/browser.d.ts +0 -17
  168. package/esm/__internal__/utils/helpers/browser/browser.js +0 -198
  169. package/esm/__internal__/utils/helpers/browser-type-check/browser-type-check.d.ts +0 -7
  170. package/esm/__internal__/utils/helpers/browser-type-check/browser-type-check.js +0 -14
  171. package/esm/__internal__/utils/helpers/guid/__spec__.d.ts +0 -1
  172. package/esm/__internal__/utils/helpers/guid/__spec__.js +0 -10
  173. package/esm/__internal__/utils/helpers/guid/guid.d.ts +0 -2
  174. package/esm/__internal__/utils/helpers/guid/package.json +0 -3
  175. package/esm/__internal__/utils/helpers/immutable/__spec__.d.ts +0 -1
  176. package/esm/__internal__/utils/helpers/immutable/__spec__.js +0 -117
  177. package/esm/__internal__/utils/helpers/immutable/immutable.d.ts +0 -4
  178. package/esm/__internal__/utils/helpers/immutable/immutable.js +0 -36
  179. package/esm/__internal__/utils/helpers/immutable/package.json +0 -4
  180. package/esm/__internal__/utils/helpers/with-unique-id-props/index.d.ts +0 -1
  181. package/esm/__internal__/utils/helpers/with-unique-id-props/index.js +0 -1
  182. package/esm/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.d.ts +0 -7
  183. package/esm/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.js +0 -82
  184. package/esm/__internal__/utils/logger/logger.d.ts +0 -9
  185. package/esm/__internal__/utils/logger/logger.js +0 -71
  186. package/esm/components/button/button.d.ts +0 -85
  187. package/esm/components/tooltip/tooltip.d.ts +0 -40
  188. package/lib/__internal__/utils/ether/ether.d.ts +0 -19
  189. package/lib/__internal__/utils/ether/ether.js +0 -33
  190. package/lib/__internal__/utils/ether/index.d.ts +0 -1
  191. package/lib/__internal__/utils/ether/index.js +0 -18
  192. package/lib/__internal__/utils/helpers/browser/browser.d.ts +0 -17
  193. package/lib/__internal__/utils/helpers/browser/browser.js +0 -213
  194. package/lib/__internal__/utils/helpers/browser-type-check/browser-type-check.d.ts +0 -7
  195. package/lib/__internal__/utils/helpers/browser-type-check/browser-type-check.js +0 -26
  196. package/lib/__internal__/utils/helpers/guid/__spec__.d.ts +0 -1
  197. package/lib/__internal__/utils/helpers/guid/__spec__.js +0 -15
  198. package/lib/__internal__/utils/helpers/guid/guid.d.ts +0 -2
  199. package/lib/__internal__/utils/helpers/immutable/__spec__.d.ts +0 -1
  200. package/lib/__internal__/utils/helpers/immutable/__spec__.js +0 -135
  201. package/lib/__internal__/utils/helpers/immutable/immutable.d.ts +0 -4
  202. package/lib/__internal__/utils/helpers/immutable/immutable.js +0 -46
  203. package/lib/__internal__/utils/helpers/immutable/package.json +0 -4
  204. package/lib/__internal__/utils/helpers/with-unique-id-props/index.d.ts +0 -1
  205. package/lib/__internal__/utils/helpers/with-unique-id-props/index.js +0 -15
  206. package/lib/__internal__/utils/helpers/with-unique-id-props/package.json +0 -6
  207. package/lib/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.d.ts +0 -7
  208. package/lib/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.js +0 -96
  209. package/lib/__internal__/utils/logger/logger.d.ts +0 -9
  210. package/lib/__internal__/utils/logger/logger.js +0 -78
  211. package/lib/components/button/button.d.ts +0 -85
  212. package/lib/components/tooltip/tooltip.d.ts +0 -40
@@ -12,7 +12,7 @@ import StyledSplitButtonChildrenContainer from "./split-button-children.style";
12
12
  import Events from "../../__internal__/utils/helpers/events";
13
13
  import guid from "../../__internal__/utils/helpers/guid";
14
14
  import Popover from "../../__internal__/popover";
15
- import { filterStyledSystemMarginProps } from "../../style/utils";
15
+ import { filterStyledSystemMarginProps, filterOutStyledSystemSpacingProps } from "../../style/utils";
16
16
  import { baseTheme } from "../../style/themes";
17
17
  import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
18
18
  import Logger from "../../__internal__/utils/logger";
@@ -32,6 +32,8 @@ const SplitButton = ({
32
32
  size = "medium",
33
33
  subtext,
34
34
  text,
35
+ "data-element": dataElement,
36
+ "data-role": dataRole,
35
37
  ...rest
36
38
  }) => {
37
39
  if (!deprecatedWarnTriggered && as) {
@@ -114,7 +116,8 @@ const SplitButton = ({
114
116
  iconType,
115
117
  onClick,
116
118
  size,
117
- subtext
119
+ subtext,
120
+ ...filterOutStyledSystemSpacingProps(rest)
118
121
  };
119
122
  }
120
123
 
@@ -142,8 +145,8 @@ const SplitButton = ({
142
145
  function componentTags() {
143
146
  return {
144
147
  "data-component": "split-button",
145
- "data-element": rest["data-element"],
146
- "data-role": rest["data-role"]
148
+ "data-element": dataElement,
149
+ "data-role": dataRole
147
150
  };
148
151
  }
149
152
 
@@ -1,6 +1,9 @@
1
1
  import * as React from "react";
2
+ import { MarginProps } from "styled-system";
2
3
 
3
- export interface SplitButtonProps {
4
+ export interface SplitButtonProps
5
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
6
+ MarginProps {
4
7
  /** Set align of the rendered content */
5
8
  align?: "left" | "right";
6
9
  /** Button type: "primary" | "secondary" for legacy theme */
@@ -23,6 +26,6 @@ export interface SplitButtonProps {
23
26
  text: string;
24
27
  }
25
28
 
26
- declare class SplitButton extends React.Component<SplitButtonProps> {}
29
+ declare function SplitButton(props: SplitButtonProps): JSX.Element;
27
30
 
28
31
  export default SplitButton;
@@ -356,18 +356,16 @@ const StyledTabTitle = styled.button`
356
356
 
357
357
  ${alternateStyling && css`
358
358
  &:focus {
359
- background-color: var(--colorsActionMinor100);
359
+ background-color: var(--colorsActionMinor200);
360
360
  }
361
361
 
362
362
  &:hover {
363
- background-color: ${isTabSelected ? "var(--colorsActionMinor100)" : "var(--colorsActionMinor150)"};
363
+ background-color: ${isTabSelected ? "var(--colorsActionMinor200)" : "var(--colorsActionMinor250)"};
364
364
  }
365
365
 
366
366
  ${isTabSelected && css`
367
- background-color: var(--colorsActionMinor100);
367
+ background-color: var(--colorsActionMinor200);
368
368
  `}
369
-
370
- ${isInSidebar && `padding-bottom: 1px;`}
371
369
  `}
372
370
  `}
373
371
  `;
@@ -1,6 +1,5 @@
1
1
  export { Textbox as OriginalTextbox };
2
- declare var _default: JSX.Element;
3
- export default _default;
2
+ export default Textbox;
4
3
  declare function Textbox({ align, autoFocus, children, disabled, inputIcon, leftChildren, labelId: externalLabelId, label, labelAlign, labelHelp, labelInline, labelSpacing, id, formattedValue, fieldHelp, error, warning, info, name, reverse, size, value, readOnly, placeholder, inputRef, onBlur, onClick, onFocus, onChange, onMouseDown, onChangeDeferred, deferTimeout, isOptional, iconOnClick, iconOnMouseDown, iconTabIndex, validationOnLabel, labelWidth, inputWidth, prefix, adaptiveLabelBreakpoint, required, positionedChildren, tooltipPosition, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, enforceCharacterLimit, characterLimit, warnOverLimit, helpAriaLabel, ...props }: {
5
4
  [x: string]: any;
6
5
  align: any;
@@ -7,7 +7,7 @@ import { filterStyledSystemMarginProps } from "../../style/utils";
7
7
  import { Input, InputPresentation } from "../../__internal__/input";
8
8
  import InputIconToggle from "../../__internal__/input-icon-toggle";
9
9
  import FormField from "../../__internal__/form-field";
10
- import withUniqueIdProps from "../../__internal__/utils/helpers/with-unique-id-props";
10
+ import useUniqueId from "../../__internal__/utils/helpers/useUniqueId";
11
11
  import { InputBehaviour } from "../../__internal__/input-behaviour";
12
12
  import StyledPrefix from "./__internal__/prefix.style";
13
13
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
@@ -83,13 +83,14 @@ const Textbox = ({
83
83
 
84
84
  const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
85
85
 
86
+ const [uniqueId, uniqueName] = useUniqueId(id, name);
86
87
  const {
87
88
  labelId: internalLabelId,
88
89
  validationIconId,
89
90
  fieldHelpId,
90
91
  ariaDescribedBy
91
92
  } = useInputAccessibility({
92
- id,
93
+ id: uniqueId,
93
94
  error,
94
95
  warning,
95
96
  info,
@@ -115,7 +116,7 @@ const Textbox = ({
115
116
  labelInline: computeLabelPropValues(labelInline),
116
117
  labelSpacing: labelSpacing,
117
118
  labelWidth: computeLabelPropValues(labelWidth),
118
- id: id,
119
+ id: uniqueId,
119
120
  reverse: computeLabelPropValues(reverse),
120
121
  isOptional: isOptional,
121
122
  useValidationIcon: computeLabelPropValues(validationOnLabel),
@@ -155,9 +156,9 @@ const Textbox = ({
155
156
  autoFocus: autoFocus,
156
157
  deferTimeout: deferTimeout,
157
158
  disabled: disabled,
158
- id: id,
159
+ id: uniqueId,
159
160
  inputRef: inputRef,
160
- name: name,
161
+ name: uniqueName,
161
162
  onBlur: onBlur,
162
163
  onChange: onChange,
163
164
  onChangeDeferred: onChangeDeferred,
@@ -379,4 +380,4 @@ Textbox.defaultProps = {
379
380
  validationOnLabel: false
380
381
  };
381
382
  export { Textbox as OriginalTextbox };
382
- export default withUniqueIdProps(Textbox);
383
+ export default Textbox;
@@ -1 +1,2 @@
1
- export { default } from "./tooltip";
1
+ export { default } from "./tooltip.component";
2
+ export type { TooltipProps } from "./tooltip.component";
@@ -1,2 +1,11 @@
1
+ import { Placement } from "tippy.js";
2
+ interface StyledTooltipPointer {
3
+ /** Sets position of the tooltip */
4
+ position?: Placement;
5
+ /** Defines the message type */
6
+ type?: string;
7
+ /** Override background color of the Tooltip, provide any color from palette or any valid css color value. */
8
+ bgColor?: string;
9
+ }
10
+ declare const StyledTooltipPointer: import("styled-components").StyledComponent<"div", any, StyledTooltipPointer, never>;
1
11
  export default StyledTooltipPointer;
2
- declare const StyledTooltipPointer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,9 +1,8 @@
1
- import PropTypes from "prop-types";
2
1
  import styled, { css } from "styled-components";
3
2
  import baseTheme from "../../style/themes/base";
4
3
  import { toColor } from "../../style/utils/color";
5
4
 
6
- const pointerColor = (type, theme, bgColor) => {
5
+ const pointerColor = (theme, bgColor, type) => {
7
6
  if (bgColor) return toColor(theme, bgColor);
8
7
  return type === "error" ? "var(--colorsSemanticNegative500)" : "var(--colorsSemanticNeutral500)";
9
8
  };
@@ -22,7 +21,7 @@ const StyledTooltipPointer = styled.div`
22
21
  ${position === "top" && css`
23
22
  border-left: 8px solid transparent;
24
23
  border-right: 8px solid transparent;
25
- border-top: 8px solid ${pointerColor(type, theme, bgColor)};
24
+ border-top: 8px solid ${pointerColor(theme, bgColor, type)};
26
25
  bottom: calc(-1 * var(--spacing100));
27
26
  @-moz-document url-prefix() {
28
27
  bottom: -7px;
@@ -32,7 +31,7 @@ const StyledTooltipPointer = styled.div`
32
31
  ${position === "bottom" && css`
33
32
  border-left: 8px solid transparent;
34
33
  border-right: 8px solid transparent;
35
- border-bottom: 8px solid ${pointerColor(type, theme, bgColor)};
34
+ border-bottom: 8px solid ${pointerColor(theme, bgColor, type)};
36
35
  top: calc(-1 * var(--spacing100));
37
36
  @-moz-document url-prefix() {
38
37
  top: -7px;
@@ -42,7 +41,7 @@ const StyledTooltipPointer = styled.div`
42
41
  ${position === "right" && css`
43
42
  border-top: 8px solid transparent;
44
43
  border-bottom: 8px solid transparent;
45
- border-right: 8px solid ${pointerColor(type, theme, bgColor)};
44
+ border-right: 8px solid ${pointerColor(theme, bgColor, type)};
46
45
  left: calc(-1 * var(--spacing100));
47
46
  @-moz-document url-prefix() {
48
47
  left: -7px;
@@ -52,7 +51,7 @@ const StyledTooltipPointer = styled.div`
52
51
  ${position === "left" && css`
53
52
  border-top: 8px solid transparent;
54
53
  border-bottom: 8px solid transparent;
55
- border-left: 8px solid ${pointerColor(type, theme, bgColor)};
54
+ border-left: 8px solid ${pointerColor(theme, bgColor, type)};
56
55
  right: calc(-1 * var(--spacing100));
57
56
  @-moz-document url-prefix() {
58
57
  right: -7px;
@@ -64,10 +63,4 @@ StyledTooltipPointer.defaultProps = {
64
63
  theme: baseTheme,
65
64
  position: "top"
66
65
  };
67
- StyledTooltipPointer.propTypes = {
68
- position: PropTypes.oneOf(["bottom", "left", "right", "top"]),
69
- theme: PropTypes.object,
70
- type: PropTypes.string,
71
- bgColor: PropTypes.string
72
- };
73
66
  export default StyledTooltipPointer;
@@ -1,3 +1,34 @@
1
- export default Tooltip;
2
- declare const Tooltip: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
1
  import React from "react";
2
+ import { TooltipPositions } from "./tooltip.config";
3
+ export declare type InputSizes = "small" | "medium" | "large";
4
+ export interface TooltipProps {
5
+ /** The message to be displayed within the tooltip */
6
+ message: React.ReactNode;
7
+ /** The id attribute to use for the tooltip */
8
+ id?: string;
9
+ /** Whether to to show the Tooltip */
10
+ isVisible?: boolean;
11
+ /** Sets position of the tooltip */
12
+ position?: TooltipPositions;
13
+ /** Defines the message type */
14
+ type?: string;
15
+ /** Children elements */
16
+ children: React.ReactElement;
17
+ /** Defines the size of the tooltip content */
18
+ size?: "medium" | "large";
19
+ /** Override background color of the Tooltip, provide any color from palette or any valid css color value. */
20
+ bgColor?: string;
21
+ /** Override font color of the Tooltip, provide any color from palette or any valid css color value. */
22
+ fontColor?: string;
23
+ /**
24
+ * Overrides the default flip behaviour of the Tooltip,
25
+ * must be an array containing some or all of ["top", "bottom", "left", "right"]
26
+ * (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements)
27
+ */
28
+ flipOverrides?: TooltipPositions[];
29
+ target?: Element;
30
+ isPartOfInput?: boolean;
31
+ inputSize?: InputSizes;
32
+ }
33
+ export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement | null>>;
34
+ export default Tooltip;
@@ -1,134 +1,279 @@
1
- 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); }
1
+ function _extends() {
2
+ _extends =
3
+ Object.assign ||
4
+ function (target) {
5
+ for (var i = 1; i < arguments.length; i++) {
6
+ var source = arguments[i];
7
+ for (var key in source) {
8
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
9
+ target[key] = source[key];
10
+ }
11
+ }
12
+ }
13
+ return target;
14
+ };
15
+ return _extends.apply(this, arguments);
16
+ }
2
17
 
3
- import React, { useRef } from "react";
18
+ import React from "react";
4
19
  import PropTypes from "prop-types";
5
20
  import Tippy from "@tippyjs/react/headless";
6
21
  import { sticky } from "tippy.js";
22
+ import invariant from "invariant";
7
23
  import StyledTooltip from "./tooltip.style";
8
24
  import StyledPointer from "./tooltip-pointer.style";
25
+ import { TOOLTIP_POSITIONS } from "./tooltip.config";
9
26
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
10
27
  import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component";
11
28
  const TOOLTIP_DELAY = 100;
12
29
  const tippyPlugins = [sticky];
13
- const Tooltip = /*#__PURE__*/React.forwardRef(({
14
- children,
15
- isVisible,
16
- position = "top",
17
- message,
18
- type,
19
- size = "medium",
20
- isPartOfInput,
21
- inputSize,
22
- id,
23
- bgColor,
24
- fontColor,
25
- flipOverrides,
26
- target,
27
- ...rest
28
- }, ref) => {
29
- const tooltipRef = useRef(ref || null);
30
+ const Tooltip = /*#__PURE__*/ React.forwardRef(
31
+ (
32
+ {
33
+ children,
34
+ isVisible,
35
+ position = "top",
36
+ message,
37
+ type,
38
+ size = "medium",
39
+ isPartOfInput,
40
+ inputSize,
41
+ id,
42
+ bgColor,
43
+ fontColor,
44
+ flipOverrides,
45
+ target,
46
+ ...rest
47
+ },
48
+ ref
49
+ ) => {
50
+ const isFlipOverridesValid =
51
+ !flipOverrides ||
52
+ (Array.isArray(flipOverrides) &&
53
+ flipOverrides.every((placement) =>
54
+ TOOLTIP_POSITIONS.includes(placement)
55
+ ));
56
+ invariant(
57
+ isFlipOverridesValid,
58
+ `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`
59
+ );
30
60
 
31
- const tooltip = (attrs, content) => {
32
- const currentPosition = attrs["data-placement"] || position;
33
- return /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null, /*#__PURE__*/React.createElement(StyledTooltip, _extends({
34
- "data-element": "tooltip",
35
- role: "tooltip",
36
- tabIndex: "-1",
37
- type: type,
38
- size: size,
39
- id: id
40
- }, tagComponent("tooltip", rest), {
41
- isPartOfInput: isPartOfInput,
42
- inputSize: inputSize
43
- }, attrs, {
44
- position: currentPosition,
45
- ref: tooltipRef,
46
- bgColor: bgColor,
47
- fontColor: fontColor
48
- }), /*#__PURE__*/React.createElement(StyledPointer, _extends({
49
- key: "pointer",
50
- type: type
51
- }, attrs, {
52
- position: currentPosition,
53
- "data-popper-arrow": "",
54
- "data-element": "tooltip-pointer",
55
- bgColor: bgColor
56
- })), content));
57
- };
61
+ const tooltip = (attrs, content) => {
62
+ const currentPosition = attrs["data-placement"] || position;
63
+ return /*#__PURE__*/ React.createElement(
64
+ CarbonScopedTokensProvider,
65
+ null,
66
+ /*#__PURE__*/ React.createElement(
67
+ StyledTooltip,
68
+ _extends(
69
+ {
70
+ "data-element": "tooltip",
71
+ role: "tooltip",
72
+ tabIndex: -1,
73
+ type: type,
74
+ size: size,
75
+ id: id,
76
+ },
77
+ tagComponent("tooltip", rest),
78
+ {
79
+ isPartOfInput: isPartOfInput,
80
+ inputSize: inputSize,
81
+ },
82
+ attrs,
83
+ {
84
+ position: currentPosition,
85
+ ref: ref,
86
+ bgColor: bgColor,
87
+ fontColor: fontColor,
88
+ }
89
+ ),
90
+ /*#__PURE__*/ React.createElement(
91
+ StyledPointer,
92
+ _extends(
93
+ {
94
+ key: "pointer",
95
+ type: type,
96
+ },
97
+ attrs,
98
+ {
99
+ position: currentPosition,
100
+ "data-popper-arrow": "",
101
+ "data-element": "tooltip-pointer",
102
+ bgColor: bgColor,
103
+ }
104
+ )
105
+ ),
106
+ content
107
+ )
108
+ );
109
+ };
58
110
 
59
- return /*#__PURE__*/React.createElement(Tippy, _extends({
60
- placement: position,
61
- delay: TOOLTIP_DELAY
62
- }, isVisible !== undefined && {
63
- visible: isVisible
64
- }, {
65
- plugins: tippyPlugins,
66
- sticky: true,
67
- render: attrs => tooltip(attrs, message),
68
- reference: target,
69
- popperOptions: {
70
- modifiers: [...(flipOverrides ? [{
71
- name: "flip",
72
- options: {
73
- fallbackPlacements: flipOverrides
74
- }
75
- }] : []), {
76
- name: "computeStyles",
77
- options: {
78
- gpuAcceleration: false
111
+ return /*#__PURE__*/ React.createElement(
112
+ Tippy,
113
+ _extends(
114
+ {
115
+ placement: position,
116
+ delay: TOOLTIP_DELAY,
117
+ },
118
+ isVisible !== undefined && {
119
+ visible: isVisible,
120
+ },
121
+ {
122
+ plugins: tippyPlugins,
123
+ sticky: true,
124
+ render: (attrs) => tooltip(attrs, message),
125
+ reference: target,
126
+ popperOptions: {
127
+ modifiers: [
128
+ ...(flipOverrides
129
+ ? [
130
+ {
131
+ name: "flip",
132
+ options: {
133
+ fallbackPlacements: flipOverrides,
134
+ },
135
+ },
136
+ ]
137
+ : []),
138
+ {
139
+ name: "computeStyles",
140
+ options: {
141
+ gpuAcceleration: false,
142
+ },
143
+ },
144
+ ],
145
+ },
79
146
  }
80
- }]
81
- }
82
- }), children);
83
- });
84
- const placements = ["top", "bottom", "left", "right"];
85
- Tooltip.propTypes = {
86
- /** The message to be displayed within the tooltip */
87
- message: PropTypes.node.isRequired,
147
+ ),
148
+ children
149
+ );
150
+ }
151
+ );
88
152
 
89
- /** The id attribute to use for the tooltip */
153
+ Tooltip.propTypes = {
154
+ /**
155
+ * Override background color of the Tooltip, provide any color from palette or any valid css color value.
156
+ */
157
+ bgColor: PropTypes.string,
158
+ /**
159
+ * Children elements
160
+ */
161
+ children: PropTypes.element.isRequired,
162
+ /**
163
+ * Overrides the default flip behaviour of the Tooltip,
164
+ * must be an array containing some or all of ["top", "bottom", "left", "right"]
165
+ * (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements)
166
+ */
167
+ flipOverrides: PropTypes.arrayOf(
168
+ PropTypes.oneOf(["bottom", "left", "right", "top"])
169
+ ),
170
+ /**
171
+ * Override font color of the Tooltip, provide any color from palette or any valid css color value.
172
+ */
173
+ fontColor: PropTypes.string,
174
+ /**
175
+ * The id attribute to use for the tooltip
176
+ */
90
177
  id: PropTypes.string,
91
-
92
- /** Whether to to show the Tooltip */
178
+ inputSize: PropTypes.oneOf(["large", "medium", "small"]),
179
+ isPartOfInput: PropTypes.bool,
180
+ /**
181
+ * Whether to to show the Tooltip
182
+ */
93
183
  isVisible: PropTypes.bool,
94
-
95
- /** Sets position of the tooltip */
96
- position: PropTypes.oneOf(placements),
97
-
98
- /** Defines the message type */
184
+ key: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
185
+ /**
186
+ * The message to be displayed within the tooltip
187
+ */
188
+ message: PropTypes.node,
189
+ /**
190
+ * Sets position of the tooltip
191
+ */
192
+ position: PropTypes.oneOf(["bottom", "left", "right", "top"]),
193
+ /**
194
+ * Defines the size of the tooltip content
195
+ */
196
+ size: PropTypes.oneOf(["large", "medium"]),
197
+ target: function (props, propName) {
198
+ if (props[propName] == null) {
199
+ return null;
200
+ } else if (
201
+ typeof props[propName] !== "object" ||
202
+ props[propName].nodeType !== 1
203
+ ) {
204
+ return new Error(
205
+ "Expected prop '" + propName + "' to be of type Element"
206
+ );
207
+ }
208
+ },
209
+ /**
210
+ * Defines the message type
211
+ */
99
212
  type: PropTypes.string,
213
+ };
100
214
 
101
- /** Children elements */
102
- children: PropTypes.node.isRequired,
103
-
104
- /** Defines the size of the tooltip content */
105
- size: PropTypes.oneOf(["medium", "large"]),
106
- // Reference element, tooltip will be positioned in relation to this element
107
- target: PropTypes.instanceOf(Element),
108
-
109
- /** Override background color of the Tooltip, provide design token, any color from palette or any valid css color value. */
215
+ Tooltip.propTypes = {
216
+ /**
217
+ * Override background color of the Tooltip, provide any color from palette or any valid css color value.
218
+ */
110
219
  bgColor: PropTypes.string,
111
-
112
- /** Override font color of the Tooltip, provide design token, any color from palette or any valid css color value. */
220
+ /**
221
+ * Children elements
222
+ */
223
+ children: PropTypes.element.isRequired,
224
+ /**
225
+ * Overrides the default flip behaviour of the Tooltip,
226
+ * must be an array containing some or all of ["top", "bottom", "left", "right"]
227
+ * (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements)
228
+ */
229
+ flipOverrides: PropTypes.arrayOf(
230
+ PropTypes.oneOf(["bottom", "left", "right", "top"])
231
+ ),
232
+ /**
233
+ * Override font color of the Tooltip, provide any color from palette or any valid css color value.
234
+ */
113
235
  fontColor: PropTypes.string,
114
-
115
- /** @ignore @private */
236
+ /**
237
+ * The id attribute to use for the tooltip
238
+ */
239
+ id: PropTypes.string,
240
+ inputSize: PropTypes.oneOf(["large", "medium", "small"]),
116
241
  isPartOfInput: PropTypes.bool,
117
-
118
- /** @ignore @private */
119
- inputSize: PropTypes.oneOf(["small", "medium", "large"]),
120
-
121
- /** Overrides the default flip behaviour of the Tooltip, must be an array containing some or all of ["top", "bottom", "left", "right"] (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements) */
122
- flipOverrides: (props, propName) => {
123
- const prop = props[propName];
124
- const isValid = prop && Array.isArray(prop) && prop.every(placement => placements.includes(placement));
125
-
126
- if (!prop || isValid) {
242
+ /**
243
+ * Whether to to show the Tooltip
244
+ */
245
+ isVisible: PropTypes.bool,
246
+ key: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
247
+ /**
248
+ * The message to be displayed within the tooltip
249
+ */
250
+ message: PropTypes.node,
251
+ /**
252
+ * Sets position of the tooltip
253
+ */
254
+ position: PropTypes.oneOf(["bottom", "left", "right", "top"]),
255
+ /**
256
+ * Defines the size of the tooltip content
257
+ */
258
+ size: PropTypes.oneOf(["large", "medium"]),
259
+ target: function (props, propName) {
260
+ if (props[propName] == null) {
127
261
  return null;
262
+ } else if (
263
+ typeof props[propName] !== "object" ||
264
+ props[propName].nodeType !== 1
265
+ ) {
266
+ return new Error(
267
+ "Expected prop '" + propName + "' to be of type Element"
268
+ );
128
269
  }
129
-
130
- return new Error( // eslint-disable-next-line max-len
131
- `The \`${propName}\` prop supplied to \`Tooltip\` must be an array containing some or all of ["top", "bottom", "left", "right"].`);
132
- }
270
+ },
271
+ /**
272
+ * Defines the message type
273
+ */
274
+ type: PropTypes.string,
133
275
  };
134
- export default Tooltip;
276
+
277
+ export { Tooltip };
278
+ Tooltip.displayName = "Tooltip";
279
+ export default Tooltip;
@@ -1 +1,2 @@
1
- export const TOOLTIP_POSITIONS: string[];
1
+ export declare const TOOLTIP_POSITIONS: string[];
2
+ export declare type TooltipPositions = "top" | "bottom" | "left" | "right";
@@ -1,2 +1,7 @@
1
- export default StyledTooltipWrapper;
2
- declare const StyledTooltipWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
1
+ import { Placement } from "tippy.js";
2
+ import { TooltipProps } from "./tooltip.component";
3
+ interface StyledTooltipProps extends Omit<TooltipProps, "children" | "message" | "position"> {
4
+ position: Placement;
5
+ }
6
+ declare const StyledTooltip: import("styled-components").StyledComponent<"div", any, StyledTooltipProps, never>;
7
+ export default StyledTooltip;