@deephaven/components 0.82.0 → 0.82.1-alpha-combobox.11

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 (90) hide show
  1. package/dist/SearchableCombobox.d.ts +2 -2
  2. package/dist/SearchableCombobox.d.ts.map +1 -1
  3. package/dist/SearchableCombobox.js.map +1 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +0 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/spectrum/collections.d.ts +1 -1
  9. package/dist/spectrum/collections.d.ts.map +1 -1
  10. package/dist/spectrum/collections.js +10 -3
  11. package/dist/spectrum/collections.js.map +1 -1
  12. package/dist/spectrum/comboBox/ComboBox.d.ts +7 -0
  13. package/dist/spectrum/comboBox/ComboBox.d.ts.map +1 -0
  14. package/dist/spectrum/comboBox/ComboBox.js +41 -0
  15. package/dist/spectrum/comboBox/ComboBox.js.map +1 -0
  16. package/dist/spectrum/comboBox/ComboBoxNormalized.d.ts +15 -0
  17. package/dist/spectrum/comboBox/ComboBoxNormalized.d.ts.map +1 -0
  18. package/dist/spectrum/comboBox/ComboBoxNormalized.js +42 -0
  19. package/dist/spectrum/comboBox/ComboBoxNormalized.js.map +1 -0
  20. package/dist/spectrum/comboBox/index.d.ts +3 -0
  21. package/dist/spectrum/comboBox/index.d.ts.map +1 -0
  22. package/dist/spectrum/comboBox/index.js +3 -0
  23. package/dist/spectrum/comboBox/index.js.map +1 -0
  24. package/dist/spectrum/index.d.ts +1 -1
  25. package/dist/spectrum/index.d.ts.map +1 -1
  26. package/dist/spectrum/index.js +1 -1
  27. package/dist/spectrum/index.js.map +1 -1
  28. package/dist/spectrum/listView/ListViewWrapper.js.map +1 -1
  29. package/dist/spectrum/picker/Picker.d.ts +2 -25
  30. package/dist/spectrum/picker/Picker.d.ts.map +1 -1
  31. package/dist/spectrum/picker/Picker.js +20 -68
  32. package/dist/spectrum/picker/Picker.js.map +1 -1
  33. package/dist/spectrum/picker/PickerNormalized.d.ts +2 -9
  34. package/dist/spectrum/picker/PickerNormalized.d.ts.map +1 -1
  35. package/dist/spectrum/picker/PickerNormalized.js +13 -80
  36. package/dist/spectrum/picker/PickerNormalized.js.map +1 -1
  37. package/dist/spectrum/picker/PickerProps.d.ts +64 -0
  38. package/dist/spectrum/picker/PickerProps.d.ts.map +1 -0
  39. package/dist/spectrum/picker/PickerProps.js +2 -0
  40. package/dist/spectrum/picker/PickerProps.js.map +1 -0
  41. package/dist/spectrum/picker/index.d.ts +4 -0
  42. package/dist/spectrum/picker/index.d.ts.map +1 -1
  43. package/dist/spectrum/picker/index.js +4 -0
  44. package/dist/spectrum/picker/index.js.map +1 -1
  45. package/dist/spectrum/picker/usePickerItemScale.d.ts +9 -0
  46. package/dist/spectrum/picker/usePickerItemScale.d.ts.map +1 -0
  47. package/dist/spectrum/picker/usePickerItemScale.js +17 -0
  48. package/dist/spectrum/picker/usePickerItemScale.js.map +1 -0
  49. package/dist/spectrum/picker/usePickerNormalizedProps.d.ts +27 -0
  50. package/dist/spectrum/picker/usePickerNormalizedProps.d.ts.map +1 -0
  51. package/dist/spectrum/picker/usePickerNormalizedProps.js +101 -0
  52. package/dist/spectrum/picker/usePickerNormalizedProps.js.map +1 -0
  53. package/dist/spectrum/picker/usePickerProps.d.ts +28 -0
  54. package/dist/spectrum/picker/usePickerProps.d.ts.map +1 -0
  55. package/dist/spectrum/picker/usePickerProps.js +75 -0
  56. package/dist/spectrum/picker/usePickerProps.js.map +1 -0
  57. package/dist/spectrum/picker/usePickerScrollOnOpen.d.ts +3 -3
  58. package/dist/spectrum/picker/usePickerScrollOnOpen.d.ts.map +1 -1
  59. package/dist/spectrum/picker/usePickerScrollOnOpen.js.map +1 -1
  60. package/dist/spectrum/utils/index.d.ts +2 -0
  61. package/dist/spectrum/utils/index.d.ts.map +1 -1
  62. package/dist/spectrum/utils/index.js +2 -0
  63. package/dist/spectrum/utils/index.js.map +1 -1
  64. package/dist/spectrum/utils/itemUtils.d.ts +7 -2
  65. package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
  66. package/dist/spectrum/utils/itemUtils.js +13 -0
  67. package/dist/spectrum/utils/itemUtils.js.map +1 -1
  68. package/dist/spectrum/utils/itemWrapperUtils.d.ts.map +1 -1
  69. package/dist/spectrum/utils/itemWrapperUtils.js +2 -2
  70. package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -1
  71. package/dist/spectrum/utils/useOnChangeTrackUncontrolled.d.ts +19 -0
  72. package/dist/spectrum/utils/useOnChangeTrackUncontrolled.d.ts.map +1 -0
  73. package/dist/spectrum/utils/useOnChangeTrackUncontrolled.js +31 -0
  74. package/dist/spectrum/utils/useOnChangeTrackUncontrolled.js.map +1 -0
  75. package/dist/spectrum/utils/useStaticItemInitialScrollPosition.d.ts +10 -0
  76. package/dist/spectrum/utils/useStaticItemInitialScrollPosition.d.ts.map +1 -0
  77. package/dist/spectrum/utils/useStaticItemInitialScrollPosition.js +27 -0
  78. package/dist/spectrum/utils/useStaticItemInitialScrollPosition.js.map +1 -0
  79. package/dist/spectrum/utils/useStringifiedSelection.d.ts +2 -2
  80. package/dist/spectrum/utils/useStringifiedSelection.d.ts.map +1 -1
  81. package/dist/spectrum/utils/useStringifiedSelection.js.map +1 -1
  82. package/package.json +7 -7
  83. package/dist/ComboBox.d.ts +0 -120
  84. package/dist/ComboBox.d.ts.map +0 -1
  85. package/dist/ComboBox.js +0 -497
  86. package/dist/ComboBox.js.map +0 -1
  87. package/dist/spectrum/pickers.d.ts +0 -2
  88. package/dist/spectrum/pickers.d.ts.map +0 -1
  89. package/dist/spectrum/pickers.js +0 -2
  90. package/dist/spectrum/pickers.js.map +0 -1
@@ -1,17 +1,10 @@
1
1
  /// <reference types="react" />
2
- import type { PickerProps as PickerBaseProps } from './Picker';
3
- import { NormalizedItem, NormalizedSection } from '../utils';
4
- export interface PickerNormalizedProps extends Omit<PickerBaseProps, 'children'> {
5
- normalizedItems: (NormalizedItem | NormalizedSection)[];
6
- showItemIcons: boolean;
7
- getInitialScrollPosition?: () => Promise<number | null | undefined>;
8
- onScroll?: (event: Event) => void;
9
- }
2
+ import type { PickerNormalizedProps } from './PickerProps';
10
3
  /**
11
4
  * Picker that takes an array of `NormalizedItem` or `NormalizedSection` items
12
5
  * as children and uses a render item function to render the items. This is
13
6
  * necessary to support windowed data.
14
7
  */
15
- export declare function PickerNormalized({ normalizedItems, tooltip, selectedKey, defaultSelectedKey, disabledKeys, showItemIcons, UNSAFE_className, getInitialScrollPosition, onChange, onOpenChange, onScroll, onSelectionChange, ...props }: PickerNormalizedProps): JSX.Element;
8
+ export declare function PickerNormalized({ UNSAFE_className, ...props }: PickerNormalizedProps): JSX.Element;
16
9
  export default PickerNormalized;
17
10
  //# sourceMappingURL=PickerNormalized.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PickerNormalized.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerNormalized.tsx"],"names":[],"mappings":";AAMA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,EAGL,cAAc,EACd,iBAAiB,EAIlB,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC;IACzC,eAAe,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IACxD,aAAa,EAAE,OAAO,CAAC;IACvB,wBAAwB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,eAAe,EACf,OAAc,EACd,WAAW,EACX,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"}
1
+ {"version":3,"file":"PickerNormalized.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerNormalized.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAI3D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,gBAAgB,EAChB,GAAG,KAAK,EACT,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAkBrC;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,4 +1,5 @@
1
- var _excluded = ["normalizedItems", "tooltip", "selectedKey", "defaultSelectedKey", "disabledKeys", "showItemIcons", "UNSAFE_className", "getInitialScrollPosition", "onChange", "onOpenChange", "onScroll", "onSelectionChange"];
1
+ var _excluded = ["UNSAFE_className"],
2
+ _excluded2 = ["forceRerenderKey"];
2
3
  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
4
  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
5
  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; }
@@ -6,99 +7,31 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
6
7
  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
8
  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
9
  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
10
  import { Picker as SpectrumPicker } from '@adobe/react-spectrum';
11
11
  import cl from 'classnames';
12
- import { EMPTY_FUNCTION } from '@deephaven/utils';
13
- import { Section } from "../shared.js";
14
- import { getItemKey, isNormalizedSection, normalizeTooltipOptions, useRenderNormalizedItem, useStringifiedSelection } from "../utils/index.js";
15
- import usePickerScrollOnOpen from "./usePickerScrollOnOpen.js";
16
- import { jsx as _jsx } from "react/jsx-runtime";
17
- import { createElement as _createElement } from "react";
12
+ import usePickerNormalizedProps from "./usePickerNormalizedProps.js";
18
13
  /**
19
14
  * Picker that takes an array of `NormalizedItem` or `NormalizedSection` items
20
15
  * as children and uses a render item function to render the items. This is
21
16
  * necessary to support windowed data.
22
17
  */
18
+ import { createElement as _createElement } from "react";
23
19
  export function PickerNormalized(_ref) {
24
20
  var {
25
- normalizedItems,
26
- tooltip = true,
27
- selectedKey,
28
- defaultSelectedKey,
29
- disabledKeys,
30
- showItemIcons,
31
- UNSAFE_className,
32
- getInitialScrollPosition,
33
- onChange,
34
- onOpenChange,
35
- onScroll = EMPTY_FUNCTION,
36
- onSelectionChange
21
+ UNSAFE_className
37
22
  } = _ref,
38
23
  props = _objectWithoutProperties(_ref, _excluded);
39
- var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip), [tooltip]);
40
- var renderNormalizedItem = useRenderNormalizedItem({
41
- itemIconSlot: 'icon',
42
- // Descriptions introduce variable item heights which throws off calculation
43
- // of initial scroll position and setting viewport on windowed data. For now
44
- // not going to implement description support in Picker.
45
- // https://github.com/deephaven/web-client-ui/issues/1958
46
- showItemDescriptions: false,
47
- showItemIcons,
48
- tooltipOptions
49
- });
50
-
51
- // Spectrum doesn't re-render if only the `renderNormalizedItems` function
52
- // changes, so we create a key from its dependencies that can be used to force
53
- // re-render.
54
- var forceRerenderKey = "".concat(showItemIcons, "-").concat(tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.placement);
55
- var {
56
- ref: scrollRef,
57
- onOpenChange: onOpenChangeInternal
58
- } = usePickerScrollOnOpen({
59
- getInitialScrollPosition,
60
- onScroll,
61
- onOpenChange
62
- });
63
-
64
- // Spectrum Picker treats keys as strings if the `key` prop is explicitly
65
- // set on `Item` elements. Since we do this in `renderItem`, we need to
66
- // map original key types to and from strings so that selection works.
67
- var {
68
- selectedStringKey,
69
- defaultSelectedStringKey,
70
- disabledStringKeys,
71
- onStringSelectionChange
72
- } = useStringifiedSelection({
73
- normalizedItems,
74
- selectedKey,
75
- defaultSelectedKey,
76
- disabledKeys,
77
- onChange: onChange !== null && onChange !== void 0 ? onChange : onSelectionChange
78
- });
24
+ var _usePickerNormalizedP = usePickerNormalizedProps(props),
25
+ {
26
+ forceRerenderKey
27
+ } = _usePickerNormalizedP,
28
+ pickerProps = _objectWithoutProperties(_usePickerNormalizedP, _excluded2);
79
29
  return /*#__PURE__*/_createElement(SpectrumPicker
80
30
  // eslint-disable-next-line react/jsx-props-no-spreading
81
- , _objectSpread(_objectSpread({}, props), {}, {
31
+ , _objectSpread(_objectSpread({}, pickerProps), {}, {
82
32
  key: forceRerenderKey,
83
- ref: scrollRef,
84
- UNSAFE_className: cl('dh-picker', 'dh-picker-normalized', UNSAFE_className),
85
- items: normalizedItems,
86
- selectedKey: selectedStringKey,
87
- defaultSelectedKey: defaultSelectedStringKey,
88
- disabledKeys: disabledStringKeys,
89
- onSelectionChange: onStringSelectionChange,
90
- onOpenChange: onOpenChangeInternal
91
- }), itemOrSection => {
92
- if (isNormalizedSection(itemOrSection)) {
93
- var _itemOrSection$item, _itemOrSection$item2;
94
- return /*#__PURE__*/_jsx(Section, {
95
- title: (_itemOrSection$item = itemOrSection.item) === null || _itemOrSection$item === void 0 ? void 0 : _itemOrSection$item.title,
96
- items: (_itemOrSection$item2 = itemOrSection.item) === null || _itemOrSection$item2 === void 0 ? void 0 : _itemOrSection$item2.items,
97
- children: renderNormalizedItem
98
- }, getItemKey(itemOrSection));
99
- }
100
- return renderNormalizedItem(itemOrSection);
101
- });
33
+ UNSAFE_className: cl('dh-picker', 'dh-picker-normalized', UNSAFE_className)
34
+ }));
102
35
  }
103
36
  export default PickerNormalized;
104
37
  //# sourceMappingURL=PickerNormalized.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PickerNormalized.js","names":["useMemo","Picker","SpectrumPicker","cl","EMPTY_FUNCTION","Section","getItemKey","isNormalizedSection","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedSelection","usePickerScrollOnOpen","jsx","_jsx","createElement","_createElement","PickerNormalized","_ref","normalizedItems","tooltip","selectedKey","defaultSelectedKey","disabledKeys","showItemIcons","UNSAFE_className","getInitialScrollPosition","onChange","onOpenChange","onScroll","onSelectionChange","props","_objectWithoutProperties","_excluded","tooltipOptions","renderNormalizedItem","itemIconSlot","showItemDescriptions","forceRerenderKey","concat","placement","ref","scrollRef","onOpenChangeInternal","selectedStringKey","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","_objectSpread","key","items","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title","item","children"],"sources":["../../../src/spectrum/picker/PickerNormalized.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport type { DOMRef } from '@react-types/shared';\nimport cl from 'classnames';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport { Section } from '../shared';\nimport type { PickerProps as PickerBaseProps } from './Picker';\n\nimport {\n getItemKey,\n isNormalizedSection,\n NormalizedItem,\n NormalizedSection,\n normalizeTooltipOptions,\n useRenderNormalizedItem,\n useStringifiedSelection,\n} from '../utils';\nimport usePickerScrollOnOpen from './usePickerScrollOnOpen';\n\nexport interface PickerNormalizedProps\n extends Omit<PickerBaseProps, 'children'> {\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n showItemIcons: boolean;\n getInitialScrollPosition?: () => Promise<number | null | undefined>;\n onScroll?: (event: Event) => void;\n}\n\n/**\n * Picker that takes an array of `NormalizedItem` or `NormalizedSection` items\n * as children and uses a render item function to render the items. This is\n * necessary to support windowed data.\n */\nexport function PickerNormalized({\n normalizedItems,\n tooltip = true,\n selectedKey,\n defaultSelectedKey,\n disabledKeys,\n showItemIcons,\n UNSAFE_className,\n getInitialScrollPosition,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n ...props\n}: PickerNormalizedProps): JSX.Element {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem({\n itemIconSlot: 'icon',\n // Descriptions introduce variable item heights which throws off calculation\n // of initial scroll position and setting viewport on windowed data. For now\n // not going to implement description support in Picker.\n // https://github.com/deephaven/web-client-ui/issues/1958\n showItemDescriptions: false,\n showItemIcons,\n tooltipOptions,\n });\n\n // Spectrum doesn't re-render if only the `renderNormalizedItems` function\n // changes, so we create a key from its dependencies that can be used to force\n // re-render.\n const forceRerenderKey = `${showItemIcons}-${tooltipOptions?.placement}`;\n\n const { ref: scrollRef, onOpenChange: onOpenChangeInternal } =\n usePickerScrollOnOpen({\n getInitialScrollPosition,\n onScroll,\n onOpenChange,\n });\n\n // Spectrum Picker treats keys as strings if the `key` prop is explicitly\n // set on `Item` elements. Since we do this in `renderItem`, we need to\n // map original key types to and from strings so that selection works.\n const {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedSelection({\n normalizedItems,\n selectedKey,\n defaultSelectedKey,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n key={forceRerenderKey}\n ref={scrollRef as DOMRef<HTMLDivElement>}\n UNSAFE_className={cl(\n 'dh-picker',\n 'dh-picker-normalized',\n UNSAFE_className\n )}\n items={normalizedItems}\n selectedKey={selectedStringKey}\n defaultSelectedKey={defaultSelectedStringKey}\n disabledKeys={disabledStringKeys}\n onSelectionChange={onStringSelectionChange}\n onOpenChange={onOpenChangeInternal}\n >\n {itemOrSection => {\n if (isNormalizedSection(itemOrSection)) {\n return (\n <Section\n key={getItemKey(itemOrSection)}\n title={itemOrSection.item?.title}\n items={itemOrSection.item?.items}\n >\n {renderNormalizedItem}\n </Section>\n );\n }\n\n return renderNormalizedItem(itemOrSection);\n }}\n </SpectrumPicker>\n );\n}\n\nexport default PickerNormalized;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AAEhE,OAAOC,EAAE,MAAM,YAAY;AAC3B,SAASC,cAAc,QAAQ,kBAAkB;AAAC,SACzCC,OAAO;AAAA,SAIdC,UAAU,EACVC,mBAAmB,EAGnBC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB;AAAA,OAElBC,qBAAqB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,a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,KAAK;IACTkB,GAAG,EAAEX,gBAAiB;IACtBG,GAAG,EAAEC,SAAoC;IACzCjB,gBAAgB,EAAErB,EAAE,CAClB,WAAW,EACX,sBAAsB,EACtBqB,gBACF,CAAE;IACFyB,KAAK,EAAE/B,eAAgB;IACvBE,WAAW,EAAEuB,iBAAkB;IAC/BtB,kBAAkB,EAAEuB,wBAAyB;IAC7CtB,YAAY,EAAEuB,kBAAmB;IACjChB,iBAAiB,EAAEiB,uBAAwB;IAC3CnB,YAAY,EAAEe;EAAqB,IAElCQ,aAAa,IAAI;IAChB,IAAI3C,mBAAmB,CAAC2C,aAAa,CAAC,EAAE;MAAA,IAAAC,mBAAA,EAAAC,oBAAA;MACtC,oBACEvC,IAAA,CAACR,OAAO;QAENgD,KAAK,GAAAF,mBAAA,GAAED,aAAa,CAACI,IAAI,cAAAH,mBAAA,uBAAlBA,mBAAA,CAAoBE,KAAM;QACjCJ,KAAK,GAAAG,oBAAA,GAAEF,aAAa,CAACI,IAAI,cAAAF,oBAAA,uBAAlBA,oBAAA,CAAoBH,KAAM;QAAAM,QAAA,EAEhCrB;MAAoB,GAJhB5B,UAAU,CAAC4C,aAAa,CAKtB,CAAC;IAEd;IAEA,OAAOhB,oBAAoB,CAACgB,aAAa,CAAC;EAC5C,CACc,CAAC;AAErB;AAEA,eAAelC,gBAAgB"}
1
+ {"version":3,"file":"PickerNormalized.js","names":["Picker","SpectrumPicker","cl","usePickerNormalizedProps","createElement","_createElement","PickerNormalized","_ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerNormalizedP","forceRerenderKey","pickerProps","_excluded2","_objectSpread","key"],"sources":["../../../src/spectrum/picker/PickerNormalized.tsx"],"sourcesContent":["import { Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport cl from 'classnames';\nimport type { PickerNormalizedProps } from './PickerProps';\n\nimport usePickerNormalizedProps from './usePickerNormalizedProps';\n\n/**\n * Picker that takes an array of `NormalizedItem` or `NormalizedSection` items\n * as children and uses a render item function to render the items. This is\n * necessary to support windowed data.\n */\nexport function PickerNormalized({\n UNSAFE_className,\n ...props\n}: PickerNormalizedProps): JSX.Element {\n const { forceRerenderKey, ...pickerProps } = usePickerNormalizedProps<\n PickerNormalizedProps,\n HTMLDivElement\n >(props);\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...pickerProps}\n key={forceRerenderKey}\n UNSAFE_className={cl(\n 'dh-picker',\n 'dh-picker-normalized',\n UNSAFE_className\n )}\n />\n );\n}\n\nexport default PickerNormalized;\n"],"mappings":";;;;;;;;;AAAA,SAASA,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AAChE,OAAOC,EAAE,MAAM,YAAY;AAAC,OAGrBC,wBAAwB;AAE/B;AACA;AACA;AACA;AACA;AAJA,SAAAC,aAAA,IAAAC,cAAA;AAKA,OAAO,SAASC,gBAAgBA,CAAAC,IAAA,EAGO;EAAA,IAHN;MAC/BC;IAEqB,CAAC,GAAAD,IAAA;IADnBE,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAER,IAAAC,qBAAA,GAA6CT,wBAAwB,CAGnEM,KAAK,CAAC;IAHF;MAAEI;IAAiC,CAAC,GAAAD,qBAAA;IAAbE,WAAW,GAAAJ,wBAAA,CAAAE,qBAAA,EAAAG,UAAA;EAKxC,oBACEV,cAAA,CAACJ;EACC;EAAA,EAAAe,aAAA,CAAAA,aAAA,KACIF,WAAW;IACfG,GAAG,EAAEJ,gBAAiB;IACtBL,gBAAgB,EAAEN,EAAE,CAClB,WAAW,EACX,sBAAsB,EACtBM,gBACF;EAAE,EACH,CAAC;AAEN;AAEA,eAAeF,gBAAgB"}
@@ -0,0 +1,64 @@
1
+ import type { SpectrumPickerProps } from '@adobe/react-spectrum';
2
+ import type { ItemKey, ItemOrSection, NormalizedItem, NormalizedSection, TooltipOptions } from '../utils';
3
+ /**
4
+ * Extend Spectrum Picker props (also other components that adhere to the same
5
+ * apis such as ComboBox).
6
+ * - `children` is extended to include primitive types and to exclude render function
7
+ * - `items` and `defaultItems` are excluded since we are not currently supporting
8
+ * render functions as `children`
9
+ * - selection key types are extended to include number + boolean primitive types
10
+ * - remaining props from the original type are passed through
11
+ */
12
+ export type PickerPropsT<TProps> = Omit<TProps, 'children' | 'onSelectionChange' | 'selectedKey' | 'defaultSelectedKey' | 'disabledKeys' | 'defaultItems' | 'items'> & {
13
+ children: ItemOrSection | ItemOrSection[];
14
+ /** Can be set to true or a TooltipOptions to enable item tooltips */
15
+ tooltip?: boolean | TooltipOptions;
16
+ /** The currently selected key in the collection (controlled). */
17
+ selectedKey?: ItemKey | null;
18
+ /** The initial selected key in the collection (uncontrolled). */
19
+ defaultSelectedKey?: ItemKey;
20
+ /**
21
+ * The item keys that are disabled. These items cannot be selected, focused,
22
+ * or otherwise interacted with.
23
+ */
24
+ disabledKeys?: Iterable<ItemKey>;
25
+ /**
26
+ * Handler that is called when the selection change.
27
+ * Note that under the hood, this is just an alias for Spectrum's
28
+ * `onSelectionChange`. We are renaming for better consistency with other
29
+ * components.
30
+ */
31
+ onChange?: (key: ItemKey | null) => void;
32
+ /**
33
+ * Method that is called when the open state of the menu changes.
34
+ */
35
+ onOpenChange?: (isOpen: boolean) => void;
36
+ /** Handler that is called when the picker is scrolled. */
37
+ onScroll?: (event: Event) => void;
38
+ /**
39
+ * Handler that is called when the selection changes.
40
+ * @deprecated Use `onChange` instead
41
+ */
42
+ onSelectionChange?: (key: ItemKey | null) => void;
43
+ };
44
+ /**
45
+ * Extend Picker props for usage with normalized items list instead of React
46
+ * `children` elements.
47
+ */
48
+ export type PickerNormalizedPropsT<TProps> = Omit<PickerPropsT<TProps>, 'children'> & {
49
+ /**
50
+ * Normalized format for items and sections instead React elements.
51
+ */
52
+ normalizedItems: (NormalizedItem | NormalizedSection)[];
53
+ /**
54
+ * Whether to show icons in items.
55
+ */
56
+ showItemIcons: boolean;
57
+ /**
58
+ * Get the initial scroll position to use when picker is opened.
59
+ */
60
+ getInitialScrollPosition?: () => Promise<number | null | undefined>;
61
+ };
62
+ export type PickerProps = PickerPropsT<SpectrumPickerProps<NormalizedItem>>;
63
+ export type PickerNormalizedProps = PickerNormalizedPropsT<PickerProps>;
64
+ //# sourceMappingURL=PickerProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickerProps.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,cAAc,EACf,MAAM,UAAU,CAAC;AAElB;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,CAAC,MAAM,IAAI,IAAI,CACrC,MAAM,EAEJ,UAAU,GACV,mBAAmB,GACnB,aAAa,GACb,oBAAoB,GACpB,cAAc,GAId,cAAc,GACd,OAAO,CACV,GAAG;IACF,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;;;OAGG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAEjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAEzC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAEzC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAElC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,CAAC,MAAM,IAAI,IAAI,CAC/C,YAAY,CAAC,MAAM,CAAC,EACpB,UAAU,CACX,GAAG;IACF;;OAEG;IACH,eAAe,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAExD;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACrE,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC,CAAC;AAC5E,MAAM,MAAM,qBAAqB,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PickerProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickerProps.js","names":[],"sources":["../../../src/spectrum/picker/PickerProps.ts"],"sourcesContent":["import type { SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type {\n ItemKey,\n ItemOrSection,\n NormalizedItem,\n NormalizedSection,\n TooltipOptions,\n} from '../utils';\n\n/**\n * Extend Spectrum Picker props (also other components that adhere to the same\n * apis such as ComboBox).\n * - `children` is extended to include primitive types and to exclude render function\n * - `items` and `defaultItems` are excluded since we are not currently supporting\n * render functions as `children`\n * - selection key types are extended to include number + boolean primitive types\n * - remaining props from the original type are passed through\n */\nexport type PickerPropsT<TProps> = Omit<\n TProps,\n // These props are all re-defined below\n | 'children'\n | 'onSelectionChange'\n | 'selectedKey'\n | 'defaultSelectedKey'\n | 'disabledKeys'\n // Excluding `defaultItems` and `items` since we are not currently supporting\n // a render function as `children`. This simplifies the API for determining\n // initial scroll position and wrapping items with tooltips.\n | 'defaultItems'\n | 'items'\n> & {\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 * The item keys that are disabled. These items cannot be selected, focused,\n * or otherwise interacted with.\n */\n disabledKeys?: Iterable<ItemKey>;\n\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (key: ItemKey | null) => void;\n\n /**\n * Method that is called when the open state of the menu changes.\n */\n onOpenChange?: (isOpen: boolean) => 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 | null) => void;\n};\n\n/**\n * Extend Picker props for usage with normalized items list instead of React\n * `children` elements.\n */\nexport type PickerNormalizedPropsT<TProps> = Omit<\n PickerPropsT<TProps>,\n 'children'\n> & {\n /**\n * Normalized format for items and sections instead React elements.\n */\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n\n /**\n * Whether to show icons in items.\n */\n showItemIcons: boolean;\n\n /**\n * Get the initial scroll position to use when picker is opened.\n */\n getInitialScrollPosition?: () => Promise<number | null | undefined>;\n};\n\nexport type PickerProps = PickerPropsT<SpectrumPickerProps<NormalizedItem>>;\nexport type PickerNormalizedProps = PickerNormalizedPropsT<PickerProps>;\n"],"mappings":""}
@@ -1,4 +1,8 @@
1
1
  export * from './Picker';
2
2
  export * from './PickerNormalized';
3
+ export * from './PickerProps';
4
+ export * from './usePickerItemScale';
5
+ export * from './usePickerNormalizedProps';
6
+ export * from './usePickerProps';
3
7
  export * from './usePickerScrollOnOpen';
4
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
@@ -1,4 +1,8 @@
1
1
  export * from "./Picker.js";
2
2
  export * from "./PickerNormalized.js";
3
+ export * from "./PickerProps.js";
4
+ export * from "./usePickerItemScale.js";
5
+ export * from "./usePickerNormalizedProps.js";
6
+ export * from "./usePickerProps.js";
3
7
  export * from "./usePickerScrollOnOpen.js";
4
8
  //# 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 './PickerNormalized';\nexport * from './usePickerScrollOnOpen';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/picker/index.ts"],"sourcesContent":["export * from './Picker';\nexport * from './PickerNormalized';\nexport * from './PickerProps';\nexport * from './usePickerItemScale';\nexport * from './usePickerNormalizedProps';\nexport * from './usePickerProps';\nexport * from './usePickerScrollOnOpen';\n"],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get Picker Item height for current scale.
3
+ * @returns Picker Item height
4
+ */
5
+ export declare function usePickerItemScale(): {
6
+ itemHeight: number;
7
+ };
8
+ export default usePickerItemScale;
9
+ //# sourceMappingURL=usePickerItemScale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerItemScale.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerItemScale.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAK3D;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { PICKER_ITEM_HEIGHTS } from '@deephaven/utils';
2
+ import { useSpectrumThemeProvider } from "../../theme/index.js";
3
+ /**
4
+ * Get Picker Item height for current scale.
5
+ * @returns Picker Item height
6
+ */
7
+ export function usePickerItemScale() {
8
+ var {
9
+ scale
10
+ } = useSpectrumThemeProvider();
11
+ var itemHeight = PICKER_ITEM_HEIGHTS[scale];
12
+ return {
13
+ itemHeight
14
+ };
15
+ }
16
+ export default usePickerItemScale;
17
+ //# sourceMappingURL=usePickerItemScale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerItemScale.js","names":["PICKER_ITEM_HEIGHTS","useSpectrumThemeProvider","usePickerItemScale","scale","itemHeight"],"sources":["../../../src/spectrum/picker/usePickerItemScale.ts"],"sourcesContent":["import { PICKER_ITEM_HEIGHTS } from '@deephaven/utils';\nimport { useSpectrumThemeProvider } from '../../theme';\n\n/**\n * Get Picker Item height for current scale.\n * @returns Picker Item height\n */\nexport function usePickerItemScale(): { itemHeight: number } {\n const { scale } = useSpectrumThemeProvider();\n const itemHeight = PICKER_ITEM_HEIGHTS[scale];\n\n return { itemHeight };\n}\n\nexport default usePickerItemScale;\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,kBAAkB;AAAC,SAC9CC,wBAAwB;AAEjC;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAA,EAA2B;EAC3D,IAAM;IAAEC;EAAM,CAAC,GAAGF,wBAAwB,CAAC,CAAC;EAC5C,IAAMG,UAAU,GAAGJ,mBAAmB,CAACG,KAAK,CAAC;EAE7C,OAAO;IAAEC;EAAW,CAAC;AACvB;AAEA,eAAeF,kBAAkB"}
@@ -0,0 +1,27 @@
1
+ import { Key } from 'react';
2
+ import type { DOMRef } from '@react-types/shared';
3
+ import { NormalizedItem, NormalizedSection } from '../utils';
4
+ import { PickerNormalizedPropsT } from './PickerProps';
5
+ /** Props that are derived by `usePickerNormalizedProps` */
6
+ export type UsePickerNormalizedDerivedProps<THtml extends HTMLElement> = {
7
+ children: (itemOrSection: NormalizedItem | NormalizedSection) => JSX.Element;
8
+ forceRerenderKey: Key;
9
+ items: (NormalizedItem | NormalizedSection)[];
10
+ defaultSelectedKey?: Key;
11
+ disabledKeys?: Iterable<Key>;
12
+ ref: DOMRef<THtml>;
13
+ selectedKey?: Key | null;
14
+ onSelectionChange: (key: Key | null) => void;
15
+ onOpenChange: (isOpen: boolean) => void;
16
+ };
17
+ /**
18
+ * Props that are passed through untouched. (should exclude all of the
19
+ * destructured props passed into `usePickerNormalizedProps` that are not in the
20
+ * spread ...props)
21
+ */
22
+ export type UsePickerNormalizedPassthroughProps<TProps> = Omit<PickerNormalizedPropsT<TProps>, 'defaultSelectedKey' | 'disabledKeys' | 'getInitialScrollPosition' | 'normalizedItems' | 'onChange' | 'onOpenChange' | 'onScroll' | 'onSelectionChange' | 'selectedKey' | 'showItemIcons' | 'tooltip'>;
23
+ /** Props returned from `usePickerNormalizedProps` hook. */
24
+ export type UsePickerNormalizedProps<TProps, THtml extends HTMLElement> = UsePickerNormalizedDerivedProps<THtml> & UsePickerNormalizedPassthroughProps<TProps>;
25
+ export declare function usePickerNormalizedProps<TProps, THtml extends HTMLElement = HTMLElement>({ defaultSelectedKey, disabledKeys, getInitialScrollPosition, normalizedItems, onChange, onOpenChange, onScroll, onSelectionChange, selectedKey, showItemIcons, tooltip, ...props }: PickerNormalizedPropsT<TProps>): UsePickerNormalizedProps<TProps, THtml>;
26
+ export default usePickerNormalizedProps;
27
+ //# sourceMappingURL=usePickerNormalizedProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerNormalizedProps.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerNormalizedProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,M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,WAAW,GAAG,WAAW,EACvC,EACA,kBAAkB,EAClB,YAAY,EACZ,wBAAwB,EACxB,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,OAAc,EACd,GAAG,KAAK,EACT,EAAE,sBAAsB,CAAC,MAAM,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC,CA4E1E;AAED,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,101 @@
1
+ var _excluded = ["defaultSelectedKey", "disabledKeys", "getInitialScrollPosition", "normalizedItems", "onChange", "onOpenChange", "onScroll", "onSelectionChange", "selectedKey", "showItemIcons", "tooltip"];
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 { useCallback, useMemo } from 'react';
10
+ import { EMPTY_FUNCTION } from '@deephaven/utils';
11
+ import { getItemKey, isNormalizedSection, normalizeTooltipOptions, useRenderNormalizedItem, useStringifiedSelection } from "../utils/index.js";
12
+ import { usePickerScrollOnOpen } from "./usePickerScrollOnOpen.js";
13
+ import { Section } from "../shared.js";
14
+ /** Props that are derived by `usePickerNormalizedProps` */
15
+ /**
16
+ * Props that are passed through untouched. (should exclude all of the
17
+ * destructured props passed into `usePickerNormalizedProps` that are not in the
18
+ * spread ...props)
19
+ */
20
+ /** Props returned from `usePickerNormalizedProps` hook. */
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ export function usePickerNormalizedProps(_ref) {
23
+ var {
24
+ defaultSelectedKey,
25
+ disabledKeys,
26
+ getInitialScrollPosition,
27
+ normalizedItems,
28
+ onChange,
29
+ onOpenChange,
30
+ onScroll = EMPTY_FUNCTION,
31
+ onSelectionChange,
32
+ selectedKey,
33
+ showItemIcons,
34
+ tooltip = true
35
+ } = _ref,
36
+ props = _objectWithoutProperties(_ref, _excluded);
37
+ var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip), [tooltip]);
38
+ var renderNormalizedItem = useRenderNormalizedItem({
39
+ itemIconSlot: 'icon',
40
+ // Descriptions introduce variable item heights which throws off calculation
41
+ // of initial scroll position and setting viewport on windowed data. For now
42
+ // not going to implement description support in Picker.
43
+ // https://github.com/deephaven/web-client-ui/issues/1958
44
+ showItemDescriptions: false,
45
+ showItemIcons,
46
+ tooltipOptions
47
+ });
48
+
49
+ // Spectrum doesn't re-render if only the `renderNormalizedItems` function
50
+ // changes, so we create a key from its dependencies that can be used to force
51
+ // re-render.
52
+ var forceRerenderKey = "".concat(showItemIcons, "-").concat(tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.placement);
53
+ var {
54
+ ref,
55
+ onOpenChange: onOpenChangeInternal
56
+ } = usePickerScrollOnOpen({
57
+ getInitialScrollPosition,
58
+ onScroll,
59
+ onOpenChange
60
+ });
61
+
62
+ // Spectrum Picker treats keys as strings if the `key` prop is explicitly
63
+ // set on `Item` elements. Since we do this in `renderItem`, we need to
64
+ // map original key types to and from strings so that selection works.
65
+ var {
66
+ selectedStringKey,
67
+ defaultSelectedStringKey,
68
+ disabledStringKeys,
69
+ onStringSelectionChange
70
+ } = useStringifiedSelection({
71
+ normalizedItems,
72
+ selectedKey,
73
+ defaultSelectedKey,
74
+ disabledKeys,
75
+ onChange: onChange !== null && onChange !== void 0 ? onChange : onSelectionChange
76
+ });
77
+ var children = useCallback(itemOrSection => {
78
+ if (isNormalizedSection(itemOrSection)) {
79
+ var _itemOrSection$item, _itemOrSection$item2;
80
+ return /*#__PURE__*/_jsx(Section, {
81
+ title: (_itemOrSection$item = itemOrSection.item) === null || _itemOrSection$item === void 0 ? void 0 : _itemOrSection$item.title,
82
+ items: (_itemOrSection$item2 = itemOrSection.item) === null || _itemOrSection$item2 === void 0 ? void 0 : _itemOrSection$item2.items,
83
+ children: renderNormalizedItem
84
+ }, getItemKey(itemOrSection));
85
+ }
86
+ return renderNormalizedItem(itemOrSection);
87
+ }, [renderNormalizedItem]);
88
+ return _objectSpread(_objectSpread({}, props), {}, {
89
+ children,
90
+ forceRerenderKey,
91
+ ref,
92
+ items: normalizedItems,
93
+ selectedKey: selectedStringKey,
94
+ defaultSelectedKey: defaultSelectedStringKey,
95
+ disabledKeys: disabledStringKeys,
96
+ onSelectionChange: onStringSelectionChange,
97
+ onOpenChange: onOpenChangeInternal
98
+ });
99
+ }
100
+ export default usePickerNormalizedProps;
101
+ //# sourceMappingURL=usePickerNormalizedProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerNormalizedProps.js","names":["useCallback","useMemo","EMPTY_FUNCTION","getItemKey","isNormalizedSection","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedSelection","usePickerScrollOnOpen","Section","jsx","_jsx","usePickerNormalizedProps","_ref","defaultSelectedKey","disabledKeys","getInitialScrollPosition","normalizedItems","onChange","onOpenChange","onScroll","onSelectionChange","selectedKey","showItemIcons","tooltip","props","_objectWithoutProperties","_excluded","tooltipOptions","renderNormalizedItem","itemIconSlot","showItemDescriptions","forceRerenderKey","concat","placement","ref","onOpenChangeInternal","selectedStringKey","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","children","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title","item","items","_objectSpread"],"sources":["../../../src/spectrum/picker/usePickerNormalizedProps.tsx"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport type { DOMRef } from '@react-types/shared';\nimport {\n getItemKey,\n isNormalizedSection,\n NormalizedItem,\n NormalizedSection,\n normalizeTooltipOptions,\n useRenderNormalizedItem,\n useStringifiedSelection,\n} from '../utils';\nimport { PickerNormalizedPropsT } from './PickerProps';\nimport { usePickerScrollOnOpen } from './usePickerScrollOnOpen';\nimport { Section } from '../shared';\n\n/** Props that are derived by `usePickerNormalizedProps` */\nexport type UsePickerNormalizedDerivedProps<THtml extends HTMLElement> = {\n children: (itemOrSection: NormalizedItem | NormalizedSection) => JSX.Element;\n forceRerenderKey: Key;\n items: (NormalizedItem | NormalizedSection)[];\n defaultSelectedKey?: Key;\n disabledKeys?: Iterable<Key>;\n ref: DOMRef<THtml>;\n selectedKey?: Key | null;\n onSelectionChange: (key: Key | null) => void;\n onOpenChange: (isOpen: boolean) => void;\n};\n\n/**\n * Props that are passed through untouched. (should exclude all of the\n * destructured props passed into `usePickerNormalizedProps` that are not in the\n * spread ...props)\n */\nexport type UsePickerNormalizedPassthroughProps<TProps> = Omit<\n PickerNormalizedPropsT<TProps>,\n | 'defaultSelectedKey'\n | 'disabledKeys'\n | 'getInitialScrollPosition'\n | 'normalizedItems'\n | 'onChange'\n | 'onOpenChange'\n | 'onScroll'\n | 'onSelectionChange'\n | 'selectedKey'\n | 'showItemIcons'\n | 'tooltip'\n>;\n\n/** Props returned from `usePickerNormalizedProps` hook. */\nexport type UsePickerNormalizedProps<\n TProps,\n THtml extends HTMLElement,\n> = UsePickerNormalizedDerivedProps<THtml> &\n UsePickerNormalizedPassthroughProps<TProps>;\n\nexport function usePickerNormalizedProps<\n TProps,\n THtml extends HTMLElement = HTMLElement,\n>({\n defaultSelectedKey,\n disabledKeys,\n getInitialScrollPosition,\n normalizedItems,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n selectedKey,\n showItemIcons,\n tooltip = true,\n ...props\n}: PickerNormalizedPropsT<TProps>): UsePickerNormalizedProps<TProps, THtml> {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem({\n itemIconSlot: 'icon',\n // Descriptions introduce variable item heights which throws off calculation\n // of initial scroll position and setting viewport on windowed data. For now\n // not going to implement description support in Picker.\n // https://github.com/deephaven/web-client-ui/issues/1958\n showItemDescriptions: false,\n showItemIcons,\n tooltipOptions,\n });\n\n // Spectrum doesn't re-render if only the `renderNormalizedItems` function\n // changes, so we create a key from its dependencies that can be used to force\n // re-render.\n const forceRerenderKey = `${showItemIcons}-${tooltipOptions?.placement}`;\n\n const { ref, onOpenChange: onOpenChangeInternal } =\n usePickerScrollOnOpen<THtml>({\n getInitialScrollPosition,\n onScroll,\n onOpenChange,\n });\n\n // Spectrum Picker treats keys as strings if the `key` prop is explicitly\n // set on `Item` elements. Since we do this in `renderItem`, we need to\n // map original key types to and from strings so that selection works.\n const {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedSelection({\n normalizedItems,\n selectedKey,\n defaultSelectedKey,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n const children = useCallback(\n (itemOrSection: NormalizedItem | NormalizedSection) => {\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 [renderNormalizedItem]\n );\n\n return {\n ...props,\n children,\n forceRerenderKey,\n ref,\n items: normalizedItems,\n selectedKey: selectedStringKey,\n defaultSelectedKey: defaultSelectedStringKey,\n disabledKeys: disabledStringKeys,\n onSelectionChange: onStringSelectionChange,\n onOpenChange: onOpenChangeInternal,\n };\n}\n\nexport default usePickerNormalizedProps;\n"],"mappings":";;;;;;;;AAAA,SAAcA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACjD,SAASC,cAAc,QAAQ,kBAAkB;AAAC,SAGhDC,UAAU,EACVC,mBAAmB,EAGnBC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB;AAAA,SAGhBC,qBAAqB;AAAA,SACrBC,OAAO;AAEhB;AAaA;AACA;AACA;AACA;AACA;AAgBA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOA,OAAO,SAASC,wBAAwBA,CAAAC,IAAA,EAgBoC;EAAA,IAb1E;MACAC,kBAAkB;MAClBC,YAAY;MACZC,wBAAwB;MACxBC,eAAe;MACfC,QAAQ;MACRC,YAAY;MACZC,QAAQ,GAAGlB,cAAc;MACzBmB,iBAAiB;MACjBC,WAAW;MACXC,aAAa;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,oBAAA,CAAoBG,KAAM;QAAAN,QAAA,EAEhCZ;MAAoB,GAJhB1B,UAAU,CAACuC,aAAa,CAKtB,CAAC;IAEd;IAEA,OAAOb,oBAAoB,CAACa,aAAa,CAAC;EAC5C,CAAC,EACD,CAACb,oBAAoB,CACvB,CAAC;EAED,OAAAmB,aAAA,CAAAA,aAAA,KACKvB,KAAK;IACRgB,QAAQ;IACRT,gBAAgB;IAChBG,GAAG;IACHY,KAAK,EAAE9B,eAAe;IACtBK,WAAW,EAAEe,iBAAiB;IAC9BvB,kBAAkB,EAAEwB,wBAAwB;IAC5CvB,YAAY,EAAEwB,kBAAkB;IAChClB,iBAAiB,EAAEmB,uBAAuB;IAC1CrB,YAAY,EAAEiB;EAAoB;AAEtC;AAEA,eAAexB,wBAAwB"}
@@ -0,0 +1,28 @@
1
+ import { DOMRef } from '@react-types/shared';
2
+ import { ItemKey, SectionElement, ItemElement } from '../utils';
3
+ import type { PickerPropsT } from './PickerProps';
4
+ /** Props that are derived by `usePickerProps`. */
5
+ export type UsePickerDerivedProps<THtml extends HTMLElement> = {
6
+ children: (SectionElement<unknown> | ItemElement<unknown>)[];
7
+ defaultSelectedKey?: ItemKey | undefined;
8
+ ref: DOMRef<THtml>;
9
+ selectedKey?: ItemKey | null | undefined;
10
+ onOpenChange: (isOpen: boolean) => void;
11
+ onSelectionChange: ((key: ItemKey | null) => void) | undefined;
12
+ };
13
+ /**
14
+ * Props that are passed through untouched. (should exclude all of the
15
+ * destructured props passed into `usePickerProps` that are not in the spread
16
+ * ...props)
17
+ ) */
18
+ export type UsePickerPassthroughProps<TProps> = Omit<PickerPropsT<TProps>, 'children' | 'defaultSelectedKey' | 'selectedKey' | 'tooltip' | 'onChange' | 'onOpenChange' | 'onScroll' | 'onSelectionChange'>;
19
+ /** Props returned from `usePickerProps` hook. */
20
+ export type UsePickerProps<TProps, THtml extends HTMLElement> = UsePickerDerivedProps<THtml> & UsePickerPassthroughProps<TProps>;
21
+ /**
22
+ * Derive props for Picker components (e.g. Picker and ComboBox). Specifically
23
+ * handles wrapping children items and initial scroll position when the picker
24
+ * is opened.
25
+ */
26
+ export declare function usePickerProps<TProps, THtml extends HTMLElement = HTMLElement>({ children, defaultSelectedKey, selectedKey, tooltip, onChange: onChangeHandler, onOpenChange: onOpenChangeHandler, onScroll, onSelectionChange: onSelectionChangeHandler, ...props }: PickerPropsT<TProps>): UsePickerProps<TProps, THtml>;
27
+ export default usePickerProps;
28
+ //# sourceMappingURL=usePickerProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerProps.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerProps.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAKL,OAAO,EACP,cAAc,EACd,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,kDAAkD;AAClD,MAAM,MAAM,qBAAqB,CAAC,KAAK,SAAS,WAAW,IAAI;IAC7D,QAAQ,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IAC7D,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,iBAAiB,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAChE,CAAC;AAEF;;;;IAII;AACJ,MAAM,MAAM,yBAAyB,CAAC,MAAM,IAAI,IAAI,CAClD,YAAY,CAAC,MAAM,CAAC,EAClB,UAAU,GACV,oBAAoB,GACpB,aAAa,GACb,SAAS,GACT,UAAU,GACV,cAAc,GACd,UAAU,GACV,mBAAmB,CACtB,CAAC;AAEF,iDAAiD;AACjD,MAAM,MAAM,cAAc,CACxB,MAAM,EACN,KAAK,SAAS,WAAW,IACvB,qBAAqB,CAAC,KAAK,CAAC,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAErE;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EACN,KAAK,SAAS,WAAW,GAAG,WAAW,EACvC,EACA,QAAQ,EACR,kBAAkB,EAClB,WAAW,EACX,OAAc,EACd,QAAQ,EAAE,eAAe,EACzB,YAAY,EAAE,mBAAmB,EACjC,QAAyB,EACzB,iBAAiB,EAAE,wBAAwB,EAC3C,GAAG,KAAK,EACT,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CA0CtD;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,75 @@
1
+ var _excluded = ["children", "defaultSelectedKey", "selectedKey", "tooltip", "onChange", "onOpenChange", "onScroll", "onSelectionChange"];
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
9
+ import { EMPTY_FUNCTION, ensureArray, PICKER_TOP_OFFSET } from '@deephaven/utils';
10
+ import { useMemo } from 'react';
11
+ import { normalizeTooltipOptions, wrapItemChildren, useOnChangeTrackUncontrolled, useStaticItemInitialScrollPosition } from "../utils/index.js";
12
+ import usePickerItemScale from "./usePickerItemScale.js";
13
+ import usePickerScrollOnOpen from "./usePickerScrollOnOpen.js";
14
+ /** Props that are derived by `usePickerProps`. */
15
+ /**
16
+ * Props that are passed through untouched. (should exclude all of the
17
+ * destructured props passed into `usePickerProps` that are not in the spread
18
+ * ...props)
19
+ ) */
20
+ /** Props returned from `usePickerProps` hook. */
21
+ /**
22
+ * Derive props for Picker components (e.g. Picker and ComboBox). Specifically
23
+ * handles wrapping children items and initial scroll position when the picker
24
+ * is opened.
25
+ */
26
+ export function usePickerProps(_ref) {
27
+ var {
28
+ children,
29
+ defaultSelectedKey,
30
+ selectedKey,
31
+ tooltip = true,
32
+ onChange: onChangeHandler,
33
+ onOpenChange: onOpenChangeHandler,
34
+ onScroll = EMPTY_FUNCTION,
35
+ onSelectionChange: onSelectionChangeHandler
36
+ } = _ref,
37
+ props = _objectWithoutProperties(_ref, _excluded);
38
+ var {
39
+ itemHeight
40
+ } = usePickerItemScale();
41
+ var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip), [tooltip]);
42
+ var items = useMemo(() => ensureArray(wrapItemChildren(children, tooltipOptions)), [children, tooltipOptions]);
43
+ var {
44
+ selectedKeyMaybeUncontrolled,
45
+ onChangeMaybeUncontrolled
46
+ } = useOnChangeTrackUncontrolled({
47
+ defaultSelectedKey,
48
+ selectedKey,
49
+ onChange: onChangeHandler !== null && onChangeHandler !== void 0 ? onChangeHandler : onSelectionChangeHandler
50
+ });
51
+ var getInitialScrollPosition = useStaticItemInitialScrollPosition({
52
+ itemHeight,
53
+ items,
54
+ selectedKey: selectedKeyMaybeUncontrolled,
55
+ topOffset: PICKER_TOP_OFFSET
56
+ });
57
+ var {
58
+ ref,
59
+ onOpenChange
60
+ } = usePickerScrollOnOpen({
61
+ getInitialScrollPosition,
62
+ onScroll,
63
+ onOpenChange: onOpenChangeHandler
64
+ });
65
+ return _objectSpread(_objectSpread({}, props), {}, {
66
+ defaultSelectedKey,
67
+ ref,
68
+ selectedKey,
69
+ children: items,
70
+ onOpenChange,
71
+ onSelectionChange: onChangeMaybeUncontrolled
72
+ });
73
+ }
74
+ export default usePickerProps;
75
+ //# sourceMappingURL=usePickerProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerProps.js","names":["EMPTY_FUNCTION","ensureArray","PICKER_TOP_OFFSET","useMemo","normalizeTooltipOptions","wrapItemChildren","useOnChangeTrackUncontrolled","useStaticItemInitialScrollPosition","usePickerItemScale","usePickerScrollOnOpen","usePickerProps","_ref","children","defaultSelectedKey","selectedKey","tooltip","onChange","onChangeHandler","onOpenChange","onOpenChangeHandler","onScroll","onSelectionChange","onSelectionChangeHandler","props","_objectWithoutProperties","_excluded","itemHeight","tooltipOptions","items","selectedKeyMaybeUncontrolled","onChangeMaybeUncontrolled","getInitialScrollPosition","topOffset","ref","_objectSpread"],"sources":["../../../src/spectrum/picker/usePickerProps.ts"],"sourcesContent":["import {\n EMPTY_FUNCTION,\n ensureArray,\n PICKER_TOP_OFFSET,\n} from '@deephaven/utils';\nimport { DOMRef } from '@react-types/shared';\nimport { useMemo } from 'react';\nimport {\n normalizeTooltipOptions,\n wrapItemChildren,\n useOnChangeTrackUncontrolled,\n useStaticItemInitialScrollPosition,\n ItemKey,\n SectionElement,\n ItemElement,\n} from '../utils';\nimport type { PickerPropsT } from './PickerProps';\nimport usePickerItemScale from './usePickerItemScale';\nimport usePickerScrollOnOpen from './usePickerScrollOnOpen';\n\n/** Props that are derived by `usePickerProps`. */\nexport type UsePickerDerivedProps<THtml extends HTMLElement> = {\n children: (SectionElement<unknown> | ItemElement<unknown>)[];\n defaultSelectedKey?: ItemKey | undefined;\n ref: DOMRef<THtml>;\n selectedKey?: ItemKey | null | undefined;\n onOpenChange: (isOpen: boolean) => void;\n onSelectionChange: ((key: ItemKey | null) => void) | undefined;\n};\n\n/** \n * Props that are passed through untouched. (should exclude all of the\n * destructured props passed into `usePickerProps` that are not in the spread\n * ...props)\n) */\nexport type UsePickerPassthroughProps<TProps> = Omit<\n PickerPropsT<TProps>,\n | 'children'\n | 'defaultSelectedKey'\n | 'selectedKey'\n | 'tooltip'\n | 'onChange'\n | 'onOpenChange'\n | 'onScroll'\n | 'onSelectionChange'\n>;\n\n/** Props returned from `usePickerProps` hook. */\nexport type UsePickerProps<\n TProps,\n THtml extends HTMLElement,\n> = UsePickerDerivedProps<THtml> & UsePickerPassthroughProps<TProps>;\n\n/**\n * Derive props for Picker components (e.g. Picker and ComboBox). Specifically\n * handles wrapping children items and initial scroll position when the picker\n * is opened.\n */\nexport function usePickerProps<\n TProps,\n THtml extends HTMLElement = HTMLElement,\n>({\n children,\n defaultSelectedKey,\n selectedKey,\n tooltip = true,\n onChange: onChangeHandler,\n onOpenChange: onOpenChangeHandler,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange: onSelectionChangeHandler,\n ...props\n}: PickerPropsT<TProps>): UsePickerProps<TProps, THtml> {\n const { itemHeight } = usePickerItemScale();\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const items = useMemo(\n () => ensureArray(wrapItemChildren(children, tooltipOptions)),\n [children, tooltipOptions]\n );\n\n const { selectedKeyMaybeUncontrolled, onChangeMaybeUncontrolled } =\n useOnChangeTrackUncontrolled({\n defaultSelectedKey,\n selectedKey,\n onChange: onChangeHandler ?? onSelectionChangeHandler,\n });\n\n const getInitialScrollPosition = useStaticItemInitialScrollPosition({\n itemHeight,\n items,\n selectedKey: selectedKeyMaybeUncontrolled,\n topOffset: PICKER_TOP_OFFSET,\n });\n\n const { ref, onOpenChange } = usePickerScrollOnOpen<THtml>({\n getInitialScrollPosition,\n onScroll,\n onOpenChange: onOpenChangeHandler,\n });\n\n return {\n ...props,\n defaultSelectedKey,\n ref,\n selectedKey,\n children: items,\n onOpenChange,\n onSelectionChange: onChangeMaybeUncontrolled,\n };\n}\n\nexport default usePickerProps;\n"],"mappings":";;;;;;;;AAAA,SACEA,cAAc,EACdC,WAAW,EACXC,iBAAiB,QACZ,kBAAkB;AAEzB,SAASC,OAAO,QAAQ,OAAO;AAAC,SAE9BC,uBAAuB,EACvBC,gBAAgB,EAChBC,4BAA4B,EAC5BC,kCAAkC;AAAA,OAM7BC,kBAAkB;AAAA,OAClBC,qBAAqB;AAE5B;AAUA;AACA;AACA;AACA;AACA;AAaA;AAMA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAAC,IAAA,EAa0B;EAAA,IAVtD;MACAC,QAAQ;MACRC,kBAAkB;MAClBC,WAAW;MACXC,OAAO,GAAG,IAAI;MACdC,QAAQ,EAAEC,eAAe;MACzB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