@teselagen/ui 0.10.4 → 0.10.6
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/DataTable/DisplayOptions.d.ts +2 -1
- package/DataTable/DraggableColumnOptions.d.ts +7 -0
- package/DataTable/SortableColumns.d.ts +2 -1
- package/DataTable/ThComponent.d.ts +2 -1
- package/DataTable/dragNoticeEl.d.ts +1 -0
- package/DataTable/viewColumn.d.ts +0 -2
- package/index.cjs.js +1879 -6768
- package/index.es.js +595 -5484
- package/package.json +1 -1
- package/src/DataTable/Columns.js +13 -5
- package/src/DataTable/DisplayOptions.js +33 -126
- package/src/DataTable/DraggableColumnOptions.js +176 -0
- package/src/DataTable/SortableColumns.js +38 -26
- package/src/DataTable/ThComponent.js +22 -9
- package/src/DataTable/dragNoticeEl.js +13 -0
- package/src/DataTable/index.js +66 -129
- package/src/DataTable/style.css +18 -13
- package/src/DataTable/utils/queryParams.js +6 -1
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +180 -142
- package/src/DataTable/utils/withTableParams.js +2 -3
- package/src/DataTable/viewColumn.js +0 -1
- package/src/TgSelect/index.js +2 -0
- package/ui.css +18 -13
package/src/DataTable/index.js
CHANGED
|
@@ -229,7 +229,6 @@ const DataTable = ({
|
|
|
229
229
|
const {
|
|
230
230
|
doNotCoercePageSize,
|
|
231
231
|
isInfinite = isSimple && !withPaging,
|
|
232
|
-
syncDisplayOptionsToDb,
|
|
233
232
|
urlConnected,
|
|
234
233
|
withSelectedEntities
|
|
235
234
|
} = props;
|
|
@@ -255,7 +254,7 @@ const DataTable = ({
|
|
|
255
254
|
_defaults.order = r;
|
|
256
255
|
}
|
|
257
256
|
|
|
258
|
-
if (
|
|
257
|
+
if (userSetPageSize) {
|
|
259
258
|
_defaults.pageSize = userSetPageSize;
|
|
260
259
|
}
|
|
261
260
|
|
|
@@ -266,7 +265,6 @@ const DataTable = ({
|
|
|
266
265
|
isLocalCall,
|
|
267
266
|
orderByFirstColumn,
|
|
268
267
|
props.defaults,
|
|
269
|
-
syncDisplayOptionsToDb,
|
|
270
268
|
userSetPageSize
|
|
271
269
|
]);
|
|
272
270
|
|
|
@@ -393,8 +391,6 @@ const DataTable = ({
|
|
|
393
391
|
controlled_setPage,
|
|
394
392
|
controlled_setPageSize,
|
|
395
393
|
controlled_total,
|
|
396
|
-
currentUser,
|
|
397
|
-
deleteTableConfiguration,
|
|
398
394
|
disabled = false,
|
|
399
395
|
disableSetPageSize,
|
|
400
396
|
doNotShowEmptyRows,
|
|
@@ -471,8 +467,6 @@ const DataTable = ({
|
|
|
471
467
|
tableConfigurations,
|
|
472
468
|
tableName,
|
|
473
469
|
topLeftItems,
|
|
474
|
-
upsertFieldOption,
|
|
475
|
-
upsertTableConfiguration,
|
|
476
470
|
variables,
|
|
477
471
|
withCheckboxes = false,
|
|
478
472
|
withDisplayOptions,
|
|
@@ -537,11 +531,7 @@ const DataTable = ({
|
|
|
537
531
|
useEffect(() => {
|
|
538
532
|
if (withDisplayOptions) {
|
|
539
533
|
let newTableConfig = {};
|
|
540
|
-
|
|
541
|
-
newTableConfig = tableConfigurations && tableConfigurations[0];
|
|
542
|
-
} else {
|
|
543
|
-
newTableConfig = getTableConfigFromStorage(formName);
|
|
544
|
-
}
|
|
534
|
+
newTableConfig = getTableConfigFromStorage(formName);
|
|
545
535
|
!noExcessiveCheck &&
|
|
546
536
|
isBeingCalledExcessively({ uniqName: `dt_setTableConfig_${formName}` });
|
|
547
537
|
// if the tableConfig is the same as the newTableConfig, don't update
|
|
@@ -564,7 +554,6 @@ const DataTable = ({
|
|
|
564
554
|
convertedSchema, // If the schema changes we want to take into account the synced tableConfig again
|
|
565
555
|
formName,
|
|
566
556
|
setTableConfig,
|
|
567
|
-
syncDisplayOptionsToDb,
|
|
568
557
|
tableConfigurations,
|
|
569
558
|
withDisplayOptions,
|
|
570
559
|
noExcessiveCheck
|
|
@@ -628,8 +617,7 @@ const DataTable = ({
|
|
|
628
617
|
if (noValsForField && entities.length) {
|
|
629
618
|
return {
|
|
630
619
|
...field,
|
|
631
|
-
isHidden: true
|
|
632
|
-
isForcedHidden: true
|
|
620
|
+
isHidden: true
|
|
633
621
|
};
|
|
634
622
|
} else if (fieldOpt) {
|
|
635
623
|
return {
|
|
@@ -697,6 +685,7 @@ const DataTable = ({
|
|
|
697
685
|
withDisplayOptions,
|
|
698
686
|
recordIdToIsVisibleMap
|
|
699
687
|
]);
|
|
688
|
+
const [columns, setColumns] = useState([]);
|
|
700
689
|
|
|
701
690
|
const {
|
|
702
691
|
moveColumnPersist,
|
|
@@ -715,79 +704,45 @@ const DataTable = ({
|
|
|
715
704
|
|
|
716
705
|
if (withDisplayOptions) {
|
|
717
706
|
const fieldOptsByPath = keyBy(tableConfig.fieldOptions, "path");
|
|
718
|
-
if (syncDisplayOptionsToDb) {
|
|
719
|
-
// sync up to db
|
|
720
|
-
// There must be a better way to set this variable...
|
|
721
|
-
let tableConfigurationId;
|
|
722
|
-
resetDefaultVisibility = function () {
|
|
723
|
-
tableConfigurationId = tableConfig.id;
|
|
724
|
-
if (tableConfigurationId) {
|
|
725
|
-
deleteTableConfiguration(tableConfigurationId);
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
updateColumnVisibility = function ({ shouldShow, path }) {
|
|
729
|
-
if (tableConfigurationId) {
|
|
730
|
-
const existingFieldOpt = fieldOptsByPath[path] || {};
|
|
731
|
-
upsertFieldOption({
|
|
732
|
-
id: existingFieldOpt.id,
|
|
733
|
-
path,
|
|
734
|
-
isHidden: !shouldShow,
|
|
735
|
-
tableConfigurationId
|
|
736
|
-
});
|
|
737
|
-
} else {
|
|
738
|
-
upsertTableConfiguration({
|
|
739
|
-
userId: currentUser.user.id,
|
|
740
|
-
formName,
|
|
741
|
-
fieldOptions: [
|
|
742
|
-
{
|
|
743
|
-
path,
|
|
744
|
-
isHidden: !shouldShow
|
|
745
|
-
}
|
|
746
|
-
]
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
} else {
|
|
751
|
-
const syncStorage = newTableConfig => {
|
|
752
|
-
setTableConfig(newTableConfig);
|
|
753
|
-
window.localStorage.setItem(formName, JSON.stringify(newTableConfig));
|
|
754
|
-
};
|
|
755
707
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
syncStorage({ ...tableConfig, fieldOptions: toArray(newFieldOpts) });
|
|
770
|
-
};
|
|
771
|
-
updateTableDisplayDensity = function (density) {
|
|
772
|
-
syncStorage({ ...tableConfig, density: density });
|
|
773
|
-
};
|
|
774
|
-
persistPageSize = function (pageSize) {
|
|
775
|
-
syncStorage({ ...tableConfig, userSetPageSize: pageSize });
|
|
776
|
-
};
|
|
777
|
-
moveColumnPersist = function ({ oldIndex, newIndex }) {
|
|
778
|
-
// we might already have an array of the fields [path1, path2, ..etc]
|
|
779
|
-
const columnOrderings =
|
|
780
|
-
tableConfig.columnOrderings ||
|
|
781
|
-
schema.fields.map(({ path }) => path); // columnOrderings is [path1, path2, ..etc]
|
|
782
|
-
syncStorage({
|
|
783
|
-
...tableConfig,
|
|
784
|
-
columnOrderings: arrayMove(columnOrderings, oldIndex, newIndex)
|
|
785
|
-
});
|
|
786
|
-
};
|
|
787
|
-
resizePersist = function (newResized) {
|
|
788
|
-
syncStorage({ ...tableConfig, resized: newResized });
|
|
708
|
+
const syncStorage = newTableConfig => {
|
|
709
|
+
setTableConfig(newTableConfig);
|
|
710
|
+
window.localStorage.setItem(formName, JSON.stringify(newTableConfig));
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
//sync display options with localstorage
|
|
714
|
+
resetDefaultVisibility = function () {
|
|
715
|
+
setTableConfig({ fieldOptions: [] });
|
|
716
|
+
window.localStorage.removeItem(formName);
|
|
717
|
+
};
|
|
718
|
+
updateColumnVisibility = function ({ path, paths, shouldShow }) {
|
|
719
|
+
const newFieldOpts = {
|
|
720
|
+
...fieldOptsByPath
|
|
789
721
|
};
|
|
790
|
-
|
|
722
|
+
const pathsToUse = paths ? paths : [path];
|
|
723
|
+
pathsToUse.forEach(path => {
|
|
724
|
+
newFieldOpts[path] = { path, isHidden: !shouldShow };
|
|
725
|
+
});
|
|
726
|
+
syncStorage({ ...tableConfig, fieldOptions: toArray(newFieldOpts) });
|
|
727
|
+
};
|
|
728
|
+
updateTableDisplayDensity = function (density) {
|
|
729
|
+
syncStorage({ ...tableConfig, density: density });
|
|
730
|
+
};
|
|
731
|
+
persistPageSize = function (pageSize) {
|
|
732
|
+
syncStorage({ ...tableConfig, userSetPageSize: pageSize });
|
|
733
|
+
};
|
|
734
|
+
moveColumnPersist = function ({ oldIndex, newIndex }) {
|
|
735
|
+
// we might already have an array of the fields [path1, path2, ..etc]
|
|
736
|
+
const columnOrderings =
|
|
737
|
+
tableConfig.columnOrderings || columns.map(({ path }) => path); // columnOrderings is [path1, path2, ..etc]
|
|
738
|
+
syncStorage({
|
|
739
|
+
...tableConfig,
|
|
740
|
+
columnOrderings: arrayMove(columnOrderings, oldIndex, newIndex)
|
|
741
|
+
});
|
|
742
|
+
};
|
|
743
|
+
resizePersist = function (newResized) {
|
|
744
|
+
syncStorage({ ...tableConfig, resized: newResized });
|
|
745
|
+
};
|
|
791
746
|
}
|
|
792
747
|
return {
|
|
793
748
|
moveColumnPersist,
|
|
@@ -797,18 +752,7 @@ const DataTable = ({
|
|
|
797
752
|
updateColumnVisibility,
|
|
798
753
|
updateTableDisplayDensity
|
|
799
754
|
};
|
|
800
|
-
}, [
|
|
801
|
-
currentUser?.user?.id,
|
|
802
|
-
deleteTableConfiguration,
|
|
803
|
-
formName,
|
|
804
|
-
setTableConfig,
|
|
805
|
-
schema.fields,
|
|
806
|
-
syncDisplayOptionsToDb,
|
|
807
|
-
tableConfig,
|
|
808
|
-
upsertFieldOption,
|
|
809
|
-
upsertTableConfiguration,
|
|
810
|
-
withDisplayOptions
|
|
811
|
-
]);
|
|
755
|
+
}, [formName, setTableConfig, columns, tableConfig, withDisplayOptions]);
|
|
812
756
|
|
|
813
757
|
let compact = _compact;
|
|
814
758
|
let extraCompact = _extraCompact;
|
|
@@ -1524,7 +1468,6 @@ const DataTable = ({
|
|
|
1524
1468
|
);
|
|
1525
1469
|
|
|
1526
1470
|
const { handleKeyDown, handleKeyUp } = useHotkeys(hotKeys);
|
|
1527
|
-
const [columns, setColumns] = useState([]);
|
|
1528
1471
|
const [fullscreen, setFullscreen] = useState(false);
|
|
1529
1472
|
const [selectingAll, setSelectingAll] = useState(false);
|
|
1530
1473
|
|
|
@@ -1735,21 +1678,19 @@ const DataTable = ({
|
|
|
1735
1678
|
addFilters(additionalFilters);
|
|
1736
1679
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1737
1680
|
}, [additionalFilters]);
|
|
1738
|
-
|
|
1739
1681
|
useEffect(() => {
|
|
1740
|
-
|
|
1741
|
-
schema.fields
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
);
|
|
1682
|
+
const newCols = schema.fields
|
|
1683
|
+
? schema.fields.reduce((columns, field, i) => {
|
|
1684
|
+
if (field.isHidden) {
|
|
1685
|
+
return columns.concat(field);
|
|
1686
|
+
}
|
|
1687
|
+
return columns.concat({
|
|
1688
|
+
...field,
|
|
1689
|
+
columnIndex: i
|
|
1690
|
+
});
|
|
1691
|
+
}, [])
|
|
1692
|
+
: [];
|
|
1693
|
+
setColumns(newCols);
|
|
1753
1694
|
}, [schema?.fields]);
|
|
1754
1695
|
|
|
1755
1696
|
const setSelectedIds = useCallback(
|
|
@@ -1830,28 +1771,22 @@ const DataTable = ({
|
|
|
1830
1771
|
const TheadComponent = useCallback(
|
|
1831
1772
|
({ className, style, children }) => {
|
|
1832
1773
|
const moveColumn = ({ oldIndex, newIndex }) => {
|
|
1833
|
-
let oldStateColumnIndex, newStateColumnIndex;
|
|
1834
|
-
columns.forEach((column, i) => {
|
|
1835
|
-
if (oldIndex === column.columnIndex) oldStateColumnIndex = i;
|
|
1836
|
-
if (newIndex === column.columnIndex) newStateColumnIndex = i;
|
|
1837
|
-
});
|
|
1838
1774
|
// because it is all handled in state we need
|
|
1839
1775
|
// to perform the move and update the columnIndices
|
|
1840
1776
|
// because they are used for the sortable columns
|
|
1841
|
-
const newColumns = arrayMove(
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
};
|
|
1850
|
-
});
|
|
1777
|
+
const newColumns = arrayMove(columns, oldIndex, newIndex).map(
|
|
1778
|
+
(column, i) => {
|
|
1779
|
+
return {
|
|
1780
|
+
...column,
|
|
1781
|
+
columnIndex: i
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
);
|
|
1851
1785
|
setColumns(newColumns);
|
|
1852
1786
|
};
|
|
1853
1787
|
return (
|
|
1854
1788
|
<SortableColumns
|
|
1789
|
+
sortedItemsFull={columns.map(c => c.path)}
|
|
1855
1790
|
className={className}
|
|
1856
1791
|
style={style}
|
|
1857
1792
|
moveColumn={moveColumnPersist || moveColumn}
|
|
@@ -2761,7 +2696,7 @@ const DataTable = ({
|
|
|
2761
2696
|
columns,
|
|
2762
2697
|
currentParams,
|
|
2763
2698
|
compact,
|
|
2764
|
-
|
|
2699
|
+
withDisplayOptions,
|
|
2765
2700
|
resetDefaultVisibility,
|
|
2766
2701
|
editingCellSelectAll,
|
|
2767
2702
|
entities,
|
|
@@ -2825,6 +2760,7 @@ const DataTable = ({
|
|
|
2825
2760
|
noVirtual={noVirtual}
|
|
2826
2761
|
className={classNames({
|
|
2827
2762
|
isCellEditable,
|
|
2763
|
+
loading: isLoading,
|
|
2828
2764
|
"tg-table-loading": isLoading,
|
|
2829
2765
|
"tg-table-disabled": disabled
|
|
2830
2766
|
})}
|
|
@@ -3261,6 +3197,7 @@ const DataTable = ({
|
|
|
3261
3197
|
resetDefaultVisibility={resetDefaultVisibility}
|
|
3262
3198
|
updateColumnVisibility={updateColumnVisibility}
|
|
3263
3199
|
updateTableDisplayDensity={updateTableDisplayDensity}
|
|
3200
|
+
moveColumnPersist={moveColumnPersist}
|
|
3264
3201
|
showForcedHiddenColumns={showForcedHiddenColumns}
|
|
3265
3202
|
setShowForcedHidden={setShowForcedHidden}
|
|
3266
3203
|
hasOptionForForcedHidden={
|
package/src/DataTable/style.css
CHANGED
|
@@ -253,7 +253,11 @@ body:not(.drag-active)
|
|
|
253
253
|
user-select: none;
|
|
254
254
|
background: #f7f7f7;
|
|
255
255
|
}
|
|
256
|
-
|
|
256
|
+
/* disable the table header interactions while the table is loading */
|
|
257
|
+
.ReactTable.loading .rt-thead {
|
|
258
|
+
opacity: 0.7;
|
|
259
|
+
pointer-events: none;
|
|
260
|
+
}
|
|
257
261
|
.ReactTable .rt-thead {
|
|
258
262
|
box-shadow: none;
|
|
259
263
|
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
|
@@ -421,10 +425,6 @@ body:not(.drag-active)
|
|
|
421
425
|
padding-left: 2px;
|
|
422
426
|
}
|
|
423
427
|
|
|
424
|
-
.ReactTable .-loading.disabled {
|
|
425
|
-
cursor: not-allowed;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
428
|
/* to get the height to resize based on its container: */
|
|
429
429
|
.ReactTable {
|
|
430
430
|
height: 100%;
|
|
@@ -540,14 +540,6 @@ body:not(.drag-active)
|
|
|
540
540
|
color: inherit !important;
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
-
.bp3-dark .ReactTable .-loading {
|
|
544
|
-
background: #30404d !important;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
.bp3-dark .ReactTable .-loading > div {
|
|
548
|
-
color: #f5f8fa !important;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
543
|
.bp3-dark .ReactTable .rt-tr-group.selected {
|
|
552
544
|
background: #26738cb0 !important;
|
|
553
545
|
}
|
|
@@ -606,3 +598,16 @@ body:not(.drag-active)
|
|
|
606
598
|
display: flex;
|
|
607
599
|
flex-direction: column;
|
|
608
600
|
}
|
|
601
|
+
.th-dragging {
|
|
602
|
+
z-index: 999 !important;
|
|
603
|
+
cursor: grabbing !important;
|
|
604
|
+
opacity: 0.8;
|
|
605
|
+
background-color: #f5f8fa;
|
|
606
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
.bp3-dark .th-dragging {
|
|
610
|
+
background-color: #30404d;
|
|
611
|
+
box-shadow: 0 2px 8px rgba(250, 245, 245, 0.15);
|
|
612
|
+
outline: 1px solid #48aff0;
|
|
613
|
+
}
|
|
@@ -311,10 +311,15 @@ export function getQueryParams({
|
|
|
311
311
|
const ccDisplayName = orderVal.replace(/^-/gi, "");
|
|
312
312
|
const schemaForField = ccFields[ccDisplayName];
|
|
313
313
|
if (schemaForField) {
|
|
314
|
-
const { path } = schemaForField;
|
|
314
|
+
const { path, additionalSearchPaths } = schemaForField;
|
|
315
315
|
const reversed = ccDisplayName !== orderVal;
|
|
316
316
|
const prefix = reversed ? "-" : "";
|
|
317
317
|
cleanedOrder.push(prefix + path);
|
|
318
|
+
if (additionalSearchPaths && additionalSearchPaths.length) {
|
|
319
|
+
additionalSearchPaths.forEach(additionalPath => {
|
|
320
|
+
cleanedOrder.push(prefix + additionalPath);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
318
323
|
} else {
|
|
319
324
|
!noOrderError &&
|
|
320
325
|
console.error(
|