@deephaven/components 0.82.1-beta.5 → 0.82.1-beta.7
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/spectrum/comboBox/ComboBox.js +5 -5
- package/dist/spectrum/comboBox/ComboBox.js.map +1 -1
- 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 +1 -0
- package/dist/spectrum/comboBox/index.d.ts.map +1 -1
- package/dist/spectrum/comboBox/index.js +1 -0
- package/dist/spectrum/comboBox/index.js.map +1 -1
- package/dist/spectrum/listView/ListViewWrapper.js.map +1 -1
- package/dist/spectrum/picker/Picker.d.ts.map +1 -1
- package/dist/spectrum/picker/Picker.js +2 -4
- package/dist/spectrum/picker/Picker.js.map +1 -1
- package/dist/spectrum/picker/PickerNormalized.d.ts +1 -1
- package/dist/spectrum/picker/PickerNormalized.d.ts.map +1 -1
- package/dist/spectrum/picker/PickerNormalized.js +12 -79
- package/dist/spectrum/picker/PickerNormalized.js.map +1 -1
- package/dist/spectrum/picker/index.d.ts +1 -0
- package/dist/spectrum/picker/index.d.ts.map +1 -1
- package/dist/spectrum/picker/index.js +1 -0
- package/dist/spectrum/picker/index.js.map +1 -1
- 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 +11 -6
- package/dist/spectrum/picker/usePickerProps.d.ts.map +1 -1
- package/dist/spectrum/picker/usePickerProps.js +9 -4
- package/dist/spectrum/picker/usePickerProps.js.map +1 -1
- 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/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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Key } from 'react';
|
|
2
2
|
import { SpectrumComboBoxProps } from '@adobe/react-spectrum';
|
|
3
|
-
import type {
|
|
3
|
+
import type { DOMRefValue } from '@react-types/shared';
|
|
4
4
|
export interface SearchableComboboxProps<TItem, TKey extends Key> extends Omit<SpectrumComboBoxProps<TItem>, 'children' | 'menuTrigger' | 'onSelectionChange'> {
|
|
5
5
|
getItemDisplayText: (item: TItem | null | undefined) => string | null;
|
|
6
6
|
getKey: (item: TItem | null | undefined) => TKey | null;
|
|
7
|
-
scrollRef: React.RefObject<
|
|
7
|
+
scrollRef: React.RefObject<DOMRefValue>;
|
|
8
8
|
onSelectionChange: (key: TKey | null) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare function SearchableCombobox<TItem, TKey extends Key>({ scrollRef, getItemDisplayText, getKey, ...props }: SearchableComboboxProps<TItem, TKey>): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchableCombobox.d.ts","sourceRoot":"","sources":["../src/SearchableCombobox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAe,MAAM,OAAO,CAAC;AACzC,OAAO,EAAkB,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchableCombobox.d.ts","sourceRoot":"","sources":["../src/SearchableCombobox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAe,MAAM,OAAO,CAAC;AACzC,OAAO,EAAkB,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAC;AAGrE,MAAM,WAAW,uBAAuB,CAAC,KAAK,EAAE,IAAI,SAAS,GAAG,CAC9D,SAAQ,IAAI,CACV,qBAAqB,CAAC,KAAK,CAAC,EAC5B,UAAU,GAAG,aAAa,GAAG,mBAAmB,CACjD;IACD,kBAAkB,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,KAAK,MAAM,GAAG,IAAI,CAAC;IACtE,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,GAAG,IAAI,CAAC;IACxD,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,iBAAiB,EAAE,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,IAAI,SAAS,GAAG,EAAE,EAC1D,SAAS,EACT,kBAAkB,EAClB,MAAM,EACN,GAAG,KAAK,EACT,EAAE,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,CA4BpD;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchableCombobox.js","names":["useCallback","ComboBox","Item","TextWithTooltip","jsx","_jsx","SearchableCombobox","_ref","scrollRef","getItemDisplayText","getKey","props","_objectWithoutProperties","_excluded","renderItem","item","key","displayText","textValue","String","children","text","_objectSpread","ref","menuTrigger","onSelectionChange"],"sources":["../src/SearchableCombobox.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\nimport { Key, useCallback } from 'react';\nimport { ComboBox, Item, SpectrumComboBoxProps } from '@adobe/react-spectrum';\nimport type { FocusableRef } from '@react-types/shared';\nimport
|
|
1
|
+
{"version":3,"file":"SearchableCombobox.js","names":["useCallback","ComboBox","Item","TextWithTooltip","jsx","_jsx","SearchableCombobox","_ref","scrollRef","getItemDisplayText","getKey","props","_objectWithoutProperties","_excluded","renderItem","item","key","displayText","textValue","String","children","text","_objectSpread","ref","menuTrigger","onSelectionChange"],"sources":["../src/SearchableCombobox.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\nimport { Key, useCallback } from 'react';\nimport { ComboBox, Item, SpectrumComboBoxProps } from '@adobe/react-spectrum';\nimport type { DOMRefValue, FocusableRef } from '@react-types/shared';\nimport TextWithTooltip from './TextWithTooltip';\n\nexport interface SearchableComboboxProps<TItem, TKey extends Key>\n extends Omit<\n SpectrumComboBoxProps<TItem>,\n 'children' | 'menuTrigger' | 'onSelectionChange'\n > {\n getItemDisplayText: (item: TItem | null | undefined) => string | null;\n getKey: (item: TItem | null | undefined) => TKey | null;\n scrollRef: React.RefObject<DOMRefValue>;\n onSelectionChange: (key: TKey | null) => void;\n}\n\nexport function SearchableCombobox<TItem, TKey extends Key>({\n scrollRef,\n getItemDisplayText,\n getKey,\n ...props\n}: SearchableComboboxProps<TItem, TKey>): JSX.Element {\n const renderItem = useCallback(\n item => {\n const key = getKey(item);\n const displayText = getItemDisplayText(item);\n\n return (\n <Item key={key} textValue={displayText ?? String(key)}>\n <TextWithTooltip text={displayText} />\n </Item>\n );\n },\n [getItemDisplayText, getKey]\n );\n\n return (\n <ComboBox\n {...props}\n // The `ref`prop type defined by React Spectrum is incorrect here\n ref={scrollRef as unknown as FocusableRef<HTMLElement>}\n menuTrigger=\"focus\"\n // Type assertion is necessary since <ComboBox> types don't recognize the\n // generic key arg\n onSelectionChange={props.onSelectionChange as (key: Key | null) => void}\n >\n {renderItem}\n </ComboBox>\n );\n}\n\nexport default SearchableCombobox;\n"],"mappings":";;;;;;;;AAAA;AACA,SAAcA,WAAW,QAAQ,OAAO;AACxC,SAASC,QAAQ,EAAEC,IAAI,QAA+B,uBAAuB;AAAC,OAEvEC,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAatB,OAAO,SAASC,kBAAkBA,CAAAC,IAAA,EAKoB;EAAA,IALM;MAC1DC,SAAS;MACTC,kBAAkB;MAClBC;IAEoC,CAAC,GAAAH,IAAA;IADlCI,KAAK,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EAER,IAAMC,UAAU,GAAGd,WAAW,CAC5Be,IAAI,IAAI;IACN,IAAMC,GAAG,GAAGN,MAAM,CAACK,IAAI,CAAC;IACxB,IAAME,WAAW,GAAGR,kBAAkB,CAACM,IAAI,CAAC;IAE5C,oBACEV,IAAA,CAACH,IAAI;MAAWgB,SAAS,EAAED,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAIE,MAAM,CAACH,GAAG,CAAE;MAAAI,QAAA,eACpDf,IAAA,CAACF,eAAe;QAACkB,IAAI,EAAEJ;MAAY,CAAE;IAAC,GAD7BD,GAEL,CAAC;EAEX,CAAC,EACD,CAACP,kBAAkB,EAAEC,MAAM,CAC7B,CAAC;EAED,oBACEL,IAAA,CAACJ,QAAQ,EAAAqB,aAAA,CAAAA,aAAA,KACHX,KAAK;IACT;IACAY,GAAG,EAAEf,SAAkD;IACvDgB,WAAW,EAAC;IACZ;IACA;IAAA;IACAC,iBAAiB,EAAEd,KAAK,CAACc,iBAA+C;IAAAL,QAAA,EAEvEN;EAAU,EACH,CAAC;AAEf;AAEA,eAAeR,kBAAkB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _excluded = ["UNSAFE_className"],
|
|
2
|
-
_excluded2 = ["defaultSelectedKey", "disabledKeys", "
|
|
2
|
+
_excluded2 = ["defaultSelectedKey", "disabledKeys", "ref", "selectedKey"];
|
|
3
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; }
|
|
4
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; }
|
|
5
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; }
|
|
@@ -20,15 +20,15 @@ export function ComboBox(_ref) {
|
|
|
20
20
|
{
|
|
21
21
|
defaultSelectedKey,
|
|
22
22
|
disabledKeys,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
ref,
|
|
24
|
+
selectedKey
|
|
25
25
|
} = _usePickerProps,
|
|
26
26
|
comboBoxProps = _objectWithoutProperties(_usePickerProps, _excluded2);
|
|
27
27
|
return /*#__PURE__*/_jsx(SpectrumComboBox
|
|
28
28
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
29
29
|
, _objectSpread(_objectSpread({}, comboBoxProps), {}, {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
UNSAFE_className: cl('dh-combobox', UNSAFE_className),
|
|
31
|
+
ref: ref
|
|
32
32
|
// Type assertions are necessary here since Spectrum types don't account
|
|
33
33
|
// for number and boolean key values even though they are valid runtime
|
|
34
34
|
// values.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.js","names":["ComboBox","SpectrumComboBox","cl","usePickerProps","jsx","_jsx","_ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerProps","defaultSelectedKey","disabledKeys","
|
|
1
|
+
{"version":3,"file":"ComboBox.js","names":["ComboBox","SpectrumComboBox","cl","usePickerProps","jsx","_jsx","_ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerProps","defaultSelectedKey","disabledKeys","ref","selectedKey","comboBoxProps","_excluded2","_objectSpread"],"sources":["../../../src/spectrum/comboBox/ComboBox.tsx"],"sourcesContent":["import {\n ComboBox as SpectrumComboBox,\n SpectrumComboBoxProps,\n} from '@adobe/react-spectrum';\nimport type { FocusableRef } from '@react-types/shared';\nimport cl from 'classnames';\nimport type { NormalizedItem } from '../utils';\nimport { PickerPropsT, usePickerProps } from '../picker';\n\nexport type ComboBoxProps = PickerPropsT<SpectrumComboBoxProps<NormalizedItem>>;\n\nexport function ComboBox({\n UNSAFE_className,\n ...props\n}: ComboBoxProps): JSX.Element {\n const {\n defaultSelectedKey,\n disabledKeys,\n ref,\n selectedKey,\n ...comboBoxProps\n } = usePickerProps(props);\n\n return (\n <SpectrumComboBox\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...comboBoxProps}\n UNSAFE_className={cl('dh-combobox', UNSAFE_className)}\n ref={ref as FocusableRef<HTMLElement>}\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 SpectrumComboBoxProps<NormalizedItem>['defaultSelectedKey']\n }\n disabledKeys={\n disabledKeys as SpectrumComboBoxProps<NormalizedItem>['disabledKeys']\n }\n selectedKey={\n selectedKey as SpectrumComboBoxProps<NormalizedItem>['selectedKey']\n }\n />\n );\n}\n"],"mappings":";;;;;;;;;AAAA,SACEA,QAAQ,IAAIC,gBAAgB,QAEvB,uBAAuB;AAE9B,OAAOC,EAAE,MAAM,YAAY;AAAC,SAELC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAIrC,OAAO,SAASL,QAAQA,CAAAM,IAAA,EAGO;EAAA,IAHN;MACvBC;IAEa,CAAC,GAAAD,IAAA;IADXE,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAER,IAAAC,eAAA,GAMIR,cAAc,CAACK,KAAK,CAAC;IANnB;MACJI,kBAAkB;MAClBC,YAAY;MACZC,GAAG;MACHC;IAEF,CAAC,GAAAJ,eAAA;IADIK,aAAa,GAAAP,wBAAA,CAAAE,eAAA,EAAAM,UAAA;EAGlB,oBACEZ,IAAA,CAACJ;EACC;EAAA,EAAAiB,aAAA,CAAAA,aAAA,KACIF,aAAa;IACjBT,gBAAgB,EAAEL,EAAE,CAAC,aAAa,EAAEK,gBAAgB,CAAE;IACtDO,GAAG,EAAEA;IACL;IACA;IACA;IAAA;IACAF,kBAAkB,EAChBA,kBACD;IACDC,YAAY,EACVA,YACD;IACDE,WAAW,EACTA;EACD,EACF,CAAC;AAEN"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PickerNormalizedPropsT } from '../picker';
|
|
3
|
+
import { ComboBoxProps } from './ComboBox';
|
|
4
|
+
export type ComboBoxNormalizedProps = PickerNormalizedPropsT<ComboBoxProps>;
|
|
5
|
+
/**
|
|
6
|
+
* ComboBox that takes an array of `NormalizedItem` or `NormalizedSection` items
|
|
7
|
+
* as children and uses a render item function to render the items. `NormalizedItem`
|
|
8
|
+
* and `NormalizedSection` datums always provide a `key` property but have an
|
|
9
|
+
* optional `item` property that can be lazy loaded. This is necessary to support
|
|
10
|
+
* windowed data since we need a representative key for every item in the
|
|
11
|
+
* collection.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ComboBoxNormalized({ UNSAFE_className, ...props }: ComboBoxNormalizedProps): JSX.Element;
|
|
14
|
+
export default ComboBoxNormalized;
|
|
15
|
+
//# sourceMappingURL=ComboBoxNormalized.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboBoxNormalized.d.ts","sourceRoot":"","sources":["../../../src/spectrum/comboBox/ComboBoxNormalized.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,sBAAsB,EAA4B,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;AAE5E;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,gBAAgB,EAChB,GAAG,KAAK,EACT,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CAiBvC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var _excluded = ["UNSAFE_className"],
|
|
2
|
+
_excluded2 = ["forceRerenderKey", "ref"];
|
|
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; }
|
|
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; }
|
|
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
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
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); }
|
|
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; }
|
|
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; }
|
|
10
|
+
import { ComboBox as SpectrumComboBox } from '@adobe/react-spectrum';
|
|
11
|
+
import cl from 'classnames';
|
|
12
|
+
import { usePickerNormalizedProps } from "../picker/index.js";
|
|
13
|
+
import { createElement as _createElement } from "react";
|
|
14
|
+
/**
|
|
15
|
+
* ComboBox that takes an array of `NormalizedItem` or `NormalizedSection` items
|
|
16
|
+
* as children and uses a render item function to render the items. `NormalizedItem`
|
|
17
|
+
* and `NormalizedSection` datums always provide a `key` property but have an
|
|
18
|
+
* optional `item` property that can be lazy loaded. This is necessary to support
|
|
19
|
+
* windowed data since we need a representative key for every item in the
|
|
20
|
+
* collection.
|
|
21
|
+
*/
|
|
22
|
+
export function ComboBoxNormalized(_ref) {
|
|
23
|
+
var {
|
|
24
|
+
UNSAFE_className
|
|
25
|
+
} = _ref,
|
|
26
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
var _usePickerNormalizedP = usePickerNormalizedProps(props),
|
|
28
|
+
{
|
|
29
|
+
forceRerenderKey,
|
|
30
|
+
ref
|
|
31
|
+
} = _usePickerNormalizedP,
|
|
32
|
+
pickerProps = _objectWithoutProperties(_usePickerNormalizedP, _excluded2);
|
|
33
|
+
return /*#__PURE__*/_createElement(SpectrumComboBox
|
|
34
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
35
|
+
, _objectSpread(_objectSpread({}, pickerProps), {}, {
|
|
36
|
+
key: forceRerenderKey,
|
|
37
|
+
ref: ref,
|
|
38
|
+
UNSAFE_className: cl('dh-combobox', 'dh-combobox-normalized', UNSAFE_className)
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
export default ComboBoxNormalized;
|
|
42
|
+
//# sourceMappingURL=ComboBoxNormalized.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboBoxNormalized.js","names":["ComboBox","SpectrumComboBox","cl","usePickerNormalizedProps","createElement","_createElement","ComboBoxNormalized","_ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerNormalizedP","forceRerenderKey","ref","pickerProps","_excluded2","_objectSpread","key"],"sources":["../../../src/spectrum/comboBox/ComboBoxNormalized.tsx"],"sourcesContent":["import { ComboBox as SpectrumComboBox } from '@adobe/react-spectrum';\nimport { FocusableRef } from '@react-types/shared';\nimport cl from 'classnames';\nimport { PickerNormalizedPropsT, usePickerNormalizedProps } from '../picker';\nimport { ComboBoxProps } from './ComboBox';\n\nexport type ComboBoxNormalizedProps = PickerNormalizedPropsT<ComboBoxProps>;\n\n/**\n * ComboBox that takes an array of `NormalizedItem` or `NormalizedSection` items\n * as children and uses a render item function to render the items. `NormalizedItem`\n * and `NormalizedSection` datums always provide a `key` property but have an\n * optional `item` property that can be lazy loaded. This is necessary to support\n * windowed data since we need a representative key for every item in the\n * collection.\n */\nexport function ComboBoxNormalized({\n UNSAFE_className,\n ...props\n}: ComboBoxNormalizedProps): JSX.Element {\n const { forceRerenderKey, ref, ...pickerProps } =\n usePickerNormalizedProps<ComboBoxNormalizedProps>(props);\n\n return (\n <SpectrumComboBox\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...pickerProps}\n key={forceRerenderKey}\n ref={ref as FocusableRef<HTMLElement>}\n UNSAFE_className={cl(\n 'dh-combobox',\n 'dh-combobox-normalized',\n UNSAFE_className\n )}\n />\n );\n}\n\nexport default ComboBoxNormalized;\n"],"mappings":";;;;;;;;;AAAA,SAASA,QAAQ,IAAIC,gBAAgB,QAAQ,uBAAuB;AAEpE,OAAOC,EAAE,MAAM,YAAY;AAAC,SACKC,wBAAwB;AAAA,SAAAC,aAAA,IAAAC,cAAA;AAKzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAAC,IAAA,EAGO;EAAA,IAHN;MACjCC;IAEuB,CAAC,GAAAD,IAAA;IADrBE,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAER,IAAAC,qBAAA,GACET,wBAAwB,CAA0BM,KAAK,CAAC;IADpD;MAAEI,gBAAgB;MAAEC;IAAoB,CAAC,GAAAF,qBAAA;IAAbG,WAAW,GAAAL,wBAAA,CAAAE,qBAAA,EAAAI,UAAA;EAG7C,oBACEX,cAAA,CAACJ;EACC;EAAA,EAAAgB,aAAA,CAAAA,aAAA,KACIF,WAAW;IACfG,GAAG,EAAEL,gBAAiB;IACtBC,GAAG,EAAEA,GAAiC;IACtCN,gBAAgB,EAAEN,EAAE,CAClB,aAAa,EACb,wBAAwB,EACxBM,gBACF;EAAE,EACH,CAAC;AAEN;AAEA,eAAeF,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/comboBox/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/comboBox/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/comboBox/index.ts"],"sourcesContent":["export * from './ComboBox';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/comboBox/index.ts"],"sourcesContent":["export * from './ComboBox';\nexport * from './ComboBoxNormalized';\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListViewWrapper.js","names":["ListView","SpectrumListView","extractSpectrumHTMLElement","useContentRect","useOnScrollRef","EMPTY_FUNCTION","cl","useSpectrumThemeProvider","Flex","separateSpectrumProps","jsx","_jsx","ListViewWrapper","props","_styleProps$minHeight","_listViewProps$densit","ariaLabelProps","componentProps","styleProps","onScroll","listViewProps","_objectWithoutProperties","_excluded","scale","scrollRef","ref","contentRectRef","contentRect","_objectSpread","direction","minHeight","UNSAFE_className","concat","density","children","height"],"sources":["../../../src/spectrum/listView/ListViewWrapper.tsx"],"sourcesContent":["import {\n ListView as SpectrumListView,\n SpectrumListViewProps,\n} from '@adobe/react-spectrum';\nimport {\n extractSpectrumHTMLElement,\n useContentRect,\n useOnScrollRef,\n} from '@deephaven/react-hooks';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport cl from 'classnames';\nimport { useSpectrumThemeProvider } from '../../theme';\nimport { Flex } from '../layout';\nimport { separateSpectrumProps } from '../utils';\nimport './ListViewWrapper.scss';\n\nexport interface ListViewWrapperProps<T> extends SpectrumListViewProps<T> {\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n}\n\n/**\n * Helper component to wrap a ListView with the appropriate styling + scroll\n * handling. This is used by both the `@deephaven/components` `ListView` and\n * the `@deephaven/jsapi-components` `ListView` (via `ListViewNormalized`) to\n * ensure consistency.\n *\n * Note that This component will usually not be used directly. Instead, it is\n * recommended to use\n * - `@deephaven/components`'s `ListView` for non-table data sources\n * - `@deephaven/jsapi-components`'s `ListView` for table data sources\n */\nexport function ListViewWrapper<T>(\n props: ListViewWrapperProps<T>\n): JSX.Element {\n const { ariaLabelProps, componentProps, styleProps } =\n separateSpectrumProps(props);\n\n const { onScroll = EMPTY_FUNCTION, ...listViewProps } = componentProps;\n\n const { scale } = useSpectrumThemeProvider();\n\n const scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);\n\n // Spectrum ListView crashes when it has zero height. Track the contentRect\n // of the parent container and only render the ListView when it has a non-zero\n // height. See https://github.com/adobe/react-spectrum/issues/6213\n const { ref: contentRectRef, contentRect } = useContentRect(\n extractSpectrumHTMLElement
|
|
1
|
+
{"version":3,"file":"ListViewWrapper.js","names":["ListView","SpectrumListView","extractSpectrumHTMLElement","useContentRect","useOnScrollRef","EMPTY_FUNCTION","cl","useSpectrumThemeProvider","Flex","separateSpectrumProps","jsx","_jsx","ListViewWrapper","props","_styleProps$minHeight","_listViewProps$densit","ariaLabelProps","componentProps","styleProps","onScroll","listViewProps","_objectWithoutProperties","_excluded","scale","scrollRef","ref","contentRectRef","contentRect","_objectSpread","direction","minHeight","UNSAFE_className","concat","density","children","height"],"sources":["../../../src/spectrum/listView/ListViewWrapper.tsx"],"sourcesContent":["import {\n ListView as SpectrumListView,\n SpectrumListViewProps,\n} from '@adobe/react-spectrum';\nimport {\n extractSpectrumHTMLElement,\n useContentRect,\n useOnScrollRef,\n} from '@deephaven/react-hooks';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport cl from 'classnames';\nimport { useSpectrumThemeProvider } from '../../theme';\nimport { Flex } from '../layout';\nimport { separateSpectrumProps } from '../utils';\nimport './ListViewWrapper.scss';\n\nexport interface ListViewWrapperProps<T> extends SpectrumListViewProps<T> {\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n}\n\n/**\n * Helper component to wrap a ListView with the appropriate styling + scroll\n * handling. This is used by both the `@deephaven/components` `ListView` and\n * the `@deephaven/jsapi-components` `ListView` (via `ListViewNormalized`) to\n * ensure consistency.\n *\n * Note that This component will usually not be used directly. Instead, it is\n * recommended to use\n * - `@deephaven/components`'s `ListView` for non-table data sources\n * - `@deephaven/jsapi-components`'s `ListView` for table data sources\n */\nexport function ListViewWrapper<T>(\n props: ListViewWrapperProps<T>\n): JSX.Element {\n const { ariaLabelProps, componentProps, styleProps } =\n separateSpectrumProps(props);\n\n const { onScroll = EMPTY_FUNCTION, ...listViewProps } = componentProps;\n\n const { scale } = useSpectrumThemeProvider();\n\n const scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);\n\n // Spectrum ListView crashes when it has zero height. Track the contentRect\n // of the parent container and only render the ListView when it has a non-zero\n // height. See https://github.com/adobe/react-spectrum/issues/6213\n const { ref: contentRectRef, contentRect } = useContentRect(\n extractSpectrumHTMLElement<HTMLDivElement>\n );\n\n return (\n <Flex\n direction=\"column\"\n ref={contentRectRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...styleProps}\n // Set min-height to 1px so that `ListView` is rendered whenever container\n // is visible. This prevents the height from shrinking to zero as a result\n // of a parent grid or flex container calculating content sizes. The\n // container height can still be zero when it is not being displayed such\n // as when one of its parents have `display: none`.\n minHeight={styleProps.minHeight ?? 1}\n UNSAFE_className={cl(\n 'dh-list-view-wrapper',\n `dh-list-view-wrapper-density-${listViewProps.density ?? 'regular'}`,\n `dh-list-view-wrapper-scale-${scale}`,\n styleProps.UNSAFE_className\n )}\n >\n {/**\n * Only render ListView if parent is visible. Some time in the future we\n * should consider using `checkVisibility()` once it has better browser\n * support.\n */}\n {contentRect.height === 0 ? null : (\n <SpectrumListView\n ref={scrollRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...ariaLabelProps}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...listViewProps}\n />\n )}\n </Flex>\n );\n}\n\nexport default ListViewWrapper;\n"],"mappings":";;;;;;;;AAAA,SACEA,QAAQ,IAAIC,gBAAgB,QAEvB,uBAAuB;AAC9B,SACEC,0BAA0B,EAC1BC,cAAc,EACdC,cAAc,QACT,wBAAwB;AAC/B,SAASC,cAAc,QAAQ,kBAAkB;AACjD,OAAOC,EAAE,MAAM,YAAY;AAAC,SACnBC,wBAAwB;AAAA,SACxBC,IAAI;AAAA,SACJC,qBAAqB;AAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAQ9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,KAA8B,EACjB;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EACb,IAAM;IAAEC,cAAc;IAAEC,cAAc;IAAEC;EAAW,CAAC,GAClDT,qBAAqB,CAACI,KAAK,CAAC;EAE9B,IAAM;MAAEM,QAAQ,GAAGd;IAAiC,CAAC,GAAGY,cAAc;IAAhCG,aAAa,GAAAC,wBAAA,CAAKJ,cAAc,EAAAK,SAAA;EAEtE,IAAM;IAAEC;EAAM,CAAC,GAAGhB,wBAAwB,CAAC,CAAC;EAE5C,IAAMiB,SAAS,GAAGpB,cAAc,CAACe,QAAQ,EAAEjB,0BAA0B,CAAC;;EAEtE;EACA;EACA;EACA,IAAM;IAAEuB,GAAG,EAAEC,cAAc;IAAEC;EAAY,CAAC,GAAGxB,cAAc,CACzDD,0BACF,CAAC;EAED,oBACES,IAAA,CAACH,IAAI,EAAAoB,aAAA,CAAAA,aAAA;IACHC,SAAS,EAAC,QAAQ;IAClBJ,GAAG,EAAEC;IACL;EAAA,GACIR,UAAU;IACd;IACA;IACA;IACA;IACA;IACAY,SAAS,GAAAhB,qBAAA,GAAEI,UAAU,CAACY,SAAS,cAAAhB,qBAAA,cAAAA,qBAAA,GAAI,CAAE;IACrCiB,gBAAgB,EAAEzB,EAAE,CAClB,sBAAsB,kCAAA0B,MAAA,EAAAjB,qBAAA,GACUK,aAAa,CAACa,OAAO,cAAAlB,qBAAA,cAAAA,qBAAA,GAAI,SAAS,iCAAAiB,MAAA,CACpCT,KAAK,GACnCL,UAAU,CAACa,gBACb,CAAE;IAAAG,QAAA,EAODP,WAAW,CAACQ,MAAM,KAAK,CAAC,GAAG,IAAI,gBAC9BxB,IAAA,CAACV,gBAAgB,EAAA2B,aAAA,CAAAA,aAAA;MACfH,GAAG,EAAED;MACL;IAAA,GACIR,cAAc,GAEdI,aAAa,CAClB;EACF,EACG,CAAC;AAEX;AAEA,eAAeR,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/Picker.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/Picker.tsx"],"names":[],"mappings":";AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EACrB,gBAAgB,EAChB,GAAG,KAAK,EACT,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAuB3B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _excluded = ["UNSAFE_className"],
|
|
2
|
-
_excluded2 = ["defaultSelectedKey", "disabledKeys", "selectedKey"
|
|
2
|
+
_excluded2 = ["defaultSelectedKey", "disabledKeys", "selectedKey"];
|
|
3
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; }
|
|
4
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; }
|
|
5
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; }
|
|
@@ -27,14 +27,12 @@ export function Picker(_ref) {
|
|
|
27
27
|
{
|
|
28
28
|
defaultSelectedKey,
|
|
29
29
|
disabledKeys,
|
|
30
|
-
selectedKey
|
|
31
|
-
scrollRef
|
|
30
|
+
selectedKey
|
|
32
31
|
} = _usePickerProps,
|
|
33
32
|
pickerProps = _objectWithoutProperties(_usePickerProps, _excluded2);
|
|
34
33
|
return /*#__PURE__*/_jsx(SpectrumPicker
|
|
35
34
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
36
35
|
, _objectSpread(_objectSpread({}, pickerProps), {}, {
|
|
37
|
-
ref: scrollRef,
|
|
38
36
|
UNSAFE_className: cl('dh-picker', UNSAFE_className)
|
|
39
37
|
// Type assertions are necessary here since Spectrum types don't account
|
|
40
38
|
// for number and boolean key values even though they are valid runtime
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.js","names":["Picker","SpectrumPicker","cl","usePickerProps","jsx","_jsx","_ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerProps","defaultSelectedKey","disabledKeys","selectedKey","
|
|
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"}
|
|
@@ -5,6 +5,6 @@ import type { PickerNormalizedProps } from './PickerProps';
|
|
|
5
5
|
* as children and uses a render item function to render the items. This is
|
|
6
6
|
* necessary to support windowed data.
|
|
7
7
|
*/
|
|
8
|
-
export declare function PickerNormalized({
|
|
8
|
+
export declare function PickerNormalized({ UNSAFE_className, ...props }: PickerNormalizedProps): JSX.Element;
|
|
9
9
|
export default PickerNormalized;
|
|
10
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";
|
|
12
|
+
import usePickerNormalizedProps from "./usePickerNormalizedProps.js";
|
|
16
13
|
/**
|
|
17
14
|
* Picker that takes an array of `NormalizedItem` or `NormalizedSection` items
|
|
18
15
|
* as children and uses a render item function to render the items. This is
|
|
19
16
|
* necessary to support windowed data.
|
|
20
17
|
*/
|
|
21
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
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"}
|
|
@@ -2,6 +2,7 @@ export * from './Picker';
|
|
|
2
2
|
export * from './PickerNormalized';
|
|
3
3
|
export * from './PickerProps';
|
|
4
4
|
export * from './usePickerItemScale';
|
|
5
|
+
export * from './usePickerNormalizedProps';
|
|
5
6
|
export * from './usePickerProps';
|
|
6
7
|
export * from './usePickerScrollOnOpen';
|
|
7
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,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,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"}
|
|
@@ -2,6 +2,7 @@ export * from "./Picker.js";
|
|
|
2
2
|
export * from "./PickerNormalized.js";
|
|
3
3
|
export * from "./PickerProps.js";
|
|
4
4
|
export * from "./usePickerItemScale.js";
|
|
5
|
+
export * from "./usePickerNormalizedProps.js";
|
|
5
6
|
export * from "./usePickerProps.js";
|
|
6
7
|
export * from "./usePickerScrollOnOpen.js";
|
|
7
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 './PickerProps';\nexport * from './usePickerItemScale';\nexport * from './usePickerProps';\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,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"}
|
|
@@ -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;MACbC,OAAO,GAAG;IAEoB,CAAC,GAAAX,IAAA;IAD5BY,KAAK,GAAAC,wBAAA,CAAAb,IAAA,EAAAc,SAAA;EAER,IAAMC,cAAc,GAAG3B,OAAO,CAC5B,MAAMI,uBAAuB,CAACmB,OAAO,CAAC,EACtC,CAACA,OAAO,CACV,CAAC;EAED,IAAMK,oBAAoB,GAAGvB,uBAAuB,CAAC;IACnDwB,YAAY,EAAE,MAAM;IACpB;IACA;IACA;IACA;IACAC,oBAAoB,EAAE,KAAK;IAC3BR,aAAa;IACbK;EACF,CAAC,CAAC;;EAEF;EACA;EACA;EACA,IAAMI,gBAAgB,MAAAC,MAAA,CAAMV,aAAa,OAAAU,MAAA,CAAIL,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEM,SAAS,CAAE;EAExE,IAAM;IAAEC,GAAG;IAAEhB,YAAY,EAAEiB;EAAqB,CAAC,GAC/C5B,qBAAqB,CAAQ;IAC3BQ,wBAAwB;IACxBI,QAAQ;IACRD;EACF,CAAC,CAAC;;EAEJ;EACA;EACA;EACA,IAAM;IACJkB,iBAAiB;IACjBC,wBAAwB;IACxBC,kBAAkB;IAClBC;EACF,CAAC,GAAGjC,uBAAuB,CAAC;IAC1BU,eAAe;IACfK,WAAW;IACXR,kBAAkB;IAClBC,YAAY;IACZG,QAAQ,EAAEA,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIG;EACxB,CAAC,CAAC;EAEF,IAAMoB,QAAQ,GAAGzC,WAAW,CACzB0C,aAAiD,IAAK;IACrD,IAAItC,mBAAmB,CAACsC,aAAa,CAAC,EAAE;MAAA,IAAAC,mBAAA,EAAAC,oBAAA;MACtC,oBACEjC,IAAA,CAACF,OAAO;QAENoC,KAAK,GAAAF,mBAAA,GAAED,aAAa,CAACI,IAAI,cAAAH,mBAAA,uBAAlBA,mBAAA,CAAoBE,KAAM;QACjCE,KAAK,GAAAH,oBAAA,GAAEF,aAAa,CAACI,IAAI,cAAAF,oBAAA,uBAAlBA,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"}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { DOMRef } from '@react-types/shared';
|
|
2
2
|
import { ItemKey, SectionElement, ItemElement } from '../utils';
|
|
3
3
|
import type { PickerPropsT } from './PickerProps';
|
|
4
|
-
/** Props that are derived
|
|
5
|
-
export type UsePickerDerivedProps = {
|
|
4
|
+
/** Props that are derived by `usePickerProps`. */
|
|
5
|
+
export type UsePickerDerivedProps<THtml extends HTMLElement> = {
|
|
6
6
|
children: (SectionElement<unknown> | ItemElement<unknown>)[];
|
|
7
7
|
defaultSelectedKey?: ItemKey | undefined;
|
|
8
|
+
ref: DOMRef<THtml>;
|
|
8
9
|
selectedKey?: ItemKey | null | undefined;
|
|
9
|
-
scrollRef: DOMRef<HTMLElement>;
|
|
10
10
|
onOpenChange: (isOpen: boolean) => void;
|
|
11
11
|
onSelectionChange: ((key: ItemKey | null) => void) | undefined;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
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
|
+
) */
|
|
14
18
|
export type UsePickerPassthroughProps<TProps> = Omit<PickerPropsT<TProps>, 'children' | 'defaultSelectedKey' | 'selectedKey' | 'tooltip' | 'onChange' | 'onOpenChange' | 'onScroll' | 'onSelectionChange'>;
|
|
15
|
-
|
|
19
|
+
/** Props returned from `usePickerProps` hook. */
|
|
20
|
+
export type UsePickerProps<TProps, THtml extends HTMLElement> = UsePickerDerivedProps<THtml> & UsePickerPassthroughProps<TProps>;
|
|
16
21
|
/**
|
|
17
22
|
* Derive props for Picker components (e.g. Picker and ComboBox). Specifically
|
|
18
23
|
* handles wrapping children items and initial scroll position when the picker
|
|
19
24
|
* is opened.
|
|
20
25
|
*/
|
|
21
|
-
export declare function usePickerProps<TProps>({ children, defaultSelectedKey, selectedKey, tooltip, onChange: onChangeHandler, onOpenChange: onOpenChangeHandler, onScroll, onSelectionChange: onSelectionChangeHandler, ...props }: PickerPropsT<TProps>): UsePickerProps<TProps>;
|
|
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>;
|
|
22
27
|
export default usePickerProps;
|
|
23
28
|
//# sourceMappingURL=usePickerProps.d.ts.map
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -11,8 +11,13 @@ import { useMemo } from 'react';
|
|
|
11
11
|
import { normalizeTooltipOptions, wrapItemChildren, useOnChangeTrackUncontrolled, useStaticItemInitialScrollPosition } from "../utils/index.js";
|
|
12
12
|
import usePickerItemScale from "./usePickerItemScale.js";
|
|
13
13
|
import usePickerScrollOnOpen from "./usePickerScrollOnOpen.js";
|
|
14
|
-
/** Props that are derived
|
|
15
|
-
/**
|
|
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. */
|
|
16
21
|
/**
|
|
17
22
|
* Derive props for Picker components (e.g. Picker and ComboBox). Specifically
|
|
18
23
|
* handles wrapping children items and initial scroll position when the picker
|
|
@@ -50,7 +55,7 @@ export function usePickerProps(_ref) {
|
|
|
50
55
|
topOffset: PICKER_TOP_OFFSET
|
|
51
56
|
});
|
|
52
57
|
var {
|
|
53
|
-
ref
|
|
58
|
+
ref,
|
|
54
59
|
onOpenChange
|
|
55
60
|
} = usePickerScrollOnOpen({
|
|
56
61
|
getInitialScrollPosition,
|
|
@@ -59,9 +64,9 @@ export function usePickerProps(_ref) {
|
|
|
59
64
|
});
|
|
60
65
|
return _objectSpread(_objectSpread({}, props), {}, {
|
|
61
66
|
defaultSelectedKey,
|
|
67
|
+
ref,
|
|
62
68
|
selectedKey,
|
|
63
69
|
children: items,
|
|
64
|
-
scrollRef,
|
|
65
70
|
onOpenChange,
|
|
66
71
|
onSelectionChange: onChangeMaybeUncontrolled
|
|
67
72
|
});
|
|
@@ -1 +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","
|
|
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;MACzBC,YAAY,EAAEC,mBAAmB;MACjCC,QAAQ,GAAGpB,cAAc;MACzBqB,iBAAiB,EAAEC;IAEC,CAAC,GAAAX,IAAA;IADlBY,KAAK,GAAAC,wBAAA,CAAAb,IAAA,EAAAc,SAAA;EAER,IAAM;IAAEC;EAAW,CAAC,GAAGlB,kBAAkB,CAAC,CAAC;EAE3C,IAAMmB,cAAc,GAAGxB,OAAO,CAC5B,MAAMC,uBAAuB,CAACW,OAAO,CAAC,EACtC,CAACA,OAAO,CACV,CAAC;EAED,IAAMa,KAAK,GAAGzB,OAAO,CACnB,MAAMF,WAAW,CAACI,gBAAgB,CAACO,QAAQ,EAAEe,cAAc,CAAC,CAAC,EAC7D,CAACf,QAAQ,EAAEe,cAAc,CAC3B,CAAC;EAED,IAAM;IAAEE,4BAA4B;IAAEC;EAA0B,CAAC,GAC/DxB,4BAA4B,CAAC;IAC3BO,kBAAkB;IAClBC,WAAW;IACXE,QAAQ,EAAEC,eAAe,aAAfA,eAAe,cAAfA,eAAe,GAAIK;EAC/B,CAAC,CAAC;EAEJ,IAAMS,wBAAwB,GAAGxB,kCAAkC,CAAC;IAClEmB,UAAU;IACVE,KAAK;IACLd,WAAW,EAAEe,4BAA4B;IACzCG,SAAS,EAAE9B;EACb,CAAC,CAAC;EAEF,IAAM;IAAE+B,GAAG;IAAEf;EAAa,CAAC,GAAGT,qBAAqB,CAAQ;IACzDsB,wBAAwB;IACxBX,QAAQ;IACRF,YAAY,EAAEC;EAChB,CAAC,CAAC;EAEF,OAAAe,aAAA,CAAAA,aAAA,KACKX,KAAK;IACRV,kBAAkB;IAClBoB,GAAG;IACHnB,WAAW;IACXF,QAAQ,EAAEgB,KAAK;IACfV,YAAY;IACZG,iBAAiB,EAAES;EAAyB;AAEhD;AAEA,eAAepB,cAAc"}
|
|
@@ -4,8 +4,8 @@ export interface UsePickerScrollOnOpenOptions {
|
|
|
4
4
|
onScroll: (event: Event) => void;
|
|
5
5
|
onOpenChange?: (isOpen: boolean) => void;
|
|
6
6
|
}
|
|
7
|
-
export interface UsePickerScrollOnOpenResult {
|
|
8
|
-
ref: DOMRef<
|
|
7
|
+
export interface UsePickerScrollOnOpenResult<THtml extends HTMLElement> {
|
|
8
|
+
ref: DOMRef<THtml>;
|
|
9
9
|
onOpenChange: (isOpen: boolean) => void;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -17,6 +17,6 @@ export interface UsePickerScrollOnOpenResult {
|
|
|
17
17
|
* @return A ref to attach to the Picker and a callback to handle open change
|
|
18
18
|
* events for the Picker.
|
|
19
19
|
*/
|
|
20
|
-
export declare function usePickerScrollOnOpen({ getInitialScrollPosition, onScroll, onOpenChange, }: UsePickerScrollOnOpenOptions): UsePickerScrollOnOpenResult
|
|
20
|
+
export declare function usePickerScrollOnOpen<THtml extends HTMLElement = HTMLElement>({ getInitialScrollPosition, onScroll, onOpenChange, }: UsePickerScrollOnOpenOptions): UsePickerScrollOnOpenResult<THtml>;
|
|
21
21
|
export default usePickerScrollOnOpen;
|
|
22
22
|
//# sourceMappingURL=usePickerScrollOnOpen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePickerScrollOnOpen.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerScrollOnOpen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAMlD,MAAM,WAAW,4BAA4B;IAC3C,wBAAwB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACpE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,2BAA2B;
|
|
1
|
+
{"version":3,"file":"usePickerScrollOnOpen.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerScrollOnOpen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAMlD,MAAM,WAAW,4BAA4B;IAC3C,wBAAwB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACpE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,2BAA2B,CAAC,KAAK,SAAS,WAAW;IACpE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACnB,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EAAE,EAC7E,wBAAwB,EACxB,QAAQ,EACR,YAAY,GACb,EAAE,4BAA4B,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAqBnE;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePickerScrollOnOpen.js","names":["useCallback","findSpectrumPickerScrollArea","usePopoverOnScrollRef","usePickerScrollOnOpen","_ref","getInitialScrollPosition","onScroll","onOpenChange","ref","popoverOnOpenChange","onOpenChangeInternal","isOpen"],"sources":["../../../src/spectrum/picker/usePickerScrollOnOpen.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport type { DOMRef } from '@react-types/shared';\nimport {\n findSpectrumPickerScrollArea,\n usePopoverOnScrollRef,\n} from '@deephaven/react-hooks';\n\nexport interface UsePickerScrollOnOpenOptions {\n getInitialScrollPosition?: () => Promise<number | null | undefined>;\n onScroll: (event: Event) => void;\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface UsePickerScrollOnOpenResult {\n ref: DOMRef<
|
|
1
|
+
{"version":3,"file":"usePickerScrollOnOpen.js","names":["useCallback","findSpectrumPickerScrollArea","usePopoverOnScrollRef","usePickerScrollOnOpen","_ref","getInitialScrollPosition","onScroll","onOpenChange","ref","popoverOnOpenChange","onOpenChangeInternal","isOpen"],"sources":["../../../src/spectrum/picker/usePickerScrollOnOpen.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport type { DOMRef } from '@react-types/shared';\nimport {\n findSpectrumPickerScrollArea,\n usePopoverOnScrollRef,\n} from '@deephaven/react-hooks';\n\nexport interface UsePickerScrollOnOpenOptions {\n getInitialScrollPosition?: () => Promise<number | null | undefined>;\n onScroll: (event: Event) => void;\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface UsePickerScrollOnOpenResult<THtml extends HTMLElement> {\n ref: DOMRef<THtml>;\n onOpenChange: (isOpen: boolean) => void;\n}\n\n/**\n * Handle scroll event registration and scrolling to initial scroll position\n * whenever a Picker popover is opened.\n * @param getInitialScrollPosition Function to get the initial scroll position.\n * @param onScroll Callback for scroll events.\n * @param onOpenChange Callback for open change events.\n * @return A ref to attach to the Picker and a callback to handle open change\n * events for the Picker.\n */\nexport function usePickerScrollOnOpen<THtml extends HTMLElement = HTMLElement>({\n getInitialScrollPosition,\n onScroll,\n onOpenChange,\n}: UsePickerScrollOnOpenOptions): UsePickerScrollOnOpenResult<THtml> {\n const { ref, onOpenChange: popoverOnOpenChange } = usePopoverOnScrollRef(\n findSpectrumPickerScrollArea<THtml>,\n onScroll,\n getInitialScrollPosition\n );\n\n const onOpenChangeInternal = useCallback(\n (isOpen: boolean): void => {\n // Attach scroll event handling\n popoverOnOpenChange(isOpen);\n\n onOpenChange?.(isOpen);\n },\n [onOpenChange, popoverOnOpenChange]\n );\n\n return {\n ref,\n onOpenChange: onOpenChangeInternal,\n };\n}\n\nexport default usePickerScrollOnOpen;\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,OAAO;AAEnC,SACEC,4BAA4B,EAC5BC,qBAAqB,QAChB,wBAAwB;AAa/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAAAC,IAAA,EAIgC;EAAA,IAJU;IAC7EC,wBAAwB;IACxBC,QAAQ;IACRC;EAC4B,CAAC,GAAAH,IAAA;EAC7B,IAAM;IAAEI,GAAG;IAAED,YAAY,EAAEE;EAAoB,CAAC,GAAGP,qBAAqB,CACtED,4BAA4B,EAC5BK,QAAQ,EACRD,wBACF,CAAC;EAED,IAAMK,oBAAoB,GAAGV,WAAW,CACrCW,MAAe,IAAW;IACzB;IACAF,mBAAmB,CAACE,MAAM,CAAC;IAE3BJ,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAGI,MAAM,CAAC;EACxB,CAAC,EACD,CAACJ,YAAY,EAAEE,mBAAmB,CACpC,CAAC;EAED,OAAO;IACLD,GAAG;IACHD,YAAY,EAAEG;EAChB,CAAC;AACH;AAEA,eAAeP,qBAAqB"}
|
|
@@ -5,13 +5,13 @@ export interface UseStringifiedSelectionOptions {
|
|
|
5
5
|
selectedKey: ItemKey | null | undefined;
|
|
6
6
|
defaultSelectedKey: ItemKey | undefined;
|
|
7
7
|
disabledKeys: Iterable<ItemKey> | undefined;
|
|
8
|
-
onChange: ((key: ItemKey) => void) | undefined;
|
|
8
|
+
onChange: ((key: ItemKey | null) => void) | undefined;
|
|
9
9
|
}
|
|
10
10
|
export interface UseStringifiedSelectionResult {
|
|
11
11
|
defaultSelectedStringKey?: Key;
|
|
12
12
|
selectedStringKey?: Key | null;
|
|
13
13
|
disabledStringKeys?: Set<Key>;
|
|
14
|
-
onStringSelectionChange: (key: Key) => void;
|
|
14
|
+
onStringSelectionChange: (key: Key | null) => void;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Spectrum collection components treat keys as strings if the `key` prop is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStringifiedSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,OAAO,EAEP,cAAc,EACd,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,8BAA8B;IAC7C,eAAe,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IACxD,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,kBAAkB,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAC5C,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useStringifiedSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,OAAO,EAEP,cAAc,EACd,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,8BAA8B;IAC7C,eAAe,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IACxD,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,kBAAkB,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAC5C,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACvD;AAED,MAAM,WAAW,6BAA6B;IAC5C,wBAAwB,CAAC,EAAE,GAAG,CAAC;IAC/B,iBAAiB,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC/B,kBAAkB,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,uBAAuB,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC;CACpD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,EAAE,8BAA8B,GAAG,6BAA6B,CA6ChE;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStringifiedSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedSelection","_ref","normalizedItems","defaultSelectedKey","selectedKey","disabledKeys","onChange","selectedStringKey","String","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","key","_getItemKey","selectedItem","find","item","actualKey"],"sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n ItemKey,\n itemSelectionToStringSet,\n NormalizedItem,\n NormalizedSection,\n} from './itemUtils';\n\nexport interface UseStringifiedSelectionOptions {\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n selectedKey: ItemKey | null | undefined;\n defaultSelectedKey: ItemKey | undefined;\n disabledKeys: Iterable<ItemKey> | undefined;\n onChange: ((key: ItemKey) => void) | undefined;\n}\n\nexport interface UseStringifiedSelectionResult {\n defaultSelectedStringKey?: Key;\n selectedStringKey?: Key | null;\n disabledStringKeys?: Set<Key>;\n onStringSelectionChange: (key: Key) => void;\n}\n\n/**\n * Spectrum collection components treat keys as strings if the `key` prop is\n * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,\n * we need to ensure that keys are strings in order for selection to work. We\n * then need to convert back to the original key types in the onChange handler.\n * This hook encapsulates converting to and from strings so that keys can match\n * the original key type.\n * @param normalizedItems The normalized items to select from.\n * @param selectedKey The currently selected key in the collection.\n * @param defaultSelectedKey The initial selected key in the collection.\n * @param disabledKeys The currently disabled keys in the collection.\n * @param onChange Handler that is called when the selection changes.\n * @returns UseStringifiedSelectionResult with stringified key sets and string\n * key selection change handler.\n */\nexport function useStringifiedSelection({\n normalizedItems,\n defaultSelectedKey,\n selectedKey,\n disabledKeys,\n onChange,\n}: UseStringifiedSelectionOptions): UseStringifiedSelectionResult {\n const selectedStringKey = useMemo(\n () => (selectedKey == null ? selectedKey : String(selectedKey)),\n [selectedKey]\n );\n\n const defaultSelectedStringKey = useMemo(\n () =>\n defaultSelectedKey == null\n ? defaultSelectedKey\n : String(defaultSelectedKey),\n [defaultSelectedKey]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (key: Key): void => {\n if (onChange == null) {\n return;\n }\n\n // The `key` arg will always be a string due to us setting the `Item` key\n // prop in `renderItem`. We need to find the matching item to determine\n // the actual key.\n const selectedItem = normalizedItems.find(\n item => String(getItemKey(item)) === key\n );\n\n const actualKey = getItemKey(selectedItem) ?? key;\n\n onChange(actualKey);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedSelection;\n"],"mappings":"AAAA,SAAcA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAEhDC,UAAU,EAEVC,wBAAwB;AAoB1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAAC,IAAA,EAM2B;EAAA,IAN1B;IACtCC,eAAe;IACfC,kBAAkB;IAClBC,WAAW;IACXC,YAAY;IACZC;EAC8B,CAAC,GAAAL,IAAA;EAC/B,IAAMM,iBAAiB,GAAGV,OAAO,CAC/B,MAAOO,WAAW,IAAI,IAAI,GAAGA,WAAW,GAAGI,MAAM,CAACJ,WAAW,CAAE,EAC/D,CAACA,WAAW,CACd,CAAC;EAED,IAAMK,wBAAwB,GAAGZ,OAAO,CACtC,MACEM,kBAAkB,IAAI,IAAI,GACtBA,kBAAkB,GAClBK,MAAM,CAACL,kBAAkB,CAAC,EAChC,CAACA,kBAAkB,CACrB,CAAC;EAED,IAAMO,kBAAkB,GAAGb,OAAO,CAChC,MAAME,wBAAwB,CAACM,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMM,uBAAuB,GAAGf,WAAW,CACxCgB,
|
|
1
|
+
{"version":3,"file":"useStringifiedSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedSelection","_ref","normalizedItems","defaultSelectedKey","selectedKey","disabledKeys","onChange","selectedStringKey","String","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","key","_getItemKey","selectedItem","find","item","actualKey"],"sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n ItemKey,\n itemSelectionToStringSet,\n NormalizedItem,\n NormalizedSection,\n} from './itemUtils';\n\nexport interface UseStringifiedSelectionOptions {\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n selectedKey: ItemKey | null | undefined;\n defaultSelectedKey: ItemKey | undefined;\n disabledKeys: Iterable<ItemKey> | undefined;\n onChange: ((key: ItemKey | null) => void) | undefined;\n}\n\nexport interface UseStringifiedSelectionResult {\n defaultSelectedStringKey?: Key;\n selectedStringKey?: Key | null;\n disabledStringKeys?: Set<Key>;\n onStringSelectionChange: (key: Key | null) => void;\n}\n\n/**\n * Spectrum collection components treat keys as strings if the `key` prop is\n * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,\n * we need to ensure that keys are strings in order for selection to work. We\n * then need to convert back to the original key types in the onChange handler.\n * This hook encapsulates converting to and from strings so that keys can match\n * the original key type.\n * @param normalizedItems The normalized items to select from.\n * @param selectedKey The currently selected key in the collection.\n * @param defaultSelectedKey The initial selected key in the collection.\n * @param disabledKeys The currently disabled keys in the collection.\n * @param onChange Handler that is called when the selection changes.\n * @returns UseStringifiedSelectionResult with stringified key sets and string\n * key selection change handler.\n */\nexport function useStringifiedSelection({\n normalizedItems,\n defaultSelectedKey,\n selectedKey,\n disabledKeys,\n onChange,\n}: UseStringifiedSelectionOptions): UseStringifiedSelectionResult {\n const selectedStringKey = useMemo(\n () => (selectedKey == null ? selectedKey : String(selectedKey)),\n [selectedKey]\n );\n\n const defaultSelectedStringKey = useMemo(\n () =>\n defaultSelectedKey == null\n ? defaultSelectedKey\n : String(defaultSelectedKey),\n [defaultSelectedKey]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (key: Key | null): void => {\n if (onChange == null) {\n return;\n }\n\n // The `key` arg will always be a string due to us setting the `Item` key\n // prop in `renderItem`. We need to find the matching item to determine\n // the actual key.\n const selectedItem = normalizedItems.find(\n item => String(getItemKey(item)) === key\n );\n\n const actualKey = getItemKey(selectedItem) ?? key;\n\n onChange(actualKey);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedSelection;\n"],"mappings":"AAAA,SAAcA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAEhDC,UAAU,EAEVC,wBAAwB;AAoB1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAAC,IAAA,EAM2B;EAAA,IAN1B;IACtCC,eAAe;IACfC,kBAAkB;IAClBC,WAAW;IACXC,YAAY;IACZC;EAC8B,CAAC,GAAAL,IAAA;EAC/B,IAAMM,iBAAiB,GAAGV,OAAO,CAC/B,MAAOO,WAAW,IAAI,IAAI,GAAGA,WAAW,GAAGI,MAAM,CAACJ,WAAW,CAAE,EAC/D,CAACA,WAAW,CACd,CAAC;EAED,IAAMK,wBAAwB,GAAGZ,OAAO,CACtC,MACEM,kBAAkB,IAAI,IAAI,GACtBA,kBAAkB,GAClBK,MAAM,CAACL,kBAAkB,CAAC,EAChC,CAACA,kBAAkB,CACrB,CAAC;EAED,IAAMO,kBAAkB,GAAGb,OAAO,CAChC,MAAME,wBAAwB,CAACM,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMM,uBAAuB,GAAGf,WAAW,CACxCgB,GAAe,IAAW;IAAA,IAAAC,WAAA;IACzB,IAAIP,QAAQ,IAAI,IAAI,EAAE;MACpB;IACF;;IAEA;IACA;IACA;IACA,IAAMQ,YAAY,GAAGZ,eAAe,CAACa,IAAI,CACvCC,IAAI,IAAIR,MAAM,CAACV,UAAU,CAACkB,IAAI,CAAC,CAAC,KAAKJ,GACvC,CAAC;IAED,IAAMK,SAAS,IAAAJ,WAAA,GAAGf,UAAU,CAACgB,YAAY,CAAC,cAAAD,WAAA,cAAAA,WAAA,GAAID,GAAG;IAEjDN,QAAQ,CAACW,SAAS,CAAC;EACrB,CAAC,EACD,CAACf,eAAe,EAAEI,QAAQ,CAC5B,CAAC;EAED,OAAO;IACLC,iBAAiB;IACjBE,wBAAwB;IACxBC,kBAAkB;IAClBC;EACF,CAAC;AACH;AAEA,eAAeX,uBAAuB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/components",
|
|
3
|
-
"version": "0.82.1-beta.
|
|
3
|
+
"version": "0.82.1-beta.7+a30341a7",
|
|
4
4
|
"description": "Deephaven React component library",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@adobe/react-spectrum": "3.35.1",
|
|
28
|
-
"@deephaven/icons": "^0.82.1-beta.
|
|
29
|
-
"@deephaven/log": "^0.82.1-beta.
|
|
30
|
-
"@deephaven/react-hooks": "^0.82.1-beta.
|
|
31
|
-
"@deephaven/utils": "^0.82.1-beta.
|
|
28
|
+
"@deephaven/icons": "^0.82.1-beta.7+a30341a7",
|
|
29
|
+
"@deephaven/log": "^0.82.1-beta.7+a30341a7",
|
|
30
|
+
"@deephaven/react-hooks": "^0.82.1-beta.7+a30341a7",
|
|
31
|
+
"@deephaven/utils": "^0.82.1-beta.7+a30341a7",
|
|
32
32
|
"@fortawesome/fontawesome-svg-core": "^6.2.1",
|
|
33
33
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
34
34
|
"@react-spectrum/theme-default": "^3.5.1",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-dom": ">=16.8.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@deephaven/mocks": "^0.82.1-beta.
|
|
59
|
+
"@deephaven/mocks": "^0.82.1-beta.7+a30341a7"
|
|
60
60
|
},
|
|
61
61
|
"files": [
|
|
62
62
|
"dist",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "a30341a728625dc7fdc2b0a54b88dfc737977b7a"
|
|
74
74
|
}
|