@deephaven/components 0.94.1-beta.0 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AutoCompleteInput.d.ts +1 -1
- package/dist/AutoCompleteInput.d.ts.map +1 -1
- package/dist/AutoCompleteInput.js.map +1 -1
- package/dist/Button.d.ts +1 -1
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js.map +1 -1
- package/dist/CardFlip.d.ts.map +1 -1
- package/dist/CardFlip.js.map +1 -1
- package/dist/ComponentUtils.d.ts +2 -1
- package/dist/ComponentUtils.d.ts.map +1 -1
- package/dist/ComponentUtils.js.map +1 -1
- package/dist/CopyButton.d.ts +1 -1
- package/dist/CopyButton.d.ts.map +1 -1
- package/dist/CopyButton.js.map +1 -1
- package/dist/CustomTimeSelect.d.ts +3 -3
- package/dist/CustomTimeSelect.d.ts.map +1 -1
- package/dist/CustomTimeSelect.js.map +1 -1
- package/dist/DateInput.js.map +1 -1
- package/dist/DateInputUtils.d.ts +1 -1
- package/dist/DateInputUtils.d.ts.map +1 -1
- package/dist/DateInputUtils.js.map +1 -1
- package/dist/DateTimeInput.d.ts +1 -1
- package/dist/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput.js.map +1 -1
- package/dist/DraggableItemList.d.ts +3 -3
- package/dist/DraggableItemList.d.ts.map +1 -1
- package/dist/DraggableItemList.js.map +1 -1
- package/dist/EditableItemList.js.map +1 -1
- package/dist/ErrorBoundary.d.ts +1 -1
- package/dist/ErrorBoundary.d.ts.map +1 -1
- package/dist/ErrorBoundary.js.map +1 -1
- package/dist/HierarchicalCheckboxMenu.d.ts +1 -1
- package/dist/HierarchicalCheckboxMenu.d.ts.map +1 -1
- package/dist/HierarchicalCheckboxMenu.js.map +1 -1
- package/dist/ItemList.d.ts +3 -3
- package/dist/ItemList.d.ts.map +1 -1
- package/dist/ItemList.js.map +1 -1
- package/dist/MaskedInput.d.ts +1 -1
- package/dist/MaskedInput.d.ts.map +1 -1
- package/dist/MaskedInput.js.map +1 -1
- package/dist/Option.d.ts +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/SearchableCombobox.d.ts +2 -2
- package/dist/SearchableCombobox.d.ts.map +1 -1
- package/dist/SearchableCombobox.js.map +1 -1
- package/dist/TextWithTooltip.d.ts +1 -1
- package/dist/TextWithTooltip.d.ts.map +1 -1
- package/dist/TextWithTooltip.js.map +1 -1
- package/dist/TimeInput.d.ts +1 -1
- package/dist/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput.js.map +1 -1
- package/dist/TimeSlider.d.ts.map +1 -1
- package/dist/TimeSlider.js.map +1 -1
- package/dist/XComponent.d.ts +1 -1
- package/dist/XComponent.d.ts.map +1 -1
- package/dist/XComponent.js.map +1 -1
- package/dist/actions/ConfirmActionButton.d.ts +1 -1
- package/dist/actions/ConfirmActionButton.d.ts.map +1 -1
- package/dist/actions/ConfirmActionButton.js.map +1 -1
- package/dist/actions/IconActionButton.d.ts +1 -1
- package/dist/actions/IconActionButton.d.ts.map +1 -1
- package/dist/actions/IconActionButton.js.map +1 -1
- package/dist/context-actions/ContextActionUtils.d.ts +3 -3
- package/dist/context-actions/ContextActionUtils.d.ts.map +1 -1
- package/dist/context-actions/ContextActionUtils.js.map +1 -1
- package/dist/context-actions/ContextActions.d.ts +1 -1
- package/dist/context-actions/ContextActions.d.ts.map +1 -1
- package/dist/context-actions/ContextActions.js.map +1 -1
- package/dist/context-actions/ContextMenu.d.ts +2 -2
- package/dist/context-actions/ContextMenu.d.ts.map +1 -1
- package/dist/context-actions/ContextMenu.js.map +1 -1
- package/dist/context-actions/ContextMenuItem.js.map +1 -1
- package/dist/context-actions/ContextMenuRoot.d.ts +1 -1
- package/dist/context-actions/ContextMenuRoot.d.ts.map +1 -1
- package/dist/context-actions/ContextMenuRoot.js.map +1 -1
- package/dist/dialogs/ActionButtonDialogTrigger.d.ts +1 -1
- package/dist/dialogs/ActionButtonDialogTrigger.d.ts.map +1 -1
- package/dist/dialogs/ActionButtonDialogTrigger.js.map +1 -1
- package/dist/dialogs/ConfirmationDialog.d.ts +1 -1
- package/dist/dialogs/ConfirmationDialog.d.ts.map +1 -1
- package/dist/dialogs/ConfirmationDialog.js.map +1 -1
- package/dist/menu-actions/DropdownMenu.d.ts +3 -3
- package/dist/menu-actions/DropdownMenu.d.ts.map +1 -1
- package/dist/menu-actions/DropdownMenu.js.map +1 -1
- package/dist/menu-actions/Menu.d.ts +1 -1
- package/dist/menu-actions/Menu.d.ts.map +1 -1
- package/dist/menu-actions/Menu.js.map +1 -1
- package/dist/modal/InfoModal.d.ts +1 -1
- package/dist/modal/InfoModal.d.ts.map +1 -1
- package/dist/modal/InfoModal.js.map +1 -1
- package/dist/modal/Modal.d.ts +1 -1
- package/dist/modal/Modal.d.ts.map +1 -1
- package/dist/modal/Modal.js.map +1 -1
- package/dist/modal/ModalBody.d.ts +1 -1
- package/dist/modal/ModalBody.d.ts.map +1 -1
- package/dist/modal/ModalBody.js.map +1 -1
- package/dist/modal/ModalFooter.d.ts +1 -1
- package/dist/modal/ModalFooter.d.ts.map +1 -1
- package/dist/modal/ModalFooter.js.map +1 -1
- package/dist/modal/ModalHeader.d.ts +1 -1
- package/dist/modal/ModalHeader.d.ts.map +1 -1
- package/dist/modal/ModalHeader.js.map +1 -1
- package/dist/navigation/Menu.d.ts +1 -1
- package/dist/navigation/Menu.d.ts.map +1 -1
- package/dist/navigation/Menu.js.map +1 -1
- package/dist/navigation/MenuItem.d.ts +1 -1
- package/dist/navigation/MenuItem.d.ts.map +1 -1
- package/dist/navigation/MenuItem.js.map +1 -1
- package/dist/navigation/NavTab.d.ts +1 -1
- package/dist/navigation/NavTab.d.ts.map +1 -1
- package/dist/navigation/NavTab.js.map +1 -1
- package/dist/navigation/NavTabList.d.ts +2 -2
- package/dist/navigation/NavTabList.d.ts.map +1 -1
- package/dist/navigation/NavTabList.js.map +1 -1
- package/dist/popper/Popper.d.ts +1 -1
- package/dist/popper/Popper.d.ts.map +1 -1
- package/dist/popper/Popper.js.map +1 -1
- package/dist/popper/Tooltip.d.ts +1 -1
- package/dist/popper/Tooltip.d.ts.map +1 -1
- package/dist/popper/Tooltip.js.map +1 -1
- package/dist/shortcuts/Shortcut.d.ts +2 -2
- package/dist/shortcuts/Shortcut.d.ts.map +1 -1
- package/dist/shortcuts/Shortcut.js.map +1 -1
- package/dist/shortcuts/ShortcutRegistry.d.ts +2 -2
- package/dist/shortcuts/ShortcutRegistry.d.ts.map +1 -1
- package/dist/shortcuts/ShortcutRegistry.js.map +1 -1
- package/dist/spectrum/ActionGroup.d.ts +3 -3
- package/dist/spectrum/ActionGroup.d.ts.map +1 -1
- package/dist/spectrum/ActionGroup.js.map +1 -1
- package/dist/spectrum/ActionMenu.d.ts +3 -3
- package/dist/spectrum/ActionMenu.d.ts.map +1 -1
- package/dist/spectrum/ActionMenu.js.map +1 -1
- package/dist/spectrum/ItemContent.d.ts +2 -2
- package/dist/spectrum/ItemContent.d.ts.map +1 -1
- package/dist/spectrum/ItemContent.js.map +1 -1
- package/dist/spectrum/ItemTooltip.d.ts +2 -2
- package/dist/spectrum/ItemTooltip.d.ts.map +1 -1
- package/dist/spectrum/ItemTooltip.js.map +1 -1
- package/dist/spectrum/ListActionGroup.d.ts +2 -2
- package/dist/spectrum/ListActionGroup.d.ts.map +1 -1
- package/dist/spectrum/ListActionGroup.js.map +1 -1
- package/dist/spectrum/ListActionMenu.d.ts +2 -2
- package/dist/spectrum/ListActionMenu.d.ts.map +1 -1
- package/dist/spectrum/ListActionMenu.js.map +1 -1
- package/dist/spectrum/View.js.map +1 -1
- package/dist/spectrum/comboBox/ComboBox.d.ts +2 -2
- package/dist/spectrum/comboBox/ComboBox.d.ts.map +1 -1
- package/dist/spectrum/comboBox/ComboBox.js.map +1 -1
- package/dist/spectrum/comboBox/ComboBoxNormalized.d.ts +2 -2
- package/dist/spectrum/comboBox/ComboBoxNormalized.d.ts.map +1 -1
- package/dist/spectrum/comboBox/ComboBoxNormalized.js.map +1 -1
- package/dist/spectrum/dateAndTime.d.ts +1 -1
- package/dist/spectrum/dateAndTime.d.ts.map +1 -1
- package/dist/spectrum/dateAndTime.js.map +1 -1
- package/dist/spectrum/listView/ListView.d.ts +3 -3
- package/dist/spectrum/listView/ListView.d.ts.map +1 -1
- package/dist/spectrum/listView/ListView.js.map +1 -1
- package/dist/spectrum/listView/ListViewNormalized.d.ts +1 -1
- package/dist/spectrum/listView/ListViewNormalized.d.ts.map +1 -1
- package/dist/spectrum/listView/ListViewNormalized.js.map +1 -1
- package/dist/spectrum/listView/ListViewWrapper.d.ts +1 -1
- package/dist/spectrum/listView/ListViewWrapper.d.ts.map +1 -1
- package/dist/spectrum/listView/ListViewWrapper.js.map +1 -1
- package/dist/spectrum/picker/Picker.d.ts +1 -1
- package/dist/spectrum/picker/Picker.d.ts.map +1 -1
- package/dist/spectrum/picker/Picker.js.map +1 -1
- package/dist/spectrum/picker/usePickerNormalizedProps.d.ts +3 -3
- package/dist/spectrum/picker/usePickerNormalizedProps.d.ts.map +1 -1
- package/dist/spectrum/picker/usePickerNormalizedProps.js.map +1 -1
- package/dist/spectrum/picker/usePickerProps.d.ts +2 -2
- package/dist/spectrum/picker/usePickerProps.d.ts.map +1 -1
- package/dist/spectrum/picker/usePickerProps.js.map +1 -1
- package/dist/spectrum/utils/itemUtils.d.ts +4 -4
- package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
- package/dist/spectrum/utils/itemUtils.js.map +1 -1
- package/dist/spectrum/utils/itemWrapperUtils.d.ts +2 -2
- package/dist/spectrum/utils/itemWrapperUtils.d.ts.map +1 -1
- package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -1
- package/dist/spectrum/utils/useOnChangeTrackUncontrolled.d.ts +1 -1
- package/dist/spectrum/utils/useOnChangeTrackUncontrolled.d.ts.map +1 -1
- package/dist/spectrum/utils/useOnChangeTrackUncontrolled.js.map +1 -1
- package/dist/spectrum/utils/useRenderNormalizedItem.d.ts +4 -4
- package/dist/spectrum/utils/useRenderNormalizedItem.d.ts.map +1 -1
- package/dist/spectrum/utils/useRenderNormalizedItem.js.map +1 -1
- package/dist/spectrum/utils/useStaticItemInitialScrollPosition.d.ts +1 -1
- package/dist/spectrum/utils/useStaticItemInitialScrollPosition.d.ts.map +1 -1
- package/dist/spectrum/utils/useStaticItemInitialScrollPosition.js.map +1 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts +2 -2
- package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts.map +1 -1
- package/dist/spectrum/utils/useStringifiedMultiSelection.js.map +1 -1
- package/dist/spectrum/utils/useStringifiedSelection.d.ts +2 -2
- package/dist/spectrum/utils/useStringifiedSelection.d.ts.map +1 -1
- package/dist/spectrum/utils/useStringifiedSelection.js.map +1 -1
- package/dist/theme/SpectrumThemeProvider.d.ts +1 -1
- package/dist/theme/SpectrumThemeProvider.d.ts.map +1 -1
- package/dist/theme/SpectrumThemeProvider.js.map +1 -1
- package/dist/theme/ThemePicker.js.map +1 -1
- package/dist/theme/ThemeProvider.d.ts +2 -2
- package/dist/theme/ThemeProvider.d.ts.map +1 -1
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/ThemeUtils.d.ts +1 -1
- package/dist/theme/ThemeUtils.d.ts.map +1 -1
- package/dist/theme/ThemeUtils.js.map +1 -1
- package/dist/theme/colorUtils.d.ts +1 -1
- package/dist/theme/colorUtils.d.ts.map +1 -1
- package/dist/theme/colorUtils.js.map +1 -1
- package/dist/theme/useTheme.d.ts +1 -1
- package/dist/theme/useTheme.d.ts.map +1 -1
- package/dist/theme/useTheme.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxNormalized.js","names":["ComboBox","SpectrumComboBox","cl","usePickerNormalizedProps","createElement","_createElement","ComboBoxNormalized","_ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerNormalizedP","forceRerenderKey","ref","pickerProps","_excluded2","_objectSpread","key"],"sources":["../../../src/spectrum/comboBox/ComboBoxNormalized.tsx"],"sourcesContent":["import { ComboBox as SpectrumComboBox } from '@adobe/react-spectrum';\nimport { FocusableRef } from '@react-types/shared';\nimport cl from 'classnames';\nimport { PickerNormalizedPropsT
|
|
1
|
+
{"version":3,"file":"ComboBoxNormalized.js","names":["ComboBox","SpectrumComboBox","cl","usePickerNormalizedProps","createElement","_createElement","ComboBoxNormalized","_ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerNormalizedP","forceRerenderKey","ref","pickerProps","_excluded2","_objectSpread","key"],"sources":["../../../src/spectrum/comboBox/ComboBoxNormalized.tsx"],"sourcesContent":["import { ComboBox as SpectrumComboBox } from '@adobe/react-spectrum';\nimport { type FocusableRef } from '@react-types/shared';\nimport cl from 'classnames';\nimport {\n type PickerNormalizedPropsT,\n usePickerNormalizedProps,\n} from '../picker';\nimport { type ComboBoxProps } from './ComboBox';\n\nexport type ComboBoxNormalizedProps = PickerNormalizedPropsT<ComboBoxProps>;\n\n/**\n * ComboBox that takes an array of `NormalizedItem` or `NormalizedSection` items\n * as children and uses a render item function to render the items. `NormalizedItem`\n * and `NormalizedSection` datums always provide a `key` property but have an\n * optional `item` property that can be lazy loaded. This is necessary to support\n * windowed data since we need a representative key for every item in the\n * collection.\n */\nexport function ComboBoxNormalized({\n UNSAFE_className,\n ...props\n}: ComboBoxNormalizedProps): JSX.Element {\n const { forceRerenderKey, ref, ...pickerProps } =\n usePickerNormalizedProps<ComboBoxNormalizedProps>(props);\n\n return (\n <SpectrumComboBox\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...pickerProps}\n key={forceRerenderKey}\n ref={ref as FocusableRef<HTMLElement>}\n UNSAFE_className={cl(\n 'dh-combobox',\n 'dh-combobox-normalized',\n UNSAFE_className\n )}\n />\n );\n}\n\nexport default ComboBoxNormalized;\n"],"mappings":";;;;;;;;;AAAA,SAASA,QAAQ,IAAIC,gBAAgB,QAAQ,uBAAuB;AAEpE,OAAOC,EAAE,MAAM,YAAY;AAAC,SAG1BC,wBAAwB;AAAA,SAAAC,aAAA,IAAAC,cAAA;AAM1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAAC,IAAA,EAGO;EAAA,IAHN;MACjCC;IAEuB,CAAC,GAAAD,IAAA;IADrBE,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAER,IAAAC,qBAAA,GACET,wBAAwB,CAA0BM,KAAK,CAAC;IADpD;MAAEI,gBAAgB;MAAEC;IAAoB,CAAC,GAAAF,qBAAA;IAAbG,WAAW,GAAAL,wBAAA,CAAAE,qBAAA,EAAAI,UAAA;EAG7C,oBACEX,cAAA,CAACJ;EACC;EAAA,EAAAgB,aAAA,CAAAA,aAAA,KACIF,WAAW;IACfG,GAAG,EAAEL,gBAAiB;IACtBC,GAAG,EAAEA,GAAiC;IACtCN,gBAAgB,EAAEN,EAAE,CAClB,aAAa,EACb,wBAAwB,EACxBM,gBACF;EAAE,EACH,CAAC;AAEN;AAEA,eAAeF,kBAAkB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CalendarDate, CalendarDateTime, ZonedDateTime } from '@internationalized/date';
|
|
1
|
+
import { type CalendarDate, type CalendarDateTime, type ZonedDateTime } from '@internationalized/date';
|
|
2
2
|
export { Calendar, type SpectrumCalendarProps as CalendarProps, DateField, type SpectrumDateFieldProps as DateFieldProps, DatePicker, type SpectrumDatePickerProps as DatePickerProps, DateRangePicker, type SpectrumDateRangePickerProps as DateRangePickerProps, RangeCalendar, type SpectrumRangeCalendarProps as RangeCalendarProps, TimeField, type SpectrumTimeFieldProps as TimeFieldProps, } from '@adobe/react-spectrum';
|
|
3
3
|
export type { CalendarDate, CalendarDateTime, ZonedDateTime };
|
|
4
4
|
export type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateAndTime.d.ts","sourceRoot":"","sources":["../../src/spectrum/dateAndTime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,
|
|
1
|
+
{"version":3,"file":"dateAndTime.d.ts","sourceRoot":"","sources":["../../src/spectrum/dateAndTime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,QAAQ,EACR,KAAK,qBAAqB,IAAI,aAAa,EAC3C,SAAS,EACT,KAAK,sBAAsB,IAAI,cAAc,EAC7C,UAAU,EACV,KAAK,uBAAuB,IAAI,eAAe,EAC/C,eAAe,EACf,KAAK,4BAA4B,IAAI,oBAAoB,EACzD,aAAa,EACb,KAAK,0BAA0B,IAAI,kBAAkB,EACrD,SAAS,EACT,KAAK,sBAAsB,IAAI,cAAc,GAC9C,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC;AAG9D,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAGxE,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,aAAa,GACpD,aAAa,GACb,CAAC,SAAS,gBAAgB,GAC1B,gBAAgB,GAChB,CAAC,SAAS,YAAY,GACtB,YAAY,GACZ,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateAndTime.js","names":["Calendar","DateField","DatePicker","DateRangePicker","RangeCalendar","TimeField"],"sources":["../../src/spectrum/dateAndTime.ts"],"sourcesContent":["import {\n CalendarDate,\n CalendarDateTime,\n ZonedDateTime,\n} from '@internationalized/date';\n\nexport {\n Calendar,\n type SpectrumCalendarProps as CalendarProps,\n DateField,\n type SpectrumDateFieldProps as DateFieldProps,\n DatePicker,\n type SpectrumDatePickerProps as DatePickerProps,\n DateRangePicker,\n type SpectrumDateRangePickerProps as DateRangePickerProps,\n RangeCalendar,\n type SpectrumRangeCalendarProps as RangeCalendarProps,\n TimeField,\n type SpectrumTimeFieldProps as TimeFieldProps,\n} from '@adobe/react-spectrum';\n\nexport type { CalendarDate, CalendarDateTime, ZonedDateTime };\n\n// This is the type for the DatePicker value\nexport type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;\n\n// This is the type for DatePicker onChange\nexport type MappedDateValue<T> = T extends ZonedDateTime\n ? ZonedDateTime\n : T extends CalendarDateTime\n ? CalendarDateTime\n : T extends CalendarDate\n ? CalendarDate\n : never;\n"],"mappings":"AAMA,SACEA,QAAQ,EAERC,SAAS,EAETC,UAAU,EAEVC,eAAe,EAEfC,aAAa,EAEbC,SAAS,QAEJ,uBAAuB;;AAI9B;;AAGA"}
|
|
1
|
+
{"version":3,"file":"dateAndTime.js","names":["Calendar","DateField","DatePicker","DateRangePicker","RangeCalendar","TimeField"],"sources":["../../src/spectrum/dateAndTime.ts"],"sourcesContent":["import {\n type CalendarDate,\n type CalendarDateTime,\n type ZonedDateTime,\n} from '@internationalized/date';\n\nexport {\n Calendar,\n type SpectrumCalendarProps as CalendarProps,\n DateField,\n type SpectrumDateFieldProps as DateFieldProps,\n DatePicker,\n type SpectrumDatePickerProps as DatePickerProps,\n DateRangePicker,\n type SpectrumDateRangePickerProps as DateRangePickerProps,\n RangeCalendar,\n type SpectrumRangeCalendarProps as RangeCalendarProps,\n TimeField,\n type SpectrumTimeFieldProps as TimeFieldProps,\n} from '@adobe/react-spectrum';\n\nexport type { CalendarDate, CalendarDateTime, ZonedDateTime };\n\n// This is the type for the DatePicker value\nexport type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;\n\n// This is the type for DatePicker onChange\nexport type MappedDateValue<T> = T extends ZonedDateTime\n ? ZonedDateTime\n : T extends CalendarDateTime\n ? CalendarDateTime\n : T extends CalendarDate\n ? CalendarDate\n : never;\n"],"mappings":"AAMA,SACEA,QAAQ,EAERC,SAAS,EAETC,UAAU,EAEVC,eAAe,EAEfC,aAAa,EAEbC,SAAS,QAEJ,uBAAuB;;AAI9B;;AAGA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SpectrumListViewProps } from '@adobe/react-spectrum';
|
|
2
|
-
import { MultipleItemSelectionProps, NormalizedItem, TooltipOptions } from '../utils';
|
|
3
|
-
import { ItemElementOrPrimitive } from '../shared';
|
|
1
|
+
import { type SpectrumListViewProps } from '@adobe/react-spectrum';
|
|
2
|
+
import { type MultipleItemSelectionProps, type NormalizedItem, type TooltipOptions } from '../utils';
|
|
3
|
+
import { type ItemElementOrPrimitive } from '../shared';
|
|
4
4
|
export type ListViewProps = MultipleItemSelectionProps & {
|
|
5
5
|
children: ItemElementOrPrimitive | ItemElementOrPrimitive[];
|
|
6
6
|
/** Can be set to true or a TooltipOptions to enable item tooltips */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListView.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListView.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EAEnB,KAAK,cAAc,EAEpB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,0BAA0B,GAAG;IACvD,QAAQ,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAC;IAC5D,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAEnC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC,GAAG,IAAI,CACJ,qBAAqB,CAAC,cAAc,CAAC,EACnC,UAAU,GACV,OAAO,GACP,cAAc,GACd,qBAAqB,GACrB,cAAc,GACd,mBAAmB,CACtB,CAAC;AAEJ,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,OAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,QAAyB,EACzB,iBAAiB,EACjB,GAAG,qBAAqB,EACzB,EAAE,aAAa,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CA+BpC;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.js","names":["useMemo","cl","EMPTY_FUNCTION","normalizeTooltipOptions","wrapItemChildren","ListViewWrapper","jsx","_jsx","ListView","_ref","children","tooltip","selectedKeys","defaultSelectedKeys","disabledKeys","UNSAFE_className","onChange","onScroll","onSelectionChange","spectrumListViewProps","_objectWithoutProperties","_excluded","tooltipOptions","wrappedItems","_objectSpread"],"sources":["../../../src/spectrum/listView/ListView.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { SpectrumListViewProps } from '@adobe/react-spectrum';\nimport cl from 'classnames';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport {\n MultipleItemSelectionProps,\n NormalizedItem,\n normalizeTooltipOptions,\n TooltipOptions,\n wrapItemChildren,\n} from '../utils';\nimport { ListViewWrapper, ListViewWrapperProps } from './ListViewWrapper';\nimport { ItemElementOrPrimitive } from '../shared';\n\nexport type ListViewProps = MultipleItemSelectionProps & {\n children: ItemElementOrPrimitive | ItemElementOrPrimitive[];\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n} & Omit<\n SpectrumListViewProps<NormalizedItem>,\n | 'children'\n | 'items'\n | 'selectedKeys'\n | 'defaultSelectedKeys'\n | 'disabledKeys'\n | 'onSelectionChange'\n >;\n\nexport function ListView({\n children,\n tooltip = true,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n UNSAFE_className,\n onChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n ...spectrumListViewProps\n}: ListViewProps): JSX.Element | null {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip, 'bottom'),\n [tooltip]\n );\n\n const wrappedItems = useMemo(\n () => wrapItemChildren(children, tooltipOptions),\n [children, tooltipOptions]\n );\n\n return (\n <ListViewWrapper\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumListViewProps}\n UNSAFE_className={cl('dh-list-view', UNSAFE_className)}\n selectedKeys={\n selectedKeys as ListViewWrapperProps<unknown>['selectedKeys']\n }\n defaultSelectedKeys={\n defaultSelectedKeys as ListViewWrapperProps<unknown>['defaultSelectedKeys']\n }\n disabledKeys={\n disabledKeys as ListViewWrapperProps<unknown>['disabledKeys']\n }\n onScroll={onScroll}\n onSelectionChange={onChange ?? onSelectionChange}\n >\n {wrappedItems}\n </ListViewWrapper>\n );\n}\n\nexport default ListView;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,OAAOC,EAAE,MAAM,YAAY;AAC3B,SAASC,cAAc,QAAQ,kBAAkB;AAAC,SAIhDC,uBAAuB,EAEvBC,gBAAgB;AAAA,SAETC,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAoBxB,OAAO,SAASC,QAAQA,CAAAC,IAAA,EAWc;EAAA,IAXb;MACvBC,QAAQ;MACRC,OAAO,GAAG,IAAI;MACdC,YAAY;MACZC,mBAAmB;MACnBC,YAAY;MACZC,gBAAgB;MAChBC,QAAQ;MACRC,QAAQ,GAAGf,cAAc;MACzBgB;IAEa,CAAC,GAAAT,IAAA;IADXU,qBAAqB,GAAAC,wBAAA,CAAAX,IAAA,EAAAY,SAAA;EAExB,IAAMC,cAAc,GAAGtB,OAAO,CAC5B,MAAMG,uBAAuB,CAACQ,OAAO,EAAE,QAAQ,CAAC,EAChD,CAACA,OAAO,CACV,CAAC;EAED,IAAMY,YAAY,GAAGvB,OAAO,CAC1B,MAAMI,gBAAgB,CAACM,QAAQ,EAAEY,cAAc,CAAC,EAChD,CAACZ,QAAQ,EAAEY,cAAc,CAC3B,CAAC;EAED,oBACEf,IAAA,CAACF;EACC;EAAA,EAAAmB,aAAA,CAAAA,aAAA,KACIL,qBAAqB;IACzBJ,gBAAgB,EAAEd,EAAE,CAAC,cAAc,EAAEc,gBAAgB,CAAE;IACvDH,YAAY,EACVA,YACD;IACDC,mBAAmB,EACjBA,mBACD;IACDC,YAAY,EACVA,YACD;IACDG,QAAQ,EAAEA,QAAS;IACnBC,iBAAiB,EAAEF,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIE,iBAAkB;IAAAR,QAAA,EAEhDa;EAAY,EACE,CAAC;AAEtB;AAEA,eAAef,QAAQ"}
|
|
1
|
+
{"version":3,"file":"ListView.js","names":["useMemo","cl","EMPTY_FUNCTION","normalizeTooltipOptions","wrapItemChildren","ListViewWrapper","jsx","_jsx","ListView","_ref","children","tooltip","selectedKeys","defaultSelectedKeys","disabledKeys","UNSAFE_className","onChange","onScroll","onSelectionChange","spectrumListViewProps","_objectWithoutProperties","_excluded","tooltipOptions","wrappedItems","_objectSpread"],"sources":["../../../src/spectrum/listView/ListView.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { type SpectrumListViewProps } from '@adobe/react-spectrum';\nimport cl from 'classnames';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport {\n type MultipleItemSelectionProps,\n type NormalizedItem,\n normalizeTooltipOptions,\n type TooltipOptions,\n wrapItemChildren,\n} from '../utils';\nimport { ListViewWrapper, type ListViewWrapperProps } from './ListViewWrapper';\nimport { type ItemElementOrPrimitive } from '../shared';\n\nexport type ListViewProps = MultipleItemSelectionProps & {\n children: ItemElementOrPrimitive | ItemElementOrPrimitive[];\n /** Can be set to true or a TooltipOptions to enable item tooltips */\n tooltip?: boolean | TooltipOptions;\n\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n} & Omit<\n SpectrumListViewProps<NormalizedItem>,\n | 'children'\n | 'items'\n | 'selectedKeys'\n | 'defaultSelectedKeys'\n | 'disabledKeys'\n | 'onSelectionChange'\n >;\n\nexport function ListView({\n children,\n tooltip = true,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n UNSAFE_className,\n onChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n ...spectrumListViewProps\n}: ListViewProps): JSX.Element | null {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip, 'bottom'),\n [tooltip]\n );\n\n const wrappedItems = useMemo(\n () => wrapItemChildren(children, tooltipOptions),\n [children, tooltipOptions]\n );\n\n return (\n <ListViewWrapper\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...spectrumListViewProps}\n UNSAFE_className={cl('dh-list-view', UNSAFE_className)}\n selectedKeys={\n selectedKeys as ListViewWrapperProps<unknown>['selectedKeys']\n }\n defaultSelectedKeys={\n defaultSelectedKeys as ListViewWrapperProps<unknown>['defaultSelectedKeys']\n }\n disabledKeys={\n disabledKeys as ListViewWrapperProps<unknown>['disabledKeys']\n }\n onScroll={onScroll}\n onSelectionChange={onChange ?? onSelectionChange}\n >\n {wrappedItems}\n </ListViewWrapper>\n );\n}\n\nexport default ListView;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,OAAOC,EAAE,MAAM,YAAY;AAC3B,SAASC,cAAc,QAAQ,kBAAkB;AAAC,SAIhDC,uBAAuB,EAEvBC,gBAAgB;AAAA,SAETC,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAoBxB,OAAO,SAASC,QAAQA,CAAAC,IAAA,EAWc;EAAA,IAXb;MACvBC,QAAQ;MACRC,OAAO,GAAG,IAAI;MACdC,YAAY;MACZC,mBAAmB;MACnBC,YAAY;MACZC,gBAAgB;MAChBC,QAAQ;MACRC,QAAQ,GAAGf,cAAc;MACzBgB;IAEa,CAAC,GAAAT,IAAA;IADXU,qBAAqB,GAAAC,wBAAA,CAAAX,IAAA,EAAAY,SAAA;EAExB,IAAMC,cAAc,GAAGtB,OAAO,CAC5B,MAAMG,uBAAuB,CAACQ,OAAO,EAAE,QAAQ,CAAC,EAChD,CAACA,OAAO,CACV,CAAC;EAED,IAAMY,YAAY,GAAGvB,OAAO,CAC1B,MAAMI,gBAAgB,CAACM,QAAQ,EAAEY,cAAc,CAAC,EAChD,CAACZ,QAAQ,EAAEY,cAAc,CAC3B,CAAC;EAED,oBACEf,IAAA,CAACF;EACC;EAAA,EAAAmB,aAAA,CAAAA,aAAA,KACIL,qBAAqB;IACzBJ,gBAAgB,EAAEd,EAAE,CAAC,cAAc,EAAEc,gBAAgB,CAAE;IACvDH,YAAY,EACVA,YACD;IACDC,mBAAmB,EACjBA,mBACD;IACDC,YAAY,EACVA,YACD;IACDG,QAAQ,EAAEA,QAAS;IACnBC,iBAAiB,EAAEF,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIE,iBAAkB;IAAAR,QAAA,EAEhDa;EAAY,EACE,CAAC;AAEtB;AAEA,eAAef,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListActions, NormalizedItem } from '../utils';
|
|
1
|
+
import { type ListActions, type NormalizedItem } from '../utils';
|
|
2
2
|
import type { ListViewProps } from './ListView';
|
|
3
3
|
export interface ListViewNormalizedProps extends Omit<ListViewProps, 'children'> {
|
|
4
4
|
normalizedItems: NormalizedItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListViewNormalized.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListViewNormalized.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"ListViewNormalized.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListViewNormalized.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,cAAc,EAIpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,MAAM,WAAW,uBACf,SAAQ,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC;IACvC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,eAAe,EACf,OAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CAmDvC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListViewNormalized.js","names":["useMemo","cl","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedMultiSelection","ListViewWrapper","createElement","_createElement","ListViewNormalized","_ref","normalizedItems","tooltip","selectedKeys","defaultSelectedKeys","disabledKeys","showItemIcons","actions","UNSAFE_className","onChange","onSelectionChange","props","_objectWithoutProperties","_excluded","tooltipOptions","renderNormalizedItem","itemIconSlot","showItemDescriptions","forceRerenderKey","concat","placement","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","_objectSpread","key","items"],"sources":["../../../src/spectrum/listView/ListViewNormalized.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport cl from 'classnames';\nimport {\n ListActions,\n NormalizedItem,\n normalizeTooltipOptions,\n useRenderNormalizedItem,\n useStringifiedMultiSelection,\n} from '../utils';\nimport type { ListViewProps } from './ListView';\nimport { ListViewWrapper } from './ListViewWrapper';\n\nexport interface ListViewNormalizedProps\n extends Omit<ListViewProps, 'children'> {\n normalizedItems: NormalizedItem[];\n showItemIcons: boolean;\n actions?: ListActions<unknown>;\n}\n\n/**\n * ListView supporting normalized item data. This component mostly exists to\n * decouple some of the logic needed to support table data. Specifically it\n * handles item rendering configurations as well as converting selection keys\n * to / from strings. This makes it easier to test logic in isolation without\n * a dependency on JS apis (e.g. in the Styleguide).\n *\n * Note that This component will usually not be used directly. Instead, it is\n * recommended to use\n * - `@deephaven/components`'s `ListView` for non-table data sources\n * - `@deephaven/jsapi-components`'s `ListView` for table data sources\n */\nexport function ListViewNormalized({\n normalizedItems,\n tooltip = true,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n showItemIcons,\n actions,\n UNSAFE_className,\n onChange,\n onSelectionChange,\n ...props\n}: ListViewNormalizedProps): JSX.Element {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip, 'bottom'),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem({\n itemIconSlot: 'illustration',\n // Descriptions introduce variable item heights which throws off setting\n // viewport on windowed data. For now not going to implement description\n // support in Picker.\n // https://github.com/deephaven/web-client-ui/issues/1958\n showItemDescriptions: false,\n showItemIcons,\n tooltipOptions,\n actions,\n });\n\n // Spectrum doesn't re-render if only the `renderNormalizedItems` function\n // changes, so we create a key from its dependencies that can be used to force\n // re-render.\n const forceRerenderKey = `${showItemIcons}-${tooltipOptions?.placement}`;\n\n const {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedMultiSelection({\n normalizedItems,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n return (\n <ListViewWrapper\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n UNSAFE_className={cl('dh-list-view-normalized', UNSAFE_className)}\n key={forceRerenderKey}\n items={normalizedItems}\n selectedKeys={selectedStringKeys}\n defaultSelectedKeys={defaultSelectedStringKeys}\n disabledKeys={disabledStringKeys}\n onSelectionChange={onStringSelectionChange}\n >\n {renderNormalizedItem}\n </ListViewWrapper>\n );\n}\n\nexport default ListViewNormalized;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,OAAOC,EAAE,MAAM,YAAY;AAAC,SAI1BC,uBAAuB,EACvBC,uBAAuB,EACvBC,4BAA4B;AAAA,SAGrBC,eAAe;AAAA,SAAAC,aAAA,IAAAC,cAAA;AASxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAAC,IAAA,EAYO;EAAA,IAZN;MACjCC,eAAe;MACfC,OAAO,GAAG,IAAI;MACdC,YAAY;MACZC,mBAAmB;MACnBC,YAAY;MACZC,aAAa;MACbC,OAAO;MACPC,gBAAgB;MAChBC,QAAQ;MACRC;IAEuB,CAAC,GAAAV,IAAA;IADrBW,KAAK,GAAAC,wBAAA,CAAAZ,IAAA,EAAAa,SAAA;EAER,IAAMC,cAAc,GAAGvB,OAAO,CAC5B,MAAME,uBAAuB,CAACS,OAAO,EAAE,QAAQ,CAAC,EAChD,CAACA,OAAO,CACV,CAAC;EAED,IAAMa,oBAAoB,GAAGrB,uBAAuB,CAAC;IACnDsB,YAAY,EAAE,cAAc;IAC5B;IACA;IACA;IACA;IACAC,oBAAoB,EAAE,KAAK;IAC3BX,aAAa;IACbQ,cAAc;IACdP;EACF,CAAC,CAAC;;EAEF;EACA;EACA;EACA,IAAMW,gBAAgB,MAAAC,MAAA,CAAMb,aAAa,OAAAa,MAAA,CAAIL,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEM,SAAS,CAAE;EAExE,IAAM;IACJC,kBAAkB;IAClBC,yBAAyB;IACzBC,kBAAkB;IAClBC;EACF,CAAC,GAAG7B,4BAA4B,CAAC;IAC/BM,eAAe;IACfE,YAAY;IACZC,mBAAmB;IACnBC,YAAY;IACZI,QAAQ,EAAEA,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIC;EACxB,CAAC,CAAC;EAEF,oBACEZ,cAAA,CAACF;EACC;EAAA,EAAA6B,aAAA,CAAAA,aAAA,KACId,KAAK;IACTH,gBAAgB,EAAEhB,EAAE,CAAC,yBAAyB,EAAEgB,gBAAgB,CAAE;IAClEkB,GAAG,EAAER,gBAAiB;IACtBS,KAAK,EAAE1B,eAAgB;IACvBE,YAAY,EAAEkB,kBAAmB;IACjCjB,mBAAmB,EAAEkB,yBAA0B;IAC/CjB,YAAY,EAAEkB,kBAAmB;IACjCb,iBAAiB,EAAEc;EAAwB,IAE1CT,oBACc,CAAC;AAEtB;AAEA,eAAehB,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"ListViewNormalized.js","names":["useMemo","cl","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedMultiSelection","ListViewWrapper","createElement","_createElement","ListViewNormalized","_ref","normalizedItems","tooltip","selectedKeys","defaultSelectedKeys","disabledKeys","showItemIcons","actions","UNSAFE_className","onChange","onSelectionChange","props","_objectWithoutProperties","_excluded","tooltipOptions","renderNormalizedItem","itemIconSlot","showItemDescriptions","forceRerenderKey","concat","placement","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","_objectSpread","key","items"],"sources":["../../../src/spectrum/listView/ListViewNormalized.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport cl from 'classnames';\nimport {\n type ListActions,\n type NormalizedItem,\n normalizeTooltipOptions,\n useRenderNormalizedItem,\n useStringifiedMultiSelection,\n} from '../utils';\nimport type { ListViewProps } from './ListView';\nimport { ListViewWrapper } from './ListViewWrapper';\n\nexport interface ListViewNormalizedProps\n extends Omit<ListViewProps, 'children'> {\n normalizedItems: NormalizedItem[];\n showItemIcons: boolean;\n actions?: ListActions<unknown>;\n}\n\n/**\n * ListView supporting normalized item data. This component mostly exists to\n * decouple some of the logic needed to support table data. Specifically it\n * handles item rendering configurations as well as converting selection keys\n * to / from strings. This makes it easier to test logic in isolation without\n * a dependency on JS apis (e.g. in the Styleguide).\n *\n * Note that This component will usually not be used directly. Instead, it is\n * recommended to use\n * - `@deephaven/components`'s `ListView` for non-table data sources\n * - `@deephaven/jsapi-components`'s `ListView` for table data sources\n */\nexport function ListViewNormalized({\n normalizedItems,\n tooltip = true,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n showItemIcons,\n actions,\n UNSAFE_className,\n onChange,\n onSelectionChange,\n ...props\n}: ListViewNormalizedProps): JSX.Element {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip, 'bottom'),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem({\n itemIconSlot: 'illustration',\n // Descriptions introduce variable item heights which throws off setting\n // viewport on windowed data. For now not going to implement description\n // support in Picker.\n // https://github.com/deephaven/web-client-ui/issues/1958\n showItemDescriptions: false,\n showItemIcons,\n tooltipOptions,\n actions,\n });\n\n // Spectrum doesn't re-render if only the `renderNormalizedItems` function\n // changes, so we create a key from its dependencies that can be used to force\n // re-render.\n const forceRerenderKey = `${showItemIcons}-${tooltipOptions?.placement}`;\n\n const {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedMultiSelection({\n normalizedItems,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n return (\n <ListViewWrapper\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n UNSAFE_className={cl('dh-list-view-normalized', UNSAFE_className)}\n key={forceRerenderKey}\n items={normalizedItems}\n selectedKeys={selectedStringKeys}\n defaultSelectedKeys={defaultSelectedStringKeys}\n disabledKeys={disabledStringKeys}\n onSelectionChange={onStringSelectionChange}\n >\n {renderNormalizedItem}\n </ListViewWrapper>\n );\n}\n\nexport default ListViewNormalized;\n"],"mappings":";;;;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,OAAOC,EAAE,MAAM,YAAY;A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E;IAClEkB,GAAG,EAAER,gBAAiB;IACtBS,KAAK,EAAE1B,eAAgB;IACvBE,YAAY,EAAEkB,kBAAmB;IACjCjB,mBAAmB,EAAEkB,yBAA0B;IAC/CjB,YAAY,EAAEkB,kBAAmB;IACjCb,iBAAiB,EAAEc;EAAwB,IAE1CT,oBACc,CAAC;AAEtB;AAEA,eAAehB,kBAAkB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SpectrumListViewProps } from '@adobe/react-spectrum';
|
|
1
|
+
import { type SpectrumListViewProps } from '@adobe/react-spectrum';
|
|
2
2
|
import './ListViewWrapper.scss';
|
|
3
3
|
export interface ListViewWrapperProps<T> extends SpectrumListViewProps<T> {
|
|
4
4
|
/** Handler that is called when the picker is scrolled. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListViewWrapper.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListViewWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,
|
|
1
|
+
{"version":3,"file":"ListViewWrapper.d.ts","sourceRoot":"","sources":["../../../src/spectrum/listView/ListViewWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAW/B,OAAO,wBAAwB,CAAC;AAEhC,MAAM,WAAW,oBAAoB,CAAC,CAAC,CAAE,SAAQ,qBAAqB,CAAC,CAAC,CAAC;IACvE,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC7B,GAAG,CAAC,OAAO,CAoDb;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListViewWrapper.js","names":["ListView","SpectrumListView","extractSpectrumHTMLElement","useContentRect","useOnScrollRef","EMPTY_FUNCTION","cl","useSpectrumThemeProvider","Flex","separateSpectrumProps","jsx","_jsx","ListViewWrapper","props","_styleProps$minHeight","_listViewProps$densit","ariaLabelProps","componentProps","styleProps","onScroll","listViewProps","_objectWithoutProperties","_excluded","scale","scrollRef","ref","contentRectRef","contentRect","_objectSpread","direction","minHeight","UNSAFE_className","concat","density","children","height"],"sources":["../../../src/spectrum/listView/ListViewWrapper.tsx"],"sourcesContent":["import {\n ListView as SpectrumListView,\n SpectrumListViewProps,\n} from '@adobe/react-spectrum';\nimport {\n extractSpectrumHTMLElement,\n useContentRect,\n useOnScrollRef,\n} from '@deephaven/react-hooks';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport cl from 'classnames';\nimport { useSpectrumThemeProvider } from '../../theme';\nimport { Flex } from '../layout';\nimport { separateSpectrumProps } from '../utils';\nimport './ListViewWrapper.scss';\n\nexport interface ListViewWrapperProps<T> extends SpectrumListViewProps<T> {\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n}\n\n/**\n * Helper component to wrap a ListView with the appropriate styling + scroll\n * handling. This is used by both the `@deephaven/components` `ListView` and\n * the `@deephaven/jsapi-components` `ListView` (via `ListViewNormalized`) to\n * ensure consistency.\n *\n * Note that This component will usually not be used directly. Instead, it is\n * recommended to use\n * - `@deephaven/components`'s `ListView` for non-table data sources\n * - `@deephaven/jsapi-components`'s `ListView` for table data sources\n */\nexport function ListViewWrapper<T>(\n props: ListViewWrapperProps<T>\n): JSX.Element {\n const { ariaLabelProps, componentProps, styleProps } =\n separateSpectrumProps(props);\n\n const { onScroll = EMPTY_FUNCTION, ...listViewProps } = componentProps;\n\n const { scale } = useSpectrumThemeProvider();\n\n const scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);\n\n // Spectrum ListView crashes when it has zero height. Track the contentRect\n // of the parent container and only render the ListView when it has a non-zero\n // height. See https://github.com/adobe/react-spectrum/issues/6213\n const { ref: contentRectRef, contentRect } = useContentRect(\n extractSpectrumHTMLElement<HTMLDivElement>\n );\n\n return (\n <Flex\n direction=\"column\"\n ref={contentRectRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...styleProps}\n // Set min-height to 1px so that `ListView` is rendered whenever container\n // is visible. This prevents the height from shrinking to zero as a result\n // of a parent grid or flex container calculating content sizes. The\n // container height can still be zero when it is not being displayed such\n // as when one of its parents have `display: none`.\n minHeight={styleProps.minHeight ?? 1}\n UNSAFE_className={cl(\n 'dh-list-view-wrapper',\n `dh-list-view-wrapper-density-${listViewProps.density ?? 'regular'}`,\n `dh-list-view-wrapper-scale-${scale}`,\n styleProps.UNSAFE_className\n )}\n >\n {/**\n * Only render ListView if parent is visible. Some time in the future we\n * should consider using `checkVisibility()` once it has better browser\n * support.\n */}\n {contentRect.height === 0 ? null : (\n <SpectrumListView\n ref={scrollRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...ariaLabelProps}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...listViewProps}\n />\n )}\n </Flex>\n );\n}\n\nexport default ListViewWrapper;\n"],"mappings":";;;;;;;;AAAA,SACEA,QAAQ,IAAIC,gBAAgB,QAEvB,uBAAuB;AAC9B,SACEC,0BAA0B,EAC1BC,cAAc,EACdC,cAAc,QACT,wBAAwB;AAC/B,SAASC,cAAc,QAAQ,kBAAkB;AACjD,OAAOC,EAAE,MAAM,YAAY;AAAC,SACnBC,wBAAwB;AAAA,SACxBC,IAAI;AAAA,SACJC,qBAAqB;AAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAQ9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,KAA8B,EACjB;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EACb,IAAM;IAAEC,cAAc;IAAEC,cAAc;IAAEC;EAAW,CAAC,GAClDT,qBAAqB,CAACI,KAAK,CAAC;EAE9B,IAAM;MAAEM,QAAQ,GAAGd;IAAiC,CAAC,GAAGY,cAAc;IAAhCG,aAAa,GAAAC,wBAAA,CAAKJ,cAAc,EAAAK,SAAA;EAEtE,IAAM;IAAEC;EAAM,CAAC,GAAGhB,wBAAwB,CAAC,CAAC;EAE5C,IAAMiB,SAAS,GAAGpB,cAAc,CAACe,QAAQ,EAAEjB,0BAA0B,CAAC;;EAEtE;EACA;EACA;EACA,IAAM;IAAEuB,GAAG,EAAEC,cAAc;IAAEC;EAAY,CAAC,GAAGxB,cAAc,CACzDD,0BACF,CAAC;EAED,oBACES,IAAA,CAACH,IAAI,EAAAoB,aAAA,CAAAA,aAAA;IACHC,SAAS,EAAC,QAAQ;IAClBJ,GAAG,EAAEC;IACL;EAAA,GACIR,UAAU;IACd;IACA;IACA;IACA;IACA;IACAY,SAAS,GAAAhB,qBAAA,GAAEI,UAAU,CAACY,SAAS,cAAAhB,qBAAA,cAAAA,qBAAA,GAAI,CAAE;IACrCiB,gBAAgB,EAAEzB,EAAE,CAClB,sBAAsB,kCAAA0B,MAAA,EAAAjB,qBAAA,GACUK,aAAa,CAACa,OAAO,cAAAlB,qBAAA,cAAAA,qBAAA,GAAI,SAAS,iCAAAiB,MAAA,CACpCT,KAAK,GACnCL,UAAU,CAACa,gBACb,CAAE;IAAAG,QAAA,EAODP,WAAW,CAACQ,MAAM,KAAK,CAAC,GAAG,IAAI,gBAC9BxB,IAAA,CAACV,gBAAgB,EAAA2B,aAAA,CAAAA,aAAA;MACfH,GAAG,EAAED;MACL;IAAA,GACIR,cAAc,GAEdI,aAAa,CAClB;EACF,EACG,CAAC;AAEX;AAEA,eAAeR,eAAe"}
|
|
1
|
+
{"version":3,"file":"ListViewWrapper.js","names":["ListView","SpectrumListView","extractSpectrumHTMLElement","useContentRect","useOnScrollRef","EMPTY_FUNCTION","cl","useSpectrumThemeProvider","Flex","separateSpectrumProps","jsx","_jsx","ListViewWrapper","props","_styleProps$minHeight","_listViewProps$densit","ariaLabelProps","componentProps","styleProps","onScroll","listViewProps","_objectWithoutProperties","_excluded","scale","scrollRef","ref","contentRectRef","contentRect","_objectSpread","direction","minHeight","UNSAFE_className","concat","density","children","height"],"sources":["../../../src/spectrum/listView/ListViewWrapper.tsx"],"sourcesContent":["import {\n ListView as SpectrumListView,\n type SpectrumListViewProps,\n} from '@adobe/react-spectrum';\nimport {\n extractSpectrumHTMLElement,\n useContentRect,\n useOnScrollRef,\n} from '@deephaven/react-hooks';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport cl from 'classnames';\nimport { useSpectrumThemeProvider } from '../../theme';\nimport { Flex } from '../layout';\nimport { separateSpectrumProps } from '../utils';\nimport './ListViewWrapper.scss';\n\nexport interface ListViewWrapperProps<T> extends SpectrumListViewProps<T> {\n /** Handler that is called when the picker is scrolled. */\n onScroll?: (event: Event) => void;\n}\n\n/**\n * Helper component to wrap a ListView with the appropriate styling + scroll\n * handling. This is used by both the `@deephaven/components` `ListView` and\n * the `@deephaven/jsapi-components` `ListView` (via `ListViewNormalized`) to\n * ensure consistency.\n *\n * Note that This component will usually not be used directly. Instead, it is\n * recommended to use\n * - `@deephaven/components`'s `ListView` for non-table data sources\n * - `@deephaven/jsapi-components`'s `ListView` for table data sources\n */\nexport function ListViewWrapper<T>(\n props: ListViewWrapperProps<T>\n): JSX.Element {\n const { ariaLabelProps, componentProps, styleProps } =\n separateSpectrumProps(props);\n\n const { onScroll = EMPTY_FUNCTION, ...listViewProps } = componentProps;\n\n const { scale } = useSpectrumThemeProvider();\n\n const scrollRef = useOnScrollRef(onScroll, extractSpectrumHTMLElement);\n\n // Spectrum ListView crashes when it has zero height. Track the contentRect\n // of the parent container and only render the ListView when it has a non-zero\n // height. See https://github.com/adobe/react-spectrum/issues/6213\n const { ref: contentRectRef, contentRect } = useContentRect(\n extractSpectrumHTMLElement<HTMLDivElement>\n );\n\n return (\n <Flex\n direction=\"column\"\n ref={contentRectRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...styleProps}\n // Set min-height to 1px so that `ListView` is rendered whenever container\n // is visible. This prevents the height from shrinking to zero as a result\n // of a parent grid or flex container calculating content sizes. The\n // container height can still be zero when it is not being displayed such\n // as when one of its parents have `display: none`.\n minHeight={styleProps.minHeight ?? 1}\n UNSAFE_className={cl(\n 'dh-list-view-wrapper',\n `dh-list-view-wrapper-density-${listViewProps.density ?? 'regular'}`,\n `dh-list-view-wrapper-scale-${scale}`,\n styleProps.UNSAFE_className\n )}\n >\n {/**\n * Only render ListView if parent is visible. Some time in the future we\n * should consider using `checkVisibility()` once it has better browser\n * support.\n */}\n {contentRect.height === 0 ? null : (\n <SpectrumListView\n ref={scrollRef}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...ariaLabelProps}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...listViewProps}\n />\n )}\n </Flex>\n );\n}\n\nexport default ListViewWrapper;\n"],"mappings":";;;;;;;;AAAA,SACEA,QAAQ,IAAIC,gBAAgB,QAEvB,uBAAuB;AAC9B,SACEC,0BAA0B,EAC1BC,cAAc,EACdC,cAAc,QACT,wBAAwB;AAC/B,SAASC,cAAc,QAAQ,kBAAkB;AACjD,OAAOC,EAAE,MAAM,YAAY;AAAC,SACnBC,wBAAwB;AAAA,SACxBC,IAAI;AAAA,SACJC,qBAAqB;AAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAQ9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,KAA8B,EACjB;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EACb,IAAM;IAAEC,cAAc;IAAEC,cAAc;IAAEC;EAAW,CAAC,GAClDT,qBAAqB,CAACI,KAAK,CAAC;EAE9B,IAAM;MAAEM,QAAQ,GAAGd;IAAiC,CAAC,GAAGY,cAAc;IAAhCG,aAAa,GAAAC,wBAAA,CAAKJ,cAAc,EAAAK,SAAA;EAEtE,IAAM;IAAEC;EAAM,CAAC,GAAGhB,wBAAwB,CAAC,CAAC;EAE5C,IAAMiB,SAAS,GAAGpB,cAAc,CAACe,QAAQ,EAAEjB,0BAA0B,CAAC;;EAEtE;EACA;EACA;EACA,IAAM;IAAEuB,GAAG,EAAEC,cAAc;IAAEC;EAAY,CAAC,GAAGxB,cAAc,CACzDD,0BACF,CAAC;EAED,oBACES,IAAA,CAACH,IAAI,EAAAoB,aAAA,CAAAA,aAAA;IACHC,SAAS,EAAC,QAAQ;IAClBJ,GAAG,EAAEC;IACL;EAAA,GACIR,UAAU;IACd;IACA;IACA;IACA;IACA;IACAY,SAAS,GAAAhB,qBAAA,GAAEI,UAAU,CAACY,SAAS,cAAAhB,qBAAA,cAAAA,qBAAA,GAAI,CAAE;IACrCiB,gBAAgB,EAAEzB,EAAE,CAClB,sBAAsB,kCAAA0B,MAAA,EAAAjB,qBAAA,GACUK,aAAa,CAACa,OAAO,cAAAlB,qBAAA,cAAAA,qBAAA,GAAI,SAAS,iCAAAiB,MAAA,CACpCT,KAAK,GACnCL,UAAU,CAACa,gBACb,CAAE;IAAAG,QAAA,EAODP,WAAW,CAACQ,MAAM,KAAK,CAAC,GAAG,IAAI,gBAC9BxB,IAAA,CAACV,gBAAgB,EAAA2B,aAAA,CAAAA,aAAA;MACfH,GAAG,EAAED;MACL;IAAA,GACIR,cAAc,GAEdI,aAAa,CAClB;EACF,EACG,CAAC;AAEX;AAEA,eAAeR,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/Picker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/Picker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C;;;;;;GAMG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;mFAgCjB,CAAC;AAGH,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.js","names":["Picker","SpectrumPicker","cl","React","useMergeRef","usePickerProps","jsx","_jsx","forwardRef","_ref","ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerProps","defaultSelectedKey","disabledKeys","selectedKey","scrollRef","pickerProps","_excluded2","pickerRef","_objectSpread","displayName"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import {\n Picker as SpectrumPicker,\n SpectrumPickerProps,\n} from '@adobe/react-spectrum';\nimport type { DOMRef } from '@react-types/shared';\nimport cl from 'classnames';\nimport React from 'react';\nimport { useMergeRef } from '@deephaven/react-hooks';\nimport type { NormalizedItem } from '../utils';\nimport type { PickerProps } from './PickerProps';\nimport { usePickerProps } from './usePickerProps';\n\n/**\n * Picker component for selecting items from a list of items. Items can be\n * provided via the `children` prop. Each item can be a string,\tnumber, boolean,\n * or a Spectrum <Item> element. The remaining props are just\tpass through props\n * for the Spectrum Picker component.\n * See https://react-spectrum.adobe.com/react-spectrum/Picker.html\n */\nexport const Picker = React.forwardRef(function Picker(\n { UNSAFE_className, ...props }: PickerProps,\n ref: DOMRef<HTMLDivElement>\n): JSX.Element {\n const {\n defaultSelectedKey,\n disabledKeys,\n selectedKey,\n ref: scrollRef,\n ...pickerProps\n } = usePickerProps(props);\n const pickerRef = useMergeRef(ref, scrollRef);\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...pickerProps}\n ref={pickerRef}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n // Type assertions are necessary here since Spectrum types don't account\n // for number and boolean key values even though they are valid runtime\n // values.\n defaultSelectedKey={\n defaultSelectedKey as SpectrumPickerProps<NormalizedItem>['defaultSelectedKey']\n }\n disabledKeys={\n disabledKeys as SpectrumPickerProps<NormalizedItem>['disabledKeys']\n }\n selectedKey={\n selectedKey as SpectrumPickerProps<NormalizedItem>['selectedKey']\n }\n />\n );\n});\nPicker.displayName = 'Picker';\n\nexport default Picker;\n"],"mappings":";;;;;;;;;AAAA,SACEA,MAAM,IAAIC,cAAc,QAEnB,uBAAuB;AAE9B,OAAOC,EAAE,MAAM,YAAY;AAC3B,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,wBAAwB;AAAC,SAG5CC,cAAc;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AANA,SAAAC,GAAA,IAAAC,IAAA;AAOA,OAAO,IAAMP,MAAM,gBAAGG,KAAK,CAACK,UAAU,CAAC,SAASR,MAAMA,CAAAS,IAAA,EAEpDC,GAA2B,EACd;EAAA,IAFb;MAAEC;IAAwC,CAAC,GAAAF,IAAA;IAApBG,KAAK,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EAG5B,IAAAC,eAAA,GAMIV,cAAc,CAACO,KAAK,CAAC;IANnB;MACJI,kBAAkB;MAClBC,YAAY;MACZC,WAAW;MACXR,GAAG,EAAES;IAEP,CAAC,GAAAJ,eAAA;IADIK,WAAW,GAAAP,wBAAA,CAAAE,eAAA,EAAAM,UAAA;EAEhB,IAAMC,SAAS,GAAGlB,WAAW,CAACM,GAAG,EAAES,SAAS,CAAC;EAC7C,oBACEZ,IAAA,CAACN;EACC;EAAA,EAAAsB,aAAA,CAAAA,aAAA,KACIH,WAAW;IACfV,GAAG,EAAEY,SAAU;IACfX,gBAAgB,EAAET,EAAE,CAAC,WAAW,EAAES,gBAAgB;IAClD;IACA;IACA;IAAA;IACAK,kBAAkB,EAChBA,kBACD;IACDC,YAAY,EACVA,YACD;IACDC,WAAW,EACTA;EACD,EACF,CAAC;AAEN,CAAC,CAAC;AACFlB,MAAM,CAACwB,WAAW,GAAG,QAAQ;AAE7B,eAAexB,MAAM"}
|
|
1
|
+
{"version":3,"file":"Picker.js","names":["Picker","SpectrumPicker","cl","React","useMergeRef","usePickerProps","jsx","_jsx","forwardRef","_ref","ref","UNSAFE_className","props","_objectWithoutProperties","_excluded","_usePickerProps","defaultSelectedKey","disabledKeys","selectedKey","scrollRef","pickerProps","_excluded2","pickerRef","_objectSpread","displayName"],"sources":["../../../src/spectrum/picker/Picker.tsx"],"sourcesContent":["import {\n Picker as SpectrumPicker,\n type SpectrumPickerProps,\n} from '@adobe/react-spectrum';\nimport type { DOMRef } from '@react-types/shared';\nimport cl from 'classnames';\nimport React from 'react';\nimport { useMergeRef } from '@deephaven/react-hooks';\nimport type { NormalizedItem } from '../utils';\nimport type { PickerProps } from './PickerProps';\nimport { usePickerProps } from './usePickerProps';\n\n/**\n * Picker component for selecting items from a list of items. Items can be\n * provided via the `children` prop. Each item can be a string,\tnumber, boolean,\n * or a Spectrum <Item> element. The remaining props are just\tpass through props\n * for the Spectrum Picker component.\n * See https://react-spectrum.adobe.com/react-spectrum/Picker.html\n */\nexport const Picker = React.forwardRef(function Picker(\n { UNSAFE_className, ...props }: PickerProps,\n ref: DOMRef<HTMLDivElement>\n): JSX.Element {\n const {\n defaultSelectedKey,\n disabledKeys,\n selectedKey,\n ref: scrollRef,\n ...pickerProps\n } = usePickerProps(props);\n const pickerRef = useMergeRef(ref, scrollRef);\n return (\n <SpectrumPicker\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...pickerProps}\n ref={pickerRef}\n UNSAFE_className={cl('dh-picker', UNSAFE_className)}\n // Type assertions are necessary here since Spectrum types don't account\n // for number and boolean key values even though they are valid runtime\n // values.\n defaultSelectedKey={\n defaultSelectedKey as SpectrumPickerProps<NormalizedItem>['defaultSelectedKey']\n }\n disabledKeys={\n disabledKeys as SpectrumPickerProps<NormalizedItem>['disabledKeys']\n }\n selectedKey={\n selectedKey as SpectrumPickerProps<NormalizedItem>['selectedKey']\n }\n />\n );\n});\nPicker.displayName = 'Picker';\n\nexport default Picker;\n"],"mappings":";;;;;;;;;AAAA,SACEA,MAAM,IAAIC,cAAc,QAEnB,uBAAuB;AAE9B,OAAOC,EAAE,MAAM,YAAY;AAC3B,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,wBAAwB;AAAC,SAG5CC,cAAc;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AANA,SAAAC,GAAA,IAAAC,IAAA;AAOA,OAAO,IAAMP,MAAM,gBAAGG,KAAK,CAACK,UAAU,CAAC,SAASR,MAAMA,CAAAS,IAAA,EAEpDC,GAA2B,EACd;EAAA,IAFb;MAAEC;IAAwC,CAAC,GAAAF,IAAA;IAApBG,KAAK,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EAG5B,IAAAC,eAAA,GAMIV,cAAc,CAACO,KAAK,CAAC;IANnB;MACJI,kBAAkB;MAClBC,YAAY;MACZC,WAAW;MACXR,GAAG,EAAES;IAEP,CAAC,GAAAJ,eAAA;IADIK,WAAW,GAAAP,wBAAA,CAAAE,eAAA,EAAAM,UAAA;EAEhB,IAAMC,SAAS,GAAGlB,WAAW,CAACM,GAAG,EAAES,SAAS,CAAC;EAC7C,oBACEZ,IAAA,CAACN;EACC;EAAA,EAAAsB,aAAA,CAAAA,aAAA,KACIH,WAAW;IACfV,GAAG,EAAEY,SAAU;IACfX,gBAAgB,EAAET,EAAE,CAAC,WAAW,EAAES,gBAAgB;IAClD;IACA;IACA;IAAA;IACAK,kBAAkB,EAChBA,kBACD;IACDC,YAAY,EACVA,YACD;IACDC,WAAW,EACTA;EACD,EACF,CAAC;AAEN,CAAC,CAAC;AACFlB,MAAM,CAACwB,WAAW,GAAG,QAAQ;AAE7B,eAAexB,MAAM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Key } from 'react';
|
|
1
|
+
import { type Key } from 'react';
|
|
2
2
|
import type { DOMRef } from '@react-types/shared';
|
|
3
|
-
import { NormalizedItem, NormalizedSection } from '../utils';
|
|
4
|
-
import { PickerNormalizedPropsT } from './PickerProps';
|
|
3
|
+
import { type NormalizedItem, type NormalizedSection } from '../utils';
|
|
4
|
+
import { type PickerNormalizedPropsT } from './PickerProps';
|
|
5
5
|
/** Props that are derived by `usePickerNormalizedProps` */
|
|
6
6
|
export type UsePickerNormalizedDerivedProps<THtml extends HTMLElement> = {
|
|
7
7
|
children: (itemOrSection: NormalizedItem | NormalizedSection) => JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePickerNormalizedProps.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerNormalizedProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"usePickerNormalizedProps.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerNormalizedProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAwB,MAAM,OAAO,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAIvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAI5D,2DAA2D;AAC3D,MAAM,MAAM,+BAA+B,CAAC,KAAK,SAAS,WAAW,IAAI;IACvE,QAAQ,EAAE,CAAC,aAAa,EAAE,cAAc,GAAG,iBAAiB,KAAK,GAAG,CAAC,OAAO,CAAC;IAC7E,gBAAgB,EAAE,GAAG,CAAC;IACtB,KAAK,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAC9C,kBAAkB,CAAC,EAAE,GAAG,CAAC;IACzB,YAAY,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACnB,WAAW,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IACzB,iBAAiB,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7C,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mCAAmC,CAAC,MAAM,IAAI,IAAI,CAC5D,sBAAsB,CAAC,MAAM,CAAC,EAC5B,oBAAoB,GACpB,cAAc,GACd,0BAA0B,GAC1B,iBAAiB,GACjB,UAAU,GACV,cAAc,GACd,UAAU,GACV,mBAAmB,GACnB,aAAa,GACb,eAAe,GACf,SAAS,CACZ,CAAC;AAEF,2DAA2D;AAC3D,MAAM,MAAM,wBAAwB,CAClC,MAAM,EACN,KAAK,SAAS,WAAW,IACvB,+BAA+B,CAAC,KAAK,CAAC,GACxC,mCAAmC,CAAC,MAAM,CAAC,CAAC;AAE9C,wBAAgB,wBAAwB,CACtC,MAAM,EACN,KAAK,SAAS,WAAW,GAAG,WAAW,EACvC,EACA,kBAAkB,EAClB,YAAY,EACZ,wBAAwB,EACxB,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,QAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,OAAc,EACd,GAAG,KAAK,EACT,EAAE,sBAAsB,CAAC,MAAM,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC,CA4E1E;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePickerNormalizedProps.js","names":["useCallback","useMemo","EMPTY_FUNCTION","getItemKey","isNormalizedSection","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedSelection","usePickerScrollOnOpen","Section","jsx","_jsx","usePickerNormalizedProps","_ref","defaultSelectedKey","disabledKeys","getInitialScrollPosition","normalizedItems","onChange","onOpenChange","onScroll","onSelectionChange","selectedKey","showItemIcons","tooltip","props","_objectWithoutProperties","_excluded","tooltipOptions","renderNormalizedItem","itemIconSlot","showItemDescriptions","forceRerenderKey","concat","placement","ref","onOpenChangeInternal","selectedStringKey","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","children","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title","item","items","_objectSpread"],"sources":["../../../src/spectrum/picker/usePickerNormalizedProps.tsx"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport type { DOMRef } from '@react-types/shared';\nimport {\n getItemKey,\n isNormalizedSection,\n NormalizedItem,\n NormalizedSection,\n normalizeTooltipOptions,\n useRenderNormalizedItem,\n useStringifiedSelection,\n} from '../utils';\nimport { PickerNormalizedPropsT } from './PickerProps';\nimport { usePickerScrollOnOpen } from './usePickerScrollOnOpen';\nimport { Section } from '../shared';\n\n/** Props that are derived by `usePickerNormalizedProps` */\nexport type UsePickerNormalizedDerivedProps<THtml extends HTMLElement> = {\n children: (itemOrSection: NormalizedItem | NormalizedSection) => JSX.Element;\n forceRerenderKey: Key;\n items: (NormalizedItem | NormalizedSection)[];\n defaultSelectedKey?: Key;\n disabledKeys?: Iterable<Key>;\n ref: DOMRef<THtml>;\n selectedKey?: Key | null;\n onSelectionChange: (key: Key | null) => void;\n onOpenChange: (isOpen: boolean) => void;\n};\n\n/**\n * Props that are passed through untouched. (should exclude all of the\n * destructured props passed into `usePickerNormalizedProps` that are not in the\n * spread ...props)\n */\nexport type UsePickerNormalizedPassthroughProps<TProps> = Omit<\n PickerNormalizedPropsT<TProps>,\n | 'defaultSelectedKey'\n | 'disabledKeys'\n | 'getInitialScrollPosition'\n | 'normalizedItems'\n | 'onChange'\n | 'onOpenChange'\n | 'onScroll'\n | 'onSelectionChange'\n | 'selectedKey'\n | 'showItemIcons'\n | 'tooltip'\n>;\n\n/** Props returned from `usePickerNormalizedProps` hook. */\nexport type UsePickerNormalizedProps<\n TProps,\n THtml extends HTMLElement,\n> = UsePickerNormalizedDerivedProps<THtml> &\n UsePickerNormalizedPassthroughProps<TProps>;\n\nexport function usePickerNormalizedProps<\n TProps,\n THtml extends HTMLElement = HTMLElement,\n>({\n defaultSelectedKey,\n disabledKeys,\n getInitialScrollPosition,\n normalizedItems,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n selectedKey,\n showItemIcons,\n tooltip = true,\n ...props\n}: PickerNormalizedPropsT<TProps>): UsePickerNormalizedProps<TProps, THtml> {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem({\n itemIconSlot: 'icon',\n // Descriptions introduce variable item heights which throws off calculation\n // of initial scroll position and setting viewport on windowed data. For now\n // not going to implement description support in Picker.\n // https://github.com/deephaven/web-client-ui/issues/1958\n showItemDescriptions: false,\n showItemIcons,\n tooltipOptions,\n });\n\n // Spectrum doesn't re-render if only the `renderNormalizedItems` function\n // changes, so we create a key from its dependencies that can be used to force\n // re-render.\n const forceRerenderKey = `${showItemIcons}-${tooltipOptions?.placement}`;\n\n const { ref, onOpenChange: onOpenChangeInternal } =\n usePickerScrollOnOpen<THtml>({\n getInitialScrollPosition,\n onScroll,\n onOpenChange,\n });\n\n // Spectrum Picker treats keys as strings if the `key` prop is explicitly\n // set on `Item` elements. Since we do this in `renderItem`, we need to\n // map original key types to and from strings so that selection works.\n const {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedSelection({\n normalizedItems,\n selectedKey,\n defaultSelectedKey,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n const children = useCallback(\n (itemOrSection: NormalizedItem | NormalizedSection) => {\n if (isNormalizedSection(itemOrSection)) {\n return (\n <Section\n key={getItemKey(itemOrSection)}\n title={itemOrSection.item?.title}\n items={itemOrSection.item?.items}\n >\n {renderNormalizedItem}\n </Section>\n );\n }\n\n return renderNormalizedItem(itemOrSection);\n },\n [renderNormalizedItem]\n );\n\n return {\n ...props,\n children,\n forceRerenderKey,\n ref,\n items: normalizedItems,\n selectedKey: selectedStringKey,\n defaultSelectedKey: defaultSelectedStringKey,\n disabledKeys: disabledStringKeys,\n onSelectionChange: onStringSelectionChange,\n onOpenChange: onOpenChangeInternal,\n };\n}\n\nexport default usePickerNormalizedProps;\n"],"mappings":";;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"usePickerNormalizedProps.js","names":["useCallback","useMemo","EMPTY_FUNCTION","getItemKey","isNormalizedSection","normalizeTooltipOptions","useRenderNormalizedItem","useStringifiedSelection","usePickerScrollOnOpen","Section","jsx","_jsx","usePickerNormalizedProps","_ref","defaultSelectedKey","disabledKeys","getInitialScrollPosition","normalizedItems","onChange","onOpenChange","onScroll","onSelectionChange","selectedKey","showItemIcons","tooltip","props","_objectWithoutProperties","_excluded","tooltipOptions","renderNormalizedItem","itemIconSlot","showItemDescriptions","forceRerenderKey","concat","placement","ref","onOpenChangeInternal","selectedStringKey","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","children","itemOrSection","_itemOrSection$item","_itemOrSection$item2","title","item","items","_objectSpread"],"sources":["../../../src/spectrum/picker/usePickerNormalizedProps.tsx"],"sourcesContent":["import { type Key, useCallback, useMemo } from 'react';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport type { DOMRef } from '@react-types/shared';\nimport {\n getItemKey,\n isNormalizedSection,\n type NormalizedItem,\n type NormalizedSection,\n normalizeTooltipOptions,\n useRenderNormalizedItem,\n useStringifiedSelection,\n} from '../utils';\nimport { type PickerNormalizedPropsT } from './PickerProps';\nimport { usePickerScrollOnOpen } from './usePickerScrollOnOpen';\nimport { Section } from '../shared';\n\n/** Props that are derived by `usePickerNormalizedProps` */\nexport type UsePickerNormalizedDerivedProps<THtml extends HTMLElement> = {\n children: (itemOrSection: NormalizedItem | NormalizedSection) => JSX.Element;\n forceRerenderKey: Key;\n items: (NormalizedItem | NormalizedSection)[];\n defaultSelectedKey?: Key;\n disabledKeys?: Iterable<Key>;\n ref: DOMRef<THtml>;\n selectedKey?: Key | null;\n onSelectionChange: (key: Key | null) => void;\n onOpenChange: (isOpen: boolean) => void;\n};\n\n/**\n * Props that are passed through untouched. (should exclude all of the\n * destructured props passed into `usePickerNormalizedProps` that are not in the\n * spread ...props)\n */\nexport type UsePickerNormalizedPassthroughProps<TProps> = Omit<\n PickerNormalizedPropsT<TProps>,\n | 'defaultSelectedKey'\n | 'disabledKeys'\n | 'getInitialScrollPosition'\n | 'normalizedItems'\n | 'onChange'\n | 'onOpenChange'\n | 'onScroll'\n | 'onSelectionChange'\n | 'selectedKey'\n | 'showItemIcons'\n | 'tooltip'\n>;\n\n/** Props returned from `usePickerNormalizedProps` hook. */\nexport type UsePickerNormalizedProps<\n TProps,\n THtml extends HTMLElement,\n> = UsePickerNormalizedDerivedProps<THtml> &\n UsePickerNormalizedPassthroughProps<TProps>;\n\nexport function usePickerNormalizedProps<\n TProps,\n THtml extends HTMLElement = HTMLElement,\n>({\n defaultSelectedKey,\n disabledKeys,\n getInitialScrollPosition,\n normalizedItems,\n onChange,\n onOpenChange,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange,\n selectedKey,\n showItemIcons,\n tooltip = true,\n ...props\n}: PickerNormalizedPropsT<TProps>): UsePickerNormalizedProps<TProps, THtml> {\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const renderNormalizedItem = useRenderNormalizedItem({\n itemIconSlot: 'icon',\n // Descriptions introduce variable item heights which throws off calculation\n // of initial scroll position and setting viewport on windowed data. For now\n // not going to implement description support in Picker.\n // https://github.com/deephaven/web-client-ui/issues/1958\n showItemDescriptions: false,\n showItemIcons,\n tooltipOptions,\n });\n\n // Spectrum doesn't re-render if only the `renderNormalizedItems` function\n // changes, so we create a key from its dependencies that can be used to force\n // re-render.\n const forceRerenderKey = `${showItemIcons}-${tooltipOptions?.placement}`;\n\n const { ref, onOpenChange: onOpenChangeInternal } =\n usePickerScrollOnOpen<THtml>({\n getInitialScrollPosition,\n onScroll,\n onOpenChange,\n });\n\n // Spectrum Picker treats keys as strings if the `key` prop is explicitly\n // set on `Item` elements. Since we do this in `renderItem`, we need to\n // map original key types to and from strings so that selection works.\n const {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n } = useStringifiedSelection({\n normalizedItems,\n selectedKey,\n defaultSelectedKey,\n disabledKeys,\n onChange: onChange ?? onSelectionChange,\n });\n\n const children = useCallback(\n (itemOrSection: NormalizedItem | NormalizedSection) => {\n if (isNormalizedSection(itemOrSection)) {\n return (\n <Section\n key={getItemKey(itemOrSection)}\n title={itemOrSection.item?.title}\n items={itemOrSection.item?.items}\n >\n {renderNormalizedItem}\n </Section>\n );\n }\n\n return renderNormalizedItem(itemOrSection);\n },\n [renderNormalizedItem]\n );\n\n return {\n ...props,\n children,\n forceRerenderKey,\n ref,\n items: normalizedItems,\n selectedKey: selectedStringKey,\n defaultSelectedKey: defaultSelectedStringKey,\n disabledKeys: disabledStringKeys,\n onSelectionChange: onStringSelectionChange,\n onOpenChange: onOpenChangeInternal,\n };\n}\n\nexport default usePickerNormalizedProps;\n"],"mappings":";;;;;;;;AAAA,SAAmBA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACtD,SAASC,cAAc,QAAQ,kBAAkB;AAAC,SAGhDC,UAAU,EACVC,mBAAmB,EAGnBC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB;AAAA,SAGhBC,qBAAqB;AAAA,SACrBC,OAAO;AAEhB;AAaA;AACA;AACA;AACA;AACA;AAgBA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOA,OAAO,SAASC,wBAAwBA,CAAAC,IAAA,EAgBoC;EAAA,IAb1E;MACAC,kBAAkB;MAClBC,YAAY;MACZC,wBAAwB;MACxBC,eAAe;MACfC,QAAQ;MACRC,YAAY;MACZC,QAAQ,GAAGlB,cAAc;MACzBmB,iBAAiB;MACjBC,WAAW;MACXC,aAAa;MACbC,OAAO,GAAG;IAEoB,CAAC,GAAAX,IAAA;IAD5BY,KAAK,GA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,UAAU,CAACuC,aAAa,CAKtB,CAAC;IAEd;IAEA,OAAOb,oBAAoB,CAACa,aAAa,CAAC;EAC5C,CAAC,EACD,CAACb,oBAAoB,CACvB,CAAC;EAED,OAAAmB,aAAA,CAAAA,aAAA,KACKvB,KAAK;IACRgB,QAAQ;IACRT,gBAAgB;IAChBG,GAAG;IACHY,KAAK,EAAE9B,eAAe;IACtBK,WAAW,EAAEe,iBAAiB;IAC9BvB,kBAAkB,EAAEwB,wBAAwB;IAC5CvB,YAAY,EAAEwB,kBAAkB;IAChClB,iBAAiB,EAAEmB,uBAAuB;IAC1CrB,YAAY,EAAEiB;EAAoB;AAEtC;AAEA,eAAexB,wBAAwB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DOMRef } from '@react-types/shared';
|
|
2
|
-
import { ItemKey, SectionElement, ItemElement } from '../utils';
|
|
1
|
+
import { type DOMRef } from '@react-types/shared';
|
|
2
|
+
import { type ItemKey, type SectionElement, type ItemElement } from '../utils';
|
|
3
3
|
import type { PickerPropsT } from './PickerProps';
|
|
4
4
|
/** Props that are derived by `usePickerProps`. */
|
|
5
5
|
export type UsePickerDerivedProps<THtml extends HTMLElement> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePickerProps.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerProps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"usePickerProps.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/usePickerProps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,kDAAkD;AAClD,MAAM,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.js","names":["EMPTY_FUNCTION","ensureArray","useMemo","PICKER_TOP_OFFSET","normalizeTooltipOptions","wrapItemChildren","useOnChangeTrackUncontrolled","useStaticItemInitialScrollPosition","usePickerItemScale","usePickerScrollOnOpen","usePickerProps","_ref","children","defaultSelectedKey","selectedKey","tooltip","onChange","onChangeHandler","onOpenChange","onOpenChangeHandler","onScroll","onSelectionChange","onSelectionChangeHandler","props","_objectWithoutProperties","_excluded","itemHeight","tooltipOptions","items","selectedKeyMaybeUncontrolled","onChangeMaybeUncontrolled","getInitialScrollPosition","topOffset","ref","_objectSpread"],"sources":["../../../src/spectrum/picker/usePickerProps.ts"],"sourcesContent":["import { EMPTY_FUNCTION, ensureArray } from '@deephaven/utils';\nimport { DOMRef } from '@react-types/shared';\nimport { useMemo } from 'react';\nimport { PICKER_TOP_OFFSET } from '../../UIConstants';\nimport {\n normalizeTooltipOptions,\n wrapItemChildren,\n useOnChangeTrackUncontrolled,\n useStaticItemInitialScrollPosition,\n ItemKey,\n SectionElement,\n ItemElement,\n} from '../utils';\nimport type { PickerPropsT } from './PickerProps';\nimport usePickerItemScale from './usePickerItemScale';\nimport usePickerScrollOnOpen from './usePickerScrollOnOpen';\n\n/** Props that are derived by `usePickerProps`. */\nexport type UsePickerDerivedProps<THtml extends HTMLElement> = {\n children: (SectionElement<unknown> | ItemElement<unknown>)[];\n defaultSelectedKey?: ItemKey | undefined;\n ref: DOMRef<THtml>;\n selectedKey?: ItemKey | null | undefined;\n onOpenChange: (isOpen: boolean) => void;\n onSelectionChange: ((key: ItemKey | null) => void) | undefined;\n};\n\n/** \n * Props that are passed through untouched. (should exclude all of the\n * destructured props passed into `usePickerProps` that are not in the spread\n * ...props)\n) */\nexport type UsePickerPassthroughProps<TProps> = Omit<\n PickerPropsT<TProps>,\n | 'children'\n | 'defaultSelectedKey'\n | 'selectedKey'\n | 'tooltip'\n | 'onChange'\n | 'onOpenChange'\n | 'onScroll'\n | 'onSelectionChange'\n>;\n\n/** Props returned from `usePickerProps` hook. */\nexport type UsePickerProps<\n TProps,\n THtml extends HTMLElement,\n> = UsePickerDerivedProps<THtml> & UsePickerPassthroughProps<TProps>;\n\n/**\n * Derive props for Picker components (e.g. Picker and ComboBox). Specifically\n * handles wrapping children items and initial scroll position when the picker\n * is opened.\n */\nexport function usePickerProps<\n TProps,\n THtml extends HTMLElement = HTMLElement,\n>({\n children,\n defaultSelectedKey,\n selectedKey,\n tooltip = true,\n onChange: onChangeHandler,\n onOpenChange: onOpenChangeHandler,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange: onSelectionChangeHandler,\n ...props\n}: PickerPropsT<TProps>): UsePickerProps<TProps, THtml> {\n const { itemHeight } = usePickerItemScale();\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const items = useMemo(\n () => ensureArray(wrapItemChildren(children, tooltipOptions)),\n [children, tooltipOptions]\n );\n\n const { selectedKeyMaybeUncontrolled, onChangeMaybeUncontrolled } =\n useOnChangeTrackUncontrolled({\n defaultSelectedKey,\n selectedKey,\n onChange: onChangeHandler ?? onSelectionChangeHandler,\n });\n\n const getInitialScrollPosition = useStaticItemInitialScrollPosition({\n itemHeight,\n items,\n selectedKey: selectedKeyMaybeUncontrolled,\n topOffset: PICKER_TOP_OFFSET,\n });\n\n const { ref, onOpenChange } = usePickerScrollOnOpen<THtml>({\n getInitialScrollPosition,\n onScroll,\n onOpenChange: onOpenChangeHandler,\n });\n\n return {\n ...props,\n defaultSelectedKey,\n ref,\n selectedKey,\n children: items,\n onOpenChange,\n onSelectionChange: onChangeMaybeUncontrolled,\n };\n}\n\nexport default usePickerProps;\n"],"mappings":";;;;;;;;AAAA,SAASA,cAAc,EAAEC,WAAW,QAAQ,kBAAkB;AAE9D,SAASC,OAAO,QAAQ,OAAO;AAAC,SACvBC,iBAAiB;AAAA,SAExBC,uBAAuB,EACvBC,gBAAgB,EAChBC,4BAA4B,EAC5BC,kCAAkC;AAAA,OAM7BC,kBAAkB;AA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GAAG;IACHnB,WAAW;IACXF,QAAQ,EAAEgB,KAAK;IACfV,YAAY;IACZG,iBAAiB,EAAES;EAAyB;AAEhD;AAEA,eAAepB,cAAc"}
|
|
1
|
+
{"version":3,"file":"usePickerProps.js","names":["EMPTY_FUNCTION","ensureArray","useMemo","PICKER_TOP_OFFSET","normalizeTooltipOptions","wrapItemChildren","useOnChangeTrackUncontrolled","useStaticItemInitialScrollPosition","usePickerItemScale","usePickerScrollOnOpen","usePickerProps","_ref","children","defaultSelectedKey","selectedKey","tooltip","onChange","onChangeHandler","onOpenChange","onOpenChangeHandler","onScroll","onSelectionChange","onSelectionChangeHandler","props","_objectWithoutProperties","_excluded","itemHeight","tooltipOptions","items","selectedKeyMaybeUncontrolled","onChangeMaybeUncontrolled","getInitialScrollPosition","topOffset","ref","_objectSpread"],"sources":["../../../src/spectrum/picker/usePickerProps.ts"],"sourcesContent":["import { EMPTY_FUNCTION, ensureArray } from '@deephaven/utils';\nimport { type DOMRef } from '@react-types/shared';\nimport { useMemo } from 'react';\nimport { PICKER_TOP_OFFSET } from '../../UIConstants';\nimport {\n normalizeTooltipOptions,\n wrapItemChildren,\n useOnChangeTrackUncontrolled,\n useStaticItemInitialScrollPosition,\n type ItemKey,\n type SectionElement,\n type ItemElement,\n} from '../utils';\nimport type { PickerPropsT } from './PickerProps';\nimport usePickerItemScale from './usePickerItemScale';\nimport usePickerScrollOnOpen from './usePickerScrollOnOpen';\n\n/** Props that are derived by `usePickerProps`. */\nexport type UsePickerDerivedProps<THtml extends HTMLElement> = {\n children: (SectionElement<unknown> | ItemElement<unknown>)[];\n defaultSelectedKey?: ItemKey | undefined;\n ref: DOMRef<THtml>;\n selectedKey?: ItemKey | null | undefined;\n onOpenChange: (isOpen: boolean) => void;\n onSelectionChange: ((key: ItemKey | null) => void) | undefined;\n};\n\n/** \n * Props that are passed through untouched. (should exclude all of the\n * destructured props passed into `usePickerProps` that are not in the spread\n * ...props)\n) */\nexport type UsePickerPassthroughProps<TProps> = Omit<\n PickerPropsT<TProps>,\n | 'children'\n | 'defaultSelectedKey'\n | 'selectedKey'\n | 'tooltip'\n | 'onChange'\n | 'onOpenChange'\n | 'onScroll'\n | 'onSelectionChange'\n>;\n\n/** Props returned from `usePickerProps` hook. */\nexport type UsePickerProps<\n TProps,\n THtml extends HTMLElement,\n> = UsePickerDerivedProps<THtml> & UsePickerPassthroughProps<TProps>;\n\n/**\n * Derive props for Picker components (e.g. Picker and ComboBox). Specifically\n * handles wrapping children items and initial scroll position when the picker\n * is opened.\n */\nexport function usePickerProps<\n TProps,\n THtml extends HTMLElement = HTMLElement,\n>({\n children,\n defaultSelectedKey,\n selectedKey,\n tooltip = true,\n onChange: onChangeHandler,\n onOpenChange: onOpenChangeHandler,\n onScroll = EMPTY_FUNCTION,\n onSelectionChange: onSelectionChangeHandler,\n ...props\n}: PickerPropsT<TProps>): UsePickerProps<TProps, THtml> {\n const { itemHeight } = usePickerItemScale();\n\n const tooltipOptions = useMemo(\n () => normalizeTooltipOptions(tooltip),\n [tooltip]\n );\n\n const items = useMemo(\n () => ensureArray(wrapItemChildren(children, tooltipOptions)),\n [children, tooltipOptions]\n );\n\n const { selectedKeyMaybeUncontrolled, onChangeMaybeUncontrolled } =\n useOnChangeTrackUncontrolled({\n defaultSelectedKey,\n selectedKey,\n onChange: onChangeHandler ?? onSelectionChangeHandler,\n });\n\n const getInitialScrollPosition = useStaticItemInitialScrollPosition({\n itemHeight,\n items,\n selectedKey: selectedKeyMaybeUncontrolled,\n topOffset: PICKER_TOP_OFFSET,\n });\n\n const { ref, onOpenChange } = usePickerScrollOnOpen<THtml>({\n getInitialScrollPosition,\n onScroll,\n onOpenChange: onOpenChangeHandler,\n });\n\n return {\n ...props,\n defaultSelectedKey,\n ref,\n selectedKey,\n children: items,\n onOpenChange,\n onSelectionChange: onChangeMaybeUncontrolled,\n };\n}\n\nexport default usePickerProps;\n"],"mappings":";;;;;;;;AAAA,SAASA,cAAc,EAAEC,WAAW,QAAQ,kBAAk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qBAAqB,CAAQ;IACzDsB,wBAAwB;IACxBX,QAAQ;IACRF,YAAY,EAAEC;EAChB,CAAC,CAAC;EAEF,OAAAe,aAAA,CAAAA,aAAA,KACKX,KAAK;IACRV,kBAAkB;IAClBoB,GAAG;IACHnB,WAAW;IACXF,QAAQ,EAAEgB,KAAK;IACfV,YAAY;IACZG,iBAAiB,EAAES;EAAyB;AAEhD;AAEA,eAAepB,cAAc"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Key, ReactElement, ReactNode } from 'react';
|
|
1
|
+
import { type Key, type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
import type { ItemRenderer } from '@react-types/shared';
|
|
3
|
-
import { KeyedItem, SelectionT } from '@deephaven/utils';
|
|
4
|
-
import { ItemElementOrPrimitive, ItemProps, SectionProps } from '../shared';
|
|
5
|
-
import { PopperOptions } from '../../popper';
|
|
3
|
+
import { type KeyedItem, type SelectionT } from '@deephaven/utils';
|
|
4
|
+
import { type ItemElementOrPrimitive, type ItemProps, type SectionProps } from '../shared';
|
|
5
|
+
import { type PopperOptions } from '../../popper';
|
|
6
6
|
/**
|
|
7
7
|
* `Item.textValue` prop needs to be a non-empty string for accessibility
|
|
8
8
|
* purposes. This is not displayed in the UI.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/itemUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"itemUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/itemUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAe,KAAK,SAA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AAI,IAAI,aAAa,CAQtE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,EACzC,SAAS,GAAE,cAAc,CAAC,WAAW,CAAW,GAC/C,cAAc,GAAG,IAAI,CAUvB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,SAAS,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,EACnD,OAAO,SAAS,KAAK,SAAS,KAAK,GAC/B,KAAK,GACL,KAAK,SAAS,QAAQ,CAAC,OAAO,CAAC,GAC/B,GAAG,CAAC,MAAM,CAAC,GACX,SAAS,EACb,QAAQ,EAAE,KAAK,GAAG,OAAO,CAM1B"}
|
|
@@ -1 +1 @@
|
|
|
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","getItemTextValue","props","textValue","itemKeyStr","undefined","String","includes","children","getPositionOfSelectedItemElement","_x","_getPositionOfSelectedItemElement","apply","arguments","_asyncToGenerator","_ref","items","itemHeight","selectedKey","topOffset","position","i","length","isSectionElement","node","isItemElement","isItemElementWithDescription","childrenArray","result","some","child","_child$props","slot","isNormalizedItemsWithKeysList","Array","isArray","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeTooltipOptions","options","placement","itemSelectionToStringSet","itemKeys","Set","map"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { Key, ReactElement, ReactNode } from 'react';\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 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 * Determine Item `textValue` based on the `textValue` prop or primitive children\n * value.\n * @param item The item to get the text value for\n * @returns The text value of the item\n */\nexport function getItemTextValue<T>(item: ItemElement<T>): string | undefined {\n if (item.props.textValue == null) {\n const itemKeyStr = item.key == null ? undefined : String(item.key);\n return ['string', 'boolean', 'number'].includes(typeof item.props.children)\n ? String(item.props.children)\n : itemKeyStr;\n }\n\n return item.props.textValue === ''\n ? ITEM_EMPTY_STRING_TEXT_VALUE\n : item.props.textValue;\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 (\n !isItemOrSection(node[0]) && typeof node[0] === 'object' && 'key' in node[0]\n );\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":";;AAEA,SAASA,eAAe,QAAQ,wBAAwB;AACxD,SAASC,WAAW,QAA+B,kBAAkB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;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASe,uBAAuBA,CACrCC,OAAyC,EAElB;EAAA,IADvBC,SAAsC,GAAA5B,SAAA,CAAAS,MAAA,QAAAT,SAAA,QAAAR,SAAA,GAAAQ,SAAA,MAAG,OAAO;EAEhD,IAAI2B,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,SAASE,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,CAACvC,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","getItemTextValue","props","textValue","itemKeyStr","undefined","String","includes","children","getPositionOfSelectedItemElement","_x","_getPositionOfSelectedItemElement","apply","arguments","_asyncToGenerator","_ref","items","itemHeight","selectedKey","topOffset","position","i","length","isSectionElement","node","isItemElement","isItemElementWithDescription","childrenArray","result","some","child","_child$props","slot","isNormalizedItemsWithKeysList","Array","isArray","isItemOrSection","isNormalizedSection","maybeNormalizedSection","normalizeTooltipOptions","options","placement","itemSelectionToStringSet","itemKeys","Set","map"],"sources":["../../../src/spectrum/utils/itemUtils.ts"],"sourcesContent":["import { type Key, type ReactElement, type ReactNode } from 'react';\nimport type { ItemRenderer } from '@react-types/shared';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport { ensureArray, type KeyedItem, type SelectionT } from '@deephaven/utils';\nimport {\n Item,\n type ItemElementOrPrimitive,\n type ItemProps,\n Section,\n type SectionProps,\n} from '../shared';\nimport { type 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 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 * Determine Item `textValue` based on the `textValue` prop or primitive children\n * value.\n * @param item The item to get the text value for\n * @returns The text value of the item\n */\nexport function getItemTextValue<T>(item: ItemElement<T>): string | undefined {\n if (item.props.textValue == null) {\n const itemKeyStr = item.key == null ? undefined : String(item.key);\n return ['string', 'boolean', 'number'].includes(typeof item.props.children)\n ? String(item.props.children)\n : itemKeyStr;\n }\n\n return item.props.textValue === ''\n ? ITEM_EMPTY_STRING_TEXT_VALUE\n : item.props.textValue;\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 (\n !isItemOrSection(node[0]) && typeof node[0] === 'object' && 'key' in node[0]\n );\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":";;AAEA,SAASA,eAAe,QAAQ,wBAAwB;AACxD,SAASC,WAAW,QAAyC,kBAAkB;AAAC,SAE9EC,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;AAUA;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;AACA,OAAO,SAASC,gBAAgBA,CAAIJ,IAAoB,EAAsB;EAC5E,IAAIA,IAAI,CAACK,KAAK,CAACC,SAAS,IAAI,IAAI,EAAE;IAChC,IAAMC,UAAU,GAAGP,IAAI,CAACG,GAAG,IAAI,IAAI,GAAGK,SAAS,GAAGC,MAAM,CAACT,IAAI,CAACG,GAAG,CAAC;IAClE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAACO,QAAQ,CAAC,OAAOV,IAAI,CAACK,KAAK,CAACM,QAAQ,CAAC,GACvEF,MAAM,CAACT,IAAI,CAACK,KAAK,CAACM,QAAQ,CAAC,GAC3BJ,UAAU;EAChB;EAEA,OAAOP,I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OA,IAAI,KAAK,QAAQ,IACxB,OAAOA,IAAI,KAAK,QAAQ,IACxB,OAAOA,IAAI,KAAK,SAAS,IACzBC,aAAa,CAACD,IAAI,CAAC,IACnBD,gBAAgB,CAACC,IAAI,CAAC;AAE1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASe,uBAAuBA,CACrCC,OAAyC,EAElB;EAAA,IADvBC,SAAsC,GAAA5B,SAAA,CAAAS,MAAA,QAAAT,SAAA,QAAAR,SAAA,GAAAQ,SAAA,MAAG,OAAO;EAEhD,IAAI2B,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,SAASE,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,CAACvC,MAAM,CAAC,CAAC;AAC3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { ItemElement, ItemIconSlot, ItemOrSection, SectionElement, TooltipOptions } from './itemUtils';
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ItemElement, type ItemIconSlot, type ItemOrSection, type SectionElement, type TooltipOptions } from './itemUtils';
|
|
3
3
|
/**
|
|
4
4
|
* If the given content is a string, wrap it in an Icon component. Otherwise,
|
|
5
5
|
* return the original content. If the key is not found in the dhIcons object,
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"itemWrapperUtils.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/itemWrapperUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMrD,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAElB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,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,CAiD7E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,SAAS,EACnB,IAAI,CAAC,EAAE,MAAM,GACZ,SAAS,CAeX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemWrapperUtils.js","names":["cloneElement","Item","FontAwesomeIcon","dh","dhIcons","isElementOfType","ensureArray","NON_BREAKING_SPACE","getItemTextValue","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 getItemTextValue,\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 = getItemTextValue(item);\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 {/* Non-breaking space is needed to avoid the Text element's height \n collapsing when content is empty */}\n {content === '' ? NON_BREAKING_SPACE : String(content)}\n </Text>\n );\n }\n\n return content;\n}\n"],"mappings":";;;;;AAAA,SAASA,YAAY,
|
|
1
|
+
{"version":3,"file":"itemWrapperUtils.js","names":["cloneElement","Item","FontAwesomeIcon","dh","dhIcons","isElementOfType","ensureArray","NON_BREAKING_SPACE","getItemTextValue","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, type 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 getItemTextValue,\n isItemElement,\n isSectionElement,\n type ItemElement,\n type ItemIconSlot,\n type ItemOrSection,\n ITEM_EMPTY_STRING_TEXT_VALUE,\n type SectionElement,\n type 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 = getItemTextValue(item);\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 {/* Non-breaking space is needed to avoid the Text element's height \n collapsing when content is empty */}\n {content === '' ? NON_BREAKING_SPACE : String(content)}\n </Text>\n );\n }\n\n return content;\n}\n"],"mappings":";;;;;AAAA,SAASA,YAAY,QAAwB,OAAO;AACpD,SAASC,IAAI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xDA,IAEL,CAAC;EAEX,CAAC,CAAC;;EAEF;EACA,OAAOE,KAAK,CAACC,OAAO,CAACjB,eAAe,CAAC,GAAGG,MAAM,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,EAGduB,OAAO,KAAK,EAAE,GAAGtC,kBAAkB,GAAGkC,MAAM,CAACI,OAAO;IAAC,CAClD,CAAC;EAEX;EAEA,OAAOA,OAAO;AAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnChangeTrackUncontrolled.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useOnChangeTrackUncontrolled.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"useOnChangeTrackUncontrolled.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useOnChangeTrackUncontrolled.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,mCAAmC;IAClD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,kCAAkC;IACjD,4BAA4B,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9C,yBAAyB,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CAC1D;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,kBAAkB,EAClB,WAAW,EACX,QAAQ,EAAE,eAAe,GAC1B,EAAE,mCAAmC,GAAG,kCAAkC,CA0B1E;AAED,eAAe,4BAA4B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnChangeTrackUncontrolled.js","names":["useCallback","useState","useOnChangeTrackUncontrolled","_ref","defaultSelectedKey","selectedKey","onChange","onChangeHandler","isUncontrolled","undefined","uncontrolledSelectedKey","setUncontrolledSelectedKey","onChangeMaybeUncontrolled","key","selectedKeyMaybeUncontrolled"],"sources":["../../../src/spectrum/utils/useOnChangeTrackUncontrolled.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { ItemKey } from './itemUtils';\n\nexport interface UseOnChangeTrackUncontrolledOptions {\n defaultSelectedKey?: ItemKey;\n selectedKey?: ItemKey | null;\n onChange?: (key: ItemKey | null) => void;\n}\n\nexport interface UseOnChangeTrackUncontrolledResult {\n selectedKeyMaybeUncontrolled?: ItemKey | null;\n onChangeMaybeUncontrolled: (key: ItemKey | null) => void;\n}\n\n/**\n * Returns a selectedKey and onChange handler that can manage selection state\n * for both controlled and uncontrolled components. Useful for cases where a\n * component needs to always track its selection state regardless of its\n * controlled / uncontrolled status.\n */\nexport function useOnChangeTrackUncontrolled({\n defaultSelectedKey,\n selectedKey,\n onChange: onChangeHandler,\n}: UseOnChangeTrackUncontrolledOptions): UseOnChangeTrackUncontrolledResult {\n // `null` is a valid value for `selectedKey` in controlled mode, so we check\n // for explicit `undefined` to identify uncontrolled mode.\n const isUncontrolled = selectedKey === undefined;\n const [uncontrolledSelectedKey, setUncontrolledSelectedKey] = useState<\n ItemKey | null | undefined\n >(defaultSelectedKey);\n\n const onChangeMaybeUncontrolled = useCallback(\n (key: ItemKey | null): void => {\n // If our component is uncontrolled, track the selected key internally\n if (isUncontrolled) {\n setUncontrolledSelectedKey(key);\n }\n\n onChangeHandler?.(key);\n },\n [isUncontrolled, onChangeHandler]\n );\n\n return {\n selectedKeyMaybeUncontrolled: isUncontrolled\n ? uncontrolledSelectedKey\n : selectedKey,\n onChangeMaybeUncontrolled,\n };\n}\n\nexport default useOnChangeTrackUncontrolled;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAc7C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAAC,IAAA,EAIgC;EAAA,IAJ/B;IAC3CC,kBAAkB;IAClBC,WAAW;IACXC,QAAQ,EAAEC;EACyB,CAAC,GAAAJ,IAAA;EACpC;EACA;EACA,IAAMK,cAAc,GAAGH,WAAW,KAAKI,SAAS;EAChD,IAAM,CAACC,uBAAuB,EAAEC,0BAA0B,CAAC,GAAGV,QAAQ,CAEpEG,kBAAkB,CAAC;EAErB,IAAMQ,yBAAyB,GAAGZ,WAAW,CAC1Ca,GAAmB,IAAW;IAC7B;IACA,IAAIL,cAAc,EAAE;MAClBG,0BAA0B,CAACE,GAAG,CAAC;IACjC;IAEAN,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAGM,GAAG,CAAC;EACxB,CAAC,EACD,CAACL,cAAc,EAAED,eAAe,CAClC,CAAC;EAED,OAAO;IACLO,4BAA4B,EAAEN,cAAc,GACxCE,uBAAuB,GACvBL,WAAW;IACfO;EACF,CAAC;AACH;AAEA,eAAeV,4BAA4B"}
|
|
1
|
+
{"version":3,"file":"useOnChangeTrackUncontrolled.js","names":["useCallback","useState","useOnChangeTrackUncontrolled","_ref","defaultSelectedKey","selectedKey","onChange","onChangeHandler","isUncontrolled","undefined","uncontrolledSelectedKey","setUncontrolledSelectedKey","onChangeMaybeUncontrolled","key","selectedKeyMaybeUncontrolled"],"sources":["../../../src/spectrum/utils/useOnChangeTrackUncontrolled.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { type ItemKey } from './itemUtils';\n\nexport interface UseOnChangeTrackUncontrolledOptions {\n defaultSelectedKey?: ItemKey;\n selectedKey?: ItemKey | null;\n onChange?: (key: ItemKey | null) => void;\n}\n\nexport interface UseOnChangeTrackUncontrolledResult {\n selectedKeyMaybeUncontrolled?: ItemKey | null;\n onChangeMaybeUncontrolled: (key: ItemKey | null) => void;\n}\n\n/**\n * Returns a selectedKey and onChange handler that can manage selection state\n * for both controlled and uncontrolled components. Useful for cases where a\n * component needs to always track its selection state regardless of its\n * controlled / uncontrolled status.\n */\nexport function useOnChangeTrackUncontrolled({\n defaultSelectedKey,\n selectedKey,\n onChange: onChangeHandler,\n}: UseOnChangeTrackUncontrolledOptions): UseOnChangeTrackUncontrolledResult {\n // `null` is a valid value for `selectedKey` in controlled mode, so we check\n // for explicit `undefined` to identify uncontrolled mode.\n const isUncontrolled = selectedKey === undefined;\n const [uncontrolledSelectedKey, setUncontrolledSelectedKey] = useState<\n ItemKey | null | undefined\n >(defaultSelectedKey);\n\n const onChangeMaybeUncontrolled = useCallback(\n (key: ItemKey | null): void => {\n // If our component is uncontrolled, track the selected key internally\n if (isUncontrolled) {\n setUncontrolledSelectedKey(key);\n }\n\n onChangeHandler?.(key);\n },\n [isUncontrolled, onChangeHandler]\n );\n\n return {\n selectedKeyMaybeUncontrolled: isUncontrolled\n ? uncontrolledSelectedKey\n : selectedKey,\n onChangeMaybeUncontrolled,\n };\n}\n\nexport default useOnChangeTrackUncontrolled;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAc7C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAAC,IAAA,EAIgC;EAAA,IAJ/B;IAC3CC,kBAAkB;IAClBC,WAAW;IACXC,QAAQ,EAAEC;EACyB,CAAC,GAAAJ,IAAA;EACpC;EACA;EACA,IAAMK,cAAc,GAAGH,WAAW,KAAKI,SAAS;EAChD,IAAM,CAACC,uBAAuB,EAAEC,0BAA0B,CAAC,GAAGV,QAAQ,CAEpEG,kBAAkB,CAAC;EAErB,IAAMQ,yBAAyB,GAAGZ,WAAW,CAC1Ca,GAAmB,IAAW;IAC7B;IACA,IAAIL,cAAc,EAAE;MAClBG,0BAA0B,CAACE,GAAG,CAAC;IACjC;IAEAN,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAGM,GAAG,CAAC;EACxB,CAAC,EACD,CAACL,cAAc,EAAED,eAAe,CAClC,CAAC;EAED,OAAO;IACLO,4BAA4B,EAAEN,cAAc,GACxCE,uBAAuB,GACvBL,WAAW;IACfO;EACF,CAAC;AACH;AAEA,eAAeV,4BAA4B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { ListActionGroupProps } from '../ListActionGroup';
|
|
3
|
-
import { ListActionMenuProps } from '../ListActionMenu';
|
|
4
|
-
import { ItemIconSlot, NormalizedItem, TooltipOptions } from './itemUtils';
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type ListActionGroupProps } from '../ListActionGroup';
|
|
3
|
+
import { type ListActionMenuProps } from '../ListActionMenu';
|
|
4
|
+
import { type ItemIconSlot, type NormalizedItem, type TooltipOptions } from './itemUtils';
|
|
5
5
|
export type ListActions<T> = ReactElement<ListActionGroupProps<T>> | ReactElement<ListActionMenuProps<T>>;
|
|
6
6
|
export interface UseRenderNormalizedItemOptions {
|
|
7
7
|
itemIconSlot: ItemIconSlot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRenderNormalizedItem.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"useRenderNormalizedItem.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,YAAY,EAAe,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,WAAW,CAAC,CAAC,IACrB,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,GACrC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzC,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,CAsEf;AAED,eAAe,uBAAuB,CAAC"}
|