@carbon/ibm-products 1.22.0 → 1.24.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/css/components/Datagrid/styles/datagrid.css +87 -11
- package/css/components/Datagrid/styles/datagrid.css.map +1 -1
- package/css/components/Datagrid/styles/index.css +94 -11
- package/css/components/Datagrid/styles/index.css.map +1 -1
- package/css/components/Datagrid/styles/useExpandedRow.css +9 -0
- package/css/components/Datagrid/styles/useExpandedRow.css.map +1 -0
- package/css/index-full-carbon.css +276 -181
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -8
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +37 -41
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -7
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +271 -54
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -7
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +274 -177
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -8
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +56 -423
- package/es/components/AddSelect/AddSelectBody.js +345 -0
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +11 -31
- package/es/components/AddSelect/AddSelectColumn.js +95 -42
- package/es/components/AddSelect/AddSelectFilter.js +2 -3
- package/es/components/AddSelect/AddSelectList.js +11 -62
- package/es/components/AddSelect/AddSelectMetaPanel.js +9 -8
- package/es/components/AddSelect/AddSelectSidebar.js +24 -39
- package/es/components/AddSelect/AddSelectSort.js +4 -2
- package/es/components/AddSelect/add-select-utils.js +85 -59
- package/es/components/AddSelect/hooks/useParentSelect.js +16 -0
- package/es/components/AddSelect/hooks/usePath.js +66 -0
- package/es/components/Card/Card.js +1 -1
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +1 -5
- package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +1 -5
- package/es/components/Datagrid/Datagrid/Datagrid.js +17 -12
- package/es/components/Datagrid/Datagrid/DatagridRow.js +4 -2
- package/es/components/Datagrid/useExpandedRow.js +1 -0
- package/es/components/Datagrid/useOnRowClick.js +10 -3
- package/es/components/EditFullPage/EditFullPage.js +79 -0
- package/es/components/EditFullPage/index.js +7 -0
- package/es/components/EditTearsheet/EditTearsheet.js +205 -0
- package/es/components/EditTearsheet/EditTearsheetForm.js +103 -0
- package/es/components/EditTearsheet/index.js +8 -0
- package/es/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +230 -0
- package/es/components/EditTearsheetNarrow/EditTearsheetNarrow.js +79 -0
- package/es/components/EditTearsheetNarrow/index.js +7 -0
- package/es/components/PageHeader/PageHeaderUtils.js +5 -0
- package/es/components/TagSet/TagSet.js +15 -5
- package/es/components/WebTerminal/WebTerminal.js +5 -3
- package/es/components/index.js +4 -1
- package/es/global/js/package-settings.js +4 -1
- package/lib/components/AddSelect/AddSelect.js +53 -431
- package/lib/components/AddSelect/AddSelectBody.js +380 -0
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +11 -30
- package/lib/components/AddSelect/AddSelectColumn.js +93 -40
- package/lib/components/AddSelect/AddSelectFilter.js +2 -3
- package/lib/components/AddSelect/AddSelectList.js +12 -61
- package/lib/components/AddSelect/AddSelectMetaPanel.js +9 -8
- package/lib/components/AddSelect/AddSelectSidebar.js +22 -38
- package/lib/components/AddSelect/AddSelectSort.js +4 -2
- package/lib/components/AddSelect/add-select-utils.js +88 -64
- package/lib/components/AddSelect/hooks/useParentSelect.js +27 -0
- package/lib/components/AddSelect/hooks/usePath.js +75 -0
- package/lib/components/Card/Card.js +1 -1
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +1 -5
- package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +1 -5
- package/lib/components/Datagrid/Datagrid/Datagrid.js +17 -12
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +3 -1
- package/lib/components/Datagrid/useExpandedRow.js +1 -0
- package/lib/components/Datagrid/useOnRowClick.js +10 -3
- package/lib/components/EditFullPage/EditFullPage.js +85 -0
- package/lib/components/EditFullPage/index.js +13 -0
- package/lib/components/EditTearsheet/EditTearsheet.js +229 -0
- package/lib/components/EditTearsheet/EditTearsheetForm.js +122 -0
- package/lib/components/EditTearsheet/index.js +21 -0
- package/lib/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +254 -0
- package/lib/components/EditTearsheetNarrow/EditTearsheetNarrow.js +85 -0
- package/lib/components/EditTearsheetNarrow/index.js +13 -0
- package/lib/components/PageHeader/PageHeaderUtils.js +5 -0
- package/lib/components/TagSet/TagSet.js +15 -5
- package/lib/components/WebTerminal/WebTerminal.js +5 -2
- package/lib/components/index.js +25 -1
- package/lib/global/js/package-settings.js +4 -1
- package/package.json +16 -16
- package/scss/components/Cascade/_cascade.scss +2 -1
- package/scss/components/CreateInfluencer/_create-influencer.scss +2 -2
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -1
- package/scss/components/Datagrid/_datagrid.scss +0 -1
- package/scss/components/Datagrid/_storybook-styles.scss +57 -0
- package/scss/components/Datagrid/styles/datagrid.scss +97 -12
- package/scss/components/Datagrid/styles/index.scss +1 -0
- package/scss/components/Datagrid/styles/useExpandedRow.scss +7 -0
- package/scss/components/EditFullPage/_edit-full-page.scss +34 -0
- package/scss/components/EditFullPage/_index.scss +8 -0
- package/scss/components/EditFullPage/_storybook-styles.scss +10 -0
- package/scss/components/EditTearsheet/_edit-tearsheet.scss +132 -0
- package/scss/components/EditTearsheet/_index.scss +8 -0
- package/scss/components/EditTearsheet/_storybook-styles.scss +55 -0
- package/scss/components/EditTearsheetNarrow/_edit-tearsheet-narrow.scss +34 -0
- package/scss/components/EditTearsheetNarrow/_index.scss +8 -0
- package/scss/components/EditTearsheetNarrow/_storybook-styles.scss +10 -0
- package/scss/components/InlineEdit/_inline-edit.scss +10 -21
- package/scss/components/NotificationsPanel/_notifications-panel.scss +1 -0
- package/scss/components/OptionsTile/_options-tile.scss +1 -0
- package/scss/components/PageHeader/_page-header.scss +11 -4
- package/scss/components/SidePanel/_side-panel.scss +1 -2
- package/scss/components/StatusIcon/_status-icon.scss +1 -1
- package/scss/components/TagSet/_tag-set.scss +4 -0
- package/scss/components/Tearsheet/_tearsheet.scss +2 -2
- package/scss/components/WebTerminal/_web-terminal.scss +2 -1
- package/scss/components/_index.scss +3 -0
|
@@ -46,28 +46,33 @@ export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
46
46
|
_datagridState$vertic = datagridState.verticalAlign,
|
|
47
47
|
verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
|
|
48
48
|
variableRowHeight = datagridState.variableRowHeight,
|
|
49
|
-
className = datagridState.className
|
|
49
|
+
className = datagridState.className,
|
|
50
|
+
gridTitle = datagridState.gridTitle,
|
|
51
|
+
gridDescription = datagridState.gridDescription,
|
|
52
|
+
useDenseHeader = datagridState.useDenseHeader;
|
|
50
53
|
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
|
51
54
|
var dataGrid = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContainer, {
|
|
52
|
-
className: cx("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '')
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
className: cx("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '', DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', useDenseHeader ? "".concat(blockClass, "__dense-header") : ''),
|
|
56
|
+
title: gridTitle,
|
|
57
|
+
description: gridDescription
|
|
58
|
+
}, /*#__PURE__*/React.createElement(DatagridToolbar, datagridState), /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: "".concat(blockClass, "__table-container")
|
|
60
|
+
}, leftPanel && leftPanel.isOpen && /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: "".concat(blockClass, "__datagridLeftPanel")
|
|
62
|
+
}, leftPanel.panelContent), /*#__PURE__*/React.createElement(Table, _extends({}, getTableProps(), {
|
|
63
|
+
className: cx(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), _defineProperty({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className)
|
|
55
64
|
}), /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
|
|
56
65
|
rows: rows
|
|
57
|
-
})))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/React.createElement(CustomizeColumnsModal, {
|
|
66
|
+
}))))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/React.createElement(CustomizeColumnsModal, {
|
|
58
67
|
instance: datagridState
|
|
59
68
|
}));
|
|
60
69
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
61
70
|
id: tableId,
|
|
62
71
|
ref: ref,
|
|
63
72
|
className: cx(className, blockClass, withVirtualScroll ? "".concat(blockClass, "__datagridWrap") : "".concat(blockClass, "__datagridWrap-simple"), !isFetching && rows.length === 0 ? "".concat(blockClass, "__empty-state") : '')
|
|
64
|
-
}, getDevtoolsProps(componentName)),
|
|
65
|
-
className: "".concat(blockClass, "
|
|
66
|
-
}, leftPanel
|
|
67
|
-
className: "".concat(blockClass, "__datagridLeftPanel")
|
|
68
|
-
}, leftPanel.panelContent), /*#__PURE__*/React.createElement("div", {
|
|
69
|
-
className: "".concat(blockClass, "__datagridWithPanel")
|
|
70
|
-
}, dataGrid)), leftPanel === undefined && dataGrid);
|
|
73
|
+
}, getDevtoolsProps(componentName)), leftPanel && /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
className: "".concat(blockClass, "__datagridWithPanel ").concat(blockClass, "__displayFlex ").concat(blockClass, "__leftPanel-position")
|
|
75
|
+
}, dataGrid), leftPanel === undefined && dataGrid);
|
|
71
76
|
}); // Return a placeholder if not released and not enabled by feature flag
|
|
72
77
|
|
|
73
78
|
Datagrid = pkg.checkComponentEnabled(Datagrid, componentName); // The display name of the component, used by React. Note that displayName
|
|
@@ -15,15 +15,17 @@ import React from 'react';
|
|
|
15
15
|
import { DataTable, SkeletonText } from 'carbon-components-react';
|
|
16
16
|
import { selectionColumnId } from '../common-column-ids';
|
|
17
17
|
import cx from 'classnames';
|
|
18
|
-
import { pkg } from '../../../settings';
|
|
18
|
+
import { pkg, carbon } from '../../../settings';
|
|
19
19
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
20
20
|
var TableRow = DataTable.TableRow,
|
|
21
21
|
TableCell = DataTable.TableCell; // eslint-disable-next-line react/prop-types
|
|
22
22
|
|
|
23
23
|
var DatagridRow = function DatagridRow(datagridState) {
|
|
24
|
+
var _cx;
|
|
25
|
+
|
|
24
26
|
var row = datagridState.row;
|
|
25
27
|
return /*#__PURE__*/React.createElement(TableRow, _extends({
|
|
26
|
-
className: cx("".concat(blockClass, "__carbon-row"),
|
|
28
|
+
className: cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), _cx))
|
|
27
29
|
}, row.getRowProps(), {
|
|
28
30
|
key: row.id,
|
|
29
31
|
onMouseEnter: function onMouseEnter(event) {
|
|
@@ -37,6 +37,7 @@ var useExpandedRow = function useExpandedRow(hooks) {
|
|
|
37
37
|
return _objectSpread(_objectSpread({}, row), {}, {
|
|
38
38
|
canExpand: row.original && !row.original.notExpandable,
|
|
39
39
|
expandedContentHeight: expandedRowsHeight[row.index] || expandedContentHeight,
|
|
40
|
+
// RowRenderer: DatagridExpandedRow(row.RowRenderer, expansionRenderer),
|
|
40
41
|
RowRenderer: DatagridExpandedRow(row.RowRenderer, ExpandedRowContentComponent)
|
|
41
42
|
});
|
|
42
43
|
});
|
|
@@ -6,16 +6,23 @@
|
|
|
6
6
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
7
7
|
*/
|
|
8
8
|
var useOnRowClick = function useOnRowClick(hooks) {
|
|
9
|
-
var useInstance = function useInstance(
|
|
10
|
-
var onRowClick =
|
|
9
|
+
var useInstance = function useInstance(rowInstance) {
|
|
10
|
+
var onRowClick = rowInstance.onRowClick;
|
|
11
11
|
|
|
12
12
|
var getRowProps = function getRowProps(props, datagridState) {
|
|
13
13
|
var isFetching = datagridState.isFetching,
|
|
14
|
-
row = datagridState.row
|
|
14
|
+
row = datagridState.row,
|
|
15
|
+
instance = datagridState.instance;
|
|
16
|
+
var id = row.id,
|
|
17
|
+
toggleRowSelected = row.toggleRowSelected;
|
|
15
18
|
|
|
16
19
|
var onClick = function onClick() {
|
|
17
20
|
if (!isFetching && onRowClick) {
|
|
18
21
|
onRowClick(row);
|
|
22
|
+
instance.selectedFlatRows && instance.selectedFlatRows.map(function (toggleRow) {
|
|
23
|
+
return toggleRow.toggleRowSelected(false);
|
|
24
|
+
});
|
|
25
|
+
toggleRowSelected(id, true);
|
|
19
26
|
}
|
|
20
27
|
};
|
|
21
28
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["children", "className"];
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright IBM Corp. 2022, 2022
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/
|
|
11
|
+
// Import portions of React that are needed.
|
|
12
|
+
import React from 'react'; // Other standard imports.
|
|
13
|
+
|
|
14
|
+
import PropTypes from 'prop-types';
|
|
15
|
+
import cx from 'classnames';
|
|
16
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
|
17
|
+
import { pkg
|
|
18
|
+
/*, carbon */
|
|
19
|
+
} from '../../settings'; // Carbon and package components we use.
|
|
20
|
+
|
|
21
|
+
/* TODO: @import(s) of carbon components and other package components. */
|
|
22
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
|
23
|
+
|
|
24
|
+
var blockClass = "".concat(pkg.prefix, "--edit-full-page");
|
|
25
|
+
var componentName = 'EditFullPage'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
|
26
|
+
// Default values can be included here and then assigned to the prop params,
|
|
27
|
+
// e.g. prop = defaults.prop,
|
|
28
|
+
// This gathers default values together neatly and ensures non-primitive
|
|
29
|
+
// values are initialized early to avoid react making unnecessary re-renders.
|
|
30
|
+
// Note that default values are not required for props that are 'required',
|
|
31
|
+
// nor for props where the component can apply undefined values reasonably.
|
|
32
|
+
// Default values should be provided when the component needs to make a choice
|
|
33
|
+
// or assumption when a prop is not supplied.
|
|
34
|
+
// Default values for props
|
|
35
|
+
// const defaults = {
|
|
36
|
+
// /* TODO: add defaults for relevant props if needed */
|
|
37
|
+
// };
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* TODO: A description of the component.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
export var EditFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
44
|
+
var children = _ref.children,
|
|
45
|
+
className = _ref.className,
|
|
46
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
47
|
+
|
|
48
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
49
|
+
className: cx(blockClass, // Apply the block class to the main HTML element
|
|
50
|
+
className, // Apply any supplied class names to the main HTML element.
|
|
51
|
+
// example: `${blockClass}__template-string-class-${kind}-n-${size}`,
|
|
52
|
+
{// switched classes dependant on props or state
|
|
53
|
+
// example: [`${blockClass}__here-if-small`]: size === 'sm',
|
|
54
|
+
}),
|
|
55
|
+
ref: ref,
|
|
56
|
+
role: "main"
|
|
57
|
+
}, getDevtoolsProps(componentName)), children);
|
|
58
|
+
}); // Return a placeholder if not released and not enabled by feature flag
|
|
59
|
+
|
|
60
|
+
EditFullPage = pkg.checkComponentEnabled(EditFullPage, componentName); // The display name of the component, used by React. Note that displayName
|
|
61
|
+
// is used in preference to relying on function.name.
|
|
62
|
+
|
|
63
|
+
EditFullPage.displayName = componentName; // The types and DocGen commentary for the component props,
|
|
64
|
+
// in alphabetical order (for consistency).
|
|
65
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
|
66
|
+
|
|
67
|
+
EditFullPage.propTypes = {
|
|
68
|
+
/**
|
|
69
|
+
* Provide the contents of the EditFullPage.
|
|
70
|
+
*/
|
|
71
|
+
children: PropTypes.node.isRequired,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Provide an optional class to be applied to the containing node.
|
|
75
|
+
*/
|
|
76
|
+
className: PropTypes.string
|
|
77
|
+
/* TODO: add types and DocGen for all props. */
|
|
78
|
+
|
|
79
|
+
};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["cancelButtonText", "children", "className", "description", "influencerWidth", "label", "onClose", "open", "submitButtonText", "title", "verticalPosition", "onHandleModalClick"];
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright IBM Corp. 2022, 2022
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
import React, { forwardRef, useState, useRef, createContext } from 'react';
|
|
13
|
+
import PropTypes from 'prop-types';
|
|
14
|
+
import cx from 'classnames';
|
|
15
|
+
import { Grid, Form, SideNav, SideNavItems, SideNavMenuItem } from 'carbon-components-react';
|
|
16
|
+
import { pkg } from '../../settings';
|
|
17
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
|
18
|
+
import { TearsheetShell } from '../Tearsheet/TearsheetShell';
|
|
19
|
+
var componentName = 'EditTearsheet';
|
|
20
|
+
var blockClass = "".concat(pkg.prefix, "--tearsheet-edit"); // This is a general context for the forms container
|
|
21
|
+
// containing information about the state of the container
|
|
22
|
+
// and providing some callback methods for forms to use
|
|
23
|
+
|
|
24
|
+
export var FormContext = /*#__PURE__*/createContext(null); // This is a context supplied separately to each form in the container
|
|
25
|
+
// to let it know what number it is in the sequence of forms
|
|
26
|
+
|
|
27
|
+
export var FormNumberContext = /*#__PURE__*/createContext(0); // Default values for props
|
|
28
|
+
|
|
29
|
+
var defaults = {
|
|
30
|
+
verticalPosition: 'normal',
|
|
31
|
+
influencerWidth: 'narrow'
|
|
32
|
+
};
|
|
33
|
+
export var EditTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
34
|
+
var cancelButtonText = _ref.cancelButtonText,
|
|
35
|
+
children = _ref.children,
|
|
36
|
+
className = _ref.className,
|
|
37
|
+
description = _ref.description,
|
|
38
|
+
_ref$influencerWidth = _ref.influencerWidth,
|
|
39
|
+
influencerWidth = _ref$influencerWidth === void 0 ? defaults.influencerWidth : _ref$influencerWidth,
|
|
40
|
+
label = _ref.label,
|
|
41
|
+
onClose = _ref.onClose,
|
|
42
|
+
open = _ref.open,
|
|
43
|
+
submitButtonText = _ref.submitButtonText,
|
|
44
|
+
title = _ref.title,
|
|
45
|
+
_ref$verticalPosition = _ref.verticalPosition,
|
|
46
|
+
verticalPosition = _ref$verticalPosition === void 0 ? defaults.verticalPosition : _ref$verticalPosition,
|
|
47
|
+
onHandleModalClick = _ref.onHandleModalClick,
|
|
48
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
49
|
+
|
|
50
|
+
var _useState = useState(0),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
currentForm = _useState2[0],
|
|
53
|
+
setCurrentForm = _useState2[1];
|
|
54
|
+
|
|
55
|
+
var contentRef = useRef();
|
|
56
|
+
|
|
57
|
+
var handleCurrentForm = function handleCurrentForm(form) {
|
|
58
|
+
setCurrentForm(form);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var sideNavItems = [{
|
|
62
|
+
label: 'Topic Name'
|
|
63
|
+
}, {
|
|
64
|
+
label: 'Location'
|
|
65
|
+
}, {
|
|
66
|
+
label: 'Partitions'
|
|
67
|
+
}, {
|
|
68
|
+
label: 'Message retention'
|
|
69
|
+
}];
|
|
70
|
+
var influencer = /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: "tearsheet-stories__dummy-influencer-block"
|
|
72
|
+
}, /*#__PURE__*/React.createElement(SideNav, {
|
|
73
|
+
"aria-label": "Side navigation",
|
|
74
|
+
className: "".concat(blockClass, "__side-nav"),
|
|
75
|
+
expanded: true,
|
|
76
|
+
isFixedNav: false
|
|
77
|
+
}, /*#__PURE__*/React.createElement(SideNavItems, null, sideNavItems.map(function (item, index) {
|
|
78
|
+
return /*#__PURE__*/React.createElement(SideNavMenuItem, {
|
|
79
|
+
key: index,
|
|
80
|
+
onClick: function onClick() {
|
|
81
|
+
return handleCurrentForm(index);
|
|
82
|
+
},
|
|
83
|
+
isActive: currentForm === index
|
|
84
|
+
}, item.label);
|
|
85
|
+
}))));
|
|
86
|
+
return /*#__PURE__*/React.createElement(TearsheetShell, _extends({}, rest, getDevtoolsProps(componentName), {
|
|
87
|
+
actions: [{
|
|
88
|
+
label: submitButtonText,
|
|
89
|
+
onClick: onHandleModalClick,
|
|
90
|
+
kind: 'primary'
|
|
91
|
+
}, {
|
|
92
|
+
label: cancelButtonText,
|
|
93
|
+
onClick: onHandleModalClick,
|
|
94
|
+
kind: 'secondary'
|
|
95
|
+
}],
|
|
96
|
+
className: cx(blockClass, className),
|
|
97
|
+
description: description,
|
|
98
|
+
hasCloseIcon: false,
|
|
99
|
+
influencer: influencer,
|
|
100
|
+
influencerPosition: "left",
|
|
101
|
+
influencerWidth: influencerWidth,
|
|
102
|
+
label: label,
|
|
103
|
+
onClose: onClose,
|
|
104
|
+
open: open,
|
|
105
|
+
size: "wide",
|
|
106
|
+
title: title,
|
|
107
|
+
verticalPosition: verticalPosition,
|
|
108
|
+
ref: ref
|
|
109
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
className: "".concat(blockClass, "__content"),
|
|
111
|
+
ref: contentRef,
|
|
112
|
+
role: "main"
|
|
113
|
+
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
114
|
+
value: {
|
|
115
|
+
currentForm: currentForm
|
|
116
|
+
}
|
|
117
|
+
}, React.Children.map(children, function (child, index) {
|
|
118
|
+
return /*#__PURE__*/React.createElement(FormNumberContext.Provider, {
|
|
119
|
+
value: index
|
|
120
|
+
}, child);
|
|
121
|
+
}))))));
|
|
122
|
+
}); // Return a placeholder if not released and not enabled by feature flag
|
|
123
|
+
|
|
124
|
+
EditTearsheet = pkg.checkComponentEnabled(EditTearsheet, componentName); // The display name of the component, used by React. Note that displayName
|
|
125
|
+
// is used in preference to relying on function.name.
|
|
126
|
+
|
|
127
|
+
EditTearsheet.displayName = componentName; // Note that the descriptions here should be kept in sync with those for the
|
|
128
|
+
// corresponding props for TearsheetNarrow and TearsheetShell components.
|
|
129
|
+
|
|
130
|
+
EditTearsheet.propTypes = {
|
|
131
|
+
/**
|
|
132
|
+
* The cancel button text
|
|
133
|
+
*/
|
|
134
|
+
cancelButtonText: PropTypes.string,
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The main content of the tearsheet
|
|
138
|
+
*/
|
|
139
|
+
children: PropTypes.node,
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* An optional class or classes to be added to the outermost element.
|
|
143
|
+
*/
|
|
144
|
+
className: PropTypes.string,
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A description of the flow, displayed in the header area of the tearsheet.
|
|
148
|
+
*/
|
|
149
|
+
description: PropTypes.node,
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The content for the influencer section of the tearsheet, displayed
|
|
153
|
+
* alongside the main content. This is typically a menu, or filter, or
|
|
154
|
+
* progress indicator, or similar.
|
|
155
|
+
*/
|
|
156
|
+
influencer: PropTypes.element,
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Used to set the size of the influencer
|
|
160
|
+
*/
|
|
161
|
+
influencerWidth: PropTypes.oneOf(['narrow', 'wide']),
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A label for the tearsheet, displayed in the header area of the tearsheet
|
|
165
|
+
* to maintain context for the tearsheet (e.g. as the title changes from page
|
|
166
|
+
* to page of a multi-page task).
|
|
167
|
+
*/
|
|
168
|
+
label: PropTypes.node,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* An optional handler that is called when the user closes the tearsheet (by
|
|
172
|
+
* clicking the close button, if enabled, or clicking outside, if enabled).
|
|
173
|
+
* Returning `false` here prevents the modal from closing.
|
|
174
|
+
*/
|
|
175
|
+
onClose: PropTypes.func,
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Specifies whether the tearsheet is currently open.
|
|
179
|
+
*/
|
|
180
|
+
onHandleModalClick: PropTypes.func,
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Specifies whether the tearsheet is currently open.
|
|
184
|
+
*/
|
|
185
|
+
open: PropTypes.bool,
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The submit button text
|
|
189
|
+
*/
|
|
190
|
+
submitButtonText: PropTypes.string,
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The main title of the tearsheet, displayed in the header area.
|
|
194
|
+
*/
|
|
195
|
+
title: PropTypes.node,
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The position of the top of tearsheet in the viewport. The 'normal'
|
|
199
|
+
* position (the default) is a short distance down from the top of the
|
|
200
|
+
* viewport, leaving room at the top for a global header bar to show through
|
|
201
|
+
* from below. The 'lower' position provides a little extra room at the top
|
|
202
|
+
* to allow an action bar navigation or breadcrumbs to also show through.
|
|
203
|
+
*/
|
|
204
|
+
verticalPosition: PropTypes.oneOf(['normal', 'lower'])
|
|
205
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["children", "className", "description", "fieldsetLegendText", "hasFieldset", "subtitle", "title"];
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright IBM Corp. 2022, 2022
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
import React, { forwardRef, useContext } from 'react';
|
|
13
|
+
import PropTypes from 'prop-types';
|
|
14
|
+
import cx from 'classnames';
|
|
15
|
+
import { Column, FormGroup, Row } from 'carbon-components-react';
|
|
16
|
+
import { FormContext, FormNumberContext } from './EditTearsheet';
|
|
17
|
+
import { pkg } from '../../settings';
|
|
18
|
+
import pconsole from '../../global/js/utils/pconsole';
|
|
19
|
+
var componentName = 'EditTearsheetForm';
|
|
20
|
+
var blockClass = "".concat(pkg.prefix, "--tearsheet-edit__form"); // Default values for props
|
|
21
|
+
|
|
22
|
+
var defaults = {
|
|
23
|
+
hasFieldset: true
|
|
24
|
+
};
|
|
25
|
+
export var EditTearsheetForm = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
26
|
+
var _cx;
|
|
27
|
+
|
|
28
|
+
var children = _ref.children,
|
|
29
|
+
className = _ref.className,
|
|
30
|
+
description = _ref.description,
|
|
31
|
+
fieldsetLegendText = _ref.fieldsetLegendText,
|
|
32
|
+
_ref$hasFieldset = _ref.hasFieldset,
|
|
33
|
+
hasFieldset = _ref$hasFieldset === void 0 ? defaults.hasFieldset : _ref$hasFieldset,
|
|
34
|
+
subtitle = _ref.subtitle,
|
|
35
|
+
title = _ref.title,
|
|
36
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
37
|
+
|
|
38
|
+
var formContext = useContext(FormContext);
|
|
39
|
+
var formNumber = useContext(FormNumberContext);
|
|
40
|
+
return formContext ? /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
41
|
+
className: cx(blockClass, className, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__form--hidden-form"), formNumber !== (formContext === null || formContext === void 0 ? void 0 : formContext.currentForm)), _defineProperty(_cx, "".concat(blockClass, "__form--visible-form"), formNumber === (formContext === null || formContext === void 0 ? void 0 : formContext.currentForm)), _cx)),
|
|
42
|
+
ref: ref
|
|
43
|
+
}), /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
|
|
44
|
+
xlg: 12,
|
|
45
|
+
lg: 12,
|
|
46
|
+
md: 8,
|
|
47
|
+
sm: 8
|
|
48
|
+
}, /*#__PURE__*/React.createElement("h4", {
|
|
49
|
+
className: "".concat(blockClass, "--title")
|
|
50
|
+
}, title), subtitle && /*#__PURE__*/React.createElement("h6", {
|
|
51
|
+
className: "".concat(blockClass, "--subtitle")
|
|
52
|
+
}, subtitle), description && /*#__PURE__*/React.createElement("p", {
|
|
53
|
+
className: "".concat(blockClass, "--description")
|
|
54
|
+
}, description))), hasFieldset ? /*#__PURE__*/React.createElement(FormGroup, {
|
|
55
|
+
legendText: fieldsetLegendText,
|
|
56
|
+
className: "".concat(blockClass, "--fieldset")
|
|
57
|
+
}, children) : children) : pconsole.warn("You have tried using a ".concat(componentName, " component outside of a EditTearsheet. This is not allowed. ").concat(componentName, "s should always be children of the EditTearsheet"));
|
|
58
|
+
}); // Return a placeholder if not released and not enabled by feature flag
|
|
59
|
+
|
|
60
|
+
EditTearsheetForm = pkg.checkComponentEnabled(EditTearsheetForm, componentName);
|
|
61
|
+
EditTearsheetForm.propTypes = {
|
|
62
|
+
/**
|
|
63
|
+
* Content that shows in the tearsheet form
|
|
64
|
+
*/
|
|
65
|
+
children: PropTypes.node,
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Sets an optional className to be added to the tearsheet form
|
|
69
|
+
*/
|
|
70
|
+
className: PropTypes.string,
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Sets an optional description on the form component
|
|
74
|
+
*/
|
|
75
|
+
description: PropTypes.string,
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* This is the required legend text that appears above a fieldset html element for accessibility purposes.
|
|
79
|
+
* You can set the `hasFieldset` prop to false if you have multiple fieldset elements or want to control the children of your Full Page's form content.
|
|
80
|
+
* Otherwise, use CSS to hide/remove this label text.
|
|
81
|
+
*/
|
|
82
|
+
fieldsetLegendText: PropTypes.string.isRequired.if(function (_ref2) {
|
|
83
|
+
var hasFieldset = _ref2.hasFieldset;
|
|
84
|
+
return !!hasFieldset;
|
|
85
|
+
}),
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* This optional prop will render your form content inside of a fieldset html element
|
|
89
|
+
* and is defaulted to true.
|
|
90
|
+
* You can set this prop to `false` if you have multiple fieldset elements or want to control the children of your Full Page's form content.
|
|
91
|
+
*/
|
|
92
|
+
hasFieldset: PropTypes.bool,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Sets an optional subtitle on the form component
|
|
96
|
+
*/
|
|
97
|
+
subtitle: PropTypes.string,
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Sets the title text for a tearsheet form
|
|
101
|
+
*/
|
|
102
|
+
title: PropTypes.node.isRequired
|
|
103
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
|
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 { EditTearsheet } from './EditTearsheet';
|
|
8
|
+
export { EditTearsheetForm } from './EditTearsheetForm';
|