@carbon/ibm-products 1.35.2 → 1.37.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/README.md +3 -3
- package/css/index-full-carbon.css +288 -265
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +65 -68
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +3 -3
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +90 -70
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +257 -237
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/ActionSet/ActionSet.js +6 -3
- package/es/components/AddSelect/add-select-utils.js +2 -2
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +2 -1
- package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +8 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +88 -0
- package/es/components/Datagrid/useNestedRowExpander.js +8 -3
- package/es/components/FilterSummary/FilterSummary.js +54 -0
- package/es/components/FilterSummary/index.js +7 -0
- package/es/components/OptionsTile/OptionsTile.js +25 -10
- package/es/components/PageHeader/PageHeaderTitle.js +2 -4
- package/es/global/js/hooks/index.js +2 -1
- package/es/global/js/hooks/useControllableState.js +74 -0
- package/lib/components/ActionSet/ActionSet.js +6 -3
- package/lib/components/AddSelect/add-select-utils.js +2 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +2 -1
- package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +8 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +101 -0
- package/lib/components/Datagrid/useNestedRowExpander.js +7 -2
- package/lib/components/FilterSummary/FilterSummary.js +63 -0
- package/lib/components/FilterSummary/index.js +13 -0
- package/lib/components/OptionsTile/OptionsTile.js +25 -10
- package/lib/components/PageHeader/PageHeaderTitle.js +2 -4
- package/lib/global/js/hooks/index.js +8 -1
- package/lib/global/js/hooks/useControllableState.js +80 -0
- package/package.json +15 -15
- package/scss/components/ActionSet/_action-set.scss +9 -4
- package/scss/components/Datagrid/styles/_useNestedRows.scss +17 -0
- package/scss/components/FilterSummary/_filter-summary.scss +17 -0
- package/scss/components/FilterSummary/_index.scss +10 -0
- package/scss/components/FilterSummary/_storybook-styles.scss +14 -0
- package/scss/components/PageHeader/_page-header.scss +0 -4
- package/scss/components/_index.scss +1 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
/**
|
4
|
+
* Copyright IBM Corp. 2022, 2022
|
5
|
+
*
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
import React, { createContext } from 'react';
|
10
|
+
import PropTypes from 'prop-types';
|
11
|
+
import { DATE, DROPDOWN, NUMBER, RADIO, CHECKBOX } from './constants';
|
12
|
+
export var FilterContext = /*#__PURE__*/createContext();
|
13
|
+
var prepareFiltersForTags = function prepareFiltersForTags(filters) {
|
14
|
+
var tags = [];
|
15
|
+
filters.forEach(function (_ref) {
|
16
|
+
var id = _ref.id,
|
17
|
+
type = _ref.type,
|
18
|
+
value = _ref.value;
|
19
|
+
if (type === DROPDOWN || type === RADIO || type === NUMBER) {
|
20
|
+
tags.push(_defineProperty({}, id, value));
|
21
|
+
} else if (type === DATE) {
|
22
|
+
var _value = _slicedToArray(value, 2),
|
23
|
+
startDate = _value[0],
|
24
|
+
endDate = _value[1];
|
25
|
+
tags.push(_defineProperty({}, id, "".concat(startDate.toLocaleString(), " - ").concat(endDate.toLocaleString())));
|
26
|
+
} else if (type === CHECKBOX) {
|
27
|
+
value.forEach(function (checkbox) {
|
28
|
+
tags.push(_defineProperty({}, id, checkbox.value));
|
29
|
+
});
|
30
|
+
}
|
31
|
+
});
|
32
|
+
return tags;
|
33
|
+
};
|
34
|
+
export var FilterProvider = function FilterProvider(_ref2) {
|
35
|
+
var children = _ref2.children,
|
36
|
+
filters = _ref2.filters;
|
37
|
+
console.log(filters);
|
38
|
+
var filterTags = prepareFiltersForTags(filters);
|
39
|
+
console.log({
|
40
|
+
filterTags: filterTags
|
41
|
+
});
|
42
|
+
var value = {
|
43
|
+
filterTags: filterTags
|
44
|
+
};
|
45
|
+
return /*#__PURE__*/React.createElement(FilterContext.Provider, {
|
46
|
+
value: value
|
47
|
+
}, children);
|
48
|
+
};
|
49
|
+
FilterProvider.propTypes = {
|
50
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
51
|
+
filters: PropTypes.arrayOf(PropTypes.object).isRequired
|
52
|
+
};
|
53
|
+
[{
|
54
|
+
id: 'joined',
|
55
|
+
value: ['2022-10-02T04:00:00.000Z', '2022-10-26T04:00:00.000Z'],
|
56
|
+
type: 'date'
|
57
|
+
}, {
|
58
|
+
id: 'visits',
|
59
|
+
value: '1',
|
60
|
+
type: 'number'
|
61
|
+
}, {
|
62
|
+
id: 'passwordStrength',
|
63
|
+
value: [{
|
64
|
+
id: 'normal',
|
65
|
+
labelText: 'Normal',
|
66
|
+
value: 'normal',
|
67
|
+
selected: true
|
68
|
+
}, {
|
69
|
+
id: 'minor-warning',
|
70
|
+
labelText: 'Minor warning',
|
71
|
+
value: 'minor-warning',
|
72
|
+
selected: true
|
73
|
+
}, {
|
74
|
+
id: 'critical',
|
75
|
+
labelText: 'Critical',
|
76
|
+
value: 'critical',
|
77
|
+
selected: false
|
78
|
+
}],
|
79
|
+
type: 'checkbox'
|
80
|
+
}, {
|
81
|
+
id: 'role',
|
82
|
+
value: 'developer',
|
83
|
+
type: 'radio'
|
84
|
+
}, {
|
85
|
+
id: 'status',
|
86
|
+
value: 'complicated',
|
87
|
+
type: 'dropdown'
|
88
|
+
}];
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
4
|
/* eslint-disable react/prop-types */
|
4
5
|
/*
|
@@ -11,7 +12,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
12
|
import React from 'react';
|
12
13
|
import { ChevronRight16 } from '@carbon/icons-react';
|
13
14
|
import cx from 'classnames';
|
14
|
-
import { pkg } from '../../settings';
|
15
|
+
import { pkg, carbon } from '../../settings';
|
15
16
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
16
17
|
var useNestedRowExpander = function useNestedRowExpander(hooks) {
|
17
18
|
var visibleColumns = function visibleColumns(columns) {
|
@@ -20,8 +21,12 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
|
|
20
21
|
Cell: function Cell(_ref) {
|
21
22
|
var _cx;
|
22
23
|
var row = _ref.row;
|
23
|
-
return row.canExpand && /*#__PURE__*/React.createElement("
|
24
|
-
|
24
|
+
return row.canExpand && /*#__PURE__*/React.createElement("button", _extends({
|
25
|
+
type: "button",
|
26
|
+
"aria-label": "Expand current row",
|
27
|
+
className: cx("".concat(blockClass, "__row-expander"), "".concat(carbon.prefix, "--btn"), "".concat(carbon.prefix, "--btn--ghost"))
|
28
|
+
}, row.getToggleRowExpandedProps()), /*#__PURE__*/React.createElement(ChevronRight16, {
|
29
|
+
className: cx("".concat(blockClass, "__expander-icon"), "".concat(blockClass, "__row-expander--icon"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__expander-icon--not-open"), !row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__expander-icon--open"), row.isExpanded), _cx))
|
25
30
|
}));
|
26
31
|
},
|
27
32
|
width: 48,
|
@@ -0,0 +1,54 @@
|
|
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
|
+
import { Button } from 'carbon-components-react';
|
8
|
+
import React from 'react';
|
9
|
+
import PropTypes from 'prop-types';
|
10
|
+
import cx from 'classnames';
|
11
|
+
import { TagSet } from '../TagSet';
|
12
|
+
import { pkg } from '../../settings';
|
13
|
+
var blockClass = "".concat(pkg.prefix, "--filter-summary");
|
14
|
+
var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
15
|
+
var _ref$className = _ref.className,
|
16
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
17
|
+
_ref$clearFiltersText = _ref.clearFiltersText,
|
18
|
+
clearFiltersText = _ref$clearFiltersText === void 0 ? 'Clear filters' : _ref$clearFiltersText,
|
19
|
+
_ref$clearFilters = _ref.clearFilters,
|
20
|
+
clearFilters = _ref$clearFilters === void 0 ? function () {} : _ref$clearFilters,
|
21
|
+
_ref$filters = _ref.filters,
|
22
|
+
filters = _ref$filters === void 0 ? [] : _ref$filters;
|
23
|
+
var tagFilters = filters.map(function (_ref2) {
|
24
|
+
var key = _ref2.key,
|
25
|
+
value = _ref2.value;
|
26
|
+
return {
|
27
|
+
type: 'gray',
|
28
|
+
label: "".concat(key, ": ").concat(value)
|
29
|
+
};
|
30
|
+
});
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
32
|
+
ref: ref,
|
33
|
+
className: cx([blockClass, className])
|
34
|
+
}, /*#__PURE__*/React.createElement(TagSet, {
|
35
|
+
allTagsModalSearchLabel: "Search all tags",
|
36
|
+
allTagsModalSearchPlaceholderText: "Search all tags",
|
37
|
+
allTagsModalTitle: "All tags",
|
38
|
+
showAllTagsLabel: "View all tags",
|
39
|
+
tags: tagFilters
|
40
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
41
|
+
kind: "ghost",
|
42
|
+
size: "sm",
|
43
|
+
onClick: clearFilters
|
44
|
+
}, clearFiltersText));
|
45
|
+
});
|
46
|
+
var componentName = 'FilterSummary';
|
47
|
+
FilterSummary.displayName = componentName;
|
48
|
+
FilterSummary.propTypes = {
|
49
|
+
className: PropTypes.string,
|
50
|
+
clearFilters: PropTypes.func.isRequired,
|
51
|
+
clearFiltersText: PropTypes.string,
|
52
|
+
filters: PropTypes.arrayOf(PropTypes.object).isRequired
|
53
|
+
};
|
54
|
+
export default FilterSummary;
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
-
var _excluded = ["children", "className", "enabled", "invalid", "invalidText", "locked", "lockedText", "onToggle", "open", "size", "summary", "title", "titleId", "warn", "warnText"];
|
5
|
+
var _excluded = ["children", "className", "enabled", "invalid", "invalidText", "locked", "lockedText", "onChange", "onToggle", "open", "size", "summary", "title", "titleId", "warn", "warnText"];
|
6
6
|
/**
|
7
7
|
* Copyright IBM Corp. 2021, 2022
|
8
8
|
*
|
@@ -19,6 +19,7 @@ import cx from 'classnames';
|
|
19
19
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
20
20
|
import uuidv4 from '../../global/js/utils/uuidv4';
|
21
21
|
import { pkg } from '../../settings';
|
22
|
+
import { useControllableState } from '../../global/js/hooks';
|
22
23
|
|
23
24
|
// Carbon and package components we use.
|
24
25
|
import { Toggle } from 'carbon-components-react';
|
@@ -33,6 +34,7 @@ var componentName = 'OptionsTile';
|
|
33
34
|
|
34
35
|
// Default values for props
|
35
36
|
var defaults = {
|
37
|
+
onChange: function onChange() {},
|
36
38
|
size: 'xl'
|
37
39
|
};
|
38
40
|
|
@@ -47,6 +49,8 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
47
49
|
invalidText = _ref.invalidText,
|
48
50
|
locked = _ref.locked,
|
49
51
|
lockedText = _ref.lockedText,
|
52
|
+
_ref$onChange = _ref.onChange,
|
53
|
+
_onChange = _ref$onChange === void 0 ? defaults.onChange : _ref$onChange,
|
50
54
|
onToggle = _ref.onToggle,
|
51
55
|
open = _ref.open,
|
52
56
|
_ref$size = _ref.size,
|
@@ -59,16 +63,22 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
59
63
|
rest = _objectWithoutProperties(_ref, _excluded);
|
60
64
|
var _useState = useState(open),
|
61
65
|
_useState2 = _slicedToArray(_useState, 2),
|
62
|
-
|
63
|
-
|
64
|
-
var _useState3 = useState(
|
66
|
+
prevIsOpen = _useState2[0],
|
67
|
+
setPrevIsOpen = _useState2[1];
|
68
|
+
var _useState3 = useState(false),
|
65
69
|
_useState4 = _slicedToArray(_useState3, 2),
|
66
|
-
|
67
|
-
|
68
|
-
var
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
closing = _useState4[0],
|
71
|
+
setClosing = _useState4[1];
|
72
|
+
var _useControllableState = useControllableState({
|
73
|
+
value: open,
|
74
|
+
defaultValue: open || null,
|
75
|
+
onChange: function onChange(value) {
|
76
|
+
return _onChange(value);
|
77
|
+
}
|
78
|
+
}),
|
79
|
+
_useControllableState2 = _slicedToArray(_useControllableState, 2),
|
80
|
+
isOpen = _useControllableState2[0],
|
81
|
+
setIsOpen = _useControllableState2[1];
|
72
82
|
var detailsRef = useRef(null);
|
73
83
|
var contentRef = useRef(null);
|
74
84
|
var id = uuidv4();
|
@@ -272,6 +282,11 @@ OptionsTile.propTypes = {
|
|
272
282
|
* Provide a text explaining why the OptionsTile is in locked state.
|
273
283
|
*/
|
274
284
|
lockedText: PropTypes.string,
|
285
|
+
/**
|
286
|
+
* Provide a function which will be called each time the user
|
287
|
+
* toggles the open state of the OptionsTile.
|
288
|
+
*/
|
289
|
+
onChange: PropTypes.func,
|
275
290
|
/**
|
276
291
|
* Provide a function which will be called each time the user
|
277
292
|
* interacts with the toggle.
|
@@ -62,12 +62,10 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
62
62
|
titleInnards = content;
|
63
63
|
titleText = asText;
|
64
64
|
}
|
65
|
-
return /*#__PURE__*/React.createElement("
|
65
|
+
return /*#__PURE__*/React.createElement("h1", {
|
66
66
|
className: cx("".concat(blockClass, "__title"), _defineProperty({}, "".concat(blockClass, "__title--editable"), isEditable), _defineProperty({}, "".concat(blockClass, "__title--fades"), hasBreadcrumbRow)),
|
67
67
|
title: titleText
|
68
|
-
},
|
69
|
-
className: "".concat(blockClass, "__title-wrapper")
|
70
|
-
}, titleInnards));
|
68
|
+
}, titleInnards);
|
71
69
|
};
|
72
70
|
export var inlineEditRequired = function inlineEditRequired(_ref2) {
|
73
71
|
var onSave = _ref2.onSave;
|
@@ -14,4 +14,5 @@ export { useCreateComponentStepChange } from './useCreateComponentStepChange';
|
|
14
14
|
export { usePreviousValue } from './usePreviousValue';
|
15
15
|
export { useResetCreateComponent } from './useResetCreateComponent';
|
16
16
|
export { useRetrieveStepData } from './useRetrieveStepData';
|
17
|
-
export { useValidCreateStepCount } from './useValidCreateStepCount';
|
17
|
+
export { useValidCreateStepCount } from './useValidCreateStepCount';
|
18
|
+
export { useControllableState } from './useControllableState';
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
/**
|
3
|
+
* Copyright IBM Corp. 2016, 2022
|
4
|
+
*
|
5
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
7
|
+
*/
|
8
|
+
|
9
|
+
import { useEffect, useRef, useState } from 'react';
|
10
|
+
import pconsole from '../utils/pconsole';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* This custom hook simplifies the behavior of a component if it has state that
|
14
|
+
* can be both controlled and uncontrolled. It functions identical to a
|
15
|
+
* useState() hook and provides [state, setState] for you to use. You can use
|
16
|
+
* the `onChange` argument to allow updates to the `state` to be communicated to
|
17
|
+
* owners of controlled components.
|
18
|
+
*
|
19
|
+
* Note: this hook will warn if a component is switching from controlled to
|
20
|
+
* uncontrolled, or vice-versa.
|
21
|
+
*
|
22
|
+
* @param {object} config
|
23
|
+
* @param {string} config.name - the name of the custom component
|
24
|
+
* @param {any} config.defaultValue - the default value used for the state. This will be
|
25
|
+
* the fallback value used if `value` is not defined.
|
26
|
+
* @param {Function} config.onChange - an optional function that is called when
|
27
|
+
* the value of the state changes. This is useful for communicating to parents of
|
28
|
+
* controlled components that the value is requesting to be changed.
|
29
|
+
* @param {any} config.value - a controlled value. Omitting this means that the state is
|
30
|
+
* uncontrolled
|
31
|
+
* @returns {[any, Function]}
|
32
|
+
*/
|
33
|
+
export function useControllableState(_ref) {
|
34
|
+
var defaultValue = _ref.defaultValue,
|
35
|
+
_ref$name = _ref.name,
|
36
|
+
name = _ref$name === void 0 ? 'custom' : _ref$name,
|
37
|
+
onChange = _ref.onChange,
|
38
|
+
value = _ref.value;
|
39
|
+
var _useState = useState(value !== null && value !== void 0 ? value : defaultValue),
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
41
|
+
state = _useState2[0],
|
42
|
+
internalSetState = _useState2[1];
|
43
|
+
var controlled = useRef(null);
|
44
|
+
if (controlled.current === null) {
|
45
|
+
controlled.current = value !== undefined;
|
46
|
+
}
|
47
|
+
function setState(stateOrUpdater) {
|
48
|
+
var value = typeof stateOrUpdater === 'function' ? stateOrUpdater(state) : stateOrUpdater;
|
49
|
+
if (controlled.current === false) {
|
50
|
+
internalSetState(value);
|
51
|
+
}
|
52
|
+
if (onChange) {
|
53
|
+
onChange(value);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
useEffect(function () {
|
57
|
+
var controlledValue = value !== undefined;
|
58
|
+
// Uncontrolled -> Controlled
|
59
|
+
// If the component prop is uncontrolled, the prop value should be undefined
|
60
|
+
if (controlled.current === false && controlledValue) {
|
61
|
+
pconsole.warn("A component is changing an uncontrolled %s component to be controlled.\n This is likely caused by the value changing to a defined value\n from undefined. Decide between using a controlled or uncontrolled\n value for the lifetime of the component.\n More info: https://reactjs.org/link/controlled-components");
|
62
|
+
}
|
63
|
+
|
64
|
+
// Controlled -> Uncontrolled
|
65
|
+
// If the component prop is controlled, the prop value should be defined
|
66
|
+
if (controlled.current === true && !controlledValue) {
|
67
|
+
pconsole.warn("A component is changing a controlled %s component to be uncontrolled.\n 'This is likely caused by the value changing to an undefined value\n 'from a defined one. Decide between using a controlled or\n 'uncontrolled value for the lifetime of the component.\n 'More info: https://reactjs.org/link/controlled-components");
|
68
|
+
}
|
69
|
+
}, [name, value]);
|
70
|
+
if (controlled.current === true) {
|
71
|
+
return [value, setState];
|
72
|
+
}
|
73
|
+
return [state, setState];
|
74
|
+
}
|
@@ -14,7 +14,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
14
|
var _settings = require("../../settings");
|
15
15
|
var _propsHelper = require("../../global/js/utils/props-helper");
|
16
16
|
var _carbonComponentsReact = require("carbon-components-react");
|
17
|
-
var _excluded = ["className", "disabled", "kind", "label", "loading"],
|
17
|
+
var _excluded = ["className", "disabled", "kind", "label", "loading", "isExpressive"],
|
18
18
|
_excluded2 = ["actions", "buttonSize", "className", "size"];
|
19
19
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
20
20
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
@@ -24,15 +24,18 @@ var componentName = 'ActionSet';
|
|
24
24
|
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
25
25
|
|
26
26
|
var ActionSetButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
27
|
+
var _ref2;
|
27
28
|
var className = _ref.className,
|
28
29
|
disabled = _ref.disabled,
|
29
30
|
kind = _ref.kind,
|
30
31
|
label = _ref.label,
|
31
32
|
loading = _ref.loading,
|
33
|
+
_ref$isExpressive = _ref.isExpressive,
|
34
|
+
isExpressive = _ref$isExpressive === void 0 ? true : _ref$isExpressive,
|
32
35
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
33
36
|
return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({}, rest, {
|
34
|
-
isExpressive:
|
35
|
-
className: (0, _classnames.default)(className, ["".concat(blockClass, "__action-button"), (0, _defineProperty2.default)(
|
37
|
+
isExpressive: isExpressive,
|
38
|
+
className: (0, _classnames.default)(className, ["".concat(blockClass, "__action-button"), (_ref2 = {}, (0, _defineProperty2.default)(_ref2, "".concat(blockClass, "__action-button--ghost"), kind === 'ghost' || kind === 'danger--ghost'), (0, _defineProperty2.default)(_ref2, "".concat(blockClass, "__action-button--expressive"), isExpressive), _ref2)]),
|
36
39
|
disabled: disabled || loading || false,
|
37
40
|
kind: kind,
|
38
41
|
ref: ref
|
@@ -83,7 +83,7 @@ var getFilteredItems = function getFilteredItems(useNormalizedItems, normalizedI
|
|
83
83
|
var itemIds = Object.keys(normalizedItems);
|
84
84
|
if (searchTerm || globalFiltersApplied) {
|
85
85
|
var results = itemIds.reduce(function (prev, cur) {
|
86
|
-
if (normalizedItems[cur].title.toLowerCase().includes(searchTerm)) {
|
86
|
+
if (normalizedItems[cur].title.toLowerCase().includes(searchTerm.toLowerCase())) {
|
87
87
|
prev.push(normalizedItems[cur]);
|
88
88
|
}
|
89
89
|
return prev;
|
@@ -122,7 +122,7 @@ var getFilteredItems = function getFilteredItems(useNormalizedItems, normalizedI
|
|
122
122
|
} else {
|
123
123
|
if (searchTerm) {
|
124
124
|
return items.entries.filter(function (item) {
|
125
|
-
return item.title.toLowerCase().includes(searchTerm);
|
125
|
+
return item.title.toLowerCase().includes(searchTerm.toLowerCase());
|
126
126
|
});
|
127
127
|
}
|
128
128
|
return items.entries;
|
@@ -355,7 +355,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
355
355
|
currentMatcher: currentMatcher,
|
356
356
|
rows: rows,
|
357
357
|
setActiveCellContent: setActiveCellContent,
|
358
|
-
updateData: updateData
|
358
|
+
updateData: updateData,
|
359
|
+
activeCellCoordinates: activeCellCoordinates
|
359
360
|
};
|
360
361
|
// Allow arrow key navigation if there are less than two activeKeys OR
|
361
362
|
// if one of the activeCellCoordinates is in a header position
|
@@ -14,11 +14,18 @@ var _rangeWithCallback = require("../../../global/js/utils/rangeWithCallback");
|
|
14
14
|
*/
|
15
15
|
|
16
16
|
var handleCellDeletion = function handleCellDeletion(_ref) {
|
17
|
-
var
|
17
|
+
var activeCellCoordinates = _ref.activeCellCoordinates,
|
18
|
+
selectionAreas = _ref.selectionAreas,
|
18
19
|
currentMatcher = _ref.currentMatcher,
|
19
20
|
rows = _ref.rows,
|
20
21
|
setActiveCellContent = _ref.setActiveCellContent,
|
21
22
|
updateData = _ref.updateData;
|
23
|
+
// This means that the delete key has been pressed when the active cell is in a header,
|
24
|
+
// not within the spreadsheet body. To delete an entire row/column, it must first be
|
25
|
+
// selected, and then can be deleted.
|
26
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
|
27
|
+
return;
|
28
|
+
}
|
22
29
|
var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
|
23
30
|
var indexOfCurrentSelectionArea = selectionAreaClone.findIndex(function (item) {
|
24
31
|
return item.matcher === currentMatcher;
|
@@ -0,0 +1,101 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.FilterProvider = exports.FilterContext = void 0;
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
13
|
+
var _constants = require("./constants");
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
16
|
+
/**
|
17
|
+
* Copyright IBM Corp. 2022, 2022
|
18
|
+
*
|
19
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
21
|
+
*/
|
22
|
+
|
23
|
+
var FilterContext = /*#__PURE__*/(0, _react.createContext)();
|
24
|
+
exports.FilterContext = FilterContext;
|
25
|
+
var prepareFiltersForTags = function prepareFiltersForTags(filters) {
|
26
|
+
var tags = [];
|
27
|
+
filters.forEach(function (_ref) {
|
28
|
+
var id = _ref.id,
|
29
|
+
type = _ref.type,
|
30
|
+
value = _ref.value;
|
31
|
+
if (type === _constants.DROPDOWN || type === _constants.RADIO || type === _constants.NUMBER) {
|
32
|
+
tags.push((0, _defineProperty2.default)({}, id, value));
|
33
|
+
} else if (type === _constants.DATE) {
|
34
|
+
var _value = (0, _slicedToArray2.default)(value, 2),
|
35
|
+
startDate = _value[0],
|
36
|
+
endDate = _value[1];
|
37
|
+
tags.push((0, _defineProperty2.default)({}, id, "".concat(startDate.toLocaleString(), " - ").concat(endDate.toLocaleString())));
|
38
|
+
} else if (type === _constants.CHECKBOX) {
|
39
|
+
value.forEach(function (checkbox) {
|
40
|
+
tags.push((0, _defineProperty2.default)({}, id, checkbox.value));
|
41
|
+
});
|
42
|
+
}
|
43
|
+
});
|
44
|
+
return tags;
|
45
|
+
};
|
46
|
+
var FilterProvider = function FilterProvider(_ref2) {
|
47
|
+
var children = _ref2.children,
|
48
|
+
filters = _ref2.filters;
|
49
|
+
console.log(filters);
|
50
|
+
var filterTags = prepareFiltersForTags(filters);
|
51
|
+
console.log({
|
52
|
+
filterTags: filterTags
|
53
|
+
});
|
54
|
+
var value = {
|
55
|
+
filterTags: filterTags
|
56
|
+
};
|
57
|
+
return /*#__PURE__*/_react.default.createElement(FilterContext.Provider, {
|
58
|
+
value: value
|
59
|
+
}, children);
|
60
|
+
};
|
61
|
+
exports.FilterProvider = FilterProvider;
|
62
|
+
FilterProvider.propTypes = {
|
63
|
+
children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]).isRequired,
|
64
|
+
filters: _propTypes.default.arrayOf(_propTypes.default.object).isRequired
|
65
|
+
};
|
66
|
+
[{
|
67
|
+
id: 'joined',
|
68
|
+
value: ['2022-10-02T04:00:00.000Z', '2022-10-26T04:00:00.000Z'],
|
69
|
+
type: 'date'
|
70
|
+
}, {
|
71
|
+
id: 'visits',
|
72
|
+
value: '1',
|
73
|
+
type: 'number'
|
74
|
+
}, {
|
75
|
+
id: 'passwordStrength',
|
76
|
+
value: [{
|
77
|
+
id: 'normal',
|
78
|
+
labelText: 'Normal',
|
79
|
+
value: 'normal',
|
80
|
+
selected: true
|
81
|
+
}, {
|
82
|
+
id: 'minor-warning',
|
83
|
+
labelText: 'Minor warning',
|
84
|
+
value: 'minor-warning',
|
85
|
+
selected: true
|
86
|
+
}, {
|
87
|
+
id: 'critical',
|
88
|
+
labelText: 'Critical',
|
89
|
+
value: 'critical',
|
90
|
+
selected: false
|
91
|
+
}],
|
92
|
+
type: 'checkbox'
|
93
|
+
}, {
|
94
|
+
id: 'role',
|
95
|
+
value: 'developer',
|
96
|
+
type: 'radio'
|
97
|
+
}, {
|
98
|
+
id: 'status',
|
99
|
+
value: 'complicated',
|
100
|
+
type: 'dropdown'
|
101
|
+
}];
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.default = void 0;
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
10
11
|
var _react = _interopRequireDefault(require("react"));
|
11
12
|
var _iconsReact = require("@carbon/icons-react");
|
@@ -28,8 +29,12 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
|
|
28
29
|
Cell: function Cell(_ref) {
|
29
30
|
var _cx;
|
30
31
|
var row = _ref.row;
|
31
|
-
return row.canExpand && /*#__PURE__*/_react.default.createElement("
|
32
|
-
|
32
|
+
return row.canExpand && /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
|
33
|
+
type: "button",
|
34
|
+
"aria-label": "Expand current row",
|
35
|
+
className: (0, _classnames.default)("".concat(blockClass, "__row-expander"), "".concat(_settings.carbon.prefix, "--btn"), "".concat(_settings.carbon.prefix, "--btn--ghost"))
|
36
|
+
}, row.getToggleRowExpandedProps()), /*#__PURE__*/_react.default.createElement(_iconsReact.ChevronRight16, {
|
37
|
+
className: (0, _classnames.default)("".concat(blockClass, "__expander-icon"), "".concat(blockClass, "__row-expander--icon"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__expander-icon--not-open"), !row.isExpanded), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__expander-icon--open"), row.isExpanded), _cx))
|
33
38
|
}));
|
34
39
|
},
|
35
40
|
width: 48,
|
@@ -0,0 +1,63 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.default = void 0;
|
8
|
+
var _carbonComponentsReact = require("carbon-components-react");
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
12
|
+
var _TagSet = require("../TagSet");
|
13
|
+
var _settings = require("../../settings");
|
14
|
+
/**
|
15
|
+
* Copyright IBM Corp. 2022, 2022
|
16
|
+
*
|
17
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
19
|
+
*/
|
20
|
+
|
21
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--filter-summary");
|
22
|
+
var FilterSummary = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
23
|
+
var _ref$className = _ref.className,
|
24
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
25
|
+
_ref$clearFiltersText = _ref.clearFiltersText,
|
26
|
+
clearFiltersText = _ref$clearFiltersText === void 0 ? 'Clear filters' : _ref$clearFiltersText,
|
27
|
+
_ref$clearFilters = _ref.clearFilters,
|
28
|
+
clearFilters = _ref$clearFilters === void 0 ? function () {} : _ref$clearFilters,
|
29
|
+
_ref$filters = _ref.filters,
|
30
|
+
filters = _ref$filters === void 0 ? [] : _ref$filters;
|
31
|
+
var tagFilters = filters.map(function (_ref2) {
|
32
|
+
var key = _ref2.key,
|
33
|
+
value = _ref2.value;
|
34
|
+
return {
|
35
|
+
type: 'gray',
|
36
|
+
label: "".concat(key, ": ").concat(value)
|
37
|
+
};
|
38
|
+
});
|
39
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
40
|
+
ref: ref,
|
41
|
+
className: (0, _classnames.default)([blockClass, className])
|
42
|
+
}, /*#__PURE__*/_react.default.createElement(_TagSet.TagSet, {
|
43
|
+
allTagsModalSearchLabel: "Search all tags",
|
44
|
+
allTagsModalSearchPlaceholderText: "Search all tags",
|
45
|
+
allTagsModalTitle: "All tags",
|
46
|
+
showAllTagsLabel: "View all tags",
|
47
|
+
tags: tagFilters
|
48
|
+
}), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
49
|
+
kind: "ghost",
|
50
|
+
size: "sm",
|
51
|
+
onClick: clearFilters
|
52
|
+
}, clearFiltersText));
|
53
|
+
});
|
54
|
+
var componentName = 'FilterSummary';
|
55
|
+
FilterSummary.displayName = componentName;
|
56
|
+
FilterSummary.propTypes = {
|
57
|
+
className: _propTypes.default.string,
|
58
|
+
clearFilters: _propTypes.default.func.isRequired,
|
59
|
+
clearFiltersText: _propTypes.default.string,
|
60
|
+
filters: _propTypes.default.arrayOf(_propTypes.default.object).isRequired
|
61
|
+
};
|
62
|
+
var _default = FilterSummary;
|
63
|
+
exports.default = _default;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
Object.defineProperty(exports, "FilterSummary", {
|
8
|
+
enumerable: true,
|
9
|
+
get: function get() {
|
10
|
+
return _FilterSummary.default;
|
11
|
+
}
|
12
|
+
});
|
13
|
+
var _FilterSummary = _interopRequireDefault(require("./FilterSummary"));
|