carbon-react 124.3.1 → 124.4.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 (48) hide show
  1. package/esm/components/box/box.component.d.ts +1 -3
  2. package/esm/components/box/box.component.js +3 -4
  3. package/esm/components/box/box.config.d.ts +0 -1
  4. package/esm/components/box/box.config.js +0 -7
  5. package/esm/components/box/box.style.js +4 -3
  6. package/esm/components/select/select-list/select-list.component.js +6 -7
  7. package/esm/components/tile/flex-tile-cell/flex-tile-cell.component.d.ts +9 -0
  8. package/esm/components/tile/flex-tile-cell/flex-tile-cell.component.js +3808 -0
  9. package/esm/components/tile/flex-tile-cell/index.d.ts +2 -0
  10. package/esm/components/tile/flex-tile-cell/index.js +1 -0
  11. package/esm/components/tile/flex-tile-container/flex-tile-container.component.d.ts +8 -0
  12. package/esm/components/tile/flex-tile-container/flex-tile-container.component.js +29 -0
  13. package/esm/components/tile/flex-tile-container/index.d.ts +2 -0
  14. package/esm/components/tile/flex-tile-container/index.js +1 -0
  15. package/esm/components/tile/flex-tile-divider/flex-tile-divider.component.d.ts +3 -0
  16. package/esm/components/tile/flex-tile-divider/flex-tile-divider.component.js +17 -0
  17. package/esm/components/tile/flex-tile-divider/index.d.ts +1 -0
  18. package/esm/components/tile/flex-tile-divider/index.js +1 -0
  19. package/esm/components/tile/index.d.ts +5 -0
  20. package/esm/components/tile/index.js +4 -1
  21. package/esm/style/utils/box-gap.d.ts +5 -0
  22. package/esm/style/utils/box-gap.js +9 -0
  23. package/lib/components/box/box.component.d.ts +1 -3
  24. package/lib/components/box/box.component.js +3 -4
  25. package/lib/components/box/box.config.d.ts +0 -1
  26. package/lib/components/box/box.config.js +0 -7
  27. package/lib/components/box/box.style.js +4 -3
  28. package/lib/components/select/select-list/select-list.component.js +6 -7
  29. package/lib/components/tile/flex-tile-cell/flex-tile-cell.component.d.ts +9 -0
  30. package/lib/components/tile/flex-tile-cell/flex-tile-cell.component.js +3815 -0
  31. package/lib/components/tile/flex-tile-cell/index.d.ts +2 -0
  32. package/lib/components/tile/flex-tile-cell/index.js +13 -0
  33. package/lib/components/tile/flex-tile-cell/package.json +6 -0
  34. package/lib/components/tile/flex-tile-container/flex-tile-container.component.d.ts +8 -0
  35. package/lib/components/tile/flex-tile-container/flex-tile-container.component.js +36 -0
  36. package/lib/components/tile/flex-tile-container/index.d.ts +2 -0
  37. package/lib/components/tile/flex-tile-container/index.js +13 -0
  38. package/lib/components/tile/flex-tile-container/package.json +6 -0
  39. package/lib/components/tile/flex-tile-divider/flex-tile-divider.component.d.ts +3 -0
  40. package/lib/components/tile/flex-tile-divider/flex-tile-divider.component.js +25 -0
  41. package/lib/components/tile/flex-tile-divider/index.d.ts +1 -0
  42. package/lib/components/tile/flex-tile-divider/index.js +13 -0
  43. package/lib/components/tile/flex-tile-divider/package.json +6 -0
  44. package/lib/components/tile/index.d.ts +5 -0
  45. package/lib/components/tile/index.js +21 -0
  46. package/lib/style/utils/box-gap.d.ts +5 -0
  47. package/lib/style/utils/box-gap.js +18 -0
  48. package/package.json +1 -1
@@ -1,13 +1,11 @@
1
1
  import React from "react";
2
2
  import { SpaceProps, LayoutProps, FlexboxProps, PositionProps, GridProps } from "styled-system";
3
3
  import * as DesignTokens from "@sage/design-tokens/js/base/common";
4
+ import { Gap } from "style/utils/box-gap";
4
5
  import { TagProps } from "../../__internal__/utils/helpers/tags";
5
- declare const GAP_VALUES: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8];
6
6
  export declare type OverflowWrap = "break-word" | "anywhere";
7
7
  export declare type ScrollVariant = "light" | "dark";
8
8
  export declare type BoxSizing = "content-box" | "border-box";
9
- export declare type AllowedNumericalValues = typeof GAP_VALUES[number];
10
- export declare type Gap = AllowedNumericalValues | string;
11
9
  declare type DesignTokensType = keyof typeof DesignTokens;
12
10
  declare type BoxShadowsType = Extract<DesignTokensType, `boxShadow${string}`>;
13
11
  declare type BorderRadiusType = Extract<DesignTokensType, `borderRadius${string}`>;
@@ -4,7 +4,6 @@ import PropTypes from "prop-types";
4
4
  import { filterStyledSystemMarginProps, filterStyledSystemPaddingProps, filterStyledSystemLayoutProps, filterStyledSystemFlexboxProps, filterStyledSystemGridProps } from "../../style/utils";
5
5
  import StyledBox from "./box.style";
6
6
  import tagComponent from "../../__internal__/utils/helpers/tags";
7
- const GAP_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
8
7
  const Box = /*#__PURE__*/React.forwardRef(({
9
8
  "data-component": dataComponent,
10
9
  as,
@@ -475,7 +474,7 @@ Box.propTypes = {
475
474
  "children": PropTypes.node,
476
475
  "className": PropTypes.string,
477
476
  "color": PropTypes.string,
478
- "columnGap": PropTypes.oneOfType([PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]), PropTypes.string]),
477
+ "columnGap": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
479
478
  "data-component": PropTypes.string,
480
479
  "data-element": PropTypes.string,
481
480
  "data-role": PropTypes.string,
@@ -986,7 +985,7 @@ Box.propTypes = {
986
985
  "valueOf": PropTypes.func.isRequired
987
986
  })]),
988
987
  "flexWrap": PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "inherit", "initial", "nowrap", "revert-layer", "revert", "unset", "wrap-reverse", "wrap"]), PropTypes.arrayOf(PropTypes.oneOf(["-moz-initial", "inherit", "initial", "nowrap", "revert-layer", "revert", "unset", "wrap-reverse", "wrap", null])), PropTypes.object]),
989
- "gap": PropTypes.oneOfType([PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]), PropTypes.string]),
988
+ "gap": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
990
989
  "gridArea": PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "auto", "inherit", "initial", "revert-layer", "revert", "unset"]), PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "auto", "inherit", "initial", "revert-layer", "revert", "unset", null]), PropTypes.shape({
991
990
  "__@iterator": PropTypes.func.isRequired,
992
991
  "anchor": PropTypes.func.isRequired,
@@ -3423,7 +3422,7 @@ Box.propTypes = {
3423
3422
  "valueOf": PropTypes.func.isRequired
3424
3423
  }), PropTypes.string]),
3425
3424
  "role": PropTypes.string,
3426
- "rowGap": PropTypes.oneOfType([PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]), PropTypes.string]),
3425
+ "rowGap": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
3427
3426
  "scrollVariant": PropTypes.oneOf(["dark", "light"]),
3428
3427
  "size": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
3429
3428
  "__@iterator": PropTypes.func.isRequired,
@@ -7,6 +7,5 @@ declare const _default: {
7
7
  thumb: string;
8
8
  track: string;
9
9
  };
10
- gap: (gapValue: number | string) => string;
11
10
  };
12
11
  export default _default;
@@ -1,4 +1,3 @@
1
- import { space } from "../../style/themes/base/base-theme.config";
2
1
  export default {
3
2
  light: {
4
3
  thumb: "var(--colorsUtilityMajor300)",
@@ -7,11 +6,5 @@ export default {
7
6
  dark: {
8
7
  thumb: "var(--colorsUtilityMajor200)",
9
8
  track: "var(--colorsUtilityMajor400)"
10
- },
11
- gap: gapValue => {
12
- if (typeof gapValue === "number") {
13
- return space[gapValue];
14
- }
15
- return gapValue;
16
9
  }
17
10
  };
@@ -1,5 +1,6 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import { space, layout, flexbox, grid, position as positionFn } from "styled-system";
3
+ import boxGap from "../../style/utils/box-gap";
3
4
  import BaseTheme from "../../style/themes/base";
4
5
  import styledColor from "../../style/utils/color";
5
6
  import boxConfig from "./box.config";
@@ -88,15 +89,15 @@ const StyledBox = styled.div`
88
89
  rowGap
89
90
  }) => (display === "flex" || display === "inline-flex" || display === "grid" || display === "inline-grid") && css`
90
91
  ${gap !== undefined && css`
91
- gap: ${boxConfig.gap(gap)};
92
+ gap: ${boxGap(gap)};
92
93
  `}
93
94
 
94
95
  ${columnGap !== undefined && css`
95
- column-gap: ${boxConfig.gap(columnGap)};
96
+ column-gap: ${boxGap(columnGap)};
96
97
  `}
97
98
 
98
99
  ${rowGap !== undefined && css`
99
- row-gap: ${boxConfig.gap(rowGap)};
100
+ row-gap: ${boxGap(rowGap)};
100
101
  `}
101
102
  `};
102
103
 
@@ -184,6 +184,9 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
184
184
  const lastOptionIndex = findLastIndex(childrenList, child => /*#__PURE__*/React.isValidElement(child) && (child.type === Option || child.type === OptionRow));
185
185
  const getNextHighlightableItemIndex = useCallback((key, indexOfHighlighted) => {
186
186
  const lastIndex = lastOptionIndex;
187
+ if (lastIndex === -1) {
188
+ return -1;
189
+ }
187
190
  let nextIndex = getNextIndexByKey(key, indexOfHighlighted, lastIndex, isLoading);
188
191
  const nextElement = childrenList[nextIndex];
189
192
  if ( /*#__PURE__*/React.isValidElement(nextElement) && nextElement.type !== Option && nextElement.type !== OptionRow) {
@@ -201,7 +204,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
201
204
  currentIndex = indexOfHighlighted;
202
205
  }
203
206
  const nextIndex = getNextHighlightableItemIndex(key, currentIndex);
204
- if (currentIndex === nextIndex) {
207
+ if (nextIndex === -1 || currentIndex === nextIndex) {
205
208
  return;
206
209
  }
207
210
  const {
@@ -282,10 +285,10 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
282
285
  const element = event.target;
283
286
 
284
287
  /* istanbul ignore else */
285
- if (onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
288
+ if (isOpen && onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
286
289
  onListScrollBottom();
287
290
  }
288
- }, [onListScrollBottom]);
291
+ }, [onListScrollBottom, isOpen]);
289
292
  useEffect(() => {
290
293
  const keyboardEvent = "keydown";
291
294
  const listElement = listContainerRef.current;
@@ -322,10 +325,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
322
325
  }
323
326
  setCurrentOptionsListIndex(indexOfMatch);
324
327
  virtualizer.scrollToIndex(indexOfMatch, SCROLL_OPTIONS);
325
- // TODO: is there a better way than calling handleListScroll manually?
326
- handleListScroll({
327
- target: listContainerRef.current
328
- });
329
328
  }, [getIndexOfMatch, highlightedValue, virtualizer, handleListScroll, listContainerRef]);
330
329
  useEffect(() => {
331
330
  if (isLoading && currentOptionsListIndex === lastOptionIndex && lastOptionIndex > -1) {
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { BoxProps } from "../../box";
3
+ import { TagProps } from "../../../__internal__/utils/helpers/tags";
4
+ export interface FlexTileCellProps extends TagProps, BoxProps {
5
+ /** The content to render within the responsive cell. */
6
+ children: React.ReactNode;
7
+ }
8
+ export declare const FlexTileCell: ({ children, flexGrow, flexBasis, flexShrink, ...rest }: FlexTileCellProps) => JSX.Element;
9
+ export default FlexTileCell;