@deephaven/components 0.74.1-beta.7 → 0.75.0

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 (52) hide show
  1. package/dist/Button.d.ts +1 -1
  2. package/dist/Select.d.ts +1 -1
  3. package/dist/spectrum/listView/ListView.d.ts +3 -2
  4. package/dist/spectrum/listView/ListView.d.ts.map +1 -1
  5. package/dist/spectrum/listView/ListView.js +10 -63
  6. package/dist/spectrum/listView/ListView.js.map +1 -1
  7. package/dist/spectrum/listView/ListViewNormalized.d.ts +22 -0
  8. package/dist/spectrum/listView/ListViewNormalized.d.ts.map +1 -0
  9. package/dist/spectrum/listView/ListViewNormalized.js +80 -0
  10. package/dist/spectrum/listView/ListViewNormalized.js.map +1 -0
  11. package/dist/spectrum/listView/ListViewWrapper.css +39 -0
  12. package/dist/spectrum/listView/ListViewWrapper.css.map +1 -0
  13. package/dist/spectrum/listView/ListViewWrapper.d.ts +21 -0
  14. package/dist/spectrum/listView/ListViewWrapper.d.ts.map +1 -0
  15. package/dist/spectrum/listView/ListViewWrapper.js +71 -0
  16. package/dist/spectrum/listView/ListViewWrapper.js.map +1 -0
  17. package/dist/spectrum/listView/index.d.ts +2 -0
  18. package/dist/spectrum/listView/index.d.ts.map +1 -1
  19. package/dist/spectrum/listView/index.js +2 -0
  20. package/dist/spectrum/listView/index.js.map +1 -1
  21. package/dist/spectrum/picker/Picker.d.ts.map +1 -1
  22. package/dist/spectrum/picker/Picker.js +2 -2
  23. package/dist/spectrum/picker/Picker.js.map +1 -1
  24. package/dist/spectrum/picker/PickerNormalized.d.ts +2 -1
  25. package/dist/spectrum/picker/PickerNormalized.d.ts.map +1 -1
  26. package/dist/spectrum/picker/PickerNormalized.js +31 -15
  27. package/dist/spectrum/picker/PickerNormalized.js.map +1 -1
  28. package/dist/spectrum/shared.d.ts +13 -9
  29. package/dist/spectrum/shared.d.ts.map +1 -1
  30. package/dist/spectrum/shared.js +16 -1
  31. package/dist/spectrum/shared.js.map +1 -1
  32. package/dist/spectrum/utils/index.d.ts +1 -0
  33. package/dist/spectrum/utils/index.d.ts.map +1 -1
  34. package/dist/spectrum/utils/index.js +1 -0
  35. package/dist/spectrum/utils/index.js.map +1 -1
  36. package/dist/spectrum/utils/itemUtils.d.ts +9 -14
  37. package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
  38. package/dist/spectrum/utils/itemUtils.js +8 -108
  39. package/dist/spectrum/utils/itemUtils.js.map +1 -1
  40. package/dist/spectrum/utils/itemWrapperUtils.d.ts +19 -3
  41. package/dist/spectrum/utils/itemWrapperUtils.d.ts.map +1 -1
  42. package/dist/spectrum/utils/itemWrapperUtils.js +65 -19
  43. package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -1
  44. package/dist/spectrum/utils/propsUtils.d.ts +14 -0
  45. package/dist/spectrum/utils/propsUtils.d.ts.map +1 -0
  46. package/dist/spectrum/utils/propsUtils.js +93 -0
  47. package/dist/spectrum/utils/propsUtils.js.map +1 -0
  48. package/dist/spectrum/utils/useRenderNormalizedItem.d.ts +11 -2
  49. package/dist/spectrum/utils/useRenderNormalizedItem.d.ts.map +1 -1
  50. package/dist/spectrum/utils/useRenderNormalizedItem.js +21 -8
  51. package/dist/spectrum/utils/useRenderNormalizedItem.js.map +1 -1
  52. package/package.json +7 -7
@@ -1,2 +1,4 @@
1
1
  export * from "./ListView.js";
2
+ export * from "./ListViewNormalized.js";
3
+ export * from "./ListViewWrapper.js";
2
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/listView/index.ts"],"sourcesContent":["export * from './ListView';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/listView/index.ts"],"sourcesContent":["export * from './ListView';\nexport * from './ListViewNormalized';\nexport * from './ListViewWrapper';\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/Picker.tsx"],"names":[],"mappings":";AASA,OAAO,EACL,6BAA6B,EAC7B,aAAa,EAEb,OAAO,EAEP,cAAc,EAGf,MAAM,oBAAoB,CAAC;AAK5B,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,aAAa,GAAG,aAAa,EAAE,CAAC;IAE1C,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAEnC,iEAAiE;IACjE,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAE7B,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAElC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAElC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C,GAKK,IAAI,CACR,6BAA6B,EAC3B,UAAU,GACV,OAAO,GACP,mBAAmB,GACnB,aAAa,GACb,oBAAoB,CACvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,OAAc,EACd,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,iBAAiB,EAEjB,gBAAgB,EAChB,GAAG,mBAAmB,EACvB,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAuF3B;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/Picker.tsx"],"names":[],"mappings":";AAUA,OAAO,EACL,6BAA6B,EAC7B,aAAa,EAEb,OAAO,EAEP,cAAc,EAGf,MAAM,oBAAoB,CAAC;AAK5B,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,aAAa,GAAG,aAAa,EAAE,CAAC;IAE1C,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAEnC,iEAAiE;IACjE,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAE7B,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAElC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAElC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C,GAKK,IAAI,CACR,6BAA6B,EAC3B,UAAU,GACV,OAAO,GACP,mBAAmB,GACnB,aAAa,GACb,oBAAoB,CACvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,OAAc,EACd,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,iBAAiB,EAEjB,gBAAgB,EAChB,GAAG,mBAAmB,EACvB,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAuF3B;AAED,eAAe,MAAM,CAAC"}
@@ -11,7 +11,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
11
11
  import { useCallback, useMemo, useState } from 'react';
12
12
  import { Picker as SpectrumPicker } from '@adobe/react-spectrum';
13
13
  import cl from 'classnames';
14
- import { EMPTY_FUNCTION, PICKER_ITEM_HEIGHTS, PICKER_TOP_OFFSET } from '@deephaven/utils';
14
+ import { EMPTY_FUNCTION, ensureArray, PICKER_ITEM_HEIGHTS, PICKER_TOP_OFFSET } from '@deephaven/utils';
15
15
  import { getPositionOfSelectedItemElement, normalizeTooltipOptions, isItemElementWithDescription, isSectionElement } from "../utils/itemUtils.js";
16
16
  import { wrapItemChildren } from "../utils/itemWrapperUtils.js";
17
17
  import usePickerScrollOnOpen from "./usePickerScrollOnOpen.js";
@@ -48,7 +48,7 @@ export function Picker(_ref) {
48
48
  // for explicit `undefined` to identify uncontrolled mode.
49
49
  var isUncontrolled = selectedKey === undefined;
50
50
  var [uncontrolledSelectedKey, setUncontrolledSelectedKey] = useState(defaultSelectedKey);
51
- var wrappedItems = useMemo(() => wrapItemChildren(children, tooltipOptions), [children, tooltipOptions]);
51
+ var wrappedItems = useMemo(() => ensureArray(wrapItemChildren(children, tooltipOptions)), [children, tooltipOptions]);
52
52
 
53
53
  // Item descriptions and Section elements introduce variable item heights.
54
54
  // This throws off scroll position calculations, so we disable auto scrolling
@@ -1 +1 @@
1
- {"version":3,"file":"Picker.js","names":["useCallback","useMemo","useState","Picker","SpectrumPicker","cl","EMPTY_FUNCTION","PICKER_ITEM_HEIGHTS","PICKER_TOP_OFFSET","getPositionOfSelectedItemElement","normalizeTooltipOptions","isItemElementWithDescription","isSectionElement","wrapItemChildren","usePickerScrollOnOpen","useSpectrumThemeProvider","jsx","_jsx","_ref","children","tooltip","defaultSelectedKey","selectedKey","onChange","onOpenChange","onScroll","onSelectionChange","UNSAFE_className","spectrumPickerProps","_objectWithoutProperties","_excluded","scale","itemHeight","tooltipOptions","isUncontrolled","undefined","uncontrolledSelectedKey","setUncontrolledSelectedKey","wrappedItems","disableScrollOnOpen","some","item","getInitialScrollPosition","_asyncToGenerator","items","topOffset","onSelectionChangeInternal","key","_ref3","ref","scrollRef","onOpenChangeInternal","_objectSpread"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport type { DOMRef } from '@react-types/shared';\nimport { Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport cl from 'classnames';\nimport {\n EMPTY_FUNCTION,\n PICKER_ITEM_HEIGHTS,\n PICKER_TOP_OFFSET,\n} from '@deephaven/utils';\nimport {\n NormalizedSpectrumPickerProps,\n ItemOrSection,\n getPositionOfSelectedItemElement,\n ItemKey,\n normalizeTooltipOptions,\n TooltipOptions,\n isItemElementWithDescription,\n isSectionElement,\n} from '../utils/itemUtils';\nimport { wrapItemChildren } from '../utils/itemWrapperUtils';\nimport usePickerScrollOnOpen from './usePickerScrollOnOpen';\nimport { useSpectrumThemeProvider } from '../../theme';\n\nexport type PickerProps = {\n children: ItemOrSection | ItemOrSection[];\n\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n\n /** The currently selected key in the collection (controlled). */\n selectedKey?: ItemKey | null;\n\n /** The initial selected key in the collection (uncontrolled). */\n defaultSelectedKey?: 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?: (key: ItemKey) => void;\n\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead\n */\n onSelectionChange?: (key: ItemKey) => void;\n} /*\n * Support remaining SpectrumPickerProps.\n * Note that `selectedKey`, `defaultSelectedKey`, and `onSelectionChange` are\n * re-defined above to account for boolean types which aren't included in the\n * React `Key` type, but are actually supported by the Spectrum Picker component.\n */ & Omit<\n NormalizedSpectrumPickerProps,\n | 'children'\n | 'items'\n | 'onSelectionChange'\n | 'selectedKey'\n | 'defaultSelectedKey'\n>;\n\n/**\n * Picker component for selecting items from a list of items. Items can be\n * provided via the `children` prop. Each item can be a string,\tnumber, boolean,\n * or a Spectrum <Item> element. The remaining props are just\tpass through props\n * for the Spectrum Picker component.\n * See https://react-spectrum.adobe.com/react-spectrum/Picker.html\n */\nexport function Picker({\n children,\n tooltip = true,\n defaultSelectedKey,\n selectedKey,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n // eslint-disable-next-line camelcase\n UNSAFE_className,\n ...spectrumPickerProps\n}: PickerProps): JSX.Element {\n const { scale } = useSpectrumThemeProvider();\n const itemHeight = PICKER_ITEM_HEIGHTS[scale];\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\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] =\n useState(defaultSelectedKey);\n\n const wrappedItems = useMemo(\n () => wrapItemChildren(children, tooltipOptions),\n [children, tooltipOptions]\n );\n\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 wrappedItems.some(\n item => isSectionElement(item) || isItemElementWithDescription(item)\n ),\n [wrappedItems]\n );\n\n const getInitialScrollPosition = useCallback(\n async () =>\n disableScrollOnOpen\n ? null\n : getPositionOfSelectedItemElement({\n items: wrappedItems,\n itemHeight,\n selectedKey: isUncontrolled ? uncontrolledSelectedKey : selectedKey,\n topOffset: PICKER_TOP_OFFSET,\n }),\n [\n disableScrollOnOpen,\n isUncontrolled,\n itemHeight,\n selectedKey,\n uncontrolledSelectedKey,\n wrappedItems,\n ]\n );\n\n const onSelectionChangeInternal = useCallback(\n (key: ItemKey): void => {\n // If our component is uncontrolled, track the selected key internally\n // so that we can scroll to the selected item if the user re-opens\n if (isUncontrolled) {\n setUncontrolledSelectedKey(key);\n }\n\n (onChange ?? onSelectionChange)?.(key);\n },\n [isUncontrolled, onChange, onSelectionChange]\n );\n\n const { ref: scrollRef, onOpenChange: onOpenChangeInternal } =\n usePickerScrollOnOpen({\n getInitialScrollPosition,\n onScroll,\n onOpenChange,\n });\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumPickerProps}\n ref={scrollRef as DOMRef<HTMLDivElement>}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n selectedKey={selectedKey as NormalizedSpectrumPickerProps['selectedKey']}\n defaultSelectedKey={\n defaultSelectedKey as NormalizedSpectrumPickerProps['defaultSelectedKey']\n }\n onSelectionChange={onSelectionChangeInternal}\n onOpenChange={onOpenChangeInternal}\n >\n {wrappedItems}\n </SpectrumPicker>\n );\n}\n\nexport default Picker;\n"],"mappings":";;;;;;;;;;AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAEtD,SAASC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AAChE,OAAOC,EAAE,MAAM,YAAY;AAC3B,SACEC,cAAc,EACdC,mBAAmB,EACnBC,iBAAiB,QACZ,kBAAkB;AAAC,SAIxBC,gCAAgC,EAEhCC,uBAAuB,EAEvBC,4BAA4B,EAC5BC,gBAAgB;AAAA,SAETC,gBAAgB;AAAA,OAClBC,qBAAqB;AAAA,SACnBC,wBAAwB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AA4CjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASd,MAAMA,CAAAe,IAAA,EAYO;EAAA,IAZN;MACrBC,QAAQ;MACRC,OAAO,GAAG,IAAI;MACdC,kBAAkB;MAClBC,WAAW;MACXC,QAAQ;MACRC,YAAY;MACZC,QAAQ,GAAGnB,cAAc;MACzBoB,iBAAiB;MACjB;MACAC;IAEW,CAAC,GAAAT,IAAA;IADTU,mBAAmB,GAAAC,wBAAA,CAAAX,IAAA,EAAAY,SAAA;EAEtB,IAAM;IAAEC;EAAM,CAAC,GAAGhB,wBAAwB,CAAC,CAAC;EAC5C,IAAMiB,UAAU,GAAGzB,mBAAmB,CAACwB,KAAK,CAAC;EAE7C,IAAME,cAAc,GAAGhC,OAAO,CAC5B,MAAMS,uBAAuB,CAACU,OAAO,CAAC,EACtC,CAACA,OAAO,CACV,CAAC;;EAED;EACA;EACA,IAAMc,cAAc,GAAGZ,WAAW,KAAKa,SAAS;EAChD,IAAM,CAACC,uBAAuB,EAAEC,0BAA0B,CAAC,GACzDnC,QAAQ,CAACmB,kBAAkB,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EAAA,EAAAgD,aAAA,CAAAA,aAAA,KACIxB,mBAAmB;IACvBqB,GAAG,EAAEC,SAAoC;IACzCvB,gBAAgB,EAAEtB,EAAE,CAAC,WAAW,EAAEsB,gBAAgB,CAAE;IACpDL,WAAW,EAAEA,WAA4D;IACzED,kBAAkB,EAChBA,kBACD;IACDK,iBAAiB,EAAEoB,yBAA0B;IAC7CtB,YAAY,EAAE2B,oBAAqB;IAAAhC,QAAA,EAElCmB;EAAY,EACC,CAAC;AAErB;AAEA,eAAenC,MAAM"}
1
+ {"version":3,"file":"Picker.js","names":["useCallback","useMemo","useState","Picker","SpectrumPicker","cl","EMPTY_FUNCTION","ensureArray","PICKER_ITEM_HEIGHTS","PICKER_TOP_OFFSET","getPositionOfSelectedItemElement","normalizeTooltipOptions","isItemElementWithDescription","isSectionElement","wrapItemChildren","usePickerScrollOnOpen","useSpectrumThemeProvider","jsx","_jsx","_ref","children","tooltip","defaultSelectedKey","selectedKey","onChange","onOpenChange","onScroll","onSelectionChange","UNSAFE_className","spectrumPickerProps","_objectWithoutProperties","_excluded","scale","itemHeight","tooltipOptions","isUncontrolled","undefined","uncontrolledSelectedKey","setUncontrolledSelectedKey","wrappedItems","disableScrollOnOpen","some","item","getInitialScrollPosition","_asyncToGenerator","items","topOffset","onSelectionChangeInternal","key","_ref3","ref","scrollRef","onOpenChangeInternal","_objectSpread"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport type { DOMRef } from '@react-types/shared';\nimport { Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport cl from 'classnames';\nimport {\n EMPTY_FUNCTION,\n ensureArray,\n PICKER_ITEM_HEIGHTS,\n PICKER_TOP_OFFSET,\n} from '@deephaven/utils';\nimport {\n NormalizedSpectrumPickerProps,\n ItemOrSection,\n getPositionOfSelectedItemElement,\n ItemKey,\n normalizeTooltipOptions,\n TooltipOptions,\n isItemElementWithDescription,\n isSectionElement,\n} from '../utils/itemUtils';\nimport { wrapItemChildren } from '../utils/itemWrapperUtils';\nimport usePickerScrollOnOpen from './usePickerScrollOnOpen';\nimport { useSpectrumThemeProvider } from '../../theme';\n\nexport type PickerProps = {\n children: ItemOrSection | ItemOrSection[];\n\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n\n /** The currently selected key in the collection (controlled). */\n selectedKey?: ItemKey | null;\n\n /** The initial selected key in the collection (uncontrolled). */\n defaultSelectedKey?: 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?: (key: ItemKey) => void;\n\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead\n */\n onSelectionChange?: (key: ItemKey) => void;\n} /*\n * Support remaining SpectrumPickerProps.\n * Note that `selectedKey`, `defaultSelectedKey`, and `onSelectionChange` are\n * re-defined above to account for boolean types which aren't included in the\n * React `Key` type, but are actually supported by the Spectrum Picker component.\n */ & Omit<\n NormalizedSpectrumPickerProps,\n | 'children'\n | 'items'\n | 'onSelectionChange'\n | 'selectedKey'\n | 'defaultSelectedKey'\n>;\n\n/**\n * Picker component for selecting items from a list of items. Items can be\n * provided via the `children` prop. Each item can be a string,\tnumber, boolean,\n * or a Spectrum <Item> element. The remaining props are just\tpass through props\n * for the Spectrum Picker component.\n * See https://react-spectrum.adobe.com/react-spectrum/Picker.html\n */\nexport function Picker({\n children,\n tooltip = true,\n defaultSelectedKey,\n selectedKey,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n // eslint-disable-next-line camelcase\n UNSAFE_className,\n ...spectrumPickerProps\n}: PickerProps): JSX.Element {\n const { scale } = useSpectrumThemeProvider();\n const itemHeight = PICKER_ITEM_HEIGHTS[scale];\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\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] =\n useState(defaultSelectedKey);\n\n const wrappedItems = useMemo(\n () => ensureArray(wrapItemChildren(children, tooltipOptions)),\n [children, tooltipOptions]\n );\n\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 wrappedItems.some(\n item => isSectionElement(item) || isItemElementWithDescription(item)\n ),\n [wrappedItems]\n );\n\n const getInitialScrollPosition = useCallback(\n async () =>\n disableScrollOnOpen\n ? null\n : getPositionOfSelectedItemElement({\n items: wrappedItems,\n itemHeight,\n selectedKey: isUncontrolled ? uncontrolledSelectedKey : selectedKey,\n topOffset: PICKER_TOP_OFFSET,\n }),\n [\n disableScrollOnOpen,\n isUncontrolled,\n itemHeight,\n selectedKey,\n uncontrolledSelectedKey,\n wrappedItems,\n ]\n );\n\n const onSelectionChangeInternal = useCallback(\n (key: ItemKey): void => {\n // If our component is uncontrolled, track the selected key internally\n // so that we can scroll to the selected item if the user re-opens\n if (isUncontrolled) {\n setUncontrolledSelectedKey(key);\n }\n\n (onChange ?? onSelectionChange)?.(key);\n },\n [isUncontrolled, onChange, onSelectionChange]\n );\n\n const { ref: scrollRef, onOpenChange: onOpenChangeInternal } =\n usePickerScrollOnOpen({\n getInitialScrollPosition,\n onScroll,\n onOpenChange,\n });\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumPickerProps}\n ref={scrollRef as DOMRef<HTMLDivElement>}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n selectedKey={selectedKey as NormalizedSpectrumPickerProps['selectedKey']}\n defaultSelectedKey={\n defaultSelectedKey as NormalizedSpectrumPickerProps['defaultSelectedKey']\n }\n onSelectionChange={onSelectionChange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mB;IACvBqB,GAAG,EAAEC,SAAoC;IACzCvB,gBAAgB,EAAEvB,EAAE,CAAC,WAAW,EAAEuB,gBAAgB,CAAE;IACpDL,WAAW,EAAEA,WAA4D;IACzED,kBAAkB,EAChBA,kBACD;IACDK,iBAAiB,EAAEoB,yBAA0B;IAC7CtB,YAAY,EAAE2B,oBAAqB;IAAAhC,QAAA,EAElCmB;EAAY,EACC,CAAC;AAErB;AAEA,eAAepC,MAAM"}
@@ -3,6 +3,7 @@ import type { PickerProps as PickerBaseProps } from './Picker';
3
3
  import { NormalizedItem, NormalizedSection } from '../utils';
4
4
  export interface PickerNormalizedProps extends Omit<PickerBaseProps, 'children'> {
5
5
  normalizedItems: (NormalizedItem | NormalizedSection)[];
6
+ showItemIcons: boolean;
6
7
  getInitialScrollPosition?: () => Promise<number | null | undefined>;
7
8
  onScroll?: (event: Event) => void;
8
9
  }
@@ -11,6 +12,6 @@ export interface PickerNormalizedProps extends Omit<PickerBaseProps, 'children'>
11
12
  * as children and uses a render item function to render the items. This is
12
13
  * necessary to support windowed data.
13
14
  */
14
- export declare function PickerNormalized({ normalizedItems, tooltip, selectedKey, defaultSelectedKey, disabledKeys, UNSAFE_className, getInitialScrollPosition, onChange, onOpenChange, onScroll, onSelectionChange, ...props }: PickerNormalizedProps): JSX.Element;
15
+ export declare function PickerNormalized({ normalizedItems, tooltip, selectedKey, defaultSelectedKey, disabledKeys, showItemIcons, UNSAFE_className, getInitialScrollPosition, onChange, onOpenChange, onScroll, onSelectionChange, ...props }: PickerNormalizedProps): JSX.Element;
15
16
  export default PickerNormalized;
16
17
  //# sourceMappingURL=PickerNormalized.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PickerNormalized.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerNormalized.tsx"],"names":[],"mappings":";AAMA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,EAGL,cAAc,EACd,iBAAiB,EA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,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,wBAAwB,EACxB,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAgFrC;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,4 +1,4 @@
1
- var _excluded = ["normalizedItems", "tooltip", "selectedKey", "defaultSelectedKey", "disabledKeys", "UNSAFE_className", "getInitialScrollPosition", "onChange", "onOpenChange", "onScroll", "onSelectionChange"];
1
+ var _excluded = ["normalizedItems", "tooltip", "selectedKey", "defaultSelectedKey", "disabledKeys", "showItemIcons", "UNSAFE_className", "getInitialScrollPosition", "onChange", "onOpenChange", "onScroll", "onSelectionChange"];
2
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
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
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; }
@@ -14,6 +14,7 @@ import { Section } from "../shared.js";
14
14
  import { getItemKey, isNormalizedSection, normalizeTooltipOptions, useRenderNormalizedItem, useStringifiedSelection } from "../utils/index.js";
15
15
  import usePickerScrollOnOpen from "./usePickerScrollOnOpen.js";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { createElement as _createElement } from "react";
17
18
  /**
18
19
  * Picker that takes an array of `NormalizedItem` or `NormalizedSection` items
19
20
  * as children and uses a render item function to render the items. This is
@@ -26,6 +27,7 @@ export function PickerNormalized(_ref) {
26
27
  selectedKey,
27
28
  defaultSelectedKey,
28
29
  disabledKeys,
30
+ showItemIcons,
29
31
  UNSAFE_className,
30
32
  getInitialScrollPosition,
31
33
  onChange,
@@ -35,7 +37,21 @@ export function PickerNormalized(_ref) {
35
37
  } = _ref,
36
38
  props = _objectWithoutProperties(_ref, _excluded);
37
39
  var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip), [tooltip]);
38
- var renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);
40
+ var renderNormalizedItem = useRenderNormalizedItem({
41
+ itemIconSlot: 'icon',
42
+ // Descriptions introduce variable item heights which throws off calculation
43
+ // of initial scroll position and setting viewport on windowed data. For now
44
+ // not going to implement description support in Picker.
45
+ // https://github.com/deephaven/web-client-ui/issues/1958
46
+ showItemDescriptions: false,
47
+ showItemIcons,
48
+ tooltipOptions
49
+ });
50
+
51
+ // Spectrum doesn't re-render if only the `renderNormalizedItems` function
52
+ // changes, so we create a key from its dependencies that can be used to force
53
+ // re-render.
54
+ var forceRerenderKey = "".concat(showItemIcons, "-").concat(tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.placement);
39
55
  var {
40
56
  ref: scrollRef,
41
57
  onOpenChange: onOpenChangeInternal
@@ -60,9 +76,10 @@ export function PickerNormalized(_ref) {
60
76
  disabledKeys,
61
77
  onChange: onChange !== null && onChange !== void 0 ? onChange : onSelectionChange
62
78
  });
63
- return /*#__PURE__*/_jsx(SpectrumPicker
79
+ return /*#__PURE__*/_createElement(SpectrumPicker
64
80
  // eslint-disable-next-line react/jsx-props-no-spreading
65
81
  , _objectSpread(_objectSpread({}, props), {}, {
82
+ key: forceRerenderKey,
66
83
  ref: scrollRef,
67
84
  UNSAFE_className: cl('dh-picker', 'dh-picker-normalized', UNSAFE_className),
68
85
  items: normalizedItems,
@@ -70,19 +87,18 @@ export function PickerNormalized(_ref) {
70
87
  defaultSelectedKey: defaultSelectedStringKey,
71
88
  disabledKeys: disabledStringKeys,
72
89
  onSelectionChange: onStringSelectionChange,
73
- onOpenChange: onOpenChangeInternal,
74
- children: itemOrSection => {
75
- if (isNormalizedSection(itemOrSection)) {
76
- var _itemOrSection$item, _itemOrSection$item2;
77
- return /*#__PURE__*/_jsx(Section, {
78
- title: (_itemOrSection$item = itemOrSection.item) === null || _itemOrSection$item === void 0 ? void 0 : _itemOrSection$item.title,
79
- items: (_itemOrSection$item2 = itemOrSection.item) === null || _itemOrSection$item2 === void 0 ? void 0 : _itemOrSection$item2.items,
80
- children: renderNormalizedItem
81
- }, getItemKey(itemOrSection));
82
- }
83
- return renderNormalizedItem(itemOrSection);
90
+ onOpenChange: onOpenChangeInternal
91
+ }), itemOrSection => {
92
+ if (isNormalizedSection(itemOrSection)) {
93
+ var _itemOrSection$item, _itemOrSection$item2;
94
+ return /*#__PURE__*/_jsx(Section, {
95
+ title: (_itemOrSection$item = itemOrSection.item) === null || _itemOrSection$item === void 0 ? void 0 : _itemOrSection$item.title,
96
+ items: (_itemOrSection$item2 = itemOrSection.item) === null || _itemOrSection$item2 === void 0 ? void 0 : _itemOrSection$item2.items,
97
+ children: renderNormalizedItem
98
+ }, getItemKey(itemOrSection));
84
99
  }
85
- }));
100
+ return renderNormalizedItem(itemOrSection);
101
+ });
86
102
  }
87
103
  export default PickerNormalized;
88
104
  //# sourceMappingURL=PickerNormalized.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PickerNormalized.js","names":["useMemo","Picker","SpectrumPicker","cl","EMPTY_FUNCTION","Section","getItemKey","isNormalizedSection","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedSelection","usePickerScrollOnOpen","jsx","_jsx","PickerNormalized","_ref","normalizedItems","tooltip","selectedKey","defaultSelectedKey","disabledKeys","UNSAFE_className","getInitialScrollPosition","onChange","onOpenChange","onScroll","onSelectionChange","props","_objectWithoutProperties","_excluded","tooltipOptions","renderNormalizedItem","ref","scrollRef","onOpenChangeInternal","selectedStringKey","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","_objectSpread","items","children","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title","item"],"sources":["../../../src/spectrum/picker/PickerNormalized.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport type { DOMRef } from '@react-types/shared';\nimport cl from 'classnames';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport { Section } from '../shared';\nimport type { PickerProps as PickerBaseProps } from './Picker';\n\nimport {\n getItemKey,\n isNormalizedSection,\n NormalizedItem,\n NormalizedSection,\n normalizeTooltipOptions,\n useRenderNormalizedItem,\n useStringifiedSelection,\n} from '../utils';\nimport usePickerScrollOnOpen from './usePickerScrollOnOpen';\n\nexport interface PickerNormalizedProps\n extends Omit<PickerBaseProps, 'children'> {\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n getInitialScrollPosition?: () => Promise<number | null | undefined>;\n onScroll?: (event: Event) => void;\n}\n\n/**\n * Picker that takes an array of `NormalizedItem` or `NormalizedSection` items\n * as children and uses a render item function to render the items. This is\n * necessary to support windowed data.\n */\nexport function PickerNormalized({\n normalizedItems,\n tooltip = true,\n selectedKey,\n defaultSelectedKey,\n disabledKeys,\n UNSAFE_className,\n getInitialScrollPosition,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n ...props\n}: PickerNormalizedProps): JSX.Element {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);\n\n const { ref: scrollRef, onOpenChange: onOpenChangeInternal } =\n usePickerScrollOnOpen({\n getInitialScrollPosition,\n onScroll,\n onOpenChange,\n });\n\n // Spectrum Picker treats keys as strings if the `key` prop is explicitly\n // set on `Item` elements. Since we do this in `renderItem`, we need to\n // map original key types to and from strings so that selection works.\n const {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedSelection({\n normalizedItems,\n selectedKey,\n defaultSelectedKey,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n ref={scrollRef as DOMRef<HTMLDivElement>}\n UNSAFE_className={cl(\n 'dh-picker',\n 'dh-picker-normalized',\n UNSAFE_className\n )}\n items={normalizedItems}\n selectedKey={selectedStringKey}\n defaultSelectedKey={defaultSelectedStringKey}\n disabledKeys={disabledStringKeys}\n onSelectionChange={onStringSelectionChange}\n onOpenChange={onOpenChangeInternal}\n >\n {itemOrSection => {\n if (isNormalizedSection(itemOrSection)) {\n return (\n <Section\n key={getItemKey(itemOrSection)}\n title={itemOrSection.item?.title}\n items={itemOrSection.item?.items}\n >\n {renderNormalizedItem}\n </Section>\n );\n }\n\n return renderNormalizedItem(itemOrSection);\n }}\n </SpectrumPicker>\n );\n}\n\nexport default PickerNormalized;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AAEhE,OAAOC,EAAE,MAAM,YAAY;AAC3B,SAASC,cAAc,QAAQ,kBAAkB;AAAC,SACzCC,OAAO;AAAA,SAIdC,UAAU,EACVC,mBAAmB,EAGnBC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB;AAAA,OAElBC,qBAAqB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAS5B;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAAC,IAAA,EAaO;EAAA,IAbN;MAC/BC,eAAe;MACfC,OAAO,GAAG,IAAI;MACdC,WAAW;MACXC,kBAAkB;MAClBC,YAAY;MACZC,gBAAgB;MAChBC,wBAAwB;MACxBC,QAAQ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AAED,aAAa,CAACI,IAAI,cAAAH,mBAAA,uBAAlBA,mBAAA,CAAoBE,KAAM;UACjCL,KAAK,GAAAI,oBAAA,GAAEF,aAAa,CAACI,IAAI,cAAAF,oBAAA,uBAAlBA,oBAAA,CAAoBJ,KAAM;UAAAC,QAAA,EAEhCV;QAAoB,GAJhBzB,UAAU,CAACoC,aAAa,CAKtB,CAAC;MAEd;MAEA,OAAOX,oBAAoB,CAACW,aAAa,CAAC;IAC5C;EAAC,EACa,CAAC;AAErB;AAEA,eAAe5B,gBAAgB"}
1
+ {"version":3,"file":"PickerNormalized.js","names":["useMemo","Picker","SpectrumPicker","cl","EMPTY_FUNCTION","Section","getItemKey","isNormalizedSection","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedSelection","usePickerScrollOnOpen","jsx","_jsx","createElement","_createElement","PickerNormalized","_ref","normalizedItems","tooltip","selectedKey","defaultSelectedKey","disabledKeys","showItemIcons","UNSAFE_className","getInitialScrollPosition","onChange","onOpenChange","onScroll","onSelectionChange","props","_objectWithoutProperties","_excluded","tooltipOptions","renderNormalizedItem","itemIconSlot","showItemDescriptions","forceRerenderKey","concat","placement","ref","scrollRef","onOpenChangeInternal","selectedStringKey","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","_objectSpread","key","items","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title","item","children"],"sources":["../../../src/spectrum/picker/PickerNormalized.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport type { DOMRef } from '@react-types/shared';\nimport cl from 'classnames';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport { Section } from '../shared';\nimport type { PickerProps as PickerBaseProps } from './Picker';\n\nimport {\n getItemKey,\n isNormalizedSection,\n NormalizedItem,\n NormalizedSection,\n normalizeTooltipOptions,\n useRenderNormalizedItem,\n useStringifiedSelection,\n} from '../utils';\nimport usePickerScrollOnOpen from './usePickerScrollOnOpen';\n\nexport interface PickerNormalizedProps\n extends Omit<PickerBaseProps, 'children'> {\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n showItemIcons: boolean;\n getInitialScrollPosition?: () => Promise<number | null | undefined>;\n onScroll?: (event: Event) => void;\n}\n\n/**\n * Picker that takes an array of `NormalizedItem` or `NormalizedSection` items\n * as children and uses a render item function to render the items. This is\n * necessary to support windowed data.\n */\nexport function PickerNormalized({\n normalizedItems,\n tooltip = true,\n selectedKey,\n defaultSelectedKey,\n disabledKeys,\n showItemIcons,\n UNSAFE_className,\n getInitialScrollPosition,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n ...props\n}: PickerNormalizedProps): JSX.Element {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem({\n itemIconSlot: 'icon',\n // Descriptions introduce variable item heights which throws off calculation\n // of initial scroll position and setting viewport on windowed data. For now\n // not going to implement description support in Picker.\n // https://github.com/deephaven/web-client-ui/issues/1958\n showItemDescriptions: false,\n showItemIcons,\n tooltipOptions,\n });\n\n // Spectrum doesn't re-render if only the `renderNormalizedItems` function\n // changes, so we create a key from its dependencies that can be used to force\n // re-render.\n const forceRerenderKey = `${showItemIcons}-${tooltipOptions?.placement}`;\n\n const { ref: scrollRef, onOpenChange: onOpenChangeInternal } =\n usePickerScrollOnOpen({\n getInitialScrollPosition,\n onScroll,\n onOpenChange,\n });\n\n // Spectrum Picker treats keys as strings if the `key` prop is explicitly\n // set on `Item` elements. Since we do this in `renderItem`, we need to\n // map original key types to and from strings so that selection works.\n const {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedSelection({\n normalizedItems,\n selectedKey,\n defaultSelectedKey,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n key={forceRerenderKey}\n ref={scrollRef as DOMRef<HTMLDivElement>}\n UNSAFE_className={cl(\n 'dh-picker',\n 'dh-picker-normalized',\n UNSAFE_className\n )}\n items={normalizedItems}\n selectedKey={selectedStringKey}\n defaultSelectedKey={defaultSelectedStringKey}\n disabledKeys={disabledStringKeys}\n onSelectionChange={onStringSelectionChange}\n onOpenChange={onOpenChangeInternal}\n >\n {itemOrSection => {\n if (isNormalizedSection(itemOrSection)) {\n return (\n <Section\n key={getItemKey(itemOrSection)}\n title={itemOrSection.item?.title}\n items={itemOrSection.item?.items}\n >\n {renderNormalizedItem}\n </Section>\n );\n }\n\n return renderNormalizedItem(itemOrSection);\n }}\n </SpectrumPicker>\n );\n}\n\nexport default PickerNormalized;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AAEhE,OAAOC,EAAE,MAAM,YAAY;AAC3B,SAASC,cAAc,QAAQ,kBAAkB;AAAC,SACzCC,OAAO;AAAA,SAIdC,UAAU,EACVC,mBAAmB,EAGnBC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB;AAAA,OAElBC,qBAAqB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,aAAA,IAAAC,cAAA;AAU5B;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAAC,IAAA,EAcO;EAAA,IAdN;MAC/BC,eAAe;MACfC,OAAO,GAAG,IAAI;MACdC,WAAW;MACXC,kBAAkB;MAClBC,YAAY;MACZC,aAAa;MACbC,gBAAgB;MAChBC,wBAAwB;MACxBC,QAAQ;MACRC,YAAY;MACZC,QAAQ,GAAGxB,cAAc;MACzByB;IAEqB,CAAC,GAAAZ,IAAA;IADnBa,KAAK,GAAAC,wBAAA,CAAAd,IAAA,EAAAe,SAAA;EAER,IAAMC,cAAc,GAAGjC,OAAO,CAC5B,MAAMQ,uBAAuB,CAACW,OAAO,CAAC,EACtC,CAACA,OAAO,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,OAAO;QAENgD,KAAK,GAAAF,mBAAA,GAAED,aAAa,CAACI,IAAI,cAAAH,mBAAA,uBAAlBA,mBAAA,CAAoBE,KAAM;QACjCJ,KAAK,GAAAG,oBAAA,GAAEF,aAAa,CAACI,IAAI,cAAAF,oBAAA,uBAAlBA,oBAAA,CAAoBH,KAAM;QAAAM,QAAA,EAEhCrB;MAAoB,GAJhB5B,UAAU,CAAC4C,aAAa,CAKtB,CAAC;IAEd;IAEA,OAAOhB,oBAAoB,CAACgB,aAAa,CAAC;EAC5C,CACc,CAAC;AAErB;AAEA,eAAelC,gBAAgB"}
@@ -1,12 +1,16 @@
1
+ /// <reference types="react" />
2
+ import type { ItemElement, ItemRenderer, SectionProps as SpectrumSectionProps } from '@react-types/shared';
3
+ export { Item } from '@adobe/react-spectrum';
4
+ export type { ItemProps } from '@react-types/shared';
5
+ export type ItemElementOrPrimitive<T = unknown> = number | string | boolean | ItemElement<T>;
1
6
  /**
2
- * Wrapping Spectrum `Item` and `Section` components will break functionality
3
- * due to the way they are consumed by collection components. They are only used
4
- * to pass data and don't render anything on their own, so they don't need to be
5
- * wrapped. If we do ever need to wrap them for whatever reason, the static
6
- * `getCollectionNode` method will need to be implemented.
7
- * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Item.ts#L17
8
- * https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Section.ts#L18
7
+ * Spectrum SectionProps augmented with support for primitive item children.
9
8
  */
10
- export { Item, Section } from '@adobe/react-spectrum';
11
- export type { ItemProps, SectionProps } from '@react-types/shared';
9
+ export type SectionProps<T> = Omit<SpectrumSectionProps<T>, 'children'> & {
10
+ children: ItemElementOrPrimitive<T> | ItemElementOrPrimitive<T>[] | ItemRenderer<T>;
11
+ };
12
+ /**
13
+ * Re-export Spectrum Section component with augmented props type.
14
+ */
15
+ export declare const Section: <T>(props: SectionProps<T>) => JSX.Element;
12
16
  //# sourceMappingURL=shared.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/spectrum/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/spectrum/shared.ts"],"names":[],"mappings":";AAUA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,YAAY,IAAI,oBAAoB,EACrC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAMrD,MAAM,MAAM,sBAAsB,CAAC,CAAC,GAAG,OAAO,IAC1C,MAAM,GACN,MAAM,GACN,OAAO,GACP,WAAW,CAAC,CAAC,CAAC,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG;IACxE,QAAQ,EACJ,sBAAsB,CAAC,CAAC,CAAC,GACzB,sBAAsB,CAAC,CAAC,CAAC,EAAE,GAC3B,YAAY,CAAC,CAAC,CAAC,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,iCAEf,WAAW,CAAC"}
@@ -7,5 +7,20 @@
7
7
  * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Item.ts#L17
8
8
  * https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Section.ts#L18
9
9
  */
10
- export { Item, Section } from '@adobe/react-spectrum';
10
+ import { Section as SpectrumSection } from '@adobe/react-spectrum';
11
+ export { Item } from '@adobe/react-spectrum';
12
+
13
+ /*
14
+ * We support primitive values as shorthand for `Item` elements in certain
15
+ * components. This type represents this augmentation of the Spectrum types.
16
+ */
17
+
18
+ /**
19
+ * Spectrum SectionProps augmented with support for primitive item children.
20
+ */
21
+
22
+ /**
23
+ * Re-export Spectrum Section component with augmented props type.
24
+ */
25
+ export var Section = SpectrumSection;
11
26
  //# sourceMappingURL=shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","names":["Item","Section"],"sources":["../../src/spectrum/shared.ts"],"sourcesContent":["/**\n * Wrapping Spectrum `Item` and `Section` components will break functionality\n * due to the way they are consumed by collection components. They are only used\n * to pass data and don't render anything on their own, so they don't need to be\n * wrapped. If we do ever need to wrap them for whatever reason, the static\n * `getCollectionNode` method will need to be implemented.\n * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Item.ts#L17\n * https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Section.ts#L18\n */\nexport { Item, Section } from '@adobe/react-spectrum';\nexport type { ItemProps, SectionProps } from '@react-types/shared';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,OAAO,QAAQ,uBAAuB"}
1
+ {"version":3,"file":"shared.js","names":["Section","SpectrumSection","Item"],"sources":["../../src/spectrum/shared.ts"],"sourcesContent":["/**\n * Wrapping Spectrum `Item` and `Section` components will break functionality\n * due to the way they are consumed by collection components. They are only used\n * to pass data and don't render anything on their own, so they don't need to be\n * wrapped. If we do ever need to wrap them for whatever reason, the static\n * `getCollectionNode` method will need to be implemented.\n * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Item.ts#L17\n * https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Section.ts#L18\n */\nimport { Section as SpectrumSection } from '@adobe/react-spectrum';\nimport type {\n ItemElement,\n ItemRenderer,\n SectionProps as SpectrumSectionProps,\n} from '@react-types/shared';\n\nexport { Item } from '@adobe/react-spectrum';\nexport type { ItemProps } from '@react-types/shared';\n\n/*\n * We support primitive values as shorthand for `Item` elements in certain\n * components. This type represents this augmentation of the Spectrum types.\n */\nexport type ItemElementOrPrimitive<T = unknown> =\n | number\n | string\n | boolean\n | ItemElement<T>;\n\n/**\n * Spectrum SectionProps augmented with support for primitive item children.\n */\nexport type SectionProps<T> = Omit<SpectrumSectionProps<T>, 'children'> & {\n children:\n | ItemElementOrPrimitive<T>\n | ItemElementOrPrimitive<T>[]\n | ItemRenderer<T>;\n};\n\n/**\n * Re-export Spectrum Section component with augmented props type.\n */\nexport const Section = SpectrumSection as <T>(\n props: SectionProps<T>\n) => JSX.Element;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAO,IAAIC,eAAe,QAAQ,uBAAuB;AAOlE,SAASC,IAAI,QAAQ,uBAAuB;;AAG5C;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAQA;AACA;AACA;AACA,OAAO,IAAMF,OAAO,GAAGC,eAEP"}
@@ -1,5 +1,6 @@
1
1
  export * from './itemUtils';
2
2
  export * from './itemWrapperUtils';
3
+ export * from './propsUtils';
3
4
  export * from './themeUtils';
4
5
  export * from './useRenderNormalizedItem';
5
6
  export * from './useStringifiedMultiSelection';
@@ -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,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,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export * from "./itemUtils.js";
2
2
  export * from "./itemWrapperUtils.js";
3
+ export * from "./propsUtils.js";
3
4
  export * from "./themeUtils.js";
4
5
  export * from "./useRenderNormalizedItem.js";
5
6
  export * from "./useStringifiedMultiSelection.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/utils/index.ts"],"sourcesContent":["export * from './itemUtils';\nexport * from './itemWrapperUtils';\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 './useRenderNormalizedItem';\nexport * from './useStringifiedMultiSelection';\nexport * from './useStringifiedSelection';\n"],"mappings":""}
@@ -2,14 +2,13 @@ import { Key, ReactElement, ReactNode } from 'react';
2
2
  import { SpectrumPickerProps } from '@adobe/react-spectrum';
3
3
  import type { ItemRenderer } from '@react-types/shared';
4
4
  import { KeyedItem, SelectionT } from '@deephaven/utils';
5
- import { ItemProps, SectionProps } from '../shared';
5
+ import { ItemElementOrPrimitive, ItemProps, SectionProps } from '../shared';
6
6
  import { PopperOptions } from '../../popper';
7
7
  /**
8
8
  * `Item.textValue` prop needs to be a non-empty string for accessibility
9
9
  * purposes. This is not displayed in the UI.
10
10
  */
11
11
  export declare const ITEM_EMPTY_STRING_TEXT_VALUE = "Empty";
12
- export declare const INVALID_ITEM_ERROR_MESSAGE = "Items must be strings, numbers, booleans, <Item> or <Section> elements:";
13
12
  /**
14
13
  * React Spectrum <Section> supports an `ItemRenderer` function as a child. The
15
14
  * DH picker makes use of this internally, but we don't want to support it as
@@ -18,10 +17,10 @@ export declare const INVALID_ITEM_ERROR_MESSAGE = "Items must be strings, number
18
17
  type SectionPropsNoItemRenderer<T> = Omit<SectionProps<T>, 'children'> & {
19
18
  children: Exclude<SectionProps<T>['children'], ItemRenderer<T>>;
20
19
  };
21
- export type ItemElement = ReactElement<ItemProps<unknown>>;
22
- export type SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;
23
- export type ItemElementOrPrimitive = number | string | boolean | ItemElement;
24
- export type ItemOrSection = ItemElementOrPrimitive | SectionElement;
20
+ export type ItemElement<T = unknown> = ReactElement<ItemProps<T>>;
21
+ export type SectionElement<T = unknown> = ReactElement<SectionPropsNoItemRenderer<T>>;
22
+ export type ItemOrSection<T = unknown> = ItemElementOrPrimitive<T> | SectionElement<T>;
23
+ export type ItemIconSlot = 'icon' | 'image' | 'illustration';
25
24
  /**
26
25
  * Augment the Spectrum selection key type to include boolean values.
27
26
  * Spectrum collection components already supports this, but the built in types
@@ -38,6 +37,8 @@ export type ItemSelectionChangeHandler = (key: ItemKey) => void;
38
37
  export interface NormalizedItemData {
39
38
  key?: ItemKey;
40
39
  content: ReactNode;
40
+ description?: ReactNode;
41
+ icon?: ReactNode;
41
42
  textValue: string | undefined;
42
43
  }
43
44
  export interface NormalizedSectionData {
@@ -89,13 +90,13 @@ export declare function getPositionOfSelectedItemElement<TKey extends string | n
89
90
  * @param node The node to check
90
91
  * @returns True if the node is a Section element
91
92
  */
92
- export declare function isSectionElement<T>(node: ReactNode): node is ReactElement<SectionProps<T>>;
93
+ export declare function isSectionElement<T>(node: ReactNode): node is SectionElement<T>;
93
94
  /**
94
95
  * Determine if a node is an Item element.
95
96
  * @param node The node to check
96
97
  * @returns True if the node is an Item element
97
98
  */
98
- export declare function isItemElement<T>(node: ReactNode): node is ReactElement<ItemProps<T>>;
99
+ export declare function isItemElement<T>(node: ReactNode): node is ItemElement<T>;
99
100
  /**
100
101
  * Determine if a node is an Item element containing a child `Text` element with
101
102
  * a `slot` prop set to `description`.
@@ -123,12 +124,6 @@ export declare function isNormalizedSection(maybeNormalizedSection: NormalizedIt
123
124
  * @returns True if the node is an item or section
124
125
  */
125
126
  export declare function isItemOrSection(node: ReactNode): node is ItemOrSection;
126
- /**
127
- * Normalize an item or section or a list of items or sections.
128
- * @param itemsOrSections An item or section or array of items or sections
129
- * @returns An array of normalized items or sections
130
- */
131
- export declare function normalizeItemList<TItemOrSection extends ItemOrSection>(itemsOrSections: TItemOrSection | TItemOrSection[] | NormalizedItem[]): NormalizedItemOrSection<TItemOrSection>[];
132
127
  /**
133
128
  * Returns a TooltipOptions object or null if options is false or null.
134
129
  * @param options Tooltip options
@@ -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;AAGxD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAQ,SAAS,EAAW,YAAY,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAM7C;;;GAGG;AACH,eAAO,MAAM,4BAA4B,UAAU,CAAC;AAEpD,eAAO,MAAM,0BAA0B,4EACoC,CAAC;AAE5E;;;;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,GAAG,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3D,MAAM,MAAM,cA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gB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAC5C,IAAI,EAAE,SAAS,GACd,IAAI,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAiBpC;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,cAAc,SAAS,aAAa,EAEpC,IAAI,EACA,cAAc,GACd,cAAc,EAAE,GAChB,uBAAuB,CAAC,cAAc,CAAC,EAAE,GAC5C,IAAI,IAAI,uBAAuB,CAAC,cAAc,CAAC,EAAE,CAUnD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,sBAAsB,EAAE,cAAc,GAAG,iBAAiB,GACzD,sBAAsB,IAAI,iBAAiB,CAK7C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,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"}
@@ -1,18 +1,15 @@
1
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
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 Log from '@deephaven/log';
4
3
  import { isElementOfType } from '@deephaven/react-hooks';
4
+ import { ensureArray } from '@deephaven/utils';
5
5
  import { Item, Section } from "../shared.js";
6
6
  import { Text } from "../Text.js";
7
7
  import ItemContent from "../ItemContent.js";
8
- var log = Log.module('itemUtils');
9
-
10
8
  /**
11
9
  * `Item.textValue` prop needs to be a non-empty string for accessibility
12
10
  * purposes. This is not displayed in the UI.
13
11
  */
14
12
  export var ITEM_EMPTY_STRING_TEXT_VALUE = 'Empty';
15
- export var INVALID_ITEM_ERROR_MESSAGE = 'Items must be strings, numbers, booleans, <Item> or <Section> elements:';
16
13
 
17
14
  /**
18
15
  * React Spectrum <Section> supports an `ItemRenderer` function as a child. The
@@ -20,18 +17,19 @@ export var INVALID_ITEM_ERROR_MESSAGE = 'Items must be strings, numbers, boolean
20
17
  * an incoming prop.
21
18
  */
22
19
 
20
+ // Picker uses `icon` slot. ListView can use `image` or `illustration` slots.
21
+ // https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/picker/src/Picker.tsx#L194
22
+ // https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/list/src/ListViewItem.tsx#L266-L267
23
23
  /**
24
24
  * Augment the Spectrum selection key type to include boolean values.
25
25
  * Spectrum collection components already supports this, but the built in types
26
26
  * don't reflect it.
27
27
  */
28
-
29
28
  /**
30
29
  * Augment the Spectrum selection change handler type to include boolean keys.
31
30
  * Spectrum components already supports this, but the built in types don't
32
31
  * reflect it.
33
32
  */
34
-
35
33
  /**
36
34
  * Spectrum collection components support a variety of item types, including
37
35
  * strings, numbers, booleans, and more complex React elements. This type
@@ -40,7 +38,6 @@ export var INVALID_ITEM_ERROR_MESSAGE = 'Items must be strings, numbers, boolean
40
38
  * `KeyedItem` interface to be compatible with Windowed data utils
41
39
  * (e.g. `useViewportData`).
42
40
  */
43
-
44
41
  /**
45
42
  * DH wrappers of Spectrum collection components use a normalized item that
46
43
  * includes a `key` prop and an optional `item` prop. This is mostly to support
@@ -85,8 +82,8 @@ function _getPositionOfSelectedItemElement() {
85
82
  return position;
86
83
  }
87
84
  for (var i = 0; i < items.length; i += 1) {
88
- var _item = items[i];
89
- if (_item.key === selectedKey) {
85
+ var item = items[i];
86
+ if (item.key === selectedKey) {
90
87
  return position;
91
88
  }
92
89
  position += itemHeight;
@@ -121,10 +118,10 @@ export function isItemElementWithDescription(node) {
121
118
 
122
119
  // If children are wrapped in `ItemContent`, go down 1 level
123
120
  var children = isElementOfType(node.props.children, ItemContent) ? node.props.children.props.children : node.props.children;
124
- var childrenArray = Array.isArray(children) ? children : [children];
121
+ var childrenArray = ensureArray(children);
125
122
  var result = childrenArray.some(child => {
126
123
  var _child$props;
127
- return ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.slot) === 'description' && isElementOfType(child, Text);
124
+ return isElementOfType(child, Text) && ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.slot) === 'description';
128
125
  });
129
126
  return result;
130
127
  }
@@ -164,103 +161,6 @@ export function isItemOrSection(node) {
164
161
  return typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean' || isItemElement(node) || isSectionElement(node);
165
162
  }
166
163
 
167
- /**
168
- * Determine the `key` of an item or section.
169
- * @param itemOrSection The item or section
170
- * @returns A `ItemKey` for the item or undefined if a key can't be determined
171
- */
172
-
173
- function normalizeItemKey(itemOrSection) {
174
- var _itemOrSection$props$;
175
- // string, number, or boolean
176
- if (typeof itemOrSection !== 'object') {
177
- return itemOrSection;
178
- }
179
-
180
- // If `key` prop is explicitly set
181
- if (itemOrSection.key != null) {
182
- return itemOrSection.key;
183
- }
184
-
185
- // Section element
186
- if (isSectionElement(itemOrSection)) {
187
- return typeof itemOrSection.props.title === 'string' ? itemOrSection.props.title : undefined;
188
- }
189
-
190
- // Item element
191
- return (_itemOrSection$props$ = itemOrSection.props.textValue) !== null && _itemOrSection$props$ !== void 0 ? _itemOrSection$props$ : typeof itemOrSection.props.children === 'string' ? itemOrSection.props.children : undefined;
192
- }
193
-
194
- /**
195
- * Get a normalized `textValue` for an item ensuring it is a string.
196
- * @param item The item
197
- * @returns A string `textValue` for the item
198
- */
199
- function normalizeTextValue(item) {
200
- if (typeof item !== 'object') {
201
- return String(item);
202
- }
203
- if (item.props.textValue != null) {
204
- return item.props.textValue;
205
- }
206
- if (typeof item.props.children === 'string') {
207
- return item.props.children;
208
- }
209
- return undefined;
210
- }
211
-
212
- /**
213
- * Normalize an item or section to an object form.
214
- * @param itemOrSection item to normalize
215
- * @returns NormalizedItem or NormalizedSection object
216
- */
217
- function normalizeItem(itemOrSection) {
218
- if (!isItemOrSection(itemOrSection)) {
219
- log.debug(INVALID_ITEM_ERROR_MESSAGE, itemOrSection);
220
- throw new Error(INVALID_ITEM_ERROR_MESSAGE);
221
- }
222
- if (isSectionElement(itemOrSection)) {
223
- var _key = normalizeItemKey(itemOrSection);
224
- var {
225
- title
226
- } = itemOrSection.props;
227
- var items = normalizeItemList(itemOrSection.props.children).filter(
228
- // We don't support nested section elements
229
- childItem => !isSectionElement(childItem));
230
- return {
231
- item: {
232
- key: _key,
233
- title,
234
- items
235
- }
236
- };
237
- }
238
- var key = normalizeItemKey(itemOrSection);
239
- var content = isItemElement(itemOrSection) ? itemOrSection.props.children : itemOrSection;
240
- var textValue = normalizeTextValue(itemOrSection);
241
- return {
242
- item: {
243
- key,
244
- content,
245
- textValue
246
- }
247
- };
248
- }
249
-
250
- /**
251
- * Normalize an item or section or a list of items or sections.
252
- * @param itemsOrSections An item or section or array of items or sections
253
- * @returns An array of normalized items or sections
254
- */
255
- export function normalizeItemList(itemsOrSections) {
256
- // If already normalized, just return as-is
257
- if (isNormalizedItemsWithKeysList(itemsOrSections)) {
258
- return itemsOrSections;
259
- }
260
- var itemsArray = Array.isArray(itemsOrSections) ? itemsOrSections : [itemsOrSections];
261
- return itemsArray.map(normalizeItem);
262
- }
263
-
264
164
  /**
265
165
  * Returns a TooltipOptions object or null if options is false or null.
266
166
  * @param options Tooltip options