@vuu-ui/vuu-table 1.0.0 → 1.0.2
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/data-row/DataRow.js +1 -1
- package/cjs/data-row/DataRow.js.map +1 -1
- package/cjs/index.js +6 -4
- package/cjs/index.js.map +1 -1
- package/esm/data-row/DataRow.js +1 -1
- package/esm/data-row/DataRow.js.map +1 -1
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/package.json +10 -10
- package/types/index.d.ts +3 -3
package/cjs/data-row/DataRow.js
CHANGED
|
@@ -26,7 +26,7 @@ const stringNumericTypes = {
|
|
|
26
26
|
const isStringNumericType = (type) => stringNumericTypes[type] === true;
|
|
27
27
|
const MAX_DECIMALS = "0000000";
|
|
28
28
|
const injectDecimalPoint = (value, decimal) => {
|
|
29
|
-
if (value === "0" || value === "-0") {
|
|
29
|
+
if (value === "0" || value === "-0" || value === "") {
|
|
30
30
|
return value;
|
|
31
31
|
} else {
|
|
32
32
|
if (value[0] === "-") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataRow.js","sources":["../../../../packages/vuu-table/src/data-row/DataRow.ts"],"sourcesContent":["import { DataSourceRow, SchemaColumn } from \"@vuu-ui/vuu-data-types\";\nimport {\n StringNumericType,\n VuuColumnDataType,\n VuuDataRow,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport {\n DataRow,\n DataRowIntrinsicAttribute,\n DataRowOperation,\n DataRowOperations,\n} from \"@vuu-ui/vuu-table-types\";\n\ntype ColumnMapEntry = {\n index: number;\n type: VuuColumnDataType;\n};\n\nconst dataRowSymbol = Symbol(\"DataRow\");\n\n/**\n * We allow undefined to allow us to null out rather than delete entries, for\n * performance reasons.\n */\ntype DataRowColumnMap = Record<string, ColumnMapEntry | undefined>;\n\nconst dataRowIntrinsicAttributes: Record<DataRowIntrinsicAttribute, true> = {\n childCount: true,\n depth: true,\n index: true,\n isExpanded: true,\n isSelected: true,\n isLeaf: true,\n key: true,\n renderIndex: true,\n};\n\nconst dataRowOperations: Record<DataRowOperation, true> = {\n hasColumn: true,\n};\n\nconst isDataRowIntrinsicAttribute = (\n attrName: string,\n): attrName is DataRowIntrinsicAttribute =>\n dataRowIntrinsicAttributes[attrName as DataRowIntrinsicAttribute] === true;\n\nconst isDataRowOperation = (attrName: string): attrName is DataRowOperation =>\n dataRowOperations[attrName as DataRowOperation] === true;\n\nconst stringNumericTypes: Record<StringNumericType, true> = {\n long: true,\n scaleddecimal2: true,\n scaleddecimal4: true,\n scaleddecimal6: true,\n scaleddecimal8: true,\n};\n\nconst isStringNumericType = (\n type: VuuColumnDataType,\n): type is StringNumericType =>\n stringNumericTypes[type as StringNumericType] === true;\n\nconst MAX_DECIMALS = \"0000000\";\n\nconst injectDecimalPoint = (value: string, decimal: 2 | 4 | 6 | 8) => {\n if (value === \"0\" || value === \"-0\") {\n return value;\n } else {\n if (value[0] === \"-\") {\n const digits = value.slice(1);\n if (digits.length < decimal) {\n return `-0.${(MAX_DECIMALS + digits).slice(-decimal)}`;\n } else if (digits.length === decimal) {\n return `-0.${value}`;\n } else {\n return `-${digits.slice(0, -decimal)}.${digits.slice(-decimal)}`;\n }\n } else {\n if (value.length < decimal) {\n return `0.${(MAX_DECIMALS + value).slice(-decimal)}`;\n } else if (value.length === decimal) {\n return `0.${value}`;\n } else {\n return `${value.slice(0, -decimal)}.${value.slice(-decimal)}`;\n }\n }\n }\n};\n\nconst formatStringNumeric = (value: string, type: StringNumericType) => {\n switch (type) {\n case \"long\":\n return value;\n case \"scaleddecimal2\":\n return injectDecimalPoint(value, 2);\n case \"scaleddecimal4\":\n return injectDecimalPoint(value, 4);\n case \"scaleddecimal6\":\n return injectDecimalPoint(value, 6);\n case \"scaleddecimal8\":\n return injectDecimalPoint(value, 8);\n }\n};\n/**\n * DataRow wraps a vuu DataSourceRow and a columnMap to provide a more convenient\n * API for manipulating rows from server. It is now used internally by Table. This\n * removes the need to always provide a columnMap to any componnet that must work with\n * data rows. It also removes a category of timing bugs which cause the columnMap\n * to get out of sync with data.\n * Because properties are provided via a proxy, and the DataRow has the Schema, there is\n * flexibility to enhance handling for specific properties. This is used now to insert\n * decimal point in scaleddecimal values.\n * @param data\n * @param columnMap\n * @returns\n */\nfunction DataRowImpl(data: VuuDataRow, columnMap: DataRowColumnMap): DataRow {\n const target: Record<string, VuuRowDataItemType> = {};\n\n const getPropertyNames = () => {\n return Object.keys(columnMap);\n };\n\n const jsonSerializer = () => {\n return Object.entries(columnMap).reduce<Record<string, VuuRowDataItemType>>(\n (json, [name, mapEntry]) => {\n if (mapEntry) {\n json[name] = data[mapEntry.index];\n }\n return json;\n },\n {},\n );\n };\n\n const DataRowOperations: DataRowOperations = {\n hasColumn: (name: string) => columnMap[name] !== undefined,\n };\n\n return new Proxy(target, {\n get(_obj, prop: string | symbol) {\n if (typeof prop === \"symbol\") {\n if (prop === dataRowSymbol) return true;\n // TODO what does React use this for\n return undefined;\n } else if (prop === \"toJSON\") {\n return jsonSerializer;\n } else if (prop === \"toString\") {\n return \"DataRow\";\n } else if (prop === \"$$typeof\") {\n // some react internal weirdness\n return undefined;\n } else if (isDataRowOperation(prop)) {\n return DataRowOperations[prop];\n } else if (prop === \"getPropertyNames\") {\n return getPropertyNames;\n }\n const columnMapEntry = columnMap[prop];\n\n if (columnMapEntry === undefined) {\n if (prop !== \"\") {\n // System columns like the selection checkbox column\n console.warn(`[DataRow:Proxy] unknown column ${prop}`);\n }\n return undefined;\n }\n\n if (isDataRowIntrinsicAttribute(prop)) {\n return data[columnMapEntry.index];\n }\n\n if (isStringNumericType(columnMapEntry.type)) {\n return formatStringNumeric(\n data[columnMapEntry.index] as string,\n columnMapEntry.type,\n );\n }\n\n return data[columnMapEntry.index];\n\n // throw new Error(`Unknown column: ${prop}`);\n },\n set() {\n throw new TypeError(\"DataRow is readonly\");\n },\n }) as DataRow;\n}\n\nexport type DataRowFunc = (data: DataSourceRow) => DataRow;\n\nconst ColumnMapIntrinsicColumns: DataRowColumnMap = {\n index: { index: 0, type: \"int\" },\n renderIndex: { index: 1, type: \"int\" },\n isLeaf: { index: 2, type: \"boolean\" },\n isExpanded: { index: 3, type: \"boolean\" },\n depth: { index: 4, type: \"int\" },\n childCount: { index: 5, type: \"int\" },\n key: { index: 6, type: \"string\" },\n isSelected: { index: 7, type: \"boolean\" },\n};\n\nfunction createColumnMap(\n columns: string[],\n schemaColumns: readonly SchemaColumn[],\n) {\n const columnMap: DataRowColumnMap = {\n ...ColumnMapIntrinsicColumns,\n };\n\n columns.forEach((name, i) => {\n const schemaColumn = schemaColumns.find((col) => col.name === name);\n if (schemaColumn) {\n columnMap[name] = { index: i + 10, type: schemaColumn.serverDataType };\n } else {\n throw Error(`[DataRow] dataRowFactory column not in schema ${name}`);\n }\n });\n return columnMap;\n}\n\n/**\n *\n * @param columns the names of columns included in subscription\n * @param schemaColumns full schema definitions for all available columns,\n * the serverDataTypes are used.\n * @returns a tuple containing:\n * - factory function that will create a DataRow instance from a DataSourceRow\n * array.\n * - a function that can be used to reset the columns, which will be used for all\n * subsequently created DataRows. Used by Table when user adds or removes columns\n * at runtime.\n */\nexport const dataRowFactory = (\n columns: string[],\n schemaColumns: readonly SchemaColumn[],\n): [DataRowFunc, (columns: string[]) => void] => {\n let columnMap = createColumnMap(columns, schemaColumns);\n\n columns.forEach((name, i) => {\n const schemaColumn = schemaColumns.find((col) => col.name === name);\n if (schemaColumn) {\n columnMap[name] = { index: i + 10, type: schemaColumn.serverDataType };\n } else {\n throw Error(`[DataRow] dataRowFactory column not in schema ${name}`);\n }\n });\n\n const setColumns = (columns: string[]) => {\n // new columnMap will be used for all subsequently created DataRows\n columnMap = createColumnMap(columns, schemaColumns);\n };\n\n const DataRow = function (data: DataSourceRow) {\n return DataRowImpl(data, columnMap);\n };\n\n return [DataRow, setColumns];\n};\n\nif (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore\n window.devtoolsFormatters = [\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n header: function (obj: any) {\n if (obj[dataRowSymbol]) {\n return [\n \"div\",\n {\n style: \"display: flex; gap: 4px; justify-content: space-between\",\n },\n [\"span\", {}, \"Vuu DataRow\"],\n [\"span\", { style: \"font-weight: bold;\" }, `[${obj.index}]`],\n [\n \"span\",\n { style: \"font-weight: bold; color: blue;\" },\n `#${obj.key}`,\n ],\n ];\n }\n return null;\n },\n hasBody: function () {\n return true;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n body: function (obj: any) {\n return [\n \"div\",\n {},\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"index\"],\n [\"span\", {}, obj.index],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"key\"],\n [\"span\", {}, obj.key],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"renderIndex\"],\n [\"span\", {}, obj.renderIndex],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"isSelected\"],\n [\"span\", {}, obj.isSelected],\n ],\n ...obj.getPropertyNames().map((name: string) => {\n return [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, name],\n [\"span\", {}, obj[name]],\n ];\n }),\n ];\n },\n },\n ];\n}\n"],"names":["DataRowOperations","columns","DataRow"],"mappings":";;AAmBA,MAAM,aAAA,0BAAuB,SAAS,CAAA;AAQtC,MAAM,0BAAsE,GAAA;AAAA,EAC1E,UAAY,EAAA,IAAA;AAAA,EACZ,KAAO,EAAA,IAAA;AAAA,EACP,KAAO,EAAA,IAAA;AAAA,EACP,UAAY,EAAA,IAAA;AAAA,EACZ,UAAY,EAAA,IAAA;AAAA,EACZ,MAAQ,EAAA,IAAA;AAAA,EACR,GAAK,EAAA,IAAA;AAAA,EACL,WAAa,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AAAA,YAC1B,CAAC,MAAA,EAAQ,EAAC,EAAG,IAAI,WAAW;AAAA,WAC9B;AAAA,UACA;AAAA,YACE,KAAA;AAAA,YACA;AAAA,cACE,KAAO,EAAA;AAAA,aACT;AAAA,YACA,CAAC,MAAA,EAAQ,EAAC,EAAG,YAAY,CAAA;AAAA,YACzB,CAAC,MAAA,EAAQ,EAAC,EAAG,IAAI,UAAU;AAAA,WAC7B;AAAA,UACA,GAAG,GAAI,CAAA,gBAAA,EAAmB,CAAA,GAAA,CAAI,CAAC,IAAiB,KAAA;AAC9C,YAAO,OAAA;AAAA,cACL,KAAA;AAAA,cACA;AAAA,gBACE,KAAO,EAAA;AAAA,eACT;AAAA,cACA,CAAC,MAAA,EAAQ,EAAC,EAAG,IAAI,CAAA;AAAA,cACjB,CAAC,MAAQ,EAAA,EAAI,EAAA,GAAA,CAAI,IAAI,CAAC;AAAA,aACxB;AAAA,WACD;AAAA,SACH;AAAA;AACF;AACF,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"DataRow.js","sources":["../../../../packages/vuu-table/src/data-row/DataRow.ts"],"sourcesContent":["import { DataSourceRow, SchemaColumn } from \"@vuu-ui/vuu-data-types\";\nimport {\n StringNumericType,\n VuuColumnDataType,\n VuuDataRow,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport {\n DataRow,\n DataRowIntrinsicAttribute,\n DataRowOperation,\n DataRowOperations,\n} from \"@vuu-ui/vuu-table-types\";\n\ntype ColumnMapEntry = {\n index: number;\n type: VuuColumnDataType;\n};\n\nconst dataRowSymbol = Symbol(\"DataRow\");\n\n/**\n * We allow undefined to allow us to null out rather than delete entries, for\n * performance reasons.\n */\ntype DataRowColumnMap = Record<string, ColumnMapEntry | undefined>;\n\nconst dataRowIntrinsicAttributes: Record<DataRowIntrinsicAttribute, true> = {\n childCount: true,\n depth: true,\n index: true,\n isExpanded: true,\n isSelected: true,\n isLeaf: true,\n key: true,\n renderIndex: true,\n};\n\nconst dataRowOperations: Record<DataRowOperation, true> = {\n hasColumn: true,\n};\n\nconst isDataRowIntrinsicAttribute = (\n attrName: string,\n): attrName is DataRowIntrinsicAttribute =>\n dataRowIntrinsicAttributes[attrName as DataRowIntrinsicAttribute] === true;\n\nconst isDataRowOperation = (attrName: string): attrName is DataRowOperation =>\n dataRowOperations[attrName as DataRowOperation] === true;\n\nconst stringNumericTypes: Record<StringNumericType, true> = {\n long: true,\n scaleddecimal2: true,\n scaleddecimal4: true,\n scaleddecimal6: true,\n scaleddecimal8: true,\n};\n\nconst isStringNumericType = (\n type: VuuColumnDataType,\n): type is StringNumericType =>\n stringNumericTypes[type as StringNumericType] === true;\n\nconst MAX_DECIMALS = \"0000000\";\n\nconst injectDecimalPoint = (value: string, decimal: 2 | 4 | 6 | 8) => {\n if (value === \"0\" || value === \"-0\" || value === \"\") {\n return value;\n } else {\n if (value[0] === \"-\") {\n const digits = value.slice(1);\n if (digits.length < decimal) {\n return `-0.${(MAX_DECIMALS + digits).slice(-decimal)}`;\n } else if (digits.length === decimal) {\n return `-0.${value}`;\n } else {\n return `-${digits.slice(0, -decimal)}.${digits.slice(-decimal)}`;\n }\n } else {\n if (value.length < decimal) {\n return `0.${(MAX_DECIMALS + value).slice(-decimal)}`;\n } else if (value.length === decimal) {\n return `0.${value}`;\n } else {\n return `${value.slice(0, -decimal)}.${value.slice(-decimal)}`;\n }\n }\n }\n};\n\nconst formatStringNumeric = (value: string, type: StringNumericType) => {\n switch (type) {\n case \"long\":\n return value;\n case \"scaleddecimal2\":\n return injectDecimalPoint(value, 2);\n case \"scaleddecimal4\":\n return injectDecimalPoint(value, 4);\n case \"scaleddecimal6\":\n return injectDecimalPoint(value, 6);\n case \"scaleddecimal8\":\n return injectDecimalPoint(value, 8);\n }\n};\n/**\n * DataRow wraps a vuu DataSourceRow and a columnMap to provide a more convenient\n * API for manipulating rows from server. It is now used internally by Table. This\n * removes the need to always provide a columnMap to any componnet that must work with\n * data rows. It also removes a category of timing bugs which cause the columnMap\n * to get out of sync with data.\n * Because properties are provided via a proxy, and the DataRow has the Schema, there is\n * flexibility to enhance handling for specific properties. This is used now to insert\n * decimal point in scaleddecimal values.\n * @param data\n * @param columnMap\n * @returns\n */\nfunction DataRowImpl(data: VuuDataRow, columnMap: DataRowColumnMap): DataRow {\n const target: Record<string, VuuRowDataItemType> = {};\n\n const getPropertyNames = () => {\n return Object.keys(columnMap);\n };\n\n const jsonSerializer = () => {\n return Object.entries(columnMap).reduce<Record<string, VuuRowDataItemType>>(\n (json, [name, mapEntry]) => {\n if (mapEntry) {\n json[name] = data[mapEntry.index];\n }\n return json;\n },\n {},\n );\n };\n\n const DataRowOperations: DataRowOperations = {\n hasColumn: (name: string) => columnMap[name] !== undefined,\n };\n\n return new Proxy(target, {\n get(_obj, prop: string | symbol) {\n if (typeof prop === \"symbol\") {\n if (prop === dataRowSymbol) return true;\n // TODO what does React use this for\n return undefined;\n } else if (prop === \"toJSON\") {\n return jsonSerializer;\n } else if (prop === \"toString\") {\n return \"DataRow\";\n } else if (prop === \"$$typeof\") {\n // some react internal weirdness\n return undefined;\n } else if (isDataRowOperation(prop)) {\n return DataRowOperations[prop];\n } else if (prop === \"getPropertyNames\") {\n return getPropertyNames;\n }\n const columnMapEntry = columnMap[prop];\n\n if (columnMapEntry === undefined) {\n if (prop !== \"\") {\n // System columns like the selection checkbox column\n console.warn(`[DataRow:Proxy] unknown column ${prop}`);\n }\n return undefined;\n }\n\n if (isDataRowIntrinsicAttribute(prop)) {\n return data[columnMapEntry.index];\n }\n\n if (isStringNumericType(columnMapEntry.type)) {\n return formatStringNumeric(\n data[columnMapEntry.index] as string,\n columnMapEntry.type,\n );\n }\n\n return data[columnMapEntry.index];\n\n // throw new Error(`Unknown column: ${prop}`);\n },\n set() {\n throw new TypeError(\"DataRow is readonly\");\n },\n }) as DataRow;\n}\n\nexport type DataRowFunc = (data: DataSourceRow) => DataRow;\n\nconst ColumnMapIntrinsicColumns: DataRowColumnMap = {\n index: { index: 0, type: \"int\" },\n renderIndex: { index: 1, type: \"int\" },\n isLeaf: { index: 2, type: \"boolean\" },\n isExpanded: { index: 3, type: \"boolean\" },\n depth: { index: 4, type: \"int\" },\n childCount: { index: 5, type: \"int\" },\n key: { index: 6, type: \"string\" },\n isSelected: { index: 7, type: \"boolean\" },\n};\n\nfunction createColumnMap(\n columns: string[],\n schemaColumns: readonly SchemaColumn[],\n) {\n const columnMap: DataRowColumnMap = {\n ...ColumnMapIntrinsicColumns,\n };\n\n columns.forEach((name, i) => {\n const schemaColumn = schemaColumns.find((col) => col.name === name);\n if (schemaColumn) {\n columnMap[name] = { index: i + 10, type: schemaColumn.serverDataType };\n } else {\n throw Error(`[DataRow] dataRowFactory column not in schema ${name}`);\n }\n });\n return columnMap;\n}\n\n/**\n *\n * @param columns the names of columns included in subscription\n * @param schemaColumns full schema definitions for all available columns,\n * the serverDataTypes are used.\n * @returns a tuple containing:\n * - factory function that will create a DataRow instance from a DataSourceRow\n * array.\n * - a function that can be used to reset the columns, which will be used for all\n * subsequently created DataRows. Used by Table when user adds or removes columns\n * at runtime.\n */\nexport const dataRowFactory = (\n columns: string[],\n schemaColumns: readonly SchemaColumn[],\n): [DataRowFunc, (columns: string[]) => void] => {\n let columnMap = createColumnMap(columns, schemaColumns);\n\n columns.forEach((name, i) => {\n const schemaColumn = schemaColumns.find((col) => col.name === name);\n if (schemaColumn) {\n columnMap[name] = { index: i + 10, type: schemaColumn.serverDataType };\n } else {\n throw Error(`[DataRow] dataRowFactory column not in schema ${name}`);\n }\n });\n\n const setColumns = (columns: string[]) => {\n // new columnMap will be used for all subsequently created DataRows\n columnMap = createColumnMap(columns, schemaColumns);\n };\n\n const DataRow = function (data: DataSourceRow) {\n return DataRowImpl(data, columnMap);\n };\n\n return [DataRow, setColumns];\n};\n\nif (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore\n window.devtoolsFormatters = [\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n header: function (obj: any) {\n if (obj[dataRowSymbol]) {\n return [\n \"div\",\n {\n style: \"display: flex; gap: 4px; justify-content: space-between\",\n },\n [\"span\", {}, \"Vuu DataRow\"],\n [\"span\", { style: \"font-weight: bold;\" }, `[${obj.index}]`],\n [\n \"span\",\n { style: \"font-weight: bold; color: blue;\" },\n `#${obj.key}`,\n ],\n ];\n }\n return null;\n },\n hasBody: function () {\n return true;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n body: function (obj: any) {\n return [\n \"div\",\n {},\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"index\"],\n [\"span\", {}, obj.index],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"key\"],\n [\"span\", {}, obj.key],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"renderIndex\"],\n [\"span\", {}, obj.renderIndex],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"isSelected\"],\n [\"span\", {}, obj.isSelected],\n ],\n ...obj.getPropertyNames().map((name: string) => {\n return [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, name],\n [\"span\", {}, obj[name]],\n ];\n }),\n ];\n },\n },\n ];\n}\n"],"names":["DataRowOperations","columns","DataRow"],"mappings":";;AAmBA,MAAM,aAAA,0BAAuB,SAAS,CAAA;AAQtC,MAAM,0BAAsE,GAAA;AAAA,EAC1E,UAAY,EAAA,IAAA;AAAA,EACZ,KAAO,EAAA,IAAA;AAAA,EACP,KAAO,EAAA,IAAA;AAAA,EACP,UAAY,EAAA,IAAA;AAAA,EACZ,UAAY,EAAA,IAAA;AAAA,EACZ,MAAQ,EAAA,IAAA;AAAA,EACR,GAAK,EAAA,IAAA;AAAA,EACL,WAAa,EAAA;AACf,CAAA;AAEA,MAAM,iBAAoD,GAAA;AAAA,EACxD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AC,EAAG,IAAI,WAAW;AAAA,WAC9B;AAAA,UACA;AAAA,YACE,KAAA;AAAA,YACA;AAAA,cACE,KAAO,EAAA;AAAA,aACT;AAAA,YACA,CAAC,MAAA,EAAQ,EAAC,EAAG,YAAY,CAAA;AAAA,YACzB,CAAC,MAAA,EAAQ,EAAC,EAAG,IAAI,UAAU;AAAA,WAC7B;AAAA,UACA,GAAG,GAAI,CAAA,gBAAA,EAAmB,CAAA,GAAA,CAAI,CAAC,IAAiB,KAAA;AAC9C,YAAO,OAAA;AAAA,cACL,KAAA;AAAA,cACA;AAAA,gBACE,KAAO,EAAA;AAAA,eACT;AAAA,cACA,CAAC,MAAA,EAAQ,EAAC,EAAG,IAAI,CAAA;AAAA,cACjB,CAAC,MAAQ,EAAA,EAAI,EAAA,GAAA,CAAI,IAAI,CAAC;AAAA,aACxB;AAAA,WACD;AAAA,SACH;AAAA;AACF;AACF,GACF;AACF;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -10,7 +10,9 @@ var InputCell = require('./cell-renderers/input-cell/InputCell.js');
|
|
|
10
10
|
var ToggleCell = require('./cell-renderers/toggle-cell/ToggleCell.js');
|
|
11
11
|
var GroupHeaderCell = require('./header-cell/GroupHeaderCell.js');
|
|
12
12
|
var HeaderCell = require('./header-cell/HeaderCell.js');
|
|
13
|
+
var DataRow = require('./data-row/DataRow.js');
|
|
13
14
|
var PaginationControl = require('./pagination/PaginationControl.js');
|
|
15
|
+
var Row = require('./Row.js');
|
|
14
16
|
var Table = require('./Table.js');
|
|
15
17
|
var TableCell = require('./table-cell/TableCell.js');
|
|
16
18
|
var TableGroupCell = require('./table-cell/TableGroupCell.js');
|
|
@@ -21,12 +23,11 @@ var useControlledTableNavigation = require('./useControlledTableNavigation.js');
|
|
|
21
23
|
var useEditableCell = require('./useEditableCell.js');
|
|
22
24
|
var useHighlighting = require('./useHighlighting.js');
|
|
23
25
|
var useKeyboardNavigation = require('./useKeyboardNavigation.js');
|
|
24
|
-
var useTableModel = require('./useTableModel.js');
|
|
25
26
|
var useTableContextMenu = require('./useTableContextMenu.js');
|
|
27
|
+
var useTableModel = require('./useTableModel.js');
|
|
26
28
|
var useTableScroll = require('./useTableScroll.js');
|
|
27
29
|
var useTableViewport = require('./useTableViewport.js');
|
|
28
30
|
var VirtualColSpan = require('./VirtualColSpan.js');
|
|
29
|
-
var DataRow = require('./data-row/DataRow.js');
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
|
|
@@ -40,7 +41,9 @@ exports.InputCell = InputCell.InputCell;
|
|
|
40
41
|
exports.ToggleCell = ToggleCell.ToggleCell;
|
|
41
42
|
exports.GroupHeaderCell = GroupHeaderCell.GroupHeaderCell;
|
|
42
43
|
exports.HeaderCell = HeaderCell.HeaderCell;
|
|
44
|
+
exports.dataRowFactory = DataRow.dataRowFactory;
|
|
43
45
|
exports.PaginationControl = PaginationControl.PaginationControl;
|
|
46
|
+
exports.Row = Row.Row;
|
|
44
47
|
exports.Table = Table.Table;
|
|
45
48
|
exports.TableCell = TableCell.TableCell;
|
|
46
49
|
exports.TableGroupCell = TableGroupCell.TableGroupCell;
|
|
@@ -55,12 +58,11 @@ exports.useHighlighting = useHighlighting.useHighlighting;
|
|
|
55
58
|
exports.isNavigationKey = useKeyboardNavigation.isNavigationKey;
|
|
56
59
|
exports.isPagingKey = useKeyboardNavigation.isPagingKey;
|
|
57
60
|
exports.useKeyboardNavigation = useKeyboardNavigation.useKeyboardNavigation;
|
|
58
|
-
exports.useTableModel = useTableModel.useTableModel;
|
|
59
61
|
exports.isTableLocation = useTableContextMenu.isTableLocation;
|
|
60
62
|
exports.useTableContextMenu = useTableContextMenu.useTableContextMenu;
|
|
63
|
+
exports.useTableModel = useTableModel.useTableModel;
|
|
61
64
|
exports.noScrolling = useTableScroll.noScrolling;
|
|
62
65
|
exports.useTableScroll = useTableScroll.useTableScroll;
|
|
63
66
|
exports.useTableViewport = useTableViewport.useTableViewport;
|
|
64
67
|
exports.VirtualColSpan = VirtualColSpan.VirtualColSpan;
|
|
65
|
-
exports.dataRowFactory = DataRow.dataRowFactory;
|
|
66
68
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/esm/data-row/DataRow.js
CHANGED
|
@@ -24,7 +24,7 @@ const stringNumericTypes = {
|
|
|
24
24
|
const isStringNumericType = (type) => stringNumericTypes[type] === true;
|
|
25
25
|
const MAX_DECIMALS = "0000000";
|
|
26
26
|
const injectDecimalPoint = (value, decimal) => {
|
|
27
|
-
if (value === "0" || value === "-0") {
|
|
27
|
+
if (value === "0" || value === "-0" || value === "") {
|
|
28
28
|
return value;
|
|
29
29
|
} else {
|
|
30
30
|
if (value[0] === "-") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataRow.js","sources":["../../../../packages/vuu-table/src/data-row/DataRow.ts"],"sourcesContent":["import { DataSourceRow, SchemaColumn } from \"@vuu-ui/vuu-data-types\";\nimport {\n StringNumericType,\n VuuColumnDataType,\n VuuDataRow,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport {\n DataRow,\n DataRowIntrinsicAttribute,\n DataRowOperation,\n DataRowOperations,\n} from \"@vuu-ui/vuu-table-types\";\n\ntype ColumnMapEntry = {\n index: number;\n type: VuuColumnDataType;\n};\n\nconst dataRowSymbol = Symbol(\"DataRow\");\n\n/**\n * We allow undefined to allow us to null out rather than delete entries, for\n * performance reasons.\n */\ntype DataRowColumnMap = Record<string, ColumnMapEntry | undefined>;\n\nconst dataRowIntrinsicAttributes: Record<DataRowIntrinsicAttribute, true> = {\n childCount: true,\n depth: true,\n index: true,\n isExpanded: true,\n isSelected: true,\n isLeaf: true,\n key: true,\n renderIndex: true,\n};\n\nconst dataRowOperations: Record<DataRowOperation, true> = {\n hasColumn: true,\n};\n\nconst isDataRowIntrinsicAttribute = (\n attrName: string,\n): attrName is DataRowIntrinsicAttribute =>\n dataRowIntrinsicAttributes[attrName as DataRowIntrinsicAttribute] === true;\n\nconst isDataRowOperation = (attrName: string): attrName is DataRowOperation =>\n dataRowOperations[attrName as DataRowOperation] === true;\n\nconst stringNumericTypes: Record<StringNumericType, true> = {\n long: true,\n scaleddecimal2: true,\n scaleddecimal4: true,\n scaleddecimal6: true,\n scaleddecimal8: true,\n};\n\nconst isStringNumericType = (\n type: VuuColumnDataType,\n): type is StringNumericType =>\n stringNumericTypes[type as StringNumericType] === true;\n\nconst MAX_DECIMALS = \"0000000\";\n\nconst injectDecimalPoint = (value: string, decimal: 2 | 4 | 6 | 8) => {\n if (value === \"0\" || value === \"-0\") {\n return value;\n } else {\n if (value[0] === \"-\") {\n const digits = value.slice(1);\n if (digits.length < decimal) {\n return `-0.${(MAX_DECIMALS + digits).slice(-decimal)}`;\n } else if (digits.length === decimal) {\n return `-0.${value}`;\n } else {\n return `-${digits.slice(0, -decimal)}.${digits.slice(-decimal)}`;\n }\n } else {\n if (value.length < decimal) {\n return `0.${(MAX_DECIMALS + value).slice(-decimal)}`;\n } else if (value.length === decimal) {\n return `0.${value}`;\n } else {\n return `${value.slice(0, -decimal)}.${value.slice(-decimal)}`;\n }\n }\n }\n};\n\nconst formatStringNumeric = (value: string, type: StringNumericType) => {\n switch (type) {\n case \"long\":\n return value;\n case \"scaleddecimal2\":\n return injectDecimalPoint(value, 2);\n case \"scaleddecimal4\":\n return injectDecimalPoint(value, 4);\n case \"scaleddecimal6\":\n return injectDecimalPoint(value, 6);\n case \"scaleddecimal8\":\n return injectDecimalPoint(value, 8);\n }\n};\n/**\n * DataRow wraps a vuu DataSourceRow and a columnMap to provide a more convenient\n * API for manipulating rows from server. It is now used internally by Table. This\n * removes the need to always provide a columnMap to any componnet that must work with\n * data rows. It also removes a category of timing bugs which cause the columnMap\n * to get out of sync with data.\n * Because properties are provided via a proxy, and the DataRow has the Schema, there is\n * flexibility to enhance handling for specific properties. This is used now to insert\n * decimal point in scaleddecimal values.\n * @param data\n * @param columnMap\n * @returns\n */\nfunction DataRowImpl(data: VuuDataRow, columnMap: DataRowColumnMap): DataRow {\n const target: Record<string, VuuRowDataItemType> = {};\n\n const getPropertyNames = () => {\n return Object.keys(columnMap);\n };\n\n const jsonSerializer = () => {\n return Object.entries(columnMap).reduce<Record<string, VuuRowDataItemType>>(\n (json, [name, mapEntry]) => {\n if (mapEntry) {\n json[name] = data[mapEntry.index];\n }\n return json;\n },\n {},\n );\n };\n\n const DataRowOperations: DataRowOperations = {\n hasColumn: (name: string) => columnMap[name] !== undefined,\n };\n\n return new Proxy(target, {\n get(_obj, prop: string | symbol) {\n if (typeof prop === \"symbol\") {\n if (prop === dataRowSymbol) return true;\n // TODO what does React use this for\n return undefined;\n } else if (prop === \"toJSON\") {\n return jsonSerializer;\n } else if (prop === \"toString\") {\n return \"DataRow\";\n } else if (prop === \"$$typeof\") {\n // some react internal weirdness\n return undefined;\n } else if (isDataRowOperation(prop)) {\n return DataRowOperations[prop];\n } else if (prop === \"getPropertyNames\") {\n return getPropertyNames;\n }\n const columnMapEntry = columnMap[prop];\n\n if (columnMapEntry === undefined) {\n if (prop !== \"\") {\n // System columns like the selection checkbox column\n console.warn(`[DataRow:Proxy] unknown column ${prop}`);\n }\n return undefined;\n }\n\n if (isDataRowIntrinsicAttribute(prop)) {\n return data[columnMapEntry.index];\n }\n\n if (isStringNumericType(columnMapEntry.type)) {\n return formatStringNumeric(\n data[columnMapEntry.index] as string,\n columnMapEntry.type,\n );\n }\n\n return data[columnMapEntry.index];\n\n // throw new Error(`Unknown column: ${prop}`);\n },\n set() {\n throw new TypeError(\"DataRow is readonly\");\n },\n }) as DataRow;\n}\n\nexport type DataRowFunc = (data: DataSourceRow) => DataRow;\n\nconst ColumnMapIntrinsicColumns: DataRowColumnMap = {\n index: { index: 0, type: \"int\" },\n renderIndex: { index: 1, type: \"int\" },\n isLeaf: { index: 2, type: \"boolean\" },\n isExpanded: { index: 3, type: \"boolean\" },\n depth: { index: 4, type: \"int\" },\n childCount: { index: 5, type: \"int\" },\n key: { index: 6, type: \"string\" },\n isSelected: { index: 7, type: \"boolean\" },\n};\n\nfunction createColumnMap(\n columns: string[],\n schemaColumns: readonly SchemaColumn[],\n) {\n const columnMap: DataRowColumnMap = {\n ...ColumnMapIntrinsicColumns,\n };\n\n columns.forEach((name, i) => {\n const schemaColumn = schemaColumns.find((col) => col.name === name);\n if (schemaColumn) {\n columnMap[name] = { index: i + 10, type: schemaColumn.serverDataType };\n } else {\n throw Error(`[DataRow] dataRowFactory column not in schema ${name}`);\n }\n });\n return columnMap;\n}\n\n/**\n *\n * @param columns the names of columns included in subscription\n * @param schemaColumns full schema definitions for all available columns,\n * the serverDataTypes are used.\n * @returns a tuple containing:\n * - factory function that will create a DataRow instance from a DataSourceRow\n * array.\n * - a function that can be used to reset the columns, which will be used for all\n * subsequently created DataRows. Used by Table when user adds or removes columns\n * at runtime.\n */\nexport const dataRowFactory = (\n columns: string[],\n schemaColumns: readonly SchemaColumn[],\n): [DataRowFunc, (columns: string[]) => void] => {\n let columnMap = createColumnMap(columns, schemaColumns);\n\n columns.forEach((name, i) => {\n const schemaColumn = schemaColumns.find((col) => col.name === name);\n if (schemaColumn) {\n columnMap[name] = { index: i + 10, type: schemaColumn.serverDataType };\n } else {\n throw Error(`[DataRow] dataRowFactory column not in schema ${name}`);\n }\n });\n\n const setColumns = (columns: string[]) => {\n // new columnMap will be used for all subsequently created DataRows\n columnMap = createColumnMap(columns, schemaColumns);\n };\n\n const DataRow = function (data: DataSourceRow) {\n return DataRowImpl(data, columnMap);\n };\n\n return [DataRow, setColumns];\n};\n\nif (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore\n window.devtoolsFormatters = [\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n header: function (obj: any) {\n if (obj[dataRowSymbol]) {\n return [\n \"div\",\n {\n style: \"display: flex; gap: 4px; justify-content: space-between\",\n },\n [\"span\", {}, \"Vuu DataRow\"],\n [\"span\", { style: \"font-weight: bold;\" }, `[${obj.index}]`],\n [\n \"span\",\n { style: \"font-weight: bold; color: blue;\" },\n `#${obj.key}`,\n ],\n ];\n }\n return null;\n },\n hasBody: function () {\n return true;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n body: function (obj: any) {\n return [\n \"div\",\n {},\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"index\"],\n [\"span\", {}, obj.index],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"key\"],\n [\"span\", {}, obj.key],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"renderIndex\"],\n [\"span\", {}, obj.renderIndex],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"isSelected\"],\n [\"span\", {}, obj.isSelected],\n ],\n ...obj.getPropertyNames().map((name: string) => {\n return [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, name],\n [\"span\", {}, obj[name]],\n ];\n }),\n ];\n },\n },\n ];\n}\n"],"names":["DataRowOperations","columns","DataRow"],"mappings":"AAmBA,MAAM,aAAA,0BAAuB,SAAS,CAAA;AAQtC,MAAM,0BAAsE,GAAA;AAAA,EAC1E,UAAY,EAAA,IAAA;AAAA,EACZ,KAAO,EAAA,IAAA;AAAA,EACP,KAAO,EAAA,IAAA;AAAA,EACP,UAAY,EAAA,IAAA;AAAA,EACZ,UAAY,EAAA,IAAA;AAAA,EACZ,MAAQ,EAAA,IAAA;AAAA,EACR,GAAK,EAAA,IAAA;AAAA,EACL,WAAa,EAAA;AACf,CAA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AAC,MAAA,EAAQ,EAAC,EAAG,IAAI,WAAW;AAAA,WAC9B;AAAA,UACA;AAAA,YACE,KAAA;AAAA,YACA;AAAA,cACE,KAAO,EAAA;AAAA,aACT;AAAA,YACA,CAAC,MAAA,EAAQ,EAAC,EAAG,YAAY,CAAA;AAAA,YACzB,CAAC,MAAA,EAAQ,EAAC,EAAG,IAAI,UAAU;AAAA,WAC7B;AAAA,UACA,GAAG,GAAI,CAAA,gBAAA,EAAmB,CAAA,GAAA,CAAI,CAAC,IAAiB,KAAA;AAC9C,YAAO,OAAA;AAAA,cACL,KAAA;AAAA,cACA;AAAA,gBACE,KAAO,EAAA;AAAA,eACT;AAAA,cACA,CAAC,MAAA,EAAQ,EAAC,EAAG,IAAI,CAAA;AAAA,cACjB,CAAC,MAAQ,EAAA,EAAI,EAAA,GAAA,CAAI,IAAI,CAAC;AAAA,aACxB;AAAA,WACD;AAAA,SACH;AAAA;AACF;AACF,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"DataRow.js","sources":["../../../../packages/vuu-table/src/data-row/DataRow.ts"],"sourcesContent":["import { DataSourceRow, SchemaColumn } from \"@vuu-ui/vuu-data-types\";\nimport {\n StringNumericType,\n VuuColumnDataType,\n VuuDataRow,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport {\n DataRow,\n DataRowIntrinsicAttribute,\n DataRowOperation,\n DataRowOperations,\n} from \"@vuu-ui/vuu-table-types\";\n\ntype ColumnMapEntry = {\n index: number;\n type: VuuColumnDataType;\n};\n\nconst dataRowSymbol = Symbol(\"DataRow\");\n\n/**\n * We allow undefined to allow us to null out rather than delete entries, for\n * performance reasons.\n */\ntype DataRowColumnMap = Record<string, ColumnMapEntry | undefined>;\n\nconst dataRowIntrinsicAttributes: Record<DataRowIntrinsicAttribute, true> = {\n childCount: true,\n depth: true,\n index: true,\n isExpanded: true,\n isSelected: true,\n isLeaf: true,\n key: true,\n renderIndex: true,\n};\n\nconst dataRowOperations: Record<DataRowOperation, true> = {\n hasColumn: true,\n};\n\nconst isDataRowIntrinsicAttribute = (\n attrName: string,\n): attrName is DataRowIntrinsicAttribute =>\n dataRowIntrinsicAttributes[attrName as DataRowIntrinsicAttribute] === true;\n\nconst isDataRowOperation = (attrName: string): attrName is DataRowOperation =>\n dataRowOperations[attrName as DataRowOperation] === true;\n\nconst stringNumericTypes: Record<StringNumericType, true> = {\n long: true,\n scaleddecimal2: true,\n scaleddecimal4: true,\n scaleddecimal6: true,\n scaleddecimal8: true,\n};\n\nconst isStringNumericType = (\n type: VuuColumnDataType,\n): type is StringNumericType =>\n stringNumericTypes[type as StringNumericType] === true;\n\nconst MAX_DECIMALS = \"0000000\";\n\nconst injectDecimalPoint = (value: string, decimal: 2 | 4 | 6 | 8) => {\n if (value === \"0\" || value === \"-0\" || value === \"\") {\n return value;\n } else {\n if (value[0] === \"-\") {\n const digits = value.slice(1);\n if (digits.length < decimal) {\n return `-0.${(MAX_DECIMALS + digits).slice(-decimal)}`;\n } else if (digits.length === decimal) {\n return `-0.${value}`;\n } else {\n return `-${digits.slice(0, -decimal)}.${digits.slice(-decimal)}`;\n }\n } else {\n if (value.length < decimal) {\n return `0.${(MAX_DECIMALS + value).slice(-decimal)}`;\n } else if (value.length === decimal) {\n return `0.${value}`;\n } else {\n return `${value.slice(0, -decimal)}.${value.slice(-decimal)}`;\n }\n }\n }\n};\n\nconst formatStringNumeric = (value: string, type: StringNumericType) => {\n switch (type) {\n case \"long\":\n return value;\n case \"scaleddecimal2\":\n return injectDecimalPoint(value, 2);\n case \"scaleddecimal4\":\n return injectDecimalPoint(value, 4);\n case \"scaleddecimal6\":\n return injectDecimalPoint(value, 6);\n case \"scaleddecimal8\":\n return injectDecimalPoint(value, 8);\n }\n};\n/**\n * DataRow wraps a vuu DataSourceRow and a columnMap to provide a more convenient\n * API for manipulating rows from server. It is now used internally by Table. This\n * removes the need to always provide a columnMap to any componnet that must work with\n * data rows. It also removes a category of timing bugs which cause the columnMap\n * to get out of sync with data.\n * Because properties are provided via a proxy, and the DataRow has the Schema, there is\n * flexibility to enhance handling for specific properties. This is used now to insert\n * decimal point in scaleddecimal values.\n * @param data\n * @param columnMap\n * @returns\n */\nfunction DataRowImpl(data: VuuDataRow, columnMap: DataRowColumnMap): DataRow {\n const target: Record<string, VuuRowDataItemType> = {};\n\n const getPropertyNames = () => {\n return Object.keys(columnMap);\n };\n\n const jsonSerializer = () => {\n return Object.entries(columnMap).reduce<Record<string, VuuRowDataItemType>>(\n (json, [name, mapEntry]) => {\n if (mapEntry) {\n json[name] = data[mapEntry.index];\n }\n return json;\n },\n {},\n );\n };\n\n const DataRowOperations: DataRowOperations = {\n hasColumn: (name: string) => columnMap[name] !== undefined,\n };\n\n return new Proxy(target, {\n get(_obj, prop: string | symbol) {\n if (typeof prop === \"symbol\") {\n if (prop === dataRowSymbol) return true;\n // TODO what does React use this for\n return undefined;\n } else if (prop === \"toJSON\") {\n return jsonSerializer;\n } else if (prop === \"toString\") {\n return \"DataRow\";\n } else if (prop === \"$$typeof\") {\n // some react internal weirdness\n return undefined;\n } else if (isDataRowOperation(prop)) {\n return DataRowOperations[prop];\n } else if (prop === \"getPropertyNames\") {\n return getPropertyNames;\n }\n const columnMapEntry = columnMap[prop];\n\n if (columnMapEntry === undefined) {\n if (prop !== \"\") {\n // System columns like the selection checkbox column\n console.warn(`[DataRow:Proxy] unknown column ${prop}`);\n }\n return undefined;\n }\n\n if (isDataRowIntrinsicAttribute(prop)) {\n return data[columnMapEntry.index];\n }\n\n if (isStringNumericType(columnMapEntry.type)) {\n return formatStringNumeric(\n data[columnMapEntry.index] as string,\n columnMapEntry.type,\n );\n }\n\n return data[columnMapEntry.index];\n\n // throw new Error(`Unknown column: ${prop}`);\n },\n set() {\n throw new TypeError(\"DataRow is readonly\");\n },\n }) as DataRow;\n}\n\nexport type DataRowFunc = (data: DataSourceRow) => DataRow;\n\nconst ColumnMapIntrinsicColumns: DataRowColumnMap = {\n index: { index: 0, type: \"int\" },\n renderIndex: { index: 1, type: \"int\" },\n isLeaf: { index: 2, type: \"boolean\" },\n isExpanded: { index: 3, type: \"boolean\" },\n depth: { index: 4, type: \"int\" },\n childCount: { index: 5, type: \"int\" },\n key: { index: 6, type: \"string\" },\n isSelected: { index: 7, type: \"boolean\" },\n};\n\nfunction createColumnMap(\n columns: string[],\n schemaColumns: readonly SchemaColumn[],\n) {\n const columnMap: DataRowColumnMap = {\n ...ColumnMapIntrinsicColumns,\n };\n\n columns.forEach((name, i) => {\n const schemaColumn = schemaColumns.find((col) => col.name === name);\n if (schemaColumn) {\n columnMap[name] = { index: i + 10, type: schemaColumn.serverDataType };\n } else {\n throw Error(`[DataRow] dataRowFactory column not in schema ${name}`);\n }\n });\n return columnMap;\n}\n\n/**\n *\n * @param columns the names of columns included in subscription\n * @param schemaColumns full schema definitions for all available columns,\n * the serverDataTypes are used.\n * @returns a tuple containing:\n * - factory function that will create a DataRow instance from a DataSourceRow\n * array.\n * - a function that can be used to reset the columns, which will be used for all\n * subsequently created DataRows. Used by Table when user adds or removes columns\n * at runtime.\n */\nexport const dataRowFactory = (\n columns: string[],\n schemaColumns: readonly SchemaColumn[],\n): [DataRowFunc, (columns: string[]) => void] => {\n let columnMap = createColumnMap(columns, schemaColumns);\n\n columns.forEach((name, i) => {\n const schemaColumn = schemaColumns.find((col) => col.name === name);\n if (schemaColumn) {\n columnMap[name] = { index: i + 10, type: schemaColumn.serverDataType };\n } else {\n throw Error(`[DataRow] dataRowFactory column not in schema ${name}`);\n }\n });\n\n const setColumns = (columns: string[]) => {\n // new columnMap will be used for all subsequently created DataRows\n columnMap = createColumnMap(columns, schemaColumns);\n };\n\n const DataRow = function (data: DataSourceRow) {\n return DataRowImpl(data, columnMap);\n };\n\n return [DataRow, setColumns];\n};\n\nif (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore\n window.devtoolsFormatters = [\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n header: function (obj: any) {\n if (obj[dataRowSymbol]) {\n return [\n \"div\",\n {\n style: \"display: flex; gap: 4px; justify-content: space-between\",\n },\n [\"span\", {}, \"Vuu DataRow\"],\n [\"span\", { style: \"font-weight: bold;\" }, `[${obj.index}]`],\n [\n \"span\",\n { style: \"font-weight: bold; color: blue;\" },\n `#${obj.key}`,\n ],\n ];\n }\n return null;\n },\n hasBody: function () {\n return true;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n body: function (obj: any) {\n return [\n \"div\",\n {},\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"index\"],\n [\"span\", {}, obj.index],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"key\"],\n [\"span\", {}, obj.key],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"renderIndex\"],\n [\"span\", {}, obj.renderIndex],\n ],\n [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, \"isSelected\"],\n [\"span\", {}, obj.isSelected],\n ],\n ...obj.getPropertyNames().map((name: string) => {\n return [\n \"div\",\n {\n style: \"display: flex; gap: 4px;\",\n },\n [\"span\", {}, name],\n [\"span\", {}, obj[name]],\n ];\n }),\n ];\n },\n },\n ];\n}\n"],"names":["DataRowOperations","columns","DataRow"],"mappings":"AAmBA,MAAM,aAAA,0BAAuB,SAAS,CAAA;AAQtC,MAAM,0BAAsE,GAAA;AAAA,EAC1E,UAAY,EAAA,IAAA;AAAA,EACZ,KAAO,EAAA,IAAA;AAAA,EACP,KAAO,EAAA,IAAA;AAAA,EACP,UAAY,EAAA,IAAA;AAAA,EACZ,UAAY,EAAA,IAAA;AAAA,EACZ,MAAQ,EAAA,IAAA;AAAA,EACR,GAAK,EAAA,IAAA;AAAA,EACL,WAAa,EAAA;AACf,CAAA;AAEA,MAAM,iBAAoD,GAAA;AAAA,EACxD,SAAW,EAAA;AAC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WAAW;AAAA,WAC9B;AAAA,UACA;AAAA,YACE,KAAA;AAAA,YACA;AAAA,cACE,KAAO,EAAA;AAAA,aACT;AAAA,YACA,CAAC,MAAA,EAAQ,EAAC,EAAG,YAAY,CAAA;AAAA,YACzB,CAAC,MAAA,EAAQ,EAAC,EAAG,IAAI,UAAU;AAAA,WAC7B;AAAA,UACA,GAAG,GAAI,CAAA,gBAAA,EAAmB,CAAA,GAAA,CAAI,CAAC,IAAiB,KAAA;AAC9C,YAAO,OAAA;AAAA,cACL,KAAA;AAAA,cACA;AAAA,gBACE,KAAO,EAAA;AAAA,eACT;AAAA,cACA,CAAC,MAAA,EAAQ,EAAC,EAAG,IAAI,CAAA;AAAA,cACjB,CAAC,MAAQ,EAAA,EAAI,EAAA,GAAA,CAAI,IAAI,CAAC;AAAA,aACxB;AAAA,WACD;AAAA,SACH;AAAA;AACF;AACF,GACF;AACF;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -8,7 +8,9 @@ export { InputCell } from './cell-renderers/input-cell/InputCell.js';
|
|
|
8
8
|
export { ToggleCell } from './cell-renderers/toggle-cell/ToggleCell.js';
|
|
9
9
|
export { GroupHeaderCell } from './header-cell/GroupHeaderCell.js';
|
|
10
10
|
export { HeaderCell } from './header-cell/HeaderCell.js';
|
|
11
|
+
export { dataRowFactory } from './data-row/DataRow.js';
|
|
11
12
|
export { PaginationControl } from './pagination/PaginationControl.js';
|
|
13
|
+
export { Row } from './Row.js';
|
|
12
14
|
export { Table } from './Table.js';
|
|
13
15
|
export { TableCell } from './table-cell/TableCell.js';
|
|
14
16
|
export { TableGroupCell } from './table-cell/TableGroupCell.js';
|
|
@@ -19,10 +21,9 @@ export { isRowSelectionKey, useControlledTableNavigation } from './useControlled
|
|
|
19
21
|
export { useEditableCell } from './useEditableCell.js';
|
|
20
22
|
export { useHighlighting } from './useHighlighting.js';
|
|
21
23
|
export { isNavigationKey, isPagingKey, useKeyboardNavigation } from './useKeyboardNavigation.js';
|
|
22
|
-
export { useTableModel } from './useTableModel.js';
|
|
23
24
|
export { isTableLocation, useTableContextMenu } from './useTableContextMenu.js';
|
|
25
|
+
export { useTableModel } from './useTableModel.js';
|
|
24
26
|
export { noScrolling, useTableScroll } from './useTableScroll.js';
|
|
25
27
|
export { useTableViewport } from './useTableViewport.js';
|
|
26
28
|
export { VirtualColSpan } from './VirtualColSpan.js';
|
|
27
|
-
export { dataRowFactory } from './data-row/DataRow.js';
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.2",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@vuu-ui/vuu-data-types": "1.0.
|
|
7
|
-
"@vuu-ui/vuu-table-types": "1.0.
|
|
8
|
-
"@vuu-ui/vuu-protocol-types": "1.0.
|
|
6
|
+
"@vuu-ui/vuu-data-types": "1.0.2",
|
|
7
|
+
"@vuu-ui/vuu-table-types": "1.0.2",
|
|
8
|
+
"@vuu-ui/vuu-protocol-types": "1.0.2"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@salt-ds/core": "1.54.1",
|
|
12
12
|
"@salt-ds/styles": "0.2.1",
|
|
13
13
|
"@salt-ds/window": "0.1.1",
|
|
14
|
-
"@vuu-ui/vuu-context-menu": "1.0.
|
|
15
|
-
"@vuu-ui/vuu-data-react": "1.0.
|
|
16
|
-
"@vuu-ui/vuu-popups": "1.0.
|
|
17
|
-
"@vuu-ui/vuu-table-extras": "1.0.
|
|
18
|
-
"@vuu-ui/vuu-ui-controls": "1.0.
|
|
19
|
-
"@vuu-ui/vuu-utils": "1.0.
|
|
14
|
+
"@vuu-ui/vuu-context-menu": "1.0.2",
|
|
15
|
+
"@vuu-ui/vuu-data-react": "1.0.2",
|
|
16
|
+
"@vuu-ui/vuu-popups": "1.0.2",
|
|
17
|
+
"@vuu-ui/vuu-table-extras": "1.0.2",
|
|
18
|
+
"@vuu-ui/vuu-ui-controls": "1.0.2",
|
|
19
|
+
"@vuu-ui/vuu-utils": "1.0.2"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"clsx": "^2.0.0",
|
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from "./bulk-edit";
|
|
2
2
|
export * from "./cell-renderers";
|
|
3
3
|
export * from "./header-cell";
|
|
4
|
-
export
|
|
4
|
+
export { dataRowFactory, type DataRowFunc } from "./data-row/DataRow";
|
|
5
5
|
export * from "./pagination";
|
|
6
|
+
export { Row } from "./Row";
|
|
6
7
|
export * from "./Table";
|
|
7
8
|
export * from "./table-cell";
|
|
8
9
|
export * from "./table-config";
|
|
@@ -11,9 +12,8 @@ export * from "./useControlledTableNavigation";
|
|
|
11
12
|
export * from "./useEditableCell";
|
|
12
13
|
export * from "./useHighlighting";
|
|
13
14
|
export * from "./useKeyboardNavigation";
|
|
14
|
-
export * from "./useTableModel";
|
|
15
15
|
export * from "./useTableContextMenu";
|
|
16
|
+
export * from "./useTableModel";
|
|
16
17
|
export * from "./useTableScroll";
|
|
17
18
|
export * from "./useTableViewport";
|
|
18
19
|
export * from "./VirtualColSpan";
|
|
19
|
-
export { dataRowFactory, type DataRowFunc } from "./data-row/DataRow";
|