@deephaven/jsapi-components 1.7.2-beta.1 → 1.7.2-react-18-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ColumnNameError.js.map +1 -1
- package/dist/Constants.js.map +1 -1
- package/dist/HookTestUtils.js.map +1 -1
- package/dist/TableDisconnectError.js.map +1 -1
- package/dist/TableDropdown.js +3 -4
- package/dist/TableDropdown.js.map +1 -1
- package/dist/TableInput.d.ts +0 -7
- package/dist/TableInput.d.ts.map +1 -1
- package/dist/TableInput.js +6 -13
- package/dist/TableInput.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/spectrum/ComboBox.js +2 -2
- package/dist/spectrum/ComboBox.js.map +1 -1
- package/dist/spectrum/ListView.js.map +1 -1
- package/dist/spectrum/Picker.js.map +1 -1
- package/dist/spectrum/PickerProps.js.map +1 -1
- package/dist/spectrum/index.js.map +1 -1
- package/dist/spectrum/utils/index.js.map +1 -1
- package/dist/spectrum/utils/itemUtils.js.map +1 -1
- package/dist/spectrum/utils/useItemRowDeserializer.js.map +1 -1
- package/dist/spectrum/utils/usePickerProps.js +2 -2
- package/dist/spectrum/utils/usePickerProps.js.map +1 -1
- package/dist/useBroadcastChannel.js.map +1 -1
- package/dist/useBroadcastLoginListener.js +2 -2
- package/dist/useBroadcastLoginListener.js.map +1 -1
- package/dist/useCheckIfExistsValue.js.map +1 -1
- package/dist/useDebouncedViewportSearch.js.map +1 -1
- package/dist/useDebouncedViewportSelectionFilter.js.map +1 -1
- package/dist/useFilterConditionFactories.js.map +1 -1
- package/dist/useFilteredItemsWithDefaultValue.js.map +1 -1
- package/dist/useFormatter.js.map +1 -1
- package/dist/useGetItemIndexByValue.js +1 -1
- package/dist/useGetItemIndexByValue.js.map +1 -1
- package/dist/useGetItemPosition.js +1 -1
- package/dist/useGetItemPosition.js.map +1 -1
- package/dist/useInitializeViewportData.js.map +1 -1
- package/dist/useNotNullOrEmptyFilter.js.map +1 -1
- package/dist/usePickerWithSelectedValues.d.ts +1 -1
- package/dist/usePickerWithSelectedValues.d.ts.map +1 -1
- package/dist/usePickerWithSelectedValues.js.map +1 -1
- package/dist/useSearchableViewportData.js.map +1 -1
- package/dist/useSelectDistinctTable.js +2 -2
- package/dist/useSelectDistinctTable.js.map +1 -1
- package/dist/useSetPaddedViewportCallback.js +1 -1
- package/dist/useSetPaddedViewportCallback.js.map +1 -1
- package/dist/useShowOnlyEmptyFilter.js.map +1 -1
- package/dist/useTable.d.ts.map +1 -1
- package/dist/useTable.js.map +1 -1
- package/dist/useTableColumn.js.map +1 -1
- package/dist/useTableListener.js.map +1 -1
- package/dist/useTableSize.js.map +1 -1
- package/dist/useTableUtils.js.map +1 -1
- package/dist/useValueFilter.js.map +1 -1
- package/dist/useViewportData.js +1 -1
- package/dist/useViewportData.js.map +1 -1
- package/dist/useViewportFilter.js.map +1 -1
- package/dist/useWidgetClose.js +1 -1
- package/dist/useWidgetClose.js.map +1 -1
- package/package.json +11 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDebouncedViewportSelectionFilter.js","names":["createKeyedItemKey","createSelectedValuesFilter","isSelectionMaybeInvertedEqual","useDebouncedValue","useIsEqualMemo","useMappedSelection","useMemo","useTableUtils","DEBOUNCE_MS","useDebouncedViewportSelectionFilter","_ref","viewportData","columnName","shouldSelectAllOnNoSelection","mapItemToValue","tableUtils","valuesSelection","value","debouncedValuesSelection","memoValuesSelection","selection","isInverted"],"sources":["../src/useDebouncedViewportSelectionFilter.ts"],"sourcesContent":["import {\n createKeyedItemKey,\n createSelectedValuesFilter,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport {\n isSelectionMaybeInvertedEqual,\n useDebouncedValue,\n useIsEqualMemo,\n useMappedSelection,\n type WindowedListData,\n} from '@deephaven/react-hooks';\nimport { type KeyedItem } from '@deephaven/utils';\nimport { useMemo } from 'react';\nimport useTableUtils from './useTableUtils';\n\nexport const DEBOUNCE_MS = 300;\n\nexport interface UseDebouncedViewportSelectionFilterOptions<TItem, TValue> {\n viewportData: WindowedListData<KeyedItem<TItem>>;\n columnName: string;\n shouldSelectAllOnNoSelection: boolean;\n mapItemToValue: (item: KeyedItem<TItem>) => TValue;\n}\n\n/**\n * Creates a filter factory for the current selected keys of a viewport. The\n * selected keys will be mapped to values to match in a given column name. The\n * resulting filter factory is debounced to allow some cushion for cases where\n * a user rapidly changes selections, e.g. in a checkbox list.\n */\nexport function useDebouncedViewportSelectionFilter<TItem, TValue>({\n viewportData,\n columnName,\n shouldSelectAllOnNoSelection,\n mapItemToValue,\n}: UseDebouncedViewportSelectionFilterOptions<\n TItem,\n TValue\n>): FilterConditionFactory {\n const tableUtils = useTableUtils();\n\n // Map selection to values contained in the column to filter\n const valuesSelection = useMappedSelection(\n viewportData,\n mapItemToValue,\n createKeyedItemKey\n );\n\n // Debounce so user can rapidly select multiple items in a row without the\n // cost of updating the table on each change\n const { value: debouncedValuesSelection } = useDebouncedValue(\n valuesSelection,\n DEBOUNCE_MS\n );\n\n // In cases where a user rapidly selects then deselects the selection\n // reference will change, but the state it represents will remain unchanged.\n // Memoize based on the selection value to avoid unnecessarily re-applying\n // table filters.\n const memoValuesSelection = useIsEqualMemo(\n debouncedValuesSelection,\n isSelectionMaybeInvertedEqual\n );\n\n return useMemo(\n () =>\n createSelectedValuesFilter(\n tableUtils,\n columnName,\n memoValuesSelection.selection,\n shouldSelectAllOnNoSelection,\n memoValuesSelection.isInverted\n ),\n [columnName, memoValuesSelection, shouldSelectAllOnNoSelection, tableUtils]\n );\n}\n\nexport default useDebouncedViewportSelectionFilter;\n"],"mappings":"AAAA,SACEA,kBAAkB,EAClBC,0BAA0B,QAErB,wBAAwB;AAC/B,SACEC,6BAA6B,EAC7BC,iBAAiB,EACjBC,cAAc,EACdC,kBAAkB,QAEb,wBAAwB;AAE/B,SAASC,OAAO,QAAQ,OAAO;AAAC,OACzBC,aAAa;AAEpB,OAAO,IAAMC,WAAW,GAAG,GAAG;AAS9B;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mCAAmCA,CAAAC,IAAA,EAQxB;EAAA,IARwC;IACjEC,YAAY;IACZC,UAAU;IACVC,4BAA4B;IAC5BC;EAIF,CAAC,GAAAJ,IAAA;EACC,IAAMK,UAAU,GAAGR,aAAa,CAAC,CAAC;;EAElC;EACA,IAAMS,eAAe,GAAGX,kBAAkB,CACxCM,YAAY,EACZG,cAAc,EACdd,kBACF,CAAC;;EAED;EACA;EACA,IAAM;IAAEiB,KAAK,EAAEC;EAAyB,CAAC,GAAGf,iBAAiB,CAC3Da,eAAe,EACfR,WACF,CAAC;;EAED;EACA;EACA;EACA;EACA,IAAMW,mBAAmB,GAAGf,cAAc,CACxCc,wBAAwB,EACxBhB,6BACF,CAAC;EAED,OAAOI,OAAO,CACZ,MACEL,0BAA0B,CACxBc,UAAU,EACVH,UAAU,EACVO,mBAAmB,CAACC,SAAS,EAC7BP,4BAA4B,EAC5BM,mBAAmB,CAACE,UACtB,CAAC,EACH,CAACT,UAAU,EAAEO,mBAAmB,EAAEN,4BAA4B,EAAEE,UAAU,CAC5E,CAAC;AACH;AAEA,eAAeN,mCAAmC"}
|
|
1
|
+
{"version":3,"file":"useDebouncedViewportSelectionFilter.js","names":["createKeyedItemKey","createSelectedValuesFilter","isSelectionMaybeInvertedEqual","useDebouncedValue","useIsEqualMemo","useMappedSelection","useMemo","useTableUtils","DEBOUNCE_MS","useDebouncedViewportSelectionFilter","_ref","viewportData","columnName","shouldSelectAllOnNoSelection","mapItemToValue","tableUtils","valuesSelection","value","debouncedValuesSelection","memoValuesSelection","selection","isInverted"],"sources":["../src/useDebouncedViewportSelectionFilter.ts"],"sourcesContent":["import {\n createKeyedItemKey,\n createSelectedValuesFilter,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport {\n isSelectionMaybeInvertedEqual,\n useDebouncedValue,\n useIsEqualMemo,\n useMappedSelection,\n type WindowedListData,\n} from '@deephaven/react-hooks';\nimport { type KeyedItem } from '@deephaven/utils';\nimport { useMemo } from 'react';\nimport useTableUtils from './useTableUtils';\n\nexport const DEBOUNCE_MS = 300;\n\nexport interface UseDebouncedViewportSelectionFilterOptions<TItem, TValue> {\n viewportData: WindowedListData<KeyedItem<TItem>>;\n columnName: string;\n shouldSelectAllOnNoSelection: boolean;\n mapItemToValue: (item: KeyedItem<TItem>) => TValue;\n}\n\n/**\n * Creates a filter factory for the current selected keys of a viewport. The\n * selected keys will be mapped to values to match in a given column name. The\n * resulting filter factory is debounced to allow some cushion for cases where\n * a user rapidly changes selections, e.g. in a checkbox list.\n */\nexport function useDebouncedViewportSelectionFilter<TItem, TValue>({\n viewportData,\n columnName,\n shouldSelectAllOnNoSelection,\n mapItemToValue,\n}: UseDebouncedViewportSelectionFilterOptions<\n TItem,\n TValue\n>): FilterConditionFactory {\n const tableUtils = useTableUtils();\n\n // Map selection to values contained in the column to filter\n const valuesSelection = useMappedSelection(\n viewportData,\n mapItemToValue,\n createKeyedItemKey\n );\n\n // Debounce so user can rapidly select multiple items in a row without the\n // cost of updating the table on each change\n const { value: debouncedValuesSelection } = useDebouncedValue(\n valuesSelection,\n DEBOUNCE_MS\n );\n\n // In cases where a user rapidly selects then deselects the selection\n // reference will change, but the state it represents will remain unchanged.\n // Memoize based on the selection value to avoid unnecessarily re-applying\n // table filters.\n const memoValuesSelection = useIsEqualMemo(\n debouncedValuesSelection,\n isSelectionMaybeInvertedEqual\n );\n\n return useMemo(\n () =>\n createSelectedValuesFilter(\n tableUtils,\n columnName,\n memoValuesSelection.selection,\n shouldSelectAllOnNoSelection,\n memoValuesSelection.isInverted\n ),\n [columnName, memoValuesSelection, shouldSelectAllOnNoSelection, tableUtils]\n );\n}\n\nexport default useDebouncedViewportSelectionFilter;\n"],"mappings":"AAAA,SACEA,kBAAkB,EAClBC,0BAA0B,QAErB,wBAAwB;AAC/B,SACEC,6BAA6B,EAC7BC,iBAAiB,EACjBC,cAAc,EACdC,kBAAkB,QAEb,wBAAwB;AAE/B,SAASC,OAAO,QAAQ,OAAO;AAAC,OACzBC,aAAa;AAEpB,OAAO,IAAMC,WAAW,GAAG,GAAG;AAS9B;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mCAAmCA,CAAAC,IAAA,EAQxB;EAAA,IARwC;IACjEC,YAAY;IACZC,UAAU;IACVC,4BAA4B;IAC5BC;EAIF,CAAC,GAAAJ,IAAA;EACC,IAAMK,UAAU,GAAGR,aAAa,CAAC,CAAC;;EAElC;EACA,IAAMS,eAAe,GAAGX,kBAAkB,CACxCM,YAAY,EACZG,cAAc,EACdd,kBACF,CAAC;;EAED;EACA;EACA,IAAM;IAAEiB,KAAK,EAAEC;EAAyB,CAAC,GAAGf,iBAAiB,CAC3Da,eAAe,EACfR,WACF,CAAC;;EAED;EACA;EACA;EACA;EACA,IAAMW,mBAAmB,GAAGf,cAAc,CACxCc,wBAAwB,EACxBhB,6BACF,CAAC;EAED,OAAOI,OAAO,CACZ,MACEL,0BAA0B,CACxBc,UAAU,EACVH,UAAU,EACVO,mBAAmB,CAACC,SAAS,EAC7BP,4BAA4B,EAC5BM,mBAAmB,CAACE,UACtB,CAAC,EACH,CAACT,UAAU,EAAEO,mBAAmB,EAAEN,4BAA4B,EAAEE,UAAU,CAC5E,CAAC;AACH;AAEA,eAAeN,mCAAmC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilterConditionFactories.js","names":["useMemo","removeNullAndUndefined","useFilterConditionFactories","maybeTable","_len","arguments","length","filterConditionFactories","Array","_key","map","f"],"sources":["../src/useFilterConditionFactories.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport type { FilterConditionFactory } from '@deephaven/jsapi-utils';\nimport { removeNullAndUndefined } from '@deephaven/utils';\n\nexport function useFilterConditionFactories(\n maybeTable: dh.Table | dh.TreeTable | null | undefined,\n ...filterConditionFactories: FilterConditionFactory[]\n): dh.FilterCondition[] {\n return useMemo(\n () =>\n removeNullAndUndefined(\n ...filterConditionFactories.map(f => f(maybeTable))\n ),\n // Intentionally disabling hooks check so we can spread\n // the array items as dependencies.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [maybeTable, ...filterConditionFactories]\n );\n}\n\nexport default useFilterConditionFactories;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAG/B,SAASC,sBAAsB,QAAQ,kBAAkB;AAEzD,OAAO,SAASC,2BAA2BA,CACzCC,UAAsD,EAEhC;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EADnBC,wBAAwB,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAxBF,wBAAwB,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;EAAA;EAE3B,OAAOT,OAAO,CACZ,MACEC,sBAAsB,CACpB,GAAGM,wBAAwB,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACR,UAAU,CAAC,CACpD,CAAC;EACH;EACA;EACA;EACA,CAACA,UAAU,EAAE,GAAGI,wBAAwB,CAC1C,CAAC;AACH;AAEA,eAAeL,2BAA2B"}
|
|
1
|
+
{"version":3,"file":"useFilterConditionFactories.js","names":["useMemo","removeNullAndUndefined","useFilterConditionFactories","maybeTable","_len","arguments","length","filterConditionFactories","Array","_key","map","f"],"sources":["../src/useFilterConditionFactories.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport type { FilterConditionFactory } from '@deephaven/jsapi-utils';\nimport { removeNullAndUndefined } from '@deephaven/utils';\n\nexport function useFilterConditionFactories(\n maybeTable: dh.Table | dh.TreeTable | null | undefined,\n ...filterConditionFactories: FilterConditionFactory[]\n): dh.FilterCondition[] {\n return useMemo(\n () =>\n removeNullAndUndefined(\n ...filterConditionFactories.map(f => f(maybeTable))\n ),\n // Intentionally disabling hooks check so we can spread\n // the array items as dependencies.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [maybeTable, ...filterConditionFactories]\n );\n}\n\nexport default useFilterConditionFactories;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAG/B,SAASC,sBAAsB,QAAQ,kBAAkB;AAEzD,OAAO,SAASC,2BAA2BA,CACzCC,UAAsD,EAEhC;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EADnBC,wBAAwB,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAxBF,wBAAwB,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;EAAA;EAE3B,OAAOT,OAAO,CACZ,MACEC,sBAAsB,CACpB,GAAGM,wBAAwB,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACR,UAAU,CAAC,CACpD,CAAC;EACH;EACA;EACA;EACA,CAACA,UAAU,EAAE,GAAGI,wBAAwB,CAC1C,CAAC;AACH;AAEA,eAAeL,2BAA2B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilteredItemsWithDefaultValue.js","names":["useMemo","useRef","useFilteredItemsWithDefaultValue","items","displayProp","searchText","defaultDisplayValue","searchTextRef","current","isLoading","length","item","toLowerCase","includes","key"],"sources":["../src/useFilteredItemsWithDefaultValue.ts"],"sourcesContent":["import { useMemo, useRef } from 'react';\nimport { type KeyedItem } from '@deephaven/utils';\n\n/**\n * Takes an array of items and adds a default item to the top of the list if:\n * 1. defaultDisplayValue is provided\n * 2. The `searchText` is empty or\n * The `searchText` is contained (case insensitive) in the default item display text.\n * @param items List of items filtered on `searchText`\n * @param displayProp The item prop containing display text\n * @param searchText The current search text that is filtering the items\n * @param defaultDisplayValue The display text to set as the default item `displayProp` value\n */\nexport function useFilteredItemsWithDefaultValue<\n TItem,\n TProp extends keyof TItem,\n>(\n items: KeyedItem<TItem>[],\n displayProp: TProp,\n searchText: string,\n defaultDisplayValue?: string | null\n): KeyedItem<TItem>[] {\n // Exclude search text from updating the memo. This ensures that adding /\n // removing of the default item stays in sync with data loading. Otherwise,\n // the item can move while data is still loading.\n const searchTextRef = useRef('');\n searchTextRef.current = searchText;\n\n return useMemo(() => {\n // If the list is still loading, items will exist, but their item prop will be undefined\n const isLoading = items.length > 0 && items[0].item == null;\n\n if (\n !isLoading &&\n defaultDisplayValue != null &&\n (searchTextRef.current === '' ||\n defaultDisplayValue\n .toLowerCase()\n .includes(searchTextRef.current.toLowerCase()))\n ) {\n return [\n {\n key: defaultDisplayValue,\n item: { [displayProp]: defaultDisplayValue } as TItem,\n },\n ...items,\n ];\n }\n\n return items;\n }, [defaultDisplayValue, displayProp, items]);\n}\n\nexport default useFilteredItemsWithDefaultValue;\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAGvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gCAAgCA,CAI9CC,KAAyB,EACzBC,WAAkB,EAClBC,UAAkB,EAClBC,mBAAmC,EACf;EACpB;EACA;EACA;EACA,IAAMC,aAAa,GAAGN,MAAM,CAAC,EAAE,CAAC;EAChCM,aAAa,CAACC,OAAO,GAAGH,UAAU;EAElC,OAAOL,OAAO,CAAC,MAAM;IACnB;IACA,IAAMS,SAAS,GAAGN,KAAK,CAACO,MAAM,GAAG,CAAC,IAAIP,KAAK,CAAC,CAAC,CAAC,CAACQ,IAAI,IAAI,IAAI;IAE3D,IACE,CAACF,SAAS,IACVH,mBAAmB,IAAI,IAAI,KAC1BC,aAAa,CAACC,OAAO,KAAK,EAAE,IAC3BF,mBAAmB,CAChBM,WAAW,CAAC,CAAC,CACbC,QAAQ,CAACN,aAAa,CAACC,OAAO,CAACI,WAAW,CAAC,CAAC,CAAC,CAAC,EACnD;MACA,OAAO,CACL;QACEE,GAAG,EAAER,mBAAmB;QACxBK,IAAI,EAAE;UAAE,CAACP,WAAW,GAAGE;QAAoB;MAC7C,CAAC,EACD,GAAGH,KAAK,CACT;IACH;IAEA,OAAOA,KAAK;EACd,CAAC,EAAE,CAACG,mBAAmB,EAAEF,WAAW,EAAED,KAAK,CAAC,CAAC;AAC/C;AAEA,eAAeD,gCAAgC"}
|
|
1
|
+
{"version":3,"file":"useFilteredItemsWithDefaultValue.js","names":["useMemo","useRef","useFilteredItemsWithDefaultValue","items","displayProp","searchText","defaultDisplayValue","searchTextRef","current","isLoading","length","item","toLowerCase","includes","key"],"sources":["../src/useFilteredItemsWithDefaultValue.ts"],"sourcesContent":["import { useMemo, useRef } from 'react';\nimport { type KeyedItem } from '@deephaven/utils';\n\n/**\n * Takes an array of items and adds a default item to the top of the list if:\n * 1. defaultDisplayValue is provided\n * 2. The `searchText` is empty or\n * The `searchText` is contained (case insensitive) in the default item display text.\n * @param items List of items filtered on `searchText`\n * @param displayProp The item prop containing display text\n * @param searchText The current search text that is filtering the items\n * @param defaultDisplayValue The display text to set as the default item `displayProp` value\n */\nexport function useFilteredItemsWithDefaultValue<\n TItem,\n TProp extends keyof TItem,\n>(\n items: KeyedItem<TItem>[],\n displayProp: TProp,\n searchText: string,\n defaultDisplayValue?: string | null\n): KeyedItem<TItem>[] {\n // Exclude search text from updating the memo. This ensures that adding /\n // removing of the default item stays in sync with data loading. Otherwise,\n // the item can move while data is still loading.\n const searchTextRef = useRef('');\n searchTextRef.current = searchText;\n\n return useMemo(() => {\n // If the list is still loading, items will exist, but their item prop will be undefined\n const isLoading = items.length > 0 && items[0].item == null;\n\n if (\n !isLoading &&\n defaultDisplayValue != null &&\n (searchTextRef.current === '' ||\n defaultDisplayValue\n .toLowerCase()\n .includes(searchTextRef.current.toLowerCase()))\n ) {\n return [\n {\n key: defaultDisplayValue,\n item: { [displayProp]: defaultDisplayValue } as TItem,\n },\n ...items,\n ];\n }\n\n return items;\n }, [defaultDisplayValue, displayProp, items]);\n}\n\nexport default useFilteredItemsWithDefaultValue;\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAGvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gCAAgCA,CAI9CC,KAAyB,EACzBC,WAAkB,EAClBC,UAAkB,EAClBC,mBAAmC,EACf;EACpB;EACA;EACA;EACA,IAAMC,aAAa,GAAGN,MAAM,CAAC,EAAE,CAAC;EAChCM,aAAa,CAACC,OAAO,GAAGH,UAAU;EAElC,OAAOL,OAAO,CAAC,MAAM;IACnB;IACA,IAAMS,SAAS,GAAGN,KAAK,CAACO,MAAM,GAAG,CAAC,IAAIP,KAAK,CAAC,CAAC,CAAC,CAACQ,IAAI,IAAI,IAAI;IAE3D,IACE,CAACF,SAAS,IACVH,mBAAmB,IAAI,IAAI,KAC1BC,aAAa,CAACC,OAAO,KAAK,EAAE,IAC3BF,mBAAmB,CAChBM,WAAW,CAAC,CAAC,CACbC,QAAQ,CAACN,aAAa,CAACC,OAAO,CAACI,WAAW,CAAC,CAAC,CAAC,CAAC,EACnD;MACA,OAAO,CACL;QACEE,GAAG,EAAER,mBAAmB;QACxBK,IAAI,EAAE;UAAE,CAACP,WAAW,GAAGE;QAAoB;MAC7C,CAAC,EACD,GAAGH,KAAK,CACT;IACH;IAEA,OAAOA,KAAK;EACd,CAAC,EAAE,CAACG,mBAAmB,EAAEF,WAAW,EAAED,KAAK,CAAC,CAAC;AAC/C;AAEA,eAAeD,gCAAgC","ignoreList":[]}
|
package/dist/useFormatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormatter.js","names":["useApi","createFormatterFromSettings","bindAllMethods","useMemo","useFormatter","settings","dh","formatter","instance","getColumnFormat","getColumnFormatMapForType","getColumnTypeFormatter","getFormattedString","timeZone"],"sources":["../src/useFormatter.ts"],"sourcesContent":["import { useApi } from '@deephaven/jsapi-bootstrap';\nimport {\n createFormatterFromSettings,\n type Formatter,\n type Settings,\n} from '@deephaven/jsapi-utils';\nimport { bindAllMethods } from '@deephaven/utils';\nimport { useMemo } from 'react';\n\nexport type UseFormatterResult = Pick<\n Formatter,\n | 'getColumnFormat'\n | 'getColumnFormatMapForType'\n | 'getColumnTypeFormatter'\n | 'getFormattedString'\n | 'timeZone'\n>;\n\n/**\n * Returns a subset of members of a `Formatter` instance. The `Formatter` will be\n * constructed based on the given options or fallback to the configuration found\n * in the current `FormatSettingsContext`. Members that are functions are bound\n * to the `Formatter` instance, so they are safe to destructure. Static methods\n * can still be accessed statically from the `Formatter` class.\n * @param settings Optional settings to use when constructing the `Formatter`\n */\nexport function useFormatter(settings?: Settings): UseFormatterResult {\n const dh = useApi();\n\n const formatter = useMemo(() => {\n const instance = createFormatterFromSettings(dh, settings);\n\n // Bind all methods so we can destructure them\n bindAllMethods(instance);\n\n return instance;\n }, [dh, settings]);\n\n const {\n getColumnFormat,\n getColumnFormatMapForType,\n getColumnTypeFormatter,\n getFormattedString,\n } = formatter;\n\n return {\n getColumnFormat,\n getColumnFormatMapForType,\n getColumnTypeFormatter,\n getFormattedString,\n timeZone: formatter.timeZone,\n };\n}\n\nexport default useFormatter;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,4BAA4B;AACnD,SACEC,2BAA2B,QAGtB,wBAAwB;AAC/B,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,OAAO,QAAQ,OAAO;AAW/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,QAAmB,EAAsB;EACpE,IAAMC,EAAE,GAAGN,MAAM,CAAC,CAAC;EAEnB,IAAMO,SAAS,GAAGJ,OAAO,CAAC,MAAM;IAC9B,IAAMK,QAAQ,GAAGP,2BAA2B,CAACK,EAAE,EAAED,QAAQ,CAAC;;IAE1D;IACAH,cAAc,CAACM,QAAQ,CAAC;IAExB,OAAOA,QAAQ;EACjB,CAAC,EAAE,CAACF,EAAE,EAAED,QAAQ,CAAC,CAAC;EAElB,IAAM;IACJI,eAAe;IACfC,yBAAyB;IACzBC,sBAAsB;IACtBC;EACF,CAAC,GAAGL,SAAS;EAEb,OAAO;IACLE,eAAe;IACfC,yBAAyB;IACzBC,sBAAsB;IACtBC,kBAAkB;IAClBC,QAAQ,EAAEN,SAAS,CAACM;EACtB,CAAC;AACH;AAEA,eAAeT,YAAY"}
|
|
1
|
+
{"version":3,"file":"useFormatter.js","names":["useApi","createFormatterFromSettings","bindAllMethods","useMemo","useFormatter","settings","dh","formatter","instance","getColumnFormat","getColumnFormatMapForType","getColumnTypeFormatter","getFormattedString","timeZone"],"sources":["../src/useFormatter.ts"],"sourcesContent":["import { useApi } from '@deephaven/jsapi-bootstrap';\nimport {\n createFormatterFromSettings,\n type Formatter,\n type Settings,\n} from '@deephaven/jsapi-utils';\nimport { bindAllMethods } from '@deephaven/utils';\nimport { useMemo } from 'react';\n\nexport type UseFormatterResult = Pick<\n Formatter,\n | 'getColumnFormat'\n | 'getColumnFormatMapForType'\n | 'getColumnTypeFormatter'\n | 'getFormattedString'\n | 'timeZone'\n>;\n\n/**\n * Returns a subset of members of a `Formatter` instance. The `Formatter` will be\n * constructed based on the given options or fallback to the configuration found\n * in the current `FormatSettingsContext`. Members that are functions are bound\n * to the `Formatter` instance, so they are safe to destructure. Static methods\n * can still be accessed statically from the `Formatter` class.\n * @param settings Optional settings to use when constructing the `Formatter`\n */\nexport function useFormatter(settings?: Settings): UseFormatterResult {\n const dh = useApi();\n\n const formatter = useMemo(() => {\n const instance = createFormatterFromSettings(dh, settings);\n\n // Bind all methods so we can destructure them\n bindAllMethods(instance);\n\n return instance;\n }, [dh, settings]);\n\n const {\n getColumnFormat,\n getColumnFormatMapForType,\n getColumnTypeFormatter,\n getFormattedString,\n } = formatter;\n\n return {\n getColumnFormat,\n getColumnFormatMapForType,\n getColumnTypeFormatter,\n getFormattedString,\n timeZone: formatter.timeZone,\n };\n}\n\nexport default useFormatter;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,4BAA4B;AACnD,SACEC,2BAA2B,QAGtB,wBAAwB;AAC/B,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,OAAO,QAAQ,OAAO;AAW/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,QAAmB,EAAsB;EACpE,IAAMC,EAAE,GAAGN,MAAM,CAAC,CAAC;EAEnB,IAAMO,SAAS,GAAGJ,OAAO,CAAC,MAAM;IAC9B,IAAMK,QAAQ,GAAGP,2BAA2B,CAACK,EAAE,EAAED,QAAQ,CAAC;;IAE1D;IACAH,cAAc,CAACM,QAAQ,CAAC;IAExB,OAAOA,QAAQ;EACjB,CAAC,EAAE,CAACF,EAAE,EAAED,QAAQ,CAAC,CAAC;EAElB,IAAM;IACJI,eAAe;IACfC,yBAAyB;IACzBC,sBAAsB;IACtBC;EACF,CAAC,GAAGL,SAAS;EAEb,OAAO;IACLE,eAAe;IACfC,yBAAyB;IACzBC,sBAAsB;IACtBC,kBAAkB;IAClBC,QAAQ,EAAEN,SAAS,CAACM;EACtB,CAAC;AACH;AAEA,eAAeT,YAAY","ignoreList":[]}
|
|
@@ -18,7 +18,7 @@ export function useGetItemIndexByValue(_ref) {
|
|
|
18
18
|
table
|
|
19
19
|
} = _ref;
|
|
20
20
|
var tableUtils = useTableUtils();
|
|
21
|
-
return useCallback(
|
|
21
|
+
return useCallback(/*#__PURE__*/_asyncToGenerator(function* () {
|
|
22
22
|
if (table == null || value == null || columnName == null) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetItemIndexByValue.js","names":["useCallback","useTableUtils","useGetItemIndexByValue","_ref","columnName","value","table","tableUtils","_asyncToGenerator","column","findColumn","columnValueType","getValueType","type","index","seekRow"],"sources":["../src/useGetItemIndexByValue.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { type dh } from '@deephaven/jsapi-types';\nimport { useTableUtils } from './useTableUtils';\n\n/**\n * Returns a function that gets the index of the first row containing a column\n * value.\n * @param columnName The name of the column to search\n * @param value The value to search for\n * @param table The table to search in\n * @returns A function that returns the index of the first row containing the\n * matching value, or `null` if no match is found\n */\nexport function useGetItemIndexByValue<TValue>({\n columnName,\n value,\n table,\n}: {\n columnName: string | null;\n table: dh.Table | null;\n value: TValue | null | undefined;\n}): () => Promise<number | null> {\n const tableUtils = useTableUtils();\n\n return useCallback(async () => {\n if (table == null || value == null || columnName == null) {\n return null;\n }\n\n const column = table.findColumn(columnName);\n const columnValueType = tableUtils.getValueType(column.type);\n\n const index = await table.seekRow(0, column, columnValueType, value);\n return index === -1 ? null : index;\n }, [columnName, table, tableUtils, value]);\n}\n\nexport default useGetItemIndexByValue;\n"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AAAC,SAE3BC,aAAa;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAAAC,IAAA,EAQL;EAAA,IARc;IAC7CC,UAAU;IACVC,KAAK;IACLC;EAKF,CAAC,GAAAH,IAAA;EACC,IAAMI,UAAU,GAAGN,aAAa,CAAC,CAAC;EAElC,OAAOD,WAAW,
|
|
1
|
+
{"version":3,"file":"useGetItemIndexByValue.js","names":["useCallback","useTableUtils","useGetItemIndexByValue","_ref","columnName","value","table","tableUtils","_asyncToGenerator","column","findColumn","columnValueType","getValueType","type","index","seekRow"],"sources":["../src/useGetItemIndexByValue.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { type dh } from '@deephaven/jsapi-types';\nimport { useTableUtils } from './useTableUtils';\n\n/**\n * Returns a function that gets the index of the first row containing a column\n * value.\n * @param columnName The name of the column to search\n * @param value The value to search for\n * @param table The table to search in\n * @returns A function that returns the index of the first row containing the\n * matching value, or `null` if no match is found\n */\nexport function useGetItemIndexByValue<TValue>({\n columnName,\n value,\n table,\n}: {\n columnName: string | null;\n table: dh.Table | null;\n value: TValue | null | undefined;\n}): () => Promise<number | null> {\n const tableUtils = useTableUtils();\n\n return useCallback(async () => {\n if (table == null || value == null || columnName == null) {\n return null;\n }\n\n const column = table.findColumn(columnName);\n const columnValueType = tableUtils.getValueType(column.type);\n\n const index = await table.seekRow(0, column, columnValueType, value);\n return index === -1 ? null : index;\n }, [columnName, table, tableUtils, value]);\n}\n\nexport default useGetItemIndexByValue;\n"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AAAC,SAE3BC,aAAa;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAAAC,IAAA,EAQL;EAAA,IARc;IAC7CC,UAAU;IACVC,KAAK;IACLC;EAKF,CAAC,GAAAH,IAAA;EACC,IAAMI,UAAU,GAAGN,aAAa,CAAC,CAAC;EAElC,OAAOD,WAAW,cAAAQ,iBAAA,CAAC,aAAY;IAC7B,IAAIF,KAAK,IAAI,IAAI,IAAID,KAAK,IAAI,IAAI,IAAID,UAAU,IAAI,IAAI,EAAE;MACxD,OAAO,IAAI;IACb;IAEA,IAAMK,MAAM,GAAGH,KAAK,CAACI,UAAU,CAACN,UAAU,CAAC;IAC3C,IAAMO,eAAe,GAAGJ,UAAU,CAACK,YAAY,CAACH,MAAM,CAACI,IAAI,CAAC;IAE5D,IAAMC,KAAK,SAASR,KAAK,CAACS,OAAO,CAAC,CAAC,EAAEN,MAAM,EAAEE,eAAe,EAAEN,KAAK,CAAC;IACpE,OAAOS,KAAK,KAAK,CAAC,CAAC,GAAG,IAAI,GAAGA,KAAK;EACpC,CAAC,GAAE,CAACV,UAAU,EAAEE,KAAK,EAAEC,UAAU,EAAEF,KAAK,CAAC,CAAC;AAC5C;AAEA,eAAeH,sBAAsB","ignoreList":[]}
|
|
@@ -20,7 +20,7 @@ export function useGetItemPosition(_ref) {
|
|
|
20
20
|
topOffset = 0,
|
|
21
21
|
value
|
|
22
22
|
} = _ref;
|
|
23
|
-
return useCallback(
|
|
23
|
+
return useCallback(/*#__PURE__*/_asyncToGenerator(function* () {
|
|
24
24
|
if (table == null || value === '' || value === defaultValue) {
|
|
25
25
|
return topOffset;
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetItemPosition.js","names":["useCallback","useGetItemPosition","_ref","table","columnName","defaultValue","itemHeight","topOffset","value","_asyncToGenerator","column","findColumn","rowIndex","seekRow","defaultItemOffset"],"sources":["../src/useGetItemPosition.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\n\nexport interface UseGetItemPositionOptions {\n table?: dh.Table | null;\n columnName: string;\n defaultValue?: string | null;\n itemHeight: number;\n topOffset?: number;\n value: string;\n}\n\n/**\n * Gets an item's position in a list of items based on its row index in a table.\n * @param table Table to search for the item in\n * @param columnName Column name to search for the item in\n * @param defaultValue Optional default value. This would be the first item in\n * the list and not expected to be in the Table.\n * @param itemHeight Height of each item in the list\n * @param topOffset Optional pixel offset from the top of the list\n * @param value Value to search for in the column\n */\nexport function useGetItemPosition({\n table,\n columnName,\n defaultValue,\n itemHeight,\n topOffset = 0,\n value,\n}: UseGetItemPositionOptions): () => Promise<number> {\n return useCallback(async () => {\n if (table == null || value === '' || value === defaultValue) {\n return topOffset;\n }\n\n const column = table.findColumn(columnName);\n const rowIndex = await table.seekRow(0, column, 'String', value);\n\n // If a default item exists at the top of the list, offset the item index by 1\n const defaultItemOffset = defaultValue == null ? 0 : 1;\n\n return (rowIndex + defaultItemOffset) * itemHeight + topOffset;\n }, [columnName, defaultValue, itemHeight, table, topOffset, value]);\n}\n\nexport default useGetItemPosition;\n"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AAYnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAAC,IAAA,EAOmB;EAAA,IAPlB;IACjCC,KAAK;IACLC,UAAU;IACVC,YAAY;IACZC,UAAU;IACVC,SAAS,GAAG,CAAC;IACbC;EACyB,CAAC,GAAAN,IAAA;EAC1B,OAAOF,WAAW,
|
|
1
|
+
{"version":3,"file":"useGetItemPosition.js","names":["useCallback","useGetItemPosition","_ref","table","columnName","defaultValue","itemHeight","topOffset","value","_asyncToGenerator","column","findColumn","rowIndex","seekRow","defaultItemOffset"],"sources":["../src/useGetItemPosition.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\n\nexport interface UseGetItemPositionOptions {\n table?: dh.Table | null;\n columnName: string;\n defaultValue?: string | null;\n itemHeight: number;\n topOffset?: number;\n value: string;\n}\n\n/**\n * Gets an item's position in a list of items based on its row index in a table.\n * @param table Table to search for the item in\n * @param columnName Column name to search for the item in\n * @param defaultValue Optional default value. This would be the first item in\n * the list and not expected to be in the Table.\n * @param itemHeight Height of each item in the list\n * @param topOffset Optional pixel offset from the top of the list\n * @param value Value to search for in the column\n */\nexport function useGetItemPosition({\n table,\n columnName,\n defaultValue,\n itemHeight,\n topOffset = 0,\n value,\n}: UseGetItemPositionOptions): () => Promise<number> {\n return useCallback(async () => {\n if (table == null || value === '' || value === defaultValue) {\n return topOffset;\n }\n\n const column = table.findColumn(columnName);\n const rowIndex = await table.seekRow(0, column, 'String', value);\n\n // If a default item exists at the top of the list, offset the item index by 1\n const defaultItemOffset = defaultValue == null ? 0 : 1;\n\n return (rowIndex + defaultItemOffset) * itemHeight + topOffset;\n }, [columnName, defaultValue, itemHeight, table, topOffset, value]);\n}\n\nexport default useGetItemPosition;\n"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AAYnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAAC,IAAA,EAOmB;EAAA,IAPlB;IACjCC,KAAK;IACLC,UAAU;IACVC,YAAY;IACZC,UAAU;IACVC,SAAS,GAAG,CAAC;IACbC;EACyB,CAAC,GAAAN,IAAA;EAC1B,OAAOF,WAAW,cAAAS,iBAAA,CAAC,aAAY;IAC7B,IAAIN,KAAK,IAAI,IAAI,IAAIK,KAAK,KAAK,EAAE,IAAIA,KAAK,KAAKH,YAAY,EAAE;MAC3D,OAAOE,SAAS;IAClB;IAEA,IAAMG,MAAM,GAAGP,KAAK,CAACQ,UAAU,CAACP,UAAU,CAAC;IAC3C,IAAMQ,QAAQ,SAAST,KAAK,CAACU,OAAO,CAAC,CAAC,EAAEH,MAAM,EAAE,QAAQ,EAAEF,KAAK,CAAC;;IAEhE;IACA,IAAMM,iBAAiB,GAAGT,YAAY,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC;IAEtD,OAAO,CAACO,QAAQ,GAAGE,iBAAiB,IAAIR,UAAU,GAAGC,SAAS;EAChE,CAAC,GAAE,CAACH,UAAU,EAAEC,YAAY,EAAEC,UAAU,EAAEH,KAAK,EAAEI,SAAS,EAAEC,KAAK,CAAC,CAAC;AACrE;AAEA,eAAeP,kBAAkB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitializeViewportData.js","names":["useEffect","generateEmptyKeyedItems","useWindowedListData","Log","useTableSize","log","module","resizeItemsArray","_ref","items","targetSize","reuseExistingItems","currentSize","length","debug","Array","from","slice","useInitializeViewportData","table","reuseItemsOnTableResize","arguments","undefined","viewportData","Math","max","setItems"],"sources":["../src/useInitializeViewportData.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { generateEmptyKeyedItems } from '@deephaven/jsapi-utils';\nimport {\n useWindowedListData,\n type WindowedListData,\n} from '@deephaven/react-hooks';\nimport { type KeyedItem } from '@deephaven/utils';\nimport Log from '@deephaven/log';\nimport useTableSize from './useTableSize';\n\nconst log = Log.module('useInitializeViewportData');\n\n/**\n * Given an array of items, returns a new array containing the target number of\n * items. If reuseExistingItems is true, existing items will be re-used. If\n * false, all items will be replaced with new, empty items.\n * @param items The array of items to resize.\n * @param targetSize The desired size of the array.\n * @param reuseExistingItems If true, existing items will be re-used. If false,\n * all items will be replaced with new, empty items.\n * @returns The resized array of items.\n */\nfunction resizeItemsArray<T>({\n items,\n targetSize,\n reuseExistingItems,\n}: {\n items: KeyedItem<T, string>[];\n reuseExistingItems: boolean;\n targetSize: number;\n}): KeyedItem<T, string>[] {\n const currentSize = items.length;\n\n // If size isn't changing, do nothing\n if (currentSize === targetSize) {\n return items;\n }\n\n log.debug('size changed:', { currentSize, targetSize });\n\n // Re-create entire array with empty items\n if (!reuseExistingItems) {\n return Array.from(generateEmptyKeyedItems<T>(0, targetSize - 1));\n }\n\n // Drop extra items\n if (currentSize > targetSize) {\n return items.slice(0, targetSize);\n }\n\n // Add missing items\n return [...items, ...generateEmptyKeyedItems<T>(currentSize, targetSize - 1)];\n}\n\n/**\n * Initializes a ListData instance that can be used for windowed views of a\n * Table. The list must always contain a KeyedItem for every record in the table,\n * so it is pre-populated with empty items that can be updated with real data as\n * the window changes.\n *\n * IMPORTANT: this will create an empty KeyedItem object for every row in the\n * source table. This is intended for \"human\" sized tables such as those used in\n * admin panels. This is not suitable for \"machine\" scale with millions+ rows.\n * @param table The table that will be used to determine the list size.\n * @param reuseItemsOnTableResize Whether to reuse existing items when the table\n * size changes (defaults to false).\n * - If true, existing items will be reused when the table resizes. This is\n * recommended for ticking tables where the data is frequently updated in order\n * to avoid UI flicker.\n * - If false, all of the items will be replaced when the table resizes. This is\n * recommnded for tables that don't change size frequently but may change size\n * due to a user interaction. e.g. Filter via a search input. This avoids a\n * different kind of flicker, where the item values will shift around as the\n * user types. It is less jarring for the items to all reset to empty and then\n * show the new results all at once.\n * @returns a WindowedListData object.\n */\nexport function useInitializeViewportData<T>(\n table: dh.Table | dh.TreeTable | null,\n reuseItemsOnTableResize = false\n): WindowedListData<KeyedItem<T>> {\n const viewportData = useWindowedListData<KeyedItem<T>>({});\n\n // If the table changes size, we need to re-initialize it.\n const targetSize = Math.max(0, useTableSize(table));\n\n // Whenever the table reference or size changes, resize the list.\n useEffect(() => {\n viewportData.setItems(\n resizeItemsArray({\n items: viewportData.items,\n targetSize,\n reuseExistingItems: reuseItemsOnTableResize,\n })\n );\n\n // Intentionally excluding viewportData since it changes on every render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [targetSize, table]);\n\n return viewportData;\n}\n\nexport default useInitializeViewportData;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,uBAAuB,QAAQ,wBAAwB;AAChE,SACEC,mBAAmB,QAEd,wBAAwB;AAE/B,OAAOC,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,YAAY;AAEnB,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,2BAA2B,CAAC;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAAAC,IAAA,EAQE;EAAA,IARE;IAC3BC,KAAK;IACLC,UAAU;IACVC;EAKF,CAAC,GAAAH,IAAA;EACC,IAAMI,WAAW,GAAGH,KAAK,CAACI,MAAM;;EAEhC;EACA,IAAID,WAAW,KAAKF,UAAU,EAAE;IAC9B,OAAOD,KAAK;EACd;EAEAJ,GAAG,CAACS,KAAK,CAAC,eAAe,EAAE;IAAEF,WAAW;IAAEF;EAAW,CAAC,CAAC;;EAEvD;EACA,IAAI,CAACC,kBAAkB,EAAE;IACvB,OAAOI,KAAK,CAACC,IAAI,CAACf,uBAAuB,CAAI,CAAC,EAAES,UAAU,GAAG,CAAC,CAAC,CAAC;EAClE;;EAEA;EACA,IAAIE,WAAW,GAAGF,UAAU,EAAE;IAC5B,OAAOD,KAAK,CAACQ,KAAK,CAAC,CAAC,EAAEP,UAAU,CAAC;EACnC;;EAEA;EACA,OAAO,CAAC,GAAGD,KAAK,EAAE,GAAGR,uBAAuB,CAAIW,WAAW,EAAEF,UAAU,GAAG,CAAC,CAAC,CAAC;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,yBAAyBA,CACvCC,KAAqC,EAEL;EAAA,IADhCC,uBAAuB,GAAAC,SAAA,CAAAR,MAAA,QAAAQ,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,KAAK;EAE/B,IAAME,YAAY,GAAGrB,mBAAmB,CAAe,CAAC,CAAC,CAAC;;EAE1D;EACA,IAAMQ,UAAU,GAAGc,IAAI,CAACC,GAAG,CAAC,CAAC,EAAErB,YAAY,CAACe,KAAK,CAAC,CAAC;;EAEnD;EACAnB,SAAS,CAAC,MAAM;IACduB,YAAY,CAACG,QAAQ,CACnBnB,gBAAgB,CAAC;MACfE,KAAK,EAAEc,YAAY,CAACd,KAAK;MACzBC,UAAU;MACVC,kBAAkB,EAAES;IACtB,CAAC,CACH,CAAC;;IAED;IACA;EACF,CAAC,EAAE,CAACV,UAAU,EAAES,KAAK,CAAC,CAAC;EAEvB,OAAOI,YAAY;AACrB;AAEA,eAAeL,yBAAyB"}
|
|
1
|
+
{"version":3,"file":"useInitializeViewportData.js","names":["useEffect","generateEmptyKeyedItems","useWindowedListData","Log","useTableSize","log","module","resizeItemsArray","_ref","items","targetSize","reuseExistingItems","currentSize","length","debug","Array","from","slice","useInitializeViewportData","table","reuseItemsOnTableResize","arguments","undefined","viewportData","Math","max","setItems"],"sources":["../src/useInitializeViewportData.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { generateEmptyKeyedItems } from '@deephaven/jsapi-utils';\nimport {\n useWindowedListData,\n type WindowedListData,\n} from '@deephaven/react-hooks';\nimport { type KeyedItem } from '@deephaven/utils';\nimport Log from '@deephaven/log';\nimport useTableSize from './useTableSize';\n\nconst log = Log.module('useInitializeViewportData');\n\n/**\n * Given an array of items, returns a new array containing the target number of\n * items. If reuseExistingItems is true, existing items will be re-used. If\n * false, all items will be replaced with new, empty items.\n * @param items The array of items to resize.\n * @param targetSize The desired size of the array.\n * @param reuseExistingItems If true, existing items will be re-used. If false,\n * all items will be replaced with new, empty items.\n * @returns The resized array of items.\n */\nfunction resizeItemsArray<T>({\n items,\n targetSize,\n reuseExistingItems,\n}: {\n items: KeyedItem<T, string>[];\n reuseExistingItems: boolean;\n targetSize: number;\n}): KeyedItem<T, string>[] {\n const currentSize = items.length;\n\n // If size isn't changing, do nothing\n if (currentSize === targetSize) {\n return items;\n }\n\n log.debug('size changed:', { currentSize, targetSize });\n\n // Re-create entire array with empty items\n if (!reuseExistingItems) {\n return Array.from(generateEmptyKeyedItems<T>(0, targetSize - 1));\n }\n\n // Drop extra items\n if (currentSize > targetSize) {\n return items.slice(0, targetSize);\n }\n\n // Add missing items\n return [...items, ...generateEmptyKeyedItems<T>(currentSize, targetSize - 1)];\n}\n\n/**\n * Initializes a ListData instance that can be used for windowed views of a\n * Table. The list must always contain a KeyedItem for every record in the table,\n * so it is pre-populated with empty items that can be updated with real data as\n * the window changes.\n *\n * IMPORTANT: this will create an empty KeyedItem object for every row in the\n * source table. This is intended for \"human\" sized tables such as those used in\n * admin panels. This is not suitable for \"machine\" scale with millions+ rows.\n * @param table The table that will be used to determine the list size.\n * @param reuseItemsOnTableResize Whether to reuse existing items when the table\n * size changes (defaults to false).\n * - If true, existing items will be reused when the table resizes. This is\n * recommended for ticking tables where the data is frequently updated in order\n * to avoid UI flicker.\n * - If false, all of the items will be replaced when the table resizes. This is\n * recommnded for tables that don't change size frequently but may change size\n * due to a user interaction. e.g. Filter via a search input. This avoids a\n * different kind of flicker, where the item values will shift around as the\n * user types. It is less jarring for the items to all reset to empty and then\n * show the new results all at once.\n * @returns a WindowedListData object.\n */\nexport function useInitializeViewportData<T>(\n table: dh.Table | dh.TreeTable | null,\n reuseItemsOnTableResize = false\n): WindowedListData<KeyedItem<T>> {\n const viewportData = useWindowedListData<KeyedItem<T>>({});\n\n // If the table changes size, we need to re-initialize it.\n const targetSize = Math.max(0, useTableSize(table));\n\n // Whenever the table reference or size changes, resize the list.\n useEffect(() => {\n viewportData.setItems(\n resizeItemsArray({\n items: viewportData.items,\n targetSize,\n reuseExistingItems: reuseItemsOnTableResize,\n })\n );\n\n // Intentionally excluding viewportData since it changes on every render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [targetSize, table]);\n\n return viewportData;\n}\n\nexport default useInitializeViewportData;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,uBAAuB,QAAQ,wBAAwB;AAChE,SACEC,mBAAmB,QAEd,wBAAwB;AAE/B,OAAOC,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,YAAY;AAEnB,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,2BAA2B,CAAC;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAAAC,IAAA,EAQE;EAAA,IARE;IAC3BC,KAAK;IACLC,UAAU;IACVC;EAKF,CAAC,GAAAH,IAAA;EACC,IAAMI,WAAW,GAAGH,KAAK,CAACI,MAAM;;EAEhC;EACA,IAAID,WAAW,KAAKF,UAAU,EAAE;IAC9B,OAAOD,KAAK;EACd;EAEAJ,GAAG,CAACS,KAAK,CAAC,eAAe,EAAE;IAAEF,WAAW;IAAEF;EAAW,CAAC,CAAC;;EAEvD;EACA,IAAI,CAACC,kBAAkB,EAAE;IACvB,OAAOI,KAAK,CAACC,IAAI,CAACf,uBAAuB,CAAI,CAAC,EAAES,UAAU,GAAG,CAAC,CAAC,CAAC;EAClE;;EAEA;EACA,IAAIE,WAAW,GAAGF,UAAU,EAAE;IAC5B,OAAOD,KAAK,CAACQ,KAAK,CAAC,CAAC,EAAEP,UAAU,CAAC;EACnC;;EAEA;EACA,OAAO,CAAC,GAAGD,KAAK,EAAE,GAAGR,uBAAuB,CAAIW,WAAW,EAAEF,UAAU,GAAG,CAAC,CAAC,CAAC;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,yBAAyBA,CACvCC,KAAqC,EAEL;EAAA,IADhCC,uBAAuB,GAAAC,SAAA,CAAAR,MAAA,QAAAQ,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,KAAK;EAE/B,IAAME,YAAY,GAAGrB,mBAAmB,CAAe,CAAC,CAAC,CAAC;;EAE1D;EACA,IAAMQ,UAAU,GAAGc,IAAI,CAACC,GAAG,CAAC,CAAC,EAAErB,YAAY,CAACe,KAAK,CAAC,CAAC;;EAEnD;EACAnB,SAAS,CAAC,MAAM;IACduB,YAAY,CAACG,QAAQ,CACnBnB,gBAAgB,CAAC;MACfE,KAAK,EAAEc,YAAY,CAACd,KAAK;MACzBC,UAAU;MACVC,kBAAkB,EAAES;IACtB,CAAC,CACH,CAAC;;IAED;IACA;EACF,CAAC,EAAE,CAACV,UAAU,EAAES,KAAK,CAAC,CAAC;EAEvB,OAAOI,YAAY;AACrB;AAEA,eAAeL,yBAAyB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotNullOrEmptyFilter.js","names":["useMemo","createFilterConditionFactory","createNotNullOrEmptyFilterCondition","useTableUtils","useNotNullOrEmptyFilter","columnNames","conditionOperator","arguments","length","undefined","tableUtils","notNullOrEmptyFilterCondition"],"sources":["../src/useNotNullOrEmptyFilter.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n createFilterConditionFactory,\n createNotNullOrEmptyFilterCondition,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport useTableUtils from './useTableUtils';\n\nexport function useNotNullOrEmptyFilter(\n columnNames: string | string[],\n conditionOperator: 'and' | 'or' = 'or'\n): FilterConditionFactory {\n const tableUtils = useTableUtils();\n\n const notNullOrEmptyFilterCondition = useMemo(\n () => createNotNullOrEmptyFilterCondition(tableUtils),\n [tableUtils]\n );\n\n return useMemo(\n () =>\n createFilterConditionFactory(\n columnNames,\n notNullOrEmptyFilterCondition,\n conditionOperator\n ),\n [columnNames, conditionOperator, notNullOrEmptyFilterCondition]\n );\n}\n\nexport default useNotNullOrEmptyFilter;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,4BAA4B,EAC5BC,mCAAmC,QAE9B,wBAAwB;AAAC,OACzBC,aAAa;AAEpB,OAAO,SAASC,uBAAuBA,CACrCC,WAA8B,EAEN;EAAA,IADxBC,iBAA+B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAEtC,IAAMG,UAAU,GAAGP,aAAa,CAAC,CAAC;EAElC,IAAMQ,6BAA6B,GAAGX,OAAO,CAC3C,MAAME,mCAAmC,CAACQ,UAAU,CAAC,EACrD,CAACA,UAAU,CACb,CAAC;EAED,OAAOV,OAAO,CACZ,MACEC,4BAA4B,CAC1BI,WAAW,EACXM,6BAA6B,EAC7BL,iBACF,CAAC,EACH,CAACD,WAAW,EAAEC,iBAAiB,EAAEK,6BAA6B,CAChE,CAAC;AACH;AAEA,eAAeP,uBAAuB"}
|
|
1
|
+
{"version":3,"file":"useNotNullOrEmptyFilter.js","names":["useMemo","createFilterConditionFactory","createNotNullOrEmptyFilterCondition","useTableUtils","useNotNullOrEmptyFilter","columnNames","conditionOperator","arguments","length","undefined","tableUtils","notNullOrEmptyFilterCondition"],"sources":["../src/useNotNullOrEmptyFilter.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n createFilterConditionFactory,\n createNotNullOrEmptyFilterCondition,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport useTableUtils from './useTableUtils';\n\nexport function useNotNullOrEmptyFilter(\n columnNames: string | string[],\n conditionOperator: 'and' | 'or' = 'or'\n): FilterConditionFactory {\n const tableUtils = useTableUtils();\n\n const notNullOrEmptyFilterCondition = useMemo(\n () => createNotNullOrEmptyFilterCondition(tableUtils),\n [tableUtils]\n );\n\n return useMemo(\n () =>\n createFilterConditionFactory(\n columnNames,\n notNullOrEmptyFilterCondition,\n conditionOperator\n ),\n [columnNames, conditionOperator, notNullOrEmptyFilterCondition]\n );\n}\n\nexport default useNotNullOrEmptyFilter;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,4BAA4B,EAC5BC,mCAAmC,QAE9B,wBAAwB;AAAC,OACzBC,aAAa;AAEpB,OAAO,SAASC,uBAAuBA,CACrCC,WAA8B,EAEN;EAAA,IADxBC,iBAA+B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAEtC,IAAMG,UAAU,GAAGP,aAAa,CAAC,CAAC;EAElC,IAAMQ,6BAA6B,GAAGX,OAAO,CAC3C,MAAME,mCAAmC,CAACQ,UAAU,CAAC,EACrD,CAACA,UAAU,CACb,CAAC;EAED,OAAOV,OAAO,CACZ,MACEC,4BAA4B,CAC1BI,WAAW,EACXM,6BAA6B,EAC7BL,iBACF,CAAC,EACH,CAACD,WAAW,EAAEC,iBAAiB,EAAEK,6BAA6B,CAChE,CAAC;AACH;AAEA,eAAeP,uBAAuB","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Key } from '@react-types/shared';
|
|
2
2
|
import type { dh } from '@deephaven/jsapi-types';
|
|
3
3
|
import { type FilterConditionFactory } from '@deephaven/jsapi-utils';
|
|
4
4
|
import { type KeyedItem, type SelectionT } from '@deephaven/utils';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePickerWithSelectedValues.d.ts","sourceRoot":"","sources":["../src/usePickerWithSelectedValues.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePickerWithSelectedValues.d.ts","sourceRoot":"","sources":["../src/usePickerWithSelectedValues.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,E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,CAAC,KAAK,MAAM,CAAC;IACnD,wBAAwB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACpD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,iCAAiC,CAAC,KAAK,EAAE,MAAM,CAAC,CAgOnD;AAED,eAAe,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePickerWithSelectedValues.js","names":["useCallback","useMemo","useState","createSearchTextFilter","createSelectedValuesFilter","useDebouncedCallback","useDebouncedValue","usePromiseFactory","usePickerItemScale","useFilterConditionFactories","useViewportData","useViewportFilter","useTableUtils","useWidgetClose","SEARCH_DEBOUNCE_MS","VIEWPORT_PADDING","VIEWPORT_SIZE","usePickerWithSelectedValues","_ref","maybeTable","columnName","mapItemToValue","filterConditionFactories","trimSearchText","timeZone","itemHeight","tableUtils","searchText","setSearchText","appliedSearchText","setAppliedSearchText","applySearchText","text","trim","searchTextMaybeTrimmed","selectedKey","setSelectedKey","selectedValueMap","setSelectedValueMap","Map","data","valueExists","isLoading","valueExistsIsLoading","doesColumnValueExist","isDebouncing","isApplyingFilter","searchTextExists","searchTextFilter","excludeSelectedValuesFilter","Set","keys","listTable","createDistinctSortedColumnTable","list","table","viewportSize","viewportPadding","hasSearchTextWithZeroResults","length","size","searchTextIsInSelectedValues","has","onDebouncedSearchTextChange","onSearchTextChange","setSelectedKeyOnNextFrame","onSelectKey","key","item","viewportData","findItem","value","prev","next","set","onAddValues","values","onRemoveValues","delete","filter"],"sources":["../src/usePickerWithSelectedValues.ts"],"sourcesContent":["import { type Key, useCallback, useMemo, useState } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport {\n createSearchTextFilter,\n createSelectedValuesFilter,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport {\n useDebouncedCallback,\n useDebouncedValue,\n usePromiseFactory,\n} from '@deephaven/react-hooks';\nimport { usePickerItemScale } from '@deephaven/components';\nimport { type KeyedItem, type SelectionT } from '@deephaven/utils';\nimport useFilterConditionFactories from './useFilterConditionFactories';\nimport useViewportData, { type UseViewportDataResult } from './useViewportData';\nimport useViewportFilter from './useViewportFilter';\nimport useTableUtils from './useTableUtils';\nimport useWidgetClose from './useWidgetClose';\nimport {\n SEARCH_DEBOUNCE_MS,\n VIEWPORT_PADDING,\n VIEWPORT_SIZE,\n} from './Constants';\n\nexport interface UsePickerWithSelectedValuesResult<TItem, TValue> {\n list: UseViewportDataResult<TItem, dh.Table>;\n hasSearchTextWithZeroResults: boolean;\n searchText: string;\n searchTextExists: boolean | null;\n searchTextIsInSelectedValues: boolean;\n selectedKey: Key | null;\n selectedValueMap: ReadonlyMap<TValue, { value: TValue }>;\n onSearchTextChange: (searchText: string) => void;\n onSelectKey: (key: Key | null) => void;\n onAddValues: (values: ReadonlySet<TValue>) => void;\n onRemoveValues: (values: SelectionT<TValue>) => void;\n}\n\n/**\n * Manages a list of available items that can be searched and selected. Selected\n * items are removed from the list and managed in a selectedValueMap data\n * structure. Useful for components that contain a picker but show selected\n * values in a separate component.\n * @param maybeTable The table to get the list of items from\n * @param columnName The column name to get the list of items from\n * @param mapItemToValue A function to map an item to a value\n * @param filterConditionFactories Optional filter condition factories to apply to the list\n * @param trimSearchText Whether to trim the search text before filtering. Defaults to false\n * @param timeZone The timezone to use for date parsing\n */\nexport function usePickerWithSelectedValues<TItem, TValue>({\n maybeTable,\n columnName,\n mapItemToValue,\n filterConditionFactories = [],\n trimSearchText = false,\n timeZone,\n}: {\n maybeTable: dh.Table | null;\n columnName: string;\n mapItemToValue: (item: KeyedItem<TItem>) => TValue;\n filterConditionFactories?: FilterConditionFactory[];\n trimSearchText?: boolean;\n timeZone: string;\n}): UsePickerWithSelectedValuesResult<TItem, TValue> {\n const { itemHeight } = usePickerItemScale();\n\n const tableUtils = useTableUtils();\n\n // `searchText` should always be up to date for controlled search input.\n // `appliedSearchText` will get updated after a delay to avoid updating\n // filters on every key stroke. It will also be trimmed of leading / trailing\n // spaces if `trimSearchText` is true.\n const [searchText, setSearchText] = useState('');\n const [appliedSearchText, setAppliedSearchText] = useState('');\n\n const applySearchText = useCallback(\n (text: string) => {\n setAppliedSearchText(trimSearchText ? text.trim() : text);\n },\n [trimSearchText]\n );\n\n const searchTextMaybeTrimmed = useMemo(\n () => (trimSearchText ? searchText.trim() : searchText),\n [searchText, trimSearchText]\n );\n\n const [selectedKey, setSelectedKey] = useState<Key | null>(null);\n const [selectedValueMap, setSelectedValueMap] = useState<\n Map<TValue, { value: TValue }>\n >(() => new Map());\n\n const { data: valueExists, isLoading: valueExistsIsLoading } =\n usePromiseFactory(tableUtils.doesColumnValueExist, [\n maybeTable,\n columnName,\n appliedSearchText,\n false /* isCaseSensitive */,\n ]);\n\n // The `searchTextFilter` starts getting applied to the list whenever\n // `appliedSearchText` changes, after which there is a small delay before the\n // items are in sync. Use a debounce timer to allow a little extra time\n // before calculating `searchTextExists` below. Note that there are 2 debounce\n // timers at play here:\n // 1. `onDebouncedSearchTextChange` applies the search text after user stops typing\n // 2. `useDebouncedValue` debounces whenever the result of the first debounce\n // changes, and `isApplyingFilter` will be true while this 2nd timer is active.\n const { isDebouncing: isApplyingFilter } = useDebouncedValue(\n appliedSearchText,\n SEARCH_DEBOUNCE_MS\n );\n\n // If value exists check is still loading or if debounce hasn't completed, set\n // `searchTextExists` to null since it is indeterminate.\n const searchTextExists =\n isApplyingFilter || valueExistsIsLoading ? null : valueExists;\n\n const searchTextFilter = useMemo(\n () =>\n createSearchTextFilter(\n tableUtils,\n columnName,\n appliedSearchText,\n timeZone\n ),\n [appliedSearchText, columnName, tableUtils, timeZone]\n );\n\n // Filter out selected values from the picker\n const excludeSelectedValuesFilter = useMemo(\n () =>\n createSelectedValuesFilter(\n tableUtils,\n columnName,\n new Set(selectedValueMap.keys()),\n false,\n true\n ),\n [columnName, selectedValueMap, tableUtils]\n );\n\n const { data: listTable } = usePromiseFactory(\n tableUtils.createDistinctSortedColumnTable,\n [maybeTable, columnName, 'asc', ...filterConditionFactories]\n );\n\n useWidgetClose(listTable);\n\n const list = useViewportData<TItem, dh.Table>({\n table: listTable,\n itemHeight,\n viewportSize: VIEWPORT_SIZE,\n viewportPadding: VIEWPORT_PADDING,\n });\n\n const hasSearchTextWithZeroResults =\n searchTextMaybeTrimmed.length > 0 && list.size === 0;\n const searchTextIsInSelectedValues = selectedValueMap.has(\n searchTextMaybeTrimmed as TValue\n );\n\n const onDebouncedSearchTextChange = useDebouncedCallback(\n applySearchText,\n SEARCH_DEBOUNCE_MS\n );\n\n const onSearchTextChange = useCallback(\n (text: string) => {\n setSearchText(text);\n onDebouncedSearchTextChange(text);\n },\n [onDebouncedSearchTextChange]\n );\n\n const setSelectedKeyOnNextFrame = useDebouncedCallback(setSelectedKey, 0);\n\n const onSelectKey = useCallback(\n (key: Key | null) => {\n setSearchText('');\n applySearchText('');\n\n // Set the selection temporarily to avoid the picker staying open\n setSelectedKey(key);\n\n // Clear the selection on next frame since selected items get removed from\n // the list and added to `selectedValues` Map\n setSelectedKeyOnNextFrame(null);\n\n // key will be null in scenarios where search text doesn't match an item\n // and user clicks outside of picker\n if (key == null) {\n return;\n }\n\n const item = list.viewportData.findItem(key);\n\n if (item == null) {\n return;\n }\n\n const value = mapItemToValue(item);\n\n setSelectedValueMap(prev => {\n const next = new Map(prev);\n next.set(value, { value });\n return next;\n });\n },\n [\n applySearchText,\n setSelectedKeyOnNextFrame,\n list.viewportData,\n mapItemToValue,\n ]\n );\n\n const onAddValues = useCallback((values: ReadonlySet<TValue>) => {\n setSelectedValueMap(prev => {\n if (values.size === 0) {\n return prev;\n }\n\n const next = new Map(prev);\n\n // eslint-disable-next-line no-restricted-syntax\n for (const value of values) {\n next.set(value, { value });\n }\n\n return next;\n });\n }, []);\n\n const onRemoveValues = useCallback((values: SelectionT<TValue>) => {\n setSelectedValueMap(prev => {\n if (values === 'all') {\n return new Map();\n }\n\n const next = new Map(prev);\n\n // eslint-disable-next-line no-restricted-syntax\n for (const value of values) {\n next.delete(value);\n }\n\n return next;\n });\n }, []);\n\n const filter = useFilterConditionFactories(\n list.table,\n searchTextFilter,\n excludeSelectedValuesFilter\n );\n\n useViewportFilter(list, filter);\n\n return useMemo(\n () => ({\n list,\n hasSearchTextWithZeroResults,\n searchText,\n searchTextExists,\n searchTextIsInSelectedValues,\n selectedKey,\n selectedValueMap,\n onSearchTextChange,\n onSelectKey,\n onAddValues,\n onRemoveValues,\n }),\n [\n hasSearchTextWithZeroResults,\n list,\n onAddValues,\n onRemoveValues,\n onSearchTextChange,\n onSelectKey,\n searchText,\n searchTextExists,\n searchTextIsInSelectedValues,\n selectedKey,\n selectedValueMap,\n ]\n );\n}\n\nexport default usePickerWithSelectedValues;\n"],"mappings":"AAAA,SAAmBA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAEhE,SACEC,sBAAsB,EACtBC,0BAA0B,QAErB,wBAAwB;AAC/B,SACEC,oBAAoB,EACpBC,iBAAiB,EACjBC,iBAAiB,QACZ,wBAAwB;AAC/B,SAASC,kBAAkB,QAAQ,uBAAuB;AAAC,OAEpDC,2BAA2B;AAAA,OAC3BC,eAAe;AAAA,OACfC,iBAAiB;AAAA,OACjBC,aAAa;AAAA,OACbC,cAAc;AAAA,SAEnBC,kBAAkB,EAClBC,gBAAgB,EAChBC,aAAa;AAiBf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CAAAC,IAAA,EAcU;EAAA,IAdM;IACzDC,UAAU;IACVC,UAAU;IACVC,cAAc;IACdC,wBAAwB,GAAG,EAAE;IAC7BC,cAAc,GAAG,KAAK;IACtBC;EAQF,CAAC,GAAAN,IAAA;EACC,IAAM;IAAEO;EAAW,CAAC,GAAGjB,kBAAkB,CAAC,CAAC;EAE3C,IAAMkB,UAAU,GAAGd,aAAa,CAAC,CAAC;;EAElC;EACA;EACA;EACA;EACA,IAAM,CAACe,UAAU,EAAEC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ClB;MAEA,IAAMkC,IAAI,GAAG,IAAIlC,GAAG,CAACiC,IAAI,CAAC;;MAE1B;MACA,KAAK,IAAMD,KAAK,IAAIK,MAAM,EAAE;QAC1BH,IAAI,CAACK,MAAM,CAACP,KAAK,CAAC;MACpB;MAEA,OAAOE,IAAI;IACb,CAAC,CAAC;EACJ,CAAC,EAAE,EAAE,CAAC;EAEN,IAAMM,MAAM,GAAGtE,2BAA2B,CACxC6C,IAAI,CAACC,KAAK,EACVP,gBAAgB,EAChBC,2BACF,CAAC;EAEDtC,iBAAiB,CAAC2C,IAAI,EAAEyB,MAAM,CAAC;EAE/B,OAAO9E,OAAO,CACZ,OAAO;IACLqD,IAAI;IACJI,4BAA4B;IAC5B/B,UAAU;IACVoB,gBAAgB;IAChBc,4BAA4B;IAC5B1B,WAAW;IACXE,gBAAgB;IAChB2B,kBAAkB;IAClBE,WAAW;IACXS,WAAW;IACXE;EACF,CAAC,CAAC,EACF,CACEnB,4BAA4B,EAC5BJ,IAAI,EACJqB,WAAW,EACXE,cAAc,EACdb,kBAAkB,EAClBE,WAAW,EACXvC,UAAU,EACVoB,gBAAgB,EAChBc,4BAA4B,EAC5B1B,WAAW,EACXE,gBAAgB,CAEpB,CAAC;AACH;AAEA,eAAepB,2BAA2B"}
|
|
1
|
+
{"version":3,"file":"usePickerWithSelectedValues.js","names":["useCallback","useMemo","useState","createSearchTextFilter","createSelectedValuesFilter","useDebouncedCallback","useDebouncedValue","usePromiseFactory","usePickerItemScale","useFilterConditionFactories","useViewportData","useViewportFilter","useTableUtils","useWidgetClose","SEARCH_DEBOUNCE_MS","VIEWPORT_PADDING","VIEWPORT_SIZE","usePickerWithSelectedValues","_ref","maybeTable","columnName","mapItemToValue","filterConditionFactories","trimSearchText","timeZone","itemHeight","tableUtils","searchText","setSearchText","appliedSearchText","setAppliedSearchText","applySearchText","text","trim","searchTextMaybeTrimmed","selectedKey","setSelectedKey","selectedValueMap","setSelectedValueMap","Map","data","valueExists","isLoading","valueExistsIsLoading","doesColumnValueExist","isDebouncing","isApplyingFilter","searchTextExists","searchTextFilter","excludeSelectedValuesFilter","Set","keys","listTable","createDistinctSortedColumnTable","list","table","viewportSize","viewportPadding","hasSearchTextWithZeroResults","length","size","searchTextIsInSelectedValues","has","onDebouncedSearchTextChange","onSearchTextChange","setSelectedKeyOnNextFrame","onSelectKey","key","item","viewportData","findItem","value","prev","next","set","onAddValues","values","onRemoveValues","delete","filter"],"sources":["../src/usePickerWithSelectedValues.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport type { Key } from '@react-types/shared';\nimport type { dh } from '@deephaven/jsapi-types';\nimport {\n createSearchTextFilter,\n createSelectedValuesFilter,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport {\n useDebouncedCallback,\n useDebouncedValue,\n usePromiseFactory,\n} from '@deephaven/react-hooks';\nimport { usePickerItemScale } from '@deephaven/components';\nimport { type KeyedItem, type SelectionT } from '@deephaven/utils';\nimport useFilterConditionFactories from './useFilterConditionFactories';\nimport useViewportData, { type UseViewportDataResult } from './useViewportData';\nimport useViewportFilter from './useViewportFilter';\nimport useTableUtils from './useTableUtils';\nimport useWidgetClose from './useWidgetClose';\nimport {\n SEARCH_DEBOUNCE_MS,\n VIEWPORT_PADDING,\n VIEWPORT_SIZE,\n} from './Constants';\n\nexport interface UsePickerWithSelectedValuesResult<TItem, TValue> {\n list: UseViewportDataResult<TItem, dh.Table>;\n hasSearchTextWithZeroResults: boolean;\n searchText: string;\n searchTextExists: boolean | null;\n searchTextIsInSelectedValues: boolean;\n selectedKey: Key | null;\n selectedValueMap: ReadonlyMap<TValue, { value: TValue }>;\n onSearchTextChange: (searchText: string) => void;\n onSelectKey: (key: Key | null) => void;\n onAddValues: (values: ReadonlySet<TValue>) => void;\n onRemoveValues: (values: SelectionT<TValue>) => void;\n}\n\n/**\n * Manages a list of available items that can be searched and selected. Selected\n * items are removed from the list and managed in a selectedValueMap data\n * structure. Useful for components that contain a picker but show selected\n * values in a separate component.\n * @param maybeTable The table to get the list of items from\n * @param columnName The column name to get the list of items from\n * @param mapItemToValue A function to map an item to a value\n * @param filterConditionFactories Optional filter condition factories to apply to the list\n * @param trimSearchText Whether to trim the search text before filtering. Defaults to false\n * @param timeZone The timezone to use for date parsing\n */\nexport function usePickerWithSelectedValues<TItem, TValue>({\n maybeTable,\n columnName,\n mapItemToValue,\n filterConditionFactories = [],\n trimSearchText = false,\n timeZone,\n}: {\n maybeTable: dh.Table | null;\n columnName: string;\n mapItemToValue: (item: KeyedItem<TItem>) => TValue;\n filterConditionFactories?: FilterConditionFactory[];\n trimSearchText?: boolean;\n timeZone: string;\n}): UsePickerWithSelectedValuesResult<TItem, TValue> {\n const { itemHeight } = usePickerItemScale();\n\n const tableUtils = useTableUtils();\n\n // `searchText` should always be up to date for controlled search input.\n // `appliedSearchText` will get updated after a delay to avoid updating\n // filters on every key stroke. It will also be trimmed of leading / trailing\n // spaces if `trimSearchText` is true.\n const [searchText, setSearchText] = useState('');\n const [appliedSearchText, setAppliedSearchText] = useState('');\n\n const applySearchText = useCallback(\n (text: string) => {\n setAppliedSearchText(trimSearchText ? text.trim() : text);\n },\n [trimSearchText]\n );\n\n const searchTextMaybeTrimmed = useMemo(\n () => (trimSearchText ? searchText.trim() : searchText),\n [searchText, trimSearchText]\n );\n\n const [selectedKey, setSelectedKey] = useState<Key | null>(null);\n const [selectedValueMap, setSelectedValueMap] = useState<\n Map<TValue, { value: TValue }>\n >(() => new Map());\n\n const { data: valueExists, isLoading: valueExistsIsLoading } =\n usePromiseFactory(tableUtils.doesColumnValueExist, [\n maybeTable,\n columnName,\n appliedSearchText,\n false /* isCaseSensitive */,\n ]);\n\n // The `searchTextFilter` starts getting applied to the list whenever\n // `appliedSearchText` changes, after which there is a small delay before the\n // items are in sync. Use a debounce timer to allow a little extra time\n // before calculating `searchTextExists` below. Note that there are 2 debounce\n // timers at play here:\n // 1. `onDebouncedSearchTextChange` applies the search text after user stops typing\n // 2. `useDebouncedValue` debounces whenever the result of the first debounce\n // changes, and `isApplyingFilter` will be true while this 2nd timer is active.\n const { isDebouncing: isApplyingFilter } = useDebouncedValue(\n appliedSearchText,\n SEARCH_DEBOUNCE_MS\n );\n\n // If value exists check is still loading or if debounce hasn't completed, set\n // `searchTextExists` to null since it is indeterminate.\n const searchTextExists =\n isApplyingFilter || valueExistsIsLoading ? null : valueExists;\n\n const searchTextFilter = useMemo(\n () =>\n createSearchTextFilter(\n tableUtils,\n columnName,\n appliedSearchText,\n timeZone\n ),\n [appliedSearchText, columnName, tableUtils, timeZone]\n );\n\n // Filter out selected values from the picker\n const excludeSelectedValuesFilter = useMemo(\n () =>\n createSelectedValuesFilter(\n tableUtils,\n columnName,\n new Set(selectedValueMap.keys()),\n false,\n true\n ),\n [columnName, selectedValueMap, tableUtils]\n );\n\n const { data: listTable } = usePromiseFactory(\n tableUtils.createDistinctSortedColumnTable,\n [maybeTable, columnName, 'asc', ...filterConditionFactories]\n );\n\n useWidgetClose(listTable);\n\n const list = useViewportData<TItem, dh.Table>({\n table: listTable,\n itemHeight,\n viewportSize: VIEWPORT_SIZE,\n viewportPadding: VIEWPORT_PADDING,\n });\n\n const hasSearchTextWithZeroResults =\n searchTextMaybeTrimmed.length > 0 && list.size === 0;\n const searchTextIsInSelectedValues = selectedValueMap.has(\n searchTextMaybeTrimmed as TValue\n );\n\n const onDebouncedSearchTextChange = useDebouncedCallback(\n applySearchText,\n SEARCH_DEBOUNCE_MS\n );\n\n const onSearchTextChange = useCallback(\n (text: string) => {\n setSearchText(text);\n onDebouncedSearchTextChange(text);\n },\n [onDebouncedSearchTextChange]\n );\n\n const setSelectedKeyOnNextFrame = useDebouncedCallback(setSelectedKey, 0);\n\n const onSelectKey = useCallback(\n (key: Key | null) => {\n setSearchText('');\n applySearchText('');\n\n // Set the selection temporarily to avoid the picker staying open\n setSelectedKey(key);\n\n // Clear the selection on next frame since selected items get removed from\n // the list and added to `selectedValues` Map\n setSelectedKeyOnNextFrame(null);\n\n // key will be null in scenarios where search text doesn't match an item\n // and user clicks outside of picker\n if (key == null) {\n return;\n }\n\n const item = list.viewportData.findItem(key);\n\n if (item == null) {\n return;\n }\n\n const value = mapItemToValue(item);\n\n setSelectedValueMap(prev => {\n const next = new Map(prev);\n next.set(value, { value });\n return next;\n });\n },\n [\n applySearchText,\n setSelectedKeyOnNextFrame,\n list.viewportData,\n mapItemToValue,\n ]\n );\n\n const onAddValues = useCallback((values: ReadonlySet<TValue>) => {\n setSelectedValueMap(prev => {\n if (values.size === 0) {\n return prev;\n }\n\n const next = new Map(prev);\n\n // eslint-disable-next-line no-restricted-syntax\n for (const value of values) {\n next.set(value, { value });\n }\n\n return next;\n });\n }, []);\n\n const onRemoveValues = useCallback((values: SelectionT<TValue>) => {\n setSelectedValueMap(prev => {\n if (values === 'all') {\n return new Map();\n }\n\n const next = new Map(prev);\n\n // eslint-disable-next-line no-restricted-syntax\n for (const value of values) {\n next.delete(value);\n }\n\n return next;\n });\n }, []);\n\n const filter = useFilterConditionFactories(\n list.table,\n searchTextFilter,\n excludeSelectedValuesFilter\n );\n\n useViewportFilter(list, filter);\n\n return useMemo(\n () => ({\n list,\n hasSearchTextWithZeroResults,\n searchText,\n searchTextExists,\n searchTextIsInSelectedValues,\n selectedKey,\n selectedValueMap,\n onSearchTextChange,\n onSelectKey,\n onAddValues,\n onRemoveValues,\n }),\n [\n hasSearchTextWithZeroResults,\n list,\n onAddValues,\n onRemoveValues,\n onSearchTextChange,\n onSelectKey,\n searchText,\n searchTextExists,\n searchTextIsInSelectedValues,\n selectedKey,\n selectedValueMap,\n ]\n );\n}\n\nexport default usePickerWithSelectedValues;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAGtD,SACEC,sBAAsB,EACtBC,0BAA0B,QAErB,wBAAwB;AAC/B,SACEC,oBAAoB,EACpBC,iBAAiB,EACjBC,iBAAiB,QACZ,wBAAwB;AAC/B,SAASC,kBAAkB,QAAQ,u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XvC,UAAU,EACVoB,gBAAgB,EAChBc,4BAA4B,EAC5B1B,WAAW,EACXE,gBAAgB,CAEpB,CAAC;AACH;AAEA,eAAepB,2BAA2B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearchableViewportData.js","names":["useMemo","useState","TABLE_ROW_HEIGHT","createSearchTextFilter","useDebouncedCallback","useTableUtils","useViewportData","useFilterConditionFactories","useViewportFilter","SEARCH_DEBOUNCE_MS","VIEWPORT_PADDING","VIEWPORT_SIZE","useSearchableViewportData","_ref","additionalFilterConditionFactories","searchColumnNames","timeZone","props","_objectWithoutProperties","_excluded","tableUtils","searchText","setSearchText","searchTextFilter","onSearchTextChange","list","_objectSpread","itemHeight","viewportSize","viewportPadding","filter","table"],"sources":["../src/useSearchableViewportData.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { TABLE_ROW_HEIGHT } from '@deephaven/components';\nimport type { dh } from '@deephaven/jsapi-types';\nimport {\n createSearchTextFilter,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport { useDebouncedCallback } from '@deephaven/react-hooks';\nimport { useTableUtils } from './useTableUtils';\nimport useViewportData, {\n type UseViewportDataProps,\n type UseViewportDataResult,\n} from './useViewportData';\nimport useFilterConditionFactories from './useFilterConditionFactories';\nimport useViewportFilter from './useViewportFilter';\nimport {\n SEARCH_DEBOUNCE_MS,\n VIEWPORT_PADDING,\n VIEWPORT_SIZE,\n} from './Constants';\n\nexport interface UseSearchableViewportDataProps<TData>\n extends UseViewportDataProps<TData, dh.Table> {\n additionalFilterConditionFactories?: FilterConditionFactory[];\n searchColumnNames: string | string[];\n timeZone: string;\n}\n\nexport interface SearchableViewportData<TData>\n extends UseViewportDataResult<TData, dh.Table> {\n onSearchTextChange: (searchText: string) => void;\n}\n\n/**\n * Use a viewport data list with a search text filter. Supports additional filters.\n * @param table The table to use\n * @param itemHeight The height of each item\n * @param scrollDebounce The debounce time for scroll events\n * @param viewportSize The size of the viewport\n * @param viewportPadding The padding around the viewport\n * @param deserializeRow The row deserializer\n * @param searchColumnNames The column names to search\n * @param timeZone Timezone to use for date parsing\n * @param additionalFilterConditionFactories Additional filter condition factories\n */\nexport function useSearchableViewportData<TData>({\n additionalFilterConditionFactories = [],\n searchColumnNames,\n timeZone,\n ...props\n}: UseSearchableViewportDataProps<TData>): SearchableViewportData<TData> {\n const tableUtils = useTableUtils();\n\n const [searchText, setSearchText] = useState<string>('');\n\n const searchTextFilter = useMemo(\n () =>\n createSearchTextFilter(\n tableUtils,\n searchColumnNames,\n searchText,\n timeZone\n ),\n [searchColumnNames, searchText, tableUtils, timeZone]\n );\n\n const onSearchTextChange = useDebouncedCallback(\n setSearchText,\n SEARCH_DEBOUNCE_MS\n );\n\n const list = useViewportData<TData, dh.Table>({\n itemHeight: TABLE_ROW_HEIGHT,\n viewportSize: VIEWPORT_SIZE,\n viewportPadding: VIEWPORT_PADDING,\n ...props,\n });\n\n const filter = useFilterConditionFactories(\n list.table,\n searchTextFilter,\n ...additionalFilterConditionFactories\n );\n\n useViewportFilter(list, filter);\n\n return {\n ...list,\n onSearchTextChange,\n };\n}\n\nexport default useSearchableViewportData;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACzC,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,SACEC,sBAAsB,QAEjB,wBAAwB;AAC/B,SAASC,oBAAoB,QAAQ,wBAAwB;AAAC,SACrDC,aAAa;AAAA,OACfC,eAAe;AAAA,OAIfC,2BAA2B;AAAA,OAC3BC,iBAAiB;AAAA,SAEtBC,kBAAkB,EAClBC,gBAAgB,EAChBC,aAAa;AAef;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAAC,IAAA,EAKgC;EAAA,IALxB;MAC/CC,kCAAkC,GAAG,EAAE;MACvCC,iBAAiB;MACjBC;IAEqC,CAAC,GAAAH,IAAA;IADnCI,KAAK,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EAER,IAAMC,UAAU,GAAGf,aAAa,CAAC,CAAC;EAElC,IAAM,CAACgB,UAAU,EAAEC,aAAa,CAAC,GAAGrB,QAAQ,CAAS,EAAE,CAAC;EAExD,IAAMsB,gBAAgB,GAAGvB,OAAO,CAC9B,MACEG,sBAAsB,CACpBiB,UAAU,EACVL,iBAAiB,EACjBM,UAAU,EACVL,QACF,CAAC,EACH,CAACD,iBAAiB,EAAEM,UAAU,EAAED,UAAU,EAAEJ,QAAQ,CACtD,CAAC;EAED,IAAMQ,kBAAkB,GAAGpB,oBAAoB,CAC7CkB,aAAa,EACbb,kBACF,CAAC;EAED,IAAMgB,IAAI,GAAGnB,eAAe,CAAAoB,aAAA;IAC1BC,UAAU,EAAEzB,gBAAgB;IAC5B0B,YAAY,EAAEjB,aAAa;IAC3BkB,eAAe,EAAEnB;EAAgB,GAC9BO,KAAK,CACT,CAAC;EAEF,IAAMa,MAAM,GAAGvB,2BAA2B,CACxCkB,IAAI,CAACM,KAAK,EACVR,gBAAgB,EAChB,GAAGT,kCACL,CAAC;EAEDN,iBAAiB,CAACiB,IAAI,EAAEK,MAAM,CAAC;EAE/B,OAAAJ,aAAA,CAAAA,aAAA,KACKD,IAAI;IACPD;EAAkB;AAEtB;AAEA,eAAeZ,yBAAyB"}
|
|
1
|
+
{"version":3,"file":"useSearchableViewportData.js","names":["useMemo","useState","TABLE_ROW_HEIGHT","createSearchTextFilter","useDebouncedCallback","useTableUtils","useViewportData","useFilterConditionFactories","useViewportFilter","SEARCH_DEBOUNCE_MS","VIEWPORT_PADDING","VIEWPORT_SIZE","useSearchableViewportData","_ref","additionalFilterConditionFactories","searchColumnNames","timeZone","props","_objectWithoutProperties","_excluded","tableUtils","searchText","setSearchText","searchTextFilter","onSearchTextChange","list","_objectSpread","itemHeight","viewportSize","viewportPadding","filter","table"],"sources":["../src/useSearchableViewportData.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { TABLE_ROW_HEIGHT } from '@deephaven/components';\nimport type { dh } from '@deephaven/jsapi-types';\nimport {\n createSearchTextFilter,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport { useDebouncedCallback } from '@deephaven/react-hooks';\nimport { useTableUtils } from './useTableUtils';\nimport useViewportData, {\n type UseViewportDataProps,\n type UseViewportDataResult,\n} from './useViewportData';\nimport useFilterConditionFactories from './useFilterConditionFactories';\nimport useViewportFilter from './useViewportFilter';\nimport {\n SEARCH_DEBOUNCE_MS,\n VIEWPORT_PADDING,\n VIEWPORT_SIZE,\n} from './Constants';\n\nexport interface UseSearchableViewportDataProps<TData>\n extends UseViewportDataProps<TData, dh.Table> {\n additionalFilterConditionFactories?: FilterConditionFactory[];\n searchColumnNames: string | string[];\n timeZone: string;\n}\n\nexport interface SearchableViewportData<TData>\n extends UseViewportDataResult<TData, dh.Table> {\n onSearchTextChange: (searchText: string) => void;\n}\n\n/**\n * Use a viewport data list with a search text filter. Supports additional filters.\n * @param table The table to use\n * @param itemHeight The height of each item\n * @param scrollDebounce The debounce time for scroll events\n * @param viewportSize The size of the viewport\n * @param viewportPadding The padding around the viewport\n * @param deserializeRow The row deserializer\n * @param searchColumnNames The column names to search\n * @param timeZone Timezone to use for date parsing\n * @param additionalFilterConditionFactories Additional filter condition factories\n */\nexport function useSearchableViewportData<TData>({\n additionalFilterConditionFactories = [],\n searchColumnNames,\n timeZone,\n ...props\n}: UseSearchableViewportDataProps<TData>): SearchableViewportData<TData> {\n const tableUtils = useTableUtils();\n\n const [searchText, setSearchText] = useState<string>('');\n\n const searchTextFilter = useMemo(\n () =>\n createSearchTextFilter(\n tableUtils,\n searchColumnNames,\n searchText,\n timeZone\n ),\n [searchColumnNames, searchText, tableUtils, timeZone]\n );\n\n const onSearchTextChange = useDebouncedCallback(\n setSearchText,\n SEARCH_DEBOUNCE_MS\n );\n\n const list = useViewportData<TData, dh.Table>({\n itemHeight: TABLE_ROW_HEIGHT,\n viewportSize: VIEWPORT_SIZE,\n viewportPadding: VIEWPORT_PADDING,\n ...props,\n });\n\n const filter = useFilterConditionFactories(\n list.table,\n searchTextFilter,\n ...additionalFilterConditionFactories\n );\n\n useViewportFilter(list, filter);\n\n return {\n ...list,\n onSearchTextChange,\n };\n}\n\nexport default useSearchableViewportData;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACzC,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,SACEC,sBAAsB,QAEjB,wBAAwB;AAC/B,SAASC,oBAAoB,QAAQ,wBAAwB;AAAC,SACrDC,aAAa;AAAA,OACfC,eAAe;AAAA,OAIfC,2BAA2B;AAAA,OAC3BC,iBAAiB;AAAA,SAEtBC,kBAAkB,EAClBC,gBAAgB,EAChBC,aAAa;AAef;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAAC,IAAA,EAKgC;EAAA,IALxB;MAC/CC,kCAAkC,GAAG,EAAE;MACvCC,iBAAiB;MACjBC;IAEqC,CAAC,GAAAH,IAAA;IADnCI,KAAK,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EAER,IAAMC,UAAU,GAAGf,aAAa,CAAC,CAAC;EAElC,IAAM,CAACgB,UAAU,EAAEC,aAAa,CAAC,GAAGrB,QAAQ,CAAS,EAAE,CAAC;EAExD,IAAMsB,gBAAgB,GAAGvB,OAAO,CAC9B,MACEG,sBAAsB,CACpBiB,UAAU,EACVL,iBAAiB,EACjBM,UAAU,EACVL,QACF,CAAC,EACH,CAACD,iBAAiB,EAAEM,UAAU,EAAED,UAAU,EAAEJ,QAAQ,CACtD,CAAC;EAED,IAAMQ,kBAAkB,GAAGpB,oBAAoB,CAC7CkB,aAAa,EACbb,kBACF,CAAC;EAED,IAAMgB,IAAI,GAAGnB,eAAe,CAAAoB,aAAA;IAC1BC,UAAU,EAAEzB,gBAAgB;IAC5B0B,YAAY,EAAEjB,aAAa;IAC3BkB,eAAe,EAAEnB;EAAgB,GAC9BO,KAAK,CACT,CAAC;EAEF,IAAMa,MAAM,GAAGvB,2BAA2B,CACxCkB,IAAI,CAACM,KAAK,EACVR,gBAAgB,EAChB,GAAGT,kCACL,CAAC;EAEDN,iBAAiB,CAACiB,IAAI,EAAEK,MAAM,CAAC;EAE/B,OAAAJ,aAAA,CAAAA,aAAA,KACKD,IAAI;IACPD;EAAkB;AAEtB;AAEA,eAAeZ,yBAAyB","ignoreList":[]}
|
|
@@ -17,7 +17,7 @@ export default function useSelectDistinctTable(table) {
|
|
|
17
17
|
for (var _len = arguments.length, columnNames = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
18
18
|
columnNames[_key - 1] = arguments[_key];
|
|
19
19
|
}
|
|
20
|
-
var selectDistinct = useCallback(
|
|
20
|
+
var selectDistinct = useCallback(/*#__PURE__*/_asyncToGenerator(function* () {
|
|
21
21
|
var _table$selectDistinct;
|
|
22
22
|
return (_table$selectDistinct = table === null || table === void 0 ? void 0 : table.selectDistinct(table.findColumns(columnNames))) !== null && _table$selectDistinct !== void 0 ? _table$selectDistinct : null;
|
|
23
23
|
}),
|
|
@@ -31,7 +31,7 @@ export default function useSelectDistinctTable(table) {
|
|
|
31
31
|
isLoading
|
|
32
32
|
} = usePromiseFactory(selectDistinct, []);
|
|
33
33
|
useEffect(() => () => {
|
|
34
|
-
distinctTable === null || distinctTable === void 0
|
|
34
|
+
distinctTable === null || distinctTable === void 0 || distinctTable.close();
|
|
35
35
|
}, [distinctTable]);
|
|
36
36
|
return {
|
|
37
37
|
distinctTable,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelectDistinctTable.js","names":["useCallback","useEffect","usePromiseFactory","useSelectDistinctTable","table","_len","arguments","length","columnNames","Array","_key","selectDistinct","_asyncToGenerator","_table$selectDistinct","findColumns","data","distinctTable","error","isError","isLoading","close"],"sources":["../src/useSelectDistinctTable.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { usePromiseFactory } from '@deephaven/react-hooks';\n\n/**\n * Return type of `useSelectDistinctTable` hook.\n */\nexport interface UseSelectDistinctTableResult {\n distinctTable: dh.Table | null;\n error: string | Error | null;\n isError: boolean;\n isLoading: boolean;\n}\n\n/**\n * Creates and subscribes to a `selectDistinct` derived table and unsubscribes\n * on unmount.\n * @param table The table to call `selectDistinct` on.\n * @param columnNames The list of column names to pass to `selectDistinct`.\n */\nexport default function useSelectDistinctTable(\n table: dh.Table | dh.TreeTable | null,\n ...columnNames: string[]\n): UseSelectDistinctTableResult {\n const selectDistinct = useCallback(\n async () => table?.selectDistinct(table.findColumns(columnNames)) ?? null,\n // Disabling the exhaustive checks due to the spreading of `columnNames`\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [table, ...columnNames]\n );\n\n const {\n data: distinctTable,\n error,\n isError,\n isLoading,\n } = usePromiseFactory(selectDistinct, []);\n\n useEffect(\n () => () => {\n distinctTable?.close();\n },\n [distinctTable]\n );\n\n return { distinctTable, error, isError, isLoading };\n}\n"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,QAAQ,OAAO;AAE9C,SAASC,iBAAiB,QAAQ,wBAAwB;;AAE1D;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,sBAAsBA,CAC5CC,KAAqC,EAEP;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAD3BC,WAAW,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAXF,WAAW,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;EAAA;EAEd,IAAMC,cAAc,GAAGX,WAAW,
|
|
1
|
+
{"version":3,"file":"useSelectDistinctTable.js","names":["useCallback","useEffect","usePromiseFactory","useSelectDistinctTable","table","_len","arguments","length","columnNames","Array","_key","selectDistinct","_asyncToGenerator","_table$selectDistinct","findColumns","data","distinctTable","error","isError","isLoading","close"],"sources":["../src/useSelectDistinctTable.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { usePromiseFactory } from '@deephaven/react-hooks';\n\n/**\n * Return type of `useSelectDistinctTable` hook.\n */\nexport interface UseSelectDistinctTableResult {\n distinctTable: dh.Table | null;\n error: string | Error | null;\n isError: boolean;\n isLoading: boolean;\n}\n\n/**\n * Creates and subscribes to a `selectDistinct` derived table and unsubscribes\n * on unmount.\n * @param table The table to call `selectDistinct` on.\n * @param columnNames The list of column names to pass to `selectDistinct`.\n */\nexport default function useSelectDistinctTable(\n table: dh.Table | dh.TreeTable | null,\n ...columnNames: string[]\n): UseSelectDistinctTableResult {\n const selectDistinct = useCallback(\n async () => table?.selectDistinct(table.findColumns(columnNames)) ?? null,\n // Disabling the exhaustive checks due to the spreading of `columnNames`\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [table, ...columnNames]\n );\n\n const {\n data: distinctTable,\n error,\n isError,\n isLoading,\n } = usePromiseFactory(selectDistinct, []);\n\n useEffect(\n () => () => {\n distinctTable?.close();\n },\n [distinctTable]\n );\n\n return { distinctTable, error, isError, isLoading };\n}\n"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,QAAQ,OAAO;AAE9C,SAASC,iBAAiB,QAAQ,wBAAwB;;AAE1D;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,sBAAsBA,CAC5CC,KAAqC,EAEP;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAD3BC,WAAW,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAXF,WAAW,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;EAAA;EAEd,IAAMC,cAAc,GAAGX,WAAW,cAAAY,iBAAA,CAChC;IAAA,IAAAC,qBAAA;IAAA,QAAAA,qBAAA,GAAYT,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEO,cAAc,CAACP,KAAK,CAACU,WAAW,CAACN,WAAW,CAAC,CAAC,cAAAK,qBAAA,cAAAA,qBAAA,GAAI,IAAI;EAAA;EACzE;EACA;EACA,CAACT,KAAK,EAAE,GAAGI,WAAW,CACxB,CAAC;EAED,IAAM;IACJO,IAAI,EAAEC,aAAa;IACnBC,KAAK;IACLC,OAAO;IACPC;EACF,CAAC,GAAGjB,iBAAiB,CAACS,cAAc,EAAE,EAAE,CAAC;EAEzCV,SAAS,CACP,MAAM,MAAM;IACVe,aAAa,aAAbA,aAAa,eAAbA,aAAa,CAAEI,KAAK,CAAC,CAAC;EACxB,CAAC,EACD,CAACJ,aAAa,CAChB,CAAC;EAED,OAAO;IAAEA,aAAa;IAAEC,KAAK;IAAEC,OAAO;IAAEC;EAAU,CAAC;AACrD","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@ import { getSize, padFirstAndLastRow } from '@deephaven/jsapi-utils';
|
|
|
14
14
|
export function useSetPaddedViewportCallback(table, viewportSize, viewportPadding) {
|
|
15
15
|
return useCallback(function setPaddedViewport(firstRow) {
|
|
16
16
|
var [first, last] = padFirstAndLastRow(firstRow, viewportSize, viewportPadding, getSize(table));
|
|
17
|
-
table === null || table === void 0
|
|
17
|
+
table === null || table === void 0 || table.setViewport(first, last);
|
|
18
18
|
}, [table, viewportPadding, viewportSize]);
|
|
19
19
|
}
|
|
20
20
|
export default useSetPaddedViewportCallback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSetPaddedViewportCallback.js","names":["useCallback","getSize","padFirstAndLastRow","useSetPaddedViewportCallback","table","viewportSize","viewportPadding","setPaddedViewport","firstRow","first","last","setViewport"],"sources":["../src/useSetPaddedViewportCallback.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { getSize, padFirstAndLastRow } from '@deephaven/jsapi-utils';\n\n/**\n * Creates a callback function that will set a Table viewport. The callback has\n * a closure over the Table, a desired viewport size, and additional padding.\n * These will be combined with a first row index passed to the callback to\n * calculate the final viewport.\n * @param table Table to call `setViewport` on.\n * @param viewportSize The desired viewport size.\n * @param viewportPadding Padding to add before and after the viewport.\n * @returns A callback function for setting the viewport.\n */\nexport function useSetPaddedViewportCallback(\n table: dh.Table | dh.TreeTable | null,\n viewportSize: number,\n viewportPadding: number\n): (firstRow: number) => void {\n return useCallback(\n function setPaddedViewport(firstRow: number) {\n const [first, last] = padFirstAndLastRow(\n firstRow,\n viewportSize,\n viewportPadding,\n getSize(table)\n );\n\n table?.setViewport(first, last);\n },\n [table, viewportPadding, viewportSize]\n );\n}\n\nexport default useSetPaddedViewportCallback;\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,OAAO;AAEnC,SAASC,OAAO,EAAEC,kBAAkB,QAAQ,wBAAwB;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAC1CC,KAAqC,EACrCC,YAAoB,EACpBC,eAAuB,EACK;EAC5B,OAAON,WAAW,CAChB,SAASO,iBAAiBA,CAACC,QAAgB,EAAE;IAC3C,IAAM,CAACC,KAAK,EAAEC,IAAI,CAAC,GAAGR,kBAAkB,CACtCM,QAAQ,EACRH,YAAY,EACZC,eAAe,EACfL,OAAO,CAACG,KAAK,CACf,CAAC;IAEDA,KAAK,aAALA,KAAK,
|
|
1
|
+
{"version":3,"file":"useSetPaddedViewportCallback.js","names":["useCallback","getSize","padFirstAndLastRow","useSetPaddedViewportCallback","table","viewportSize","viewportPadding","setPaddedViewport","firstRow","first","last","setViewport"],"sources":["../src/useSetPaddedViewportCallback.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { getSize, padFirstAndLastRow } from '@deephaven/jsapi-utils';\n\n/**\n * Creates a callback function that will set a Table viewport. The callback has\n * a closure over the Table, a desired viewport size, and additional padding.\n * These will be combined with a first row index passed to the callback to\n * calculate the final viewport.\n * @param table Table to call `setViewport` on.\n * @param viewportSize The desired viewport size.\n * @param viewportPadding Padding to add before and after the viewport.\n * @returns A callback function for setting the viewport.\n */\nexport function useSetPaddedViewportCallback(\n table: dh.Table | dh.TreeTable | null,\n viewportSize: number,\n viewportPadding: number\n): (firstRow: number) => void {\n return useCallback(\n function setPaddedViewport(firstRow: number) {\n const [first, last] = padFirstAndLastRow(\n firstRow,\n viewportSize,\n viewportPadding,\n getSize(table)\n );\n\n table?.setViewport(first, last);\n },\n [table, viewportPadding, viewportSize]\n );\n}\n\nexport default useSetPaddedViewportCallback;\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,OAAO;AAEnC,SAASC,OAAO,EAAEC,kBAAkB,QAAQ,wBAAwB;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAC1CC,KAAqC,EACrCC,YAAoB,EACpBC,eAAuB,EACK;EAC5B,OAAON,WAAW,CAChB,SAASO,iBAAiBA,CAACC,QAAgB,EAAE;IAC3C,IAAM,CAACC,KAAK,EAAEC,IAAI,CAAC,GAAGR,kBAAkB,CACtCM,QAAQ,EACRH,YAAY,EACZC,eAAe,EACfL,OAAO,CAACG,KAAK,CACf,CAAC;IAEDA,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEO,WAAW,CAACF,KAAK,EAAEC,IAAI,CAAC;EACjC,CAAC,EACD,CAACN,KAAK,EAAEE,eAAe,EAAED,YAAY,CACvC,CAAC;AACH;AAEA,eAAeF,4BAA4B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShowOnlyEmptyFilter.js","names":["useMemo","createFilterConditionFactory","createShowOnlyEmptyFilterCondition","useTableUtils","useShowOnlyEmptyFilter","isOn","columnNames","tableUtils","createColumnCondition"],"sources":["../src/useShowOnlyEmptyFilter.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n createFilterConditionFactory,\n createShowOnlyEmptyFilterCondition,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport useTableUtils from './useTableUtils';\n\n/**\n * Creates a filter condition factory that can be toggle on or off. If on, the\n * filter will match only values that are null or empty strings. If off, the\n * filter will match all values.\n * @param isOn Whether the filter is on or off\n * @param columnNames Column names to filter\n */\nexport function useShowOnlyEmptyFilter(\n isOn: boolean,\n columnNames: string | string[]\n): FilterConditionFactory {\n const tableUtils = useTableUtils();\n\n const createColumnCondition = useMemo(\n () => createShowOnlyEmptyFilterCondition(tableUtils, isOn),\n [isOn, tableUtils]\n );\n\n return useMemo(\n () => createFilterConditionFactory(columnNames, createColumnCondition),\n [columnNames, createColumnCondition]\n );\n}\n\nexport default useShowOnlyEmptyFilter;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,4BAA4B,EAC5BC,kCAAkC,QAE7B,wBAAwB;AAAC,OACzBC,aAAa;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,IAAa,EACbC,WAA8B,EACN;EACxB,IAAMC,UAAU,GAAGJ,aAAa,CAAC,CAAC;EAElC,IAAMK,qBAAqB,GAAGR,OAAO,CACnC,MAAME,kCAAkC,CAACK,UAAU,EAAEF,IAAI,CAAC,EAC1D,CAACA,IAAI,EAAEE,UAAU,CACnB,CAAC;EAED,OAAOP,OAAO,CACZ,MAAMC,4BAA4B,CAACK,WAAW,EAAEE,qBAAqB,CAAC,EACtE,CAACF,WAAW,EAAEE,qBAAqB,CACrC,CAAC;AACH;AAEA,eAAeJ,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"useShowOnlyEmptyFilter.js","names":["useMemo","createFilterConditionFactory","createShowOnlyEmptyFilterCondition","useTableUtils","useShowOnlyEmptyFilter","isOn","columnNames","tableUtils","createColumnCondition"],"sources":["../src/useShowOnlyEmptyFilter.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n createFilterConditionFactory,\n createShowOnlyEmptyFilterCondition,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport useTableUtils from './useTableUtils';\n\n/**\n * Creates a filter condition factory that can be toggle on or off. If on, the\n * filter will match only values that are null or empty strings. If off, the\n * filter will match all values.\n * @param isOn Whether the filter is on or off\n * @param columnNames Column names to filter\n */\nexport function useShowOnlyEmptyFilter(\n isOn: boolean,\n columnNames: string | string[]\n): FilterConditionFactory {\n const tableUtils = useTableUtils();\n\n const createColumnCondition = useMemo(\n () => createShowOnlyEmptyFilterCondition(tableUtils, isOn),\n [isOn, tableUtils]\n );\n\n return useMemo(\n () => createFilterConditionFactory(columnNames, createColumnCondition),\n [columnNames, createColumnCondition]\n );\n}\n\nexport default useShowOnlyEmptyFilter;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,4BAA4B,EAC5BC,kCAAkC,QAE7B,wBAAwB;AAAC,OACzBC,aAAa;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,IAAa,EACbC,WAA8B,EACN;EACxB,IAAMC,UAAU,GAAGJ,aAAa,CAAC,CAAC;EAElC,IAAMK,qBAAqB,GAAGR,OAAO,CACnC,MAAME,kCAAkC,CAACK,UAAU,EAAEF,IAAI,CAAC,EAC1D,CAACA,IAAI,EAAEE,UAAU,CACnB,CAAC;EAED,OAAOP,OAAO,CACZ,MAAMC,4BAA4B,CAACK,WAAW,EAAEE,qBAAqB,CAAC,EACtE,CAACF,WAAW,EAAEE,qBAAqB,CACrC,CAAC;AACH;AAEA,eAAeJ,sBAAsB","ignoreList":[]}
|
package/dist/useTable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTable.d.ts","sourceRoot":"","sources":["../src/useTable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"useTable.d.ts","sourceRoot":"","sources":["../src/useTable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AASjD,QAAA,MAAM,QAAQ,UACL,EAAE,CAAC,KAAK,GAAG,SAAS,YACjB,MAAM,WACP,MAAM,gBACD,MAAM,EAAE,KACrB;IACD,OAAO,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CA2DrB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/dist/useTable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTable.js","names":["useCallback","useEffect","useState","useApi","Log","useTableListener","ColumnNameError","TableDisconnectError","log","module","useTable","table","firstRow","lastRow","columnNames","dh","columns","setColumns","undefined","data","setData","columnError","setColumnError","tableError","setTableError","findColumns","e","error","debug2","setViewport","handleUpdate","_ref","detail","viewportData","map","column","rows","r","get","handleDisconnect","handleReconnect","Table","EVENT_UPDATED","EVENT_DISCONNECT","EVENT_RECONNECT"],"sources":["../src/useTable.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport type { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport useTableListener from './useTableListener';\nimport ColumnNameError from './ColumnNameError';\nimport TableDisconnectError from './TableDisconnectError';\n\nconst log = Log.module('useTable');\n\nconst useTable = (\n table: dh.Table | undefined,\n firstRow: number,\n lastRow: number,\n columnNames?: string[]\n): {\n columns: dh.Column[] | undefined;\n data: unknown[][];\n error: Error | null;\n} => {\n const dh = useApi();\n const [columns, setColumns] = useState<dh.Column[] | undefined>(undefined);\n const [data, setData] = useState<unknown[][]>([]);\n const [columnError, setColumnError] = useState<Error | null>(null);\n const [tableError, setTableError] = useState<Error | null>(null);\n\n useEffect(() => {\n if (columnNames === undefined) {\n setColumns(table?.columns);\n setColumnError(null);\n return;\n }\n try {\n setColumns(table?.findColumns(columnNames));\n setColumnError(null);\n } catch (e) {\n log.error(`Column not found`, e, columnNames);\n setColumnError(new ColumnNameError('Invalid columnNames argument'));\n }\n }, [table, columnNames]);\n\n useEffect(() => {\n if (!columns || !table) {\n log.debug2('Table or column not initialized, skip viewport update.');\n return;\n }\n log.debug2('Setting viewport', firstRow, lastRow);\n table.setViewport(firstRow, lastRow, columns);\n }, [columns, table, firstRow, lastRow]);\n\n const handleUpdate = useCallback(\n ({ detail }) => {\n if (!columns) {\n log.error('Columns not initialized.');\n return;\n }\n const viewportData = columns.map(column =>\n
|
|
1
|
+
{"version":3,"file":"useTable.js","names":["useCallback","useEffect","useState","useApi","Log","useTableListener","ColumnNameError","TableDisconnectError","log","module","useTable","table","firstRow","lastRow","columnNames","dh","columns","setColumns","undefined","data","setData","columnError","setColumnError","tableError","setTableError","findColumns","e","error","debug2","setViewport","handleUpdate","_ref","detail","viewportData","map","column","rows","r","get","handleDisconnect","handleReconnect","Table","EVENT_UPDATED","EVENT_DISCONNECT","EVENT_RECONNECT"],"sources":["../src/useTable.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { type OnTableUpdatedEvent } from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport useTableListener from './useTableListener';\nimport ColumnNameError from './ColumnNameError';\nimport TableDisconnectError from './TableDisconnectError';\n\nconst log = Log.module('useTable');\n\nconst useTable = (\n table: dh.Table | undefined,\n firstRow: number,\n lastRow: number,\n columnNames?: string[]\n): {\n columns: dh.Column[] | undefined;\n data: unknown[][];\n error: Error | null;\n} => {\n const dh = useApi();\n const [columns, setColumns] = useState<dh.Column[] | undefined>(undefined);\n const [data, setData] = useState<unknown[][]>([]);\n const [columnError, setColumnError] = useState<Error | null>(null);\n const [tableError, setTableError] = useState<Error | null>(null);\n\n useEffect(() => {\n if (columnNames === undefined) {\n setColumns(table?.columns);\n setColumnError(null);\n return;\n }\n try {\n setColumns(table?.findColumns(columnNames));\n setColumnError(null);\n } catch (e) {\n log.error(`Column not found`, e, columnNames);\n setColumnError(new ColumnNameError('Invalid columnNames argument'));\n }\n }, [table, columnNames]);\n\n useEffect(() => {\n if (!columns || !table) {\n log.debug2('Table or column not initialized, skip viewport update.');\n return;\n }\n log.debug2('Setting viewport', firstRow, lastRow);\n table.setViewport(firstRow, lastRow, columns);\n }, [columns, table, firstRow, lastRow]);\n\n const handleUpdate = useCallback(\n ({ detail }: OnTableUpdatedEvent) => {\n if (!columns) {\n log.error('Columns not initialized.');\n return;\n }\n const viewportData = columns.map(column =>\n detail.rows.map(r => r.get(column))\n );\n setData(viewportData);\n },\n [columns]\n );\n\n const handleDisconnect = useCallback(() => {\n setTableError(new TableDisconnectError('Table disconnected'));\n }, []);\n\n const handleReconnect = useCallback(() => {\n setTableError(null);\n }, []);\n\n useTableListener(table, dh.Table.EVENT_UPDATED, handleUpdate);\n useTableListener(table, dh.Table.EVENT_DISCONNECT, handleDisconnect);\n useTableListener(table, dh.Table.EVENT_RECONNECT, handleReconnect);\n\n return { columns, data, error: tableError ?? columnError };\n};\n\nexport default useTable;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACxD,SAASC,MAAM,QAAQ,4BAA4B;AAGnD,OAAOC,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,gBAAgB;AAAA,OAChBC,eAAe;AAAA,OACfC,oBAAoB;AAE3B,IAAMC,GAAG,GAAGJ,GAAG,CAACK,MAAM,CAAC,UAAU,CAAC;AAElC,IAAMC,QAAQ,GAAGA,CACfC,KAA2B,EAC3BC,QAAgB,EAChBC,OAAe,EACfC,WAAsB,KAKnB;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,OAAO,CAAC,CAAC;EAEvC,IAAMiB,YAAY,GAAG9B,WAAW,CAC9B+B,IAAA,IAAqC;IAAA,IAApC;MAAEC;IAA4B,CAAC,GAAAD,IAAA;IAC9B,IAAI,CAACf,OAAO,EAAE;MACZR,GAAG,CAACmB,KAAK,CAAC,0BAA0B,CAAC;MACrC;IACF;IACA,IAAMM,YAAY,GAAGjB,OAAO,CAACkB,GAAG,CAACC,MAAM,IACrCH,MAAM,CAACI,IAAI,CAACF,GAAG,CAACG,CAAC,IAAIA,CAAC,CAACC,GAAG,CAACH,MAAM,CAAC,CACpC,CAAC;IACDf,OAAO,CAACa,YAAY,CAAC;EACvB,CAAC,EACD,CAACjB,OAAO,CACV,CAAC;EAED,IAAMuB,gBAAgB,GAAGvC,WAAW,CAAC,MAAM;IACzCwB,aAAa,CAAC,IAAIjB,oBAAoB,CAAC,oBAAoB,CAAC,CAAC;EAC/D,CAAC,EAAE,EAAE,CAAC;EAEN,IAAMiC,eAAe,GAAGxC,WAAW,CAAC,MAAM;IACxCwB,aAAa,CAAC,IAAI,CAAC;EACrB,CAAC,EAAE,EAAE,CAAC;EAENnB,gBAAgB,CAACM,KAAK,EAAEI,EAAE,CAAC0B,KAAK,CAACC,aAAa,EAAEZ,YAAY,CAAC;EAC7DzB,gBAAgB,CAACM,KAAK,EAAEI,EAAE,CAAC0B,KAAK,CAACE,gBAAgB,EAAEJ,gBAAgB,CAAC;EACpElC,gBAAgB,CAACM,KAAK,EAAEI,EAAE,CAAC0B,KAAK,CAACG,eAAe,EAAEJ,eAAe,CAAC;EAElE,OAAO;IAAExB,OAAO;IAAEG,IAAI;IAAEQ,KAAK,EAAEJ,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAIF;EAAY,CAAC;AAC5D,CAAC;AAED,eAAeX,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableColumn.js","names":["useMemo","useTable","useTableColumn","table","firstRow","lastRow","columnName","columnNames","columns","data","error","column"],"sources":["../src/useTableColumn.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport useTable from './useTable';\n\n/**\n * Subscribe to viewport updates on a single table column\n * @param table Table to get the data from\n * @param firstRow First viewport row\n * @param lastRow Last viewport row\n * @param columnName Column to get the data from\n * @returns Column object, data array for the column, error, setViewport method\n */\nconst useTableColumn = (\n table: dh.Table | undefined,\n firstRow: number,\n lastRow: number,\n columnName: string\n): {\n column: dh.Column | undefined;\n data: unknown[];\n error: Error | null;\n} => {\n const columnNames = useMemo(() => [columnName], [columnName]);\n const {\n columns = [],\n data = [],\n error,\n } = useTable(table, firstRow, lastRow, columnNames);\n return {\n column: columns[0],\n data: data[0],\n error,\n };\n};\n\nexport default useTableColumn;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAAC,OAEzBC,QAAQ;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAGA,CACrBC,KAA2B,EAC3BC,QAAgB,EAChBC,OAAe,EACfC,UAAkB,KAKf;EACH,IAAMC,WAAW,GAAGP,OAAO,CAAC,MAAM,CAACM,UAAU,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;EAC7D,IAAM;IACJE,OAAO,GAAG,EAAE;IACZC,IAAI,GAAG,EAAE;IACTC;EACF,CAAC,GAAGT,QAAQ,CAACE,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEE,WAAW,CAAC;EACnD,OAAO;IACLI,MAAM,EAAEH,OAAO,CAAC,CAAC,CAAC;IAClBC,IAAI,EAAEA,IAAI,CAAC,CAAC,CAAC;IACbC;EACF,CAAC;AACH,CAAC;AAED,eAAeR,cAAc"}
|
|
1
|
+
{"version":3,"file":"useTableColumn.js","names":["useMemo","useTable","useTableColumn","table","firstRow","lastRow","columnName","columnNames","columns","data","error","column"],"sources":["../src/useTableColumn.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport useTable from './useTable';\n\n/**\n * Subscribe to viewport updates on a single table column\n * @param table Table to get the data from\n * @param firstRow First viewport row\n * @param lastRow Last viewport row\n * @param columnName Column to get the data from\n * @returns Column object, data array for the column, error, setViewport method\n */\nconst useTableColumn = (\n table: dh.Table | undefined,\n firstRow: number,\n lastRow: number,\n columnName: string\n): {\n column: dh.Column | undefined;\n data: unknown[];\n error: Error | null;\n} => {\n const columnNames = useMemo(() => [columnName], [columnName]);\n const {\n columns = [],\n data = [],\n error,\n } = useTable(table, firstRow, lastRow, columnNames);\n return {\n column: columns[0],\n data: data[0],\n error,\n };\n};\n\nexport default useTableColumn;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAAC,OAEzBC,QAAQ;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAGA,CACrBC,KAA2B,EAC3BC,QAAgB,EAChBC,OAAe,EACfC,UAAkB,KAKf;EACH,IAAMC,WAAW,GAAGP,OAAO,CAAC,MAAM,CAACM,UAAU,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;EAC7D,IAAM;IACJE,OAAO,GAAG,EAAE;IACZC,IAAI,GAAG,EAAE;IACTC;EACF,CAAC,GAAGT,QAAQ,CAACE,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEE,WAAW,CAAC;EACnD,OAAO;IACLI,MAAM,EAAEH,OAAO,CAAC,CAAC,CAAC;IAClBC,IAAI,EAAEA,IAAI,CAAC,CAAC,CAAC;IACbC;EACF,CAAC;AACH,CAAC;AAED,eAAeR,cAAc","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableListener.js","names":["useEffect","Log","log","module","useTableListener","eventEmitter","eventName","callback","initEventEmitter","debug2","addEventListener"],"sources":["../src/useTableListener.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\n\nconst log = Log.module('useTableListener');\n\nexport const useTableListener = <T = unknown>(\n eventEmitter: dh.HasEventHandling | undefined | null,\n eventName: string,\n callback: (event: dh.Event<T>) => void\n): void =>\n useEffect(\n function initEventEmitter() {\n if (eventEmitter == null) {\n log.debug2('Emitter undefined, skipping addEventListener', eventName);\n return;\n }\n log.debug2('Adding listener', eventName);\n return eventEmitter.addEventListener(eventName, callback);\n },\n [eventEmitter, eventName, callback]\n );\n\nexport default useTableListener;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,OAAOC,GAAG,MAAM,gBAAgB;AAEhC,IAAMC,GAAG,GAAGD,GAAG,CAACE,MAAM,CAAC,kBAAkB,CAAC;AAE1C,OAAO,IAAMC,gBAAgB,GAAGA,CAC9BC,YAAoD,EACpDC,SAAiB,EACjBC,QAAsC,KAEtCP,SAAS,CACP,SAASQ,gBAAgBA,CAAA,EAAG;EAC1B,IAAIH,YAAY,IAAI,IAAI,EAAE;IACxBH,GAAG,CAACO,MAAM,CAAC,8CAA8C,EAAEH,SAAS,CAAC;IACrE;EACF;EACAJ,GAAG,CAACO,MAAM,CAAC,iBAAiB,EAAEH,SAAS,CAAC;EACxC,OAAOD,YAAY,CAACK,gBAAgB,CAACJ,SAAS,EAAEC,QAAQ,CAAC;AAC3D,CAAC,EACD,CAACF,YAAY,EAAEC,SAAS,EAAEC,QAAQ,CACpC,CAAC;AAEH,eAAeH,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"useTableListener.js","names":["useEffect","Log","log","module","useTableListener","eventEmitter","eventName","callback","initEventEmitter","debug2","addEventListener"],"sources":["../src/useTableListener.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\n\nconst log = Log.module('useTableListener');\n\nexport const useTableListener = <T = unknown>(\n eventEmitter: dh.HasEventHandling | undefined | null,\n eventName: string,\n callback: (event: dh.Event<T>) => void\n): void =>\n useEffect(\n function initEventEmitter() {\n if (eventEmitter == null) {\n log.debug2('Emitter undefined, skipping addEventListener', eventName);\n return;\n }\n log.debug2('Adding listener', eventName);\n return eventEmitter.addEventListener(eventName, callback);\n },\n [eventEmitter, eventName, callback]\n );\n\nexport default useTableListener;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,OAAOC,GAAG,MAAM,gBAAgB;AAEhC,IAAMC,GAAG,GAAGD,GAAG,CAACE,MAAM,CAAC,kBAAkB,CAAC;AAE1C,OAAO,IAAMC,gBAAgB,GAAGA,CAC9BC,YAAoD,EACpDC,SAAiB,EACjBC,QAAsC,KAEtCP,SAAS,CACP,SAASQ,gBAAgBA,CAAA,EAAG;EAC1B,IAAIH,YAAY,IAAI,IAAI,EAAE;IACxBH,GAAG,CAACO,MAAM,CAAC,8CAA8C,EAAEH,SAAS,CAAC;IACrE;EACF;EACAJ,GAAG,CAACO,MAAM,CAAC,iBAAiB,EAAEH,SAAS,CAAC;EACxC,OAAOD,YAAY,CAACK,gBAAgB,CAACJ,SAAS,EAAEC,QAAQ,CAAC;AAC3D,CAAC,EACD,CAACF,YAAY,EAAEC,SAAS,EAAEC,QAAQ,CACpC,CAAC;AAEH,eAAeH,gBAAgB","ignoreList":[]}
|
package/dist/useTableSize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableSize.js","names":["useCallback","useState","useApi","getSize","useTableListener","useTableSize","table","forceRerender","dh","onSizeChanged","i","Table","EVENT_SIZECHANGED"],"sources":["../src/useTableSize.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { getSize } from '@deephaven/jsapi-utils';\nimport useTableListener from './useTableListener';\n\n/**\n * React hook that returns the size of a given table or zero if table is null or\n * undefined. The hook subscribes to the dh.Table.EVENT_SIZECHANGED event and\n * triggers a re-render if any events are received to ensure we have the current\n * size.\n * @param table The table to check the size on.\n */\nexport function useTableSize(\n table: dh.Table | dh.TreeTable | null | undefined\n): number {\n const [, forceRerender] = useState(0);\n\n const dh = useApi();\n\n const onSizeChanged = useCallback(() => {\n forceRerender(i => i + 1);\n }, []);\n\n useTableListener(table, dh.Table.EVENT_SIZECHANGED, onSizeChanged);\n\n return getSize(table);\n}\n\nexport default useTableSize;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAC7C,SAASC,MAAM,QAAQ,4BAA4B;AAEnD,SAASC,OAAO,QAAQ,wBAAwB;AAAC,OAC1CC,gBAAgB;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAC1BC,KAAiD,EACzC;EACR,IAAM,GAAGC,aAAa,CAAC,GAAGN,QAAQ,CAAC,CAAC,CAAC;EAErC,IAAMO,EAAE,GAAGN,MAAM,CAAC,CAAC;EAEnB,IAAMO,aAAa,GAAGT,WAAW,CAAC,MAAM;IACtCO,aAAa,CAACG,CAAC,IAAIA,CAAC,GAAG,CAAC,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAENN,gBAAgB,CAACE,KAAK,EAAEE,EAAE,CAACG,KAAK,CAACC,iBAAiB,EAAEH,aAAa,CAAC;EAElE,OAAON,OAAO,CAACG,KAAK,CAAC;AACvB;AAEA,eAAeD,YAAY"}
|
|
1
|
+
{"version":3,"file":"useTableSize.js","names":["useCallback","useState","useApi","getSize","useTableListener","useTableSize","table","forceRerender","dh","onSizeChanged","i","Table","EVENT_SIZECHANGED"],"sources":["../src/useTableSize.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { getSize } from '@deephaven/jsapi-utils';\nimport useTableListener from './useTableListener';\n\n/**\n * React hook that returns the size of a given table or zero if table is null or\n * undefined. The hook subscribes to the dh.Table.EVENT_SIZECHANGED event and\n * triggers a re-render if any events are received to ensure we have the current\n * size.\n * @param table The table to check the size on.\n */\nexport function useTableSize(\n table: dh.Table | dh.TreeTable | null | undefined\n): number {\n const [, forceRerender] = useState(0);\n\n const dh = useApi();\n\n const onSizeChanged = useCallback(() => {\n forceRerender(i => i + 1);\n }, []);\n\n useTableListener(table, dh.Table.EVENT_SIZECHANGED, onSizeChanged);\n\n return getSize(table);\n}\n\nexport default useTableSize;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAC7C,SAASC,MAAM,QAAQ,4BAA4B;AAEnD,SAASC,OAAO,QAAQ,wBAAwB;AAAC,OAC1CC,gBAAgB;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAC1BC,KAAiD,EACzC;EACR,IAAM,GAAGC,aAAa,CAAC,GAAGN,QAAQ,CAAC,CAAC,CAAC;EAErC,IAAMO,EAAE,GAAGN,MAAM,CAAC,CAAC;EAEnB,IAAMO,aAAa,GAAGT,WAAW,CAAC,MAAM;IACtCO,aAAa,CAACG,CAAC,IAAIA,CAAC,GAAG,CAAC,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAENN,gBAAgB,CAACE,KAAK,EAAEE,EAAE,CAACG,KAAK,CAACC,iBAAiB,EAAEH,aAAa,CAAC;EAElE,OAAON,OAAO,CAACG,KAAK,CAAC;AACvB;AAEA,eAAeD,YAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableUtils.js","names":["useMemo","useApi","TableUtils","useTableUtils","dh"],"sources":["../src/useTableUtils.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport { TableUtils } from '@deephaven/jsapi-utils';\n\n/**\n * Get a `TableUtils` instance using `dh` api from the current context.\n */\nexport function useTableUtils(): TableUtils {\n const dh = useApi();\n return useMemo(() => new TableUtils(dh), [dh]);\n}\n\nexport default useTableUtils;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SAASC,UAAU,QAAQ,wBAAwB;;AAEnD;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAA,EAAe;EAC1C,IAAMC,EAAE,GAAGH,MAAM,CAAC,CAAC;EACnB,OAAOD,OAAO,CAAC,MAAM,IAAIE,UAAU,CAACE,EAAE,CAAC,EAAE,CAACA,EAAE,CAAC,CAAC;AAChD;AAEA,eAAeD,aAAa"}
|
|
1
|
+
{"version":3,"file":"useTableUtils.js","names":["useMemo","useApi","TableUtils","useTableUtils","dh"],"sources":["../src/useTableUtils.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport { TableUtils } from '@deephaven/jsapi-utils';\n\n/**\n * Get a `TableUtils` instance using `dh` api from the current context.\n */\nexport function useTableUtils(): TableUtils {\n const dh = useApi();\n return useMemo(() => new TableUtils(dh), [dh]);\n}\n\nexport default useTableUtils;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SAASC,UAAU,QAAQ,wBAAwB;;AAEnD;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAA,EAAe;EAC1C,IAAMC,EAAE,GAAGH,MAAM,CAAC,CAAC;EACnB,OAAOD,OAAO,CAAC,MAAM,IAAIE,UAAU,CAACE,EAAE,CAAC,EAAE,CAACA,EAAE,CAAC,CAAC;AAChD;AAEA,eAAeD,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useValueFilter.js","names":["useMemo","createValueFilter","useTableUtils","useValueFilter","columnNames","value","operator","tableUtils"],"sources":["../src/useValueFilter.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n createValueFilter,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport useTableUtils from './useTableUtils';\n\n/**\n * Create a filter condition factory for a filter operator that matches the given value.\n * @param columnNames Column names to compare value to\n * @param value Value to match\n * @param operator Operator to use for matching\n */\nexport function useValueFilter(\n columnNames: string | string[],\n value: string,\n operator: 'contains' | 'eq' | 'notEq'\n): FilterConditionFactory {\n const tableUtils = useTableUtils();\n\n return useMemo(\n () => createValueFilter(tableUtils, columnNames, value, operator),\n [columnNames, operator, tableUtils, value]\n );\n}\n\nexport default useValueFilter;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,iBAAiB,QAEZ,wBAAwB;AAAC,OACzBC,aAAa;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,WAA8B,EAC9BC,KAAa,EACbC,QAAqC,EACb;EACxB,IAAMC,UAAU,GAAGL,aAAa,CAAC,CAAC;EAElC,OAAOF,OAAO,CACZ,MAAMC,iBAAiB,CAACM,UAAU,EAAEH,WAAW,EAAEC,KAAK,EAAEC,QAAQ,CAAC,EACjE,CAACF,WAAW,EAAEE,QAAQ,EAAEC,UAAU,EAAEF,KAAK,CAC3C,CAAC;AACH;AAEA,eAAeF,cAAc"}
|
|
1
|
+
{"version":3,"file":"useValueFilter.js","names":["useMemo","createValueFilter","useTableUtils","useValueFilter","columnNames","value","operator","tableUtils"],"sources":["../src/useValueFilter.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n createValueFilter,\n type FilterConditionFactory,\n} from '@deephaven/jsapi-utils';\nimport useTableUtils from './useTableUtils';\n\n/**\n * Create a filter condition factory for a filter operator that matches the given value.\n * @param columnNames Column names to compare value to\n * @param value Value to match\n * @param operator Operator to use for matching\n */\nexport function useValueFilter(\n columnNames: string | string[],\n value: string,\n operator: 'contains' | 'eq' | 'notEq'\n): FilterConditionFactory {\n const tableUtils = useTableUtils();\n\n return useMemo(\n () => createValueFilter(tableUtils, columnNames, value, operator),\n [columnNames, operator, tableUtils, value]\n );\n}\n\nexport default useValueFilter;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,iBAAiB,QAEZ,wBAAwB;AAAC,OACzBC,aAAa;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,WAA8B,EAC9BC,KAAa,EACbC,QAAqC,EACb;EACxB,IAAMC,UAAU,GAAGL,aAAa,CAAC,CAAC;EAElC,OAAOF,OAAO,CACZ,MAAMC,iBAAiB,CAACM,UAAU,EAAEH,WAAW,EAAEC,KAAK,EAAEC,QAAQ,CAAC,EACjE,CAACF,WAAW,EAAEE,QAAQ,EAAEC,UAAU,EAAEF,KAAK,CAC3C,CAAC;AACH;AAEA,eAAeF,cAAc","ignoreList":[]}
|
package/dist/useViewportData.js
CHANGED
|
@@ -66,7 +66,7 @@ export function useViewportData(_ref) {
|
|
|
66
66
|
onTableUpdatedRef.current = useMemo(() => createOnTableUpdatedHandler(viewportData, deserializeRow), [deserializeRow, viewportData]);
|
|
67
67
|
var onTableUpdated = useCallback(event => {
|
|
68
68
|
var _onTableUpdatedRef$cu;
|
|
69
|
-
(_onTableUpdatedRef$cu = onTableUpdatedRef.current) === null || _onTableUpdatedRef$cu === void 0
|
|
69
|
+
(_onTableUpdatedRef$cu = onTableUpdatedRef.current) === null || _onTableUpdatedRef$cu === void 0 || _onTableUpdatedRef$cu.call(onTableUpdatedRef, event);
|
|
70
70
|
}, []);
|
|
71
71
|
useTableListener(table, dh.Table.EVENT_UPDATED, onTableUpdated);
|
|
72
72
|
var size = useTableSize(table);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewportData.js","names":["useCallback","useEffect","useMemo","useRef","defaultRowDeserializer","isClosed","createOnTableUpdatedHandler","Log","useApi","useOnScrollOffsetChangeCallback","useInitializeViewportData","useSetPaddedViewportCallback","useTableSize","useTableListener","SCROLL_DEBOUNCE_MS","log","module","useViewportData","_ref","table","itemHeight","scrollDebounce","viewportSize","viewportPadding","deserializeRow","reuseItemsOnTableResize","currentViewportFirstRowRef","viewportData","setPaddedViewport","setViewport","firstRow","current","debug","applyFiltersAndRefresh","filters","applyFilter","dh","onTableUpdatedRef","onTableUpdated","event","_onTableUpdatedRef$cu","call","Table","EVENT_UPDATED","size","onScroll"],"sources":["../src/useViewportData.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport {\n type RowDeserializer,\n defaultRowDeserializer,\n isClosed,\n createOnTableUpdatedHandler,\n type OnTableUpdatedEvent,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport {\n useOnScrollOffsetChangeCallback,\n type WindowedListData,\n} from '@deephaven/react-hooks';\nimport { type KeyedItem } from '@deephaven/utils';\nimport useInitializeViewportData from './useInitializeViewportData';\nimport useSetPaddedViewportCallback from './useSetPaddedViewportCallback';\nimport useTableSize from './useTableSize';\nimport useTableListener from './useTableListener';\nimport { SCROLL_DEBOUNCE_MS } from './Constants';\n\nconst log = Log.module('useViewportData');\n\nexport interface UseViewportDataProps<\n TItem,\n TTable extends dh.Table | dh.TreeTable,\n> {\n reuseItemsOnTableResize?: boolean;\n table: TTable | null;\n itemHeight?: number;\n scrollDebounce?: number;\n viewportPadding?: number;\n viewportSize?: number;\n deserializeRow?: RowDeserializer<TItem>;\n}\n\nexport interface UseViewportDataResult<\n TItem,\n TTable extends dh.Table | dh.TreeTable,\n> {\n /** Manages deserialized row items associated with a DH Table */\n viewportData: WindowedListData<KeyedItem<TItem>>;\n /** Size of the underlying Table */\n size: number;\n\n table: TTable | null;\n /** Apply filters and refresh viewport. */\n applyFiltersAndRefresh: (filters: dh.FilterCondition[]) => void;\n /** Set the viewport of the Table */\n setViewport: (firstRow: number) => void;\n /** Handler for scroll events to update viewport */\n onScroll: (event: Event) => void;\n}\n\n/**\n * Sets up state management for windowed Table viewports. Returns a ListData\n * instance for managing items associated with the Table + a `setViewport`\n * callback for changing the current viewport.\n *\n * IMPORTANT: this will create an empty KeyedItem object for every row in the\n * source table. This is intended for \"human\" sized tables such as those used in\n * admin panels. This is not suitable for \"machine\" scale with millions+ rows.\n * @param table The Table to viewport.\n * @param itemHeight The height of each item in the viewport.\n * @param scrollDebounce The number of milliseconds to debounce scroll events.\n * @param viewportSize The number of items to display in the viewport.\n * @param viewportPadding The number of items to fetch at start and end of the viewport.\n * @param deserializeRow A function to deserialize a row from the Table.\n * @param reuseItemsOnTableResize If true, existing items will be re-used when\n * the table size changes.\n * @returns An object for managing Table viewport state.\n */\nexport function useViewportData<TItem, TTable extends dh.Table | dh.TreeTable>({\n table,\n itemHeight = 1,\n scrollDebounce = SCROLL_DEBOUNCE_MS,\n viewportSize = 10,\n viewportPadding = 50,\n deserializeRow = defaultRowDeserializer,\n reuseItemsOnTableResize = false,\n}: UseViewportDataProps<TItem, TTable>): UseViewportDataResult<TItem, TTable> {\n const currentViewportFirstRowRef = useRef<number>(0);\n\n const viewportData = useInitializeViewportData<TItem>(\n table,\n reuseItemsOnTableResize\n );\n\n const setPaddedViewport = useSetPaddedViewportCallback(\n table,\n viewportSize,\n viewportPadding\n );\n\n const setViewport = useCallback(\n (firstRow: number) => {\n currentViewportFirstRowRef.current = firstRow;\n\n if (table && !isClosed(table)) {\n setPaddedViewport(firstRow);\n } else {\n log.debug('setViewport called on closed table.', table);\n }\n },\n [table, setPaddedViewport]\n );\n\n const applyFiltersAndRefresh = useCallback(\n (filters: dh.FilterCondition[]) => {\n if (table && !isClosed(table)) {\n table.applyFilter(filters);\n setViewport(0);\n } else {\n log.debug('applyFiltersAndRefresh called on closed table.', table);\n }\n },\n [setViewport, table]\n );\n\n const dh = useApi();\n\n // Store the memoized callback in a ref so that changes to `viewportData`\n // don't invalidate the memoization of `onTableUpdated`. This prevents\n // `useTableListener` from unnecessarily re-subscribing to the same event over\n // and over.\n const onTableUpdatedRef = useRef<(event: OnTableUpdatedEvent) => void>();\n onTableUpdatedRef.current = useMemo(\n () => createOnTableUpdatedHandler(viewportData, deserializeRow),\n [deserializeRow, viewportData]\n );\n\n const onTableUpdated = useCallback((event: OnTableUpdatedEvent) => {\n onTableUpdatedRef.current?.(event);\n }, []);\n\n useTableListener(table, dh.Table.EVENT_UPDATED, onTableUpdated);\n\n const size = useTableSize(table);\n\n useEffect(() => {\n log.debug('Initializing viewport');\n\n // Hydrate the viewport with real data. This will fetch data from index\n // 0 to the end of the viewport + padding.\n setViewport(0);\n }, [table, setViewport]);\n\n useEffect(() => {\n setViewport(currentViewportFirstRowRef.current);\n }, [setViewport, size]);\n\n const onScroll = useOnScrollOffsetChangeCallback(\n itemHeight,\n setViewport,\n scrollDebounce\n );\n\n return useMemo(\n () => ({\n viewportData,\n size,\n table,\n applyFiltersAndRefresh,\n setViewport,\n onScroll,\n }),\n [applyFiltersAndRefresh, onScroll, setViewport, size, table, viewportData]\n );\n}\n\nexport default useViewportData;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE/D,SAEEC,sBAAsB,EACtBC,QAAQ,EACRC,2BAA2B,QAEtB,wBAAwB;AAC/B,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SACEC,+BAA+B,QAE1B,wBAAwB;AAAC,OAEzBC,yBAAyB;AAAA,OACzBC,4BAA4B;AAAA,OAC5BC,YAAY;AAAA,OACZC,gBAAgB;AAAA,SACdC,kBAAkB;AAE3B,IAAMC,GAAG,GAAGR,GAAG,CAACS,MAAM,CAAC,iBAAiB,CAAC;AAiCzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAAAC,IAAA,EAQ+C;EAAA,IARC;IAC7EC,KAAK;IACLC,UAAU,GAAG,CAAC;IACdC,cAAc,GAAGP,kBAAkB;IACnCQ,YAAY,GAAG,EAAE;IACjBC,eAAe,GAAG,EAAE;IACpBC,cAAc,GAAGpB,sBAAsB;IACvCqB,uBAA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,IAAAC,qBAAA;IACjE,CAAAA,qBAAA,GAAAH,iBAAiB,CAACN,OAAO,cAAAS,qBAAA,
|
|
1
|
+
{"version":3,"file":"useViewportData.js","names":["useCallback","useEffect","useMemo","useRef","defaultRowDeserializer","isClosed","createOnTableUpdatedHandler","Log","useApi","useOnScrollOffsetChangeCallback","useInitializeViewportData","useSetPaddedViewportCallback","useTableSize","useTableListener","SCROLL_DEBOUNCE_MS","log","module","useViewportData","_ref","table","itemHeight","scrollDebounce","viewportSize","viewportPadding","deserializeRow","reuseItemsOnTableResize","currentViewportFirstRowRef","viewportData","setPaddedViewport","setViewport","firstRow","current","debug","applyFiltersAndRefresh","filters","applyFilter","dh","onTableUpdatedRef","onTableUpdated","event","_onTableUpdatedRef$cu","call","Table","EVENT_UPDATED","size","onScroll"],"sources":["../src/useViewportData.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport {\n type RowDeserializer,\n defaultRowDeserializer,\n isClosed,\n createOnTableUpdatedHandler,\n type OnTableUpdatedEvent,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport {\n useOnScrollOffsetChangeCallback,\n type WindowedListData,\n} from '@deephaven/react-hooks';\nimport { type KeyedItem } from '@deephaven/utils';\nimport useInitializeViewportData from './useInitializeViewportData';\nimport useSetPaddedViewportCallback from './useSetPaddedViewportCallback';\nimport useTableSize from './useTableSize';\nimport useTableListener from './useTableListener';\nimport { SCROLL_DEBOUNCE_MS } from './Constants';\n\nconst log = Log.module('useViewportData');\n\nexport interface UseViewportDataProps<\n TItem,\n TTable extends dh.Table | dh.TreeTable,\n> {\n reuseItemsOnTableResize?: boolean;\n table: TTable | null;\n itemHeight?: number;\n scrollDebounce?: number;\n viewportPadding?: number;\n viewportSize?: number;\n deserializeRow?: RowDeserializer<TItem>;\n}\n\nexport interface UseViewportDataResult<\n TItem,\n TTable extends dh.Table | dh.TreeTable,\n> {\n /** Manages deserialized row items associated with a DH Table */\n viewportData: WindowedListData<KeyedItem<TItem>>;\n /** Size of the underlying Table */\n size: number;\n\n table: TTable | null;\n /** Apply filters and refresh viewport. */\n applyFiltersAndRefresh: (filters: dh.FilterCondition[]) => void;\n /** Set the viewport of the Table */\n setViewport: (firstRow: number) => void;\n /** Handler for scroll events to update viewport */\n onScroll: (event: Event) => void;\n}\n\n/**\n * Sets up state management for windowed Table viewports. Returns a ListData\n * instance for managing items associated with the Table + a `setViewport`\n * callback for changing the current viewport.\n *\n * IMPORTANT: this will create an empty KeyedItem object for every row in the\n * source table. This is intended for \"human\" sized tables such as those used in\n * admin panels. This is not suitable for \"machine\" scale with millions+ rows.\n * @param table The Table to viewport.\n * @param itemHeight The height of each item in the viewport.\n * @param scrollDebounce The number of milliseconds to debounce scroll events.\n * @param viewportSize The number of items to display in the viewport.\n * @param viewportPadding The number of items to fetch at start and end of the viewport.\n * @param deserializeRow A function to deserialize a row from the Table.\n * @param reuseItemsOnTableResize If true, existing items will be re-used when\n * the table size changes.\n * @returns An object for managing Table viewport state.\n */\nexport function useViewportData<TItem, TTable extends dh.Table | dh.TreeTable>({\n table,\n itemHeight = 1,\n scrollDebounce = SCROLL_DEBOUNCE_MS,\n viewportSize = 10,\n viewportPadding = 50,\n deserializeRow = defaultRowDeserializer,\n reuseItemsOnTableResize = false,\n}: UseViewportDataProps<TItem, TTable>): UseViewportDataResult<TItem, TTable> {\n const currentViewportFirstRowRef = useRef<number>(0);\n\n const viewportData = useInitializeViewportData<TItem>(\n table,\n reuseItemsOnTableResize\n );\n\n const setPaddedViewport = useSetPaddedViewportCallback(\n table,\n viewportSize,\n viewportPadding\n );\n\n const setViewport = useCallback(\n (firstRow: number) => {\n currentViewportFirstRowRef.current = firstRow;\n\n if (table && !isClosed(table)) {\n setPaddedViewport(firstRow);\n } else {\n log.debug('setViewport called on closed table.', table);\n }\n },\n [table, setPaddedViewport]\n );\n\n const applyFiltersAndRefresh = useCallback(\n (filters: dh.FilterCondition[]) => {\n if (table && !isClosed(table)) {\n table.applyFilter(filters);\n setViewport(0);\n } else {\n log.debug('applyFiltersAndRefresh called on closed table.', table);\n }\n },\n [setViewport, table]\n );\n\n const dh = useApi();\n\n // Store the memoized callback in a ref so that changes to `viewportData`\n // don't invalidate the memoization of `onTableUpdated`. This prevents\n // `useTableListener` from unnecessarily re-subscribing to the same event over\n // and over.\n const onTableUpdatedRef = useRef<(event: OnTableUpdatedEvent) => void>();\n onTableUpdatedRef.current = useMemo(\n () => createOnTableUpdatedHandler(viewportData, deserializeRow),\n [deserializeRow, viewportData]\n );\n\n const onTableUpdated = useCallback((event: OnTableUpdatedEvent) => {\n onTableUpdatedRef.current?.(event);\n }, []);\n\n useTableListener(table, dh.Table.EVENT_UPDATED, onTableUpdated);\n\n const size = useTableSize(table);\n\n useEffect(() => {\n log.debug('Initializing viewport');\n\n // Hydrate the viewport with real data. This will fetch data from index\n // 0 to the end of the viewport + padding.\n setViewport(0);\n }, [table, setViewport]);\n\n useEffect(() => {\n setViewport(currentViewportFirstRowRef.current);\n }, [setViewport, size]);\n\n const onScroll = useOnScrollOffsetChangeCallback(\n itemHeight,\n setViewport,\n scrollDebounce\n );\n\n return useMemo(\n () => ({\n viewportData,\n size,\n table,\n applyFiltersAndRefresh,\n setViewport,\n onScroll,\n }),\n [applyFiltersAndRefresh, onScroll, setViewport, size, table, viewportData]\n );\n}\n\nexport default useViewportData;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE/D,SAEEC,sBAAsB,EACtBC,QAAQ,EACRC,2BAA2B,QAEtB,wBAAwB;AAC/B,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SACEC,+BAA+B,QAE1B,wBAAwB;AAAC,OAEzBC,yBAAyB;AAAA,OACzBC,4BAA4B;AAAA,OAC5BC,YAAY;AAAA,OACZ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,sBAAsB,EAAEY,QAAQ,EAAEhB,WAAW,EAAEe,IAAI,EAAEzB,KAAK,EAAEQ,YAAY,CAC3E,CAAC;AACH;AAEA,eAAeV,eAAe","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewportFilter.js","names":["useEffect","useViewportFilter","viewportData","filter","applyFiltersAndRefresh"],"sources":["../src/useViewportFilter.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { type UseViewportDataResult } from './useViewportData';\n\n/**\n * Applies a filter to a viewport.\n * @param viewportData Viewport to filter\n * @param filter Filter to apply\n */\nexport function useViewportFilter<TItem>(\n viewportData: UseViewportDataResult<TItem, dh.Table>,\n filter: dh.FilterCondition[]\n): void {\n const { applyFiltersAndRefresh } = viewportData;\n\n useEffect(() => {\n applyFiltersAndRefresh(filter);\n }, [applyFiltersAndRefresh, filter]);\n}\n\nexport default useViewportFilter;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAIjC;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,YAAoD,EACpDC,MAA4B,EACtB;EACN,IAAM;IAAEC;EAAuB,CAAC,GAAGF,YAAY;EAE/CF,SAAS,CAAC,MAAM;IACdI,sBAAsB,CAACD,MAAM,CAAC;EAChC,CAAC,EAAE,CAACC,sBAAsB,EAAED,MAAM,CAAC,CAAC;AACtC;AAEA,eAAeF,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"useViewportFilter.js","names":["useEffect","useViewportFilter","viewportData","filter","applyFiltersAndRefresh"],"sources":["../src/useViewportFilter.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { type UseViewportDataResult } from './useViewportData';\n\n/**\n * Applies a filter to a viewport.\n * @param viewportData Viewport to filter\n * @param filter Filter to apply\n */\nexport function useViewportFilter<TItem>(\n viewportData: UseViewportDataResult<TItem, dh.Table>,\n filter: dh.FilterCondition[]\n): void {\n const { applyFiltersAndRefresh } = viewportData;\n\n useEffect(() => {\n applyFiltersAndRefresh(filter);\n }, [applyFiltersAndRefresh, filter]);\n}\n\nexport default useViewportFilter;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAIjC;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,YAAoD,EACpDC,MAA4B,EACtB;EACN,IAAM;IAAEC;EAAuB,CAAC,GAAGF,YAAY;EAE/CF,SAAS,CAAC,MAAM;IACdI,sBAAsB,CAACD,MAAM,CAAC;EAChC,CAAC,EAAE,CAACC,sBAAsB,EAAED,MAAM,CAAC,CAAC;AACtC;AAEA,eAAeF,iBAAiB","ignoreList":[]}
|
package/dist/useWidgetClose.js
CHANGED
|
@@ -13,7 +13,7 @@ export default function useWidgetClose(widget) {
|
|
|
13
13
|
}
|
|
14
14
|
if (!isClosed(widget)) {
|
|
15
15
|
var _widget$close;
|
|
16
|
-
(_widget$close = widget.close) === null || _widget$close === void 0
|
|
16
|
+
(_widget$close = widget.close) === null || _widget$close === void 0 || _widget$close.call(widget);
|
|
17
17
|
}
|
|
18
18
|
}, [widget]);
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWidgetClose.js","names":["useEffect","isClosed","useWidgetClose","widget","_widget$close","close","call","useTableClose"],"sources":["../src/useWidgetClose.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { type WidgetTypes } from '@deephaven/jsapi-bootstrap';\nimport { isClosed } from '@deephaven/jsapi-utils';\n\n/**\n * React hook that closes a given widget when the reference changes or when the\n * component unmounts.\n * @param widget The widget to close\n */\nexport default function useWidgetClose(\n widget: WidgetTypes | null | undefined\n): void {\n useEffect(\n () => () => {\n if (widget == null) {\n return;\n }\n\n if (!isClosed(widget)) {\n widget.close?.();\n }\n },\n [widget]\n );\n}\n\n/**\n * @deprecated Use `useWidgetClose` instead.\n */\nexport const useTableClose = useWidgetClose;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,QAAQ,QAAQ,wBAAwB;;AAEjD;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CACpCC,MAAsC,EAChC;EACNH,SAAS,CACP,MAAM,MAAM;IACV,IAAIG,MAAM,IAAI,IAAI,EAAE;MAClB;IACF;IAEA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC,EAAE;MAAA,IAAAC,aAAA;MACrB,CAAAA,aAAA,GAAAD,MAAM,CAACE,KAAK,cAAAD,aAAA,
|
|
1
|
+
{"version":3,"file":"useWidgetClose.js","names":["useEffect","isClosed","useWidgetClose","widget","_widget$close","close","call","useTableClose"],"sources":["../src/useWidgetClose.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { type WidgetTypes } from '@deephaven/jsapi-bootstrap';\nimport { isClosed } from '@deephaven/jsapi-utils';\n\n/**\n * React hook that closes a given widget when the reference changes or when the\n * component unmounts.\n * @param widget The widget to close\n */\nexport default function useWidgetClose(\n widget: WidgetTypes | null | undefined\n): void {\n useEffect(\n () => () => {\n if (widget == null) {\n return;\n }\n\n if (!isClosed(widget)) {\n widget.close?.();\n }\n },\n [widget]\n );\n}\n\n/**\n * @deprecated Use `useWidgetClose` instead.\n */\nexport const useTableClose = useWidgetClose;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,QAAQ,QAAQ,wBAAwB;;AAEjD;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CACpCC,MAAsC,EAChC;EACNH,SAAS,CACP,MAAM,MAAM;IACV,IAAIG,MAAM,IAAI,IAAI,EAAE;MAClB;IACF;IAEA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC,EAAE;MAAA,IAAAC,aAAA;MACrB,CAAAA,aAAA,GAAAD,MAAM,CAACE,KAAK,cAAAD,aAAA,eAAZA,aAAA,CAAAE,IAAA,CAAAH,MAAe,CAAC;IAClB;EACF,CAAC,EACD,CAACA,MAAM,CACT,CAAC;AACH;;AAEA;AACA;AACA;AACA,OAAO,IAAMI,aAAa,GAAGL,cAAc","ignoreList":[]}
|