@carbon/ibm-products 2.43.2-canary.56 → 2.43.2-canary.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +16 -13
- package/es/components/ConditionBuilder/ConditionBuilder.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +5 -3
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +1 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +1 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +33 -15
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.d.ts +3 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +16 -6
- package/es/components/Datagrid/types/index.d.ts +9 -6
- package/es/components/Datagrid/useStickyColumn.d.ts +8 -1
- package/es/components/Datagrid/useStickyColumn.js +12 -9
- package/es/components/Tearsheet/TearsheetShell.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +16 -13
- package/lib/components/ConditionBuilder/ConditionBuilder.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +5 -3
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +1 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +1 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +33 -15
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.d.ts +3 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +16 -6
- package/lib/components/Datagrid/types/index.d.ts +9 -6
- package/lib/components/Datagrid/useStickyColumn.d.ts +8 -1
- package/lib/components/Datagrid/useStickyColumn.js +12 -9
- package/lib/components/Tearsheet/TearsheetShell.js +2 -2
- package/package.json +3 -3
@@ -139,11 +139,23 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
139
139
|
'aria-setsize': aria.setsize
|
140
140
|
} : {};
|
141
141
|
};
|
142
|
+
var renderChildren = function renderChildren(popoverRef) {
|
143
|
+
return /*#__PURE__*/React__default.createElement(ItemComponent, {
|
144
|
+
conditionState: {
|
145
|
+
property: property,
|
146
|
+
operator: operator,
|
147
|
+
value: value
|
148
|
+
},
|
149
|
+
onChange: onValueChangeHandler,
|
150
|
+
config: config,
|
151
|
+
"data-name": "valueField",
|
152
|
+
parentRef: popoverRef
|
153
|
+
});
|
154
|
+
};
|
142
155
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
143
156
|
className: cx("".concat(blockClass, "__condition-block"), _defineProperty({}, "".concat(blockClass, "__condition__deletion-preview"), showDeletionPreview), _defineProperty({}, "".concat(blockClass, "__gap-bottom"), variant == 'tree' && !(conditionIndex + 1 >= group.conditions.length)), _defineProperty({}, "".concat(blockClass, "__gap ").concat(blockClass, "__gap-bottom"), variant == 'sentence')),
|
144
157
|
role: "row",
|
145
|
-
"aria-label": conditionRowText
|
146
|
-
tabIndex: -1
|
158
|
+
"aria-label": conditionRowText
|
147
159
|
}, getAriaAttributes()), conjunction ? /*#__PURE__*/React__default.createElement(ConditionConnector, {
|
148
160
|
className: "".concat(blockClass, "__gap"),
|
149
161
|
operator: conjunction,
|
@@ -206,18 +218,9 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
206
218
|
showToolTip: true,
|
207
219
|
"data-name": "valueField",
|
208
220
|
condition: condition,
|
209
|
-
config: config
|
210
|
-
}, /*#__PURE__*/React__default.createElement(ItemComponent, {
|
211
|
-
conditionState: {
|
212
|
-
property: property,
|
213
|
-
operator: operator,
|
214
|
-
value: value
|
215
|
-
},
|
216
|
-
onChange: onValueChangeHandler,
|
217
221
|
config: config,
|
218
|
-
|
219
|
-
|
220
|
-
})), /*#__PURE__*/React__default.createElement("span", {
|
222
|
+
renderChildren: renderChildren
|
223
|
+
}), /*#__PURE__*/React__default.createElement("span", {
|
221
224
|
role: "gridcell",
|
222
225
|
"aria-label": removeConditionText
|
223
226
|
}, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, {
|
@@ -202,7 +202,7 @@ ConditionBuilder.propTypes = {
|
|
202
202
|
/**
|
203
203
|
* Optional prop, if you need to pass translations to the texts on the component instead of the defined defaults.
|
204
204
|
* This callback function will receive the message id and you need to return the corresponding text for that id.
|
205
|
-
* The message id will be one of [ "ifText","addConditionText", "addConditionGroupText", "addSubgroupText", "conditionText", "propertyText", "operatorText", "valueText", "connectorText", "conditionRowText", "removeConditionText", "addConditionRowText", "startText", "endText", "clearSearchText", "actionsText", "then", "removeActionText", "addActionText", "invalidText",
|
205
|
+
* The message id will be one of [ "ifText","addConditionText", "addConditionGroupText", "addSubgroupText", "conditionText", "propertyText", "operatorText", "valueText", "connectorText", "conditionRowText", "removeConditionText", "addConditionRowText", "startText", "endText", "clearSearchText", "actionsText", "then", "removeActionText", "addActionText", "invalidText", "invalidDateText", "invalidNumberWarnText"]
|
206
206
|
]
|
207
207
|
*/
|
208
208
|
translateWithId: PropTypes.func,
|
@@ -106,11 +106,13 @@ var valueRenderers = {
|
|
106
106
|
},
|
107
107
|
date: function date(value) {
|
108
108
|
if (Array.isArray(value) && value.length > 1) {
|
109
|
-
var start = value !== null && value !== void 0 && value[0] ? formatDate(new Date(value[0])) : '';
|
110
|
-
var end = value !== null && value !== void 0 && value[1] ? formatDate(new Date(value[1])) : '';
|
109
|
+
var start = value !== null && value !== void 0 && value[0] && !isNaN(new Date(value[0])) ? formatDate(new Date(value[0])) : '';
|
110
|
+
var end = value !== null && value !== void 0 && value[1] && !isNaN(new Date(value[1])) ? formatDate(new Date(value[1])) : '';
|
111
111
|
return "".concat(start, " To ").concat(end);
|
112
|
+
} else if (Array.isArray(value) && !isNaN(new Date(value[0]))) {
|
113
|
+
return formatDate(new Date(value[0]));
|
112
114
|
} else {
|
113
|
-
return value
|
115
|
+
return value;
|
114
116
|
}
|
115
117
|
},
|
116
118
|
custom: function custom(value) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export function ConditionBuilderItem({ children, className, label, renderIcon, title, type, showToolTip, condition, popOverClassName, config, ...rest }: {
|
1
|
+
export function ConditionBuilderItem({ children, className, label, renderIcon, title, type, showToolTip, condition, popOverClassName, config, renderChildren, ...rest }: {
|
2
2
|
[x: string]: any;
|
3
3
|
children: any;
|
4
4
|
className: any;
|
@@ -10,6 +10,7 @@ export function ConditionBuilderItem({ children, className, label, renderIcon, t
|
|
10
10
|
condition: any;
|
11
11
|
popOverClassName: any;
|
12
12
|
config: any;
|
13
|
+
renderChildren: any;
|
13
14
|
}): import("react/jsx-runtime").JSX.Element;
|
14
15
|
export namespace ConditionBuilderItem {
|
15
16
|
namespace propTypes {
|
@@ -19,6 +20,7 @@ export namespace ConditionBuilderItem {
|
|
19
20
|
let config: PropTypes.Requireable<object>;
|
20
21
|
let label: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
21
22
|
let popOverClassName: PropTypes.Requireable<string>;
|
23
|
+
let renderChildren: PropTypes.Requireable<(...args: any[]) => any>;
|
22
24
|
let renderIcon: PropTypes.Requireable<object>;
|
23
25
|
let showToolTip: PropTypes.Requireable<boolean>;
|
24
26
|
let title: PropTypes.Requireable<string>;
|
@@ -14,7 +14,7 @@ import { blockClass, valueRenderers } from '../ConditionBuilderContext/DataConfi
|
|
14
14
|
import { ConditionBuilderButton } from '../ConditionBuilderButton/ConditionBuilderButton.js';
|
15
15
|
import { useTranslations } from '../utils/useTranslations.js';
|
16
16
|
|
17
|
-
var _excluded = ["children", "className", "label", "renderIcon", "title", "type", "showToolTip", "condition", "popOverClassName", "config"];
|
17
|
+
var _excluded = ["children", "className", "label", "renderIcon", "title", "type", "showToolTip", "condition", "popOverClassName", "config", "renderChildren"];
|
18
18
|
var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
19
19
|
var children = _ref.children,
|
20
20
|
className = _ref.className,
|
@@ -26,23 +26,31 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
26
26
|
condition = _ref.condition,
|
27
27
|
popOverClassName = _ref.popOverClassName,
|
28
28
|
config = _ref.config,
|
29
|
+
renderChildren = _ref.renderChildren,
|
29
30
|
rest = _objectWithoutProperties(_ref, _excluded);
|
30
31
|
var contentRef = useRef(null);
|
32
|
+
var popoverRef = useRef(null);
|
31
33
|
var _useState = useState(false),
|
32
34
|
_useState2 = _slicedToArray(_useState, 2),
|
33
35
|
open = _useState2[0],
|
34
36
|
setOpen = _useState2[1];
|
35
|
-
var _useTranslations = useTranslations(['invalidText', 'addConditionText', label]),
|
36
|
-
_useTranslations2 = _slicedToArray(_useTranslations,
|
37
|
+
var _useTranslations = useTranslations(['invalidText', 'addConditionText', label, 'invalidDateText']),
|
38
|
+
_useTranslations2 = _slicedToArray(_useTranslations, 4),
|
37
39
|
invalidText = _useTranslations2[0],
|
38
40
|
addConditionText = _useTranslations2[1],
|
39
|
-
labelText = _useTranslations2[2]
|
41
|
+
labelText = _useTranslations2[2],
|
42
|
+
invalidDateText = _useTranslations2[3];
|
40
43
|
var getPropertyDetails = function getPropertyDetails() {
|
41
44
|
if (label === 'INVALID') {
|
42
45
|
return {
|
43
46
|
propertyLabel: invalidText,
|
44
47
|
isInvalid: true
|
45
48
|
};
|
49
|
+
} else if (label === 'INVALID_DATE') {
|
50
|
+
return {
|
51
|
+
propertyLabel: invalidDateText,
|
52
|
+
isInvalid: true
|
53
|
+
};
|
46
54
|
}
|
47
55
|
var propertyId = rest['data-name'] == 'valueField' && type ? valueRenderers[type](label, config) : labelText;
|
48
56
|
return {
|
@@ -63,19 +71,19 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
63
71
|
//if any condition is changed, state prop is triggered
|
64
72
|
if (condition.popoverToOpen && currentField !== condition.popoverToOpen) {
|
65
73
|
// close the previous popover
|
66
|
-
|
74
|
+
closePopover();
|
67
75
|
} else if (currentField == 'valueField' && type == 'option' && condition.operator !== 'oneOf') {
|
68
76
|
//close the current popover if the field is valueField and is a single select dropdown. For all other inputs ,popover need to be open on value changes.
|
69
|
-
|
77
|
+
closePopover();
|
70
78
|
}
|
71
79
|
if (condition.popoverToOpen == currentField) {
|
72
80
|
//current popover need to be opened
|
73
|
-
|
81
|
+
openPopOver();
|
74
82
|
}
|
75
83
|
} else {
|
76
84
|
// when we change any statement(if/ excl.if) which is not part of condition state, label change is triggered.
|
77
85
|
//close popOver when statement is changed.
|
78
|
-
|
86
|
+
closePopover();
|
79
87
|
}
|
80
88
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
81
89
|
}, [condition, label]);
|
@@ -88,20 +96,26 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
88
96
|
}
|
89
97
|
}
|
90
98
|
}, [contentRef, open]);
|
99
|
+
var closePopover = function closePopover() {
|
100
|
+
return setOpen(false);
|
101
|
+
};
|
102
|
+
var openPopOver = function openPopOver() {
|
103
|
+
return setOpen(true);
|
104
|
+
};
|
105
|
+
var togglePopover = function togglePopover() {
|
106
|
+
return setOpen(!open);
|
107
|
+
};
|
91
108
|
return /*#__PURE__*/React__default.createElement(Popover, {
|
92
109
|
open: open,
|
93
110
|
isTabTip: true,
|
94
111
|
role: "gridcell",
|
95
112
|
className: popOverClassName,
|
96
|
-
|
97
|
-
|
98
|
-
}
|
113
|
+
ref: popoverRef,
|
114
|
+
onRequestClose: closePopover
|
99
115
|
}, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, _extends({
|
100
116
|
label: propertyLabel !== null && propertyLabel !== void 0 ? propertyLabel : addConditionText,
|
101
117
|
hideLabel: !label ? true : false,
|
102
|
-
onClick:
|
103
|
-
children ? setOpen(!open) : null;
|
104
|
-
},
|
118
|
+
onClick: togglePopover,
|
105
119
|
className: className,
|
106
120
|
"aria-haspopup": true,
|
107
121
|
"aria-expanded": open,
|
@@ -118,7 +132,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
118
132
|
}, title), /*#__PURE__*/React__default.createElement("div", {
|
119
133
|
ref: contentRef,
|
120
134
|
className: "".concat(blockClass, "__popover-content")
|
121
|
-
}, children))));
|
135
|
+
}, renderChildren ? renderChildren(popoverRef) : children))));
|
122
136
|
};
|
123
137
|
ConditionBuilderItem.propTypes = {
|
124
138
|
/**
|
@@ -146,6 +160,10 @@ ConditionBuilderItem.propTypes = {
|
|
146
160
|
* class name for popover
|
147
161
|
*/
|
148
162
|
popOverClassName: PropTypes.string,
|
163
|
+
/**
|
164
|
+
* callback prop that returns the jsx for children
|
165
|
+
*/
|
166
|
+
renderChildren: PropTypes.func,
|
149
167
|
/**
|
150
168
|
* Optional prop to allow overriding the icon rendering.
|
151
169
|
*/
|
@@ -1,11 +1,13 @@
|
|
1
|
-
export function ConditionBuilderItemDate({ conditionState, onChange }: {
|
1
|
+
export function ConditionBuilderItemDate({ conditionState, onChange, parentRef, }: {
|
2
2
|
conditionState: any;
|
3
3
|
onChange: any;
|
4
|
+
parentRef: any;
|
4
5
|
}): import("react/jsx-runtime").JSX.Element;
|
5
6
|
export namespace ConditionBuilderItemDate {
|
6
7
|
namespace propTypes {
|
7
8
|
let conditionState: PropTypes.Requireable<object>;
|
8
9
|
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
10
|
+
let parentRef: PropTypes.Requireable<object>;
|
9
11
|
}
|
10
12
|
}
|
11
13
|
import PropTypes from 'prop-types';
|
@@ -15,21 +15,26 @@ import { useTranslations } from '../../utils/useTranslations.js';
|
|
15
15
|
var blockClass = "".concat(pkg.prefix, "--condition-builder");
|
16
16
|
var ConditionBuilderItemDate = function ConditionBuilderItemDate(_ref) {
|
17
17
|
var conditionState = _ref.conditionState,
|
18
|
-
onChange = _ref.onChange
|
18
|
+
onChange = _ref.onChange,
|
19
|
+
parentRef = _ref.parentRef;
|
19
20
|
var DatePickerInputRef = useRef();
|
20
21
|
var _useTranslations = useTranslations(['startText', 'endText']),
|
21
22
|
_useTranslations2 = _slicedToArray(_useTranslations, 2),
|
22
23
|
startText = _useTranslations2[0],
|
23
24
|
endText = _useTranslations2[1];
|
24
25
|
var datePickerType = conditionState.operator == 'between' ? 'range' : 'single';
|
26
|
+
var onCloseHandler = function onCloseHandler(selectedDate) {
|
27
|
+
onChange(selectedDate && selectedDate.length > 0 ? selectedDate : 'INVALID_DATE');
|
28
|
+
};
|
25
29
|
return /*#__PURE__*/React__default.createElement("div", {
|
26
30
|
className: "".concat(blockClass, "__item-date ")
|
27
31
|
}, datePickerType == 'single' && /*#__PURE__*/React__default.createElement(DatePicker, {
|
28
32
|
ref: DatePickerInputRef,
|
29
33
|
dateFormat: "d/m/Y",
|
30
34
|
datePickerType: "single",
|
31
|
-
|
32
|
-
|
35
|
+
value: conditionState.value,
|
36
|
+
onClose: onCloseHandler,
|
37
|
+
appendTo: parentRef === null || parentRef === void 0 ? void 0 : parentRef.current
|
33
38
|
}, /*#__PURE__*/React__default.createElement(DatePickerInput, {
|
34
39
|
id: "datePicker",
|
35
40
|
placeholder: "dd/mm/yyyy",
|
@@ -38,8 +43,9 @@ var ConditionBuilderItemDate = function ConditionBuilderItemDate(_ref) {
|
|
38
43
|
ref: DatePickerInputRef,
|
39
44
|
dateFormat: "d/m/Y",
|
40
45
|
datePickerType: datePickerType,
|
41
|
-
onClose:
|
42
|
-
value: conditionState.value
|
46
|
+
onClose: onCloseHandler,
|
47
|
+
value: conditionState.value,
|
48
|
+
appendTo: parentRef === null || parentRef === void 0 ? void 0 : parentRef.current
|
43
49
|
}, /*#__PURE__*/React__default.createElement(DatePickerInput, {
|
44
50
|
id: "datePickerStart",
|
45
51
|
placeholder: "dd/mm/yyyy",
|
@@ -58,7 +64,11 @@ ConditionBuilderItemDate.propTypes = {
|
|
58
64
|
/**
|
59
65
|
* callback to update state oin date change
|
60
66
|
*/
|
61
|
-
onChange: PropTypes.func
|
67
|
+
onChange: PropTypes.func,
|
68
|
+
/**
|
69
|
+
* reference to the popover node
|
70
|
+
*/
|
71
|
+
parentRef: PropTypes.object
|
62
72
|
};
|
63
73
|
|
64
74
|
export { ConditionBuilderItemDate };
|
@@ -6,7 +6,7 @@ import { RadioButtonGroupProps } from '@carbon/react/lib/components/RadioButtonG
|
|
6
6
|
import { CheckboxProps } from '@carbon/react/lib/components/Checkbox';
|
7
7
|
import { NumberInputProps } from '@carbon/react/lib/components/NumberInput/NumberInput';
|
8
8
|
import React, { CSSProperties, ComponentType, FunctionComponent, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
9
|
-
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
9
|
+
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsOptions, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
10
10
|
import { CarbonIconType } from '@carbon/react/icons';
|
11
11
|
import { IconButton, type ButtonProps } from '@carbon/react';
|
12
12
|
import { TableBatchActionsProps } from '@carbon/react/lib/components/DataTable/TableBatchActions';
|
@@ -97,7 +97,7 @@ export interface DataGridToggleAllRowsProps extends TableToggleAllRowsSelectedPr
|
|
97
97
|
}
|
98
98
|
export interface DatagridTableHooks<T extends object = any> extends UseTableHooks<T> {
|
99
99
|
}
|
100
|
-
export interface DatagridColumn<T extends object = any> extends ColumnInstance<T>, UseSortByOptions<T> {
|
100
|
+
export interface DatagridColumn<T extends object = any> extends ColumnInstance<T>, UseSortByOptions<T>, Partial<UseResizeColumnsColumnProps<T>>, UseResizeColumnsOptions<T> {
|
101
101
|
sticky?: 'left' | 'right';
|
102
102
|
className?: string;
|
103
103
|
rightAlignedColumn?: boolean;
|
@@ -124,15 +124,13 @@ export interface DataGridHeader<T extends object = any> extends ColumnInstance,
|
|
124
124
|
}
|
125
125
|
export interface DataGridHeaderGroup<T extends object = any> extends HeaderGroup<T>, UseResizeColumnsColumnProps<T> {
|
126
126
|
}
|
127
|
-
export interface
|
128
|
-
className?: string;
|
129
|
-
role?: string;
|
130
|
-
style?: CSSStyleDeclaration;
|
127
|
+
export interface DataGridTableProps extends TableCommonProps {
|
131
128
|
}
|
132
129
|
interface DataGridTableState extends UseResizeColumnsState<any>, UseRowSelectState<any> {
|
133
130
|
filters: Filters<DataGridFilter>;
|
134
131
|
}
|
135
132
|
export interface DataGridTableInstance<T extends object = any> extends TableInstance<T> {
|
133
|
+
withSelectRows?: boolean;
|
136
134
|
}
|
137
135
|
export interface RowAction {
|
138
136
|
id?: string;
|
@@ -234,6 +232,11 @@ export interface DataGridState<T extends object = any> extends TableCommonProps,
|
|
234
232
|
onRowExpand?: (row: DatagridRow, event: React.MouseEvent<HTMLElement>) => void;
|
235
233
|
ExpandedRowContentComponent?: JSXElementConstructor<any>;
|
236
234
|
}
|
235
|
+
export interface DataGridData {
|
236
|
+
instance?: DataGridTableInstance;
|
237
|
+
column?: DatagridColumn;
|
238
|
+
cell?: DataGridCell;
|
239
|
+
}
|
237
240
|
export interface ResizeHeaderProps {
|
238
241
|
resizerProps?: ResizerProps;
|
239
242
|
header: DataGridHeader;
|
@@ -1,2 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2021, 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 useStickyColumn: (hooks: Hooks) => void;
|
1
9
|
export default useStickyColumn;
|
2
|
-
declare function useStickyColumn(hooks: any): void;
|
@@ -18,12 +18,13 @@ var OFFSET_SCROLL_CLASS = "".concat(styleClassPrefix, "-offset-scroll");
|
|
18
18
|
var useStickyColumn = function useStickyColumn(hooks) {
|
19
19
|
var tableBodyRef = useRef();
|
20
20
|
var stickyHeaderCellRef = useRef();
|
21
|
-
var _useState = useState(
|
21
|
+
var _useState = useState(),
|
22
22
|
_useState2 = _slicedToArray(_useState, 2),
|
23
23
|
windowSize = _useState2[0],
|
24
24
|
setWindowSize = _useState2[1];
|
25
25
|
useEffect(function () {
|
26
|
-
|
26
|
+
var _window;
|
27
|
+
setWindowSize((_window = window) === null || _window === void 0 ? void 0 : _window.innerWidth);
|
27
28
|
}, []);
|
28
29
|
useLayoutEffect(function () {
|
29
30
|
/* istanbul ignore next */
|
@@ -49,10 +50,11 @@ var useStickyColumn = function useStickyColumn(hooks) {
|
|
49
50
|
var useEventListener = function useEventListener(instance) {
|
50
51
|
useEffect(function () {
|
51
52
|
var tableBodyElement = tableBodyRef.current;
|
52
|
-
var headerCellElement = stickyHeaderCellRef.current;
|
53
|
+
var headerCellElement = stickyHeaderCellRef === null || stickyHeaderCellRef === void 0 ? void 0 : stickyHeaderCellRef.current;
|
53
54
|
/* istanbul ignore next */
|
54
55
|
if (hasVertScroll(tableBodyElement) && headerCellElement) {
|
55
|
-
|
56
|
+
var _headerCellElement$cl;
|
57
|
+
headerCellElement === null || headerCellElement === void 0 || (_headerCellElement$cl = headerCellElement.classList) === null || _headerCellElement$cl === void 0 || _headerCellElement$cl.add(OFFSET_SCROLL_CLASS);
|
56
58
|
}
|
57
59
|
var boundListener = debounce(onBodyResize.bind(null, tableBodyElement, headerCellElement), 250);
|
58
60
|
/* istanbul ignore next */
|
@@ -74,7 +76,7 @@ var useStickyColumn = function useStickyColumn(hooks) {
|
|
74
76
|
};
|
75
77
|
toggleStickyShadow(tableBodyElement, headerCellElement);
|
76
78
|
if (tableBodyElement) {
|
77
|
-
tableBodyElement.addEventListener('scroll', listener);
|
79
|
+
tableBodyElement === null || tableBodyElement === void 0 || tableBodyElement.addEventListener('scroll', listener);
|
78
80
|
}
|
79
81
|
return function () {
|
80
82
|
if (tableBodyElement) {
|
@@ -138,18 +140,19 @@ var addTableBodyProps = function addTableBodyProps(tableBodyRef, props) {
|
|
138
140
|
}];
|
139
141
|
};
|
140
142
|
var changeProps = function changeProps(elementName, headerCellRef, windowSize, props, data) {
|
141
|
-
var
|
142
|
-
|
143
|
+
var _data$cell;
|
144
|
+
var column = data.column || ((_data$cell = data.cell) === null || _data$cell === void 0 ? void 0 : _data$cell.column);
|
145
|
+
if ((column === null || column === void 0 ? void 0 : column.sticky) === 'right') {
|
143
146
|
return [props, _objectSpread2({
|
144
147
|
className: cx(_defineProperty(_defineProperty(_defineProperty({}, "".concat(styleClassPrefix, "-").concat(elementName), true), "".concat(blockClass, "__resizableColumn"), false), "".concat(blockClass, "__sortableColumn"), false))
|
145
148
|
}, headerCellRef && {
|
146
149
|
ref: headerCellRef
|
147
150
|
})];
|
148
151
|
}
|
149
|
-
if (column.sticky === 'left') {
|
152
|
+
if ((column === null || column === void 0 ? void 0 : column.sticky) === 'left') {
|
150
153
|
var _data$instance;
|
151
154
|
return [props, _objectSpread2({
|
152
|
-
className: cx(_defineProperty(_defineProperty({}, "".concat(leftStickyStyleClassPrefix, "-").concat(elementName), windowSize > 671), "".concat(leftStickyStyleClassPrefix, "-").concat(elementName, "--with-extra-select-column"), (data === null || data === void 0 || (_data$instance = data.instance) === null || _data$instance === void 0 ? void 0 : _data$instance.withSelectRows) && windowSize > 671))
|
155
|
+
className: cx(_defineProperty(_defineProperty({}, "".concat(leftStickyStyleClassPrefix, "-").concat(elementName), windowSize && windowSize > 671), "".concat(leftStickyStyleClassPrefix, "-").concat(elementName, "--with-extra-select-column"), (data === null || data === void 0 || (_data$instance = data.instance) === null || _data$instance === void 0 ? void 0 : _data$instance.withSelectRows) && windowSize && windowSize > 671))
|
153
156
|
}, headerCellRef && {
|
154
157
|
ref: headerCellRef
|
155
158
|
})];
|
@@ -313,9 +313,9 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
313
313
|
// The display name of the component, used by React. Note that displayName
|
314
314
|
// is used in preference to relying on function.name.
|
315
315
|
TearsheetShell.displayName = componentName;
|
316
|
-
var portalType = typeof Element === 'undefined' ? PropTypes.object
|
316
|
+
var portalType = typeof Element === 'undefined' ? PropTypes.object :
|
317
317
|
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
|
318
|
-
|
318
|
+
PropTypes.instanceOf(Element);
|
319
319
|
var deprecatedProps = {
|
320
320
|
/**
|
321
321
|
* **Deprecated**
|
@@ -148,11 +148,23 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
148
148
|
'aria-setsize': aria.setsize
|
149
149
|
} : {};
|
150
150
|
};
|
151
|
+
var renderChildren = function renderChildren(popoverRef) {
|
152
|
+
return /*#__PURE__*/React__default["default"].createElement(ItemComponent, {
|
153
|
+
conditionState: {
|
154
|
+
property: property,
|
155
|
+
operator: operator,
|
156
|
+
value: value
|
157
|
+
},
|
158
|
+
onChange: onValueChangeHandler,
|
159
|
+
config: config,
|
160
|
+
"data-name": "valueField",
|
161
|
+
parentRef: popoverRef
|
162
|
+
});
|
163
|
+
};
|
151
164
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
152
165
|
className: cx__default["default"]("".concat(DataConfigs.blockClass, "__condition-block"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__condition__deletion-preview"), showDeletionPreview), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__gap-bottom"), variant == 'tree' && !(conditionIndex + 1 >= group.conditions.length)), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-bottom"), variant == 'sentence')),
|
153
166
|
role: "row",
|
154
|
-
"aria-label": conditionRowText
|
155
|
-
tabIndex: -1
|
167
|
+
"aria-label": conditionRowText
|
156
168
|
}, getAriaAttributes()), conjunction ? /*#__PURE__*/React__default["default"].createElement(ConditionConnector["default"], {
|
157
169
|
className: "".concat(DataConfigs.blockClass, "__gap"),
|
158
170
|
operator: conjunction,
|
@@ -215,18 +227,9 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
215
227
|
showToolTip: true,
|
216
228
|
"data-name": "valueField",
|
217
229
|
condition: condition,
|
218
|
-
config: config
|
219
|
-
}, /*#__PURE__*/React__default["default"].createElement(ItemComponent, {
|
220
|
-
conditionState: {
|
221
|
-
property: property,
|
222
|
-
operator: operator,
|
223
|
-
value: value
|
224
|
-
},
|
225
|
-
onChange: onValueChangeHandler,
|
226
230
|
config: config,
|
227
|
-
|
228
|
-
|
229
|
-
})), /*#__PURE__*/React__default["default"].createElement("span", {
|
231
|
+
renderChildren: renderChildren
|
232
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
230
233
|
role: "gridcell",
|
231
234
|
"aria-label": removeConditionText
|
232
235
|
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, {
|
@@ -211,7 +211,7 @@ exports.ConditionBuilder.propTypes = {
|
|
211
211
|
/**
|
212
212
|
* Optional prop, if you need to pass translations to the texts on the component instead of the defined defaults.
|
213
213
|
* This callback function will receive the message id and you need to return the corresponding text for that id.
|
214
|
-
* The message id will be one of [ "ifText","addConditionText", "addConditionGroupText", "addSubgroupText", "conditionText", "propertyText", "operatorText", "valueText", "connectorText", "conditionRowText", "removeConditionText", "addConditionRowText", "startText", "endText", "clearSearchText", "actionsText", "then", "removeActionText", "addActionText", "invalidText",
|
214
|
+
* The message id will be one of [ "ifText","addConditionText", "addConditionGroupText", "addSubgroupText", "conditionText", "propertyText", "operatorText", "valueText", "connectorText", "conditionRowText", "removeConditionText", "addConditionRowText", "startText", "endText", "clearSearchText", "actionsText", "then", "removeActionText", "addActionText", "invalidText", "invalidDateText", "invalidNumberWarnText"]
|
215
215
|
]
|
216
216
|
*/
|
217
217
|
translateWithId: index["default"].func,
|
@@ -110,11 +110,13 @@ var valueRenderers = {
|
|
110
110
|
},
|
111
111
|
date: function date(value) {
|
112
112
|
if (Array.isArray(value) && value.length > 1) {
|
113
|
-
var start = value !== null && value !== void 0 && value[0] ? formatDate(new Date(value[0])) : '';
|
114
|
-
var end = value !== null && value !== void 0 && value[1] ? formatDate(new Date(value[1])) : '';
|
113
|
+
var start = value !== null && value !== void 0 && value[0] && !isNaN(new Date(value[0])) ? formatDate(new Date(value[0])) : '';
|
114
|
+
var end = value !== null && value !== void 0 && value[1] && !isNaN(new Date(value[1])) ? formatDate(new Date(value[1])) : '';
|
115
115
|
return "".concat(start, " To ").concat(end);
|
116
|
+
} else if (Array.isArray(value) && !isNaN(new Date(value[0]))) {
|
117
|
+
return formatDate(new Date(value[0]));
|
116
118
|
} else {
|
117
|
-
return value
|
119
|
+
return value;
|
118
120
|
}
|
119
121
|
},
|
120
122
|
custom: function custom(value) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export function ConditionBuilderItem({ children, className, label, renderIcon, title, type, showToolTip, condition, popOverClassName, config, ...rest }: {
|
1
|
+
export function ConditionBuilderItem({ children, className, label, renderIcon, title, type, showToolTip, condition, popOverClassName, config, renderChildren, ...rest }: {
|
2
2
|
[x: string]: any;
|
3
3
|
children: any;
|
4
4
|
className: any;
|
@@ -10,6 +10,7 @@ export function ConditionBuilderItem({ children, className, label, renderIcon, t
|
|
10
10
|
condition: any;
|
11
11
|
popOverClassName: any;
|
12
12
|
config: any;
|
13
|
+
renderChildren: any;
|
13
14
|
}): import("react/jsx-runtime").JSX.Element;
|
14
15
|
export namespace ConditionBuilderItem {
|
15
16
|
namespace propTypes {
|
@@ -19,6 +20,7 @@ export namespace ConditionBuilderItem {
|
|
19
20
|
let config: PropTypes.Requireable<object>;
|
20
21
|
let label: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
21
22
|
let popOverClassName: PropTypes.Requireable<string>;
|
23
|
+
let renderChildren: PropTypes.Requireable<(...args: any[]) => any>;
|
22
24
|
let renderIcon: PropTypes.Requireable<object>;
|
23
25
|
let showToolTip: PropTypes.Requireable<boolean>;
|
24
26
|
let title: PropTypes.Requireable<string>;
|
@@ -22,7 +22,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
22
22
|
|
23
23
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
24
24
|
|
25
|
-
var _excluded = ["children", "className", "label", "renderIcon", "title", "type", "showToolTip", "condition", "popOverClassName", "config"];
|
25
|
+
var _excluded = ["children", "className", "label", "renderIcon", "title", "type", "showToolTip", "condition", "popOverClassName", "config", "renderChildren"];
|
26
26
|
var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
27
27
|
var children = _ref.children,
|
28
28
|
className = _ref.className,
|
@@ -34,23 +34,31 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
34
34
|
condition = _ref.condition,
|
35
35
|
popOverClassName = _ref.popOverClassName,
|
36
36
|
config = _ref.config,
|
37
|
+
renderChildren = _ref.renderChildren,
|
37
38
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
38
39
|
var contentRef = React.useRef(null);
|
40
|
+
var popoverRef = React.useRef(null);
|
39
41
|
var _useState = React.useState(false),
|
40
42
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
41
43
|
open = _useState2[0],
|
42
44
|
setOpen = _useState2[1];
|
43
|
-
var _useTranslations = useTranslations.useTranslations(['invalidText', 'addConditionText', label]),
|
44
|
-
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations,
|
45
|
+
var _useTranslations = useTranslations.useTranslations(['invalidText', 'addConditionText', label, 'invalidDateText']),
|
46
|
+
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 4),
|
45
47
|
invalidText = _useTranslations2[0],
|
46
48
|
addConditionText = _useTranslations2[1],
|
47
|
-
labelText = _useTranslations2[2]
|
49
|
+
labelText = _useTranslations2[2],
|
50
|
+
invalidDateText = _useTranslations2[3];
|
48
51
|
var getPropertyDetails = function getPropertyDetails() {
|
49
52
|
if (label === 'INVALID') {
|
50
53
|
return {
|
51
54
|
propertyLabel: invalidText,
|
52
55
|
isInvalid: true
|
53
56
|
};
|
57
|
+
} else if (label === 'INVALID_DATE') {
|
58
|
+
return {
|
59
|
+
propertyLabel: invalidDateText,
|
60
|
+
isInvalid: true
|
61
|
+
};
|
54
62
|
}
|
55
63
|
var propertyId = rest['data-name'] == 'valueField' && type ? DataConfigs.valueRenderers[type](label, config) : labelText;
|
56
64
|
return {
|
@@ -71,19 +79,19 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
71
79
|
//if any condition is changed, state prop is triggered
|
72
80
|
if (condition.popoverToOpen && currentField !== condition.popoverToOpen) {
|
73
81
|
// close the previous popover
|
74
|
-
|
82
|
+
closePopover();
|
75
83
|
} else if (currentField == 'valueField' && type == 'option' && condition.operator !== 'oneOf') {
|
76
84
|
//close the current popover if the field is valueField and is a single select dropdown. For all other inputs ,popover need to be open on value changes.
|
77
|
-
|
85
|
+
closePopover();
|
78
86
|
}
|
79
87
|
if (condition.popoverToOpen == currentField) {
|
80
88
|
//current popover need to be opened
|
81
|
-
|
89
|
+
openPopOver();
|
82
90
|
}
|
83
91
|
} else {
|
84
92
|
// when we change any statement(if/ excl.if) which is not part of condition state, label change is triggered.
|
85
93
|
//close popOver when statement is changed.
|
86
|
-
|
94
|
+
closePopover();
|
87
95
|
}
|
88
96
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
89
97
|
}, [condition, label]);
|
@@ -96,20 +104,26 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
96
104
|
}
|
97
105
|
}
|
98
106
|
}, [contentRef, open]);
|
107
|
+
var closePopover = function closePopover() {
|
108
|
+
return setOpen(false);
|
109
|
+
};
|
110
|
+
var openPopOver = function openPopOver() {
|
111
|
+
return setOpen(true);
|
112
|
+
};
|
113
|
+
var togglePopover = function togglePopover() {
|
114
|
+
return setOpen(!open);
|
115
|
+
};
|
99
116
|
return /*#__PURE__*/React__default["default"].createElement(react.Popover, {
|
100
117
|
open: open,
|
101
118
|
isTabTip: true,
|
102
119
|
role: "gridcell",
|
103
120
|
className: popOverClassName,
|
104
|
-
|
105
|
-
|
106
|
-
}
|
121
|
+
ref: popoverRef,
|
122
|
+
onRequestClose: closePopover
|
107
123
|
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, _rollupPluginBabelHelpers["extends"]({
|
108
124
|
label: propertyLabel !== null && propertyLabel !== void 0 ? propertyLabel : addConditionText,
|
109
125
|
hideLabel: !label ? true : false,
|
110
|
-
onClick:
|
111
|
-
children ? setOpen(!open) : null;
|
112
|
-
},
|
126
|
+
onClick: togglePopover,
|
113
127
|
className: className,
|
114
128
|
"aria-haspopup": true,
|
115
129
|
"aria-expanded": open,
|
@@ -126,7 +140,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
126
140
|
}, title), /*#__PURE__*/React__default["default"].createElement("div", {
|
127
141
|
ref: contentRef,
|
128
142
|
className: "".concat(DataConfigs.blockClass, "__popover-content")
|
129
|
-
}, children))));
|
143
|
+
}, renderChildren ? renderChildren(popoverRef) : children))));
|
130
144
|
};
|
131
145
|
ConditionBuilderItem.propTypes = {
|
132
146
|
/**
|
@@ -154,6 +168,10 @@ ConditionBuilderItem.propTypes = {
|
|
154
168
|
* class name for popover
|
155
169
|
*/
|
156
170
|
popOverClassName: index["default"].string,
|
171
|
+
/**
|
172
|
+
* callback prop that returns the jsx for children
|
173
|
+
*/
|
174
|
+
renderChildren: index["default"].func,
|
157
175
|
/**
|
158
176
|
* Optional prop to allow overriding the icon rendering.
|
159
177
|
*/
|
@@ -1,11 +1,13 @@
|
|
1
|
-
export function ConditionBuilderItemDate({ conditionState, onChange }: {
|
1
|
+
export function ConditionBuilderItemDate({ conditionState, onChange, parentRef, }: {
|
2
2
|
conditionState: any;
|
3
3
|
onChange: any;
|
4
|
+
parentRef: any;
|
4
5
|
}): import("react/jsx-runtime").JSX.Element;
|
5
6
|
export namespace ConditionBuilderItemDate {
|
6
7
|
namespace propTypes {
|
7
8
|
let conditionState: PropTypes.Requireable<object>;
|
8
9
|
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
10
|
+
let parentRef: PropTypes.Requireable<object>;
|
9
11
|
}
|
10
12
|
}
|
11
13
|
import PropTypes from 'prop-types';
|
@@ -23,21 +23,26 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
23
|
var blockClass = "".concat(settings.pkg.prefix, "--condition-builder");
|
24
24
|
var ConditionBuilderItemDate = function ConditionBuilderItemDate(_ref) {
|
25
25
|
var conditionState = _ref.conditionState,
|
26
|
-
onChange = _ref.onChange
|
26
|
+
onChange = _ref.onChange,
|
27
|
+
parentRef = _ref.parentRef;
|
27
28
|
var DatePickerInputRef = React.useRef();
|
28
29
|
var _useTranslations = useTranslations.useTranslations(['startText', 'endText']),
|
29
30
|
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 2),
|
30
31
|
startText = _useTranslations2[0],
|
31
32
|
endText = _useTranslations2[1];
|
32
33
|
var datePickerType = conditionState.operator == 'between' ? 'range' : 'single';
|
34
|
+
var onCloseHandler = function onCloseHandler(selectedDate) {
|
35
|
+
onChange(selectedDate && selectedDate.length > 0 ? selectedDate : 'INVALID_DATE');
|
36
|
+
};
|
33
37
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
34
38
|
className: "".concat(blockClass, "__item-date ")
|
35
39
|
}, datePickerType == 'single' && /*#__PURE__*/React__default["default"].createElement(react.DatePicker, {
|
36
40
|
ref: DatePickerInputRef,
|
37
41
|
dateFormat: "d/m/Y",
|
38
42
|
datePickerType: "single",
|
39
|
-
|
40
|
-
|
43
|
+
value: conditionState.value,
|
44
|
+
onClose: onCloseHandler,
|
45
|
+
appendTo: parentRef === null || parentRef === void 0 ? void 0 : parentRef.current
|
41
46
|
}, /*#__PURE__*/React__default["default"].createElement(react.DatePickerInput, {
|
42
47
|
id: "datePicker",
|
43
48
|
placeholder: "dd/mm/yyyy",
|
@@ -46,8 +51,9 @@ var ConditionBuilderItemDate = function ConditionBuilderItemDate(_ref) {
|
|
46
51
|
ref: DatePickerInputRef,
|
47
52
|
dateFormat: "d/m/Y",
|
48
53
|
datePickerType: datePickerType,
|
49
|
-
onClose:
|
50
|
-
value: conditionState.value
|
54
|
+
onClose: onCloseHandler,
|
55
|
+
value: conditionState.value,
|
56
|
+
appendTo: parentRef === null || parentRef === void 0 ? void 0 : parentRef.current
|
51
57
|
}, /*#__PURE__*/React__default["default"].createElement(react.DatePickerInput, {
|
52
58
|
id: "datePickerStart",
|
53
59
|
placeholder: "dd/mm/yyyy",
|
@@ -66,7 +72,11 @@ ConditionBuilderItemDate.propTypes = {
|
|
66
72
|
/**
|
67
73
|
* callback to update state oin date change
|
68
74
|
*/
|
69
|
-
onChange: index["default"].func
|
75
|
+
onChange: index["default"].func,
|
76
|
+
/**
|
77
|
+
* reference to the popover node
|
78
|
+
*/
|
79
|
+
parentRef: index["default"].object
|
70
80
|
};
|
71
81
|
|
72
82
|
exports.ConditionBuilderItemDate = ConditionBuilderItemDate;
|
@@ -6,7 +6,7 @@ import { RadioButtonGroupProps } from '@carbon/react/lib/components/RadioButtonG
|
|
6
6
|
import { CheckboxProps } from '@carbon/react/lib/components/Checkbox';
|
7
7
|
import { NumberInputProps } from '@carbon/react/lib/components/NumberInput/NumberInput';
|
8
8
|
import React, { CSSProperties, ComponentType, FunctionComponent, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
9
|
-
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
9
|
+
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsOptions, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
10
10
|
import { CarbonIconType } from '@carbon/react/icons';
|
11
11
|
import { IconButton, type ButtonProps } from '@carbon/react';
|
12
12
|
import { TableBatchActionsProps } from '@carbon/react/lib/components/DataTable/TableBatchActions';
|
@@ -97,7 +97,7 @@ export interface DataGridToggleAllRowsProps extends TableToggleAllRowsSelectedPr
|
|
97
97
|
}
|
98
98
|
export interface DatagridTableHooks<T extends object = any> extends UseTableHooks<T> {
|
99
99
|
}
|
100
|
-
export interface DatagridColumn<T extends object = any> extends ColumnInstance<T>, UseSortByOptions<T> {
|
100
|
+
export interface DatagridColumn<T extends object = any> extends ColumnInstance<T>, UseSortByOptions<T>, Partial<UseResizeColumnsColumnProps<T>>, UseResizeColumnsOptions<T> {
|
101
101
|
sticky?: 'left' | 'right';
|
102
102
|
className?: string;
|
103
103
|
rightAlignedColumn?: boolean;
|
@@ -124,15 +124,13 @@ export interface DataGridHeader<T extends object = any> extends ColumnInstance,
|
|
124
124
|
}
|
125
125
|
export interface DataGridHeaderGroup<T extends object = any> extends HeaderGroup<T>, UseResizeColumnsColumnProps<T> {
|
126
126
|
}
|
127
|
-
export interface
|
128
|
-
className?: string;
|
129
|
-
role?: string;
|
130
|
-
style?: CSSStyleDeclaration;
|
127
|
+
export interface DataGridTableProps extends TableCommonProps {
|
131
128
|
}
|
132
129
|
interface DataGridTableState extends UseResizeColumnsState<any>, UseRowSelectState<any> {
|
133
130
|
filters: Filters<DataGridFilter>;
|
134
131
|
}
|
135
132
|
export interface DataGridTableInstance<T extends object = any> extends TableInstance<T> {
|
133
|
+
withSelectRows?: boolean;
|
136
134
|
}
|
137
135
|
export interface RowAction {
|
138
136
|
id?: string;
|
@@ -234,6 +232,11 @@ export interface DataGridState<T extends object = any> extends TableCommonProps,
|
|
234
232
|
onRowExpand?: (row: DatagridRow, event: React.MouseEvent<HTMLElement>) => void;
|
235
233
|
ExpandedRowContentComponent?: JSXElementConstructor<any>;
|
236
234
|
}
|
235
|
+
export interface DataGridData {
|
236
|
+
instance?: DataGridTableInstance;
|
237
|
+
column?: DatagridColumn;
|
238
|
+
cell?: DataGridCell;
|
239
|
+
}
|
237
240
|
export interface ResizeHeaderProps {
|
238
241
|
resizerProps?: ResizerProps;
|
239
242
|
header: DataGridHeader;
|
@@ -1,2 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2021, 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 useStickyColumn: (hooks: Hooks) => void;
|
1
9
|
export default useStickyColumn;
|
2
|
-
declare function useStickyColumn(hooks: any): void;
|
@@ -27,12 +27,13 @@ var OFFSET_SCROLL_CLASS = "".concat(styleClassPrefix, "-offset-scroll");
|
|
27
27
|
var useStickyColumn = function useStickyColumn(hooks) {
|
28
28
|
var tableBodyRef = React.useRef();
|
29
29
|
var stickyHeaderCellRef = React.useRef();
|
30
|
-
var _useState = React.useState(
|
30
|
+
var _useState = React.useState(),
|
31
31
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
32
32
|
windowSize = _useState2[0],
|
33
33
|
setWindowSize = _useState2[1];
|
34
34
|
React.useEffect(function () {
|
35
|
-
|
35
|
+
var _window;
|
36
|
+
setWindowSize((_window = window) === null || _window === void 0 ? void 0 : _window.innerWidth);
|
36
37
|
}, []);
|
37
38
|
React.useLayoutEffect(function () {
|
38
39
|
/* istanbul ignore next */
|
@@ -58,10 +59,11 @@ var useStickyColumn = function useStickyColumn(hooks) {
|
|
58
59
|
var useEventListener = function useEventListener(instance) {
|
59
60
|
React.useEffect(function () {
|
60
61
|
var tableBodyElement = tableBodyRef.current;
|
61
|
-
var headerCellElement = stickyHeaderCellRef.current;
|
62
|
+
var headerCellElement = stickyHeaderCellRef === null || stickyHeaderCellRef === void 0 ? void 0 : stickyHeaderCellRef.current;
|
62
63
|
/* istanbul ignore next */
|
63
64
|
if (hasVertScroll(tableBodyElement) && headerCellElement) {
|
64
|
-
|
65
|
+
var _headerCellElement$cl;
|
66
|
+
headerCellElement === null || headerCellElement === void 0 || (_headerCellElement$cl = headerCellElement.classList) === null || _headerCellElement$cl === void 0 || _headerCellElement$cl.add(OFFSET_SCROLL_CLASS);
|
65
67
|
}
|
66
68
|
var boundListener = debounce__default["default"](onBodyResize.bind(null, tableBodyElement, headerCellElement), 250);
|
67
69
|
/* istanbul ignore next */
|
@@ -83,7 +85,7 @@ var useStickyColumn = function useStickyColumn(hooks) {
|
|
83
85
|
};
|
84
86
|
toggleStickyShadow(tableBodyElement, headerCellElement);
|
85
87
|
if (tableBodyElement) {
|
86
|
-
tableBodyElement.addEventListener('scroll', listener);
|
88
|
+
tableBodyElement === null || tableBodyElement === void 0 || tableBodyElement.addEventListener('scroll', listener);
|
87
89
|
}
|
88
90
|
return function () {
|
89
91
|
if (tableBodyElement) {
|
@@ -147,18 +149,19 @@ var addTableBodyProps = function addTableBodyProps(tableBodyRef, props) {
|
|
147
149
|
}];
|
148
150
|
};
|
149
151
|
var changeProps = function changeProps(elementName, headerCellRef, windowSize, props, data) {
|
150
|
-
var
|
151
|
-
|
152
|
+
var _data$cell;
|
153
|
+
var column = data.column || ((_data$cell = data.cell) === null || _data$cell === void 0 ? void 0 : _data$cell.column);
|
154
|
+
if ((column === null || column === void 0 ? void 0 : column.sticky) === 'right') {
|
152
155
|
return [props, _rollupPluginBabelHelpers.objectSpread2({
|
153
156
|
className: cx__default["default"](_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(styleClassPrefix, "-").concat(elementName), true), "".concat(blockClass, "__resizableColumn"), false), "".concat(blockClass, "__sortableColumn"), false))
|
154
157
|
}, headerCellRef && {
|
155
158
|
ref: headerCellRef
|
156
159
|
})];
|
157
160
|
}
|
158
|
-
if (column.sticky === 'left') {
|
161
|
+
if ((column === null || column === void 0 ? void 0 : column.sticky) === 'left') {
|
159
162
|
var _data$instance;
|
160
163
|
return [props, _rollupPluginBabelHelpers.objectSpread2({
|
161
|
-
className: cx__default["default"](_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(leftStickyStyleClassPrefix, "-").concat(elementName), windowSize > 671), "".concat(leftStickyStyleClassPrefix, "-").concat(elementName, "--with-extra-select-column"), (data === null || data === void 0 || (_data$instance = data.instance) === null || _data$instance === void 0 ? void 0 : _data$instance.withSelectRows) && windowSize > 671))
|
164
|
+
className: cx__default["default"](_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(leftStickyStyleClassPrefix, "-").concat(elementName), windowSize && windowSize > 671), "".concat(leftStickyStyleClassPrefix, "-").concat(elementName, "--with-extra-select-column"), (data === null || data === void 0 || (_data$instance = data.instance) === null || _data$instance === void 0 ? void 0 : _data$instance.withSelectRows) && windowSize && windowSize > 671))
|
162
165
|
}, headerCellRef && {
|
163
166
|
ref: headerCellRef
|
164
167
|
})];
|
@@ -322,9 +322,9 @@ var TearsheetShell = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
322
322
|
// The display name of the component, used by React. Note that displayName
|
323
323
|
// is used in preference to relying on function.name.
|
324
324
|
TearsheetShell.displayName = componentName;
|
325
|
-
var portalType = typeof Element === 'undefined' ? index["default"].object
|
325
|
+
var portalType = typeof Element === 'undefined' ? index["default"].object :
|
326
326
|
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
|
327
|
-
|
327
|
+
index["default"].instanceOf(Element);
|
328
328
|
var deprecatedProps = {
|
329
329
|
/**
|
330
330
|
* **Deprecated**
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "2.43.2-canary.
|
4
|
+
"version": "2.43.2-canary.58+78962b154",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -96,7 +96,7 @@
|
|
96
96
|
"dependencies": {
|
97
97
|
"@babel/runtime": "^7.23.9",
|
98
98
|
"@carbon/feature-flags": "^0.20.0",
|
99
|
-
"@carbon/ibm-products-styles": "^2.
|
99
|
+
"@carbon/ibm-products-styles": "^2.40.0-rc.1",
|
100
100
|
"@carbon/telemetry": "^0.1.0",
|
101
101
|
"@dnd-kit/core": "^6.0.8",
|
102
102
|
"@dnd-kit/modifiers": "^7.0.0",
|
@@ -120,5 +120,5 @@
|
|
120
120
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
121
121
|
"react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
|
122
122
|
},
|
123
|
-
"gitHead": "
|
123
|
+
"gitHead": "78962b154b909895d77aa523ea96ade0044b9f34"
|
124
124
|
}
|