@deephaven/components 0.82.0 → 0.82.1-alpha-combobox.15
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.
- package/dist/SearchableCombobox.d.ts +2 -2
- package/dist/SearchableCombobox.d.ts.map +1 -1
- package/dist/SearchableCombobox.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/spectrum/View.d.ts +17 -3
- package/dist/spectrum/View.d.ts.map +1 -1
- package/dist/spectrum/View.js +42 -7
- package/dist/spectrum/View.js.map +1 -1
- package/dist/spectrum/collections.d.ts +1 -1
- package/dist/spectrum/collections.d.ts.map +1 -1
- package/dist/spectrum/collections.js +10 -3
- package/dist/spectrum/collections.js.map +1 -1
- package/dist/spectrum/comboBox/ComboBox.d.ts +7 -0
- package/dist/spectrum/comboBox/ComboBox.d.ts.map +1 -0
- package/dist/spectrum/comboBox/ComboBox.js +41 -0
- package/dist/spectrum/comboBox/ComboBox.js.map +1 -0
- package/dist/spectrum/comboBox/ComboBoxNormalized.d.ts +15 -0
- package/dist/spectrum/comboBox/ComboBoxNormalized.d.ts.map +1 -0
- package/dist/spectrum/comboBox/ComboBoxNormalized.js +42 -0
- package/dist/spectrum/comboBox/ComboBoxNormalized.js.map +1 -0
- package/dist/spectrum/comboBox/index.d.ts +3 -0
- package/dist/spectrum/comboBox/index.d.ts.map +1 -0
- package/dist/spectrum/comboBox/index.js +3 -0
- package/dist/spectrum/comboBox/index.js.map +1 -0
- package/dist/spectrum/index.d.ts +1 -1
- package/dist/spectrum/index.d.ts.map +1 -1
- package/dist/spectrum/index.js +1 -1
- package/dist/spectrum/index.js.map +1 -1
- package/dist/spectrum/listView/ListViewWrapper.js.map +1 -1
- package/dist/spectrum/picker/Picker.d.ts +2 -25
- package/dist/spectrum/picker/Picker.d.ts.map +1 -1
- package/dist/spectrum/picker/Picker.js +20 -68
- package/dist/spectrum/picker/Picker.js.map +1 -1
- package/dist/spectrum/picker/PickerNormalized.d.ts +2 -9
- package/dist/spectrum/picker/PickerNormalized.d.ts.map +1 -1
- package/dist/spectrum/picker/PickerNormalized.js +13 -80
- package/dist/spectrum/picker/PickerNormalized.js.map +1 -1
- package/dist/spectrum/picker/PickerProps.d.ts +64 -0
- package/dist/spectrum/picker/PickerProps.d.ts.map +1 -0
- package/dist/spectrum/picker/PickerProps.js +2 -0
- package/dist/spectrum/picker/PickerProps.js.map +1 -0
- package/dist/spectrum/picker/index.d.ts +4 -0
- package/dist/spectrum/picker/index.d.ts.map +1 -1
- package/dist/spectrum/picker/index.js +4 -0
- package/dist/spectrum/picker/index.js.map +1 -1
- package/dist/spectrum/picker/usePickerItemScale.d.ts +9 -0
- package/dist/spectrum/picker/usePickerItemScale.d.ts.map +1 -0
- package/dist/spectrum/picker/usePickerItemScale.js +17 -0
- package/dist/spectrum/picker/usePickerItemScale.js.map +1 -0
- package/dist/spectrum/picker/usePickerNormalizedProps.d.ts +27 -0
- package/dist/spectrum/picker/usePickerNormalizedProps.d.ts.map +1 -0
- package/dist/spectrum/picker/usePickerNormalizedProps.js +101 -0
- package/dist/spectrum/picker/usePickerNormalizedProps.js.map +1 -0
- package/dist/spectrum/picker/usePickerProps.d.ts +28 -0
- package/dist/spectrum/picker/usePickerProps.d.ts.map +1 -0
- package/dist/spectrum/picker/usePickerProps.js +75 -0
- package/dist/spectrum/picker/usePickerProps.js.map +1 -0
- package/dist/spectrum/picker/usePickerScrollOnOpen.d.ts +3 -3
- package/dist/spectrum/picker/usePickerScrollOnOpen.d.ts.map +1 -1
- package/dist/spectrum/picker/usePickerScrollOnOpen.js.map +1 -1
- package/dist/spectrum/utils/index.d.ts +2 -0
- package/dist/spectrum/utils/index.d.ts.map +1 -1
- package/dist/spectrum/utils/index.js +2 -0
- package/dist/spectrum/utils/index.js.map +1 -1
- package/dist/spectrum/utils/itemUtils.d.ts +7 -2
- package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
- package/dist/spectrum/utils/itemUtils.js +13 -0
- package/dist/spectrum/utils/itemUtils.js.map +1 -1
- package/dist/spectrum/utils/itemWrapperUtils.d.ts.map +1 -1
- package/dist/spectrum/utils/itemWrapperUtils.js +2 -2
- package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -1
- package/dist/spectrum/utils/useOnChangeTrackUncontrolled.d.ts +19 -0
- package/dist/spectrum/utils/useOnChangeTrackUncontrolled.d.ts.map +1 -0
- package/dist/spectrum/utils/useOnChangeTrackUncontrolled.js +31 -0
- package/dist/spectrum/utils/useOnChangeTrackUncontrolled.js.map +1 -0
- package/dist/spectrum/utils/useStaticItemInitialScrollPosition.d.ts +10 -0
- package/dist/spectrum/utils/useStaticItemInitialScrollPosition.d.ts.map +1 -0
- package/dist/spectrum/utils/useStaticItemInitialScrollPosition.js +27 -0
- package/dist/spectrum/utils/useStaticItemInitialScrollPosition.js.map +1 -0
- package/dist/spectrum/utils/useStringifiedSelection.d.ts +2 -2
- package/dist/spectrum/utils/useStringifiedSelection.d.ts.map +1 -1
- package/dist/spectrum/utils/useStringifiedSelection.js.map +1 -1
- package/package.json +7 -7
- package/dist/ComboBox.d.ts +0 -120
- package/dist/ComboBox.d.ts.map +0 -1
- package/dist/ComboBox.js +0 -497
- package/dist/ComboBox.js.map +0 -1
- package/dist/spectrum/pickers.d.ts +0 -2
- package/dist/spectrum/pickers.d.ts.map +0 -1
- package/dist/spectrum/pickers.js +0 -2
- package/dist/spectrum/pickers.js.map +0 -1
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
var _excluded = ["
|
|
1
|
+
var _excluded = ["UNSAFE_className"],
|
|
2
|
+
_excluded2 = ["defaultSelectedKey", "disabledKeys", "selectedKey"];
|
|
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; }
|
|
5
6
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
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
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
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; }
|
|
10
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; }
|
|
11
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
12
10
|
import { Picker as SpectrumPicker } from '@adobe/react-spectrum';
|
|
13
11
|
import cl from 'classnames';
|
|
14
|
-
import {
|
|
15
|
-
import { getPositionOfSelectedItemElement, normalizeTooltipOptions, isItemElementWithDescription, isSectionElement } from "../utils/itemUtils.js";
|
|
16
|
-
import { wrapItemChildren } from "../utils/itemWrapperUtils.js";
|
|
17
|
-
import usePickerScrollOnOpen from "./usePickerScrollOnOpen.js";
|
|
18
|
-
import { useSpectrumThemeProvider } from "../../theme/index.js";
|
|
19
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { usePickerProps } from "./usePickerProps.js";
|
|
20
13
|
/**
|
|
21
14
|
* Picker component for selecting items from a list of items. Items can be
|
|
22
15
|
* provided via the `children` prop. Each item can be a string, number, boolean,
|
|
@@ -24,71 +17,30 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
17
|
* for the Spectrum Picker component.
|
|
25
18
|
* See https://react-spectrum.adobe.com/react-spectrum/Picker.html
|
|
26
19
|
*/
|
|
20
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
21
|
export function Picker(_ref) {
|
|
28
22
|
var {
|
|
29
|
-
children,
|
|
30
|
-
tooltip = true,
|
|
31
|
-
defaultSelectedKey,
|
|
32
|
-
selectedKey,
|
|
33
|
-
onChange,
|
|
34
|
-
onOpenChange,
|
|
35
|
-
onScroll = EMPTY_FUNCTION,
|
|
36
|
-
onSelectionChange,
|
|
37
|
-
// eslint-disable-next-line camelcase
|
|
38
23
|
UNSAFE_className
|
|
39
24
|
} = _ref,
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// for explicit `undefined` to identify uncontrolled mode.
|
|
49
|
-
var isUncontrolled = selectedKey === undefined;
|
|
50
|
-
var [uncontrolledSelectedKey, setUncontrolledSelectedKey] = useState(defaultSelectedKey);
|
|
51
|
-
var wrappedItems = useMemo(() => ensureArray(wrapItemChildren(children, tooltipOptions)), [children, tooltipOptions]);
|
|
52
|
-
|
|
53
|
-
// Item descriptions and Section elements introduce variable item heights.
|
|
54
|
-
// This throws off scroll position calculations, so we disable auto scrolling
|
|
55
|
-
// if either of these are found.
|
|
56
|
-
var disableScrollOnOpen = useMemo(() => wrappedItems.some(item => isSectionElement(item) || isItemElementWithDescription(item)), [wrappedItems]);
|
|
57
|
-
var getInitialScrollPosition = useCallback( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
58
|
-
return disableScrollOnOpen ? null : getPositionOfSelectedItemElement({
|
|
59
|
-
items: wrappedItems,
|
|
60
|
-
itemHeight,
|
|
61
|
-
selectedKey: isUncontrolled ? uncontrolledSelectedKey : selectedKey,
|
|
62
|
-
topOffset: PICKER_TOP_OFFSET
|
|
63
|
-
});
|
|
64
|
-
}), [disableScrollOnOpen, isUncontrolled, itemHeight, selectedKey, uncontrolledSelectedKey, wrappedItems]);
|
|
65
|
-
var onSelectionChangeInternal = useCallback(key => {
|
|
66
|
-
var _ref3;
|
|
67
|
-
// If our component is uncontrolled, track the selected key internally
|
|
68
|
-
// so that we can scroll to the selected item if the user re-opens
|
|
69
|
-
if (isUncontrolled) {
|
|
70
|
-
setUncontrolledSelectedKey(key);
|
|
71
|
-
}
|
|
72
|
-
(_ref3 = onChange !== null && onChange !== void 0 ? onChange : onSelectionChange) === null || _ref3 === void 0 ? void 0 : _ref3(key);
|
|
73
|
-
}, [isUncontrolled, onChange, onSelectionChange]);
|
|
74
|
-
var {
|
|
75
|
-
ref: scrollRef,
|
|
76
|
-
onOpenChange: onOpenChangeInternal
|
|
77
|
-
} = usePickerScrollOnOpen({
|
|
78
|
-
getInitialScrollPosition,
|
|
79
|
-
onScroll,
|
|
80
|
-
onOpenChange
|
|
81
|
-
});
|
|
25
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
var _usePickerProps = usePickerProps(props),
|
|
27
|
+
{
|
|
28
|
+
defaultSelectedKey,
|
|
29
|
+
disabledKeys,
|
|
30
|
+
selectedKey
|
|
31
|
+
} = _usePickerProps,
|
|
32
|
+
pickerProps = _objectWithoutProperties(_usePickerProps, _excluded2);
|
|
82
33
|
return /*#__PURE__*/_jsx(SpectrumPicker
|
|
83
34
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
84
|
-
, _objectSpread(_objectSpread({},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
35
|
+
, _objectSpread(_objectSpread({}, pickerProps), {}, {
|
|
36
|
+
UNSAFE_className: cl('dh-picker', UNSAFE_className)
|
|
37
|
+
// Type assertions are necessary here since Spectrum types don't account
|
|
38
|
+
// for number and boolean key values even though they are valid runtime
|
|
39
|
+
// values.
|
|
40
|
+
,
|
|
88
41
|
defaultSelectedKey: defaultSelectedKey,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
children: wrappedItems
|
|
42
|
+
disabledKeys: disabledKeys,
|
|
43
|
+
selectedKey: selectedKey
|
|
92
44
|
}));
|
|
93
45
|
}
|
|
94
46
|
export default Picker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.js","names":["
|
|
1
|
+
{"version":3,"file":"Picker.js","names":["Picker","SpectrumPicker","cl","usePickerProps","jsx","_jsx","_ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerProps","defaultSelectedKey","disabledKeys","selectedKey","pickerProps","_excluded2","_objectSpread"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import {\n Picker as SpectrumPicker,\n SpectrumPickerProps,\n} from '@adobe/react-spectrum';\nimport cl from 'classnames';\nimport type { NormalizedItem } from '../utils';\nimport type { PickerProps } from './PickerProps';\nimport { usePickerProps } from './usePickerProps';\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 UNSAFE_className,\n ...props\n}: PickerProps): JSX.Element {\n const { defaultSelectedKey, disabledKeys, selectedKey, ...pickerProps } =\n usePickerProps<PickerProps, HTMLDivElement>(props);\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...pickerProps}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n // Type assertions are necessary here since Spectrum types don't account\n // for number and boolean key values even though they are valid runtime\n // values.\n defaultSelectedKey={\n defaultSelectedKey as SpectrumPickerProps<NormalizedItem>['defaultSelectedKey']\n }\n disabledKeys={\n disabledKeys as SpectrumPickerProps<NormalizedItem>['disabledKeys']\n }\n selectedKey={\n selectedKey as SpectrumPickerProps<NormalizedItem>['selectedKey']\n }\n />\n );\n}\n\nexport default Picker;\n"],"mappings":";;;;;;;;;AAAA,SACEA,MAAM,IAAIC,cAAc,QAEnB,uBAAuB;AAC9B,OAAOC,EAAE,MAAM,YAAY;AAAC,SAGnBC,cAAc;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AANA,SAAAC,GAAA,IAAAC,IAAA;AAOA,OAAO,SAASL,MAAMA,CAAAM,IAAA,EAGO;EAAA,IAHN;MACrBC;IAEW,CAAC,GAAAD,IAAA;IADTE,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAER,IAAAC,eAAA,GACER,cAAc,CAA8BK,KAAK,CAAC;IAD9C;MAAEI,kBAAkB;MAAEC,YAAY;MAAEC;IAA4B,CAAC,GAAAH,eAAA;IAAbI,WAAW,GAAAN,wBAAA,CAAAE,eAAA,EAAAK,UAAA;EAGrE,oBACEX,IAAA,CAACJ;EACC;EAAA,EAAAgB,aAAA,CAAAA,aAAA,KACIF,WAAW;IACfR,gBAAgB,EAAEL,EAAE,CAAC,WAAW,EAAEK,gBAAgB;IAClD;IACA;IACA;IAAA;IACAK,kBAAkB,EAChBA,kBACD;IACDC,YAAY,EACVA,YACD;IACDC,WAAW,EACTA;EACD,EACF,CAAC;AAEN;AAEA,eAAed,MAAM"}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
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({
|
|
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":";
|
|
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 = ["
|
|
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
|
|
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
|
-
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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({},
|
|
31
|
+
, _objectSpread(_objectSpread({}, pickerProps), {}, {
|
|
82
32
|
key: forceRerenderKey,
|
|
83
|
-
|
|
84
|
-
|
|
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":["
|
|
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 @@
|
|
|
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 @@
|
|
|
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,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAGL,cAAc,EACd,iBAAiB,EAIlB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAIvD,2DAA2D;AAC3D,MAAM,MAAM,+BAA+B,CAAC,KAAK,SAAS,WAAW,IAAI;IACvE,QAAQ,EAAE,CAAC,aAAa,EAAE,cAAc,GAAG,iBAAiB,KAAK,GAAG,CAAC,OAAO,CAAC;IAC7E,gBAAgB,EAAE,GAAG,CAAC;IACtB,KAAK,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAC9C,kBAAkB,CAAC,EAAE,GAAG,CAAC;IACzB,YAAY,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACnB,WAAW,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IACzB,iBAAiB,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7C,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mCAAmC,CAAC,MAAM,IAAI,IAAI,CAC5D,sBAAsB,CAAC,MAAM,CAAC,EAC5B,oBAAoB,GACpB,cAAc,GACd,0BAA0B,GAC1B,iBAAiB,GACjB,UAAU,GACV,cAAc,GACd,UAAU,GACV,mBAAmB,GACnB,aAAa,GACb,eAAe,GACf,SAAS,CACZ,CAAC;AAEF,2DAA2D;AAC3D,MAAM,MAAM,wBAAwB,CAClC,MAAM,EACN,KAAK,SAAS,WAAW,IACvB,+BAA+B,CAAC,KAAK,CAAC,GACxC,mCAAmC,CAAC,MAAM,CAAC,CAAC;AAE9C,wBAAgB,wBAAwB,CACtC,MAAM,EACN,KAAK,SAAS,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"}
|