@deephaven/components 0.72.0 → 0.72.1-alpha-list-view.17

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 (65) hide show
  1. package/dist/Button.d.ts +1 -1
  2. package/dist/Select.d.ts +1 -1
  3. package/dist/spectrum/Heading.d.ts +4 -1
  4. package/dist/spectrum/Heading.d.ts.map +1 -1
  5. package/dist/spectrum/Heading.js +5 -3
  6. package/dist/spectrum/Heading.js.map +1 -1
  7. package/dist/spectrum/ItemContent.d.ts +15 -0
  8. package/dist/spectrum/ItemContent.d.ts.map +1 -0
  9. package/dist/spectrum/{picker/PickerItemContent.js → ItemContent.js} +42 -18
  10. package/dist/spectrum/ItemContent.js.map +1 -0
  11. package/dist/spectrum/ItemTooltip.d.ts +12 -0
  12. package/dist/spectrum/ItemTooltip.d.ts.map +1 -0
  13. package/dist/spectrum/ItemTooltip.js +30 -0
  14. package/dist/spectrum/ItemTooltip.js.map +1 -0
  15. package/dist/spectrum/Text.d.ts +4 -1
  16. package/dist/spectrum/Text.d.ts.map +1 -1
  17. package/dist/spectrum/Text.js +5 -4
  18. package/dist/spectrum/Text.js.map +1 -1
  19. package/dist/spectrum/View.d.ts +4 -1
  20. package/dist/spectrum/View.d.ts.map +1 -1
  21. package/dist/spectrum/View.js +5 -3
  22. package/dist/spectrum/View.js.map +1 -1
  23. package/dist/spectrum/collections.d.ts +1 -1
  24. package/dist/spectrum/collections.d.ts.map +1 -1
  25. package/dist/spectrum/collections.js +1 -1
  26. package/dist/spectrum/collections.js.map +1 -1
  27. package/dist/spectrum/index.d.ts +3 -0
  28. package/dist/spectrum/index.d.ts.map +1 -1
  29. package/dist/spectrum/index.js +3 -0
  30. package/dist/spectrum/index.js.map +1 -1
  31. package/dist/spectrum/listView/ListView.d.ts +28 -0
  32. package/dist/spectrum/listView/ListView.d.ts.map +1 -0
  33. package/dist/spectrum/listView/ListView.js +59 -0
  34. package/dist/spectrum/listView/ListView.js.map +1 -0
  35. package/dist/spectrum/listView/index.d.ts +2 -0
  36. package/dist/spectrum/listView/index.d.ts.map +1 -0
  37. package/dist/spectrum/listView/index.js +2 -0
  38. package/dist/spectrum/listView/index.js.map +1 -0
  39. package/dist/spectrum/picker/Picker.d.ts.map +1 -1
  40. package/dist/spectrum/picker/Picker.js +9 -60
  41. package/dist/spectrum/picker/Picker.js.map +1 -1
  42. package/dist/spectrum/picker/index.d.ts +0 -1
  43. package/dist/spectrum/picker/index.d.ts.map +1 -1
  44. package/dist/spectrum/picker/index.js +0 -1
  45. package/dist/spectrum/picker/index.js.map +1 -1
  46. package/dist/spectrum/utils/index.d.ts +2 -0
  47. package/dist/spectrum/utils/index.d.ts.map +1 -1
  48. package/dist/spectrum/utils/index.js +2 -0
  49. package/dist/spectrum/utils/index.js.map +1 -1
  50. package/dist/spectrum/utils/itemUtils.d.ts +14 -10
  51. package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
  52. package/dist/spectrum/utils/itemUtils.js +11 -8
  53. package/dist/spectrum/utils/itemUtils.js.map +1 -1
  54. package/dist/spectrum/utils/useRenderNormalizedItem.d.ts +5 -0
  55. package/dist/spectrum/utils/useRenderNormalizedItem.d.ts.map +1 -0
  56. package/dist/spectrum/utils/useRenderNormalizedItem.js +34 -0
  57. package/dist/spectrum/utils/useRenderNormalizedItem.js.map +1 -0
  58. package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts +43 -0
  59. package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts.map +1 -0
  60. package/dist/spectrum/utils/useStringifiedMultiSelection.js +56 -0
  61. package/dist/spectrum/utils/useStringifiedMultiSelection.js.map +1 -0
  62. package/package.json +7 -7
  63. package/dist/spectrum/picker/PickerItemContent.d.ts +0 -11
  64. package/dist/spectrum/picker/PickerItemContent.d.ts.map +0 -1
  65. package/dist/spectrum/picker/PickerItemContent.js.map +0 -1
@@ -15,6 +15,7 @@ export * from "./status.js";
15
15
  /**
16
16
  * Custom DH components wrapping React Spectrum components.
17
17
  */
18
+ export * from "./listView/index.js";
18
19
  export * from "./picker/index.js";
19
20
  export * from "./Heading.js";
20
21
  export * from "./Text.js";
@@ -22,5 +23,7 @@ export * from "./View.js";
22
23
  /**
23
24
  * Custom DH spectrum utils
24
25
  */
26
+ export * from "./ItemContent.js";
27
+ export * from "./ItemTooltip.js";
25
28
  export * from "./utils/index.js";
26
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/spectrum/index.ts"],"sourcesContent":["/**\n * Re-exporting React Spectrum components + props.\n */\nexport * from './buttons';\nexport * from './collections';\nexport * from './content';\nexport * from './dateAndTime';\nexport * from './forms';\nexport * from './layout';\nexport * from './navigation';\nexport * from './overlays';\nexport * from './pickers';\nexport * from './shared';\nexport * from './status';\n\n/**\n * Custom DH components wrapping React Spectrum components.\n */\nexport * from './picker';\nexport * from './Heading';\nexport * from './Text';\nexport * from './View';\n\n/**\n * Custom DH spectrum utils\n */\nexport * from './utils';\n"],"mappings":"AAAA;AACA;AACA;AAFA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA;AACA;AACA;AAFA;AAAA;AAAA;AAAA;AAQA;AACA;AACA;AAFA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/spectrum/index.ts"],"sourcesContent":["/**\n * Re-exporting React Spectrum components + props.\n */\nexport * from './buttons';\nexport * from './collections';\nexport * from './content';\nexport * from './dateAndTime';\nexport * from './forms';\nexport * from './layout';\nexport * from './navigation';\nexport * from './overlays';\nexport * from './pickers';\nexport * from './shared';\nexport * from './status';\n\n/**\n * Custom DH components wrapping React Spectrum components.\n */\nexport * from './listView';\nexport * from './picker';\nexport * from './Heading';\nexport * from './Text';\nexport * from './View';\n\n/**\n * Custom DH spectrum utils\n */\nexport * from './ItemContent';\nexport * from './ItemTooltip';\nexport * from './utils';\n"],"mappings":"AAAA;AACA;AACA;AAFA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA;AACA;AACA;AAFA;AAAA;AAAA;AAAA;AAAA;AASA;AACA;AACA;AAFA;AAAA;AAAA"}
@@ -0,0 +1,28 @@
1
+ /// <reference types="react" />
2
+ import { SpectrumListViewProps } from '@adobe/react-spectrum';
3
+ import { ItemElementOrPrimitive, ItemKey, ItemSelection, NormalizedItem, TooltipOptions } from '../utils';
4
+ export type ListViewProps = {
5
+ children: ItemElementOrPrimitive | ItemElementOrPrimitive[] | NormalizedItem[];
6
+ /** Can be set to true or a TooltipOptions to enable item tooltips */
7
+ tooltip?: boolean | TooltipOptions;
8
+ selectedKeys?: 'all' | Iterable<ItemKey>;
9
+ defaultSelectedKeys?: 'all' | Iterable<ItemKey>;
10
+ disabledKeys?: Iterable<ItemKey>;
11
+ /**
12
+ * Handler that is called when the selection change.
13
+ * Note that under the hood, this is just an alias for Spectrum's
14
+ * `onSelectionChange`. We are renaming for better consistency with other
15
+ * components.
16
+ */
17
+ onChange?: (keys: ItemSelection) => void;
18
+ /** Handler that is called when the picker is scrolled. */
19
+ onScroll?: (event: Event) => void;
20
+ /**
21
+ * Handler that is called when the selection changes.
22
+ * @deprecated Use `onChange` instead
23
+ */
24
+ onSelectionChange?: (keys: ItemSelection) => void;
25
+ } & Omit<SpectrumListViewProps<NormalizedItem>, 'children' | 'items' | 'selectedKeys' | 'defaultSelectedKeys' | 'disabledKeys' | 'onSelectionChange'>;
26
+ export declare function ListView({ children, tooltip, selectedKeys, defaultSelectedKeys, disabledKeys, UNSAFE_className, onChange, onScroll, onSelectionChange, ...spectrumListViewProps }: ListViewProps): JSX.Element;
27
+ export default ListView;
28
+ //# sourceMappingURL=ListView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListView.tsx"],"names":[],"mappings":";AACA,OAAO,EAEL,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EACL,sBAAsB,EACtB,OAAO,EACP,aAAa,EACb,cAAc,EAGd,cAAc,EAGf,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EACJ,sBAAsB,GACtB,sBAAsB,EAAE,GACxB,cAAc,EAAE,CAAC;IACrB,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,YAAY,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzC,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IAEzC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAElC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;CACnD,GAAG,IAAI,CACN,qBAAqB,CAAC,cAAc,CAAC,EACnC,UAAU,GACV,OAAO,GACP,cAAc,GACd,qBAAqB,GACrB,cAAc,GACd,mBAAmB,CACtB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,OAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,QAAyB,EACzB,iBAAiB,EACjB,GAAG,qBAAqB,EACzB,EAAE,aAAa,GAAG,GAAG,CAAC,OAAO,CA2C7B;AAED,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,59 @@
1
+ var _excluded = ["children", "tooltip", "selectedKeys", "defaultSelectedKeys", "disabledKeys", "UNSAFE_className", "onChange", "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 { useMemo } from 'react';
10
+ import { ListView as SpectrumListView } from '@adobe/react-spectrum';
11
+ import { EMPTY_FUNCTION } from '@deephaven/utils';
12
+ import { extractSpectrumHTMLElement, useOnScrollRef } from '@deephaven/react-hooks';
13
+ import cl from 'classnames';
14
+ import { normalizeItemList, normalizeTooltipOptions, useRenderNormalizedItem, useStringifiedMultiSelection } from "../utils/index.js";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ export function ListView(_ref) {
17
+ var {
18
+ children,
19
+ tooltip = true,
20
+ selectedKeys,
21
+ defaultSelectedKeys,
22
+ disabledKeys,
23
+ UNSAFE_className,
24
+ onChange,
25
+ onScroll = EMPTY_FUNCTION,
26
+ onSelectionChange
27
+ } = _ref,
28
+ spectrumListViewProps = _objectWithoutProperties(_ref, _excluded);
29
+ var normalizedItems = useMemo(() => normalizeItemList(children), [children]);
30
+ var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip, 'bottom'), [tooltip]);
31
+ var renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);
32
+ var {
33
+ selectedStringKeys,
34
+ defaultSelectedStringKeys,
35
+ disabledStringKeys,
36
+ onStringSelectionChange
37
+ } = useStringifiedMultiSelection({
38
+ normalizedItems,
39
+ selectedKeys,
40
+ defaultSelectedKeys,
41
+ disabledKeys,
42
+ onChange: onChange !== null && onChange !== void 0 ? onChange : onSelectionChange
43
+ });
44
+ var scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);
45
+ return /*#__PURE__*/_jsx(SpectrumListView
46
+ // eslint-disable-next-line react/jsx-props-no-spreading
47
+ , _objectSpread(_objectSpread({}, spectrumListViewProps), {}, {
48
+ ref: scrollRef,
49
+ UNSAFE_className: cl('dh-list-view', UNSAFE_className),
50
+ items: normalizedItems,
51
+ selectedKeys: selectedStringKeys,
52
+ defaultSelectedKeys: defaultSelectedStringKeys,
53
+ disabledKeys: disabledStringKeys,
54
+ onSelectionChange: onStringSelectionChange,
55
+ children: renderNormalizedItem
56
+ }));
57
+ }
58
+ export default ListView;
59
+ //# sourceMappingURL=ListView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListView.js","names":["useMemo","ListView","SpectrumListView","EMPTY_FUNCTION","extractSpectrumHTMLElement","useOnScrollRef","cl","normalizeItemList","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedMultiSelection","jsx","_jsx","_ref","children","tooltip","selectedKeys","defaultSelectedKeys","disabledKeys","UNSAFE_className","onChange","onScroll","onSelectionChange","spectrumListViewProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderNormalizedItem","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","scrollRef","_objectSpread","ref","items"],"sources":["../../../src/spectrum/listView/ListView.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n ListView as SpectrumListView,\n SpectrumListViewProps,\n} from '@adobe/react-spectrum';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport {\n extractSpectrumHTMLElement,\n useOnScrollRef,\n} from '@deephaven/react-hooks';\nimport cl from 'classnames';\nimport {\n ItemElementOrPrimitive,\n ItemKey,\n ItemSelection,\n NormalizedItem,\n normalizeItemList,\n normalizeTooltipOptions,\n TooltipOptions,\n useRenderNormalizedItem,\n useStringifiedMultiSelection,\n} from '../utils';\n\nexport type ListViewProps = {\n children:\n | ItemElementOrPrimitive\n | ItemElementOrPrimitive[]\n | NormalizedItem[];\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\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 /** 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?: (keys: ItemSelection) => void;\n} & Omit<\n SpectrumListViewProps<NormalizedItem>,\n | 'children'\n | 'items'\n | 'selectedKeys'\n | 'defaultSelectedKeys'\n | 'disabledKeys'\n | 'onSelectionChange'\n>;\n\nexport function ListView({\n children,\n tooltip = true,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n UNSAFE_className,\n onChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n ...spectrumListViewProps\n}: ListViewProps): JSX.Element {\n const normalizedItems = useMemo(\n () => normalizeItemList(children),\n [children]\n );\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip, 'bottom'),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);\n\n const {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedMultiSelection({\n normalizedItems,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n const scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);\n\n return (\n <SpectrumListView\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumListViewProps}\n ref={scrollRef}\n UNSAFE_className={cl('dh-list-view', UNSAFE_className)}\n items={normalizedItems}\n selectedKeys={selectedStringKeys}\n defaultSelectedKeys={defaultSelectedStringKeys}\n disabledKeys={disabledStringKeys}\n onSelectionChange={onStringSelectionChange}\n >\n {renderNormalizedItem}\n </SpectrumListView>\n );\n}\n\nexport default ListView;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,QAAQ,IAAIC,gBAAgB,QAEvB,uBAAuB;AAC9B,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,0BAA0B,EAC1BC,cAAc,QACT,wBAAwB;AAC/B,OAAOC,EAAE,MAAM,YAAY;AAAC,SAM1BC,iBAAiB,EACjBC,uBAAuB,EAEvBC,uBAAuB,EACvBC,4BAA4B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AAA,EAE1Cc;EAAoB,EACL,CAAC;AAEvB;AAEA,eAAe3B,QAAQ"}
@@ -0,0 +1,2 @@
1
+ export * from './ListView';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./ListView.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/listView/index.ts"],"sourcesContent":["export * from './ListView';\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/Picker.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAEL,6BAA6B,EAG7B,cAAc,EACd,aAAa,EACb,cAAc,EACd,OAAO,EAER,MAAM,oBAAoB,CAAC;AAK5B,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,cAAc,EAAE,CAAC;IAC7D,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,iEAAiE;IACjE,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,2EAA2E;IAC3E,wBAAwB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACxD;;;;;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;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,GACP,mBAAmB,GACnB,aAAa,GACb,oBAAoB,CACvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,OAAc,EACd,kBAAkB,EAClB,WAAW,EACX,wBAAwB,EACxB,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,iBAAiB,EAEjB,gBAAgB,EAChB,GAAG,mBAAmB,EACvB,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAqG3B;AAED,eAAe,MAAM,CAAC"}
@@ -7,36 +7,14 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
7
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
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
9
  import { useCallback, useMemo } from 'react';
10
- import { Flex, Picker as SpectrumPicker } from '@adobe/react-spectrum';
11
- import { getPositionOfSelectedItem, findSpectrumPickerScrollArea, isElementOfType, usePopoverOnScrollRef } from '@deephaven/react-hooks';
10
+ import { Picker as SpectrumPicker } from '@adobe/react-spectrum';
11
+ import { getPositionOfSelectedItem, findSpectrumPickerScrollArea, usePopoverOnScrollRef } from '@deephaven/react-hooks';
12
12
  import { EMPTY_FUNCTION, PICKER_ITEM_HEIGHT, PICKER_TOP_OFFSET } from '@deephaven/utils';
13
13
  import cl from 'classnames';
14
- import { Tooltip } from "../../popper/index.js";
15
14
  import { isNormalizedSection, normalizeItemList, normalizeTooltipOptions, getItemKey } from "../utils/itemUtils.js";
16
- import { PickerItemContent } from "./PickerItemContent.js";
17
- import { Item, Section } from "../shared.js";
18
- import { Text } from "../Text.js";
15
+ import { Section } from "../shared.js";
16
+ import { useRenderNormalizedItem } from "../utils/index.js";
19
17
  import { jsx as _jsx } from "react/jsx-runtime";
20
- import { Fragment as _Fragment } from "react/jsx-runtime";
21
- import { jsxs as _jsxs } from "react/jsx-runtime";
22
- /**
23
- * Create tooltip content optionally wrapping with a Flex column for array
24
- * content. This is needed for Items containing description `Text` elements.
25
- */
26
- function createTooltipContent(content) {
27
- if (typeof content === 'boolean') {
28
- return String(content);
29
- }
30
- if (Array.isArray(content)) {
31
- return /*#__PURE__*/_jsx(Flex, {
32
- direction: "column",
33
- alignItems: "start",
34
- children: content.filter(node => isElementOfType(node, Text))
35
- });
36
- }
37
- return content;
38
- }
39
-
40
18
  /**
41
19
  * Picker component for selecting items from a list of items. Items can be
42
20
  * provided via the `items` prop or as children. Each item can be a string,
@@ -61,35 +39,7 @@ export function Picker(_ref) {
61
39
  spectrumPickerProps = _objectWithoutProperties(_ref, _excluded);
62
40
  var normalizedItems = useMemo(() => normalizeItemList(children), [children]);
63
41
  var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip), [tooltip]);
64
- var renderItem = useCallback(normalizedItem => {
65
- var _normalizedItem$item$, _normalizedItem$item, _normalizedItem$item$2, _normalizedItem$item2;
66
- var key = getItemKey(normalizedItem);
67
- var content = (_normalizedItem$item$ = (_normalizedItem$item = normalizedItem.item) === null || _normalizedItem$item === void 0 ? void 0 : _normalizedItem$item.content) !== null && _normalizedItem$item$ !== void 0 ? _normalizedItem$item$ : '';
68
- var textValue = (_normalizedItem$item$2 = (_normalizedItem$item2 = normalizedItem.item) === null || _normalizedItem$item2 === void 0 ? void 0 : _normalizedItem$item2.textValue) !== null && _normalizedItem$item$2 !== void 0 ? _normalizedItem$item$2 : '';
69
- return /*#__PURE__*/_jsx(Item
70
- // Note that setting the `key` prop explicitly on `Item` elements
71
- // causes the picker to expect `selectedKey` and `defaultSelectedKey`
72
- // to be strings. It also passes the stringified value of the key to
73
- // `onSelectionChange` handlers` regardless of the actual type of the
74
- // key. We can't really get around setting in order to support Windowed
75
- // data, so we'll need to do some manual conversion of keys to strings
76
- // in other places of this component.
77
- , {
78
- // The `textValue` prop gets used to provide the content of `<option>`
79
- // elements that back the Spectrum Picker. These are not visible in the UI,
80
- // but are used for accessibility purposes, so we set to an arbitrary
81
- // 'Empty' value so that they are not empty strings.
82
- textValue: textValue === '' ? 'Empty' : textValue,
83
- children: /*#__PURE__*/_jsxs(_Fragment, {
84
- children: [/*#__PURE__*/_jsx(PickerItemContent, {
85
- children: content
86
- }), tooltipOptions == null || content === '' ? null : /*#__PURE__*/_jsx(Tooltip, {
87
- options: tooltipOptions,
88
- children: createTooltipContent(content)
89
- })]
90
- })
91
- }, key);
92
- }, [tooltipOptions]);
42
+ var renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);
93
43
  var getInitialScrollPositionInternal = useCallback(() => getInitialScrollPosition == null ? getPositionOfSelectedItem({
94
44
  keyedItems: normalizedItems,
95
45
  // TODO: #1890 & deephaven-plugins#371 add support for sections and
@@ -119,7 +69,6 @@ export function Picker(_ref) {
119
69
  return /*#__PURE__*/_jsx(SpectrumPicker
120
70
  // eslint-disable-next-line react/jsx-props-no-spreading
121
71
  , _objectSpread(_objectSpread({}, spectrumPickerProps), {}, {
122
- // The `ref` prop type defined by React Spectrum is incorrect here
123
72
  ref: scrollRef,
124
73
  onOpenChange: onOpenChangeInternal,
125
74
  UNSAFE_className: cl('dh-picker', UNSAFE_className),
@@ -129,8 +78,8 @@ export function Picker(_ref) {
129
78
  // ensure that `selectedKey` and `defaultSelectedKey` are strings in order
130
79
  // for selection to work.
131
80
  ,
132
- selectedKey: selectedKey === null || selectedKey === void 0 ? void 0 : selectedKey.toString(),
133
- defaultSelectedKey: defaultSelectedKey === null || defaultSelectedKey === void 0 ? void 0 : defaultSelectedKey.toString()
81
+ selectedKey: selectedKey == null ? selectedKey : selectedKey.toString(),
82
+ defaultSelectedKey: defaultSelectedKey == null ? defaultSelectedKey : defaultSelectedKey.toString()
134
83
  // `onChange` is just an alias for `onSelectionChange`
135
84
  ,
136
85
  onSelectionChange: onSelectionChangeInternal,
@@ -140,10 +89,10 @@ export function Picker(_ref) {
140
89
  return /*#__PURE__*/_jsx(Section, {
141
90
  title: (_itemOrSection$item = itemOrSection.item) === null || _itemOrSection$item === void 0 ? void 0 : _itemOrSection$item.title,
142
91
  items: (_itemOrSection$item2 = itemOrSection.item) === null || _itemOrSection$item2 === void 0 ? void 0 : _itemOrSection$item2.items,
143
- children: renderItem
92
+ children: renderNormalizedItem
144
93
  }, getItemKey(itemOrSection));
145
94
  }
146
- return renderItem(itemOrSection);
95
+ return renderNormalizedItem(itemOrSection);
147
96
  }
148
97
  }));
149
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Picker.js","names":["useCallback","useMemo","Flex","Picker","SpectrumPicker","getPositionOfSelectedItem","findSpectrumPickerScrollArea","isElementOfType","usePopoverOnScrollRef","EMPTY_FUNCTION","PICKER_ITEM_HEIGHT","PICKER_TOP_OFFSET","cl","Tooltip","isNormalizedSection","normalizeItemList","normalizeTooltipOptions","getItemKey","PickerItemContent","Item","Section","Text","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","createTooltipContent","content","String","Array","isArray","direction","alignItems","children","filter","node","_ref","tooltip","defaultSelectedKey","selectedKey","getInitialScrollPosition","onChange","onOpenChange","onScroll","onSelectionChange","UNSAFE_className","spectrumPickerProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderItem","normalizedItem","_normalizedItem$item$","_normalizedItem$item","_normalizedItem$item$2","_normalizedItem$item2","key","item","textValue","options","getInitialScrollPositionInternal","keyedItems","itemHeight","topOffset","ref","scrollRef","popoverOnOpenChange","onOpenChangeInternal","isOpen","onSelectionChangeInternal","_getItemKey","_ref2","selectedItem","find","actualKey","_objectSpread","items","toString","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { Key, ReactNode, useCallback, useMemo } from 'react';\nimport { DOMRef } from '@react-types/shared';\nimport { Flex, Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport {\n getPositionOfSelectedItem,\n findSpectrumPickerScrollArea,\n isElementOfType,\n usePopoverOnScrollRef,\n} from '@deephaven/react-hooks';\nimport {\n EMPTY_FUNCTION,\n PICKER_ITEM_HEIGHT,\n PICKER_TOP_OFFSET,\n} from '@deephaven/utils';\nimport cl from 'classnames';\nimport { Tooltip } from '../../popper';\nimport {\n isNormalizedSection,\n NormalizedSpectrumPickerProps,\n normalizeItemList,\n normalizeTooltipOptions,\n NormalizedItem,\n ItemOrSection,\n TooltipOptions,\n ItemKey,\n getItemKey,\n} from '../utils/itemUtils';\nimport { PickerItemContent } from './PickerItemContent';\nimport { Item, Section } from '../shared';\nimport { Text } from '../Text';\n\nexport type PickerProps = {\n children: ItemOrSection | ItemOrSection[] | NormalizedItem[];\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n /** The currently selected key in the collection (controlled). */\n selectedKey?: ItemKey | null;\n /** The initial selected key in the collection (uncontrolled). */\n defaultSelectedKey?: ItemKey;\n /** Function to retrieve initial scroll position when opening the picker */\n getInitialScrollPosition?: () => Promise<number | null>;\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 * Create tooltip content optionally wrapping with a Flex column for array\n * content. This is needed for Items containing description `Text` elements.\n */\nfunction createTooltipContent(content: ReactNode) {\n if (typeof content === 'boolean') {\n return String(content);\n }\n\n if (Array.isArray(content)) {\n return (\n <Flex direction=\"column\" alignItems=\"start\">\n {content.filter(node => isElementOfType(node, Text))}\n </Flex>\n );\n }\n\n return content;\n}\n\n/**\n * Picker component for selecting items from a list of items. Items can be\n * provided via the `items` prop or as children. Each item can be a string,\n * number, boolean, or a Spectrum <Item> element. The remaining props are just\n * pass through props 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 getInitialScrollPosition,\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 normalizedItems = useMemo(\n () => normalizeItemList(children),\n [children]\n );\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderItem = useCallback(\n (normalizedItem: NormalizedItem) => {\n const key = getItemKey(normalizedItem);\n const content = normalizedItem.item?.content ?? '';\n const textValue = normalizedItem.item?.textValue ?? '';\n\n return (\n <Item\n // Note that setting the `key` prop explicitly on `Item` elements\n // causes the picker to expect `selectedKey` and `defaultSelectedKey`\n // to be strings. It also passes the stringified value of the key to\n // `onSelectionChange` handlers` regardless of the actual type of the\n // key. We can't really get around setting in order to support Windowed\n // data, so we'll need to do some manual conversion of keys to strings\n // in other places of this component.\n key={key as Key}\n // The `textValue` prop gets used to provide the content of `<option>`\n // elements that back the Spectrum Picker. These are not visible in the UI,\n // but are used for accessibility purposes, so we set to an arbitrary\n // 'Empty' value so that they are not empty strings.\n textValue={textValue === '' ? 'Empty' : textValue}\n >\n <>\n <PickerItemContent>{content}</PickerItemContent>\n {tooltipOptions == null || content === '' ? null : (\n <Tooltip options={tooltipOptions}>\n {createTooltipContent(content)}\n </Tooltip>\n )}\n </>\n </Item>\n );\n },\n [tooltipOptions]\n );\n\n const getInitialScrollPositionInternal = useCallback(\n () =>\n getInitialScrollPosition == null\n ? getPositionOfSelectedItem({\n keyedItems: normalizedItems,\n // TODO: #1890 & deephaven-plugins#371 add support for sections and\n // items with descriptions since they impact the height calculations\n itemHeight: PICKER_ITEM_HEIGHT,\n selectedKey,\n topOffset: PICKER_TOP_OFFSET,\n })\n : getInitialScrollPosition(),\n [getInitialScrollPosition, normalizedItems, selectedKey]\n );\n\n const { ref: scrollRef, onOpenChange: popoverOnOpenChange } =\n usePopoverOnScrollRef(\n findSpectrumPickerScrollArea,\n onScroll,\n getInitialScrollPositionInternal\n );\n\n const onOpenChangeInternal = useCallback(\n (isOpen: boolean): void => {\n // Attach scroll event handling\n popoverOnOpenChange(isOpen);\n\n onOpenChange?.(isOpen);\n },\n [onOpenChange, popoverOnOpenChange]\n );\n\n const onSelectionChangeInternal = useCallback(\n (key: ItemKey): void => {\n // The `key` arg will always be a string due to us setting the `Item` key\n // prop in `renderItem`. We need to find the matching item to determine\n // the actual key.\n const selectedItem = normalizedItems.find(\n item => String(getItemKey(item)) === key\n );\n\n const actualKey = getItemKey(selectedItem) ?? key;\n\n (onChange ?? onSelectionChange)?.(actualKey);\n },\n [normalizedItems, onChange, onSelectionChange]\n );\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumPickerProps}\n // The `ref` prop type defined by React Spectrum is incorrect here\n ref={scrollRef as unknown as DOMRef<HTMLDivElement>}\n onOpenChange={onOpenChangeInternal}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n items={normalizedItems}\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 // ensure that `selectedKey` and `defaultSelectedKey` are strings in order\n // for selection to work.\n selectedKey={selectedKey?.toString()}\n defaultSelectedKey={defaultSelectedKey?.toString()}\n // `onChange` is just an alias for `onSelectionChange`\n onSelectionChange={\n onSelectionChangeInternal as NormalizedSpectrumPickerProps['onSelectionChange']\n }\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 {renderItem}\n </Section>\n );\n }\n\n return renderItem(itemOrSection);\n }}\n </SpectrumPicker>\n );\n}\n\nexport default Picker;\n"],"mappings":";;;;;;;;AAAA,SAAyBA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAE5D,SAASC,IAAI,EAAEC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AACtE,SACEC,yBAAyB,EACzBC,4BAA4B,EAC5BC,eAAe,EACfC,qBAAqB,QAChB,wBAAwB;AAC/B,SACEC,cAAc,EACdC,kBAAkB,EAClBC,iBAAiB,QACZ,kBAAkB;AACzB,OAAOC,EAAE,MAAM,YAAY;AAAC,SACnBC,OAAO;AAAA,SAEdC,mBAAmB,EAEnBC,iBAAiB,EACjBC,uBAAuB,EAKvBC,UAAU;AAAA,SAEHC,iBAAiB;AAAA,SACjBC,IAAI,EAAEC,OAAO;AAAA,SACbC,IAAI;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AA0Cb;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAACC,OAAkB,EAAE;EAChD,IAAI,OAAOA,OAAO,KAAK,SAAS,EAAE;IAChC,OAAOC,MAAM,CAACD,OAAO,CAAC;EACxB;EAEA,IAAIE,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,EAAE;IAC1B,oBACEN,IAAA,CAACrB,IAAI;MAA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A,CAAoBE,KAAM;UACjCL,KAAK,GAAAI,oBAAA,GAAEF,aAAa,CAACrB,IAAI,cAAAuB,oBAAA,uBAAlBA,oBAAA,CAAoBJ,KAAM;UAAA5C,QAAA,EAEhCkB;QAAU,GAJNpC,UAAU,CAACgE,aAAa,CAKtB,CAAC;MAEd;MAEA,OAAO5B,UAAU,CAAC4B,aAAa,CAAC;IAClC;EAAC,EACa,CAAC;AAErB;AAEA,eAAe9E,MAAM"}
1
+ {"version":3,"file":"Picker.js","names":["useCallback","useMemo","Picker","SpectrumPicker","getPositionOfSelectedItem","findSpectrumPickerScrollArea","usePopoverOnScrollRef","EMPTY_FUNCTION","PICKER_ITEM_HEIGHT","PICKER_TOP_OFFSET","cl","isNormalizedSection","normalizeItemList","normalizeTooltipOptions","getItemKey","Section","useRenderNormalizedItem","jsx","_jsx","_ref","children","tooltip","defaultSelectedKey","selectedKey","getInitialScrollPosition","onChange","onOpenChange","onScroll","onSelectionChange","UNSAFE_className","spectrumPickerProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderNormalizedItem","getInitialScrollPositionInternal","keyedItems","itemHeight","topOffset","ref","scrollRef","popoverOnOpenChange","onOpenChangeInternal","isOpen","onSelectionChangeInternal","key","_getItemKey","_ref2","selectedItem","find","item","String","actualKey","_objectSpread","items","toString","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { DOMRef } from '@react-types/shared';\nimport { Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport {\n getPositionOfSelectedItem,\n findSpectrumPickerScrollArea,\n usePopoverOnScrollRef,\n} from '@deephaven/react-hooks';\nimport {\n EMPTY_FUNCTION,\n PICKER_ITEM_HEIGHT,\n PICKER_TOP_OFFSET,\n} from '@deephaven/utils';\nimport cl from 'classnames';\nimport {\n isNormalizedSection,\n NormalizedSpectrumPickerProps,\n normalizeItemList,\n normalizeTooltipOptions,\n NormalizedItem,\n ItemOrSection,\n TooltipOptions,\n ItemKey,\n getItemKey,\n} from '../utils/itemUtils';\nimport { Section } from '../shared';\nimport { useRenderNormalizedItem } from '../utils';\n\nexport type PickerProps = {\n children: ItemOrSection | ItemOrSection[] | NormalizedItem[];\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n /** The currently selected key in the collection (controlled). */\n selectedKey?: ItemKey | null;\n /** The initial selected key in the collection (uncontrolled). */\n defaultSelectedKey?: ItemKey;\n /** Function to retrieve initial scroll position when opening the picker */\n getInitialScrollPosition?: () => Promise<number | null>;\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 `items` prop or as children. Each item can be a string,\n * number, boolean, or a Spectrum <Item> element. The remaining props are just\n * pass through props 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 getInitialScrollPosition,\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 normalizedItems = useMemo(\n () => normalizeItemList(children),\n [children]\n );\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);\n\n const getInitialScrollPositionInternal = useCallback(\n () =>\n getInitialScrollPosition == null\n ? getPositionOfSelectedItem({\n keyedItems: normalizedItems,\n // TODO: #1890 & deephaven-plugins#371 add support for sections and\n // items with descriptions since they impact the height calculations\n itemHeight: PICKER_ITEM_HEIGHT,\n selectedKey,\n topOffset: PICKER_TOP_OFFSET,\n })\n : getInitialScrollPosition(),\n [getInitialScrollPosition, normalizedItems, selectedKey]\n );\n\n const { ref: scrollRef, onOpenChange: popoverOnOpenChange } =\n usePopoverOnScrollRef(\n findSpectrumPickerScrollArea,\n onScroll,\n getInitialScrollPositionInternal\n );\n\n const onOpenChangeInternal = useCallback(\n (isOpen: boolean): void => {\n // Attach scroll event handling\n popoverOnOpenChange(isOpen);\n\n onOpenChange?.(isOpen);\n },\n [onOpenChange, popoverOnOpenChange]\n );\n\n const onSelectionChangeInternal = useCallback(\n (key: ItemKey): void => {\n // The `key` arg will always be a string due to us setting the `Item` key\n // prop in `renderItem`. We need to find the matching item to determine\n // the actual key.\n const selectedItem = normalizedItems.find(\n item => String(getItemKey(item)) === key\n );\n\n const actualKey = getItemKey(selectedItem) ?? key;\n\n (onChange ?? onSelectionChange)?.(actualKey);\n },\n [normalizedItems, onChange, onSelectionChange]\n );\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumPickerProps}\n ref={scrollRef as unknown as DOMRef<HTMLDivElement>}\n onOpenChange={onOpenChangeInternal}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n items={normalizedItems}\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 // ensure that `selectedKey` and `defaultSelectedKey` are strings in order\n // for selection to work.\n selectedKey={selectedKey == null ? selectedKey : selectedKey.toString()}\n defaultSelectedKey={\n defaultSelectedKey == null\n ? defaultSelectedKey\n : defaultSelectedKey.toString()\n }\n // `onChange` is just an alias for `onSelectionChange`\n onSelectionChange={\n onSelectionChangeInternal as NormalizedSpectrumPickerProps['onSelectionChange']\n }\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 Picker;\n"],"mappings":";;;;;;;;AAAA,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAE5C,SAASC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AAChE,SACEC,yBAAyB,EACzBC,4BAA4B,EAC5BC,qBAAqB,QAChB,wBAAwB;AAC/B,SACEC,cAAc,EACdC,kBAAkB,EAClBC,iBAAiB,QACZ,kBAAkB;AACzB,OAAOC,EAAE,MAAM,YAAY;AAAC,SAE1BC,mBAAmB,EAEnBC,iBAAiB,EACjBC,uBAAuB,EAKvBC,UAAU;AAAA,SAEHC,OAAO;AAAA,SACPC,uBAAuB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AA0ChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAShB,MAAMA,CAAAiB,IAAA,EAaO;EAAA,IAbN;MACrBC,QAAQ;MACRC,OAAO,GAAG,IAAI;MACdC,kBAAkB;MAClBC,WAAW;MACXC,wBAAwB;MACxBC,QAAQ;MACRC,YAAY;MACZC,QAAQ,GAAGpB,cAAc;MACzBqB,iBAAiB;MACjB;MACAC;IAEW,CAAC,GAAAV,IAAA;IADTW,mBAAmB,GAAAC,wBAAA,CAAAZ,IAAA,EAAAa,SAAA;EAEtB,IAAMC,eAAe,GAAGhC,OAAO,CAC7B,MAAMW,iBAAiB,CAACQ,QAAQ,CAAC,EACjC,CAACA,QAAQ,CACX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
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -1,3 +1,2 @@
1
1
  export * from "./Picker.js";
2
- export * from "./PickerItemContent.js";
3
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/picker/index.ts"],"sourcesContent":["export * from './Picker';\nexport * from './PickerItemContent';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/picker/index.ts"],"sourcesContent":["export * from './Picker';\n"],"mappings":""}
@@ -1,3 +1,5 @@
1
1
  export * from './itemUtils';
2
2
  export * from './themeUtils';
3
+ export * from './useRenderNormalizedItem';
4
+ export * from './useStringifiedMultiSelection';
3
5
  //# 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,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC"}
@@ -1,3 +1,5 @@
1
1
  export * from "./itemUtils.js";
2
2
  export * from "./themeUtils.js";
3
+ export * from "./useRenderNormalizedItem.js";
4
+ export * from "./useStringifiedMultiSelection.js";
3
5
  //# 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 './themeUtils';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/utils/index.ts"],"sourcesContent":["export * from './itemUtils';\nexport * from './themeUtils';\nexport * from './useRenderNormalizedItem';\nexport * from './useStringifiedMultiSelection';\n"],"mappings":""}
@@ -23,6 +23,7 @@ export type ItemOrSection = ItemElementOrPrimitive | SectionElement;
23
23
  * don't reflect it.
24
24
  */
25
25
  export type ItemKey = Key | boolean;
26
+ export type ItemSelection = 'all' | Set<ItemKey>;
26
27
  /**
27
28
  * Augment the Spectrum selection change handler type to include boolean keys.
28
29
  * Spectrum components already supports this, but the built in types don't
@@ -49,6 +50,7 @@ export interface NormalizedSectionData {
49
50
  */
50
51
  export type NormalizedItem = KeyedItem<NormalizedItemData, ItemKey | undefined>;
51
52
  export type NormalizedSection = KeyedItem<NormalizedSectionData, Key | undefined>;
53
+ export type NormalizedItemOrSection<TItemOrSection extends ItemOrSection> = TItemOrSection extends SectionElement ? NormalizedSection : NormalizedItem;
52
54
  export type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedItem>;
53
55
  export type TooltipOptions = {
54
56
  placement: PopperOptions['placement'];
@@ -76,12 +78,12 @@ export declare function isSectionElement<T>(node: ReactNode): node is ReactEleme
76
78
  */
77
79
  export declare function isItemElement<T>(node: ReactNode): node is ReactElement<ItemProps<T>>;
78
80
  /**
79
- * Determine if a node is an array containing normalized items with keys.
80
- * Note that this only checks the first node in the array.
81
+ * Determine if a node is an array containing normalized items or sections with
82
+ * keys. Note that this only checks the first node in the array.
81
83
  * @param node The node to check
82
- * @returns True if the node is a normalized item with keys array
84
+ * @returns True if the node is a normalized item or section with keys array
83
85
  */
84
- export declare function isNormalizedItemsWithKeysList(node: ItemOrSection | ItemOrSection[] | (NormalizedItem | NormalizedSection)[]): node is (NormalizedItem | NormalizedSection)[];
86
+ export declare function isNormalizedItemsWithKeysList<TItemOrSection extends ItemOrSection>(node: TItemOrSection | TItemOrSection[] | NormalizedItemOrSection<TItemOrSection>[]): node is NormalizedItemOrSection<TItemOrSection>[];
85
87
  /**
86
88
  * Determine if an object is a normalized section.
87
89
  * @param maybeNormalizedSection The object to check
@@ -96,16 +98,18 @@ export declare function isNormalizedSection(maybeNormalizedSection: NormalizedIt
96
98
  */
97
99
  export declare function isItemOrSection(node: ReactNode): node is ItemOrSection;
98
100
  /**
99
- * Get normalized items from an item or array of items.
100
- * @param itemsOrSections An item or array of items
101
- * @returns An array of normalized items
101
+ * Normalize an item or section or a list of items or sections.
102
+ * @param itemsOrSections An item or section or array of items or sections
103
+ * @returns An array of normalized items or sections
102
104
  */
103
- export declare function normalizeItemList(itemsOrSections: ItemOrSection | ItemOrSection[] | NormalizedItem[]): (NormalizedItem | NormalizedSection)[];
105
+ export declare function normalizeItemList<TItemOrSection extends ItemOrSection>(itemsOrSections: TItemOrSection | TItemOrSection[] | NormalizedItem[]): NormalizedItemOrSection<TItemOrSection>[];
104
106
  /**
105
107
  * Returns a TooltipOptions object or null if options is false or null.
106
- * @param options
108
+ * @param options Tooltip options
109
+ * @param placement Default placement for the tooltip if `options` is set
110
+ * explicitly to `true`
107
111
  * @returns TooltipOptions or null
108
112
  */
109
- export declare function normalizeTooltipOptions(options?: boolean | TooltipOptions | null): TooltipOptions | null;
113
+ export declare function normalizeTooltipOptions(options?: boolean | TooltipOptions | null, placement?: TooltipOptions['placement']): TooltipOptions | null;
110
114
  export {};
111
115
  //# sourceMappingURL=itemUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"itemUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/itemUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,SAAS,E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GAAG,IAAI,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,IAAI,EAAE,SAAS,GACd,IAAI,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAEvC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,IAAI,EAAE,SAAS,GACd,IAAI,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAEpC;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;AAiGD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,SAAS,aAAa,EACpE,eAAe,EAAE,cAAc,GAAG,cAAc,EAAE,GAAG,cAAc,EAAE,GACpE,uBAAuB,CAAC,cAAc,CAAC,EAAE,CAW3C;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"}
@@ -64,10 +64,10 @@ export function isItemElement(node) {
64
64
  }
65
65
 
66
66
  /**
67
- * Determine if a node is an array containing normalized items with keys.
68
- * Note that this only checks the first node in the array.
67
+ * Determine if a node is an array containing normalized items or sections with
68
+ * keys. Note that this only checks the first node in the array.
69
69
  * @param node The node to check
70
- * @returns True if the node is a normalized item with keys array
70
+ * @returns True if the node is a normalized item or section with keys array
71
71
  */
72
72
  export function isNormalizedItemsWithKeysList(node) {
73
73
  if (!Array.isArray(node)) {
@@ -182,9 +182,9 @@ function normalizeItem(itemOrSection) {
182
182
  }
183
183
 
184
184
  /**
185
- * Get normalized items from an item or array of items.
186
- * @param itemsOrSections An item or array of items
187
- * @returns An array of normalized items
185
+ * Normalize an item or section or a list of items or sections.
186
+ * @param itemsOrSections An item or section or array of items or sections
187
+ * @returns An array of normalized items or sections
188
188
  */
189
189
  export function normalizeItemList(itemsOrSections) {
190
190
  // If already normalized, just return as-is
@@ -197,16 +197,19 @@ export function normalizeItemList(itemsOrSections) {
197
197
 
198
198
  /**
199
199
  * Returns a TooltipOptions object or null if options is false or null.
200
- * @param options
200
+ * @param options Tooltip options
201
+ * @param placement Default placement for the tooltip if `options` is set
202
+ * explicitly to `true`
201
203
  * @returns TooltipOptions or null
202
204
  */
203
205
  export function normalizeTooltipOptions(options) {
206
+ var placement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'right';
204
207
  if (options == null || options === false) {
205
208
  return null;
206
209
  }
207
210
  if (options === true) {
208
211
  return {
209
- placement: 'right'
212
+ placement
210
213
  };
211
214
  }
212
215
  return options;
@@ -1 +1 @@
1
- {"version":3,"file":"itemUtils.js","names":["isValidElement","Log","Item","Section","log","module","INVALID_ITEM_ERROR_MESSAGE","getItemKey","item","_item$item$key","_item$item","key","isSectionElement","node","type","isItemElement","isNormalizedItemsWithKeysList","Array","isArray","length","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeItemKey","itemOrSection","_itemOrSection$props$","props","title","undefined","textValue","children","normalizeTextValue","String","normalizeItem","debug","Error","items","normalizeItemList","filter","childItem","content","itemsOrSections","itemsArray","map","normalizeTooltipOptions","options","placement"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { isValidElement, Key, ReactElement, ReactNode } from 'react';\nimport { SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type { ItemRenderer } from '@react-types/shared';\nimport Log from '@deephaven/log';\nimport { KeyedItem } from '@deephaven/utils';\nimport { Item, ItemProps, Section, SectionProps } from '../shared';\nimport { PopperOptions } from '../../popper';\n\nconst log = Log.module('itemUtils');\n\nexport const INVALID_ITEM_ERROR_MESSAGE =\n 'Items must be strings, numbers, booleans, <Item> or <Section> elements:';\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\ntype ItemElement = ReactElement<ItemProps<unknown>>;\nexport type SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;\n\nexport type ItemElementOrPrimitive = number | string | boolean | ItemElement;\nexport type ItemOrSection = ItemElementOrPrimitive | SectionElement;\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\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 NormalizedItemData {\n key?: ItemKey;\n content: ReactNode;\n textValue?: string;\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 | undefined>;\n\nexport type NormalizedSection = KeyedItem<\n NormalizedSectionData,\n Key | undefined\n>;\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 | undefined\n : TItem extends NormalizedSection\n ? Key | undefined\n : undefined,\n>(item: TItem | null | undefined): TKey {\n return (item?.item?.key ?? item?.key) as TKey;\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 ReactElement<SectionProps<T>> {\n return isValidElement<SectionProps<T>>(node) && node.type === 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>(\n node: ReactNode\n): node is ReactElement<ItemProps<T>> {\n return isValidElement<ItemProps<T>>(node) && node.type === Item;\n}\n\n/**\n * Determine if a node is an array containing normalized items with keys.\n * 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 with keys array\n */\nexport function isNormalizedItemsWithKeysList(\n node: ItemOrSection | ItemOrSection[] | (NormalizedItem | NormalizedSection)[]\n): node is (NormalizedItem | NormalizedSection)[] {\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 * Determine the `key` of an item or section.\n * @param itemOrSection The item or section\n * @returns A `ItemKey` for the item or undefined if a key can't be determined\n */\nfunction normalizeItemKey(item: ItemElementOrPrimitive): ItemKey | undefined;\nfunction normalizeItemKey(section: SectionElement): Key | undefined;\nfunction normalizeItemKey(\n itemOrSection: ItemElementOrPrimitive | SectionElement\n): Key | ItemKey | undefined {\n // string, number, or boolean\n if (typeof itemOrSection !== 'object') {\n return itemOrSection;\n }\n\n // If `key` prop is explicitly set\n if (itemOrSection.key != null) {\n return itemOrSection.key;\n }\n\n // Section element\n if (isSectionElement(itemOrSection)) {\n return typeof itemOrSection.props.title === 'string'\n ? itemOrSection.props.title\n : undefined;\n }\n\n // Item element\n return (\n itemOrSection.props.textValue ??\n (typeof itemOrSection.props.children === 'string'\n ? itemOrSection.props.children\n : undefined)\n );\n}\n\n/**\n * Get a normalized `textValue` for an item ensuring it is a string.\n * @param item The item\n * @returns A string `textValue` for the item\n */\nfunction normalizeTextValue(item: ItemElementOrPrimitive): string | undefined {\n if (typeof item !== 'object') {\n return String(item);\n }\n\n if (item.props.textValue != null) {\n return item.props.textValue;\n }\n\n if (typeof item.props.children === 'string') {\n return item.props.children;\n }\n\n return undefined;\n}\n\n/**\n * Normalize an item or section to an object form.\n * @param itemOrSection item to normalize\n * @returns NormalizedItem or NormalizedSection object\n */\nfunction normalizeItem(\n itemOrSection: ItemOrSection\n): NormalizedItem | NormalizedSection {\n if (!isItemOrSection(itemOrSection)) {\n log.debug(INVALID_ITEM_ERROR_MESSAGE, itemOrSection);\n throw new Error(INVALID_ITEM_ERROR_MESSAGE);\n }\n\n if (isSectionElement(itemOrSection)) {\n const key = normalizeItemKey(itemOrSection);\n const { title } = itemOrSection.props;\n\n const items = normalizeItemList(itemOrSection.props.children).filter(\n // We don't support nested section elements\n childItem => !isSectionElement(childItem)\n ) as NormalizedItem[];\n\n return {\n item: { key, title, items },\n };\n }\n\n const key = normalizeItemKey(itemOrSection);\n const content = isItemElement(itemOrSection)\n ? itemOrSection.props.children\n : itemOrSection;\n const textValue = normalizeTextValue(itemOrSection);\n\n return {\n item: { key, content, textValue },\n };\n}\n\n/**\n * Get normalized items from an item or array of items.\n * @param itemsOrSections An item or array of items\n * @returns An array of normalized items\n */\nexport function normalizeItemList(\n itemsOrSections: ItemOrSection | ItemOrSection[] | NormalizedItem[]\n): (NormalizedItem | NormalizedSection)[] {\n // If already normalized, just return as-is\n if (isNormalizedItemsWithKeysList(itemsOrSections)) {\n return itemsOrSections;\n }\n\n const itemsArray = Array.isArray(itemsOrSections)\n ? itemsOrSections\n : [itemsOrSections];\n\n return itemsArray.map(normalizeItem);\n}\n\n/**\n * Returns a TooltipOptions object or null if options is false or null.\n * @param options\n * @returns TooltipOptions or null\n */\nexport function normalizeTooltipOptions(\n options?: boolean | TooltipOptions | null\n): TooltipOptions | null {\n if (options == null || options === false) {\n return null;\n }\n\n if (options === true) {\n return { placement: 'right' };\n }\n\n return options;\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAsC,OAAO;AAGpE,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SAExBC,IAAI,EAAaC,OAAO;AAGjC,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,WAAW,CAAC;AAEnC,OAAO,IAAMC,0BAA0B,GACrC,yEAAyE;;AAE3E;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAOxBC,IAA8B,EAAQ;EAAA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;AACA,OAAO,SAASW,uBAAuBA,CACrCC,OAAyC,EAClB;EACvB,IAAIA,OAAO,IAAI,IAAI,IAAIA,OAAO,KAAK,KAAK,EAAE;IACxC,OAAO,IAAI;EACb;EAEA,IAAIA,OAAO,KAAK,IAAI,EAAE;IACpB,OAAO;MAAEC,SAAS,EAAE;IAAQ,CAAC;EAC/B;EAEA,OAAOD,OAAO;AAChB"}
1
+ {"version":3,"file":"itemUtils.js","names":["isValidElement","Log","Item","Section","log","module","INVALID_ITEM_ERROR_MESSAGE","getItemKey","item","_item$item$key","_item$item","key","isSectionElement","node","type","isItemElement","isNormalizedItemsWithKeysList","Array","isArray","length","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeItemKey","itemOrSection","_itemOrSection$props$","props","title","undefined","textValue","children","normalizeTextValue","String","normalizeItem","debug","Error","items","normalizeItemList","filter","childItem","content","itemsOrSections","itemsArray","map","normalizeTooltipOptions","options","placement","arguments"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { isValidElement, Key, ReactElement, ReactNode } from 'react';\nimport { SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type { ItemRenderer } from '@react-types/shared';\nimport Log from '@deephaven/log';\nimport { KeyedItem } from '@deephaven/utils';\nimport { Item, ItemProps, Section, SectionProps } from '../shared';\nimport { PopperOptions } from '../../popper';\n\nconst log = Log.module('itemUtils');\n\nexport const INVALID_ITEM_ERROR_MESSAGE =\n 'Items must be strings, numbers, booleans, <Item> or <Section> elements:';\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\ntype ItemElement = ReactElement<ItemProps<unknown>>;\nexport type SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;\n\nexport type ItemElementOrPrimitive = number | string | boolean | ItemElement;\nexport type ItemOrSection = ItemElementOrPrimitive | SectionElement;\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 = 'all' | Set<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 NormalizedItemData {\n key?: ItemKey;\n content: ReactNode;\n textValue?: string;\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 | undefined>;\n\nexport type NormalizedSection = KeyedItem<\n NormalizedSectionData,\n Key | undefined\n>;\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 | undefined\n : TItem extends NormalizedSection\n ? Key | undefined\n : undefined,\n>(item: TItem | null | undefined): TKey {\n return (item?.item?.key ?? item?.key) as TKey;\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 ReactElement<SectionProps<T>> {\n return isValidElement<SectionProps<T>>(node) && node.type === 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>(\n node: ReactNode\n): node is ReactElement<ItemProps<T>> {\n return isValidElement<ItemProps<T>>(node) && node.type === Item;\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 * Determine the `key` of an item or section.\n * @param itemOrSection The item or section\n * @returns A `ItemKey` for the item or undefined if a key can't be determined\n */\nfunction normalizeItemKey(item: ItemElementOrPrimitive): ItemKey | undefined;\nfunction normalizeItemKey(section: SectionElement): Key | undefined;\nfunction normalizeItemKey(\n itemOrSection: ItemElementOrPrimitive | SectionElement\n): Key | ItemKey | undefined {\n // string, number, or boolean\n if (typeof itemOrSection !== 'object') {\n return itemOrSection;\n }\n\n // If `key` prop is explicitly set\n if (itemOrSection.key != null) {\n return itemOrSection.key;\n }\n\n // Section element\n if (isSectionElement(itemOrSection)) {\n return typeof itemOrSection.props.title === 'string'\n ? itemOrSection.props.title\n : undefined;\n }\n\n // Item element\n return (\n itemOrSection.props.textValue ??\n (typeof itemOrSection.props.children === 'string'\n ? itemOrSection.props.children\n : undefined)\n );\n}\n\n/**\n * Get a normalized `textValue` for an item ensuring it is a string.\n * @param item The item\n * @returns A string `textValue` for the item\n */\nfunction normalizeTextValue(item: ItemElementOrPrimitive): string | undefined {\n if (typeof item !== 'object') {\n return String(item);\n }\n\n if (item.props.textValue != null) {\n return item.props.textValue;\n }\n\n if (typeof item.props.children === 'string') {\n return item.props.children;\n }\n\n return undefined;\n}\n\n/**\n * Normalize an item or section to an object form.\n * @param itemOrSection item to normalize\n * @returns NormalizedItem or NormalizedSection object\n */\nfunction normalizeItem<TItemOrSection extends ItemOrSection>(\n itemOrSection: TItemOrSection\n): NormalizedItemOrSection<TItemOrSection> {\n if (!isItemOrSection(itemOrSection)) {\n log.debug(INVALID_ITEM_ERROR_MESSAGE, itemOrSection);\n throw new Error(INVALID_ITEM_ERROR_MESSAGE);\n }\n\n if (isSectionElement(itemOrSection)) {\n const key = normalizeItemKey(itemOrSection);\n const { title } = itemOrSection.props;\n\n const items = normalizeItemList(itemOrSection.props.children).filter(\n // We don't support nested section elements\n childItem => !isSectionElement(childItem)\n ) as NormalizedItem[];\n\n return {\n item: { key, title, items },\n } as NormalizedItemOrSection<TItemOrSection>;\n }\n\n const key = normalizeItemKey(itemOrSection);\n const content = isItemElement(itemOrSection)\n ? itemOrSection.props.children\n : itemOrSection;\n const textValue = normalizeTextValue(itemOrSection);\n\n return {\n item: { key, content, textValue },\n } as NormalizedItemOrSection<TItemOrSection>;\n}\n\n/**\n * Normalize an item or section or a list of items or sections.\n * @param itemsOrSections An item or section or array of items or sections\n * @returns An array of normalized items or sections\n */\nexport function normalizeItemList<TItemOrSection extends ItemOrSection>(\n itemsOrSections: TItemOrSection | TItemOrSection[] | NormalizedItem[]\n): NormalizedItemOrSection<TItemOrSection>[] {\n // If already normalized, just return as-is\n if (isNormalizedItemsWithKeysList(itemsOrSections)) {\n return itemsOrSections as NormalizedItemOrSection<TItemOrSection>[];\n }\n\n const itemsArray: TItemOrSection[] = Array.isArray(itemsOrSections)\n ? itemsOrSections\n : [itemsOrSections];\n\n return itemsArray.map(normalizeItem);\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"],"mappings":"AAAA,SAASA,cAAc,QAAsC,OAAO;AAGpE,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SAExBC,IAAI,EAAaC,OAAO;AAGjC,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,WAAW,CAAC;AAEnC,OAAO,IAAMC,0BAA0B,GACrC,yEAAyE;;AAE3E;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;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,UAA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B,SAAA,MAAG,OAAO;EAEhD,IAAIF,OAAO,IAAI,IAAI,IAAIA,OAAO,KAAK,KAAK,EAAE;IACxC,OAAO,IAAI;EACb;EAEA,IAAIA,OAAO,KAAK,IAAI,EAAE;IACpB,OAAO;MAAEC;IAAU,CAAC;EACtB;EAEA,OAAOD,OAAO;AAChB"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { NormalizedItem, TooltipOptions } from './itemUtils';
3
+ export declare function useRenderNormalizedItem(tooltipOptions: TooltipOptions | null): (normalizedItem: NormalizedItem) => JSX.Element;
4
+ export default useRenderNormalizedItem;
5
+ //# sourceMappingURL=useRenderNormalizedItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRenderNormalizedItem.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAc,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEzE,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,cAAc,GAAG,IAAI,GACpC,CAAC,cAAc,EAAE,cAAc,KAAK,GAAG,CAAC,OAAO,CA6BjD;AAED,eAAe,uBAAuB,CAAC"}