@deephaven/components 0.82.0 → 0.82.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/spectrum/comboBox/ComboBox.d.ts +7 -0
  6. package/dist/spectrum/comboBox/ComboBox.d.ts.map +1 -0
  7. package/dist/spectrum/comboBox/ComboBox.js +41 -0
  8. package/dist/spectrum/comboBox/ComboBox.js.map +1 -0
  9. package/dist/spectrum/comboBox/index.d.ts +2 -0
  10. package/dist/spectrum/comboBox/index.d.ts.map +1 -0
  11. package/dist/spectrum/comboBox/index.js +2 -0
  12. package/dist/spectrum/comboBox/index.js.map +1 -0
  13. package/dist/spectrum/index.d.ts +1 -1
  14. package/dist/spectrum/index.d.ts.map +1 -1
  15. package/dist/spectrum/index.js +1 -1
  16. package/dist/spectrum/index.js.map +1 -1
  17. package/dist/spectrum/picker/Picker.d.ts +2 -25
  18. package/dist/spectrum/picker/Picker.d.ts.map +1 -1
  19. package/dist/spectrum/picker/Picker.js +21 -67
  20. package/dist/spectrum/picker/Picker.js.map +1 -1
  21. package/dist/spectrum/picker/PickerNormalized.d.ts +1 -8
  22. package/dist/spectrum/picker/PickerNormalized.d.ts.map +1 -1
  23. package/dist/spectrum/picker/PickerNormalized.js +2 -2
  24. package/dist/spectrum/picker/PickerNormalized.js.map +1 -1
  25. package/dist/spectrum/picker/PickerProps.d.ts +64 -0
  26. package/dist/spectrum/picker/PickerProps.d.ts.map +1 -0
  27. package/dist/spectrum/picker/PickerProps.js +2 -0
  28. package/dist/spectrum/picker/PickerProps.js.map +1 -0
  29. package/dist/spectrum/picker/index.d.ts +3 -0
  30. package/dist/spectrum/picker/index.d.ts.map +1 -1
  31. package/dist/spectrum/picker/index.js +3 -0
  32. package/dist/spectrum/picker/index.js.map +1 -1
  33. package/dist/spectrum/picker/usePickerItemScale.d.ts +9 -0
  34. package/dist/spectrum/picker/usePickerItemScale.d.ts.map +1 -0
  35. package/dist/spectrum/picker/usePickerItemScale.js +17 -0
  36. package/dist/spectrum/picker/usePickerItemScale.js.map +1 -0
  37. package/dist/spectrum/picker/usePickerProps.d.ts +23 -0
  38. package/dist/spectrum/picker/usePickerProps.d.ts.map +1 -0
  39. package/dist/spectrum/picker/usePickerProps.js +70 -0
  40. package/dist/spectrum/picker/usePickerProps.js.map +1 -0
  41. package/dist/spectrum/utils/index.d.ts +2 -0
  42. package/dist/spectrum/utils/index.d.ts.map +1 -1
  43. package/dist/spectrum/utils/index.js +2 -0
  44. package/dist/spectrum/utils/index.js.map +1 -1
  45. package/dist/spectrum/utils/itemUtils.d.ts +7 -2
  46. package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
  47. package/dist/spectrum/utils/itemUtils.js +13 -0
  48. package/dist/spectrum/utils/itemUtils.js.map +1 -1
  49. package/dist/spectrum/utils/itemWrapperUtils.d.ts.map +1 -1
  50. package/dist/spectrum/utils/itemWrapperUtils.js +2 -2
  51. package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -1
  52. package/dist/spectrum/utils/useOnChangeTrackUncontrolled.d.ts +19 -0
  53. package/dist/spectrum/utils/useOnChangeTrackUncontrolled.d.ts.map +1 -0
  54. package/dist/spectrum/utils/useOnChangeTrackUncontrolled.js +31 -0
  55. package/dist/spectrum/utils/useOnChangeTrackUncontrolled.js.map +1 -0
  56. package/dist/spectrum/utils/useStaticItemInitialScrollPosition.d.ts +10 -0
  57. package/dist/spectrum/utils/useStaticItemInitialScrollPosition.d.ts.map +1 -0
  58. package/dist/spectrum/utils/useStaticItemInitialScrollPosition.js +27 -0
  59. package/dist/spectrum/utils/useStaticItemInitialScrollPosition.js.map +1 -0
  60. package/package.json +7 -7
  61. package/dist/ComboBox.d.ts +0 -120
  62. package/dist/ComboBox.d.ts.map +0 -1
  63. package/dist/ComboBox.js +0 -497
  64. package/dist/ComboBox.js.map +0 -1
  65. package/dist/spectrum/pickers.d.ts +0 -2
  66. package/dist/spectrum/pickers.d.ts.map +0 -1
  67. package/dist/spectrum/pickers.js +0 -2
  68. package/dist/spectrum/pickers.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerItemScale.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerItemScale.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAK3D;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { PICKER_ITEM_HEIGHTS } from '@deephaven/utils';
2
+ import { useSpectrumThemeProvider } from "../../theme/index.js";
3
+ /**
4
+ * Get Picker Item height for current scale.
5
+ * @returns Picker Item height
6
+ */
7
+ export function usePickerItemScale() {
8
+ var {
9
+ scale
10
+ } = useSpectrumThemeProvider();
11
+ var itemHeight = PICKER_ITEM_HEIGHTS[scale];
12
+ return {
13
+ itemHeight
14
+ };
15
+ }
16
+ export default usePickerItemScale;
17
+ //# sourceMappingURL=usePickerItemScale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerItemScale.js","names":["PICKER_ITEM_HEIGHTS","useSpectrumThemeProvider","usePickerItemScale","scale","itemHeight"],"sources":["../../../src/spectrum/picker/usePickerItemScale.ts"],"sourcesContent":["import { PICKER_ITEM_HEIGHTS } from '@deephaven/utils';\nimport { useSpectrumThemeProvider } from '../../theme';\n\n/**\n * Get Picker Item height for current scale.\n * @returns Picker Item height\n */\nexport function usePickerItemScale(): { itemHeight: number } {\n const { scale } = useSpectrumThemeProvider();\n const itemHeight = PICKER_ITEM_HEIGHTS[scale];\n\n return { itemHeight };\n}\n\nexport default usePickerItemScale;\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,kBAAkB;AAAC,SAC9CC,wBAAwB;AAEjC;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAA,EAA2B;EAC3D,IAAM;IAAEC;EAAM,CAAC,GAAGF,wBAAwB,CAAC,CAAC;EAC5C,IAAMG,UAAU,GAAGJ,mBAAmB,CAACG,KAAK,CAAC;EAE7C,OAAO;IAAEC;EAAW,CAAC;AACvB;AAEA,eAAeF,kBAAkB"}
@@ -0,0 +1,23 @@
1
+ import { DOMRef } from '@react-types/shared';
2
+ import { ItemKey, SectionElement, ItemElement } from '../utils';
3
+ import type { PickerPropsT } from './PickerProps';
4
+ /** Props that are derived. */
5
+ export type UsePickerDerivedProps = {
6
+ children: (SectionElement<unknown> | ItemElement<unknown>)[];
7
+ defaultSelectedKey?: ItemKey | undefined;
8
+ selectedKey?: ItemKey | null | undefined;
9
+ scrollRef: DOMRef<HTMLElement>;
10
+ onOpenChange: (isOpen: boolean) => void;
11
+ onSelectionChange: ((key: ItemKey | null) => void) | undefined;
12
+ };
13
+ /** Props that are passed through untouched. */
14
+ export type UsePickerPassthroughProps<TProps> = Omit<PickerPropsT<TProps>, 'children' | 'defaultSelectedKey' | 'selectedKey' | 'tooltip' | 'onChange' | 'onOpenChange' | 'onScroll' | 'onSelectionChange'>;
15
+ export type UsePickerProps<TProps> = UsePickerDerivedProps & UsePickerPassthroughProps<TProps>;
16
+ /**
17
+ * Derive props for Picker components (e.g. Picker and ComboBox). Specifically
18
+ * handles wrapping children items and initial scroll position when the picker
19
+ * is opened.
20
+ */
21
+ export declare function usePickerProps<TProps>({ children, defaultSelectedKey, selectedKey, tooltip, onChange: onChangeHandler, onOpenChange: onOpenChangeHandler, onScroll, onSelectionChange: onSelectionChangeHandler, ...props }: PickerPropsT<TProps>): UsePickerProps<TProps>;
22
+ export default usePickerProps;
23
+ //# sourceMappingURL=usePickerProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerProps.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerProps.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MA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0,0 +1,70 @@
1
+ var _excluded = ["children", "defaultSelectedKey", "selectedKey", "tooltip", "onChange", "onOpenChange", "onScroll", "onSelectionChange"];
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
9
+ import { EMPTY_FUNCTION, ensureArray, PICKER_TOP_OFFSET } from '@deephaven/utils';
10
+ import { useMemo } from 'react';
11
+ import { normalizeTooltipOptions, wrapItemChildren, useOnChangeTrackUncontrolled, useStaticItemInitialScrollPosition } from "../utils/index.js";
12
+ import usePickerItemScale from "./usePickerItemScale.js";
13
+ import usePickerScrollOnOpen from "./usePickerScrollOnOpen.js";
14
+ /** Props that are derived. */
15
+ /** Props that are passed through untouched. */
16
+ /**
17
+ * Derive props for Picker components (e.g. Picker and ComboBox). Specifically
18
+ * handles wrapping children items and initial scroll position when the picker
19
+ * is opened.
20
+ */
21
+ export function usePickerProps(_ref) {
22
+ var {
23
+ children,
24
+ defaultSelectedKey,
25
+ selectedKey,
26
+ tooltip = true,
27
+ onChange: onChangeHandler,
28
+ onOpenChange: onOpenChangeHandler,
29
+ onScroll = EMPTY_FUNCTION,
30
+ onSelectionChange: onSelectionChangeHandler
31
+ } = _ref,
32
+ props = _objectWithoutProperties(_ref, _excluded);
33
+ var {
34
+ itemHeight
35
+ } = usePickerItemScale();
36
+ var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip), [tooltip]);
37
+ var items = useMemo(() => ensureArray(wrapItemChildren(children, tooltipOptions)), [children, tooltipOptions]);
38
+ var {
39
+ selectedKeyMaybeUncontrolled,
40
+ onChangeMaybeUncontrolled
41
+ } = useOnChangeTrackUncontrolled({
42
+ defaultSelectedKey,
43
+ selectedKey,
44
+ onChange: onChangeHandler !== null && onChangeHandler !== void 0 ? onChangeHandler : onSelectionChangeHandler
45
+ });
46
+ var getInitialScrollPosition = useStaticItemInitialScrollPosition({
47
+ itemHeight,
48
+ items,
49
+ selectedKey: selectedKeyMaybeUncontrolled,
50
+ topOffset: PICKER_TOP_OFFSET
51
+ });
52
+ var {
53
+ ref: scrollRef,
54
+ onOpenChange
55
+ } = usePickerScrollOnOpen({
56
+ getInitialScrollPosition,
57
+ onScroll,
58
+ onOpenChange: onOpenChangeHandler
59
+ });
60
+ return _objectSpread(_objectSpread({}, props), {}, {
61
+ defaultSelectedKey,
62
+ selectedKey,
63
+ children: items,
64
+ scrollRef,
65
+ onOpenChange,
66
+ onSelectionChange: onChangeMaybeUncontrolled
67
+ });
68
+ }
69
+ export default usePickerProps;
70
+ //# sourceMappingURL=usePickerProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerProps.js","names":["EMPTY_FUNCTION","ensureArray","PICKER_TOP_OFFSET","useMemo","normalizeTooltipOptions","wrapItemChildren","useOnChangeTrackUncontrolled","useStaticItemInitialScrollPosition","usePickerItemScale","usePickerScrollOnOpen","usePickerProps","_ref","children","defaultSelectedKey","selectedKey","tooltip","onChange","onChangeHandler","onOpenChange","onOpenChangeHandler","onScroll","onSelectionChange","onSelectionChangeHandler","props","_objectWithoutProperties","_excluded","itemHeight","tooltipOptions","items","selectedKeyMaybeUncontrolled","onChangeMaybeUncontrolled","getInitialScrollPosition","topOffset","ref","scrollRef","_objectSpread"],"sources":["../../../src/spectrum/picker/usePickerProps.ts"],"sourcesContent":["import {\n EMPTY_FUNCTION,\n ensureArray,\n PICKER_TOP_OFFSET,\n} from '@deephaven/utils';\nimport { DOMRef } from '@react-types/shared';\nimport { useMemo } from 'react';\nimport {\n normalizeTooltipOptions,\n wrapItemChildren,\n useOnChangeTrackUncontrolled,\n useStaticItemInitialScrollPosition,\n ItemKey,\n SectionElement,\n ItemElement,\n} from '../utils';\nimport type { PickerPropsT } from './PickerProps';\nimport usePickerItemScale from './usePickerItemScale';\nimport usePickerScrollOnOpen from './usePickerScrollOnOpen';\n\n/** Props that are derived. */\nexport type UsePickerDerivedProps = {\n children: (SectionElement<unknown> | ItemElement<unknown>)[];\n defaultSelectedKey?: ItemKey | undefined;\n selectedKey?: ItemKey | null | undefined;\n scrollRef: DOMRef<HTMLElement>;\n onOpenChange: (isOpen: boolean) => void;\n onSelectionChange: ((key: ItemKey | null) => void) | undefined;\n};\n\n/** Props that are passed through untouched. */\nexport type UsePickerPassthroughProps<TProps> = Omit<\n PickerPropsT<TProps>,\n | 'children'\n | 'defaultSelectedKey'\n | 'selectedKey'\n | 'tooltip'\n | 'onChange'\n | 'onOpenChange'\n | 'onScroll'\n | 'onSelectionChange'\n>;\n\nexport type UsePickerProps<TProps> = UsePickerDerivedProps &\n UsePickerPassthroughProps<TProps>;\n\n/**\n * Derive props for Picker components (e.g. Picker and ComboBox). Specifically\n * handles wrapping children items and initial scroll position when the picker\n * is opened.\n */\nexport function usePickerProps<TProps>({\n children,\n defaultSelectedKey,\n selectedKey,\n tooltip = true,\n onChange: onChangeHandler,\n onOpenChange: onOpenChangeHandler,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange: onSelectionChangeHandler,\n ...props\n}: PickerPropsT<TProps>): UsePickerProps<TProps> {\n const { itemHeight } = usePickerItemScale();\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const items = useMemo(\n () => ensureArray(wrapItemChildren(children, tooltipOptions)),\n [children, tooltipOptions]\n );\n\n const { selectedKeyMaybeUncontrolled, onChangeMaybeUncontrolled } =\n useOnChangeTrackUncontrolled({\n defaultSelectedKey,\n selectedKey,\n onChange: onChangeHandler ?? onSelectionChangeHandler,\n });\n\n const getInitialScrollPosition = useStaticItemInitialScrollPosition({\n itemHeight,\n items,\n selectedKey: selectedKeyMaybeUncontrolled,\n topOffset: PICKER_TOP_OFFSET,\n });\n\n const { ref: scrollRef, onOpenChange } = usePickerScrollOnOpen({\n getInitialScrollPosition,\n onScroll,\n onOpenChange: onOpenChangeHandler,\n });\n\n return {\n ...props,\n defaultSelectedKey,\n selectedKey,\n children: items,\n scrollRef,\n onOpenChange,\n onSelectionChange: onChangeMaybeUncontrolled,\n };\n}\n\nexport default usePickerProps;\n"],"mappings":";;;;;;;;AAAA,SACEA,cAAc,E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,GAAGT,qBAAqB,CAAC;IAC7DsB,wBAAwB;IACxBX,QAAQ;IACRF,YAAY,EAAEC;EAChB,CAAC,CAAC;EAEF,OAAAgB,aAAA,CAAAA,aAAA,KACKZ,KAAK;IACRV,kBAAkB;IAClBC,WAAW;IACXF,QAAQ,EAAEgB,KAAK;IACfM,SAAS;IACThB,YAAY;IACZG,iBAAiB,EAAES;EAAyB;AAEhD;AAEA,eAAepB,cAAc"}
@@ -2,7 +2,9 @@ export * from './itemUtils';
2
2
  export * from './itemWrapperUtils';
3
3
  export * from './propsUtils';
4
4
  export * from './themeUtils';
5
+ export * from './useOnChangeTrackUncontrolled';
5
6
  export * from './useRenderNormalizedItem';
7
+ export * from './useStaticItemInitialScrollPosition';
6
8
  export * from './useStringifiedMultiSelection';
7
9
  export * from './useStringifiedSelection';
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC"}
@@ -2,7 +2,9 @@ export * from "./itemUtils.js";
2
2
  export * from "./itemWrapperUtils.js";
3
3
  export * from "./propsUtils.js";
4
4
  export * from "./themeUtils.js";
5
+ export * from "./useOnChangeTrackUncontrolled.js";
5
6
  export * from "./useRenderNormalizedItem.js";
7
+ export * from "./useStaticItemInitialScrollPosition.js";
6
8
  export * from "./useStringifiedMultiSelection.js";
7
9
  export * from "./useStringifiedSelection.js";
8
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/utils/index.ts"],"sourcesContent":["export * from './itemUtils';\nexport * from './itemWrapperUtils';\nexport * from './propsUtils';\nexport * from './themeUtils';\nexport * from './useRenderNormalizedItem';\nexport * from './useStringifiedMultiSelection';\nexport * from './useStringifiedSelection';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/utils/index.ts"],"sourcesContent":["export * from './itemUtils';\nexport * from './itemWrapperUtils';\nexport * from './propsUtils';\nexport * from './themeUtils';\nexport * from './useOnChangeTrackUncontrolled';\nexport * from './useRenderNormalizedItem';\nexport * from './useStaticItemInitialScrollPosition';\nexport * from './useStringifiedMultiSelection';\nexport * from './useStringifiedSelection';\n"],"mappings":""}
@@ -1,5 +1,4 @@
1
1
  import { Key, ReactElement, ReactNode } from 'react';
2
- import { SpectrumPickerProps } from '@adobe/react-spectrum';
3
2
  import type { ItemRenderer } from '@react-types/shared';
4
3
  import { KeyedItem, SelectionT } from '@deephaven/utils';
5
4
  import { ItemElementOrPrimitive, ItemProps, SectionProps } from '../shared';
@@ -74,7 +73,6 @@ export interface NormalizedSectionData {
74
73
  export type NormalizedItem = KeyedItem<NormalizedItemData, ItemKey>;
75
74
  export type NormalizedSection = KeyedItem<NormalizedSectionData, Key>;
76
75
  export type NormalizedItemOrSection<TItemOrSection extends ItemOrSection> = TItemOrSection extends SectionElement ? NormalizedSection : NormalizedItem;
77
- export type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedItem>;
78
76
  export type TooltipOptions = {
79
77
  placement: PopperOptions['placement'];
80
78
  };
@@ -88,6 +86,13 @@ export type TooltipOptions = {
88
86
  * @returns The `key` of the item or section
89
87
  */
90
88
  export declare function getItemKey<TItem extends NormalizedItem | NormalizedSection, TKey extends TItem extends NormalizedItem ? ItemKey : TItem extends NormalizedSection ? Key : undefined>(item: TItem | null | undefined): TKey;
89
+ /**
90
+ * Determine Item `textValue` based on the `textValue` prop or primitive children
91
+ * value.
92
+ * @param item The item to get the text value for
93
+ * @returns The text value of the item
94
+ */
95
+ export declare function getItemTextValue<T>(item: ItemElement<T>): string | undefined;
91
96
  /**
92
97
  * Get the position of the item with the given selected key in a list of items.
93
98
  * @param items The items to search
@@ -1 +1 @@
1
- {"version":3,"file":"itemUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/itemUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAe,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAEL,sBAAsB,EACtB,SAAS,EAET,YAAY,EACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C;;;GAGG;AACH,eAAO,MAAM,4BAA4B,UAAU,CAAC;AAEpD;;;;GAIG;AACH,KAAK,0BAA0B,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG;IACvE,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACl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IAAI,EAAE,SAAS,GAAG,IAAI,IAAI,aAAa,CAQtE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,EACzC,SAAS,GAAE,cAAc,CAAC,WAAW,CAAW,GAC/C,cAAc,GAAG,IAAI,CAUvB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,SAAS,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,EACnD,OAAO,SAAS,KAAK,SAAS,KAAK,GAC/B,KAAK,GACL,KAAK,SAAS,QAAQ,CAAC,OAAO,CAAC,GAC/B,GAAG,CAAC,MAAM,CAAC,GACX,SAAS,EACb,QAAQ,EAAE,KAAK,GAAG,OAAO,CAM1B"}
@@ -52,6 +52,19 @@ export function getItemKey(item) {
52
52
  return (_item$item$key = item === null || item === void 0 ? void 0 : (_item$item = item.item) === null || _item$item === void 0 ? void 0 : _item$item.key) !== null && _item$item$key !== void 0 ? _item$item$key : item === null || item === void 0 ? void 0 : item.key;
53
53
  }
54
54
 
55
+ /**
56
+ * Determine Item `textValue` based on the `textValue` prop or primitive children
57
+ * value.
58
+ * @param item The item to get the text value for
59
+ * @returns The text value of the item
60
+ */
61
+ export function getItemTextValue(item) {
62
+ if (item.props.textValue == null) {
63
+ return ['string', 'boolean', 'number'].includes(typeof item.props.children) ? String(item.props.children) : undefined;
64
+ }
65
+ return item.props.textValue === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : item.props.textValue;
66
+ }
67
+
55
68
  /**
56
69
  * Get the position of the item with the given selected key in a list of items.
57
70
  * @param items The items to search
@@ -1 +1 @@
1
- {"version":3,"file":"itemUtils.js","names":["isElementOfType","ensureArray","Item","Section","Text","ItemContent","ITEM_EMPTY_STRING_TEXT_VALUE","getItemKey","item","_item$item$key","_item$item","key","getPositionOfSelectedItemElement","_x","_getPositionOfSelectedItemElement","apply","arguments","_asyncToGenerator","_ref","items","itemHeight","selectedKey","topOffset","position","i","length","isSectionElement","node","isItemElement","isItemElementWithDescription","children","props","childrenArray","result","some","child","_child$props","slot","isNormalizedItemsWithKeysList","Array","isArray","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeTooltipOptions","options","placement","undefined","itemSelectionToStringSet","itemKeys","Set","map","String"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { Key, ReactElement, ReactNode } from 'react';\nimport { SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type { ItemRenderer } from '@react-types/shared';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport { ensureArray, KeyedItem, SelectionT } from '@deephaven/utils';\nimport {\n Item,\n ItemElementOrPrimitive,\n ItemProps,\n Section,\n SectionProps,\n} from '../shared';\nimport { PopperOptions } from '../../popper';\nimport { Text } from '../Text';\nimport ItemContent from '../ItemContent';\n\n/**\n * `Item.textValue` prop needs to be a non-empty string for accessibility\n * purposes. This is not displayed in the UI.\n */\nexport const ITEM_EMPTY_STRING_TEXT_VALUE = 'Empty';\n\n/**\n * React Spectrum <Section> supports an `ItemRenderer` function as a child. The\n * DH picker makes use of this internally, but we don't want to support it as\n * an incoming prop.\n */\ntype SectionPropsNoItemRenderer<T> = Omit<SectionProps<T>, 'children'> & {\n children: Exclude<SectionProps<T>['children'], ItemRenderer<T>>;\n};\n\nexport type ItemElement<T = unknown> = ReactElement<ItemProps<T>>;\nexport type SectionElement<T = unknown> = ReactElement<\n SectionPropsNoItemRenderer<T>\n>;\n\nexport type ItemOrSection<T = unknown> =\n | ItemElementOrPrimitive<T>\n | SectionElement<T>;\n\n// Picker uses `icon` slot. ListView can use `image` or `illustration` slots.\n// https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/picker/src/Picker.tsx#L194\n// https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/list/src/ListViewItem.tsx#L266-L267\nexport type ItemIconSlot = 'icon' | 'image' | 'illustration';\n\n/**\n * Augment the Spectrum selection key type to include boolean values.\n * Spectrum collection components already supports this, but the built in types\n * don't reflect it.\n */\nexport type ItemKey = Key | boolean;\n\nexport type ItemSelection = SelectionT<ItemKey>;\n\n/**\n * Augment the Spectrum selection change handler type to include boolean keys.\n * Spectrum components already supports this, but the built in types don't\n * reflect it.\n */\nexport type ItemSelectionChangeHandler = (key: ItemKey) => void;\n\nexport interface MultipleItemSelectionProps {\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: ItemSelection) => void;\n\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead\n */\n onSelectionChange?: (keys: ItemSelection) => void;\n}\n\nexport interface NormalizedItemData {\n key?: ItemKey;\n content: ReactNode;\n description?: ReactNode;\n icon?: ReactNode;\n textValue: string | undefined;\n}\n\nexport interface NormalizedSectionData {\n key?: Key;\n title?: ReactNode;\n items: NormalizedItem[];\n}\n\n/**\n * Spectrum collection components support a variety of item types, including\n * strings, numbers, booleans, and more complex React elements. This type\n * represents a normalized form to make rendering items simpler and keep the\n * logic of transformation in separate util methods. It also adheres to the\n * `KeyedItem` interface to be compatible with Windowed data utils\n * (e.g. `useViewportData`).\n */\nexport type NormalizedItem = KeyedItem<NormalizedItemData, ItemKey>;\n\nexport type NormalizedSection = KeyedItem<NormalizedSectionData, Key>;\n\nexport type NormalizedItemOrSection<TItemOrSection extends ItemOrSection> =\n TItemOrSection extends SectionElement ? NormalizedSection : NormalizedItem;\n\nexport type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedItem>;\n\nexport type TooltipOptions = { placement: PopperOptions['placement'] };\n\n/**\n * DH wrappers of Spectrum collection components use a normalized item that\n * includes a `key` prop and an optional `item` prop. This is mostly to support\n * Windowed data where items are created before their data has been loaded (data\n * gets set in the `item` prop). If data has loaded, return its `key`. If not,\n * return the top-level `key` on the normalized item.\n * @param item The normalized item or section\n * @returns The `key` of the item or section\n */\nexport function getItemKey<\n TItem extends NormalizedItem | NormalizedSection,\n TKey extends TItem extends NormalizedItem\n ? ItemKey\n : TItem extends NormalizedSection\n ? Key\n : undefined,\n>(item: TItem | null | undefined): TKey {\n return (item?.item?.key ?? item?.key) as TKey;\n}\n\n/**\n * Get the position of the item with the given selected key in a list of items.\n * @param items The items to search\n * @param itemHeight The height of each item\n * @param selectedKey The key of the selected item\n * @param topOffset The top offset of the list\n * @returns The position of the selected item or the top offset if not found\n */\nexport async function getPositionOfSelectedItemElement<\n TKey extends string | number | boolean | undefined,\n>({\n items,\n itemHeight,\n selectedKey,\n topOffset,\n}: {\n items: ItemElement[];\n selectedKey: TKey | null | undefined;\n itemHeight: number;\n topOffset: number;\n}): Promise<number> {\n let position = topOffset;\n\n if (selectedKey == null) {\n return position;\n }\n\n for (let i = 0; i < items.length; i += 1) {\n const item = items[i];\n if (item.key === selectedKey) {\n return position;\n }\n\n position += itemHeight;\n }\n\n return topOffset;\n}\n\n/**\n * Determine if a node is a Section element.\n * @param node The node to check\n * @returns True if the node is a Section element\n */\nexport function isSectionElement<T>(\n node: ReactNode\n): node is SectionElement<T> {\n return isElementOfType(node, Section);\n}\n\n/**\n * Determine if a node is an Item element.\n * @param node The node to check\n * @returns True if the node is an Item element\n */\nexport function isItemElement<T>(node: ReactNode): node is ItemElement<T> {\n return isElementOfType(node, Item);\n}\n\n/**\n * Determine if a node is an Item element containing a child `Text` element with\n * a `slot` prop set to `description`.\n * @param node The node to check\n * @returns True if the node is an Item element with a description\n */\nexport function isItemElementWithDescription<T>(\n node: ReactNode\n): node is ReactElement<ItemProps<T>> {\n if (!isItemElement(node)) {\n return false;\n }\n\n // If children are wrapped in `ItemContent`, go down 1 level\n const children = isElementOfType(node.props.children, ItemContent)\n ? node.props.children.props.children\n : node.props.children;\n\n const childrenArray = ensureArray(children);\n\n const result = childrenArray.some(\n child => isElementOfType(child, Text) && child.props?.slot === 'description'\n );\n\n return result;\n}\n\n/**\n * Determine if a node is an array containing normalized items or sections with\n * keys. Note that this only checks the first node in the array.\n * @param node The node to check\n * @returns True if the node is a normalized item or section with keys array\n */\nexport function isNormalizedItemsWithKeysList<\n TItemOrSection extends ItemOrSection,\n>(\n node:\n | TItemOrSection\n | TItemOrSection[]\n | NormalizedItemOrSection<TItemOrSection>[]\n): node is NormalizedItemOrSection<TItemOrSection>[] {\n if (!Array.isArray(node)) {\n return false;\n }\n\n if (node.length === 0) {\n return true;\n }\n\n return !isItemOrSection(node[0]) && 'key' in node[0];\n}\n\n/**\n * Determine if an object is a normalized section.\n * @param maybeNormalizedSection The object to check\n * @returns True if the object is a normalized section\n */\nexport function isNormalizedSection(\n maybeNormalizedSection: NormalizedItem | NormalizedSection\n): maybeNormalizedSection is NormalizedSection {\n return (\n maybeNormalizedSection.item != null &&\n 'items' in maybeNormalizedSection.item\n );\n}\n\n/**\n * Determine if a node is an item or section. Valid types include strings,\n * numbers, booleans, Item elements, and Section elements.\n * @param node The node to check\n * @returns True if the node is an item or section\n */\nexport function isItemOrSection(node: ReactNode): node is ItemOrSection {\n return (\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n isItemElement(node) ||\n isSectionElement(node)\n );\n}\n\n/**\n * Returns a TooltipOptions object or null if options is false or null.\n * @param options Tooltip options\n * @param placement Default placement for the tooltip if `options` is set\n * explicitly to `true`\n * @returns TooltipOptions or null\n */\nexport function normalizeTooltipOptions(\n options?: boolean | TooltipOptions | null,\n placement: TooltipOptions['placement'] = 'right'\n): TooltipOptions | null {\n if (options == null || options === false) {\n return null;\n }\n\n if (options === true) {\n return { placement };\n }\n\n return options;\n}\n\n/**\n * Convert a selection of `ItemKey`s to a selection of strings.\n * @param itemKeys The selection of `ItemKey`s\n * @returns The selection of strings\n */\nexport function itemSelectionToStringSet<\n TKeys extends 'all' | Iterable<ItemKey> | undefined,\n TResult extends TKeys extends 'all'\n ? 'all'\n : TKeys extends Iterable<ItemKey>\n ? Set<string>\n : undefined,\n>(itemKeys: TKeys): TResult {\n if (itemKeys == null || itemKeys === 'all') {\n return itemKeys as undefined | 'all' as TResult;\n }\n\n return new Set([...itemKeys].map(String)) as TResult;\n}\n"],"mappings":";;AAGA,SAASA,eAAe,QAAQ,wBAAwB;AACxD,SAASC,WAAW,QAA+B,kBAAkB;AAAC,SAEpEC,IAAI,EAGJC,OAAO;AAAA,SAIAC,IAAI;AAAA,OACNC,WAAW;AAElB;AACA;AACA;AACA;AACA,OAAO,IAAMC,4BAA4B,GAAG,OAAO;;AAEnD;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAqCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAOxBC,IAA8B,EAAQ;EAAA,IAAAC,cAAA,EAAAC,UAAA;EACtC,QAAAD,cAAA,GAAQD,IAAI,aAAJA,IAAI,wBAAAE,UAAA,GAAJF,IAAI,CAAEA,IAAI,cAAAE,UAAA,uBAAVA,UAAA,CAAYC,GAAG,cAAAF,cAAA,cAAAA,cAAA,GAAID,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,GAAG;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAsBC,gCAAgCA,CAAAC,EAAA;EAAA,OAAAC,iCAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;;AA+BtD;AACA;AACA;AACA;AACA;AAJA,SAAAF,kCAAA;EAAAA,iCAAA,GAAAG,iBAAA,CA/BO,WAAAC,IAAA,EAYa;IAAA,IAVlB;MACAC,KAAK;MACLC,UAAU;MACVC,WAAW;MACXC;IAMF,CAAC,GAAAJ,IAAA;IACC,IAAIK,QAAQ,GAAGD,SAAS;IAExB,IAAID,W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AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,wBAAwBA,CAOtCC,QAAe,EAAW;EAC1B,IAAIA,QAAQ,IAAI,IAAI,IAAIA,QAAQ,KAAK,KAAK,EAAE;IAC1C,OAAOA,QAAQ;EACjB;EAEA,OAAO,IAAIC,GAAG,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAACE,GAAG,CAACC,MAAM,CAAC,CAAC;AAC3C"}
1
+ {"version":3,"file":"itemUtils.js","names":["isElementOfType","ensureArray","Item","Section","Text","ItemContent","ITEM_EMPTY_STRING_TEXT_VALUE","getItemKey","item","_item$item$key","_item$item","key","getItemTextValue","props","textValue","includes","children","String","undefined","getPositionOfSelectedItemElement","_x","_getPositionOfSelectedItemElement","apply","arguments","_asyncToGenerator","_ref","items","itemHeight","selectedKey","topOffset","position","i","length","isSectionElement","node","isItemElement","isItemElementWithDescription","childrenArray","result","some","child","_child$props","slot","isNormalizedItemsWithKeysList","Array","isArray","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeTooltipOptions","options","placement","itemSelectionToStringSet","itemKeys","Set","map"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { Key, ReactElement, ReactNode } from 'react';\nimport type { ItemRenderer } from '@react-types/shared';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport { ensureArray, KeyedItem, SelectionT } from '@deephaven/utils';\nimport {\n Item,\n ItemElementOrPrimitive,\n ItemProps,\n Section,\n SectionProps,\n} from '../shared';\nimport { PopperOptions } from '../../popper';\nimport { Text } from '../Text';\nimport ItemContent from '../ItemContent';\n\n/**\n * `Item.textValue` prop needs to be a non-empty string for accessibility\n * purposes. This is not displayed in the UI.\n */\nexport const ITEM_EMPTY_STRING_TEXT_VALUE = 'Empty';\n\n/**\n * React Spectrum <Section> supports an `ItemRenderer` function as a child. The\n * DH picker makes use of this internally, but we don't want to support it as\n * an incoming prop.\n */\ntype SectionPropsNoItemRenderer<T> = Omit<SectionProps<T>, 'children'> & {\n children: Exclude<SectionProps<T>['children'], ItemRenderer<T>>;\n};\n\nexport type ItemElement<T = unknown> = ReactElement<ItemProps<T>>;\nexport type SectionElement<T = unknown> = ReactElement<\n SectionPropsNoItemRenderer<T>\n>;\n\nexport type ItemOrSection<T = unknown> =\n | ItemElementOrPrimitive<T>\n | SectionElement<T>;\n\n// Picker uses `icon` slot. ListView can use `image` or `illustration` slots.\n// https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/picker/src/Picker.tsx#L194\n// https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/list/src/ListViewItem.tsx#L266-L267\nexport type ItemIconSlot = 'icon' | 'image' | 'illustration';\n\n/**\n * Augment the Spectrum selection key type to include boolean values.\n * Spectrum collection components already supports this, but the built in types\n * don't reflect it.\n */\nexport type ItemKey = Key | boolean;\n\nexport type ItemSelection = SelectionT<ItemKey>;\n\n/**\n * Augment the Spectrum selection change handler type to include boolean keys.\n * Spectrum components already supports this, but the built in types don't\n * reflect it.\n */\nexport type ItemSelectionChangeHandler = (key: ItemKey) => void;\n\nexport interface MultipleItemSelectionProps {\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: ItemSelection) => void;\n\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead\n */\n onSelectionChange?: (keys: ItemSelection) => void;\n}\n\nexport interface NormalizedItemData {\n key?: ItemKey;\n content: ReactNode;\n description?: ReactNode;\n icon?: ReactNode;\n textValue: string | undefined;\n}\n\nexport interface NormalizedSectionData {\n key?: Key;\n title?: ReactNode;\n items: NormalizedItem[];\n}\n\n/**\n * Spectrum collection components support a variety of item types, including\n * strings, numbers, booleans, and more complex React elements. This type\n * represents a normalized form to make rendering items simpler and keep the\n * logic of transformation in separate util methods. It also adheres to the\n * `KeyedItem` interface to be compatible with Windowed data utils\n * (e.g. `useViewportData`).\n */\nexport type NormalizedItem = KeyedItem<NormalizedItemData, ItemKey>;\n\nexport type NormalizedSection = KeyedItem<NormalizedSectionData, Key>;\n\nexport type NormalizedItemOrSection<TItemOrSection extends ItemOrSection> =\n TItemOrSection extends SectionElement ? NormalizedSection : NormalizedItem;\n\nexport type TooltipOptions = { placement: PopperOptions['placement'] };\n\n/**\n * DH wrappers of Spectrum collection components use a normalized item that\n * includes a `key` prop and an optional `item` prop. This is mostly to support\n * Windowed data where items are created before their data has been loaded (data\n * gets set in the `item` prop). If data has loaded, return its `key`. If not,\n * return the top-level `key` on the normalized item.\n * @param item The normalized item or section\n * @returns The `key` of the item or section\n */\nexport function getItemKey<\n TItem extends NormalizedItem | NormalizedSection,\n TKey extends TItem extends NormalizedItem\n ? ItemKey\n : TItem extends NormalizedSection\n ? Key\n : undefined,\n>(item: TItem | null | undefined): TKey {\n return (item?.item?.key ?? item?.key) as TKey;\n}\n\n/**\n * Determine Item `textValue` based on the `textValue` prop or primitive children\n * value.\n * @param item The item to get the text value for\n * @returns The text value of the item\n */\nexport function getItemTextValue<T>(item: ItemElement<T>): string | undefined {\n if (item.props.textValue == null) {\n return ['string', 'boolean', 'number'].includes(typeof item.props.children)\n ? String(item.props.children)\n : undefined;\n }\n\n return item.props.textValue === ''\n ? ITEM_EMPTY_STRING_TEXT_VALUE\n : item.props.textValue;\n}\n\n/**\n * Get the position of the item with the given selected key in a list of items.\n * @param items The items to search\n * @param itemHeight The height of each item\n * @param selectedKey The key of the selected item\n * @param topOffset The top offset of the list\n * @returns The position of the selected item or the top offset if not found\n */\nexport async function getPositionOfSelectedItemElement<\n TKey extends string | number | boolean | undefined,\n>({\n items,\n itemHeight,\n selectedKey,\n topOffset,\n}: {\n items: ItemElement[];\n selectedKey: TKey | null | undefined;\n itemHeight: number;\n topOffset: number;\n}): Promise<number> {\n let position = topOffset;\n\n if (selectedKey == null) {\n return position;\n }\n\n for (let i = 0; i < items.length; i += 1) {\n const item = items[i];\n if (item.key === selectedKey) {\n return position;\n }\n\n position += itemHeight;\n }\n\n return topOffset;\n}\n\n/**\n * Determine if a node is a Section element.\n * @param node The node to check\n * @returns True if the node is a Section element\n */\nexport function isSectionElement<T>(\n node: ReactNode\n): node is SectionElement<T> {\n return isElementOfType(node, Section);\n}\n\n/**\n * Determine if a node is an Item element.\n * @param node The node to check\n * @returns True if the node is an Item element\n */\nexport function isItemElement<T>(node: ReactNode): node is ItemElement<T> {\n return isElementOfType(node, Item);\n}\n\n/**\n * Determine if a node is an Item element containing a child `Text` element with\n * a `slot` prop set to `description`.\n * @param node The node to check\n * @returns True if the node is an Item element with a description\n */\nexport function isItemElementWithDescription<T>(\n node: ReactNode\n): node is ReactElement<ItemProps<T>> {\n if (!isItemElement(node)) {\n return false;\n }\n\n // If children are wrapped in `ItemContent`, go down 1 level\n const children = isElementOfType(node.props.children, ItemContent)\n ? node.props.children.props.children\n : node.props.children;\n\n const childrenArray = ensureArray(children);\n\n const result = childrenArray.some(\n child => isElementOfType(child, Text) && child.props?.slot === 'description'\n );\n\n return result;\n}\n\n/**\n * Determine if a node is an array containing normalized items or sections with\n * keys. Note that this only checks the first node in the array.\n * @param node The node to check\n * @returns True if the node is a normalized item or section with keys array\n */\nexport function isNormalizedItemsWithKeysList<\n TItemOrSection extends ItemOrSection,\n>(\n node:\n | TItemOrSection\n | TItemOrSection[]\n | NormalizedItemOrSection<TItemOrSection>[]\n): node is NormalizedItemOrSection<TItemOrSection>[] {\n if (!Array.isArray(node)) {\n return false;\n }\n\n if (node.length === 0) {\n return true;\n }\n\n return !isItemOrSection(node[0]) && 'key' in node[0];\n}\n\n/**\n * Determine if an object is a normalized section.\n * @param maybeNormalizedSection The object to check\n * @returns True if the object is a normalized section\n */\nexport function isNormalizedSection(\n maybeNormalizedSection: NormalizedItem | NormalizedSection\n): maybeNormalizedSection is NormalizedSection {\n return (\n maybeNormalizedSection.item != null &&\n 'items' in maybeNormalizedSection.item\n );\n}\n\n/**\n * Determine if a node is an item or section. Valid types include strings,\n * numbers, booleans, Item elements, and Section elements.\n * @param node The node to check\n * @returns True if the node is an item or section\n */\nexport function isItemOrSection(node: ReactNode): node is ItemOrSection {\n return (\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n isItemElement(node) ||\n isSectionElement(node)\n );\n}\n\n/**\n * Returns a TooltipOptions object or null if options is false or null.\n * @param options Tooltip options\n * @param placement Default placement for the tooltip if `options` is set\n * explicitly to `true`\n * @returns TooltipOptions or null\n */\nexport function normalizeTooltipOptions(\n options?: boolean | TooltipOptions | null,\n placement: TooltipOptions['placement'] = 'right'\n): TooltipOptions | null {\n if (options == null || options === false) {\n return null;\n }\n\n if (options === true) {\n return { placement };\n }\n\n return options;\n}\n\n/**\n * Convert a selection of `ItemKey`s to a selection of strings.\n * @param itemKeys The selection of `ItemKey`s\n * @returns The selection of strings\n */\nexport function itemSelectionToStringSet<\n TKeys extends 'all' | Iterable<ItemKey> | undefined,\n TResult extends TKeys extends 'all'\n ? 'all'\n : TKeys extends Iterable<ItemKey>\n ? Set<string>\n : undefined,\n>(itemKeys: TKeys): TResult {\n if (itemKeys == null || itemKeys === 'all') {\n return itemKeys as undefined | 'all' as TResult;\n }\n\n return new Set([...itemKeys].map(String)) as TResult;\n}\n"],"mappings":";;AAEA,SAASA,eAAe,QAAQ,wBAAwB;AACxD,SAASC,WAAW,QAA+B,kBAAkB;AAAC,SAEpEC,IAAI,EAGJC,OAAO;AAAA,SAIAC,IAAI;AAAA,OACNC,WAAW;AAElB;AACA;AACA;AACA;AACA,OAAO,IAAMC,4BAA4B,GAAG,OAAO;;AAEnD;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAqCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;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,IAAI,IAAI,IAAIA,QAAQ,KAAK,KAAK,EAAE;IAC1C,OAAOA,QAAQ;EACjB;EAEA,OAAO,IAAIC,GAAG,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAACE,GAAG,CAACtC,MAAM,CAAC,CAAC;AAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"itemWrapperUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/itemWrapperUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD,OAAO,EAGL,WAAW,EACX,YAAY,EACZ,aAAa,EAEb,cAAc,EACd,cAAc,EACf,MAAM,aAAa,CAAC;AAKrB;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,YAAY,EAAE,SAAS,EACvB,IAAI,EAAE,YAAY,GACjB,SAAS,CAaX;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,EACtD,cAAc,EAAE,cAAc,GAAG,IAAI,GACpC,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAoD7E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,SAAS,EACnB,IAAI,CAAC,EAAE,MAAM,GACZ,SAAS,CAeX"}
1
+ {"version":3,"file":"itemWrapperUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/itemWrapperUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD,OAAO,EAIL,WAAW,EACX,YAAY,EACZ,aAAa,EAEb,cAAc,EACd,cAAc,EACf,MAAM,aAAa,CAAC;AAKrB;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,YAAY,EAAE,SAAS,EACvB,IAAI,EAAE,YAAY,GACjB,SAAS,CAaX;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,EACtD,cAAc,EAAE,cAAc,GAAG,IAAI,GACpC,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAiD7E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,SAAS,EACnB,IAAI,CAAC,EAAE,MAAM,GACZ,SAAS,CAeX"}
@@ -9,7 +9,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
9
  import { dh as dhIcons } from '@deephaven/icons';
10
10
  import { isElementOfType } from '@deephaven/react-hooks';
11
11
  import { ensureArray, NON_BREAKING_SPACE } from '@deephaven/utils';
12
- import { isItemElement, isSectionElement, ITEM_EMPTY_STRING_TEXT_VALUE } from "./itemUtils.js";
12
+ import { getItemTextValue, isItemElement, isSectionElement, ITEM_EMPTY_STRING_TEXT_VALUE } from "./itemUtils.js";
13
13
  import { ItemContent } from "../ItemContent.js";
14
14
  import { Icon } from "../icons.js";
15
15
  import { Text } from "../Text.js";
@@ -55,7 +55,7 @@ export function wrapItemChildren(itemsOrSections, tooltipOptions) {
55
55
  return item;
56
56
  }
57
57
  var key = (_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : item.props.textValue;
58
- var _textValue = item.props.textValue === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : item.props.textValue;
58
+ var _textValue = getItemTextValue(item);
59
59
 
60
60
  // Wrap in `ItemContent` so we can support tooltips and handle text
61
61
  // overflow
@@ -1 +1 @@
1
- {"version":3,"file":"itemWrapperUtils.js","names":["cloneElement","Item","FontAwesomeIcon","dh","dhIcons","isElementOfType","ensureArray","NON_BREAKING_SPACE","isItemElement","isSectionElement","ITEM_EMPTY_STRING_TEXT_VALUE","ItemContent","Icon","Text","jsx","_jsx","wrapIcon","maybeIconKey","slot","_maybeIconKey","_dhIcons$maybeIconKey","children","icon","vsBlank","wrapItemChildren","itemsOrSections","tooltipOptions","itemsOrSectionsArray","result","map","item","_item$key","props","key","textValue","_objectSpread","_item$key2","title","undefined","text","String","Array","isArray","wrapPrimitiveWithText","content","_content","includes"],"sources":["../../../src/spectrum/utils/itemWrapperUtils.tsx"],"sourcesContent":["import { cloneElement, ReactNode } from 'react';\nimport { Item } from '@adobe/react-spectrum';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { dh as dhIcons } from '@deephaven/icons';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport { ensureArray, NON_BREAKING_SPACE } from '@deephaven/utils';\nimport {\n isItemElement,\n isSectionElement,\n ItemElement,\n ItemIconSlot,\n ItemOrSection,\n ITEM_EMPTY_STRING_TEXT_VALUE,\n SectionElement,\n TooltipOptions,\n} from './itemUtils';\nimport { ItemContent } from '../ItemContent';\nimport { Icon } from '../icons';\nimport { Text } from '../Text';\n\n/**\n * If the given content is a string, wrap it in an Icon component. Otherwise,\n * return the original content. If the key is not found in the dhIcons object,\n * the vsBlank icon will be used.\n * @param maybeIconKey The content to wrap\n * @param slot The slot to use for the Icon component\n * @returns The wrapped content or original content if not a string\n */\nexport function wrapIcon(\n maybeIconKey: ReactNode,\n slot: ItemIconSlot\n): ReactNode {\n // eslint-disable-next-line no-param-reassign\n maybeIconKey = maybeIconKey ?? '';\n\n if (typeof maybeIconKey !== 'string') {\n return maybeIconKey;\n }\n\n return (\n <Icon slot={slot}>\n <FontAwesomeIcon icon={dhIcons[maybeIconKey] ?? dhIcons.vsBlank} />\n </Icon>\n );\n}\n\n/**\n * Ensure all primitive children are wrapped in `Item` elements and that all\n * `Item` element content is wrapped in `ItemContent` elements to handle text\n * overflow consistently and to support tooltips.\n * @param itemsOrSections The items or sections to wrap\n * @param tooltipOptions The tooltip options to use when wrapping items\n * @returns The wrapped items or sections\n */\nexport function wrapItemChildren<T>(\n itemsOrSections: ItemOrSection<T> | ItemOrSection<T>[],\n tooltipOptions: TooltipOptions | null\n): ItemElement<T> | SectionElement<T> | (ItemElement<T> | SectionElement<T>)[] {\n const itemsOrSectionsArray = ensureArray(itemsOrSections);\n\n const result = itemsOrSectionsArray.map(item => {\n if (isItemElement(item)) {\n // Item content is already wrapped\n if (isElementOfType(item.props.children, ItemContent)) {\n return item;\n }\n\n const key = item.key ?? item.props.textValue;\n const textValue =\n item.props.textValue === ''\n ? ITEM_EMPTY_STRING_TEXT_VALUE\n : item.props.textValue;\n\n // Wrap in `ItemContent` so we can support tooltips and handle text\n // overflow\n return cloneElement(item, {\n ...item.props,\n key,\n textValue,\n children: (\n <ItemContent tooltipOptions={tooltipOptions}>\n {item.props.children}\n </ItemContent>\n ),\n });\n }\n\n if (isSectionElement(item)) {\n return cloneElement(item, {\n ...item.props,\n key:\n item.key ??\n (typeof item.props.title === 'string' ? item.props.title : undefined),\n children: wrapItemChildren<T>(item.props.children, tooltipOptions),\n });\n }\n\n const text = String(item);\n const textValue = text === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : text;\n\n return (\n <Item key={text} textValue={textValue}>\n <ItemContent tooltipOptions={tooltipOptions}>{text}</ItemContent>\n </Item>\n );\n });\n\n // Keep consistent with original data structure as array or single node\n return Array.isArray(itemsOrSections) ? result : result[0];\n}\n\n/**\n * If the given content is a primitive type, wrap it in a Text component.\n * @param content The content to wrap\n * @param slot The slot to use for the Text component\n * @returns The wrapped content or original content if not a primitive type\n */\nexport function wrapPrimitiveWithText(\n content?: ReactNode,\n slot?: string\n): ReactNode {\n // eslint-disable-next-line no-param-reassign\n content = content ?? '';\n\n if (['string', 'boolean', 'number'].includes(typeof content)) {\n return (\n <Text slot={slot}>\n {/* Non-breaking space is needed to avoid the Text element's height \n collapsing when content is empty */}\n {content === '' ? NON_BREAKING_SPACE : String(content)}\n </Text>\n );\n }\n\n return content;\n}\n"],"mappings":";;;;;AAAA,SAASA,YAAY,QAAmB,OAAO;AAC/C,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,EAAE,IAAIC,OAAO,QAAQ,kBAAkB;AAChD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,kBAAkB;AAAC,SAEjEC,aAAa,EACbC,gBAAgB,EAIhBC,4BAA4B;AAAA,SAIrBC,WAAW;AAAA,SACXC,IAAI;AAAA,SACJC,IAAI;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,SAAAC,GAAA,IAAAC,IAAA;AAQA,OAAO,SAASC,QAAQA,CACtBC,YAAuB,EACvBC,IAAkB,EACP;EAAA,IAAAC,aAAA,EAAAC,qBAAA;EACX;EACAH,YAAY,IAAAE,aAAA,GAAGF,YAAY,cAAAE,aAAA,cAAAA,aAAA,GAAI,EAAE;EAEjC,IAAI,OAAOF,YAAY,KAAK,QAAQ,EAAE;IACpC,OAAOA,YAAY;EACrB;EAEA,oBACEF,IAAA,CAACH,IAAI;IAACM,IAAI,EAAEA,IAAK;IAAAG,QAAA,eACfN,IAAA,CAACb,eAAe;MAACoB,IAAI,GAAAF,qBAAA,GAAEhB,OAAO,CAACa,YAAY,CAAC,cAAAG,qBAAA,cAAAA,qBAAA,GAAIhB,OAAO,CAACmB;IAAQ,CAAE;EAAC,CAC/D,CAAC;AAEX;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,eAAsD,EACtDC,cAAqC,EACwC;EAC7E,IAAMC,oBAAoB,GAAGrB,WAAW,CAACmB,eAAe,CAAC;EAEzD,IAAMG,MAAM,GAAGD,oBAAoB,CAACE,GAAG,CAACC,IAAI,IAAI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KAAK,EAAE,GAAG7B,4BAA4B,GAAG6B,IAAI;IAEnE,oBACExB,IAAA,CAACd,IAAI;MAAYiC,SAAS,EAAEA,SAAU;MAAAb,QAAA,eACpCN,IAAA,CAACJ,WAAW;QAACe,cAAc,EAAEA,cAAe;QAAAL,QAAA,EAAEkB;MAAI,CAAc;IAAC,GADxDA,IAEL,CAAC;EAEX,CAAC,CAAC;;EAEF;EACA,OAAOE,KAAK,CAACC,OAAO,CAACjB,eAAe,CAAC,GAAGG,MAAM,GAAGA,MAAM,CAAC,CAAC,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASe,qBAAqBA,CACnCC,OAAmB,EACnB1B,IAAa,EACF;EAAA,IAAA2B,QAAA;EACX;EACAD,OAAO,IAAAC,QAAA,GAAGD,OAAO,cAAAC,QAAA,cAAAA,QAAA,GAAI,EAAE;EAEvB,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAACC,QAAQ,CAAC,OAAOF,OAAO,CAAC,EAAE;IAC5D,oBACE7B,IAAA,CAACF,IAAI;MAACK,IAAI,EAAEA,IAAK;MAAAG,QAAA,EAGduB,OAAO,KAAK,EAAE,GAAGrC,kBAAkB,GAAGiC,MAAM,CAACI,OAAO;IAAC,CAClD,CAAC;EAEX;EAEA,OAAOA,OAAO;AAChB"}
1
+ {"version":3,"file":"itemWrapperUtils.js","names":["cloneElement","Item","FontAwesomeIcon","dh","dhIcons","isElementOfType","ensureArray","NON_BREAKING_SPACE","getItemTextValue","isItemElement","isSectionElement","ITEM_EMPTY_STRING_TEXT_VALUE","ItemContent","Icon","Text","jsx","_jsx","wrapIcon","maybeIconKey","slot","_maybeIconKey","_dhIcons$maybeIconKey","children","icon","vsBlank","wrapItemChildren","itemsOrSections","tooltipOptions","itemsOrSectionsArray","result","map","item","_item$key","props","key","textValue","_objectSpread","_item$key2","title","undefined","text","String","Array","isArray","wrapPrimitiveWithText","content","_content","includes"],"sources":["../../../src/spectrum/utils/itemWrapperUtils.tsx"],"sourcesContent":["import { cloneElement, ReactNode } from 'react';\nimport { Item } from '@adobe/react-spectrum';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { dh as dhIcons } from '@deephaven/icons';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport { ensureArray, NON_BREAKING_SPACE } from '@deephaven/utils';\nimport {\n getItemTextValue,\n isItemElement,\n isSectionElement,\n ItemElement,\n ItemIconSlot,\n ItemOrSection,\n ITEM_EMPTY_STRING_TEXT_VALUE,\n SectionElement,\n TooltipOptions,\n} from './itemUtils';\nimport { ItemContent } from '../ItemContent';\nimport { Icon } from '../icons';\nimport { Text } from '../Text';\n\n/**\n * If the given content is a string, wrap it in an Icon component. Otherwise,\n * return the original content. If the key is not found in the dhIcons object,\n * the vsBlank icon will be used.\n * @param maybeIconKey The content to wrap\n * @param slot The slot to use for the Icon component\n * @returns The wrapped content or original content if not a string\n */\nexport function wrapIcon(\n maybeIconKey: ReactNode,\n slot: ItemIconSlot\n): ReactNode {\n // eslint-disable-next-line no-param-reassign\n maybeIconKey = maybeIconKey ?? '';\n\n if (typeof maybeIconKey !== 'string') {\n return maybeIconKey;\n }\n\n return (\n <Icon slot={slot}>\n <FontAwesomeIcon icon={dhIcons[maybeIconKey] ?? dhIcons.vsBlank} />\n </Icon>\n );\n}\n\n/**\n * Ensure all primitive children are wrapped in `Item` elements and that all\n * `Item` element content is wrapped in `ItemContent` elements to handle text\n * overflow consistently and to support tooltips.\n * @param itemsOrSections The items or sections to wrap\n * @param tooltipOptions The tooltip options to use when wrapping items\n * @returns The wrapped items or sections\n */\nexport function wrapItemChildren<T>(\n itemsOrSections: ItemOrSection<T> | ItemOrSection<T>[],\n tooltipOptions: TooltipOptions | null\n): ItemElement<T> | SectionElement<T> | (ItemElement<T> | SectionElement<T>)[] {\n const itemsOrSectionsArray = ensureArray(itemsOrSections);\n\n const result = itemsOrSectionsArray.map(item => {\n if (isItemElement(item)) {\n // Item content is already wrapped\n if (isElementOfType(item.props.children, ItemContent)) {\n return item;\n }\n\n const key = item.key ?? item.props.textValue;\n const textValue = getItemTextValue(item);\n\n // Wrap in `ItemContent` so we can support tooltips and handle text\n // overflow\n return cloneElement(item, {\n ...item.props,\n key,\n textValue,\n children: (\n <ItemContent tooltipOptions={tooltipOptions}>\n {item.props.children}\n </ItemContent>\n ),\n });\n }\n\n if (isSectionElement(item)) {\n return cloneElement(item, {\n ...item.props,\n key:\n item.key ??\n (typeof item.props.title === 'string' ? item.props.title : undefined),\n children: wrapItemChildren<T>(item.props.children, tooltipOptions),\n });\n }\n\n const text = String(item);\n const textValue = text === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : text;\n\n return (\n <Item key={text} textValue={textValue}>\n <ItemContent tooltipOptions={tooltipOptions}>{text}</ItemContent>\n </Item>\n );\n });\n\n // Keep consistent with original data structure as array or single node\n return Array.isArray(itemsOrSections) ? result : result[0];\n}\n\n/**\n * If the given content is a primitive type, wrap it in a Text component.\n * @param content The content to wrap\n * @param slot The slot to use for the Text component\n * @returns The wrapped content or original content if not a primitive type\n */\nexport function wrapPrimitiveWithText(\n content?: ReactNode,\n slot?: string\n): ReactNode {\n // eslint-disable-next-line no-param-reassign\n content = content ?? '';\n\n if (['string', 'boolean', 'number'].includes(typeof content)) {\n return (\n <Text slot={slot}>\n {/* Non-breaking space is needed to avoid the Text element's height \n collapsing when content is empty */}\n {content === '' ? NON_BREAKING_SPACE : String(content)}\n </Text>\n );\n }\n\n return content;\n}\n"],"mappings":";;;;;AAAA,SAASA,YAAY,QAAmB,OAAO;AAC/C,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,EAAE,IAAIC,OAAO,QAAQ,kBAAkB;AAChD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,kBAAkB;AAAC,SAEjEC,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB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ACF;EAAA,IAAA2B,QAAA;EACX;EACAD,OAAO,IAAAC,QAAA,GAAGD,OAAO,cAAAC,QAAA,cAAAA,QAAA,GAAI,EAAE;EAEvB,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAACC,QAAQ,CAAC,OAAOF,OAAO,CAAC,EAAE;IAC5D,oBACE7B,IAAA,CAACF,IAAI;MAACK,IAAI,EAAEA,IAAK;MAAAG,QAAA,EAGduB,OAAO,KAAK,EAAE,GAAGtC,kBAAkB,GAAGkC,MAAM,CAACI,OAAO;IAAC,CAClD,CAAC;EAEX;EAEA,OAAOA,OAAO;AAChB"}
@@ -0,0 +1,19 @@
1
+ import { ItemKey } from './itemUtils';
2
+ export interface UseOnChangeTrackUncontrolledOptions {
3
+ defaultSelectedKey?: ItemKey;
4
+ selectedKey?: ItemKey | null;
5
+ onChange?: (key: ItemKey | null) => void;
6
+ }
7
+ export interface UseOnChangeTrackUncontrolledResult {
8
+ selectedKeyMaybeUncontrolled?: ItemKey | null;
9
+ onChangeMaybeUncontrolled: (key: ItemKey | null) => void;
10
+ }
11
+ /**
12
+ * Returns a selectedKey and onChange handler that can manage selection state
13
+ * for both controlled and uncontrolled components. Useful for cases where a
14
+ * component needs to always track its selection state regardless of its
15
+ * controlled / uncontrolled status.
16
+ */
17
+ export declare function useOnChangeTrackUncontrolled({ defaultSelectedKey, selectedKey, onChange: onChangeHandler, }: UseOnChangeTrackUncontrolledOptions): UseOnChangeTrackUncontrolledResult;
18
+ export default useOnChangeTrackUncontrolled;
19
+ //# sourceMappingURL=useOnChangeTrackUncontrolled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnChangeTrackUncontrolled.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useOnChangeTrackUncontrolled.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,WAAW,mCAAmC;IAClD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,kCAAkC;IACjD,4BAA4B,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9C,yBAAyB,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CAC1D;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,kBAAkB,EAClB,WAAW,EACX,QAAQ,EAAE,eAAe,GAC1B,EAAE,mCAAmC,GAAG,kCAAkC,CA0B1E;AAED,eAAe,4BAA4B,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { useCallback, useState } from 'react';
2
+ /**
3
+ * Returns a selectedKey and onChange handler that can manage selection state
4
+ * for both controlled and uncontrolled components. Useful for cases where a
5
+ * component needs to always track its selection state regardless of its
6
+ * controlled / uncontrolled status.
7
+ */
8
+ export function useOnChangeTrackUncontrolled(_ref) {
9
+ var {
10
+ defaultSelectedKey,
11
+ selectedKey,
12
+ onChange: onChangeHandler
13
+ } = _ref;
14
+ // `null` is a valid value for `selectedKey` in controlled mode, so we check
15
+ // for explicit `undefined` to identify uncontrolled mode.
16
+ var isUncontrolled = selectedKey === undefined;
17
+ var [uncontrolledSelectedKey, setUncontrolledSelectedKey] = useState(defaultSelectedKey);
18
+ var onChangeMaybeUncontrolled = useCallback(key => {
19
+ // If our component is uncontrolled, track the selected key internally
20
+ if (isUncontrolled) {
21
+ setUncontrolledSelectedKey(key);
22
+ }
23
+ onChangeHandler === null || onChangeHandler === void 0 ? void 0 : onChangeHandler(key);
24
+ }, [isUncontrolled, onChangeHandler]);
25
+ return {
26
+ selectedKeyMaybeUncontrolled: isUncontrolled ? uncontrolledSelectedKey : selectedKey,
27
+ onChangeMaybeUncontrolled
28
+ };
29
+ }
30
+ export default useOnChangeTrackUncontrolled;
31
+ //# sourceMappingURL=useOnChangeTrackUncontrolled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnChangeTrackUncontrolled.js","names":["useCallback","useState","useOnChangeTrackUncontrolled","_ref","defaultSelectedKey","selectedKey","onChange","onChangeHandler","isUncontrolled","undefined","uncontrolledSelectedKey","setUncontrolledSelectedKey","onChangeMaybeUncontrolled","key","selectedKeyMaybeUncontrolled"],"sources":["../../../src/spectrum/utils/useOnChangeTrackUncontrolled.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { ItemKey } from './itemUtils';\n\nexport interface UseOnChangeTrackUncontrolledOptions {\n defaultSelectedKey?: ItemKey;\n selectedKey?: ItemKey | null;\n onChange?: (key: ItemKey | null) => void;\n}\n\nexport interface UseOnChangeTrackUncontrolledResult {\n selectedKeyMaybeUncontrolled?: ItemKey | null;\n onChangeMaybeUncontrolled: (key: ItemKey | null) => void;\n}\n\n/**\n * Returns a selectedKey and onChange handler that can manage selection state\n * for both controlled and uncontrolled components. Useful for cases where a\n * component needs to always track its selection state regardless of its\n * controlled / uncontrolled status.\n */\nexport function useOnChangeTrackUncontrolled({\n defaultSelectedKey,\n selectedKey,\n onChange: onChangeHandler,\n}: UseOnChangeTrackUncontrolledOptions): UseOnChangeTrackUncontrolledResult {\n // `null` is a valid value for `selectedKey` in controlled mode, so we check\n // for explicit `undefined` to identify uncontrolled mode.\n const isUncontrolled = selectedKey === undefined;\n const [uncontrolledSelectedKey, setUncontrolledSelectedKey] = useState<\n ItemKey | null | undefined\n >(defaultSelectedKey);\n\n const onChangeMaybeUncontrolled = useCallback(\n (key: ItemKey | null): void => {\n // If our component is uncontrolled, track the selected key internally\n if (isUncontrolled) {\n setUncontrolledSelectedKey(key);\n }\n\n onChangeHandler?.(key);\n },\n [isUncontrolled, onChangeHandler]\n );\n\n return {\n selectedKeyMaybeUncontrolled: isUncontrolled\n ? uncontrolledSelectedKey\n : selectedKey,\n onChangeMaybeUncontrolled,\n };\n}\n\nexport default useOnChangeTrackUncontrolled;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAc7C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAAC,IAAA,EAIgC;EAAA,IAJ/B;IAC3CC,kBAAkB;IAClBC,WAAW;IACXC,QAAQ,EAAEC;EACyB,CAAC,GAAAJ,IAAA;EACpC;EACA;EACA,IAAMK,cAAc,GAAGH,WAAW,KAAKI,SAAS;EAChD,IAAM,CAACC,uBAAuB,EAAEC,0BAA0B,CAAC,GAAGV,QAAQ,CAEpEG,kBAAkB,CAAC;EAErB,IAAMQ,yBAAyB,GAAGZ,WAAW,CAC1Ca,GAAmB,IAAW;IAC7B;IACA,IAAIL,cAAc,EAAE;MAClBG,0BAA0B,CAACE,GAAG,CAAC;IACjC;IAEAN,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAGM,GAAG,CAAC;EACxB,CAAC,EACD,CAACL,cAAc,EAAED,eAAe,CAClC,CAAC;EAED,OAAO;IACLO,4BAA4B,EAAEN,cAAc,GACxCE,uBAAuB,GACvBL,WAAW;IACfO;EACF,CAAC;AACH;AAEA,eAAeV,4BAA4B"}
@@ -0,0 +1,10 @@
1
+ import { ItemElement, ItemKey, SectionElement } from './itemUtils';
2
+ export interface UseStaticItemInitialScrollPositionOptions {
3
+ itemHeight: number;
4
+ items: (ItemElement<unknown> | SectionElement<unknown>)[];
5
+ selectedKey?: ItemKey | null;
6
+ topOffset: number;
7
+ }
8
+ export declare function useStaticItemInitialScrollPosition({ itemHeight, selectedKey, topOffset, items, }: UseStaticItemInitialScrollPositionOptions): () => Promise<number | null>;
9
+ export default useStaticItemInitialScrollPosition;
10
+ //# sourceMappingURL=useStaticItemInitialScrollPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStaticItemInitialScrollPosition.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStaticItemInitialScrollPosition.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,WAAW,EACX,OAAO,EACP,cAAc,EACf,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,yCAAyC;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IAC1D,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,kCAAkC,CAAC,EACjD,UAAU,EACV,WAAW,EACX,SAAS,EACT,KAAK,GACN,EAAE,yCAAyC,GAAG,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0B1E;AAED,eAAe,kCAAkC,CAAC"}
@@ -0,0 +1,27 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
+ import { useCallback, useMemo } from 'react';
4
+ import { getPositionOfSelectedItemElement, isItemElementWithDescription, isSectionElement } from "./itemUtils.js";
5
+ export function useStaticItemInitialScrollPosition(_ref) {
6
+ var {
7
+ itemHeight,
8
+ selectedKey,
9
+ topOffset,
10
+ items
11
+ } = _ref;
12
+ // Item descriptions and Section elements introduce variable item heights.
13
+ // This throws off scroll position calculations, so we disable auto scrolling
14
+ // if either of these are found.
15
+ var disableScrollOnOpen = useMemo(() => items.some(item => isSectionElement(item) || isItemElementWithDescription(item)), [items]);
16
+ var getInitialScrollPosition = useCallback( /*#__PURE__*/_asyncToGenerator(function* () {
17
+ return disableScrollOnOpen ? topOffset : getPositionOfSelectedItemElement({
18
+ items,
19
+ itemHeight,
20
+ selectedKey,
21
+ topOffset
22
+ });
23
+ }), [disableScrollOnOpen, itemHeight, items, selectedKey, topOffset]);
24
+ return getInitialScrollPosition;
25
+ }
26
+ export default useStaticItemInitialScrollPosition;
27
+ //# sourceMappingURL=useStaticItemInitialScrollPosition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStaticItemInitialScrollPosition.js","names":["useCallback","useMemo","getPositionOfSelectedItemElement","isItemElementWithDescription","isSectionElement","useStaticItemInitialScrollPosition","_ref","itemHeight","selectedKey","topOffset","items","disableScrollOnOpen","some","item","getInitialScrollPosition","_asyncToGenerator"],"sources":["../../../src/spectrum/utils/useStaticItemInitialScrollPosition.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport {\n getPositionOfSelectedItemElement,\n isItemElementWithDescription,\n isSectionElement,\n ItemElement,\n ItemKey,\n SectionElement,\n} from './itemUtils';\n\nexport interface UseStaticItemInitialScrollPositionOptions {\n itemHeight: number;\n items: (ItemElement<unknown> | SectionElement<unknown>)[];\n selectedKey?: ItemKey | null;\n topOffset: number;\n}\n\nexport function useStaticItemInitialScrollPosition({\n itemHeight,\n selectedKey,\n topOffset,\n items,\n}: UseStaticItemInitialScrollPositionOptions): () => Promise<number | null> {\n // Item descriptions and Section elements introduce variable item heights.\n // This throws off scroll position calculations, so we disable auto scrolling\n // if either of these are found.\n const disableScrollOnOpen = useMemo(\n () =>\n items.some(\n item => isSectionElement(item) || isItemElementWithDescription(item)\n ),\n [items]\n );\n\n const getInitialScrollPosition = useCallback(\n async () =>\n disableScrollOnOpen\n ? topOffset\n : getPositionOfSelectedItemElement({\n items,\n itemHeight,\n selectedKey,\n topOffset,\n }),\n [disableScrollOnOpen, itemHeight, items, selectedKey, topOffset]\n );\n\n return getInitialScrollPosition;\n}\n\nexport default useStaticItemInitialScrollPosition;\n"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAE3CC,gCAAgC,EAChCC,4BAA4B,EAC5BC,gBAAgB;AAalB,OAAO,SAASC,kCAAkCA,CAAAC,IAAA,EAK0B;EAAA,IALzB;IACjDC,UAAU;IACVC,WAAW;IACXC,SAAS;IACTC;EACyC,CAAC,GAAAJ,IAAA;EAC1C;EACA;EACA;EACA,IAAMK,mBAAmB,GAAGV,OAAO,CACjC,MACES,KAAK,CAACE,IAAI,CACRC,IAAI,IAAIT,gBAAgB,CAACS,IAAI,CAAC,IAAIV,4BAA4B,CAACU,IAAI,CACrE,CAAC,EACH,CAACH,KAAK,CACR,CAAC;EAED,IAAMI,wBAAwB,GAAGd,WAAW,eAAAe,iBAAA,CAC1C;IAAA,OACEJ,mBAAmB,GACfF,SAAS,GACTP,gCAAgC,CAAC;MAC/BQ,KAAK;MACLH,UAAU;MACVC,WAAW;MACXC;IACF,CAAC,CAAC;EAAA,IACR,CAACE,mBAAmB,EAAEJ,UAAU,EAAEG,KAAK,EAAEF,WAAW,EAAEC,SAAS,CACjE,CAAC;EAED,OAAOK,wBAAwB;AACjC;AAEA,eAAeT,kCAAkC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/components",
3
- "version": "0.82.0",
3
+ "version": "0.82.1-beta.2+640e002f",
4
4
  "description": "Deephaven React component library",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "Apache-2.0",
@@ -25,10 +25,10 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@adobe/react-spectrum": "3.35.1",
28
- "@deephaven/icons": "^0.82.0",
29
- "@deephaven/log": "^0.82.0",
30
- "@deephaven/react-hooks": "^0.82.0",
31
- "@deephaven/utils": "^0.82.0",
28
+ "@deephaven/icons": "^0.82.1-beta.2+640e002f",
29
+ "@deephaven/log": "^0.82.1-beta.2+640e002f",
30
+ "@deephaven/react-hooks": "^0.82.1-beta.2+640e002f",
31
+ "@deephaven/utils": "^0.82.1-beta.2+640e002f",
32
32
  "@fortawesome/fontawesome-svg-core": "^6.2.1",
33
33
  "@fortawesome/react-fontawesome": "^0.2.0",
34
34
  "@react-spectrum/theme-default": "^3.5.1",
@@ -56,7 +56,7 @@
56
56
  "react-dom": ">=16.8.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@deephaven/mocks": "^0.82.0"
59
+ "@deephaven/mocks": "^0.82.1-beta.2+640e002f"
60
60
  },
61
61
  "files": [
62
62
  "dist",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "c804b1518d77f908fdc5525197fd8c87c3e27b10"
73
+ "gitHead": "640e002f85ea86961a22695c9c7659ca5d1de1ee"
74
74
  }