@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.
- package/es/components/CodeSnippet/CodeSnippet.js +2 -2
- package/es/components/ComboBox/ComboBox.d.ts +151 -0
- package/es/components/ComboBox/ComboBox.js +28 -21
- package/es/components/ComposedModal/ComposedModal.js +2 -2
- package/es/components/DataTable/TableSelectRow.d.ts +88 -0
- package/es/components/DataTable/TableSelectRow.js +3 -5
- package/es/components/DataTable/tools/sorting.js +3 -0
- package/es/components/DatePicker/DatePicker.js +1 -1
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
- package/es/components/DatePicker/plugins/rangePlugin.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +14 -16
- package/es/components/Grid/CSSGrid.d.ts +9 -0
- package/es/components/Grid/CSSGrid.js +8 -5
- package/es/components/Grid/Column.d.ts +73 -0
- package/es/components/Grid/Column.js +40 -34
- package/es/components/Grid/ColumnHang.d.ts +24 -0
- package/es/components/Grid/ColumnHang.js +7 -4
- package/es/components/Grid/FlexGrid.d.ts +9 -0
- package/es/components/Grid/FlexGrid.js +6 -3
- package/es/components/Grid/Grid.d.ts +9 -0
- package/es/components/Grid/Grid.js +6 -5
- package/es/components/Grid/GridContext.d.ts +38 -0
- package/es/components/Grid/GridContext.js +6 -6
- package/es/components/Grid/GridTypes.d.ts +37 -0
- package/es/components/Grid/Row.d.ts +34 -0
- package/es/components/Grid/Row.js +4 -2
- package/es/components/Grid/index.d.ts +11 -0
- package/es/components/NumberInput/NumberInput.d.ts +132 -0
- package/es/components/NumberInput/NumberInput.js +9 -7
- package/es/components/TextArea/TextArea.js +1 -0
- package/es/components/Toggle/Toggle.js +54 -33
- package/es/components/Toggletip/index.js +26 -1
- package/es/index.js +5 -5
- package/es/internal/useNormalizedInputProps.js +3 -3
- package/lib/components/CodeSnippet/CodeSnippet.js +4 -3
- package/lib/components/ComboBox/ComboBox.d.ts +151 -0
- package/lib/components/ComboBox/ComboBox.js +28 -21
- package/lib/components/ComposedModal/ComposedModal.js +2 -2
- package/lib/components/DataTable/TableSelectRow.d.ts +88 -0
- package/lib/components/DataTable/TableSelectRow.js +2 -4
- package/lib/components/DataTable/tools/sorting.js +3 -0
- package/lib/components/DatePicker/DatePicker.js +9 -8
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
- package/lib/components/DatePicker/plugins/rangePlugin.js +6 -2
- package/lib/components/FileUploader/FileUploaderButton.js +14 -16
- package/lib/components/Grid/CSSGrid.d.ts +9 -0
- package/lib/components/Grid/CSSGrid.js +8 -5
- package/lib/components/Grid/Column.d.ts +73 -0
- package/lib/components/Grid/Column.js +36 -30
- package/lib/components/Grid/ColumnHang.d.ts +24 -0
- package/lib/components/Grid/ColumnHang.js +7 -4
- package/lib/components/Grid/FlexGrid.d.ts +9 -0
- package/lib/components/Grid/FlexGrid.js +6 -3
- package/lib/components/Grid/Grid.d.ts +9 -0
- package/lib/components/Grid/Grid.js +2 -1
- package/lib/components/Grid/GridContext.d.ts +38 -0
- package/lib/components/Grid/GridContext.js +6 -6
- package/lib/components/Grid/GridTypes.d.ts +37 -0
- package/lib/components/Grid/Row.d.ts +34 -0
- package/lib/components/Grid/Row.js +4 -2
- package/lib/components/Grid/index.d.ts +11 -0
- package/lib/components/NumberInput/NumberInput.d.ts +132 -0
- package/lib/components/NumberInput/NumberInput.js +9 -7
- package/lib/components/TextArea/TextArea.js +1 -0
- package/lib/components/Toggle/Toggle.js +53 -32
- package/lib/components/Toggletip/index.js +26 -1
- package/lib/index.js +10 -10
- package/lib/internal/useNormalizedInputProps.js +3 -3
- package/package.json +3 -5
- package/es/_virtual/ResizeObserver.es.js +0 -13
- package/es/_virtual/_commonjsHelpers.js +0 -42
- package/es/_virtual/index.js +0 -14
- package/es/_virtual/rangePlugin.js +0 -14
- package/es/node_modules/flatpickr/dist/l10n/index.js +0 -1423
- package/es/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -196
- package/es/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1112
- package/es/node_modules/use-resize-observer/polyfilled.js +0 -111
- package/lib/_virtual/ResizeObserver.es.js +0 -17
- package/lib/_virtual/_commonjsHelpers.js +0 -48
- package/lib/_virtual/index.js +0 -18
- package/lib/_virtual/rangePlugin.js +0 -18
- package/lib/node_modules/flatpickr/dist/l10n/index.js +0 -1427
- package/lib/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -200
- package/lib/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1116
- package/lib/node_modules/use-resize-observer/polyfilled.js +0 -119
|
@@ -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
|
-
|
|
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
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
315
|
-
|
|
318
|
+
if (_typeof(breakpoint) === 'object') {
|
|
319
|
+
var span = breakpoint.span,
|
|
320
|
+
offset = breakpoint.offset;
|
|
316
321
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
322
|
+
if (typeof span === 'number') {
|
|
323
|
+
classNames.push("".concat(prefix, "--col-").concat(name, "-").concat(span));
|
|
324
|
+
}
|
|
320
325
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
326
|
+
if (span === true) {
|
|
327
|
+
classNames.push("".concat(prefix, "--col-").concat(name));
|
|
328
|
+
}
|
|
324
329
|
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
18
|
+
return /*#__PURE__*/React__default.createElement(CSSGridComponent, props);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
return /*#__PURE__*/React__default.createElement(
|
|
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(
|
|
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
|
-
|
|
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';
|
|
@@ -0,0 +1,132 @@
|
|
|
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 React, { ReactNode } from 'react';
|
|
8
|
+
export declare const translationIds: {
|
|
9
|
+
'increment.number': string;
|
|
10
|
+
'decrement.number': string;
|
|
11
|
+
};
|
|
12
|
+
type ExcludedAttributes = 'defaultValue' | 'id' | 'min' | 'max' | 'onChange' | 'onClick' | 'size' | 'step' | 'value';
|
|
13
|
+
export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
14
|
+
/**
|
|
15
|
+
* `true` to allow empty string.
|
|
16
|
+
*/
|
|
17
|
+
allowEmpty?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Specify an optional className to be applied to the wrapper node
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional starting value for uncontrolled state
|
|
24
|
+
*/
|
|
25
|
+
defaultValue?: number | string;
|
|
26
|
+
/**
|
|
27
|
+
* Specify if the wheel functionality for the input should be disabled, or not
|
|
28
|
+
*/
|
|
29
|
+
disableWheel?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Specify if the control should be disabled, or not
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Provide text that is used alongside the control label for additional help
|
|
36
|
+
*/
|
|
37
|
+
helperText?: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Specify whether you want the underlying label to be visually hidden
|
|
40
|
+
*/
|
|
41
|
+
hideLabel?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Specify whether you want the steppers to be hidden
|
|
44
|
+
*/
|
|
45
|
+
hideSteppers?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Provide a description for up/down icons that can be read by screen readers
|
|
48
|
+
*/
|
|
49
|
+
iconDescription?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Specify a custom `id` for the input
|
|
52
|
+
*/
|
|
53
|
+
id: string;
|
|
54
|
+
/**
|
|
55
|
+
* Specify if the currently value is invalid.
|
|
56
|
+
*/
|
|
57
|
+
invalid?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Message which is displayed if the value is invalid.
|
|
60
|
+
*/
|
|
61
|
+
invalidText?: ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* Generic `label` that will be used as the textual representation of what
|
|
64
|
+
* this field is for
|
|
65
|
+
*/
|
|
66
|
+
label?: ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* `true` to use the light version.
|
|
69
|
+
*
|
|
70
|
+
* @deprecated The `light` prop for `NumberInput` is no longer needed and has
|
|
71
|
+
* been deprecated in v11 in favor of the new `Layer` component. It will be moved in the next major release.
|
|
72
|
+
*/
|
|
73
|
+
light?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The maximum value.
|
|
76
|
+
*/
|
|
77
|
+
max?: number;
|
|
78
|
+
/**
|
|
79
|
+
* The minimum value.
|
|
80
|
+
*/
|
|
81
|
+
min?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Provide an optional handler that is called when the internal state of
|
|
84
|
+
* NumberInput changes. This handler is called with event and state info.
|
|
85
|
+
* `(event, { value, direction }) => void`
|
|
86
|
+
*/
|
|
87
|
+
onChange?: (event: React.MouseEvent<HTMLButtonElement>, state: {
|
|
88
|
+
value: number | string;
|
|
89
|
+
direction: string;
|
|
90
|
+
}) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Provide an optional function to be called when the up/down button is clicked
|
|
93
|
+
*/
|
|
94
|
+
onClick?: (event: React.MouseEvent<HTMLElement>, state?: {
|
|
95
|
+
value: number | string;
|
|
96
|
+
direction: string;
|
|
97
|
+
}) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Provide an optional function to be called when a key is pressed in the number input
|
|
100
|
+
*/
|
|
101
|
+
onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
102
|
+
/**
|
|
103
|
+
* Specify if the component should be read-only
|
|
104
|
+
*/
|
|
105
|
+
readOnly?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Specify the size of the Number Input.
|
|
108
|
+
*/
|
|
109
|
+
size?: 'sm' | 'md' | 'lg';
|
|
110
|
+
/**
|
|
111
|
+
* Specify how much the values should increase/decrease upon clicking on up/down button
|
|
112
|
+
*/
|
|
113
|
+
step?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Provide custom text for the component for each translation id
|
|
116
|
+
*/
|
|
117
|
+
translateWithId?: (id: string) => string;
|
|
118
|
+
/**
|
|
119
|
+
* Specify the value of the input
|
|
120
|
+
*/
|
|
121
|
+
value?: number | string;
|
|
122
|
+
/**
|
|
123
|
+
* Specify whether the control is currently in warning state
|
|
124
|
+
*/
|
|
125
|
+
warn?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Provide the text that is displayed when the control is in warning state
|
|
128
|
+
*/
|
|
129
|
+
warnText?: ReactNode;
|
|
130
|
+
}
|
|
131
|
+
declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<unknown>>;
|
|
132
|
+
export { NumberInput };
|