@deephaven/components 0.74.0 → 0.74.1-alpha-listview-actions.30

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.
Files changed (87) hide show
  1. package/dist/Button.d.ts +1 -1
  2. package/dist/Select.d.ts +1 -1
  3. package/dist/spectrum/ActionGroup.d.ts +14 -0
  4. package/dist/spectrum/ActionGroup.d.ts.map +1 -0
  5. package/dist/spectrum/ActionGroup.js +42 -0
  6. package/dist/spectrum/ActionGroup.js.map +1 -0
  7. package/dist/spectrum/ItemContent.d.ts.map +1 -1
  8. package/dist/spectrum/ItemContent.js +2 -1
  9. package/dist/spectrum/ItemContent.js.map +1 -1
  10. package/dist/spectrum/ListActionGroup.d.ts +19 -0
  11. package/dist/spectrum/ListActionGroup.d.ts.map +1 -0
  12. package/dist/spectrum/ListActionGroup.js +9 -0
  13. package/dist/spectrum/ListActionGroup.js.map +1 -0
  14. package/dist/spectrum/buttons.d.ts +1 -1
  15. package/dist/spectrum/buttons.d.ts.map +1 -1
  16. package/dist/spectrum/buttons.js +1 -1
  17. package/dist/spectrum/buttons.js.map +1 -1
  18. package/dist/spectrum/index.d.ts +2 -0
  19. package/dist/spectrum/index.d.ts.map +1 -1
  20. package/dist/spectrum/index.js +2 -0
  21. package/dist/spectrum/index.js.map +1 -1
  22. package/dist/spectrum/listView/ListView.d.ts +4 -18
  23. package/dist/spectrum/listView/ListView.d.ts.map +1 -1
  24. package/dist/spectrum/listView/ListView.js +10 -63
  25. package/dist/spectrum/listView/ListView.js.map +1 -1
  26. package/dist/spectrum/listView/ListViewNormalized.d.ts +11 -0
  27. package/dist/spectrum/listView/ListViewNormalized.d.ts.map +1 -0
  28. package/dist/spectrum/listView/ListViewNormalized.js +70 -0
  29. package/dist/spectrum/listView/ListViewNormalized.js.map +1 -0
  30. package/dist/spectrum/listView/ListViewWrapper.css +39 -0
  31. package/dist/spectrum/listView/ListViewWrapper.css.map +1 -0
  32. package/dist/spectrum/listView/ListViewWrapper.d.ts +10 -0
  33. package/dist/spectrum/listView/ListViewWrapper.d.ts.map +1 -0
  34. package/dist/spectrum/listView/ListViewWrapper.js +45 -0
  35. package/dist/spectrum/listView/ListViewWrapper.js.map +1 -0
  36. package/dist/spectrum/listView/index.d.ts +2 -0
  37. package/dist/spectrum/listView/index.d.ts.map +1 -1
  38. package/dist/spectrum/listView/index.js +2 -0
  39. package/dist/spectrum/listView/index.js.map +1 -1
  40. package/dist/spectrum/picker/Picker.d.ts +6 -8
  41. package/dist/spectrum/picker/Picker.d.ts.map +1 -1
  42. package/dist/spectrum/picker/Picker.js +54 -59
  43. package/dist/spectrum/picker/Picker.js.map +1 -1
  44. package/dist/spectrum/picker/PickerNormalized.d.ts +17 -0
  45. package/dist/spectrum/picker/PickerNormalized.d.ts.map +1 -0
  46. package/dist/spectrum/picker/PickerNormalized.js +104 -0
  47. package/dist/spectrum/picker/PickerNormalized.js.map +1 -0
  48. package/dist/spectrum/picker/index.d.ts +2 -0
  49. package/dist/spectrum/picker/index.d.ts.map +1 -1
  50. package/dist/spectrum/picker/index.js +2 -0
  51. package/dist/spectrum/picker/index.js.map +1 -1
  52. package/dist/spectrum/picker/usePickerScrollOnOpen.d.ts +22 -0
  53. package/dist/spectrum/picker/usePickerScrollOnOpen.d.ts.map +1 -0
  54. package/dist/spectrum/picker/usePickerScrollOnOpen.js +33 -0
  55. package/dist/spectrum/picker/usePickerScrollOnOpen.js.map +1 -0
  56. package/dist/spectrum/shared.d.ts +15 -9
  57. package/dist/spectrum/shared.d.ts.map +1 -1
  58. package/dist/spectrum/shared.js +16 -1
  59. package/dist/spectrum/shared.js.map +1 -1
  60. package/dist/spectrum/utils/index.d.ts +3 -0
  61. package/dist/spectrum/utils/index.d.ts.map +1 -1
  62. package/dist/spectrum/utils/index.js +3 -0
  63. package/dist/spectrum/utils/index.js.map +1 -1
  64. package/dist/spectrum/utils/itemUtils.d.ts +57 -19
  65. package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
  66. package/dist/spectrum/utils/itemUtils.js +72 -106
  67. package/dist/spectrum/utils/itemUtils.js.map +1 -1
  68. package/dist/spectrum/utils/itemWrapperUtils.d.ts +28 -0
  69. package/dist/spectrum/utils/itemWrapperUtils.d.ts.map +1 -0
  70. package/dist/spectrum/utils/itemWrapperUtils.js +111 -0
  71. package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -0
  72. package/dist/spectrum/utils/propsUtils.d.ts +14 -0
  73. package/dist/spectrum/utils/propsUtils.d.ts.map +1 -0
  74. package/dist/spectrum/utils/propsUtils.js +93 -0
  75. package/dist/spectrum/utils/propsUtils.js.map +1 -0
  76. package/dist/spectrum/utils/useRenderNormalizedItem.d.ts +16 -3
  77. package/dist/spectrum/utils/useRenderNormalizedItem.d.ts.map +1 -1
  78. package/dist/spectrum/utils/useRenderNormalizedItem.js +42 -13
  79. package/dist/spectrum/utils/useRenderNormalizedItem.js.map +1 -1
  80. package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts.map +1 -1
  81. package/dist/spectrum/utils/useStringifiedMultiSelection.js +5 -2
  82. package/dist/spectrum/utils/useStringifiedMultiSelection.js.map +1 -1
  83. package/dist/spectrum/utils/useStringifiedSelection.d.ts +33 -0
  84. package/dist/spectrum/utils/useStringifiedSelection.d.ts.map +1 -0
  85. package/dist/spectrum/utils/useStringifiedSelection.js +50 -0
  86. package/dist/spectrum/utils/useStringifiedSelection.js.map +1 -0
  87. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"itemUtils.js","names":["isValidElement","Log","Item","Section","log","module","INVALID_ITEM_ERROR_MESSAGE","getItemKey","item","_item$item$key","_item$item","key","isSectionElement","node","type","isItemElement","isNormalizedItemsWithKeysList","Array","isArray","length","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeItemKey","itemOrSection","_itemOrSection$props$","props","title","undefined","textValue","children","normalizeTextValue","String","normalizeItem","debug","Error","items","normalizeItemList","filter","childItem","content","itemsOrSections","itemsArray","map","normalizeTooltipOptions","options","placement","arguments","itemSelectionToStringSet","itemKeys","Set"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { isValidElement, Key, ReactElement, ReactNode } from 'react';\nimport { SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type { ItemRenderer } from '@react-types/shared';\nimport Log from '@deephaven/log';\nimport { KeyedItem, SelectionT } from '@deephaven/utils';\nimport { Item, ItemProps, Section, SectionProps } from '../shared';\nimport { PopperOptions } from '../../popper';\n\nconst log = Log.module('itemUtils');\n\nexport const INVALID_ITEM_ERROR_MESSAGE =\n 'Items must be strings, numbers, booleans, <Item> or <Section> elements:';\n\n/**\n * React Spectrum <Section> supports an `ItemRenderer` function as a child. The\n * DH picker makes use of this internally, but we don't want to support it as\n * an incoming prop.\n */\ntype SectionPropsNoItemRenderer<T> = Omit<SectionProps<T>, 'children'> & {\n children: Exclude<SectionProps<T>['children'], ItemRenderer<T>>;\n};\n\ntype ItemElement = ReactElement<ItemProps<unknown>>;\nexport type SectionElement = ReactElement<SectionPropsNoItemRenderer<unknown>>;\n\nexport type ItemElementOrPrimitive = number | string | boolean | ItemElement;\nexport type ItemOrSection = ItemElementOrPrimitive | SectionElement;\n\n/**\n * Augment the Spectrum selection key type to include boolean values.\n * Spectrum collection components already supports this, but the built in types\n * don't reflect it.\n */\nexport type ItemKey = Key | boolean;\n\nexport type ItemSelection = SelectionT<ItemKey>;\n\n/**\n * Augment the Spectrum selection change handler type to include boolean keys.\n * Spectrum components already supports this, but the built in types don't\n * reflect it.\n */\nexport type ItemSelectionChangeHandler = (key: ItemKey) => void;\n\nexport interface NormalizedItemData {\n key?: ItemKey;\n content: ReactNode;\n textValue?: string;\n}\n\nexport interface NormalizedSectionData {\n key?: Key;\n title?: ReactNode;\n items: NormalizedItem[];\n}\n\n/**\n * Spectrum collection components support a variety of item types, including\n * strings, numbers, booleans, and more complex React elements. This type\n * represents a normalized form to make rendering items simpler and keep the\n * logic of transformation in separate util methods. It also adheres to the\n * `KeyedItem` interface to be compatible with Windowed data utils\n * (e.g. `useViewportData`).\n */\nexport type NormalizedItem = KeyedItem<NormalizedItemData, ItemKey | undefined>;\n\nexport type NormalizedSection = KeyedItem<\n NormalizedSectionData,\n Key | undefined\n>;\n\nexport type NormalizedItemOrSection<TItemOrSection extends ItemOrSection> =\n TItemOrSection extends SectionElement ? NormalizedSection : NormalizedItem;\n\nexport type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedItem>;\n\nexport type TooltipOptions = { placement: PopperOptions['placement'] };\n\n/**\n * DH wrappers of Spectrum collection components use a normalized item that\n * includes a `key` prop and an optional `item` prop. This is mostly to support\n * Windowed data where items are created before their data has been loaded (data\n * gets set in the `item` prop). If data has loaded, return its `key`. If not,\n * return the top-level `key` on the normalized item.\n * @param item The normalized item or section\n * @returns The `key` of the item or section\n */\nexport function getItemKey<\n TItem extends NormalizedItem | NormalizedSection,\n TKey extends TItem extends NormalizedItem\n ? ItemKey | undefined\n : TItem extends NormalizedSection\n ? Key | undefined\n : undefined,\n>(item: TItem | null | undefined): TKey {\n return (item?.item?.key ?? item?.key) as TKey;\n}\n\n/**\n * Determine if a node is a Section element.\n * @param node The node to check\n * @returns True if the node is a Section element\n */\nexport function isSectionElement<T>(\n node: ReactNode\n): node is ReactElement<SectionProps<T>> {\n return isValidElement<SectionProps<T>>(node) && node.type === Section;\n}\n\n/**\n * Determine if a node is an Item element.\n * @param node The node to check\n * @returns True if the node is an Item element\n */\nexport function isItemElement<T>(\n node: ReactNode\n): node is ReactElement<ItemProps<T>> {\n return isValidElement<ItemProps<T>>(node) && node.type === Item;\n}\n\n/**\n * Determine if a node is an array containing normalized items or sections with\n * keys. Note that this only checks the first node in the array.\n * @param node The node to check\n * @returns True if the node is a normalized item or section with keys array\n */\nexport function isNormalizedItemsWithKeysList<\n TItemOrSection extends ItemOrSection,\n>(\n node:\n | TItemOrSection\n | TItemOrSection[]\n | NormalizedItemOrSection<TItemOrSection>[]\n): node is NormalizedItemOrSection<TItemOrSection>[] {\n if (!Array.isArray(node)) {\n return false;\n }\n\n if (node.length === 0) {\n return true;\n }\n\n return !isItemOrSection(node[0]) && 'key' in node[0];\n}\n\n/**\n * Determine if an object is a normalized section.\n * @param maybeNormalizedSection The object to check\n * @returns True if the object is a normalized section\n */\nexport function isNormalizedSection(\n maybeNormalizedSection: NormalizedItem | NormalizedSection\n): maybeNormalizedSection is NormalizedSection {\n return (\n maybeNormalizedSection.item != null &&\n 'items' in maybeNormalizedSection.item\n );\n}\n\n/**\n * Determine if a node is an item or section. Valid types include strings,\n * numbers, booleans, Item elements, and Section elements.\n * @param node The node to check\n * @returns True if the node is an item or section\n */\nexport function isItemOrSection(node: ReactNode): node is ItemOrSection {\n return (\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n isItemElement(node) ||\n isSectionElement(node)\n );\n}\n\n/**\n * Determine the `key` of an item or section.\n * @param itemOrSection The item or section\n * @returns A `ItemKey` for the item or undefined if a key can't be determined\n */\nfunction normalizeItemKey(item: ItemElementOrPrimitive): ItemKey | undefined;\nfunction normalizeItemKey(section: SectionElement): Key | undefined;\nfunction normalizeItemKey(\n itemOrSection: ItemElementOrPrimitive | SectionElement\n): Key | ItemKey | undefined {\n // string, number, or boolean\n if (typeof itemOrSection !== 'object') {\n return itemOrSection;\n }\n\n // If `key` prop is explicitly set\n if (itemOrSection.key != null) {\n return itemOrSection.key;\n }\n\n // Section element\n if (isSectionElement(itemOrSection)) {\n return typeof itemOrSection.props.title === 'string'\n ? itemOrSection.props.title\n : undefined;\n }\n\n // Item element\n return (\n itemOrSection.props.textValue ??\n (typeof itemOrSection.props.children === 'string'\n ? itemOrSection.props.children\n : undefined)\n );\n}\n\n/**\n * Get a normalized `textValue` for an item ensuring it is a string.\n * @param item The item\n * @returns A string `textValue` for the item\n */\nfunction normalizeTextValue(item: ItemElementOrPrimitive): string | undefined {\n if (typeof item !== 'object') {\n return String(item);\n }\n\n if (item.props.textValue != null) {\n return item.props.textValue;\n }\n\n if (typeof item.props.children === 'string') {\n return item.props.children;\n }\n\n return undefined;\n}\n\n/**\n * Normalize an item or section to an object form.\n * @param itemOrSection item to normalize\n * @returns NormalizedItem or NormalizedSection object\n */\nfunction normalizeItem<TItemOrSection extends ItemOrSection>(\n itemOrSection: TItemOrSection\n): NormalizedItemOrSection<TItemOrSection> {\n if (!isItemOrSection(itemOrSection)) {\n log.debug(INVALID_ITEM_ERROR_MESSAGE, itemOrSection);\n throw new Error(INVALID_ITEM_ERROR_MESSAGE);\n }\n\n if (isSectionElement(itemOrSection)) {\n const key = normalizeItemKey(itemOrSection);\n const { title } = itemOrSection.props;\n\n const items = normalizeItemList(itemOrSection.props.children).filter(\n // We don't support nested section elements\n childItem => !isSectionElement(childItem)\n ) as NormalizedItem[];\n\n return {\n item: { key, title, items },\n } as NormalizedItemOrSection<TItemOrSection>;\n }\n\n const key = normalizeItemKey(itemOrSection);\n const content = isItemElement(itemOrSection)\n ? itemOrSection.props.children\n : itemOrSection;\n const textValue = normalizeTextValue(itemOrSection);\n\n return {\n item: { key, content, textValue },\n } as NormalizedItemOrSection<TItemOrSection>;\n}\n\n/**\n * Normalize an item or section or a list of items or sections.\n * @param itemsOrSections An item or section or array of items or sections\n * @returns An array of normalized items or sections\n */\nexport function normalizeItemList<TItemOrSection extends ItemOrSection>(\n itemsOrSections: TItemOrSection | TItemOrSection[] | NormalizedItem[]\n): NormalizedItemOrSection<TItemOrSection>[] {\n // If already normalized, just return as-is\n if (isNormalizedItemsWithKeysList(itemsOrSections)) {\n return itemsOrSections as NormalizedItemOrSection<TItemOrSection>[];\n }\n\n const itemsArray: TItemOrSection[] = Array.isArray(itemsOrSections)\n ? itemsOrSections\n : [itemsOrSections];\n\n return itemsArray.map(normalizeItem);\n}\n\n/**\n * Returns a TooltipOptions object or null if options is false or null.\n * @param options Tooltip options\n * @param placement Default placement for the tooltip if `options` is set\n * explicitly to `true`\n * @returns TooltipOptions or null\n */\nexport function normalizeTooltipOptions(\n options?: boolean | TooltipOptions | null,\n placement: TooltipOptions['placement'] = 'right'\n): TooltipOptions | null {\n if (options == null || options === false) {\n return null;\n }\n\n if (options === true) {\n return { placement };\n }\n\n return options;\n}\n\n/**\n * Convert a selection of `ItemKey`s to a selection of strings.\n * @param itemKeys The selection of `ItemKey`s\n * @returns The selection of strings\n */\nexport function itemSelectionToStringSet(\n itemKeys?: 'all' | Iterable<ItemKey>\n): undefined | 'all' | Set<string> {\n if (itemKeys == null || itemKeys === 'all') {\n return itemKeys as undefined | 'all';\n }\n\n return new Set([...itemKeys].map(String));\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAsC,OAAO;AAGpE,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SAExBC,IAAI,EAAaC,OAAO;AAGjC,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,WAAW,CAAC;AAEnC,OAAO,IAAMC,0BAA0B,GACrC,yEAAyE;;AAE3E;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAOxBC,IAA8B,EAAQ;EAAA,IAAAC,cAAA,EAAAC,UAAA;EACtC,QAAAD,cAAA,GAAQD,IAAI,aAAJA,IAAI,wBAAAE,UAAA,GAAJF,IAAI,CAAEA,IAAI,cAAAE,UAAA,uBAAVA,UAAA,CAAYC,GAAG,cAAAF,cAAA,cAAAA,cAAA,GAAID,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,GAAG;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,IAAe,EACwB;EACvC,OAAO,aAAAb,cAAc,CAAkBa,IAAI,CAAC,IAAIA,IAAI,CAACC,IAAI,KAAKX,OAAO;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,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AI,IAAI,IAAIA,QAAQ,KAAK,KAAK,EAAE;IAC1C,OAAOA,QAAQ;EACjB;EAEA,OAAO,IAAIC,GAAG,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAACN,GAAG,CAACX,MAAM,CAAC,CAAC;AAC3C"}
1
+ {"version":3,"file":"itemUtils.js","names":["isElementOfType","ensureArray","Item","Section","Text","ItemContent","ITEM_EMPTY_STRING_TEXT_VALUE","getItemKey","item","_item$item$key","_item$item","key","getPositionOfSelectedItemElement","_x","_getPositionOfSelectedItemElement","apply","arguments","_asyncToGenerator","_ref","items","itemHeight","selectedKey","topOffset","position","i","length","isSectionElement","node","isItemElement","isItemElementWithDescription","children","props","childrenArray","result","some","child","_child$props","slot","isNormalizedItemsWithKeysList","Array","isArray","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeTooltipOptions","options","placement","undefined","itemSelectionToStringSet","itemKeys","Set","map","String"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { Key, ReactElement, ReactNode } from 'react';\nimport { SpectrumPickerProps } from '@adobe/react-spectrum';\nimport type { ItemRenderer } from '@react-types/shared';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport { ensureArray, KeyedItem, SelectionT } from '@deephaven/utils';\nimport {\n Item,\n ItemElementOrPrimitive,\n ItemProps,\n Section,\n SectionProps,\n} from '../shared';\nimport { PopperOptions } from '../../popper';\nimport { Text } from '../Text';\nimport ItemContent from '../ItemContent';\n\n/**\n * `Item.textValue` prop needs to be a non-empty string for accessibility\n * purposes. This is not displayed in the UI.\n */\nexport const ITEM_EMPTY_STRING_TEXT_VALUE = 'Empty';\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\nexport type ItemElement<T = unknown> = ReactElement<ItemProps<T>>;\nexport type SectionElement<T = unknown> = ReactElement<\n SectionPropsNoItemRenderer<T>\n>;\n\nexport type ItemOrSection<T = unknown> =\n | ItemElementOrPrimitive<T>\n | SectionElement<T>;\n\n// Picker uses `icon` slot. ListView can use `image` or `illustration` slots.\n// https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/picker/src/Picker.tsx#L194\n// https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/list/src/ListViewItem.tsx#L266-L267\nexport type ItemIconSlot = 'icon' | 'image' | 'illustration';\n\n/**\n * Augment the Spectrum selection key type to include boolean values.\n * Spectrum collection components already supports this, but the built in types\n * don't reflect it.\n */\nexport type ItemKey = Key | boolean;\n\nexport type ItemSelection = SelectionT<ItemKey>;\n\n/**\n * Augment the Spectrum selection change handler type to include boolean keys.\n * Spectrum components already supports this, but the built in types don't\n * reflect it.\n */\nexport type ItemSelectionChangeHandler = (key: ItemKey) => void;\n\nexport interface MultipleItemSelectionProps {\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: ItemSelection) => void;\n\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead\n */\n onSelectionChange?: (keys: ItemSelection) => void;\n}\n\nexport interface NormalizedItemData {\n key?: ItemKey;\n content: ReactNode;\n description?: ReactNode;\n icon?: ReactNode;\n textValue: string | undefined;\n}\n\nexport interface NormalizedSectionData {\n key?: Key;\n title?: ReactNode;\n items: NormalizedItem[];\n}\n\n/**\n * Spectrum collection components support a variety of item types, including\n * strings, numbers, booleans, and more complex React elements. This type\n * represents a normalized form to make rendering items simpler and keep the\n * logic of transformation in separate util methods. It also adheres to the\n * `KeyedItem` interface to be compatible with Windowed data utils\n * (e.g. `useViewportData`).\n */\nexport type NormalizedItem = KeyedItem<NormalizedItemData, ItemKey>;\n\nexport type NormalizedSection = KeyedItem<NormalizedSectionData, Key>;\n\nexport type NormalizedItemOrSection<TItemOrSection extends ItemOrSection> =\n TItemOrSection extends SectionElement ? NormalizedSection : NormalizedItem;\n\nexport type NormalizedSpectrumPickerProps = SpectrumPickerProps<NormalizedItem>;\n\nexport type TooltipOptions = { placement: PopperOptions['placement'] };\n\n/**\n * DH wrappers of Spectrum collection components use a normalized item that\n * includes a `key` prop and an optional `item` prop. This is mostly to support\n * Windowed data where items are created before their data has been loaded (data\n * gets set in the `item` prop). If data has loaded, return its `key`. If not,\n * return the top-level `key` on the normalized item.\n * @param item The normalized item or section\n * @returns The `key` of the item or section\n */\nexport function getItemKey<\n TItem extends NormalizedItem | NormalizedSection,\n TKey extends TItem extends NormalizedItem\n ? ItemKey\n : TItem extends NormalizedSection\n ? Key\n : undefined,\n>(item: TItem | null | undefined): TKey {\n return (item?.item?.key ?? item?.key) as TKey;\n}\n\n/**\n * Get the position of the item with the given selected key in a list of items.\n * @param items The items to search\n * @param itemHeight The height of each item\n * @param selectedKey The key of the selected item\n * @param topOffset The top offset of the list\n * @returns The position of the selected item or the top offset if not found\n */\nexport async function getPositionOfSelectedItemElement<\n TKey extends string | number | boolean | undefined,\n>({\n items,\n itemHeight,\n selectedKey,\n topOffset,\n}: {\n items: ItemElement[];\n selectedKey: TKey | null | undefined;\n itemHeight: number;\n topOffset: number;\n}): Promise<number> {\n let position = topOffset;\n\n if (selectedKey == null) {\n return position;\n }\n\n for (let i = 0; i < items.length; i += 1) {\n const item = items[i];\n if (item.key === selectedKey) {\n return position;\n }\n\n position += itemHeight;\n }\n\n return topOffset;\n}\n\n/**\n * Determine if a node is a Section element.\n * @param node The node to check\n * @returns True if the node is a Section element\n */\nexport function isSectionElement<T>(\n node: ReactNode\n): node is SectionElement<T> {\n return isElementOfType(node, 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>(node: ReactNode): node is ItemElement<T> {\n return isElementOfType(node, Item);\n}\n\n/**\n * Determine if a node is an Item element containing a child `Text` element with\n * a `slot` prop set to `description`.\n * @param node The node to check\n * @returns True if the node is an Item element with a description\n */\nexport function isItemElementWithDescription<T>(\n node: ReactNode\n): node is ReactElement<ItemProps<T>> {\n if (!isItemElement(node)) {\n return false;\n }\n\n // If children are wrapped in `ItemContent`, go down 1 level\n const children = isElementOfType(node.props.children, ItemContent)\n ? node.props.children.props.children\n : node.props.children;\n\n const childrenArray = ensureArray(children);\n\n const result = childrenArray.some(\n child => isElementOfType(child, Text) && child.props?.slot === 'description'\n );\n\n return result;\n}\n\n/**\n * Determine if a node is an array containing normalized items or sections with\n * keys. Note that this only checks the first node in the array.\n * @param node The node to check\n * @returns True if the node is a normalized item or section with keys array\n */\nexport function isNormalizedItemsWithKeysList<\n TItemOrSection extends ItemOrSection,\n>(\n node:\n | TItemOrSection\n | TItemOrSection[]\n | NormalizedItemOrSection<TItemOrSection>[]\n): node is NormalizedItemOrSection<TItemOrSection>[] {\n if (!Array.isArray(node)) {\n return false;\n }\n\n if (node.length === 0) {\n return true;\n }\n\n return !isItemOrSection(node[0]) && 'key' in node[0];\n}\n\n/**\n * Determine if an object is a normalized section.\n * @param maybeNormalizedSection The object to check\n * @returns True if the object is a normalized section\n */\nexport function isNormalizedSection(\n maybeNormalizedSection: NormalizedItem | NormalizedSection\n): maybeNormalizedSection is NormalizedSection {\n return (\n maybeNormalizedSection.item != null &&\n 'items' in maybeNormalizedSection.item\n );\n}\n\n/**\n * Determine if a node is an item or section. Valid types include strings,\n * numbers, booleans, Item elements, and Section elements.\n * @param node The node to check\n * @returns True if the node is an item or section\n */\nexport function isItemOrSection(node: ReactNode): node is ItemOrSection {\n return (\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean' ||\n isItemElement(node) ||\n isSectionElement(node)\n );\n}\n\n/**\n * Returns a TooltipOptions object or null if options is false or null.\n * @param options Tooltip options\n * @param placement Default placement for the tooltip if `options` is set\n * explicitly to `true`\n * @returns TooltipOptions or null\n */\nexport function normalizeTooltipOptions(\n options?: boolean | TooltipOptions | null,\n placement: TooltipOptions['placement'] = 'right'\n): TooltipOptions | null {\n if (options == null || options === false) {\n return null;\n }\n\n if (options === true) {\n return { placement };\n }\n\n return options;\n}\n\n/**\n * Convert a selection of `ItemKey`s to a selection of strings.\n * @param itemKeys The selection of `ItemKey`s\n * @returns The selection of strings\n */\nexport function itemSelectionToStringSet<\n TKeys extends 'all' | Iterable<ItemKey> | undefined,\n TResult extends TKeys extends 'all'\n ? 'all'\n : TKeys extends Iterable<ItemKey>\n ? Set<string>\n : undefined,\n>(itemKeys: TKeys): TResult {\n if (itemKeys == null || itemKeys === 'all') {\n return itemKeys as undefined | 'all' as TResult;\n }\n\n return new Set([...itemKeys].map(String)) as TResult;\n}\n"],"mappings":";;AAGA,SAASA,eAAe,QAAQ,wBAAwB;AACxD,SAASC,WAAW,QAA+B,kBAAkB;AAAC,SAEpEC,IAAI,EAGJC,OAAO;AAAA,SAIAC,IAAI;AAAA,OACNC,WAAW;AAElB;AACA;AACA;AACA;AACA,OAAO,IAAMC,4BAA4B,GAAG,OAAO;;AAEnD;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAqCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAOxBC,IAA8B,EAAQ;EAAA,IAAAC,cAAA,EAAAC,UAAA;EACtC,QAAAD,cAAA,GAAQD,IAAI,aAAJA,IAAI,wBAAAE,UAAA,GAAJF,IAAI,CAAEA,IAAI,cAAAE,UAAA,uBAAVA,UAAA,CAAYC,GAAG,cAAAF,cAAA,cAAAA,cAAA,GAAID,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,GAAG;AACt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AEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASiB,uBAAuBA,CACrCC,OAAyC,EAElB;EAAA,IADvBC,SAAsC,GAAA9B,SAAA,CAAAS,MAAA,QAAAT,SAAA,QAAA+B,SAAA,GAAA/B,SAAA,MAAG,OAAO;EAEhD,IAAI6B,OAAO,IAAI,IAAI,IAAIA,OAAO,KAAK,KAAK,EAAE;IACxC,OAAO,IAAI;EACb;EAEA,IAAIA,OAAO,KAAK,IAAI,EAAE;IACpB,OAAO;MAAEC;IAAU,CAAC;EACtB;EAEA,OAAOD,OAAO;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,wBAAwBA,CAOtCC,QAAe,EAAW;EAC1B,IAAIA,QAAQ,IAAI,IAAI,IAAIA,QAAQ,KAAK,KAAK,EAAE;IAC1C,OAAOA,QAAQ;EACjB;EAEA,OAAO,IAAIC,GAAG,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAACE,GAAG,CAACC,MAAM,CAAC,CAAC;AAC3C"}
@@ -0,0 +1,28 @@
1
+ import { ReactNode } from 'react';
2
+ import { ItemElement, ItemIconSlot, ItemOrSection, SectionElement, TooltipOptions } from './itemUtils';
3
+ /**
4
+ * If the given content is a string, wrap it in an Icon component. Otherwise,
5
+ * return the original content. If the key is not found in the dhIcons object,
6
+ * the vsBlank icon will be used.
7
+ * @param maybeIconKey The content to wrap
8
+ * @param slot The slot to use for the Icon component
9
+ * @returns The wrapped content or original content if not a string
10
+ */
11
+ export declare function wrapIcon(maybeIconKey: ReactNode, slot: ItemIconSlot): ReactNode;
12
+ /**
13
+ * Ensure all primitive children are wrapped in `Item` elements and that all
14
+ * `Item` element content is wrapped in `ItemContent` elements to handle text
15
+ * overflow consistently and to support tooltips.
16
+ * @param itemsOrSections The items or sections to wrap
17
+ * @param tooltipOptions The tooltip options to use when wrapping items
18
+ * @returns The wrapped items or sections
19
+ */
20
+ export declare function wrapItemChildren<T>(itemsOrSections: ItemOrSection<T> | ItemOrSection<T>[], tooltipOptions: TooltipOptions | null): ItemElement<T> | SectionElement<T> | (ItemElement<T> | SectionElement<T>)[];
21
+ /**
22
+ * If the given content is a primitive type, wrap it in a Text component.
23
+ * @param content The content to wrap
24
+ * @param slot The slot to use for the Text component
25
+ * @returns The wrapped content or original content if not a primitive type
26
+ */
27
+ export declare function wrapPrimitiveWithText(content?: ReactNode, slot?: string): ReactNode;
28
+ //# sourceMappingURL=itemWrapperUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"itemWrapperUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/itemWrapperUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD,OAAO,EAGL,WAAW,EACX,YAAY,EACZ,aAAa,EAEb,cAAc,EACd,cAAc,EACf,MAAM,aAAa,CAAC;AAKrB;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,YAAY,EAAE,SAAS,EACvB,IAAI,EAAE,YAAY,GACjB,SAAS,CAaX;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,EACtD,cAAc,EAAE,cAAc,GAAG,IAAI,GACpC,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAoD7E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,SAAS,EACnB,IAAI,CAAC,EAAE,MAAM,GACZ,SAAS,CAaX"}
@@ -0,0 +1,111 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ import { cloneElement } from 'react';
7
+ import { Item } from '@adobe/react-spectrum';
8
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
+ import { dh as dhIcons } from '@deephaven/icons';
10
+ import { isElementOfType } from '@deephaven/react-hooks';
11
+ import { ensureArray, NON_BREAKING_SPACE } from '@deephaven/utils';
12
+ import { isItemElement, isSectionElement, ITEM_EMPTY_STRING_TEXT_VALUE } from "./itemUtils.js";
13
+ import { ItemContent } from "../ItemContent.js";
14
+ import { Icon } from "../icons.js";
15
+ import { Text } from "../Text.js";
16
+ /**
17
+ * If the given content is a string, wrap it in an Icon component. Otherwise,
18
+ * return the original content. If the key is not found in the dhIcons object,
19
+ * the vsBlank icon will be used.
20
+ * @param maybeIconKey The content to wrap
21
+ * @param slot The slot to use for the Icon component
22
+ * @returns The wrapped content or original content if not a string
23
+ */
24
+ import { jsx as _jsx } from "react/jsx-runtime";
25
+ export function wrapIcon(maybeIconKey, slot) {
26
+ var _maybeIconKey, _dhIcons$maybeIconKey;
27
+ // eslint-disable-next-line no-param-reassign
28
+ maybeIconKey = (_maybeIconKey = maybeIconKey) !== null && _maybeIconKey !== void 0 ? _maybeIconKey : '';
29
+ if (typeof maybeIconKey !== 'string') {
30
+ return maybeIconKey;
31
+ }
32
+ return /*#__PURE__*/_jsx(Icon, {
33
+ slot: slot,
34
+ children: /*#__PURE__*/_jsx(FontAwesomeIcon, {
35
+ icon: (_dhIcons$maybeIconKey = dhIcons[maybeIconKey]) !== null && _dhIcons$maybeIconKey !== void 0 ? _dhIcons$maybeIconKey : dhIcons.vsBlank
36
+ })
37
+ });
38
+ }
39
+
40
+ /**
41
+ * Ensure all primitive children are wrapped in `Item` elements and that all
42
+ * `Item` element content is wrapped in `ItemContent` elements to handle text
43
+ * overflow consistently and to support tooltips.
44
+ * @param itemsOrSections The items or sections to wrap
45
+ * @param tooltipOptions The tooltip options to use when wrapping items
46
+ * @returns The wrapped items or sections
47
+ */
48
+ export function wrapItemChildren(itemsOrSections, tooltipOptions) {
49
+ var itemsOrSectionsArray = ensureArray(itemsOrSections);
50
+ var result = itemsOrSectionsArray.map(item => {
51
+ if (isItemElement(item)) {
52
+ var _item$key;
53
+ // Item content is already wrapped
54
+ if (isElementOfType(item.props.children, ItemContent)) {
55
+ return item;
56
+ }
57
+ var key = (_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : item.props.textValue;
58
+ var _textValue = item.props.textValue === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : item.props.textValue;
59
+
60
+ // Wrap in `ItemContent` so we can support tooltips and handle text
61
+ // overflow
62
+ return /*#__PURE__*/cloneElement(item, _objectSpread(_objectSpread({}, item.props), {}, {
63
+ key,
64
+ textValue: _textValue,
65
+ children: /*#__PURE__*/_jsx(ItemContent, {
66
+ tooltipOptions: tooltipOptions,
67
+ children: item.props.children
68
+ })
69
+ }));
70
+ }
71
+ if (isSectionElement(item)) {
72
+ var _item$key2;
73
+ return /*#__PURE__*/cloneElement(item, _objectSpread(_objectSpread({}, item.props), {}, {
74
+ key: (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : typeof item.props.title === 'string' ? item.props.title : undefined,
75
+ children: wrapItemChildren(item.props.children, tooltipOptions)
76
+ }));
77
+ }
78
+ var text = String(item);
79
+ var textValue = text === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : text;
80
+ return /*#__PURE__*/_jsx(Item, {
81
+ textValue: textValue,
82
+ children: /*#__PURE__*/_jsx(ItemContent, {
83
+ tooltipOptions: tooltipOptions,
84
+ children: text
85
+ })
86
+ }, text);
87
+ });
88
+
89
+ // Keep consistent with original data structure as array or single node
90
+ return Array.isArray(itemsOrSections) ? result : result[0];
91
+ }
92
+
93
+ /**
94
+ * If the given content is a primitive type, wrap it in a Text component.
95
+ * @param content The content to wrap
96
+ * @param slot The slot to use for the Text component
97
+ * @returns The wrapped content or original content if not a primitive type
98
+ */
99
+ export function wrapPrimitiveWithText(content, slot) {
100
+ var _content;
101
+ // eslint-disable-next-line no-param-reassign
102
+ content = (_content = content) !== null && _content !== void 0 ? _content : '';
103
+ if (['string', 'boolean', 'number'].includes(typeof content)) {
104
+ return /*#__PURE__*/_jsx(Text, {
105
+ slot: slot,
106
+ children: content === '' ? NON_BREAKING_SPACE : String(content)
107
+ });
108
+ }
109
+ return content;
110
+ }
111
+ //# sourceMappingURL=itemWrapperUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"itemWrapperUtils.js","names":["cloneElement","Item","FontAwesomeIcon","dh","dhIcons","isElementOfType","ensureArray","NON_BREAKING_SPACE","isItemElement","isSectionElement","ITEM_EMPTY_STRING_TEXT_VALUE","ItemContent","Icon","Text","jsx","_jsx","wrapIcon","maybeIconKey","slot","_maybeIconKey","_dhIcons$maybeIconKey","children","icon","vsBlank","wrapItemChildren","itemsOrSections","tooltipOptions","itemsOrSectionsArray","result","map","item","_item$key","props","key","textValue","_objectSpread","_item$key2","title","undefined","text","String","Array","isArray","wrapPrimitiveWithText","content","_content","includes"],"sources":["../../../src/spectrum/utils/itemWrapperUtils.tsx"],"sourcesContent":["import { cloneElement, ReactNode } from 'react';\nimport { Item } from '@adobe/react-spectrum';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { dh as dhIcons } from '@deephaven/icons';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport { ensureArray, NON_BREAKING_SPACE } from '@deephaven/utils';\nimport {\n isItemElement,\n isSectionElement,\n ItemElement,\n ItemIconSlot,\n ItemOrSection,\n ITEM_EMPTY_STRING_TEXT_VALUE,\n SectionElement,\n TooltipOptions,\n} from './itemUtils';\nimport { ItemContent } from '../ItemContent';\nimport { Icon } from '../icons';\nimport { Text } from '../Text';\n\n/**\n * If the given content is a string, wrap it in an Icon component. Otherwise,\n * return the original content. If the key is not found in the dhIcons object,\n * the vsBlank icon will be used.\n * @param maybeIconKey The content to wrap\n * @param slot The slot to use for the Icon component\n * @returns The wrapped content or original content if not a string\n */\nexport function wrapIcon(\n maybeIconKey: ReactNode,\n slot: ItemIconSlot\n): ReactNode {\n // eslint-disable-next-line no-param-reassign\n maybeIconKey = maybeIconKey ?? '';\n\n if (typeof maybeIconKey !== 'string') {\n return maybeIconKey;\n }\n\n return (\n <Icon slot={slot}>\n <FontAwesomeIcon icon={dhIcons[maybeIconKey] ?? dhIcons.vsBlank} />\n </Icon>\n );\n}\n\n/**\n * Ensure all primitive children are wrapped in `Item` elements and that all\n * `Item` element content is wrapped in `ItemContent` elements to handle text\n * overflow consistently and to support tooltips.\n * @param itemsOrSections The items or sections to wrap\n * @param tooltipOptions The tooltip options to use when wrapping items\n * @returns The wrapped items or sections\n */\nexport function wrapItemChildren<T>(\n itemsOrSections: ItemOrSection<T> | ItemOrSection<T>[],\n tooltipOptions: TooltipOptions | null\n): ItemElement<T> | SectionElement<T> | (ItemElement<T> | SectionElement<T>)[] {\n const itemsOrSectionsArray = ensureArray(itemsOrSections);\n\n const result = itemsOrSectionsArray.map(item => {\n if (isItemElement(item)) {\n // Item content is already wrapped\n if (isElementOfType(item.props.children, ItemContent)) {\n return item;\n }\n\n const key = item.key ?? item.props.textValue;\n const textValue =\n item.props.textValue === ''\n ? ITEM_EMPTY_STRING_TEXT_VALUE\n : item.props.textValue;\n\n // Wrap in `ItemContent` so we can support tooltips and handle text\n // overflow\n return cloneElement(item, {\n ...item.props,\n key,\n textValue,\n children: (\n <ItemContent tooltipOptions={tooltipOptions}>\n {item.props.children}\n </ItemContent>\n ),\n });\n }\n\n if (isSectionElement(item)) {\n return cloneElement(item, {\n ...item.props,\n key:\n item.key ??\n (typeof item.props.title === 'string' ? item.props.title : undefined),\n children: wrapItemChildren<T>(item.props.children, tooltipOptions),\n });\n }\n\n const text = String(item);\n const textValue = text === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : text;\n\n return (\n <Item key={text} textValue={textValue}>\n <ItemContent tooltipOptions={tooltipOptions}>{text}</ItemContent>\n </Item>\n );\n });\n\n // Keep consistent with original data structure as array or single node\n return Array.isArray(itemsOrSections) ? result : result[0];\n}\n\n/**\n * If the given content is a primitive type, wrap it in a Text component.\n * @param content The content to wrap\n * @param slot The slot to use for the Text component\n * @returns The wrapped content or original content if not a primitive type\n */\nexport function wrapPrimitiveWithText(\n content?: ReactNode,\n slot?: string\n): ReactNode {\n // eslint-disable-next-line no-param-reassign\n content = content ?? '';\n\n if (['string', 'boolean', 'number'].includes(typeof content)) {\n return (\n <Text slot={slot}>\n {content === '' ? NON_BREAKING_SPACE : String(content)}\n </Text>\n );\n }\n\n return content;\n}\n"],"mappings":";;;;;AAAA,SAASA,YAAY,QAAmB,OAAO;AAC/C,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,EAAE,IAAIC,OAAO,QAAQ,kBAAkB;AAChD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SAASC,WAAW,EAAE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AM,GAAGA,MAAM,CAAC,CAAC,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASe,qBAAqBA,CACnCC,OAAmB,EACnB1B,IAAa,EACF;EAAA,IAAA2B,QAAA;EACX;EACAD,OAAO,IAAAC,QAAA,GAAGD,OAAO,cAAAC,QAAA,cAAAA,QAAA,GAAI,EAAE;EAEvB,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAACC,QAAQ,CAAC,OAAOF,OAAO,CAAC,EAAE;IAC5D,oBACE7B,IAAA,CAACF,IAAI;MAACK,IAAI,EAAEA,IAAK;MAAAG,QAAA,EACduB,OAAO,KAAK,EAAE,GAAGrC,kBAAkB,GAAGiC,MAAM,CAACI,OAAO;IAAC,CAClD,CAAC;EAEX;EAEA,OAAOA,OAAO;AAChB"}
@@ -0,0 +1,14 @@
1
+ import type { AriaLabelingProps, StyleProps } from '@react-types/shared';
2
+ /**
3
+ * Separate props for Spectrum components into AriaLabelingProps, StyleProps, and
4
+ * any remaining props.
5
+ * @param props The props to separate
6
+ * @returns The separated props
7
+ */
8
+ export declare function separateSpectrumProps<T extends AriaLabelingProps & StyleProps>(props: T): {
9
+ ariaLabelProps: AriaLabelingProps;
10
+ styleProps: StyleProps;
11
+ componentProps: Omit<T, keyof (AriaLabelingProps & StyleProps)>;
12
+ };
13
+ export default separateSpectrumProps;
14
+ //# sourceMappingURL=propsUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propsUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/propsUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEzE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,iBAAiB,GAAG,UAAU,EAC5E,KAAK,EAAE,CAAC,GACP;IACD,cAAc,EAAE,iBAAiB,CAAC;IAClC,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,iBAAiB,GAAG,UAAU,CAAC,CAAC,CAAC;CACjE,CAsFA;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,93 @@
1
+ var _excluded = ["aria-label", "aria-labelledby", "aria-describedby", "aria-details", "marginX", "marginY", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "flex", "flexGrow", "flexShrink", "flexBasis", "justifySelf", "alignSelf", "order", "gridArea", "gridColumn", "gridRow", "gridColumnStart", "gridColumnEnd", "gridRowStart", "gridRowEnd", "position", "zIndex", "top", "bottom", "start", "end", "left", "right", "isHidden"];
2
+ 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; }
3
+ 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; }
4
+ /**
5
+ * Separate props for Spectrum components into AriaLabelingProps, StyleProps, and
6
+ * any remaining props.
7
+ * @param props The props to separate
8
+ * @returns The separated props
9
+ */
10
+ export function separateSpectrumProps(props) {
11
+ var {
12
+ 'aria-label': ariaLabel,
13
+ 'aria-labelledby': ariaLabelledby,
14
+ 'aria-describedby': ariaDescribedby,
15
+ 'aria-details': ariaHidden,
16
+ marginX,
17
+ marginY,
18
+ width,
19
+ height,
20
+ minWidth,
21
+ minHeight,
22
+ maxWidth,
23
+ maxHeight,
24
+ flex,
25
+ flexGrow,
26
+ flexShrink,
27
+ flexBasis,
28
+ justifySelf,
29
+ alignSelf,
30
+ order,
31
+ gridArea,
32
+ gridColumn,
33
+ gridRow,
34
+ gridColumnStart,
35
+ gridColumnEnd,
36
+ gridRowStart,
37
+ gridRowEnd,
38
+ position,
39
+ zIndex,
40
+ top,
41
+ bottom,
42
+ start,
43
+ end,
44
+ left,
45
+ right,
46
+ isHidden
47
+ } = props,
48
+ componentProps = _objectWithoutProperties(props, _excluded);
49
+ return {
50
+ ariaLabelProps: {
51
+ 'aria-label': ariaLabel,
52
+ 'aria-labelledby': ariaLabelledby,
53
+ 'aria-describedby': ariaDescribedby,
54
+ 'aria-details': ariaHidden
55
+ },
56
+ styleProps: {
57
+ marginX,
58
+ marginY,
59
+ width,
60
+ height,
61
+ minWidth,
62
+ minHeight,
63
+ maxWidth,
64
+ maxHeight,
65
+ flex,
66
+ flexGrow,
67
+ flexShrink,
68
+ flexBasis,
69
+ justifySelf,
70
+ alignSelf,
71
+ order,
72
+ gridArea,
73
+ gridColumn,
74
+ gridRow,
75
+ gridColumnStart,
76
+ gridColumnEnd,
77
+ gridRowStart,
78
+ gridRowEnd,
79
+ position,
80
+ zIndex,
81
+ top,
82
+ bottom,
83
+ start,
84
+ end,
85
+ left,
86
+ right,
87
+ isHidden
88
+ },
89
+ componentProps: componentProps
90
+ };
91
+ }
92
+ export default separateSpectrumProps;
93
+ //# sourceMappingURL=propsUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propsUtils.js","names":["separateSpectrumProps","props","ariaLabel","ariaLabelledby","ariaDescribedby","ariaHidden","marginX","marginY","width","height","minWidth","minHeight","maxWidth","maxHeight","flex","flexGrow","flexShrink","flexBasis","justifySelf","alignSelf","order","gridArea","gridColumn","gridRow","gridColumnStart","gridColumnEnd","gridRowStart","gridRowEnd","position","zIndex","top","bottom","start","end","left","right","isHidden","componentProps","_objectWithoutProperties","_excluded","ariaLabelProps","styleProps"],"sources":["../../../src/spectrum/utils/propsUtils.ts"],"sourcesContent":["import type { AriaLabelingProps, StyleProps } from '@react-types/shared';\n\n/**\n * Separate props for Spectrum components into AriaLabelingProps, StyleProps, and\n * any remaining props.\n * @param props The props to separate\n * @returns The separated props\n */\nexport function separateSpectrumProps<T extends AriaLabelingProps & StyleProps>(\n props: T\n): {\n ariaLabelProps: AriaLabelingProps;\n styleProps: StyleProps;\n componentProps: Omit<T, keyof (AriaLabelingProps & StyleProps)>;\n} {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n 'aria-details': ariaHidden,\n\n marginX,\n marginY,\n width,\n height,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flex,\n flexGrow,\n flexShrink,\n flexBasis,\n justifySelf,\n alignSelf,\n order,\n gridArea,\n gridColumn,\n gridRow,\n gridColumnStart,\n gridColumnEnd,\n gridRowStart,\n gridRowEnd,\n position,\n zIndex,\n top,\n bottom,\n start,\n end,\n left,\n right,\n isHidden,\n ...componentProps\n } = props;\n\n return {\n ariaLabelProps: {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n 'aria-details': ariaHidden,\n },\n styleProps: {\n marginX,\n marginY,\n width,\n height,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flex,\n flexGrow,\n flexShrink,\n flexBasis,\n justifySelf,\n alignSelf,\n order,\n gridArea,\n gridColumn,\n gridRow,\n gridColumnStart,\n gridColumnEnd,\n gridRowStart,\n gridRowEnd,\n position,\n zIndex,\n top,\n bottom,\n start,\n end,\n left,\n right,\n isHidden,\n },\n componentProps: componentProps as Omit<\n T,\n keyof (AriaLabelingProps & StyleProps)\n >,\n };\n}\n\nexport default separateSpectrumProps;\n"],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,qBAAqBA,CACnCC,KAAQ,EAKR;EACA,IAAM;MACJ,YAAY,EAAEC,SAAS;MACvB,iBAAiB,EAAEC,cAAc;MACjC,kBAAkB,EAAEC,eAAe;MACnC,cAAc,EAAEC,UAAU;MAE1BC,OAAO;MACPC,OAAO;MACPC,KAAK;MACLC,MAAM;MACNC,QAAQ;MACRC,SAAS;MACTC,QAAQ;MACRC,SAAS;MACTC,IAAI;MACJC,QAAQ;MACRC,UAAU;MACVC,SAAS;MACTC,WAAW;MACXC,SAAS;MACTC,KAAK;MACLC,QAAQ;MACRC,UAAU;MACVC,OAAO;MACPC,eAAe;MACfC,aAAa;MACbC,YAAY;MACZC,UAAU;MACVC,QAAQ;MACRC,MAAM;MACNC,GAAG;MACHC,MAAM;MACNC,KAAK;MACLC,GAAG;MACHC,IAAI;MACJC,KAAK;MACLC;IAEF,CAAC,GAAGnC,KAAK;IADJoC,cAAc,GAAAC,wBAAA,CACfrC,KAAK,EAAAsC,SAAA;EAET,OAAO;IACLC,cAAc,EAAE;MACd,YAAY,EAAEtC,SAAS;MACvB,iBAAiB,EAAEC,cAAc;MACjC,kBAAkB,EAAEC,eAAe;MACnC,cAAc,EAAEC;IAClB,CAAC;IACDoC,UAAU,EAAE;MACVnC,OAAO;MACPC,OAAO;MACPC,KAAK;MACLC,MAAM;MACNC,QAAQ;MACRC,SAAS;MACTC,QAAQ;MACRC,SAAS;MACTC,IAAI;MACJC,QAAQ;MACRC,UAAU;MACVC,SAAS;MACTC,WAAW;MACXC,SAAS;MACTC,KAAK;MACLC,QAAQ;MACRC,UAAU;MACVC,OAAO;MACPC,eAAe;MACfC,aAAa;MACbC,YAAY;MACZC,UAAU;MACVC,QAAQ;MACRC,MAAM;MACNC,GAAG;MACHC,MAAM;MACNC,KAAK;MACLC,GAAG;MACHC,IAAI;MACJC,KAAK;MACLC;IACF,CAAC;IACDC,cAAc,EAAEA;EAIlB,CAAC;AACH;AAEA,eAAerC,qBAAqB"}
@@ -1,11 +1,24 @@
1
- /// <reference types="react" />
2
- import { NormalizedItem, TooltipOptions } from './itemUtils';
1
+ import { ReactElement } from 'react';
2
+ import { ListActionGroupProps } from '../ListActionGroup';
3
+ import { ItemIconSlot, NormalizedItem, TooltipOptions } from './itemUtils';
4
+ export type ListActions<T> = ReactElement<ListActionGroupProps<T>>;
5
+ export interface UseRenderNormalizedItemOptions {
6
+ itemIconSlot: ItemIconSlot;
7
+ showItemDescriptions: boolean;
8
+ showItemIcons: boolean;
9
+ tooltipOptions: TooltipOptions | null;
10
+ actions?: ListActions<unknown>;
11
+ }
3
12
  /**
4
13
  * Returns a render function that can be used to render a normalized item in
5
14
  * collection components.
15
+ * @param itemIconSlot Slot to use for item icons
16
+ * @param showItemDescriptions Whether to show item descriptions
17
+ * @param showItemIcons Whether to show item icons
6
18
  * @param tooltipOptions Tooltip options to use when rendering the item
19
+ * @param actions Optional actions to render with the item
7
20
  * @returns Render function for normalized items
8
21
  */
9
- export declare function useRenderNormalizedItem(tooltipOptions: TooltipOptions | null): (normalizedItem: NormalizedItem) => JSX.Element;
22
+ export declare function useRenderNormalizedItem({ itemIconSlot, showItemDescriptions, showItemIcons, tooltipOptions, actions, }: UseRenderNormalizedItemOptions): (normalizedItem: NormalizedItem) => JSX.Element;
10
23
  export default useRenderNormalizedItem;
11
24
  //# sourceMappingURL=useRenderNormalizedItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRenderNormalizedItem.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAc,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEzE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,cAAc,GAAG,IAAI,GACpC,CAAC,cAAc,EAAE,cAAc,KAAK,GAAG,CAAC,OAAO,CA6BjD;AAED,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"useRenderNormalizedItem.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,YAAY,EAAe,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAEL,YAAY,EAEZ,cAAc,EACd,cAAc,EACf,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnE,MAAM,WAAW,8BAA8B;IAC7C,YAAY,EAAE,YAAY,CAAC;IAC3B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,OAAO,GACR,EAAE,8BAA8B,GAAG,CAClC,cAAc,EAAE,cAAc,KAC3B,GAAG,CAAC,OAAO,CAmDf;AAED,eAAe,uBAAuB,CAAC"}
@@ -1,20 +1,41 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
6
  import { useCallback } from 'react';
7
+ import ActionGroup from "../ActionGroup.js";
2
8
  import { ItemContent } from "../ItemContent.js";
3
9
  import { Item } from "../shared.js";
4
- import { getItemKey } from "./itemUtils.js";
10
+ import { getItemKey, ITEM_EMPTY_STRING_TEXT_VALUE } from "./itemUtils.js";
11
+ import { wrapIcon, wrapPrimitiveWithText } from "./itemWrapperUtils.js";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
5
14
  /**
6
15
  * Returns a render function that can be used to render a normalized item in
7
16
  * collection components.
17
+ * @param itemIconSlot Slot to use for item icons
18
+ * @param showItemDescriptions Whether to show item descriptions
19
+ * @param showItemIcons Whether to show item icons
8
20
  * @param tooltipOptions Tooltip options to use when rendering the item
21
+ * @param actions Optional actions to render with the item
9
22
  * @returns Render function for normalized items
10
23
  */
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- export function useRenderNormalizedItem(tooltipOptions) {
24
+ export function useRenderNormalizedItem(_ref) {
25
+ var {
26
+ itemIconSlot,
27
+ showItemDescriptions,
28
+ showItemIcons,
29
+ tooltipOptions,
30
+ actions
31
+ } = _ref;
13
32
  return useCallback(normalizedItem => {
14
- var _normalizedItem$item$, _normalizedItem$item, _normalizedItem$item$2, _normalizedItem$item2;
15
- var key = getItemKey(normalizedItem);
16
- var content = (_normalizedItem$item$ = (_normalizedItem$item = normalizedItem.item) === null || _normalizedItem$item === void 0 ? void 0 : _normalizedItem$item.content) !== null && _normalizedItem$item$ !== void 0 ? _normalizedItem$item$ : '';
17
- var textValue = (_normalizedItem$item$2 = (_normalizedItem$item2 = normalizedItem.item) === null || _normalizedItem$item2 === void 0 ? void 0 : _normalizedItem$item2.textValue) !== null && _normalizedItem$item$2 !== void 0 ? _normalizedItem$item$2 : '';
33
+ var _normalizedItem$item, _normalizedItem$item$, _normalizedItem$item2, _normalizedItem$item3, _normalizedItem$item4;
34
+ var itemKey = getItemKey(normalizedItem);
35
+ var content = wrapPrimitiveWithText((_normalizedItem$item = normalizedItem.item) === null || _normalizedItem$item === void 0 ? void 0 : _normalizedItem$item.content);
36
+ var textValue = (_normalizedItem$item$ = (_normalizedItem$item2 = normalizedItem.item) === null || _normalizedItem$item2 === void 0 ? void 0 : _normalizedItem$item2.textValue) !== null && _normalizedItem$item$ !== void 0 ? _normalizedItem$item$ : '';
37
+ var description = showItemDescriptions ? wrapPrimitiveWithText((_normalizedItem$item3 = normalizedItem.item) === null || _normalizedItem$item3 === void 0 ? void 0 : _normalizedItem$item3.description, 'description') : null;
38
+ var icon = showItemIcons ? wrapIcon((_normalizedItem$item4 = normalizedItem.item) === null || _normalizedItem$item4 === void 0 ? void 0 : _normalizedItem$item4.icon, itemIconSlot) : null;
18
39
  return /*#__PURE__*/_jsx(Item
19
40
  // Note that setting the `key` prop explicitly on `Item` elements
20
41
  // causes the picker to expect `selectedKey` and `defaultSelectedKey`
@@ -27,14 +48,22 @@ export function useRenderNormalizedItem(tooltipOptions) {
27
48
  // The `textValue` prop gets used to provide the content of `<option>`
28
49
  // elements that back the Spectrum Picker. These are not visible in the UI,
29
50
  // but are used for accessibility purposes, so we set to an arbitrary
30
- // 'Empty' value so that they are not empty strings.
31
- textValue: textValue === '' ? 'Empty' : textValue,
32
- children: /*#__PURE__*/_jsx(ItemContent, {
51
+ // `ITEM_EMPTY_STRING_TEXT_VALUE` value so that they are not empty strings.
52
+ textValue: textValue === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : textValue,
53
+ children: /*#__PURE__*/_jsxs(ItemContent, {
33
54
  tooltipOptions: tooltipOptions,
34
- children: content
55
+ children: [icon, content, description, (actions === null || actions === void 0 ? void 0 : actions.props) == null ? null : /*#__PURE__*/_jsx(ActionGroup
56
+ // eslint-disable-next-line react/jsx-props-no-spreading
57
+ , _objectSpread(_objectSpread({}, actions.props), {}, {
58
+ onAction: key => actions.props.onAction(key, itemKey),
59
+ onChange: keys => {
60
+ var _actions$props$onChan, _actions$props;
61
+ return (_actions$props$onChan = (_actions$props = actions.props).onChange) === null || _actions$props$onChan === void 0 ? void 0 : _actions$props$onChan.call(_actions$props, keys, itemKey);
62
+ }
63
+ }))]
35
64
  })
36
- }, key);
37
- }, [tooltipOptions]);
65
+ }, itemKey);
66
+ }, [actions, itemIconSlot, showItemDescriptions, showItemIcons, tooltipOptions]);
38
67
  }
39
68
  export default useRenderNormalizedItem;
40
69
  //# sourceMappingURL=useRenderNormalizedItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRenderNormalizedItem.js","names":["useCallback","ItemContent","Item","getItemKey","jsx","_jsx","useRenderNormalizedItem","tooltipOptions","normalizedItem","_normalizedItem$item$","_normalizedItem$item","_normalizedItem$item$2","_normalizedItem$item2","key","content","item","textValue","children"],"sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"sourcesContent":["import { Key, useCallback } from 'react';\nimport { ItemContent } from '../ItemContent';\nimport { Item } from '../shared';\nimport { getItemKey, NormalizedItem, TooltipOptions } from './itemUtils';\n\n/**\n * Returns a render function that can be used to render a normalized item in\n * collection components.\n * @param tooltipOptions Tooltip options to use when rendering the item\n * @returns Render function for normalized items\n */\nexport function useRenderNormalizedItem(\n tooltipOptions: TooltipOptions | null\n): (normalizedItem: NormalizedItem) => JSX.Element {\n return useCallback(\n (normalizedItem: NormalizedItem) => {\n const key = getItemKey(normalizedItem);\n const content = normalizedItem.item?.content ?? '';\n const textValue = normalizedItem.item?.textValue ?? '';\n\n return (\n <Item\n // Note that setting the `key` prop explicitly on `Item` elements\n // causes the picker to expect `selectedKey` and `defaultSelectedKey`\n // to be strings. It also passes the stringified value of the key to\n // `onSelectionChange` handlers` regardless of the actual type of the\n // key. We can't really get around setting in order to support Windowed\n // data, so we'll need to do some manual conversion of keys to strings\n // in other components that use this hook.\n key={key as Key}\n // The `textValue` prop gets used to provide the content of `<option>`\n // elements that back the Spectrum Picker. These are not visible in the UI,\n // but are used for accessibility purposes, so we set to an arbitrary\n // 'Empty' value so that they are not empty strings.\n textValue={textValue === '' ? 'Empty' : textValue}\n >\n <ItemContent tooltipOptions={tooltipOptions}>{content}</ItemContent>\n </Item>\n );\n },\n [tooltipOptions]\n );\n}\n\nexport default useRenderNormalizedItem;\n"],"mappings":"AAAA,SAAcA,WAAW,QAAQ,OAAO;AAAC,SAChCC,WAAW;AAAA,SACXC,IAAI;AAAA,SACJC,UAAU;AAEnB;AACA;AACA;AACA;AACA;AACA;AALA,SAAAC,GAAA,IAAAC,IAAA;AAMA,OAAO,SAASC,uBAAuBA,CACrCC,cAAqC,EACY;EACjD,OAAOP,WAAW,CACfQ,cAA8B,IAAK;IAAA,IAAAC,qBAAA,EAAAC,oBAAA,EAAAC,sBAAA,EAAAC,qBAAA;IAClC,IAAMC,GAAG,GAAGV,UAAU,CAACK,cAAc,CAAC;IACtC,IAAMM,OAAO,IAAAL,qBAAA,IAAAC,oBAAA,GAAGF,cAAc,CAACO,IAAI,cAAAL,oBAAA,uBAAnBA,oBAAA,CAAqBI,OAAO,cAAAL,qBAAA,cAAAA,qBAAA,GAAI,EAAE;IAClD,IAAMO,SAAS,IAAAL,sBAAA,IAAAC,qBAAA,GAAGJ,cAAc,CAACO,IAAI,cAAAH,qBAAA,uBAAnBA,qBAAA,CAAqBI,SAAS,cAAAL,sBAAA,cAAAA,sBAAA,GAAI,EAAE;IAEtD,oBACEN,IAAA,CAACH;IACC;IACA;IACA;IACA;IACA;IACA;IACA;IAAA;MAEA;MACA;MACA;MACA;MACAc,SAAS,EAAEA,SAAS,KAAK,EAAE,GAAG,OAAO,GAAGA,SAAU;MAAAC,QAAA,eAElDZ,IAAA,CAACJ,WAAW;QAACM,cAAc,EAAEA,cAAe;QAAAU,QAAA,EAAEH;MAAO,CAAc;IAAC,GAP/DD,GAQD,CAAC;EAEX,CAAC,EACD,CAACN,cAAc,CACjB,CAAC;AACH;AAEA,eAAeD,uBAAuB"}
1
+ {"version":3,"file":"useRenderNormalizedItem.js","names":["useCallback","ActionGroup","ItemContent","Item","getItemKey","ITEM_EMPTY_STRING_TEXT_VALUE","wrapIcon","wrapPrimitiveWithText","jsx","_jsx","jsxs","_jsxs","useRenderNormalizedItem","_ref","itemIconSlot","showItemDescriptions","showItemIcons","tooltipOptions","actions","normalizedItem","_normalizedItem$item","_normalizedItem$item$","_normalizedItem$item2","_normalizedItem$item3","_normalizedItem$item4","itemKey","content","item","textValue","description","icon","children","props","_objectSpread","onAction","key","onChange","keys","_actions$props$onChan","_actions$props","call"],"sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"sourcesContent":["import { Key, ReactElement, useCallback } from 'react';\nimport ActionGroup from '../ActionGroup';\nimport { ItemContent } from '../ItemContent';\nimport { ListActionGroupProps } from '../ListActionGroup';\nimport { Item } from '../shared';\nimport {\n getItemKey,\n ItemIconSlot,\n ITEM_EMPTY_STRING_TEXT_VALUE,\n NormalizedItem,\n TooltipOptions,\n} from './itemUtils';\nimport { wrapIcon, wrapPrimitiveWithText } from './itemWrapperUtils';\n\nexport type ListActions<T> = ReactElement<ListActionGroupProps<T>>;\n\nexport interface UseRenderNormalizedItemOptions {\n itemIconSlot: ItemIconSlot;\n showItemDescriptions: boolean;\n showItemIcons: boolean;\n tooltipOptions: TooltipOptions | null;\n actions?: ListActions<unknown>;\n}\n\n/**\n * Returns a render function that can be used to render a normalized item in\n * collection components.\n * @param itemIconSlot Slot to use for item icons\n * @param showItemDescriptions Whether to show item descriptions\n * @param showItemIcons Whether to show item icons\n * @param tooltipOptions Tooltip options to use when rendering the item\n * @param actions Optional actions to render with the item\n * @returns Render function for normalized items\n */\nexport function useRenderNormalizedItem({\n itemIconSlot,\n showItemDescriptions,\n showItemIcons,\n tooltipOptions,\n actions,\n}: UseRenderNormalizedItemOptions): (\n normalizedItem: NormalizedItem\n) => JSX.Element {\n return useCallback(\n (normalizedItem: NormalizedItem) => {\n const itemKey = getItemKey(normalizedItem);\n const content = wrapPrimitiveWithText(normalizedItem.item?.content);\n const textValue = normalizedItem.item?.textValue ?? '';\n\n const description = showItemDescriptions\n ? wrapPrimitiveWithText(normalizedItem.item?.description, 'description')\n : null;\n\n const icon = showItemIcons\n ? wrapIcon(normalizedItem.item?.icon, itemIconSlot)\n : null;\n\n return (\n <Item\n // Note that setting the `key` prop explicitly on `Item` elements\n // causes the picker to expect `selectedKey` and `defaultSelectedKey`\n // to be strings. It also passes the stringified value of the key to\n // `onSelectionChange` handlers` regardless of the actual type of the\n // key. We can't really get around setting in order to support Windowed\n // data, so we'll need to do some manual conversion of keys to strings\n // in other components that use this hook.\n key={itemKey as Key}\n // The `textValue` prop gets used to provide the content of `<option>`\n // elements that back the Spectrum Picker. These are not visible in the UI,\n // but are used for accessibility purposes, so we set to an arbitrary\n // `ITEM_EMPTY_STRING_TEXT_VALUE` value so that they are not empty strings.\n textValue={\n textValue === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : textValue\n }\n >\n <ItemContent tooltipOptions={tooltipOptions}>\n {icon}\n {content}\n {description}\n {actions?.props == null ? null : (\n <ActionGroup\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...actions.props}\n onAction={key => actions.props.onAction(key, itemKey)}\n onChange={keys => actions.props.onChange?.(keys, itemKey)}\n />\n )}\n </ItemContent>\n </Item>\n );\n },\n [actions, itemIconSlot, showItemDescriptions, showItemIcons, tooltipOptions]\n );\n}\n\nexport default useRenderNormalizedItem;\n"],"mappings":";;;;;AAAA,SAA4BA,WAAW,QAAQ,OAAO;AAAC,OAChDC,WAAW;AAAA,SACTC,WAAW;AAAA,SAEXC,IAAI;AAAA,SAEXC,UAAU,EAEVC,4BAA4B;AAAA,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B,SACnD;MAAAG,QAAA,eAEDpB,KAAA,CAACT,WAAW;QAACe,cAAc,EAAEA,cAAe;QAAAc,QAAA,GACzCD,IAAI,EACJJ,OAAO,EACPG,WAAW,EACX,CAAAX,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEc,KAAK,KAAI,IAAI,GAAG,IAAI,gBAC5BvB,IAAA,CAACR;QACC;QAAA,EAAAgC,aAAA,CAAAA,aAAA,KACIf,OAAO,CAACc,KAAK;UACjBE,QAAQ,EAAEC,GAAG,IAAIjB,OAAO,CAACc,KAAK,CAACE,QAAQ,CAACC,GAAG,EAAEV,OAAO,CAAE;UACtDW,QAAQ,EAAEC,IAAI;YAAA,IAAAC,qBAAA,EAAAC,cAAA;YAAA,QAAAD,qBAAA,GAAI,CAAAC,cAAA,GAAArB,OAAO,CAACc,KAAK,EAACI,QAAQ,cAAAE,qBAAA,uBAAtBA,qBAAA,CAAAE,IAAA,CAAAD,cAAA,EAAyBF,IAAI,EAAEZ,OAAO,CAAC;UAAA;QAAC,EAC3D,CACF;MAAA,CACU;IAAC,GArBTA,OAsBD,CAAC;EAEX,CAAC,EACD,CAACP,OAAO,EAAEJ,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,EAAEC,cAAc,CAC7E,CAAC;AACH;AAEA,eAAeL,uBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useStringifiedMultiSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,OAAO,EACP,aAAa,EAEb,cAAc,EACf,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,mCAAmC;IAClD,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzC,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,kCAAkC;IACjD,iCAAiC;IACjC,kBAAkB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,yCAAyC;IACzC,yBAAyB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,gCAAgC;IAChC,kBAAkB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,mEAAmE;IACnE,uBAAuB,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,GACT,EAAE,mCAAmC,GAAG,kCAAkC,CA0C1E;AAED,eAAe,4BAA4B,CAAC"}
1
+ {"version":3,"file":"useStringifiedMultiSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,OAAO,EACP,aAAa,EAEb,cAAc,EACf,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,mCAAmC;IAClD,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzC,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,kCAAkC;IACjD,iCAAiC;IACjC,kBAAkB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,yCAAyC;IACzC,yBAAyB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,gCAAgC;IAChC,kBAAkB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,mEAAmE;IACnE,uBAAuB,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,GACT,EAAE,mCAAmC,GAAG,kCAAkC,CA8C1E;AAED,eAAe,4BAA4B,CAAC"}
@@ -27,8 +27,11 @@ export function useStringifiedMultiSelection(_ref) {
27
27
  var defaultSelectedStringKeys = useMemo(() => itemSelectionToStringSet(defaultSelectedKeys), [defaultSelectedKeys]);
28
28
  var disabledStringKeys = useMemo(() => itemSelectionToStringSet(disabledKeys), [disabledKeys]);
29
29
  var onStringSelectionChange = useCallback(keys => {
30
+ if (onChange == null) {
31
+ return;
32
+ }
30
33
  if (keys === 'all') {
31
- onChange === null || onChange === void 0 ? void 0 : onChange('all');
34
+ onChange('all');
32
35
  return;
33
36
  }
34
37
  var actualKeys = new Set();
@@ -37,7 +40,7 @@ export function useStringifiedMultiSelection(_ref) {
37
40
  actualKeys.add(getItemKey(item));
38
41
  }
39
42
  });
40
- onChange === null || onChange === void 0 ? void 0 : onChange(actualKeys);
43
+ onChange(actualKeys);
41
44
  }, [normalizedItems, onChange]);
42
45
  return {
43
46
  selectedStringKeys,
@@ -1 +1 @@
1
- {"version":3,"file":"useStringifiedMultiSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedMultiSelection","_ref","normalizedItems","defaultSelectedKeys","disabledKeys","selectedKeys","onChange","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","keys","actualKeys","Set","forEach","item","has","String","add"],"sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n ItemKey,\n ItemSelection,\n itemSelectionToStringSet,\n NormalizedItem,\n} from './itemUtils';\n\nexport interface UseStringifiedMultiSelectionOptions {\n normalizedItems: NormalizedItem[];\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: ItemSelection) => void;\n}\n\nexport interface UseStringifiedMultiSelectionResult {\n /** Stringified selection keys */\n selectedStringKeys?: 'all' | Set<Key>;\n /** Stringified default selection keys */\n defaultSelectedStringKeys?: 'all' | Set<Key>;\n /** Stringified disabled keys */\n disabledStringKeys?: 'all' | Set<Key>;\n /** Handler that is called when the string key selections change */\n onStringSelectionChange: (keys: 'all' | Set<Key>) => void;\n}\n\n/**\n * Spectrum collection components treat keys as strings if the `key` prop is\n * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,\n * we need to ensure that keys are strings in order for selection to work. We\n * then need to convert back to the original key types in the onChange handler.\n * This hook encapsulates converting to and from strings so that keys can match\n * the original key type.\n * @param normalizedItems The normalized items to select from.\n * @param selectedKeys The currently selected keys in the collection.\n * @param defaultSelectedKeys The initial selected keys in the collection.\n * @param disabledKeys The currently disabled keys in the collection.\n * @param onChange Handler that is called when the selection changes.\n * @returns UseStringifiedMultiSelectionResult with stringified key sets and\n * string key selection change handler.\n */\nexport function useStringifiedMultiSelection({\n normalizedItems,\n defaultSelectedKeys,\n disabledKeys,\n selectedKeys,\n onChange,\n}: UseStringifiedMultiSelectionOptions): UseStringifiedMultiSelectionResult {\n const selectedStringKeys = useMemo(\n () => itemSelectionToStringSet(selectedKeys),\n [selectedKeys]\n );\n\n const defaultSelectedStringKeys = useMemo(\n () => itemSelectionToStringSet(defaultSelectedKeys),\n [defaultSelectedKeys]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (keys: 'all' | Set<Key>) => {\n if (keys === 'all') {\n onChange?.('all');\n return;\n }\n\n const actualKeys = new Set<ItemKey>();\n\n normalizedItems.forEach(item => {\n if (keys.has(String(getItemKey(item)))) {\n actualKeys.add(getItemKey(item));\n }\n });\n\n onChange?.(actualKeys);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedMultiSelection;\n"],"mappings":"AAAA,SAAcA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAEhDC,UAAU,EAGVC,wBAAwB;AA6B1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAAC,IAAA,EAMgC;EAAA,IAN/B;IAC3CC,eAAe;IACfC,mBAAmB;IACnBC,YAAY;IACZC,YAAY;IACZC;EACmC,CAAC,GAAAL,IAAA;EACpC,IAAMM,kBAAkB,GAAGV,OAAO,CAChC,MAAME,wBAAwB,CAACM,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMG,yBAAyB,GAAGX,OAAO,CACvC,MAAME,wBAAwB,CAACI,mBAAmB,CAAC,EACnD,CAACA,mBAAmB,CACtB,CAAC;EAED,IAAMM,kBAAkB,GAAGZ,OAAO,CAChC,MAAME,wBAAwB,CAACK,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMM,uBAAuB,GAAGd,WAAW,CACxCe,IAAsB,IAAK;IAC1B,IAAIA,IAAI,KAAK,KAAK,EAAE;MAClBL,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAG,KAAK,CAAC;MACjB;IACF;IAEA,IAAMM,UAAU,GAAG,IAAIC,GAAG,CAAU,CAAC;IAErCX,eAAe,CAACY,OAAO,CAACC,IAAI,IAAI;MAC9B,IAAIJ,IAAI,CAACK,GAAG,CAACC,MAAM,CAACnB,UAAU,CAACiB,IAAI,CAAC,CAAC,CAAC,EAAE;QACtCH,UAAU,CAACM,GAAG,CAACpB,UAAU,CAACiB,IAAI,CAAC,CAAC;MAClC;IACF,CAAC,CAAC;IAEFT,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAGM,UAAU,CAAC;EACxB,CAAC,EACD,CAACV,eAAe,EAAEI,QAAQ,CAC5B,CAAC;EAED,OAAO;IACLC,kBAAkB;IAClBC,yBAAyB;IACzBC,kBAAkB;IAClBC;EACF,CAAC;AACH;AAEA,eAAeV,4BAA4B"}
1
+ {"version":3,"file":"useStringifiedMultiSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedMultiSelection","_ref","normalizedItems","defaultSelectedKeys","disabledKeys","selectedKeys","onChange","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","keys","actualKeys","Set","forEach","item","has","String","add"],"sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n ItemKey,\n ItemSelection,\n itemSelectionToStringSet,\n NormalizedItem,\n} from './itemUtils';\n\nexport interface UseStringifiedMultiSelectionOptions {\n normalizedItems: NormalizedItem[];\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: ItemSelection) => void;\n}\n\nexport interface UseStringifiedMultiSelectionResult {\n /** Stringified selection keys */\n selectedStringKeys?: 'all' | Set<Key>;\n /** Stringified default selection keys */\n defaultSelectedStringKeys?: 'all' | Set<Key>;\n /** Stringified disabled keys */\n disabledStringKeys?: 'all' | Set<Key>;\n /** Handler that is called when the string key selections change */\n onStringSelectionChange: (keys: 'all' | Set<Key>) => void;\n}\n\n/**\n * Spectrum collection components treat keys as strings if the `key` prop is\n * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,\n * we need to ensure that keys are strings in order for selection to work. We\n * then need to convert back to the original key types in the onChange handler.\n * This hook encapsulates converting to and from strings so that keys can match\n * the original key type.\n * @param normalizedItems The normalized items to select from.\n * @param selectedKeys The currently selected keys in the collection.\n * @param defaultSelectedKeys The initial selected keys in the collection.\n * @param disabledKeys The currently disabled keys in the collection.\n * @param onChange Handler that is called when the selection changes.\n * @returns UseStringifiedMultiSelectionResult with stringified key sets and\n * string key selection change handler.\n */\nexport function useStringifiedMultiSelection({\n normalizedItems,\n defaultSelectedKeys,\n disabledKeys,\n selectedKeys,\n onChange,\n}: UseStringifiedMultiSelectionOptions): UseStringifiedMultiSelectionResult {\n const selectedStringKeys = useMemo(\n () => itemSelectionToStringSet(selectedKeys),\n [selectedKeys]\n );\n\n const defaultSelectedStringKeys = useMemo(\n () => itemSelectionToStringSet(defaultSelectedKeys),\n [defaultSelectedKeys]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (keys: 'all' | Set<Key>) => {\n if (onChange == null) {\n return;\n }\n\n if (keys === 'all') {\n onChange('all');\n return;\n }\n\n const actualKeys = new Set<ItemKey>();\n\n normalizedItems.forEach(item => {\n if (keys.has(String(getItemKey(item)))) {\n actualKeys.add(getItemKey(item));\n }\n });\n\n onChange(actualKeys);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedMultiSelection;\n"],"mappings":"AAAA,SAAcA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAEhDC,UAAU,EAGVC,wBAAwB;AA6B1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAAC,IAAA,EAMgC;EAAA,IAN/B;IAC3CC,eAAe;IACfC,mBAAmB;IACnBC,YAAY;IACZC,YAAY;IACZC;EACmC,CAAC,GAAAL,IAAA;EACpC,IAAMM,kBAAkB,GAAGV,OAAO,CAChC,MAAME,wBAAwB,CAACM,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMG,yBAAyB,GAAGX,OAAO,CACvC,MAAME,wBAAwB,CAACI,mBAAmB,CAAC,EACnD,CAACA,mBAAmB,CACtB,CAAC;EAED,IAAMM,kBAAkB,GAAGZ,OAAO,CAChC,MAAME,wBAAwB,CAACK,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMM,uBAAuB,GAAGd,WAAW,CACxCe,IAAsB,IAAK;IAC1B,IAAIL,QAAQ,IAAI,IAAI,EAAE;MACpB;IACF;IAEA,IAAIK,IAAI,KAAK,KAAK,EAAE;MAClBL,QAAQ,CAAC,KAAK,CAAC;MACf;IACF;IAEA,IAAMM,UAAU,GAAG,IAAIC,GAAG,CAAU,CAAC;IAErCX,eAAe,CAACY,OAAO,CAACC,IAAI,IAAI;MAC9B,IAAIJ,IAAI,CAACK,GAAG,CAACC,MAAM,CAACnB,UAAU,CAACiB,IAAI,CAAC,CAAC,CAAC,EAAE;QACtCH,UAAU,CAACM,GAAG,CAACpB,UAAU,CAACiB,IAAI,CAAC,CAAC;MAClC;IACF,CAAC,CAAC;IAEFT,QAAQ,CAACM,UAAU,CAAC;EACtB,CAAC,EACD,CAACV,eAAe,EAAEI,QAAQ,CAC5B,CAAC;EAED,OAAO;IACLC,kBAAkB;IAClBC,yBAAyB;IACzBC,kBAAkB;IAClBC;EACF,CAAC;AACH;AAEA,eAAeV,4BAA4B"}
@@ -0,0 +1,33 @@
1
+ import { Key } from 'react';
2
+ import { ItemKey, NormalizedItem, NormalizedSection } from './itemUtils';
3
+ export interface UseStringifiedSelectionOptions {
4
+ normalizedItems: (NormalizedItem | NormalizedSection)[];
5
+ selectedKey: ItemKey | null | undefined;
6
+ defaultSelectedKey: ItemKey | undefined;
7
+ disabledKeys: Iterable<ItemKey> | undefined;
8
+ onChange: ((key: ItemKey) => void) | undefined;
9
+ }
10
+ export interface UseStringifiedSelectionResult {
11
+ defaultSelectedStringKey?: Key;
12
+ selectedStringKey?: Key | null;
13
+ disabledStringKeys?: Set<Key>;
14
+ onStringSelectionChange: (key: Key) => void;
15
+ }
16
+ /**
17
+ * Spectrum collection components treat keys as strings if the `key` prop is
18
+ * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,
19
+ * we need to ensure that keys are strings in order for selection to work. We
20
+ * then need to convert back to the original key types in the onChange handler.
21
+ * This hook encapsulates converting to and from strings so that keys can match
22
+ * the original key type.
23
+ * @param normalizedItems The normalized items to select from.
24
+ * @param selectedKey The currently selected key in the collection.
25
+ * @param defaultSelectedKey The initial selected key in the collection.
26
+ * @param disabledKeys The currently disabled keys in the collection.
27
+ * @param onChange Handler that is called when the selection changes.
28
+ * @returns UseStringifiedSelectionResult with stringified key sets and string
29
+ * key selection change handler.
30
+ */
31
+ export declare function useStringifiedSelection({ normalizedItems, defaultSelectedKey, selectedKey, disabledKeys, onChange, }: UseStringifiedSelectionOptions): UseStringifiedSelectionResult;
32
+ export default useStringifiedSelection;
33
+ //# sourceMappingURL=useStringifiedSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStringifiedSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,OAAO,EAEP,cAAc,EACd,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,8BAA8B;IAC7C,eAAe,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IACxD,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,kBAAkB,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAC5C,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,6BAA6B;IAC5C,wBAAwB,CAAC,EAAE,GAAG,CAAC;IAC/B,iBAAiB,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC/B,kBAAkB,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,uBAAuB,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,EAAE,8BAA8B,GAAG,6BAA6B,CA6ChE;AAED,eAAe,uBAAuB,CAAC"}