@deephaven/components 0.66.1-beta.1 → 0.66.2-alpha-ui-picker.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.
@@ -2,7 +2,7 @@
2
2
  * The Spectrum ActionBar hard codes a max-width: 960px for the content area.
3
3
  * Overriding so the bar fills the same width as its associated list component.
4
4
  */
5
- .spectrumActionBar [class^=react-spectrum-ActionBar-bar] {
5
+ .spectrumActionBar [class*=react-spectrum-ActionBar-bar] {
6
6
  max-width: none;
7
7
  }
8
8
 
@@ -1 +1 @@
1
- {"version":3,"sourceRoot":"","sources":["../src/SpectrumComponent.module.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAAA;AAKE;EACE;;;AAIJ;EACE;EACA;;;AAGF;EACE;EACA;EACA","file":"SpectrumComponent.module.css","sourcesContent":["/**\n * The Spectrum ActionBar hard codes a max-width: 960px for the content area.\n * Overriding so the bar fills the same width as its associated list component.\n */\n.spectrumActionBar {\n [class^='react-spectrum-ActionBar-bar'] {\n max-width: none;\n }\n}\n\n.spectrumDialogComponentHeading {\n font-weight: normal;\n overflow-wrap: break-word;\n}\n\n.spectrumEllipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n"]}
1
+ {"version":3,"sourceRoot":"","sources":["../src/SpectrumComponent.module.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAAA;AAKE;EACE;;;AAIJ;EACE;EACA;;;AAGF;EACE;EACA;EACA","file":"SpectrumComponent.module.css","sourcesContent":["/**\n * The Spectrum ActionBar hard codes a max-width: 960px for the content area.\n * Overriding so the bar fills the same width as its associated list component.\n */\n.spectrumActionBar {\n [class*='react-spectrum-ActionBar-bar'] {\n max-width: none;\n }\n}\n\n.spectrumDialogComponentHeading {\n font-weight: normal;\n overflow-wrap: break-word;\n}\n\n.spectrumEllipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { NormalizedSpectrumPickerProps, PickerItem, PickerItemKey, TooltipOptions } from './PickerUtils';
2
+ import { NormalizedSpectrumPickerProps, PickerItemOrSection, PickerItemKey, TooltipOptions } from './PickerUtils';
3
3
  export type PickerProps = {
4
- children: PickerItem | PickerItem[];
4
+ children: PickerItemOrSection | PickerItemOrSection[];
5
5
  /** Can be set to true or a TooltipOptions to enable item tooltips */
6
6
  tooltip?: boolean | TooltipOptions;
7
7
  /** The currently selected key in the collection (controlled). */
@@ -1 +1 @@
1
- {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/Picker.tsx"],"names":[],"mappings":";AAGA,OAAO,EACL,6BAA6B,EAG7B,UAAU,EACV,aAAa,EACb,cAAc,EACf,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,UAAU,GAAG,UAAU,EAAE,CAAC;IACpC,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,iEAAiE;IACjE,WAAW,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACnC,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD,GAKK,IAAI,CACR,6BAA6B,EAC3B,UAAU,GACV,OAAO,GACP,mBAAmB,GACnB,aAAa,GACb,oBAAoB,CACvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,GAAG,mBAAmB,EACvB,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAuC3B;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/Picker.tsx"],"names":[],"mappings":";AAGA,OAAO,EACL,6BAA6B,EAG7B,mBAAmB,EACnB,aAAa,EACb,cAAc,EAEf,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,CAAC;IACtD,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,iEAAiE;IACjE,WAAW,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACnC,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD,GAKK,IAAI,CACR,6BAA6B,EAC3B,UAAU,GACV,OAAO,GACP,mBAAmB,GACnB,aAAa,GACb,oBAAoB,CACvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,GAAG,mBAAmB,EACvB,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CA0D3B;AAED,eAAe,MAAM,CAAC"}
@@ -6,8 +6,8 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
6
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
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
- import { useMemo } from 'react';
10
- import { Item, Picker as SpectrumPicker } from '@adobe/react-spectrum';
9
+ import { useCallback, useMemo } from 'react';
10
+ import { Item, Picker as SpectrumPicker, Section } from '@adobe/react-spectrum';
11
11
  import { Tooltip } from "../../popper/index.js";
12
12
  import { normalizePickerItemList, normalizeTooltipOptions } from "./PickerUtils.js";
13
13
  import { PickerItemContent } from "./PickerItemContent.js";
@@ -32,6 +32,21 @@ export function Picker(_ref) {
32
32
  spectrumPickerProps = _objectWithoutProperties(_ref, _excluded);
33
33
  var normalizedItems = useMemo(() => normalizePickerItemList(children), [children]);
34
34
  var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip), [tooltip]);
35
+ var renderItem = useCallback(_ref2 => {
36
+ var {
37
+ content,
38
+ textValue
39
+ } = _ref2;
40
+ return /*#__PURE__*/_jsxs(Item, {
41
+ textValue: textValue === '' ? 'Empty' : textValue,
42
+ children: [/*#__PURE__*/_jsx(PickerItemContent, {
43
+ children: content
44
+ }), tooltipOptions == null || content === '' ? null : /*#__PURE__*/_jsx(Tooltip, {
45
+ options: tooltipOptions,
46
+ children: content
47
+ })]
48
+ });
49
+ }, [tooltipOptions]);
35
50
  return /*#__PURE__*/_jsx(SpectrumPicker
36
51
  // eslint-disable-next-line react/jsx-props-no-spreading
37
52
  , _objectSpread(_objectSpread({}, spectrumPickerProps), {}, {
@@ -45,20 +60,15 @@ export function Picker(_ref) {
45
60
  // `onChange` is just an alias for `onSelectionChange`
46
61
  ,
47
62
  onSelectionChange: onChange !== null && onChange !== void 0 ? onChange : onSelectionChange,
48
- children: _ref2 => {
49
- var {
50
- content,
51
- textValue
52
- } = _ref2;
53
- return /*#__PURE__*/_jsxs(Item, {
54
- textValue: textValue === '' ? 'Empty' : textValue,
55
- children: [/*#__PURE__*/_jsx(PickerItemContent, {
56
- children: content
57
- }), tooltipOptions == null || content === '' ? null : /*#__PURE__*/_jsx(Tooltip, {
58
- options: tooltipOptions,
59
- children: content
60
- })]
61
- });
63
+ children: itemOrSection => {
64
+ if ('items' in itemOrSection) {
65
+ return /*#__PURE__*/_jsx(Section, {
66
+ title: itemOrSection.title,
67
+ items: itemOrSection.items,
68
+ children: renderItem
69
+ }, itemOrSection.key);
70
+ }
71
+ return renderItem(itemOrSection);
62
72
  }
63
73
  }));
64
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Picker.js","names":["useMemo","Item","Picker","SpectrumPicker","Tooltip","normalizePickerItemList","normalizeTooltipOptions","PickerItemContent","jsx","_jsx","jsxs","_jsxs","_ref","children","tooltip","defaultSelectedKey","selectedKey","onChange","onSelectionChange","spectrumPickerProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","_objectSpread","items","_ref2","content","textValue","options"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { Item, Picker as SpectrumPicker } from '@adobe/react-spectrum';\nimport { Tooltip } from '../../popper';\nimport {\n NormalizedSpectrumPickerProps,\n normalizePickerItemList,\n normalizeTooltipOptions,\n PickerItem,\n PickerItemKey,\n TooltipOptions,\n} from './PickerUtils';\nimport { PickerItemContent } from './PickerItemContent';\n\nexport type PickerProps = {\n children: PickerItem | PickerItem[];\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 * 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,\n defaultSelectedKey,\n selectedKey,\n onChange,\n onSelectionChange,\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 return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumPickerProps}\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 {({ content, textValue }) => (\n <Item textValue={textValue === '' ? 'Empty' : textValue}>\n <PickerItemContent>{content}</PickerItemContent>\n {tooltipOptions == null || content === '' ? null : (\n <Tooltip options={tooltipOptions}>{content}</Tooltip>\n )}\n </Item>\n )}\n </SpectrumPicker>\n );\n}\n\nexport default Picker;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,IAAI,EAAEC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AAAC,SAC9DC,OAAO;AAAA,SAGdC,uBAAuB,EACvBC,uBAAuB;AAAA,SAKhBC,iBAAiB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAoC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAST,MAAMA,CAAAU,IAAA,EAQO;EAAA,IARN;MACrBC,QAAQ;MACRC,OAAO;MACPC,kBAAkB;MAClBC,WAAW;MACXC,QAAQ;MACRC;IAEW,CAAC,GAAAN,IAAA;IADTO,mBAAmB,GAAAC,wBAAA,CAAAR,IAAA,EAAAS,SAAA;EAEtB,IAAMC,eAAe,GAAGtB,OAAO,CAC7B,MAAMK,uBAAuB,CAACQ,QAAQ,CAAC,EACvC,CAACA,QAAQ,CACX,CAAC;EAED,IAAMU,cAAc,GAAGvB,OAAO,CAC5B,MAAMM,uBAAuB,CAACQ,OAAO,CAAC,EACtC,CAACA,OAAO,CACV,CAAC;EAED,oBACEL,IAAA,CAACN;EACC;EAAA,EAAAqB,aAAA,CAAAA,aAAA,KACIL,mBAAmB;IACvBM,KAAK,EAAEH;IACP;IACA;IACA;IAAA;IACAN,WAAW,EAAEA,WAA4D;IACzED,kBAAkB,EAChBA;IAEF;IAAA;IACAG,iBAAiB,EACdD,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GACPC,iBACH;IAAAL,QAAA,EAEAa,KAAA;MAAA,IAAC;QAAEC,OAAO;QAAEC;MAAU,CAAC,GAAAF,KAAA;MAAA,oBACtBf,KAAA,CAACV,IAAI;QAAC2B,SAAS,EAAEA,SAAS,KAAK,EAAE,GAAG,OAAO,GAAGA,SAAU;QAAAf,QAAA,gBACtDJ,IAAA,CAACF,iBAAiB;UAAAM,QAAA,EAAEc;QAAO,CAAoB,CAAC,EAC/CJ,cAAc,IAAI,IAAI,IAAII,OAAO,KAAK,EAAE,GAAG,IAAI,gBAC9ClB,IAAA,CAACL,OAAO;UAACyB,OAAO,EAAEN,cAAe;UAAAV,QAAA,EAAEc;QAAO,CAAU,CACrD;MAAA,CACG,CAAC;IAAA;EACR,EACa,CAAC;AAErB;AAEA,eAAezB,MAAM"}
1
+ {"version":3,"file":"Picker.js","names":["useCallback","useMemo","Item","Picker","SpectrumPicker","Section","Tooltip","normalizePickerItemList","normalizeTooltipOptions","PickerItemContent","jsx","_jsx","jsxs","_jsxs","_ref","children","tooltip","defaultSelectedKey","selectedKey","onChange","onSelectionChange","spectrumPickerProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderItem","_ref2","content","textValue","options","_objectSpread","items","itemOrSection","title","key"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { Item, Picker as SpectrumPicker, Section } from '@adobe/react-spectrum';\nimport { Tooltip } from '../../popper';\nimport {\n NormalizedSpectrumPickerProps,\n normalizePickerItemList,\n normalizeTooltipOptions,\n PickerItemOrSection,\n PickerItemKey,\n TooltipOptions,\n NormalizedPickerItem,\n} from './PickerUtils';\nimport { PickerItemContent } from './PickerItemContent';\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 * 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,\n defaultSelectedKey,\n selectedKey,\n onChange,\n onSelectionChange,\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 ({ content, textValue }: NormalizedPickerItem) => (\n <Item textValue={textValue === '' ? 'Empty' : textValue}>\n <PickerItemContent>{content}</PickerItemContent>\n {tooltipOptions == null || content === '' ? null : (\n <Tooltip options={tooltipOptions}>{content}</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 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 ('items' in 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,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC5C,SAASC,IAAI,EAAEC,MAAM,IAAIC,cAAc,EAAEC,OAAO,QAAQ,uBAAuB;AAAC,SACvEC,OAAO;AAAA,SAGdC,uBAAuB,EACvBC,uBAAuB;AAAA,SAMhBC,iBAAiB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAoC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASV,MAAMA,CAAAW,IAAA,EAQO;EAAA,IARN;MACrBC,QAAQ;MACRC,OAAO;MACPC,kBAAkB;MAClBC,WAAW;MACXC,QAAQ;MACRC;IAEW,CAAC,GAAAN,IAAA;IADTO,mBAAmB,GAAAC,wBAAA,CAAAR,IAAA,EAAAS,SAAA;EAEtB,IAAMC,eAAe,GAAGvB,OAAO,CAC7B,MAAMM,uBAAuB,CAACQ,QAAQ,CAAC,EACvC,CAACA,QAAQ,CACX,CAAC;EAED,IAAMU,cAAc,GAAGxB,OAAO,CAC5B,MAAMO,uBAAuB,CAACQ,OAAO,CAAC,EACtC,CAACA,OAAO,CACV,CAAC;EAED,IAAMU,UAAU,GAAG1B,WAAW,CAC5B2B,KAAA;IAAA,IAAC;MAAEC,OAAO;MAAEC;IAAgC,CAAC,GAAAF,KAAA;IAAA,oBAC3Cd,KAAA,CAACX,IAAI;MAAC2B,SAAS,EAAEA,SAAS,KAAK,EAAE,GAAG,OAAO,GAAGA,SAAU;MAAAd,QAAA,gBACtDJ,IAAA,CAACF,iBAAiB;QAAAM,QAAA,EAAEa;MAAO,CAAoB,CAAC,EAC/CH,cAAc,IAAI,IAAI,IAAIG,OAAO,KAAK,EAAE,GAAG,IAAI,gBAC9CjB,IAAA,CAACL,OAAO;QAACwB,OAAO,EAAEL,cAAe;QAAAV,QAAA,EAAEa;MAAO,CAAU,CACrD;IAAA,CACG,CAAC;EAAA,CACR,EACD,CAACH,cAAc,CACjB,CAAC;EAED,oBACEd,IAAA,CAACP;EACC;EAAA,EAAA2B,aAAA,CAAAA,aAAA,KACIV,mBAAmB;IACvBW,KAAK,EAAER;IACP;IACA;IACA;IAAA;IACAN,WAAW,EAAEA,WAA4D;IACzED,kBAAkB,EAChBA;IAEF;IAAA;IACAG,iBAAiB,EACdD,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GACPC,iBACH;IAAAL,QAAA,EAEAkB,aAAa,IAAI;MAChB,IAAI,OAAO,IAAIA,aAAa,EAAE;QAC5B,oBACEtB,IAAA,CAACN,OAAO;UAEN6B,KAAK,EAAED,aAAa,CAACC,KAAM;UAC3BF,KAAK,EAAEC,aAAa,CAACD,KAAM;UAAAjB,QAAA,EAE1BW;QAAU,GAJNO,aAAa,CAACE,GAKZ,CAAC;MAEd;MAEA,OAAOT,UAAU,CAACO,aAAa,CAAC;IAClC;EAAC,EACa,CAAC;AAErB;AAEA,eAAe9B,MAAM"}
@@ -1,9 +1,15 @@
1
1
  import { Key, ReactElement, ReactNode } from 'react';
2
- import type { SpectrumPickerProps } from '@adobe/react-spectrum';
3
- import type { ItemProps } from '@react-types/shared';
2
+ import { SpectrumPickerProps } from '@adobe/react-spectrum';
3
+ import type { ItemProps, ItemRenderer, SectionProps } from '@react-types/shared';
4
4
  import { PopperOptions } from '../../popper';
5
+ export type SectionPropsNoItemRenderer<T> = Omit<SectionProps<T>, 'children'> & {
6
+ children: Exclude<SectionProps<T>['children'], ItemRenderer<T>>;
7
+ };
5
8
  export type ItemElement = ReactElement<ItemProps<unknown>>;
9
+ export type SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;
6
10
  export type PickerItem = number | string | boolean | ItemElement;
11
+ export type PickerSection = SectionElement;
12
+ export type PickerItemOrSection = PickerItem | PickerSection;
7
13
  /**
8
14
  * Augment the Spectrum selection key type to include boolean values.
9
15
  * The Spectrum Picker already supports this, but the built in types don't
@@ -27,16 +33,23 @@ export interface NormalizedPickerItem {
27
33
  content: ReactNode;
28
34
  textValue: string;
29
35
  }
36
+ export interface NormalizedPickerSection {
37
+ key: Key;
38
+ title: ReactNode;
39
+ items: NormalizedPickerItem[];
40
+ }
30
41
  export type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedPickerItem>;
31
42
  export type TooltipOptions = {
32
43
  placement: PopperOptions['placement'];
33
44
  };
45
+ export declare function isSectionElement<T>(node: ReactNode): node is ReactElement<SectionProps<T>>;
46
+ export declare function isItemElement<T>(node: ReactNode): node is ReactElement<ItemProps<T>>;
34
47
  /**
35
48
  * Get normalized picker items from a picker item or array of picker items.
36
49
  * @param items A picker item or array of picker items
37
50
  * @returns An array of normalized picker items
38
51
  */
39
- export declare function normalizePickerItemList(items: PickerItem | PickerItem[]): NormalizedPickerItem[];
52
+ export declare function normalizePickerItemList(items: PickerItemOrSection | PickerItemOrSection[]): (NormalizedPickerItem | NormalizedPickerSection)[];
40
53
  /**
41
54
  * Returns a TooltipOptions object or null if options is false or null.
42
55
  * @param options
@@ -1 +1 @@
1
- {"version":3,"file":"PickerUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,MAAM,WAAW,G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AAa,CAAC,CAAC,EAC7B,IAAI,EAAE,SAAS,GACd,IAAI,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAEpC;AA+FD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,GACjD,CAAC,oBAAoB,GAAG,uBAAuB,CAAC,EAAE,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,GACxC,aAAa,GAAG,IAAI,CAUtB"}
@@ -1,3 +1,6 @@
1
+ import { isValidElement } from 'react';
2
+ import { Item, Section } from '@adobe/react-spectrum';
3
+
1
4
  /**
2
5
  * Augment the Spectrum selection key type to include boolean values.
3
6
  * The Spectrum Picker already supports this, but the built in types don't
@@ -17,26 +20,42 @@
17
20
  * in separate util methods.
18
21
  */
19
22
 
23
+ export function isSectionElement(node) {
24
+ return /*#__PURE__*/isValidElement(node) && node.type === Section;
25
+ }
26
+ export function isItemElement(node) {
27
+ return /*#__PURE__*/isValidElement(node) && node.type === Item;
28
+ }
29
+
20
30
  /**
21
31
  * Determine the `key` of a picker item.
22
- * @param item The picker item
32
+ * @param item The picker item or section
23
33
  * @returns A `PickerItemKey` for the picker item
24
34
  */
35
+
25
36
  function normalizeItemKey(item) {
26
- var _item$props$textValue;
27
37
  // string, number, or boolean
28
38
  if (typeof item !== 'object') {
29
39
  return item;
30
40
  }
31
41
 
32
- // `ItemElement` with `key` prop set
42
+ // If `key` prop is explicitly set
33
43
  if (item.key != null) {
34
44
  return item.key;
35
45
  }
46
+ if (isSectionElement(item)) {
47
+ if (typeof item.props.title === 'string') {
48
+ return item.props.title;
49
+ }
50
+ } else if (isItemElement(item)) {
51
+ if (item.props.textValue != null) {
52
+ return item.props.textValue;
53
+ }
54
+ }
36
55
  if (typeof item.props.children === 'string') {
37
56
  return item.props.children;
38
57
  }
39
- return (_item$props$textValue = item.props.textValue) !== null && _item$props$textValue !== void 0 ? _item$props$textValue : '';
58
+ return '';
40
59
  }
41
60
 
42
61
  /**
@@ -63,6 +82,20 @@ function normalizeTextValue(item) {
63
82
  * @returns NormalizedPickerItem object
64
83
  */
65
84
  function normalizePickerItem(item) {
85
+ if (isSectionElement(item)) {
86
+ var _key = normalizeItemKey(item);
87
+ var {
88
+ title
89
+ } = item.props;
90
+ var items = normalizePickerItemList(item.props.children).filter(
91
+ // We don't support nested section elements
92
+ childItem => !isSectionElement(childItem));
93
+ return {
94
+ key: _key,
95
+ title,
96
+ items
97
+ };
98
+ }
66
99
  var key = normalizeItemKey(item);
67
100
  var content = typeof item === 'object' ? item.props.children : String(item);
68
101
  var textValue = normalizeTextValue(item);
@@ -1 +1 @@
1
- {"version":3,"file":"PickerUtils.js","names":["normalizeItemKey","item","_item$props$textValue","key","props","children","textValue","normalizeTextValue","String","normalizePickerItem","content","normalizePickerItemList","items","itemsArray","Array","isArray","map","normalizeTooltipOptions","options","placement"],"sources":["../../../src/spectrum/picker/PickerUtils.ts"],"sourcesContent":["import { Key, ReactElement, ReactNode } from 'react';\nimport type { SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type { ItemProps } from '@react-types/shared';\nimport { PopperOptions } from '../../popper';\n\nexport type ItemElement = ReactElement<ItemProps<unknown>>;\nexport type PickerItem = number | string | boolean | ItemElement;\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 type NormalizedSpectrumPickerProps =\n SpectrumPickerProps<NormalizedPickerItem>;\n\nexport type TooltipOptions = { placement: PopperOptions['placement'] };\n\n/**\n * Determine the `key` of a picker item.\n * @param item The picker item\n * @returns A `PickerItemKey` for the picker item\n */\nfunction normalizeItemKey(item: PickerItem): PickerItemKey {\n // string, number, or boolean\n if (typeof item !== 'object') {\n return item;\n }\n\n // `ItemElement` with `key` prop set\n if (item.key != null) {\n return item.key;\n }\n\n if (typeof item.props.children === 'string') {\n return item.props.children;\n }\n\n return item.props.textValue ?? '';\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 item item to normalize\n * @returns NormalizedPickerItem object\n */\nfunction normalizePickerItem(item: PickerItem): NormalizedPickerItem {\n const key = normalizeItemKey(item);\n const content = typeof item === 'object' ? item.props.children : String(item);\n const textValue = normalizeTextValue(item);\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 items A picker item or array of picker items\n * @returns An array of normalized picker items\n */\nexport function normalizePickerItemList(\n items: PickerItem | PickerItem[]\n): NormalizedPickerItem[] {\n const itemsArray = Array.isArray(items) ? items : [items];\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":"AAQA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;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AAO;IACLE,GAAG;IACHO,OAAO;IACPJ;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,uBAAuBA,CACrCC,KAAgC,EACR;EACxB,IAAMC,UAAU,GAAGC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAG,CAACA,KAAK,CAAC;EACzD,OAAOC,UAAU,CAACG,GAAG,CAACP,mBAAmB,CAAC;AAC5C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,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","Item","Section","isSectionElement","node","type","isItemElement","normalizeItemKey","item","key","props","title","textValue","children","normalizeTextValue","String","normalizePickerItem","items","normalizePickerItemList","filter","childItem","content","itemsArray","Array","isArray","map","normalizeTooltipOptions","options","placement"],"sources":["../../../src/spectrum/picker/PickerUtils.ts"],"sourcesContent":["import { isValidElement, Key, ReactElement, ReactNode } from 'react';\nimport { Item, Section, SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type {\n ItemProps,\n ItemRenderer,\n SectionProps,\n} from '@react-types/shared';\nimport { PopperOptions } from '../../popper';\n\nexport type SectionPropsNoItemRenderer<T> = Omit<\n SectionProps<T>,\n 'children'\n> & {\n children: Exclude<SectionProps<T>['children'], ItemRenderer<T>>;\n};\n\nexport type ItemElement = ReactElement<ItemProps<unknown>>;\nexport type SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;\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\nexport function isSectionElement<T>(\n node: ReactNode\n): node is ReactElement<SectionProps<T>> {\n return isValidElement<SectionProps<T>>(node) && node.type === Section;\n}\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 the `key` of a picker item.\n * @param item The picker item or section\n * @returns A `PickerItemKey` for the picker item\n */\nfunction normalizeItemKey(item: PickerItem): PickerItemKey;\nfunction normalizeItemKey(item: PickerSection): Key;\nfunction normalizeItemKey(\n item: PickerItem | PickerSection\n): Key | PickerItemKey {\n // string, number, or boolean\n if (typeof item !== 'object') {\n return item as PickerItemKey;\n }\n\n // If `key` prop is explicitly set\n if (item.key != null) {\n return item.key;\n }\n\n if (isSectionElement(item)) {\n if (typeof item.props.title === 'string') {\n return item.props.title;\n }\n } else if (isItemElement(item)) {\n if (item.props.textValue != null) {\n return item.props.textValue;\n }\n }\n\n if (typeof item.props.children === 'string') {\n return item.props.children;\n }\n\n return '';\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 item item to normalize\n * @returns NormalizedPickerItem object\n */\nfunction normalizePickerItem(\n item: PickerItemOrSection\n): NormalizedPickerItem | NormalizedPickerSection {\n if (isSectionElement(item)) {\n const key = normalizeItemKey(item);\n const { title } = item.props;\n\n const items = normalizePickerItemList(item.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(item);\n const content = typeof item === 'object' ? item.props.children : String(item);\n const textValue = normalizeTextValue(item);\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 items A picker item or array of picker items\n * @returns An array of normalized picker items\n */\nexport function normalizePickerItemList(\n items: PickerItemOrSection | PickerItemOrSection[]\n): (NormalizedPickerItem | NormalizedPickerSection)[] {\n const itemsArray = Array.isArray(items) ? items : [items];\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;AACpE,SAASC,IAAI,EAAEC,OAAO,QAA6B,uBAAuB;;AAqB1E;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAkBA,OAAO,SAASC,gBAAgBA,CAC9BC,IAAe,EACwB;EACvC,OAAO,aAAAJ,cAAc,CAAkBI,IA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EA,IAAIA,OAAO,KAAK,IAAI,EAAE;IACpB,OAAO;MAAEC,SAAS,EAAE;IAAY,CAAC;EACnC;EAEA,OAAOD,OAAO;AAChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/components",
3
- "version": "0.66.1-beta.1+e7c6b84b",
3
+ "version": "0.66.2-alpha-ui-picker.2+f00d1db4",
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.66.1-beta.1+e7c6b84b",
29
- "@deephaven/log": "^0.66.1-beta.1+e7c6b84b",
30
- "@deephaven/react-hooks": "^0.66.1-beta.1+e7c6b84b",
31
- "@deephaven/utils": "^0.66.1-beta.1+e7c6b84b",
28
+ "@deephaven/icons": "^0.66.2-alpha-ui-picker.2+f00d1db4",
29
+ "@deephaven/log": "^0.66.2-alpha-ui-picker.2+f00d1db4",
30
+ "@deephaven/react-hooks": "^0.66.2-alpha-ui-picker.2+f00d1db4",
31
+ "@deephaven/utils": "^0.66.2-alpha-ui-picker.2+f00d1db4",
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",
@@ -52,7 +52,7 @@
52
52
  "react-dom": "^17.x"
53
53
  },
54
54
  "devDependencies": {
55
- "@deephaven/mocks": "^0.66.1-beta.1+e7c6b84b"
55
+ "@deephaven/mocks": "^0.66.2-alpha-ui-picker.2+f00d1db4"
56
56
  },
57
57
  "files": [
58
58
  "dist",
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "gitHead": "e7c6b84b113e1d05f5ca2460d796d864c5445b09"
69
+ "gitHead": "f00d1db469c2a12aa1b7dbdf1073236518bb3082"
70
70
  }