@carbon/react 1.23.0-rc.0 → 1.23.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 (37) hide show
  1. package/es/components/DataTable/tools/sorting.js +3 -0
  2. package/es/components/Grid/CSSGrid.d.ts +9 -0
  3. package/es/components/Grid/CSSGrid.js +8 -5
  4. package/es/components/Grid/Column.d.ts +73 -0
  5. package/es/components/Grid/Column.js +40 -34
  6. package/es/components/Grid/ColumnHang.d.ts +24 -0
  7. package/es/components/Grid/ColumnHang.js +7 -4
  8. package/es/components/Grid/FlexGrid.d.ts +9 -0
  9. package/es/components/Grid/FlexGrid.js +6 -3
  10. package/es/components/Grid/Grid.d.ts +9 -0
  11. package/es/components/Grid/Grid.js +6 -5
  12. package/es/components/Grid/GridContext.d.ts +38 -0
  13. package/es/components/Grid/GridContext.js +6 -6
  14. package/es/components/Grid/GridTypes.d.ts +37 -0
  15. package/es/components/Grid/Row.d.ts +34 -0
  16. package/es/components/Grid/Row.js +4 -2
  17. package/es/components/Grid/index.d.ts +11 -0
  18. package/es/index.js +5 -5
  19. package/lib/components/DataTable/tools/sorting.js +3 -0
  20. package/lib/components/Grid/CSSGrid.d.ts +9 -0
  21. package/lib/components/Grid/CSSGrid.js +8 -5
  22. package/lib/components/Grid/Column.d.ts +73 -0
  23. package/lib/components/Grid/Column.js +36 -30
  24. package/lib/components/Grid/ColumnHang.d.ts +24 -0
  25. package/lib/components/Grid/ColumnHang.js +7 -4
  26. package/lib/components/Grid/FlexGrid.d.ts +9 -0
  27. package/lib/components/Grid/FlexGrid.js +6 -3
  28. package/lib/components/Grid/Grid.d.ts +9 -0
  29. package/lib/components/Grid/Grid.js +2 -1
  30. package/lib/components/Grid/GridContext.d.ts +38 -0
  31. package/lib/components/Grid/GridContext.js +6 -6
  32. package/lib/components/Grid/GridTypes.d.ts +37 -0
  33. package/lib/components/Grid/Row.d.ts +34 -0
  34. package/lib/components/Grid/Row.js +4 -2
  35. package/lib/components/Grid/index.d.ts +11 -0
  36. package/lib/index.js +10 -10
  37. package/package.json +3 -3
@@ -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,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';
package/es/index.js CHANGED
@@ -14,6 +14,11 @@ export { default as Dropdown } from './components/Dropdown/Dropdown.js';
14
14
  export { default as DropdownSkeleton } from './components/Dropdown/Dropdown.Skeleton.js';
15
15
  export { default as FluidForm } from './components/FluidForm/FluidForm.js';
16
16
  export { FormContext } from './components/FluidForm/FormContext.js';
17
+ export { FlexGrid } from './components/Grid/FlexGrid.js';
18
+ export { Grid } from './components/Grid/Grid.js';
19
+ export { default as Row } from './components/Grid/Row.js';
20
+ export { default as Column } from './components/Grid/Column.js';
21
+ export { ColumnHang } from './components/Grid/ColumnHang.js';
17
22
  export { IdPrefix } from './components/IdPrefix/index.js';
18
23
  export { default as OverflowMenu } from './components/OverflowMenu/index.js';
19
24
  export { default as Slider } from './components/Slider/index.js';
@@ -70,8 +75,6 @@ export { default as FileUploaderDropContainer } from './components/FileUploader/
70
75
  export { default as FileUploaderItem } from './components/FileUploader/FileUploaderItem.js';
71
76
  export { default as FormItem } from './components/FormItem/FormItem.js';
72
77
  export { default as FormLabel } from './components/FormLabel/FormLabel.js';
73
- export { default as Row } from './components/Grid/Row.js';
74
- export { default as Column } from './components/Grid/Column.js';
75
78
  export { default as InlineLoading } from './components/InlineLoading/InlineLoading.js';
76
79
  export { default as Loading } from './components/Loading/Loading.js';
77
80
  export { default as NumberInputSkeleton } from './components/NumberInput/NumberInput.Skeleton.js';
@@ -150,9 +153,6 @@ export { default as FileUploader } from './components/FileUploader/FileUploader.
150
153
  export { default as FilterableMultiSelect } from './components/MultiSelect/FilterableMultiSelect.js';
151
154
  export { default as Form } from './components/Form/Form.js';
152
155
  export { default as FormGroup } from './components/FormGroup/FormGroup.js';
153
- export { FlexGrid } from './components/Grid/FlexGrid.js';
154
- export { Grid } from './components/Grid/Grid.js';
155
- export { ColumnHang } from './components/Grid/ColumnHang.js';
156
156
  export { default as Link } from './components/Link/Link.js';
157
157
  export { default as ListItem } from './components/ListItem/ListItem.js';
158
158
  export { default as Modal } from './components/Modal/Modal.js';
@@ -27,6 +27,9 @@ var sortStates = require('../state/sortStates.js');
27
27
 
28
28
  var compare = function compare(a, b) {
29
29
  var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en';
30
+ // prevent multiple null values in one column (sorting breaks)
31
+ a === null ? a = '' : null;
32
+ b === null ? b = '' : null;
30
33
 
31
34
  if (typeof a === 'number' && typeof b === 'number') {
32
35
  return a - b;
@@ -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 };
@@ -64,11 +64,13 @@ function CSSGrid(_ref) {
64
64
  }, rest), children));
65
65
  }
66
66
 
67
- var className = cx__default["default"](customClassName, (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--css-grid"), true), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--css-grid--condensed"), mode === 'condensed'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--css-grid--narrow"), mode === 'narrow'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--css-grid--full-width"), fullWidth), _cx));
67
+ var className = cx__default["default"](customClassName, (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--css-grid"), true), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--css-grid--condensed"), mode === 'condensed'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--css-grid--narrow"), mode === 'narrow'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--css-grid--full-width"), fullWidth), _cx)); // cast as any to let TypeScript allow passing in attributes to base component
68
+
69
+ var BaseComponentAsAny = BaseComponent;
68
70
  return /*#__PURE__*/React__default["default"].createElement(GridContext.GridSettings, {
69
71
  mode: "css-grid",
70
72
  subgrid: true
71
- }, /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({
73
+ }, /*#__PURE__*/React__default["default"].createElement(BaseComponentAsAny, _rollupPluginBabelHelpers["extends"]({
72
74
  className: className
73
75
  }, rest), children));
74
76
  }
@@ -107,7 +109,7 @@ CSSGrid.propTypes = {
107
109
  narrow: PropTypes__default["default"].bool
108
110
  };
109
111
 
110
- function Subgrid(_ref2) {
112
+ var Subgrid = function Subgrid(_ref2) {
111
113
  var _cx2;
112
114
 
113
115
  var _ref2$as = _ref2.as,
@@ -122,7 +124,7 @@ function Subgrid(_ref2) {
122
124
  return /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({}, rest, {
123
125
  className: className
124
126
  }), children);
125
- }
127
+ };
126
128
 
127
129
  Subgrid.propTypes = {
128
130
  /**
@@ -145,5 +147,6 @@ Subgrid.propTypes = {
145
147
  */
146
148
  mode: PropTypes__default["default"].oneOf(['wide', 'narrow', 'condensed'])
147
149
  };
150
+ var CSSGridComponent = CSSGrid;
148
151
 
149
- exports.CSSGrid = CSSGrid;
152
+ exports.CSSGrid = CSSGridComponent;
@@ -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;
@@ -75,8 +75,10 @@ function Column(_ref) {
75
75
  }
76
76
 
77
77
  var columnClassName = getClassNameForFlexGridBreakpoints([sm, md, lg, xlg, max], prefix);
78
- var className = cx__default["default"](customClassName, columnClassName, _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--col"), columnClassName.length === 0));
79
- return /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({
78
+ var className = cx__default["default"](customClassName, columnClassName, _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--col"), columnClassName.length === 0)); // cast as any to let TypeScript allow passing in attributes to base component
79
+
80
+ var BaseComponentAsAny = BaseComponent;
81
+ return /*#__PURE__*/React__default["default"].createElement(BaseComponentAsAny, _rollupPluginBabelHelpers["extends"]({
80
82
  className: className
81
83
  }, rest), children);
82
84
  }
@@ -281,28 +283,30 @@ function getClassNameForBreakpoints(breakpoints, prefix) {
281
283
  continue;
282
284
  }
283
285
 
284
- var span = breakpoint.span,
285
- offset = breakpoint.offset,
286
- start = breakpoint.start,
287
- end = breakpoint.end;
286
+ if (_rollupPluginBabelHelpers["typeof"](breakpoint) === 'object') {
287
+ var span = breakpoint.span,
288
+ offset = breakpoint.offset,
289
+ start = breakpoint.start,
290
+ end = breakpoint.end;
288
291
 
289
- if (typeof offset === 'number' && offset > 0) {
290
- classNames.push("".concat(prefix, "--").concat(name, ":col-start-").concat(offset + 1));
291
- }
292
+ if (typeof offset === 'number' && offset > 0) {
293
+ classNames.push("".concat(prefix, "--").concat(name, ":col-start-").concat(offset + 1));
294
+ }
292
295
 
293
- if (typeof start === 'number') {
294
- classNames.push("".concat(prefix, "--").concat(name, ":col-start-").concat(start));
295
- }
296
+ if (typeof start === 'number') {
297
+ classNames.push("".concat(prefix, "--").concat(name, ":col-start-").concat(start));
298
+ }
296
299
 
297
- if (typeof end === 'number') {
298
- classNames.push("".concat(prefix, "--").concat(name, ":col-end-").concat(end));
299
- }
300
+ if (typeof end === 'number') {
301
+ classNames.push("".concat(prefix, "--").concat(name, ":col-end-").concat(end));
302
+ }
300
303
 
301
- if (typeof span === 'number') {
302
- classNames.push("".concat(prefix, "--").concat(name, ":col-span-").concat(span));
303
- } else if (typeof span === 'string') {
304
- classNames.push("".concat(prefix, "--").concat(name, ":col-span-").concat(span.slice(0, -1)));
305
- continue;
304
+ if (typeof span === 'number') {
305
+ classNames.push("".concat(prefix, "--").concat(name, ":col-span-").concat(span));
306
+ } else if (typeof span === 'string') {
307
+ classNames.push("".concat(prefix, "--").concat(name, ":col-span-").concat(span.slice(0, -1)));
308
+ continue;
309
+ }
306
310
  }
307
311
  }
308
312
 
@@ -340,19 +344,21 @@ function getClassNameForFlexGridBreakpoints(breakpoints, prefix) {
340
344
  continue;
341
345
  }
342
346
 
343
- var span = breakpoint.span,
344
- offset = breakpoint.offset;
347
+ if (_rollupPluginBabelHelpers["typeof"](breakpoint) === 'object') {
348
+ var span = breakpoint.span,
349
+ offset = breakpoint.offset;
345
350
 
346
- if (typeof span === 'number') {
347
- classNames.push("".concat(prefix, "--col-").concat(name, "-").concat(span));
348
- }
351
+ if (typeof span === 'number') {
352
+ classNames.push("".concat(prefix, "--col-").concat(name, "-").concat(span));
353
+ }
349
354
 
350
- if (span === true) {
351
- classNames.push("".concat(prefix, "--col-").concat(name));
352
- }
355
+ if (span === true) {
356
+ classNames.push("".concat(prefix, "--col-").concat(name));
357
+ }
353
358
 
354
- if (typeof offset === 'number') {
355
- classNames.push("".concat(prefix, "--offset-").concat(name, "-").concat(offset));
359
+ if (typeof offset === 'number') {
360
+ classNames.push("".concat(prefix, "--offset-").concat(name, "-").concat(offset));
361
+ }
356
362
  }
357
363
  }
358
364
 
@@ -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 };
@@ -22,11 +22,11 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
22
22
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
23
23
 
24
24
  var _excluded = ["as", "className", "children"];
25
+
25
26
  /**
26
27
  * Helper component for rendering content that hangs on the column. Useful when
27
28
  * trying to align content across different grid modes
28
29
  */
29
-
30
30
  function ColumnHang(_ref) {
31
31
  var _ref$as = _ref.as,
32
32
  BaseComponent = _ref$as === void 0 ? 'div' : _ref$as,
@@ -35,8 +35,10 @@ function ColumnHang(_ref) {
35
35
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
36
36
 
37
37
  var prefix = usePrefix.usePrefix();
38
- var className = cx__default["default"](customClassName, "".concat(prefix, "--grid-column-hang"));
39
- return /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({}, rest, {
38
+ var className = cx__default["default"](customClassName, "".concat(prefix, "--grid-column-hang")); // cast as any to let TypeScript allow passing in attributes to base component
39
+
40
+ var BaseComponentAsAny = BaseComponent;
41
+ return /*#__PURE__*/React__default["default"].createElement(BaseComponentAsAny, _rollupPluginBabelHelpers["extends"]({}, rest, {
40
42
  className: className
41
43
  }), children);
42
44
  }
@@ -57,5 +59,6 @@ ColumnHang.propTypes = {
57
59
  */
58
60
  className: PropTypes__default["default"].string
59
61
  };
62
+ var ColumnHangComponent = ColumnHang;
60
63
 
61
- exports.ColumnHang = ColumnHang;
64
+ exports.ColumnHang = ColumnHangComponent;
@@ -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 };
@@ -40,11 +40,13 @@ function FlexGrid(_ref) {
40
40
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
41
41
 
42
42
  var prefix = usePrefix.usePrefix();
43
- var className = cx__default["default"](containerClassName, (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--grid"), true), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--grid--condensed"), condensed), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--grid--narrow"), narrow), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--grid--full-width"), fullWidth), _cx));
43
+ var className = cx__default["default"](containerClassName, (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--grid"), true), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--grid--condensed"), condensed), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--grid--narrow"), narrow), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--grid--full-width"), fullWidth), _cx)); // cast as any to let TypeScript allow passing in attributes to base component
44
+
45
+ var BaseComponentAsAny = BaseComponent;
44
46
  return /*#__PURE__*/React__default["default"].createElement(GridContext.GridSettings, {
45
47
  mode: "flexbox",
46
48
  subgrid: false
47
- }, /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({
49
+ }, /*#__PURE__*/React__default["default"].createElement(BaseComponentAsAny, _rollupPluginBabelHelpers["extends"]({
48
50
  className: className
49
51
  }, rest), children));
50
52
  }
@@ -82,5 +84,6 @@ FlexGrid.propTypes = {
82
84
  */
83
85
  narrow: PropTypes__default["default"].bool
84
86
  };
87
+ var FlexGridComponent = FlexGrid;
85
88
 
86
- exports.FlexGrid = FlexGrid;
89
+ exports.FlexGrid = FlexGridComponent;
@@ -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 };
@@ -63,5 +63,6 @@ Grid.propTypes = {
63
63
  */
64
64
  narrow: PropTypes__default["default"].bool
65
65
  };
66
+ var GridAsGridComponent = Grid;
66
67
 
67
- exports.Grid = Grid;
68
+ exports.Grid = GridAsGridComponent;
@@ -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;
@@ -39,12 +39,11 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
39
39
  * Provides a grid context for communication the grid "mode" (flexbox or
40
40
  * css-grid) along with subgrid information.
41
41
  */
42
-
43
42
  var GridSettingsContext = /*#__PURE__*/React__namespace.createContext({
44
43
  mode: 'flexbox',
45
44
  subgrid: false
46
45
  });
47
- function GridSettings(_ref) {
46
+ var GridSettings = function GridSettings(_ref) {
48
47
  var children = _ref.children,
49
48
  mode = _ref.mode,
50
49
  _ref$subgrid = _ref.subgrid,
@@ -58,7 +57,8 @@ function GridSettings(_ref) {
58
57
  return /*#__PURE__*/React__namespace.createElement(GridSettingsContext.Provider, {
59
58
  value: value
60
59
  }, children);
61
- }
60
+ };
61
+ var gridModes = ['flexbox', 'css-grid'];
62
62
  GridSettings.propTypes = {
63
63
  /**
64
64
  * Pass in components which will be rendered within the `GridSettings`
@@ -69,7 +69,7 @@ GridSettings.propTypes = {
69
69
  /**
70
70
  * Specify the grid mode for the GridContext
71
71
  */
72
- mode: PropTypes__default["default"].oneOf(['flexbox', 'css-grid']).isRequired,
72
+ mode: PropTypes__default["default"].oneOf(gridModes).isRequired,
73
73
 
74
74
  /**
75
75
  * Specify whether subgrid should be enabled
@@ -80,9 +80,9 @@ GridSettings.propTypes = {
80
80
  * Helper function for accessing the GridContext value
81
81
  */
82
82
 
83
- function useGridSettings() {
83
+ var useGridSettings = function useGridSettings() {
84
84
  return React__namespace.useContext(GridSettingsContext);
85
- }
85
+ };
86
86
 
87
87
  exports.GridSettings = GridSettings;
88
88
  exports.useGridSettings = 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;
@@ -37,8 +37,10 @@ function Row(_ref) {
37
37
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
38
38
 
39
39
  var prefix = usePrefix.usePrefix();
40
- var className = cx__default["default"](containerClassName, (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--row"), true), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--row--condensed"), condensed), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--row--narrow"), narrow), _cx));
41
- return /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({
40
+ var className = cx__default["default"](containerClassName, (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--row"), true), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--row--condensed"), condensed), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--row--narrow"), narrow), _cx)); // TypeScript type validation reports conflicts on different instances of keyof JSX.IntrinsicElements
41
+
42
+ var BaseComponentAsAny = BaseComponent;
43
+ return /*#__PURE__*/React__default["default"].createElement(BaseComponentAsAny, _rollupPluginBabelHelpers["extends"]({
42
44
  className: className
43
45
  }, rest), children);
44
46
  }
@@ -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';
package/lib/index.js CHANGED
@@ -18,6 +18,11 @@ var Dropdown = require('./components/Dropdown/Dropdown.js');
18
18
  var Dropdown_Skeleton = require('./components/Dropdown/Dropdown.Skeleton.js');
19
19
  var FluidForm = require('./components/FluidForm/FluidForm.js');
20
20
  var FormContext = require('./components/FluidForm/FormContext.js');
21
+ var FlexGrid = require('./components/Grid/FlexGrid.js');
22
+ var Grid = require('./components/Grid/Grid.js');
23
+ var Row = require('./components/Grid/Row.js');
24
+ var Column = require('./components/Grid/Column.js');
25
+ var ColumnHang = require('./components/Grid/ColumnHang.js');
21
26
  var index$4 = require('./components/IdPrefix/index.js');
22
27
  var index$5 = require('./components/OverflowMenu/index.js');
23
28
  var index$6 = require('./components/Slider/index.js');
@@ -74,8 +79,6 @@ var FileUploaderDropContainer = require('./components/FileUploader/FileUploaderD
74
79
  var FileUploaderItem = require('./components/FileUploader/FileUploaderItem.js');
75
80
  var FormItem = require('./components/FormItem/FormItem.js');
76
81
  var FormLabel = require('./components/FormLabel/FormLabel.js');
77
- var Row = require('./components/Grid/Row.js');
78
- var Column = require('./components/Grid/Column.js');
79
82
  var InlineLoading = require('./components/InlineLoading/InlineLoading.js');
80
83
  var Loading = require('./components/Loading/Loading.js');
81
84
  var NumberInput_Skeleton = require('./components/NumberInput/NumberInput.Skeleton.js');
@@ -154,9 +157,6 @@ var FileUploader = require('./components/FileUploader/FileUploader.js');
154
157
  var FilterableMultiSelect = require('./components/MultiSelect/FilterableMultiSelect.js');
155
158
  var Form = require('./components/Form/Form.js');
156
159
  var FormGroup = require('./components/FormGroup/FormGroup.js');
157
- var FlexGrid = require('./components/Grid/FlexGrid.js');
158
- var Grid = require('./components/Grid/Grid.js');
159
- var ColumnHang = require('./components/Grid/ColumnHang.js');
160
160
  var Link = require('./components/Link/Link.js');
161
161
  var ListItem = require('./components/ListItem/ListItem.js');
162
162
  var Modal = require('./components/Modal/Modal.js');
@@ -232,6 +232,11 @@ exports.Dropdown = Dropdown["default"];
232
232
  exports.DropdownSkeleton = Dropdown_Skeleton["default"];
233
233
  exports.FluidForm = FluidForm["default"];
234
234
  exports.FormContext = FormContext.FormContext;
235
+ exports.FlexGrid = FlexGrid.FlexGrid;
236
+ exports.Grid = Grid.Grid;
237
+ exports.Row = Row["default"];
238
+ exports.Column = Column["default"];
239
+ exports.ColumnHang = ColumnHang.ColumnHang;
235
240
  exports.IdPrefix = index$4.IdPrefix;
236
241
  exports.OverflowMenu = index$5["default"];
237
242
  exports.Slider = index$6["default"];
@@ -301,8 +306,6 @@ exports.FileUploaderDropContainer = FileUploaderDropContainer["default"];
301
306
  exports.FileUploaderItem = FileUploaderItem["default"];
302
307
  exports.FormItem = FormItem["default"];
303
308
  exports.FormLabel = FormLabel["default"];
304
- exports.Row = Row["default"];
305
- exports.Column = Column["default"];
306
309
  exports.InlineLoading = InlineLoading["default"];
307
310
  exports.Loading = Loading["default"];
308
311
  exports.NumberInputSkeleton = NumberInput_Skeleton["default"];
@@ -382,9 +385,6 @@ exports.FileUploader = FileUploader["default"];
382
385
  exports.FilterableMultiSelect = FilterableMultiSelect["default"];
383
386
  exports.Form = Form["default"];
384
387
  exports.FormGroup = FormGroup["default"];
385
- exports.FlexGrid = FlexGrid.FlexGrid;
386
- exports.Grid = Grid.Grid;
387
- exports.ColumnHang = ColumnHang.ColumnHang;
388
388
  exports.Link = Link["default"];
389
389
  exports.ListItem = ListItem["default"];
390
390
  exports.Modal = Modal["default"];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.23.0-rc.0",
4
+ "version": "1.23.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -46,7 +46,7 @@
46
46
  "@carbon/feature-flags": "^0.12.0",
47
47
  "@carbon/icons-react": "^11.16.0",
48
48
  "@carbon/layout": "^11.11.0",
49
- "@carbon/styles": "^1.23.0-rc.0",
49
+ "@carbon/styles": "^1.23.0",
50
50
  "@carbon/telemetry": "0.1.0",
51
51
  "classnames": "2.3.2",
52
52
  "copy-to-clipboard": "^3.3.1",
@@ -133,5 +133,5 @@
133
133
  "**/*.scss",
134
134
  "**/*.css"
135
135
  ],
136
- "gitHead": "61937768ed4c69f8ec98c7c193d3c30b12c03b46"
136
+ "gitHead": "6234f2b1304e340345fff3935342f80a1e36e08e"
137
137
  }