@teselagen/ui 0.10.5 → 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 +1647 -1514
- package/index.es.js +546 -413
- package/package.json +1 -1
- package/src/DataTable/Columns.js +12 -4
- package/src/DataTable/DisplayOptions.js +27 -122
- 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 +65 -129
- package/src/DataTable/style.css +13 -0
- package/src/DataTable/utils/queryParams.js +6 -1
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +179 -147
- package/src/DataTable/utils/withTableParams.js +2 -3
- package/src/DataTable/viewColumn.js +0 -1
- package/src/TgSelect/index.js +1 -0
- package/ui.css +13 -0
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}
|
|
@@ -2825,7 +2760,7 @@ const DataTable = ({
|
|
|
2825
2760
|
noVirtual={noVirtual}
|
|
2826
2761
|
className={classNames({
|
|
2827
2762
|
isCellEditable,
|
|
2828
|
-
|
|
2763
|
+
loading: isLoading,
|
|
2829
2764
|
"tg-table-loading": isLoading,
|
|
2830
2765
|
"tg-table-disabled": disabled
|
|
2831
2766
|
})}
|
|
@@ -3262,6 +3197,7 @@ const DataTable = ({
|
|
|
3262
3197
|
resetDefaultVisibility={resetDefaultVisibility}
|
|
3263
3198
|
updateColumnVisibility={updateColumnVisibility}
|
|
3264
3199
|
updateTableDisplayDensity={updateTableDisplayDensity}
|
|
3200
|
+
moveColumnPersist={moveColumnPersist}
|
|
3265
3201
|
showForcedHiddenColumns={showForcedHiddenColumns}
|
|
3266
3202
|
setShowForcedHidden={setShowForcedHidden}
|
|
3267
3203
|
hasOptionForForcedHidden={
|
package/src/DataTable/style.css
CHANGED
|
@@ -598,3 +598,16 @@ body:not(.drag-active)
|
|
|
598
598
|
display: flex;
|
|
599
599
|
flex-direction: column;
|
|
600
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(
|