@carbon/react 1.22.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 (85) hide show
  1. package/es/components/CodeSnippet/CodeSnippet.js +2 -2
  2. package/es/components/ComboBox/ComboBox.d.ts +151 -0
  3. package/es/components/ComboBox/ComboBox.js +28 -21
  4. package/es/components/ComposedModal/ComposedModal.js +2 -2
  5. package/es/components/DataTable/TableSelectRow.d.ts +88 -0
  6. package/es/components/DataTable/TableSelectRow.js +3 -5
  7. package/es/components/DataTable/tools/sorting.js +3 -0
  8. package/es/components/DatePicker/DatePicker.js +1 -1
  9. package/es/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
  10. package/es/components/DatePicker/plugins/rangePlugin.js +1 -1
  11. package/es/components/FileUploader/FileUploaderButton.js +14 -16
  12. package/es/components/Grid/CSSGrid.d.ts +9 -0
  13. package/es/components/Grid/CSSGrid.js +8 -5
  14. package/es/components/Grid/Column.d.ts +73 -0
  15. package/es/components/Grid/Column.js +40 -34
  16. package/es/components/Grid/ColumnHang.d.ts +24 -0
  17. package/es/components/Grid/ColumnHang.js +7 -4
  18. package/es/components/Grid/FlexGrid.d.ts +9 -0
  19. package/es/components/Grid/FlexGrid.js +6 -3
  20. package/es/components/Grid/Grid.d.ts +9 -0
  21. package/es/components/Grid/Grid.js +6 -5
  22. package/es/components/Grid/GridContext.d.ts +38 -0
  23. package/es/components/Grid/GridContext.js +6 -6
  24. package/es/components/Grid/GridTypes.d.ts +37 -0
  25. package/es/components/Grid/Row.d.ts +34 -0
  26. package/es/components/Grid/Row.js +4 -2
  27. package/es/components/Grid/index.d.ts +11 -0
  28. package/es/components/NumberInput/NumberInput.d.ts +132 -0
  29. package/es/components/NumberInput/NumberInput.js +9 -7
  30. package/es/components/TextArea/TextArea.js +1 -0
  31. package/es/components/Toggle/Toggle.js +54 -33
  32. package/es/components/Toggletip/index.js +26 -1
  33. package/es/index.js +5 -5
  34. package/es/internal/useNormalizedInputProps.js +3 -3
  35. package/lib/components/CodeSnippet/CodeSnippet.js +4 -3
  36. package/lib/components/ComboBox/ComboBox.d.ts +151 -0
  37. package/lib/components/ComboBox/ComboBox.js +28 -21
  38. package/lib/components/ComposedModal/ComposedModal.js +2 -2
  39. package/lib/components/DataTable/TableSelectRow.d.ts +88 -0
  40. package/lib/components/DataTable/TableSelectRow.js +2 -4
  41. package/lib/components/DataTable/tools/sorting.js +3 -0
  42. package/lib/components/DatePicker/DatePicker.js +9 -8
  43. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
  44. package/lib/components/DatePicker/plugins/rangePlugin.js +6 -2
  45. package/lib/components/FileUploader/FileUploaderButton.js +14 -16
  46. package/lib/components/Grid/CSSGrid.d.ts +9 -0
  47. package/lib/components/Grid/CSSGrid.js +8 -5
  48. package/lib/components/Grid/Column.d.ts +73 -0
  49. package/lib/components/Grid/Column.js +36 -30
  50. package/lib/components/Grid/ColumnHang.d.ts +24 -0
  51. package/lib/components/Grid/ColumnHang.js +7 -4
  52. package/lib/components/Grid/FlexGrid.d.ts +9 -0
  53. package/lib/components/Grid/FlexGrid.js +6 -3
  54. package/lib/components/Grid/Grid.d.ts +9 -0
  55. package/lib/components/Grid/Grid.js +2 -1
  56. package/lib/components/Grid/GridContext.d.ts +38 -0
  57. package/lib/components/Grid/GridContext.js +6 -6
  58. package/lib/components/Grid/GridTypes.d.ts +37 -0
  59. package/lib/components/Grid/Row.d.ts +34 -0
  60. package/lib/components/Grid/Row.js +4 -2
  61. package/lib/components/Grid/index.d.ts +11 -0
  62. package/lib/components/NumberInput/NumberInput.d.ts +132 -0
  63. package/lib/components/NumberInput/NumberInput.js +9 -7
  64. package/lib/components/TextArea/TextArea.js +1 -0
  65. package/lib/components/Toggle/Toggle.js +53 -32
  66. package/lib/components/Toggletip/index.js +26 -1
  67. package/lib/index.js +10 -10
  68. package/lib/internal/useNormalizedInputProps.js +3 -3
  69. package/package.json +3 -5
  70. package/es/_virtual/ResizeObserver.es.js +0 -13
  71. package/es/_virtual/_commonjsHelpers.js +0 -42
  72. package/es/_virtual/index.js +0 -14
  73. package/es/_virtual/rangePlugin.js +0 -14
  74. package/es/node_modules/flatpickr/dist/l10n/index.js +0 -1423
  75. package/es/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -196
  76. package/es/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1112
  77. package/es/node_modules/use-resize-observer/polyfilled.js +0 -111
  78. package/lib/_virtual/ResizeObserver.es.js +0 -17
  79. package/lib/_virtual/_commonjsHelpers.js +0 -48
  80. package/lib/_virtual/index.js +0 -18
  81. package/lib/_virtual/rangePlugin.js +0 -18
  82. package/lib/node_modules/flatpickr/dist/l10n/index.js +0 -1427
  83. package/lib/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -200
  84. package/lib/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1116
  85. package/lib/node_modules/use-resize-observer/polyfilled.js +0 -119
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2018
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 PropTypes from 'prop-types';
8
+ import React from 'react';
9
+ export interface TableSelectRowProps {
10
+ /**
11
+ * Specify the aria label for the underlying input control
12
+ */
13
+ ariaLabel: string;
14
+ /**
15
+ * Specify whether this row is selected, or not
16
+ */
17
+ checked: boolean;
18
+ /**
19
+ * The CSS class names of the cell that wraps the underlying input control
20
+ */
21
+ className?: string;
22
+ /**
23
+ * Specify whether the control is disabled
24
+ */
25
+ disabled?: boolean;
26
+ /**
27
+ * Provide an `id` for the underlying input control
28
+ */
29
+ id: string;
30
+ /**
31
+ * Provide a `name` for the underlying input control
32
+ */
33
+ name: string;
34
+ /**
35
+ * Provide an optional hook that is called each time the input is updated
36
+ */
37
+ onChange?: (value: boolean, name: string, event: React.ChangeEvent<HTMLInputElement>) => void;
38
+ /**
39
+ * Provide a handler to listen to when a user initiates a selection request
40
+ */
41
+ onSelect: React.MouseEventHandler<HTMLInputElement>;
42
+ /**
43
+ * Specify whether the control should be a radio button or inline checkbox
44
+ */
45
+ radio?: boolean;
46
+ }
47
+ declare const TableSelectRow: {
48
+ ({ ariaLabel, checked, id, name, onSelect, onChange, disabled, radio, className, }: TableSelectRowProps): JSX.Element;
49
+ propTypes: {
50
+ /**
51
+ * Specify the aria label for the underlying input control
52
+ */
53
+ ariaLabel: PropTypes.Validator<string>;
54
+ /**
55
+ * Specify whether this row is selected, or not
56
+ */
57
+ checked: PropTypes.Validator<boolean>;
58
+ /**
59
+ * The CSS class names of the cell that wraps the underlying input control
60
+ */
61
+ className: PropTypes.Requireable<string>;
62
+ /**
63
+ * Specify whether the control is disabled
64
+ */
65
+ disabled: PropTypes.Requireable<boolean>;
66
+ /**
67
+ * Provide an `id` for the underlying input control
68
+ */
69
+ id: PropTypes.Validator<string>;
70
+ /**
71
+ * Provide a `name` for the underlying input control
72
+ */
73
+ name: PropTypes.Validator<string>;
74
+ /**
75
+ * Provide an optional hook that is called each time the input is updated
76
+ */
77
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
78
+ /**
79
+ * Provide a handler to listen to when a user initiates a selection request
80
+ */
81
+ onSelect: PropTypes.Validator<(...args: any[]) => any>;
82
+ /**
83
+ * Specify whether the control should be a radio button or inline checkbox
84
+ */
85
+ radio: PropTypes.Requireable<boolean>;
86
+ };
87
+ };
88
+ export default TableSelectRow;
@@ -24,8 +24,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
24
24
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
25
25
 
26
26
  var TableSelectRow = function TableSelectRow(_ref) {
27
- var _classNames;
28
-
29
27
  var ariaLabel = _ref.ariaLabel,
30
28
  checked = _ref.checked,
31
29
  id = _ref.id,
@@ -45,7 +43,7 @@ var TableSelectRow = function TableSelectRow(_ref) {
45
43
  disabled: disabled
46
44
  };
47
45
  var InlineInputComponent = radio ? RadioButton["default"] : InlineCheckbox["default"];
48
- var tableSelectRowClasses = cx__default["default"]("".concat(prefix, "--table-column-checkbox"), (_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, className, className), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--table-column-radio"), radio), _classNames));
46
+ var tableSelectRowClasses = cx__default["default"]("".concat(prefix, "--table-column-checkbox"), _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, className && _rollupPluginBabelHelpers.defineProperty({}, className, true)), {}, _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--table-column-radio"), radio)));
49
47
  return /*#__PURE__*/React__default["default"].createElement("td", {
50
48
  className: tableSelectRowClasses
51
49
  }, /*#__PURE__*/React__default["default"].createElement(InlineInputComponent, _rollupPluginBabelHelpers["extends"]({}, selectionInputProps, radio && {
@@ -63,7 +61,7 @@ TableSelectRow.propTypes = {
63
61
  ariaLabel: PropTypes__default["default"].string.isRequired,
64
62
 
65
63
  /**
66
- * Specify whether all items are selected, or not
64
+ * Specify whether this row is selected, or not
67
65
  */
68
66
  checked: PropTypes__default["default"].bool.isRequired,
69
67
 
@@ -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;
@@ -14,7 +14,7 @@ var PropTypes = require('prop-types');
14
14
  var React = require('react');
15
15
  var cx = require('classnames');
16
16
  var flatpickr = require('flatpickr');
17
- var index = require('../../node_modules/flatpickr/dist/l10n/index.js');
17
+ var l10n = require('flatpickr/dist/l10n/index');
18
18
  var DatePickerInput = require('../DatePickerInput/DatePickerInput.js');
19
19
  var appendToPlugin = require('./plugins/appendToPlugin.js');
20
20
  var fixEventsPlugin = require('./plugins/fixEventsPlugin.js');
@@ -34,16 +34,17 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
34
34
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
35
35
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
36
36
  var flatpickr__default = /*#__PURE__*/_interopDefaultLegacy(flatpickr);
37
+ var l10n__default = /*#__PURE__*/_interopDefaultLegacy(l10n);
37
38
 
38
39
  var _excluded = ["allowInput", "appendTo", "children", "className", "closeOnSelect", "dateFormat", "datePickerType", "disable", "enable", "inline", "invalid", "invalidText", "warn", "warnText", "light", "locale", "maxDate", "minDate", "onChange", "onClose", "onOpen", "readOnly", "short", "value"];
39
40
 
40
- index["default"].en.weekdays.shorthand.forEach(function (_day, index$1) {
41
- var currentDay = index["default"].en.weekdays.shorthand;
41
+ l10n__default["default"].en.weekdays.shorthand.forEach(function (_day, index) {
42
+ var currentDay = l10n__default["default"].en.weekdays.shorthand;
42
43
 
43
- if (currentDay[index$1] === 'Thu' || currentDay[index$1] === 'Th') {
44
- currentDay[index$1] = 'Th';
44
+ if (currentDay[index] === 'Thu' || currentDay[index] === 'Th') {
45
+ currentDay[index] = 'Th';
45
46
  } else {
46
- currentDay[index$1] = currentDay[index$1].charAt(0);
47
+ currentDay[index] = currentDay[index].charAt(0);
47
48
  }
48
49
  });
49
50
  var forEach = Array.prototype.forEach;
@@ -291,9 +292,9 @@ var DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Date
291
292
 
292
293
  if (_rollupPluginBabelHelpers["typeof"](locale) === 'object') {
293
294
  var location = locale.locale ? locale.locale : 'en';
294
- localeData = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, index["default"][location]), locale);
295
+ localeData = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, l10n__default["default"][location]), locale);
295
296
  } else {
296
- localeData = index["default"][locale];
297
+ localeData = l10n__default["default"][locale];
297
298
  }
298
299
 
299
300
  var start = startInputField.current;
@@ -69,7 +69,16 @@ var carbonFlatpickrFixEventsPlugin = (function (config) {
69
69
 
70
70
  if (selectedToDate && currentValueToDate && selectedToDate !== currentValueToDate) {
71
71
  // Update the calendar with the value of the `to` date input
72
- fp.setDate([inputFrom.value, inputTo && inputTo.value], false, fp.config.dateFormat);
72
+ fp.setDate([inputFrom.value, inputTo && inputTo.value], true, fp.config.dateFormat);
73
+ }
74
+ } // save end date in calendar inmediately after it's been written down
75
+
76
+
77
+ if (inputTo === target && fp.selectedDates.length === 1 && inputTo.value) {
78
+ var currentEndDate = new Date(inputTo.value);
79
+
80
+ if (currentEndDate.toString() !== 'Invalid Date') {
81
+ fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
73
82
  }
74
83
  }
75
84
  };
@@ -9,7 +9,11 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
- var rangePlugin = require('../../../node_modules/flatpickr/dist/plugins/rangePlugin.js');
12
+ var rangePlugin = require('flatpickr/dist/plugins/rangePlugin');
13
+
14
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
+
16
+ var rangePlugin__default = /*#__PURE__*/_interopDefaultLegacy(rangePlugin);
13
17
 
14
18
  /**
15
19
  * @param {object} config Plugin configuration.
@@ -20,7 +24,7 @@ var rangePlugin = require('../../../node_modules/flatpickr/dist/plugins/rangePlu
20
24
  */
21
25
 
22
26
  var carbonFlatpickrRangePlugin = (function (config) {
23
- var factory = rangePlugin["default"](Object.assign({
27
+ var factory = rangePlugin__default["default"](Object.assign({
24
28
  position: 'left'
25
29
  }, config));
26
30
  return function (fp) {
@@ -17,6 +17,7 @@ var types = require('../../prop-types/types.js');
17
17
  var uniqueId = require('../../tools/uniqueId.js');
18
18
  var usePrefix = require('../../internal/usePrefix.js');
19
19
  var FeatureFlags = require('@carbon/feature-flags');
20
+ var deprecate = require('../../prop-types/deprecate.js');
20
21
  var match = require('../../internal/keyboard/match.js');
21
22
  var keys = require('../../internal/keyboard/keys.js');
22
23
 
@@ -45,7 +46,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
45
46
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
46
47
  var FeatureFlags__namespace = /*#__PURE__*/_interopNamespace(FeatureFlags);
47
48
 
48
- var _excluded = ["accept", "buttonKind", "className", "disabled", "disableLabelChanges", "id", "labelText", "multiple", "onChange", "role", "name", "size", "tabIndex", "innerRef"];
49
+ var _excluded = ["accept", "buttonKind", "className", "disabled", "disableLabelChanges", "id", "labelText", "multiple", "onChange", "name", "size", "innerRef"];
49
50
 
50
51
  function noop() {}
51
52
 
@@ -67,13 +68,9 @@ function FileUploaderButton(_ref) {
67
68
  multiple = _ref$multiple === void 0 ? false : _ref$multiple,
68
69
  _ref$onChange = _ref.onChange,
69
70
  onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
70
- _ref$role = _ref.role,
71
- role = _ref$role === void 0 ? 'button' : _ref$role,
72
71
  name = _ref.name,
73
72
  _ref$size = _ref.size,
74
73
  size = _ref$size === void 0 ? 'md' : _ref$size,
75
- _ref$tabIndex = _ref.tabIndex,
76
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
77
74
  innerRef = _ref.innerRef,
78
75
  other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
79
76
 
@@ -102,6 +99,7 @@ function FileUploaderButton(_ref) {
102
99
 
103
100
  function onClick(event) {
104
101
  event.target.value = null;
102
+ inputNode.current.click();
105
103
  }
106
104
 
107
105
  function onKeyDown(event) {
@@ -125,16 +123,17 @@ function FileUploaderButton(_ref) {
125
123
  onChange(event);
126
124
  }
127
125
 
128
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
129
- ref: innerRef,
130
- tabIndex: disabled ? -1 : tabIndex || 0,
126
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({
127
+ type: "button",
128
+ disabled: disabled,
131
129
  className: classes,
132
- onKeyDown: onKeyDown,
130
+ onClick: onClick,
131
+ onKeyDown: onKeyDown
132
+ }, other), labelText), /*#__PURE__*/React__default["default"].createElement("label", {
133
+ className: "".concat(prefix, "--visually-hidden"),
134
+ ref: innerRef,
133
135
  htmlFor: inputId
134
- }, other), /*#__PURE__*/React__default["default"].createElement("span", {
135
- role: role,
136
- "aria-disabled": disabled
137
- }, labelText)), /*#__PURE__*/React__default["default"].createElement("input", {
136
+ }, /*#__PURE__*/React__default["default"].createElement("span", null, labelText)), /*#__PURE__*/React__default["default"].createElement("input", {
138
137
  className: "".concat(prefix, "--visually-hidden"),
139
138
  ref: inputNode,
140
139
  id: inputId,
@@ -144,8 +143,7 @@ function FileUploaderButton(_ref) {
144
143
  multiple: multiple,
145
144
  accept: accept,
146
145
  name: name,
147
- onChange: handleOnChange,
148
- onClick: onClick
146
+ onChange: handleOnChange
149
147
  }));
150
148
  }
151
149
 
@@ -223,7 +221,7 @@ FileUploaderButton.propTypes = {
223
221
  /**
224
222
  * Provide a custom tabIndex value for the `<FileUploaderButton>`
225
223
  */
226
- tabIndex: PropTypes__default["default"].number
224
+ tabIndex: deprecate["default"](PropTypes__default["default"].number, 'The `tabIndex` prop for `FileUploaderButton` has ' + 'been deprecated since it now renders a button element by default.')
227
225
  };
228
226
 
229
227
  exports["default"] = FileUploaderButton;
@@ -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;