carbon-react 109.7.1 → 110.0.2

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 (67) hide show
  1. package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +1 -1
  2. package/esm/components/date/date.component.js +17 -15
  3. package/esm/components/definition-list/__internal__/dl.context.d.ts +6 -0
  4. package/esm/components/definition-list/dd.component.d.ts +8 -0
  5. package/esm/components/definition-list/dd.component.js +310 -5
  6. package/esm/components/definition-list/definition-list.style.d.ts +22 -0
  7. package/esm/components/definition-list/definition-list.style.js +3 -4
  8. package/esm/components/definition-list/dl.component.d.ts +9 -0
  9. package/esm/components/definition-list/dl.component.js +323 -27
  10. package/esm/components/definition-list/dt.component.d.ts +8 -0
  11. package/esm/components/definition-list/dt.component.js +310 -5
  12. package/esm/components/definition-list/index.d.ts +6 -3
  13. package/esm/components/definition-list/index.js +2 -2
  14. package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +30 -2
  15. package/esm/components/link/link.component.d.ts +0 -2
  16. package/esm/components/link/link.component.js +0 -4
  17. package/esm/components/menu/__internal__/submenu/submenu.component.js +6 -8
  18. package/esm/components/multi-action-button/multi-action-button.component.js +2 -1
  19. package/esm/components/popover-container/popover-container.component.js +2 -3
  20. package/esm/components/profile/index.d.ts +2 -1
  21. package/esm/components/profile/profile.component.d.ts +18 -0
  22. package/esm/components/profile/profile.component.js +8 -21
  23. package/esm/components/profile/profile.config.d.ts +55 -0
  24. package/esm/components/profile/profile.style.d.ts +16 -0
  25. package/esm/components/profile/profile.style.js +5 -14
  26. package/esm/components/split-button/split-button.component.js +2 -1
  27. package/esm/components/text-editor/__internal__/editor-link/editor-link.component.js +3 -4
  28. package/esm/hooks/__internal__/useClickAwayListener/useClickAwayListener.d.ts +1 -2
  29. package/esm/hooks/__internal__/useClickAwayListener/useClickAwayListener.js +20 -18
  30. package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +1 -1
  31. package/lib/components/date/date.component.js +17 -15
  32. package/lib/components/definition-list/__internal__/dl.context.d.ts +6 -0
  33. package/lib/components/definition-list/dd.component.d.ts +8 -0
  34. package/lib/components/definition-list/dd.component.js +311 -7
  35. package/lib/components/definition-list/definition-list.style.d.ts +22 -0
  36. package/lib/components/definition-list/definition-list.style.js +3 -4
  37. package/lib/components/definition-list/dl.component.d.ts +9 -0
  38. package/lib/components/definition-list/dl.component.js +326 -28
  39. package/lib/components/definition-list/dt.component.d.ts +8 -0
  40. package/lib/components/definition-list/dt.component.js +311 -7
  41. package/lib/components/definition-list/index.d.ts +6 -3
  42. package/lib/components/definition-list/index.js +8 -8
  43. package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +30 -2
  44. package/lib/components/link/link.component.d.ts +0 -2
  45. package/lib/components/link/link.component.js +0 -4
  46. package/lib/components/menu/__internal__/submenu/submenu.component.js +6 -8
  47. package/lib/components/multi-action-button/multi-action-button.component.js +2 -1
  48. package/lib/components/popover-container/popover-container.component.js +2 -3
  49. package/lib/components/profile/index.d.ts +2 -1
  50. package/lib/components/profile/profile.component.d.ts +18 -0
  51. package/lib/components/profile/profile.component.js +9 -24
  52. package/lib/components/profile/profile.config.d.ts +55 -0
  53. package/lib/components/profile/profile.style.d.ts +16 -0
  54. package/lib/components/profile/profile.style.js +5 -14
  55. package/lib/components/split-button/split-button.component.js +2 -1
  56. package/lib/components/text-editor/__internal__/editor-link/editor-link.component.js +3 -4
  57. package/lib/hooks/__internal__/useClickAwayListener/useClickAwayListener.d.ts +1 -2
  58. package/lib/hooks/__internal__/useClickAwayListener/useClickAwayListener.js +20 -18
  59. package/package.json +1 -1
  60. package/esm/components/definition-list/dd.d.ts +0 -11
  61. package/esm/components/definition-list/dl.d.ts +0 -19
  62. package/esm/components/definition-list/dt.d.ts +0 -10
  63. package/esm/components/profile/profile.d.ts +0 -18
  64. package/lib/components/definition-list/dd.d.ts +0 -11
  65. package/lib/components/definition-list/dl.d.ts +0 -19
  66. package/lib/components/definition-list/dt.d.ts +0 -10
  67. package/lib/components/profile/profile.d.ts +0 -18
@@ -0,0 +1,55 @@
1
+ export declare const PROFILE_SIZES: readonly ["XS", "S", "M", "ML", "L", "XL", "XXL"];
2
+ declare type AllProfileSizes = typeof PROFILE_SIZES;
3
+ export declare type ProfileSize = AllProfileSizes[number];
4
+ declare const _default: {
5
+ XS: {
6
+ nameSize: string;
7
+ emailSize: string;
8
+ lineHeight: string;
9
+ marginLeft: string;
10
+ marginTop: string;
11
+ };
12
+ S: {
13
+ nameSize: string;
14
+ emailSize: string;
15
+ lineHeight: string;
16
+ marginLeft: string;
17
+ marginTop: string;
18
+ };
19
+ M: {
20
+ nameSize: string;
21
+ emailSize: string;
22
+ lineHeight: string;
23
+ marginLeft: string;
24
+ marginTop: string;
25
+ };
26
+ ML: {
27
+ nameSize: string;
28
+ emailSize: string;
29
+ lineHeight: string;
30
+ marginLeft: string;
31
+ marginTop: string;
32
+ };
33
+ L: {
34
+ nameSize: string;
35
+ emailSize: string;
36
+ lineHeight: string;
37
+ marginLeft: string;
38
+ marginTop: string;
39
+ };
40
+ XL: {
41
+ nameSize: string;
42
+ emailSize: string;
43
+ lineHeight: string;
44
+ marginLeft: string;
45
+ marginTop: string;
46
+ };
47
+ XXL: {
48
+ nameSize: string;
49
+ emailSize: string;
50
+ lineHeight: string;
51
+ marginLeft: string;
52
+ marginTop: string;
53
+ };
54
+ };
55
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import Portrait from "../portrait";
2
+ import { ProfileSize } from "./profile.config";
3
+ interface ProfileSizeProps {
4
+ size?: ProfileSize;
5
+ }
6
+ interface ProfileHasSrcProps {
7
+ hasSrc: boolean;
8
+ }
9
+ interface ProfileDetailsStyleProps extends ProfileSizeProps, ProfileHasSrcProps {
10
+ }
11
+ declare const ProfileNameStyle: import("styled-components").StyledComponent<"span", any, ProfileSizeProps, never>;
12
+ declare const ProfileEmailStyle: import("styled-components").StyledComponent<"span", any, ProfileSizeProps, never>;
13
+ declare const ProfileStyle: import("styled-components").StyledComponent<"div", any, ProfileHasSrcProps, never>;
14
+ declare const ProfileDetailsStyle: import("styled-components").StyledComponent<"div", any, ProfileDetailsStyleProps, never>;
15
+ declare const ProfileAvatarStyle: import("styled-components").StyledComponent<typeof Portrait, any, {}, never>;
16
+ export { ProfileStyle, ProfileNameStyle, ProfileDetailsStyle, ProfileAvatarStyle, ProfileEmailStyle, };
@@ -21,13 +21,13 @@ const ProfileNameStyle = _styledComponents.default.span`
21
21
  font-weight: bold;
22
22
  display: block;
23
23
  font-size: ${({
24
- size
24
+ size = "M"
25
25
  }) => _profile.default[size].nameSize};
26
26
  `;
27
27
  exports.ProfileNameStyle = ProfileNameStyle;
28
28
  const ProfileEmailStyle = _styledComponents.default.span`
29
29
  font-size: ${({
30
- size
30
+ size = "M"
31
31
  }) => _profile.default[size].emailSize};
32
32
  `;
33
33
  exports.ProfileEmailStyle = ProfileEmailStyle;
@@ -46,13 +46,13 @@ const ProfileDetailsStyle = _styledComponents.default.div`
46
46
  display: inline-block;
47
47
  margin-top: ${({
48
48
  hasSrc,
49
- size
49
+ size = "M"
50
50
  }) => hasSrc ? _profile.default[size].marginTop : ""};
51
51
  line-height: ${({
52
- size
52
+ size = "M"
53
53
  }) => _profile.default[size].lineHeight};
54
54
  margin-left: ${({
55
- size
55
+ size = "M"
56
56
  }) => _profile.default[size].marginLeft};
57
57
  `;
58
58
  exports.ProfileDetailsStyle = ProfileDetailsStyle;
@@ -62,13 +62,4 @@ const ProfileAvatarStyle = (0, _styledComponents.default)(_portrait.default)`
62
62
  exports.ProfileAvatarStyle = ProfileAvatarStyle;
63
63
  ProfileStyle.defaultProps = {
64
64
  theme: _base.default
65
- };
66
- ProfileNameStyle.defaultProps = {
67
- size: "M"
68
- };
69
- ProfileEmailStyle.defaultProps = {
70
- size: "M"
71
- };
72
- ProfileDetailsStyle.defaultProps = {
73
- size: "M"
74
65
  };
@@ -201,10 +201,11 @@ const SplitButton = ({
201
201
  }, childrenWithProps()));
202
202
  }
203
203
 
204
- (0, _useClickAwayListener.default)([splitButtonNode], hideButtons);
204
+ const handleClick = (0, _useClickAwayListener.default)(hideButtons);
205
205
  return /*#__PURE__*/_react.default.createElement(_splitButton.default, _extends({
206
206
  "aria-haspopup": "true",
207
207
  onMouseLeave: hideButtons,
208
+ onClick: handleClick,
208
209
  ref: splitButtonNode
209
210
  }, componentTags(), (0, _utils.filterStyledSystemMarginProps)(rest)), renderMainButton(), renderAdditionalButtons());
210
211
  };
@@ -47,12 +47,11 @@ const EditorLink = ({
47
47
 
48
48
  }, [validUrl]);
49
49
  return /*#__PURE__*/_react.default.createElement(_editorLink.default, _extends({
50
- href: validUrl,
50
+ href: !editMode ? validUrl : undefined,
51
51
  title: validUrl,
52
- "aria-label": validUrl,
52
+ "aria-label": !editMode ? validUrl : undefined,
53
53
  target: "_blank",
54
- rel: "noopener noreferrer",
55
- tabbable: !editMode
54
+ rel: "noopener noreferrer"
56
55
  }, rest), children);
57
56
  };
58
57
 
@@ -1,3 +1,2 @@
1
- import React from "react";
2
- declare const _default: (targets: React.RefObject<HTMLElement>[], handleClickAway: (ev: Event) => void, eventTypeId?: "mousedown" | "click") => void;
1
+ declare const _default: (handleClickAway: (ev: Event) => void, eventTypeId?: "mousedown" | "click") => () => void;
3
2
  export default _default;
@@ -7,27 +7,29 @@ exports.default = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- var _default = (targets, handleClickAway, eventTypeId = "click") => {
11
- const targetsRef = (0, _react.useRef)(targets);
12
- targetsRef.current = targets;
13
- (0, _react.useEffect)(() => {
14
- const fnClickAway = ev => {
15
- const clickedElements = targetsRef.current.filter(targetRef => {
16
- var _targetRef$current;
17
-
18
- return (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.contains(ev === null || ev === void 0 ? void 0 : ev.target);
19
- });
10
+ // Needs to also take Portals into account (so can't just check DOM containment), but ideally without using
11
+ // event.stopPropagation() which could have unexpected and frustrating consequences for consumers.
12
+ // Simple approach taken from https://github.com/facebook/react/issues/10962#issuecomment-444622208
13
+ var _default = (handleClickAway, eventTypeId = "click") => {
14
+ const clickIsInside = (0, _react.useRef)(false);
15
+ const onDocumentClick = (0, _react.useCallback)(ev => {
16
+ if (clickIsInside.current) {
17
+ clickIsInside.current = false;
18
+ return;
19
+ }
20
20
 
21
- if (!(clickedElements !== null && clickedElements !== void 0 && clickedElements.length)) {
22
- handleClickAway(ev);
23
- }
24
- };
25
-
26
- document.addEventListener(eventTypeId, fnClickAway);
21
+ handleClickAway(ev);
22
+ }, [handleClickAway]);
23
+ const onInsideClick = (0, _react.useCallback)(() => {
24
+ clickIsInside.current = true;
25
+ }, []);
26
+ (0, _react.useEffect)(() => {
27
+ document.addEventListener(eventTypeId, onDocumentClick);
27
28
  return function cleanup() {
28
- document.removeEventListener(eventTypeId, fnClickAway);
29
+ document.removeEventListener(eventTypeId, onDocumentClick);
29
30
  };
30
- }, [handleClickAway, eventTypeId]);
31
+ }, [onDocumentClick, eventTypeId]);
32
+ return onInsideClick;
31
33
  };
32
34
 
33
35
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "109.7.1",
3
+ "version": "110.0.2",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -1,11 +0,0 @@
1
- import * as React from "react";
2
- import { SpaceProps } from "styled-system";
3
-
4
- export interface DdProps extends SpaceProps {
5
- /** Prop for what will render in the `<Dd></Dd>` tags */
6
- children: React.ReactNode;
7
- }
8
-
9
- declare function DdComponent(props: DdProps): JSX.Element;
10
-
11
- export default DdComponent;
@@ -1,19 +0,0 @@
1
- import * as React from "react";
2
- import { SpaceProps } from "styled-system";
3
-
4
- export interface DlProps extends SpaceProps {
5
- /** This string will specify the text align styling of the `<dt></dt>`. */
6
- dtTextAlign?: "left" | "center" | "right";
7
- /** This string will specify the text align styling of the `<dd></dd>`. */
8
- ddTextAlign?: "left" | "center" | "right";
9
- /** This value will specify the width of the `StyledDtDiv` as a percentage. */
10
- w?: number;
11
- /** prop to render children. */
12
- children: React.ReactNode;
13
- /** Render the DefinitionList as a single column */
14
- asSingleColumn?: boolean;
15
- }
16
-
17
- declare function DlComponent(props: DlProps): JSX.Element;
18
-
19
- export default DlComponent;
@@ -1,10 +0,0 @@
1
- import { SpaceProps } from "styled-system";
2
-
3
- export interface DtProps extends SpaceProps {
4
- /** prop for dt text */
5
- children: string;
6
- }
7
-
8
- declare function DtComponent(props: DtProps): JSX.Element;
9
-
10
- export default DtComponent;
@@ -1,18 +0,0 @@
1
- export interface ProfileProps {
2
- /** [Legacy] A custom class name for the component */
3
- className?: string;
4
- /** Custom source URL */
5
- src?: string;
6
- /** Define the name to display. */
7
- name: string;
8
- /** Define the email to use (will check Gravatar for image). */
9
- email: string;
10
- /** Define initials to display if there is no Gravatar image. */
11
- initials?: string;
12
- /** Allow to setup size for the component */
13
- size?: "XS" | "S" | "M" | "ML" | "L" | "XL" | "XXL";
14
- }
15
-
16
- declare function Profile(props: ProfileProps): JSX.Element;
17
-
18
- export default Profile;
@@ -1,11 +0,0 @@
1
- import * as React from "react";
2
- import { SpaceProps } from "styled-system";
3
-
4
- export interface DdProps extends SpaceProps {
5
- /** Prop for what will render in the `<Dd></Dd>` tags */
6
- children: React.ReactNode;
7
- }
8
-
9
- declare function DdComponent(props: DdProps): JSX.Element;
10
-
11
- export default DdComponent;
@@ -1,19 +0,0 @@
1
- import * as React from "react";
2
- import { SpaceProps } from "styled-system";
3
-
4
- export interface DlProps extends SpaceProps {
5
- /** This string will specify the text align styling of the `<dt></dt>`. */
6
- dtTextAlign?: "left" | "center" | "right";
7
- /** This string will specify the text align styling of the `<dd></dd>`. */
8
- ddTextAlign?: "left" | "center" | "right";
9
- /** This value will specify the width of the `StyledDtDiv` as a percentage. */
10
- w?: number;
11
- /** prop to render children. */
12
- children: React.ReactNode;
13
- /** Render the DefinitionList as a single column */
14
- asSingleColumn?: boolean;
15
- }
16
-
17
- declare function DlComponent(props: DlProps): JSX.Element;
18
-
19
- export default DlComponent;
@@ -1,10 +0,0 @@
1
- import { SpaceProps } from "styled-system";
2
-
3
- export interface DtProps extends SpaceProps {
4
- /** prop for dt text */
5
- children: string;
6
- }
7
-
8
- declare function DtComponent(props: DtProps): JSX.Element;
9
-
10
- export default DtComponent;
@@ -1,18 +0,0 @@
1
- export interface ProfileProps {
2
- /** [Legacy] A custom class name for the component */
3
- className?: string;
4
- /** Custom source URL */
5
- src?: string;
6
- /** Define the name to display. */
7
- name: string;
8
- /** Define the email to use (will check Gravatar for image). */
9
- email: string;
10
- /** Define initials to display if there is no Gravatar image. */
11
- initials?: string;
12
- /** Allow to setup size for the component */
13
- size?: "XS" | "S" | "M" | "ML" | "L" | "XL" | "XXL";
14
- }
15
-
16
- declare function Profile(props: ProfileProps): JSX.Element;
17
-
18
- export default Profile;