@deephaven/components 0.74.1-beta.5 → 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 (62) hide show
  1. package/dist/Button.d.ts +1 -1
  2. package/dist/ErrorView.css +77 -0
  3. package/dist/ErrorView.css.map +1 -0
  4. package/dist/ErrorView.d.ts +16 -0
  5. package/dist/ErrorView.d.ts.map +1 -0
  6. package/dist/ErrorView.js +73 -0
  7. package/dist/ErrorView.js.map +1 -0
  8. package/dist/Select.d.ts +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/spectrum/listView/ListView.d.ts +3 -2
  14. package/dist/spectrum/listView/ListView.d.ts.map +1 -1
  15. package/dist/spectrum/listView/ListView.js +10 -63
  16. package/dist/spectrum/listView/ListView.js.map +1 -1
  17. package/dist/spectrum/listView/ListViewNormalized.d.ts +22 -0
  18. package/dist/spectrum/listView/ListViewNormalized.d.ts.map +1 -0
  19. package/dist/spectrum/listView/ListViewNormalized.js +80 -0
  20. package/dist/spectrum/listView/ListViewNormalized.js.map +1 -0
  21. package/dist/spectrum/listView/ListViewWrapper.css +39 -0
  22. package/dist/spectrum/listView/ListViewWrapper.css.map +1 -0
  23. package/dist/spectrum/listView/ListViewWrapper.d.ts +21 -0
  24. package/dist/spectrum/listView/ListViewWrapper.d.ts.map +1 -0
  25. package/dist/spectrum/listView/ListViewWrapper.js +71 -0
  26. package/dist/spectrum/listView/ListViewWrapper.js.map +1 -0
  27. package/dist/spectrum/listView/index.d.ts +2 -0
  28. package/dist/spectrum/listView/index.d.ts.map +1 -1
  29. package/dist/spectrum/listView/index.js +2 -0
  30. package/dist/spectrum/listView/index.js.map +1 -1
  31. package/dist/spectrum/picker/Picker.d.ts.map +1 -1
  32. package/dist/spectrum/picker/Picker.js +2 -2
  33. package/dist/spectrum/picker/Picker.js.map +1 -1
  34. package/dist/spectrum/picker/PickerNormalized.d.ts +2 -1
  35. package/dist/spectrum/picker/PickerNormalized.d.ts.map +1 -1
  36. package/dist/spectrum/picker/PickerNormalized.js +31 -15
  37. package/dist/spectrum/picker/PickerNormalized.js.map +1 -1
  38. package/dist/spectrum/shared.d.ts +13 -9
  39. package/dist/spectrum/shared.d.ts.map +1 -1
  40. package/dist/spectrum/shared.js +16 -1
  41. package/dist/spectrum/shared.js.map +1 -1
  42. package/dist/spectrum/utils/index.d.ts +1 -0
  43. package/dist/spectrum/utils/index.d.ts.map +1 -1
  44. package/dist/spectrum/utils/index.js +1 -0
  45. package/dist/spectrum/utils/index.js.map +1 -1
  46. package/dist/spectrum/utils/itemUtils.d.ts +9 -14
  47. package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
  48. package/dist/spectrum/utils/itemUtils.js +8 -108
  49. package/dist/spectrum/utils/itemUtils.js.map +1 -1
  50. package/dist/spectrum/utils/itemWrapperUtils.d.ts +19 -3
  51. package/dist/spectrum/utils/itemWrapperUtils.d.ts.map +1 -1
  52. package/dist/spectrum/utils/itemWrapperUtils.js +65 -19
  53. package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -1
  54. package/dist/spectrum/utils/propsUtils.d.ts +14 -0
  55. package/dist/spectrum/utils/propsUtils.d.ts.map +1 -0
  56. package/dist/spectrum/utils/propsUtils.js +93 -0
  57. package/dist/spectrum/utils/propsUtils.js.map +1 -0
  58. package/dist/spectrum/utils/useRenderNormalizedItem.d.ts +11 -2
  59. package/dist/spectrum/utils/useRenderNormalizedItem.d.ts.map +1 -1
  60. package/dist/spectrum/utils/useRenderNormalizedItem.js +21 -8
  61. package/dist/spectrum/utils/useRenderNormalizedItem.js.map +1 -1
  62. package/package.json +7 -7
@@ -7,16 +7,11 @@ 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 { useMemo } from 'react';
10
- import cl from 'classnames';
11
- import { ListView as SpectrumListView } from '@adobe/react-spectrum';
12
10
  import { EMPTY_FUNCTION } from '@deephaven/utils';
13
- import { extractSpectrumHTMLElement, useContentRect, useOnScrollRef } from '@deephaven/react-hooks';
14
- import { Flex } from "../layout.js";
15
- import { normalizeItemList, normalizeTooltipOptions, useRenderNormalizedItem, useStringifiedMultiSelection } from "../utils/index.js";
16
- import { Fragment as _Fragment } from "react/jsx-runtime";
11
+ import { normalizeTooltipOptions, wrapItemChildren } from "../utils/index.js";
12
+ import { ListViewWrapper } from "./ListViewWrapper.js";
17
13
  import { jsx as _jsx } from "react/jsx-runtime";
18
14
  export function ListView(_ref) {
19
- var _spectrumListViewProp;
20
15
  var {
21
16
  children,
22
17
  tooltip = true,
@@ -29,63 +24,15 @@ export function ListView(_ref) {
29
24
  onSelectionChange
30
25
  } = _ref,
31
26
  spectrumListViewProps = _objectWithoutProperties(_ref, _excluded);
32
- var normalizedItems = useMemo(() => normalizeItemList(children), [children]);
33
27
  var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip, 'bottom'), [tooltip]);
34
- var renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);
35
- var {
36
- selectedStringKeys,
37
- defaultSelectedStringKeys,
38
- disabledStringKeys,
39
- onStringSelectionChange
40
- } = useStringifiedMultiSelection({
41
- normalizedItems,
42
- selectedKeys,
43
- defaultSelectedKeys,
44
- disabledKeys,
45
- onChange: onChange !== null && onChange !== void 0 ? onChange : onSelectionChange
46
- });
47
- var scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);
48
-
49
- // Spectrum ListView crashes when it has zero height. Track the contentRect
50
- // of the parent container and only render the ListView when it has a non-zero
51
- // height. See https://github.com/adobe/react-spectrum/issues/6213
52
- var {
53
- ref: contentRectRef,
54
- contentRect
55
- } = useContentRect(extractSpectrumHTMLElement);
56
- return /*#__PURE__*/_jsx(Flex, {
57
- ref: contentRectRef,
58
- direction: "column",
59
- flex: (_spectrumListViewProp = spectrumListViewProps.flex) !== null && _spectrumListViewProp !== void 0 ? _spectrumListViewProp : 1,
60
- minHeight: 0,
61
- UNSAFE_className: cl('dh-list-view', UNSAFE_className),
62
- children: contentRect.height === 0 ?
63
- /*#__PURE__*/
64
- // Use &nbsp; to ensure content has a non-zero height. This ensures the
65
- // container will also have a non-zero height unless its height is
66
- // explicitly set to zero. Example use case:
67
- // 1. Tab containing ListView is visible. Container height is non-zero.
68
- // ListView is rendered.
69
- // 2. Tab is hidden. Container height is explicitly constrained to zero.
70
- // ListView is not rendered.
71
- // 3. Tab is shown again. Height constraint is removed. Resize observer
72
- // fires and shows non-zero height due to the &nbsp; (without this,
73
- // the height would remain zero forever since ListView hasn't rendered yet)
74
- // 4. ListView is rendered again.
75
- _jsx(_Fragment, {
76
- children: "\xA0"
77
- }) : /*#__PURE__*/_jsx(SpectrumListView
78
- // eslint-disable-next-line react/jsx-props-no-spreading
79
- , _objectSpread(_objectSpread({}, spectrumListViewProps), {}, {
80
- ref: scrollRef,
81
- items: normalizedItems,
82
- selectedKeys: selectedStringKeys,
83
- defaultSelectedKeys: defaultSelectedStringKeys,
84
- disabledKeys: disabledStringKeys,
85
- onSelectionChange: onStringSelectionChange,
86
- children: renderNormalizedItem
87
- }))
88
- });
28
+ var wrappedItems = useMemo(() => wrapItemChildren(children, tooltipOptions), [children, tooltipOptions]);
29
+ return /*#__PURE__*/_jsx(ListViewWrapper
30
+ // eslint-disable-next-line react/jsx-props-no-spreading
31
+ , _objectSpread(_objectSpread({}, spectrumListViewProps), {}, {
32
+ UNSAFE_className: "dh-list-view",
33
+ onScroll: onScroll,
34
+ children: wrappedItems
35
+ }));
89
36
  }
90
37
  export default ListView;
91
38
  //# sourceMappingURL=ListView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListView.js","names":["useMemo","cl","ListView","SpectrumListView","EMPTY_FUNCTION","extractSpectrumHTMLElement","useContentRect","useOnScrollRef","Flex","normalizeItemList","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedMultiSelection","Fragment","_Fragment","jsx","_jsx","_ref","_spectrumListViewProp","children","tooltip","selectedKeys","defaultSelectedKeys","disabledKeys","UNSAFE_className","onChange","onScroll","onSelectionChange","spectrumListViewProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderNormalizedItem","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","scrollRef","ref","contentRectRef","contentRect","direction","flex","minHeight","height","_objectSpread","items"],"sources":["../../../src/spectrum/listView/ListView.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport cl from 'classnames';\nimport {\n ListView as SpectrumListView,\n SpectrumListViewProps,\n} from '@adobe/react-spectrum';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport {\n extractSpectrumHTMLElement,\n useContentRect,\n useOnScrollRef,\n} from '@deephaven/react-hooks';\nimport { Flex } from '../layout';\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 | null {\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 // Spectrum ListView crashes when it has zero height. Track the contentRect\n // of the parent container and only render the ListView when it has a non-zero\n // height. See https://github.com/adobe/react-spectrum/issues/6213\n const { ref: contentRectRef, contentRect } = useContentRect(\n extractSpectrumHTMLElement\n );\n\n return (\n <Flex\n ref={contentRectRef}\n direction=\"column\"\n flex={spectrumListViewProps.flex ?? 1}\n minHeight={0}\n UNSAFE_className={cl('dh-list-view', UNSAFE_className)}\n >\n {contentRect.height === 0 ? (\n // Use &nbsp; to ensure content has a non-zero height. This ensures the\n // container will also have a non-zero height unless its height is\n // explicitly set to zero. Example use case:\n // 1. Tab containing ListView is visible. Container height is non-zero.\n // ListView is rendered.\n // 2. Tab is hidden. Container height is explicitly constrained to zero.\n // ListView is not rendered.\n // 3. Tab is shown again. Height constraint is removed. Resize observer\n // fires and shows non-zero height due to the &nbsp; (without this,\n // the height would remain zero forever since ListView hasn't rendered yet)\n // 4. ListView is rendered again.\n <>&nbsp;</>\n ) : (\n <SpectrumListView\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumListViewProps}\n ref={scrollRef}\n items={normalizedItems}\n selectedKeys={selectedStringKeys}\n defaultSelectedKeys={defaultSelectedStringKeys}\n disabledKeys={disabledStringKeys}\n onSelectionChange={onStringSelectionChange}\n >\n {renderNormalizedItem}\n </SpectrumListView>\n )}\n </Flex>\n );\n}\n\nexport default ListView;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,OAAOC,EAAE,MAAM,YAAY;AAC3B,SACEC,QAAQ,IAAIC,gBAAgB,QAEvB,uBAAuB;AAC9B,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,0BAA0B,EAC1BC,cAAc,EACdC,cAAc,QACT,wBAAwB;AAAC,SACvBC,IAAI;AAAA,SAMXC,iBAAiB,EACjBC,uBAAuB,EAEvBC,uBAAuB,EACvBC,4BAA4B;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAuC9B,OAAO,SAASd,QAAQA,CAAAe,IAAA,EAWc;EAAA,IAAAC,qBAAA;EAAA,IAXb;MACvBC,QAAQ;MACRC,OAAO,GAAG,IAAI;MACdC,YAAY;MACZC,mBAAmB;MACnBC,YAAY;MACZC,gBAAgB;MAChBC,QAAQ;MACRC,QAAQ,GAAGtB,cAAc;MACzBuB;IAEa,CAAC,GAAAV,IAAA;IADXW,qBAAqB,GAAAC,wBAAA,CAAAZ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AqB;MACzBW,GAAG,EAAED,SAAU;MACfS,KAAK,EAAEhB,eAAgB;MACvBV,YAAY,EAAEa,kBAAmB;MACjCZ,mBAAmB,EAAEa,yBAA0B;MAC/CZ,YAAY,EAAEa,kBAAmB;MACjCT,iBAAiB,EAAEU,uBAAwB;MAAAlB,QAAA,EAE1Cc;IAAoB,EACL;EACnB,CACG,CAAC;AAEX;AAEA,eAAe/B,QAAQ"}
1
+ {"version":3,"file":"ListView.js","names":["useMemo","EMPTY_FUNCTION","normalizeTooltipOptions","wrapItemChildren","ListViewWrapper","jsx","_jsx","ListView","_ref","children","tooltip","selectedKeys","defaultSelectedKeys","disabledKeys","UNSAFE_className","onChange","onScroll","onSelectionChange","spectrumListViewProps","_objectWithoutProperties","_excluded","tooltipOptions","wrappedItems","_objectSpread"],"sources":["../../../src/spectrum/listView/ListView.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { SpectrumListViewProps } from '@adobe/react-spectrum';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport {\n ItemKey,\n ItemSelection,\n NormalizedItem,\n normalizeTooltipOptions,\n TooltipOptions,\n wrapItemChildren,\n} from '../utils';\nimport { ListViewWrapper } from './ListViewWrapper';\nimport { ItemElementOrPrimitive } from '../shared';\n\nexport type ListViewProps = {\n children: ItemElementOrPrimitive | ItemElementOrPrimitive[];\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 | null {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip, 'bottom'),\n [tooltip]\n );\n\n const wrappedItems = useMemo(\n () => wrapItemChildren(children, tooltipOptions),\n [children, tooltipOptions]\n );\n\n return (\n <ListViewWrapper\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumListViewProps}\n UNSAFE_className=\"dh-list-view\"\n onScroll={onScroll}\n >\n {wrappedItems}\n </ListViewWrapper>\n );\n}\n\nexport default ListView;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,SAASC,cAAc,QAAQ,kBAAkB;AAAC,SAKhDC,uBAAuB,EAEvBC,gBAAgB;AAAA,SAETC,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAoCxB,OAAO,SAASC,QAAQA,CAAAC,IAAA,EAWc;EAAA,IAXb;MACvBC,QAAQ;MACRC,OAAO,GAAG,IAAI;MACdC,YAAY;MACZC,mBAAmB;MACnBC,YAAY;MACZC,gBAAgB;MAChBC,QAAQ;MACRC,QAAQ,GAAGf,cAAc;MACzBgB;IAEa,CAAC,GAAAT,IAAA;IADXU,qBAAqB,GAAAC,wBAAA,CAAAX,IAAA,EAAAY,SAAA;EAExB,IAAMC,cAAc,GAAGrB,OAAO,CAC5B,MAAME,uBAAuB,CAACQ,OAAO,EAAE,QAAQ,CAAC,EAChD,CAACA,OAAO,CACV,CAAC;EAED,IAAMY,YAAY,GAAGtB,OAAO,CAC1B,MAAMG,gBAAgB,CAACM,QAAQ,EAAEY,cAAc,CAAC,EAChD,CAACZ,QAAQ,EAAEY,cAAc,CAC3B,CAAC;EAED,oBACEf,IAAA,CAACF;EACC;EAAA,EAAAmB,aAAA,CAAAA,aAAA,KACIL,qBAAqB;IACzBJ,gBAAgB,EAAC,cAAc;IAC/BE,QAAQ,EAAEA,QAAS;IAAAP,QAAA,EAElBa;EAAY,EACE,CAAC;AAEtB;AAEA,eAAef,QAAQ"}
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { NormalizedItem } from '../utils';
3
+ import type { ListViewProps } from './ListView';
4
+ export interface ListViewNormalizedProps extends Omit<ListViewProps, 'children'> {
5
+ normalizedItems: NormalizedItem[];
6
+ showItemIcons: boolean;
7
+ }
8
+ /**
9
+ * ListView supporting normalized item data. This component mostly exists to
10
+ * decouple some of the logic needed to support table data. Specifically it
11
+ * handles item rendering configurations as well as converting selection keys
12
+ * to / from strings. This makes it easier to test logic in isolation without
13
+ * a dependency on JS apis (e.g. in the Styleguide).
14
+ *
15
+ * Note that This component will usually not be used directly. Instead, it is
16
+ * recommended to use
17
+ * - `@deephaven/components`'s `ListView` for non-table data sources
18
+ * - `@deephaven/jsapi-components`'s `ListView` for table data sources
19
+ */
20
+ export declare function ListViewNormalized({ normalizedItems, tooltip, selectedKeys, defaultSelectedKeys, disabledKeys, showItemIcons, UNSAFE_className, onChange, onSelectionChange, ...props }: ListViewNormalizedProps): JSX.Element;
21
+ export default ListViewNormalized;
22
+ //# sourceMappingURL=ListViewNormalized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListViewNormalized.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListViewNormalized.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,cAAc,EAIf,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,MAAM,WAAW,uBACf,SAAQ,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC;IACvC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,eAAe,EACf,OAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CAkDvC;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,80 @@
1
+ var _excluded = ["normalizedItems", "tooltip", "selectedKeys", "defaultSelectedKeys", "disabledKeys", "showItemIcons", "UNSAFE_className", "onChange", "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 cl from 'classnames';
11
+ import { normalizeTooltipOptions, useRenderNormalizedItem, useStringifiedMultiSelection } from "../utils/index.js";
12
+ import { ListViewWrapper } from "./ListViewWrapper.js";
13
+ import { createElement as _createElement } from "react";
14
+ /**
15
+ * ListView supporting normalized item data. This component mostly exists to
16
+ * decouple some of the logic needed to support table data. Specifically it
17
+ * handles item rendering configurations as well as converting selection keys
18
+ * to / from strings. This makes it easier to test logic in isolation without
19
+ * a dependency on JS apis (e.g. in the Styleguide).
20
+ *
21
+ * Note that This component will usually not be used directly. Instead, it is
22
+ * recommended to use
23
+ * - `@deephaven/components`'s `ListView` for non-table data sources
24
+ * - `@deephaven/jsapi-components`'s `ListView` for table data sources
25
+ */
26
+ export function ListViewNormalized(_ref) {
27
+ var {
28
+ normalizedItems,
29
+ tooltip = true,
30
+ selectedKeys,
31
+ defaultSelectedKeys,
32
+ disabledKeys,
33
+ showItemIcons,
34
+ UNSAFE_className,
35
+ onChange,
36
+ onSelectionChange
37
+ } = _ref,
38
+ props = _objectWithoutProperties(_ref, _excluded);
39
+ var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip, 'bottom'), [tooltip]);
40
+ var renderNormalizedItem = useRenderNormalizedItem({
41
+ itemIconSlot: 'illustration',
42
+ // Descriptions introduce variable item heights which throws off setting
43
+ // viewport on windowed data. For now not going to implement description
44
+ // 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);
55
+ var {
56
+ selectedStringKeys,
57
+ defaultSelectedStringKeys,
58
+ disabledStringKeys,
59
+ onStringSelectionChange
60
+ } = useStringifiedMultiSelection({
61
+ normalizedItems,
62
+ selectedKeys,
63
+ defaultSelectedKeys,
64
+ disabledKeys,
65
+ onChange: onChange !== null && onChange !== void 0 ? onChange : onSelectionChange
66
+ });
67
+ return /*#__PURE__*/_createElement(ListViewWrapper
68
+ // eslint-disable-next-line react/jsx-props-no-spreading
69
+ , _objectSpread(_objectSpread({}, props), {}, {
70
+ UNSAFE_className: cl('dh-list-view-normalized', UNSAFE_className),
71
+ key: forceRerenderKey,
72
+ items: normalizedItems,
73
+ selectedKeys: selectedStringKeys,
74
+ defaultSelectedKeys: defaultSelectedStringKeys,
75
+ disabledKeys: disabledStringKeys,
76
+ onSelectionChange: onStringSelectionChange
77
+ }), renderNormalizedItem);
78
+ }
79
+ export default ListViewNormalized;
80
+ //# sourceMappingURL=ListViewNormalized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListViewNormalized.js","names":["useMemo","cl","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedMultiSelection","ListViewWrapper","createElement","_createElement","ListViewNormalized","_ref","normalizedItems","tooltip","selectedKeys","defaultSelectedKeys","disabledKeys","showItemIcons","UNSAFE_className","onChange","onSelectionChange","props","_objectWithoutProperties","_excluded","tooltipOptions","renderNormalizedItem","itemIconSlot","showItemDescriptions","forceRerenderKey","concat","placement","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","_objectSpread","key","items"],"sources":["../../../src/spectrum/listView/ListViewNormalized.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport cl from 'classnames';\nimport {\n NormalizedItem,\n normalizeTooltipOptions,\n useRenderNormalizedItem,\n useStringifiedMultiSelection,\n} from '../utils';\nimport type { ListViewProps } from './ListView';\nimport { ListViewWrapper } from './ListViewWrapper';\n\nexport interface ListViewNormalizedProps\n extends Omit<ListViewProps, 'children'> {\n normalizedItems: NormalizedItem[];\n showItemIcons: boolean;\n}\n\n/**\n * ListView supporting normalized item data. This component mostly exists to\n * decouple some of the logic needed to support table data. Specifically it\n * handles item rendering configurations as well as converting selection keys\n * to / from strings. This makes it easier to test logic in isolation without\n * a dependency on JS apis (e.g. in the Styleguide).\n *\n * Note that This component will usually not be used directly. Instead, it is\n * recommended to use\n * - `@deephaven/components`'s `ListView` for non-table data sources\n * - `@deephaven/jsapi-components`'s `ListView` for table data sources\n */\nexport function ListViewNormalized({\n normalizedItems,\n tooltip = true,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n showItemIcons,\n UNSAFE_className,\n onChange,\n onSelectionChange,\n ...props\n}: ListViewNormalizedProps): JSX.Element {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip, 'bottom'),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem({\n itemIconSlot: 'illustration',\n // Descriptions introduce variable item heights which throws off setting\n // viewport on windowed data. For now not going to implement description\n // 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 {\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 return (\n <ListViewWrapper\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n UNSAFE_className={cl('dh-list-view-normalized', UNSAFE_className)}\n key={forceRerenderKey}\n items={normalizedItems}\n selectedKeys={selectedStringKeys}\n defaultSelectedKeys={defaultSelectedStringKeys}\n disabledKeys={disabledStringKeys}\n onSelectionChange={onStringSelectionChange}\n >\n {renderNormalizedItem}\n </ListViewWrapper>\n );\n}\n\nexport default ListViewNormalized;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,OAAOC,EAAE,MAAM,YAAY;AAAC,SAG1BC,uBAAuB,EACvBC,uBAAuB,EACvBC,4BAA4B;AAAA,SAGrBC,eAAe;AAAA,SAAAC,aAAA,IAAAC,cAAA;AAQxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAAC,IAAA,EAWO;EAAA,IAXN;MACjCC,eAAe;MACfC,OAAO,GAAG,IAAI;MACdC,YAAY;MACZC,mBAAmB;MACnBC,YAAY;MACZC,aAAa;MACbC,gBAAgB;MAChBC,QAAQ;MACRC;IAEuB,CAAC,GAAAT,IAAA;IADrBU,KAAK,GAAAC,wBAAA,CAAAX,IAAA,EAAAY,SAAA;EAER,IAAMC,cAAc,GAAGtB,OAAO,CAC5B,MAAME,uBAAuB,CAACS,OAAO,EAAE,QAAQ,CAAC,EAChD,CAACA,OAAO,CACV,CAAC;EAED,IAAMY,oBAAoB,GAAGpB,uBAAuB,CAAC;IACnDqB,YAAY,EAAE,cAAc;IAC5B;IACA;IACA;IACA;IACAC,oBAAoB,EAAE,KAAK;IAC3BV,aAAa;IACbO;EACF,CAAC,CAAC;;EAEF;EACA;EACA;EACA,IAAMI,gBAAgB,MAAAC,MAAA,CAAMZ,aAAa,OAAAY,MAAA,CAAIL,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEM,SAAS,CAAE;EAExE,IAAM;IACJC,kBAAkB;IAClBC,yBAAyB;IACzBC,kBAAkB;IAClBC;EACF,CAAC,GAAG5B,4BAA4B,CAAC;IAC/BM,eAAe;IACfE,YAAY;IACZC,mBAAmB;IACnBC,YAAY;IACZG,QAAQ,EAAEA,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIC;EACxB,CAAC,CAAC;EAEF,oBACEX,cAAA,CAACF;EACC;EAAA,EAAA4B,aAAA,CAAAA,aAAA,KACId,KAAK;IACTH,gBAAgB,EAAEf,EAAE,CAAC,yBAAyB,EAAEe,gBAAgB,CAAE;IAClEkB,GAAG,EAAER,gBAAiB;IACtBS,KAAK,EAAEzB,eAAgB;IACvBE,YAAY,EAAEiB,kBAAmB;IACjChB,mBAAmB,EAAEiB,yBAA0B;IAC/ChB,YAAY,EAAEiB,kBAAmB;IACjCb,iBAAiB,EAAEc;EAAwB,IAE1CT,oBACc,CAAC;AAEtB;AAEA,eAAef,kBAAkB"}
@@ -0,0 +1,39 @@
1
+ .dh-list-view-wrapper {
2
+ --dh-list-view-item-icon-compact: 16px;
3
+ --dh-list-view-item-icon-regular: 18px;
4
+ --dh-list-view-item-icon-spacious: 24px;
5
+ height: 100%;
6
+ width: 100%;
7
+ position: relative;
8
+ }
9
+ .dh-list-view-wrapper > div {
10
+ position: absolute;
11
+ height: 100%;
12
+ width: 100%;
13
+ }
14
+ .dh-list-view-wrapper > div > div > div {
15
+ transition: none !important;
16
+ }
17
+
18
+ .dh-list-view-wrapper-scale-large {
19
+ --dh-list-view-item-icon-compact: 20px;
20
+ --dh-list-view-item-icon-regular: 24px;
21
+ --dh-list-view-item-icon-spacious: 30px;
22
+ }
23
+
24
+ .dh-list-view-wrapper-density-compact svg[class*=react-spectrum-ListViewItem-thumbnail] {
25
+ height: var(--dh-list-view-item-icon-compact);
26
+ width: var(--dh-list-view-item-icon-compact);
27
+ }
28
+
29
+ .dh-list-view-wrapper-density-regular svg[class*=react-spectrum-ListViewItem-thumbnail] {
30
+ height: var(--dh-list-view-item-icon-regular);
31
+ width: var(--dh-list-view-item-icon-regular);
32
+ }
33
+
34
+ .dh-list-view-wrapper-density-spacious svg[class*=react-spectrum-ListViewItem-thumbnail] {
35
+ height: var(--dh-list-view-item-icon-spacious);
36
+ width: var(--dh-list-view-item-icon-spacious);
37
+ }
38
+
39
+ /*# sourceMappingURL=ListViewWrapper.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../../../src/spectrum/listView/ListViewWrapper.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;EAGA;EACA;EACA;;AAEA;EAGE;EACA;EACA;;AACA;EAEE;;;AAKN;EACE;EACA;EACA;;;AAIA;EACE;EACA;;;AAKF;EACE;EACA;;;AAKF;EACE;EACA","file":"ListViewWrapper.css","sourcesContent":[".dh-list-view-wrapper {\n --dh-list-view-item-icon-compact: 16px;\n --dh-list-view-item-icon-regular: 18px;\n --dh-list-view-item-icon-spacious: 24px;\n\n // set the wrapper to grow to the size of the parent container\n height: 100%;\n width: 100%;\n position: relative;\n\n > div {\n // absolute position the list view to fill the wrapper\n // so that it will grow and shrink with the wrapper\n position: absolute;\n height: 100%;\n width: 100%;\n > div > div {\n // disable the transition on the list view items\n transition: none !important;\n }\n }\n}\n\n.dh-list-view-wrapper-scale-large {\n --dh-list-view-item-icon-compact: 20px;\n --dh-list-view-item-icon-regular: 24px;\n --dh-list-view-item-icon-spacious: 30px;\n}\n\n.dh-list-view-wrapper-density-compact {\n svg[class*='react-spectrum-ListViewItem-thumbnail'] {\n height: var(--dh-list-view-item-icon-compact);\n width: var(--dh-list-view-item-icon-compact);\n }\n}\n\n.dh-list-view-wrapper-density-regular {\n svg[class*='react-spectrum-ListViewItem-thumbnail'] {\n height: var(--dh-list-view-item-icon-regular);\n width: var(--dh-list-view-item-icon-regular);\n }\n}\n\n.dh-list-view-wrapper-density-spacious {\n svg[class*='react-spectrum-ListViewItem-thumbnail'] {\n height: var(--dh-list-view-item-icon-spacious);\n width: var(--dh-list-view-item-icon-spacious);\n }\n}\n"]}
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ import { SpectrumListViewProps } from '@adobe/react-spectrum';
3
+ import './ListViewWrapper.scss';
4
+ export interface ListViewWrapperProps<T> extends SpectrumListViewProps<T> {
5
+ /** Handler that is called when the picker is scrolled. */
6
+ onScroll?: (event: Event) => void;
7
+ }
8
+ /**
9
+ * Helper component to wrap a ListView with the appropriate styling + scroll
10
+ * handling. This is used by both the `@deephaven/components` `ListView` and
11
+ * the `@deephaven/jsapi-components` `ListView` (via `ListViewNormalized`) to
12
+ * ensure consistency.
13
+ *
14
+ * Note that This component will usually not be used directly. Instead, it is
15
+ * recommended to use
16
+ * - `@deephaven/components`'s `ListView` for non-table data sources
17
+ * - `@deephaven/jsapi-components`'s `ListView` for table data sources
18
+ */
19
+ export declare function ListViewWrapper<T>(props: ListViewWrapperProps<T>): JSX.Element;
20
+ export default ListViewWrapper;
21
+ //# sourceMappingURL=ListViewWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListViewWrapper.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListViewWrapper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAW/B,OAAO,wBAAwB,CAAC;AAEhC,MAAM,WAAW,oBAAoB,CAAC,CAAC,CAAE,SAAQ,qBAAqB,CAAC,CAAC,CAAC;IACvE,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC7B,GAAG,CAAC,OAAO,CAoDb;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,71 @@
1
+ var _excluded = ["onScroll"];
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 { ListView as SpectrumListView } from '@adobe/react-spectrum';
10
+ import { extractSpectrumHTMLElement, useContentRect, useOnScrollRef } from '@deephaven/react-hooks';
11
+ import { EMPTY_FUNCTION } from '@deephaven/utils';
12
+ import cl from 'classnames';
13
+ import { useSpectrumThemeProvider } from "../../theme/index.js";
14
+ import { Flex } from "../layout.js";
15
+ import { separateSpectrumProps } from "../utils/index.js";
16
+ import "./ListViewWrapper.css";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ /**
19
+ * Helper component to wrap a ListView with the appropriate styling + scroll
20
+ * handling. This is used by both the `@deephaven/components` `ListView` and
21
+ * the `@deephaven/jsapi-components` `ListView` (via `ListViewNormalized`) to
22
+ * ensure consistency.
23
+ *
24
+ * Note that This component will usually not be used directly. Instead, it is
25
+ * recommended to use
26
+ * - `@deephaven/components`'s `ListView` for non-table data sources
27
+ * - `@deephaven/jsapi-components`'s `ListView` for table data sources
28
+ */
29
+ export function ListViewWrapper(props) {
30
+ var _styleProps$minHeight, _listViewProps$densit;
31
+ var {
32
+ ariaLabelProps,
33
+ componentProps,
34
+ styleProps
35
+ } = separateSpectrumProps(props);
36
+ var {
37
+ onScroll = EMPTY_FUNCTION
38
+ } = componentProps,
39
+ listViewProps = _objectWithoutProperties(componentProps, _excluded);
40
+ var {
41
+ scale
42
+ } = useSpectrumThemeProvider();
43
+ var scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);
44
+
45
+ // Spectrum ListView crashes when it has zero height. Track the contentRect
46
+ // of the parent container and only render the ListView when it has a non-zero
47
+ // height. See https://github.com/adobe/react-spectrum/issues/6213
48
+ var {
49
+ ref: contentRectRef,
50
+ contentRect
51
+ } = useContentRect(extractSpectrumHTMLElement);
52
+ return /*#__PURE__*/_jsx(Flex, _objectSpread(_objectSpread({
53
+ direction: "column",
54
+ ref: contentRectRef
55
+ // eslint-disable-next-line react/jsx-props-no-spreading
56
+ }, styleProps), {}, {
57
+ // Set min-height to 1px so that `ListView` is rendered whenever container
58
+ // is visible. This prevents the height from shrinking to zero as a result
59
+ // of a parent grid or flex container calculating content sizes. The
60
+ // container height can still be zero when it is not being displayed such
61
+ // as when one of its parents have `display: none`.
62
+ minHeight: (_styleProps$minHeight = styleProps.minHeight) !== null && _styleProps$minHeight !== void 0 ? _styleProps$minHeight : 1,
63
+ UNSAFE_className: cl('dh-list-view-wrapper', "dh-list-view-wrapper-density-".concat((_listViewProps$densit = listViewProps.density) !== null && _listViewProps$densit !== void 0 ? _listViewProps$densit : 'regular'), "dh-list-view-wrapper-scale-".concat(scale), styleProps.UNSAFE_className),
64
+ children: contentRect.height === 0 ? null : /*#__PURE__*/_jsx(SpectrumListView, _objectSpread(_objectSpread({
65
+ ref: scrollRef
66
+ // eslint-disable-next-line react/jsx-props-no-spreading
67
+ }, ariaLabelProps), listViewProps))
68
+ }));
69
+ }
70
+ export default ListViewWrapper;
71
+ //# sourceMappingURL=ListViewWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListViewWrapper.js","names":["ListView","SpectrumListView","extractSpectrumHTMLElement","useContentRect","useOnScrollRef","EMPTY_FUNCTION","cl","useSpectrumThemeProvider","Flex","separateSpectrumProps","jsx","_jsx","ListViewWrapper","props","_styleProps$minHeight","_listViewProps$densit","ariaLabelProps","componentProps","styleProps","onScroll","listViewProps","_objectWithoutProperties","_excluded","scale","scrollRef","ref","contentRectRef","contentRect","_objectSpread","direction","minHeight","UNSAFE_className","concat","density","children","height"],"sources":["../../../src/spectrum/listView/ListViewWrapper.tsx"],"sourcesContent":["import {\n ListView as SpectrumListView,\n SpectrumListViewProps,\n} from '@adobe/react-spectrum';\nimport {\n extractSpectrumHTMLElement,\n useContentRect,\n useOnScrollRef,\n} from '@deephaven/react-hooks';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport cl from 'classnames';\nimport { useSpectrumThemeProvider } from '../../theme';\nimport { Flex } from '../layout';\nimport { separateSpectrumProps } from '../utils';\nimport './ListViewWrapper.scss';\n\nexport interface ListViewWrapperProps<T> extends SpectrumListViewProps<T> {\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n}\n\n/**\n * Helper component to wrap a ListView with the appropriate styling + scroll\n * handling. This is used by both the `@deephaven/components` `ListView` and\n * the `@deephaven/jsapi-components` `ListView` (via `ListViewNormalized`) to\n * ensure consistency.\n *\n * Note that This component will usually not be used directly. Instead, it is\n * recommended to use\n * - `@deephaven/components`'s `ListView` for non-table data sources\n * - `@deephaven/jsapi-components`'s `ListView` for table data sources\n */\nexport function ListViewWrapper<T>(\n props: ListViewWrapperProps<T>\n): JSX.Element {\n const { ariaLabelProps, componentProps, styleProps } =\n separateSpectrumProps(props);\n\n const { onScroll = EMPTY_FUNCTION, ...listViewProps } = componentProps;\n\n const { scale } = useSpectrumThemeProvider();\n\n const scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);\n\n // Spectrum ListView crashes when it has zero height. Track the contentRect\n // of the parent container and only render the ListView when it has a non-zero\n // height. See https://github.com/adobe/react-spectrum/issues/6213\n const { ref: contentRectRef, contentRect } = useContentRect(\n extractSpectrumHTMLElement\n );\n\n return (\n <Flex\n direction=\"column\"\n ref={contentRectRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...styleProps}\n // Set min-height to 1px so that `ListView` is rendered whenever container\n // is visible. This prevents the height from shrinking to zero as a result\n // of a parent grid or flex container calculating content sizes. The\n // container height can still be zero when it is not being displayed such\n // as when one of its parents have `display: none`.\n minHeight={styleProps.minHeight ?? 1}\n UNSAFE_className={cl(\n 'dh-list-view-wrapper',\n `dh-list-view-wrapper-density-${listViewProps.density ?? 'regular'}`,\n `dh-list-view-wrapper-scale-${scale}`,\n styleProps.UNSAFE_className\n )}\n >\n {/**\n * Only render ListView if parent is visible. Some time in the future we\n * should consider using `checkVisibility()` once it has better browser\n * support.\n */}\n {contentRect.height === 0 ? null : (\n <SpectrumListView\n ref={scrollRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...ariaLabelProps}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...listViewProps}\n />\n )}\n </Flex>\n );\n}\n\nexport default ListViewWrapper;\n"],"mappings":";;;;;;;;AAAA,SACEA,QAAQ,IAAIC,gBAAgB,QAEvB,uBAAuB;AAC9B,SACEC,0BAA0B,EAC1BC,cAAc,EACdC,cAAc,QACT,wBAAwB;AAC/B,SAASC,cAAc,QAAQ,kBAAkB;AACjD,OAAOC,EAAE,MAAM,YAAY;AAAC,SACnBC,wBAAwB;AAAA,SACxBC,IAAI;AAAA,SACJC,qBAAqB;AAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAQ9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,KAA8B,EACjB;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EACb,IAAM;IAAEC,cAAc;IAAEC,cAAc;IAAEC;EAAW,CAAC,GAClDT,qBAAqB,CAACI,KAAK,CAAC;EAE9B,IAAM;MAAEM,QAAQ,GAAGd;IAAiC,CAAC,GAAGY,cAAc;IAAhCG,aAAa,GAAAC,wBAAA,CAAKJ,cAAc,EAAAK,SAAA;EAEtE,IAAM;IAAEC;EAAM,CAAC,GAAGhB,wBAAwB,CAAC,CAAC;EAE5C,IAAMiB,SAAS,GAAGpB,cAAc,CAACe,QAAQ,EAAEjB,0BAA0B,CAAC;;EAEtE;EACA;EACA;EACA,IAAM;IAAEuB,GAAG,EAAEC,cAAc;IAAEC;EAAY,CAAC,GAAGxB,cAAc,CACzDD,0BACF,CAAC;EAED,oBACES,IAAA,CAACH,IAAI,EAAAoB,aAAA,CAAAA,aAAA;IACHC,SAAS,EAAC,QAAQ;IAClBJ,GAAG,EAAEC;IACL;EAAA,GACIR,UAAU;IACd;IACA;IACA;IACA;IACA;IACAY,SAAS,GAAAhB,qBAAA,GAAEI,UAAU,CAACY,SAAS,cAAAhB,qBAAA,cAAAA,qBAAA,GAAI,CAAE;IACrCiB,gBAAgB,EAAEzB,EAAE,CAClB,sBAAsB,kCAAA0B,MAAA,EAAAjB,qBAAA,GACUK,aAAa,CAACa,OAAO,cAAAlB,qBAAA,cAAAA,qBAAA,GAAI,SAAS,iCAAAiB,MAAA,CACpCT,KAAK,GACnCL,UAAU,CAACa,gBACb,CAAE;IAAAG,QAAA,EAODP,WAAW,CAACQ,MAAM,KAAK,CAAC,GAAG,IAAI,gBAC9BxB,IAAA,CAACV,gBAAgB,EAAA2B,aAAA,CAAAA,aAAA;MACfH,GAAG,EAAED;MACL;IAAA,GACIR,cAAc,GAEdI,aAAa,CAClB;EACF,EACG,CAAC;AAEX;AAEA,eAAeR,eAAe"}
@@ -1,2 +1,4 @@
1
1
  export * from './ListView';
2
+ export * from './ListViewNormalized';
3
+ export * from './ListViewWrapper';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
@@ -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,CA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A,CAACb;EACC;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={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,WAAW,EACXC,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,SAASf,MAAMA,CAAAgB,IAAA,EAYO;EAAA,IAZN;MACrBC,QAAQ;MACRC,OAAO,GAAG,IAAI;MACdC,kBAAkB;MAClBC,WAAW;MACXC,QAAQ;MACRC,YAAY;MACZC,QAAQ,GAAGpB,cAAc;MACzBqB,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,GAAGjC,OAAO,CAC5B,MAAMU,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,GACzDpC,QAAQ,CAACoB,kBAAkB,CAAC;EAE9B,IAAMiB,YAAY,GAAGtC,OAAO,CAC1B,MA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,KACIxB,mBAAmB;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,EAC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kBAAkB,EAClB,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"}