@deephaven/components 0.67.1-beta.2 → 0.68.1-beta.0
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/css/BaseStyleSheet.css +3 -2
- package/css/BaseStyleSheet.css.map +1 -1
- package/dist/Button.d.ts +1 -1
- package/dist/Select.d.ts +1 -1
- package/dist/popper/Popper.css +20 -20
- package/dist/popper/Popper.css.map +1 -1
- package/dist/popper/Popper.d.ts.map +1 -1
- package/dist/popper/Popper.js +38 -33
- package/dist/popper/Popper.js.map +1 -1
- package/dist/spectrum/picker/Picker.d.ts.map +1 -1
- package/dist/spectrum/picker/Picker.js +22 -3
- package/dist/spectrum/picker/Picker.js.map +1 -1
- package/dist/spectrum/picker/PickerItemContent.d.ts +1 -1
- package/dist/spectrum/picker/PickerItemContent.d.ts.map +1 -1
- package/dist/spectrum/picker/PickerItemContent.js +33 -10
- package/dist/spectrum/picker/PickerItemContent.js.map +1 -1
- package/dist/spectrum/picker/PickerUtils.d.ts +4 -4
- package/dist/spectrum/picker/PickerUtils.d.ts.map +1 -1
- package/dist/spectrum/picker/PickerUtils.js +5 -5
- package/dist/spectrum/picker/PickerUtils.js.map +1 -1
- package/package.json +7 -7
- package/scss/BaseStyleSheet.scss +6 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.js","names":["useCallback","useMemo","Picker","SpectrumPicker","cl","Tooltip","normalizePickerItemList","normalizeTooltipOptions","isNormalizedPickerSection","PickerItemContent","Item","Section","jsx","_jsx","jsxs","_jsxs","
|
|
1
|
+
{"version":3,"file":"Picker.js","names":["useCallback","useMemo","Flex","Picker","SpectrumPicker","Text","isElementOfType","cl","Tooltip","normalizePickerItemList","normalizeTooltipOptions","isNormalizedPickerSection","PickerItemContent","Item","Section","jsx","_jsx","jsxs","_jsxs","createTooltipContent","content","String","Array","isArray","direction","alignItems","children","filter","node","_ref","tooltip","defaultSelectedKey","selectedKey","onChange","onSelectionChange","UNSAFE_className","spectrumPickerProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderItem","_ref2","key","textValue","options","_objectSpread","items","itemOrSection","title"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { Key, ReactNode, useCallback, useMemo } from 'react';\nimport { Flex, Picker as SpectrumPicker, Text } from '@adobe/react-spectrum';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport cl from 'classnames';\nimport { Tooltip } from '../../popper';\nimport {\n NormalizedSpectrumPickerProps,\n normalizePickerItemList,\n normalizeTooltipOptions,\n PickerItemOrSection,\n PickerItemKey,\n TooltipOptions,\n NormalizedPickerItem,\n isNormalizedPickerSection,\n} from './PickerUtils';\nimport { PickerItemContent } from './PickerItemContent';\nimport { Item } from '../Item';\nimport { Section } from '../Section';\n\nexport type PickerProps = {\n children: PickerItemOrSection | PickerItemOrSection[];\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?: PickerItemKey | null;\n /** The initial selected key in the collection (uncontrolled). */\n defaultSelectedKey?: PickerItemKey;\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: PickerItemKey) => void;\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead\n */\n onSelectionChange?: (key: PickerItemKey) => 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 onChange,\n onSelectionChange,\n // eslint-disable-next-line camelcase\n UNSAFE_className,\n ...spectrumPickerProps\n}: PickerProps): JSX.Element {\n const normalizedItems = useMemo(\n () => normalizePickerItemList(children),\n [children]\n );\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderItem = useCallback(\n ({ key, content, textValue }: NormalizedPickerItem) => (\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 <Item\n key={key as Key}\n textValue={textValue === '' || textValue == null ? 'Empty' : textValue}\n >\n <PickerItemContent>{content}</PickerItemContent>\n {tooltipOptions == null || content === '' ? null : (\n <Tooltip options={tooltipOptions}>\n {createTooltipContent(content)}\n </Tooltip>\n )}\n </Item>\n ),\n [tooltipOptions]\n );\n\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumPickerProps}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n items={normalizedItems}\n // Type assertions are necessary for `selectedKey`, `defaultSelectedKey`,\n // and `onSelectionChange` due to Spectrum types not accounting for\n // `boolean` keys\n selectedKey={selectedKey as NormalizedSpectrumPickerProps['selectedKey']}\n defaultSelectedKey={\n defaultSelectedKey as NormalizedSpectrumPickerProps['defaultSelectedKey']\n }\n // `onChange` is just an alias for `onSelectionChange`\n onSelectionChange={\n (onChange ??\n onSelectionChange) as NormalizedSpectrumPickerProps['onSelectionChange']\n }\n >\n {itemOrSection => {\n if (isNormalizedPickerSection(itemOrSection)) {\n return (\n <Section\n key={itemOrSection.key}\n title={itemOrSection.title}\n items={itemOrSection.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;AAC5D,SAASC,IAAI,EAAEC,MAAM,IAAIC,cAAc,EAAEC,IAAI,QAAQ,uBAAuB;AAC5E,SAASC,eAAe,QAAQ,wBAAwB;AACxD,OAAOC,EAAE,MAAM,YAAY;AAAC,SACnBC,OAAO;AAAA,SAGdC,uBAAuB,EACvBC,uBAAuB,EAKvBC,yBAAyB;AAAA,SAElBC,iBAAiB;AAAA,SACjBC,IAAI;AAAA,SACJC,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAoChB;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,oBACEJ,IAAA,CAACd,IAAI;MAACsB,SAAS,EAAC,QAAQ;MAACC,UAAU,EAAC,OAAO;MAAAC,QAAA,EACxCN,OAAO,CAACO,MAAM,CAACC,IAAI,IAAItB,eAAe,CAACsB,IAAI,EAAEvB,IAAI,CAAC;IAAC,CAChD,CAAC;EAEX;EAEA,OAAOe,OAAO;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASjB,MAAMA,CAAA0B,IAAA,EAUO;EAAA,IAVN;MACrBH,QAAQ;MACRI,OAAO,GAA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,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GACPC,iBACH;IAAAR,QAAA,EAEAsB,aAAa,IAAI;MAChB,IAAIrC,yBAAyB,CAACqC,aAAa,CAAC,EAAE;QAC5C,oBACEhC,IAAA,CAACF,OAAO;UAENmC,KAAK,EAAED,aAAa,CAACC,KAAM;UAC3BF,KAAK,EAAEC,aAAa,CAACD,KAAM;UAAArB,QAAA,EAE1Be;QAAU,GAJNO,aAAa,CAACL,GAKZ,CAAC;MAEd;MAEA,OAAOF,UAAU,CAACO,aAAa,CAAC;IAClC;EAAC,EACa,CAAC;AAErB;AAEA,eAAe7C,MAAM"}
|
|
@@ -6,6 +6,6 @@ export interface PickerItemContentProps {
|
|
|
6
6
|
* Picker item content. Text content will be wrapped in a Spectrum Text
|
|
7
7
|
* component with ellipsis overflow handling.
|
|
8
8
|
*/
|
|
9
|
-
export declare function PickerItemContent({ children: content, }: PickerItemContentProps): JSX.Element;
|
|
9
|
+
export declare function PickerItemContent({ children: content, }: PickerItemContentProps): JSX.Element | null;
|
|
10
10
|
export default PickerItemContent;
|
|
11
11
|
//# sourceMappingURL=PickerItemContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PickerItemContent.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerItemContent.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
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
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
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 } from 'react';
|
|
2
7
|
import { Text } from '@adobe/react-spectrum';
|
|
8
|
+
import cl from 'classnames';
|
|
9
|
+
import { isElementOfType } from '@deephaven/react-hooks';
|
|
3
10
|
import stylesCommon from "../../SpectrumComponent.module.css";
|
|
4
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
5
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
13
|
/**
|
|
7
14
|
* Picker item content. Text content will be wrapped in a Spectrum Text
|
|
8
15
|
* component with ellipsis overflow handling.
|
|
@@ -14,21 +21,37 @@ export function PickerItemContent(_ref) {
|
|
|
14
21
|
if ( /*#__PURE__*/isValidElement(content)) {
|
|
15
22
|
return content;
|
|
16
23
|
}
|
|
24
|
+
|
|
25
|
+
/* eslint-disable no-param-reassign */
|
|
17
26
|
if (content === '') {
|
|
18
27
|
// Prevent the item height from collapsing when the content is empty
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
children: "\xA0"
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
if (typeof content === 'boolean') {
|
|
28
|
+
content = '\xa0'; // Non-breaking space
|
|
29
|
+
} else if (typeof content === 'boolean') {
|
|
25
30
|
// Boolean values need to be stringified to render
|
|
26
|
-
// eslint-disable-next-line no-param-reassign
|
|
27
31
|
content = String(content);
|
|
32
|
+
} else if (Array.isArray(content)) {
|
|
33
|
+
// For cases where there are multiple `Text` children, add a css class to
|
|
34
|
+
// handle overflow. The primary use case for multiple text nodes is when a
|
|
35
|
+
// description is provided for an item. e.g.
|
|
36
|
+
// <Item textValue="Some Text">
|
|
37
|
+
// <SomeIcon />
|
|
38
|
+
// <Text>Some Label</Text>
|
|
39
|
+
// <Text slot="description">Some Description</Text>
|
|
40
|
+
// </Item>
|
|
41
|
+
content = Children.map(content, (el, i) => isElementOfType(el, Text) ? /*#__PURE__*/cloneElement(el, _objectSpread(_objectSpread({}, el.props), {}, {
|
|
42
|
+
UNSAFE_className: cl(el.props.UNSAFE_className, stylesCommon.spectrumEllipsis)
|
|
43
|
+
})) : el);
|
|
28
44
|
}
|
|
29
|
-
|
|
45
|
+
/* eslint-enable no-param-reassign */
|
|
46
|
+
|
|
47
|
+
return typeof content === 'string' || typeof content === 'number' ? /*#__PURE__*/_jsx(Text, {
|
|
30
48
|
UNSAFE_className: stylesCommon.spectrumEllipsis,
|
|
31
49
|
children: content
|
|
50
|
+
}) :
|
|
51
|
+
/*#__PURE__*/
|
|
52
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
53
|
+
_jsx(_Fragment, {
|
|
54
|
+
children: content
|
|
32
55
|
});
|
|
33
56
|
}
|
|
34
57
|
export default PickerItemContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PickerItemContent.js","names":["isValidElement","Text","
|
|
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"}
|
|
@@ -37,12 +37,12 @@ export type PickerSelectionChangeHandler = (key: PickerItemKey) => void;
|
|
|
37
37
|
* in separate util methods.
|
|
38
38
|
*/
|
|
39
39
|
export interface NormalizedPickerItem {
|
|
40
|
-
key
|
|
40
|
+
key?: PickerItemKey;
|
|
41
41
|
content: ReactNode;
|
|
42
|
-
textValue
|
|
42
|
+
textValue?: string;
|
|
43
43
|
}
|
|
44
44
|
export interface NormalizedPickerSection {
|
|
45
|
-
key
|
|
45
|
+
key?: Key;
|
|
46
46
|
title?: ReactNode;
|
|
47
47
|
items: NormalizedPickerItem[];
|
|
48
48
|
}
|
|
@@ -86,6 +86,6 @@ export declare function normalizePickerItemList(itemsOrSections: PickerItemOrSec
|
|
|
86
86
|
* @param options
|
|
87
87
|
* @returns TooltipOptions or null
|
|
88
88
|
*/
|
|
89
|
-
export declare function normalizeTooltipOptions(options?: boolean | TooltipOptions | null):
|
|
89
|
+
export declare function normalizeTooltipOptions(options?: boolean | TooltipOptions | null): TooltipOptions | null;
|
|
90
90
|
export {};
|
|
91
91
|
//# sourceMappingURL=PickerUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PickerUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAA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,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B;AAED,MAAM,MAAM,6BAA6B,GACvC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;AAE5C,MAAM,MAAM,cAAc,GAAG;IAAE,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAEvE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,IAAI,EAAE,SAAS,GACd,IAAI,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAEvC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,IAAI,EAAE,SAAS,GACd,IAAI,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAEpC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,SAAS,GACd,IAAI,IAAI,mBAAmB,CAQ7B;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,4BAA4B,EAAE,oBAAoB,GAAG,uBAAuB,GAC3E,4BAA4B,IAAI,uBAAuB,CAEzD;AAqGD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,GAC3D,CAAC,oBAAoB,GAAG,uBAAuB,CAAC,EAAE,CAKpD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,GACxC,cAAc,GAAG,IAAI,CAUvB"}
|
|
@@ -70,7 +70,7 @@ export function isNormalizedPickerSection(maybeNormalizedPickerSection) {
|
|
|
70
70
|
/**
|
|
71
71
|
* Determine the `key` of a picker item or section.
|
|
72
72
|
* @param itemOrSection The picker item or section
|
|
73
|
-
* @returns A `PickerItemKey` for the picker item
|
|
73
|
+
* @returns A `PickerItemKey` for the picker item or undefined if a key can't be determined
|
|
74
74
|
*/
|
|
75
75
|
|
|
76
76
|
function normalizeItemKey(itemOrSection) {
|
|
@@ -87,11 +87,11 @@ function normalizeItemKey(itemOrSection) {
|
|
|
87
87
|
|
|
88
88
|
// Section element
|
|
89
89
|
if (isSectionElement(itemOrSection)) {
|
|
90
|
-
return typeof itemOrSection.props.title === 'string' ? itemOrSection.props.title :
|
|
90
|
+
return typeof itemOrSection.props.title === 'string' ? itemOrSection.props.title : undefined;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
// Item element
|
|
94
|
-
return (_itemOrSection$props$ = itemOrSection.props.textValue) !== null && _itemOrSection$props$ !== void 0 ? _itemOrSection$props$ : typeof itemOrSection.props.children === 'string' ? itemOrSection.props.children :
|
|
94
|
+
return (_itemOrSection$props$ = itemOrSection.props.textValue) !== null && _itemOrSection$props$ !== void 0 ? _itemOrSection$props$ : typeof itemOrSection.props.children === 'string' ? itemOrSection.props.children : undefined;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -109,7 +109,7 @@ function normalizeTextValue(item) {
|
|
|
109
109
|
if (typeof item.props.children === 'string') {
|
|
110
110
|
return item.props.children;
|
|
111
111
|
}
|
|
112
|
-
return
|
|
112
|
+
return undefined;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -167,7 +167,7 @@ export function normalizeTooltipOptions(options) {
|
|
|
167
167
|
}
|
|
168
168
|
if (options === true) {
|
|
169
169
|
return {
|
|
170
|
-
placement: '
|
|
170
|
+
placement: 'right'
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
return options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PickerUtils.js","names":["isValidElement","Log","Item","Section","log","module","INVALID_PICKER_ITEM_ERROR_MESSAGE","isSectionElement","node","type","isItemElement","isPickerItemOrSection","isNormalizedPickerSection","maybeNormalizedPickerSection","normalizeItemKey","itemOrSection","_itemOrSection$props$","key","props","title","textValue","children","normalizeTextValue","item","String","normalizePickerItem","debug","Error","items","normalizePickerItemList","filter","childItem","content","itemsOrSections","itemsArray","Array","isArray","map","normalizeTooltipOptions","options","placement"],"sources":["../../../src/spectrum/picker/PickerUtils.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 { Item, ItemProps } from '../Item';\nimport { Section, SectionProps } from '../Section';\nimport { PopperOptions } from '../../popper';\n\nconst log = Log.module('PickerUtils');\n\nexport const INVALID_PICKER_ITEM_ERROR_MESSAGE =\n 'Picker 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>>;\ntype SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;\n\nexport type PickerItem = number | string | boolean | ItemElement;\nexport type PickerSection = SectionElement;\nexport type PickerItemOrSection = PickerItem | PickerSection;\n\n/**\n * Augment the Spectrum selection key type to include boolean values.\n * The Spectrum Picker already supports this, but the built in types don't\n * reflect it.\n */\nexport type PickerItemKey = Key | boolean;\n\n/**\n * Augment the Spectrum selection change handler type to include boolean keys.\n * The Spectrum Picker already supports this, but the built in types don't\n * reflect it.\n */\nexport type PickerSelectionChangeHandler = (key: PickerItemKey) => void;\n\n/**\n * The Picker supports a variety of item types, including strings, numbers,\n * booleans, and more complex React elements. This type represents a normalized\n * form to make rendering items simpler and keep the logic of transformation\n * in separate util methods.\n */\nexport interface NormalizedPickerItem {\n key: PickerItemKey;\n content: ReactNode;\n textValue: string;\n}\n\nexport interface NormalizedPickerSection {\n key: Key;\n title?: ReactNode;\n items: NormalizedPickerItem[];\n}\n\nexport type NormalizedSpectrumPickerProps =\n SpectrumPickerProps<NormalizedPickerItem>;\n\nexport type TooltipOptions = { placement: PopperOptions['placement'] };\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 a Picker 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 a Picker item or section\n */\nexport function isPickerItemOrSection(\n node: ReactNode\n): node is PickerItemOrSection {\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 if an object is a normalized Picker section.\n * @param maybeNormalizedPickerSection The object to check\n * @returns True if the object is a normalized Picker section\n */\nexport function isNormalizedPickerSection(\n maybeNormalizedPickerSection: NormalizedPickerItem | NormalizedPickerSection\n): maybeNormalizedPickerSection is NormalizedPickerSection {\n return 'items' in maybeNormalizedPickerSection;\n}\n\n/**\n * Determine the `key` of a picker item or section.\n * @param itemOrSection The picker item or section\n * @returns A `PickerItemKey` for the picker item\n */\nfunction normalizeItemKey(item: PickerItem): PickerItemKey;\nfunction normalizeItemKey(section: PickerSection): Key;\nfunction normalizeItemKey(\n itemOrSection: PickerItem | PickerSection\n): Key | PickerItemKey {\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 : '';\n }\n\n // Item element\n return (\n itemOrSection.props.textValue ??\n (typeof itemOrSection.props.children === 'string'\n ? itemOrSection.props.children\n : '')\n );\n}\n\n/**\n * Get a normalized `textValue` for a picker item ensuring it is a string.\n * @param item The picker item\n * @returns A string `textValue` for the picker item\n */\nfunction normalizeTextValue(item: PickerItem): string {\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 '';\n}\n\n/**\n * Normalize a picker item to an object form.\n * @param itemOrSection item to normalize\n * @returns NormalizedPickerItem object\n */\nfunction normalizePickerItem(\n itemOrSection: PickerItemOrSection\n): NormalizedPickerItem | NormalizedPickerSection {\n if (!isPickerItemOrSection(itemOrSection)) {\n log.debug(INVALID_PICKER_ITEM_ERROR_MESSAGE, itemOrSection);\n throw new Error(INVALID_PICKER_ITEM_ERROR_MESSAGE);\n }\n\n if (isSectionElement(itemOrSection)) {\n const key = normalizeItemKey(itemOrSection);\n const { title } = itemOrSection.props;\n\n const items = normalizePickerItemList(itemOrSection.props.children).filter(\n // We don't support nested section elements\n childItem => !isSectionElement(childItem)\n ) as NormalizedPickerItem[];\n\n return {\n key,\n title,\n 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 key,\n content,\n textValue,\n };\n}\n\n/**\n * Get normalized picker items from a picker item or array of picker items.\n * @param itemsOrSections A picker item or array of picker items\n * @returns An array of normalized picker items\n */\nexport function normalizePickerItemList(\n itemsOrSections: PickerItemOrSection | PickerItemOrSection[]\n): (NormalizedPickerItem | NormalizedPickerSection)[] {\n const itemsArray = Array.isArray(itemsOrSections)\n ? itemsOrSections\n : [itemsOrSections];\n return itemsArray.map(normalizePickerItem);\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): PopperOptions | null {\n if (options == null || options === false) {\n return null;\n }\n\n if (options === true) {\n return { placement: 'top-start' };\n }\n\n return options;\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAsC,OAAO;AAGpE,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SACxBC,IAAI;AAAA,SACJC,OAAO;AAGhB,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,aAAa,CAAC;AAErC,OAAO,IAAMC,iCAAiC,GAC5C,gFAAgF;;AAElF;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,IAAe,EACwB;EACvC,OAAO,aAAAR,cAAc,CAAkBQ,IAAI,CAAC,IAAIA,IAAI,CAACC,IAAI,KAAKN,OAAO;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,aAAaA,CAC3BF,IAAe,EACqB;EACpC,OAAO,aAAAR,cAAc,CAAeQ,IAAI,CAAC,IAAIA,IAAI,CAACC,IAAI,KAAKP,IAAI;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,qBAAqBA,CACnCH,IAAe,EACc;EAC7B,OACE,OAAOA,IAAI,KAAK,QAAQ,IACxB,OAAOA,IAAI,KAAK,QAAQ,IACxB,OAAOA,IAAI,KAAK,SAAS,IACzBE,aAAa,CAACF,IAAI,CAAC,IACnBD,gBAAgB,CAACC,IAAI,CAAC;AAE1B;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,yBAAyBA,CACvCC,4BAA4E,EACnB;EACzD,OAAO,OAAO,IAAIA,4BAA4B;AAChD;;AAEA;AACA;AACA;AACA;AACA;;AAGA,SAASC,gBAAgBA,CACvBC,aAAyC,EACpB;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AAgB,CAACQ,aAAa,CAAC,EAAE;IACnC,IAAME,IAAG,GAAGH,gBAAgB,CAACC,aAAa,CAAC;IAC3C,IAAM;MAAEI;IAAM,CAAC,GAAGJ,aAAa,CAACG,KAAK;IAErC,IAAMU,KAAK,GAAGC,uBAAuB,CAACd,aAAa,CAACG,KAAK,CAACG,QAAQ,CAAC,CAACS,MAAM;IACxE;IACAC,SAAS,IAAI,CAACxB,gBAAgB,CAACwB,SAAS,CAC1C,CAA2B;IAE3B,OAAO;MACLd,GAAG,EAAHA,IAAG;MACHE,KAAK;MACLS;IACF,CAAC;EACH;EAEA,IAAMX,GAAG,GAAGH,gBAAgB,CAACC,aAAa,CAAC;EAC3C,IAAMiB,OAAO,GAAGtB,aAAa,CAACK,aAAa,CAAC,GACxCA,aAAa,CAACG,KAAK,CAACG,QAAQ,GAC5BN,aAAa;EACjB,IAAMK,SAAS,GAAGE,kBAAkB,CAACP,aAAa,CAAC;EAEnD,OAAO;IACLE,GAAG;IACHe,OAAO;IACPZ;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,uBAAuBA,CACrCI,eAA4D,EACR;EACpD,IAAMC,UAAU,GAAGC,KAAK,CAACC,OAAO,CAACH,eAAe,CAAC,GAC7CA,eAAe,GACf,CAACA,eAAe,CAAC;EACrB,OAAOC,UAAU,CAACG,GAAG,CAACZ,mBAAmB,CAAC;AAC5C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASa,uBAAuBA,CACrCC,OAAyC,EACnB;EACtB,IAAIA,OAAO,IAAI,IAAI,IAAIA,OAAO,KAAK,KAAK,EAAE;IACxC,OAAO,IAAI;EACb;EAEA,IAAIA,OAAO,KAAK,IAAI,EAAE;IACpB,OAAO;MAAEC,SAAS,EAAE;IAAY,CAAC;EACnC;EAEA,OAAOD,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"PickerUtils.js","names":["isValidElement","Log","Item","Section","log","module","INVALID_PICKER_ITEM_ERROR_MESSAGE","isSectionElement","node","type","isItemElement","isPickerItemOrSection","isNormalizedPickerSection","maybeNormalizedPickerSection","normalizeItemKey","itemOrSection","_itemOrSection$props$","key","props","title","undefined","textValue","children","normalizeTextValue","item","String","normalizePickerItem","debug","Error","items","normalizePickerItemList","filter","childItem","content","itemsOrSections","itemsArray","Array","isArray","map","normalizeTooltipOptions","options","placement"],"sources":["../../../src/spectrum/picker/PickerUtils.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 { Item, ItemProps } from '../Item';\nimport { Section, SectionProps } from '../Section';\nimport { PopperOptions } from '../../popper';\n\nconst log = Log.module('PickerUtils');\n\nexport const INVALID_PICKER_ITEM_ERROR_MESSAGE =\n 'Picker 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>>;\ntype SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;\n\nexport type PickerItem = number | string | boolean | ItemElement;\nexport type PickerSection = SectionElement;\nexport type PickerItemOrSection = PickerItem | PickerSection;\n\n/**\n * Augment the Spectrum selection key type to include boolean values.\n * The Spectrum Picker already supports this, but the built in types don't\n * reflect it.\n */\nexport type PickerItemKey = Key | boolean;\n\n/**\n * Augment the Spectrum selection change handler type to include boolean keys.\n * The Spectrum Picker already supports this, but the built in types don't\n * reflect it.\n */\nexport type PickerSelectionChangeHandler = (key: PickerItemKey) => void;\n\n/**\n * The Picker supports a variety of item types, including strings, numbers,\n * booleans, and more complex React elements. This type represents a normalized\n * form to make rendering items simpler and keep the logic of transformation\n * in separate util methods.\n */\nexport interface NormalizedPickerItem {\n key?: PickerItemKey;\n content: ReactNode;\n textValue?: string;\n}\n\nexport interface NormalizedPickerSection {\n key?: Key;\n title?: ReactNode;\n items: NormalizedPickerItem[];\n}\n\nexport type NormalizedSpectrumPickerProps =\n SpectrumPickerProps<NormalizedPickerItem>;\n\nexport type TooltipOptions = { placement: PopperOptions['placement'] };\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 a Picker 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 a Picker item or section\n */\nexport function isPickerItemOrSection(\n node: ReactNode\n): node is PickerItemOrSection {\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 if an object is a normalized Picker section.\n * @param maybeNormalizedPickerSection The object to check\n * @returns True if the object is a normalized Picker section\n */\nexport function isNormalizedPickerSection(\n maybeNormalizedPickerSection: NormalizedPickerItem | NormalizedPickerSection\n): maybeNormalizedPickerSection is NormalizedPickerSection {\n return 'items' in maybeNormalizedPickerSection;\n}\n\n/**\n * Determine the `key` of a picker item or section.\n * @param itemOrSection The picker item or section\n * @returns A `PickerItemKey` for the picker item or undefined if a key can't be determined\n */\nfunction normalizeItemKey(item: PickerItem): PickerItemKey | undefined;\nfunction normalizeItemKey(section: PickerSection): Key | undefined;\nfunction normalizeItemKey(\n itemOrSection: PickerItem | PickerSection\n): Key | PickerItemKey | 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 a picker item ensuring it is a string.\n * @param item The picker item\n * @returns A string `textValue` for the picker item\n */\nfunction normalizeTextValue(item: PickerItem): 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 a picker item to an object form.\n * @param itemOrSection item to normalize\n * @returns NormalizedPickerItem object\n */\nfunction normalizePickerItem(\n itemOrSection: PickerItemOrSection\n): NormalizedPickerItem | NormalizedPickerSection {\n if (!isPickerItemOrSection(itemOrSection)) {\n log.debug(INVALID_PICKER_ITEM_ERROR_MESSAGE, itemOrSection);\n throw new Error(INVALID_PICKER_ITEM_ERROR_MESSAGE);\n }\n\n if (isSectionElement(itemOrSection)) {\n const key = normalizeItemKey(itemOrSection);\n const { title } = itemOrSection.props;\n\n const items = normalizePickerItemList(itemOrSection.props.children).filter(\n // We don't support nested section elements\n childItem => !isSectionElement(childItem)\n ) as NormalizedPickerItem[];\n\n return {\n key,\n title,\n 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 key,\n content,\n textValue,\n };\n}\n\n/**\n * Get normalized picker items from a picker item or array of picker items.\n * @param itemsOrSections A picker item or array of picker items\n * @returns An array of normalized picker items\n */\nexport function normalizePickerItemList(\n itemsOrSections: PickerItemOrSection | PickerItemOrSection[]\n): (NormalizedPickerItem | NormalizedPickerSection)[] {\n const itemsArray = Array.isArray(itemsOrSections)\n ? itemsOrSections\n : [itemsOrSections];\n return itemsArray.map(normalizePickerItem);\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,SACxBC,IAAI;AAAA,SACJC,OAAO;AAGhB,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,aAAa,CAAC;AAErC,OAAO,IAAMC,iCAAiC,GAC5C,gFAAgF;;AAElF;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,IAAe,EACwB;EACvC,OAAO,aAAAR,cAAc,CAAkBQ,IAAI,CAAC,IAAIA,IAAI,CAACC,IAAI,KAAKN,OAAO;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,aAAaA,CAC3BF,IAAe,EACqB;EACpC,OAAO,aAAAR,cAAc,CAAeQ,IAAI,CAAC,IAAIA,IAAI,CAACC,IAAI,KAAKP,IAAI;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,qBAAqBA,CACnCH,IAAe,EACc;EAC7B,OACE,OAAOA,IAAI,KAAK,QAAQ,IACxB,OAAOA,IAAI,KAAK,QAAQ,IACxB,OAAOA,IAAI,KAAK,SAAS,IACzBE,aAAa,CAACF,IAAI,CAAC,IACnBD,gBAAgB,CAACC,IAAI,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AAI;EACb;EAEA,IAAIA,OAAO,KAAK,IAAI,EAAE;IACpB,OAAO;MAAEC,SAAS,EAAE;IAAQ,CAAC;EAC/B;EAEA,OAAOD,OAAO;AAChB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.68.1-beta.0+3ed4f6bc",
|
|
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.
|
|
29
|
-
"@deephaven/log": "^0.
|
|
30
|
-
"@deephaven/react-hooks": "^0.
|
|
31
|
-
"@deephaven/utils": "^0.
|
|
28
|
+
"@deephaven/icons": "^0.68.1-beta.0+3ed4f6bc",
|
|
29
|
+
"@deephaven/log": "^0.68.1-beta.0+3ed4f6bc",
|
|
30
|
+
"@deephaven/react-hooks": "^0.68.1-beta.0+3ed4f6bc",
|
|
31
|
+
"@deephaven/utils": "^0.68.1-beta.0+3ed4f6bc",
|
|
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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"react-dom": "^17.x"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@deephaven/mocks": "^0.
|
|
56
|
+
"@deephaven/mocks": "^0.68.1-beta.0+3ed4f6bc"
|
|
57
57
|
},
|
|
58
58
|
"files": [
|
|
59
59
|
"dist",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "3ed4f6bca3fc15e6161f19256433a1205c56a1ca"
|
|
71
71
|
}
|
package/scss/BaseStyleSheet.scss
CHANGED
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
color: var(--dh-color-text);
|
|
10
10
|
|
|
11
|
-
.spectrum-theme-provider
|
|
12
|
-
|
|
11
|
+
.spectrum-theme-provider {
|
|
12
|
+
// This is important for portals with rounded corners (e.g. Popover) so that
|
|
13
|
+
// the underlying background color shows.
|
|
14
|
+
--dh-spectrum-theme-provider-bg: unset;
|
|
15
|
+
|
|
16
|
+
background-color: var(--dh-spectrum-theme-provider-bg);
|
|
13
17
|
color: var(--dh-color-text);
|
|
14
18
|
}
|
|
15
19
|
}
|