@itwin/itwinui-react 1.26.1 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/cjs/core/Buttons/Button/Button.js +4 -5
- package/cjs/core/Buttons/IconButton/IconButton.js +2 -3
- package/cjs/core/Checkbox/Checkbox.d.ts +11 -0
- package/cjs/core/Checkbox/Checkbox.js +14 -4
- package/cjs/core/ComboBox/ComboBox.d.ts +2 -2
- package/cjs/core/ErrorPage/ErrorPage.d.ts +2 -1
- package/cjs/core/ErrorPage/ErrorPage.js +3 -2
- package/cjs/core/Modal/ModalButtonBar.d.ts +2 -1
- package/cjs/core/Modal/ModalButtonBar.js +3 -2
- package/cjs/core/Table/Table.d.ts +8 -0
- package/cjs/core/Table/Table.js +71 -10
- package/cjs/core/Table/TableCell.js +1 -1
- package/cjs/core/Table/TablePaginator.d.ts +6 -6
- package/cjs/core/Table/TablePaginator.js +12 -7
- package/cjs/core/Table/TableRowMemoized.d.ts +21 -0
- package/cjs/core/Table/TableRowMemoized.js +6 -3
- package/cjs/core/Table/actionHandlers/resizeHandler.d.ts +51 -0
- package/cjs/core/Table/actionHandlers/resizeHandler.js +22 -0
- package/cjs/core/Table/actionHandlers/selectHandler.d.ts +10 -7
- package/cjs/core/Table/hooks/index.d.ts +1 -0
- package/cjs/core/Table/hooks/index.js +3 -1
- package/cjs/core/Table/hooks/useResizeColumns.d.ts +5 -0
- package/cjs/core/Table/hooks/useResizeColumns.js +271 -0
- package/cjs/core/Table/utils.d.ts +1 -1
- package/cjs/core/Table/utils.js +8 -2
- package/cjs/core/Tabs/Tabs.d.ts +4 -0
- package/cjs/core/Tabs/Tabs.js +2 -2
- package/cjs/types/react-table-config.d.ts +16 -3
- package/esm/core/Buttons/Button/Button.js +4 -5
- package/esm/core/Buttons/IconButton/IconButton.js +2 -3
- package/esm/core/Checkbox/Checkbox.d.ts +11 -0
- package/esm/core/Checkbox/Checkbox.js +14 -4
- package/esm/core/ComboBox/ComboBox.d.ts +2 -2
- package/esm/core/ErrorPage/ErrorPage.d.ts +2 -1
- package/esm/core/ErrorPage/ErrorPage.js +3 -2
- package/esm/core/Modal/ModalButtonBar.d.ts +2 -1
- package/esm/core/Modal/ModalButtonBar.js +3 -2
- package/esm/core/Table/Table.d.ts +8 -0
- package/esm/core/Table/Table.js +73 -12
- package/esm/core/Table/TableCell.js +1 -1
- package/esm/core/Table/TablePaginator.d.ts +6 -6
- package/esm/core/Table/TablePaginator.js +13 -8
- package/esm/core/Table/TableRowMemoized.d.ts +21 -0
- package/esm/core/Table/TableRowMemoized.js +4 -2
- package/esm/core/Table/actionHandlers/resizeHandler.d.ts +51 -0
- package/esm/core/Table/actionHandlers/resizeHandler.js +17 -0
- package/esm/core/Table/actionHandlers/selectHandler.d.ts +10 -7
- package/esm/core/Table/hooks/index.d.ts +1 -0
- package/esm/core/Table/hooks/index.js +1 -0
- package/esm/core/Table/hooks/useResizeColumns.d.ts +5 -0
- package/esm/core/Table/hooks/useResizeColumns.js +267 -0
- package/esm/core/Table/utils.d.ts +1 -1
- package/esm/core/Table/utils.js +8 -2
- package/esm/core/Tabs/Tabs.d.ts +4 -0
- package/esm/core/Tabs/Tabs.js +2 -2
- package/esm/types/react-table-config.d.ts +16 -3
- package/package.json +13 -5
|
@@ -9,6 +9,16 @@ export declare const onSelectHandler: <T extends Record<string, unknown>>(newSta
|
|
|
9
9
|
export declare const onSingleSelectHandler: <T extends Record<string, unknown>>(state: TableState<T>, action: ActionType, instance?: TableInstance<T> | undefined, onSelect?: ((selectedData: T[] | undefined, tableState?: TableState<T> | undefined) => void) | undefined, isRowDisabled?: ((rowData: T) => boolean) | undefined) => {
|
|
10
10
|
selectedRowIds: Record<string, boolean>;
|
|
11
11
|
hiddenColumns?: import("react-table").IdType<T>[] | undefined;
|
|
12
|
+
columnResizing: {
|
|
13
|
+
startX?: number | undefined;
|
|
14
|
+
columnWidth?: number | undefined;
|
|
15
|
+
nextColumnWidth?: number | undefined;
|
|
16
|
+
headerIdWidths?: [string, number][] | undefined;
|
|
17
|
+
nextHeaderIdWidths?: [string, number][] | undefined;
|
|
18
|
+
columnWidths: Record<string, number>;
|
|
19
|
+
isResizingColumn?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
isTableResizing?: boolean | undefined;
|
|
12
22
|
columnOrder: import("react-table").IdType<T>[];
|
|
13
23
|
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
14
24
|
filters: import("react-table").Filters<T>;
|
|
@@ -16,13 +26,6 @@ export declare const onSingleSelectHandler: <T extends Record<string, unknown>>(
|
|
|
16
26
|
groupBy: import("react-table").IdType<T>[];
|
|
17
27
|
pageSize: number;
|
|
18
28
|
pageIndex: number;
|
|
19
|
-
columnResizing: {
|
|
20
|
-
startX?: number | undefined;
|
|
21
|
-
columnWidth: number;
|
|
22
|
-
headerIdWidths: Record<string, number>;
|
|
23
|
-
columnWidths: any;
|
|
24
|
-
isResizingColumn?: string | undefined;
|
|
25
|
-
};
|
|
26
29
|
rowState: Record<string, {
|
|
27
30
|
cellState: import("react-table").UseRowStateLocalState<T, unknown>;
|
|
28
31
|
}>;
|
|
@@ -2,3 +2,4 @@ export { EXPANDER_CELL_ID, useExpanderCell } from './useExpanderCell';
|
|
|
2
2
|
export { SELECTION_CELL_ID, useSelectionCell } from './useSelectionCell';
|
|
3
3
|
export { useSubRowFiltering } from './useSubRowFiltering';
|
|
4
4
|
export { useSubRowSelection } from './useSubRowSelection';
|
|
5
|
+
export { useResizeColumns } from './useResizeColumns';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSubRowSelection = exports.useSubRowFiltering = exports.useSelectionCell = exports.SELECTION_CELL_ID = exports.useExpanderCell = exports.EXPANDER_CELL_ID = void 0;
|
|
3
|
+
exports.useResizeColumns = exports.useSubRowSelection = exports.useSubRowFiltering = exports.useSelectionCell = exports.SELECTION_CELL_ID = exports.useExpanderCell = exports.EXPANDER_CELL_ID = void 0;
|
|
4
4
|
/*---------------------------------------------------------------------------------------------
|
|
5
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -15,3 +15,5 @@ var useSubRowFiltering_1 = require("./useSubRowFiltering");
|
|
|
15
15
|
Object.defineProperty(exports, "useSubRowFiltering", { enumerable: true, get: function () { return useSubRowFiltering_1.useSubRowFiltering; } });
|
|
16
16
|
var useSubRowSelection_1 = require("./useSubRowSelection");
|
|
17
17
|
Object.defineProperty(exports, "useSubRowSelection", { enumerable: true, get: function () { return useSubRowSelection_1.useSubRowSelection; } });
|
|
18
|
+
var useResizeColumns_1 = require("./useResizeColumns");
|
|
19
|
+
Object.defineProperty(exports, "useResizeColumns", { enumerable: true, get: function () { return useResizeColumns_1.useResizeColumns; } });
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.useResizeColumns = void 0;
|
|
24
|
+
var react_table_1 = require("react-table");
|
|
25
|
+
var useResizeColumns = function (ownerDocument) { return function (hooks) {
|
|
26
|
+
hooks.getResizerProps = [defaultGetResizerProps(ownerDocument)];
|
|
27
|
+
hooks.stateReducers.push(reducer);
|
|
28
|
+
hooks.useInstanceBeforeDimensions.push(useInstanceBeforeDimensions);
|
|
29
|
+
}; };
|
|
30
|
+
exports.useResizeColumns = useResizeColumns;
|
|
31
|
+
var isTouchEvent = function (event) {
|
|
32
|
+
return event.type === 'touchstart';
|
|
33
|
+
};
|
|
34
|
+
var defaultGetResizerProps = function (ownerDocument) { return function (props, _a) {
|
|
35
|
+
var instance = _a.instance, header = _a.header, nextHeader = _a.nextHeader;
|
|
36
|
+
if (!ownerDocument) {
|
|
37
|
+
return props;
|
|
38
|
+
}
|
|
39
|
+
var dispatch = instance.dispatch, flatHeaders = instance.flatHeaders;
|
|
40
|
+
var onResizeStart = function (e, header) {
|
|
41
|
+
// lets not respond to multiple touches (e.g. 2 or 3 fingers)
|
|
42
|
+
if (isTouchEvent(e) && e.touches && e.touches.length > 1) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// Setting `width` here because it might take several rerenders until actual column width is set.
|
|
46
|
+
flatHeaders.forEach(function (h) {
|
|
47
|
+
if (!h.width) {
|
|
48
|
+
h.width = h.resizeWidth;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
var headerIdWidths = getLeafHeaders(header).map(function (d) { return [d.id, d.width]; });
|
|
52
|
+
var nextHeaderIdWidths = nextHeader
|
|
53
|
+
? getLeafHeaders(nextHeader).map(function (d) { return [d.id, d.width]; })
|
|
54
|
+
: [];
|
|
55
|
+
var clientX = isTouchEvent(e)
|
|
56
|
+
? Math.round(e.touches[0].clientX)
|
|
57
|
+
: e.clientX;
|
|
58
|
+
var dispatchMove = function (clientXPos) {
|
|
59
|
+
return dispatch({ type: react_table_1.actions.columnResizing, clientX: clientXPos });
|
|
60
|
+
};
|
|
61
|
+
var dispatchEnd = function () {
|
|
62
|
+
return dispatch({
|
|
63
|
+
type: react_table_1.actions.columnDoneResizing,
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
var handlersAndEvents = {
|
|
67
|
+
mouse: {
|
|
68
|
+
moveEvent: 'mousemove',
|
|
69
|
+
moveHandler: function (e) { return dispatchMove(e.clientX); },
|
|
70
|
+
upEvent: 'mouseup',
|
|
71
|
+
upHandler: function () {
|
|
72
|
+
ownerDocument.removeEventListener('mousemove', handlersAndEvents.mouse.moveHandler);
|
|
73
|
+
ownerDocument.removeEventListener('mouseup', handlersAndEvents.mouse.upHandler);
|
|
74
|
+
dispatchEnd();
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
touch: {
|
|
78
|
+
moveEvent: 'touchmove',
|
|
79
|
+
moveHandler: function (e) {
|
|
80
|
+
if (e.cancelable) {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
}
|
|
84
|
+
dispatchMove(e.touches[0].clientX);
|
|
85
|
+
},
|
|
86
|
+
upEvent: 'touchend',
|
|
87
|
+
upHandler: function () {
|
|
88
|
+
ownerDocument.removeEventListener(handlersAndEvents.touch.moveEvent, handlersAndEvents.touch.moveHandler);
|
|
89
|
+
ownerDocument.removeEventListener(handlersAndEvents.touch.upEvent, handlersAndEvents.touch.moveHandler);
|
|
90
|
+
dispatchEnd();
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
var events = isTouchEvent(e)
|
|
95
|
+
? handlersAndEvents.touch
|
|
96
|
+
: handlersAndEvents.mouse;
|
|
97
|
+
var passiveIfSupported = passiveEventSupported()
|
|
98
|
+
? { passive: false }
|
|
99
|
+
: false;
|
|
100
|
+
ownerDocument.addEventListener(events.moveEvent, events.moveHandler, passiveIfSupported);
|
|
101
|
+
ownerDocument.addEventListener(events.upEvent, events.upHandler, passiveIfSupported);
|
|
102
|
+
dispatch({
|
|
103
|
+
type: react_table_1.actions.columnStartResizing,
|
|
104
|
+
columnId: header.id,
|
|
105
|
+
columnWidth: header.width,
|
|
106
|
+
nextColumnWidth: nextHeader === null || nextHeader === void 0 ? void 0 : nextHeader.width,
|
|
107
|
+
headerIdWidths: headerIdWidths,
|
|
108
|
+
nextHeaderIdWidths: nextHeaderIdWidths,
|
|
109
|
+
clientX: clientX,
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
return [
|
|
113
|
+
props,
|
|
114
|
+
{
|
|
115
|
+
onMouseDown: function (e) {
|
|
116
|
+
e.persist();
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
onResizeStart(e, header);
|
|
119
|
+
},
|
|
120
|
+
onTouchStart: function (e) {
|
|
121
|
+
e.persist();
|
|
122
|
+
e.stopPropagation();
|
|
123
|
+
onResizeStart(e, header);
|
|
124
|
+
},
|
|
125
|
+
style: {
|
|
126
|
+
cursor: 'col-resize',
|
|
127
|
+
},
|
|
128
|
+
draggable: false,
|
|
129
|
+
role: 'separator',
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
}; };
|
|
133
|
+
exports.useResizeColumns.pluginName = 'useResizeColumns';
|
|
134
|
+
var reducer = function (newState, action, previousState, instance) {
|
|
135
|
+
if (action.type === react_table_1.actions.init) {
|
|
136
|
+
return __assign(__assign({}, newState), { columnResizing: {
|
|
137
|
+
columnWidths: {},
|
|
138
|
+
} });
|
|
139
|
+
}
|
|
140
|
+
if (action.type === react_table_1.actions.resetResize) {
|
|
141
|
+
return __assign(__assign({}, newState), { columnResizing: {
|
|
142
|
+
columnWidths: {},
|
|
143
|
+
} });
|
|
144
|
+
}
|
|
145
|
+
if (action.type === react_table_1.actions.columnStartResizing) {
|
|
146
|
+
var clientX = action.clientX, columnId = action.columnId, columnWidth = action.columnWidth, nextColumnWidth = action.nextColumnWidth, headerIdWidths = action.headerIdWidths, nextHeaderIdWidths = action.nextHeaderIdWidths;
|
|
147
|
+
return __assign(__assign({}, newState), { columnResizing: __assign(__assign({}, newState.columnResizing), { startX: clientX, columnWidth: columnWidth, nextColumnWidth: nextColumnWidth, headerIdWidths: headerIdWidths, nextHeaderIdWidths: nextHeaderIdWidths, isResizingColumn: columnId }) });
|
|
148
|
+
}
|
|
149
|
+
if (action.type === react_table_1.actions.columnResizing) {
|
|
150
|
+
var clientX = action.clientX;
|
|
151
|
+
var _a = newState.columnResizing, _b = _a.startX, startX = _b === void 0 ? 0 : _b, _c = _a.columnWidth, columnWidth = _c === void 0 ? 1 : _c, _d = _a.nextColumnWidth, nextColumnWidth = _d === void 0 ? 1 : _d, _e = _a.headerIdWidths, headerIdWidths = _e === void 0 ? [] : _e, _f = _a.nextHeaderIdWidths, nextHeaderIdWidths = _f === void 0 ? [] : _f;
|
|
152
|
+
var deltaX = clientX - startX;
|
|
153
|
+
var newColumnWidths = getColumnWidths(headerIdWidths, deltaX / columnWidth);
|
|
154
|
+
var newNextColumnWidths = getColumnWidths(nextHeaderIdWidths, -deltaX / nextColumnWidth);
|
|
155
|
+
if (!isNewColumnWidthsValid(newColumnWidths, instance === null || instance === void 0 ? void 0 : instance.flatHeaders) ||
|
|
156
|
+
!isNewColumnWidthsValid(newNextColumnWidths, instance === null || instance === void 0 ? void 0 : instance.flatHeaders)) {
|
|
157
|
+
return newState;
|
|
158
|
+
}
|
|
159
|
+
return __assign(__assign({}, newState), { columnResizing: __assign(__assign({}, newState.columnResizing), { columnWidths: __assign(__assign(__assign({}, newState.columnResizing.columnWidths), newColumnWidths), newNextColumnWidths) }) });
|
|
160
|
+
}
|
|
161
|
+
if (action.type === react_table_1.actions.columnDoneResizing) {
|
|
162
|
+
return __assign(__assign({}, newState), { columnResizing: __assign(__assign({}, newState.columnResizing), { startX: undefined, isResizingColumn: undefined }) });
|
|
163
|
+
}
|
|
164
|
+
return newState;
|
|
165
|
+
};
|
|
166
|
+
var getColumnWidths = function (headerIdWidths, deltaPercentage) {
|
|
167
|
+
var columnWidths = {};
|
|
168
|
+
headerIdWidths.forEach(function (_a) {
|
|
169
|
+
var headerId = _a[0], headerWidth = _a[1];
|
|
170
|
+
columnWidths[headerId] = Math.max(headerWidth + headerWidth * deltaPercentage, 0);
|
|
171
|
+
});
|
|
172
|
+
return columnWidths;
|
|
173
|
+
};
|
|
174
|
+
var isNewColumnWidthsValid = function (columnWidths, headers) {
|
|
175
|
+
// Prevents from going outside the column bounds
|
|
176
|
+
if (Object.values(columnWidths).some(function (width) { return width <= 1; })) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
var _loop_1 = function (headerId, width) {
|
|
180
|
+
var header = headers === null || headers === void 0 ? void 0 : headers.find(function (h) { return h.id === headerId; });
|
|
181
|
+
if (!header) {
|
|
182
|
+
return "continue";
|
|
183
|
+
}
|
|
184
|
+
var minWidth = header.minWidth || 0;
|
|
185
|
+
var maxWidth = header.maxWidth || Infinity;
|
|
186
|
+
if (width < minWidth || width > maxWidth) {
|
|
187
|
+
return { value: false };
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
for (var _i = 0, _a = Object.entries(columnWidths); _i < _a.length; _i++) {
|
|
191
|
+
var _b = _a[_i], headerId = _b[0], width = _b[1];
|
|
192
|
+
var state_1 = _loop_1(headerId, width);
|
|
193
|
+
if (typeof state_1 === "object")
|
|
194
|
+
return state_1.value;
|
|
195
|
+
}
|
|
196
|
+
return true;
|
|
197
|
+
};
|
|
198
|
+
var useInstanceBeforeDimensions = function (instance) {
|
|
199
|
+
var flatHeaders = instance.flatHeaders, getHooks = instance.getHooks, columnResizing = instance.state.columnResizing;
|
|
200
|
+
var getInstance = (0, react_table_1.useGetLatest)(instance);
|
|
201
|
+
flatHeaders.forEach(function (header, index) {
|
|
202
|
+
var _a;
|
|
203
|
+
var resizeWidth = columnResizing.columnWidths[header.id];
|
|
204
|
+
header.width = resizeWidth || header.width || header.originalWidth;
|
|
205
|
+
header.isResizing = columnResizing.isResizingColumn === header.id;
|
|
206
|
+
var headerToResize = header.disableResizing
|
|
207
|
+
? getPreviousResizableHeader(header, instance)
|
|
208
|
+
: header;
|
|
209
|
+
var nextResizableHeader = getNextResizableHeader(header, instance);
|
|
210
|
+
header.canResize =
|
|
211
|
+
header.disableResizing != null ? !header.disableResizing : true;
|
|
212
|
+
// Show resizer when header is resizable or when next header is resizable
|
|
213
|
+
// and there is resizable columns on the left side of the resizer.
|
|
214
|
+
header.isResizerVisible =
|
|
215
|
+
(header.canResize && !!nextResizableHeader) ||
|
|
216
|
+
(headerToResize && !!((_a = instance.flatHeaders[index + 1]) === null || _a === void 0 ? void 0 : _a.canResize));
|
|
217
|
+
header.getResizerProps = (0, react_table_1.makePropGetter)(getHooks().getResizerProps, {
|
|
218
|
+
instance: getInstance(),
|
|
219
|
+
header: headerToResize,
|
|
220
|
+
nextHeader: nextResizableHeader,
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
var getPreviousResizableHeader = function (headerColumn, instance) {
|
|
225
|
+
var _a;
|
|
226
|
+
var headersList = ((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders;
|
|
227
|
+
var headerIndex = headersList.findIndex(function (h) { return h.id === headerColumn.id; });
|
|
228
|
+
return __spreadArray([], headersList, true).slice(0, headerIndex)
|
|
229
|
+
.reverse()
|
|
230
|
+
.find(function (h) { return !h.disableResizing; });
|
|
231
|
+
};
|
|
232
|
+
var getNextResizableHeader = function (headerColumn, instance) {
|
|
233
|
+
var _a;
|
|
234
|
+
var headersList = ((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders;
|
|
235
|
+
var headerIndex = headersList.findIndex(function (h) { return h.id === headerColumn.id; });
|
|
236
|
+
return __spreadArray([], headersList, true).slice(headerIndex + 1)
|
|
237
|
+
.find(function (h) { return !h.disableResizing; });
|
|
238
|
+
};
|
|
239
|
+
function getLeafHeaders(header) {
|
|
240
|
+
var leafHeaders = [];
|
|
241
|
+
var recurseHeader = function (header) {
|
|
242
|
+
if (header.columns && header.columns.length) {
|
|
243
|
+
header.columns.map(recurseHeader);
|
|
244
|
+
}
|
|
245
|
+
leafHeaders.push(header);
|
|
246
|
+
};
|
|
247
|
+
recurseHeader(header);
|
|
248
|
+
return leafHeaders;
|
|
249
|
+
}
|
|
250
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#safely_detecting_option_support
|
|
251
|
+
var passiveSupported = null;
|
|
252
|
+
var passiveEventSupported = function () {
|
|
253
|
+
// memoize support to avoid adding multiple test events
|
|
254
|
+
if (passiveSupported != null) {
|
|
255
|
+
return passiveSupported;
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
var options = {
|
|
259
|
+
once: true,
|
|
260
|
+
get passive() {
|
|
261
|
+
passiveSupported = true;
|
|
262
|
+
return false;
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
window.addEventListener('test', function () { }, options);
|
|
266
|
+
}
|
|
267
|
+
catch (_a) {
|
|
268
|
+
passiveSupported = false;
|
|
269
|
+
}
|
|
270
|
+
return passiveSupported;
|
|
271
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ColumnInstance } from 'react-table';
|
|
2
|
-
export declare const getCellStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T
|
|
2
|
+
export declare const getCellStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, isTableResizing: boolean) => React.CSSProperties | undefined;
|
package/cjs/core/Table/utils.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCellStyle = void 0;
|
|
4
|
-
var getCellStyle = function (column) {
|
|
4
|
+
var getCellStyle = function (column, isTableResizing) {
|
|
5
5
|
var style = {};
|
|
6
6
|
style.flex = "1 1 145px";
|
|
7
7
|
if (column.width) {
|
|
8
8
|
var width = typeof column.width === 'string' ? column.width : column.width + "px";
|
|
9
9
|
style.width = width;
|
|
10
|
-
|
|
10
|
+
// This allows flexbox to handle the width of the column on table resize
|
|
11
|
+
if (isTableResizing && column.canResize) {
|
|
12
|
+
style.flex = Number(column.width) + " 1 " + width;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
style.flex = "0 0 " + width;
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
if (column.maxWidth) {
|
|
13
19
|
style.maxWidth = column.maxWidth + "px";
|
package/cjs/core/Tabs/Tabs.d.ts
CHANGED
package/cjs/core/Tabs/Tabs.js
CHANGED
|
@@ -61,7 +61,7 @@ var Tab_1 = require("./Tab");
|
|
|
61
61
|
*/
|
|
62
62
|
var Tabs = function (props) {
|
|
63
63
|
var _a, _b, _c;
|
|
64
|
-
var labels = props.labels, activeIndex = props.activeIndex, onTabSelected = props.onTabSelected, _d = props.focusActivationMode, focusActivationMode = _d === void 0 ? 'auto' : _d, _e = props.type, type = _e === void 0 ? 'default' : _e, _f = props.color, color = _f === void 0 ? 'blue' : _f, _g = props.orientation, orientation = _g === void 0 ? 'horizontal' : _g, tabsClassName = props.tabsClassName, contentClassName = props.contentClassName, children = props.children, rest = __rest(props, ["labels", "activeIndex", "onTabSelected", "focusActivationMode", "type", "color", "orientation", "tabsClassName", "contentClassName", "children"]);
|
|
64
|
+
var labels = props.labels, activeIndex = props.activeIndex, onTabSelected = props.onTabSelected, _d = props.focusActivationMode, focusActivationMode = _d === void 0 ? 'auto' : _d, _e = props.type, type = _e === void 0 ? 'default' : _e, _f = props.color, color = _f === void 0 ? 'blue' : _f, _g = props.orientation, orientation = _g === void 0 ? 'horizontal' : _g, tabsClassName = props.tabsClassName, contentClassName = props.contentClassName, wrapperClassName = props.wrapperClassName, children = props.children, rest = __rest(props, ["labels", "activeIndex", "onTabSelected", "focusActivationMode", "type", "color", "orientation", "tabsClassName", "contentClassName", "wrapperClassName", "children"]);
|
|
65
65
|
(0, utils_1.useTheme)();
|
|
66
66
|
var tablistRef = react_1.default.useRef(null);
|
|
67
67
|
var _h = (0, utils_1.useContainerWidth)(type !== 'default'), tablistSizeRef = _h[0], tabsWidth = _h[1];
|
|
@@ -173,7 +173,7 @@ var Tabs = function (props) {
|
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
175
|
var isIE = !((_c = (_b = (_a = (0, utils_1.getWindow)()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, '--stripe-width', '100px'));
|
|
176
|
-
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('iui-tabs-wrapper', "iui-" + orientation), style: stripeProperties },
|
|
176
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('iui-tabs-wrapper', "iui-" + orientation, wrapperClassName), style: stripeProperties },
|
|
177
177
|
react_1.default.createElement("ul", __assign({ className: (0, classnames_1.default)('iui-tabs', "iui-" + type, {
|
|
178
178
|
'iui-green': color === 'green',
|
|
179
179
|
'iui-animated': type !== 'default' && !isIE,
|
|
@@ -6,7 +6,7 @@ declare module 'react-table' {
|
|
|
6
6
|
cellProps: CellProps<D>;
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
};
|
|
9
|
-
interface TableOptions<D extends object = {}> extends Omit<UseTableOptions<D>, 'data'>, UseRowSelectOptions<D>, UseExpandedOptions<D>, UseFiltersOptions<D>, UsePaginationOptions<D>, UseSortByOptions<D> {
|
|
9
|
+
interface TableOptions<D extends object = {}> extends Omit<UseTableOptions<D>, 'data'>, UseRowSelectOptions<D>, UseExpandedOptions<D>, UseFiltersOptions<D>, UsePaginationOptions<D>, Omit<UseResizeColumnsOptions<D>, 'disableResizing'>, UseSortByOptions<D> {
|
|
10
10
|
/**
|
|
11
11
|
* Table data list.
|
|
12
12
|
* Must be memoized.
|
|
@@ -21,9 +21,19 @@ declare module 'react-table' {
|
|
|
21
21
|
interface TableInstance<D extends object = {}> extends UseColumnOrderInstanceProps<D>, UseExpandedInstanceProps<D>, UseFiltersInstanceProps<D>, UseGlobalFiltersInstanceProps<D>, UseGroupByInstanceProps<D>, UsePaginationInstanceProps<D>, UseRowSelectInstanceProps<D>, UseRowStateInstanceProps<D>, UseSortByInstanceProps<D> {
|
|
22
22
|
initialRows: Row<D>[];
|
|
23
23
|
}
|
|
24
|
-
interface TableState<D extends object = {}> extends UseColumnOrderState<D>, UseExpandedState<D>, UseFiltersState<D>, UseGlobalFiltersState<D>, UseGroupByState<D>, UsePaginationState<D>,
|
|
24
|
+
interface TableState<D extends object = {}> extends UseColumnOrderState<D>, UseExpandedState<D>, UseFiltersState<D>, UseGlobalFiltersState<D>, UseGroupByState<D>, UsePaginationState<D>, UseRowSelectState<D>, UseRowStateState<D>, UseSortByState<D> {
|
|
25
|
+
columnResizing: {
|
|
26
|
+
startX?: number;
|
|
27
|
+
columnWidth?: number;
|
|
28
|
+
nextColumnWidth?: number;
|
|
29
|
+
headerIdWidths?: Array<[string, number]>;
|
|
30
|
+
nextHeaderIdWidths?: Array<[string, number]>;
|
|
31
|
+
columnWidths: Record<string, number>;
|
|
32
|
+
isResizingColumn?: string;
|
|
33
|
+
};
|
|
34
|
+
isTableResizing?: boolean;
|
|
25
35
|
}
|
|
26
|
-
interface ColumnInterface<D extends object = {}> extends UseSortByColumnOptions<D>, UseFiltersColumnOptions<D> {
|
|
36
|
+
interface ColumnInterface<D extends object = {}> extends UseSortByColumnOptions<D>, UseFiltersColumnOptions<D>, UseResizeColumnsColumnOptions<D> {
|
|
27
37
|
/**
|
|
28
38
|
* Custom class name applied to header column cell.
|
|
29
39
|
*/
|
|
@@ -59,6 +69,9 @@ declare module 'react-table' {
|
|
|
59
69
|
cellRenderer?: (props: CellRendererProps<D>) => React.ReactNode;
|
|
60
70
|
}
|
|
61
71
|
interface ColumnInstance<D extends object = {}> extends UseFiltersColumnProps<D>, UseGroupByColumnProps<D>, UseResizeColumnsColumnProps<D>, UseSortByColumnProps<D> {
|
|
72
|
+
originalWidth: number;
|
|
73
|
+
resizeWidth?: number;
|
|
74
|
+
isResizerVisible?: boolean;
|
|
62
75
|
}
|
|
63
76
|
interface Cell<D extends object = {}> extends UseGroupByCellProps<D>, UseRowStateCellProps<D> {
|
|
64
77
|
}
|
|
@@ -41,18 +41,17 @@ export var Button = React.forwardRef(function (props, ref) {
|
|
|
41
41
|
var _a;
|
|
42
42
|
var children = props.children, className = props.className, size = props.size, style = props.style, _b = props.styleType, styleType = _b === void 0 ? 'default' : _b, _c = props.type, type = _c === void 0 ? 'button' : _c, startIcon = props.startIcon, endIcon = props.endIcon, rest = __rest(props, ["children", "className", "size", "style", "styleType", "type", "startIcon", "endIcon"]);
|
|
43
43
|
useTheme();
|
|
44
|
-
return (React.createElement("button", __assign({ ref: ref, className: cx('iui-button', (_a = {},
|
|
44
|
+
return (React.createElement("button", __assign({ ref: ref, className: cx('iui-button', "iui-" + styleType, (_a = {},
|
|
45
45
|
_a["iui-" + size] = !!size,
|
|
46
|
-
_a["iui-" + styleType] = styleType !== 'default',
|
|
47
46
|
_a), className), style: style, type: type }, rest),
|
|
48
47
|
startIcon &&
|
|
49
48
|
React.cloneElement(startIcon, {
|
|
50
|
-
className: cx('iui-icon', startIcon.props.className),
|
|
49
|
+
className: cx('iui-button-icon', startIcon.props.className),
|
|
51
50
|
}),
|
|
52
|
-
children && React.createElement("span", { className: 'iui-label' }, children),
|
|
51
|
+
children && React.createElement("span", { className: 'iui-button-label' }, children),
|
|
53
52
|
endIcon &&
|
|
54
53
|
React.cloneElement(endIcon, {
|
|
55
|
-
className: cx('iui-icon', endIcon.props.className),
|
|
54
|
+
className: cx('iui-button-icon', endIcon.props.className),
|
|
56
55
|
})));
|
|
57
56
|
});
|
|
58
57
|
export default Button;
|
|
@@ -38,12 +38,11 @@ export var IconButton = React.forwardRef(function (props, ref) {
|
|
|
38
38
|
var _a;
|
|
39
39
|
var isActive = props.isActive, children = props.children, _b = props.styleType, styleType = _b === void 0 ? 'default' : _b, size = props.size, _c = props.type, type = _c === void 0 ? 'button' : _c, className = props.className, rest = __rest(props, ["isActive", "children", "styleType", "size", "type", "className"]);
|
|
40
40
|
useTheme();
|
|
41
|
-
return (React.createElement("button", __assign({ ref: ref, className: cx('iui-button', (_a = {},
|
|
41
|
+
return (React.createElement("button", __assign({ ref: ref, className: cx('iui-button', "iui-" + styleType, (_a = {},
|
|
42
42
|
_a["iui-" + size] = !!size,
|
|
43
|
-
_a["iui-" + styleType] = styleType !== 'default',
|
|
44
43
|
_a['iui-active'] = isActive,
|
|
45
44
|
_a), className), type: type }, rest), React.cloneElement(children, {
|
|
46
|
-
className: cx('iui-icon', children.props.className),
|
|
45
|
+
className: cx('iui-button-icon', children.props.className),
|
|
47
46
|
'aria-hidden': true,
|
|
48
47
|
})));
|
|
49
48
|
});
|
|
@@ -14,6 +14,11 @@ export declare type CheckboxProps = {
|
|
|
14
14
|
* Status of checkbox.
|
|
15
15
|
*/
|
|
16
16
|
status?: 'positive' | 'warning' | 'negative';
|
|
17
|
+
/**
|
|
18
|
+
* Type of checkbox, regular or eyeball checkbox that is used for visibility.
|
|
19
|
+
* @default 'default'
|
|
20
|
+
*/
|
|
21
|
+
variant?: 'default' | 'eyeball';
|
|
17
22
|
/**
|
|
18
23
|
* Set focus on checkbox.
|
|
19
24
|
*/
|
|
@@ -41,6 +46,7 @@ export declare type CheckboxProps = {
|
|
|
41
46
|
* <Checkbox label='Positive Checkbox' status='positive' />
|
|
42
47
|
* <Checkbox label='Warning Checkbox' status='warning' />
|
|
43
48
|
* <Checkbox label='Negative Checkbox' status='negative' />
|
|
49
|
+
* <Checkbox label='Visibility Checkbox' variant='eyeball' />
|
|
44
50
|
*/
|
|
45
51
|
export declare const Checkbox: React.ForwardRefExoticComponent<{
|
|
46
52
|
/**
|
|
@@ -56,6 +62,11 @@ export declare const Checkbox: React.ForwardRefExoticComponent<{
|
|
|
56
62
|
* Status of checkbox.
|
|
57
63
|
*/
|
|
58
64
|
status?: "positive" | "warning" | "negative" | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Type of checkbox, regular or eyeball checkbox that is used for visibility.
|
|
67
|
+
* @default 'default'
|
|
68
|
+
*/
|
|
69
|
+
variant?: "default" | "eyeball" | undefined;
|
|
59
70
|
/**
|
|
60
71
|
* Set focus on checkbox.
|
|
61
72
|
*/
|
|
@@ -38,10 +38,11 @@ import '@itwin/itwinui-css/css/inputs.css';
|
|
|
38
38
|
* <Checkbox label='Positive Checkbox' status='positive' />
|
|
39
39
|
* <Checkbox label='Warning Checkbox' status='warning' />
|
|
40
40
|
* <Checkbox label='Negative Checkbox' status='negative' />
|
|
41
|
+
* <Checkbox label='Visibility Checkbox' variant='eyeball' />
|
|
41
42
|
*/
|
|
42
43
|
export var Checkbox = React.forwardRef(function (props, ref) {
|
|
43
44
|
var _a;
|
|
44
|
-
var className = props.className, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.indeterminate, indeterminate = _c === void 0 ? false : _c, label = props.label, status = props.status, setFocus = props.setFocus,
|
|
45
|
+
var className = props.className, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.indeterminate, indeterminate = _c === void 0 ? false : _c, label = props.label, status = props.status, _d = props.variant, variant = _d === void 0 ? 'default' : _d, setFocus = props.setFocus, _e = props.isLoading, isLoading = _e === void 0 ? false : _e, style = props.style, checkmarkClassName = props.checkmarkClassName, checkmarkStyle = props.checkmarkStyle, rest = __rest(props, ["className", "disabled", "indeterminate", "label", "status", "variant", "setFocus", "isLoading", "style", "checkmarkClassName", "checkmarkStyle"]);
|
|
45
46
|
useTheme();
|
|
46
47
|
var inputElementRef = React.useRef(null);
|
|
47
48
|
var refs = useMergedRefs(inputElementRef, ref);
|
|
@@ -58,18 +59,27 @@ export var Checkbox = React.forwardRef(function (props, ref) {
|
|
|
58
59
|
: inputElementRef.current.checked;
|
|
59
60
|
}
|
|
60
61
|
});
|
|
62
|
+
var defaultCheckbox = (React.createElement("svg", { viewBox: '0 0 16 16', "aria-hidden": 'true', focusable: 'false' },
|
|
63
|
+
React.createElement("path", { className: 'iui-check', d: 'M6,14L0,8l2-2l4,4l8-8l2,2L6,14z' }),
|
|
64
|
+
React.createElement("path", { className: 'iui-check-partial', d: 'm1 6.5h14v3h-14z' })));
|
|
65
|
+
var visibilityCheckbox = (React.createElement("svg", { viewBox: '0 0 16 16', "aria-hidden": 'true', focusable: 'false' },
|
|
66
|
+
React.createElement("path", { className: 'iui-check', d: 'm8 2.99051a8.81883 8.81883 0 0 0 -8 4.95062 8.74664 8.74664 0 0 0 8 5.06836 8.63266 8.63266 0 0 0 8-5.06836 8.83631 8.83631 0 0 0 -8-4.95062zm-1.31445 1.86981a1.47663 1.47663 0 1 1 -1.47663 1.47668 1.47665 1.47665 0 0 1 1.47663-1.47668zm1.31445 6.64917a7.17486 7.17486 0 0 1 -6.30475-3.55237 7.4952 7.4952 0 0 1 2.81475-2.6336 3.83956 3.83956 0 1 0 6.98126.00244 7.522 7.522 0 0 1 2.81774 2.63916 7.09785 7.09785 0 0 1 -6.309 3.54437z' }),
|
|
67
|
+
React.createElement("g", { className: 'iui-check-partial' },
|
|
68
|
+
React.createElement("path", { d: 'm8 3v7.9a4.01179 4.01179 0 0 0 4-4 6.7509 6.7509 0 0 0 -.2-1.4l.1.1a6.89429 6.89429 0 0 1 2.4 2.4 8.39088 8.39088 0 0 1 -2.3 2.3 6.89412 6.89412 0 0 1 -3.9 1.2c-.03345 0-.06653-.00677-.1-.0072v1.5072a8.90686 8.90686 0 0 0 8-5 8.90686 8.90686 0 0 0 -8-5z', opacity: '.33' }),
|
|
69
|
+
React.createElement("path", { d: 'm8 0a1 1 0 0 0 -1 1v2.07135a8.91637 8.91637 0 0 0 -7 4.92865 8.91637 8.91637 0 0 0 7 4.92865v2.07135a1 1 0 0 0 2 0v-14a1 1 0 0 0 -1-1zm-1.5 4.9a1.55426 1.55426 0 0 1 .5.087v2.81451a1.40746 1.40746 0 0 1 -.5.09849 1.538 1.538 0 0 1 -1.5-1.5 1.53794 1.53794 0 0 1 1.5-1.5zm-2.3 5.4a6.97279 6.97279 0 0 1 -2.5-2.3 6.89429 6.89429 0 0 1 2.4-2.4c.1 0 .1-.1.2-.1a3.194 3.194 0 0 0 -.3 1.4 4.0047 4.0047 0 0 0 3 3.857v.65289a6.37491 6.37491 0 0 1 -2.8-1.10989z' })),
|
|
70
|
+
React.createElement("path", { className: 'iui-uncheck', d: 'm1.70671 12.879 11.17218-11.17219 1.4142 1.4142-11.17218 11.17218zm.99329-1.679 1.1-1.1a5.06317 5.06317 0 0 1 -2-2.1 7.48268 7.48268 0 0 1 6.2-3.5 4.86877 4.86877 0 0 1 1.2.1l1.3-1.3a10.07431 10.07431 0 0 0 -2.5-.3 8.84129 8.84129 0 0 0 -8 5 8.42455 8.42455 0 0 0 2.7 3.2zm10.7-6.4-1.1 1.1a7.08625 7.08625 0 0 1 2 2.1 7.50323 7.50323 0 0 1 -6.2 3.5 8.31665 8.31665 0 0 1 -1.3-.2l-1.3 1.3a8.909 8.909 0 0 0 6.4-.5 9.04344 9.04344 0 0 0 4.1-4.1 9.168 9.168 0 0 0 -2.6-3.2z' })));
|
|
61
71
|
return (React.createElement("label", { className: cx('iui-checkbox', (_a = {
|
|
62
72
|
'iui-disabled': disabled
|
|
63
73
|
},
|
|
64
74
|
_a["iui-" + status] = !!status,
|
|
65
75
|
_a['iui-loading'] = isLoading,
|
|
76
|
+
_a['iui-checkbox-visibility'] = variant === 'eyeball',
|
|
66
77
|
_a), className), style: style },
|
|
67
78
|
React.createElement("input", __assign({ disabled: disabled || isLoading, type: 'checkbox', ref: refs }, rest)),
|
|
68
79
|
React.createElement("span", { className: cx('iui-checkbox-checkmark', checkmarkClassName), style: checkmarkStyle },
|
|
69
80
|
isLoading && React.createElement(ProgressRadial, { indeterminate: true }),
|
|
70
|
-
!isLoading &&
|
|
71
|
-
|
|
72
|
-
React.createElement("path", { className: 'iui-check-partial', d: 'm1 6.5h14v3h-14z' })))),
|
|
81
|
+
!isLoading &&
|
|
82
|
+
(variant === 'default' ? defaultCheckbox : visibilityCheckbox)),
|
|
73
83
|
label && React.createElement("span", { className: 'iui-label' }, label)));
|
|
74
84
|
});
|
|
75
85
|
export default Checkbox;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InputProps } from '../Input';
|
|
3
3
|
import { SelectOption } from '../Select';
|
|
4
|
-
import { PopoverProps, CommonProps } from '../utils';
|
|
4
|
+
import { PopoverProps, CommonProps, InputContainerProps } from '../utils';
|
|
5
5
|
import 'tippy.js/animations/shift-away.css';
|
|
6
6
|
export declare type ComboBoxProps<T> = {
|
|
7
7
|
/**
|
|
@@ -33,7 +33,7 @@ export declare type ComboBoxProps<T> = {
|
|
|
33
33
|
* @default 'No options found'
|
|
34
34
|
*/
|
|
35
35
|
emptyStateMessage?: string;
|
|
36
|
-
} & Omit<CommonProps, 'title'>;
|
|
36
|
+
} & Pick<InputContainerProps, 'status'> & Omit<CommonProps, 'title'>;
|
|
37
37
|
/**
|
|
38
38
|
* ComboBox component that allows typing a value to filter the options in dropdown list.
|
|
39
39
|
* Values can be selected either using mouse clicks or using the Enter key.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
2
3
|
import '@itwin/itwinui-css/css/non-ideal-state.css';
|
|
3
4
|
export declare type ErrorPageType = '401' | '403' | '404' | '500' | '502' | '503' | 'generic';
|
|
4
5
|
export declare type ErrorTypeTranslations = {
|
|
@@ -45,7 +46,7 @@ export declare type ErrorPageProps = {
|
|
|
45
46
|
* Used to translate default error messages, if no specific @errorName passed in
|
|
46
47
|
*/
|
|
47
48
|
translatedErrorMessages?: ErrorTypeTranslations;
|
|
48
|
-
}
|
|
49
|
+
} & Omit<CommonProps, 'title'>;
|
|
49
50
|
/**
|
|
50
51
|
* A stylized display to communicate common http errors.
|
|
51
52
|
* @example
|
|
@@ -34,6 +34,7 @@ import SvgError from '@itwin/itwinui-illustrations-react/cjs/illustrations/Error
|
|
|
34
34
|
import React from 'react';
|
|
35
35
|
import { Button } from '../Buttons/Button';
|
|
36
36
|
import { useTheme } from '../utils';
|
|
37
|
+
import cx from 'classnames';
|
|
37
38
|
import '@itwin/itwinui-css/css/non-ideal-state.css';
|
|
38
39
|
/**
|
|
39
40
|
* A stylized display to communicate common http errors.
|
|
@@ -41,7 +42,7 @@ import '@itwin/itwinui-css/css/non-ideal-state.css';
|
|
|
41
42
|
* <ErrorPage errorType='401' />
|
|
42
43
|
*/
|
|
43
44
|
export var ErrorPage = function (props) {
|
|
44
|
-
var errorType = props.errorType, errorName = props.errorName, errorMessage = props.errorMessage, primaryButtonHandle = props.primaryButtonHandle, primaryButtonLabel = props.primaryButtonLabel, secondaryButtonHandle = props.secondaryButtonHandle, secondaryButtonLabel = props.secondaryButtonLabel, translatedErrorMessages = props.translatedErrorMessages, rest = __rest(props, ["errorType", "errorName", "errorMessage", "primaryButtonHandle", "primaryButtonLabel", "secondaryButtonHandle", "secondaryButtonLabel", "translatedErrorMessages"]);
|
|
45
|
+
var errorType = props.errorType, errorName = props.errorName, errorMessage = props.errorMessage, primaryButtonHandle = props.primaryButtonHandle, primaryButtonLabel = props.primaryButtonLabel, secondaryButtonHandle = props.secondaryButtonHandle, secondaryButtonLabel = props.secondaryButtonLabel, translatedErrorMessages = props.translatedErrorMessages, className = props.className, rest = __rest(props, ["errorType", "errorName", "errorMessage", "primaryButtonHandle", "primaryButtonLabel", "secondaryButtonHandle", "secondaryButtonLabel", "translatedErrorMessages", "className"]);
|
|
45
46
|
useTheme();
|
|
46
47
|
var defaultErrorMessages = __assign({ badGateway: 'Bad gateway', error: 'Error', forbidden: 'Forbidden', internalServerError: 'Internal server error', pageNotFound: 'Page not found', serviceUnavailable: 'Service unavailable', unauthorized: 'Unauthorized' }, translatedErrorMessages);
|
|
47
48
|
function getErrorIcon() {
|
|
@@ -121,7 +122,7 @@ export var ErrorPage = function (props) {
|
|
|
121
122
|
primaryButton,
|
|
122
123
|
secondaryButton));
|
|
123
124
|
}
|
|
124
|
-
return (React.createElement("div", __assign({ className: 'iui-non-ideal-state' }, rest),
|
|
125
|
+
return (React.createElement("div", __assign({ className: cx('iui-non-ideal-state', className) }, rest),
|
|
125
126
|
getErrorIcon(),
|
|
126
127
|
React.createElement("div", { className: 'iui-non-ideal-state-title' }, getHeadingMessage()),
|
|
127
128
|
errorMessage && (React.createElement("div", { className: 'iui-non-ideal-state-description' }, errorMessage)),
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
2
3
|
import '@itwin/itwinui-css/css/modal.css';
|
|
3
4
|
export declare type ModalButtonBarProps = {
|
|
4
5
|
/**
|
|
5
6
|
* Buttons in the modal bar.
|
|
6
7
|
*/
|
|
7
8
|
children: React.ReactNode;
|
|
8
|
-
}
|
|
9
|
+
} & Omit<CommonProps, 'title'>;
|
|
9
10
|
/**
|
|
10
11
|
* Container for Buttons in modal.
|
|
11
12
|
*/
|