@carbon/react 1.23.0-rc.0 → 1.23.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 (81) hide show
  1. package/es/components/DataTable/tools/sorting.js +3 -0
  2. package/es/components/Dropdown/Dropdown.Skeleton.d.ts +15 -0
  3. package/es/components/Dropdown/Dropdown.Skeleton.js +1 -2
  4. package/es/components/Dropdown/index.js +1 -0
  5. package/es/components/FluidDropdown/FluidDropdown.js +1 -0
  6. package/es/components/Grid/CSSGrid.d.ts +9 -0
  7. package/es/components/Grid/CSSGrid.js +8 -5
  8. package/es/components/Grid/Column.d.ts +73 -0
  9. package/es/components/Grid/Column.js +40 -34
  10. package/es/components/Grid/ColumnHang.d.ts +24 -0
  11. package/es/components/Grid/ColumnHang.js +7 -4
  12. package/es/components/Grid/FlexGrid.d.ts +9 -0
  13. package/es/components/Grid/FlexGrid.js +6 -3
  14. package/es/components/Grid/Grid.d.ts +9 -0
  15. package/es/components/Grid/Grid.js +6 -5
  16. package/es/components/Grid/GridContext.d.ts +38 -0
  17. package/es/components/Grid/GridContext.js +6 -6
  18. package/es/components/Grid/GridTypes.d.ts +37 -0
  19. package/es/components/Grid/Row.d.ts +34 -0
  20. package/es/components/Grid/Row.js +4 -2
  21. package/es/components/Grid/index.d.ts +11 -0
  22. package/es/components/Heading/index.js +11 -4
  23. package/es/components/Menu/Menu.js +164 -216
  24. package/es/components/Menu/MenuContext.js +44 -0
  25. package/es/components/Menu/MenuItem.js +401 -23
  26. package/es/components/MultiSelect/MultiSelect.js +6 -0
  27. package/es/components/OverflowMenu/OverflowMenu.js +2 -2
  28. package/es/components/OverflowMenuV2/index.js +4 -14
  29. package/es/components/Search/Search.js +3 -3
  30. package/es/index.d.ts +1 -1
  31. package/es/index.js +7 -11
  32. package/es/prop-types/isRequiredOneOf.js +2 -2
  33. package/lib/components/DataTable/tools/sorting.js +3 -0
  34. package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +15 -0
  35. package/lib/components/Dropdown/Dropdown.Skeleton.js +1 -2
  36. package/lib/components/Dropdown/index.js +2 -0
  37. package/lib/components/FluidDropdown/FluidDropdown.js +1 -0
  38. package/lib/components/Grid/CSSGrid.d.ts +9 -0
  39. package/lib/components/Grid/CSSGrid.js +8 -5
  40. package/lib/components/Grid/Column.d.ts +73 -0
  41. package/lib/components/Grid/Column.js +36 -30
  42. package/lib/components/Grid/ColumnHang.d.ts +24 -0
  43. package/lib/components/Grid/ColumnHang.js +7 -4
  44. package/lib/components/Grid/FlexGrid.d.ts +9 -0
  45. package/lib/components/Grid/FlexGrid.js +6 -3
  46. package/lib/components/Grid/Grid.d.ts +9 -0
  47. package/lib/components/Grid/Grid.js +2 -1
  48. package/lib/components/Grid/GridContext.d.ts +38 -0
  49. package/lib/components/Grid/GridContext.js +6 -6
  50. package/lib/components/Grid/GridTypes.d.ts +37 -0
  51. package/lib/components/Grid/Row.d.ts +34 -0
  52. package/lib/components/Grid/Row.js +4 -2
  53. package/lib/components/Grid/index.d.ts +11 -0
  54. package/lib/components/Heading/index.js +11 -4
  55. package/lib/components/Menu/Menu.js +163 -216
  56. package/lib/components/Menu/MenuContext.js +53 -0
  57. package/lib/components/Menu/MenuItem.js +406 -23
  58. package/lib/components/MultiSelect/MultiSelect.js +6 -0
  59. package/lib/components/OverflowMenu/OverflowMenu.js +2 -2
  60. package/lib/components/OverflowMenuV2/index.js +5 -15
  61. package/lib/components/Search/Search.js +3 -3
  62. package/lib/index.d.ts +1 -1
  63. package/lib/index.js +17 -21
  64. package/lib/prop-types/isRequiredOneOf.js +2 -2
  65. package/package.json +4 -4
  66. package/es/components/Menu/MenuDivider.js +0 -19
  67. package/es/components/Menu/MenuGroup.js +0 -34
  68. package/es/components/Menu/MenuOption.js +0 -250
  69. package/es/components/Menu/MenuRadioGroup.js +0 -50
  70. package/es/components/Menu/MenuRadioGroupOptions.js +0 -64
  71. package/es/components/Menu/MenuSelectableItem.js +0 -57
  72. package/es/components/Menu/_utils.js +0 -177
  73. package/es/components/Menu/index.js +0 -25
  74. package/lib/components/Menu/MenuDivider.js +0 -27
  75. package/lib/components/Menu/MenuGroup.js +0 -43
  76. package/lib/components/Menu/MenuOption.js +0 -260
  77. package/lib/components/Menu/MenuRadioGroup.js +0 -59
  78. package/lib/components/Menu/MenuRadioGroupOptions.js +0 -73
  79. package/lib/components/Menu/MenuSelectableItem.js +0 -66
  80. package/lib/components/Menu/_utils.js +0 -191
  81. package/lib/components/Menu/index.js +0 -31
@@ -23,6 +23,9 @@ import { sortStates } from '../state/sortStates.js';
23
23
 
24
24
  var compare = function compare(a, b) {
25
25
  var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en';
26
+ // prevent multiple null values in one column (sorting breaks)
27
+ a === null ? a = '' : null;
28
+ b === null ? b = '' : null;
26
29
 
27
30
  if (typeof a === 'number' && typeof b === 'number') {
28
31
  return a - b;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { ListBoxSize } from '../ListBox';
9
+ import { ReactAttr } from '../../types/common';
10
+ export interface DropdownSkeletonProps extends ReactAttr<HTMLDivElement> {
11
+ size?: ListBoxSize;
12
+ }
13
+ declare const DropdownSkeleton: React.FC<DropdownSkeletonProps>;
14
+ export default DropdownSkeleton;
15
+ export { DropdownSkeleton };
@@ -42,6 +42,5 @@ DropdownSkeleton.propTypes = {
42
42
  */
43
43
  size: ListBoxSize
44
44
  };
45
- var DropdownSkeleton$1 = DropdownSkeleton;
46
45
 
47
- export { DropdownSkeleton, DropdownSkeleton$1 as default };
46
+ export { DropdownSkeleton, DropdownSkeleton as default };
@@ -7,3 +7,4 @@
7
7
 
8
8
  import Dropdown from './Dropdown.js';
9
9
  export { default as Dropdown, default } from './Dropdown.js';
10
+ export { default as DropdownSkeleton } from './Dropdown.Skeleton.js';
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
10
10
  import React__default from 'react';
11
11
  import cx from 'classnames';
12
12
  import Dropdown from '../Dropdown/Dropdown.js';
13
+ import '../Dropdown/Dropdown.Skeleton.js';
13
14
  import { usePrefix } from '../../internal/usePrefix.js';
14
15
  import { FormContext } from '../FluidForm/FormContext.js';
15
16
 
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { GridComponent } from './GridTypes';
8
+ declare const CSSGridComponent: GridComponent;
9
+ export { CSSGridComponent as CSSGrid };
@@ -54,11 +54,13 @@ function CSSGrid(_ref) {
54
54
  }, rest), children));
55
55
  }
56
56
 
57
- var className = cx(customClassName, (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--css-grid"), true), _defineProperty(_cx, "".concat(prefix, "--css-grid--condensed"), mode === 'condensed'), _defineProperty(_cx, "".concat(prefix, "--css-grid--narrow"), mode === 'narrow'), _defineProperty(_cx, "".concat(prefix, "--css-grid--full-width"), fullWidth), _cx));
57
+ var className = cx(customClassName, (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--css-grid"), true), _defineProperty(_cx, "".concat(prefix, "--css-grid--condensed"), mode === 'condensed'), _defineProperty(_cx, "".concat(prefix, "--css-grid--narrow"), mode === 'narrow'), _defineProperty(_cx, "".concat(prefix, "--css-grid--full-width"), fullWidth), _cx)); // cast as any to let TypeScript allow passing in attributes to base component
58
+
59
+ var BaseComponentAsAny = BaseComponent;
58
60
  return /*#__PURE__*/React__default.createElement(GridSettings, {
59
61
  mode: "css-grid",
60
62
  subgrid: true
61
- }, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({
63
+ }, /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({
62
64
  className: className
63
65
  }, rest), children));
64
66
  }
@@ -97,7 +99,7 @@ CSSGrid.propTypes = {
97
99
  narrow: PropTypes.bool
98
100
  };
99
101
 
100
- function Subgrid(_ref2) {
102
+ var Subgrid = function Subgrid(_ref2) {
101
103
  var _cx2;
102
104
 
103
105
  var _ref2$as = _ref2.as,
@@ -112,7 +114,7 @@ function Subgrid(_ref2) {
112
114
  return /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
113
115
  className: className
114
116
  }), children);
115
- }
117
+ };
116
118
 
117
119
  Subgrid.propTypes = {
118
120
  /**
@@ -135,5 +137,6 @@ Subgrid.propTypes = {
135
137
  */
136
138
  mode: PropTypes.oneOf(['wide', 'narrow', 'condensed'])
137
139
  };
140
+ var CSSGridComponent = CSSGrid;
138
141
 
139
- export { CSSGrid };
142
+ export { CSSGridComponent as CSSGrid };
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { PolymorphicProps } from '../../types/common';
9
+ type ColumnSpanPercent = '25%' | '50%' | '75%' | '100%';
10
+ type ColumnSpanSimple = boolean | number | ColumnSpanPercent;
11
+ interface ColumnSpanObject {
12
+ span?: ColumnSpanSimple;
13
+ offset?: number;
14
+ start?: number;
15
+ end?: number;
16
+ }
17
+ export type ColumnSpan = ColumnSpanSimple | ColumnSpanObject;
18
+ interface ColumnBaseProps {
19
+ /**
20
+ * Pass in content that will be rendered within the `Column`
21
+ */
22
+ children?: React.ReactNode;
23
+ /**
24
+ * Specify a custom className to be applied to the `Column`
25
+ */
26
+ className?: string;
27
+ /**
28
+ * Specify column span for the `lg` breakpoint (Default breakpoint up to 1312px)
29
+ * This breakpoint supports 16 columns by default.
30
+ *
31
+ * @see https://www.carbondesignsystem.com/guidelines/layout#breakpoints
32
+ */
33
+ lg?: ColumnSpan;
34
+ /**
35
+ * Specify column span for the `max` breakpoint. This breakpoint supports 16
36
+ * columns by default.
37
+ *
38
+ * @see https://www.carbondesignsystem.com/guidelines/layout#breakpoints
39
+ */
40
+ max?: ColumnSpan;
41
+ /**
42
+ * Specify column span for the `md` breakpoint (Default breakpoint up to 1056px)
43
+ * This breakpoint supports 8 columns by default.
44
+ *
45
+ * @see https://www.carbondesignsystem.com/guidelines/layout#breakpoints
46
+ */
47
+ md?: ColumnSpan;
48
+ /**
49
+ * Specify column span for the `sm` breakpoint (Default breakpoint up to 672px)
50
+ * This breakpoint supports 4 columns by default.
51
+ *
52
+ * @see https://www.carbondesignsystem.com/guidelines/layout#breakpoints
53
+ */
54
+ sm?: ColumnSpan;
55
+ /**
56
+ * Specify column span for the `xlg` breakpoint (Default breakpoint up to
57
+ * 1584px) This breakpoint supports 16 columns by default.
58
+ *
59
+ * @see https://www.carbondesignsystem.com/guidelines/layout#breakpoints
60
+ */
61
+ xlg?: ColumnSpan;
62
+ /**
63
+ * Specify constant column span, start, or end values that will not change
64
+ * based on breakpoint
65
+ */
66
+ span?: ColumnSpan;
67
+ }
68
+ export type ColumnProps<T extends React.ElementType> = PolymorphicProps<T, ColumnBaseProps>;
69
+ export interface ColumnComponent {
70
+ <T extends React.ElementType>(props: ColumnProps<T>, context?: any): React.ReactElement<any, any> | null;
71
+ }
72
+ declare const _default: ColumnComponent;
73
+ export default _default;
@@ -46,8 +46,10 @@ function Column(_ref) {
46
46
  }
47
47
 
48
48
  var columnClassName = getClassNameForFlexGridBreakpoints([sm, md, lg, xlg, max], prefix);
49
- var className = cx(customClassName, columnClassName, _defineProperty({}, "".concat(prefix, "--col"), columnClassName.length === 0));
50
- return /*#__PURE__*/React__default.createElement(BaseComponent, _extends({
49
+ var className = cx(customClassName, columnClassName, _defineProperty({}, "".concat(prefix, "--col"), columnClassName.length === 0)); // cast as any to let TypeScript allow passing in attributes to base component
50
+
51
+ var BaseComponentAsAny = BaseComponent;
52
+ return /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({
51
53
  className: className
52
54
  }, rest), children);
53
55
  }
@@ -252,28 +254,30 @@ function getClassNameForBreakpoints(breakpoints, prefix) {
252
254
  continue;
253
255
  }
254
256
 
255
- var span = breakpoint.span,
256
- offset = breakpoint.offset,
257
- start = breakpoint.start,
258
- end = breakpoint.end;
259
-
260
- if (typeof offset === 'number' && offset > 0) {
261
- classNames.push("".concat(prefix, "--").concat(name, ":col-start-").concat(offset + 1));
262
- }
263
-
264
- if (typeof start === 'number') {
265
- classNames.push("".concat(prefix, "--").concat(name, ":col-start-").concat(start));
266
- }
267
-
268
- if (typeof end === 'number') {
269
- classNames.push("".concat(prefix, "--").concat(name, ":col-end-").concat(end));
270
- }
271
-
272
- if (typeof span === 'number') {
273
- classNames.push("".concat(prefix, "--").concat(name, ":col-span-").concat(span));
274
- } else if (typeof span === 'string') {
275
- classNames.push("".concat(prefix, "--").concat(name, ":col-span-").concat(span.slice(0, -1)));
276
- continue;
257
+ if (_typeof(breakpoint) === 'object') {
258
+ var span = breakpoint.span,
259
+ offset = breakpoint.offset,
260
+ start = breakpoint.start,
261
+ end = breakpoint.end;
262
+
263
+ if (typeof offset === 'number' && offset > 0) {
264
+ classNames.push("".concat(prefix, "--").concat(name, ":col-start-").concat(offset + 1));
265
+ }
266
+
267
+ if (typeof start === 'number') {
268
+ classNames.push("".concat(prefix, "--").concat(name, ":col-start-").concat(start));
269
+ }
270
+
271
+ if (typeof end === 'number') {
272
+ classNames.push("".concat(prefix, "--").concat(name, ":col-end-").concat(end));
273
+ }
274
+
275
+ if (typeof span === 'number') {
276
+ classNames.push("".concat(prefix, "--").concat(name, ":col-span-").concat(span));
277
+ } else if (typeof span === 'string') {
278
+ classNames.push("".concat(prefix, "--").concat(name, ":col-span-").concat(span.slice(0, -1)));
279
+ continue;
280
+ }
277
281
  }
278
282
  }
279
283
 
@@ -311,19 +315,21 @@ function getClassNameForFlexGridBreakpoints(breakpoints, prefix) {
311
315
  continue;
312
316
  }
313
317
 
314
- var span = breakpoint.span,
315
- offset = breakpoint.offset;
318
+ if (_typeof(breakpoint) === 'object') {
319
+ var span = breakpoint.span,
320
+ offset = breakpoint.offset;
316
321
 
317
- if (typeof span === 'number') {
318
- classNames.push("".concat(prefix, "--col-").concat(name, "-").concat(span));
319
- }
322
+ if (typeof span === 'number') {
323
+ classNames.push("".concat(prefix, "--col-").concat(name, "-").concat(span));
324
+ }
320
325
 
321
- if (span === true) {
322
- classNames.push("".concat(prefix, "--col-").concat(name));
323
- }
326
+ if (span === true) {
327
+ classNames.push("".concat(prefix, "--col-").concat(name));
328
+ }
324
329
 
325
- if (typeof offset === 'number') {
326
- classNames.push("".concat(prefix, "--offset-").concat(name, "-").concat(offset));
330
+ if (typeof offset === 'number') {
331
+ classNames.push("".concat(prefix, "--offset-").concat(name, "-").concat(offset));
332
+ }
327
333
  }
328
334
  }
329
335
 
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { PolymorphicProps } from '../../types/common';
9
+ interface ColumnHangBaseProps {
10
+ /**
11
+ * Pass in content that will be rendered within the `ColumnHang`
12
+ */
13
+ children?: React.ReactNode;
14
+ /**
15
+ * Specify a custom className to be applied to the `ColumnHang`
16
+ */
17
+ className?: string;
18
+ }
19
+ export type ColumnHangProps<T extends React.ElementType> = PolymorphicProps<T, ColumnHangBaseProps>;
20
+ export interface ColumnHangComponent {
21
+ <T extends React.ElementType>(props: ColumnHangProps<T>, context?: any): React.ReactElement<any, any> | null;
22
+ }
23
+ declare const ColumnHangComponent: ColumnHangComponent;
24
+ export { ColumnHangComponent as ColumnHang };
@@ -12,11 +12,11 @@ import React__default from 'react';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
13
 
14
14
  var _excluded = ["as", "className", "children"];
15
+
15
16
  /**
16
17
  * Helper component for rendering content that hangs on the column. Useful when
17
18
  * trying to align content across different grid modes
18
19
  */
19
-
20
20
  function ColumnHang(_ref) {
21
21
  var _ref$as = _ref.as,
22
22
  BaseComponent = _ref$as === void 0 ? 'div' : _ref$as,
@@ -25,8 +25,10 @@ function ColumnHang(_ref) {
25
25
  rest = _objectWithoutProperties(_ref, _excluded);
26
26
 
27
27
  var prefix = usePrefix();
28
- var className = cx(customClassName, "".concat(prefix, "--grid-column-hang"));
29
- return /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
28
+ var className = cx(customClassName, "".concat(prefix, "--grid-column-hang")); // cast as any to let TypeScript allow passing in attributes to base component
29
+
30
+ var BaseComponentAsAny = BaseComponent;
31
+ return /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({}, rest, {
30
32
  className: className
31
33
  }), children);
32
34
  }
@@ -47,5 +49,6 @@ ColumnHang.propTypes = {
47
49
  */
48
50
  className: PropTypes.string
49
51
  };
52
+ var ColumnHangComponent = ColumnHang;
50
53
 
51
- export { ColumnHang };
54
+ export { ColumnHangComponent as ColumnHang };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { GridComponent } from './GridTypes';
8
+ declare const FlexGridComponent: GridComponent;
9
+ export { FlexGridComponent as FlexGrid };
@@ -30,11 +30,13 @@ function FlexGrid(_ref) {
30
30
  rest = _objectWithoutProperties(_ref, _excluded);
31
31
 
32
32
  var prefix = usePrefix();
33
- var className = cx(containerClassName, (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--grid"), true), _defineProperty(_cx, "".concat(prefix, "--grid--condensed"), condensed), _defineProperty(_cx, "".concat(prefix, "--grid--narrow"), narrow), _defineProperty(_cx, "".concat(prefix, "--grid--full-width"), fullWidth), _cx));
33
+ var className = cx(containerClassName, (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--grid"), true), _defineProperty(_cx, "".concat(prefix, "--grid--condensed"), condensed), _defineProperty(_cx, "".concat(prefix, "--grid--narrow"), narrow), _defineProperty(_cx, "".concat(prefix, "--grid--full-width"), fullWidth), _cx)); // cast as any to let TypeScript allow passing in attributes to base component
34
+
35
+ var BaseComponentAsAny = BaseComponent;
34
36
  return /*#__PURE__*/React__default.createElement(GridSettings, {
35
37
  mode: "flexbox",
36
38
  subgrid: false
37
- }, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({
39
+ }, /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({
38
40
  className: className
39
41
  }, rest), children));
40
42
  }
@@ -72,5 +74,6 @@ FlexGrid.propTypes = {
72
74
  */
73
75
  narrow: PropTypes.bool
74
76
  };
77
+ var FlexGridComponent = FlexGrid;
75
78
 
76
- export { FlexGrid };
79
+ export { FlexGridComponent as FlexGrid };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { GridComponent } from './GridTypes';
8
+ declare const GridAsGridComponent: GridComponent;
9
+ export { GridAsGridComponent as Grid };
@@ -8,17 +8,17 @@
8
8
  import PropTypes from 'prop-types';
9
9
  import React__default from 'react';
10
10
  import { useFeatureFlag } from '../FeatureFlags/index.js';
11
- import { CSSGrid } from './CSSGrid.js';
12
- import { FlexGrid } from './FlexGrid.js';
11
+ import { CSSGrid as CSSGridComponent } from './CSSGrid.js';
12
+ import { FlexGrid as FlexGridComponent } from './FlexGrid.js';
13
13
 
14
14
  function Grid(props) {
15
15
  var enableCSSGrid = useFeatureFlag('enable-css-grid');
16
16
 
17
17
  if (enableCSSGrid) {
18
- return /*#__PURE__*/React__default.createElement(CSSGrid, props);
18
+ return /*#__PURE__*/React__default.createElement(CSSGridComponent, props);
19
19
  }
20
20
 
21
- return /*#__PURE__*/React__default.createElement(FlexGrid, props);
21
+ return /*#__PURE__*/React__default.createElement(FlexGridComponent, props);
22
22
  }
23
23
 
24
24
  Grid.propTypes = {
@@ -54,5 +54,6 @@ Grid.propTypes = {
54
54
  */
55
55
  narrow: PropTypes.bool
56
56
  };
57
+ var GridAsGridComponent = Grid;
57
58
 
58
- export { Grid };
59
+ export { GridAsGridComponent as Grid };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as React from 'react';
8
+ export type GridMode = 'flexbox' | 'css-grid';
9
+ export interface GridSettingContext {
10
+ /**
11
+ * The grid mode for the GridContext
12
+ */
13
+ mode: GridMode;
14
+ /**
15
+ * Specifies whether subgrid should be enabled
16
+ */
17
+ subgrid?: boolean;
18
+ }
19
+ export interface GridSettingsProps {
20
+ /**
21
+ * Pass in components which will be rendered within the `GridSettings`
22
+ * component
23
+ */
24
+ children?: React.ReactNode;
25
+ /**
26
+ * Specify the grid mode for the GridContext
27
+ */
28
+ mode: GridMode;
29
+ /**
30
+ * Specify whether subgrid should be enabled
31
+ */
32
+ subgrid?: boolean;
33
+ }
34
+ export declare const GridSettings: React.FC<GridSettingsProps>;
35
+ /**
36
+ * Helper function for accessing the GridContext value
37
+ */
38
+ export declare const useGridSettings: () => GridSettingContext;
@@ -12,12 +12,11 @@ import * as React from 'react';
12
12
  * Provides a grid context for communication the grid "mode" (flexbox or
13
13
  * css-grid) along with subgrid information.
14
14
  */
15
-
16
15
  var GridSettingsContext = /*#__PURE__*/React.createContext({
17
16
  mode: 'flexbox',
18
17
  subgrid: false
19
18
  });
20
- function GridSettings(_ref) {
19
+ var GridSettings = function GridSettings(_ref) {
21
20
  var children = _ref.children,
22
21
  mode = _ref.mode,
23
22
  _ref$subgrid = _ref.subgrid,
@@ -31,7 +30,8 @@ function GridSettings(_ref) {
31
30
  return /*#__PURE__*/React.createElement(GridSettingsContext.Provider, {
32
31
  value: value
33
32
  }, children);
34
- }
33
+ };
34
+ var gridModes = ['flexbox', 'css-grid'];
35
35
  GridSettings.propTypes = {
36
36
  /**
37
37
  * Pass in components which will be rendered within the `GridSettings`
@@ -42,7 +42,7 @@ GridSettings.propTypes = {
42
42
  /**
43
43
  * Specify the grid mode for the GridContext
44
44
  */
45
- mode: PropTypes.oneOf(['flexbox', 'css-grid']).isRequired,
45
+ mode: PropTypes.oneOf(gridModes).isRequired,
46
46
 
47
47
  /**
48
48
  * Specify whether subgrid should be enabled
@@ -53,8 +53,8 @@ GridSettings.propTypes = {
53
53
  * Helper function for accessing the GridContext value
54
54
  */
55
55
 
56
- function useGridSettings() {
56
+ var useGridSettings = function useGridSettings() {
57
57
  return React.useContext(GridSettingsContext);
58
- }
58
+ };
59
59
 
60
60
  export { GridSettings, useGridSettings };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /// <reference types="react" />
8
+ import { PolymorphicProps } from '../../types/common';
9
+ interface GridBaseProps {
10
+ /**
11
+ * Pass in content that will be rendered within the `Grid`
12
+ */
13
+ children?: React.ReactNode;
14
+ /**
15
+ * Specify a custom className to be applied to the `Grid`
16
+ */
17
+ className?: string;
18
+ /**
19
+ * Collapse the gutter to 1px. Useful for fluid layouts.
20
+ * Rows have 1px of margin between them to match gutter.
21
+ */
22
+ condensed?: boolean;
23
+ /**
24
+ * Remove the default max width that the grid has set
25
+ */
26
+ fullWidth?: boolean;
27
+ /**
28
+ * Container hangs 16px into the gutter. Useful for
29
+ * typographic alignment with and without containers.
30
+ */
31
+ narrow?: boolean;
32
+ }
33
+ export type GridProps<T extends React.ElementType> = PolymorphicProps<T, GridBaseProps>;
34
+ export interface GridComponent {
35
+ <T extends React.ElementType>(props: GridProps<T>, context?: any): React.ReactElement<any, any> | null;
36
+ }
37
+ export {};
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { PolymorphicProps } from '../../types/common';
9
+ export interface RowBaseProps {
10
+ /**
11
+ * Pass in content that will be rendered within the `Row`
12
+ */
13
+ children?: React.ReactNode;
14
+ /**
15
+ * Specify a custom className to be applied to the `Row`
16
+ */
17
+ className?: string;
18
+ /**
19
+ * Specify a single row as condensed.Rows that are adjacent
20
+ * and are condensed will have 2px of margin between them to match gutter.
21
+ */
22
+ condensed?: boolean;
23
+ /**
24
+ * Specify a single row as narrow. The container will hang
25
+ * 16px into the gutter.
26
+ */
27
+ narrow?: boolean;
28
+ }
29
+ export type RowProps<T extends React.ElementType> = PolymorphicProps<T, RowBaseProps>;
30
+ export interface RowComponent {
31
+ <T extends React.ElementType>(props: RowProps<T>, context?: any): React.ReactElement<any, any> | null;
32
+ }
33
+ declare const _default: RowComponent;
34
+ export default _default;
@@ -27,8 +27,10 @@ function Row(_ref) {
27
27
  rest = _objectWithoutProperties(_ref, _excluded);
28
28
 
29
29
  var prefix = usePrefix();
30
- var className = cx(containerClassName, (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--row"), true), _defineProperty(_cx, "".concat(prefix, "--row--condensed"), condensed), _defineProperty(_cx, "".concat(prefix, "--row--narrow"), narrow), _cx));
31
- return /*#__PURE__*/React__default.createElement(BaseComponent, _extends({
30
+ var className = cx(containerClassName, (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--row"), true), _defineProperty(_cx, "".concat(prefix, "--row--condensed"), condensed), _defineProperty(_cx, "".concat(prefix, "--row--narrow"), narrow), _cx)); // TypeScript type validation reports conflicts on different instances of keyof JSX.IntrinsicElements
31
+
32
+ var BaseComponentAsAny = BaseComponent;
33
+ return /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({
32
34
  className: className
33
35
  }, rest), children);
34
36
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export { FlexGrid } from './FlexGrid';
8
+ export { Grid } from './Grid';
9
+ export { default as Row } from './Row';
10
+ export { default as Column } from './Column';
11
+ export { ColumnHang } from './ColumnHang';
@@ -9,18 +9,20 @@ import { objectWithoutProperties as _objectWithoutProperties } from '../../_virt
9
9
  import PropTypes from 'prop-types';
10
10
  import React__default from 'react';
11
11
 
12
- var _excluded = ["as", "children"];
12
+ var _excluded = ["as", "level", "children"];
13
13
  var HeadingContext = /*#__PURE__*/React__default.createContext(1);
14
14
 
15
15
  function Section(_ref) {
16
16
  var _ref$as = _ref.as,
17
17
  BaseComponent = _ref$as === void 0 ? 'section' : _ref$as,
18
+ levelOverride = _ref.level,
18
19
  children = _ref.children,
19
20
  rest = _objectWithoutProperties(_ref, _excluded);
20
21
 
21
- var level = React__default.useContext(HeadingContext);
22
+ var parentLevel = React__default.useContext(HeadingContext);
23
+ var level = typeof levelOverride !== 'undefined' ? levelOverride : parentLevel + 1;
22
24
  return /*#__PURE__*/React__default.createElement(HeadingContext.Provider, {
23
- value: Math.min(level + 1, 6)
25
+ value: Math.min(level, 6)
24
26
  }, /*#__PURE__*/React__default.createElement(BaseComponent, rest, children));
25
27
  }
26
28
 
@@ -39,7 +41,12 @@ Section.propTypes = {
39
41
  /**
40
42
  * Specify a class name for the outermost node of the component
41
43
  */
42
- className: PropTypes.string
44
+ className: PropTypes.string,
45
+
46
+ /**
47
+ * Overrides the level of the section
48
+ */
49
+ level: PropTypes.number
43
50
  };
44
51
 
45
52
  function Heading(props) {