@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/components",
|
|
3
|
-
"version": "0.72.1-
|
|
3
|
+
"version": "0.72.1-xcomponent.2+aa152d3f",
|
|
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.34.1",
|
|
28
|
-
"@deephaven/icons": "^0.72.1-
|
|
29
|
-
"@deephaven/log": "^0.72.1-
|
|
30
|
-
"@deephaven/react-hooks": "^0.72.1-
|
|
31
|
-
"@deephaven/utils": "^0.72.1-
|
|
28
|
+
"@deephaven/icons": "^0.72.1-xcomponent.2+aa152d3f",
|
|
29
|
+
"@deephaven/log": "^0.72.1-xcomponent.2+aa152d3f",
|
|
30
|
+
"@deephaven/react-hooks": "^0.72.1-xcomponent.2+aa152d3f",
|
|
31
|
+
"@deephaven/utils": "^0.72.1-xcomponent.2+aa152d3f",
|
|
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",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"react-dom": ">=16.8.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@deephaven/mocks": "^0.72.1-
|
|
58
|
+
"@deephaven/mocks": "^0.72.1-xcomponent.2+aa152d3f"
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"dist",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "aa152d3f63ed6212e5b50003a7a164c8c329f446"
|
|
73
73
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { TooltipOptions } from './utils';
|
|
3
|
-
export interface ItemContentProps {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
tooltipOptions?: TooltipOptions | null;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Item content. Text content will be wrapped in a Spectrum Text
|
|
9
|
-
* component with ellipsis overflow handling. If text content overflows and
|
|
10
|
-
* tooltipOptions are provided a tooltip will be displayed when hovering over
|
|
11
|
-
* the item content.
|
|
12
|
-
*/
|
|
13
|
-
export declare function ItemContent({ children: content, tooltipOptions, }: ItemContentProps): JSX.Element | null;
|
|
14
|
-
export default ItemContent;
|
|
15
|
-
//# sourceMappingURL=ItemContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ItemContent.d.ts","sourceRoot":"","sources":["../../src/spectrum/ItemContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAEV,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIzC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CACxC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EAAE,OAAO,EACjB,cAAc,GACf,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAsEvC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ItemContent.js","names":["Children","cloneElement","isValidElement","useState","cl","isElementOfType","useCheckOverflow","Text","ItemTooltip","stylesCommon","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ItemContent","_ref","children","content","tooltipOptions","checkOverflow","isOverflowing","resetIsOverflowing","previousContent","setPreviousContent","String","Array","isArray","map","el","_objectSpread","props","ref","UNSAFE_className","spectrumEllipsis","tooltip","options"],"sources":["../../src/spectrum/ItemContent.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n ReactNode,\n useState,\n} from 'react';\nimport cl from 'classnames';\nimport { isElementOfType, useCheckOverflow } from '@deephaven/react-hooks';\nimport { Text } from './Text';\nimport { TooltipOptions } from './utils';\nimport ItemTooltip from './ItemTooltip';\nimport stylesCommon from '../SpectrumComponent.module.scss';\n\nexport interface ItemContentProps {\n children: ReactNode;\n tooltipOptions?: TooltipOptions | null;\n}\n\n/**\n * Item content. Text content will be wrapped in a Spectrum Text\n * component with ellipsis overflow handling. If text content overflows and\n * tooltipOptions are provided a tooltip will be displayed when hovering over\n * the item content.\n */\nexport function ItemContent({\n children: content,\n tooltipOptions,\n}: ItemContentProps): JSX.Element | null {\n const { checkOverflow, isOverflowing, resetIsOverflowing } =\n useCheckOverflow();\n\n const [previousContent, setPreviousContent] = useState(content);\n\n // Reset `isOverflowing` if content changes. It will get re-calculated as\n // `Text` components render.\n if (previousContent !== content) {\n setPreviousContent(content);\n resetIsOverflowing();\n }\n\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 =>\n isElementOfType(el, Text)\n ? cloneElement(el, {\n ...el.props,\n ref: checkOverflow,\n UNSAFE_className: cl(\n el.props.UNSAFE_className,\n stylesCommon.spectrumEllipsis\n ),\n })\n : el\n );\n }\n\n if (typeof content === 'string' || typeof content === 'number') {\n content = (\n <Text\n ref={checkOverflow}\n UNSAFE_className={stylesCommon.spectrumEllipsis}\n >\n {content}\n </Text>\n );\n }\n /* eslint-enable no-param-reassign */\n\n const tooltip =\n tooltipOptions == null || !isOverflowing ? null : (\n <ItemTooltip options={tooltipOptions}>{content}</ItemTooltip>\n );\n\n return (\n <>\n {content}\n {tooltip}\n </>\n );\n}\n\nexport default ItemContent;\n"],"mappings":";;;;;AAAA,SACEA,QAAQ,EACRC,YAAY,EACZC,cAAc,EAEdC,QAAQ,QACH,OAAO;AACd,OAAOC,EAAE,MAAM,YAAY;AAC3B,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,wBAAwB;AAAC,SAClEC,IAAI;AAAA,OAENC,WAAW;AAAA,OACXC,YAAY;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAOnB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAAC,IAAA,EAGc;EAAA,IAHb;IAC1BC,QAAQ,EAAEC,OAAO;IACjBC;EACgB,CAAC,GAAAH,IAAA;EACjB,IAAM;IAAEI,aAAa;IAAEC,aAAa;IAAEC;EAAmB,CAAC,GACxDjB,gBAAgB,CAAC,CAAC;EAEpB,IAAM,CAACkB,eAAe,EAAEC,kBAAkB,CAAC,GAAGtB,QAAQ,CAACgB,OAAO,CAAC;;EAE/D;EACA;EACA,IAAIK,eAAe,KAAKL,OAAO,EAAE;IAC/BM,kBAAkB,CAACN,OAAO,CAAC;IAC3BI,kBAAkB,CAAC,CAAC;EACtB;EAEA,kBAAIrB,cAAc,CAACiB,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,GAAGO,MAAM,CAACP,OAAO,CAAC;EAC3B,CAAC,MAAM,IAAIQ,KAAK,CAACC,OAAO,CAACT,OAAO,CAAC,EAAE;IACjC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAA,OAAO,GAAGnB,QAAQ,CAAC6B,GAAG,CAACV,OAAO,EAAEW,EAAE,IAChCzB,eAAe,CAACyB,EAAE,EAAEvB,IAAI,CAAC,gBACrBN,YAAY,CAAC6B,EAAE,EAAAC,aAAA,CAAAA,aAAA,KACVD,EAAE,CAACE,KAAK;MACXC,GAAG,EAAEZ,aAAa;MAClBa,gBAAgB,EAAE9B,EAAE,CAClB0B,EAAE,CAACE,KAAK,CAACE,gBAAgB,EACzBzB,YAAY,CAAC0B,gBACf;IAAC,EACF,CAAC,GACFL,EACN,CAAC;EACH;EAEA,IAAI,OAAOX,OAAO,KAAK,QAAQ,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC9DA,OAAO,gBACLR,IAAA,CAACJ,IAAI;MACH0B,GAAG,EAAEZ,aAAc;MACnBa,gBAAgB,EAAEzB,YAAY,CAAC0B,gBAAiB;MAAAjB,QAAA,EAE/CC;IAAO,CACJ,CACP;EACH;EACA;;EAEA,IAAMiB,OAAO,GACXhB,cAAc,IAAI,IAAI,IAAI,CAACE,aAAa,GAAG,IAAI,gBAC7CX,IAAA,CAACH,WAAW;IAAC6B,OAAO,EAAEjB,cAAe;IAAAF,QAAA,EAAEC;EAAO,CAAc,CAC7D;EAEH,oBACEJ,KAAA,CAAAF,SAAA;IAAAK,QAAA,GACGC,OAAO,EACPiB,OAAO;EAAA,CACR,CAAC;AAEP;AAEA,eAAepB,WAAW"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { TooltipOptions } from './utils';
|
|
3
|
-
export interface ItemTooltipProps {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
options: TooltipOptions;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Tooltip for `<Item>` content.
|
|
9
|
-
*/
|
|
10
|
-
export declare function ItemTooltip({ children, options, }: ItemTooltipProps): JSX.Element;
|
|
11
|
-
export default ItemTooltip;
|
|
12
|
-
//# sourceMappingURL=ItemTooltip.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ItemTooltip.d.ts","sourceRoot":"","sources":["../../src/spectrum/ItemTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAKzC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,OAAO,GACR,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAehC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { isElementOfType } from '@deephaven/react-hooks';
|
|
2
|
-
import { Tooltip } from "../popper/index.js";
|
|
3
|
-
import { Flex } from "./layout.js";
|
|
4
|
-
import { Text } from "./Text.js";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
/**
|
|
7
|
-
* Tooltip for `<Item>` content.
|
|
8
|
-
*/
|
|
9
|
-
export function ItemTooltip(_ref) {
|
|
10
|
-
var {
|
|
11
|
-
children,
|
|
12
|
-
options
|
|
13
|
-
} = _ref;
|
|
14
|
-
if (Array.isArray(children)) {
|
|
15
|
-
return /*#__PURE__*/_jsx(Tooltip, {
|
|
16
|
-
options: options,
|
|
17
|
-
children: /*#__PURE__*/_jsx(Flex, {
|
|
18
|
-
direction: "column",
|
|
19
|
-
alignItems: "start",
|
|
20
|
-
children: children.filter(node => isElementOfType(node, Text))
|
|
21
|
-
})
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return /*#__PURE__*/_jsx(Tooltip, {
|
|
25
|
-
options: options,
|
|
26
|
-
children: children
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
export default ItemTooltip;
|
|
30
|
-
//# sourceMappingURL=ItemTooltip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ItemTooltip.js","names":["isElementOfType","Tooltip","Flex","Text","jsx","_jsx","ItemTooltip","_ref","children","options","Array","isArray","direction","alignItems","filter","node"],"sources":["../../src/spectrum/ItemTooltip.tsx"],"sourcesContent":["import { ReactNode } from 'react';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport { TooltipOptions } from './utils';\nimport { Tooltip } from '../popper';\nimport { Flex } from './layout';\nimport { Text } from './Text';\n\nexport interface ItemTooltipProps {\n children: ReactNode;\n options: TooltipOptions;\n}\n\n/**\n * Tooltip for `<Item>` content.\n */\nexport function ItemTooltip({\n children,\n options,\n}: ItemTooltipProps): JSX.Element {\n if (Array.isArray(children)) {\n return (\n <Tooltip options={options}>\n {/* Multiple children scenarios include a `<Text>` node for the label \n and at least 1 of an optional icon or `<Text slot=\"description\">` node.\n In such cases we only show the label and description `<Text>` nodes. */}\n <Flex direction=\"column\" alignItems=\"start\">\n {children.filter(node => isElementOfType(node, Text))}\n </Flex>\n </Tooltip>\n );\n }\n\n return <Tooltip options={options}>{children}</Tooltip>;\n}\n\nexport default ItemTooltip;\n"],"mappings":"AACA,SAASA,eAAe,QAAQ,wBAAwB;AAAC,SAEhDC,OAAO;AAAA,SACPC,IAAI;AAAA,SACJC,IAAI;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOb;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAAC,IAAA,EAGO;EAAA,IAHN;IAC1BC,QAAQ;IACRC;EACgB,CAAC,GAAAF,IAAA;EACjB,IAAIG,KAAK,CAACC,OAAO,CAACH,QAAQ,CAAC,EAAE;IAC3B,oBACEH,IAAA,CAACJ,OAAO;MAACQ,OAAO,EAAEA,OAAQ;MAAAD,QAAA,eAIxBH,IAAA,CAACH,IAAI;QAACU,SAAS,EAAC,QAAQ;QAACC,UAAU,EAAC,OAAO;QAAAL,QAAA,EACxCA,QAAQ,CAACM,MAAM,CAACC,IAAI,IAAIf,eAAe,CAACe,IAAI,EAAEZ,IAAI,CAAC;MAAC,CACjD;IAAC,CACA,CAAC;EAEd;EAEA,oBAAOE,IAAA,CAACJ,OAAO;IAACQ,OAAO,EAAEA,OAAQ;IAAAD,QAAA,EAAEA;EAAQ,CAAU,CAAC;AACxD;AAEA,eAAeF,WAAW"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { SpectrumListViewProps } from '@adobe/react-spectrum';
|
|
3
|
-
import { ItemElementOrPrimitive, ItemKey, NormalizedItem, TooltipOptions } from '../utils';
|
|
4
|
-
export type ListViewProps = {
|
|
5
|
-
children: ItemElementOrPrimitive | ItemElementOrPrimitive[] | NormalizedItem[];
|
|
6
|
-
/** Can be set to true or a TooltipOptions to enable item tooltips */
|
|
7
|
-
tooltip?: boolean | TooltipOptions;
|
|
8
|
-
selectedKeys?: 'all' | Iterable<ItemKey>;
|
|
9
|
-
defaultSelectedKeys?: 'all' | Iterable<ItemKey>;
|
|
10
|
-
disabledKeys?: Iterable<ItemKey>;
|
|
11
|
-
/**
|
|
12
|
-
* Handler that is called when the selection change.
|
|
13
|
-
* Note that under the hood, this is just an alias for Spectrum's
|
|
14
|
-
* `onSelectionChange`. We are renaming for better consistency with other
|
|
15
|
-
* components.
|
|
16
|
-
*/
|
|
17
|
-
onChange?: (keys: 'all' | Set<ItemKey>) => void;
|
|
18
|
-
/** Handler that is called when the picker is scrolled. */
|
|
19
|
-
onScroll?: (event: Event) => void;
|
|
20
|
-
/**
|
|
21
|
-
* Handler that is called when the selection changes.
|
|
22
|
-
* @deprecated Use `onChange` instead
|
|
23
|
-
*/
|
|
24
|
-
onSelectionChange?: (keys: 'all' | Set<ItemKey>) => void;
|
|
25
|
-
} & Omit<SpectrumListViewProps<NormalizedItem>, 'children' | 'items' | 'selectedKeys' | 'defaultSelectedKeys' | 'disabledKeys' | 'onSelectionChange'>;
|
|
26
|
-
export declare function ListView({ children, tooltip, selectedKeys, defaultSelectedKeys, disabledKeys, UNSAFE_className, onChange, onScroll, onSelectionChange, ...spectrumListViewProps }: ListViewProps): JSX.Element;
|
|
27
|
-
export default ListView;
|
|
28
|
-
//# sourceMappingURL=ListView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListView.tsx"],"names":[],"mappings":";AACA,OAAO,EAEL,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EACL,sBAAsB,EACtB,OAAO,EACP,cAAc,EAGd,cAAc,EAGf,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EACJ,sBAAsB,GACtB,sBAAsB,EAAE,GACxB,cAAc,EAAE,CAAC;IACrB,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,YAAY,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzC,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAEhD,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAElC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;CAC1D,GAAG,IAAI,CACN,qBAAqB,CAAC,cAAc,CAAC,EACnC,UAAU,GACV,OAAO,GACP,cAAc,GACd,qBAAqB,GACrB,cAAc,GACd,mBAAmB,CACtB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,OAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,QAAyB,EACzB,iBAAiB,EACjB,GAAG,qBAAqB,EACzB,EAAE,aAAa,GAAG,GAAG,CAAC,OAAO,CA2C7B;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
var _excluded = ["children", "tooltip", "selectedKeys", "defaultSelectedKeys", "disabledKeys", "UNSAFE_className", "onChange", "onScroll", "onSelectionChange"];
|
|
2
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
8
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
9
|
-
import { useMemo } from 'react';
|
|
10
|
-
import { ListView as SpectrumListView } from '@adobe/react-spectrum';
|
|
11
|
-
import { EMPTY_FUNCTION } from '@deephaven/utils';
|
|
12
|
-
import { extractSpectrumHTMLElement, useOnScrollRef } from '@deephaven/react-hooks';
|
|
13
|
-
import cl from 'classnames';
|
|
14
|
-
import { normalizeItemList, normalizeTooltipOptions, useRenderNormalizedItem, useStringifiedMultiSelection } from "../utils/index.js";
|
|
15
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
export function ListView(_ref) {
|
|
17
|
-
var {
|
|
18
|
-
children,
|
|
19
|
-
tooltip = true,
|
|
20
|
-
selectedKeys,
|
|
21
|
-
defaultSelectedKeys,
|
|
22
|
-
disabledKeys,
|
|
23
|
-
UNSAFE_className,
|
|
24
|
-
onChange,
|
|
25
|
-
onScroll = EMPTY_FUNCTION,
|
|
26
|
-
onSelectionChange
|
|
27
|
-
} = _ref,
|
|
28
|
-
spectrumListViewProps = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
-
var normalizedItems = useMemo(() => normalizeItemList(children), [children]);
|
|
30
|
-
var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip, 'bottom'), [tooltip]);
|
|
31
|
-
var renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);
|
|
32
|
-
var {
|
|
33
|
-
selectedStringKeys,
|
|
34
|
-
defaultSelectedStringKeys,
|
|
35
|
-
disabledStringKeys,
|
|
36
|
-
onStringSelectionChange
|
|
37
|
-
} = useStringifiedMultiSelection({
|
|
38
|
-
normalizedItems,
|
|
39
|
-
selectedKeys,
|
|
40
|
-
defaultSelectedKeys,
|
|
41
|
-
disabledKeys,
|
|
42
|
-
onChange: onChange !== null && onChange !== void 0 ? onChange : onSelectionChange
|
|
43
|
-
});
|
|
44
|
-
var scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);
|
|
45
|
-
return /*#__PURE__*/_jsx(SpectrumListView
|
|
46
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
47
|
-
, _objectSpread(_objectSpread({}, spectrumListViewProps), {}, {
|
|
48
|
-
ref: scrollRef,
|
|
49
|
-
UNSAFE_className: cl('dh-list-view', UNSAFE_className),
|
|
50
|
-
items: normalizedItems,
|
|
51
|
-
selectedKeys: selectedStringKeys,
|
|
52
|
-
defaultSelectedKeys: defaultSelectedStringKeys,
|
|
53
|
-
disabledKeys: disabledStringKeys,
|
|
54
|
-
onSelectionChange: onStringSelectionChange,
|
|
55
|
-
children: renderNormalizedItem
|
|
56
|
-
}));
|
|
57
|
-
}
|
|
58
|
-
export default ListView;
|
|
59
|
-
//# sourceMappingURL=ListView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.js","names":["useMemo","ListView","SpectrumListView","EMPTY_FUNCTION","extractSpectrumHTMLElement","useOnScrollRef","cl","normalizeItemList","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedMultiSelection","jsx","_jsx","_ref","children","tooltip","selectedKeys","defaultSelectedKeys","disabledKeys","UNSAFE_className","onChange","onScroll","onSelectionChange","spectrumListViewProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderNormalizedItem","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","scrollRef","_objectSpread","ref","items"],"sources":["../../../src/spectrum/listView/ListView.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n ListView as SpectrumListView,\n SpectrumListViewProps,\n} from '@adobe/react-spectrum';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport {\n extractSpectrumHTMLElement,\n useOnScrollRef,\n} from '@deephaven/react-hooks';\nimport cl from 'classnames';\nimport {\n ItemElementOrPrimitive,\n ItemKey,\n NormalizedItem,\n normalizeItemList,\n normalizeTooltipOptions,\n TooltipOptions,\n useRenderNormalizedItem,\n useStringifiedMultiSelection,\n} from '../utils';\n\nexport type ListViewProps = {\n children:\n | ItemElementOrPrimitive\n | ItemElementOrPrimitive[]\n | NormalizedItem[];\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: 'all' | Set<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?: (keys: 'all' | Set<ItemKey>) => void;\n} & Omit<\n SpectrumListViewProps<NormalizedItem>,\n | 'children'\n | 'items'\n | 'selectedKeys'\n | 'defaultSelectedKeys'\n | 'disabledKeys'\n | 'onSelectionChange'\n>;\n\nexport function ListView({\n children,\n tooltip = true,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n UNSAFE_className,\n onChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n ...spectrumListViewProps\n}: ListViewProps): JSX.Element {\n const normalizedItems = useMemo(\n () => normalizeItemList(children),\n [children]\n );\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip, 'bottom'),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem(tooltipOptions);\n\n const {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedMultiSelection({\n normalizedItems,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n const scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);\n\n return (\n <SpectrumListView\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumListViewProps}\n ref={scrollRef}\n UNSAFE_className={cl('dh-list-view', UNSAFE_className)}\n items={normalizedItems}\n selectedKeys={selectedStringKeys}\n defaultSelectedKeys={defaultSelectedStringKeys}\n disabledKeys={disabledStringKeys}\n onSelectionChange={onStringSelectionChange}\n >\n {renderNormalizedItem}\n </SpectrumListView>\n );\n}\n\nexport default ListView;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,QAAQ,IAAIC,gBAAgB,QAEvB,uBAAuB;AAC9B,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,0BAA0B,EAC1BC,cAAc,QACT,wBAAwB;AAC/B,OAAOC,EAAE,MAAM,YAAY;AAAC,SAK1BC,iBAAiB,EACjBC,uBAAuB,EAEvBC,uBAAuB,EACvBC,4BAA4B;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAuC9B,OAAO,SAASX,QAAQA,CAAAY,IAAA,EAWO;EAAA,IAXN;MACvBC,QAAQ;MACRC,OAAO,GAAG,IAAI;MACdC,YAAY;MACZC,mBAAmB;MACnBC,YAAY;MACZC,gBAAgB;MAChBC,QAAQ;MACRC,QAAQ,GAAGlB,cAAc;MACzBmB;IAEa,CAAC,GAAAT,IAAA;IADXU,qBAAqB,GAAAC,wBAAA,CAAAX,IAAA,EAAAY,SAAA;EAExB,IAAMC,eAAe,GAAG1B,OAAO,CAC7B,MAAMO,iBAAiB,CAACO,QAAQ,CAAC,EACjC,CAACA,QAAQ,CACX,CAAC;EAED,IAAMa,cAAc,GAAG3B,OAAO,CAC5B,MAAMQ,uBAAuB,CAACO,OAAO,EAAE,QAAQ,CAAC,EAChD,CAACA,OAAO,CACV,CAAC;EAED,IAAMa,oBAAoB,GAAGnB,uBAAuB,CAACkB,cAAc,CAAC;EAEpE,IAAM;IACJE,kBAAkB;IAClBC,yBAAyB;IACzBC,kBAAkB;IAClBC;EACF,CAAC,GAAGtB,4BAA4B,CAAC;IAC/BgB,eAAe;IACfV,YAAY;IACZC,mBAAmB;IACnBC,YAAY;IACZE,QAAQ,EAAEA,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIE;EACxB,CAAC,CAAC;EAEF,IAAMW,SAAS,GAAG5B,cAAc,CAACgB,QAAQ,EAAEjB,0BAA0B,CAAC;EAEtE,oBACEQ,IAAA,CAACV;EACC;EAAA,EAAAgC,aAAA,CAAAA,aAAA,KACIX,qBAAqB;IACzBY,GAAG,EAAEF,SAAU;IACfd,gBAAgB,EAAEb,EAAE,CAAC,cAAc,EAAEa,gBAAgB,CAAE;IACvDiB,KAAK,EAAEV,eAAgB;IACvBV,YAAY,EAAEa,kBAAmB;IACjCZ,mBAAmB,EAAEa,yBAA0B;IAC/CZ,YAAY,EAAEa,kBAAmB;IACjCT,iBAAiB,EAAEU,uBAAwB;IAAAlB,QAAA,EAE1Cc;EAAoB,EACL,CAAC;AAEvB;AAEA,eAAe3B,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/spectrum/listView/index.ts"],"sourcesContent":["export * from './ListView';\n"],"mappings":""}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { NormalizedItem, TooltipOptions } from './itemUtils';
|
|
3
|
-
export declare function useRenderNormalizedItem(tooltipOptions: TooltipOptions | null): (normalizedItem: NormalizedItem) => JSX.Element;
|
|
4
|
-
export default useRenderNormalizedItem;
|
|
5
|
-
//# sourceMappingURL=useRenderNormalizedItem.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRenderNormalizedItem.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAc,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEzE,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,cAAc,GAAG,IAAI,GACpC,CAAC,cAAc,EAAE,cAAc,KAAK,GAAG,CAAC,OAAO,CA6BjD;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { ItemContent } from "../ItemContent.js";
|
|
3
|
-
import { Item } from "../shared.js";
|
|
4
|
-
import { getItemKey } from "./itemUtils.js";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
export function useRenderNormalizedItem(tooltipOptions) {
|
|
7
|
-
return useCallback(normalizedItem => {
|
|
8
|
-
var _normalizedItem$item$, _normalizedItem$item, _normalizedItem$item$2, _normalizedItem$item2;
|
|
9
|
-
var key = getItemKey(normalizedItem);
|
|
10
|
-
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$ : '';
|
|
11
|
-
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 : '';
|
|
12
|
-
return /*#__PURE__*/_jsx(Item
|
|
13
|
-
// Note that setting the `key` prop explicitly on `Item` elements
|
|
14
|
-
// causes the picker to expect `selectedKey` and `defaultSelectedKey`
|
|
15
|
-
// to be strings. It also passes the stringified value of the key to
|
|
16
|
-
// `onSelectionChange` handlers` regardless of the actual type of the
|
|
17
|
-
// key. We can't really get around setting in order to support Windowed
|
|
18
|
-
// data, so we'll need to do some manual conversion of keys to strings
|
|
19
|
-
// in other places of this component.
|
|
20
|
-
, {
|
|
21
|
-
// The `textValue` prop gets used to provide the content of `<option>`
|
|
22
|
-
// elements that back the Spectrum Picker. These are not visible in the UI,
|
|
23
|
-
// but are used for accessibility purposes, so we set to an arbitrary
|
|
24
|
-
// 'Empty' value so that they are not empty strings.
|
|
25
|
-
textValue: textValue === '' ? 'Empty' : textValue,
|
|
26
|
-
children: /*#__PURE__*/_jsx(ItemContent, {
|
|
27
|
-
tooltipOptions: tooltipOptions,
|
|
28
|
-
children: content
|
|
29
|
-
})
|
|
30
|
-
}, key);
|
|
31
|
-
}, [tooltipOptions]);
|
|
32
|
-
}
|
|
33
|
-
export default useRenderNormalizedItem;
|
|
34
|
-
//# sourceMappingURL=useRenderNormalizedItem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRenderNormalizedItem.js","names":["useCallback","ItemContent","Item","getItemKey","jsx","_jsx","useRenderNormalizedItem","tooltipOptions","normalizedItem","_normalizedItem$item$","_normalizedItem$item","_normalizedItem$item$2","_normalizedItem$item2","key","content","item","textValue","children"],"sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"sourcesContent":["import { Key, useCallback } from 'react';\nimport { ItemContent } from '../ItemContent';\nimport { Item } from '../shared';\nimport { getItemKey, NormalizedItem, TooltipOptions } from './itemUtils';\n\nexport function useRenderNormalizedItem(\n tooltipOptions: TooltipOptions | null\n): (normalizedItem: NormalizedItem) => JSX.Element {\n return 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 <ItemContent tooltipOptions={tooltipOptions}>{content}</ItemContent>\n </Item>\n );\n },\n [tooltipOptions]\n );\n}\n\nexport default useRenderNormalizedItem;\n"],"mappings":"AAAA,SAAcA,WAAW,QAAQ,OAAO;AAAC,SAChCC,WAAW;AAAA,SACXC,IAAI;AAAA,SACJC,UAAU;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEnB,OAAO,SAASC,uBAAuBA,CACrCC,cAAqC,EACY;EACjD,OAAOP,WAAW,CACfQ,cAA8B,IAAK;IAAA,IAAAC,qBAAA,EAAAC,oBAAA,EAAAC,sBAAA,EAAAC,qBAAA;IAClC,IAAMC,GAAG,GAAGV,UAAU,CAACK,cAAc,CAAC;IACtC,IAAMM,OAAO,IAAAL,qBAAA,IAAAC,oBAAA,GAAGF,cAAc,CAACO,IAAI,cAAAL,oBAAA,uBAAnBA,oBAAA,CAAqBI,OAAO,cAAAL,qBAAA,cAAAA,qBAAA,GAAI,EAAE;IAClD,IAAMO,SAAS,IAAAL,sBAAA,IAAAC,qBAAA,GAAGJ,cAAc,CAACO,IAAI,cAAAH,qBAAA,uBAAnBA,qBAAA,CAAqBI,SAAS,cAAAL,sBAAA,cAAAA,sBAAA,GAAI,EAAE;IAEtD,oBACEN,IAAA,CAACH;IACC;IACA;IACA;IACA;IACA;IACA;IACA;IAAA;MAEA;MACA;MACA;MACA;MACAc,SAAS,EAAEA,SAAS,KAAK,EAAE,GAAG,OAAO,GAAGA,SAAU;MAAAC,QAAA,eAElDZ,IAAA,CAACJ,WAAW;QAACM,cAAc,EAAEA,cAAe;QAAAU,QAAA,EAAEH;MAAO,CAAc;IAAC,GAP/DD,GAQD,CAAC;EAEX,CAAC,EACD,CAACN,cAAc,CACjB,CAAC;AACH;AAEA,eAAeD,uBAAuB"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Key } from 'react';
|
|
2
|
-
import { ItemKey, NormalizedItem } from './itemUtils';
|
|
3
|
-
export interface UseStringifiedMultiSelectionOptions {
|
|
4
|
-
normalizedItems: NormalizedItem[];
|
|
5
|
-
selectedKeys?: 'all' | Iterable<ItemKey>;
|
|
6
|
-
defaultSelectedKeys?: 'all' | Iterable<ItemKey>;
|
|
7
|
-
disabledKeys?: Iterable<ItemKey>;
|
|
8
|
-
/**
|
|
9
|
-
* Handler that is called when the selection change.
|
|
10
|
-
* Note that under the hood, this is just an alias for Spectrum's
|
|
11
|
-
* `onSelectionChange`. We are renaming for better consistency with other
|
|
12
|
-
* components.
|
|
13
|
-
*/
|
|
14
|
-
onChange?: (keys: 'all' | Set<ItemKey>) => void;
|
|
15
|
-
}
|
|
16
|
-
export interface UseStringifiedMultiSelectionResult {
|
|
17
|
-
/** Stringified selection keys */
|
|
18
|
-
selectedStringKeys?: 'all' | Set<Key>;
|
|
19
|
-
/** Stringified default selection keys */
|
|
20
|
-
defaultSelectedStringKeys?: 'all' | Set<Key>;
|
|
21
|
-
/** Stringified disabled keys */
|
|
22
|
-
disabledStringKeys?: 'all' | Set<Key>;
|
|
23
|
-
/** Handler that is called when the string key selections change */
|
|
24
|
-
onStringSelectionChange: (keys: 'all' | Set<Key>) => void;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Spectrum collection components treat keys as strings if the `key` prop is
|
|
28
|
-
* explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,
|
|
29
|
-
* we need to ensure that keys are strings in order for selection to work. We
|
|
30
|
-
* then need to convert back to the original key types in the onChange handler.
|
|
31
|
-
* This hook encapsulates converting to and from strings so that keys can match
|
|
32
|
-
* the original key type.
|
|
33
|
-
* @param normalizedItems The normalized items to select from.
|
|
34
|
-
* @param selectedKeys The currently selected keys in the collection.
|
|
35
|
-
* @param defaultSelectedKeys The initial selected keys in the collection.
|
|
36
|
-
* @param disabledKeys The currently disabled keys in the collection.
|
|
37
|
-
* @param onChange Handler that is called when the selection changes.
|
|
38
|
-
* @returns UseStringifiedMultiSelectionResult with stringified key sets and
|
|
39
|
-
* string key selection change handler.
|
|
40
|
-
*/
|
|
41
|
-
export declare function useStringifiedMultiSelection({ normalizedItems, defaultSelectedKeys, disabledKeys, selectedKeys, onChange, }: UseStringifiedMultiSelectionOptions): UseStringifiedMultiSelectionResult;
|
|
42
|
-
export default useStringifiedMultiSelection;
|
|
43
|
-
//# sourceMappingURL=useStringifiedMultiSelection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useStringifiedMultiSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;AAClD,OAAO,EAAc,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAYlE,MAAM,WAAW,mCAAmC;IAClD,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzC,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,kCAAkC;IACjD,iCAAiC;IACjC,kBAAkB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,yCAAyC;IACzC,yBAAyB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,gCAAgC;IAChC,kBAAkB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,mEAAmE;IACnE,uBAAuB,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,GACT,EAAE,mCAAmC,GAAG,kCAAkC,CA0C1E;AAED,eAAe,4BAA4B,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import { getItemKey } from "./itemUtils.js";
|
|
3
|
-
function toStringKeySet(keys) {
|
|
4
|
-
if (keys == null || keys === 'all') {
|
|
5
|
-
return keys;
|
|
6
|
-
}
|
|
7
|
-
return new Set([...keys].map(String));
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Spectrum collection components treat keys as strings if the `key` prop is
|
|
11
|
-
* explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,
|
|
12
|
-
* we need to ensure that keys are strings in order for selection to work. We
|
|
13
|
-
* then need to convert back to the original key types in the onChange handler.
|
|
14
|
-
* This hook encapsulates converting to and from strings so that keys can match
|
|
15
|
-
* the original key type.
|
|
16
|
-
* @param normalizedItems The normalized items to select from.
|
|
17
|
-
* @param selectedKeys The currently selected keys in the collection.
|
|
18
|
-
* @param defaultSelectedKeys The initial selected keys in the collection.
|
|
19
|
-
* @param disabledKeys The currently disabled keys in the collection.
|
|
20
|
-
* @param onChange Handler that is called when the selection changes.
|
|
21
|
-
* @returns UseStringifiedMultiSelectionResult with stringified key sets and
|
|
22
|
-
* string key selection change handler.
|
|
23
|
-
*/
|
|
24
|
-
export function useStringifiedMultiSelection(_ref) {
|
|
25
|
-
var {
|
|
26
|
-
normalizedItems,
|
|
27
|
-
defaultSelectedKeys,
|
|
28
|
-
disabledKeys,
|
|
29
|
-
selectedKeys,
|
|
30
|
-
onChange
|
|
31
|
-
} = _ref;
|
|
32
|
-
var selectedStringKeys = useMemo(() => toStringKeySet(selectedKeys), [selectedKeys]);
|
|
33
|
-
var defaultSelectedStringKeys = useMemo(() => toStringKeySet(defaultSelectedKeys), [defaultSelectedKeys]);
|
|
34
|
-
var disabledStringKeys = useMemo(() => toStringKeySet(disabledKeys), [disabledKeys]);
|
|
35
|
-
var onStringSelectionChange = useCallback(keys => {
|
|
36
|
-
if (keys === 'all') {
|
|
37
|
-
onChange === null || onChange === void 0 ? void 0 : onChange('all');
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
var actualKeys = new Set();
|
|
41
|
-
normalizedItems.forEach(item => {
|
|
42
|
-
if (keys.has(String(getItemKey(item)))) {
|
|
43
|
-
actualKeys.add(getItemKey(item));
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(actualKeys);
|
|
47
|
-
}, [normalizedItems, onChange]);
|
|
48
|
-
return {
|
|
49
|
-
selectedStringKeys,
|
|
50
|
-
defaultSelectedStringKeys,
|
|
51
|
-
disabledStringKeys,
|
|
52
|
-
onStringSelectionChange
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
export default useStringifiedMultiSelection;
|
|
56
|
-
//# sourceMappingURL=useStringifiedMultiSelection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useStringifiedMultiSelection.js","names":["useCallback","useMemo","getItemKey","toStringKeySet","keys","Set","map","String","useStringifiedMultiSelection","_ref","normalizedItems","defaultSelectedKeys","disabledKeys","selectedKeys","onChange","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","actualKeys","forEach","item","has","add"],"sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport { getItemKey, ItemKey, NormalizedItem } from './itemUtils';\n\nfunction toStringKeySet(\n keys?: 'all' | Iterable<ItemKey>\n): undefined | 'all' | Set<Key> {\n if (keys == null || keys === 'all') {\n return keys as undefined | 'all';\n }\n\n return new Set([...keys].map(String));\n}\n\nexport interface UseStringifiedMultiSelectionOptions {\n normalizedItems: NormalizedItem[];\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: 'all' | Set<ItemKey>) => void;\n}\n\nexport interface UseStringifiedMultiSelectionResult {\n /** Stringified selection keys */\n selectedStringKeys?: 'all' | Set<Key>;\n /** Stringified default selection keys */\n defaultSelectedStringKeys?: 'all' | Set<Key>;\n /** Stringified disabled keys */\n disabledStringKeys?: 'all' | Set<Key>;\n /** Handler that is called when the string key selections change */\n onStringSelectionChange: (keys: 'all' | Set<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 selectedKeys The currently selected keys in the collection.\n * @param defaultSelectedKeys The initial selected keys 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 UseStringifiedMultiSelectionResult with stringified key sets and\n * string key selection change handler.\n */\nexport function useStringifiedMultiSelection({\n normalizedItems,\n defaultSelectedKeys,\n disabledKeys,\n selectedKeys,\n onChange,\n}: UseStringifiedMultiSelectionOptions): UseStringifiedMultiSelectionResult {\n const selectedStringKeys = useMemo(\n () => toStringKeySet(selectedKeys),\n [selectedKeys]\n );\n\n const defaultSelectedStringKeys = useMemo(\n () => toStringKeySet(defaultSelectedKeys),\n [defaultSelectedKeys]\n );\n\n const disabledStringKeys = useMemo(\n () => toStringKeySet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (keys: 'all' | Set<Key>) => {\n if (keys === 'all') {\n onChange?.('all');\n return;\n }\n\n const actualKeys = new Set<ItemKey>();\n\n normalizedItems.forEach(item => {\n if (keys.has(String(getItemKey(item)))) {\n actualKeys.add(getItemKey(item));\n }\n });\n\n onChange?.(actualKeys);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedMultiSelection;\n"],"mappings":"AAAA,SAAcA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SACzCC,UAAU;AAEnB,SAASC,cAAcA,CACrBC,IAAgC,EACF;EAC9B,IAAIA,IAAI,IAAI,IAAI,IAAIA,IAAI,KAAK,KAAK,EAAE;IAClC,OAAOA,IAAI;EACb;EAEA,OAAO,IAAIC,GAAG,CAAC,CAAC,GAAGD,IAAI,CAAC,CAACE,GAAG,CAACC,MAAM,CAAC,CAAC;AACvC;AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAAC,IAAA,EAMgC;EAAA,IAN/B;IAC3CC,eAAe;IACfC,mBAAmB;IACnBC,YAAY;IACZC,YAAY;IACZC;EACmC,CAAC,GAAAL,IAAA;EACpC,IAAMM,kBAAkB,GAAGd,OAAO,CAChC,MAAME,cAAc,CAACU,YAAY,CAAC,EAClC,CAACA,YAAY,CACf,CAAC;EAED,IAAMG,yBAAyB,GAAGf,OAAO,CACvC,MAAME,cAAc,CAACQ,mBAAmB,CAAC,EACzC,CAACA,mBAAmB,CACtB,CAAC;EAED,IAAMM,kBAAkB,GAAGhB,OAAO,CAChC,MAAME,cAAc,CAACS,YAAY,CAAC,EAClC,CAACA,YAAY,CACf,CAAC;EAED,IAAMM,uBAAuB,GAAGlB,WAAW,CACxCI,IAAsB,IAAK;IAC1B,IAAIA,IAAI,KAAK,KAAK,EAAE;MAClBU,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAG,KAAK,CAAC;MACjB;IACF;IAEA,IAAMK,UAAU,GAAG,IAAId,GAAG,CAAU,CAAC;IAErCK,eAAe,CAACU,OAAO,CAACC,IAAI,IAAI;MAC9B,IAAIjB,IAAI,CAACkB,GAAG,CAACf,MAAM,CAACL,UAAU,CAACmB,IAAI,CAAC,CAAC,CAAC,EAAE;QACtCF,UAAU,CAACI,GAAG,CAACrB,UAAU,CAACmB,IAAI,CAAC,CAAC;MAClC;IACF,CAAC,CAAC;IAEFP,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAGK,UAAU,CAAC;EACxB,CAAC,EACD,CAACT,eAAe,EAAEI,QAAQ,CAC5B,CAAC;EAED,OAAO;IACLC,kBAAkB;IAClBC,yBAAyB;IACzBC,kBAAkB;IAClBC;EACF,CAAC;AACH;AAEA,eAAeV,4BAA4B"}
|