@deephaven/components 0.66.1 → 0.66.2-alpha-ui-picker.18

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.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Wrapping Spectrum `Item` components will break functionality due to the way
3
+ * they are consumed by collection components. They are only used to pass data
4
+ * and don't render anything on their own, so they don't need to be wrapped.
5
+ * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Item.ts#L17
6
+ */
7
+ import { Item } from '@adobe/react-spectrum';
8
+ export type { ItemProps } from '@react-types/shared';
9
+ export { Item };
10
+ export default Item;
11
+ //# sourceMappingURL=Item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../src/spectrum/Item.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,eAAe,IAAI,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Wrapping Spectrum `Item` components will break functionality due to the way
3
+ * they are consumed by collection components. They are only used to pass data
4
+ * and don't render anything on their own, so they don't need to be wrapped.
5
+ * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Item.ts#L17
6
+ */
7
+ import { Item } from '@adobe/react-spectrum';
8
+ export { Item };
9
+ export default Item;
10
+ //# sourceMappingURL=Item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Item.js","names":["Item"],"sources":["../../src/spectrum/Item.tsx"],"sourcesContent":["/**\n * Wrapping Spectrum `Item` components will break functionality due to the way\n * they are consumed by collection components. They are only used to pass data\n * and don't render anything on their own, so they don't need to be wrapped.\n * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Item.ts#L17\n */\nimport { Item } from '@adobe/react-spectrum';\n\nexport type { ItemProps } from '@react-types/shared';\n\nexport { Item };\n\nexport default Item;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,uBAAuB;AAI5C,SAASA,IAAI;AAEb,eAAeA,IAAI"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Wrapping Spectrum `Section` components will break functionality due to the way
3
+ * they are consumed by collection components. They are only used to pass data
4
+ * and don't render anything on their own, so they don't need to be wrapped.
5
+ * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Section.ts#L18
6
+ */
7
+ import { Section } from '@adobe/react-spectrum';
8
+ export type { SectionProps } from '@react-types/shared';
9
+ export { Section };
10
+ export default Section;
11
+ //# sourceMappingURL=Section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Section.d.ts","sourceRoot":"","sources":["../../src/spectrum/Section.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,eAAe,OAAO,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Wrapping Spectrum `Section` components will break functionality due to the way
3
+ * they are consumed by collection components. They are only used to pass data
4
+ * and don't render anything on their own, so they don't need to be wrapped.
5
+ * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Section.ts#L18
6
+ */
7
+ import { Section } from '@adobe/react-spectrum';
8
+ export { Section };
9
+ export default Section;
10
+ //# sourceMappingURL=Section.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Section.js","names":["Section"],"sources":["../../src/spectrum/Section.tsx"],"sourcesContent":["/**\n * Wrapping Spectrum `Section` components will break functionality due to the way\n * they are consumed by collection components. They are only used to pass data\n * and don't render anything on their own, so they don't need to be wrapped.\n * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/collections/src/Section.ts#L18\n */\nimport { Section } from '@adobe/react-spectrum';\n\nexport type { SectionProps } from '@react-types/shared';\n\nexport { Section };\n\nexport default Section;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,uBAAuB;AAI/C,SAASA,OAAO;AAEhB,eAAeA,OAAO"}
@@ -1,2 +1,4 @@
1
1
  export * from './picker';
2
+ export * from './Item';
3
+ export * from './Section';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spectrum/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spectrum/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export * from "./picker/index.js";
2
+ export * from "./Item.js";
3
+ export * from "./Section.js";
2
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/spectrum/index.ts"],"sourcesContent":["export * from './picker';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/spectrum/index.ts"],"sourcesContent":["export * from './picker';\nexport * from './Item';\nexport * from './Section';\n"],"mappings":""}
@@ -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). */
@@ -28,6 +28,6 @@ export type PickerProps = {
28
28
  * pass through props for the Spectrum Picker component.
29
29
  * See https://react-spectrum.adobe.com/react-spectrum/Picker.html
30
30
  */
31
- export declare function Picker({ children, tooltip, defaultSelectedKey, selectedKey, onChange, onSelectionChange, ...spectrumPickerProps }: PickerProps): JSX.Element;
31
+ export declare function Picker({ children, tooltip, defaultSelectedKey, selectedKey, onChange, onSelectionChange, UNSAFE_className, ...spectrumPickerProps }: PickerProps): JSX.Element;
32
32
  export default Picker;
33
33
  //# sourceMappingURL=Picker.d.ts.map
@@ -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":";AAIA,OAAO,EACL,6BAA6B,EAG7B,mBAAmB,EACnB,aAAa,EACb,cAAc,EAGf,MAAM,eAAe,CAAC;AAKvB,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,OAAc,EACd,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,iBAAiB,EAEjB,gBAAgB,EAChB,GAAG,mBAAmB,EACvB,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAiE3B;AAED,eAAe,MAAM,CAAC"}
@@ -1,4 +1,4 @@
1
- var _excluded = ["children", "tooltip", "defaultSelectedKey", "selectedKey", "onChange", "onSelectionChange"];
1
+ var _excluded = ["children", "tooltip", "defaultSelectedKey", "selectedKey", "onChange", "onSelectionChange", "UNSAFE_className"];
2
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
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
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; }
@@ -6,11 +6,14 @@ 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 { Picker as SpectrumPicker } from '@adobe/react-spectrum';
11
+ import cl from 'classnames';
11
12
  import { Tooltip } from "../../popper/index.js";
12
- import { normalizePickerItemList, normalizeTooltipOptions } from "./PickerUtils.js";
13
+ import { normalizePickerItemList, normalizeTooltipOptions, isNormalizedPickerSection } from "./PickerUtils.js";
13
14
  import { PickerItemContent } from "./PickerItemContent.js";
15
+ import { Item } from "../Item.js";
16
+ import { Section } from "../Section.js";
14
17
  import { jsx as _jsx } from "react/jsx-runtime";
15
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
19
  /**
@@ -23,18 +26,44 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
23
26
  export function Picker(_ref) {
24
27
  var {
25
28
  children,
26
- tooltip,
29
+ tooltip = true,
27
30
  defaultSelectedKey,
28
31
  selectedKey,
29
32
  onChange,
30
- onSelectionChange
33
+ onSelectionChange,
34
+ // eslint-disable-next-line camelcase
35
+ UNSAFE_className
31
36
  } = _ref,
32
37
  spectrumPickerProps = _objectWithoutProperties(_ref, _excluded);
33
38
  var normalizedItems = useMemo(() => normalizePickerItemList(children), [children]);
34
39
  var tooltipOptions = useMemo(() => normalizeTooltipOptions(tooltip), [tooltip]);
40
+ var renderItem = useCallback(_ref2 => {
41
+ var {
42
+ key,
43
+ content,
44
+ textValue
45
+ } = _ref2;
46
+ return (
47
+ /*#__PURE__*/
48
+ // The `textValue` prop gets used to provide the content of `<option>`
49
+ // elements that back the Spectrum Picker. These are not visible in the UI,
50
+ // but are used for accessibility purposes, so we set to an arbitrary
51
+ // 'Empty' value so that they are not empty strings.
52
+ _jsxs(Item, {
53
+ textValue: textValue === '' ? 'Empty' : textValue,
54
+ children: [/*#__PURE__*/_jsx(PickerItemContent, {
55
+ children: content
56
+ }), tooltipOptions == null || content === '' ? null : /*#__PURE__*/_jsx(Tooltip, {
57
+ options: tooltipOptions,
58
+ children: typeof content === 'boolean' ? String(content) : content
59
+ })]
60
+ }, key)
61
+ );
62
+ }, [tooltipOptions]);
35
63
  return /*#__PURE__*/_jsx(SpectrumPicker
36
64
  // eslint-disable-next-line react/jsx-props-no-spreading
37
65
  , _objectSpread(_objectSpread({}, spectrumPickerProps), {}, {
66
+ UNSAFE_className: cl('dh-picker', UNSAFE_className),
38
67
  items: normalizedItems
39
68
  // Type assertions are necessary for `selectedKey`, `defaultSelectedKey`,
40
69
  // and `onSelectionChange` due to Spectrum types not accounting for
@@ -45,20 +74,15 @@ export function Picker(_ref) {
45
74
  // `onChange` is just an alias for `onSelectionChange`
46
75
  ,
47
76
  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
- });
77
+ children: itemOrSection => {
78
+ if (isNormalizedPickerSection(itemOrSection)) {
79
+ return /*#__PURE__*/_jsx(Section, {
80
+ title: itemOrSection.title,
81
+ items: itemOrSection.items,
82
+ children: renderItem
83
+ }, itemOrSection.key);
84
+ }
85
+ return renderItem(itemOrSection);
62
86
  }
63
87
  }));
64
88
  }
@@ -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","Picker","SpectrumPicker","cl","Tooltip","normalizePickerItemList","normalizeTooltipOptions","isNormalizedPickerSection","PickerItemContent","Item","Section","jsx","_jsx","jsxs","_jsxs","_ref","children","tooltip","defaultSelectedKey","selectedKey","onChange","onSelectionChange","UNSAFE_className","spectrumPickerProps","_objectWithoutProperties","_excluded","normalizedItems","tooltipOptions","renderItem","_ref2","key","content","textValue","options","String","_objectSpread","items","itemOrSection","title"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport { Picker as SpectrumPicker } from '@adobe/react-spectrum';\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 * 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 key={key as Key} textValue={textValue === '' ? 'Empty' : textValue}>\n <PickerItemContent>{content}</PickerItemContent>\n {tooltipOptions == null || content === '' ? null : (\n <Tooltip options={tooltipOptions}>\n {typeof content === 'boolean' ? String(content) : 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,SAAcA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACjD,SAASC,MAAM,IAAIC,cAAc,QAAQ,uBAAuB;AAChE,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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ACpDc,KAAK,EAAEV;IACP;IACA;IACA;IAAA;IACAP,WAAW,EAAEA,WAA4D;IACzED,kBAAkB,EAChBA;IAEF;IAAA;IACAG,iBAAiB,EACdD,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GACPC,iBACH;IAAAL,QAAA,EAEAqB,aAAa,IAAI;MAChB,IAAI9B,yBAAyB,CAAC8B,aAAa,CAAC,EAAE;QAC5C,oBACEzB,IAAA,CAACF,OAAO;UAEN4B,KAAK,EAAED,aAAa,CAACC,KAAM;UAC3BF,KAAK,EAAEC,aAAa,CAACD,KAAM;UAAApB,QAAA,EAE1BY;QAAU,GAJNS,aAAa,CAACP,GAKZ,CAAC;MAEd;MAEA,OAAOF,UAAU,CAACS,aAAa,CAAC;IAClC;EAAC,EACa,CAAC;AAErB;AAEA,eAAepC,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"PickerItemContent.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerItemContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlD,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,CActC;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"PickerItemContent.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerItemContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlD,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,CAoBtC;AAED,eAAe,iBAAiB,CAAC"}
@@ -21,6 +21,11 @@ export function PickerItemContent(_ref) {
21
21
  children: "\xA0"
22
22
  });
23
23
  }
24
+ if (typeof content === 'boolean') {
25
+ // Boolean values need to be stringified to render
26
+ // eslint-disable-next-line no-param-reassign
27
+ content = String(content);
28
+ }
24
29
  return /*#__PURE__*/_jsx(Text, {
25
30
  UNSAFE_className: stylesCommon.spectrumEllipsis,
26
31
  children: content
@@ -1 +1 @@
1
- {"version":3,"file":"PickerItemContent.js","names":["isValidElement","Text","stylesCommon","Fragment","_Fragment","jsx","_jsx","PickerItemContent","_ref","children","content","UNSAFE_className","spectrumEllipsis"],"sources":["../../../src/spectrum/picker/PickerItemContent.tsx"],"sourcesContent":["import { isValidElement, ReactNode } from 'react';\nimport { Text } from '@adobe/react-spectrum';\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 {\n if (isValidElement(content)) {\n return content;\n }\n\n if (content === '') {\n // Prevent the item height from collapsing when the content is empty\n // eslint-disable-next-line no-param-reassign\n content = <>&nbsp;</>;\n }\n\n return (\n <Text UNSAFE_className={stylesCommon.spectrumEllipsis}>{content}</Text>\n );\n}\n\nexport default PickerItemContent;\n"],"mappings":"AAAA,SAASA,cAAc,QAAmB,OAAO;AACjD,SAASC,IAAI,QAAQ,uBAAuB;AAAC,OACtCC,YAAY;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAMnB;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAAC,IAAA,EAEO;EAAA,IAFN;IAChCC,QAAQ,EAAEC;EACY,CAAC,GAAAF,IAAA;EACvB,kBAAIR,cAAc,CAACU,OAAO,CAAC,EAAE;IAC3B,OAAOA,OAAO;EAChB;EAEA,IAAIA,OAAO,KAAK,EAAE,EAAE;IAClB;IACA;IACAA,OAAO,gBAAGJ,IAAA,CAAAF,SAAA;MAAAK,QAAA,EAAE;IAAM,CAAE,CAAC;EACvB;EAEA,oBACEH,IAAA,CAACL,IAAI;IAACU,gBAAgB,EAAET,YAAY,CAACU,gBAAiB;IAAAH,QAAA,EAAEC;EAAO,CAAO,CAAC;AAE3E;AAEA,eAAeH,iBAAiB"}
1
+ {"version":3,"file":"PickerItemContent.js","names":["isValidElement","Text","stylesCommon","Fragment","_Fragment","jsx","_jsx","PickerItemContent","_ref","children","content","String","UNSAFE_className","spectrumEllipsis"],"sources":["../../../src/spectrum/picker/PickerItemContent.tsx"],"sourcesContent":["import { isValidElement, ReactNode } from 'react';\nimport { Text } from '@adobe/react-spectrum';\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 {\n if (isValidElement(content)) {\n return content;\n }\n\n if (content === '') {\n // Prevent the item height from collapsing when the content is empty\n // eslint-disable-next-line no-param-reassign\n content = <>&nbsp;</>;\n }\n\n if (typeof content === 'boolean') {\n // Boolean values need to be stringified to render\n // eslint-disable-next-line no-param-reassign\n content = String(content);\n }\n\n return (\n <Text UNSAFE_className={stylesCommon.spectrumEllipsis}>{content}</Text>\n );\n}\n\nexport default PickerItemContent;\n"],"mappings":"AAAA,SAASA,cAAc,QAAmB,OAAO;AACjD,SAASC,IAAI,QAAQ,uBAAuB;AAAC,OACtCC,YAAY;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAMnB;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAAC,IAAA,EAEO;EAAA,IAFN;IAChCC,QAAQ,EAAEC;EACY,CAAC,GAAAF,IAAA;EACvB,kBAAIR,cAAc,CAACU,OAAO,CAAC,EAAE;IAC3B,OAAOA,OAAO;EAChB;EAEA,IAAIA,OAAO,KAAK,EAAE,EAAE;IAClB;IACA;IACAA,OAAO,gBAAGJ,IAAA,CAAAF,SAAA;MAAAK,QAAA,EAAE;IAAM,CAAE,CAAC;EACvB;EAEA,IAAI,OAAOC,OAAO,KAAK,SAAS,EAAE;IAChC;IACA;IACAA,OAAO,GAAGC,MAAM,CAACD,OAAO,CAAC;EAC3B;EAEA,oBACEJ,IAAA,CAACL,IAAI;IAACW,gBAAgB,EAAEV,YAAY,CAACW,gBAAiB;IAAAJ,QAAA,EAAEC;EAAO,CAAO,CAAC;AAE3E;AAEA,eAAeH,iBAAiB"}
@@ -1,9 +1,23 @@
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 { ItemRenderer } from '@react-types/shared';
4
+ import { ItemProps } from '../Item';
5
+ import { SectionProps } from '../Section';
4
6
  import { PopperOptions } from '../../popper';
5
- export type ItemElement = ReactElement<ItemProps<unknown>>;
7
+ export declare const INVALID_PICKER_ITEM_ERROR_MESSAGE = "Picker items must be strings, numbers, booleans, <Item> or <Section> elements:";
8
+ /**
9
+ * React Spectrum <Section> supports an `ItemRenderer` function as a child. The
10
+ * DH picker makes use of this internally, but we don't want to support it as
11
+ * an incoming prop.
12
+ */
13
+ type SectionPropsNoItemRenderer<T> = Omit<SectionProps<T>, 'children'> & {
14
+ children: Exclude<SectionProps<T>['children'], ItemRenderer<T>>;
15
+ };
16
+ type ItemElement = ReactElement<ItemProps<unknown>>;
17
+ type SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;
6
18
  export type PickerItem = number | string | boolean | ItemElement;
19
+ export type PickerSection = SectionElement;
20
+ export type PickerItemOrSection = PickerItem | PickerSection;
7
21
  /**
8
22
  * Augment the Spectrum selection key type to include boolean values.
9
23
  * The Spectrum Picker already supports this, but the built in types don't
@@ -27,20 +41,51 @@ export interface NormalizedPickerItem {
27
41
  content: ReactNode;
28
42
  textValue: string;
29
43
  }
44
+ export interface NormalizedPickerSection {
45
+ key: Key;
46
+ title?: ReactNode;
47
+ items: NormalizedPickerItem[];
48
+ }
30
49
  export type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedPickerItem>;
31
50
  export type TooltipOptions = {
32
51
  placement: PopperOptions['placement'];
33
52
  };
53
+ /**
54
+ * Determine if a node is a Section element.
55
+ * @param node The node to check
56
+ * @returns True if the node is a Section element
57
+ */
58
+ export declare function isSectionElement<T>(node: ReactNode): node is ReactElement<SectionProps<T>>;
59
+ /**
60
+ * Determine if a node is an Item element.
61
+ * @param node The node to check
62
+ * @returns True if the node is an Item element
63
+ */
64
+ export declare function isItemElement<T>(node: ReactNode): node is ReactElement<ItemProps<T>>;
65
+ /**
66
+ * Determine if a node is a Picker item or section. Valid types include strings,
67
+ * numbers, booleans, Item elements, and Section elements.
68
+ * @param node The node to check
69
+ * @returns True if the node is a Picker item or section
70
+ */
71
+ export declare function isPickerItemOrSection(node: ReactNode): node is PickerItemOrSection;
72
+ /**
73
+ * Determine if an object is a normalized Picker section.
74
+ * @param maybeNormalizedPickerSection The object to check
75
+ * @returns True if the object is a normalized Picker section
76
+ */
77
+ export declare function isNormalizedPickerSection(maybeNormalizedPickerSection: NormalizedPickerItem | NormalizedPickerSection): maybeNormalizedPickerSection is NormalizedPickerSection;
34
78
  /**
35
79
  * Get normalized picker items from a picker item or array of picker items.
36
- * @param items A picker item or array of picker items
80
+ * @param itemsOrSections A picker item or array of picker items
37
81
  * @returns An array of normalized picker items
38
82
  */
39
- export declare function normalizePickerItemList(items: PickerItem | PickerItem[]): NormalizedPickerItem[];
83
+ export declare function normalizePickerItemList(itemsOrSections: PickerItemOrSection | PickerItemOrSection[]): (NormalizedPickerItem | NormalizedPickerSection)[];
40
84
  /**
41
85
  * Returns a TooltipOptions object or null if options is false or null.
42
86
  * @param options
43
87
  * @returns TooltipOptions or null
44
88
  */
45
89
  export declare function normalizeTooltipOptions(options?: boolean | TooltipOptions | null): PopperOptions | null;
90
+ export {};
46
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,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,GAAG,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3D,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,GAAG,OAAO,CAAC;AAE1C;;;;GAIG;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;AAExE;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,aAAa,CAAC;IACnB,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;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;AA+DvE;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,GAC/B,oBAAoB,EAAE,CAGxB;AAED;;;;GAIG;AACH,w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AI,CAUtB"}
@@ -1,3 +1,16 @@
1
+ import { isValidElement } from 'react';
2
+ import Log from '@deephaven/log';
3
+ import { Item } from "../Item.js";
4
+ import { Section } from "../Section.js";
5
+ var log = Log.module('PickerUtils');
6
+ export var INVALID_PICKER_ITEM_ERROR_MESSAGE = 'Picker items must be strings, numbers, booleans, <Item> or <Section> elements:';
7
+
8
+ /**
9
+ * React Spectrum <Section> supports an `ItemRenderer` function as a child. The
10
+ * DH picker makes use of this internally, but we don't want to support it as
11
+ * an incoming prop.
12
+ */
13
+
1
14
  /**
2
15
  * Augment the Spectrum selection key type to include boolean values.
3
16
  * The Spectrum Picker already supports this, but the built in types don't
@@ -18,25 +31,67 @@
18
31
  */
19
32
 
20
33
  /**
21
- * Determine the `key` of a picker item.
22
- * @param item The picker item
34
+ * Determine if a node is a Section element.
35
+ * @param node The node to check
36
+ * @returns True if the node is a Section element
37
+ */
38
+ export function isSectionElement(node) {
39
+ return /*#__PURE__*/isValidElement(node) && node.type === Section;
40
+ }
41
+
42
+ /**
43
+ * Determine if a node is an Item element.
44
+ * @param node The node to check
45
+ * @returns True if the node is an Item element
46
+ */
47
+ export function isItemElement(node) {
48
+ return /*#__PURE__*/isValidElement(node) && node.type === Item;
49
+ }
50
+
51
+ /**
52
+ * Determine if a node is a Picker item or section. Valid types include strings,
53
+ * numbers, booleans, Item elements, and Section elements.
54
+ * @param node The node to check
55
+ * @returns True if the node is a Picker item or section
56
+ */
57
+ export function isPickerItemOrSection(node) {
58
+ return typeof node === 'string' || typeof node === 'number' || typeof node === 'boolean' || isItemElement(node) || isSectionElement(node);
59
+ }
60
+
61
+ /**
62
+ * Determine if an object is a normalized Picker section.
63
+ * @param maybeNormalizedPickerSection The object to check
64
+ * @returns True if the object is a normalized Picker section
65
+ */
66
+ export function isNormalizedPickerSection(maybeNormalizedPickerSection) {
67
+ return 'items' in maybeNormalizedPickerSection;
68
+ }
69
+
70
+ /**
71
+ * Determine the `key` of a picker item or section.
72
+ * @param itemOrSection The picker item or section
23
73
  * @returns A `PickerItemKey` for the picker item
24
74
  */
25
- function normalizeItemKey(item) {
26
- var _item$props$textValue;
75
+
76
+ function normalizeItemKey(itemOrSection) {
77
+ var _itemOrSection$props$;
27
78
  // string, number, or boolean
28
- if (typeof item !== 'object') {
29
- return item;
79
+ if (typeof itemOrSection !== 'object') {
80
+ return itemOrSection;
30
81
  }
31
82
 
32
- // `ItemElement` with `key` prop set
33
- if (item.key != null) {
34
- return item.key;
83
+ // If `key` prop is explicitly set
84
+ if (itemOrSection.key != null) {
85
+ return itemOrSection.key;
35
86
  }
36
- if (typeof item.props.children === 'string') {
37
- return item.props.children;
87
+
88
+ // Section element
89
+ if (isSectionElement(itemOrSection)) {
90
+ return typeof itemOrSection.props.title === 'string' ? itemOrSection.props.title : '';
38
91
  }
39
- return (_item$props$textValue = item.props.textValue) !== null && _item$props$textValue !== void 0 ? _item$props$textValue : '';
92
+
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 : '';
40
95
  }
41
96
 
42
97
  /**
@@ -59,13 +114,31 @@ function normalizeTextValue(item) {
59
114
 
60
115
  /**
61
116
  * Normalize a picker item to an object form.
62
- * @param item item to normalize
117
+ * @param itemOrSection item to normalize
63
118
  * @returns NormalizedPickerItem object
64
119
  */
65
- function normalizePickerItem(item) {
66
- var key = normalizeItemKey(item);
67
- var content = typeof item === 'object' ? item.props.children : String(item);
68
- var textValue = normalizeTextValue(item);
120
+ function normalizePickerItem(itemOrSection) {
121
+ if (!isPickerItemOrSection(itemOrSection)) {
122
+ log.debug(INVALID_PICKER_ITEM_ERROR_MESSAGE, itemOrSection);
123
+ throw new Error(INVALID_PICKER_ITEM_ERROR_MESSAGE);
124
+ }
125
+ if (isSectionElement(itemOrSection)) {
126
+ var _key = normalizeItemKey(itemOrSection);
127
+ var {
128
+ title
129
+ } = itemOrSection.props;
130
+ var items = normalizePickerItemList(itemOrSection.props.children).filter(
131
+ // We don't support nested section elements
132
+ childItem => !isSectionElement(childItem));
133
+ return {
134
+ key: _key,
135
+ title,
136
+ items
137
+ };
138
+ }
139
+ var key = normalizeItemKey(itemOrSection);
140
+ var content = isItemElement(itemOrSection) ? itemOrSection.props.children : itemOrSection;
141
+ var textValue = normalizeTextValue(itemOrSection);
69
142
  return {
70
143
  key,
71
144
  content,
@@ -75,11 +148,11 @@ function normalizePickerItem(item) {
75
148
 
76
149
  /**
77
150
  * Get normalized picker items from a picker item or array of picker items.
78
- * @param items A picker item or array of picker items
151
+ * @param itemsOrSections A picker item or array of picker items
79
152
  * @returns An array of normalized picker items
80
153
  */
81
- export function normalizePickerItemList(items) {
82
- var itemsArray = Array.isArray(items) ? items : [items];
154
+ export function normalizePickerItemList(itemsOrSections) {
155
+ var itemsArray = Array.isArray(itemsOrSections) ? itemsOrSections : [itemsOrSections];
83
156
  return itemsArray.map(normalizePickerItem);
84
157
  }
85
158
 
@@ -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;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgBA,CAACC,IAAgB,EAAiB;EAAA,IAAAC,qBAAA;EACzD;EACA,IAAI,OAAOD,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOA,IAAI;EACb;;EAEA;EACA,IAAIA,IAAI,CAACE,GAAG,IAAI,IAAI,EAAE;IACpB,OAAOF,IAAI,CAACE,GAAG;EACjB;EAEA,IAAI,OAAOF,IAAI,CAACG,KAAK,CAACC,QAAQ,KAAK,QAAQ,EAAE;IAC3C,OAAOJ,IAAI,CAACG,KAAK,CAACC,QAAQ;EAC5B;EAEA,QAAAH,qBAAA,GAAOD,IAAI,CAACG,KAAK,CAACE,SAAS,cAAAJ,qBAAA,cAAAA,qBAAA,GAAI,EAAE;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASK,kBAAkBA,CAACN,IAAgB,EAAU;EACpD,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOO,MAAM,CAACP,IAAI,CAAC;EACrB;EAEA,IAAIA,IAAI,CAACG,KAAK,CAACE,SAAS,IAAI,IAAI,EAAE;IAChC,OAAOL,IAAI,CAACG,KAAK,CAACE,SAAS;EAC7B;EAEA,IAAI,OAAOL,IAAI,CAACG,KAAK,CAACC,QAAQ,KAAK,QAAQ,EAAE;IAC3C,OAAOJ,IAAI,CAACG,KAAK,CAACC,QAAQ;EAC5B;EAEA,OAAO,EAAE;AACX;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASI,mBAAmBA,CAACR,IAAgB,EAAwB;EACnE,IAAME,GAAG,GAAGH,gBAAgB,CAACC,IAAI,CAAC;EAClC,IAAMS,OAAO,GAAG,OAAOT,IAAI,KAAK,QAAQ,GAAGA,IAAI,CAACG,KAAK,CAACC,QAAQ,GAAGG,MAAM,CAACP,IAAI,CAAC;EAC7E,IAAMK,SAAS,GAAGC,kBAAkB,CAACN,IAAI,CAAC;EAE1C,OAAO;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","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,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AAS,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/components",
3
- "version": "0.66.1",
3
+ "version": "0.66.2-alpha-ui-picker.18+d04b0cfd",
4
4
  "description": "Deephaven React component library",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "Apache-2.0",
@@ -25,13 +25,14 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@adobe/react-spectrum": "^3.34.1",
28
- "@deephaven/icons": "^0.66.0",
29
- "@deephaven/log": "^0.66.0",
30
- "@deephaven/react-hooks": "^0.66.0",
31
- "@deephaven/utils": "^0.66.0",
28
+ "@deephaven/icons": "^0.66.2-alpha-ui-picker.18+d04b0cfd",
29
+ "@deephaven/log": "^0.66.2-alpha-ui-picker.18+d04b0cfd",
30
+ "@deephaven/react-hooks": "^0.66.2-alpha-ui-picker.18+d04b0cfd",
31
+ "@deephaven/utils": "^0.66.2-alpha-ui-picker.18+d04b0cfd",
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",
35
+ "@react-types/shared": "^3.22.1",
35
36
  "bootstrap": "4.6.2",
36
37
  "classnames": "^2.3.1",
37
38
  "event-target-shim": "^6.0.2",
@@ -52,7 +53,7 @@
52
53
  "react-dom": "^17.x"
53
54
  },
54
55
  "devDependencies": {
55
- "@deephaven/mocks": "^0.66.0"
56
+ "@deephaven/mocks": "^0.66.2-alpha-ui-picker.18+d04b0cfd"
56
57
  },
57
58
  "files": [
58
59
  "dist",
@@ -66,5 +67,5 @@
66
67
  "publishConfig": {
67
68
  "access": "public"
68
69
  },
69
- "gitHead": "d91d833e22658a26c0dbcdb2b9d835e1ad25c57d"
70
+ "gitHead": "d04b0cfdcdb9de17afc8d7ad0c07c34e8ded20b9"
70
71
  }