@vuu-ui/vuu-table 0.7.2-debug → 0.7.3-debug
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/cjs/index.js +48 -23
- package/cjs/index.js.map +2 -2
- package/esm/index.js +48 -23
- package/esm/index.js.map +2 -2
- package/package.json +5 -5
- package/types/useTableModel.d.ts +8 -8
package/esm/index.js
CHANGED
|
@@ -121,7 +121,10 @@ function buildAggregationMenuItems(options, dataSource) {
|
|
|
121
121
|
return [
|
|
122
122
|
{
|
|
123
123
|
label: `Aggregate ${label}`,
|
|
124
|
-
children: [
|
|
124
|
+
children: [
|
|
125
|
+
{ label: "Count", action: "agg-count", options },
|
|
126
|
+
{ label: "Distinct", action: "agg-distinct", options }
|
|
127
|
+
].concat(
|
|
125
128
|
isNumericColumn(column) ? [
|
|
126
129
|
{ label: "Sum", action: "agg-sum", options },
|
|
127
130
|
{ label: "Avg", action: "agg-avg", options },
|
|
@@ -236,7 +239,7 @@ var removeFilterColumn = (dataSourceFilter, column) => {
|
|
|
236
239
|
return dataSourceFilter;
|
|
237
240
|
}
|
|
238
241
|
};
|
|
239
|
-
var { Average, Count, High, Low, Sum } = AggregationType;
|
|
242
|
+
var { Average, Count, Distinct, High, Low, Sum } = AggregationType;
|
|
240
243
|
var useTableContextMenu = ({
|
|
241
244
|
dataSource,
|
|
242
245
|
onPersistentColumnOperation
|
|
@@ -274,6 +277,8 @@ var useTableContextMenu = ({
|
|
|
274
277
|
return dataSource.aggregations = setAggregations(dataSource.aggregations, column, Low), true;
|
|
275
278
|
case "agg-count":
|
|
276
279
|
return dataSource.aggregations = setAggregations(dataSource.aggregations, column, Count), true;
|
|
280
|
+
case "agg-distinct":
|
|
281
|
+
return dataSource.aggregations = setAggregations(dataSource.aggregations, column, Distinct), true;
|
|
277
282
|
case "agg-sum":
|
|
278
283
|
return dataSource.aggregations = setAggregations(dataSource.aggregations, column, Sum), true;
|
|
279
284
|
case "column-pin-floating":
|
|
@@ -439,7 +444,7 @@ var { DEPTH, IS_LEAF } = metadataKeys2;
|
|
|
439
444
|
var getGroupValueAndOffset = (columns, row) => {
|
|
440
445
|
const { [DEPTH]: depth, [IS_LEAF]: isLeaf } = row;
|
|
441
446
|
if (isLeaf || depth > columns.length) {
|
|
442
|
-
return [null, depth === null ? 0 : depth - 1];
|
|
447
|
+
return [null, depth === null ? 0 : Math.max(0, depth - 1)];
|
|
443
448
|
} else if (depth === 0) {
|
|
444
449
|
return ["$root", 0];
|
|
445
450
|
} else {
|
|
@@ -1733,14 +1738,18 @@ var getCellRendererForColumn = (column) => {
|
|
|
1733
1738
|
return getCellRenderer((_a = column.type) == null ? void 0 : _a.renderer);
|
|
1734
1739
|
}
|
|
1735
1740
|
};
|
|
1736
|
-
var
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
if (
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1741
|
+
var getServerDataTypeForColumn = (column, tableSchema) => {
|
|
1742
|
+
if (column.serverDataType) {
|
|
1743
|
+
return column.serverDataType;
|
|
1744
|
+
} else if (tableSchema) {
|
|
1745
|
+
const schemaColumn = tableSchema.columns.find(
|
|
1746
|
+
(col) => col.name === column.name
|
|
1747
|
+
);
|
|
1748
|
+
if (schemaColumn) {
|
|
1749
|
+
return schemaColumn.serverDataType;
|
|
1750
|
+
}
|
|
1743
1751
|
}
|
|
1752
|
+
return "string";
|
|
1744
1753
|
};
|
|
1745
1754
|
var numericTypes = ["int", "long", "double"];
|
|
1746
1755
|
var getDefaultAlignment = (serverDataType) => serverDataType === void 0 ? void 0 : numericTypes.includes(serverDataType) ? "right" : "left";
|
|
@@ -1753,8 +1762,8 @@ var columnReducer = (state, action) => {
|
|
|
1753
1762
|
return moveColumn(state, action);
|
|
1754
1763
|
case "resizeColumn":
|
|
1755
1764
|
return resizeColumn(state, action);
|
|
1756
|
-
case "
|
|
1757
|
-
return
|
|
1765
|
+
case "setTableSchema":
|
|
1766
|
+
return setTableSchema(state, action);
|
|
1758
1767
|
case "hideColumns":
|
|
1759
1768
|
return hideColumns(state, action);
|
|
1760
1769
|
case "showColumns":
|
|
@@ -1806,9 +1815,13 @@ var getLabel = (label, columnFormatHeader) => {
|
|
|
1806
1815
|
return label;
|
|
1807
1816
|
};
|
|
1808
1817
|
var toKeyedColumWithDefaults = (options) => (column, index) => {
|
|
1818
|
+
const serverDataType = getServerDataTypeForColumn(
|
|
1819
|
+
column,
|
|
1820
|
+
options.tableSchema
|
|
1821
|
+
);
|
|
1809
1822
|
const { columnDefaultWidth = DEFAULT_COLUMN_WIDTH, columnFormatHeader } = options;
|
|
1810
1823
|
const {
|
|
1811
|
-
align = getDefaultAlignment(
|
|
1824
|
+
align = getDefaultAlignment(serverDataType),
|
|
1812
1825
|
key,
|
|
1813
1826
|
name,
|
|
1814
1827
|
label = name,
|
|
@@ -1823,6 +1836,7 @@ var toKeyedColumWithDefaults = (options) => (column, index) => {
|
|
|
1823
1836
|
key: key != null ? key : index + KEY_OFFSET,
|
|
1824
1837
|
name,
|
|
1825
1838
|
originalIdx: index,
|
|
1839
|
+
serverDataType,
|
|
1826
1840
|
valueFormatter: getValueFormatter(column),
|
|
1827
1841
|
width
|
|
1828
1842
|
};
|
|
@@ -1900,12 +1914,12 @@ function resizeColumn(state, { column, phase, width }) {
|
|
|
1900
1914
|
throw Error(`useTableModel.resizeColumn, invalid resizePhase ${phase}`);
|
|
1901
1915
|
}
|
|
1902
1916
|
}
|
|
1903
|
-
function
|
|
1917
|
+
function setTableSchema(state, { tableSchema }) {
|
|
1904
1918
|
const { columns } = state;
|
|
1905
1919
|
if (columns.some(columnWithoutDataType)) {
|
|
1906
1920
|
const cols = columns.map((column) => {
|
|
1907
1921
|
var _a;
|
|
1908
|
-
const serverDataType =
|
|
1922
|
+
const serverDataType = getServerDataTypeForColumn(column, tableSchema);
|
|
1909
1923
|
return {
|
|
1910
1924
|
...column,
|
|
1911
1925
|
align: (_a = column.align) != null ? _a : getDefaultAlignment(serverDataType),
|
|
@@ -1914,10 +1928,14 @@ function setTypes(state, { columnNames, serverDataTypes }) {
|
|
|
1914
1928
|
});
|
|
1915
1929
|
return {
|
|
1916
1930
|
...state,
|
|
1917
|
-
columns: cols
|
|
1931
|
+
columns: cols,
|
|
1932
|
+
tableSchema
|
|
1918
1933
|
};
|
|
1919
1934
|
} else {
|
|
1920
|
-
return
|
|
1935
|
+
return {
|
|
1936
|
+
...state,
|
|
1937
|
+
tableSchema
|
|
1938
|
+
};
|
|
1921
1939
|
}
|
|
1922
1940
|
}
|
|
1923
1941
|
function pinColumn2(state, action) {
|
|
@@ -1983,6 +2001,13 @@ function updateTableConfig(state, { columns, confirmed, filter, groupBy, sort })
|
|
|
1983
2001
|
key
|
|
1984
2002
|
};
|
|
1985
2003
|
}
|
|
2004
|
+
} else {
|
|
2005
|
+
return toKeyedColumWithDefaults(state)(
|
|
2006
|
+
{
|
|
2007
|
+
name: colName
|
|
2008
|
+
},
|
|
2009
|
+
index
|
|
2010
|
+
);
|
|
1986
2011
|
}
|
|
1987
2012
|
throw Error(`useTableModel column ${colName} not found`);
|
|
1988
2013
|
})
|
|
@@ -2418,15 +2443,15 @@ var useTable = ({
|
|
|
2418
2443
|
size: containerMeasurements.innerSize
|
|
2419
2444
|
});
|
|
2420
2445
|
const onSubscribed = useCallback18(
|
|
2421
|
-
(
|
|
2422
|
-
if (
|
|
2423
|
-
const { columns: columnNames, dataTypes: serverDataTypes } = subscription.tableMeta;
|
|
2446
|
+
({ tableSchema }) => {
|
|
2447
|
+
if (tableSchema) {
|
|
2424
2448
|
expectConfigChangeRef.current = true;
|
|
2425
2449
|
dispatchColumnAction({
|
|
2426
|
-
type: "
|
|
2427
|
-
|
|
2428
|
-
serverDataTypes
|
|
2450
|
+
type: "setTableSchema",
|
|
2451
|
+
tableSchema
|
|
2429
2452
|
});
|
|
2453
|
+
} else {
|
|
2454
|
+
console.log("usbscription message with no schema");
|
|
2430
2455
|
}
|
|
2431
2456
|
},
|
|
2432
2457
|
[dispatchColumnAction]
|