@vuu-ui/vuu-utils 0.13.41 → 0.13.43

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.
@@ -360,6 +360,8 @@ exports.isOpenDialogAction = protocolMessageUtils.isOpenDialogAction;
360
360
  exports.isOpenSessionTableDialogMessage = protocolMessageUtils.isOpenSessionTableDialogMessage;
361
361
  exports.isRequestResponse = protocolMessageUtils.isRequestResponse;
362
362
  exports.isRpcServiceRequest = protocolMessageUtils.isRpcServiceRequest;
363
+ exports.isSelectRequest = protocolMessageUtils.isSelectRequest;
364
+ exports.isSelectSuccessWithRowCount = protocolMessageUtils.isSelectSuccessWithRowCount;
363
365
  exports.isSessionTable = protocolMessageUtils.isSessionTable;
364
366
  exports.isSessionTableActionMessage = protocolMessageUtils.isSessionTableActionMessage;
365
367
  exports.isTypeaheadRequest = protocolMessageUtils.isTypeaheadRequest;
@@ -377,15 +379,8 @@ exports.actualRowPositioning = rowUtils.actualRowPositioning;
377
379
  exports.asDataSourceRowObject = rowUtils.asDataSourceRowObject;
378
380
  exports.virtualRowPositioning = rowUtils.virtualRowPositioning;
379
381
  exports.vuuRowToDataSourceRow = rowUtils.vuuRowToDataSourceRow;
380
- exports.RowSelected = selectionUtils.RowSelected;
381
382
  exports.deselectItem = selectionUtils.deselectItem;
382
- exports.expandSelection = selectionUtils.expandSelection;
383
- exports.getSelectionStatus = selectionUtils.getSelectionStatus;
384
- exports.isRowSelected = selectionUtils.isRowSelected;
385
- exports.isRowSelectedLast = selectionUtils.isRowSelectedLast;
386
- exports.isSelected = selectionUtils.isSelected;
387
383
  exports.selectItem = selectionUtils.selectItem;
388
- exports.selectionCount = selectionUtils.selectionCount;
389
384
  exports.VuuShellLocation = shellLayoutTypes.VuuShellLocation;
390
385
  exports.addSortColumn = sortUtils.addSortColumn;
391
386
  exports.getSortStatus = sortUtils.getSortStatus;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2,7 +2,6 @@
2
2
 
3
3
  var columnUtils = require('./column-utils.js');
4
4
  var rangeUtils = require('./range-utils.js');
5
- var selectionUtils = require('./selection-utils.js');
6
5
 
7
6
  var __defProp = Object.defineProperty;
8
7
  var __typeError = (msg) => {
@@ -36,13 +35,6 @@ class MovingWindow {
36
35
  if (this.isWithinRange(index)) {
37
36
  const internalIndex = index - __privateGet(this, _range).from;
38
37
  this.data[internalIndex] = data;
39
- if (data[SELECTED]) {
40
- const previousRow = this.data[internalIndex - 1];
41
- if (selectionUtils.isRowSelectedLast(previousRow)) {
42
- this.data[internalIndex - 1] = previousRow.slice();
43
- this.data[internalIndex - 1][SELECTED] -= 4;
44
- }
45
- }
46
38
  }
47
39
  }
48
40
  getAtIndex(index) {
@@ -1 +1 @@
1
- {"version":3,"file":"moving-window.js","sources":["../../../../../../packages/vuu-utils/src/moving-window.ts"],"sourcesContent":["import { DataSourceRow } from \"@vuu-ui/vuu-data-types\";\nimport { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { metadataKeys } from \"./column-utils\";\nimport { WindowRange } from \"./range-utils\";\nimport { isRowSelectedLast } from \"./selection-utils\";\n\nconst { SELECTED } = metadataKeys;\n\nexport class MovingWindow {\n public data: DataSourceRow[];\n public rowCount = 0;\n #range: WindowRange;\n\n constructor({ from, to }: VuuRange) {\n this.#range = new WindowRange(from, to);\n //internal data is always 0 based, we add range.from to determine an offset\n this.data = new Array(Math.max(0, to - from));\n this.rowCount = 0;\n }\n\n setRowCount = (rowCount: number) => {\n if (rowCount < this.data.length) {\n this.data.length = rowCount;\n }\n\n this.rowCount = rowCount;\n };\n\n add(data: DataSourceRow) {\n const [index] = data;\n if (this.isWithinRange(index)) {\n const internalIndex = index - this.#range.from;\n this.data[internalIndex] = data;\n\n // Hack until we can deal with this more elegantly. When we have a block\n // select operation, first row is selected (and updated via server), then\n // remaining rows are selected when we select the block-end row. We get an\n // update for all rows except first. Because we're extending the select status\n // on the client, we have to adjust the first row selected (its still selected\n // but is no longer the 'last selected row in block')\n // Maybe answer is to apply ALL the selection status code here, not in Viewport\n if (data[SELECTED]) {\n const previousRow = this.data[internalIndex - 1];\n if (isRowSelectedLast(previousRow)) {\n this.data[internalIndex - 1] = previousRow.slice() as DataSourceRow;\n this.data[internalIndex - 1][SELECTED] -= 4;\n }\n }\n }\n }\n\n getAtIndex(index: number) {\n return this.#range.isWithin(index) &&\n this.data[index - this.#range.from] != null\n ? this.data[index - this.#range.from]\n : undefined;\n }\n\n isWithinRange(index: number) {\n return this.#range.isWithin(index);\n }\n\n setRange({ from, to }: VuuRange) {\n if (from !== this.#range.from || to !== this.#range.to) {\n const [overlapFrom, overlapTo] = this.#range.overlap(from, to);\n const newData = new Array(Math.max(0, to - from));\n for (let i = overlapFrom; i < overlapTo; i++) {\n const data = this.getAtIndex(i);\n if (data) {\n const index = i - from;\n newData[index] = data;\n }\n }\n this.data = newData;\n this.#range.from = from;\n this.#range.to = to;\n }\n }\n\n getSelectedRows() {\n return this.data.filter((row) => row[SELECTED] !== 0);\n }\n\n get range() {\n return this.#range;\n }\n\n slice(): DataSourceRow[] {\n const data: DataSourceRow[] = [];\n const { from } = this.range;\n for (let i = 0; i < this.data.length; i++) {\n if (this.data[i]) {\n data.push(this.data[i]);\n } else {\n data.push([from + i, from + i, true, false, 1, 0, \"\", 0, 0, false]);\n }\n }\n return data;\n }\n\n // TODO make this more performant, see implementation in\n // array-backed-moving-window - use same implementation\n get hasAllRowsWithinRange(): boolean {\n const { from, to } = this.#range;\n\n for (let i = from; i < to; i++) {\n if (this.getAtIndex(i) === undefined) {\n return false;\n }\n }\n return true;\n }\n}\n"],"names":["metadataKeys","WindowRange","isRowSelectedLast"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA,MAAA;AAMA,MAAM,EAAE,UAAa,GAAAA,wBAAA;AAEd,MAAM,YAAa,CAAA;AAAA,EAKxB,WAAY,CAAA,EAAE,IAAM,EAAA,EAAA,EAAgB,EAAA;AAJpC,IAAO,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AACP,IAAA,aAAA,CAAA,IAAA,EAAO,UAAW,EAAA,CAAA,CAAA;AAClB,IAAA,YAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AASA,IA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,OAAA,EAAA;;;;"}
1
+ {"version":3,"file":"moving-window.js","sources":["../../../../../../packages/vuu-utils/src/moving-window.ts"],"sourcesContent":["import { DataSourceRow } from \"@vuu-ui/vuu-data-types\";\nimport { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { metadataKeys } from \"./column-utils\";\nimport { WindowRange } from \"./range-utils\";\n\nconst { SELECTED } = metadataKeys;\n\nexport class MovingWindow {\n public data: DataSourceRow[];\n public rowCount = 0;\n #range: WindowRange;\n\n constructor({ from, to }: VuuRange) {\n this.#range = new WindowRange(from, to);\n //internal data is always 0 based, we add range.from to determine an offset\n this.data = new Array(Math.max(0, to - from));\n this.rowCount = 0;\n }\n\n setRowCount = (rowCount: number) => {\n if (rowCount < this.data.length) {\n this.data.length = rowCount;\n }\n\n this.rowCount = rowCount;\n };\n\n add(data: DataSourceRow) {\n const [index] = data;\n if (this.isWithinRange(index)) {\n const internalIndex = index - this.#range.from;\n this.data[internalIndex] = data;\n }\n }\n\n getAtIndex(index: number) {\n return this.#range.isWithin(index) &&\n this.data[index - this.#range.from] != null\n ? this.data[index - this.#range.from]\n : undefined;\n }\n\n isWithinRange(index: number) {\n return this.#range.isWithin(index);\n }\n\n setRange({ from, to }: VuuRange) {\n if (from !== this.#range.from || to !== this.#range.to) {\n const [overlapFrom, overlapTo] = this.#range.overlap(from, to);\n const newData = new Array(Math.max(0, to - from));\n for (let i = overlapFrom; i < overlapTo; i++) {\n const data = this.getAtIndex(i);\n if (data) {\n const index = i - from;\n newData[index] = data;\n }\n }\n this.data = newData;\n this.#range.from = from;\n this.#range.to = to;\n }\n }\n\n getSelectedRows() {\n return this.data.filter((row) => row[SELECTED] !== 0);\n }\n\n get range() {\n return this.#range;\n }\n\n slice(): DataSourceRow[] {\n const data: DataSourceRow[] = [];\n const { from } = this.range;\n for (let i = 0; i < this.data.length; i++) {\n if (this.data[i]) {\n data.push(this.data[i]);\n } else {\n data.push([from + i, from + i, true, false, 1, 0, \"\", 0, 0, false]);\n }\n }\n return data;\n }\n\n // TODO make this more performant, see implementation in\n // array-backed-moving-window - use same implementation\n get hasAllRowsWithinRange(): boolean {\n const { from, to } = this.#range;\n\n for (let i = from; i < to; i++) {\n if (this.getAtIndex(i) === undefined) {\n return false;\n }\n }\n return true;\n }\n}\n"],"names":["metadataKeys","WindowRange"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAA,MAAA;AAKA,MAAM,EAAE,UAAa,GAAAA,wBAAA;AAEd,MAAM,YAAa,CAAA;AAAA,EAKxB,WAAY,CAAA,EAAE,IAAM,EAAA,EAAA,EAAgB,EAAA;AAJpC,IAAO,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AACP,IAAA,aAAA,CAAA,IAAA,EAAO,UAAW,EAAA,CAAA,CAAA;AAClB,IAAA,YAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AASA,IAAA,aAAA,CAAA,IAAA,EAAA,aAAA,EAAc,CAAC,QAAqB,KAAA;AAClC,MAAI,IAAA,QAAA,GAAW,IAAK,CAAA,IAAA,CAAK,MAAQ,EAAA;AAC/B,QAAA,IAAA,CAAK,KAAK,MAAS,GAAA,QAAA;AAAA;AAGrB,MAAA,IAAA,CAAK,QAAW,GAAA,QAAA;AAAA,KAClB,CAAA;AAZE,IAAA,YAAA,CAAA,IAAA,EAAK,MAAS,EAAA,IAAIC,sBAAY,CAAA,IAAA,EAAM,EAAE,CAAA,CAAA;AAEtC,IAAK,IAAA,CAAA,IAAA,GAAO,IAAI,KAAM,CAAA,IAAA,CAAK,IAAI,CAAG,EAAA,EAAA,GAAK,IAAI,CAAC,CAAA;AAC5C,IAAA,IAAA,CAAK,QAAW,GAAA,CAAA;AAAA;AAClB,EAUA,IAAI,IAAqB,EAAA;AACvB,IAAM,MAAA,CAAC,KAAK,CAAI,GAAA,IAAA;AAChB,IAAI,IAAA,IAAA,CAAK,aAAc,CAAA,KAAK,CAAG,EAAA;AAC7B,MAAM,MAAA,aAAA,GAAgB,KAAQ,GAAA,YAAA,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AA,IAAI,IAAK,CAAA,UAAA,CAAW,CAAC,CAAA,KAAM,KAAW,CAAA,EAAA;AACpC,QAAO,OAAA,KAAA;AAAA;AACT;AAEF,IAAO,OAAA,IAAA;AAAA;AAEX;AAtFE,MAAA,GAAA,IAAA,OAAA,EAAA;;;;"}
@@ -14,6 +14,14 @@ const MENU_RPC_TYPES = [
14
14
  "VP_EDIT_DELETE_ROW_RPC",
15
15
  "VP_EDIT_SUBMIT_FORM_RPC"
16
16
  ];
17
+ const isSelectRequest = (message) => "type" in message && (message.type === "SELECT_ROW" || message.type === "DESELECT_ROW" || message.type === "SELECT_ROW_RANGE" || message.type === "SELECT_ALL" || message.type === "DESELECT_ALL");
18
+ const isSelectSuccessWithRowCount = (response) => [
19
+ "SELECT_ROW_SUCCESS",
20
+ "DESELECT_ROW_SUCCESS",
21
+ "SELECT_ROW_RANGE_SUCCESS",
22
+ "SELECT_ALL_SUCCESS",
23
+ "DESELECT_ALL_SUCCESS"
24
+ ].includes(response.type ?? "") && typeof response.selectedRowCount === "number";
17
25
  const isRpcServiceRequest = (message) => message.type === "RPC_REQUEST";
18
26
  const hasViewPortContext = (message) => message.context.type === "VIEWPORT_CONTEXT";
19
27
  const isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
@@ -76,6 +84,8 @@ exports.isOpenDialogAction = isOpenDialogAction;
76
84
  exports.isOpenSessionTableDialogMessage = isOpenSessionTableDialogMessage;
77
85
  exports.isRequestResponse = isRequestResponse;
78
86
  exports.isRpcServiceRequest = isRpcServiceRequest;
87
+ exports.isSelectRequest = isSelectRequest;
88
+ exports.isSelectSuccessWithRowCount = isSelectSuccessWithRowCount;
79
89
  exports.isSessionTable = isSessionTable;
80
90
  exports.isSessionTableActionMessage = isSessionTableActionMessage;
81
91
  exports.isTypeaheadRequest = isTypeaheadRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-message-utils.js","sources":["../../../../../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcEditCellRequest,\n VuuRpcRequest,\n VuuRpcEditAddRowRequest,\n VuuDataRowDto,\n VuuRpcEditDeleteRowRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n VuuLoginResponse,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { isView as componentInRegistry } from \"./component-registry\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n \"VP_EDIT_CELL_RPC\",\n \"VP_EDIT_ROW_RPC\",\n \"VP_EDIT_ADD_ROW_RPC\",\n \"VP_EDIT_DELETE_CELL_RPC\",\n \"VP_EDIT_DELETE_ROW_RPC\",\n \"VP_EDIT_SUBMIT_FORM_RPC\",\n];\n\nexport const isRpcServiceRequest = (message: {\n type: string;\n}): message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, \"context\"> =>\n message.type === \"RPC_REQUEST\";\n\nexport const hasViewPortContext = (\n message: VuuRpcServiceRequest,\n): message is VuuRpcServiceRequest<ViewportRpcContext> =>\n message.context.type === \"VIEWPORT_CONTEXT\";\n\nexport const isVuuMenuRpcRequest = (\n message: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): message is VuuRpcMenuRequest => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isLoginResponse = (message: object): message is VuuLoginResponse =>\n \"type\" in message &&\n (message.type === \"LOGIN_SUCCESS\" || message.type === \"LOGIN_FAIL\");\n\nexport const isRequestResponse = (\n message: object,\n): message is VuuUiMessageInRequestResponse => \"requestId\" in message;\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse,\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction,\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n\nexport const isTypeaheadRequest = (\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuViewportRpcTypeaheadRequest, \"vpId\"> => {\n return (\n isRpcServiceRequest(request) &&\n (request.rpcName === \"getUniqueFieldValues\" ||\n request.rpcName === \"getUniqueFieldValuesStartingWith\")\n );\n};\n\nexport function isEditCellRequest(\n request: VuuRpcRequest,\n): request is VuuRpcEditCellRequest;\nexport function isEditCellRequest(\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuRpcEditCellRequest, \"vpId\">;\nexport function isEditCellRequest(\n request: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): request is VuuRpcEditCellRequest | Omit<VuuRpcEditCellRequest, \"vpId\"> {\n return request.type === \"VP_EDIT_CELL_RPC\";\n}\n\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n vpId: string,\n): VuuRpcEditCellRequest;\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n): Omit<VuuRpcEditCellRequest, \"vpId\">;\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n vpId?: string,\n): VuuRpcEditCellRequest | Omit<VuuRpcEditCellRequest, \"vpId\"> {\n return {\n rowKey,\n field,\n value,\n type: \"VP_EDIT_CELL_RPC\",\n vpId,\n };\n}\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n vpId: string,\n): VuuRpcEditAddRowRequest;\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n): Omit<VuuRpcEditAddRowRequest, \"vpId\">;\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n vpId?: string,\n): VuuRpcEditAddRowRequest | Omit<VuuRpcEditAddRowRequest, \"vpId\"> {\n return {\n rowKey,\n data,\n type: \"VP_EDIT_ADD_ROW_RPC\",\n vpId,\n };\n}\n\nexport function vuuDeleteRowRequest(\n rowKey: string,\n vpId: string,\n): VuuRpcEditDeleteRowRequest;\nexport function vuuDeleteRowRequest(\n rowKey: string,\n): Omit<VuuRpcEditDeleteRowRequest, \"vpId\">;\nexport function vuuDeleteRowRequest(\n rowKey: string,\n vpId?: string,\n): VuuRpcEditDeleteRowRequest | Omit<VuuRpcEditDeleteRowRequest, \"vpId\"> {\n return {\n rowKey,\n type: \"VP_EDIT_DELETE_ROW_RPC\",\n vpId,\n };\n}\n\nexport const isSessionTable = (table?: unknown) => {\n if (\n table !== null &&\n typeof table === \"object\" &&\n \"table\" in table &&\n \"module\" in table\n ) {\n return (table as VuuTable).table.startsWith(\"session\");\n }\n return false;\n};\n\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess;\nexport function isActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<VuuRpcMenuSuccess, \"vpId\">;\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n) {\n return rpcResponse.type === \"VIEW_PORT_MENU_RESP\";\n}\n\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<\n VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n >,\n \"vpId\"\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n rpcResponse.action?.renderComponent === \"inline-form\"\n );\n}\n\nexport function isCustomComponentActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenComponentInDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n typeof rpcResponse.action.renderComponent === \"string\" &&\n componentInRegistry(rpcResponse.action.renderComponent)\n );\n}\n"],"names":["componentInRegistry"],"mappings":";;;;AA4BA,MAAM,cAAiB,GAAA;AAAA,EACrB,4BAAA;AAAA,EACA,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA,yBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,wBAAA;AAAA,EACA;AACF,CAAA;AAEO,MAAM,mBAAsB,GAAA,CAAC,OAGlC,KAAA,OAAA,CAAQ,IAAS,KAAA;AAEZ,MAAM,kBAAqB,GAAA,CAChC,OAEA,KAAA,OAAA,CAAQ,QAAQ,IAAS,KAAA;AAEpB,MAAM,sBAAsB,CACjC,OAAA,KACiC,eAAe,QAAS,CAAA,OAAA,CAAQ,MAAM,CAAC;AAE7D,MAAA,eAAA,GAAkB,CAAC,OAC9B,KAAA,MAAA,IAAU,YACT,OAAQ,CAAA,IAAA,KAAS,eAAmB,IAAA,OAAA,CAAQ,IAAS,KAAA,YAAA;A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A,CAAW,SAAS,CAAA;AAAA;AAEvD,EAAO,OAAA,KAAA;AACT;AAQO,SAAS,gBACd,WACA,EAAA;AACA,EAAA,OAAO,YAAY,IAAS,KAAA,qBAAA;AAC9B;AAmBO,SAAS,4BACd,WAKA,EAAA;AACA,EAAA,OACE,eAAgB,CAAA,WAAW,CAC3B,IAAA,kBAAA,CAAmB,YAAY,MAAM,CAAA,IACrC,cAAe,CAAA,WAAA,CAAY,MAAO,CAAA,KAAK,CACvC,IAAA,WAAA,CAAY,QAAQ,eAAoB,KAAA,aAAA;AAE5C;AAEO,SAAS,+BACd,WAKA,EAAA;AACA,EACE,OAAA,eAAA,CAAgB,WAAW,CAC3B,IAAA,kBAAA,CAAmB,YAAY,MAAM,CAAA,IACrC,eAAe,WAAY,CAAA,MAAA,CAAO,KAAK,CACvC,IAAA,OAAO,YAAY,MAAO,CAAA,eAAA,KAAoB,YAC9CA,wBAAoB,CAAA,WAAA,CAAY,OAAO,eAAe,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"protocol-message-utils.js","sources":["../../../../../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcEditCellRequest,\n VuuRpcRequest,\n VuuRpcEditAddRowRequest,\n VuuDataRowDto,\n VuuRpcEditDeleteRowRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n VuuLoginResponse,\n VuuRowDataItemType,\n SelectRequest,\n SelectResponse,\n SelectSuccessWithRowCount,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { isView as componentInRegistry } from \"./component-registry\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n \"VP_EDIT_CELL_RPC\",\n \"VP_EDIT_ROW_RPC\",\n \"VP_EDIT_ADD_ROW_RPC\",\n \"VP_EDIT_DELETE_CELL_RPC\",\n \"VP_EDIT_DELETE_ROW_RPC\",\n \"VP_EDIT_SUBMIT_FORM_RPC\",\n];\n\nexport const isSelectRequest = (message: object): message is SelectRequest =>\n \"type\" in message &&\n (message.type === \"SELECT_ROW\" ||\n message.type === \"DESELECT_ROW\" ||\n message.type === \"SELECT_ROW_RANGE\" ||\n message.type === \"SELECT_ALL\" ||\n message.type === \"DESELECT_ALL\");\n\nexport const isSelectSuccessWithRowCount = (\n response: SelectResponse | SelectSuccessWithRowCount,\n): response is SelectSuccessWithRowCount =>\n [\n \"SELECT_ROW_SUCCESS\",\n \"DESELECT_ROW_SUCCESS\",\n \"SELECT_ROW_RANGE_SUCCESS\",\n \"SELECT_ALL_SUCCESS\",\n \"DESELECT_ALL_SUCCESS\",\n ].includes(response.type ?? \"\") &&\n typeof (response as SelectSuccessWithRowCount).selectedRowCount === \"number\";\n\nexport const isRpcServiceRequest = (message: {\n type: string;\n}): message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, \"context\"> =>\n message.type === \"RPC_REQUEST\";\n\nexport const hasViewPortContext = (\n message: VuuRpcServiceRequest,\n): message is VuuRpcServiceRequest<ViewportRpcContext> =>\n message.context.type === \"VIEWPORT_CONTEXT\";\n\nexport const isVuuMenuRpcRequest = (\n message: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): message is VuuRpcMenuRequest => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isLoginResponse = (message: object): message is VuuLoginResponse =>\n \"type\" in message &&\n (message.type === \"LOGIN_SUCCESS\" || message.type === \"LOGIN_FAIL\");\n\nexport const isRequestResponse = (\n message: object,\n): message is VuuUiMessageInRequestResponse => \"requestId\" in message;\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse,\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction,\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n\nexport const isTypeaheadRequest = (\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuViewportRpcTypeaheadRequest, \"vpId\"> => {\n return (\n isRpcServiceRequest(request) &&\n (request.rpcName === \"getUniqueFieldValues\" ||\n request.rpcName === \"getUniqueFieldValuesStartingWith\")\n );\n};\n\nexport function isEditCellRequest(\n request: VuuRpcRequest,\n): request is VuuRpcEditCellRequest;\nexport function isEditCellRequest(\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuRpcEditCellRequest, \"vpId\">;\nexport function isEditCellRequest(\n request: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): request is VuuRpcEditCellRequest | Omit<VuuRpcEditCellRequest, \"vpId\"> {\n return request.type === \"VP_EDIT_CELL_RPC\";\n}\n\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n vpId: string,\n): VuuRpcEditCellRequest;\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n): Omit<VuuRpcEditCellRequest, \"vpId\">;\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n vpId?: string,\n): VuuRpcEditCellRequest | Omit<VuuRpcEditCellRequest, \"vpId\"> {\n return {\n rowKey,\n field,\n value,\n type: \"VP_EDIT_CELL_RPC\",\n vpId,\n };\n}\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n vpId: string,\n): VuuRpcEditAddRowRequest;\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n): Omit<VuuRpcEditAddRowRequest, \"vpId\">;\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n vpId?: string,\n): VuuRpcEditAddRowRequest | Omit<VuuRpcEditAddRowRequest, \"vpId\"> {\n return {\n rowKey,\n data,\n type: \"VP_EDIT_ADD_ROW_RPC\",\n vpId,\n };\n}\n\nexport function vuuDeleteRowRequest(\n rowKey: string,\n vpId: string,\n): VuuRpcEditDeleteRowRequest;\nexport function vuuDeleteRowRequest(\n rowKey: string,\n): Omit<VuuRpcEditDeleteRowRequest, \"vpId\">;\nexport function vuuDeleteRowRequest(\n rowKey: string,\n vpId?: string,\n): VuuRpcEditDeleteRowRequest | Omit<VuuRpcEditDeleteRowRequest, \"vpId\"> {\n return {\n rowKey,\n type: \"VP_EDIT_DELETE_ROW_RPC\",\n vpId,\n };\n}\n\nexport const isSessionTable = (table?: unknown) => {\n if (\n table !== null &&\n typeof table === \"object\" &&\n \"table\" in table &&\n \"module\" in table\n ) {\n return (table as VuuTable).table.startsWith(\"session\");\n }\n return false;\n};\n\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess;\nexport function isActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<VuuRpcMenuSuccess, \"vpId\">;\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n) {\n return rpcResponse.type === \"VIEW_PORT_MENU_RESP\";\n}\n\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<\n VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n >,\n \"vpId\"\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n rpcResponse.action?.renderComponent === \"inline-form\"\n );\n}\n\nexport function isCustomComponentActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenComponentInDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n typeof rpcResponse.action.renderComponent === \"string\" &&\n componentInRegistry(rpcResponse.action.renderComponent)\n );\n}\n"],"names":["componentInRegistry"],"mappings":";;;;AA+BA,MAAM,cAAiB,GAAA;AAAA,EACrB,4BAAA;AAAA,EACA,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA,yBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,wBAAA;AAAA,EACA;AACF,CAAA;AAEO,MAAM,kBAAkB,CAAC,OAAA,KAC9B,UAAU,OACT,KAAA,OAAA,CAAQ,SAAS,YAChB,IAAA,OAAA,CAAQ,IAAS,KAAA,cAAA,IACjB,QAAQ,IAAS,KAAA,kBAAA,IACjB,QAAQ,IAAS,KAAA,YAAA,IACjB,QAAQ,IAAS,KAAA,cAAA;AAER,MAAA,2BAAA,GAA8B,CACzC,QAEA,KAAA;AAAA,EACE,oBAAA;AAAA,EACA,sBAAA;AAAA,EACA,0BAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF,CAAA,CAAE,SAAS,QAAS,CAAA,I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E,EAAO,OAAA;AAAA,IACL,MAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAM,EAAA,qBAAA;AAAA,IACN;AAAA,GACF;AACF;AASgB,SAAA,mBAAA,CACd,QACA,IACuE,EAAA;AACvE,EAAO,OAAA;AAAA,IACL,MAAA;AAAA,IACA,IAAM,EAAA,wBAAA;AAAA,IACN;AAAA,GACF;AACF;AAEa,MAAA,cAAA,GAAiB,CAAC,KAAoB,KAAA;AACjD,EACE,IAAA,KAAA,KAAU,QACV,OAAO,KAAA,KAAU,YACjB,OAAW,IAAA,KAAA,IACX,YAAY,KACZ,EAAA;AACA,IAAQ,OAAA,KAAA,CAAmB,KAAM,CAAA,UAAA,CAAW,SAAS,CAAA;AAAA;AAEvD,EAAO,OAAA,KAAA;AACT;AAQO,SAAS,gBACd,WACA,EAAA;AACA,EAAA,OAAO,YAAY,IAAS,KAAA,qBAAA;AAC9B;AAmBO,SAAS,4BACd,WAKA,EAAA;AACA,EAAA,OACE,eAAgB,CAAA,WAAW,CAC3B,IAAA,kBAAA,CAAmB,YAAY,MAAM,CAAA,IACrC,cAAe,CAAA,WAAA,CAAY,MAAO,CAAA,KAAK,CACvC,IAAA,WAAA,CAAY,QAAQ,eAAoB,KAAA,aAAA;AAE5C;AAEO,SAAS,+BACd,WAKA,EAAA;AACA,EACE,OAAA,eAAA,CAAgB,WAAW,CAC3B,IAAA,kBAAA,CAAmB,YAAY,MAAM,CAAA,IACrC,eAAe,WAAY,CAAA,MAAA,CAAO,KAAK,CACvC,IAAA,OAAO,YAAY,MAAO,CAAA,eAAA,KAAoB,YAC9CA,wBAAoB,CAAA,WAAA,CAAY,OAAO,eAAe,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,9 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var columnUtils = require('./column-utils.js');
4
- var selectionUtils = require('./selection-utils.js');
5
4
 
6
- const { IS_LEAF, KEY, IDX } = columnUtils.metadataKeys;
5
+ const { IS_LEAF, KEY, IDX, SELECTED } = columnUtils.metadataKeys;
7
6
  const actualRowPositioning = (rowHeight) => [
8
7
  (row) => row[IDX] * rowHeight,
9
8
  (position) => Math.floor(position / rowHeight),
@@ -29,7 +28,7 @@ const asDataSourceRowObject = (row, columnMap) => {
29
28
  key,
30
29
  index,
31
30
  isGroupRow: !isLeaf,
32
- isSelected: selectionUtils.isRowSelected(row),
31
+ isSelected: row[SELECTED] !== 0,
33
32
  data: {}
34
33
  };
35
34
  for (const [colName, colIdx] of Object.entries(columnMap)) {
@@ -37,8 +36,7 @@ const asDataSourceRowObject = (row, columnMap) => {
37
36
  }
38
37
  return rowObject;
39
38
  };
40
- const NO_SELECTION = [];
41
- const vuuRowToDataSourceRow = ({ rowIndex, rowKey, sel: isSelected, ts, data }, keys, selectedRows = NO_SELECTION) => {
39
+ const vuuRowToDataSourceRow = ({ rowIndex, rowKey, sel: isSelected = 0, ts, data }, keys) => {
42
40
  return [
43
41
  rowIndex,
44
42
  keys.keyFor(rowIndex),
@@ -47,7 +45,7 @@ const vuuRowToDataSourceRow = ({ rowIndex, rowKey, sel: isSelected, ts, data },
47
45
  0,
48
46
  0,
49
47
  rowKey,
50
- isSelected ? selectionUtils.getSelectionStatus(selectedRows, rowIndex) : 0,
48
+ isSelected,
51
49
  ts,
52
50
  false
53
51
  // IsNew
@@ -1 +1 @@
1
- {"version":3,"file":"row-utils.js","sources":["../../../../../../packages/vuu-utils/src/row-utils.ts"],"sourcesContent":["//TODO this all probably belongs in vuu-table\nimport type {\n DataSourceRow,\n DataSourceRowObject,\n Selection,\n} from \"@vuu-ui/vuu-data-types\";\nimport type { MutableRefObject } from \"react\";\nimport { ColumnMap, metadataKeys } from \"./column-utils\";\nimport { getSelectionStatus, isRowSelected } from \"./selection-utils\";\nimport { IKeySet } from \"./keyset\";\nimport { VuuRow } from \"@vuu-ui/vuu-protocol-types\";\n\nconst { IS_LEAF, KEY, IDX } = metadataKeys;\n\nexport type RowOffsetFunc = (\n row: DataSourceRow,\n pctScrollTop?: number,\n) => number;\nexport type RowAtPositionFunc = (position: number) => number;\n\n/**\n * RowOffset function, RowAtPosition function, isVirtualScroll\n */\nexport type RowPositioning = [RowOffsetFunc, RowAtPositionFunc, boolean];\n\nexport const actualRowPositioning = (rowHeight: number): RowPositioning => [\n (row) => row[IDX] * rowHeight,\n (position) => Math.floor(position / rowHeight),\n false,\n];\n\n/**\n * return functions for determining a) the pixel offset to apply to a row, given the\n * row index and b) the index of the row at a given scroll offset. This implementation\n * is used when we are forced to 'virtualise' scrolling - because the number of rows\n * is high enough that we cannot create a large enough HTML content container.\n *\n * @param rowHeight\n * @param virtualisedExtent\n * @param pctScrollTop\n * @returns\n */\nexport const virtualRowPositioning = (\n rowHeight: number,\n virtualisedExtent: number,\n pctScrollTop: MutableRefObject<number>,\n): RowPositioning => [\n (row, offset = 0) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return (row[IDX] - offset) * rowHeight - rowOffset;\n },\n /*\n Return index position of closest row \n */\n (position) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return Math.round((position + rowOffset) / rowHeight);\n },\n true,\n];\n\nexport type RowToObjectMapper = (\n row: DataSourceRow,\n columnMap: ColumnMap,\n) => DataSourceRowObject;\n\nexport const asDataSourceRowObject: RowToObjectMapper = (\n row,\n columnMap,\n): DataSourceRowObject => {\n const { [IS_LEAF]: isLeaf, [KEY]: key, [IDX]: index } = row;\n\n const rowObject: DataSourceRowObject = {\n key,\n index,\n isGroupRow: !isLeaf,\n isSelected: isRowSelected(row),\n data: {},\n };\n\n for (const [colName, colIdx] of Object.entries(columnMap)) {\n rowObject.data[colName] = row[colIdx];\n }\n\n return rowObject;\n};\n\nconst NO_SELECTION: Selection = [];\nexport const vuuRowToDataSourceRow = (\n { rowIndex, rowKey, sel: isSelected, ts, data }: VuuRow,\n keys: IKeySet,\n selectedRows: Selection = NO_SELECTION,\n) => {\n return [\n rowIndex,\n keys.keyFor(rowIndex),\n true,\n false,\n 0,\n 0,\n rowKey,\n isSelected ? getSelectionStatus(selectedRows, rowIndex) : 0,\n ts,\n false, // IsNew\n ].concat(data) as DataSourceRow;\n};\n"],"names":["metadataKeys","isRowSelected","getSelectionStatus"],"mappings":";;;;;AAYA,MAAM,EAAE,OAAA,EAAS,GAAK,EAAA,GAAA,EAAQ,GAAAA,wBAAA;AAajB,MAAA,oBAAA,GAAuB,CAAC,SAAsC,KAAA;AAAA,EACzE,CAAC,GAAA,KAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,SAAA;AAAA,EACpB,CAAC,QAAA,KAAa,IAAK,CAAA,KAAA,CAAM,WAAW,SAAS,CAAA;AAAA,EAC7C;AACF;AAaO,MAAM,qBAAwB,GAAA,CACnC,SACA,EAAA,iBAAA,EACA,YACmB,KAAA;AAAA,EACnB,CAAC,GAAK,EAAA,MAAA,GAAS,CAAM,KAAA;AACnB,IAAM,MAAA,SAAA,GAAY,aAAa,OAAU,GAAA,iBAAA;AACzC,IAAA,OAAA,CAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,MAAA,IAAU,SAAY,GAAA,SAAA;AAAA,GAC3C;AAAA;AAAA;AAAA;AAAA,EAIA,CAAC,QAAa,KAAA;AACZ,IAAM,MAAA,SAAA,GAAY,aAAa,OAAU,GAAA,iBAAA;AACzC,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA,CAAO,QAAW,GAAA,SAAA,IAAa,SAAS,CAAA;AAAA,GACtD;AAAA,EACA;AACF;AAOa,MAAA,qBAAA,GAA2C,CACtD,GAAA,EACA,SACwB,KAAA;AACxB,EAAA,MAAM,EAAE,CAAC,OAAO,GAAG,MAAQ,EAAA,CAAC,GAAG,GAAG,GAAK,EAAA,CAAC,GAAG,GAAG,OAAU,GAAA,GAAA;AAExD,EAAA,MAAM,SAAiC,GAAA;AAAA,IACrC,GAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAY,CAAC,MAAA;AAAA,IACb,UAAA,EAAYC,6BAAc,GAAG,CAAA;AAAA,IAC7B,MAAM;AAAC,GACT;AAEA,EAAA,KAAA,MAAW,CAAC,OAAS,EAAA,MAAM,KAAK,MAAO,CAAA,OAAA,CAAQ,SAAS,CAAG,EAAA;AACzD,IAAA,SAAA,CAAU,IAAK,CAAA,OAAO,CAAI,GAAA,GAAA,CAAI,MAAM,CAAA;AAAA;AAGtC,EAAO,OAAA,SAAA;AACT;AAEA,MAAM,eAA0B,EAAC;AAC1B,MAAM,qBAAwB,GAAA,CACnC,EAAE,QAAA,EAAU,MAAQ,EAAA,GAAA,EAAK,UAAY,EAAA,EAAA,EAAI,IAAK,EAAA,EAC9C,IACA,EAAA,YAAA,GAA0B,YACvB,KAAA;AACH,EAAO,OAAA;AAAA,IACL,QAAA;AAAA,IACA,IAAA,CAAK,OAAO,QAAQ,CAAA;AAAA,IACpB,IAAA;AAAA,IACA,KAAA;AAAA,IACA,CAAA;AAAA,IACA,CAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAa,GAAAC,iCAAA,CAAmB,YAAc,EAAA,QAAQ,CAAI,GAAA,CAAA;AAAA,IAC1D,EAAA;AAAA,IACA;AAAA;AAAA,GACF,CAAE,OAAO,IAAI,CAAA;AACf;;;;;;;"}
1
+ {"version":3,"file":"row-utils.js","sources":["../../../../../../packages/vuu-utils/src/row-utils.ts"],"sourcesContent":["//TODO this all probably belongs in vuu-table\nimport type {\n DataSourceRow,\n DataSourceRowObject,\n} from \"@vuu-ui/vuu-data-types\";\nimport { ColumnMap, metadataKeys } from \"./column-utils\";\nimport { IKeySet } from \"./keyset\";\nimport { VuuRow } from \"@vuu-ui/vuu-protocol-types\";\nimport { RefObject } from \"react\";\n\nconst { IS_LEAF, KEY, IDX, SELECTED } = metadataKeys;\n\nexport type RowOffsetFunc = (\n row: DataSourceRow,\n pctScrollTop?: number,\n) => number;\nexport type RowAtPositionFunc = (position: number) => number;\n\n/**\n * RowOffset function, RowAtPosition function, isVirtualScroll\n */\nexport type RowPositioning = [RowOffsetFunc, RowAtPositionFunc, boolean];\n\nexport const actualRowPositioning = (rowHeight: number): RowPositioning => [\n (row) => row[IDX] * rowHeight,\n (position) => Math.floor(position / rowHeight),\n false,\n];\n\n/**\n * return functions for determining a) the pixel offset to apply to a row, given the\n * row index and b) the index of the row at a given scroll offset. This implementation\n * is used when we are forced to 'virtualise' scrolling - because the number of rows\n * is high enough that we cannot create a large enough HTML content container.\n *\n * @param rowHeight\n * @param virtualisedExtent\n * @param pctScrollTop\n * @returns\n */\nexport const virtualRowPositioning = (\n rowHeight: number,\n virtualisedExtent: number,\n pctScrollTop: RefObject<number>,\n): RowPositioning => [\n (row, offset = 0) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return (row[IDX] - offset) * rowHeight - rowOffset;\n },\n /*\n Return index position of closest row \n */\n (position) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return Math.round((position + rowOffset) / rowHeight);\n },\n true,\n];\n\nexport type RowToObjectMapper = (\n row: DataSourceRow,\n columnMap: ColumnMap,\n) => DataSourceRowObject;\n\nexport const asDataSourceRowObject: RowToObjectMapper = (\n row,\n columnMap,\n): DataSourceRowObject => {\n const { [IS_LEAF]: isLeaf, [KEY]: key, [IDX]: index } = row;\n\n const rowObject: DataSourceRowObject = {\n key,\n index,\n isGroupRow: !isLeaf,\n isSelected: row[SELECTED] !== 0,\n data: {},\n };\n\n for (const [colName, colIdx] of Object.entries(columnMap)) {\n rowObject.data[colName] = row[colIdx];\n }\n\n return rowObject;\n};\n\nexport const vuuRowToDataSourceRow = (\n { rowIndex, rowKey, sel: isSelected = 0, ts, data }: VuuRow,\n keys: IKeySet,\n) => {\n return [\n rowIndex,\n keys.keyFor(rowIndex),\n true,\n false,\n 0,\n 0,\n rowKey,\n isSelected,\n ts,\n false, // IsNew\n ].concat(data) as DataSourceRow;\n};\n"],"names":["metadataKeys"],"mappings":";;;;AAUA,MAAM,EAAE,OAAA,EAAS,GAAK,EAAA,GAAA,EAAK,UAAa,GAAAA,wBAAA;AAa3B,MAAA,oBAAA,G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AAA,SAAA;AACT;AAEa,MAAA,qBAAA,GAAwB,CACnC,EAAE,QAAU,EAAA,MAAA,EAAQ,GAAK,EAAA,UAAA,GAAa,CAAG,EAAA,EAAA,EAAI,IAAK,EAAA,EAClD,IACG,KAAA;AACH,EAAO,OAAA;AAAA,IACL,QAAA;AAAA,IACA,IAAA,CAAK,OAAO,QAAQ,CAAA;AAAA,IACpB,IAAA;AAAA,IACA,KAAA;AAAA,IACA,CAAA;AAAA,IACA,CAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,EAAA;AAAA,IACA;AAAA;AAAA,GACF,CAAE,OAAO,IAAI,CAAA;AACf;;;;;;;"}
@@ -1,246 +1,33 @@
1
1
  'use strict';
2
2
 
3
- var columnUtils = require('./column-utils.js');
4
-
5
- const NO_SELECTION = [];
6
- const { SELECTED } = columnUtils.metadataKeys;
7
- const RowSelected = {
8
- False: 0,
9
- True: 1,
10
- First: 2,
11
- Last: 4
12
- };
13
- const isRowSelected = (row) => (row[SELECTED] & RowSelected.True) === RowSelected.True;
14
- const isRowSelectedLast = (row) => row !== void 0 && (row[SELECTED] & RowSelected.Last) === RowSelected.Last;
15
- const inAscendingOrder = (item1, item2) => {
16
- const n1 = typeof item1 === "number" ? item1 : item1[0];
17
- const n2 = typeof item2 === "number" ? item2 : item2[0];
18
- return n1 - n2;
19
- };
20
- const deselectItem = (selectionModel, selected, itemIndex, rangeSelect, keepExistingSelection = false) => {
3
+ const deselectItem = (selectionModel, rowKey, rangeSelect, preserveExistingSelection = false) => {
4
+ return {
5
+ preserveExistingSelection,
6
+ rowKey,
7
+ type: "DESELECT_ROW"
8
+ };
9
+ };
10
+ const selectItem = (selectionModel, rowKey, rangeSelect, preserveExistingSelection = false, activeRowKey) => {
21
11
  const singleSelect = selectionModel === "single";
22
- const multiSelect = selectionModel === "extended" || selectionModel === "checkbox";
23
- const actsLikeSingleSelect = singleSelect || multiSelect && !keepExistingSelection && !rangeSelect;
24
- if (actsLikeSingleSelect || !rangeSelect && !keepExistingSelection) {
25
- return NO_SELECTION;
26
- } else if (!rangeSelect && keepExistingSelection) {
27
- return removeSelectedItem(selected, itemIndex);
28
- }
29
- return NO_SELECTION;
30
- };
31
- const newSelectedFillsGapOrExtends = (selection, itemIndex) => {
32
- for (let i = 0; i < selection.length; i++) {
33
- const item = selection[i];
34
- if (typeof item === "number") {
35
- if (item === itemIndex - 1) {
36
- return true;
37
- } else if (item > itemIndex) {
38
- return false;
39
- }
40
- } else if (item[0] === itemIndex + 1 || item[1] === itemIndex - 1) {
41
- return true;
42
- } else if (item[0] > itemIndex) {
43
- return false;
44
- }
45
- }
46
- return false;
47
- };
48
- const fillGapOrExtendSelection = (selection, itemIndex) => {
49
- for (let i = 0; i < selection.length; i++) {
50
- const item = selection[i];
51
- if (typeof item === "number") {
52
- if (item === itemIndex - 1) {
53
- const nextSelectionItem = selection[i + 1];
54
- if (nextSelectionItem === itemIndex + 1) {
55
- const newRange = [item, nextSelectionItem];
56
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 2));
57
- } else {
58
- const newRange = [item, itemIndex];
59
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 1));
60
- }
61
- } else if (item > itemIndex) {
62
- break;
63
- }
64
- } else if (item[0] === itemIndex + 1) {
65
- const newRange = [itemIndex, item[1]];
66
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 1));
67
- } else if (item[1] === itemIndex - 1) {
68
- const nextItem = selection[i + 1];
69
- if (Array.isArray(nextItem) && nextItem[0] === itemIndex + 1) {
70
- const newRange = [item[0], nextItem[1]];
71
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 2));
72
- } else if (typeof nextItem === "number" && nextItem === itemIndex + 1) {
73
- const newRange = [item[0], nextItem];
74
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 2));
75
- } else {
76
- const newRange = [item[0], itemIndex];
77
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 1));
78
- }
79
- }
80
- }
81
- return selection;
82
- };
83
- const selectItem = (selectionModel, selected, itemIndex, rangeSelect, keepExistingSelection = false, activeItemIndex = -1) => {
84
- const singleSelect = selectionModel === "single";
85
- const multiSelect = selectionModel === "extended" || selectionModel === "checkbox";
86
- const actsLikeSingleSelect = singleSelect || multiSelect && !keepExistingSelection && !rangeSelect || rangeSelect && activeItemIndex === -1;
12
+ const actsLikeSingleSelect = singleSelect || activeRowKey === void 0;
87
13
  if (selectionModel === "none") {
88
- return NO_SELECTION;
14
+ return;
89
15
  } else if (actsLikeSingleSelect) {
90
- return [itemIndex];
16
+ return {
17
+ preserveExistingSelection,
18
+ rowKey,
19
+ type: "SELECT_ROW"
20
+ };
91
21
  } else if (rangeSelect) {
92
- if (selected.length === 0) {
93
- return [itemIndex];
94
- } else {
95
- const range = itemIndex > activeItemIndex ? [activeItemIndex, itemIndex] : [itemIndex, activeItemIndex];
96
- return insertRange(selected, range);
97
- }
98
- } else if (!rangeSelect) {
99
- if (newSelectedFillsGapOrExtends(selected, itemIndex)) {
100
- return fillGapOrExtendSelection(selected, itemIndex);
101
- } else {
102
- return selected?.concat(itemIndex).sort(inAscendingOrder);
103
- }
104
- } else ;
105
- return NO_SELECTION;
106
- };
107
- function removeSelectedItem(selected, itemIndex) {
108
- if (selected.includes(itemIndex)) {
109
- return selected.filter((selectedItem) => selectedItem !== itemIndex);
110
- } else {
111
- const newSelected = [];
112
- for (const selectedItem of selected) {
113
- if (Array.isArray(selectedItem)) {
114
- if (rangeIncludes(selectedItem, itemIndex)) {
115
- newSelected.push(...splitRange(selectedItem, itemIndex));
116
- } else {
117
- newSelected.push(selectedItem);
118
- }
119
- } else {
120
- newSelected.push(selectedItem);
121
- }
122
- }
123
- return newSelected;
124
- }
125
- }
126
- function insertRange(selected, range) {
127
- const [from, to] = range;
128
- return selected.reduce((newSelected, selectedItem) => {
129
- if (typeof selectedItem === "number") {
130
- if (selectedItem < from || selectedItem > to) {
131
- newSelected.push(selectedItem);
132
- } else if (!includedInRange(newSelected.at(-1), selectedItem)) {
133
- newSelected.push(range);
134
- }
135
- } else if (overlappingRange(selectedItem, range)) {
136
- newSelected.push(mergeRanges(selectedItem, range));
137
- } else {
138
- if (range[1] < selectedItem[0]) {
139
- newSelected.push(range);
140
- }
141
- newSelected.push(selectedItem);
142
- }
143
- return newSelected;
144
- }, []);
145
- }
146
- const overlappingRange = (r1, r2) => r1[1] >= r2[0] && r1[1] <= r2[1] || r1[0] >= r2[0] && r1[0] <= r2[1];
147
- const mergeRanges = (r1, r2) => [
148
- Math.min(r1[0], r2[0]),
149
- Math.max(r1[1], r2[1])
150
- ];
151
- const includedInRange = (selectedItem, index) => {
152
- if (typeof selectedItem === "undefined" || typeof selectedItem === "number") {
153
- return false;
154
- } else return rangeIncludes(selectedItem, index);
155
- };
156
- const rangeIncludes = (range, index) => index >= range[0] && index <= range[1];
157
- const SINGLE_SELECTED_ROW = RowSelected.True + RowSelected.First + RowSelected.Last;
158
- const FIRST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.First;
159
- const LAST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.Last;
160
- const getSelectionStatus = (selected, itemIndex) => {
161
- for (const item of selected) {
162
- if (typeof item === "number") {
163
- if (item === itemIndex) {
164
- return SINGLE_SELECTED_ROW;
165
- }
166
- } else if (rangeIncludes(item, itemIndex)) {
167
- if (itemIndex === item[0]) {
168
- return FIRST_SELECTED_ROW_OF_BLOCK;
169
- } else if (itemIndex === item[1]) {
170
- return LAST_SELECTED_ROW_OF_BLOCK;
171
- } else {
172
- return RowSelected.True;
173
- }
174
- }
175
- }
176
- return RowSelected.False;
177
- };
178
- const isSelected = (selected, itemIndex) => {
179
- for (const item of selected) {
180
- if (typeof item === "number") {
181
- if (item === itemIndex) {
182
- return true;
183
- } else if (item > itemIndex) {
184
- return false;
185
- }
186
- } else if (rangeIncludes(item, itemIndex)) {
187
- return true;
188
- } else if (item[0] > itemIndex) {
189
- return false;
190
- }
191
- }
192
- return false;
193
- };
194
- const expandSelection = (selected) => {
195
- if (selected.every((selectedItem) => typeof selectedItem === "number")) {
196
- return selected;
197
- }
198
- const expandedSelected = [];
199
- for (const selectedItem of selected) {
200
- if (typeof selectedItem === "number") {
201
- expandedSelected.push(selectedItem);
202
- } else {
203
- for (let i = selectedItem[0]; i <= selectedItem[1]; i++) {
204
- expandedSelected.push(i);
205
- }
206
- }
207
- }
208
- return expandedSelected;
209
- };
210
- function splitRange([from, to], itemIndex) {
211
- if (itemIndex === from) {
212
- return [[from + 1, to]];
213
- } else if (itemIndex === to) {
214
- return [[from, to - 1]];
215
- } else if (to - from === 2) {
216
- return [from, to];
217
- } else if (itemIndex === to - 1) {
218
- return [[from, to - 2], to];
219
- } else {
220
- return [
221
- [from, itemIndex - 1],
222
- [itemIndex + 1, to]
223
- ];
224
- }
225
- }
226
- const selectionCount = (selected = NO_SELECTION) => {
227
- let count = selected.length;
228
- for (const selectionItem of selected) {
229
- if (Array.isArray(selectionItem)) {
230
- const [from, to] = selectionItem;
231
- count += to - from;
232
- }
22
+ return {
23
+ preserveExistingSelection,
24
+ fromRowKey: rowKey,
25
+ toRowKey: activeRowKey,
26
+ type: "SELECT_ROW_RANGE"
27
+ };
233
28
  }
234
- return count;
235
29
  };
236
30
 
237
- exports.RowSelected = RowSelected;
238
31
  exports.deselectItem = deselectItem;
239
- exports.expandSelection = expandSelection;
240
- exports.getSelectionStatus = getSelectionStatus;
241
- exports.isRowSelected = isRowSelected;
242
- exports.isRowSelectedLast = isRowSelectedLast;
243
- exports.isSelected = isSelected;
244
32
  exports.selectItem = selectItem;
245
- exports.selectionCount = selectionCount;
246
33
  //# sourceMappingURL=selection-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"selection-utils.js","sources":["../../../../../../packages/vuu-utils/src/selection-utils.ts"],"sourcesContent":["import {\n DataSourceRow,\n RangeTuple,\n Selection,\n SelectionItem,\n} from \"@vuu-ui/vuu-data-types\";\nimport { TableSelectionModel } from \"@vuu-ui/vuu-table-types\";\nimport { metadataKeys } from \"./column-utils\";\n\nconst NO_SELECTION: number[] = [];\n\nconst { SELECTED } = metadataKeys;\n\nexport const RowSelected = {\n False: 0,\n True: 1,\n First: 2,\n Last: 4,\n};\n\nexport const isRowSelected = (row: DataSourceRow): boolean =>\n (row[SELECTED] & RowSelected.True) === RowSelected.True;\n\nexport const isRowSelectedLast = (row?: DataSourceRow): boolean =>\n row !== undefined && (row[SELECTED] & RowSelected.Last) === RowSelected.Last;\n\nconst inAscendingOrder = (item1: SelectionItem, item2: SelectionItem) => {\n const n1: number = typeof item1 === \"number\" ? item1 : item1[0];\n const n2: number = typeof item2 === \"number\" ? item2 : item2[0];\n return n1 - n2;\n};\n\nexport const deselectItem = (\n selectionModel: TableSelectionModel,\n selected: Selection,\n itemIndex: number,\n rangeSelect: boolean,\n keepExistingSelection = false,\n): Selection => {\n const singleSelect = selectionModel === \"single\";\n const multiSelect =\n selectionModel === \"extended\" || selectionModel === \"checkbox\";\n const actsLikeSingleSelect =\n singleSelect || (multiSelect && !keepExistingSelection && !rangeSelect);\n\n if (actsLikeSingleSelect || (!rangeSelect && !keepExistingSelection)) {\n return NO_SELECTION;\n } else if (!rangeSelect && keepExistingSelection) {\n return removeSelectedItem(selected, itemIndex);\n }\n return NO_SELECTION;\n};\n\nconst newSelectedFillsGapOrExtends = (\n selection: Selection,\n itemIndex: number,\n): boolean => {\n for (let i = 0; i < selection.length; i++) {\n const item = selection[i];\n if (typeof item === \"number\") {\n if (item === itemIndex - 1) {\n return true;\n } else if (item > itemIndex) {\n return false;\n }\n } else if (item[0] === itemIndex + 1 || item[1] === itemIndex - 1) {\n return true;\n } else if (item[0] > itemIndex) {\n return false;\n }\n }\n return false;\n};\n\nconst fillGapOrExtendSelection = (\n selection: Selection,\n itemIndex: number,\n): Selection => {\n for (let i = 0; i < selection.length; i++) {\n const item = selection[i];\n if (typeof item === \"number\") {\n if (item === itemIndex - 1) {\n const nextSelectionItem = selection[i + 1];\n if (nextSelectionItem === itemIndex + 1) {\n const newRange: SelectionItem = [item, nextSelectionItem];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 2));\n } else {\n const newRange: SelectionItem = [item, itemIndex];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 1));\n }\n } else if (item > itemIndex) {\n break;\n }\n } else if (item[0] === itemIndex + 1) {\n const newRange: SelectionItem = [itemIndex, item[1]];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 1));\n } else if (item[1] === itemIndex - 1) {\n // check to see whether another contiguous range follows\n const nextItem = selection[i + 1];\n if (Array.isArray(nextItem) && nextItem[0] === itemIndex + 1) {\n const newRange: SelectionItem = [item[0], nextItem[1]];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 2));\n } else if (typeof nextItem === \"number\" && nextItem === itemIndex + 1) {\n const newRange: SelectionItem = [item[0], nextItem];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 2));\n } else {\n const newRange: SelectionItem = [item[0], itemIndex];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 1));\n }\n }\n }\n\n return selection;\n};\n\nexport const selectItem = (\n selectionModel: TableSelectionModel,\n selected: Selection,\n itemIndex: number,\n rangeSelect: boolean,\n keepExistingSelection = false,\n activeItemIndex = -1,\n): Selection => {\n const singleSelect = selectionModel === \"single\";\n const multiSelect =\n selectionModel === \"extended\" || selectionModel === \"checkbox\";\n const actsLikeSingleSelect =\n singleSelect ||\n (multiSelect && !keepExistingSelection && !rangeSelect) ||\n (rangeSelect && activeItemIndex === -1);\n\n if (selectionModel === \"none\") {\n return NO_SELECTION;\n } else if (actsLikeSingleSelect) {\n return [itemIndex];\n } else if (rangeSelect) {\n if (selected.length === 0) {\n return [itemIndex];\n } else {\n const range: RangeTuple =\n itemIndex > activeItemIndex\n ? [activeItemIndex, itemIndex]\n : [itemIndex, activeItemIndex];\n return insertRange(selected, range);\n }\n } else if (!rangeSelect) {\n // what if we now have a range because we just filled agap between 2\n if (newSelectedFillsGapOrExtends(selected, itemIndex)) {\n return fillGapOrExtendSelection(selected, itemIndex);\n } else {\n return selected?.concat(itemIndex).sort(inAscendingOrder);\n }\n } else if (multiSelect) {\n // const [from, to] = idx > active ? [active, idx] : [idx, active];\n // newSelected = selected?.slice();\n // for (let i = from; i <= to; i++) {\n // if (!selected?.includes(i)) {\n // newSelected.push(i);\n // }\n // }\n }\n return NO_SELECTION;\n};\n\nfunction removeSelectedItem(selected: Selection, itemIndex: number) {\n if (selected.includes(itemIndex)) {\n return selected.filter((selectedItem) => selectedItem !== itemIndex);\n } else {\n const newSelected: Selection = [];\n for (const selectedItem of selected) {\n if (Array.isArray(selectedItem)) {\n if (rangeIncludes(selectedItem, itemIndex)) {\n newSelected.push(...splitRange(selectedItem, itemIndex));\n } else {\n newSelected.push(selectedItem);\n }\n } else {\n newSelected.push(selectedItem);\n }\n }\n return newSelected;\n }\n}\n\nfunction insertRange(selected: Selection, range: RangeTuple): Selection {\n const [from, to] = range;\n return selected.reduce<Selection>((newSelected, selectedItem) => {\n if (typeof selectedItem === \"number\") {\n if (selectedItem < from || selectedItem > to) {\n newSelected.push(selectedItem);\n } else if (!includedInRange(newSelected.at(-1), selectedItem)) {\n newSelected.push(range);\n }\n } else if (overlappingRange(selectedItem, range)) {\n newSelected.push(mergeRanges(selectedItem, range));\n } else {\n if (range[1] < selectedItem[0]) {\n newSelected.push(range);\n }\n newSelected.push(selectedItem);\n }\n\n return newSelected;\n }, []);\n}\n\nconst overlappingRange = (r1: RangeTuple, r2: RangeTuple) =>\n (r1[1] >= r2[0] && r1[1] <= r2[1]) || (r1[0] >= r2[0] && r1[0] <= r2[1]);\nconst mergeRanges = (r1: RangeTuple, r2: RangeTuple): RangeTuple => [\n Math.min(r1[0], r2[0]),\n Math.max(r1[1], r2[1]),\n];\n\nconst includedInRange = (\n selectedItem: SelectionItem | undefined,\n index: number,\n) => {\n if (typeof selectedItem === \"undefined\" || typeof selectedItem === \"number\") {\n return false;\n } else return rangeIncludes(selectedItem, index);\n};\n\nconst rangeIncludes = (range: RangeTuple, index: number) =>\n index >= range[0] && index <= range[1];\n\nconst SINGLE_SELECTED_ROW =\n RowSelected.True + RowSelected.First + RowSelected.Last;\nconst FIRST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.First;\nconst LAST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.Last;\n\n/**\n * Determine the value for selected. We use a bitmap to represent a number of selection states\n * a row might exhibit. selected/not-selected is the fundamental value. We also identify first\n * row of a selected block, last row of a selected block;\n */\nexport const getSelectionStatus = (\n selected: Selection,\n itemIndex: number,\n): number => {\n for (const item of selected) {\n if (typeof item === \"number\") {\n if (item === itemIndex) {\n return SINGLE_SELECTED_ROW;\n }\n } else if (rangeIncludes(item, itemIndex)) {\n if (itemIndex === item[0]) {\n return FIRST_SELECTED_ROW_OF_BLOCK;\n } else if (itemIndex === item[1]) {\n return LAST_SELECTED_ROW_OF_BLOCK;\n } else {\n return RowSelected.True;\n }\n }\n }\n return RowSelected.False;\n};\n\nexport const isSelected = (selected: Selection, itemIndex: number) => {\n for (const item of selected) {\n if (typeof item === \"number\") {\n if (item === itemIndex) {\n return true;\n } else if (item > itemIndex) {\n return false;\n }\n } else if (rangeIncludes(item, itemIndex)) {\n return true;\n } else if (item[0] > itemIndex) {\n return false;\n }\n }\n\n return false;\n};\n/**\n * Vuu server expects a full list if indexes of selected rows. Client represents selection in a more\n * efficient structure. This converts client structure to full server format.\n */\nexport const expandSelection = (selected: Selection): number[] => {\n if (selected.every((selectedItem) => typeof selectedItem === \"number\")) {\n return selected as number[];\n }\n const expandedSelected = [];\n for (const selectedItem of selected) {\n if (typeof selectedItem === \"number\") {\n expandedSelected.push(selectedItem);\n } else {\n for (let i = selectedItem[0]; i <= selectedItem[1]; i++) {\n expandedSelected.push(i);\n }\n }\n }\n return expandedSelected;\n};\n\nfunction splitRange([from, to]: RangeTuple, itemIndex: number): Selection {\n if (itemIndex === from) {\n return [[from + 1, to]];\n } else if (itemIndex === to) {\n return [[from, to - 1]];\n } else if (to - from === 2) {\n return [from, to];\n } else if (itemIndex === to - 1) {\n return [[from, to - 2], to];\n } else {\n return [\n [from, itemIndex - 1],\n [itemIndex + 1, to],\n ];\n }\n}\n\nexport type SelectionDiff = {\n added: SelectionItem[];\n removed: SelectionItem[];\n};\n\nexport const selectionCount = (selected: Selection = NO_SELECTION) => {\n let count = selected.length;\n for (const selectionItem of selected) {\n if (Array.isArray(selectionItem)) {\n const [from, to] = selectionItem;\n // we've already counted the entry as 1, add the rest of the range\n count += to - from;\n }\n }\n return count;\n};\n"],"names":["metadataKeys"],"mappings":";;;;AASA,MAAM,eAAyB,EAAC;AAEhC,MAAM,EAAE,UAAa,GAAAA,wBAAA;AAEd,MAAM,WAAc,GAAA;AAAA,EACzB,KAAO,EAAA,CAAA;AAAA,EACP,IAAM,EAAA,CAAA;AAAA,EACN,KAAO,EAAA,CAAA;AAAA,EACP,IAAM,EAAA;AACR;AAEa,MAAA,aAAA,GAAgB,CAAC,GAC3B,KAAA,CAAA,GAAA,CAAI,QAAQ,CAAI,GAAA,WAAA,CAAY,UAAU,WAAY,CAAA;AAExC,MAAA,iBAAA,GAAoB,CAAC,GAAA,KAChC,GAAQ,KAAA,KAAA,CAAA,IAAA,CAAc,IAAI,QAAQ,CAAA,GAAI,WAAY,CAAA,IAAA,MAAU,WAAY,CAAA;AAE1E,MAAM,gBAAA,GAAmB,CAAC,KAAA,EAAsB,KAAyB,KAAA;AACvE,EAAA,MAAM,KAAa,OAAO,KAAA,KAAU,QAAW,GAAA,KAAA,GAAQ,MAAM,CAAC,CAAA;AAC9D,EAAA,MAAM,KAAa,OAAO,KAAA,KAAU,QAAW,GAAA,KAAA,GAAQ,MAAM,CAAC,CAAA;AAC9D,EAAA,OAAO,EAAK,GAAA,EAAA;AACd,CAAA;AAEO,MAAM,eAAe,CAC1B,cAAA,EACA,UACA,SACA,E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AA,IAAS,EAAK,GAAA,IAAA;AAAA;AAChB;AAEF,EAAO,OAAA,KAAA;AACT;;;;;;;;;;;;"}
1
+ {"version":3,"file":"selection-utils.js","sources":["../../../../../../packages/vuu-utils/src/selection-utils.ts"],"sourcesContent":["import { TableSelectionModel } from \"@vuu-ui/vuu-table-types\";\nimport { SelectRequest } from \"@vuu-ui/vuu-protocol-types\";\n\nexport const deselectItem = (\n selectionModel: TableSelectionModel,\n rowKey: string,\n rangeSelect: boolean,\n preserveExistingSelection = false,\n): Omit<SelectRequest, \"vpId\"> | undefined => {\n return {\n preserveExistingSelection,\n rowKey,\n type: \"DESELECT_ROW\",\n } as Omit<SelectRequest, \"vpId\">;\n};\n\nexport const selectItem = (\n selectionModel: TableSelectionModel,\n rowKey: string,\n rangeSelect: boolean,\n preserveExistingSelection = false,\n activeRowKey?: string,\n): Omit<SelectRequest, \"vpId\"> | undefined => {\n const singleSelect = selectionModel === \"single\";\n const actsLikeSingleSelect = singleSelect || activeRowKey === undefined;\n\n if (selectionModel === \"none\") {\n return;\n } else if (actsLikeSingleSelect) {\n return {\n preserveExistingSelection,\n rowKey,\n type: \"SELECT_ROW\",\n } as Omit<SelectRequest, \"vpId\">;\n } else if (rangeSelect) {\n return {\n preserveExistingSelection,\n fromRowKey: rowKey,\n toRowKey: activeRowKey,\n type: \"SELECT_ROW_RANGE\",\n } as Omit<SelectRequest, \"vpId\">;\n }\n};\n"],"names":[],"mappings":";;AAGO,MAAM,eAAe,CAC1B,cAAA,EACA,MACA,EAAA,WAAA,EACA,4BAA4B,KACgB,KAAA;AAC5C,EAAO,OAAA;AAAA,IACL,yBAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAM,EAAA;AAAA,GACR;AACF;AAEO,MAAM,aAAa,CACxB,cAAA,EACA,QACA,WACA,EAAA,yBAAA,GAA4B,OAC5B,YAC4C,KAAA;AAC5C,EAAA,MAAM,eAAe,cAAmB,KAAA,QAAA;AACxC,EAAM,MAAA,oBAAA,GAAuB,gBAAgB,YAAiB,KAAA,KAAA,CAAA;AAE9D,EAAA,IAAI,mBAAmB,MAAQ,EAAA;AAC7B,IAAA;AAAA,aACS,oBAAsB,EAAA;AAC/B,IAAO,OAAA;AAAA,MACL,yBAAA;AAAA,MACA,MAAA;AAAA,MACA,IAAM,EAAA;AAAA,KACR;AAAA,aACS,WAAa,EAAA;AACtB,IAAO,OAAA;AAAA,MACL,yBAAA;AAAA,MACA,UAAY,EAAA,MAAA;AAAA,MACZ,QAAU,EAAA,YAAA;AAAA,MACV,IAAM,EAAA;AAAA,KACR;AAAA;AAEJ;;;;;"}
@@ -47,10 +47,10 @@ export { asReactElements, createSyntheticEvent, isSimpleStateValue, useIsMounted
47
47
  export { roundDecimal } from './round-decimal.js';
48
48
  export { debounce, throttle } from './perf-utils.js';
49
49
  export { DeferredPromise } from './promise-utils.js';
50
- export { hasViewPortContext, isActionMessage, isCustomComponentActionMessage, isEditCellRequest, isLoginResponse, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isRpcServiceRequest, isSessionTable, isSessionTableActionMessage, isTypeaheadRequest, isVuuMenuRpcRequest, vuuAddRowRequest, vuuDeleteRowRequest, vuuEditCellRequest } from './protocol-message-utils.js';
50
+ export { hasViewPortContext, isActionMessage, isCustomComponentActionMessage, isEditCellRequest, isLoginResponse, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isRpcServiceRequest, isSelectRequest, isSelectSuccessWithRowCount, isSessionTable, isSessionTableActionMessage, isTypeaheadRequest, isVuuMenuRpcRequest, vuuAddRowRequest, vuuDeleteRowRequest, vuuEditCellRequest } from './protocol-message-utils.js';
51
51
  export { NULL_RANGE, Range, WindowRange, getFullRange, rangeNewItems, withinRange } from './range-utils.js';
52
52
  export { actualRowPositioning, asDataSourceRowObject, virtualRowPositioning, vuuRowToDataSourceRow } from './row-utils.js';
53
- export { RowSelected, deselectItem, expandSelection, getSelectionStatus, isRowSelected, isRowSelectedLast, isSelected, selectItem, selectionCount } from './selection-utils.js';
53
+ export { deselectItem, selectItem } from './selection-utils.js';
54
54
  export { VuuShellLocation } from './shell-layout-types.js';
55
55
  export { addSortColumn, getSortStatus, setSortColumn, toggleOrApplySort } from './sort-utils.js';
56
56
  export { getVuuTable } from './table-schema-utils.js';
@@ -1,6 +1,5 @@
1
1
  import { metadataKeys } from './column-utils.js';
2
2
  import { WindowRange } from './range-utils.js';
3
- import { isRowSelectedLast } from './selection-utils.js';
4
3
 
5
4
  var __defProp = Object.defineProperty;
6
5
  var __typeError = (msg) => {
@@ -34,13 +33,6 @@ class MovingWindow {
34
33
  if (this.isWithinRange(index)) {
35
34
  const internalIndex = index - __privateGet(this, _range).from;
36
35
  this.data[internalIndex] = data;
37
- if (data[SELECTED]) {
38
- const previousRow = this.data[internalIndex - 1];
39
- if (isRowSelectedLast(previousRow)) {
40
- this.data[internalIndex - 1] = previousRow.slice();
41
- this.data[internalIndex - 1][SELECTED] -= 4;
42
- }
43
- }
44
36
  }
45
37
  }
46
38
  getAtIndex(index) {
@@ -1 +1 @@
1
- {"version":3,"file":"moving-window.js","sources":["../../../../../../packages/vuu-utils/src/moving-window.ts"],"sourcesContent":["import { DataSourceRow } from \"@vuu-ui/vuu-data-types\";\nimport { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { metadataKeys } from \"./column-utils\";\nimport { WindowRange } from \"./range-utils\";\nimport { isRowSelectedLast } from \"./selection-utils\";\n\nconst { SELECTED } = metadataKeys;\n\nexport class MovingWindow {\n public data: DataSourceRow[];\n public rowCount = 0;\n #range: WindowRange;\n\n constructor({ from, to }: VuuRange) {\n this.#range = new WindowRange(from, to);\n //internal data is always 0 based, we add range.from to determine an offset\n this.data = new Array(Math.max(0, to - from));\n this.rowCount = 0;\n }\n\n setRowCount = (rowCount: number) => {\n if (rowCount < this.data.length) {\n this.data.length = rowCount;\n }\n\n this.rowCount = rowCount;\n };\n\n add(data: DataSourceRow) {\n const [index] = data;\n if (this.isWithinRange(index)) {\n const internalIndex = index - this.#range.from;\n this.data[internalIndex] = data;\n\n // Hack until we can deal with this more elegantly. When we have a block\n // select operation, first row is selected (and updated via server), then\n // remaining rows are selected when we select the block-end row. We get an\n // update for all rows except first. Because we're extending the select status\n // on the client, we have to adjust the first row selected (its still selected\n // but is no longer the 'last selected row in block')\n // Maybe answer is to apply ALL the selection status code here, not in Viewport\n if (data[SELECTED]) {\n const previousRow = this.data[internalIndex - 1];\n if (isRowSelectedLast(previousRow)) {\n this.data[internalIndex - 1] = previousRow.slice() as DataSourceRow;\n this.data[internalIndex - 1][SELECTED] -= 4;\n }\n }\n }\n }\n\n getAtIndex(index: number) {\n return this.#range.isWithin(index) &&\n this.data[index - this.#range.from] != null\n ? this.data[index - this.#range.from]\n : undefined;\n }\n\n isWithinRange(index: number) {\n return this.#range.isWithin(index);\n }\n\n setRange({ from, to }: VuuRange) {\n if (from !== this.#range.from || to !== this.#range.to) {\n const [overlapFrom, overlapTo] = this.#range.overlap(from, to);\n const newData = new Array(Math.max(0, to - from));\n for (let i = overlapFrom; i < overlapTo; i++) {\n const data = this.getAtIndex(i);\n if (data) {\n const index = i - from;\n newData[index] = data;\n }\n }\n this.data = newData;\n this.#range.from = from;\n this.#range.to = to;\n }\n }\n\n getSelectedRows() {\n return this.data.filter((row) => row[SELECTED] !== 0);\n }\n\n get range() {\n return this.#range;\n }\n\n slice(): DataSourceRow[] {\n const data: DataSourceRow[] = [];\n const { from } = this.range;\n for (let i = 0; i < this.data.length; i++) {\n if (this.data[i]) {\n data.push(this.data[i]);\n } else {\n data.push([from + i, from + i, true, false, 1, 0, \"\", 0, 0, false]);\n }\n }\n return data;\n }\n\n // TODO make this more performant, see implementation in\n // array-backed-moving-window - use same implementation\n get hasAllRowsWithinRange(): boolean {\n const { from, to } = this.#range;\n\n for (let i = from; i < to; i++) {\n if (this.getAtIndex(i) === undefined) {\n return false;\n }\n }\n return true;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,IAAA,MAAA;AAMA,MAAM,E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AAA;AAE1B,IAAA,KAAA,IAAS,CAAI,GAAA,IAAA,EAAM,CAAI,GAAA,EAAA,EAAI,CAAK,EAAA,EAAA;AAC9B,MAAA,IAAI,IAAK,CAAA,UAAA,CAAW,CAAC,CAAA,KAAM,KAAW,CAAA,EAAA;AACpC,QAAO,OAAA,KAAA;AAAA;AACT;AAEF,IAAO,OAAA,IAAA;AAAA;AAEX;AArGE,MAAA,GAAA,IAAA,OAAA,EAAA;;;;"}
1
+ {"version":3,"file":"moving-window.js","sources":["../../../../../../packages/vuu-utils/src/moving-window.ts"],"sourcesContent":["import { DataSourceRow } from \"@vuu-ui/vuu-data-types\";\nimport { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { metadataKeys } from \"./column-utils\";\nimport { WindowRange } from \"./range-utils\";\n\nconst { SELECTED } = metadataKeys;\n\nexport class MovingWindow {\n public data: DataSourceRow[];\n public rowCount = 0;\n #range: WindowRange;\n\n constructor({ from, to }: VuuRange) {\n this.#range = new WindowRange(from, to);\n //internal data is always 0 based, we add range.from to determine an offset\n this.data = new Array(Math.max(0, to - from));\n this.rowCount = 0;\n }\n\n setRowCount = (rowCount: number) => {\n if (rowCount < this.data.length) {\n this.data.length = rowCount;\n }\n\n this.rowCount = rowCount;\n };\n\n add(data: DataSourceRow) {\n const [index] = data;\n if (this.isWithinRange(index)) {\n const internalIndex = index - this.#range.from;\n this.data[internalIndex] = data;\n }\n }\n\n getAtIndex(index: number) {\n return this.#range.isWithin(index) &&\n this.data[index - this.#range.from] != null\n ? this.data[index - this.#range.from]\n : undefined;\n }\n\n isWithinRange(index: number) {\n return this.#range.isWithin(index);\n }\n\n setRange({ from, to }: VuuRange) {\n if (from !== this.#range.from || to !== this.#range.to) {\n const [overlapFrom, overlapTo] = this.#range.overlap(from, to);\n const newData = new Array(Math.max(0, to - from));\n for (let i = overlapFrom; i < overlapTo; i++) {\n const data = this.getAtIndex(i);\n if (data) {\n const index = i - from;\n newData[index] = data;\n }\n }\n this.data = newData;\n this.#range.from = from;\n this.#range.to = to;\n }\n }\n\n getSelectedRows() {\n return this.data.filter((row) => row[SELECTED] !== 0);\n }\n\n get range() {\n return this.#range;\n }\n\n slice(): DataSourceRow[] {\n const data: DataSourceRow[] = [];\n const { from } = this.range;\n for (let i = 0; i < this.data.length; i++) {\n if (this.data[i]) {\n data.push(this.data[i]);\n } else {\n data.push([from + i, from + i, true, false, 1, 0, \"\", 0, 0, false]);\n }\n }\n return data;\n }\n\n // TODO make this more performant, see implementation in\n // array-backed-moving-window - use same implementation\n get hasAllRowsWithinRange(): boolean {\n const { from, to } = this.#range;\n\n for (let i = from; i < to; i++) {\n if (this.getAtIndex(i) === undefined) {\n return false;\n }\n }\n return true;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,IAAA,MAAA;AAKA,MAAM,EAAE,UAAa,GAAA,YAAA;AAEd,MAAM,YAAa,CAAA;AAAA,EAKxB,WAAY,CAAA,EAAE,IAAM,EAAA,EAAA,EAAgB,EAAA;AAJpC,IAAO,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AACP,IAAA,aAAA,CAAA,IAAA,EAAO,UAAW,EAAA,CAAA,CAAA;AAClB,IAAA,YAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AASA,IAAA,aAAA,CAAA,IAAA,EAAA,aAAA,EAAc,CAAC,QAAqB,KAAA;AAClC,MAAI,IAAA,QAAA,GAAW,IAAK,CAAA,IAAA,CAAK,MAAQ,EAAA;AAC/B,QAAA,IAAA,CAAK,KAAK,MAAS,GAAA,QAAA;AAAA;AAGrB,MAAA,IAAA,CAAK,QAAW,GAAA,QAAA;AAAA,KAClB,CAAA;AAZE,IAAA,YAAA,CAAA,IAAA,EAAK,MAAS,EAAA,IAAI,WAAY,CAAA,IAAA,EAAM,EAAE,CAAA,CAAA;AAEtC,IAAK,IAAA,CAAA,IAAA,GAAO,IAAI,KAAM,CAAA,IAAA,CAAK,IAAI,CAAG,EAAA,EAAA,GAAK,IAAI,CAAC,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IAAA;AAAA;AACT;AAAA;AAAA,EAIA,IAAI,qBAAiC,GAAA;AACnC,IAAA,MAAM,EAAE,IAAA,EAAM,EAAG,EAAA,GAAI,YAAK,CAAA,IAAA,EAAA,MAAA,CAAA;AAE1B,IAAA,KAAA,IAAS,CAAI,GAAA,IAAA,EAAM,CAAI,GAAA,EAAA,EAAI,CAAK,EAAA,EAAA;AAC9B,MAAA,IAAI,IAAK,CAAA,UAAA,CAAW,CAAC,CAAA,KAAM,KAAW,CAAA,EAAA;AACpC,QAAO,OAAA,KAAA;AAAA;AACT;AAEF,IAAO,OAAA,IAAA;AAAA;AAEX;AAtFE,MAAA,GAAA,IAAA,OAAA,EAAA;;;;"}
@@ -12,6 +12,14 @@ const MENU_RPC_TYPES = [
12
12
  "VP_EDIT_DELETE_ROW_RPC",
13
13
  "VP_EDIT_SUBMIT_FORM_RPC"
14
14
  ];
15
+ const isSelectRequest = (message) => "type" in message && (message.type === "SELECT_ROW" || message.type === "DESELECT_ROW" || message.type === "SELECT_ROW_RANGE" || message.type === "SELECT_ALL" || message.type === "DESELECT_ALL");
16
+ const isSelectSuccessWithRowCount = (response) => [
17
+ "SELECT_ROW_SUCCESS",
18
+ "DESELECT_ROW_SUCCESS",
19
+ "SELECT_ROW_RANGE_SUCCESS",
20
+ "SELECT_ALL_SUCCESS",
21
+ "DESELECT_ALL_SUCCESS"
22
+ ].includes(response.type ?? "") && typeof response.selectedRowCount === "number";
15
23
  const isRpcServiceRequest = (message) => message.type === "RPC_REQUEST";
16
24
  const hasViewPortContext = (message) => message.context.type === "VIEWPORT_CONTEXT";
17
25
  const isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
@@ -65,5 +73,5 @@ function isCustomComponentActionMessage(rpcResponse) {
65
73
  return isActionMessage(rpcResponse) && isOpenDialogAction(rpcResponse.action) && isSessionTable(rpcResponse.action.table) && typeof rpcResponse.action.renderComponent === "string" && isView(rpcResponse.action.renderComponent);
66
74
  }
67
75
 
68
- export { hasViewPortContext, isActionMessage, isCustomComponentActionMessage, isEditCellRequest, isLoginResponse, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isRpcServiceRequest, isSessionTable, isSessionTableActionMessage, isTypeaheadRequest, isVuuMenuRpcRequest, vuuAddRowRequest, vuuDeleteRowRequest, vuuEditCellRequest };
76
+ export { hasViewPortContext, isActionMessage, isCustomComponentActionMessage, isEditCellRequest, isLoginResponse, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isRpcServiceRequest, isSelectRequest, isSelectSuccessWithRowCount, isSessionTable, isSessionTableActionMessage, isTypeaheadRequest, isVuuMenuRpcRequest, vuuAddRowRequest, vuuDeleteRowRequest, vuuEditCellRequest };
69
77
  //# sourceMappingURL=protocol-message-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-message-utils.js","sources":["../../../../../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcEditCellRequest,\n VuuRpcRequest,\n VuuRpcEditAddRowRequest,\n VuuDataRowDto,\n VuuRpcEditDeleteRowRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n VuuLoginResponse,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { isView as componentInRegistry } from \"./component-registry\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n \"VP_EDIT_CELL_RPC\",\n \"VP_EDIT_ROW_RPC\",\n \"VP_EDIT_ADD_ROW_RPC\",\n \"VP_EDIT_DELETE_CELL_RPC\",\n \"VP_EDIT_DELETE_ROW_RPC\",\n \"VP_EDIT_SUBMIT_FORM_RPC\",\n];\n\nexport const isRpcServiceRequest = (message: {\n type: string;\n}): message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, \"context\"> =>\n message.type === \"RPC_REQUEST\";\n\nexport const hasViewPortContext = (\n message: VuuRpcServiceRequest,\n): message is VuuRpcServiceRequest<ViewportRpcContext> =>\n message.context.type === \"VIEWPORT_CONTEXT\";\n\nexport const isVuuMenuRpcRequest = (\n message: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): message is VuuRpcMenuRequest => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isLoginResponse = (message: object): message is VuuLoginResponse =>\n \"type\" in message &&\n (message.type === \"LOGIN_SUCCESS\" || message.type === \"LOGIN_FAIL\");\n\nexport const isRequestResponse = (\n message: object,\n): message is VuuUiMessageInRequestResponse => \"requestId\" in message;\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse,\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction,\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n\nexport const isTypeaheadRequest = (\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuViewportRpcTypeaheadRequest, \"vpId\"> => {\n return (\n isRpcServiceRequest(request) &&\n (request.rpcName === \"getUniqueFieldValues\" ||\n request.rpcName === \"getUniqueFieldValuesStartingWith\")\n );\n};\n\nexport function isEditCellRequest(\n request: VuuRpcRequest,\n): request is VuuRpcEditCellRequest;\nexport function isEditCellRequest(\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuRpcEditCellRequest, \"vpId\">;\nexport function isEditCellRequest(\n request: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): request is VuuRpcEditCellRequest | Omit<VuuRpcEditCellRequest, \"vpId\"> {\n return request.type === \"VP_EDIT_CELL_RPC\";\n}\n\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n vpId: string,\n): VuuRpcEditCellRequest;\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n): Omit<VuuRpcEditCellRequest, \"vpId\">;\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n vpId?: string,\n): VuuRpcEditCellRequest | Omit<VuuRpcEditCellRequest, \"vpId\"> {\n return {\n rowKey,\n field,\n value,\n type: \"VP_EDIT_CELL_RPC\",\n vpId,\n };\n}\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n vpId: string,\n): VuuRpcEditAddRowRequest;\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n): Omit<VuuRpcEditAddRowRequest, \"vpId\">;\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n vpId?: string,\n): VuuRpcEditAddRowRequest | Omit<VuuRpcEditAddRowRequest, \"vpId\"> {\n return {\n rowKey,\n data,\n type: \"VP_EDIT_ADD_ROW_RPC\",\n vpId,\n };\n}\n\nexport function vuuDeleteRowRequest(\n rowKey: string,\n vpId: string,\n): VuuRpcEditDeleteRowRequest;\nexport function vuuDeleteRowRequest(\n rowKey: string,\n): Omit<VuuRpcEditDeleteRowRequest, \"vpId\">;\nexport function vuuDeleteRowRequest(\n rowKey: string,\n vpId?: string,\n): VuuRpcEditDeleteRowRequest | Omit<VuuRpcEditDeleteRowRequest, \"vpId\"> {\n return {\n rowKey,\n type: \"VP_EDIT_DELETE_ROW_RPC\",\n vpId,\n };\n}\n\nexport const isSessionTable = (table?: unknown) => {\n if (\n table !== null &&\n typeof table === \"object\" &&\n \"table\" in table &&\n \"module\" in table\n ) {\n return (table as VuuTable).table.startsWith(\"session\");\n }\n return false;\n};\n\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess;\nexport function isActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<VuuRpcMenuSuccess, \"vpId\">;\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n) {\n return rpcResponse.type === \"VIEW_PORT_MENU_RESP\";\n}\n\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<\n VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n >,\n \"vpId\"\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n rpcResponse.action?.renderComponent === \"inline-form\"\n );\n}\n\nexport function isCustomComponentActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenComponentInDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n typeof rpcResponse.action.renderComponent === \"string\" &&\n componentInRegistry(rpcResponse.action.renderComponent)\n );\n}\n"],"names":["componentInRegistry"],"mappings":";;AA4BA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../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcEditCellRequest,\n VuuRpcRequest,\n VuuRpcEditAddRowRequest,\n VuuDataRowDto,\n VuuRpcEditDeleteRowRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n VuuLoginResponse,\n VuuRowDataItemType,\n SelectRequest,\n SelectResponse,\n SelectSuccessWithRowCount,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { isView as componentInRegistry } from \"./component-registry\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n \"VP_EDIT_CELL_RPC\",\n \"VP_EDIT_ROW_RPC\",\n \"VP_EDIT_ADD_ROW_RPC\",\n \"VP_EDIT_DELETE_CELL_RPC\",\n \"VP_EDIT_DELETE_ROW_RPC\",\n \"VP_EDIT_SUBMIT_FORM_RPC\",\n];\n\nexport const isSelectRequest = (message: object): message is SelectRequest =>\n \"type\" in message &&\n (message.type === \"SELECT_ROW\" ||\n message.type === \"DESELECT_ROW\" ||\n message.type === \"SELECT_ROW_RANGE\" ||\n message.type === \"SELECT_ALL\" ||\n message.type === \"DESELECT_ALL\");\n\nexport const isSelectSuccessWithRowCount = (\n response: SelectResponse | SelectSuccessWithRowCount,\n): response is SelectSuccessWithRowCount =>\n [\n \"SELECT_ROW_SUCCESS\",\n \"DESELECT_ROW_SUCCESS\",\n \"SELECT_ROW_RANGE_SUCCESS\",\n \"SELECT_ALL_SUCCESS\",\n \"DESELECT_ALL_SUCCESS\",\n ].includes(response.type ?? \"\") &&\n typeof (response as SelectSuccessWithRowCount).selectedRowCount === \"number\";\n\nexport const isRpcServiceRequest = (message: {\n type: string;\n}): message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, \"context\"> =>\n message.type === \"RPC_REQUEST\";\n\nexport const hasViewPortContext = (\n message: VuuRpcServiceRequest,\n): message is VuuRpcServiceRequest<ViewportRpcContext> =>\n message.context.type === \"VIEWPORT_CONTEXT\";\n\nexport const isVuuMenuRpcRequest = (\n message: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): message is VuuRpcMenuRequest => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isLoginResponse = (message: object): message is VuuLoginResponse =>\n \"type\" in message &&\n (message.type === \"LOGIN_SUCCESS\" || message.type === \"LOGIN_FAIL\");\n\nexport const isRequestResponse = (\n message: object,\n): message is VuuUiMessageInRequestResponse => \"requestId\" in message;\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse,\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction,\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n\nexport const isTypeaheadRequest = (\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuViewportRpcTypeaheadRequest, \"vpId\"> => {\n return (\n isRpcServiceRequest(request) &&\n (request.rpcName === \"getUniqueFieldValues\" ||\n request.rpcName === \"getUniqueFieldValuesStartingWith\")\n );\n};\n\nexport function isEditCellRequest(\n request: VuuRpcRequest,\n): request is VuuRpcEditCellRequest;\nexport function isEditCellRequest(\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuRpcEditCellRequest, \"vpId\">;\nexport function isEditCellRequest(\n request: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): request is VuuRpcEditCellRequest | Omit<VuuRpcEditCellRequest, \"vpId\"> {\n return request.type === \"VP_EDIT_CELL_RPC\";\n}\n\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n vpId: string,\n): VuuRpcEditCellRequest;\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n): Omit<VuuRpcEditCellRequest, \"vpId\">;\nexport function vuuEditCellRequest(\n rowKey: string,\n field: string,\n value: VuuRowDataItemType,\n vpId?: string,\n): VuuRpcEditCellRequest | Omit<VuuRpcEditCellRequest, \"vpId\"> {\n return {\n rowKey,\n field,\n value,\n type: \"VP_EDIT_CELL_RPC\",\n vpId,\n };\n}\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n vpId: string,\n): VuuRpcEditAddRowRequest;\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n): Omit<VuuRpcEditAddRowRequest, \"vpId\">;\nexport function vuuAddRowRequest(\n rowKey: string,\n data: VuuDataRowDto,\n vpId?: string,\n): VuuRpcEditAddRowRequest | Omit<VuuRpcEditAddRowRequest, \"vpId\"> {\n return {\n rowKey,\n data,\n type: \"VP_EDIT_ADD_ROW_RPC\",\n vpId,\n };\n}\n\nexport function vuuDeleteRowRequest(\n rowKey: string,\n vpId: string,\n): VuuRpcEditDeleteRowRequest;\nexport function vuuDeleteRowRequest(\n rowKey: string,\n): Omit<VuuRpcEditDeleteRowRequest, \"vpId\">;\nexport function vuuDeleteRowRequest(\n rowKey: string,\n vpId?: string,\n): VuuRpcEditDeleteRowRequest | Omit<VuuRpcEditDeleteRowRequest, \"vpId\"> {\n return {\n rowKey,\n type: \"VP_EDIT_DELETE_ROW_RPC\",\n vpId,\n };\n}\n\nexport const isSessionTable = (table?: unknown) => {\n if (\n table !== null &&\n typeof table === \"object\" &&\n \"table\" in table &&\n \"module\" in table\n ) {\n return (table as VuuTable).table.startsWith(\"session\");\n }\n return false;\n};\n\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess;\nexport function isActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<VuuRpcMenuSuccess, \"vpId\">;\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n) {\n return rpcResponse.type === \"VIEW_PORT_MENU_RESP\";\n}\n\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<\n VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n >,\n \"vpId\"\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n rpcResponse.action?.renderComponent === \"inline-form\"\n );\n}\n\nexport function isCustomComponentActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenComponentInDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n typeof rpcResponse.action.renderComponent === \"string\" &&\n componentInRegistry(rpcResponse.action.renderComponent)\n );\n}\n"],"names":["componentInRegistry"],"mappings":";;AA+BA,MAAM,cAAiB,GAAA;AAAA,EACrB,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Ae,CAAA,WAAA,CAAY,MAAO,CAAA,KAAK,CACvC,IAAA,WAAA,CAAY,QAAQ,eAAoB,KAAA,aAAA;AAE5C;AAEO,SAAS,+BACd,WAKA,EAAA;AACA,EACE,OAAA,eAAA,CAAgB,WAAW,CAC3B,IAAA,kBAAA,CAAmB,YAAY,MAAM,CAAA,IACrC,eAAe,WAAY,CAAA,MAAA,CAAO,KAAK,CACvC,IAAA,OAAO,YAAY,MAAO,CAAA,eAAA,KAAoB,YAC9CA,MAAoB,CAAA,WAAA,CAAY,OAAO,eAAe,CAAA;AAE1D;;;;"}
@@ -1,7 +1,6 @@
1
1
  import { metadataKeys } from './column-utils.js';
2
- import { isRowSelected, getSelectionStatus } from './selection-utils.js';
3
2
 
4
- const { IS_LEAF, KEY, IDX } = metadataKeys;
3
+ const { IS_LEAF, KEY, IDX, SELECTED } = metadataKeys;
5
4
  const actualRowPositioning = (rowHeight) => [
6
5
  (row) => row[IDX] * rowHeight,
7
6
  (position) => Math.floor(position / rowHeight),
@@ -27,7 +26,7 @@ const asDataSourceRowObject = (row, columnMap) => {
27
26
  key,
28
27
  index,
29
28
  isGroupRow: !isLeaf,
30
- isSelected: isRowSelected(row),
29
+ isSelected: row[SELECTED] !== 0,
31
30
  data: {}
32
31
  };
33
32
  for (const [colName, colIdx] of Object.entries(columnMap)) {
@@ -35,8 +34,7 @@ const asDataSourceRowObject = (row, columnMap) => {
35
34
  }
36
35
  return rowObject;
37
36
  };
38
- const NO_SELECTION = [];
39
- const vuuRowToDataSourceRow = ({ rowIndex, rowKey, sel: isSelected, ts, data }, keys, selectedRows = NO_SELECTION) => {
37
+ const vuuRowToDataSourceRow = ({ rowIndex, rowKey, sel: isSelected = 0, ts, data }, keys) => {
40
38
  return [
41
39
  rowIndex,
42
40
  keys.keyFor(rowIndex),
@@ -45,7 +43,7 @@ const vuuRowToDataSourceRow = ({ rowIndex, rowKey, sel: isSelected, ts, data },
45
43
  0,
46
44
  0,
47
45
  rowKey,
48
- isSelected ? getSelectionStatus(selectedRows, rowIndex) : 0,
46
+ isSelected,
49
47
  ts,
50
48
  false
51
49
  // IsNew
@@ -1 +1 @@
1
- {"version":3,"file":"row-utils.js","sources":["../../../../../../packages/vuu-utils/src/row-utils.ts"],"sourcesContent":["//TODO this all probably belongs in vuu-table\nimport type {\n DataSourceRow,\n DataSourceRowObject,\n Selection,\n} from \"@vuu-ui/vuu-data-types\";\nimport type { MutableRefObject } from \"react\";\nimport { ColumnMap, metadataKeys } from \"./column-utils\";\nimport { getSelectionStatus, isRowSelected } from \"./selection-utils\";\nimport { IKeySet } from \"./keyset\";\nimport { VuuRow } from \"@vuu-ui/vuu-protocol-types\";\n\nconst { IS_LEAF, KEY, IDX } = metadataKeys;\n\nexport type RowOffsetFunc = (\n row: DataSourceRow,\n pctScrollTop?: number,\n) => number;\nexport type RowAtPositionFunc = (position: number) => number;\n\n/**\n * RowOffset function, RowAtPosition function, isVirtualScroll\n */\nexport type RowPositioning = [RowOffsetFunc, RowAtPositionFunc, boolean];\n\nexport const actualRowPositioning = (rowHeight: number): RowPositioning => [\n (row) => row[IDX] * rowHeight,\n (position) => Math.floor(position / rowHeight),\n false,\n];\n\n/**\n * return functions for determining a) the pixel offset to apply to a row, given the\n * row index and b) the index of the row at a given scroll offset. This implementation\n * is used when we are forced to 'virtualise' scrolling - because the number of rows\n * is high enough that we cannot create a large enough HTML content container.\n *\n * @param rowHeight\n * @param virtualisedExtent\n * @param pctScrollTop\n * @returns\n */\nexport const virtualRowPositioning = (\n rowHeight: number,\n virtualisedExtent: number,\n pctScrollTop: MutableRefObject<number>,\n): RowPositioning => [\n (row, offset = 0) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return (row[IDX] - offset) * rowHeight - rowOffset;\n },\n /*\n Return index position of closest row \n */\n (position) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return Math.round((position + rowOffset) / rowHeight);\n },\n true,\n];\n\nexport type RowToObjectMapper = (\n row: DataSourceRow,\n columnMap: ColumnMap,\n) => DataSourceRowObject;\n\nexport const asDataSourceRowObject: RowToObjectMapper = (\n row,\n columnMap,\n): DataSourceRowObject => {\n const { [IS_LEAF]: isLeaf, [KEY]: key, [IDX]: index } = row;\n\n const rowObject: DataSourceRowObject = {\n key,\n index,\n isGroupRow: !isLeaf,\n isSelected: isRowSelected(row),\n data: {},\n };\n\n for (const [colName, colIdx] of Object.entries(columnMap)) {\n rowObject.data[colName] = row[colIdx];\n }\n\n return rowObject;\n};\n\nconst NO_SELECTION: Selection = [];\nexport const vuuRowToDataSourceRow = (\n { rowIndex, rowKey, sel: isSelected, ts, data }: VuuRow,\n keys: IKeySet,\n selectedRows: Selection = NO_SELECTION,\n) => {\n return [\n rowIndex,\n keys.keyFor(rowIndex),\n true,\n false,\n 0,\n 0,\n rowKey,\n isSelected ? getSelectionStatus(selectedRows, rowIndex) : 0,\n ts,\n false, // IsNew\n ].concat(data) as DataSourceRow;\n};\n"],"names":[],"mappings":";;;AAYA,MAAM,EAAE,OAAA,EAAS,GAAK,EAAA,GAAA,EAAQ,GAAA,YAAA;AAajB,MAAA,oBAAA,GAAuB,CAAC,SAAsC,KAAA;AAAA,EACzE,CAAC,GAAA,KAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,SAAA;AAAA,EACpB,CAAC,QAAA,KAAa,IAAK,CAAA,KAAA,CAAM,WAAW,SAAS,CAAA;AAAA,EAC7C;AACF;AAaO,MAAM,qBAAwB,GAAA,CACnC,SACA,EAAA,iBAAA,EACA,YACmB,KAAA;AAAA,EACnB,CAAC,GAAK,EAAA,MAAA,GAAS,CAAM,KAAA;AACnB,IAAM,MAAA,SAAA,GAAY,aAAa,OAAU,GAAA,iBAAA;AACzC,IAAA,OAAA,CAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,MAAA,IAAU,SAAY,GAAA,SAAA;AAAA,GAC3C;AAAA;AAAA;AAAA;AAAA,EAIA,CAAC,QAAa,KAAA;AACZ,IAAM,MAAA,SAAA,GAAY,aAAa,OA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/src/row-utils.ts"],"sourcesContent":["//TODO this all probably belongs in vuu-table\nimport type {\n DataSourceRow,\n DataSourceRowObject,\n} from \"@vuu-ui/vuu-data-types\";\nimport { ColumnMap, metadataKeys } from \"./column-utils\";\nimport { IKeySet } from \"./keyset\";\nimport { VuuRow } from \"@vuu-ui/vuu-protocol-types\";\nimport { RefObject } from \"react\";\n\nconst { IS_LEAF, KEY, IDX, SELECTED } = metadataKeys;\n\nexport type RowOffsetFunc = (\n row: DataSourceRow,\n pctScrollTop?: number,\n) => number;\nexport type RowAtPositionFunc = (position: number) => number;\n\n/**\n * RowOffset function, RowAtPosition function, isVirtualScroll\n */\nexport type RowPositioning = [RowOffsetFunc, RowAtPositionFunc, boolean];\n\nexport const actualRowPositioning = (rowHeight: number): RowPositioning => [\n (row) => row[IDX] * rowHeight,\n (position) => Math.floor(position / rowHeight),\n false,\n];\n\n/**\n * return functions for determining a) the pixel offset to apply to a row, given the\n * row index and b) the index of the row at a given scroll offset. This implementation\n * is used when we are forced to 'virtualise' scrolling - because the number of rows\n * is high enough that we cannot create a large enough HTML content container.\n *\n * @param rowHeight\n * @param virtualisedExtent\n * @param pctScrollTop\n * @returns\n */\nexport const virtualRowPositioning = (\n rowHeight: number,\n virtualisedExtent: number,\n pctScrollTop: RefObject<number>,\n): RowPositioning => [\n (row, offset = 0) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return (row[IDX] - offset) * rowHeight - rowOffset;\n },\n /*\n Return index position of closest row \n */\n (position) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return Math.round((position + rowOffset) / rowHeight);\n },\n true,\n];\n\nexport type RowToObjectMapper = (\n row: DataSourceRow,\n columnMap: ColumnMap,\n) => DataSourceRowObject;\n\nexport const asDataSourceRowObject: RowToObjectMapper = (\n row,\n columnMap,\n): DataSourceRowObject => {\n const { [IS_LEAF]: isLeaf, [KEY]: key, [IDX]: index } = row;\n\n const rowObject: DataSourceRowObject = {\n key,\n index,\n isGroupRow: !isLeaf,\n isSelected: row[SELECTED] !== 0,\n data: {},\n };\n\n for (const [colName, colIdx] of Object.entries(columnMap)) {\n rowObject.data[colName] = row[colIdx];\n }\n\n return rowObject;\n};\n\nexport const vuuRowToDataSourceRow = (\n { rowIndex, rowKey, sel: isSelected = 0, ts, data }: VuuRow,\n keys: IKeySet,\n) => {\n return [\n rowIndex,\n keys.keyFor(rowIndex),\n true,\n false,\n 0,\n 0,\n rowKey,\n isSelected,\n ts,\n false, // IsNew\n ].concat(data) as DataSourceRow;\n};\n"],"names":[],"mappings":";;AAUA,MAAM,EAAE,OAAA,EAAS,GAAK,EAAA,GAAA,EAAK,UAAa,GAAA,YAAA;AAa3B,MAAA,oBAAA,GAAuB,CAAC,SAAsC,KAAA;AAAA,EACzE,CAAC,GAAA,KAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,SAAA;AAAA,EACpB,CAAC,QAAA,KAAa,IAAK,CAAA,KAAA,CAAM,WAAW,SAAS,CAAA;AAAA,EAC7C;AACF;AAaO,MAAM,qBAAwB,GAAA,CACnC,SACA,EAAA,iBAAA,EACA,YACmB,KAAA;AAAA,EACnB,CAAC,GAAK,EAAA,MAAA,GAAS,CAAM,KAAA;AACnB,IAAM,MAAA,SAAA,GAAY,aAAa,OAAU,GAAA,iBAAA;AACzC,IAAA,OAAA,CAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,MAAA,IAAU,SAAY,GAAA,SAAA;AAAA,GAC3C;AAAA;AAAA;AAAA;AAAA,EAIA,CAAC,QAAa,KAAA;AACZ,IAAM,MAAA,SAAA,GAAY,aAAa,OAAU,GAAA,iBAAA;AACzC,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA,CAAO,QAAW,GAAA,SAAA,IAAa,SAAS,CAAA;AAAA,GACtD;AAAA,EACA;AACF;AAOa,MAAA,qBAAA,GAA2C,CACtD,GAAA,EACA,SACwB,KAAA;AACxB,EAAA,MAAM,EAAE,CAAC,OAAO,GAAG,MAAQ,EAAA,CAAC,GAAG,GAAG,GAAK,EAAA,CAAC,GAAG,GAAG,OAAU,GAAA,GAAA;AAExD,EAAA,MAAM,SAAiC,GAAA;AAAA,IACrC,GAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAY,CAAC,MAAA;AAAA,IACb,UAAA,EAAY,GAAI,CAAA,QAAQ,CAAM,KAAA,CAAA;AAAA,IAC9B,MAAM;AAAC,GACT;AAEA,EAAA,KAAA,MAAW,CAAC,OAAS,EAAA,MAAM,KAAK,MAAO,CAAA,OAAA,CAAQ,SAAS,CAAG,EAAA;AACzD,IAAA,SAAA,CAAU,IAAK,CAAA,OAAO,CAAI,GAAA,GAAA,CAAI,MAAM,CAAA;AAAA;AAGtC,EAAO,OAAA,SAAA;AACT;AAEa,MAAA,qBAAA,GAAwB,CACnC,EAAE,QAAU,EAAA,MAAA,EAAQ,GAAK,EAAA,UAAA,GAAa,CAAG,EAAA,EAAA,EAAI,IAAK,EAAA,EAClD,IACG,KAAA;AACH,EAAO,OAAA;AAAA,IACL,QAAA;AAAA,IACA,IAAA,CAAK,OAAO,QAAQ,CAAA;AAAA,IACpB,IAAA;AAAA,IACA,KAAA;AAAA,IACA,CAAA;AAAA,IACA,CAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,EAAA;AAAA,IACA;AAAA;AAAA,GACF,CAAE,OAAO,IAAI,CAAA;AACf;;;;"}
@@ -1,236 +1,30 @@
1
- import { metadataKeys } from './column-utils.js';
2
-
3
- const NO_SELECTION = [];
4
- const { SELECTED } = metadataKeys;
5
- const RowSelected = {
6
- False: 0,
7
- True: 1,
8
- First: 2,
9
- Last: 4
10
- };
11
- const isRowSelected = (row) => (row[SELECTED] & RowSelected.True) === RowSelected.True;
12
- const isRowSelectedLast = (row) => row !== void 0 && (row[SELECTED] & RowSelected.Last) === RowSelected.Last;
13
- const inAscendingOrder = (item1, item2) => {
14
- const n1 = typeof item1 === "number" ? item1 : item1[0];
15
- const n2 = typeof item2 === "number" ? item2 : item2[0];
16
- return n1 - n2;
17
- };
18
- const deselectItem = (selectionModel, selected, itemIndex, rangeSelect, keepExistingSelection = false) => {
1
+ const deselectItem = (selectionModel, rowKey, rangeSelect, preserveExistingSelection = false) => {
2
+ return {
3
+ preserveExistingSelection,
4
+ rowKey,
5
+ type: "DESELECT_ROW"
6
+ };
7
+ };
8
+ const selectItem = (selectionModel, rowKey, rangeSelect, preserveExistingSelection = false, activeRowKey) => {
19
9
  const singleSelect = selectionModel === "single";
20
- const multiSelect = selectionModel === "extended" || selectionModel === "checkbox";
21
- const actsLikeSingleSelect = singleSelect || multiSelect && !keepExistingSelection && !rangeSelect;
22
- if (actsLikeSingleSelect || !rangeSelect && !keepExistingSelection) {
23
- return NO_SELECTION;
24
- } else if (!rangeSelect && keepExistingSelection) {
25
- return removeSelectedItem(selected, itemIndex);
26
- }
27
- return NO_SELECTION;
28
- };
29
- const newSelectedFillsGapOrExtends = (selection, itemIndex) => {
30
- for (let i = 0; i < selection.length; i++) {
31
- const item = selection[i];
32
- if (typeof item === "number") {
33
- if (item === itemIndex - 1) {
34
- return true;
35
- } else if (item > itemIndex) {
36
- return false;
37
- }
38
- } else if (item[0] === itemIndex + 1 || item[1] === itemIndex - 1) {
39
- return true;
40
- } else if (item[0] > itemIndex) {
41
- return false;
42
- }
43
- }
44
- return false;
45
- };
46
- const fillGapOrExtendSelection = (selection, itemIndex) => {
47
- for (let i = 0; i < selection.length; i++) {
48
- const item = selection[i];
49
- if (typeof item === "number") {
50
- if (item === itemIndex - 1) {
51
- const nextSelectionItem = selection[i + 1];
52
- if (nextSelectionItem === itemIndex + 1) {
53
- const newRange = [item, nextSelectionItem];
54
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 2));
55
- } else {
56
- const newRange = [item, itemIndex];
57
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 1));
58
- }
59
- } else if (item > itemIndex) {
60
- break;
61
- }
62
- } else if (item[0] === itemIndex + 1) {
63
- const newRange = [itemIndex, item[1]];
64
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 1));
65
- } else if (item[1] === itemIndex - 1) {
66
- const nextItem = selection[i + 1];
67
- if (Array.isArray(nextItem) && nextItem[0] === itemIndex + 1) {
68
- const newRange = [item[0], nextItem[1]];
69
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 2));
70
- } else if (typeof nextItem === "number" && nextItem === itemIndex + 1) {
71
- const newRange = [item[0], nextItem];
72
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 2));
73
- } else {
74
- const newRange = [item[0], itemIndex];
75
- return selection.slice(0, i).concat([newRange]).concat(selection.slice(i + 1));
76
- }
77
- }
78
- }
79
- return selection;
80
- };
81
- const selectItem = (selectionModel, selected, itemIndex, rangeSelect, keepExistingSelection = false, activeItemIndex = -1) => {
82
- const singleSelect = selectionModel === "single";
83
- const multiSelect = selectionModel === "extended" || selectionModel === "checkbox";
84
- const actsLikeSingleSelect = singleSelect || multiSelect && !keepExistingSelection && !rangeSelect || rangeSelect && activeItemIndex === -1;
10
+ const actsLikeSingleSelect = singleSelect || activeRowKey === void 0;
85
11
  if (selectionModel === "none") {
86
- return NO_SELECTION;
12
+ return;
87
13
  } else if (actsLikeSingleSelect) {
88
- return [itemIndex];
14
+ return {
15
+ preserveExistingSelection,
16
+ rowKey,
17
+ type: "SELECT_ROW"
18
+ };
89
19
  } else if (rangeSelect) {
90
- if (selected.length === 0) {
91
- return [itemIndex];
92
- } else {
93
- const range = itemIndex > activeItemIndex ? [activeItemIndex, itemIndex] : [itemIndex, activeItemIndex];
94
- return insertRange(selected, range);
95
- }
96
- } else if (!rangeSelect) {
97
- if (newSelectedFillsGapOrExtends(selected, itemIndex)) {
98
- return fillGapOrExtendSelection(selected, itemIndex);
99
- } else {
100
- return selected?.concat(itemIndex).sort(inAscendingOrder);
101
- }
102
- } else ;
103
- return NO_SELECTION;
104
- };
105
- function removeSelectedItem(selected, itemIndex) {
106
- if (selected.includes(itemIndex)) {
107
- return selected.filter((selectedItem) => selectedItem !== itemIndex);
108
- } else {
109
- const newSelected = [];
110
- for (const selectedItem of selected) {
111
- if (Array.isArray(selectedItem)) {
112
- if (rangeIncludes(selectedItem, itemIndex)) {
113
- newSelected.push(...splitRange(selectedItem, itemIndex));
114
- } else {
115
- newSelected.push(selectedItem);
116
- }
117
- } else {
118
- newSelected.push(selectedItem);
119
- }
120
- }
121
- return newSelected;
122
- }
123
- }
124
- function insertRange(selected, range) {
125
- const [from, to] = range;
126
- return selected.reduce((newSelected, selectedItem) => {
127
- if (typeof selectedItem === "number") {
128
- if (selectedItem < from || selectedItem > to) {
129
- newSelected.push(selectedItem);
130
- } else if (!includedInRange(newSelected.at(-1), selectedItem)) {
131
- newSelected.push(range);
132
- }
133
- } else if (overlappingRange(selectedItem, range)) {
134
- newSelected.push(mergeRanges(selectedItem, range));
135
- } else {
136
- if (range[1] < selectedItem[0]) {
137
- newSelected.push(range);
138
- }
139
- newSelected.push(selectedItem);
140
- }
141
- return newSelected;
142
- }, []);
143
- }
144
- const overlappingRange = (r1, r2) => r1[1] >= r2[0] && r1[1] <= r2[1] || r1[0] >= r2[0] && r1[0] <= r2[1];
145
- const mergeRanges = (r1, r2) => [
146
- Math.min(r1[0], r2[0]),
147
- Math.max(r1[1], r2[1])
148
- ];
149
- const includedInRange = (selectedItem, index) => {
150
- if (typeof selectedItem === "undefined" || typeof selectedItem === "number") {
151
- return false;
152
- } else return rangeIncludes(selectedItem, index);
153
- };
154
- const rangeIncludes = (range, index) => index >= range[0] && index <= range[1];
155
- const SINGLE_SELECTED_ROW = RowSelected.True + RowSelected.First + RowSelected.Last;
156
- const FIRST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.First;
157
- const LAST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.Last;
158
- const getSelectionStatus = (selected, itemIndex) => {
159
- for (const item of selected) {
160
- if (typeof item === "number") {
161
- if (item === itemIndex) {
162
- return SINGLE_SELECTED_ROW;
163
- }
164
- } else if (rangeIncludes(item, itemIndex)) {
165
- if (itemIndex === item[0]) {
166
- return FIRST_SELECTED_ROW_OF_BLOCK;
167
- } else if (itemIndex === item[1]) {
168
- return LAST_SELECTED_ROW_OF_BLOCK;
169
- } else {
170
- return RowSelected.True;
171
- }
172
- }
173
- }
174
- return RowSelected.False;
175
- };
176
- const isSelected = (selected, itemIndex) => {
177
- for (const item of selected) {
178
- if (typeof item === "number") {
179
- if (item === itemIndex) {
180
- return true;
181
- } else if (item > itemIndex) {
182
- return false;
183
- }
184
- } else if (rangeIncludes(item, itemIndex)) {
185
- return true;
186
- } else if (item[0] > itemIndex) {
187
- return false;
188
- }
189
- }
190
- return false;
191
- };
192
- const expandSelection = (selected) => {
193
- if (selected.every((selectedItem) => typeof selectedItem === "number")) {
194
- return selected;
195
- }
196
- const expandedSelected = [];
197
- for (const selectedItem of selected) {
198
- if (typeof selectedItem === "number") {
199
- expandedSelected.push(selectedItem);
200
- } else {
201
- for (let i = selectedItem[0]; i <= selectedItem[1]; i++) {
202
- expandedSelected.push(i);
203
- }
204
- }
205
- }
206
- return expandedSelected;
207
- };
208
- function splitRange([from, to], itemIndex) {
209
- if (itemIndex === from) {
210
- return [[from + 1, to]];
211
- } else if (itemIndex === to) {
212
- return [[from, to - 1]];
213
- } else if (to - from === 2) {
214
- return [from, to];
215
- } else if (itemIndex === to - 1) {
216
- return [[from, to - 2], to];
217
- } else {
218
- return [
219
- [from, itemIndex - 1],
220
- [itemIndex + 1, to]
221
- ];
222
- }
223
- }
224
- const selectionCount = (selected = NO_SELECTION) => {
225
- let count = selected.length;
226
- for (const selectionItem of selected) {
227
- if (Array.isArray(selectionItem)) {
228
- const [from, to] = selectionItem;
229
- count += to - from;
230
- }
20
+ return {
21
+ preserveExistingSelection,
22
+ fromRowKey: rowKey,
23
+ toRowKey: activeRowKey,
24
+ type: "SELECT_ROW_RANGE"
25
+ };
231
26
  }
232
- return count;
233
27
  };
234
28
 
235
- export { RowSelected, deselectItem, expandSelection, getSelectionStatus, isRowSelected, isRowSelectedLast, isSelected, selectItem, selectionCount };
29
+ export { deselectItem, selectItem };
236
30
  //# sourceMappingURL=selection-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"selection-utils.js","sources":["../../../../../../packages/vuu-utils/src/selection-utils.ts"],"sourcesContent":["import {\n DataSourceRow,\n RangeTuple,\n Selection,\n SelectionItem,\n} from \"@vuu-ui/vuu-data-types\";\nimport { TableSelectionModel } from \"@vuu-ui/vuu-table-types\";\nimport { metadataKeys } from \"./column-utils\";\n\nconst NO_SELECTION: number[] = [];\n\nconst { SELECTED } = metadataKeys;\n\nexport const RowSelected = {\n False: 0,\n True: 1,\n First: 2,\n Last: 4,\n};\n\nexport const isRowSelected = (row: DataSourceRow): boolean =>\n (row[SELECTED] & RowSelected.True) === RowSelected.True;\n\nexport const isRowSelectedLast = (row?: DataSourceRow): boolean =>\n row !== undefined && (row[SELECTED] & RowSelected.Last) === RowSelected.Last;\n\nconst inAscendingOrder = (item1: SelectionItem, item2: SelectionItem) => {\n const n1: number = typeof item1 === \"number\" ? item1 : item1[0];\n const n2: number = typeof item2 === \"number\" ? item2 : item2[0];\n return n1 - n2;\n};\n\nexport const deselectItem = (\n selectionModel: TableSelectionModel,\n selected: Selection,\n itemIndex: number,\n rangeSelect: boolean,\n keepExistingSelection = false,\n): Selection => {\n const singleSelect = selectionModel === \"single\";\n const multiSelect =\n selectionModel === \"extended\" || selectionModel === \"checkbox\";\n const actsLikeSingleSelect =\n singleSelect || (multiSelect && !keepExistingSelection && !rangeSelect);\n\n if (actsLikeSingleSelect || (!rangeSelect && !keepExistingSelection)) {\n return NO_SELECTION;\n } else if (!rangeSelect && keepExistingSelection) {\n return removeSelectedItem(selected, itemIndex);\n }\n return NO_SELECTION;\n};\n\nconst newSelectedFillsGapOrExtends = (\n selection: Selection,\n itemIndex: number,\n): boolean => {\n for (let i = 0; i < selection.length; i++) {\n const item = selection[i];\n if (typeof item === \"number\") {\n if (item === itemIndex - 1) {\n return true;\n } else if (item > itemIndex) {\n return false;\n }\n } else if (item[0] === itemIndex + 1 || item[1] === itemIndex - 1) {\n return true;\n } else if (item[0] > itemIndex) {\n return false;\n }\n }\n return false;\n};\n\nconst fillGapOrExtendSelection = (\n selection: Selection,\n itemIndex: number,\n): Selection => {\n for (let i = 0; i < selection.length; i++) {\n const item = selection[i];\n if (typeof item === \"number\") {\n if (item === itemIndex - 1) {\n const nextSelectionItem = selection[i + 1];\n if (nextSelectionItem === itemIndex + 1) {\n const newRange: SelectionItem = [item, nextSelectionItem];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 2));\n } else {\n const newRange: SelectionItem = [item, itemIndex];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 1));\n }\n } else if (item > itemIndex) {\n break;\n }\n } else if (item[0] === itemIndex + 1) {\n const newRange: SelectionItem = [itemIndex, item[1]];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 1));\n } else if (item[1] === itemIndex - 1) {\n // check to see whether another contiguous range follows\n const nextItem = selection[i + 1];\n if (Array.isArray(nextItem) && nextItem[0] === itemIndex + 1) {\n const newRange: SelectionItem = [item[0], nextItem[1]];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 2));\n } else if (typeof nextItem === \"number\" && nextItem === itemIndex + 1) {\n const newRange: SelectionItem = [item[0], nextItem];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 2));\n } else {\n const newRange: SelectionItem = [item[0], itemIndex];\n return selection\n .slice(0, i)\n .concat([newRange])\n .concat(selection.slice(i + 1));\n }\n }\n }\n\n return selection;\n};\n\nexport const selectItem = (\n selectionModel: TableSelectionModel,\n selected: Selection,\n itemIndex: number,\n rangeSelect: boolean,\n keepExistingSelection = false,\n activeItemIndex = -1,\n): Selection => {\n const singleSelect = selectionModel === \"single\";\n const multiSelect =\n selectionModel === \"extended\" || selectionModel === \"checkbox\";\n const actsLikeSingleSelect =\n singleSelect ||\n (multiSelect && !keepExistingSelection && !rangeSelect) ||\n (rangeSelect && activeItemIndex === -1);\n\n if (selectionModel === \"none\") {\n return NO_SELECTION;\n } else if (actsLikeSingleSelect) {\n return [itemIndex];\n } else if (rangeSelect) {\n if (selected.length === 0) {\n return [itemIndex];\n } else {\n const range: RangeTuple =\n itemIndex > activeItemIndex\n ? [activeItemIndex, itemIndex]\n : [itemIndex, activeItemIndex];\n return insertRange(selected, range);\n }\n } else if (!rangeSelect) {\n // what if we now have a range because we just filled agap between 2\n if (newSelectedFillsGapOrExtends(selected, itemIndex)) {\n return fillGapOrExtendSelection(selected, itemIndex);\n } else {\n return selected?.concat(itemIndex).sort(inAscendingOrder);\n }\n } else if (multiSelect) {\n // const [from, to] = idx > active ? [active, idx] : [idx, active];\n // newSelected = selected?.slice();\n // for (let i = from; i <= to; i++) {\n // if (!selected?.includes(i)) {\n // newSelected.push(i);\n // }\n // }\n }\n return NO_SELECTION;\n};\n\nfunction removeSelectedItem(selected: Selection, itemIndex: number) {\n if (selected.includes(itemIndex)) {\n return selected.filter((selectedItem) => selectedItem !== itemIndex);\n } else {\n const newSelected: Selection = [];\n for (const selectedItem of selected) {\n if (Array.isArray(selectedItem)) {\n if (rangeIncludes(selectedItem, itemIndex)) {\n newSelected.push(...splitRange(selectedItem, itemIndex));\n } else {\n newSelected.push(selectedItem);\n }\n } else {\n newSelected.push(selectedItem);\n }\n }\n return newSelected;\n }\n}\n\nfunction insertRange(selected: Selection, range: RangeTuple): Selection {\n const [from, to] = range;\n return selected.reduce<Selection>((newSelected, selectedItem) => {\n if (typeof selectedItem === \"number\") {\n if (selectedItem < from || selectedItem > to) {\n newSelected.push(selectedItem);\n } else if (!includedInRange(newSelected.at(-1), selectedItem)) {\n newSelected.push(range);\n }\n } else if (overlappingRange(selectedItem, range)) {\n newSelected.push(mergeRanges(selectedItem, range));\n } else {\n if (range[1] < selectedItem[0]) {\n newSelected.push(range);\n }\n newSelected.push(selectedItem);\n }\n\n return newSelected;\n }, []);\n}\n\nconst overlappingRange = (r1: RangeTuple, r2: RangeTuple) =>\n (r1[1] >= r2[0] && r1[1] <= r2[1]) || (r1[0] >= r2[0] && r1[0] <= r2[1]);\nconst mergeRanges = (r1: RangeTuple, r2: RangeTuple): RangeTuple => [\n Math.min(r1[0], r2[0]),\n Math.max(r1[1], r2[1]),\n];\n\nconst includedInRange = (\n selectedItem: SelectionItem | undefined,\n index: number,\n) => {\n if (typeof selectedItem === \"undefined\" || typeof selectedItem === \"number\") {\n return false;\n } else return rangeIncludes(selectedItem, index);\n};\n\nconst rangeIncludes = (range: RangeTuple, index: number) =>\n index >= range[0] && index <= range[1];\n\nconst SINGLE_SELECTED_ROW =\n RowSelected.True + RowSelected.First + RowSelected.Last;\nconst FIRST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.First;\nconst LAST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.Last;\n\n/**\n * Determine the value for selected. We use a bitmap to represent a number of selection states\n * a row might exhibit. selected/not-selected is the fundamental value. We also identify first\n * row of a selected block, last row of a selected block;\n */\nexport const getSelectionStatus = (\n selected: Selection,\n itemIndex: number,\n): number => {\n for (const item of selected) {\n if (typeof item === \"number\") {\n if (item === itemIndex) {\n return SINGLE_SELECTED_ROW;\n }\n } else if (rangeIncludes(item, itemIndex)) {\n if (itemIndex === item[0]) {\n return FIRST_SELECTED_ROW_OF_BLOCK;\n } else if (itemIndex === item[1]) {\n return LAST_SELECTED_ROW_OF_BLOCK;\n } else {\n return RowSelected.True;\n }\n }\n }\n return RowSelected.False;\n};\n\nexport const isSelected = (selected: Selection, itemIndex: number) => {\n for (const item of selected) {\n if (typeof item === \"number\") {\n if (item === itemIndex) {\n return true;\n } else if (item > itemIndex) {\n return false;\n }\n } else if (rangeIncludes(item, itemIndex)) {\n return true;\n } else if (item[0] > itemIndex) {\n return false;\n }\n }\n\n return false;\n};\n/**\n * Vuu server expects a full list if indexes of selected rows. Client represents selection in a more\n * efficient structure. This converts client structure to full server format.\n */\nexport const expandSelection = (selected: Selection): number[] => {\n if (selected.every((selectedItem) => typeof selectedItem === \"number\")) {\n return selected as number[];\n }\n const expandedSelected = [];\n for (const selectedItem of selected) {\n if (typeof selectedItem === \"number\") {\n expandedSelected.push(selectedItem);\n } else {\n for (let i = selectedItem[0]; i <= selectedItem[1]; i++) {\n expandedSelected.push(i);\n }\n }\n }\n return expandedSelected;\n};\n\nfunction splitRange([from, to]: RangeTuple, itemIndex: number): Selection {\n if (itemIndex === from) {\n return [[from + 1, to]];\n } else if (itemIndex === to) {\n return [[from, to - 1]];\n } else if (to - from === 2) {\n return [from, to];\n } else if (itemIndex === to - 1) {\n return [[from, to - 2], to];\n } else {\n return [\n [from, itemIndex - 1],\n [itemIndex + 1, to],\n ];\n }\n}\n\nexport type SelectionDiff = {\n added: SelectionItem[];\n removed: SelectionItem[];\n};\n\nexport const selectionCount = (selected: Selection = NO_SELECTION) => {\n let count = selected.length;\n for (const selectionItem of selected) {\n if (Array.isArray(selectionItem)) {\n const [from, to] = selectionItem;\n // we've already counted the entry as 1, add the rest of the range\n count += to - from;\n }\n }\n return count;\n};\n"],"names":[],"mappings":";;AASA,MAAM,eAAyB,EAAC;AAEhC,MAAM,EAAE,UAAa,GAAA,YAAA;AAEd,MAAM,WAAc,GAAA;AAAA,EACzB,KAAO,EAAA,CAAA;AAAA,EACP,IAAM,EAAA,CAAA;AAAA,EACN,KAAO,EAAA,CAAA;AAAA,EACP,IAAM,EAAA;AACR;AAEa,MAAA,aAAA,GAAgB,CAAC,GAC3B,KAAA,CAAA,GAAA,CAAI,QAAQ,CAAI,GAAA,WAAA,CAAY,UAAU,WAAY,CAAA;AAExC,MAAA,iBAAA,GAAoB,CAAC,GAAA,KAChC,GAAQ,KAAA,KAAA,CAAA,IAAA,CAAc,IAAI,QAAQ,CAAA,GAAI,WAAY,CAAA,IAAA,MAAU,WAAY,CAAA;AAE1E,MAAM,gBAAA,GAAmB,CAAC,KAAA,EAAsB,KAAyB,KAAA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AA,GAAiB,CAAC,QAAA,GAAsB,YAAiB,KAAA;AACpE,EAAA,IAAI,QAAQ,QAAS,CAAA,MAAA;AACrB,EAAA,KAAA,MAAW,iBAAiB,QAAU,EAAA;AACpC,IAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,aAAa,CAAG,EAAA;AAChC,MAAM,MAAA,CAAC,IAAM,EAAA,EAAE,CAAI,GAAA,aAAA;AAEnB,MAAA,KAAA,IAAS,EAAK,GAAA,IAAA;AAAA;AAChB;AAEF,EAAO,OAAA,KAAA;AACT;;;;"}
1
+ {"version":3,"file":"selection-utils.js","sources":["../../../../../../packages/vuu-utils/src/selection-utils.ts"],"sourcesContent":["import { TableSelectionModel } from \"@vuu-ui/vuu-table-types\";\nimport { SelectRequest } from \"@vuu-ui/vuu-protocol-types\";\n\nexport const deselectItem = (\n selectionModel: TableSelectionModel,\n rowKey: string,\n rangeSelect: boolean,\n preserveExistingSelection = false,\n): Omit<SelectRequest, \"vpId\"> | undefined => {\n return {\n preserveExistingSelection,\n rowKey,\n type: \"DESELECT_ROW\",\n } as Omit<SelectRequest, \"vpId\">;\n};\n\nexport const selectItem = (\n selectionModel: TableSelectionModel,\n rowKey: string,\n rangeSelect: boolean,\n preserveExistingSelection = false,\n activeRowKey?: string,\n): Omit<SelectRequest, \"vpId\"> | undefined => {\n const singleSelect = selectionModel === \"single\";\n const actsLikeSingleSelect = singleSelect || activeRowKey === undefined;\n\n if (selectionModel === \"none\") {\n return;\n } else if (actsLikeSingleSelect) {\n return {\n preserveExistingSelection,\n rowKey,\n type: \"SELECT_ROW\",\n } as Omit<SelectRequest, \"vpId\">;\n } else if (rangeSelect) {\n return {\n preserveExistingSelection,\n fromRowKey: rowKey,\n toRowKey: activeRowKey,\n type: \"SELECT_ROW_RANGE\",\n } as Omit<SelectRequest, \"vpId\">;\n }\n};\n"],"names":[],"mappings":"AAGO,MAAM,eAAe,CAC1B,cAAA,EACA,MACA,EAAA,WAAA,EACA,4BAA4B,KACgB,KAAA;AAC5C,EAAO,OAAA;AAAA,IACL,yBAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAM,EAAA;AAAA,GACR;AACF;AAEO,MAAM,aAAa,CACxB,cAAA,EACA,QACA,WACA,EAAA,yBAAA,GAA4B,OAC5B,YAC4C,KAAA;AAC5C,EAAA,MAAM,eAAe,cAAmB,KAAA,QAAA;AACxC,EAAM,MAAA,oBAAA,GAAuB,gBAAgB,YAAiB,KAAA,KAAA,CAAA;AAE9D,EAAA,IAAI,mBAAmB,MAAQ,EAAA;AAC7B,IAAA;AAAA,aACS,oBAAsB,EAAA;AAC/B,IAAO,OAAA;AAAA,MACL,yBAAA;AAAA,MACA,MAAA;AAAA,MACA,IAAM,EAAA;AAAA,KACR;AAAA,aACS,WAAa,EAAA;AACtB,IAAO,OAAA;AAAA,MACL,yBAAA;AAAA,MACA,UAAY,EAAA,MAAA;AAAA,MACZ,QAAU,EAAA,YAAA;AAAA,MACV,IAAM,EAAA;AAAA,KACR;AAAA;AAEJ;;;;"}
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "version": "0.13.41",
2
+ "version": "0.13.43",
3
3
  "author": "heswell",
4
4
  "license": "Apache-2.0",
5
5
  "types": "types/index.d.ts",
6
6
  "devDependencies": {
7
- "@vuu-ui/vuu-data-types": "0.13.41",
8
- "@vuu-ui/vuu-table-types": "0.13.41",
9
- "@vuu-ui/vuu-filter-types": "0.13.41",
10
- "@vuu-ui/vuu-protocol-types": "0.13.41"
7
+ "@vuu-ui/vuu-data-types": "0.13.43",
8
+ "@vuu-ui/vuu-table-types": "0.13.43",
9
+ "@vuu-ui/vuu-filter-types": "0.13.43",
10
+ "@vuu-ui/vuu-protocol-types": "0.13.43"
11
11
  },
12
12
  "peerDependencies": {
13
13
  "@internationalized/date": "^3.0.0",
14
- "@vuu-ui/vuu-filter-parser": "0.13.41",
14
+ "@vuu-ui/vuu-filter-parser": "0.13.43",
15
15
  "clsx": "^2.0.0",
16
16
  "react": "^19.1.0",
17
17
  "react-dom": "^19.1.0"
@@ -1,5 +1,7 @@
1
1
  import type { MenuRpcAction, MenuRpcResponse, OpenDialogActionWithSchema, RpcResponse, TableSchema, VuuUiMessageInRequestResponse } from "@vuu-ui/vuu-data-types";
2
- import { VuuRpcMenuRequest, OpenDialogAction, VuuRpcEditCellRequest, VuuRpcRequest, VuuRpcEditAddRowRequest, VuuDataRowDto, VuuRpcEditDeleteRowRequest, VuuRpcResponse, VuuRpcMenuSuccess, VuuViewportRpcTypeaheadRequest, VuuRpcServiceRequest, ViewportRpcContext, OpenComponentInDialogAction, VuuLoginResponse, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
2
+ import { VuuRpcMenuRequest, OpenDialogAction, VuuRpcEditCellRequest, VuuRpcRequest, VuuRpcEditAddRowRequest, VuuDataRowDto, VuuRpcEditDeleteRowRequest, VuuRpcResponse, VuuRpcMenuSuccess, VuuViewportRpcTypeaheadRequest, VuuRpcServiceRequest, ViewportRpcContext, OpenComponentInDialogAction, VuuLoginResponse, VuuRowDataItemType, SelectRequest, SelectResponse, SelectSuccessWithRowCount } from "@vuu-ui/vuu-protocol-types";
3
+ export declare const isSelectRequest: (message: object) => message is SelectRequest;
4
+ export declare const isSelectSuccessWithRowCount: (response: SelectResponse | SelectSuccessWithRowCount) => response is SelectSuccessWithRowCount;
3
5
  export declare const isRpcServiceRequest: (message: {
4
6
  type: string;
5
7
  }) => message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, "context">;
@@ -1,8 +1,8 @@
1
- import type { DataSourceRow, DataSourceRowObject, Selection } from "@vuu-ui/vuu-data-types";
2
- import type { MutableRefObject } from "react";
1
+ import type { DataSourceRow, DataSourceRowObject } from "@vuu-ui/vuu-data-types";
3
2
  import { ColumnMap } from "./column-utils";
4
3
  import { IKeySet } from "./keyset";
5
4
  import { VuuRow } from "@vuu-ui/vuu-protocol-types";
5
+ import { RefObject } from "react";
6
6
  export type RowOffsetFunc = (row: DataSourceRow, pctScrollTop?: number) => number;
7
7
  export type RowAtPositionFunc = (position: number) => number;
8
8
  /**
@@ -21,7 +21,7 @@ export declare const actualRowPositioning: (rowHeight: number) => RowPositioning
21
21
  * @param pctScrollTop
22
22
  * @returns
23
23
  */
24
- export declare const virtualRowPositioning: (rowHeight: number, virtualisedExtent: number, pctScrollTop: MutableRefObject<number>) => RowPositioning;
24
+ export declare const virtualRowPositioning: (rowHeight: number, virtualisedExtent: number, pctScrollTop: RefObject<number>) => RowPositioning;
25
25
  export type RowToObjectMapper = (row: DataSourceRow, columnMap: ColumnMap) => DataSourceRowObject;
26
26
  export declare const asDataSourceRowObject: RowToObjectMapper;
27
- export declare const vuuRowToDataSourceRow: ({ rowIndex, rowKey, sel: isSelected, ts, data }: VuuRow, keys: IKeySet, selectedRows?: Selection) => DataSourceRow;
27
+ export declare const vuuRowToDataSourceRow: ({ rowIndex, rowKey, sel: isSelected, ts, data }: VuuRow, keys: IKeySet) => DataSourceRow;
@@ -1,29 +1,4 @@
1
- import { DataSourceRow, Selection, SelectionItem } from "@vuu-ui/vuu-data-types";
2
1
  import { TableSelectionModel } from "@vuu-ui/vuu-table-types";
3
- export declare const RowSelected: {
4
- False: number;
5
- True: number;
6
- First: number;
7
- Last: number;
8
- };
9
- export declare const isRowSelected: (row: DataSourceRow) => boolean;
10
- export declare const isRowSelectedLast: (row?: DataSourceRow) => boolean;
11
- export declare const deselectItem: (selectionModel: TableSelectionModel, selected: Selection, itemIndex: number, rangeSelect: boolean, keepExistingSelection?: boolean) => Selection;
12
- export declare const selectItem: (selectionModel: TableSelectionModel, selected: Selection, itemIndex: number, rangeSelect: boolean, keepExistingSelection?: boolean, activeItemIndex?: number) => Selection;
13
- /**
14
- * Determine the value for selected. We use a bitmap to represent a number of selection states
15
- * a row might exhibit. selected/not-selected is the fundamental value. We also identify first
16
- * row of a selected block, last row of a selected block;
17
- */
18
- export declare const getSelectionStatus: (selected: Selection, itemIndex: number) => number;
19
- export declare const isSelected: (selected: Selection, itemIndex: number) => boolean;
20
- /**
21
- * Vuu server expects a full list if indexes of selected rows. Client represents selection in a more
22
- * efficient structure. This converts client structure to full server format.
23
- */
24
- export declare const expandSelection: (selected: Selection) => number[];
25
- export type SelectionDiff = {
26
- added: SelectionItem[];
27
- removed: SelectionItem[];
28
- };
29
- export declare const selectionCount: (selected?: Selection) => number;
2
+ import { SelectRequest } from "@vuu-ui/vuu-protocol-types";
3
+ export declare const deselectItem: (selectionModel: TableSelectionModel, rowKey: string, rangeSelect: boolean, preserveExistingSelection?: boolean) => Omit<SelectRequest, "vpId"> | undefined;
4
+ export declare const selectItem: (selectionModel: TableSelectionModel, rowKey: string, rangeSelect: boolean, preserveExistingSelection?: boolean, activeRowKey?: string) => Omit<SelectRequest, "vpId"> | undefined;