@deephaven/components 0.72.1-alpha-list-view.16 → 0.72.1-xcomponent.2
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/Button.d.ts +1 -1
- package/dist/Select.d.ts +1 -1
- package/dist/XComponent.d.ts +43 -0
- package/dist/XComponent.d.ts.map +1 -0
- package/dist/XComponent.js +57 -0
- package/dist/XComponent.js.map +1 -0
- package/dist/XComponentMap.d.ts +14 -0
- package/dist/XComponentMap.d.ts.map +1 -0
- package/dist/XComponentMap.js +20 -0
- package/dist/XComponentMap.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/spectrum/Heading.d.ts +1 -4
- package/dist/spectrum/Heading.d.ts.map +1 -1
- package/dist/spectrum/Heading.js +3 -5
- package/dist/spectrum/Heading.js.map +1 -1
- package/dist/spectrum/Text.d.ts +1 -4
- package/dist/spectrum/Text.d.ts.map +1 -1
- package/dist/spectrum/Text.js +4 -5
- package/dist/spectrum/Text.js.map +1 -1
- package/dist/spectrum/View.d.ts +1 -4
- package/dist/spectrum/View.d.ts.map +1 -1
- package/dist/spectrum/View.js +3 -5
- package/dist/spectrum/View.js.map +1 -1
- package/dist/spectrum/collections.d.ts +1 -1
- package/dist/spectrum/collections.d.ts.map +1 -1
- package/dist/spectrum/collections.js +1 -1
- package/dist/spectrum/collections.js.map +1 -1
- package/dist/spectrum/index.d.ts +0 -3
- package/dist/spectrum/index.d.ts.map +1 -1
- package/dist/spectrum/index.js +0 -3
- package/dist/spectrum/index.js.map +1 -1
- package/dist/spectrum/picker/Picker.d.ts.map +1 -1
- package/dist/spectrum/picker/Picker.js +60 -9
- package/dist/spectrum/picker/Picker.js.map +1 -1
- package/dist/spectrum/picker/PickerItemContent.d.ts +11 -0
- package/dist/spectrum/picker/PickerItemContent.d.ts.map +1 -0
- package/dist/spectrum/{ItemContent.js → picker/PickerItemContent.js} +18 -42
- package/dist/spectrum/picker/PickerItemContent.js.map +1 -0
- 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/utils/index.d.ts +0 -2
- package/dist/spectrum/utils/index.d.ts.map +1 -1
- package/dist/spectrum/utils/index.js +0 -2
- package/dist/spectrum/utils/index.js.map +1 -1
- package/dist/spectrum/utils/itemUtils.d.ts +10 -13
- package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
- package/dist/spectrum/utils/itemUtils.js +8 -11
- package/dist/spectrum/utils/itemUtils.js.map +1 -1
- package/package.json +7 -7
- package/dist/spectrum/ItemContent.d.ts +0 -15
- package/dist/spectrum/ItemContent.d.ts.map +0 -1
- package/dist/spectrum/ItemContent.js.map +0 -1
- package/dist/spectrum/ItemTooltip.d.ts +0 -12
- package/dist/spectrum/ItemTooltip.d.ts.map +0 -1
- package/dist/spectrum/ItemTooltip.js +0 -30
- package/dist/spectrum/ItemTooltip.js.map +0 -1
- package/dist/spectrum/listView/ListView.d.ts +0 -28
- package/dist/spectrum/listView/ListView.d.ts.map +0 -1
- package/dist/spectrum/listView/ListView.js +0 -59
- package/dist/spectrum/listView/ListView.js.map +0 -1
- package/dist/spectrum/listView/index.d.ts +0 -2
- package/dist/spectrum/listView/index.d.ts.map +0 -1
- package/dist/spectrum/listView/index.js +0 -2
- package/dist/spectrum/listView/index.js.map +0 -1
- package/dist/spectrum/utils/useRenderNormalizedItem.d.ts +0 -5
- package/dist/spectrum/utils/useRenderNormalizedItem.d.ts.map +0 -1
- package/dist/spectrum/utils/useRenderNormalizedItem.js +0 -34
- package/dist/spectrum/utils/useRenderNormalizedItem.js.map +0 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts +0 -43
- package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts.map +0 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.js +0 -56
- package/dist/spectrum/utils/useStringifiedMultiSelection.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ActionBar, type SpectrumActionBarProps as ActionBarProps, ActionMenu, type SpectrumActionMenuProps as ActionMenuProps, MenuTrigger, type SpectrumMenuTriggerProps as MenuTriggerProps, TagGroup, type SpectrumTagGroupProps as TagGroupProps, } from '@adobe/react-spectrum';
|
|
1
|
+
export { ActionBar, type SpectrumActionBarProps as ActionBarProps, ActionMenu, type SpectrumActionMenuProps as ActionMenuProps, ListView, type SpectrumListViewProps as ListViewProps, MenuTrigger, type SpectrumMenuTriggerProps as MenuTriggerProps, TagGroup, type SpectrumTagGroupProps as TagGroupProps, } from '@adobe/react-spectrum';
|
|
2
2
|
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/spectrum/collections.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,sBAAsB,IAAI,cAAc,EAC7C,UAAU,EACV,KAAK,uBAAuB,IAAI,eAAe,EAC/C,WAAW,EACX,KAAK,wBAAwB,IAAI,gBAAgB,EACjD,QAAQ,EACR,KAAK,qBAAqB,IAAI,aAAa,GAC5C,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/spectrum/collections.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,sBAAsB,IAAI,cAAc,EAC7C,UAAU,EACV,KAAK,uBAAuB,IAAI,eAAe,EAC/C,QAAQ,EACR,KAAK,qBAAqB,IAAI,aAAa,EAC3C,WAAW,EACX,KAAK,wBAAwB,IAAI,gBAAgB,EACjD,QAAQ,EACR,KAAK,qBAAqB,IAAI,aAAa,GAC5C,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ActionBar, ActionMenu, MenuTrigger, TagGroup } from '@adobe/react-spectrum';
|
|
1
|
+
export { ActionBar, ActionMenu, ListView, MenuTrigger, TagGroup } from '@adobe/react-spectrum';
|
|
2
2
|
//# sourceMappingURL=collections.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.js","names":["ActionBar","ActionMenu","MenuTrigger","TagGroup"],"sources":["../../src/spectrum/collections.ts"],"sourcesContent":["export {\n ActionBar,\n type SpectrumActionBarProps as ActionBarProps,\n ActionMenu,\n type SpectrumActionMenuProps as ActionMenuProps,\n MenuTrigger,\n type SpectrumMenuTriggerProps as MenuTriggerProps,\n TagGroup,\n type SpectrumTagGroupProps as TagGroupProps,\n} from '@adobe/react-spectrum';\n"],"mappings":"AAAA,SACEA,SAAS,EAETC,UAAU,EAEVC,WAAW,EAEXC,QAAQ,QAEH,uBAAuB"}
|
|
1
|
+
{"version":3,"file":"collections.js","names":["ActionBar","ActionMenu","ListView","MenuTrigger","TagGroup"],"sources":["../../src/spectrum/collections.ts"],"sourcesContent":["export {\n ActionBar,\n type SpectrumActionBarProps as ActionBarProps,\n ActionMenu,\n type SpectrumActionMenuProps as ActionMenuProps,\n ListView,\n type SpectrumListViewProps as ListViewProps,\n MenuTrigger,\n type SpectrumMenuTriggerProps as MenuTriggerProps,\n TagGroup,\n type SpectrumTagGroupProps as TagGroupProps,\n} from '@adobe/react-spectrum';\n"],"mappings":"AAAA,SACEA,SAAS,EAETC,UAAU,EAEVC,QAAQ,EAERC,WAAW,EAEXC,QAAQ,QAEH,uBAAuB"}
|
package/dist/spectrum/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export * from './status';
|
|
|
15
15
|
/**
|
|
16
16
|
* Custom DH components wrapping React Spectrum components.
|
|
17
17
|
*/
|
|
18
|
-
export * from './listView';
|
|
19
18
|
export * from './picker';
|
|
20
19
|
export * from './Heading';
|
|
21
20
|
export * from './Text';
|
|
@@ -23,7 +22,5 @@ export * from './View';
|
|
|
23
22
|
/**
|
|
24
23
|
* Custom DH spectrum utils
|
|
25
24
|
*/
|
|
26
|
-
export * from './ItemContent';
|
|
27
|
-
export * from './ItemTooltip';
|
|
28
25
|
export * from './utils';
|
|
29
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spectrum/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB;;GAEG;AACH,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spectrum/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB;;GAEG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AAEvB;;GAEG;AACH,cAAc,SAAS,CAAC"}
|
package/dist/spectrum/index.js
CHANGED
|
@@ -15,7 +15,6 @@ export * from "./status.js";
|
|
|
15
15
|
/**
|
|
16
16
|
* Custom DH components wrapping React Spectrum components.
|
|
17
17
|
*/
|
|
18
|
-
export * from "./listView/index.js";
|
|
19
18
|
export * from "./picker/index.js";
|
|
20
19
|
export * from "./Heading.js";
|
|
21
20
|
export * from "./Text.js";
|
|
@@ -23,7 +22,5 @@ export * from "./View.js";
|
|
|
23
22
|
/**
|
|
24
23
|
* Custom DH spectrum utils
|
|
25
24
|
*/
|
|
26
|
-
export * from "./ItemContent.js";
|
|
27
|
-
export * from "./ItemTooltip.js";
|
|
28
25
|
export * from "./utils/index.js";
|
|
29
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/spectrum/index.ts"],"sourcesContent":["/**\n * Re-exporting React Spectrum components + props.\n */\nexport * from './buttons';\nexport * from './collections';\nexport * from './content';\nexport * from './dateAndTime';\nexport * from './forms';\nexport * from './layout';\nexport * from './navigation';\nexport * from './overlays';\nexport * from './pickers';\nexport * from './shared';\nexport * from './status';\n\n/**\n * Custom DH components wrapping React Spectrum components.\n */\nexport * from './
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/spectrum/index.ts"],"sourcesContent":["/**\n * Re-exporting React Spectrum components + props.\n */\nexport * from './buttons';\nexport * from './collections';\nexport * from './content';\nexport * from './dateAndTime';\nexport * from './forms';\nexport * from './layout';\nexport * from './navigation';\nexport * from './overlays';\nexport * from './pickers';\nexport * from './shared';\nexport * from './status';\n\n/**\n * Custom DH components wrapping React Spectrum components.\n */\nexport * from './picker';\nexport * from './Heading';\nexport * from './Text';\nexport * from './View';\n\n/**\n * Custom DH spectrum utils\n */\nexport * from './utils';\n"],"mappings":"AAAA;AACA;AACA;AAFA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA;AACA;AACA;AAFA;AAAA;AAAA;AAAA;AAQA;AACA;AACA;AAFA"}
|
|
@@ -1 +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":";AAgBA,OAAO,EAEL,6BAA6B,EAG7B,cAAc,EACd,aAAa,EACb,cAAc,EACd,OAAO,EAER,MAAM,oBAAoB,CAAC;AAK5B,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,cAAc,EAAE,CAAC;IAC7D,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,iEAAiE;IACjE,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,2EAA2E;IAC3E,wBAAwB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACxD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAElC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAElC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C,GAKK,IAAI,CACR,6BAA6B,EAC3B,UAAU,GACV,OAAO,GACP,mBAAmB,GACnB,aAAa,GACb,oBAAoB,CACvB,CAAC;AAsBF;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,OAAc,EACd,kBAAkB,EAClB,WAAW,EACX,wBAAwB,EACxB,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,iBAAiB,EAEjB,gBAAgB,EAChB,GAAG,mBAAmB,EACvB,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAoI3B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -7,14 +7,36 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
7
7
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
8
8
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
9
9
|
import { useCallback, useMemo } from 'react';
|
|
10
|
-
import { Picker as SpectrumPicker } from '@adobe/react-spectrum';
|
|
11
|
-
import { getPositionOfSelectedItem, findSpectrumPickerScrollArea, usePopoverOnScrollRef } from '@deephaven/react-hooks';
|
|
10
|
+
import { Flex, Picker as SpectrumPicker } from '@adobe/react-spectrum';
|
|
11
|
+
import { getPositionOfSelectedItem, findSpectrumPickerScrollArea, isElementOfType, usePopoverOnScrollRef } from '@deephaven/react-hooks';
|
|
12
12
|
import { EMPTY_FUNCTION, PICKER_ITEM_HEIGHT, PICKER_TOP_OFFSET } from '@deephaven/utils';
|
|
13
13
|
import cl from 'classnames';
|
|
14
|
+
import { Tooltip } from "../../popper/index.js";
|
|
14
15
|
import { isNormalizedSection, normalizeItemList, normalizeTooltipOptions, getItemKey } from "../utils/itemUtils.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
16
|
+
import { PickerItemContent } from "./PickerItemContent.js";
|
|
17
|
+
import { Item, Section } from "../shared.js";
|
|
18
|
+
import { Text } from "../Text.js";
|
|
17
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
/**
|
|
23
|
+
* Create tooltip content optionally wrapping with a Flex column for array
|
|
24
|
+
* content. This is needed for Items containing description `Text` elements.
|
|
25
|
+
*/
|
|
26
|
+
function createTooltipContent(content) {
|
|
27
|
+
if (typeof content === 'boolean') {
|
|
28
|
+
return String(content);
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(content)) {
|
|
31
|
+
return /*#__PURE__*/_jsx(Flex, {
|
|
32
|
+
direction: "column",
|
|
33
|
+
alignItems: "start",
|
|
34
|
+
children: content.filter(node => isElementOfType(node, Text))
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return content;
|
|
38
|
+
}
|
|
39
|
+
|
|
18
40
|
/**
|
|
19
41
|
* Picker component for selecting items from a list of items. Items can be
|
|
20
42
|
* provided via the `items` prop or as children. Each item can be a string,
|
|
@@ -39,7 +61,35 @@ export function Picker(_ref) {
|
|
|
39
61
|
spectrumPickerProps = _objectWithoutProperties(_ref, _excluded);
|
|
40
62
|
var normalizedItems = useMemo(() => normalizeItemList(children), [children]);
|
|
41
63
|
var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip), [tooltip]);
|
|
42
|
-
var
|
|
64
|
+
var renderItem = useCallback(normalizedItem => {
|
|
65
|
+
var _normalizedItem$item$, _normalizedItem$item, _normalizedItem$item$2, _normalizedItem$item2;
|
|
66
|
+
var key = getItemKey(normalizedItem);
|
|
67
|
+
var content = (_normalizedItem$item$ = (_normalizedItem$item = normalizedItem.item) === null || _normalizedItem$item === void 0 ? void 0 : _normalizedItem$item.content) !== null && _normalizedItem$item$ !== void 0 ? _normalizedItem$item$ : '';
|
|
68
|
+
var textValue = (_normalizedItem$item$2 = (_normalizedItem$item2 = normalizedItem.item) === null || _normalizedItem$item2 === void 0 ? void 0 : _normalizedItem$item2.textValue) !== null && _normalizedItem$item$2 !== void 0 ? _normalizedItem$item$2 : '';
|
|
69
|
+
return /*#__PURE__*/_jsx(Item
|
|
70
|
+
// Note that setting the `key` prop explicitly on `Item` elements
|
|
71
|
+
// causes the picker to expect `selectedKey` and `defaultSelectedKey`
|
|
72
|
+
// to be strings. It also passes the stringified value of the key to
|
|
73
|
+
// `onSelectionChange` handlers` regardless of the actual type of the
|
|
74
|
+
// key. We can't really get around setting in order to support Windowed
|
|
75
|
+
// data, so we'll need to do some manual conversion of keys to strings
|
|
76
|
+
// in other places of this component.
|
|
77
|
+
, {
|
|
78
|
+
// The `textValue` prop gets used to provide the content of `<option>`
|
|
79
|
+
// elements that back the Spectrum Picker. These are not visible in the UI,
|
|
80
|
+
// but are used for accessibility purposes, so we set to an arbitrary
|
|
81
|
+
// 'Empty' value so that they are not empty strings.
|
|
82
|
+
textValue: textValue === '' ? 'Empty' : textValue,
|
|
83
|
+
children: /*#__PURE__*/_jsxs(_Fragment, {
|
|
84
|
+
children: [/*#__PURE__*/_jsx(PickerItemContent, {
|
|
85
|
+
children: content
|
|
86
|
+
}), tooltipOptions == null || content === '' ? null : /*#__PURE__*/_jsx(Tooltip, {
|
|
87
|
+
options: tooltipOptions,
|
|
88
|
+
children: createTooltipContent(content)
|
|
89
|
+
})]
|
|
90
|
+
})
|
|
91
|
+
}, key);
|
|
92
|
+
}, [tooltipOptions]);
|
|
43
93
|
var getInitialScrollPositionInternal = useCallback(() => getInitialScrollPosition == null ? getPositionOfSelectedItem({
|
|
44
94
|
keyedItems: normalizedItems,
|
|
45
95
|
// TODO: #1890 & deephaven-plugins#371 add support for sections and
|
|
@@ -69,6 +119,7 @@ export function Picker(_ref) {
|
|
|
69
119
|
return /*#__PURE__*/_jsx(SpectrumPicker
|
|
70
120
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
71
121
|
, _objectSpread(_objectSpread({}, spectrumPickerProps), {}, {
|
|
122
|
+
// The `ref` prop type defined by React Spectrum is incorrect here
|
|
72
123
|
ref: scrollRef,
|
|
73
124
|
onOpenChange: onOpenChangeInternal,
|
|
74
125
|
UNSAFE_className: cl('dh-picker', UNSAFE_className),
|
|
@@ -78,8 +129,8 @@ export function Picker(_ref) {
|
|
|
78
129
|
// ensure that `selectedKey` and `defaultSelectedKey` are strings in order
|
|
79
130
|
// for selection to work.
|
|
80
131
|
,
|
|
81
|
-
selectedKey: selectedKey
|
|
82
|
-
defaultSelectedKey: defaultSelectedKey
|
|
132
|
+
selectedKey: selectedKey === null || selectedKey === void 0 ? void 0 : selectedKey.toString(),
|
|
133
|
+
defaultSelectedKey: defaultSelectedKey === null || defaultSelectedKey === void 0 ? void 0 : defaultSelectedKey.toString()
|
|
83
134
|
// `onChange` is just an alias for `onSelectionChange`
|
|
84
135
|
,
|
|
85
136
|
onSelectionChange: onSelectionChangeInternal,
|
|
@@ -89,10 +140,10 @@ export function Picker(_ref) {
|
|
|
89
140
|
return /*#__PURE__*/_jsx(Section, {
|
|
90
141
|
title: (_itemOrSection$item = itemOrSection.item) === null || _itemOrSection$item === void 0 ? void 0 : _itemOrSection$item.title,
|
|
91
142
|
items: (_itemOrSection$item2 = itemOrSection.item) === null || _itemOrSection$item2 === void 0 ? void 0 : _itemOrSection$item2.items,
|
|
92
|
-
children:
|
|
143
|
+
children: renderItem
|
|
93
144
|
}, getItemKey(itemOrSection));
|
|
94
145
|
}
|
|
95
|
-
return
|
|
146
|
+
return renderItem(itemOrSection);
|
|
96
147
|
}
|
|
97
148
|
}));
|
|
98
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.js","names":["useCallback","useMemo","Picker","SpectrumPicker","getPositionOfSelectedItem","findSpectrumPickerScrollArea","usePopoverOnScrollRef","EMPTY_FUNCTION","PICKER_ITEM_HEIGHT","PICKER_TOP_OFFSET","cl","isNormalizedSection","normalizeItemList","normalizeTooltipOptions","getItemKey","Section","useRenderNormalizedItem","jsx","_jsx","_ref","children","tooltip","defaultSelectedKey","selectedKey","getInitialScrollPosition","onChange","onOpenChange","onScroll","onSelectionChange","UNSAFE_className","spectrumPickerProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderNormalizedItem","getInitialScrollPositionInternal","keyedItems","itemHeight","topOffset","ref","scrollRef","popoverOnOpenChange","onOpenChangeInternal","isOpen","onSelectionChangeInternal","key","_getItemKey","_ref2","selectedItem","find","item","String","actualKey","_objectSpread","items","toString","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { DOMRef } from '@react-types/shared';\nimport { Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport {\n getPositionOfSelectedItem,\n findSpectrumPickerScrollArea,\n usePopoverOnScrollRef,\n} from '@deephaven/react-hooks';\nimport {\n EMPTY_FUNCTION,\n PICKER_ITEM_HEIGHT,\n PICKER_TOP_OFFSET,\n} from '@deephaven/utils';\nimport cl from 'classnames';\nimport {\n isNormalizedSection,\n NormalizedSpectrumPickerProps,\n normalizeItemList,\n normalizeTooltipOptions,\n NormalizedItem,\n ItemOrSection,\n TooltipOptions,\n ItemKey,\n getItemKey,\n} from '../utils/itemUtils';\nimport { Section } from '../shared';\nimport { useRenderNormalizedItem } from '../utils';\n\nexport type PickerProps = {\n children: ItemOrSection | ItemOrSection[] | NormalizedItem[];\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n /** The currently selected key in the collection (controlled). */\n selectedKey?: ItemKey | null;\n /** The initial selected key in the collection (uncontrolled). */\n defaultSelectedKey?: ItemKey;\n /** Function to retrieve initial scroll position when opening the picker */\n getInitialScrollPosition?: () => Promise<number | null>;\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (key: ItemKey) => void;\n\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead\n */\n onSelectionChange?: (key: ItemKey) => void;\n} /*\n * Support remaining SpectrumPickerProps.\n * Note that `selectedKey`, `defaultSelectedKey`, and `onSelectionChange` are\n * re-defined above to account for boolean types which aren't included in the\n * React `Key` type, but are actually supported by the Spectrum Picker component.\n */ & Omit<\n NormalizedSpectrumPickerProps,\n | 'children'\n | 'items'\n | 'onSelectionChange'\n | 'selectedKey'\n | 'defaultSelectedKey'\n>;\n\n/**\n * Picker component for selecting items from a list of items. Items can be\n * provided via the `items` prop or as children. Each item can be a string,\n * number, boolean, or a Spectrum <Item> element. The remaining props are just\n * pass through props for the Spectrum Picker component.\n * See https://react-spectrum.adobe.com/react-spectrum/Picker.html\n */\nexport function Picker({\n children,\n tooltip = true,\n defaultSelectedKey,\n selectedKey,\n getInitialScrollPosition,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n // eslint-disable-next-line camelcase\n UNSAFE_className,\n ...spectrumPickerProps\n}: PickerProps): JSX.Element {\n const normalizedItems = useMemo(\n () => normalizeItemList(children),\n [children]\n );\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);\n\n const getInitialScrollPositionInternal = useCallback(\n () =>\n getInitialScrollPosition == null\n ? getPositionOfSelectedItem({\n keyedItems: normalizedItems,\n // TODO: #1890 & deephaven-plugins#371 add support for sections and\n // items with descriptions since they impact the height calculations\n itemHeight: PICKER_ITEM_HEIGHT,\n selectedKey,\n topOffset: PICKER_TOP_OFFSET,\n })\n : getInitialScrollPosition(),\n [getInitialScrollPosition, normalizedItems, selectedKey]\n );\n\n const { ref: scrollRef, onOpenChange: popoverOnOpenChange } =\n usePopoverOnScrollRef(\n findSpectrumPickerScrollArea,\n onScroll,\n getInitialScrollPositionInternal\n );\n\n const onOpenChangeInternal = useCallback(\n (isOpen: boolean): void => {\n // Attach scroll event handling\n popoverOnOpenChange(isOpen);\n\n onOpenChange?.(isOpen);\n },\n [onOpenChange, popoverOnOpenChange]\n );\n\n const onSelectionChangeInternal = useCallback(\n (key: ItemKey): void => {\n // The `key` arg will always be a string due to us setting the `Item` key\n // prop in `renderItem`. We need to find the matching item to determine\n // the actual key.\n const selectedItem = normalizedItems.find(\n item => String(getItemKey(item)) === key\n );\n\n const actualKey = getItemKey(selectedItem) ?? key;\n\n (onChange ?? onSelectionChange)?.(actualKey);\n },\n [normalizedItems, onChange, onSelectionChange]\n );\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumPickerProps}\n ref={scrollRef as unknown as DOMRef<HTMLDivElement>}\n onOpenChange={onOpenChangeInternal}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n items={normalizedItems}\n // Spectrum Picker treats keys as strings if the `key` prop is explicitly\n // set on `Item` elements. Since we do this in `renderItem`, we need to\n // ensure that `selectedKey` and `defaultSelectedKey` are strings in order\n // for selection to work.\n selectedKey={selectedKey == null ? selectedKey : selectedKey.toString()}\n defaultSelectedKey={\n defaultSelectedKey == null\n ? defaultSelectedKey\n : defaultSelectedKey.toString()\n }\n // `onChange` is just an alias for `onSelectionChange`\n onSelectionChange={\n onSelectionChangeInternal as NormalizedSpectrumPickerProps['onSelectionChange']\n }\n >\n {itemOrSection => {\n if (isNormalizedSection(itemOrSection)) {\n return (\n <Section\n key={getItemKey(itemOrSection)}\n title={itemOrSection.item?.title}\n items={itemOrSection.item?.items}\n >\n {renderNormalizedItem}\n </Section>\n );\n }\n\n return renderNormalizedItem(itemOrSection);\n }}\n </SpectrumPicker>\n );\n}\n\nexport default Picker;\n"],"mappings":";;;;;;;;AAAA,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAE5C,SAASC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AAChE,SACEC,yBAAyB,EACzBC,4BAA4B,EAC5BC,qBAAqB,QAChB,wBAAwB;AAC/B,SACEC,cAAc,EACdC,kBAAkB,EAClBC,iBAAiB,QACZ,kBAAkB;AACzB,OAAOC,EAA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Aa,IAAI;MAChB,IAAI9C,mBAAmB,CAAC8C,aAAa,CAAC,EAAE;QAAA,IAAAC,mBAAA,EAAAC,oBAAA;QACtC,oBACEzC,IAAA,CAACH,OAAO;UAEN6C,KAAK,GAAAF,mBAAA,GAAED,aAAa,CAACN,IAAI,cAAAO,mBAAA,uBAAlBA,mBAAA,CAAoBE,KAAM;UACjCL,KAAK,GAAAI,oBAAA,GAAEF,aAAa,CAACN,IAAI,cAAAQ,oBAAA,uBAAlBA,oBAAA,CAAoBJ,KAAM;UAAAnC,QAAA,EAEhCe;QAAoB,GAJhBrB,UAAU,CAAC2C,aAAa,CAKtB,CAAC;MAEd;MAEA,OAAOtB,oBAAoB,CAACsB,aAAa,CAAC;IAC5C;EAAC,EACa,CAAC;AAErB;AAEA,eAAevD,MAAM"}
|
|
1
|
+
{"version":3,"file":"Picker.js","names":["useCallback","useMemo","Flex","Picker","SpectrumPicker","getPositionOfSelectedItem","findSpectrumPickerScrollArea","isElementOfType","usePopoverOnScrollRef","EMPTY_FUNCTION","PICKER_ITEM_HEIGHT","PICKER_TOP_OFFSET","cl","Tooltip","isNormalizedSection","normalizeItemList","normalizeTooltipOptions","getItemKey","PickerItemContent","Item","Section","Text","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","createTooltipContent","content","String","Array","isArray","direction","alignItems","children","filter","node","_ref","tooltip","defaultSelectedKey","selectedKey","getInitialScrollPosition","onChange","onOpenChange","onScroll","onSelectionChange","UNSAFE_className","spectrumPickerProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderItem","normalizedItem","_normalizedItem$item$","_normalizedItem$item","_normalizedItem$item$2","_normalizedItem$item2","key","item","textValue","options","getInitialScrollPositionInternal","keyedItems","itemHeight","topOffset","ref","scrollRef","popoverOnOpenChange","onOpenChangeInternal","isOpen","onSelectionChangeInternal","_getItemKey","_ref2","selectedItem","find","actualKey","_objectSpread","items","toString","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { Key, ReactNode, useCallback, useMemo } from 'react';\nimport { DOMRef } from '@react-types/shared';\nimport { Flex, Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport {\n getPositionOfSelectedItem,\n findSpectrumPickerScrollArea,\n isElementOfType,\n usePopoverOnScrollRef,\n} from '@deephaven/react-hooks';\nimport {\n EMPTY_FUNCTION,\n PICKER_ITEM_HEIGHT,\n PICKER_TOP_OFFSET,\n} from '@deephaven/utils';\nimport cl from 'classnames';\nimport { Tooltip } from '../../popper';\nimport {\n isNormalizedSection,\n NormalizedSpectrumPickerProps,\n normalizeItemList,\n normalizeTooltipOptions,\n NormalizedItem,\n ItemOrSection,\n TooltipOptions,\n ItemKey,\n getItemKey,\n} from '../utils/itemUtils';\nimport { PickerItemContent } from './PickerItemContent';\nimport { Item, Section } from '../shared';\nimport { Text } from '../Text';\n\nexport type PickerProps = {\n children: ItemOrSection | ItemOrSection[] | NormalizedItem[];\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n /** The currently selected key in the collection (controlled). */\n selectedKey?: ItemKey | null;\n /** The initial selected key in the collection (uncontrolled). */\n defaultSelectedKey?: ItemKey;\n /** Function to retrieve initial scroll position when opening the picker */\n getInitialScrollPosition?: () => Promise<number | null>;\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (key: ItemKey) => void;\n\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead\n */\n onSelectionChange?: (key: ItemKey) => void;\n} /*\n * Support remaining SpectrumPickerProps.\n * Note that `selectedKey`, `defaultSelectedKey`, and `onSelectionChange` are\n * re-defined above to account for boolean types which aren't included in the\n * React `Key` type, but are actually supported by the Spectrum Picker component.\n */ & Omit<\n NormalizedSpectrumPickerProps,\n | 'children'\n | 'items'\n | 'onSelectionChange'\n | 'selectedKey'\n | 'defaultSelectedKey'\n>;\n\n/**\n * Create tooltip content optionally wrapping with a Flex column for array\n * content. This is needed for Items containing description `Text` elements.\n */\nfunction createTooltipContent(content: ReactNode) {\n if (typeof content === 'boolean') {\n return String(content);\n }\n\n if (Array.isArray(content)) {\n return (\n <Flex direction=\"column\" alignItems=\"start\">\n {content.filter(node => isElementOfType(node, Text))}\n </Flex>\n );\n }\n\n return content;\n}\n\n/**\n * Picker component for selecting items from a list of items. Items can be\n * provided via the `items` prop or as children. Each item can be a string,\n * number, boolean, or a Spectrum <Item> element. The remaining props are just\n * pass through props for the Spectrum Picker component.\n * See https://react-spectrum.adobe.com/react-spectrum/Picker.html\n */\nexport function Picker({\n children,\n tooltip = true,\n defaultSelectedKey,\n selectedKey,\n getInitialScrollPosition,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n // eslint-disable-next-line camelcase\n UNSAFE_className,\n ...spectrumPickerProps\n}: PickerProps): JSX.Element {\n const normalizedItems = useMemo(\n () => normalizeItemList(children),\n [children]\n );\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderItem = useCallback(\n (normalizedItem: NormalizedItem) => {\n const key = getItemKey(normalizedItem);\n const content = normalizedItem.item?.content ?? '';\n const textValue = normalizedItem.item?.textValue ?? '';\n\n return (\n <Item\n // Note that setting the `key` prop explicitly on `Item` elements\n // causes the picker to expect `selectedKey` and `defaultSelectedKey`\n // to be strings. It also passes the stringified value of the key to\n // `onSelectionChange` handlers` regardless of the actual type of the\n // key. We can't really get around setting in order to support Windowed\n // data, so we'll need to do some manual conversion of keys to strings\n // in other places of this component.\n key={key as Key}\n // The `textValue` prop gets used to provide the content of `<option>`\n // elements that back the Spectrum Picker. These are not visible in the UI,\n // but are used for accessibility purposes, so we set to an arbitrary\n // 'Empty' value so that they are not empty strings.\n textValue={textValue === '' ? 'Empty' : textValue}\n >\n <>\n <PickerItemContent>{content}</PickerItemContent>\n {tooltipOptions == null || content === '' ? null : (\n <Tooltip options={tooltipOptions}>\n {createTooltipContent(content)}\n </Tooltip>\n )}\n </>\n </Item>\n );\n },\n [tooltipOptions]\n );\n\n const getInitialScrollPositionInternal = useCallback(\n () =>\n getInitialScrollPosition == null\n ? getPositionOfSelectedItem({\n keyedItems: normalizedItems,\n // TODO: #1890 & deephaven-plugins#371 add support for sections and\n // items with descriptions since they impact the height calculations\n itemHeight: PICKER_ITEM_HEIGHT,\n selectedKey,\n topOffset: PICKER_TOP_OFFSET,\n })\n : getInitialScrollPosition(),\n [getInitialScrollPosition, normalizedItems, selectedKey]\n );\n\n const { ref: scrollRef, onOpenChange: popoverOnOpenChange } =\n usePopoverOnScrollRef(\n findSpectrumPickerScrollArea,\n onScroll,\n getInitialScrollPositionInternal\n );\n\n const onOpenChangeInternal = useCallback(\n (isOpen: boolean): void => {\n // Attach scroll event handling\n popoverOnOpenChange(isOpen);\n\n onOpenChange?.(isOpen);\n },\n [onOpenChange, popoverOnOpenChange]\n );\n\n const onSelectionChangeInternal = useCallback(\n (key: ItemKey): void => {\n // The `key` arg will always be a string due to us setting the `Item` key\n // prop in `renderItem`. We need to find the matching item to determine\n // the actual key.\n const selectedItem = normalizedItems.find(\n item => String(getItemKey(item)) === key\n );\n\n const actualKey = getItemKey(selectedItem) ?? key;\n\n (onChange ?? onSelectionChange)?.(actualKey);\n },\n [normalizedItems, onChange, onSelectionChange]\n );\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumPickerProps}\n // The `ref` prop type defined by React Spectrum is incorrect here\n ref={scrollRef as unknown as DOMRef<HTMLDivElement>}\n onOpenChange={onOpenChangeInternal}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n items={normalizedItems}\n // Spectrum Picker treats keys as strings if the `key` prop is explicitly\n // set on `Item` elements. Since we do this in `renderItem`, we need to\n // ensure that `selectedKey` and `defaultSelectedKey` are strings in order\n // for selection to work.\n selectedKey={selectedKey?.toString()}\n defaultSelectedKey={defaultSelectedKey?.toString()}\n // `onChange` is just an alias for `onSelectionChange`\n onSelectionChange={\n onSelectionChangeInternal as NormalizedSpectrumPickerProps['onSelectionChange']\n }\n >\n {itemOrSection => {\n if (isNormalizedSection(itemOrSection)) {\n return (\n <Section\n key={getItemKey(itemOrSection)}\n title={itemOrSection.item?.title}\n items={itemOrSection.item?.items}\n >\n {renderItem}\n </Section>\n );\n }\n\n return renderItem(itemOrSection);\n }}\n </SpectrumPicker>\n );\n}\n\nexport default Picker;\n"],"mappings":";;;;;;;;AAAA,SAAyBA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAE5D,SAASC,IAAI,EAAEC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AACtE,SACEC,yBAAyB,EACzBC,4BAA4B,EAC5BC,eAAe,EACfC,qBAAqB,QAChB,wBAAwB;AAC/B,SACEC,cAAc,EACdC,kBAAkB,EAClBC,iBAAiB,QACZ,kBAAkB;AACzB,OAAOC,EAAE,MAAM,YAAY;AAAC,SACnBC,OAAO;AAAA,SAEdC,mBAAmB,EAEnBC,iBAAiB,EACjBC,uBAAuB,EAKvBC,UAAU;AAAA,SAEHC,iBAAiB;AAAA,SACjBC,IAAI,EAAEC,OAAO;AAAA,SACbC,IAAI;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AA0Cb;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAACC,OAAkB,EAAE;EAChD,IAAI,OAAOA,OAAO,KAAK,SAAS,EAAE;IAChC,OAAOC,MAAM,CAACD,OAAO,CAAC;EACxB;EAEA,IAAIE,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,EAAE;IAC1B,oBACEN,IAAA,CAACrB,IAAI;MAAC+B,SAAS,EAAC,QAAQ;MAACC,UAAU,EAAC,OAAO;MAAAC,QAAA,E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B,IAAI,cAAAuB,oBAAA,uBAAlBA,oBAAA,CAAoBJ,KAAM;UAAA5C,QAAA,EAEhCkB;QAAU,GAJNpC,UAAU,CAACgE,aAAa,CAKtB,CAAC;MAEd;MAEA,OAAO5B,UAAU,CAAC4B,aAAa,CAAC;IAClC;EAAC,EACa,CAAC;AAErB;AAEA,eAAe9E,MAAM"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface PickerItemContentProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Picker item content. Text content will be wrapped in a Spectrum Text
|
|
7
|
+
* component with ellipsis overflow handling.
|
|
8
|
+
*/
|
|
9
|
+
export declare function PickerItemContent({ children: content, }: PickerItemContentProps): JSX.Element | null;
|
|
10
|
+
export default PickerItemContent;
|
|
11
|
+
//# sourceMappingURL=PickerItemContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PickerItemContent.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerItemContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,SAAS,EAAE,MAAM,OAAO,CAAC;AAM1E,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EAAE,OAAO,GAClB,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAyC7C;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -3,39 +3,21 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
3
3
|
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; }
|
|
4
4
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
5
5
|
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); }
|
|
6
|
-
import { Children, cloneElement, isValidElement
|
|
6
|
+
import { Children, cloneElement, isValidElement } from 'react';
|
|
7
|
+
import { Text } from '@adobe/react-spectrum';
|
|
7
8
|
import cl from 'classnames';
|
|
8
|
-
import { isElementOfType
|
|
9
|
-
import
|
|
10
|
-
import ItemTooltip from "./ItemTooltip.js";
|
|
11
|
-
import stylesCommon from "../SpectrumComponent.module.css";
|
|
9
|
+
import { isElementOfType } from '@deephaven/react-hooks';
|
|
10
|
+
import stylesCommon from "../../SpectrumComponent.module.css";
|
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
17
|
-
* component with ellipsis overflow handling.
|
|
18
|
-
* tooltipOptions are provided a tooltip will be displayed when hovering over
|
|
19
|
-
* the item content.
|
|
14
|
+
* Picker item content. Text content will be wrapped in a Spectrum Text
|
|
15
|
+
* component with ellipsis overflow handling.
|
|
20
16
|
*/
|
|
21
|
-
export function
|
|
17
|
+
export function PickerItemContent(_ref) {
|
|
22
18
|
var {
|
|
23
|
-
children: content
|
|
24
|
-
tooltipOptions
|
|
19
|
+
children: content
|
|
25
20
|
} = _ref;
|
|
26
|
-
var {
|
|
27
|
-
checkOverflow,
|
|
28
|
-
isOverflowing,
|
|
29
|
-
resetIsOverflowing
|
|
30
|
-
} = useCheckOverflow();
|
|
31
|
-
var [previousContent, setPreviousContent] = useState(content);
|
|
32
|
-
|
|
33
|
-
// Reset `isOverflowing` if content changes. It will get re-calculated as
|
|
34
|
-
// `Text` components render.
|
|
35
|
-
if (previousContent !== content) {
|
|
36
|
-
setPreviousContent(content);
|
|
37
|
-
resetIsOverflowing();
|
|
38
|
-
}
|
|
39
21
|
if ( /*#__PURE__*/isValidElement(content)) {
|
|
40
22
|
return content;
|
|
41
23
|
}
|
|
@@ -56,27 +38,21 @@ export function ItemContent(_ref) {
|
|
|
56
38
|
// <Text>Some Label</Text>
|
|
57
39
|
// <Text slot="description">Some Description</Text>
|
|
58
40
|
// </Item>
|
|
59
|
-
content = Children.map(content, el => isElementOfType(el, Text) ? /*#__PURE__*/cloneElement(el, _objectSpread(_objectSpread({}, el.props), {}, {
|
|
60
|
-
ref: checkOverflow,
|
|
41
|
+
content = Children.map(content, (el, i) => isElementOfType(el, Text) ? /*#__PURE__*/cloneElement(el, _objectSpread(_objectSpread({}, el.props), {}, {
|
|
61
42
|
UNSAFE_className: cl(el.props.UNSAFE_className, stylesCommon.spectrumEllipsis)
|
|
62
43
|
})) : el);
|
|
63
44
|
}
|
|
64
|
-
if (typeof content === 'string' || typeof content === 'number') {
|
|
65
|
-
content = /*#__PURE__*/_jsx(Text, {
|
|
66
|
-
ref: checkOverflow,
|
|
67
|
-
UNSAFE_className: stylesCommon.spectrumEllipsis,
|
|
68
|
-
children: content
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
45
|
/* eslint-enable no-param-reassign */
|
|
72
46
|
|
|
73
|
-
|
|
74
|
-
|
|
47
|
+
return typeof content === 'string' || typeof content === 'number' ? /*#__PURE__*/_jsx(Text, {
|
|
48
|
+
UNSAFE_className: stylesCommon.spectrumEllipsis,
|
|
49
|
+
children: content
|
|
50
|
+
}) :
|
|
51
|
+
/*#__PURE__*/
|
|
52
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
53
|
+
_jsx(_Fragment, {
|
|
75
54
|
children: content
|
|
76
|
-
});
|
|
77
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
78
|
-
children: [content, tooltip]
|
|
79
55
|
});
|
|
80
56
|
}
|
|
81
|
-
export default
|
|
82
|
-
//# sourceMappingURL=
|
|
57
|
+
export default PickerItemContent;
|
|
58
|
+
//# sourceMappingURL=PickerItemContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PickerItemContent.js","names":["Children","cloneElement","isValidElement","Text","cl","isElementOfType","stylesCommon","jsx","_jsx","Fragment","_Fragment","PickerItemContent","_ref","children","content","String","Array","isArray","map","el","i","_objectSpread","props","UNSAFE_className","spectrumEllipsis"],"sources":["../../../src/spectrum/picker/PickerItemContent.tsx"],"sourcesContent":["import { Children, cloneElement, isValidElement, ReactNode } from 'react';\nimport { Text } from '@adobe/react-spectrum';\nimport cl from 'classnames';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport stylesCommon from '../../SpectrumComponent.module.scss';\n\nexport interface PickerItemContentProps {\n children: ReactNode;\n}\n\n/**\n * Picker item content. Text content will be wrapped in a Spectrum Text\n * component with ellipsis overflow handling.\n */\nexport function PickerItemContent({\n children: content,\n}: PickerItemContentProps): JSX.Element | null {\n if (isValidElement(content)) {\n return content;\n }\n\n /* eslint-disable no-param-reassign */\n if (content === '') {\n // Prevent the item height from collapsing when the content is empty\n content = '\\xa0'; // Non-breaking space\n } else if (typeof content === 'boolean') {\n // Boolean values need to be stringified to render\n content = String(content);\n } else if (Array.isArray(content)) {\n // For cases where there are multiple `Text` children, add a css class to\n // handle overflow. The primary use case for multiple text nodes is when a\n // description is provided for an item. e.g.\n // <Item textValue=\"Some Text\">\n // <SomeIcon />\n // <Text>Some Label</Text>\n // <Text slot=\"description\">Some Description</Text>\n // </Item>\n content = Children.map(content, (el, i) =>\n isElementOfType(el, Text)\n ? cloneElement(el, {\n ...el.props,\n UNSAFE_className: cl(\n el.props.UNSAFE_className,\n stylesCommon.spectrumEllipsis\n ),\n })\n : el\n );\n }\n /* eslint-enable no-param-reassign */\n\n return typeof content === 'string' || typeof content === 'number' ? (\n <Text UNSAFE_className={stylesCommon.spectrumEllipsis}>{content}</Text>\n ) : (\n // eslint-disable-next-line react/jsx-no-useless-fragment\n <>{content}</>\n );\n}\n\nexport default PickerItemContent;\n"],"mappings":";;;;;AAAA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,cAAc,QAAmB,OAAO;AACzE,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,OAAOC,EAAE,MAAM,YAAY;AAC3B,SAASC,eAAe,QAAQ,wBAAwB;AAAC,OAClDC,YAAY;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAMnB;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAAC,IAAA,EAEc;EAAA,IAFb;IAChCC,QAAQ,EAAEC;EACY,CAAC,GAAAF,IAAA;EACvB,kBAAIV,cAAc,CAACY,OAAO,CAAC,EAAE;IAC3B,OAAOA,OAAO;EAChB;;EAEA;EACA,IAAIA,OAAO,KAAK,EAAE,EAAE;IAClB;IACAA,OAAO,GAAG,MAAM,CAAC,CAAC;EACpB,CAAC,MAAM,IAAI,OAAOA,OAAO,KAAK,SAAS,EAAE;IACvC;IACAA,OAAO,GAAGC,MAAM,CAACD,OAAO,CAAC;EAC3B,CAAC,MAAM,IAAIE,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,EAAE;IACjC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAA,OAAO,GAAGd,QAAQ,CAACkB,GAAG,CAACJ,OAAO,EAAE,CAACK,EAAE,EAAEC,CAAC,KACpCf,eAAe,CAACc,EAAE,EAAEhB,IAAI,CAAC,gBACrBF,YAAY,CAACkB,EAAE,EAAAE,aAAA,CAAAA,aAAA,KACVF,EAAE,CAACG,KAAK;MACXC,gBAAgB,EAAEnB,EAAE,CAClBe,EAAE,CAACG,KAAK,CAACC,gBAAgB,EACzBjB,YAAY,CAACkB,gBACf;IAAC,EACF,CAAC,GACFL,EACN,CAAC;EACH;EACA;;EAEA,OAAO,OAAOL,OAAO,KAAK,QAAQ,IAAI,OAAOA,OAAO,KAAK,QAAQ,gBAC/DN,IAAA,CAACL,IAAI;IAACoB,gBAAgB,EAAEjB,YAAY,CAACkB,gBAAiB;IAAAX,QAAA,EAAEC;EAAO,CAAO,CAAC;EAAA;EAEvE;EACAN,IAAA,CAAAE,SAAA;IAAAG,QAAA,EAAGC;EAAO,CAAG,CACd;AACH;AAEA,eAAeH,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/picker/index.ts"],"sourcesContent":["export * from './Picker';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/picker/index.ts"],"sourcesContent":["export * from './Picker';\nexport * from './PickerItemContent';\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/utils/index.ts"],"sourcesContent":["export * from './itemUtils';\nexport * from './themeUtils';\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/utils/index.ts"],"sourcesContent":["export * from './itemUtils';\nexport * from './themeUtils';\n"],"mappings":""}
|
|
@@ -49,7 +49,6 @@ export interface NormalizedSectionData {
|
|
|
49
49
|
*/
|
|
50
50
|
export type NormalizedItem = KeyedItem<NormalizedItemData, ItemKey | undefined>;
|
|
51
51
|
export type NormalizedSection = KeyedItem<NormalizedSectionData, Key | undefined>;
|
|
52
|
-
export type NormalizedItemOrSection<TItemOrSection extends ItemOrSection> = TItemOrSection extends SectionElement ? NormalizedSection : NormalizedItem;
|
|
53
52
|
export type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedItem>;
|
|
54
53
|
export type TooltipOptions = {
|
|
55
54
|
placement: PopperOptions['placement'];
|
|
@@ -77,12 +76,12 @@ export declare function isSectionElement<T>(node: ReactNode): node is ReactEleme
|
|
|
77
76
|
*/
|
|
78
77
|
export declare function isItemElement<T>(node: ReactNode): node is ReactElement<ItemProps<T>>;
|
|
79
78
|
/**
|
|
80
|
-
* Determine if a node is an array containing normalized items
|
|
81
|
-
*
|
|
79
|
+
* Determine if a node is an array containing normalized items with keys.
|
|
80
|
+
* Note that this only checks the first node in the array.
|
|
82
81
|
* @param node The node to check
|
|
83
|
-
* @returns True if the node is a normalized item
|
|
82
|
+
* @returns True if the node is a normalized item with keys array
|
|
84
83
|
*/
|
|
85
|
-
export declare function isNormalizedItemsWithKeysList
|
|
84
|
+
export declare function isNormalizedItemsWithKeysList(node: ItemOrSection | ItemOrSection[] | (NormalizedItem | NormalizedSection)[]): node is (NormalizedItem | NormalizedSection)[];
|
|
86
85
|
/**
|
|
87
86
|
* Determine if an object is a normalized section.
|
|
88
87
|
* @param maybeNormalizedSection The object to check
|
|
@@ -97,18 +96,16 @@ export declare function isNormalizedSection(maybeNormalizedSection: NormalizedIt
|
|
|
97
96
|
*/
|
|
98
97
|
export declare function isItemOrSection(node: ReactNode): node is ItemOrSection;
|
|
99
98
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @param itemsOrSections An item or
|
|
102
|
-
* @returns An array of normalized items
|
|
99
|
+
* Get normalized items from an item or array of items.
|
|
100
|
+
* @param itemsOrSections An item or array of items
|
|
101
|
+
* @returns An array of normalized items
|
|
103
102
|
*/
|
|
104
|
-
export declare function normalizeItemList
|
|
103
|
+
export declare function normalizeItemList(itemsOrSections: ItemOrSection | ItemOrSection[] | NormalizedItem[]): (NormalizedItem | NormalizedSection)[];
|
|
105
104
|
/**
|
|
106
105
|
* Returns a TooltipOptions object or null if options is false or null.
|
|
107
|
-
* @param options
|
|
108
|
-
* @param placement Default placement for the tooltip if `options` is set
|
|
109
|
-
* explicitly to `true`
|
|
106
|
+
* @param options
|
|
110
107
|
* @returns TooltipOptions or null
|
|
111
108
|
*/
|
|
112
|
-
export declare function normalizeTooltipOptions(options?: boolean | TooltipOptions | null
|
|
109
|
+
export declare function normalizeTooltipOptions(options?: boolean | TooltipOptions | null): TooltipOptions | null;
|
|
113
110
|
export {};
|
|
114
111
|
//# sourceMappingURL=itemUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/itemUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAQ,SAAS,EAAW,YAAY,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,eAAO,MAAM,0BAA0B,4EACoC,CAAC;AAE5E;;;;GAIG;AACH,KAAK,0BAA0B,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG;IACvE,QAAQ,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;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,IAAI,aAAa,CAQtE;AAiGD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,eAAe,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,cAAc,EAAE,GAClE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAWxC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,GACxC,cAAc,GAAG,IAAI,CAUvB"}
|
|
@@ -64,10 +64,10 @@ export function isItemElement(node) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* Determine if a node is an array containing normalized items
|
|
68
|
-
*
|
|
67
|
+
* Determine if a node is an array containing normalized items with keys.
|
|
68
|
+
* Note that this only checks the first node in the array.
|
|
69
69
|
* @param node The node to check
|
|
70
|
-
* @returns True if the node is a normalized item
|
|
70
|
+
* @returns True if the node is a normalized item with keys array
|
|
71
71
|
*/
|
|
72
72
|
export function isNormalizedItemsWithKeysList(node) {
|
|
73
73
|
if (!Array.isArray(node)) {
|
|
@@ -182,9 +182,9 @@ function normalizeItem(itemOrSection) {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
|
-
*
|
|
186
|
-
* @param itemsOrSections An item or
|
|
187
|
-
* @returns An array of normalized items
|
|
185
|
+
* Get normalized items from an item or array of items.
|
|
186
|
+
* @param itemsOrSections An item or array of items
|
|
187
|
+
* @returns An array of normalized items
|
|
188
188
|
*/
|
|
189
189
|
export function normalizeItemList(itemsOrSections) {
|
|
190
190
|
// If already normalized, just return as-is
|
|
@@ -197,19 +197,16 @@ export function normalizeItemList(itemsOrSections) {
|
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
199
|
* Returns a TooltipOptions object or null if options is false or null.
|
|
200
|
-
* @param options
|
|
201
|
-
* @param placement Default placement for the tooltip if `options` is set
|
|
202
|
-
* explicitly to `true`
|
|
200
|
+
* @param options
|
|
203
201
|
* @returns TooltipOptions or null
|
|
204
202
|
*/
|
|
205
203
|
export function normalizeTooltipOptions(options) {
|
|
206
|
-
var placement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'right';
|
|
207
204
|
if (options == null || options === false) {
|
|
208
205
|
return null;
|
|
209
206
|
}
|
|
210
207
|
if (options === true) {
|
|
211
208
|
return {
|
|
212
|
-
placement
|
|
209
|
+
placement: 'right'
|
|
213
210
|
};
|
|
214
211
|
}
|
|
215
212
|
return options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemUtils.js","names":["isValidElement","Log","Item","Section","log","module","INVALID_ITEM_ERROR_MESSAGE","getItemKey","item","_item$item$key","_item$item","key","isSectionElement","node","type","isItemElement","isNormalizedItemsWithKeysList","Array","isArray","length","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeItemKey","itemOrSection","_itemOrSection$props$","props","title","undefined","textValue","children","normalizeTextValue","String","normalizeItem","debug","Error","items","normalizeItemList","filter","childItem","content","itemsOrSections","itemsArray","map","normalizeTooltipOptions","options","placement","arguments"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { isValidElement, Key, ReactElement, ReactNode } from 'react';\nimport { SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type { ItemRenderer } from '@react-types/shared';\nimport Log from '@deephaven/log';\nimport { KeyedItem } from '@deephaven/utils';\nimport { Item, ItemProps, Section, SectionProps } from '../shared';\nimport { PopperOptions } from '../../popper';\n\nconst log = Log.module('itemUtils');\n\nexport const INVALID_ITEM_ERROR_MESSAGE =\n 'Items must be strings, numbers, booleans, <Item> or <Section> elements:';\n\n/**\n * React Spectrum <Section> supports an `ItemRenderer` function as a child. The\n * DH picker makes use of this internally, but we don't want to support it as\n * an incoming prop.\n */\ntype SectionPropsNoItemRenderer<T> = Omit<SectionProps<T>, 'children'> & {\n children: Exclude<SectionProps<T>['children'], ItemRenderer<T>>;\n};\n\ntype ItemElement = ReactElement<ItemProps<unknown>>;\nexport type SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;\n\nexport type ItemElementOrPrimitive = number | string | boolean | ItemElement;\nexport type ItemOrSection = ItemElementOrPrimitive | SectionElement;\n\n/**\n * Augment the Spectrum selection key type to include boolean values.\n * Spectrum collection components already supports this, but the built in types\n * don't reflect it.\n */\nexport type ItemKey = Key | boolean;\n\n/**\n * Augment the Spectrum selection change handler type to include boolean keys.\n * Spectrum components already supports this, but the built in types don't\n * reflect it.\n */\nexport type ItemSelectionChangeHandler = (key: ItemKey) => void;\n\nexport interface NormalizedItemData {\n key?: ItemKey;\n content: ReactNode;\n textValue?: string;\n}\n\nexport interface NormalizedSectionData {\n key?: Key;\n title?: ReactNode;\n items: NormalizedItem[];\n}\n\n/**\n * Spectrum collection components support a variety of item types, including\n * strings, numbers, booleans, and more complex React elements. This type\n * represents a normalized form to make rendering items simpler and keep the\n * logic of transformation in separate util methods. It also adheres to the\n * `KeyedItem` interface to be compatible with Windowed data utils\n * (e.g. `useViewportData`).\n */\nexport type NormalizedItem = KeyedItem<NormalizedItemData, ItemKey | undefined>;\n\nexport type NormalizedSection = KeyedItem<\n NormalizedSectionData,\n Key | undefined\n>;\n\nexport type NormalizedItemOrSection<TItemOrSection extends ItemOrSection> =\n TItemOrSection extends SectionElement ? NormalizedSection : NormalizedItem;\n\nexport type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedItem>;\n\nexport type TooltipOptions = { placement: PopperOptions['placement'] };\n\n/**\n * DH wrappers of Spectrum collection components use a normalized item that\n * includes a `key` prop and an optional `item` prop. This is mostly to support\n * Windowed data where items are created before their data has been loaded (data\n * gets set in the `item` prop). If data has loaded, return its `key`. If not,\n * return the top-level `key` on the normalized item.\n * @param item The normalized item or section\n * @returns The `key` of the item or section\n */\nexport function getItemKey<\n TItem extends NormalizedItem | NormalizedSection,\n TKey extends TItem extends NormalizedItem\n ? ItemKey | undefined\n : TItem extends NormalizedSection\n ? Key | undefined\n : undefined,\n>(item: TItem | null | undefined): TKey {\n return (item?.item?.key ?? item?.key) as TKey;\n}\n\n/**\n * Determine if a node is a Section element.\n * @param node The node to check\n * @returns True if the node is a Section element\n */\nexport function isSectionElement<T>(\n node: ReactNode\n): node is ReactElement<SectionProps<T>> {\n return isValidElement<SectionProps<T>>(node) && node.type === Section;\n}\n\n/**\n * Determine if a node is an Item element.\n * @param node The node to check\n * @returns True if the node is an Item element\n */\nexport function isItemElement<T>(\n node: ReactNode\n): node is ReactElement<ItemProps<T>> {\n return isValidElement<ItemProps<T>>(node) && node.type === Item;\n}\n\n/**\n * Determine if a node is an array containing normalized items or sections with\n * keys. Note that this only checks the first node in the array.\n * @param node The node to check\n * @returns True if the node is a normalized item or section with keys array\n */\nexport function isNormalizedItemsWithKeysList<\n TItemOrSection extends ItemOrSection,\n>(\n node:\n | TItemOrSection\n | TItemOrSection[]\n | NormalizedItemOrSection<TItemOrSection>[]\n): node is NormalizedItemOrSection<TItemOrSection>[] {\n if (!Array.isArray(node)) {\n return false;\n }\n\n if (node.length === 0) {\n return true;\n }\n\n return !isItemOrSection(node[0]) && 'key' in node[0];\n}\n\n/**\n * Determine if an object is a normalized section.\n * @param maybeNormalizedSection The object to check\n * @returns True if the object is a normalized section\n */\nexport function isNormalizedSection(\n maybeNormalizedSection: NormalizedItem | NormalizedSection\n): maybeNormalizedSection is NormalizedSection {\n return (\n maybeNormalizedSection.item != null &&\n 'items' in maybeNormalizedSection.item\n );\n}\n\n/**\n * Determine if a node is an item or section. Valid types include strings,\n * numbers, booleans, Item elements, and Section elements.\n * @param node The node to check\n * @returns True if the node is an item or section\n */\nexport function isItemOrSection(node: ReactNode): node is ItemOrSection {\n return (\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n isItemElement(node) ||\n isSectionElement(node)\n );\n}\n\n/**\n * Determine the `key` of an item or section.\n * @param itemOrSection The item or section\n * @returns A `ItemKey` for the item or undefined if a key can't be determined\n */\nfunction normalizeItemKey(item: ItemElementOrPrimitive): ItemKey | undefined;\nfunction normalizeItemKey(section: SectionElement): Key | undefined;\nfunction normalizeItemKey(\n itemOrSection: ItemElementOrPrimitive | SectionElement\n): Key | ItemKey | undefined {\n // string, number, or boolean\n if (typeof itemOrSection !== 'object') {\n return itemOrSection;\n }\n\n // If `key` prop is explicitly set\n if (itemOrSection.key != null) {\n return itemOrSection.key;\n }\n\n // Section element\n if (isSectionElement(itemOrSection)) {\n return typeof itemOrSection.props.title === 'string'\n ? itemOrSection.props.title\n : undefined;\n }\n\n // Item element\n return (\n itemOrSection.props.textValue ??\n (typeof itemOrSection.props.children === 'string'\n ? itemOrSection.props.children\n : undefined)\n );\n}\n\n/**\n * Get a normalized `textValue` for an item ensuring it is a string.\n * @param item The item\n * @returns A string `textValue` for the item\n */\nfunction normalizeTextValue(item: ItemElementOrPrimitive): string | undefined {\n if (typeof item !== 'object') {\n return String(item);\n }\n\n if (item.props.textValue != null) {\n return item.props.textValue;\n }\n\n if (typeof item.props.children === 'string') {\n return item.props.children;\n }\n\n return undefined;\n}\n\n/**\n * Normalize an item or section to an object form.\n * @param itemOrSection item to normalize\n * @returns NormalizedItem or NormalizedSection object\n */\nfunction normalizeItem<TItemOrSection extends ItemOrSection>(\n itemOrSection: TItemOrSection\n): NormalizedItemOrSection<TItemOrSection> {\n if (!isItemOrSection(itemOrSection)) {\n log.debug(INVALID_ITEM_ERROR_MESSAGE, itemOrSection);\n throw new Error(INVALID_ITEM_ERROR_MESSAGE);\n }\n\n if (isSectionElement(itemOrSection)) {\n const key = normalizeItemKey(itemOrSection);\n const { title } = itemOrSection.props;\n\n const items = normalizeItemList(itemOrSection.props.children).filter(\n // We don't support nested section elements\n childItem => !isSectionElement(childItem)\n ) as NormalizedItem[];\n\n return {\n item: { key, title, items },\n } as NormalizedItemOrSection<TItemOrSection>;\n }\n\n const key = normalizeItemKey(itemOrSection);\n const content = isItemElement(itemOrSection)\n ? itemOrSection.props.children\n : itemOrSection;\n const textValue = normalizeTextValue(itemOrSection);\n\n return {\n item: { key, content, textValue },\n } as NormalizedItemOrSection<TItemOrSection>;\n}\n\n/**\n * Normalize an item or section or a list of items or sections.\n * @param itemsOrSections An item or section or array of items or sections\n * @returns An array of normalized items or sections\n */\nexport function normalizeItemList<TItemOrSection extends ItemOrSection>(\n itemsOrSections: TItemOrSection | TItemOrSection[] | NormalizedItem[]\n): NormalizedItemOrSection<TItemOrSection>[] {\n // If already normalized, just return as-is\n if (isNormalizedItemsWithKeysList(itemsOrSections)) {\n return itemsOrSections as NormalizedItemOrSection<TItemOrSection>[];\n }\n\n const itemsArray: TItemOrSection[] = Array.isArray(itemsOrSections)\n ? itemsOrSections\n : [itemsOrSections];\n\n return itemsArray.map(normalizeItem);\n}\n\n/**\n * Returns a TooltipOptions object or null if options is false or null.\n * @param options Tooltip options\n * @param placement Default placement for the tooltip if `options` is set\n * explicitly to `true`\n * @returns TooltipOptions or null\n */\nexport function normalizeTooltipOptions(\n options?: boolean | TooltipOptions | null,\n placement: TooltipOptions['placement'] = 'right'\n): TooltipOptions | null {\n if (options == null || options === false) {\n return null;\n }\n\n if (options === true) {\n return { placement };\n }\n\n return options;\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAsC,OAAO;AAGpE,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SAExBC,IAAI,EAAaC,OAAO;AAGjC,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,WAAW,CAAC;AAEnC,OAAO,IAAMC,0BAA0B,GACrC,yEAAyE;;AAE3E;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAOxBC,IAA8B,EAAQ;EAAA,IAAAC,cAAA,EAAAC,UAAA;EAC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AuBA,CACrCC,OAAyC,EAElB;EAAA,IADvBC,SAAsC,GAAAC,SAAA,CAAA5B,MAAA,QAAA4B,SAAA,QAAAnB,SAAA,GAAAmB,SAAA,MAAG,OAAO;EAEhD,IAAIF,OAAO,IAAI,IAAI,IAAIA,OAAO,KAAK,KAAK,EAAE;IACxC,OAAO,IAAI;EACb;EAEA,IAAIA,OAAO,KAAK,IAAI,EAAE;IACpB,OAAO;MAAEC;IAAU,CAAC;EACtB;EAEA,OAAOD,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"itemUtils.js","names":["isValidElement","Log","Item","Section","log","module","INVALID_ITEM_ERROR_MESSAGE","getItemKey","item","_item$item$key","_item$item","key","isSectionElement","node","type","isItemElement","isNormalizedItemsWithKeysList","Array","isArray","length","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeItemKey","itemOrSection","_itemOrSection$props$","props","title","undefined","textValue","children","normalizeTextValue","String","normalizeItem","debug","Error","items","normalizeItemList","filter","childItem","content","itemsOrSections","itemsArray","map","normalizeTooltipOptions","options","placement"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { isValidElement, Key, ReactElement, ReactNode } from 'react';\nimport { SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type { ItemRenderer } from '@react-types/shared';\nimport Log from '@deephaven/log';\nimport { KeyedItem } from '@deephaven/utils';\nimport { Item, ItemProps, Section, SectionProps } from '../shared';\nimport { PopperOptions } from '../../popper';\n\nconst log = Log.module('itemUtils');\n\nexport const INVALID_ITEM_ERROR_MESSAGE =\n 'Items must be strings, numbers, booleans, <Item> or <Section> elements:';\n\n/**\n * React Spectrum <Section> supports an `ItemRenderer` function as a child. The\n * DH picker makes use of this internally, but we don't want to support it as\n * an incoming prop.\n */\ntype SectionPropsNoItemRenderer<T> = Omit<SectionProps<T>, 'children'> & {\n children: Exclude<SectionProps<T>['children'], ItemRenderer<T>>;\n};\n\ntype ItemElement = ReactElement<ItemProps<unknown>>;\nexport type SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;\n\nexport type ItemElementOrPrimitive = number | string | boolean | ItemElement;\nexport type ItemOrSection = ItemElementOrPrimitive | SectionElement;\n\n/**\n * Augment the Spectrum selection key type to include boolean values.\n * Spectrum collection components already supports this, but the built in types\n * don't reflect it.\n */\nexport type ItemKey = Key | boolean;\n\n/**\n * Augment the Spectrum selection change handler type to include boolean keys.\n * Spectrum components already supports this, but the built in types don't\n * reflect it.\n */\nexport type ItemSelectionChangeHandler = (key: ItemKey) => void;\n\nexport interface NormalizedItemData {\n key?: ItemKey;\n content: ReactNode;\n textValue?: string;\n}\n\nexport interface NormalizedSectionData {\n key?: Key;\n title?: ReactNode;\n items: NormalizedItem[];\n}\n\n/**\n * Spectrum collection components support a variety of item types, including\n * strings, numbers, booleans, and more complex React elements. This type\n * represents a normalized form to make rendering items simpler and keep the\n * logic of transformation in separate util methods. It also adheres to the\n * `KeyedItem` interface to be compatible with Windowed data utils\n * (e.g. `useViewportData`).\n */\nexport type NormalizedItem = KeyedItem<NormalizedItemData, ItemKey | undefined>;\n\nexport type NormalizedSection = KeyedItem<\n NormalizedSectionData,\n Key | undefined\n>;\n\nexport type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedItem>;\n\nexport type TooltipOptions = { placement: PopperOptions['placement'] };\n\n/**\n * DH wrappers of Spectrum collection components use a normalized item that\n * includes a `key` prop and an optional `item` prop. This is mostly to support\n * Windowed data where items are created before their data has been loaded (data\n * gets set in the `item` prop). If data has loaded, return its `key`. If not,\n * return the top-level `key` on the normalized item.\n * @param item The normalized item or section\n * @returns The `key` of the item or section\n */\nexport function getItemKey<\n TItem extends NormalizedItem | NormalizedSection,\n TKey extends TItem extends NormalizedItem\n ? ItemKey | undefined\n : TItem extends NormalizedSection\n ? Key | undefined\n : undefined,\n>(item: TItem | null | undefined): TKey {\n return (item?.item?.key ?? item?.key) as TKey;\n}\n\n/**\n * Determine if a node is a Section element.\n * @param node The node to check\n * @returns True if the node is a Section element\n */\nexport function isSectionElement<T>(\n node: ReactNode\n): node is ReactElement<SectionProps<T>> {\n return isValidElement<SectionProps<T>>(node) && node.type === Section;\n}\n\n/**\n * Determine if a node is an Item element.\n * @param node The node to check\n * @returns True if the node is an Item element\n */\nexport function isItemElement<T>(\n node: ReactNode\n): node is ReactElement<ItemProps<T>> {\n return isValidElement<ItemProps<T>>(node) && node.type === Item;\n}\n\n/**\n * Determine if a node is an array containing normalized items with keys.\n * Note that this only checks the first node in the array.\n * @param node The node to check\n * @returns True if the node is a normalized item with keys array\n */\nexport function isNormalizedItemsWithKeysList(\n node: ItemOrSection | ItemOrSection[] | (NormalizedItem | NormalizedSection)[]\n): node is (NormalizedItem | NormalizedSection)[] {\n if (!Array.isArray(node)) {\n return false;\n }\n\n if (node.length === 0) {\n return true;\n }\n\n return !isItemOrSection(node[0]) && 'key' in node[0];\n}\n\n/**\n * Determine if an object is a normalized section.\n * @param maybeNormalizedSection The object to check\n * @returns True if the object is a normalized section\n */\nexport function isNormalizedSection(\n maybeNormalizedSection: NormalizedItem | NormalizedSection\n): maybeNormalizedSection is NormalizedSection {\n return (\n maybeNormalizedSection.item != null &&\n 'items' in maybeNormalizedSection.item\n );\n}\n\n/**\n * Determine if a node is an item or section. Valid types include strings,\n * numbers, booleans, Item elements, and Section elements.\n * @param node The node to check\n * @returns True if the node is an item or section\n */\nexport function isItemOrSection(node: ReactNode): node is ItemOrSection {\n return (\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n isItemElement(node) ||\n isSectionElement(node)\n );\n}\n\n/**\n * Determine the `key` of an item or section.\n * @param itemOrSection The item or section\n * @returns A `ItemKey` for the item or undefined if a key can't be determined\n */\nfunction normalizeItemKey(item: ItemElementOrPrimitive): ItemKey | undefined;\nfunction normalizeItemKey(section: SectionElement): Key | undefined;\nfunction normalizeItemKey(\n itemOrSection: ItemElementOrPrimitive | SectionElement\n): Key | ItemKey | undefined {\n // string, number, or boolean\n if (typeof itemOrSection !== 'object') {\n return itemOrSection;\n }\n\n // If `key` prop is explicitly set\n if (itemOrSection.key != null) {\n return itemOrSection.key;\n }\n\n // Section element\n if (isSectionElement(itemOrSection)) {\n return typeof itemOrSection.props.title === 'string'\n ? itemOrSection.props.title\n : undefined;\n }\n\n // Item element\n return (\n itemOrSection.props.textValue ??\n (typeof itemOrSection.props.children === 'string'\n ? itemOrSection.props.children\n : undefined)\n );\n}\n\n/**\n * Get a normalized `textValue` for an item ensuring it is a string.\n * @param item The item\n * @returns A string `textValue` for the item\n */\nfunction normalizeTextValue(item: ItemElementOrPrimitive): string | undefined {\n if (typeof item !== 'object') {\n return String(item);\n }\n\n if (item.props.textValue != null) {\n return item.props.textValue;\n }\n\n if (typeof item.props.children === 'string') {\n return item.props.children;\n }\n\n return undefined;\n}\n\n/**\n * Normalize an item or section to an object form.\n * @param itemOrSection item to normalize\n * @returns NormalizedItem or NormalizedSection object\n */\nfunction normalizeItem(\n itemOrSection: ItemOrSection\n): NormalizedItem | NormalizedSection {\n if (!isItemOrSection(itemOrSection)) {\n log.debug(INVALID_ITEM_ERROR_MESSAGE, itemOrSection);\n throw new Error(INVALID_ITEM_ERROR_MESSAGE);\n }\n\n if (isSectionElement(itemOrSection)) {\n const key = normalizeItemKey(itemOrSection);\n const { title } = itemOrSection.props;\n\n const items = normalizeItemList(itemOrSection.props.children).filter(\n // We don't support nested section elements\n childItem => !isSectionElement(childItem)\n ) as NormalizedItem[];\n\n return {\n item: { key, title, items },\n };\n }\n\n const key = normalizeItemKey(itemOrSection);\n const content = isItemElement(itemOrSection)\n ? itemOrSection.props.children\n : itemOrSection;\n const textValue = normalizeTextValue(itemOrSection);\n\n return {\n item: { key, content, textValue },\n };\n}\n\n/**\n * Get normalized items from an item or array of items.\n * @param itemsOrSections An item or array of items\n * @returns An array of normalized items\n */\nexport function normalizeItemList(\n itemsOrSections: ItemOrSection | ItemOrSection[] | NormalizedItem[]\n): (NormalizedItem | NormalizedSection)[] {\n // If already normalized, just return as-is\n if (isNormalizedItemsWithKeysList(itemsOrSections)) {\n return itemsOrSections;\n }\n\n const itemsArray = Array.isArray(itemsOrSections)\n ? itemsOrSections\n : [itemsOrSections];\n\n return itemsArray.map(normalizeItem);\n}\n\n/**\n * Returns a TooltipOptions object or null if options is false or null.\n * @param options\n * @returns TooltipOptions or null\n */\nexport function normalizeTooltipOptions(\n options?: boolean | TooltipOptions | null\n): TooltipOptions | null {\n if (options == null || options === false) {\n return null;\n }\n\n if (options === true) {\n return { placement: 'right' };\n }\n\n return options;\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAsC,OAAO;AAGpE,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SAExBC,IAAI,EAAaC,OAAO;AAGjC,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,WAAW,CAAC;AAEnC,OAAO,IAAMC,0BAA0B,GACrC,yEAAyE;;AAE3E;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAOxBC,IAA8B,EAAQ;EAAA,IAAAC,cAAA,EAAAC,UAAA;EACtC,QAAAD,cAAA,GAAQD,IAAI,aAAJA,IAAI,wBAAAE,UAAA,GAAJF,IAAI,CAAEA,IAAI,cAAAE,UAAA,uBAAVA,UAAA,CAAYC,GAAG,cAAAF,cAAA,cAAAA,cAAA,GAAID,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,GAAG;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,IAAe,EACwB;EACvC,OAAO,aAAAb,cAAc,CAAkBa,IAAI,CAAC,IAAIA,IAAI,CAACC,IAAI,KAAKX,OAAO;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASY,aAAaA,CAC3BF,IA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