@teselagen/ui 0.7.35 → 0.8.1
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/index.cjs.js +1 -2
- package/index.es.js +1 -2
- package/package.json +1 -1
- package/src/DataTable/Columns.js +1 -1
- package/src/DataTable/DisplayOptions.js +1 -1
- package/src/DataTable/FilterAndSortMenu.js +30 -27
- package/src/DataTable/index.js +14 -3
- package/src/DataTable/utils/queryParams.js +771 -64
- package/src/DataTable/utils/withTableParams.js +16 -3
- package/src/index.js +0 -1
- package/src/utils/isBeingCalledExcessively.js +14 -7
- package/AdvancedOptions.js +0 -33
- package/AssignDefaultsModeContext.js +0 -22
- package/CellDragHandle.js +0 -132
- package/ColumnFilterMenu.js +0 -62
- package/Columns.js +0 -979
- package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +0 -5
- package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +0 -2
- package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +0 -26
- package/DisabledLoadingComponent.js +0 -15
- package/DisplayOptions.js +0 -199
- package/DropdownButton.js +0 -36
- package/DropdownCell.js +0 -61
- package/EditableCell.js +0 -44
- package/FillWindow.css +0 -6
- package/FillWindow.js +0 -69
- package/FilterAndSortMenu.js +0 -391
- package/FormSeparator.js +0 -9
- package/LoadingDots.js +0 -14
- package/MatchHeaders.js +0 -234
- package/PagingTool.js +0 -225
- package/RenderCell.js +0 -191
- package/SearchBar.js +0 -69
- package/SimpleStepViz.js +0 -22
- package/SortableColumns.js +0 -100
- package/TableFormTrackerContext.js +0 -10
- package/Tag.js +0 -112
- package/ThComponent.js +0 -44
- package/TimelineEvent.js +0 -31
- package/UploadCsvWizard.css +0 -4
- package/UploadCsvWizard.js +0 -719
- package/Uploader.js +0 -1278
- package/adHoc.js +0 -10
- package/autoTooltip.js +0 -201
- package/basicHandleActionsWithFullState.js +0 -14
- package/browserUtils.js +0 -3
- package/combineReducersWithFullState.js +0 -14
- package/commandControls.js +0 -82
- package/commandUtils.js +0 -112
- package/constants.js +0 -1
- package/convertSchema.js +0 -69
- package/customIcons.js +0 -361
- package/dataTableEnhancer.js +0 -41
- package/defaultFormatters.js +0 -32
- package/defaultValidators.js +0 -40
- package/determineBlackOrWhiteTextColor.js +0 -4
- package/editCellHelper.js +0 -44
- package/formatPasteData.js +0 -16
- package/getAllRows.js +0 -11
- package/getCellCopyText.js +0 -7
- package/getCellInfo.js +0 -36
- package/getCellVal.js +0 -20
- package/getDayjsFormatter.js +0 -35
- package/getFieldPathToField.js +0 -7
- package/getIdOrCodeOrIndex.js +0 -9
- package/getLastSelectedEntity.js +0 -11
- package/getNewEntToSelect.js +0 -25
- package/getNewName.js +0 -31
- package/getRowCopyText.js +0 -28
- package/getTableConfigFromStorage.js +0 -5
- package/getTextFromEl.js +0 -28
- package/getVals.js +0 -8
- package/handleCopyColumn.js +0 -21
- package/handleCopyHelper.js +0 -15
- package/handleCopyRows.js +0 -23
- package/handleCopyTable.js +0 -16
- package/handlerHelpers.js +0 -24
- package/hotkeyUtils.js +0 -131
- package/index.js +0 -1
- package/isBeingCalledExcessively.js +0 -32
- package/isBottomRightCornerOfRectangle.js +0 -20
- package/isEntityClean.js +0 -15
- package/isTruthy.js +0 -12
- package/isValueEmpty.js +0 -3
- package/itemUpload.js +0 -84
- package/menuUtils.js +0 -433
- package/popoverOverflowModifiers.js +0 -11
- package/primarySelectedValue.js +0 -1
- package/pureNoFunc.js +0 -31
- package/queryParams.js +0 -1058
- package/removeCleanRows.js +0 -22
- package/renderOnDoc.js +0 -32
- package/rerenderOnWindowResize.js +0 -26
- package/rowClick.js +0 -181
- package/selection.js +0 -8
- package/showAppSpinner.js +0 -12
- package/showDialogOnDocBody.js +0 -33
- package/showProgressToast.js +0 -22
- package/sortify.js +0 -73
- package/src/DataTable/utils/filterLocalEntitiesToHasura.js +0 -236
- package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +0 -587
- package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +0 -26
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +0 -253
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +0 -206
- package/style.css +0 -29
- package/tagUtils.js +0 -45
- package/tgFormValues.js +0 -35
- package/tg_modalState.js +0 -47
- package/throwFormError.js +0 -16
- package/toastr.js +0 -148
- package/tryToMatchSchemas.js +0 -264
- package/typeToCommonType.js +0 -6
- package/useDeepEqualMemo.js +0 -15
- package/useDialog.js +0 -63
- package/useStableReference.js +0 -9
- package/useTableEntities.js +0 -38
- package/useTraceUpdate.js +0 -19
- package/utils.js +0 -37
- package/validateTableWideErrors.js +0 -160
- package/viewColumn.js +0 -97
- package/withField.js +0 -20
- package/withFields.js +0 -11
- package/withLocalStorage.js +0 -11
- package/withSelectTableRecords.js +0 -43
- package/withSelectedEntities.js +0 -65
- package/withStore.js +0 -10
- package/withTableParams.js +0 -301
- package/wrapDialog.js +0 -116
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export function tableQueryParamsToHasuraClauses({ page, pageSize, searchTerm, filters, order, schema, additionalFilter }: {
|
|
2
|
-
page: any;
|
|
3
|
-
pageSize: any;
|
|
4
|
-
searchTerm: any;
|
|
5
|
-
filters: any;
|
|
6
|
-
order: any;
|
|
7
|
-
schema: any;
|
|
8
|
-
additionalFilter: any;
|
|
9
|
-
}): {
|
|
10
|
-
where: {};
|
|
11
|
-
order_by: {};
|
|
12
|
-
limit: any;
|
|
13
|
-
offset: number;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Takes a schema and returns an object with the fields mapped by their camelCased display name.
|
|
17
|
-
* If the displayName is not set or is a jsx element, the path is used instead.
|
|
18
|
-
* The same conversion must be done when using the result of this method
|
|
19
|
-
*/
|
|
20
|
-
export function getFieldsMappedByCCDisplayName(schema: any): any;
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {object} field
|
|
24
|
-
* @returns the camelCase display name of the field, to be used for filters, sorting, etc
|
|
25
|
-
*/
|
|
26
|
-
export function getCCDisplayName(field: object): string;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ReactTableDefaults } from "@teselagen/react-table";
|
|
3
|
-
const { LoadingComponent } = ReactTableDefaults;
|
|
4
|
-
|
|
5
|
-
function DisabledLoadingComponent({ disabled, loading, loadingText }) {
|
|
6
|
-
return (
|
|
7
|
-
<LoadingComponent
|
|
8
|
-
className={disabled ? "disabled" : ""}
|
|
9
|
-
loading={loading}
|
|
10
|
-
loadingText={disabled ? "" : loadingText}
|
|
11
|
-
/>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default DisabledLoadingComponent;
|
package/DisplayOptions.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { map, isEmpty, noop, startCase } from "lodash-es";
|
|
3
|
-
import {
|
|
4
|
-
Button,
|
|
5
|
-
Checkbox,
|
|
6
|
-
Menu,
|
|
7
|
-
MenuItem,
|
|
8
|
-
Classes,
|
|
9
|
-
InputGroup,
|
|
10
|
-
Popover,
|
|
11
|
-
Switch
|
|
12
|
-
} from "@blueprintjs/core";
|
|
13
|
-
import { getCCDisplayName } from "./utils/queryParams";
|
|
14
|
-
|
|
15
|
-
const DisplayOptions = ({
|
|
16
|
-
compact,
|
|
17
|
-
extraCompact,
|
|
18
|
-
disabled,
|
|
19
|
-
hideDisplayOptionsIcon,
|
|
20
|
-
resetDefaultVisibility = noop,
|
|
21
|
-
updateColumnVisibility = noop,
|
|
22
|
-
updateTableDisplayDensity,
|
|
23
|
-
showForcedHiddenColumns,
|
|
24
|
-
setShowForcedHidden,
|
|
25
|
-
hasOptionForForcedHidden,
|
|
26
|
-
schema
|
|
27
|
-
}) => {
|
|
28
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
29
|
-
const [searchTerms, setSearchTerms] = useState({});
|
|
30
|
-
|
|
31
|
-
const changeTableDensity = e => {
|
|
32
|
-
updateTableDisplayDensity(e.target.value);
|
|
33
|
-
setIsOpen(false);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const toggleForcedHidden = e => setShowForcedHidden(e.target.checked);
|
|
37
|
-
|
|
38
|
-
if (hideDisplayOptionsIcon) {
|
|
39
|
-
return null; //don't show antyhing!
|
|
40
|
-
}
|
|
41
|
-
const { fields } = schema;
|
|
42
|
-
const fieldGroups = {};
|
|
43
|
-
const mainFields = [];
|
|
44
|
-
|
|
45
|
-
fields.forEach(field => {
|
|
46
|
-
if (field.hideInMenu) return;
|
|
47
|
-
if (!field.fieldGroup) return mainFields.push(field);
|
|
48
|
-
if (!fieldGroups[field.fieldGroup]) fieldGroups[field.fieldGroup] = [];
|
|
49
|
-
fieldGroups[field.fieldGroup].push(field);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
let numVisible = 0;
|
|
53
|
-
|
|
54
|
-
const getFieldCheckbox = (field, i) => {
|
|
55
|
-
const { displayName, isHidden, isForcedHidden, path } = field;
|
|
56
|
-
if (isForcedHidden) return;
|
|
57
|
-
if (!isHidden) numVisible++;
|
|
58
|
-
return (
|
|
59
|
-
<Checkbox
|
|
60
|
-
name={`${path}-${i}`}
|
|
61
|
-
key={path || i}
|
|
62
|
-
onChange={() => {
|
|
63
|
-
if (numVisible <= 1 && !isHidden) {
|
|
64
|
-
return window.toastr.warning(
|
|
65
|
-
"We have to display at least one column :)"
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
updateColumnVisibility({ shouldShow: isHidden, path });
|
|
69
|
-
}}
|
|
70
|
-
checked={!isHidden}
|
|
71
|
-
label={displayName}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
let fieldGroupMenu;
|
|
77
|
-
if (!isEmpty(fieldGroups)) {
|
|
78
|
-
fieldGroupMenu = map(fieldGroups, (groupFields, groupName) => {
|
|
79
|
-
const searchTerm = searchTerms[groupName] || "";
|
|
80
|
-
const anyVisible = groupFields.some(
|
|
81
|
-
field => !field.isHidden && !field.isForcedHidden
|
|
82
|
-
);
|
|
83
|
-
const anyNotForcedHidden = groupFields.some(
|
|
84
|
-
field => !field.isForcedHidden
|
|
85
|
-
);
|
|
86
|
-
if (!anyNotForcedHidden) return;
|
|
87
|
-
return (
|
|
88
|
-
<MenuItem key={groupName} text={groupName}>
|
|
89
|
-
<InputGroup
|
|
90
|
-
leftIcon="search"
|
|
91
|
-
value={searchTerm}
|
|
92
|
-
onChange={e => {
|
|
93
|
-
setSearchTerms(prev => ({
|
|
94
|
-
...prev,
|
|
95
|
-
[groupName]: e.target.value
|
|
96
|
-
}));
|
|
97
|
-
}}
|
|
98
|
-
/>
|
|
99
|
-
<Button
|
|
100
|
-
className={Classes.MINIMAL}
|
|
101
|
-
text={(anyVisible ? "Hide" : "Show") + " All"}
|
|
102
|
-
style={{ margin: "10px 0" }}
|
|
103
|
-
onClick={() => {
|
|
104
|
-
updateColumnVisibility({
|
|
105
|
-
shouldShow: !anyVisible,
|
|
106
|
-
paths: groupFields.map(field => field.path)
|
|
107
|
-
});
|
|
108
|
-
}}
|
|
109
|
-
/>
|
|
110
|
-
{groupFields
|
|
111
|
-
.filter(
|
|
112
|
-
field =>
|
|
113
|
-
startCase(getCCDisplayName(field)) // We have to use startCase with the camelCase here because the displayName is not always a string
|
|
114
|
-
.toLowerCase()
|
|
115
|
-
.indexOf(searchTerm.toLowerCase()) > -1
|
|
116
|
-
)
|
|
117
|
-
.map(getFieldCheckbox)}
|
|
118
|
-
</MenuItem>
|
|
119
|
-
);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<Popover
|
|
125
|
-
isOpen={isOpen}
|
|
126
|
-
onClose={() => setIsOpen(false)}
|
|
127
|
-
content={
|
|
128
|
-
<Menu>
|
|
129
|
-
<div style={{ padding: 10, paddingLeft: 20, paddingRight: 20 }}>
|
|
130
|
-
<h5 style={{ marginBottom: 10 }}>Display Density:</h5>
|
|
131
|
-
<div className={Classes.SELECT + " tg-table-display-density"}>
|
|
132
|
-
<select
|
|
133
|
-
onChange={changeTableDensity}
|
|
134
|
-
value={
|
|
135
|
-
extraCompact ? "extraCompact" : compact ? "compact" : "normal"
|
|
136
|
-
}
|
|
137
|
-
>
|
|
138
|
-
<option className={Classes.POPOVER_DISMISS} value="normal">
|
|
139
|
-
Comfortable
|
|
140
|
-
</option>
|
|
141
|
-
{/* tnr: as you can see we're calling what was "compact" Normal now in response to https://github.com/TeselaGen/lims/issues/4713 */}
|
|
142
|
-
<option className={Classes.POPOVER_DISMISS} value="compact">
|
|
143
|
-
Normal
|
|
144
|
-
</option>
|
|
145
|
-
<option
|
|
146
|
-
className={Classes.POPOVER_DISMISS}
|
|
147
|
-
value="extraCompact"
|
|
148
|
-
>
|
|
149
|
-
Compact
|
|
150
|
-
</option>
|
|
151
|
-
</select>
|
|
152
|
-
</div>
|
|
153
|
-
<h5 style={{ marginBottom: 10, marginTop: 10 }}>
|
|
154
|
-
Displayed Columns:
|
|
155
|
-
</h5>
|
|
156
|
-
<div style={{ maxHeight: 260, overflowY: "auto", padding: 2 }}>
|
|
157
|
-
{mainFields.map(getFieldCheckbox)}
|
|
158
|
-
</div>
|
|
159
|
-
<div>{fieldGroupMenu}</div>
|
|
160
|
-
{hasOptionForForcedHidden && (
|
|
161
|
-
<div style={{ marginTop: 15 }}>
|
|
162
|
-
<Switch
|
|
163
|
-
label="Show Empty Columns"
|
|
164
|
-
checked={showForcedHiddenColumns}
|
|
165
|
-
onChange={toggleForcedHidden}
|
|
166
|
-
/>
|
|
167
|
-
</div>
|
|
168
|
-
)}
|
|
169
|
-
<div
|
|
170
|
-
style={{
|
|
171
|
-
width: "100%",
|
|
172
|
-
display: "flex",
|
|
173
|
-
justifyContent: "flex-end"
|
|
174
|
-
}}
|
|
175
|
-
>
|
|
176
|
-
<Button
|
|
177
|
-
onClick={resetDefaultVisibility}
|
|
178
|
-
title="Display Options"
|
|
179
|
-
minimal
|
|
180
|
-
>
|
|
181
|
-
Reset
|
|
182
|
-
</Button>
|
|
183
|
-
</div>
|
|
184
|
-
</div>
|
|
185
|
-
</Menu>
|
|
186
|
-
}
|
|
187
|
-
>
|
|
188
|
-
<Button
|
|
189
|
-
className="tg-table-display-options"
|
|
190
|
-
onClick={() => setIsOpen(true)}
|
|
191
|
-
disabled={disabled}
|
|
192
|
-
minimal
|
|
193
|
-
icon="cog"
|
|
194
|
-
/>
|
|
195
|
-
</Popover>
|
|
196
|
-
);
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
export default DisplayOptions;
|
package/DropdownButton.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* Copyright (C) 2018 TeselaGen Biotechnology, Inc. */
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { Button, Popover, Position } from "@blueprintjs/core";
|
|
5
|
-
import classnames from "classnames";
|
|
6
|
-
import popoverOverflowModifiers from "./utils/popoverOverflowModifiers";
|
|
7
|
-
|
|
8
|
-
function DropdownButton({
|
|
9
|
-
disabled,
|
|
10
|
-
menu,
|
|
11
|
-
noRightIcon,
|
|
12
|
-
popoverProps,
|
|
13
|
-
className,
|
|
14
|
-
...rest
|
|
15
|
-
}) {
|
|
16
|
-
return (
|
|
17
|
-
<Popover
|
|
18
|
-
minimal
|
|
19
|
-
modifiers={popoverOverflowModifiers}
|
|
20
|
-
disabled={disabled}
|
|
21
|
-
autoFocus={false}
|
|
22
|
-
content={menu}
|
|
23
|
-
position={Position.BOTTOM_LEFT}
|
|
24
|
-
{...popoverProps}
|
|
25
|
-
>
|
|
26
|
-
<Button
|
|
27
|
-
disabled={disabled}
|
|
28
|
-
className={classnames(className, "dropdown-button")}
|
|
29
|
-
rightIcon={noRightIcon ? undefined : "caret-down"}
|
|
30
|
-
{...rest}
|
|
31
|
-
/>
|
|
32
|
-
</Popover>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default DropdownButton;
|
package/DropdownCell.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import TgSelect from "../TgSelect";
|
|
4
|
-
|
|
5
|
-
export const DropdownCell = ({
|
|
6
|
-
options,
|
|
7
|
-
isMulti,
|
|
8
|
-
initialValue,
|
|
9
|
-
finishEdit,
|
|
10
|
-
cancelEdit,
|
|
11
|
-
dataTest
|
|
12
|
-
}) => {
|
|
13
|
-
const [v, setV] = useState(
|
|
14
|
-
isMulti
|
|
15
|
-
? initialValue.split(",").map(v => ({ value: v, label: v }))
|
|
16
|
-
: initialValue
|
|
17
|
-
);
|
|
18
|
-
return (
|
|
19
|
-
<div
|
|
20
|
-
className={classNames("tg-dropdown-cell-edit-container", {
|
|
21
|
-
"tg-dropdown-cell-edit-container-multi": isMulti
|
|
22
|
-
})}
|
|
23
|
-
>
|
|
24
|
-
<TgSelect
|
|
25
|
-
small
|
|
26
|
-
multi={isMulti}
|
|
27
|
-
autoOpen
|
|
28
|
-
value={v}
|
|
29
|
-
onChange={val => {
|
|
30
|
-
if (isMulti) {
|
|
31
|
-
setV(val);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
finishEdit(val ? val.value : null);
|
|
35
|
-
}}
|
|
36
|
-
{...dataTest}
|
|
37
|
-
popoverProps={{
|
|
38
|
-
onClose: e => {
|
|
39
|
-
if (isMulti) {
|
|
40
|
-
if (e && e.key === "Escape") {
|
|
41
|
-
cancelEdit();
|
|
42
|
-
} else {
|
|
43
|
-
finishEdit(
|
|
44
|
-
v && v.map
|
|
45
|
-
? v
|
|
46
|
-
.map(v => v.value)
|
|
47
|
-
.filter(v => v)
|
|
48
|
-
.join(",")
|
|
49
|
-
: v
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
cancelEdit();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}}
|
|
57
|
-
options={options.map(value => ({ label: value, value }))}
|
|
58
|
-
/>
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
};
|
package/EditableCell.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
export const EditableCell = ({
|
|
4
|
-
cancelEdit,
|
|
5
|
-
dataTest,
|
|
6
|
-
finishEdit,
|
|
7
|
-
isNumeric,
|
|
8
|
-
initialValue
|
|
9
|
-
}) => {
|
|
10
|
-
const [value, setValue] = useState(initialValue);
|
|
11
|
-
const inputRef = useRef(null);
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
if (inputRef.current) {
|
|
15
|
-
inputRef.current.focus();
|
|
16
|
-
}
|
|
17
|
-
}, [isNumeric]);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<input
|
|
21
|
-
style={{
|
|
22
|
-
border: 0,
|
|
23
|
-
width: "95%",
|
|
24
|
-
fontSize: 12,
|
|
25
|
-
background: "none"
|
|
26
|
-
}}
|
|
27
|
-
ref={inputRef}
|
|
28
|
-
{...dataTest}
|
|
29
|
-
autoFocus
|
|
30
|
-
onKeyDown={e => {
|
|
31
|
-
e.stopPropagation();
|
|
32
|
-
if (e.key === "Enter") {
|
|
33
|
-
e.target.blur();
|
|
34
|
-
} else if (e.key === "Escape") {
|
|
35
|
-
cancelEdit();
|
|
36
|
-
}
|
|
37
|
-
}}
|
|
38
|
-
onBlur={() => finishEdit(value)}
|
|
39
|
-
onChange={e => setValue(e.target.value)}
|
|
40
|
-
type={isNumeric ? "number" : undefined}
|
|
41
|
-
value={value}
|
|
42
|
-
/>
|
|
43
|
-
);
|
|
44
|
-
};
|
package/FillWindow.css
DELETED
package/FillWindow.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { createPortal } from "react-dom";
|
|
3
|
-
import { isFunction } from "lodash-es";
|
|
4
|
-
import rerenderOnWindowResize from "./rerenderOnWindowResize";
|
|
5
|
-
import "./FillWindow.css";
|
|
6
|
-
|
|
7
|
-
// use like:
|
|
8
|
-
// <FillWindow>
|
|
9
|
-
// {({ width, height }) => {
|
|
10
|
-
// return <div style={{width, height}}></div>
|
|
11
|
-
// }
|
|
12
|
-
// <FillWindow/>
|
|
13
|
-
|
|
14
|
-
export default class FillWindow extends React.Component {
|
|
15
|
-
constructor(props) {
|
|
16
|
-
super(props);
|
|
17
|
-
rerenderOnWindowResize(this);
|
|
18
|
-
}
|
|
19
|
-
// this is left here for posterity. componentDidMount didn't work before commit ee1853a5ae2e6e27b720dd225650cc2154076db5 "fixing rerenderOnWindowResize to bind this keyword correctly"
|
|
20
|
-
// componentDidMount(){
|
|
21
|
-
// this.setState({thomas: "realCool"})
|
|
22
|
-
// }
|
|
23
|
-
|
|
24
|
-
render() {
|
|
25
|
-
const w = window,
|
|
26
|
-
d = document,
|
|
27
|
-
e = d.documentElement,
|
|
28
|
-
g = d.getElementsByTagName("body")[0],
|
|
29
|
-
width = w.innerWidth || e.clientWidth || g.clientWidth,
|
|
30
|
-
height = w.innerHeight || e.clientHeight || g.clientHeight;
|
|
31
|
-
const windowDimensions = {
|
|
32
|
-
width,
|
|
33
|
-
height
|
|
34
|
-
};
|
|
35
|
-
const {
|
|
36
|
-
containerStyle = {},
|
|
37
|
-
style,
|
|
38
|
-
styleOverrides,
|
|
39
|
-
className,
|
|
40
|
-
asPortal,
|
|
41
|
-
...rest
|
|
42
|
-
} = this.props;
|
|
43
|
-
if (this.props.disabled) return this.props.children(windowDimensions);
|
|
44
|
-
const inner = (
|
|
45
|
-
<div
|
|
46
|
-
className={
|
|
47
|
-
"tg-fillWindow " + (asPortal ? "bp3-portal " : "") + (className || "")
|
|
48
|
-
}
|
|
49
|
-
style={{
|
|
50
|
-
...style,
|
|
51
|
-
width,
|
|
52
|
-
height,
|
|
53
|
-
position: "fixed",
|
|
54
|
-
top: 0,
|
|
55
|
-
left: 0,
|
|
56
|
-
...containerStyle,
|
|
57
|
-
...styleOverrides
|
|
58
|
-
}}
|
|
59
|
-
{...rest}
|
|
60
|
-
>
|
|
61
|
-
{this.props.children && isFunction(this.props.children)
|
|
62
|
-
? this.props.children(windowDimensions)
|
|
63
|
-
: this.props.children}
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
if (asPortal) return createPortal(inner, window.document.body);
|
|
67
|
-
return inner;
|
|
68
|
-
}
|
|
69
|
-
}
|