@deephaven/jsapi-utils 1.1.1-react-v18-grid-fix.0 → 1.1.1-uri.8

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.
@@ -2,6 +2,8 @@ import { type PostMessage } from '@deephaven/utils';
2
2
  export {
3
3
  /** @deprecated Use `@deephaven/utils` `getWindowParent` instead. */
4
4
  getWindowParent,
5
+ /** @deprecated Use `@deephaven/utils` `isMessage` instead. */
6
+ isMessage,
5
7
  /** @deprecated Use `@deephaven/utils` `isResponse` instead. */
6
8
  isResponse,
7
9
  /** @deprecated Use `@deephaven/utils` `makeMessage` instead. */
@@ -1 +1 @@
1
- {"version":3,"file":"MessageUtils.d.ts","sourceRoot":"","sources":["../src/MessageUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO;AACL,oEAAoE;AACpE,eAAe;AACf,+DAA+D;AAC/D,UAAU;AACV,gEAAgE;AAChE,WAAW;AACX,iEAAiE;AACjE,YAAY;AACZ,0EAA0E;AAC1E,qBAAqB;AACrB,mEAAmE;AACnE,KAAK,WAAW,IAAI,OAAO,GAC5B,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,qBAAqB,8CACW,CAAC;AAE9C,eAAO,MAAM,uBAAuB,gDACW,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,uBAAuB,iCAAiC,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AAExE,MAAM,WAAW,qBAAsB,SAAQ,WAAW,CAAC,IAAI,CAAC;IAC9D,OAAO,EAAE,OAAO,uBAAuB,CAAC;CACzC;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW,CAAC,IAAI,CAAC;IAC/D,OAAO,EAAE,OAAO,wBAAwB,CAAC;CAC1C;AAED,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,qBAAqB,CAE9B;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,sBAAsB,CAE/B"}
1
+ {"version":3,"file":"MessageUtils.d.ts","sourceRoot":"","sources":["../src/MessageUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO;AACL,oEAAoE;AACpE,eAAe;AACf,8DAA8D;AAC9D,SAAS;AACT,+DAA+D;AAC/D,UAAU;AACV,gEAAgE;AAChE,WAAW;AACX,iEAAiE;AACjE,YAAY;AACZ,0EAA0E;AAC1E,qBAAqB;AACrB,mEAAmE;AACnE,KAAK,WAAW,IAAI,OAAO,GAC5B,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,qBAAqB,8CACW,CAAC;AAE9C,eAAO,MAAM,uBAAuB,gDACW,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,uBAAuB,iCAAiC,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AAExE,MAAM,WAAW,qBAAsB,SAAQ,WAAW,CAAC,IAAI,CAAC;IAC9D,OAAO,EAAE,OAAO,uBAAuB,CAAC;CACzC;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW,CAAC,IAAI,CAAC;IAC/D,OAAO,EAAE,OAAO,wBAAwB,CAAC;CAC1C;AAED,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,qBAAqB,CAE9B;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,sBAAsB,CAE/B"}
@@ -1,6 +1,7 @@
1
1
  import { isMessage } from '@deephaven/utils';
2
2
  export { /** @deprecated Use `@deephaven/utils` `getWindowParent` instead. */
3
- getWindowParent, /** @deprecated Use `@deephaven/utils` `isResponse` instead. */
3
+ getWindowParent, /** @deprecated Use `@deephaven/utils` `isMessage` instead. */
4
+ isMessage, /** @deprecated Use `@deephaven/utils` `isResponse` instead. */
4
5
  isResponse, /** @deprecated Use `@deephaven/utils` `makeMessage` instead. */
5
6
  makeMessage, /** @deprecated Use `@deephaven/utils` `makeResponse` instead. */
6
7
  makeResponse, /** @deprecated Use `@deephaven/utils` `requestParentResponse` instead. */
@@ -1 +1 @@
1
- {"version":3,"file":"MessageUtils.js","names":["isMessage","getWindowParent","isResponse","makeMessage","makeResponse","requestParentResponse","LOGIN_OPTIONS_REQUEST","SESSION_DETAILS_REQUEST","BROADCAST_CHANNEL_NAME","BROADCAST_LOGIN_MESSAGE","BROADCAST_LOGOUT_MESSAGE","isBroadcastLoginMessage","obj","message","isBroadcastLogoutMessage"],"sources":["../src/MessageUtils.ts"],"sourcesContent":["import { isMessage, type PostMessage } from '@deephaven/utils';\n\nexport {\n /** @deprecated Use `@deephaven/utils` `getWindowParent` instead. */\n getWindowParent,\n /** @deprecated Use `@deephaven/utils` `isResponse` instead. */\n isResponse,\n /** @deprecated Use `@deephaven/utils` `makeMessage` instead. */\n makeMessage,\n /** @deprecated Use `@deephaven/utils` `makeResponse` instead. */\n makeResponse,\n /** @deprecated Use `@deephaven/utils` `requestParentResponse` instead. */\n requestParentResponse,\n /** @deprecated Use `@deephaven/utils` `PostMessage<T>` instead. */\n type PostMessage as Message,\n} from '@deephaven/utils';\n\nexport const LOGIN_OPTIONS_REQUEST =\n 'io.deephaven.message.LoginOptions.request';\n\nexport const SESSION_DETAILS_REQUEST =\n 'io.deephaven.message.SessionDetails.request';\n\n/**\n * Use a BroadcastChannel for sending messages between tabs, such as when the user logs out.\n */\nexport const BROADCAST_CHANNEL_NAME = 'io.deephaven.broadcast';\n\n/**\n * Event emitted when the user has logged in successfully\n */\nexport const BROADCAST_LOGIN_MESSAGE = 'io.deephaven.broadcast.Login';\n\n/**\n * Event emitted when the user has logged out\n */\nexport const BROADCAST_LOGOUT_MESSAGE = 'io.deephaven.broadcast.Logout';\n\nexport interface BroadcastLoginMessage extends PostMessage<void> {\n message: typeof BROADCAST_LOGIN_MESSAGE;\n}\n\nexport interface BroadcastLogoutMessage extends PostMessage<void> {\n message: typeof BROADCAST_LOGOUT_MESSAGE;\n}\n\nexport function isBroadcastLoginMessage(\n obj: unknown\n): obj is BroadcastLoginMessage {\n return isMessage(obj) && obj.message === BROADCAST_LOGIN_MESSAGE;\n}\n\nexport function isBroadcastLogoutMessage(\n obj: unknown\n): obj is BroadcastLogoutMessage {\n return isMessage(obj) && obj.message === BROADCAST_LOGOUT_MESSAGE;\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAA0B,kBAAkB;AAE9D,SACE;AACAC,eAAe,EACf;AACAC,UAAU,EACV;AACAC,WAAW,EACX;AACAC,YAAY,EACZ;AACAC;AACA,2EAEK,kBAAkB;AAEzB,OAAO,IAAMC,qBAAqB,GAChC,2CAA2C;AAE7C,OAAO,IAAMC,uBAAuB,GAClC,6CAA6C;;AAE/C;AACA;AACA;AACA,OAAO,IAAMC,sBAAsB,GAAG,wBAAwB;;AAE9D;AACA;AACA;AACA,OAAO,IAAMC,uBAAuB,GAAG,8BAA8B;;AAErE;AACA;AACA;AACA,OAAO,IAAMC,wBAAwB,GAAG,+BAA+B;AAUvE,OAAO,SAASC,uBAAuBA,CACrCC,GAAY,EACkB;EAC9B,OAAOZ,SAAS,CAACY,GAAG,CAAC,IAAIA,GAAG,CAACC,OAAO,KAAKJ,uBAAuB;AAClE;AAEA,OAAO,SAASK,wBAAwBA,CACtCF,GAAY,EACmB;EAC/B,OAAOZ,SAAS,CAACY,GAAG,CAAC,IAAIA,GAAG,CAACC,OAAO,KAAKH,wBAAwB;AACnE"}
1
+ {"version":3,"file":"MessageUtils.js","names":["isMessage","getWindowParent","isResponse","makeMessage","makeResponse","requestParentResponse","LOGIN_OPTIONS_REQUEST","SESSION_DETAILS_REQUEST","BROADCAST_CHANNEL_NAME","BROADCAST_LOGIN_MESSAGE","BROADCAST_LOGOUT_MESSAGE","isBroadcastLoginMessage","obj","message","isBroadcastLogoutMessage"],"sources":["../src/MessageUtils.ts"],"sourcesContent":["import { isMessage, type PostMessage } from '@deephaven/utils';\n\nexport {\n /** @deprecated Use `@deephaven/utils` `getWindowParent` instead. */\n getWindowParent,\n /** @deprecated Use `@deephaven/utils` `isMessage` instead. */\n isMessage,\n /** @deprecated Use `@deephaven/utils` `isResponse` instead. */\n isResponse,\n /** @deprecated Use `@deephaven/utils` `makeMessage` instead. */\n makeMessage,\n /** @deprecated Use `@deephaven/utils` `makeResponse` instead. */\n makeResponse,\n /** @deprecated Use `@deephaven/utils` `requestParentResponse` instead. */\n requestParentResponse,\n /** @deprecated Use `@deephaven/utils` `PostMessage<T>` instead. */\n type PostMessage as Message,\n} from '@deephaven/utils';\n\nexport const LOGIN_OPTIONS_REQUEST =\n 'io.deephaven.message.LoginOptions.request';\n\nexport const SESSION_DETAILS_REQUEST =\n 'io.deephaven.message.SessionDetails.request';\n\n/**\n * Use a BroadcastChannel for sending messages between tabs, such as when the user logs out.\n */\nexport const BROADCAST_CHANNEL_NAME = 'io.deephaven.broadcast';\n\n/**\n * Event emitted when the user has logged in successfully\n */\nexport const BROADCAST_LOGIN_MESSAGE = 'io.deephaven.broadcast.Login';\n\n/**\n * Event emitted when the user has logged out\n */\nexport const BROADCAST_LOGOUT_MESSAGE = 'io.deephaven.broadcast.Logout';\n\nexport interface BroadcastLoginMessage extends PostMessage<void> {\n message: typeof BROADCAST_LOGIN_MESSAGE;\n}\n\nexport interface BroadcastLogoutMessage extends PostMessage<void> {\n message: typeof BROADCAST_LOGOUT_MESSAGE;\n}\n\nexport function isBroadcastLoginMessage(\n obj: unknown\n): obj is BroadcastLoginMessage {\n return isMessage(obj) && obj.message === BROADCAST_LOGIN_MESSAGE;\n}\n\nexport function isBroadcastLogoutMessage(\n obj: unknown\n): obj is BroadcastLogoutMessage {\n return isMessage(obj) && obj.message === BROADCAST_LOGOUT_MESSAGE;\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAA0B,kBAAkB;AAE9D,SACE;AACAC,eAAe,EACf;AACAD,SAAS,EACT;AACAE,UAAU,EACV;AACAC,WAAW,EACX;AACAC,YAAY,EACZ;AACAC;AACA,2EAEK,kBAAkB;AAEzB,OAAO,IAAMC,qBAAqB,GAChC,2CAA2C;AAE7C,OAAO,IAAMC,uBAAuB,GAClC,6CAA6C;;AAE/C;AACA;AACA;AACA,OAAO,IAAMC,sBAAsB,GAAG,wBAAwB;;AAE9D;AACA;AACA;AACA,OAAO,IAAMC,uBAAuB,GAAG,8BAA8B;;AAErE;AACA;AACA;AACA,OAAO,IAAMC,wBAAwB,GAAG,+BAA+B;AAUvE,OAAO,SAASC,uBAAuBA,CACrCC,GAAY,EACkB;EAC9B,OAAOZ,SAAS,CAACY,GAAG,CAAC,IAAIA,GAAG,CAACC,OAAO,KAAKJ,uBAAuB;AAClE;AAEA,OAAO,SAASK,wBAAwBA,CACtCF,GAAY,EACmB;EAC/B,OAAOZ,SAAS,CAACY,GAAG,CAAC,IAAIA,GAAG,CAACC,OAAO,KAAKH,wBAAwB;AACnE"}
@@ -57,7 +57,7 @@ export declare function getSize(table?: dh.Table | dh.TreeTable | null): number;
57
57
  * so will always return false.
58
58
  * @param table The table to check if it is closed.
59
59
  */
60
- export declare function isClosed(table: dh.Table | dh.TreeTable): boolean;
60
+ export declare function isClosed(table: dh.Table | dh.TreeTable | dh.Widget): boolean;
61
61
  /**
62
62
  * Determine the first and last row index for a viewport + extra leading and
63
63
  * trailing padding. Values will be "clamped" to stay within the table size.
@@ -1 +1 @@
1
- {"version":3,"file":"ViewportDataUtils.d.ts","sourceRoot":"","sources":["../src/ViewportDataUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AA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I,CAAA;CAAE,EACzE,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC,GACjC,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAqBtC;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,GAAG,EAAE,EAAE,CAAC,GAAG,EACX,OAAO,EAAE,EAAE,CAAC,MAAM,EAAE,GACnB,CAAC,CAMH;AAED;;;;;;;GAOG;AACH,wBAAiB,uBAAuB,CAAC,CAAC,EACxC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAKxC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,GAAG,MAAM,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC,MAAM,GAAG,OAAO,CAM5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,CAAC,MAAM,EAAE,MAAM,CAAC,CAQlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"ViewportDataUtils.js","names":["clamp","Log","ITEM_KEY_PREFIX","log","module","createKeyedItemKey","index","concat","createOnTableUpdatedHandler","_ref","deserializeRow","bulkUpdate","onTableUpdated","event","columns","offset","rows","detail","debug","updateKeyMap","Map","forEach","row","offsetInSnapshot","item","key","set","defaultRowDeserializer","reduce","result","col","name","get","generateEmptyKeyedItems","start","end","i","getSize","table","isClosed","size","padFirstAndLastRow","firstRow","viewportSize","padding","tableSize","lastRow","min","max","first","last"],"sources":["../src/ViewportDataUtils.ts"],"sourcesContent":["import type { Key } from 'react';\nimport clamp from 'lodash.clamp';\nimport type { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport { type KeyedItem, type ValueOf } from '@deephaven/utils';\n\nexport const ITEM_KEY_PREFIX = 'DH_ITEM_KEY';\n\nexport type OnTableUpdatedEvent = dh.Event<{\n offset: number;\n columns: dh.Column[];\n rows: dh.Row[];\n}>;\n\nexport type RowDeserializer<T> = (row: dh.Row, columns: dh.Column[]) => T;\n\nconst log = Log.module('ViewportDataUtils');\n\n/**\n * Create a `KeyedItem.key` for a given index. The prefix is necessary to avoid\n * collisions with property values in the `item` property that may be used as\n * keys once the item is loaded and rendered.\n * @param index Index to create a key for.\n * @returns A unique key for the given index.\n */\nexport function createKeyedItemKey(index: number): string {\n return `${ITEM_KEY_PREFIX}_${index}`;\n}\n\n/**\n * Creates a handler function for a `dh.Table.EVENT_UPDATED` event. Rows that\n * get passed to the handler will be bulk updated in the given `viewportData`\n * object based on their derived item keys.\n * @param viewportData State object for managing a list of KeyedItem data.\n * @param deserializeRow Converts a DH Row to an item object.\n * @returns Handler function for a `dh.Table.EVENT_UPDATED` event.\n */\nexport function createOnTableUpdatedHandler<T>(\n { bulkUpdate }: { bulkUpdate: (itemMap: Map<Key, KeyedItem<T>>) => void },\n deserializeRow: RowDeserializer<T>\n): (event: OnTableUpdatedEvent) => void {\n /**\n * Handler for a `dh.Table.EVENT_UPDATED` event.\n */\n return function onTableUpdated(event: OnTableUpdatedEvent) {\n const { columns, offset, rows } = event.detail;\n\n log.debug('table updated', event.detail);\n\n const updateKeyMap = new Map<Key, KeyedItem<T>>();\n\n rows.forEach((row, offsetInSnapshot) => {\n const item = deserializeRow(row, columns);\n const key = createKeyedItemKey(offset + offsetInSnapshot);\n updateKeyMap.set(key, { key, item });\n });\n\n log.debug('update keys', updateKeyMap);\n\n bulkUpdate(updateKeyMap);\n };\n}\n\n/**\n * Maps a Row to a key / value object. Keys are mapped ver batim from column\n * names.\n * @param row Row to map to an item.\n * @param columns Columns to map.\n * @returns A key / value object for the row.\n */\nexport function defaultRowDeserializer<T>(\n row: dh.Row,\n columns: dh.Column[]\n): T {\n return columns.reduce((result, col) => {\n // eslint-disable-next-line no-param-reassign\n result[col.name as keyof T] = row.get(col) as ValueOf<T>;\n return result;\n }, {} as T);\n}\n\n/**\n * For windowing to work, the underlying list needs to maintain a KeyedItem for\n * each row in the backing table (even if these rows haven't been loaded yet).\n * This is needed internally by react-spectrum so it can calculate the content\n * area size. This generator can create a range of empty `KeyedItem` objects.\n * @param start The starting index to generate\n * @param end The ending index to generate\n */\nexport function* generateEmptyKeyedItems<T>(\n start: number,\n end: number\n): Generator<KeyedItem<T>, void, unknown> {\n // eslint-disable-next-line no-plusplus\n for (let i = start; i <= end; ++i) {\n yield { key: createKeyedItemKey(i) };\n }\n}\n\n/**\n * Check a Table to see if it is closed before checking its size property. This\n * is important because calling Table.size on a closed table throws an error. If\n * the table is null or closed, return zero. Otherwise, return the current size.\n * @param table The table to check for its size.\n * @returns The size of the table or zero if the table is null or closed.\n */\nexport function getSize(table?: dh.Table | dh.TreeTable | null): number {\n return table == null || isClosed(table) ? 0 : table.size;\n}\n\n/**\n * Check if a given table is closed. Tree tables don't have an `isClosed` prop,\n * so will always return false.\n * @param table The table to check if it is closed.\n */\nexport function isClosed(table: dh.Table | dh.TreeTable): boolean {\n if ('isClosed' in table) {\n return table.isClosed;\n }\n\n return false;\n}\n\n/**\n * Determine the first and last row index for a viewport + extra leading and\n * trailing padding. Values will be \"clamped\" to stay within the table size.\n * @param firstRow Starting row index for the viewport.\n * @param viewportSize Size of the viewport.\n * @param padding Extra rows to add to the viewport. Will be used for leading\n * and trailing rows.\n * @param tableSize Total table size.\n * @returns Tuple containing indices for the first and last row.\n */\nexport function padFirstAndLastRow(\n firstRow: number,\n viewportSize: number,\n padding: number,\n tableSize: number\n): [number, number] {\n const lastRow = firstRow + viewportSize - 1;\n const [min, max] = [0, tableSize - 1];\n\n const first = clamp(firstRow - padding, min, max);\n const last = clamp(lastRow + padding, min, max);\n\n return [first, last];\n}\n"],"mappings":"AACA,OAAOA,KAAK,MAAM,cAAc;AAEhC,OAAOC,GAAG,MAAM,gBAAgB;AAGhC,OAAO,IAAMC,eAAe,GAAG,aAAa;AAU5C,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,mBAAmB,CAAC;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,KAAa,EAAU;EACxD,UAAAC,MAAA,CAAUL,eAAe,OAAAK,MAAA,CAAID,KAAK;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,2BAA2BA,CAAAC,IAAA,EAEzCC,cAAkC,EACI;EAAA,IAFtC;IAAEC;EAAsE,CAAC,GAAAF,IAAA;EAGzE;AACF;AACA;EACE,OAAO,SAASG,cAAcA,CAACC,KAA0B,EAAE;IACzD,IAAM;MAAEC,OAAO;MAAEC,MAAM;MAAEC;IAAK,CAAC,GAAGH,KAAK,CAACI,MAAM;IAE9Cd,GAAG,CAACe,KAAK,CAAC,eAAe,EAAEL,KAAK,CAACI,MAAM,CAAC;IAExC,IAAME,YAAY,GAAG,IAAIC,GAAG,CAAoB,CAAC;IAEjDJ,IAAI,CAACK,OAAO,CAAC,CAACC,GAAG,EAAEC,gBAAgB,KAAK;MACtC,IAAMC,IAAI,GAAGd,cAAc,CAACY,GAAG,EAAER,OAAO,CAAC;MACzC,IAAMW,GAAG,GAAGpB,kBAAkB,CAACU,MAAM,GAAGQ,gBAAgB,CAAC;MACzDJ,YAAY,CAACO,GAAG,CAACD,GAAG,EAAE;QAAEA,GAAG;QAAED;MAAK,CAAC,CAAC;IACtC,CAAC,CAAC;IAEFrB,GAAG,CAACe,KAAK,CAAC,aAAa,EAAEC,YAAY,CAAC;IAEtCR,UAAU,CAACQ,YAAY,CAAC;EAC1B,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;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GjD,KAAK,CAAC0C,QAAQ,GAAGE,OAAO,EAAEG,GAAG,EAAEC,GAAG,CAAC;EACjD,IAAME,IAAI,GAAGlD,KAAK,CAAC8C,OAAO,GAAGF,OAAO,EAAEG,GAAG,EAAEC,GAAG,CAAC;EAE/C,OAAO,CAACC,KAAK,EAAEC,IAAI,CAAC;AACtB"}
1
+ {"version":3,"file":"ViewportDataUtils.js","names":["clamp","Log","ITEM_KEY_PREFIX","log","module","createKeyedItemKey","index","concat","createOnTableUpdatedHandler","_ref","deserializeRow","bulkUpdate","onTableUpdated","event","columns","offset","rows","detail","debug","updateKeyMap","Map","forEach","row","offsetInSnapshot","item","key","set","defaultRowDeserializer","reduce","result","col","name","get","generateEmptyKeyedItems","start","end","i","getSize","table","isClosed","size","padFirstAndLastRow","firstRow","viewportSize","padding","tableSize","lastRow","min","max","first","last"],"sources":["../src/ViewportDataUtils.ts"],"sourcesContent":["import type { Key } from 'react';\nimport clamp from 'lodash.clamp';\nimport type { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport { type KeyedItem, type ValueOf } from '@deephaven/utils';\n\nexport const ITEM_KEY_PREFIX = 'DH_ITEM_KEY';\n\nexport type OnTableUpdatedEvent = dh.Event<{\n offset: number;\n columns: dh.Column[];\n rows: dh.Row[];\n}>;\n\nexport type RowDeserializer<T> = (row: dh.Row, columns: dh.Column[]) => T;\n\nconst log = Log.module('ViewportDataUtils');\n\n/**\n * Create a `KeyedItem.key` for a given index. The prefix is necessary to avoid\n * collisions with property values in the `item` property that may be used as\n * keys once the item is loaded and rendered.\n * @param index Index to create a key for.\n * @returns A unique key for the given index.\n */\nexport function createKeyedItemKey(index: number): string {\n return `${ITEM_KEY_PREFIX}_${index}`;\n}\n\n/**\n * Creates a handler function for a `dh.Table.EVENT_UPDATED` event. Rows that\n * get passed to the handler will be bulk updated in the given `viewportData`\n * object based on their derived item keys.\n * @param viewportData State object for managing a list of KeyedItem data.\n * @param deserializeRow Converts a DH Row to an item object.\n * @returns Handler function for a `dh.Table.EVENT_UPDATED` event.\n */\nexport function createOnTableUpdatedHandler<T>(\n { bulkUpdate }: { bulkUpdate: (itemMap: Map<Key, KeyedItem<T>>) => void },\n deserializeRow: RowDeserializer<T>\n): (event: OnTableUpdatedEvent) => void {\n /**\n * Handler for a `dh.Table.EVENT_UPDATED` event.\n */\n return function onTableUpdated(event: OnTableUpdatedEvent) {\n const { columns, offset, rows } = event.detail;\n\n log.debug('table updated', event.detail);\n\n const updateKeyMap = new Map<Key, KeyedItem<T>>();\n\n rows.forEach((row, offsetInSnapshot) => {\n const item = deserializeRow(row, columns);\n const key = createKeyedItemKey(offset + offsetInSnapshot);\n updateKeyMap.set(key, { key, item });\n });\n\n log.debug('update keys', updateKeyMap);\n\n bulkUpdate(updateKeyMap);\n };\n}\n\n/**\n * Maps a Row to a key / value object. Keys are mapped ver batim from column\n * names.\n * @param row Row to map to an item.\n * @param columns Columns to map.\n * @returns A key / value object for the row.\n */\nexport function defaultRowDeserializer<T>(\n row: dh.Row,\n columns: dh.Column[]\n): T {\n return columns.reduce((result, col) => {\n // eslint-disable-next-line no-param-reassign\n result[col.name as keyof T] = row.get(col) as ValueOf<T>;\n return result;\n }, {} as T);\n}\n\n/**\n * For windowing to work, the underlying list needs to maintain a KeyedItem for\n * each row in the backing table (even if these rows haven't been loaded yet).\n * This is needed internally by react-spectrum so it can calculate the content\n * area size. This generator can create a range of empty `KeyedItem` objects.\n * @param start The starting index to generate\n * @param end The ending index to generate\n */\nexport function* generateEmptyKeyedItems<T>(\n start: number,\n end: number\n): Generator<KeyedItem<T>, void, unknown> {\n // eslint-disable-next-line no-plusplus\n for (let i = start; i <= end; ++i) {\n yield { key: createKeyedItemKey(i) };\n }\n}\n\n/**\n * Check a Table to see if it is closed before checking its size property. This\n * is important because calling Table.size on a closed table throws an error. If\n * the table is null or closed, return zero. Otherwise, return the current size.\n * @param table The table to check for its size.\n * @returns The size of the table or zero if the table is null or closed.\n */\nexport function getSize(table?: dh.Table | dh.TreeTable | null): number {\n return table == null || isClosed(table) ? 0 : table.size;\n}\n\n/**\n * Check if a given table is closed. Tree tables don't have an `isClosed` prop,\n * so will always return false.\n * @param table The table to check if it is closed.\n */\nexport function isClosed(table: dh.Table | dh.TreeTable | dh.Widget): boolean {\n if ('isClosed' in table) {\n return table.isClosed;\n }\n\n return false;\n}\n\n/**\n * Determine the first and last row index for a viewport + extra leading and\n * trailing padding. Values will be \"clamped\" to stay within the table size.\n * @param firstRow Starting row index for the viewport.\n * @param viewportSize Size of the viewport.\n * @param padding Extra rows to add to the viewport. Will be used for leading\n * and trailing rows.\n * @param tableSize Total table size.\n * @returns Tuple containing indices for the first and last row.\n */\nexport function padFirstAndLastRow(\n firstRow: number,\n viewportSize: number,\n padding: number,\n tableSize: number\n): [number, number] {\n const lastRow = firstRow + viewportSize - 1;\n const [min, max] = [0, tableSize - 1];\n\n const first = clamp(firstRow - padding, min, max);\n const last = clamp(lastRow + padding, min, max);\n\n return [first, last];\n}\n"],"mappings":"AACA,OAAOA,KAAK,MAAM,cAAc;AAEhC,OAAOC,GAAG,MAAM,gBAAgB;AAGhC,OAAO,IAAMC,eAAe,GAAG,aAAa;AAU5C,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,mBAAmB,CAAC;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,KAAa,EAAU;EACxD,UAAAC,MAAA,CAAUL,eAAe,OAAAK,MAAA,CAAID,KAAK;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,2BAA2BA,CAAAC,IAAA,EAEzCC,cAAkC,EACI;EAAA,IAFtC;IAAEC;EAAsE,CAAC,GAAAF,IAAA;EAGzE;AACF;AACA;EACE,OAAO,SAASG,cAAcA,CAACC,KAA0B,EAAE;IACzD,IAAM;MAAEC,OAAO;MAAEC,MAAM;MAAEC;IAAK,CAAC,GAAGH,KAAK,CAACI,MAAM;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AAIC,QAAQ,CAACD,KAAK,CAAC,GAAG,CAAC,GAAGA,KAAK,CAACE,IAAI;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASD,QAAQA,CAACD,KAA0C,EAAW;EAC5E,IAAI,UAAU,IAAIA,KAAK,EAAE;IACvB,OAAOA,KAAK,CAACC,QAAQ;EACvB;EAEA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,kBAAkBA,CAChCC,QAAgB,EAChBC,YAAoB,EACpBC,OAAe,EACfC,SAAiB,EACC;EAClB,IAAMC,OAAO,GAAGJ,QAAQ,GAAGC,YAAY,GAAG,CAAC;EAC3C,IAAM,CAACI,GAAG,EAAEC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAEH,SAAS,GAAG,CAAC,CAAC;EAErC,IAAMI,KAAK,GAAGjD,KAAK,CAAC0C,QAAQ,GAAGE,OAAO,EAAEG,GAAG,EAAEC,GAAG,CAAC;EACjD,IAAME,IAAI,GAAGlD,KAAK,CAAC8C,OAAO,GAAGF,OAAO,EAAEG,GAAG,EAAEC,GAAG,CAAC;EAE/C,OAAO,CAACC,KAAK,EAAEC,IAAI,CAAC;AACtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/jsapi-utils",
3
- "version": "1.1.1-react-v18-grid-fix.0+4ae283c8",
3
+ "version": "1.1.1-uri.8+ea3e9c4f",
4
4
  "description": "Deephaven JSAPI Utils",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "Apache-2.0",
@@ -21,16 +21,16 @@
21
21
  "build:babel": "babel ./src --out-dir ./dist --extensions \".ts,.tsx,.js,.jsx\" --source-maps --root-mode upward"
22
22
  },
23
23
  "dependencies": {
24
- "@deephaven/filters": "^1.1.1-react-v18-grid-fix.0+4ae283c8",
24
+ "@deephaven/filters": "^1.1.1-uri.8+ea3e9c4f",
25
25
  "@deephaven/jsapi-types": "^1.0.0-dev0.39.4",
26
- "@deephaven/log": "^1.1.1-react-v18-grid-fix.0+4ae283c8",
27
- "@deephaven/utils": "^1.1.1-react-v18-grid-fix.0+4ae283c8",
26
+ "@deephaven/log": "^1.1.1-uri.8+ea3e9c4f",
27
+ "@deephaven/utils": "^1.1.1-uri.8+ea3e9c4f",
28
28
  "lodash.clamp": "^4.0.3",
29
29
  "nanoid": "^5.0.7"
30
30
  },
31
31
  "devDependencies": {
32
- "@deephaven/jsapi-shim": "^1.1.1-react-v18-grid-fix.0+4ae283c8",
33
- "@deephaven/test-utils": "^1.1.1-react-v18-grid-fix.0+4ae283c8"
32
+ "@deephaven/jsapi-shim": "^1.1.1-uri.8+ea3e9c4f",
33
+ "@deephaven/test-utils": "^1.1.1-uri.8+ea3e9c4f"
34
34
  },
35
35
  "files": [
36
36
  "dist"
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "4ae283c8a6a678dc020daa02d677a4fa979fae37"
42
+ "gitHead": "ea3e9c4f1550ecd3f01d312b4ab151b917227a01"
43
43
  }