carbon-react 144.10.0 → 144.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/esm/components/draggable/draggable-container.component.d.ts +6 -1
  2. package/esm/components/draggable/draggable-container.component.js +4 -1
  3. package/esm/components/draggable/draggable-item/draggable-item.component.d.ts +6 -1
  4. package/esm/components/draggable/draggable-item/draggable-item.component.js +7 -3
  5. package/esm/components/draggable/draggable-item/draggable-item.style.d.ts +2 -3
  6. package/esm/components/draggable/draggable-item/draggable-item.style.js +5 -6
  7. package/esm/components/tabs/__internal__/tab-title/tab-title.component.js +0 -1
  8. package/esm/components/tabs/__internal__/tab-title/tab-title.style.js +166 -118
  9. package/esm/components/tabs/__internal__/tabs-header/tabs-header.component.d.ts +2 -1
  10. package/esm/components/tabs/__internal__/tabs-header/tabs-header.component.js +102 -50
  11. package/esm/components/tabs/__internal__/tabs-header/tabs-header.style.d.ts +21 -10
  12. package/esm/components/tabs/__internal__/tabs-header/tabs-header.style.js +72 -85
  13. package/esm/components/tabs/tabs.component.js +17 -2
  14. package/lib/components/draggable/draggable-container.component.d.ts +6 -1
  15. package/lib/components/draggable/draggable-container.component.js +4 -1
  16. package/lib/components/draggable/draggable-item/draggable-item.component.d.ts +6 -1
  17. package/lib/components/draggable/draggable-item/draggable-item.component.js +6 -2
  18. package/lib/components/draggable/draggable-item/draggable-item.style.d.ts +2 -3
  19. package/lib/components/draggable/draggable-item/draggable-item.style.js +5 -6
  20. package/lib/components/tabs/__internal__/tab-title/tab-title.component.js +0 -1
  21. package/lib/components/tabs/__internal__/tab-title/tab-title.style.js +166 -118
  22. package/lib/components/tabs/__internal__/tabs-header/tabs-header.component.d.ts +2 -1
  23. package/lib/components/tabs/__internal__/tabs-header/tabs-header.component.js +100 -47
  24. package/lib/components/tabs/__internal__/tabs-header/tabs-header.style.d.ts +21 -10
  25. package/lib/components/tabs/__internal__/tabs-header/tabs-header.style.js +72 -85
  26. package/lib/components/tabs/tabs.component.js +17 -2
  27. package/package.json +1 -1
@@ -10,9 +10,14 @@ export interface DraggableContainerProps extends MarginProps, Omit<TagProps, "da
10
10
  * `<DraggableItem />` is required to make `Draggable` works
11
11
  */
12
12
  children?: React.ReactNode;
13
+ /**
14
+ * Defines the direction in which the draggable items contents are placed.
15
+ * Can be either "row" or "row-reverse".
16
+ */
17
+ flexDirection?: "row" | "row-reverse";
13
18
  }
14
19
  declare const DraggableContainer: {
15
- ({ "data-element": dataElement, "data-role": dataRole, children, getOrder, ...rest }: DraggableContainerProps): JSX.Element;
20
+ ({ "data-element": dataElement, "data-role": dataRole, children, getOrder, flexDirection, ...rest }: DraggableContainerProps): JSX.Element;
16
21
  displayName: string;
17
22
  };
18
23
  export default DraggableContainer;
@@ -12,6 +12,7 @@ const DraggableContainer = ({
12
12
  "data-role": dataRole = "draggable-container",
13
13
  children,
14
14
  getOrder,
15
+ flexDirection = "row",
15
16
  ...rest
16
17
  }) => {
17
18
  const [draggableItems, setDraggableItems] = useState(React.Children.toArray(children));
@@ -67,7 +68,8 @@ const DraggableContainer = ({
67
68
  return /*#__PURE__*/React.isValidElement(item) && /*#__PURE__*/React.cloneElement(item, {
68
69
  id: `${item.props.id}`,
69
70
  findItem,
70
- moveItem
71
+ moveItem,
72
+ flexDirection
71
73
  }, [item.props.children]);
72
74
  })));
73
75
  };
@@ -76,6 +78,7 @@ if (process.env.NODE_ENV !== "production") {
76
78
  "children": PropTypes.node,
77
79
  "data-element": PropTypes.string,
78
80
  "data-role": PropTypes.string,
81
+ "flexDirection": PropTypes.oneOf(["row-reverse", "row"]),
79
82
  "getOrder": PropTypes.func,
80
83
  "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
81
84
  "__@toStringTag": PropTypes.string.isRequired,
@@ -22,9 +22,14 @@ export interface DraggableItemProps extends PaddingProps {
22
22
  * @ignore
23
23
  */
24
24
  moveItem?: (droppedId: string | number, overIndex: number | undefined) => void;
25
+ /**
26
+ * @private
27
+ * @ignore
28
+ */
29
+ flexDirection?: "row" | "row-reverse";
25
30
  }
26
31
  declare const DraggableItem: {
27
- ({ id, findItem, moveItem, children, py, ...rest }: DraggableItemProps): JSX.Element;
32
+ ({ id, findItem, moveItem, children, py, flexDirection, ...rest }: DraggableItemProps): JSX.Element;
28
33
  displayName: string;
29
34
  };
30
35
  export default DraggableItem;
@@ -3,13 +3,15 @@ import React from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { useDrop, useDrag } from "react-dnd";
5
5
  import { filterStyledSystemPaddingProps } from "../../../style/utils";
6
- import { StyledDraggableItem, StyledIcon } from "./draggable-item.style";
6
+ import { StyledDraggableItem } from "./draggable-item.style";
7
+ import Icon from "../../icon";
7
8
  const DraggableItem = ({
8
9
  id,
9
10
  findItem,
10
11
  moveItem,
11
12
  children,
12
13
  py = 1,
14
+ flexDirection,
13
15
  ...rest
14
16
  }) => {
15
17
  let originalIndex;
@@ -60,8 +62,9 @@ const DraggableItem = ({
60
62
  "data-role": "draggable-item",
61
63
  isDragging: isDragging,
62
64
  ref: node => drag(drop(node)),
63
- py: py
64
- }, paddingProps), children, /*#__PURE__*/React.createElement(StyledIcon, {
65
+ py: py,
66
+ flexDirection: flexDirection
67
+ }, paddingProps), children, /*#__PURE__*/React.createElement(Icon, {
65
68
  type: "drag"
66
69
  }));
67
70
  };
@@ -69,6 +72,7 @@ if (process.env.NODE_ENV !== "production") {
69
72
  DraggableItem.propTypes = {
70
73
  "children": PropTypes.node,
71
74
  "findItem": PropTypes.func,
75
+ "flexDirection": PropTypes.oneOf(["row-reverse", "row"]),
72
76
  "id": PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
73
77
  "moveItem": PropTypes.func,
74
78
  "p": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
@@ -1,9 +1,8 @@
1
- /// <reference types="react" />
2
1
  import { PaddingProps } from "styled-system";
3
2
  declare const StyledDraggableContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
4
3
  interface StyledDraggableItemProps extends PaddingProps {
5
4
  isDragging?: boolean;
5
+ flexDirection?: "row" | "row-reverse";
6
6
  }
7
7
  declare const StyledDraggableItem: import("styled-components").StyledComponent<"div", any, StyledDraggableItemProps, never>;
8
- declare const StyledIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
9
- export { StyledDraggableContainer, StyledDraggableItem, StyledIcon };
8
+ export { StyledDraggableContainer, StyledDraggableItem };
@@ -1,7 +1,6 @@
1
1
  import styled from "styled-components";
2
2
  import { padding, margin } from "styled-system";
3
3
  import { baseTheme } from "../../../style/themes";
4
- import Icon from "../../icon";
5
4
  const StyledDraggableContainer = styled.div`
6
5
  ${margin}
7
6
  `;
@@ -11,18 +10,18 @@ const StyledDraggableItem = styled.div`
11
10
  border-bottom: 1px solid var(--colorsUtilityMajor050);
12
11
  ${padding}
13
12
  cursor: move;
14
-
13
+ justify-content: space-between;
14
+ flex-direction: ${({
15
+ flexDirection
16
+ }) => flexDirection};
15
17
  opacity: ${({
16
18
  isDragging
17
19
  }) => isDragging ? "0" : "1"};
18
20
  `;
19
- const StyledIcon = styled(Icon)`
20
- margin-left: auto;
21
- `;
22
21
  StyledDraggableContainer.defaultProps = {
23
22
  theme: baseTheme
24
23
  };
25
24
  StyledDraggableItem.defaultProps = {
26
25
  theme: baseTheme
27
26
  };
28
- export { StyledDraggableContainer, StyledDraggableItem, StyledIcon };
27
+ export { StyledDraggableContainer, StyledDraggableItem };
@@ -62,7 +62,6 @@ const TabTitle = /*#__PURE__*/React.forwardRef(({
62
62
  }
63
63
  };
64
64
  const handleKeyDown = ev => {
65
- ev.stopPropagation();
66
65
  if (href && Events.isEnterOrSpaceKey(ev)) {
67
66
  return window.open(href, "_blank");
68
67
  }
@@ -1,13 +1,10 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import StyledIcon from "../../../icon/icon.style";
3
3
  import StyledValidationIcon from "../../../../__internal__/validations/validation-icon.style";
4
- import addFocusStyling from "../../../../style/utils/add-focus-styling";
5
- const oldFocusStyling = `
6
- outline: solid 3px var(--colorsSemanticFocus500);
7
- `;
8
4
  const StyledTitleContent = styled.span`
9
5
  outline: none;
10
- display: inline-flex;
6
+ display: flex;
7
+ align-items: flex-start;
11
8
  line-height: 20px;
12
9
  margin: 0;
13
10
  position: relative;
@@ -110,7 +107,7 @@ const StyledTitleContent = styled.span`
110
107
  padding: 10px 16px;
111
108
 
112
109
  ${borders && `padding-bottom: 9px;`}
113
- `}
110
+ `}
114
111
 
115
112
  ${(warning || info) && css`
116
113
  outline: 1px solid;
@@ -133,7 +130,7 @@ const StyledTitleContent = styled.span`
133
130
  border-right-color: transparent;
134
131
  padding-right: ${size === "large" ? "26px" : "18px"};
135
132
  `}
136
-
133
+
137
134
  &:hover {
138
135
  outline: 1px solid;
139
136
  outline-offset: -1px;
@@ -174,7 +171,7 @@ const StyledTitleContent = styled.span`
174
171
  border-right-color: transparent;
175
172
  padding-right: ${size === "large" ? "26px" : "18px"};
176
173
  `}
177
-
174
+
178
175
  &:hover {
179
176
  outline: 2px solid var(--colorsSemanticNegative500);
180
177
  outline-offset: -2px;
@@ -274,152 +271,198 @@ const tabTitleStyles = css`
274
271
  height: ${size === "large" ? "var(--sizing600)" : "var(--sizing500)"};
275
272
 
276
273
  ${position === "top" && css`
277
- ${borders && !(noRightBorder || noLeftBorder) && css`
278
- &:nth-of-type(n + 1):not(:first-of-type) {
279
- margin-left: -1px;
280
- }
281
- &:first-child {
282
- margin-left: 0;
283
- }
274
+ ${borders && !(noRightBorder || noLeftBorder) && css`
275
+ &:nth-of-type(n + 1):not(:first-of-type) {
276
+ margin-left: -1px;
277
+ }
278
+ &:first-child {
279
+ margin-left: 0;
280
+ }
281
+ `}
284
282
  `}
285
- `}
286
283
  ${position === "left" && css`
287
- ${borders && css`
288
- &:nth-of-type(n + 1):not(:first-of-type) {
289
- margin-top: -1px;
290
- }
291
- &:first-child {
292
- margin-top: 0;
293
- }
284
+ ${borders && css`
285
+ &:nth-of-type(n + 1):not(:first-of-type) {
286
+ margin-top: -1px;
287
+ }
288
+ &:first-child {
289
+ margin-top: 0;
290
+ }
291
+ `}
294
292
  `}
295
- `}
296
293
 
297
294
  ${!isTabSelected && css`
298
- color: var(--colorsActionMinorYin090);
299
- ${validationRedesignOptIn && css`
300
- background: transparent;
301
- `}
302
-
303
- &:hover {
304
- background: var(--colorsActionMinor100);
295
+ color: var(--colorsActionMinorYin090);
305
296
  ${validationRedesignOptIn && css`
306
- background: var(--colorsUtilityMajor100);
297
+ background: transparent;
307
298
  `}
308
- color: var(--colorsActionMinorYin090);
309
- outline: none;
310
- }
311
- &:focus {
312
- color: var(--colorsActionMinorYin090);
313
- outline: none;
314
- }
315
- `}
316
299
 
317
- ${isTabSelected && css`
318
- color: var(--colorsActionMajorYin090);
319
- background-color: var(--colorsActionMajorYang100);
320
-
321
- ${(error || warning || info) && css`
322
- padding-bottom: 0px;
300
+ &:hover {
301
+ background: var(--colorsActionMinor100);
302
+ ${validationRedesignOptIn && css`
303
+ background: var(--colorsUtilityMajor100);
304
+ `}
305
+ color: var(--colorsActionMinorYin090);
306
+ outline: none;
307
+ }
308
+ &:focus {
309
+ color: var(--colorsActionMinorYin090);
310
+ outline: none;
311
+ }
323
312
  `}
324
313
 
325
- &:hover {
326
- background-color: var(--colorsActionMajorYang100);
327
- border-bottom-color: ${alternateStyling ? "var(--colorsActionMinor100)" : "var(--colorsActionMajor500)"};
314
+ ${isTabSelected && css`
328
315
  color: var(--colorsActionMajorYin090);
329
- cursor: default;
330
- }
331
- `}
316
+ background-color: var(--colorsActionMajorYang100);
332
317
 
333
- &:focus {
334
- ${({
335
- theme
336
- }) => `${!theme.focusRedesignOptOut ? addFocusStyling() : /* istanbul ignore next */oldFocusStyling}`}
337
- z-index: 3;
318
+ ${(error || warning || info) && css`
319
+ padding-bottom: 0px;
320
+ `}
338
321
 
339
- ${isInSidebar && css`
340
- outline-offset: -3px;
322
+ &:hover {
323
+ background-color: var(--colorsActionMajorYang100);
324
+ border-bottom-color: ${alternateStyling ? "var(--colorsActionMinor100)" : "var(--colorsActionMajor500)"};
325
+ color: var(--colorsActionMajorYin090);
326
+ cursor: default;
327
+ }
341
328
  `}
342
- }
343
329
 
344
- ${position === "left" && css`
345
- background-color: transparent;
346
- border-bottom: 0px;
347
-
348
- ${!isInSidebar && !error && css`
349
- --border-right-value: ${validationRedesignOptIn ? "0px" : "2px"}
350
- border-right:
351
- ${alternateStyling ? "1px" : "var(--border-right-value)"} solid
352
- var(--colorsActionMinor100);
353
- `}
330
+ ${({
331
+ theme
332
+ }) => `
333
+ &:focus {
334
+ outline: 4px solid ${!theme.focusRedesignOptOut ? "black" : /* istanbul ignore next */"var(--colorsSemanticFocus500)"};
335
+ top: -2px;
336
+ z-index: 6;
354
337
 
355
- ${!borders && css`
356
- ${StyledTitleContent} {
357
- border-bottom: none;
338
+ > span[data-role="tab-title-content"] {
339
+ outline:none;
358
340
  }
359
- `}
360
341
 
361
- display: flex;
362
- height: auto;
363
- margin-left: 0px;
342
+ ${position === "top" ? css`
343
+ border-top-left-radius: var(--borderRadius100);
344
+ border-top-right-radius: var(--borderRadius100);
345
+ ` : css`
346
+ border-top-left-radius: var(--borderRadius100);
347
+ border-bottom-left-radius: var(--borderRadius100);
348
+ `}
349
+
350
+ ${!theme.focusRedesignOptOut ? `::before {
351
+ content: "";
352
+ position: absolute;
353
+ top: 0;
354
+ left 0;
355
+ bottom: 0;
356
+ right: ${position === "top" ? "0" : "-1px"};
357
+ outline: 3px solid var(--colorsSemanticFocus500);
358
+ ${position === "top" ? css`
359
+ border-top-left-radius: var(--borderRadius100);
360
+ border-top-right-radius: var(--borderRadius100);
361
+ ` : css`
362
+ border-top-left-radius: var(--borderRadius100);
363
+ border-bottom-left-radius: var(--borderRadius100);
364
+ `}
365
+ outline-offset: -2px;
366
+ z-index: 5;
367
+ }
364
368
 
365
- &:first-child {
366
- margin-top: 0;
369
+ > [data-element="tab-selected-indicator"] {
370
+ z-index: 4;
371
+ ${position === "top" ? css`
372
+ bottom: 2px;
373
+ left: 2px;
374
+ right: 1px;
375
+ ` : css`
376
+ bottom: 2px;
377
+ right: 1px;
378
+ `}
379
+ }` : /* istanbul ignore next */""}
367
380
  }
381
+ `}
368
382
 
369
- &:hover {
370
- ${alternateStyling && "border-right-color: var(--colorsActionMinor100)"}
371
- }
383
+ ${position === "left" && css`
384
+ background-color: transparent;
385
+ border-bottom: 0px;
386
+
387
+ ${!isInSidebar && !error && css`
388
+ --border-right-value: ${validationRedesignOptIn ? "0px" : "2px"}
389
+ border-right:
390
+ ${alternateStyling ? "1px" : "var(--border-right-value)"} solid
391
+ var(--colorsActionMinor100);
392
+ `}
372
393
 
373
- ${(warning || info) && css`
374
- border-right: none;
375
- `}
394
+ ${!borders && css`
395
+ ${StyledTitleContent} {
396
+ border-bottom: none;
397
+ }
398
+ `}
376
399
 
377
- ${!isTabSelected && css`
378
- border-right-color: var(--colorsActionMinor100);
379
- `}
400
+ display: flex;
401
+ height: auto;
402
+ margin-left: 0px;
380
403
 
381
- ${isTabSelected && css`
382
- ${alternateStyling && css`
404
+ &:first-child {
405
+ margin-top: 0;
406
+ }
407
+
408
+ &:hover {
409
+ ${alternateStyling && "border-right-color: var(--colorsActionMinor100)"}
410
+ }
411
+
412
+ ${(warning || info) && css`
413
+ border-right: none;
414
+ `}
415
+
416
+ ${!isTabSelected && css`
383
417
  border-right-color: var(--colorsActionMinor100);
384
418
  `}
385
419
 
386
- ${!alternateStyling && css`
387
- border-right: none;
388
- padding-bottom: 0px;
420
+ ${isTabSelected && css`
421
+ ${alternateStyling && css`
422
+ border-right-color: var(--colorsActionMinor100);
423
+ `}
389
424
 
390
- ${StyledTitleContent} {
391
- ${!(error || warning || info) && !validationRedesignOptIn && "margin-right: 2px;"}
425
+ ${!alternateStyling && css`
392
426
  border-right: none;
393
- }
394
- `}
395
-
427
+ padding-bottom: 0px;
428
+
429
+ ${StyledTitleContent} {
430
+ ${!(error || warning || info) && !validationRedesignOptIn && "margin-right: 2px;"}
431
+ border-right: none;
432
+ }
433
+ `}
434
+
396
435
  background-color: var(--colorsActionMajorYang100);
397
436
 
398
- &:hover {
399
- ${alternateStyling && "border-right-color: var(--colorsActionMinor100);"}
400
- background-color: var(--colorsActionMajorYang100);
401
- ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
402
- }
437
+ &:hover {
438
+ ${alternateStyling && "border-right-color: var(--colorsActionMinor100);"}
439
+ background-color: var(--colorsActionMajorYang100);
440
+ ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
441
+ }
403
442
 
404
- &:focus {
405
- ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
406
- }
443
+ &:focus {
444
+ ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
445
+ }
446
+ `}
407
447
  `}
408
- `}
409
448
 
410
449
  ${alternateStyling && css`
411
- &:focus {
412
- background-color: var(--colorsActionMinor200);
413
- }
450
+ &:focus {
451
+ background-color: var(--colorsActionMinor200);
452
+ }
414
453
 
415
- &:hover {
416
- background-color: ${isTabSelected ? "var(--colorsActionMinor200)" : "var(--colorsActionMinor250)"};
417
- }
454
+ &:hover {
455
+ background-color: ${isTabSelected ? "var(--colorsActionMinor200)" : "var(--colorsActionMinor250)"};
456
+ }
418
457
 
419
- ${isTabSelected && css`
420
- background-color: var(--colorsActionMinor200);
458
+ ${isTabSelected && css`
459
+ background-color: var(--colorsActionMinor200);
460
+ `}
421
461
  `}
422
- `}
462
+
463
+ & ${StyledIcon} { {
464
+ ${validationRedesignOptIn ? "margin-top: 10px;" : "margin-top: 2px;"}
465
+ }
423
466
  `}
424
467
  `;
425
468
  const StyledTabTitleButton = styled.button`
@@ -433,7 +476,6 @@ const StyledLayoutWrapper = styled.div`
433
476
  hasCustomLayout,
434
477
  titlePosition = "before",
435
478
  hasCustomSibling,
436
- position,
437
479
  validationRedesignOptIn
438
480
  }) => css`
439
481
  ${hasCustomLayout && css`
@@ -501,7 +543,7 @@ const StyledSelectedIndicator = styled.div`
501
543
  --selected-indicator-color: var(--colorsSemanticNegative500);
502
544
  `}
503
545
  ${position === "top" && css`
504
- bottom: 0px;
546
+ bottom: -1px;
505
547
  left: 0px;
506
548
  right: 0px;
507
549
  box-shadow: inset 0px calc(-1 * var(--sizing050)) 0px
@@ -518,5 +560,11 @@ const StyledSelectedIndicator = styled.div`
518
560
  width: var(--sizing050);
519
561
  `}
520
562
  `}
563
+
564
+ &:focus {
565
+ bottom: 3px;
566
+ left: 3px;
567
+ right: 3px;
568
+ }
521
569
  `;
522
570
  export { StyledTabTitleButton, StyledTabTitleLink, StyledTitleContent, StyledLayoutWrapper, StyledSelectedIndicator, StyledVerticalIndicator };
@@ -7,6 +7,7 @@ export interface TabHeaderProps {
7
7
  isInSidebar?: boolean;
8
8
  children: React.ReactNode;
9
9
  align?: "left" | "right";
10
+ size?: "default" | "large";
10
11
  }
11
- declare const TabsHeader: ({ align, children, position, role, extendedLine, noRightBorder, isInSidebar, }: TabHeaderProps) => React.JSX.Element;
12
+ declare const TabsHeader: ({ align, children, position, role, extendedLine, noRightBorder, isInSidebar, size, }: TabHeaderProps) => React.JSX.Element;
12
13
  export default TabsHeader;