@terraware/web-components 3.5.12-rc.7 → 3.5.12
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/components/AntSwitch/index.js +27 -0
- package/components/AntSwitch/styles.scss +66 -0
- package/components/Autocomplete/Autocomplete.js +131 -0
- package/components/Autocomplete/styles.scss +155 -0
- package/components/Badge/index.js +32 -0
- package/components/BusySpinner/index.js +49 -0
- package/components/Button/Button.js +51 -0
- package/components/Button/button.test.js +25 -0
- package/components/Button/styles.scss +453 -0
- package/components/Checkbox.js +70 -0
- package/components/Confirm/index.js +94 -0
- package/components/DatePicker/DatePicker.js +150 -0
- package/components/DatePicker/styles.scss +95 -0
- package/components/DialogBox/DialogBox.js +91 -0
- package/components/DialogBox/styles.scss +165 -0
- package/components/Divisor.js +21 -0
- package/components/Dropdown.js +102 -0
- package/components/ErrorBox/ErrorBox.js +47 -0
- package/components/ErrorBox/styles.scss +63 -0
- package/components/FileChooser/index.js +137 -0
- package/components/FormBottomBar/index.js +90 -0
- package/components/Icon/Icon.js +25 -0
- package/components/Icon/icons/index.js +241 -0
- package/components/Icon/styles.scss +41 -0
- package/components/IconTooltip/index.js +61 -0
- package/components/Map/MapBox.d.ts.map +1 -1
- package/components/Map/MapBox.js +479 -0
- package/components/Map/MapContainer.js +30 -0
- package/components/Map/MapDateSliderControl.js +66 -0
- package/components/Map/MapDrawer.js +45 -0
- package/components/Map/MapLegend.js +172 -0
- package/components/Map/MapViewStyleControl.js +74 -0
- package/components/Map/ReactMapboxWrapper.d.ts +3 -0
- package/components/Map/ReactMapboxWrapper.d.ts.map +1 -0
- package/components/Map/ReactMapboxWrapper.js +9 -0
- package/components/Map/index.js +190 -0
- package/components/Map/styles.scss +130 -0
- package/components/Map/types.js +24 -0
- package/components/Map/useMaintainLayerOrder.js +32 -0
- package/components/Message/Message.js +67 -0
- package/components/Message/styles.scss +202 -0
- package/components/MultiSelect/MultiSelect.test.js +75 -0
- package/components/MultiSelect/index.js +120 -0
- package/components/MultiSelect/styles.scss +180 -0
- package/components/Navbar/NavFooter.js +17 -0
- package/components/Navbar/NavItem.js +73 -0
- package/components/Navbar/NavSection.js +22 -0
- package/components/Navbar/Navbar.js +46 -0
- package/components/Navbar/SubNavbar.js +17 -0
- package/components/Navbar/styles.scss +155 -0
- package/components/Note.js +25 -0
- package/components/PageForm/index.js +43 -0
- package/components/PhotoChooser/index.js +137 -0
- package/components/Pill/index.js +46 -0
- package/components/Pill/styles.scss +50 -0
- package/components/PillList/index.js +29 -0
- package/components/PillList/styles.scss +12 -0
- package/components/PlacementWrapper/index.js +63 -0
- package/components/PopoverMenu/Popover.js +88 -0
- package/components/PopoverMenu/index.js +59 -0
- package/components/PopoverMultiSelect/index.js +62 -0
- package/components/PopoverMultiSelect/styles.scss +10 -0
- package/components/ProgressCircle/ProgressCircle.js +34 -0
- package/components/ProgressCircle/styles.scss +87 -0
- package/components/RadioButton.js +25 -0
- package/components/Select/Select.js +19 -0
- package/components/Select/SelectT.js +245 -0
- package/components/Select/styles.scss +307 -0
- package/components/Separator/index.js +21 -0
- package/components/Size.js +5 -0
- package/components/Slider/index.js +60 -0
- package/components/SummaryBox.js +73 -0
- package/components/Tabs/index.js +111 -0
- package/components/TextTruncated/index.js +146 -0
- package/components/Textfield/Textfield.js +172 -0
- package/components/Textfield/TruncatedTextArea.js +71 -0
- package/components/Textfield/styles.scss +271 -0
- package/components/Tooltip/Tooltip.js +54 -0
- package/components/ViewPhotosDialog/index.js +136 -0
- package/components/ViewPhotosDialog/styles.scss +18 -0
- package/components/svg/BlobbyGrayIconImage.js +39 -0
- package/components/svg/BlobbyGrayIconImport.js +39 -0
- package/components/svg/BlobbyGrayIconUploadToTheCloud.js +39 -0
- package/components/svg/BlobbyIconCloudChecked.js +156 -0
- package/components/svg/BlobbyIconExportOrUploadPhoto.js +156 -0
- package/components/svg/BlobbyIconFolder.js +156 -0
- package/components/svg/BlobbyIconGraphReport.js +156 -0
- package/components/svg/BlobbyIconHappy.js +156 -0
- package/components/svg/BlobbyIconHeartMonitor.js +156 -0
- package/components/svg/BlobbyIconLeaf.js +156 -0
- package/components/svg/BlobbyIconLibrary.js +156 -0
- package/components/svg/BlobbyIconNursery.js +158 -0
- package/components/svg/BlobbyIconOrganization.js +156 -0
- package/components/svg/BlobbyIconParchment.js +156 -0
- package/components/svg/BlobbyIconPeople.js +156 -0
- package/components/svg/BlobbyIconSeedBank.js +156 -0
- package/components/svg/BlobbyIconSeedling.js +156 -0
- package/components/svg/BlobbyIconSeeds.js +156 -0
- package/components/svg/BlobbyIconSite.js +159 -0
- package/components/svg/BlobbyIconSparkles.js +156 -0
- package/components/svg/BlobbyIconWrench.js +156 -0
- package/components/svg/Bug.js +25 -0
- package/components/svg/Calendar.js +25 -0
- package/components/svg/CaretDown.js +25 -0
- package/components/svg/CaretLeft.js +25 -0
- package/components/svg/CaretRight.js +25 -0
- package/components/svg/CaretUp.js +25 -0
- package/components/svg/ChevronDown.js +25 -0
- package/components/svg/ChevronUp.js +25 -0
- package/components/svg/Close.js +25 -0
- package/components/svg/Critical.js +25 -0
- package/components/svg/Edit.js +156 -0
- package/components/svg/Error.js +25 -0
- package/components/svg/Filter.js +25 -0
- package/components/svg/Folder.js +25 -0
- package/components/svg/Help.js +25 -0
- package/components/svg/Home.js +25 -0
- package/components/svg/IconAdd.js +25 -0
- package/components/svg/IconArrowRight.js +27 -0
- package/components/svg/IconBusinessNetwork.js +25 -0
- package/components/svg/IconCancel.js +25 -0
- package/components/svg/IconChargingBattery.js +25 -0
- package/components/svg/IconCheckmark.js +25 -0
- package/components/svg/IconCoinInHand.js +25 -0
- package/components/svg/IconColumns.js +25 -0
- package/components/svg/IconComment.js +26 -0
- package/components/svg/IconDashboard.js +25 -0
- package/components/svg/IconDataMigration.js +25 -0
- package/components/svg/IconEdit.js +27 -0
- package/components/svg/IconExport.js +25 -0
- package/components/svg/IconExternalLink.js +25 -0
- package/components/svg/IconEye.js +25 -0
- package/components/svg/IconEyeOff.js +25 -0
- package/components/svg/IconFile.js +25 -0
- package/components/svg/IconFolder.js +25 -0
- package/components/svg/IconFullScreen.js +26 -0
- package/components/svg/IconFutures.js +25 -0
- package/components/svg/IconGraphReport.js +25 -0
- package/components/svg/IconHeartMonitor.js +25 -0
- package/components/svg/IconHelp.js +27 -0
- package/components/svg/IconHistory.js +25 -0
- package/components/svg/IconImport.js +25 -0
- package/components/svg/IconIndex.js +25 -0
- package/components/svg/IconLayers.js +25 -0
- package/components/svg/IconLibrary.js +26 -0
- package/components/svg/IconList.js +25 -0
- package/components/svg/IconLivePlant.js +25 -0
- package/components/svg/IconLocations.js +25 -0
- package/components/svg/IconMail.js +25 -0
- package/components/svg/IconManager.js +25 -0
- package/components/svg/IconMarker.js +25 -0
- package/components/svg/IconMenu.js +25 -0
- package/components/svg/IconMenuHorizontal.js +25 -0
- package/components/svg/IconModule.js +25 -0
- package/components/svg/IconMyLocation.js +25 -0
- package/components/svg/IconNote.js +27 -0
- package/components/svg/IconNursery.js +27 -0
- package/components/svg/IconOrg.js +25 -0
- package/components/svg/IconParchment.js +25 -0
- package/components/svg/IconPhoto.js +25 -0
- package/components/svg/IconRedo.js +25 -0
- package/components/svg/IconRestorationSite.js +25 -0
- package/components/svg/IconSeedBank.js +25 -0
- package/components/svg/IconSeedling.js +25 -0
- package/components/svg/IconSettings.js +25 -0
- package/components/svg/IconSlice.js +25 -0
- package/components/svg/IconSubmit.js +25 -0
- package/components/svg/IconSubtract.js +27 -0
- package/components/svg/IconSynced.js +25 -0
- package/components/svg/IconTrashCan.js +25 -0
- package/components/svg/IconTreasureMap.js +25 -0
- package/components/svg/IconUndo.js +25 -0
- package/components/svg/IconVariable.js +25 -0
- package/components/svg/IconWifi.js +25 -0
- package/components/svg/Info.js +25 -0
- package/components/svg/Key.js +25 -0
- package/components/svg/Leaf.js +25 -0
- package/components/svg/Lock.js +25 -0
- package/components/svg/Logo.js +43 -0
- package/components/svg/MenuVertical.js +25 -0
- package/components/svg/Notification.js +25 -0
- package/components/svg/Person.js +25 -0
- package/components/svg/Plus.js +25 -0
- package/components/svg/RestorationSite.js +25 -0
- package/components/svg/Search.js +25 -0
- package/components/svg/Seeds.js +25 -0
- package/components/svg/Site.js +25 -0
- package/components/svg/Sparkles.js +25 -0
- package/components/svg/Species.js +25 -0
- package/components/svg/Species2.js +156 -0
- package/components/svg/Spinner.js +52 -0
- package/components/svg/Success.js +25 -0
- package/components/svg/SuccessFilled.js +25 -0
- package/components/svg/TerrawareLogoDesktop.js +49 -0
- package/components/svg/TerrawareLogoMobile.js +30 -0
- package/components/svg/Touchscreen.js +25 -0
- package/components/svg/UploadCloud.js +156 -0
- package/components/svg/Warning.js +25 -0
- package/components/svg/WelcomeClipboard.js +133 -0
- package/components/svg/index.js +832 -0
- package/components/table/EnhancedTableToolbar.js +76 -0
- package/components/table/EnhancedTableToolbarV2.js +49 -0
- package/components/table/TableCellRenderer.js +244 -0
- package/components/table/TableHeader.js +75 -0
- package/components/table/TableHeaderItem.js +100 -0
- package/components/table/density.js +28 -0
- package/components/table/index.js +346 -0
- package/components/table/sort.js +72 -0
- package/components/table/sort.test.js +37 -0
- package/components/table/types.js +5 -0
- package/components/types/index.js +5 -0
- package/fonts/Inter.ttf +0 -0
- package/index.css +11 -0
- package/index.js +377 -0
- package/package.json +2 -5
- package/setupTests.js +5 -0
- package/style-dictionary-dist/TerrawareTheme.js +193 -0
- package/style-dictionary-dist/terraware.scss +414 -0
- package/theme.js +86 -0
- package/utils/date.js +124 -0
- package/utils/date.test.js +87 -0
- package/utils/index.js +53 -0
- package/utils/preventDefaultEvent.js +8 -0
- package/utils/text.js +17 -0
- package/utils/text.test.js +23 -0
- package/utils/useDeviceInfo.js +85 -0
- package/index.cjs.js +0 -88606
- package/index.cjs.js.map +0 -1
- package/index.esm.js +0 -88533
- package/index.esm.js.map +0 -1
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = EnhancedTable;
|
|
9
|
+
exports.isTopBarButton = void 0;
|
|
10
|
+
exports.tableSort = tableSort;
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _core = require("@dnd-kit/core");
|
|
13
|
+
var _sortable = require("@dnd-kit/sortable");
|
|
14
|
+
var _material = require("@mui/material");
|
|
15
|
+
var _utils = require("../../utils");
|
|
16
|
+
var _Checkbox = require("../Checkbox");
|
|
17
|
+
var _EnhancedTableToolbarV = _interopRequireDefault(require("./EnhancedTableToolbarV2"));
|
|
18
|
+
var _TableCellRenderer = _interopRequireDefault(require("./TableCellRenderer"));
|
|
19
|
+
var _TableHeader = _interopRequireDefault(require("./TableHeader"));
|
|
20
|
+
var _density = require("./density");
|
|
21
|
+
var _sort = require("./sort");
|
|
22
|
+
// Only the text related props need to be passed in by the implementer, and extra data is passed to the caller
|
|
23
|
+
|
|
24
|
+
const isTopBarButton = input => {
|
|
25
|
+
const castInput = input;
|
|
26
|
+
return !!(castInput.buttonType && castInput.onButtonClick);
|
|
27
|
+
};
|
|
28
|
+
exports.isTopBarButton = isTopBarButton;
|
|
29
|
+
function EnhancedTable(_ref) {
|
|
30
|
+
let {
|
|
31
|
+
id,
|
|
32
|
+
columns,
|
|
33
|
+
rows,
|
|
34
|
+
order: _order = 'asc',
|
|
35
|
+
orderBy: _orderBy,
|
|
36
|
+
Renderer = _TableCellRenderer.default,
|
|
37
|
+
onSelect,
|
|
38
|
+
DetailsRenderer,
|
|
39
|
+
sortComparator = _sort.descendingComparator,
|
|
40
|
+
sortHandler,
|
|
41
|
+
isInactive,
|
|
42
|
+
isPresorted,
|
|
43
|
+
onReorderEnd,
|
|
44
|
+
isClickable,
|
|
45
|
+
emptyTableMessage,
|
|
46
|
+
showCheckbox,
|
|
47
|
+
showTopBar,
|
|
48
|
+
topBarButtons,
|
|
49
|
+
selectedRows,
|
|
50
|
+
setSelectedRows,
|
|
51
|
+
controlledOnSelect,
|
|
52
|
+
reloadData,
|
|
53
|
+
stickyHeader = true,
|
|
54
|
+
hideHeader,
|
|
55
|
+
booleanFalseText,
|
|
56
|
+
booleanTrueText,
|
|
57
|
+
editText,
|
|
58
|
+
renderNumSelectedText,
|
|
59
|
+
renderPaginationText,
|
|
60
|
+
enhancedTopBarSelectionConfig,
|
|
61
|
+
density = 'comfortable',
|
|
62
|
+
tableComments
|
|
63
|
+
} = _ref;
|
|
64
|
+
const theme = (0, _material.useTheme)();
|
|
65
|
+
const [order, setOrder] = _react.default.useState(_order);
|
|
66
|
+
const [orderBy, setOrderBy] = _react.default.useState(_orderBy);
|
|
67
|
+
const [maxItemsPerPage] = (0, _react.useState)(100);
|
|
68
|
+
const [itemsToSkip, setItemsToSkip] = (0, _react.useState)(0);
|
|
69
|
+
const {
|
|
70
|
+
isMobile
|
|
71
|
+
} = (0, _utils.useDeviceInfo)();
|
|
72
|
+
const [displayColumnKeyNames, setDisplayColumnKeyNames] = (0, _react.useState)();
|
|
73
|
+
const [displayColumnsIndexed, setDisplayColumnsIndexed] = (0, _react.useState)();
|
|
74
|
+
const [displayColumnDetails, setDisplayColumnDetails] = (0, _react.useState)();
|
|
75
|
+
(0, _react.useEffect)(() => {
|
|
76
|
+
const columnsKeyNames = columns.map(col => col.key);
|
|
77
|
+
const columnsIndexed = columns.reduce((acum, value) => {
|
|
78
|
+
acum[value.key] = value;
|
|
79
|
+
return acum;
|
|
80
|
+
}, {});
|
|
81
|
+
setDisplayColumnKeyNames(columnsKeyNames);
|
|
82
|
+
setDisplayColumnsIndexed(columnsIndexed);
|
|
83
|
+
}, [columns]);
|
|
84
|
+
(0, _react.useEffect)(() => {
|
|
85
|
+
if (displayColumnKeyNames && displayColumnsIndexed) {
|
|
86
|
+
const columnsDetails = displayColumnKeyNames.map(key => {
|
|
87
|
+
const detail = {
|
|
88
|
+
...displayColumnsIndexed[key]
|
|
89
|
+
};
|
|
90
|
+
return detail;
|
|
91
|
+
});
|
|
92
|
+
setDisplayColumnDetails(columnsDetails);
|
|
93
|
+
}
|
|
94
|
+
}, [displayColumnKeyNames, displayColumnsIndexed]);
|
|
95
|
+
(0, _react.useEffect)(() => {
|
|
96
|
+
if (setSelectedRows && rows.length >= 0) {
|
|
97
|
+
setSelectedRows(currentlySelectedRows => {
|
|
98
|
+
const emptyArray = [];
|
|
99
|
+
if (rows.length || currentlySelectedRows.length > rows.length) {
|
|
100
|
+
return emptyArray;
|
|
101
|
+
}
|
|
102
|
+
return currentlySelectedRows;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}, [rows, setSelectedRows]);
|
|
106
|
+
(0, _react.useEffect)(() => {
|
|
107
|
+
// this is not most elegant but we want to do this if table was sorted by some column in a presorted table
|
|
108
|
+
// but we don't know when the data changes, hence this useEffect on the data size
|
|
109
|
+
if (isPresorted) {
|
|
110
|
+
// we want to set page back to 1 if the data changes on presorted lists,
|
|
111
|
+
// this is because the data was reset due to some sort behavior refetching new data
|
|
112
|
+
handleChangePage({}, 1);
|
|
113
|
+
}
|
|
114
|
+
}, [rows]);
|
|
115
|
+
const handleRequestSort = (event, property) => {
|
|
116
|
+
const isAsc = orderBy === property && order === 'asc';
|
|
117
|
+
const newOrder = isAsc ? 'desc' : 'asc';
|
|
118
|
+
setOrder(newOrder);
|
|
119
|
+
setOrderBy(property);
|
|
120
|
+
if (sortHandler) {
|
|
121
|
+
sortHandler(newOrder, property);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const hasEditColumn = columns.filter(c => c.type === 'edit').length > 0;
|
|
125
|
+
const isSelected = row => {
|
|
126
|
+
return selectedRows && selectedRows.indexOf(row) !== -1;
|
|
127
|
+
};
|
|
128
|
+
const handleSelectAllClick = event => {
|
|
129
|
+
if (setSelectedRows) {
|
|
130
|
+
if (event.target.checked) {
|
|
131
|
+
setSelectedRows(rows);
|
|
132
|
+
return;
|
|
133
|
+
} else {
|
|
134
|
+
setSelectedRows([]);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const handleClick = (event, row) => {
|
|
139
|
+
if (setSelectedRows && selectedRows) {
|
|
140
|
+
const selectedIndex = selectedRows.indexOf(row);
|
|
141
|
+
let newSelected = [];
|
|
142
|
+
if (selectedIndex === -1) {
|
|
143
|
+
newSelected = newSelected.concat(selectedRows, row);
|
|
144
|
+
} else if (selectedIndex === 0) {
|
|
145
|
+
newSelected = newSelected.concat(selectedRows.slice(1));
|
|
146
|
+
} else if (selectedIndex === selectedRows.length - 1) {
|
|
147
|
+
newSelected = newSelected.concat(selectedRows.slice(0, -1));
|
|
148
|
+
} else if (selectedIndex > 0) {
|
|
149
|
+
newSelected = newSelected.concat(selectedRows.slice(0, selectedIndex), selectedRows.slice(selectedIndex + 1));
|
|
150
|
+
}
|
|
151
|
+
setSelectedRows(newSelected);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const handleChangePage = (event, newPage) => {
|
|
155
|
+
setItemsToSkip(maxItemsPerPage * (newPage - 1));
|
|
156
|
+
};
|
|
157
|
+
function columnsToHeadCells(columnsR) {
|
|
158
|
+
return columnsR.map(c => ({
|
|
159
|
+
id: c.key,
|
|
160
|
+
disablePadding: true,
|
|
161
|
+
label: typeof c.name === 'string' ? c.name.toUpperCase() : c.name,
|
|
162
|
+
sx: [{
|
|
163
|
+
paddingY: (0, _density.getTableCellPaddingY)(density)
|
|
164
|
+
}, ...(Array.isArray(c.sx) ? c.sx : [c.sx])],
|
|
165
|
+
tooltipTitle: c.tooltipTitle
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
const [headCells, setHeadCells] = _react.default.useState();
|
|
169
|
+
_react.default.useEffect(() => {
|
|
170
|
+
if (displayColumnDetails) {
|
|
171
|
+
setHeadCells(columnsToHeadCells(displayColumnDetails));
|
|
172
|
+
}
|
|
173
|
+
}, [displayColumnDetails]);
|
|
174
|
+
const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.MouseSensor), (0, _core.useSensor)(_core.TouchSensor), (0, _core.useSensor)(_core.KeyboardSensor, {
|
|
175
|
+
coordinateGetter: _sortable.sortableKeyboardCoordinates
|
|
176
|
+
}));
|
|
177
|
+
const onReorderEndHandler = (0, _react.useCallback)(_ref2 => {
|
|
178
|
+
let {
|
|
179
|
+
oldIndex,
|
|
180
|
+
newIndex
|
|
181
|
+
} = _ref2;
|
|
182
|
+
if (displayColumnKeyNames) {
|
|
183
|
+
if (newIndex !== 0 && oldIndex !== 0) {
|
|
184
|
+
const newOrder = [...displayColumnKeyNames];
|
|
185
|
+
const moved = newOrder.splice(oldIndex, 1);
|
|
186
|
+
newOrder.splice(newIndex, 0, moved[0]);
|
|
187
|
+
setDisplayColumnKeyNames(newOrder);
|
|
188
|
+
if (onReorderEnd) {
|
|
189
|
+
onReorderEnd(newOrder);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, [displayColumnKeyNames, setDisplayColumnKeyNames, onReorderEnd]);
|
|
194
|
+
function handleDragEnd(event) {
|
|
195
|
+
if (headCells) {
|
|
196
|
+
const {
|
|
197
|
+
active,
|
|
198
|
+
over
|
|
199
|
+
} = event;
|
|
200
|
+
if (active && over && active.id !== over.id && onReorderEndHandler) {
|
|
201
|
+
const oldIndex = headCells.findIndex(item => item.id === active.id);
|
|
202
|
+
const newIndex = headCells.findIndex(item => item.id === over.id);
|
|
203
|
+
onReorderEndHandler({
|
|
204
|
+
oldIndex,
|
|
205
|
+
newIndex
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const pagesCount = Math.ceil(rows.length / maxItemsPerPage);
|
|
211
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showTopBar && /*#__PURE__*/_react.default.createElement(_EnhancedTableToolbarV.default, {
|
|
212
|
+
selectedRowsCount: (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) || 0,
|
|
213
|
+
pagesCount: pagesCount,
|
|
214
|
+
renderNumSelectedText: renderNumSelectedText,
|
|
215
|
+
rowsCount: rows.length,
|
|
216
|
+
topBarButtons: topBarButtons,
|
|
217
|
+
topBarSelectionConfig: enhancedTopBarSelectionConfig ? {
|
|
218
|
+
...enhancedTopBarSelectionConfig,
|
|
219
|
+
handleSelectAll: () => setSelectedRows && setSelectedRows(rows),
|
|
220
|
+
handleSelectNone: () => setSelectedRows && setSelectedRows([])
|
|
221
|
+
} : undefined
|
|
222
|
+
}), /*#__PURE__*/_react.default.createElement(_material.TableContainer, {
|
|
223
|
+
id: id
|
|
224
|
+
}, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
|
|
225
|
+
sensors: sensors,
|
|
226
|
+
onDragEnd: handleDragEnd
|
|
227
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Table, {
|
|
228
|
+
stickyHeader: stickyHeader,
|
|
229
|
+
"aria-labelledby": "tableTitle",
|
|
230
|
+
size: "medium",
|
|
231
|
+
"aria-label": "enhanced table",
|
|
232
|
+
sx: {
|
|
233
|
+
borderCollapse: 'initial'
|
|
234
|
+
}
|
|
235
|
+
}, !hideHeader && /*#__PURE__*/_react.default.createElement(_TableHeader.default, {
|
|
236
|
+
order: order,
|
|
237
|
+
orderBy: orderBy,
|
|
238
|
+
onRequestSort: handleRequestSort,
|
|
239
|
+
columns: displayColumnDetails !== null && displayColumnDetails !== void 0 ? displayColumnDetails : [],
|
|
240
|
+
onReorderEnd: onReorderEndHandler,
|
|
241
|
+
numSelected: showCheckbox ? selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length : undefined,
|
|
242
|
+
onSelectAllClick: showCheckbox ? handleSelectAllClick : undefined,
|
|
243
|
+
rowCount: showCheckbox ? rows === null || rows === void 0 ? void 0 : rows.length : undefined,
|
|
244
|
+
density: density
|
|
245
|
+
}), /*#__PURE__*/_react.default.createElement(_material.TableBody, null, rows.length < 1 && emptyTableMessage && /*#__PURE__*/_react.default.createElement(_material.TableRow, null, /*#__PURE__*/_react.default.createElement(_material.TableCell, {
|
|
246
|
+
colSpan: columns.length + 1,
|
|
247
|
+
align: "center"
|
|
248
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, emptyTableMessage))), rows && (isPresorted ? rows : (0, _sort.stableSort)(rows, (0, _sort.getComparator)(order, orderBy, sortComparator))).slice(itemsToSkip, itemsToSkip + maxItemsPerPage).map((row, index) => {
|
|
249
|
+
const onClick = onSelect && !controlledOnSelect ? () => onSelect(row) : undefined;
|
|
250
|
+
const isItemSelected = isSelected(row);
|
|
251
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
252
|
+
key: index
|
|
253
|
+
}, /*#__PURE__*/_react.default.createElement(_material.TableRow, {
|
|
254
|
+
id: "row".concat(index + 1),
|
|
255
|
+
hover: true,
|
|
256
|
+
onClick: e => {
|
|
257
|
+
e.stopPropagation();
|
|
258
|
+
if (onClick && !hasEditColumn && (isClickable ? isClickable(row) : true)) {
|
|
259
|
+
onClick();
|
|
260
|
+
}
|
|
261
|
+
if (!onClick && !hasEditColumn && (isClickable ? isClickable(row) : true)) {
|
|
262
|
+
handleClick(e, row);
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
selected: isItemSelected,
|
|
266
|
+
"aria-checked": isItemSelected,
|
|
267
|
+
sx: {
|
|
268
|
+
...(isInactive && isInactive(row) ? {
|
|
269
|
+
backgroundColor: theme.palette.neutral[50]
|
|
270
|
+
} : {}),
|
|
271
|
+
height: (0, _density.getTableRowHeight)(density),
|
|
272
|
+
'&.MuiTableRow-root.Mui-selected': {
|
|
273
|
+
backgroundColor: theme.palette.TwClrBgSelectedTertiary
|
|
274
|
+
},
|
|
275
|
+
'&:nth-of-type(odd)': {
|
|
276
|
+
backgroundColor: theme.palette.TwClrBgSecondary
|
|
277
|
+
},
|
|
278
|
+
'&:hover': {
|
|
279
|
+
backgroundColor: theme.palette.TwClrBgSecondaryHover
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}, showCheckbox && /*#__PURE__*/_react.default.createElement(_material.TableCell, {
|
|
283
|
+
padding: "checkbox",
|
|
284
|
+
sx: {
|
|
285
|
+
'&.MuiTableCell-root': {
|
|
286
|
+
borderBottom: "1px solid ".concat(theme.palette.TwClrBgSecondary)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Checkbox, {
|
|
290
|
+
disableRipple: true,
|
|
291
|
+
sx: (0, _Checkbox.CheckboxStyle)(theme),
|
|
292
|
+
color: "primary",
|
|
293
|
+
checked: isItemSelected,
|
|
294
|
+
onClick: e => !isClickable || !isClickable(row) ? handleClick(e, row) : null
|
|
295
|
+
})), displayColumnDetails && displayColumnDetails.map(c => /*#__PURE__*/_react.default.createElement(Renderer, {
|
|
296
|
+
index: index + 1,
|
|
297
|
+
key: c.key,
|
|
298
|
+
row: row,
|
|
299
|
+
column: c,
|
|
300
|
+
value: row[c.key],
|
|
301
|
+
onRowClick: onSelect && controlledOnSelect ? newValue => onSelect(row, c.key, newValue) : onClick,
|
|
302
|
+
reloadData: reloadData,
|
|
303
|
+
booleanFalseText: booleanFalseText,
|
|
304
|
+
booleanTrueText: booleanTrueText,
|
|
305
|
+
editText: editText,
|
|
306
|
+
sx: {
|
|
307
|
+
paddingY: (0, _density.getTableCellPaddingY)(density)
|
|
308
|
+
}
|
|
309
|
+
}))), DetailsRenderer && /*#__PURE__*/_react.default.createElement(DetailsRenderer, {
|
|
310
|
+
index: index,
|
|
311
|
+
row: row
|
|
312
|
+
}));
|
|
313
|
+
}))))), tableComments && /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
314
|
+
fontWeight: 400,
|
|
315
|
+
fontSize: "14px",
|
|
316
|
+
color: theme.palette.TwClrTxtSecondary,
|
|
317
|
+
marginTop: 2
|
|
318
|
+
}, tableComments), renderPaginationText && /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
319
|
+
display: "flex",
|
|
320
|
+
alignItems: "center",
|
|
321
|
+
justifyContent: "flex-end",
|
|
322
|
+
paddingTop: "24px"
|
|
323
|
+
}, rows.length ? itemsToSkip + maxItemsPerPage < rows.length ? /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
324
|
+
paddingRight: "24px",
|
|
325
|
+
fontSize: "14px"
|
|
326
|
+
}, renderPaginationText(itemsToSkip + 1, itemsToSkip + maxItemsPerPage, rows.length)) : /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
327
|
+
paddingRight: "24px",
|
|
328
|
+
fontSize: "14px"
|
|
329
|
+
}, renderPaginationText(itemsToSkip + 1, rows.length, rows.length)) : /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
330
|
+
paddingRight: "24px",
|
|
331
|
+
fontSize: "14px"
|
|
332
|
+
}, renderPaginationText(0, 0, 0)), /*#__PURE__*/_react.default.createElement(_material.Pagination, {
|
|
333
|
+
count: pagesCount,
|
|
334
|
+
page: itemsToSkip / maxItemsPerPage + 1,
|
|
335
|
+
shape: "rounded",
|
|
336
|
+
onChange: handleChangePage,
|
|
337
|
+
siblingCount: isMobile ? 0 : 1,
|
|
338
|
+
size: 'small'
|
|
339
|
+
})));
|
|
340
|
+
}
|
|
341
|
+
function tableSort(ignore, array, comparator) {
|
|
342
|
+
if (ignore) {
|
|
343
|
+
return array;
|
|
344
|
+
}
|
|
345
|
+
return (0, _sort.stableSort)(array, comparator);
|
|
346
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.descendingComparator = descendingComparator;
|
|
7
|
+
exports.getComparator = getComparator;
|
|
8
|
+
exports.stableSort = stableSort;
|
|
9
|
+
function descendingComparator(a, b, orderBy, order) {
|
|
10
|
+
var _b$orderBy, _a$orderBy;
|
|
11
|
+
// first attempt to parse into a numeric value and compare
|
|
12
|
+
const numCompare = descendingNumComparator(a, b, orderBy);
|
|
13
|
+
if (numCompare !== null) {
|
|
14
|
+
if (numCompare === 0) {
|
|
15
|
+
return numCompare;
|
|
16
|
+
} else {
|
|
17
|
+
return order === 'desc' ? numCompare * -1 : numCompare;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// if non-numeric, compare using the javascript built-in compare for this type
|
|
22
|
+
const bValue = (_b$orderBy = b[orderBy]) !== null && _b$orderBy !== void 0 ? _b$orderBy : '';
|
|
23
|
+
const aValue = (_a$orderBy = a[orderBy]) !== null && _a$orderBy !== void 0 ? _a$orderBy : '';
|
|
24
|
+
|
|
25
|
+
// blank values at the end always (any order)
|
|
26
|
+
if (isEmptyValue(aValue.toString()) && isEmptyValue(bValue.toString())) {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
if (isEmptyValue(aValue.toString())) {
|
|
30
|
+
return 1;
|
|
31
|
+
}
|
|
32
|
+
if (isEmptyValue(bValue.toString())) {
|
|
33
|
+
return -1;
|
|
34
|
+
}
|
|
35
|
+
if (bValue < aValue) {
|
|
36
|
+
return order === 'desc' ? -1 : 1;
|
|
37
|
+
}
|
|
38
|
+
if (bValue > aValue) {
|
|
39
|
+
return order === 'desc' ? 1 : -1;
|
|
40
|
+
}
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
function isEmptyValue(value) {
|
|
44
|
+
if (value === '' || value === null || (value === null || value === void 0 ? void 0 : value.toString().trim()) === '' || value === undefined) {
|
|
45
|
+
return true;
|
|
46
|
+
} else {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function descendingNumComparator(a, b, orderBy) {
|
|
51
|
+
var _a$orderBy2, _b$orderBy2;
|
|
52
|
+
const aNumValue = Number((_a$orderBy2 = a[orderBy]) !== null && _a$orderBy2 !== void 0 ? _a$orderBy2 : '0.0');
|
|
53
|
+
const bNumValue = Number((_b$orderBy2 = b[orderBy]) !== null && _b$orderBy2 !== void 0 ? _b$orderBy2 : '0.0');
|
|
54
|
+
if (!isNaN(aNumValue) && !isNaN(bNumValue)) {
|
|
55
|
+
return bNumValue - aNumValue;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
function getComparator(order, orderBy, sorting) {
|
|
60
|
+
return (a, b) => sorting(a, b, orderBy, order);
|
|
61
|
+
}
|
|
62
|
+
function stableSort(array, comparator) {
|
|
63
|
+
const stabilizedThis = array.map((el, index) => [el, index]);
|
|
64
|
+
stabilizedThis.sort((a, b) => {
|
|
65
|
+
const order = comparator(a[0], b[0]);
|
|
66
|
+
if (order !== 0) {
|
|
67
|
+
return order;
|
|
68
|
+
}
|
|
69
|
+
return a[1] - b[1];
|
|
70
|
+
});
|
|
71
|
+
return stabilizedThis.map(el => el[0]);
|
|
72
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _sort = require("./sort");
|
|
4
|
+
const rowA = {
|
|
5
|
+
string1: 'foo',
|
|
6
|
+
string2: 'same',
|
|
7
|
+
number1: '1050',
|
|
8
|
+
number2: '150',
|
|
9
|
+
number3: '1.100'
|
|
10
|
+
};
|
|
11
|
+
const rowB = {
|
|
12
|
+
string1: 'barbaz',
|
|
13
|
+
string2: 'same',
|
|
14
|
+
number1: '1099',
|
|
15
|
+
number2: '21.001',
|
|
16
|
+
number3: '1.1'
|
|
17
|
+
};
|
|
18
|
+
test('compare unequal string fields', () => {
|
|
19
|
+
const cmp = (0, _sort.descendingComparator)(rowA, rowB, 'string1', 'desc');
|
|
20
|
+
expect(cmp).toEqual(-1);
|
|
21
|
+
});
|
|
22
|
+
test('compare equal string fields', () => {
|
|
23
|
+
const cmp = (0, _sort.descendingComparator)(rowA, rowB, 'string2', 'desc');
|
|
24
|
+
expect(cmp).toEqual(0);
|
|
25
|
+
});
|
|
26
|
+
test('compare unequal number fields with same whole number digits', () => {
|
|
27
|
+
const cmp = (0, _sort.descendingComparator)(rowA, rowB, 'number1', 'desc');
|
|
28
|
+
expect(Math.sign(cmp)).toEqual(-1);
|
|
29
|
+
});
|
|
30
|
+
test('compare unequal number fields with differing whole number digits', () => {
|
|
31
|
+
const cmp = (0, _sort.descendingComparator)(rowA, rowB, 'number2', 'desc');
|
|
32
|
+
expect(Math.sign(cmp)).toEqual(1);
|
|
33
|
+
});
|
|
34
|
+
test('compare equal number fields', () => {
|
|
35
|
+
const cmp = (0, _sort.descendingComparator)(rowA, rowB, 'number3', 'desc');
|
|
36
|
+
expect(Math.sign(cmp)).toEqual(0);
|
|
37
|
+
});
|
package/fonts/Inter.ttf
ADDED
|
Binary file
|
package/index.css
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
|
|
4
|
+
'Droid Sans', 'Helvetica Neue', sans-serif;
|
|
5
|
+
-webkit-font-smoothing: antialiased;
|
|
6
|
+
-moz-osx-font-smoothing: grayscale;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
code {
|
|
10
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
|
|
11
|
+
}
|