@carbon/ibm-products 2.42.1-canary.2 → 2.42.1-canary.22
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +302 -9
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +302 -9
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +302 -9
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/Carousel/Carousel.d.ts +1 -1
- package/es/components/Carousel/Carousel.js +1 -1
- package/es/components/Coachmark/CoachmarkDragbar.d.ts +1 -1
- package/es/components/Coachmark/CoachmarkDragbar.js +1 -1
- package/es/components/Coachmark/CoachmarkHeader.d.ts +1 -1
- package/es/components/Coachmark/CoachmarkHeader.js +1 -1
- package/es/components/Coachmark/CoachmarkOverlay.d.ts +1 -1
- package/es/components/Coachmark/CoachmarkOverlay.js +1 -1
- package/es/components/Coachmark/CoachmarkTagline.d.ts +1 -1
- package/es/components/Coachmark/CoachmarkTagline.js +1 -1
- package/es/components/CoachmarkStack/CoachmarkStackHome.d.ts +1 -1
- package/es/components/CoachmarkStack/CoachmarkStackHome.js +2 -2
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +6 -0
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +74 -33
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +15 -1
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +95 -12
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +11 -2
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +27 -9
- package/es/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.js +38 -33
- package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.d.ts +2 -0
- package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +44 -0
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +5 -0
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +95 -14
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +7 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +8 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +1 -1
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +197 -67
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +10 -0
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +69 -0
- package/es/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +7 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.d.ts +7 -1
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts +1 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +13 -3
- package/es/components/Datagrid/types/index.d.ts +2 -0
- package/es/components/Datagrid/useColumnOrder.d.ts +7 -1
- package/es/components/Datagrid/useNestedRows.js +24 -2
- package/es/components/Datagrid/useOnRowClick.d.ts +8 -1
- package/es/components/Datagrid/useOnRowClick.js +2 -1
- package/es/components/Datagrid/useRowIsMouseOver.d.ts +2 -1
- package/es/components/Datagrid/useRowIsMouseOver.js +1 -1
- package/es/components/Datagrid/useSelectRows.d.ts +8 -1
- package/es/components/Datagrid/useSelectRows.js +3 -2
- package/es/components/Datagrid/useSortableColumns.d.ts +10 -3
- package/es/components/Datagrid/useSortableColumns.js +3 -2
- package/es/components/Datagrid/utils/getAutoSizedColumnWidth.d.ts +8 -1
- package/es/components/Datagrid/utils/getAutoSizedColumnWidth.js +0 -7
- package/es/components/InterstitialScreenView/InterstitialScreenView.d.ts +1 -1
- package/es/components/InterstitialScreenView/InterstitialScreenView.js +1 -1
- package/es/components/SidePanel/SidePanel.d.ts +2 -2
- package/es/components/SidePanel/SidePanel.js +5 -3
- package/es/components/SteppedAnimatedMedia/SteppedAnimatedMedia.d.ts +1 -1
- package/es/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +1 -1
- package/es/feature-flags.js +18 -0
- package/es/global/js/package-settings.js +2 -2
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/lib/components/Carousel/Carousel.d.ts +1 -1
- package/lib/components/Carousel/Carousel.js +1 -1
- package/lib/components/Coachmark/CoachmarkDragbar.d.ts +1 -1
- package/lib/components/Coachmark/CoachmarkDragbar.js +1 -1
- package/lib/components/Coachmark/CoachmarkHeader.d.ts +1 -1
- package/lib/components/Coachmark/CoachmarkHeader.js +1 -1
- package/lib/components/Coachmark/CoachmarkOverlay.d.ts +1 -1
- package/lib/components/Coachmark/CoachmarkOverlay.js +1 -1
- package/lib/components/Coachmark/CoachmarkTagline.d.ts +1 -1
- package/lib/components/Coachmark/CoachmarkTagline.js +1 -1
- package/lib/components/CoachmarkStack/CoachmarkStackHome.d.ts +1 -1
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +6 -0
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +73 -32
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +15 -1
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +92 -9
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +11 -2
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +26 -8
- package/lib/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.js +36 -31
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.d.ts +2 -0
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +52 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +5 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +92 -11
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +7 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +8 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +1 -1
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +195 -64
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +10 -0
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +77 -0
- package/lib/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +7 -4
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.d.ts +7 -1
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts +1 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +13 -3
- package/lib/components/Datagrid/types/index.d.ts +2 -0
- package/lib/components/Datagrid/useColumnOrder.d.ts +7 -1
- package/lib/components/Datagrid/useNestedRows.js +24 -2
- package/lib/components/Datagrid/useOnRowClick.d.ts +8 -1
- package/lib/components/Datagrid/useOnRowClick.js +2 -1
- package/lib/components/Datagrid/useRowIsMouseOver.d.ts +2 -1
- package/lib/components/Datagrid/useRowIsMouseOver.js +1 -1
- package/lib/components/Datagrid/useSelectRows.d.ts +8 -1
- package/lib/components/Datagrid/useSelectRows.js +3 -2
- package/lib/components/Datagrid/useSortableColumns.d.ts +10 -3
- package/lib/components/Datagrid/useSortableColumns.js +3 -2
- package/lib/components/Datagrid/utils/getAutoSizedColumnWidth.d.ts +8 -1
- package/lib/components/Datagrid/utils/getAutoSizedColumnWidth.js +0 -7
- package/lib/components/InterstitialScreenView/InterstitialScreenView.d.ts +1 -1
- package/lib/components/InterstitialScreenView/InterstitialScreenView.js +1 -1
- package/lib/components/SidePanel/SidePanel.d.ts +2 -2
- package/lib/components/SidePanel/SidePanel.js +5 -3
- package/lib/components/SteppedAnimatedMedia/SteppedAnimatedMedia.d.ts +1 -1
- package/lib/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +1 -1
- package/lib/feature-flags.js +40 -0
- package/lib/global/js/package-settings.js +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +3 -3
- package/scss/components/ConditionBuilder/_condition-builder.scss +21 -1
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +22 -3
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +58 -21
- package/scss/components/NonLinearReading/_non-linear-reading.scss +1 -1
- /package/es/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.d.ts +0 -0
- /package/lib/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.d.ts +0 -0
@@ -13,12 +13,22 @@ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHel
|
|
13
13
|
var React = require('react');
|
14
14
|
var ConditionBlock = require('../ConditionBlock/ConditionBlock.js');
|
15
15
|
var index = require('../../../node_modules/prop-types/index.js');
|
16
|
+
var cx = require('classnames');
|
16
17
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
18
|
+
var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
|
19
|
+
var ConditionBuilderItemOption = require('../ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js');
|
20
|
+
var util = require('../utils/util.js');
|
21
|
+
var ConditionConnector = require('../ConditionBuilderConnector/ConditionConnector.js');
|
22
|
+
var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
|
17
23
|
var uuidv4 = require('../../../global/js/utils/uuidv4.js');
|
24
|
+
var ConditionPreview = require('../ConditionPreview/ConditionPreview.js');
|
18
25
|
|
19
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
20
27
|
|
21
28
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
29
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
30
|
+
|
31
|
+
var _ConditionPreview, _ConditionPreview2;
|
22
32
|
|
23
33
|
/**
|
24
34
|
*
|
@@ -26,14 +36,24 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
26
36
|
* All the inner components of group are called from here.
|
27
37
|
* @returns
|
28
38
|
*/
|
39
|
+
|
29
40
|
var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
30
|
-
var _group$conditions;
|
31
41
|
var group = _ref.group,
|
32
42
|
aria = _ref.aria,
|
33
43
|
onRemove = _ref.onRemove,
|
34
44
|
onChange = _ref.onChange,
|
35
45
|
conditionBuilderRef = _ref.conditionBuilderRef,
|
36
46
|
className = _ref.className;
|
47
|
+
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
48
|
+
variant = _useContext.variant;
|
49
|
+
var _useState = React.useState(-1),
|
50
|
+
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
51
|
+
showConditionPreview = _useState2[0],
|
52
|
+
setShowConditionPreview = _useState2[1];
|
53
|
+
var _useState3 = React.useState(-1),
|
54
|
+
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
55
|
+
showConditionSubGroupPreview = _useState4[0],
|
56
|
+
setShowConditionSubGroupPreview = _useState4[1];
|
37
57
|
var onRemoveHandler = function onRemoveHandler(conditionId, evt) {
|
38
58
|
if (group.conditions.length > 1) {
|
39
59
|
onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, group), {}, {
|
@@ -64,72 +84,183 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
64
84
|
conditions: [].concat(_rollupPluginBabelHelpers.toConsumableArray(group.conditions.slice(0, conditionIndex + 1)), [newCondition], _rollupPluginBabelHelpers.toConsumableArray(group.conditions.slice(conditionIndex + 1)))
|
65
85
|
}));
|
66
86
|
};
|
67
|
-
var
|
68
|
-
|
69
|
-
|
70
|
-
var handleFocusOnClose = function handleFocusOnClose(evt) {
|
71
|
-
var _evt$currentTarget;
|
72
|
-
var previousClose = (_evt$currentTarget = evt.currentTarget) === null || _evt$currentTarget === void 0 || (_evt$currentTarget = _evt$currentTarget.closest('[role="row"]')) === null || _evt$currentTarget === void 0 || (_evt$currentTarget = _evt$currentTarget.parentElement) === null || _evt$currentTarget === void 0 || (_evt$currentTarget = _evt$currentTarget.previousSibling) === null || _evt$currentTarget === void 0 ? void 0 : _evt$currentTarget.querySelector('[data-name="closeCondition"]');
|
87
|
+
var handleFocusOnClose = function handleFocusOnClose(e) {
|
88
|
+
var _e$currentTarget;
|
89
|
+
var previousClose = (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 || (_e$currentTarget = _e$currentTarget.closest('[role="row"]')) === null || _e$currentTarget === void 0 || (_e$currentTarget = _e$currentTarget.previousSibling) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.querySelector('[data-name="closeCondition"]');
|
73
90
|
if (previousClose) {
|
74
91
|
previousClose.focus();
|
75
92
|
}
|
76
93
|
};
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
94
|
+
var addConditionSubGroupHandler = function addConditionSubGroupHandler(conditionIndex) {
|
95
|
+
onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, group), {}, {
|
96
|
+
conditions: [].concat(_rollupPluginBabelHelpers.toConsumableArray(group.conditions.slice(0, conditionIndex + 1)), [{
|
97
|
+
groupSeparateOperator: null,
|
98
|
+
groupOperator: 'and',
|
99
|
+
statement: 'if',
|
100
|
+
conditions: [{
|
101
|
+
property: undefined,
|
102
|
+
operator: '',
|
103
|
+
value: '',
|
104
|
+
popoverToOpen: 'propertyField',
|
105
|
+
id: uuidv4["default"]()
|
106
|
+
}],
|
107
|
+
id: uuidv4["default"]()
|
108
|
+
}], _rollupPluginBabelHelpers.toConsumableArray(group.conditions.slice(conditionIndex + 1)))
|
109
|
+
}));
|
110
|
+
};
|
111
|
+
var isLastCondition = function isLastCondition(conditionIndex, conditionArr) {
|
112
|
+
return conditionIndex + 1 >= conditionArr.length || conditionArr.length - 1 != conditionIndex && conditionArr[conditionIndex + 1].conditions;
|
113
|
+
};
|
114
|
+
var _showConditionSubGroupPreviewHandler = function showConditionSubGroupPreviewHandler(conditionIndex) {
|
115
|
+
setShowConditionSubGroupPreview(conditionIndex);
|
116
|
+
};
|
117
|
+
var hideConditionSubGroupPreviewHandler = function hideConditionSubGroupPreviewHandler() {
|
118
|
+
setShowConditionSubGroupPreview(-1);
|
119
|
+
};
|
120
|
+
var _showConditionPreviewHandler = function showConditionPreviewHandler(conditionIndex) {
|
121
|
+
setShowConditionPreview(conditionIndex);
|
122
|
+
};
|
123
|
+
var hideConditionPreviewHandler = function hideConditionPreviewHandler() {
|
124
|
+
setShowConditionPreview(-1);
|
125
|
+
};
|
126
|
+
var onStatementChangeHandler = function onStatementChangeHandler(updatedStatement) {
|
127
|
+
onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, group), {}, {
|
128
|
+
statement: updatedStatement
|
129
|
+
}));
|
130
|
+
};
|
131
|
+
var onConnectorOperatorChange = function onConnectorOperatorChange(op) {
|
132
|
+
onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, group), {}, {
|
133
|
+
groupOperator: op
|
134
|
+
}));
|
135
|
+
};
|
136
|
+
var getSentenceVariant = function getSentenceVariant() {
|
137
|
+
var _group$conditions;
|
84
138
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
85
|
-
|
86
|
-
},
|
87
|
-
className: "".concat(DataConfigs.blockClass, "
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
139
|
+
className: "".concat(className, " eachGroup")
|
140
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
141
|
+
className: "".concat(DataConfigs.blockClass, "__condition-wrapper"),
|
142
|
+
role: "grid",
|
143
|
+
"aria-label": DataConfigs.translateWithId('condition_builder_group')
|
144
|
+
}, group === null || group === void 0 || (_group$conditions = group.conditions) === null || _group$conditions === void 0 ? void 0 : _group$conditions.map(function (eachCondition, conditionIndex) {
|
145
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
146
|
+
key: eachCondition.id,
|
147
|
+
className: "".concat(DataConfigs.blockClass, "__group-wrapper")
|
148
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBlock["default"], {
|
149
|
+
conjunction: conditionIndex > 0 ? group.groupOperator : undefined,
|
150
|
+
aria: {
|
151
|
+
level: aria.level + 1,
|
152
|
+
posinset: conditionIndex + 1,
|
153
|
+
setsize: group.conditions.length
|
154
|
+
},
|
155
|
+
isStatement: conditionIndex == 0,
|
156
|
+
condition: eachCondition,
|
157
|
+
group: group,
|
158
|
+
conditionIndex: conditionIndex,
|
159
|
+
onChange: function onChange(updatedConditions) {
|
160
|
+
onChangeHandler(updatedConditions, conditionIndex);
|
161
|
+
},
|
162
|
+
addConditionHandler: addConditionHandler,
|
163
|
+
onRemove: function onRemove(e) {
|
164
|
+
onRemoveHandler(eachCondition.id, e);
|
165
|
+
},
|
166
|
+
onConnectorOperatorChange: onConnectorOperatorChange,
|
167
|
+
onStatementChange: onStatementChangeHandler,
|
168
|
+
isLastCondition: isLastCondition
|
169
|
+
}));
|
170
|
+
})));
|
171
|
+
};
|
172
|
+
var getTreeVariant = function getTreeVariant() {
|
173
|
+
var _group$conditions2;
|
174
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
175
|
+
className: "".concat(className, " ").concat(DataConfigs.blockClass, "__condition-wrapper"),
|
176
|
+
role: aria.level === 1 ? 'rowgroup' : undefined,
|
177
|
+
"aria-label": aria.level == 1 ? DataConfigs.translateWithId('condition_builder_group') : undefined
|
178
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
179
|
+
tabIndex: 0,
|
180
|
+
role: "row",
|
181
|
+
"aria-level": aria.level,
|
182
|
+
"aria-posinset": aria.posinset,
|
183
|
+
"aria-setsize": aria.setsize
|
184
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
185
|
+
label: group.statement,
|
186
|
+
title: DataConfigs.translateWithId('condition'),
|
187
|
+
"data-name": "connectorField",
|
188
|
+
popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
|
189
|
+
className: "".concat(DataConfigs.blockClass, "__statement-button")
|
190
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItemOption.ConditionBuilderItemOption, {
|
191
|
+
conditionState: {
|
192
|
+
value: group.statement,
|
193
|
+
label: DataConfigs.translateWithId('condition')
|
124
194
|
},
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
}));
|
195
|
+
onChange: function onChange(v, evt) {
|
196
|
+
util.focusThisField(evt);
|
197
|
+
onStatementChangeHandler(v);
|
129
198
|
},
|
130
|
-
|
199
|
+
config: {
|
200
|
+
options: DataConfigs.statementConfig
|
201
|
+
}
|
202
|
+
}))), group === null || group === void 0 || (_group$conditions2 = group.conditions) === null || _group$conditions2 === void 0 ? void 0 : _group$conditions2.map(function (eachCondition, conditionIndex) {
|
203
|
+
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, {
|
204
|
+
key: eachCondition.id
|
205
|
+
}, eachCondition.conditions ? /*#__PURE__*/React__default["default"].createElement("div", {
|
206
|
+
className: cx__default["default"]("".concat(DataConfigs.blockClass, "__condition-block subgroup ").concat(DataConfigs.blockClass, "__gap"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__gap-bottom"), group.conditions.length < conditionIndex + 1))
|
207
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionConnector["default"], {
|
208
|
+
className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__groupConnector"),
|
209
|
+
operator: group.groupOperator,
|
210
|
+
"aria-hidden": true
|
211
|
+
}), /*#__PURE__*/React__default["default"].createElement(ConditionGroupBuilder, {
|
212
|
+
aria: {
|
213
|
+
level: aria.level + 1,
|
214
|
+
posinset: conditionIndex + 1,
|
215
|
+
setsize: group.conditions.length
|
216
|
+
},
|
217
|
+
className: "".concat(DataConfigs.blockClass, "__group"),
|
218
|
+
group: eachCondition,
|
219
|
+
onChange: function onChange(updatedConditions) {
|
220
|
+
onChangeHandler(updatedConditions, conditionIndex);
|
221
|
+
},
|
222
|
+
onRemove: function onRemove(e) {
|
223
|
+
onRemoveHandler(eachCondition.id, e);
|
224
|
+
},
|
225
|
+
conditionBuilderRef: conditionBuilderRef
|
226
|
+
})) : /*#__PURE__*/React__default["default"].createElement(ConditionBlock["default"], {
|
227
|
+
conjunction: conditionIndex > 0 ? group.groupOperator : undefined,
|
228
|
+
aria: {
|
229
|
+
level: aria.level + 1,
|
230
|
+
posinset: conditionIndex + 1,
|
231
|
+
setsize: group.conditions.length
|
232
|
+
},
|
233
|
+
isStatement: false,
|
234
|
+
condition: eachCondition,
|
235
|
+
group: group,
|
236
|
+
conditionIndex: conditionIndex,
|
237
|
+
addConditionHandler: addConditionHandler,
|
238
|
+
addConditionSubGroupHandler: addConditionSubGroupHandler,
|
239
|
+
onChange: function onChange(updatedConditions) {
|
240
|
+
onChangeHandler(updatedConditions, conditionIndex);
|
241
|
+
},
|
242
|
+
onRemove: function onRemove(e) {
|
243
|
+
onRemoveHandler(eachCondition.id, e);
|
244
|
+
},
|
245
|
+
onConnectorOperatorChange: onConnectorOperatorChange,
|
246
|
+
onStatementChange: onStatementChangeHandler,
|
247
|
+
showConditionSubGroupPreviewHandler: function showConditionSubGroupPreviewHandler() {
|
248
|
+
_showConditionSubGroupPreviewHandler(conditionIndex);
|
249
|
+
},
|
250
|
+
hideConditionSubGroupPreviewHandler: hideConditionSubGroupPreviewHandler,
|
251
|
+
showConditionPreviewHandler: function showConditionPreviewHandler() {
|
252
|
+
_showConditionPreviewHandler(conditionIndex);
|
253
|
+
},
|
254
|
+
hideConditionPreviewHandler: hideConditionPreviewHandler,
|
255
|
+
isLastCondition: isLastCondition
|
256
|
+
}), conditionIndex == showConditionSubGroupPreview && (_ConditionPreview || (_ConditionPreview = /*#__PURE__*/React__default["default"].createElement(ConditionPreview["default"], {
|
257
|
+
previewType: "subGroup"
|
258
|
+
}))), conditionIndex == showConditionPreview && (_ConditionPreview2 || (_ConditionPreview2 = /*#__PURE__*/React__default["default"].createElement(ConditionPreview["default"], {
|
259
|
+
previewType: "condition"
|
260
|
+
}))));
|
131
261
|
}));
|
132
|
-
}
|
262
|
+
};
|
263
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, variant == 'tree' && getTreeVariant(), variant == 'sentence' && getSentenceVariant());
|
133
264
|
};
|
134
265
|
var ConditionGroupBuilder$1 = ConditionGroupBuilder;
|
135
266
|
ConditionGroupBuilder.propTypes = {
|
@@ -138,19 +269,19 @@ ConditionGroupBuilder.propTypes = {
|
|
138
269
|
*/
|
139
270
|
aria: index["default"].object,
|
140
271
|
/**
|
141
|
-
*
|
272
|
+
* state defines the current group
|
273
|
+
*/
|
274
|
+
/**
|
275
|
+
* Provide an optional class to be applied to the containing node.
|
142
276
|
*/
|
143
277
|
className: index["default"].string,
|
144
278
|
/**
|
279
|
+
className: PropTypes.string,
|
145
280
|
* ref of condition builder
|
146
281
|
*/
|
147
282
|
conditionBuilderRef: index["default"].object,
|
148
|
-
/**
|
149
|
-
* group defines the current group
|
150
|
-
*/
|
151
283
|
group: index["default"].object,
|
152
284
|
/**
|
153
|
-
|
154
285
|
* callback to update the current condition of the state tree
|
155
286
|
*/
|
156
287
|
onChange: index["default"].func,
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export default ConditionPreview;
|
2
|
+
declare function ConditionPreview({ previewType }: {
|
3
|
+
previewType: any;
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
5
|
+
declare namespace ConditionPreview {
|
6
|
+
namespace propTypes {
|
7
|
+
let previewType: PropTypes.Requireable<string>;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
import PropTypes from 'prop-types';
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2024
|
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
|
+
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
11
|
+
|
12
|
+
var React = require('react');
|
13
|
+
var index = require('../../../node_modules/prop-types/index.js');
|
14
|
+
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
15
|
+
var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
|
16
|
+
var ConditionConnector = require('../ConditionBuilderConnector/ConditionConnector.js');
|
17
|
+
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
19
|
+
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
21
|
+
|
22
|
+
var ConditionPreview = function ConditionPreview(_ref) {
|
23
|
+
var previewType = _ref.previewType;
|
24
|
+
var getConditionSection = function getConditionSection() {
|
25
|
+
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
26
|
+
label: DataConfigs.translateWithId('property')
|
27
|
+
}), /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
28
|
+
label: DataConfigs.translateWithId('operator')
|
29
|
+
}), /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
30
|
+
label: DataConfigs.translateWithId('value')
|
31
|
+
}));
|
32
|
+
};
|
33
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, previewType == 'newGroup' && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
34
|
+
className: "".concat(DataConfigs.blockClass, "__group__row ").concat(DataConfigs.blockClass, "__group-preview ")
|
35
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
36
|
+
className: "".concat(DataConfigs.blockClass, "__statement-button"),
|
37
|
+
label: DataConfigs.translateWithId('and')
|
38
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
39
|
+
"aria-hidden": true,
|
40
|
+
className: "".concat(DataConfigs.blockClass, "__group ").concat(DataConfigs.blockClass, "__condition-wrapper ").concat(DataConfigs.blockClass, "__group-preview ").concat(DataConfigs.blockClass, "__group-wrapper")
|
41
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
42
|
+
className: "".concat(DataConfigs.blockClass, "__gap")
|
43
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
44
|
+
className: "".concat(DataConfigs.blockClass, "__statement-button"),
|
45
|
+
label: DataConfigs.translateWithId('if')
|
46
|
+
})), getConditionSection())), previewType == 'subGroup' && /*#__PURE__*/React__default["default"].createElement("div", {
|
47
|
+
className: "".concat(DataConfigs.blockClass, "__group-preview")
|
48
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
49
|
+
className: "".concat(DataConfigs.blockClass, "__condition-block ").concat(DataConfigs.blockClass, "__gap")
|
50
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
51
|
+
label: DataConfigs.translateWithId('and'),
|
52
|
+
className: "".concat(DataConfigs.blockClass, "__statement-button"),
|
53
|
+
popOverClassName: "".concat(DataConfigs.blockClass, "__gap")
|
54
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
55
|
+
className: "".concat(DataConfigs.blockClass, "__group ").concat(DataConfigs.blockClass, "__condition-wrapper")
|
56
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionConnector["default"], {
|
57
|
+
className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__groupConnector"),
|
58
|
+
operator: DataConfigs.translateWithId('if')
|
59
|
+
}), getConditionSection()))), previewType == 'condition' && /*#__PURE__*/React__default["default"].createElement("div", {
|
60
|
+
className: "".concat(DataConfigs.blockClass, "__group-preview")
|
61
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
62
|
+
className: "".concat(DataConfigs.blockClass, "__condition-block ").concat(DataConfigs.blockClass, "__gap")
|
63
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
64
|
+
label: DataConfigs.translateWithId('and'),
|
65
|
+
className: "".concat(DataConfigs.blockClass, "__statement-button"),
|
66
|
+
popOverClassName: "".concat(DataConfigs.blockClass, "__gap")
|
67
|
+
}), getConditionSection())));
|
68
|
+
};
|
69
|
+
var ConditionPreview$1 = ConditionPreview;
|
70
|
+
ConditionPreview.propTypes = {
|
71
|
+
/**
|
72
|
+
* type of review to be displayed
|
73
|
+
*/
|
74
|
+
previewType: index["default"].oneOf(['condition', 'subGroup', 'newGroup'])
|
75
|
+
};
|
76
|
+
|
77
|
+
exports["default"] = ConditionPreview$1;
|
@@ -2,3 +2,4 @@ export function focusThisField(evt: any): void;
|
|
2
2
|
export function focusThisItem(currentElement: any): void;
|
3
3
|
export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
|
4
4
|
export function traverseReverse(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
|
5
|
+
export function checkForHoldingKey(evt: any, key: any): any;
|
@@ -194,7 +194,7 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
194
194
|
headerProps = _rollupPluginBabelHelpers["extends"]({}, (_rollupPluginBabelHelpers.objectDestructuringEmpty(_header$getHeaderProp), _header$getHeaderProp));
|
195
195
|
var resizerProps = header === null || header === void 0 || (_header$getResizerPro = header.getResizerProps) === null || _header$getResizerPro === void 0 ? void 0 : _header$getResizerPro.call(header);
|
196
196
|
return /*#__PURE__*/React__default["default"].createElement(react.TableHeader, _rollupPluginBabelHelpers["extends"]({}, headerProps, {
|
197
|
-
className: cx__default["default"](header === null || header === void 0 ? void 0 : header.className, _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__resizableColumn"), resizerProps), "".concat(blockClass, "__isResizing"), header === null || header === void 0 ? void 0 : header.isResizing), "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable && header.id !== 'spacer'), "".concat(blockClass, "__isSorted"), header === null || header === void 0 ? void 0 : header.isSorted), "".concat(blockClass, "__header-actions-column"), header === null || header === void 0 ? void 0 : header.isAction), "".concat(blockClass, "__with-slug"), header.slug && /*#__PURE__*/React__default["default"].isValidElement(header === null || header === void 0 ? void 0 : header.slug))),
|
197
|
+
className: cx__default["default"](header === null || header === void 0 ? void 0 : header.className, _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__resizableColumn"), resizerProps), "".concat(blockClass, "__isResizing"), header === null || header === void 0 ? void 0 : header.isResizing), "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable && header.id !== 'spacer'), "".concat(blockClass, "__isSorted"), header === null || header === void 0 ? void 0 : header.isSorted), "".concat(blockClass, "__header-actions-column"), header === null || header === void 0 ? void 0 : header.isAction), "".concat(blockClass, "__with-slug"), header.slug && /*#__PURE__*/React__default["default"].isValidElement(header === null || header === void 0 ? void 0 : header.slug)), headerProps.className),
|
198
198
|
key: header.id,
|
199
199
|
"aria-hidden": header.id === 'spacer' && 'true'
|
200
200
|
}, getAccessibilityProps(header)), header.render('Header'), renderSlug(header.slug), resizerProps && !header.isAction && /*#__PURE__*/React__default["default"].createElement(ResizeHeader, {
|
package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js
CHANGED
@@ -82,7 +82,7 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
82
82
|
};
|
83
83
|
var onCheckboxCheck = function onCheckboxCheck(col, value) {
|
84
84
|
var changedDefinitions = columnObjects.map(function (definition) {
|
85
|
-
if (Array.isArray(col) && col.indexOf(definition) != -1 || definition.id === col.id) {
|
85
|
+
if ((Array.isArray(col) && col.indexOf(definition) != -1 || definition.id === col.id) && definition.canFilter && !definition.disabled) {
|
86
86
|
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, definition), {}, {
|
87
87
|
isVisible: value
|
88
88
|
});
|
@@ -106,9 +106,12 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
106
106
|
React.useEffect(function () {
|
107
107
|
var notFilterableCount = columnObjects.filter(function (col) {
|
108
108
|
return !col.canFilter;
|
109
|
-
});
|
110
|
-
|
111
|
-
|
109
|
+
}).length;
|
110
|
+
var actionCount = columnObjects.filter(function (col) {
|
111
|
+
return col.id === 'actions';
|
112
|
+
}).length;
|
113
|
+
setVisibleColumnsCount(getVisibleColumnsCount() - notFilterableCount - actionCount);
|
114
|
+
setTotalColumns(columnObjects.length - notFilterableCount - actionCount);
|
112
115
|
}, [getVisibleColumnsCount, columnObjects]);
|
113
116
|
return /*#__PURE__*/React__default["default"].createElement(TearsheetNarrow.TearsheetNarrow, {
|
114
117
|
className: "".concat(blockClass, "__customize-columns-tearsheet"),
|
@@ -1,2 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2023, 2024
|
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
|
+
declare const useFilterContext: () => any;
|
1
8
|
export default useFilterContext;
|
2
|
-
declare function useFilterContext(): any;
|
package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts
CHANGED
@@ -20,6 +20,7 @@ export namespace InlineEditCell {
|
|
20
20
|
rows: PropTypes.Requireable<(object | null | undefined)[]>;
|
21
21
|
rowSize: PropTypes.Requireable<string>;
|
22
22
|
tableId: PropTypes.Requireable<string>;
|
23
|
+
cellEditing: PropTypes.Requireable<object>;
|
23
24
|
}>>;
|
24
25
|
let nonEditCell: PropTypes.Requireable<boolean>;
|
25
26
|
let placeholder: PropTypes.Requireable<string>;
|
@@ -45,7 +45,8 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
45
45
|
var columnIndex = instance.columns.findIndex(function (col) {
|
46
46
|
return col.id === columnId;
|
47
47
|
});
|
48
|
-
var
|
48
|
+
var rowIndex = cell.row.index;
|
49
|
+
var cellId = "column-".concat(columnIndex, "-row-").concat(rowIndex);
|
49
50
|
var _useContext = React.useContext(InlineEditContext.InlineEditContext),
|
50
51
|
state = _useContext.state,
|
51
52
|
dispatch = _useContext.dispatch;
|
@@ -81,6 +82,14 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
81
82
|
var rowSize = instance.rowSize,
|
82
83
|
onDataUpdate = instance.onDataUpdate;
|
83
84
|
var saveCellData;
|
85
|
+
if (inEditMode) {
|
86
|
+
instance.cellEditing = {
|
87
|
+
cellId: cellId,
|
88
|
+
columnIndex: columnIndex,
|
89
|
+
rowIndex: rowIndex,
|
90
|
+
curCellValue: cellValue
|
91
|
+
};
|
92
|
+
}
|
84
93
|
React.useEffect(function () {
|
85
94
|
setInitialValue(value);
|
86
95
|
var columnId = cell.column.id;
|
@@ -454,7 +463,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
454
463
|
"data-inline-type": type,
|
455
464
|
onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
|
456
465
|
onKeyDown: !nonEditCell ? handleKeyDown : null,
|
457
|
-
className: cx__default["default"]("".concat(blockClass, "__inline-edit--outer-cell-button"), _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__inline-edit--outer-cell-button--").concat(rowSize), rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--lg"), !rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--invalid"), config === null || config === void 0 || (_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, cellValue)), "".concat(blockClass, "__static--outer-cell"), !disabledCell))
|
466
|
+
className: cx__default["default"]("".concat(blockClass, "__inline-edit--outer-cell-button"), _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__inline-edit--outer-cell-button--").concat(rowSize), rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--lg"), !rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--invalid"), inEditMode && (config === null || config === void 0 || (_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, cellValue))), "".concat(blockClass, "__static--outer-cell"), !disabledCell))
|
458
467
|
}, !nonEditCell && !disabledCell && renderRegularCell(), (!inEditMode || disabledCell) && /*#__PURE__*/React__default["default"].createElement(InlineEditButton.InlineEditButton, {
|
459
468
|
isActiveCell: cellId === activeCellId,
|
460
469
|
renderIcon: setRenderIcon(),
|
@@ -478,7 +487,8 @@ InlineEditCell.propTypes = {
|
|
478
487
|
onDataUpdate: index["default"].func,
|
479
488
|
rows: index["default"].arrayOf(index["default"].object),
|
480
489
|
rowSize: index["default"].string,
|
481
|
-
tableId: index["default"].string
|
490
|
+
tableId: index["default"].string,
|
491
|
+
cellEditing: index["default"].object
|
482
492
|
}),
|
483
493
|
nonEditCell: index["default"].bool,
|
484
494
|
placeholder: index["default"].string,
|
@@ -192,6 +192,8 @@ export interface DataGridState<T extends object = any> extends TableCommonProps,
|
|
192
192
|
onVirtualScroll?: (evt?: boolean) => void;
|
193
193
|
fetchMoreData?: () => void;
|
194
194
|
loadMoreThreshold?: number;
|
195
|
+
onRowClick?: (row: any, event: any) => void;
|
196
|
+
onSort?: boolean;
|
195
197
|
}
|
196
198
|
export interface ResizeHeaderProps {
|
197
199
|
resizerProps?: ResizerProps;
|
@@ -1,2 +1,8 @@
|
|
1
|
-
|
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
|
+
*/
|
2
7
|
import { useColumnOrder } from 'react-table';
|
8
|
+
export default useColumnOrder;
|
@@ -23,6 +23,23 @@ var blockClass = "".concat(settings.pkg.prefix, "--datagrid");
|
|
23
23
|
var useNestedRows = function useNestedRows(hooks) {
|
24
24
|
useNestedRowExpander["default"](hooks);
|
25
25
|
var useInstance = function useInstance(instance) {
|
26
|
+
React.useEffect(function () {
|
27
|
+
var rows = instance.rows;
|
28
|
+
var defaultExpandedRows = rows.filter(function (row) {
|
29
|
+
var _row$original;
|
30
|
+
return row === null || row === void 0 || (_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.defaultExpanded;
|
31
|
+
});
|
32
|
+
if (defaultExpandedRows !== null && defaultExpandedRows !== void 0 && defaultExpandedRows.length) {
|
33
|
+
defaultExpandedRows.map(function (defaultExpandedRow) {
|
34
|
+
if (!defaultExpandedRow.isExpanded && !defaultExpandedRow.hasExpanded) {
|
35
|
+
var _defaultExpandedRow$t;
|
36
|
+
defaultExpandedRow === null || defaultExpandedRow === void 0 || (_defaultExpandedRow$t = defaultExpandedRow.toggleRowExpanded) === null || _defaultExpandedRow$t === void 0 || _defaultExpandedRow$t.call(defaultExpandedRow);
|
37
|
+
defaultExpandedRow.hasExpanded = true;
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
42
|
+
}, [instance, instance.rows]);
|
26
43
|
// This useEffect will expand rows if they exist in the initialState obj
|
27
44
|
React.useEffect(function () {
|
28
45
|
var rows = instance.rows,
|
@@ -54,16 +71,21 @@ var useNestedRows = function useNestedRows(hooks) {
|
|
54
71
|
}
|
55
72
|
}];
|
56
73
|
};
|
74
|
+
var getIndentation = function getIndentation(depth) {
|
75
|
+
return 32 * depth + 16;
|
76
|
+
}; // row indentation padding
|
57
77
|
var getCellProps = function getCellProps(props, _ref3) {
|
58
78
|
var cell = _ref3.cell,
|
59
79
|
instance = _ref3.instance;
|
60
|
-
//
|
80
|
+
// we add a dynamic -ve margin right only if the cell is resized below minimum width i.e 50px, else we set the width based on indentation at different levels
|
61
81
|
var isFirstCell = instance.columns.findIndex(function (c) {
|
62
82
|
return c.id === cell.column.id;
|
63
83
|
}) === 0;
|
64
84
|
return [props, {
|
65
85
|
style: {
|
66
|
-
marginRight:
|
86
|
+
marginRight: isFirstCell && cell.row.depth > 0 && parseInt(props.style.width, 10) <= getIndentation(cell.row.depth) + 50 // indentation padding + expander cell or empty cell width
|
87
|
+
? "".concat(parseInt(props.style.width, 10) - (getIndentation(cell.row.depth) + 50), "px") : '',
|
88
|
+
width: isFirstCell && cell.row.depth > 0 ? parseInt(props.style.width, 10) - getIndentation(cell.row.depth) : props.style.width
|
67
89
|
}
|
68
90
|
}];
|
69
91
|
};
|
@@ -1,2 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 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 { Hooks } from 'react-table';
|
8
|
+
declare const useOnRowClick: (hooks: Hooks) => void;
|
1
9
|
export default useOnRowClick;
|
2
|
-
declare function useOnRowClick(hooks: any): void;
|
@@ -13,7 +13,8 @@ var settings = require('../../settings.js');
|
|
13
13
|
|
14
14
|
var useOnRowClick = function useOnRowClick(hooks) {
|
15
15
|
var useInstance = function useInstance(rowInstance) {
|
16
|
-
var
|
16
|
+
var _ref = rowInstance,
|
17
|
+
onRowClick = _ref.onRowClick;
|
17
18
|
var getRowProps = function getRowProps(props, datagridState) {
|
18
19
|
var isFetching = datagridState.isFetching,
|
19
20
|
row = datagridState.row,
|
@@ -25,7 +25,7 @@ var useRowIsMouseOver = function useRowIsMouseOver(hooks) {
|
|
25
25
|
setMouseOverRowIndex = _useState2[1];
|
26
26
|
var onMouseChange = useDebounce(function (datagridState) {
|
27
27
|
var row = datagridState.row;
|
28
|
-
setMouseOverRowIndex(row.index);
|
28
|
+
setMouseOverRowIndex(row === null || row === void 0 ? void 0 : row.index);
|
29
29
|
}, 100);
|
30
30
|
var getRowProps = function getRowProps(props, datagridState) {
|
31
31
|
var onMouseOver = function onMouseOver() {
|