@deephaven/components 0.94.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":"useRenderNormalizedItem.js","names":["isElementOfType","useCallback","ActionGroup","ActionMenu","ItemContent","ListActionGroup","ListActionMenu","Item","getItemKey","ITEM_EMPTY_STRING_TEXT_VALUE","wrapIcon","wrapPrimitiveWithText","jsx","_jsx","jsxs","_jsxs","useRenderNormalizedItem","_ref","itemIconSlot","showItemDescriptions","showItemIcons","tooltipOptions","actions","normalizedItem","_normalizedItem$item","_normalizedItem$item$","_normalizedItem$item2","_normalizedItem$item3","_normalizedItem$item4","itemKey","content","item","textValue","undefined","String","description","icon","action","_objectSpread","props","onAction","key","onChange","keys","_actions$props$onChan","_actions$props","call","onOpenChange","isOpen","_actions$props$onOpen","_actions$props2","children"],"sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"sourcesContent":["import { isElementOfType } from '@deephaven/react-hooks';\nimport { Key, ReactElement, useCallback } from 'react';\nimport ActionGroup from '../ActionGroup';\nimport ActionMenu from '../ActionMenu';\nimport { ItemContent } from '../ItemContent';\nimport { ListActionGroup, ListActionGroupProps } from '../ListActionGroup';\nimport { ListActionMenu, ListActionMenuProps } from '../ListActionMenu';\nimport { Item } from '../shared';\nimport {\n getItemKey,\n ITEM_EMPTY_STRING_TEXT_VALUE,\n ItemIconSlot,\n NormalizedItem,\n TooltipOptions,\n} from './itemUtils';\nimport { wrapIcon, wrapPrimitiveWithText } from './itemWrapperUtils';\n\nexport type ListActions<T> =\n | ReactElement<ListActionGroupProps<T>>\n | ReactElement<ListActionMenuProps<T>>;\n\nexport interface UseRenderNormalizedItemOptions {\n itemIconSlot: ItemIconSlot;\n showItemDescriptions: boolean;\n showItemIcons: boolean;\n tooltipOptions: TooltipOptions | null;\n actions?: ListActions<unknown>;\n}\n\n/**\n * Returns a render function that can be used to render a normalized item in\n * collection components.\n * @param itemIconSlot Slot to use for item icons\n * @param showItemDescriptions Whether to show item descriptions\n * @param showItemIcons Whether to show item icons\n * @param tooltipOptions Tooltip options to use when rendering the item\n * @param actions Optional actions to render with the item\n * @returns Render function for normalized items\n */\nexport function useRenderNormalizedItem({\n itemIconSlot,\n showItemDescriptions,\n showItemIcons,\n tooltipOptions,\n actions,\n}: UseRenderNormalizedItemOptions): (\n normalizedItem: NormalizedItem\n) => JSX.Element {\n return useCallback(\n (normalizedItem: NormalizedItem) => {\n const itemKey = getItemKey(normalizedItem);\n const content = wrapPrimitiveWithText(normalizedItem.item?.content);\n const textValue =\n normalizedItem.item?.textValue ??\n (itemKey == null ? undefined : String(itemKey));\n\n const description = showItemDescriptions\n ? wrapPrimitiveWithText(normalizedItem.item?.description, 'description')\n : null;\n\n const icon = showItemIcons\n ? wrapIcon(normalizedItem.item?.icon, itemIconSlot)\n : null;\n\n let action = null;\n\n if (isElementOfType(actions, ListActionGroup)) {\n action = (\n <ActionGroup\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...actions.props}\n onAction={key => actions.props.onAction(key, itemKey)}\n onChange={keys => actions.props.onChange?.(keys, itemKey)}\n />\n );\n } else if (isElementOfType(actions, ListActionMenu)) {\n action = (\n <ActionMenu\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...actions.props}\n onAction={key => actions.props.onAction(key, itemKey)}\n onOpenChange={isOpen =>\n actions.props.onOpenChange?.(isOpen, itemKey)\n }\n />\n );\n }\n\n return (\n <Item\n // Note that setting the `key` prop explicitly on `Item` elements\n // causes the picker to expect `selectedKey` and `defaultSelectedKey`\n // to be strings. It also passes the stringified value of the key to\n // `onSelectionChange` handlers` regardless of the actual type of the\n // key. We can't really get around setting in order to support Windowed\n // data, so we'll need to do some manual conversion of keys to strings\n // in other components that use this hook.\n key={itemKey as Key}\n // The `textValue` prop gets used to provide the content of `<option>`\n // elements that back the Spectrum Picker. These are not visible in the UI,\n // but are used for accessibility purposes, so we set to an arbitrary\n // `ITEM_EMPTY_STRING_TEXT_VALUE` value so that they are not empty strings.\n textValue={\n textValue === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : textValue\n }\n >\n <ItemContent tooltipOptions={tooltipOptions}>\n {icon}\n {content}\n {description}\n {action}\n </ItemContent>\n </Item>\n );\n },\n [actions, itemIconSlot, showItemDescriptions, showItemIcons, tooltipOptions]\n );\n}\n\nexport default useRenderNormalizedItem;\n"],"mappings":";;;;;AAAA,SAASA,eAAe,QAAQ,wBAAwB;AACxD,
|
|
1
|
+
{"version":3,"file":"useRenderNormalizedItem.js","names":["isElementOfType","useCallback","ActionGroup","ActionMenu","ItemContent","ListActionGroup","ListActionMenu","Item","getItemKey","ITEM_EMPTY_STRING_TEXT_VALUE","wrapIcon","wrapPrimitiveWithText","jsx","_jsx","jsxs","_jsxs","useRenderNormalizedItem","_ref","itemIconSlot","showItemDescriptions","showItemIcons","tooltipOptions","actions","normalizedItem","_normalizedItem$item","_normalizedItem$item$","_normalizedItem$item2","_normalizedItem$item3","_normalizedItem$item4","itemKey","content","item","textValue","undefined","String","description","icon","action","_objectSpread","props","onAction","key","onChange","keys","_actions$props$onChan","_actions$props","call","onOpenChange","isOpen","_actions$props$onOpen","_actions$props2","children"],"sources":["../../../src/spectrum/utils/useRenderNormalizedItem.tsx"],"sourcesContent":["import { isElementOfType } from '@deephaven/react-hooks';\nimport { type Key, type ReactElement, useCallback } from 'react';\nimport ActionGroup from '../ActionGroup';\nimport ActionMenu from '../ActionMenu';\nimport { ItemContent } from '../ItemContent';\nimport { ListActionGroup, type ListActionGroupProps } from '../ListActionGroup';\nimport { ListActionMenu, type ListActionMenuProps } from '../ListActionMenu';\nimport { Item } from '../shared';\nimport {\n getItemKey,\n ITEM_EMPTY_STRING_TEXT_VALUE,\n type ItemIconSlot,\n type NormalizedItem,\n type TooltipOptions,\n} from './itemUtils';\nimport { wrapIcon, wrapPrimitiveWithText } from './itemWrapperUtils';\n\nexport type ListActions<T> =\n | ReactElement<ListActionGroupProps<T>>\n | ReactElement<ListActionMenuProps<T>>;\n\nexport interface UseRenderNormalizedItemOptions {\n itemIconSlot: ItemIconSlot;\n showItemDescriptions: boolean;\n showItemIcons: boolean;\n tooltipOptions: TooltipOptions | null;\n actions?: ListActions<unknown>;\n}\n\n/**\n * Returns a render function that can be used to render a normalized item in\n * collection components.\n * @param itemIconSlot Slot to use for item icons\n * @param showItemDescriptions Whether to show item descriptions\n * @param showItemIcons Whether to show item icons\n * @param tooltipOptions Tooltip options to use when rendering the item\n * @param actions Optional actions to render with the item\n * @returns Render function for normalized items\n */\nexport function useRenderNormalizedItem({\n itemIconSlot,\n showItemDescriptions,\n showItemIcons,\n tooltipOptions,\n actions,\n}: UseRenderNormalizedItemOptions): (\n normalizedItem: NormalizedItem\n) => JSX.Element {\n return useCallback(\n (normalizedItem: NormalizedItem) => {\n const itemKey = getItemKey(normalizedItem);\n const content = wrapPrimitiveWithText(normalizedItem.item?.content);\n const textValue =\n normalizedItem.item?.textValue ??\n (itemKey == null ? undefined : String(itemKey));\n\n const description = showItemDescriptions\n ? wrapPrimitiveWithText(normalizedItem.item?.description, 'description')\n : null;\n\n const icon = showItemIcons\n ? wrapIcon(normalizedItem.item?.icon, itemIconSlot)\n : null;\n\n let action = null;\n\n if (isElementOfType(actions, ListActionGroup)) {\n action = (\n <ActionGroup\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...actions.props}\n onAction={key => actions.props.onAction(key, itemKey)}\n onChange={keys => actions.props.onChange?.(keys, itemKey)}\n />\n );\n } else if (isElementOfType(actions, ListActionMenu)) {\n action = (\n <ActionMenu\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...actions.props}\n onAction={key => actions.props.onAction(key, itemKey)}\n onOpenChange={isOpen =>\n actions.props.onOpenChange?.(isOpen, itemKey)\n }\n />\n );\n }\n\n return (\n <Item\n // Note that setting the `key` prop explicitly on `Item` elements\n // causes the picker to expect `selectedKey` and `defaultSelectedKey`\n // to be strings. It also passes the stringified value of the key to\n // `onSelectionChange` handlers` regardless of the actual type of the\n // key. We can't really get around setting in order to support Windowed\n // data, so we'll need to do some manual conversion of keys to strings\n // in other components that use this hook.\n key={itemKey as Key}\n // The `textValue` prop gets used to provide the content of `<option>`\n // elements that back the Spectrum Picker. These are not visible in the UI,\n // but are used for accessibility purposes, so we set to an arbitrary\n // `ITEM_EMPTY_STRING_TEXT_VALUE` value so that they are not empty strings.\n textValue={\n textValue === '' ? ITEM_EMPTY_STRING_TEXT_VALUE : textValue\n }\n >\n <ItemContent tooltipOptions={tooltipOptions}>\n {icon}\n {content}\n {description}\n {action}\n </ItemContent>\n </Item>\n );\n },\n [actions, itemIconSlot, showItemDescriptions, showItemIcons, tooltipOptions]\n );\n}\n\nexport default useRenderNormalizedItem;\n"],"mappings":";;;;;AAAA,SAASA,eAAe,QAAQ,wBAAwB;AACxD,SAAsCC,WAAW,QAAQ,OAAO;AAAC,OAC1DC,WAAW;AAAA,OACXC,UAAU;AAAA,SACRC,WAAW;AAAA,SACXC,eAAe;AAAA,SACfC,cAAc;AAAA,SACdC,IAAI;AAAA,SAEXC,UAAU,EACVC,4BAA4B;AAAA,SAKrBC,QAAQ,EAAEC,qBAAqB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAcxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAAC,IAAA,EAQtB;EAAA,IARuB;IACtCC,YAAY;IACZC,oBAAoB;IACpBC,aAAa;IACbC,cAAc;IACdC;EAC8B,CAAC,GAAAL,IAAA;EAG/B,OAAOhB,WAAW,CACfsB,cAA8B,IAAK;IAAA,IAAAC,oBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;IAClC,IAAMC,OAAO,GAAGrB,UAAU,CAACe,cAAc,CAAC;IAC1C,IAAMO,OAAO,GAAGnB,qBAAqB,EAAAa,oBAAA,GAACD,cAAc,CAACQ,IAAI,cAAAP,oBAAA,uBAAnBA,oBAAA,CAAqBM,OAAO,CAAC;IACnE,IAAME,SAAS,IAAAP,qBAAA,IAAAC,qBAAA,GACbH,cAAc,CAACQ,IAAI,cAAAL,qBAAA,uBAAnBA,qBAAA,CAAqBM,SAAS,cAAAP,qBAAA,cAAAA,qBAAA,GAC7BI,OAAO,IAAI,IAAI,GAAGI,SAAS,GAAGC,MAAM,CAACL,OAAO,CAAE;IAEjD,IAAM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ClB,CAAAC,eAAA,GAAA5B,OAAO,CAACiB,KAAK,EAACQ,YAAY,cAAAE,qBAAA,uBAA1BA,qBAAA,CAAAH,IAAA,CAAAI,eAAA,EAA6BF,MAAM,EAAEnB,OAAO,CAAC;QAAA;MAC9C,EACF,CACF;IACH;IAEA,oBACEhB,IAAA,CAACN;IACC;IACA;IACA;IACA;IACA;IACA;IACA;IAAA;MAEA;MACA;MACA;MACA;MACAyB,SAAS,EACPA,SAAS,KAAK,EAAE,GAAGvB,4BAA4B,GAAGuB,SACnD;MAAAmB,QAAA,eAEDpC,KAAA,CAACX,WAAW;QAACiB,cAAc,EAAEA,cAAe;QAAA8B,QAAA,GACzCf,IAAI,EACJN,OAAO,EACPK,WAAW,EACXE,MAAM;MAAA,CACI;IAAC,GAdTR,OAeD,CAAC;EAEX,CAAC,EACD,CAACP,OAAO,EAAEJ,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,EAAEC,cAAc,CAC7E,CAAC;AACH;AAEA,eAAeL,uBAAuB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ItemElement, ItemKey, SectionElement } from './itemUtils';
|
|
1
|
+
import { type ItemElement, type ItemKey, type SectionElement } from './itemUtils';
|
|
2
2
|
export interface UseStaticItemInitialScrollPositionOptions {
|
|
3
3
|
itemHeight: number;
|
|
4
4
|
items: (ItemElement<unknown> | SectionElement<unknown>)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStaticItemInitialScrollPosition.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStaticItemInitialScrollPosition.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,WAAW,
|
|
1
|
+
{"version":3,"file":"useStaticItemInitialScrollPosition.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStaticItemInitialScrollPosition.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,yCAAyC;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IAC1D,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,kCAAkC,CAAC,EACjD,UAAU,EACV,WAAW,EACX,SAAS,EACT,KAAK,GACN,EAAE,yCAAyC,GAAG,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0B1E;AAED,eAAe,kCAAkC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStaticItemInitialScrollPosition.js","names":["useCallback","useMemo","getPositionOfSelectedItemElement","isItemElementWithDescription","isSectionElement","useStaticItemInitialScrollPosition","_ref","itemHeight","selectedKey","topOffset","items","disableScrollOnOpen","some","item","getInitialScrollPosition","_asyncToGenerator"],"sources":["../../../src/spectrum/utils/useStaticItemInitialScrollPosition.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport {\n getPositionOfSelectedItemElement,\n isItemElementWithDescription,\n isSectionElement,\n ItemElement,\n ItemKey,\n SectionElement,\n} from './itemUtils';\n\nexport interface UseStaticItemInitialScrollPositionOptions {\n itemHeight: number;\n items: (ItemElement<unknown> | SectionElement<unknown>)[];\n selectedKey?: ItemKey | null;\n topOffset: number;\n}\n\nexport function useStaticItemInitialScrollPosition({\n itemHeight,\n selectedKey,\n topOffset,\n items,\n}: UseStaticItemInitialScrollPositionOptions): () => Promise<number | null> {\n // Item descriptions and Section elements introduce variable item heights.\n // This throws off scroll position calculations, so we disable auto scrolling\n // if either of these are found.\n const disableScrollOnOpen = useMemo(\n () =>\n items.some(\n item => isSectionElement(item) || isItemElementWithDescription(item)\n ),\n [items]\n );\n\n const getInitialScrollPosition = useCallback(\n async () =>\n disableScrollOnOpen\n ? topOffset\n : getPositionOfSelectedItemElement({\n items,\n itemHeight,\n selectedKey,\n topOffset,\n }),\n [disableScrollOnOpen, itemHeight, items, selectedKey, topOffset]\n );\n\n return getInitialScrollPosition;\n}\n\nexport default useStaticItemInitialScrollPosition;\n"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAE3CC,gCAAgC,EAChCC,4BAA4B,EAC5BC,gBAAgB;AAalB,OAAO,SAASC,kCAAkCA,CAAAC,IAAA,EAK0B;EAAA,IALzB;IACjDC,UAAU;IACVC,WAAW;IACXC,SAAS;IACTC;EACyC,CAAC,GAAAJ,IAAA;EAC1C;EACA;EACA;EACA,IAAMK,mBAAmB,GAAGV,OAAO,CACjC,MACES,KAAK,CAACE,IAAI,CACRC,IAAI,IAAIT,gBAAgB,CAACS,IAAI,CAAC,IAAIV,4BAA4B,CAACU,IAAI,CACrE,CAAC,EACH,CAACH,KAAK,CACR,CAAC;EAED,IAAMI,wBAAwB,GAAGd,WAAW,eAAAe,iBAAA,CAC1C;IAAA,OACEJ,mBAAmB,GACfF,SAAS,GACTP,gCAAgC,CAAC;MAC/BQ,KAAK;MACLH,UAAU;MACVC,WAAW;MACXC;IACF,CAAC,CAAC;EAAA,IACR,CAACE,mBAAmB,EAAEJ,UAAU,EAAEG,KAAK,EAAEF,WAAW,EAAEC,SAAS,CACjE,CAAC;EAED,OAAOK,wBAAwB;AACjC;AAEA,eAAeT,kCAAkC"}
|
|
1
|
+
{"version":3,"file":"useStaticItemInitialScrollPosition.js","names":["useCallback","useMemo","getPositionOfSelectedItemElement","isItemElementWithDescription","isSectionElement","useStaticItemInitialScrollPosition","_ref","itemHeight","selectedKey","topOffset","items","disableScrollOnOpen","some","item","getInitialScrollPosition","_asyncToGenerator"],"sources":["../../../src/spectrum/utils/useStaticItemInitialScrollPosition.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport {\n getPositionOfSelectedItemElement,\n isItemElementWithDescription,\n isSectionElement,\n type ItemElement,\n type ItemKey,\n type SectionElement,\n} from './itemUtils';\n\nexport interface UseStaticItemInitialScrollPositionOptions {\n itemHeight: number;\n items: (ItemElement<unknown> | SectionElement<unknown>)[];\n selectedKey?: ItemKey | null;\n topOffset: number;\n}\n\nexport function useStaticItemInitialScrollPosition({\n itemHeight,\n selectedKey,\n topOffset,\n items,\n}: UseStaticItemInitialScrollPositionOptions): () => Promise<number | null> {\n // Item descriptions and Section elements introduce variable item heights.\n // This throws off scroll position calculations, so we disable auto scrolling\n // if either of these are found.\n const disableScrollOnOpen = useMemo(\n () =>\n items.some(\n item => isSectionElement(item) || isItemElementWithDescription(item)\n ),\n [items]\n );\n\n const getInitialScrollPosition = useCallback(\n async () =>\n disableScrollOnOpen\n ? topOffset\n : getPositionOfSelectedItemElement({\n items,\n itemHeight,\n selectedKey,\n topOffset,\n }),\n [disableScrollOnOpen, itemHeight, items, selectedKey, topOffset]\n );\n\n return getInitialScrollPosition;\n}\n\nexport default useStaticItemInitialScrollPosition;\n"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAE3CC,gCAAgC,EAChCC,4BAA4B,EAC5BC,gBAAgB;AAalB,OAAO,SAASC,kCAAkCA,CAAAC,IAAA,EAK0B;EAAA,IALzB;IACjDC,UAAU;IACVC,WAAW;IACXC,SAAS;IACTC;EACyC,CAAC,GAAAJ,IAAA;EAC1C;EACA;EACA;EACA,IAAMK,mBAAmB,GAAGV,OAAO,CACjC,MACES,KAAK,CAACE,IAAI,CACRC,IAAI,IAAIT,gBAAgB,CAACS,IAAI,CAAC,IAAIV,4BAA4B,CAACU,IAAI,CACrE,CAAC,EACH,CAACH,KAAK,CACR,CAAC;EAED,IAAMI,wBAAwB,GAAGd,WAAW,eAAAe,iBAAA,CAC1C;IAAA,OACEJ,mBAAmB,GACfF,SAAS,GACTP,gCAAgC,CAAC;MAC/BQ,KAAK;MACLH,UAAU;MACVC,WAAW;MACXC;IACF,CAAC,CAAC;EAAA,IACR,CAACE,mBAAmB,EAAEJ,UAAU,EAAEG,KAAK,EAAEF,WAAW,EAAEC,SAAS,CACjE,CAAC;EAED,OAAOK,wBAAwB;AACjC;AAEA,eAAeT,kCAAkC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Key } from 'react';
|
|
2
|
-
import { ItemKey, ItemSelection, NormalizedItem } from './itemUtils';
|
|
1
|
+
import { type Key } from 'react';
|
|
2
|
+
import { type ItemKey, type ItemSelection, type NormalizedItem } from './itemUtils';
|
|
3
3
|
export interface UseStringifiedMultiSelectionOptions {
|
|
4
4
|
normalizedItems: NormalizedItem[];
|
|
5
5
|
selectedKeys?: 'all' | Iterable<ItemKey>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStringifiedMultiSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useStringifiedMultiSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAwB,MAAM,OAAO,CAAC;AACvD,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,aAAa,EAElB,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,mCAAmC;IAClD,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzC,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,kCAAkC;IACjD,iCAAiC;IACjC,kBAAkB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,yCAAyC;IACzC,yBAAyB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,gCAAgC;IAChC,kBAAkB,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,mEAAmE;IACnE,uBAAuB,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,GACT,EAAE,mCAAmC,GAAG,kCAAkC,CA8C1E;AAED,eAAe,4BAA4B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStringifiedMultiSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedMultiSelection","_ref","normalizedItems","defaultSelectedKeys","disabledKeys","selectedKeys","onChange","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","keys","actualKeys","Set","forEach","item","has","String","add"],"sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n ItemKey,\n ItemSelection,\n itemSelectionToStringSet,\n NormalizedItem,\n} from './itemUtils';\n\nexport interface UseStringifiedMultiSelectionOptions {\n normalizedItems: NormalizedItem[];\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: ItemSelection) => void;\n}\n\nexport interface UseStringifiedMultiSelectionResult {\n /** Stringified selection keys */\n selectedStringKeys?: 'all' | Set<Key>;\n /** Stringified default selection keys */\n defaultSelectedStringKeys?: 'all' | Set<Key>;\n /** Stringified disabled keys */\n disabledStringKeys?: 'all' | Set<Key>;\n /** Handler that is called when the string key selections change */\n onStringSelectionChange: (keys: 'all' | Set<Key>) => void;\n}\n\n/**\n * Spectrum collection components treat keys as strings if the `key` prop is\n * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,\n * we need to ensure that keys are strings in order for selection to work. We\n * then need to convert back to the original key types in the onChange handler.\n * This hook encapsulates converting to and from strings so that keys can match\n * the original key type.\n * @param normalizedItems The normalized items to select from.\n * @param selectedKeys The currently selected keys in the collection.\n * @param defaultSelectedKeys The initial selected keys in the collection.\n * @param disabledKeys The currently disabled keys in the collection.\n * @param onChange Handler that is called when the selection changes.\n * @returns UseStringifiedMultiSelectionResult with stringified key sets and\n * string key selection change handler.\n */\nexport function useStringifiedMultiSelection({\n normalizedItems,\n defaultSelectedKeys,\n disabledKeys,\n selectedKeys,\n onChange,\n}: UseStringifiedMultiSelectionOptions): UseStringifiedMultiSelectionResult {\n const selectedStringKeys = useMemo(\n () => itemSelectionToStringSet(selectedKeys),\n [selectedKeys]\n );\n\n const defaultSelectedStringKeys = useMemo(\n () => itemSelectionToStringSet(defaultSelectedKeys),\n [defaultSelectedKeys]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (keys: 'all' | Set<Key>) => {\n if (onChange == null) {\n return;\n }\n\n if (keys === 'all') {\n onChange('all');\n return;\n }\n\n const actualKeys = new Set<ItemKey>();\n\n normalizedItems.forEach(item => {\n if (keys.has(String(getItemKey(item)))) {\n actualKeys.add(getItemKey(item));\n }\n });\n\n onChange(actualKeys);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedMultiSelection;\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"useStringifiedMultiSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedMultiSelection","_ref","normalizedItems","defaultSelectedKeys","disabledKeys","selectedKeys","onChange","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","keys","actualKeys","Set","forEach","item","has","String","add"],"sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"sourcesContent":["import { type Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n type ItemKey,\n type ItemSelection,\n itemSelectionToStringSet,\n type NormalizedItem,\n} from './itemUtils';\n\nexport interface UseStringifiedMultiSelectionOptions {\n normalizedItems: NormalizedItem[];\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: ItemSelection) => void;\n}\n\nexport interface UseStringifiedMultiSelectionResult {\n /** Stringified selection keys */\n selectedStringKeys?: 'all' | Set<Key>;\n /** Stringified default selection keys */\n defaultSelectedStringKeys?: 'all' | Set<Key>;\n /** Stringified disabled keys */\n disabledStringKeys?: 'all' | Set<Key>;\n /** Handler that is called when the string key selections change */\n onStringSelectionChange: (keys: 'all' | Set<Key>) => void;\n}\n\n/**\n * Spectrum collection components treat keys as strings if the `key` prop is\n * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,\n * we need to ensure that keys are strings in order for selection to work. We\n * then need to convert back to the original key types in the onChange handler.\n * This hook encapsulates converting to and from strings so that keys can match\n * the original key type.\n * @param normalizedItems The normalized items to select from.\n * @param selectedKeys The currently selected keys in the collection.\n * @param defaultSelectedKeys The initial selected keys in the collection.\n * @param disabledKeys The currently disabled keys in the collection.\n * @param onChange Handler that is called when the selection changes.\n * @returns UseStringifiedMultiSelectionResult with stringified key sets and\n * string key selection change handler.\n */\nexport function useStringifiedMultiSelection({\n normalizedItems,\n defaultSelectedKeys,\n disabledKeys,\n selectedKeys,\n onChange,\n}: UseStringifiedMultiSelectionOptions): UseStringifiedMultiSelectionResult {\n const selectedStringKeys = useMemo(\n () => itemSelectionToStringSet(selectedKeys),\n [selectedKeys]\n );\n\n const defaultSelectedStringKeys = useMemo(\n () => itemSelectionToStringSet(defaultSelectedKeys),\n [defaultSelectedKeys]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (keys: 'all' | Set<Key>) => {\n if (onChange == null) {\n return;\n }\n\n if (keys === 'all') {\n onChange('all');\n return;\n }\n\n const actualKeys = new Set<ItemKey>();\n\n normalizedItems.forEach(item => {\n if (keys.has(String(getItemKey(item)))) {\n actualKeys.add(getItemKey(item));\n }\n });\n\n onChange(actualKeys);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedMultiSelection;\n"],"mappings":"AAAA,SAAmBA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAErDC,UAAU,EAGVC,wBAAwB;AA6B1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAAC,IAAA,EAMgC;EAAA,IAN/B;IAC3CC,eAAe;IACfC,mBAAmB;IACnBC,YAAY;IACZC,YAAY;IACZC;EACmC,CAAC,GAAAL,IAAA;EACpC,IAAMM,kBAAkB,GAAGV,OAAO,CAChC,MAAME,wBAAwB,CAACM,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMG,yBAAyB,GAAGX,OAAO,CACvC,MAAME,wBAAwB,CAACI,mBAAmB,CAAC,EACnD,CAACA,mBAAmB,CACtB,CAAC;EAED,IAAMM,kBAAkB,GAAGZ,OAAO,CAChC,MAAME,wBAAwB,CAACK,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMM,uBAAuB,GAAGd,WAAW,CACxCe,IAAsB,IAAK;IAC1B,IAAIL,QAAQ,IAAI,IAAI,EAAE;MACpB;IACF;IAEA,IAAIK,IAAI,KAAK,KAAK,EAAE;MAClBL,QAAQ,CAAC,KAAK,CAAC;MACf;IACF;IAEA,IAAMM,UAAU,GAAG,IAAIC,GAAG,CAAU,CAAC;IAErCX,eAAe,CAACY,OAAO,CAACC,IAAI,IAAI;MAC9B,IAAIJ,IAAI,CAACK,GAAG,CAACC,MAAM,CAACnB,UAAU,CAACiB,IAAI,CAAC,CAAC,CAAC,EAAE;QACtCH,UAAU,CAACM,GAAG,CAACpB,UAAU,CAACiB,IAAI,CAAC,CAAC;MAClC;IACF,CAAC,CAAC;IAEFT,QAAQ,CAACM,UAAU,CAAC;EACtB,CAAC,EACD,CAACV,eAAe,EAAEI,QAAQ,CAC5B,CAAC;EAED,OAAO;IACLC,kBAAkB;IAClBC,yBAAyB;IACzBC,kBAAkB;IAClBC;EACF,CAAC;AACH;AAEA,eAAeV,4BAA4B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Key } from 'react';
|
|
2
|
-
import { ItemKey, NormalizedItem, NormalizedSection } from './itemUtils';
|
|
1
|
+
import { type Key } from 'react';
|
|
2
|
+
import { type ItemKey, type NormalizedItem, type NormalizedSection } from './itemUtils';
|
|
3
3
|
export interface UseStringifiedSelectionOptions {
|
|
4
4
|
normalizedItems: (NormalizedItem | NormalizedSection)[];
|
|
5
5
|
selectedKey: ItemKey | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStringifiedSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useStringifiedSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAwB,MAAM,OAAO,CAAC;AACvD,OAAO,EAEL,KAAK,OAAO,EAEZ,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,8BAA8B;IAC7C,eAAe,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IACxD,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,kBAAkB,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAC5C,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACvD;AAED,MAAM,WAAW,6BAA6B;IAC5C,wBAAwB,CAAC,EAAE,GAAG,CAAC;IAC/B,iBAAiB,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC/B,kBAAkB,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,uBAAuB,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC;CACpD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,EAAE,8BAA8B,GAAG,6BAA6B,CA6ChE;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStringifiedSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedSelection","_ref","normalizedItems","defaultSelectedKey","selectedKey","disabledKeys","onChange","selectedStringKey","String","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","key","_getItemKey","selectedItem","find","item","actualKey"],"sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n ItemKey,\n itemSelectionToStringSet,\n NormalizedItem,\n NormalizedSection,\n} from './itemUtils';\n\nexport interface UseStringifiedSelectionOptions {\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n selectedKey: ItemKey | null | undefined;\n defaultSelectedKey: ItemKey | undefined;\n disabledKeys: Iterable<ItemKey> | undefined;\n onChange: ((key: ItemKey | null) => void) | undefined;\n}\n\nexport interface UseStringifiedSelectionResult {\n defaultSelectedStringKey?: Key;\n selectedStringKey?: Key | null;\n disabledStringKeys?: Set<Key>;\n onStringSelectionChange: (key: Key | null) => void;\n}\n\n/**\n * Spectrum collection components treat keys as strings if the `key` prop is\n * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,\n * we need to ensure that keys are strings in order for selection to work. We\n * then need to convert back to the original key types in the onChange handler.\n * This hook encapsulates converting to and from strings so that keys can match\n * the original key type.\n * @param normalizedItems The normalized items to select from.\n * @param selectedKey The currently selected key in the collection.\n * @param defaultSelectedKey The initial selected key in the collection.\n * @param disabledKeys The currently disabled keys in the collection.\n * @param onChange Handler that is called when the selection changes.\n * @returns UseStringifiedSelectionResult with stringified key sets and string\n * key selection change handler.\n */\nexport function useStringifiedSelection({\n normalizedItems,\n defaultSelectedKey,\n selectedKey,\n disabledKeys,\n onChange,\n}: UseStringifiedSelectionOptions): UseStringifiedSelectionResult {\n const selectedStringKey = useMemo(\n () => (selectedKey == null ? selectedKey : String(selectedKey)),\n [selectedKey]\n );\n\n const defaultSelectedStringKey = useMemo(\n () =>\n defaultSelectedKey == null\n ? defaultSelectedKey\n : String(defaultSelectedKey),\n [defaultSelectedKey]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (key: Key | null): void => {\n if (onChange == null) {\n return;\n }\n\n // The `key` arg will always be a string due to us setting the `Item` key\n // prop in `renderItem`. We need to find the matching item to determine\n // the actual key.\n const selectedItem = normalizedItems.find(\n item => String(getItemKey(item)) === key\n );\n\n const actualKey = getItemKey(selectedItem) ?? key;\n\n onChange(actualKey);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedSelection;\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"useStringifiedSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedSelection","_ref","normalizedItems","defaultSelectedKey","selectedKey","disabledKeys","onChange","selectedStringKey","String","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","key","_getItemKey","selectedItem","find","item","actualKey"],"sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"sourcesContent":["import { type Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n type ItemKey,\n itemSelectionToStringSet,\n type NormalizedItem,\n type NormalizedSection,\n} from './itemUtils';\n\nexport interface UseStringifiedSelectionOptions {\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n selectedKey: ItemKey | null | undefined;\n defaultSelectedKey: ItemKey | undefined;\n disabledKeys: Iterable<ItemKey> | undefined;\n onChange: ((key: ItemKey | null) => void) | undefined;\n}\n\nexport interface UseStringifiedSelectionResult {\n defaultSelectedStringKey?: Key;\n selectedStringKey?: Key | null;\n disabledStringKeys?: Set<Key>;\n onStringSelectionChange: (key: Key | null) => void;\n}\n\n/**\n * Spectrum collection components treat keys as strings if the `key` prop is\n * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,\n * we need to ensure that keys are strings in order for selection to work. We\n * then need to convert back to the original key types in the onChange handler.\n * This hook encapsulates converting to and from strings so that keys can match\n * the original key type.\n * @param normalizedItems The normalized items to select from.\n * @param selectedKey The currently selected key in the collection.\n * @param defaultSelectedKey The initial selected key in the collection.\n * @param disabledKeys The currently disabled keys in the collection.\n * @param onChange Handler that is called when the selection changes.\n * @returns UseStringifiedSelectionResult with stringified key sets and string\n * key selection change handler.\n */\nexport function useStringifiedSelection({\n normalizedItems,\n defaultSelectedKey,\n selectedKey,\n disabledKeys,\n onChange,\n}: UseStringifiedSelectionOptions): UseStringifiedSelectionResult {\n const selectedStringKey = useMemo(\n () => (selectedKey == null ? selectedKey : String(selectedKey)),\n [selectedKey]\n );\n\n const defaultSelectedStringKey = useMemo(\n () =>\n defaultSelectedKey == null\n ? defaultSelectedKey\n : String(defaultSelectedKey),\n [defaultSelectedKey]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (key: Key | null): void => {\n if (onChange == null) {\n return;\n }\n\n // The `key` arg will always be a string due to us setting the `Item` key\n // prop in `renderItem`. We need to find the matching item to determine\n // the actual key.\n const selectedItem = normalizedItems.find(\n item => String(getItemKey(item)) === key\n );\n\n const actualKey = getItemKey(selectedItem) ?? key;\n\n onChange(actualKey);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedSelection;\n"],"mappings":"AAAA,SAAmBA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAErDC,UAAU,EAEVC,wBAAwB;AAoB1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAAC,IAAA,EAM2B;EAAA,IAN1B;IACtCC,eAAe;IACfC,kBAAkB;IAClBC,WAAW;IACXC,YAAY;IACZC;EAC8B,CAAC,GAAAL,IAAA;EAC/B,IAAMM,iBAAiB,GAAGV,OAAO,CAC/B,MAAOO,WAAW,IAAI,IAAI,GAAGA,WAAW,GAAGI,MAAM,CAACJ,WAAW,CAAE,EAC/D,CAACA,WAAW,CACd,CAAC;EAED,IAAMK,wBAAwB,GAAGZ,OAAO,CACtC,MACEM,kBAAkB,IAAI,IAAI,GACtBA,kBAAkB,GAClBK,MAAM,CAACL,kBAAkB,CAAC,EAChC,CAACA,kBAAkB,CACrB,CAAC;EAED,IAAMO,kBAAkB,GAAGb,OAAO,CAChC,MAAME,wBAAwB,CAACM,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMM,uBAAuB,GAAGf,WAAW,CACxCgB,GAAe,IAAW;IAAA,IAAAC,WAAA;IACzB,IAAIP,QAAQ,IAAI,IAAI,EAAE;MACpB;IACF;;IAEA;IACA;IACA;IACA,IAAMQ,YAAY,GAAGZ,eAAe,CAACa,IAAI,CACvCC,IAAI,IAAIR,MAAM,CAACV,UAAU,CAACkB,IAAI,CAAC,CAAC,KAAKJ,GACvC,CAAC;IAED,IAAMK,SAAS,IAAAJ,WAAA,GAAGf,UAAU,CAACgB,YAAY,CAAC,cAAAD,WAAA,cAAAA,WAAA,GAAID,GAAG;IAEjDN,QAAQ,CAACW,SAAS,CAAC;EACrB,CAAC,EACD,CAACf,eAAe,EAAEI,QAAQ,CAC5B,CAAC;EAED,OAAO;IACLC,iBAAiB;IACjBE,wBAAwB;IACxBC,kBAAkB;IAClBC;EACF,CAAC;AACH;AAEA,eAAeX,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpectrumThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/SpectrumThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SpectrumThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/SpectrumThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAEjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;CACpE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,QAAgB,EAChB,KAAsB,EACtB,WAAW,EACX,MAAM,EACN,QAAQ,GACT,EAAE,0BAA0B,GAAG,GAAG,CAAC,OAAO,CAkB1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpectrumThemeProvider.js","names":["useState","Provider","nanoid","themeDHDefault","jsx","_jsx","SpectrumThemeProvider","_ref","children","isPortal","theme","colorScheme","zIndex","position","id","UNSAFE_className"],"sources":["../../src/theme/SpectrumThemeProvider.tsx"],"sourcesContent":["import { ReactNode, useState } from 'react';\nimport { Provider } from '@adobe/react-spectrum';\nimport type { Theme } from '@react-types/provider';\nimport { nanoid } from 'nanoid';\nimport { themeDHDefault } from '../spectrum/utils';\n\nexport interface SpectrumThemeProviderProps {\n children: ReactNode;\n isPortal?: boolean;\n theme?: Theme;\n colorScheme?: 'light' | 'dark';\n zIndex?: number;\n position?: 'static' | 'absolute' | 'fixed' | 'relative' | 'sticky';\n}\n\n/**\n * Wrapper around React Spectrum's theme Provider that provides DH mappings of\n * Spectrum's theme variables to DH's theme variables. Also exposes an optional\n * `isPortal` prop that if provided, adds a unique `data-unique-id` attribute to\n * the Provider. This is needed to force the Provider to render the theme wrapper\n * inside of portals.\n */\nexport function SpectrumThemeProvider({\n children,\n isPortal = false,\n theme = themeDHDefault,\n colorScheme,\n zIndex,\n position,\n}: SpectrumThemeProviderProps): JSX.Element {\n // a unique ID is used per provider to force it to render the theme wrapper element inside portals\n // based on https://github.com/adobe/react-spectrum/issues/1697#issuecomment-999827266\n // won't be needed if https://github.com/adobe/react-spectrum/pull/2669 is merged\n const [id] = useState(isPortal ? nanoid() : null);\n\n return (\n <Provider\n UNSAFE_className=\"spectrum-theme-provider\"\n theme={theme}\n colorScheme={colorScheme}\n zIndex={zIndex}\n position={position}\n data-unique-id={id}\n >\n {children}\n </Provider>\n );\n}\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"SpectrumThemeProvider.js","names":["useState","Provider","nanoid","themeDHDefault","jsx","_jsx","SpectrumThemeProvider","_ref","children","isPortal","theme","colorScheme","zIndex","position","id","UNSAFE_className"],"sources":["../../src/theme/SpectrumThemeProvider.tsx"],"sourcesContent":["import { type ReactNode, useState } from 'react';\nimport { Provider } from '@adobe/react-spectrum';\nimport type { Theme } from '@react-types/provider';\nimport { nanoid } from 'nanoid';\nimport { themeDHDefault } from '../spectrum/utils';\n\nexport interface SpectrumThemeProviderProps {\n children: ReactNode;\n isPortal?: boolean;\n theme?: Theme;\n colorScheme?: 'light' | 'dark';\n zIndex?: number;\n position?: 'static' | 'absolute' | 'fixed' | 'relative' | 'sticky';\n}\n\n/**\n * Wrapper around React Spectrum's theme Provider that provides DH mappings of\n * Spectrum's theme variables to DH's theme variables. Also exposes an optional\n * `isPortal` prop that if provided, adds a unique `data-unique-id` attribute to\n * the Provider. This is needed to force the Provider to render the theme wrapper\n * inside of portals.\n */\nexport function SpectrumThemeProvider({\n children,\n isPortal = false,\n theme = themeDHDefault,\n colorScheme,\n zIndex,\n position,\n}: SpectrumThemeProviderProps): JSX.Element {\n // a unique ID is used per provider to force it to render the theme wrapper element inside portals\n // based on https://github.com/adobe/react-spectrum/issues/1697#issuecomment-999827266\n // won't be needed if https://github.com/adobe/react-spectrum/pull/2669 is merged\n const [id] = useState(isPortal ? nanoid() : null);\n\n return (\n <Provider\n UNSAFE_className=\"spectrum-theme-provider\"\n theme={theme}\n colorScheme={colorScheme}\n zIndex={zIndex}\n position={position}\n data-unique-id={id}\n >\n {children}\n </Provider>\n );\n}\n"],"mappings":"AAAA,SAAyBA,QAAQ,QAAQ,OAAO;AAChD,SAASC,QAAQ,QAAQ,uBAAuB;AAEhD,SAASC,MAAM,QAAQ,QAAQ;AAAC,SACvBC,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAWvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAAAC,IAAA,EAOO;EAAA,IAPN;IACpCC,QAAQ;IACRC,QAAQ,GAAG,KAAK;IAChBC,KAAK,GAAGP,cAAc;IACtBQ,WAAW;IACXC,MAAM;IACNC;EAC0B,CAAC,GAAAN,IAAA;EAC3B;EACA;EACA;EACA,IAAM,CAACO,EAAE,CAAC,GAAGd,QAAQ,CAACS,QAAQ,GAAGP,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;EAEjD,oBACEG,IAAA,CAACJ,QAAQ;IACPc,gBAAgB,EAAC,yBAAyB;IAC1CL,KAAK,EAAEA,KAAM;IACbC,WAAW,EAAEA,WAAY;IACzBC,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEA,QAAS;IACnB,kBAAgBC,EAAG;IAAAN,QAAA,EAElBA;EAAQ,CACD,CAAC;AAEf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemePicker.js","names":["useCallback","Item","Picker","useTheme","jsx","_jsx","ThemePicker","selectedThemeKey","setSelectedThemeKey","themes","onSelectionChange","key","label","items","selectedKey","children","item","name","themeKey"],"sources":["../../src/theme/ThemePicker.tsx"],"sourcesContent":["import { Key, useCallback } from 'react';\nimport { Item, Picker } from '@adobe/react-spectrum';\nimport useTheme from './useTheme';\n\nexport function ThemePicker(): JSX.Element | null {\n const { selectedThemeKey, setSelectedThemeKey, themes } = useTheme();\n\n const onSelectionChange = useCallback(\n (key: Key) => {\n setSelectedThemeKey(key as string);\n },\n [setSelectedThemeKey]\n );\n\n return (\n <Picker\n label=\"Pick a color scheme\"\n items={themes}\n selectedKey={selectedThemeKey}\n onSelectionChange={onSelectionChange}\n >\n {item => <Item key={item.themeKey}>{item.name}</Item>}\n </Picker>\n );\n}\n\nexport default ThemePicker;\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"ThemePicker.js","names":["useCallback","Item","Picker","useTheme","jsx","_jsx","ThemePicker","selectedThemeKey","setSelectedThemeKey","themes","onSelectionChange","key","label","items","selectedKey","children","item","name","themeKey"],"sources":["../../src/theme/ThemePicker.tsx"],"sourcesContent":["import { type Key, useCallback } from 'react';\nimport { Item, Picker } from '@adobe/react-spectrum';\nimport useTheme from './useTheme';\n\nexport function ThemePicker(): JSX.Element | null {\n const { selectedThemeKey, setSelectedThemeKey, themes } = useTheme();\n\n const onSelectionChange = useCallback(\n (key: Key) => {\n setSelectedThemeKey(key as string);\n },\n [setSelectedThemeKey]\n );\n\n return (\n <Picker\n label=\"Pick a color scheme\"\n items={themes}\n selectedKey={selectedThemeKey}\n onSelectionChange={onSelectionChange}\n >\n {item => <Item key={item.themeKey}>{item.name}</Item>}\n </Picker>\n );\n}\n\nexport default ThemePicker;\n"],"mappings":"AAAA,SAAmBA,WAAW,QAAQ,OAAO;AAC7C,SAASC,IAAI,EAAEC,MAAM,QAAQ,uBAAuB;AAAC,OAC9CC,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEf,OAAO,SAASC,WAAWA,CAAA,EAAuB;EAChD,IAAM;IAAEC,gBAAgB;IAAEC,mBAAmB;IAAEC;EAAO,CAAC,GAAGN,QAAQ,CAAC,CAAC;EAEpE,IAAMO,iBAAiB,GAAGV,WAAW,CAClCW,GAAQ,IAAK;IACZH,mBAAmB,CAACG,GAAa,CAAC;EACpC,CAAC,EACD,CAACH,mBAAmB,CACtB,CAAC;EAED,oBACEH,IAAA,CAACH,MAAM;IACLU,KAAK,EAAC,qBAAqB;IAC3BC,KAAK,EAAEJ,MAAO;IACdK,WAAW,EAAEP,gBAAiB;IAC9BG,iBAAiB,EAAEA,iBAAkB;IAAAK,QAAA,EAEpCC,IAAI,iBAAIX,IAAA,CAACJ,IAAI;MAAAc,QAAA,EAAsBC,IAAI,CAACC;IAAI,GAAzBD,IAAI,CAACE,QAA2B;EAAC,CAC/C,CAAC;AAEb;AAEA,eAAeZ,WAAW"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { ThemeData } from './ThemeModel';
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ThemeData } from './ThemeModel';
|
|
3
3
|
import './theme-svg.scss';
|
|
4
4
|
export interface ThemeContextValue {
|
|
5
5
|
activeThemes: ThemeData[] | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9E,OAAO,kBAAkB,CAAC;AAE1B,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAID,eAAO,MAAM,YAAY,mDAAgD,CAAC;AAE1E,MAAM,WAAW,kBAAkB;IAMjC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EAAE,YAAY,EACpB,oBAAqD,EACrD,QAAQ,GACT,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAkFzC;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","names":["createContext","useEffect","useMemo","useState","Log","DEFAULT_PRELOAD_DATA_VARIABLES","calculatePreloadStyleContent","getActiveThemes","getDefaultBaseThemes","setThemePreloadData","overrideSVGFillColors","getDefaultSelectedThemeKey","SpectrumThemeProvider","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","log","module","ThemeContext","ThemeProvider","_ref","themes","customThemes","defaultPreloadValues","children","baseThemes","value","setValue","selectedThemeKey","setSelectedThemeKey","activeThemes","base","custom","updateThemePreloadData","preloadStyleContent","debug2","active","map","theme","themeKey","styleContent","Provider"],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ThemeProvider.js","names":["createContext","useEffect","useMemo","useState","Log","DEFAULT_PRELOAD_DATA_VARIABLES","calculatePreloadStyleContent","getActiveThemes","getDefaultBaseThemes","setThemePreloadData","overrideSVGFillColors","getDefaultSelectedThemeKey","SpectrumThemeProvider","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","log","module","ThemeContext","ThemeProvider","_ref","themes","customThemes","defaultPreloadValues","children","baseThemes","value","setValue","selectedThemeKey","setSelectedThemeKey","activeThemes","base","custom","updateThemePreloadData","preloadStyleContent","debug2","active","map","theme","themeKey","styleContent","Provider"],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport Log from '@deephaven/log';\nimport { DEFAULT_PRELOAD_DATA_VARIABLES, type ThemeData } from './ThemeModel';\nimport {\n calculatePreloadStyleContent,\n getActiveThemes,\n getDefaultBaseThemes,\n setThemePreloadData,\n overrideSVGFillColors,\n getDefaultSelectedThemeKey,\n} from './ThemeUtils';\nimport { SpectrumThemeProvider } from './SpectrumThemeProvider';\nimport './theme-svg.scss';\n\nexport interface ThemeContextValue {\n activeThemes: ThemeData[] | null;\n selectedThemeKey: string;\n themes: ThemeData[];\n setSelectedThemeKey: (themeKey: string) => void;\n}\n\nconst log = Log.module('ThemeProvider');\n\nexport const ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n /*\n * Additional themes to load in addition to the base themes. If no additional\n * themes are to be loaded, this must be set to an empty array in order to\n * tell the provider to activate the base themes.\n */\n themes: ThemeData[] | null;\n defaultPreloadValues?: Record<string, string>;\n children: ReactNode;\n}\n\nexport function ThemeProvider({\n themes: customThemes,\n defaultPreloadValues = DEFAULT_PRELOAD_DATA_VARIABLES,\n children,\n}: ThemeProviderProps): JSX.Element | null {\n const baseThemes = useMemo(() => getDefaultBaseThemes(), []);\n\n const [value, setValue] = useState<ThemeContextValue | null>(null);\n\n const [selectedThemeKey, setSelectedThemeKey] = useState<string>(\n getDefaultSelectedThemeKey\n );\n\n // Calculate active themes once a non-null themes array is provided.\n const activeThemes = useMemo(\n () =>\n customThemes == null\n ? null\n : getActiveThemes(selectedThemeKey, {\n base: baseThemes,\n custom: customThemes ?? [],\n }),\n [baseThemes, selectedThemeKey, customThemes]\n );\n\n const themes = useMemo(\n () => [...baseThemes, ...(customThemes ?? [])],\n [baseThemes, customThemes]\n );\n\n useEffect(\n function updateThemePreloadData() {\n // Don't update preload data until themes have been loaded and activated\n if (activeThemes == null || customThemes == null) {\n return;\n }\n\n // Override fill color for certain inline SVGs (the originals are provided\n // by theme-svg.scss)\n overrideSVGFillColors(defaultPreloadValues);\n\n const preloadStyleContent =\n calculatePreloadStyleContent(defaultPreloadValues);\n\n log.debug2('updateThemePreloadData:', {\n active: activeThemes.map(theme => theme.themeKey),\n custom: customThemes.map(theme => theme.themeKey),\n preloadStyleContent,\n selectedThemeKey,\n });\n\n setThemePreloadData({\n themeKey: selectedThemeKey,\n preloadStyleContent,\n });\n },\n [activeThemes, selectedThemeKey, customThemes, defaultPreloadValues]\n );\n\n useEffect(() => {\n setValue({\n activeThemes,\n selectedThemeKey,\n themes,\n setSelectedThemeKey,\n });\n }, [activeThemes, selectedThemeKey, themes]);\n\n return (\n <>\n {activeThemes == null ? null : (\n <>\n {activeThemes.map(theme => (\n <style data-theme-key={theme.themeKey} key={theme.themeKey}>\n {theme.styleContent}\n </style>\n ))}\n </>\n )}\n {value == null ? null : (\n <ThemeContext.Provider value={value}>\n <SpectrumThemeProvider>{children}</SpectrumThemeProvider>\n </ThemeContext.Provider>\n )}\n </>\n );\n}\n\nexport default ThemeProvider;\n"],"mappings":"AAAA,SACEA,aAAa,EAEbC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,OAAO;AACd,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SACxBC,8BAA8B;AAAA,SAErCC,4BAA4B,EAC5BC,eAAe,EACfC,oBAAoB,EACpBC,mBAAmB,EACnBC,qBAAqB,EACrBC,0BAA0B;AAAA,SAEnBC,qBAAqB;AAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAU9B,IAAMC,GAAG,GAAGf,GAAG,CAACgB,MAAM,CAAC,eAAe,CAAC;AAEvC,OAAO,IAAMC,YAAY,gBAAGrB,aAAa,CAA2B,IAAI,CAAC;AAazE,OAAO,SAASsB,aAAaA,CAAAC,IAAA,EAIc;EAAA,IAJb;IAC5BC,MAAM,EAAEC,YAAY;IACpBC,oBAAoB,GAAGrB,8BAA8B;IACrDsB;EACkB,CAAC,GAAAJ,IAAA;EACnB,IAAMK,UAAU,GAAG1B,OAAO,CAAC,MAA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AAC,CAAC;EACJ,CAAC,EACD,CAACJ,YAAY,EAAEF,gBAAgB,EAAEN,YAAY,EAAEC,oBAAoB,CACrE,CAAC;EAEDzB,SAAS,CAAC,MAAM;IACd6B,QAAQ,CAAC;MACPG,YAAY;MACZF,gBAAgB;MAChBP,MAAM;MACNQ;IACF,CAAC,CAAC;EACJ,CAAC,EAAE,CAACC,YAAY,EAAEF,gBAAgB,EAAEP,MAAM,CAAC,CAAC;EAE5C,oBACEN,KAAA,CAAAF,SAAA;IAAAW,QAAA,GACGM,YAAY,IAAI,IAAI,GAAG,IAAI,gBAC1BnB,IAAA,CAAAE,SAAA;MAAAW,QAAA,EACGM,YAAY,CAACO,GAAG,CAACC,KAAK,iBACrB3B,IAAA;QAAO,kBAAgB2B,KAAK,CAACC,QAAS;QAAAf,QAAA,EACnCc,KAAK,CAACE;MAAY,GADuBF,KAAK,CAACC,QAE3C,CACR;IAAC,CACF,CACH,EACAb,KAAK,IAAI,IAAI,GAAG,IAAI,gBACnBf,IAAA,CAACO,YAAY,CAACuB,QAAQ;MAACf,KAAK,EAAEA,KAAM;MAAAF,QAAA,eAClCb,IAAA,CAACF,qBAAqB;QAAAe,QAAA,EAAEA;MAAQ,CAAwB;IAAC,CACpC,CACxB;EAAA,CACD,CAAC;AAEP;AAEA,eAAeL,aAAa"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThemeData, ThemePreloadData, CssVariableStyleContent, ThemeRegistrationData, ThemeCssVariableName } from './ThemeModel';
|
|
1
|
+
import { type ThemeData, type ThemePreloadData, type CssVariableStyleContent, type ThemeRegistrationData, type ThemeCssVariableName } from './ThemeModel';
|
|
2
2
|
export declare const CSS_VAR_EXPRESSION_PREFIX = "var(--";
|
|
3
3
|
export declare const TMP_CSS_PROP_PREFIX = "dh-tmp";
|
|
4
4
|
export declare const NON_WHITESPACE_REGEX: RegExp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeUtils.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,SAAS,
|
|
1
|
+
{"version":3,"file":"ThemeUtils.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAE5B,KAAK,qBAAqB,EAG1B,KAAK,oBAAoB,EAG1B,MAAM,cAAc,CAAC;AAItB,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAC5C,eAAO,MAAM,oBAAoB,QAAO,CAAC;AACzC,eAAO,MAAM,gBAAgB,QAAO,CAAC;AAErC,MAAM,MAAM,qBAAqB,GAAG,CAAC,aAAa,EAAE,MAAM,KAAK,MAAM,CAAC;AAEtE;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3C,uBAAuB,CAazB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,OAAO,EACX,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,CAAC,OAAO,EAAE,oBAAoB,KAAK,MAAM,CAgB3C;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,iBAAiB,MAAM,EAAE,EAC7B,mBAAmB,EAAE,uBAAuB,GAC3C,IAAI,CAKN;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,GAAG,CAAC,MAAM,CAAC,CAcb;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,qBAAqB,GACvC,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CA+BtC;AAED;;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@@
|
|
|
1
|
-
{"version":3,"file":"ThemeUtils.js","names":["Log","assertNotNull","ColorUtils","themeDark","themeLight","DEFAULT_DARK_THEME_KEY","DEFAULT_LIGHT_THEME_KEY","DEFAULT_PRELOAD_DATA_VARIABLES","THEME_CACHE_LOCAL_STORAGE_KEY","SVG_ICON_MANUAL_COLOR_MAP","THEME_KEY_OVERRIDE_QUERY_PARAM","log","module","CSS_VAR_EXPRESSION_PREFIX","TMP_CSS_PROP_PREFIX","NON_WHITESPACE_REGEX","WHITESPACE_REGEX","calculatePreloadStyleContent","defaultPreloadValues","resolveVar","createCssVariableResolver","document","body","pairs","Object","keys","map","key","concat","join","el","defaultValues","computedStyle","getComputedStyle","cssVariableResolver","varName","_defaultValues","value","getPropertyValue","createPreloadStyleElement","id","preloadStyleContent","style","createElement","innerHTML","head","appendChild","extractDistinctCssVariableExpressions","record","set","Set","values","forEach","getExpressionRanges","_ref","start","end","expression","substring","includes","add","getActiveThemes","themeKey","themeRegistration","_custom$baseThemeKey","custom","find","theme","baseThemeKey","base","error","debug","getDefaultBaseThemes","name","styleContent","getDefaultSelectedThemeKey","_ref2","_getThemeKeyOverride","_getThemePreloadData","getThemeKeyOverride","getThemePreloadData","searchParams","URLSearchParams","window","location","search","get","data","localStorage","getItem","JSON","parse","_unused","_NON_WHITESPACE_REGEX","_NON_WHITESPACE_REGEX2","ranges","exec","index","parenLevel","i","length","test","push","replaceSVGFillColor","svgContent","fillColor","replace","encodeURIComponent","resolveCssVariablesInRecord","targetElement","arguments","undefined","isAlphaOptional","perfStart","performance","now","tmpPropEl","display","recordArray","entries","_ref3","setProperty","backgroundColor","tempPropElComputedStyle","result","_ref4","resolved","containsCssVar","isColor","CSS","supports","children","color","normalizeCssColor","remove","resolveCssVariablesInString","resolver","_ref5","setThemePreloadData","preloadData","setItem","stringify","getThemeKey","pluginName","themeName","preloadTheme","_getThemePreloadData2","previousPreloadStyleContent","defaultPreloadStyleContent","overrideSVGFillColors","_ref6","removeProperty","newSVGContent"],"sources":["../../src/theme/ThemeUtils.ts"],"sourcesContent":["import Log from '@deephaven/log';\nimport { assertNotNull, ColorUtils } from '@deephaven/utils';\nimport { themeDark } from './theme-dark';\nimport { themeLight } from './theme-light';\nimport {\n DEFAULT_DARK_THEME_KEY,\n DEFAULT_LIGHT_THEME_KEY,\n DEFAULT_PRELOAD_DATA_VARIABLES,\n ThemeData,\n ThemePreloadData,\n CssVariableStyleContent,\n ThemePreloadColorVariable,\n ThemeRegistrationData,\n THEME_CACHE_LOCAL_STORAGE_KEY,\n SVG_ICON_MANUAL_COLOR_MAP,\n ThemeCssVariableName,\n ThemeIconsRequiringManualColorChanges,\n THEME_KEY_OVERRIDE_QUERY_PARAM,\n} from './ThemeModel';\n\nconst log = Log.module('ThemeUtils');\n\nexport const CSS_VAR_EXPRESSION_PREFIX = 'var(--';\nexport const TMP_CSS_PROP_PREFIX = 'dh-tmp';\nexport const NON_WHITESPACE_REGEX = /\\S/;\nexport const WHITESPACE_REGEX = /\\s/;\n\nexport type VarExpressionResolver = (varExpression: string) => string;\n\n/**\n * Resolves the current values of CSS variables we want to preload. Preloading\n * happens before themes are fully loaded so that we can style things like the\n * loading spinner and background color which are shown to the user early on in\n * the app lifecycle.\n * @defaultPreloadValues Default values to use if a preload variable is not set.\n */\nexport function calculatePreloadStyleContent(\n defaultPreloadValues: Record<string, string>\n): CssVariableStyleContent {\n const resolveVar = createCssVariableResolver(\n document.body,\n defaultPreloadValues\n );\n\n // Calculate the current preload variables. If the variable is not set, use\n // the default value.\n const pairs = Object.keys(defaultPreloadValues).map(\n key => `${key}:${resolveVar(key as ThemePreloadColorVariable)}`\n );\n\n return `:root{${pairs.join(';')}}`;\n}\n\n/**\n * Create a resolver function for calculating the value of a css variable based\n * on a given element's computed style. If the variable resolves to '', we check\n * `defaultValues` for a default value, and if one does not exist,\n * return ''.\n * @param el Element to resolve css variables against\n * @param defaultValues Default values to use if a variable is not set.\n */\nexport function createCssVariableResolver(\n el: Element,\n defaultValues: Record<string, string>\n): (varName: ThemeCssVariableName) => string {\n const computedStyle = getComputedStyle(el);\n\n /**\n * Resolve the given css variable name to a value. If the variable is not set,\n * return the default preload value or '' if one does not exist.\n */\n return function cssVariableResolver(varName: ThemeCssVariableName): string {\n const value = computedStyle.getPropertyValue(varName);\n\n if (value !== '') {\n return value;\n }\n\n return defaultValues[varName as ThemePreloadColorVariable] ?? '';\n };\n}\n\n/**\n * Create a style tag containing preload css variables and add to the head.\n * @param id The id of the style tag\n * @param preloadStyleContent The css variable content to add to the style tag\n */\nexport function createPreloadStyleElement(\n id: `theme-preload-${string}`,\n preloadStyleContent: CssVariableStyleContent\n): void {\n const style = document.createElement('style');\n style.id = id;\n style.innerHTML = preloadStyleContent;\n document.head.appendChild(style);\n}\n\n/**\n * Extracts all css variable expressions from the given record and returns\n * a set of unique expressions.\n * @param record The record to extract css variable expressions from\n */\nexport function extractDistinctCssVariableExpressions(\n record: Record<string, string>\n): Set<string> {\n const set = new Set<string>();\n\n Object.values(record).forEach(value => {\n getExpressionRanges(value).forEach(([start, end]) => {\n const expression = value.substring(start, end + 1);\n\n if (expression.includes(CSS_VAR_EXPRESSION_PREFIX)) {\n set.add(expression);\n }\n });\n });\n\n return set;\n}\n\n/**\n * Returns an array of the active themes. The first item will always be one\n * of the base themes. Optionally, the second item will be a custom theme.\n */\nexport function getActiveThemes(\n themeKey: string,\n themeRegistration: ThemeRegistrationData\n): [ThemeData] | [ThemeData, ThemeData] {\n const custom = themeRegistration.custom.find(\n theme => theme.themeKey === themeKey\n );\n\n const baseThemeKey = custom?.baseThemeKey ?? themeKey;\n\n let base = themeRegistration.base.find(\n theme => theme.themeKey === baseThemeKey\n );\n\n if (base == null) {\n log.error(\n `No registered base theme found for theme key: '${baseThemeKey}'`,\n 'Registered:',\n themeRegistration.base.map(theme => theme.themeKey),\n themeRegistration.custom.map(theme => theme.themeKey)\n );\n base = themeRegistration.base.find(\n theme => theme.themeKey === DEFAULT_DARK_THEME_KEY\n );\n\n assertNotNull(\n base,\n `Default base theme '${DEFAULT_DARK_THEME_KEY}' is not registered`\n );\n }\n\n log.debug('Applied themes:', base.themeKey, custom?.themeKey);\n\n return custom == null ? [base] : [base, custom];\n}\n\n/**\n * Get default base theme data.\n */\nexport function getDefaultBaseThemes(): ThemeData[] {\n return [\n {\n name: 'Default Dark',\n themeKey: DEFAULT_DARK_THEME_KEY,\n styleContent: themeDark,\n },\n // The ThemePicker shows whenever more than 1 theme is available. Disable\n // light theme for now to keep the picker hidden until it is fully\n // implemented by #1539.\n {\n name: 'Default Light',\n themeKey: DEFAULT_LIGHT_THEME_KEY,\n styleContent: themeLight,\n },\n ];\n}\n\n/**\n * Get the default selected theme key. Precedence is:\n * 1. Theme key override query parameter\n * 2. Theme key from preload data\n * 3. Default dark theme key\n * @returns The default selected theme key\n */\nexport function getDefaultSelectedThemeKey(): string {\n return (\n getThemeKeyOverride() ??\n getThemePreloadData()?.themeKey ??\n DEFAULT_DARK_THEME_KEY\n );\n}\n\n/**\n * A theme key override can be set via a query parameter to force a specific\n * theme selection. Useful for embedded widget scenarios that don't expose the\n * theme selector.\n */\nexport function getThemeKeyOverride(): string | null {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get(THEME_KEY_OVERRIDE_QUERY_PARAM);\n}\n\n/**\n * Get the preload data from local storage or null if it does not exist or is\n * invalid\n */\nexport function getThemePreloadData(): ThemePreloadData | null {\n const data = localStorage.getItem(THEME_CACHE_LOCAL_STORAGE_KEY);\n\n try {\n return data == null ? null : JSON.parse(data);\n } catch {\n // ignore\n }\n\n return null;\n}\n\n/**\n * Identifies start and end indices of any top-level expressions in the given\n * string.\n *\n * e.g.\n * getExpressionRanges('var(--aaa-aa) #fff var(--bbb-bb)')\n * yields:\n * [\n * [0, 12], // 'var(--aaa-aa)'\n * [14, 17] // '#fff'\n * [19, 31], // 'var(--bbb-bb)'\n * ]\n *\n * In cases where there are nested expressions, only the indices of the outermost\n * expression will be included.\n *\n * e.g.\n * getExpressionRanges('var(--ccc-cc, var(--aaa-aa, green)) var(--bbb-bb)')\n * yields:\n * [\n * [0, 34], // 'var(--ccc-cc, var(--aaa-aa, green))'\n * [36, 48], // 'var(--bbb-bb)'\n * ]\n * @param value The string to search for expressions\n * @returns An array of [start, end] index pairs for each expression\n */\nexport function getExpressionRanges(value: string): [number, number][] {\n const ranges: [number, number][] = [];\n\n let start = NON_WHITESPACE_REGEX.exec(value)?.index ?? 0;\n let parenLevel = 0;\n\n for (let i = 0; i < value.length; i += 1) {\n if (value[i] === '(') {\n parenLevel += 1;\n } else if (value[i] === ')') {\n parenLevel -= 1;\n }\n\n if (\n i === value.length - 1 ||\n (WHITESPACE_REGEX.test(value[i + 1]) && parenLevel === 0)\n ) {\n ranges.push([start, i]);\n\n while (i < value.length - 1 && WHITESPACE_REGEX.test(value[i + 1])) {\n i += 1;\n }\n\n start = i + 1;\n }\n }\n\n if (parenLevel !== 0) {\n log.error('Unbalanced parentheses in css var expression', value);\n return [];\n }\n\n return ranges;\n}\n\n/**\n * Replace the `fill='...'` attribute in the given SVG content with the given\n * color string.\n * @param svgContent Inline SVG content to replace the fill color in\n * @param fillColor The color to replace the fill color with\n */\nexport function replaceSVGFillColor(\n svgContent: string,\n fillColor: string\n): string {\n return svgContent.replace(\n /fill='.*?'/,\n `fill='${encodeURIComponent(fillColor)}'`\n );\n}\n\n/**\n * Make a copy of the given object replacing any css variable expressions\n * contained in its prop values with values resolved from the given HTML element.\n * Variables that resolve to color strings will also be normalized to 8 digit\n * hex values (or optionally 6 digit hex if `isAlphaOptional` is true).\n *\n * Note that the browser will force a reflow when calling `getComputedStyle` if\n * css properties have changed. In order to avoid a reflow for every property\n * check we use distinct setup, resolve / normalize, and cleanup passes:\n * 1. Setup - Create a tmp element and set all css props we want to evaluate\n * 2. Resolve / Normalize - Evaluate all css props via `getPropertyValue` calls\n * and replace the original expressions with resolved values. Also normalize\n * css colors to rgb/a.\n * 3. Cleanup - Remove the tmp element\n * @param record An object whose values may contain css var expressions\n * @param targetElement The element to resolve css variables against. Defaults\n * to document.body\n * @param isAlphaOptional If true, the alpha value will be dropped from resolved\n * 8 character hex colors if it is 'ff'. Defaults to false.\n */\nexport function resolveCssVariablesInRecord<T extends Record<string, string>>(\n record: T,\n targetElement: HTMLElement = document.body,\n isAlphaOptional = false\n): T {\n const perfStart = performance.now();\n\n // Add a temporary div to attach temp css variables to\n const tmpPropEl = document.createElement('div');\n tmpPropEl.style.display = 'none';\n\n const recordArray = Object.entries(record);\n recordArray.forEach(([, value], i) => {\n tmpPropEl.style.setProperty(`--${TMP_CSS_PROP_PREFIX}-${i}`, value);\n // faster to create these now all at once, even if we don't use them all\n // since the parent isn't added yet to the DOM\n const el = document.createElement('div');\n // use background color instead of color to avoid inherited values\n el.style.backgroundColor = value;\n tmpPropEl.appendChild(el);\n });\n\n // append only once to avoid multiple re-layouts\n // must be part of DOM to get computed color\n targetElement.appendChild(tmpPropEl);\n const tempPropElComputedStyle = window.getComputedStyle(tmpPropEl);\n\n const result = {} as T;\n recordArray.forEach(([key, value], i) => {\n // resolves any variables in the expression\n let resolved = tempPropElComputedStyle.getPropertyValue(\n `--${TMP_CSS_PROP_PREFIX}-${i}`\n );\n\n const containsCssVar = value.includes(CSS_VAR_EXPRESSION_PREFIX);\n const isColor = CSS.supports('color', resolved);\n\n if (\n // only try to normalize non-hex strings that are valid colors\n // otherwise non-colors will be made #00000000\n isColor &&\n !/^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(resolved)\n ) {\n // getting the computed background color is necessary\n // because resolved can still contain a color-mix() function\n const el = tmpPropEl.children[i] as HTMLDivElement;\n const computedStyle = window.getComputedStyle(el);\n const color = computedStyle.getPropertyValue('background-color');\n // convert color to hex, which is what monaco and plotly require\n resolved = ColorUtils.normalizeCssColor(color, isAlphaOptional);\n }\n (result as Record<string, string>)[key] =\n containsCssVar || isColor ? resolved : value;\n });\n\n // Remove the temporary div\n tmpPropEl.remove();\n\n log.debug('Resolved css variables', performance.now() - perfStart, 'ms');\n\n return result;\n}\n\n/**\n * Resolve css variable expressions in the given string using the\n * given resolver and replace the original expressions with the resolved values.\n *\n * @param resolver Function that can resolve a css variable expression\n * @param value Value that may contain css variable expressions\n */\nexport function resolveCssVariablesInString(\n resolver: VarExpressionResolver,\n value: string\n): string {\n const result: string[] = [];\n let i = 0;\n getExpressionRanges(value).forEach(([start, end]) => {\n if (i < start) {\n result.push(value.substring(i, start));\n i += start - i;\n }\n\n const expression = value.substring(start, end + 1);\n\n result.push(\n expression.includes(CSS_VAR_EXPRESSION_PREFIX)\n ? resolver(expression)\n : expression\n );\n\n i += end - start + 1;\n });\n\n if (result.length === 0) {\n return value;\n }\n\n return result.join('');\n}\n\n/**\n * Store theme preload data in local storage.\n * @param preloadData The preload data to set\n */\nexport function setThemePreloadData(preloadData: ThemePreloadData): void {\n localStorage.setItem(\n THEME_CACHE_LOCAL_STORAGE_KEY,\n JSON.stringify(preloadData)\n );\n}\n\n/**\n * Derive unique theme key from plugin root path and theme name.\n * @param pluginName The root path of the plugin\n * @param themeName The name of the theme\n */\nexport function getThemeKey(pluginName: string, themeName: string): string {\n return `${pluginName}_${themeName}`;\n}\n\n/**\n * Preload minimal theme variables from the cache.\n * @defaultPreloadValues Optional default values to use if a preload variable is not set.\n */\nexport function preloadTheme(\n defaultPreloadValues: Record<string, string> = DEFAULT_PRELOAD_DATA_VARIABLES\n): void {\n const previousPreloadStyleContent =\n getThemePreloadData()?.preloadStyleContent;\n\n const defaultPreloadStyleContent =\n calculatePreloadStyleContent(defaultPreloadValues);\n\n log.debug('Preloading theme content:', {\n defaultPreloadStyleContent,\n previousPreloadStyleContent,\n });\n\n createPreloadStyleElement(\n 'theme-preload-defaults',\n defaultPreloadStyleContent\n );\n\n // Any preload variables that were saved by last theme load should override\n // the defaults\n if (previousPreloadStyleContent != null) {\n createPreloadStyleElement(\n 'theme-preload-previous',\n previousPreloadStyleContent\n );\n }\n}\n\n/**\n * Inline SVGs cannot depend on dynamic CSS variables, so we have to statically\n * update them if we want to change their color.\n *\n * This function:\n * 1. Clears any previous overrides\n * 2. Resolves CSS variables containing inline SVG urls\n * 3. Resolves mapped color variables and replaces the `fill='...'` attribute with the result\n * 4. Sets the original CSS variable to the new replaced value\n *\n * Note that it is preferable to use inline SVGs as background-mask values and\n * just change the background color instead of relying on this util, but this\n * is not always possible. e.g. <select> elements don't support pseudo elements,\n * so there's not a good way to set icons via masks.\n * @param defaultValues Default values to use if a variable is not set.\n */\nexport function overrideSVGFillColors(\n defaultValues: Record<string, string>\n): void {\n const resolveVar = createCssVariableResolver(document.body, defaultValues);\n\n Object.entries(SVG_ICON_MANUAL_COLOR_MAP).forEach(([key, value]) => {\n // Clear any previous override so that our variables get resolved against the\n // actual svg content provided by the active themes and not from a previous\n // override\n document.body.style.removeProperty(key);\n\n const svgContent = resolveVar(key as ThemeIconsRequiringManualColorChanges);\n const fillColor = resolveVar(value as ThemePreloadColorVariable);\n\n const newSVGContent = replaceSVGFillColor(svgContent, fillColor);\n\n // This will take precedence over any values for the variable provided by\n // the active themes\n document.body.style.setProperty(key, newSVGContent);\n });\n}\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,gBAAgB;AAChC,SAASC,aAAa,EAAEC,UAAU,QAAQ,kBAAkB;AAAC,SACpDC,SAAS;AAAA,SACTC,UAAU;AAAA,SAEjBC,sBAAsB,EACtBC,uBAAuB,EACvBC,8BAA8B,EAM9BC,6BAA6B,EAC7BC,yBAAyB,EAGzBC,8BAA8B;AAGhC,IAAMC,GAAG,GAAGX,GAAG,CAACY,MAAM,CAAC,YAAY,CAAC;AAEpC,OAAO,IAAMC,yBAAyB,GAAG,QAAQ;AACjD,OAAO,IAAMC,mBAAmB,GAAG,QAAQ;AAC3C,OAAO,IAAMC,oBAAoB,GAAG,IAAI;AACxC,OAAO,IAAMC,gBAAgB,GAAG,IAAI;AAIpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAC1CC,oBAA4C,EACnB;EACzB,IAAMC,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OAAO,SAASE,qBAAqBA,CACnCtH,aAAqC,EAC/B;EACN,IAAMZ,UAAU,GAAGC,yBAAyB,CAACC,QAAQ,CAACC,IAAI,EAAES,aAAa,CAAC;EAE1EP,MAAM,CAAC+F,OAAO,CAAC9G,yBAAyB,CAAC,CAAC2C,OAAO,CAACkG,KAAA,IAAkB;IAAA,IAAjB,CAAC3H,GAAG,EAAEU,KAAK,CAAC,GAAAiH,KAAA;IAC7D;IACA;IACA;IACAjI,QAAQ,CAACC,IAAI,CAACoB,KAAK,CAAC6G,cAAc,CAAC5H,GAAG,CAAC;IAEvC,IAAM6E,UAAU,GAAGrF,UAAU,CAACQ,GAA4C,CAAC;IAC3E,IAAM8E,SAAS,GAAGtF,UAAU,CAACkB,KAAkC,CAAC;IAEhE,IAAMmH,aAAa,GAAGjD,mBAAmB,CAACC,UAAU,EAAEC,SAAS,CAAC;;IAEhE;IACA;IACApF,QAAQ,CAACC,IAAI,CAACoB,KAAK,CAAC+E,WAAW,CAAC9F,GAAG,EAAE6H,aAAa,CAAC;EACrD,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"file":"ThemeUtils.js","names":["Log","assertNotNull","ColorUtils","themeDark","themeLight","DEFAULT_DARK_THEME_KEY","DEFAULT_LIGHT_THEME_KEY","DEFAULT_PRELOAD_DATA_VARIABLES","THEME_CACHE_LOCAL_STORAGE_KEY","SVG_ICON_MANUAL_COLOR_MAP","THEME_KEY_OVERRIDE_QUERY_PARAM","log","module","CSS_VAR_EXPRESSION_PREFIX","TMP_CSS_PROP_PREFIX","NON_WHITESPACE_REGEX","WHITESPACE_REGEX","calculatePreloadStyleContent","defaultPreloadValues","resolveVar","createCssVariableResolver","document","body","pairs","Object","keys","map","key","concat","join","el","defaultValues","computedStyle","getComputedStyle","cssVariableResolver","varName","_defaultValues","value","getPropertyValue","createPreloadStyleElement","id","preloadStyleContent","style","createElement","innerHTML","head","appendChild","extractDistinctCssVariableExpressions","record","set","Set","values","forEach","getExpressionRanges","_ref","start","end","expression","substring","includes","add","getActiveThemes","themeKey","themeRegistration","_custom$baseThemeKey","custom","find","theme","baseThemeKey","base","error","debug","getDefaultBaseThemes","name","styleContent","getDefaultSelectedThemeKey","_ref2","_getThemeKeyOverride","_getThemePreloadData","getThemeKeyOverride","getThemePreloadData","searchParams","URLSearchParams","window","location","search","get","data","localStorage","getItem","JSON","parse","_unused","_NON_WHITESPACE_REGEX","_NON_WHITESPACE_REGEX2","ranges","exec","index","parenLevel","i","length","test","push","replaceSVGFillColor","svgContent","fillColor","replace","encodeURIComponent","resolveCssVariablesInRecord","targetElement","arguments","undefined","isAlphaOptional","perfStart","performance","now","tmpPropEl","display","recordArray","entries","_ref3","setProperty","backgroundColor","tempPropElComputedStyle","result","_ref4","resolved","containsCssVar","isColor","CSS","supports","children","color","normalizeCssColor","remove","resolveCssVariablesInString","resolver","_ref5","setThemePreloadData","preloadData","setItem","stringify","getThemeKey","pluginName","themeName","preloadTheme","_getThemePreloadData2","previousPreloadStyleContent","defaultPreloadStyleContent","overrideSVGFillColors","_ref6","removeProperty","newSVGContent"],"sources":["../../src/theme/ThemeUtils.ts"],"sourcesContent":["import Log from '@deephaven/log';\nimport { assertNotNull, ColorUtils } from '@deephaven/utils';\nimport { themeDark } from './theme-dark';\nimport { themeLight } from './theme-light';\nimport {\n DEFAULT_DARK_THEME_KEY,\n DEFAULT_LIGHT_THEME_KEY,\n DEFAULT_PRELOAD_DATA_VARIABLES,\n type ThemeData,\n type ThemePreloadData,\n type CssVariableStyleContent,\n type ThemePreloadColorVariable,\n type ThemeRegistrationData,\n THEME_CACHE_LOCAL_STORAGE_KEY,\n SVG_ICON_MANUAL_COLOR_MAP,\n type ThemeCssVariableName,\n type ThemeIconsRequiringManualColorChanges,\n THEME_KEY_OVERRIDE_QUERY_PARAM,\n} from './ThemeModel';\n\nconst log = Log.module('ThemeUtils');\n\nexport const CSS_VAR_EXPRESSION_PREFIX = 'var(--';\nexport const TMP_CSS_PROP_PREFIX = 'dh-tmp';\nexport const NON_WHITESPACE_REGEX = /\\S/;\nexport const WHITESPACE_REGEX = /\\s/;\n\nexport type VarExpressionResolver = (varExpression: string) => string;\n\n/**\n * Resolves the current values of CSS variables we want to preload. Preloading\n * happens before themes are fully loaded so that we can style things like the\n * loading spinner and background color which are shown to the user early on in\n * the app lifecycle.\n * @defaultPreloadValues Default values to use if a preload variable is not set.\n */\nexport function calculatePreloadStyleContent(\n defaultPreloadValues: Record<string, string>\n): CssVariableStyleContent {\n const resolveVar = createCssVariableResolver(\n document.body,\n defaultPreloadValues\n );\n\n // Calculate the current preload variables. If the variable is not set, use\n // the default value.\n const pairs = Object.keys(defaultPreloadValues).map(\n key => `${key}:${resolveVar(key as ThemePreloadColorVariable)}`\n );\n\n return `:root{${pairs.join(';')}}`;\n}\n\n/**\n * Create a resolver function for calculating the value of a css variable based\n * on a given element's computed style. If the variable resolves to '', we check\n * `defaultValues` for a default value, and if one does not exist,\n * return ''.\n * @param el Element to resolve css variables against\n * @param defaultValues Default values to use if a variable is not set.\n */\nexport function createCssVariableResolver(\n el: Element,\n defaultValues: Record<string, string>\n): (varName: ThemeCssVariableName) => string {\n const computedStyle = getComputedStyle(el);\n\n /**\n * Resolve the given css variable name to a value. If the variable is not set,\n * return the default preload value or '' if one does not exist.\n */\n return function cssVariableResolver(varName: ThemeCssVariableName): string {\n const value = computedStyle.getPropertyValue(varName);\n\n if (value !== '') {\n return value;\n }\n\n return defaultValues[varName as ThemePreloadColorVariable] ?? '';\n };\n}\n\n/**\n * Create a style tag containing preload css variables and add to the head.\n * @param id The id of the style tag\n * @param preloadStyleContent The css variable content to add to the style tag\n */\nexport function createPreloadStyleElement(\n id: `theme-preload-${string}`,\n preloadStyleContent: CssVariableStyleContent\n): void {\n const style = document.createElement('style');\n style.id = id;\n style.innerHTML = preloadStyleContent;\n document.head.appendChild(style);\n}\n\n/**\n * Extracts all css variable expressions from the given record and returns\n * a set of unique expressions.\n * @param record The record to extract css variable expressions from\n */\nexport function extractDistinctCssVariableExpressions(\n record: Record<string, string>\n): Set<string> {\n const set = new Set<string>();\n\n Object.values(record).forEach(value => {\n getExpressionRanges(value).forEach(([start, end]) => {\n const expression = value.substring(start, end + 1);\n\n if (expression.includes(CSS_VAR_EXPRESSION_PREFIX)) {\n set.add(expression);\n }\n });\n });\n\n return set;\n}\n\n/**\n * Returns an array of the active themes. The first item will always be one\n * of the base themes. Optionally, the second item will be a custom theme.\n */\nexport function getActiveThemes(\n themeKey: string,\n themeRegistration: ThemeRegistrationData\n): [ThemeData] | [ThemeData, ThemeData] {\n const custom = themeRegistration.custom.find(\n theme => theme.themeKey === themeKey\n );\n\n const baseThemeKey = custom?.baseThemeKey ?? themeKey;\n\n let base = themeRegistration.base.find(\n theme => theme.themeKey === baseThemeKey\n );\n\n if (base == null) {\n log.error(\n `No registered base theme found for theme key: '${baseThemeKey}'`,\n 'Registered:',\n themeRegistration.base.map(theme => theme.themeKey),\n themeRegistration.custom.map(theme => theme.themeKey)\n );\n base = themeRegistration.base.find(\n theme => theme.themeKey === DEFAULT_DARK_THEME_KEY\n );\n\n assertNotNull(\n base,\n `Default base theme '${DEFAULT_DARK_THEME_KEY}' is not registered`\n );\n }\n\n log.debug('Applied themes:', base.themeKey, custom?.themeKey);\n\n return custom == null ? [base] : [base, custom];\n}\n\n/**\n * Get default base theme data.\n */\nexport function getDefaultBaseThemes(): ThemeData[] {\n return [\n {\n name: 'Default Dark',\n themeKey: DEFAULT_DARK_THEME_KEY,\n styleContent: themeDark,\n },\n // The ThemePicker shows whenever more than 1 theme is available. Disable\n // light theme for now to keep the picker hidden until it is fully\n // implemented by #1539.\n {\n name: 'Default Light',\n themeKey: DEFAULT_LIGHT_THEME_KEY,\n styleContent: themeLight,\n },\n ];\n}\n\n/**\n * Get the default selected theme key. Precedence is:\n * 1. Theme key override query parameter\n * 2. Theme key from preload data\n * 3. Default dark theme key\n * @returns The default selected theme key\n */\nexport function getDefaultSelectedThemeKey(): string {\n return (\n getThemeKeyOverride() ??\n getThemePreloadData()?.themeKey ??\n DEFAULT_DARK_THEME_KEY\n );\n}\n\n/**\n * A theme key override can be set via a query parameter to force a specific\n * theme selection. Useful for embedded widget scenarios that don't expose the\n * theme selector.\n */\nexport function getThemeKeyOverride(): string | null {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get(THEME_KEY_OVERRIDE_QUERY_PARAM);\n}\n\n/**\n * Get the preload data from local storage or null if it does not exist or is\n * invalid\n */\nexport function getThemePreloadData(): ThemePreloadData | null {\n const data = localStorage.getItem(THEME_CACHE_LOCAL_STORAGE_KEY);\n\n try {\n return data == null ? null : JSON.parse(data);\n } catch {\n // ignore\n }\n\n return null;\n}\n\n/**\n * Identifies start and end indices of any top-level expressions in the given\n * string.\n *\n * e.g.\n * getExpressionRanges('var(--aaa-aa) #fff var(--bbb-bb)')\n * yields:\n * [\n * [0, 12], // 'var(--aaa-aa)'\n * [14, 17] // '#fff'\n * [19, 31], // 'var(--bbb-bb)'\n * ]\n *\n * In cases where there are nested expressions, only the indices of the outermost\n * expression will be included.\n *\n * e.g.\n * getExpressionRanges('var(--ccc-cc, var(--aaa-aa, green)) var(--bbb-bb)')\n * yields:\n * [\n * [0, 34], // 'var(--ccc-cc, var(--aaa-aa, green))'\n * [36, 48], // 'var(--bbb-bb)'\n * ]\n * @param value The string to search for expressions\n * @returns An array of [start, end] index pairs for each expression\n */\nexport function getExpressionRanges(value: string): [number, number][] {\n const ranges: [number, number][] = [];\n\n let start = NON_WHITESPACE_REGEX.exec(value)?.index ?? 0;\n let parenLevel = 0;\n\n for (let i = 0; i < value.length; i += 1) {\n if (value[i] === '(') {\n parenLevel += 1;\n } else if (value[i] === ')') {\n parenLevel -= 1;\n }\n\n if (\n i === value.length - 1 ||\n (WHITESPACE_REGEX.test(value[i + 1]) && parenLevel === 0)\n ) {\n ranges.push([start, i]);\n\n while (i < value.length - 1 && WHITESPACE_REGEX.test(value[i + 1])) {\n i += 1;\n }\n\n start = i + 1;\n }\n }\n\n if (parenLevel !== 0) {\n log.error('Unbalanced parentheses in css var expression', value);\n return [];\n }\n\n return ranges;\n}\n\n/**\n * Replace the `fill='...'` attribute in the given SVG content with the given\n * color string.\n * @param svgContent Inline SVG content to replace the fill color in\n * @param fillColor The color to replace the fill color with\n */\nexport function replaceSVGFillColor(\n svgContent: string,\n fillColor: string\n): string {\n return svgContent.replace(\n /fill='.*?'/,\n `fill='${encodeURIComponent(fillColor)}'`\n );\n}\n\n/**\n * Make a copy of the given object replacing any css variable expressions\n * contained in its prop values with values resolved from the given HTML element.\n * Variables that resolve to color strings will also be normalized to 8 digit\n * hex values (or optionally 6 digit hex if `isAlphaOptional` is true).\n *\n * Note that the browser will force a reflow when calling `getComputedStyle` if\n * css properties have changed. In order to avoid a reflow for every property\n * check we use distinct setup, resolve / normalize, and cleanup passes:\n * 1. Setup - Create a tmp element and set all css props we want to evaluate\n * 2. Resolve / Normalize - Evaluate all css props via `getPropertyValue` calls\n * and replace the original expressions with resolved values. Also normalize\n * css colors to rgb/a.\n * 3. Cleanup - Remove the tmp element\n * @param record An object whose values may contain css var expressions\n * @param targetElement The element to resolve css variables against. Defaults\n * to document.body\n * @param isAlphaOptional If true, the alpha value will be dropped from resolved\n * 8 character hex colors if it is 'ff'. Defaults to false.\n */\nexport function resolveCssVariablesInRecord<T extends Record<string, string>>(\n record: T,\n targetElement: HTMLElement = document.body,\n isAlphaOptional = false\n): T {\n const perfStart = performance.now();\n\n // Add a temporary div to attach temp css variables to\n const tmpPropEl = document.createElement('div');\n tmpPropEl.style.display = 'none';\n\n const recordArray = Object.entries(record);\n recordArray.forEach(([, value], i) => {\n tmpPropEl.style.setProperty(`--${TMP_CSS_PROP_PREFIX}-${i}`, value);\n // faster to create these now all at once, even if we don't use them all\n // since the parent isn't added yet to the DOM\n const el = document.createElement('div');\n // use background color instead of color to avoid inherited values\n el.style.backgroundColor = value;\n tmpPropEl.appendChild(el);\n });\n\n // append only once to avoid multiple re-layouts\n // must be part of DOM to get computed color\n targetElement.appendChild(tmpPropEl);\n const tempPropElComputedStyle = window.getComputedStyle(tmpPropEl);\n\n const result = {} as T;\n recordArray.forEach(([key, value], i) => {\n // resolves any variables in the expression\n let resolved = tempPropElComputedStyle.getPropertyValue(\n `--${TMP_CSS_PROP_PREFIX}-${i}`\n );\n\n const containsCssVar = value.includes(CSS_VAR_EXPRESSION_PREFIX);\n const isColor = CSS.supports('color', resolved);\n\n if (\n // only try to normalize non-hex strings that are valid colors\n // otherwise non-colors will be made #00000000\n isColor &&\n !/^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(resolved)\n ) {\n // getting the computed background color is necessary\n // because resolved can still contain a color-mix() function\n const el = tmpPropEl.children[i] as HTMLDivElement;\n const computedStyle = window.getComputedStyle(el);\n const color = computedStyle.getPropertyValue('background-color');\n // convert color to hex, which is what monaco and plotly require\n resolved = ColorUtils.normalizeCssColor(color, isAlphaOptional);\n }\n (result as Record<string, string>)[key] =\n containsCssVar || isColor ? resolved : value;\n });\n\n // Remove the temporary div\n tmpPropEl.remove();\n\n log.debug('Resolved css variables', performance.now() - perfStart, 'ms');\n\n return result;\n}\n\n/**\n * Resolve css variable expressions in the given string using the\n * given resolver and replace the original expressions with the resolved values.\n *\n * @param resolver Function that can resolve a css variable expression\n * @param value Value that may contain css variable expressions\n */\nexport function resolveCssVariablesInString(\n resolver: VarExpressionResolver,\n value: string\n): string {\n const result: string[] = [];\n let i = 0;\n getExpressionRanges(value).forEach(([start, end]) => {\n if (i < start) {\n result.push(value.substring(i, start));\n i += start - i;\n }\n\n const expression = value.substring(start, end + 1);\n\n result.push(\n expression.includes(CSS_VAR_EXPRESSION_PREFIX)\n ? resolver(expression)\n : expression\n );\n\n i += end - start + 1;\n });\n\n if (result.length === 0) {\n return value;\n }\n\n return result.join('');\n}\n\n/**\n * Store theme preload data in local storage.\n * @param preloadData The preload data to set\n */\nexport function setThemePreloadData(preloadData: ThemePreloadData): void {\n localStorage.setItem(\n THEME_CACHE_LOCAL_STORAGE_KEY,\n JSON.stringify(preloadData)\n );\n}\n\n/**\n * Derive unique theme key from plugin root path and theme name.\n * @param pluginName The root path of the plugin\n * @param themeName The name of the theme\n */\nexport function getThemeKey(pluginName: string, themeName: string): string {\n return `${pluginName}_${themeName}`;\n}\n\n/**\n * Preload minimal theme variables from the cache.\n * @defaultPreloadValues Optional default values to use if a preload variable is not set.\n */\nexport function preloadTheme(\n defaultPreloadValues: Record<string, string> = DEFAULT_PRELOAD_DATA_VARIABLES\n): void {\n const previousPreloadStyleContent =\n getThemePreloadData()?.preloadStyleContent;\n\n const defaultPreloadStyleContent =\n calculatePreloadStyleContent(defaultPreloadValues);\n\n log.debug('Preloading theme content:', {\n defaultPreloadStyleContent,\n previousPreloadStyleContent,\n });\n\n createPreloadStyleElement(\n 'theme-preload-defaults',\n defaultPreloadStyleContent\n );\n\n // Any preload variables that were saved by last theme load should override\n // the defaults\n if (previousPreloadStyleContent != null) {\n createPreloadStyleElement(\n 'theme-preload-previous',\n previousPreloadStyleContent\n );\n }\n}\n\n/**\n * Inline SVGs cannot depend on dynamic CSS variables, so we have to statically\n * update them if we want to change their color.\n *\n * This function:\n * 1. Clears any previous overrides\n * 2. Resolves CSS variables containing inline SVG urls\n * 3. Resolves mapped color variables and replaces the `fill='...'` attribute with the result\n * 4. Sets the original CSS variable to the new replaced value\n *\n * Note that it is preferable to use inline SVGs as background-mask values and\n * just change the background color instead of relying on this util, but this\n * is not always possible. e.g. <select> elements don't support pseudo elements,\n * so there's not a good way to set icons via masks.\n * @param defaultValues Default values to use if a variable is not set.\n */\nexport function overrideSVGFillColors(\n defaultValues: Record<string, string>\n): void {\n const resolveVar = createCssVariableResolver(document.body, defaultValues);\n\n Object.entries(SVG_ICON_MANUAL_COLOR_MAP).forEach(([key, value]) => {\n // Clear any previous override so that our variables get resolved against the\n // actual svg content provided by the active themes and not from a previous\n // override\n document.body.style.removeProperty(key);\n\n const svgContent = resolveVar(key as ThemeIconsRequiringManualColorChanges);\n const fillColor = resolveVar(value as ThemePreloadColorVariable);\n\n const newSVGContent = replaceSVGFillColor(svgContent, fillColor);\n\n // This will take precedence over any values for the variable provided by\n // the active themes\n document.body.style.setProperty(key, newSVGContent);\n });\n}\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,gBAAgB;AAChC,SAASC,aAAa,EAAEC,UAAU,QAAQ,kBAAkB;AAAC,SACpDC,SAAS;AAAA,SACTC,UAAU;AAAA,SAEjBC,sBAAsB,EACtBC,uBAAuB,EACvBC,8BAA8B,EAM9BC,6BAA6B,EAC7BC,yBAAyB,EAGzBC,8BAA8B;AAGhC,IAAMC,GAAG,GAAGX,GAAG,CAACY,MAAM,CAAC,YAAY,CAAC;AAEpC,OAAO,IAAMC,yBAAyB,GAAG,QAAQ;AACjD,OAAO,IAAMC,mBAAmB,GAAG,QAAQ;AAC3C,OAAO,IAAMC,oBAAoB,GAAG,IAAI;AACxC,OAAO,IAAMC,gBAAgB,GAAG,IAAI;AAIpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAC1CC,oBAA4C,EACnB;EACzB,IAAMC,UAAU,GAAGC,yBAAyB,CAC1CC,QAAQ,CAACC,IAAI,EACbJ,oBACF,CAAC;;EAED;EACA;EACA,IAAMK,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACP,oBAAoB,CAAC,CAACQ,GAAG,CACjDC,GAAG,OAAAC,MAAA,CAAOD,GAAG,OAAAC,MAAA,CAAIT,UAAU,CAACQ,GAAgC,CAAC,CAC/D,CAAC;EAED,gBAAAC,MAAA,CAAgBL,KAAK,CAACM,IAAI,CAAC,GAAG,CAAC;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAST,yBAAyBA,CACvCU,EAAW,EACXC,aAAqC,EACM;EAC3C,IAAMC,aAAa,GAAGC,gBAAgB,CAACH,EAAE,CAAC;;EAE1C;AACF;AACA;AACA;EACE,OAAO,SAASI,mBAAmBA,CAACC,OAA6B,EAAU;IAAA,IAA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;IACApF,QAAQ,CAACC,IAAI,CAACoB,KAAK,CAAC+E,WAAW,CAAC9F,GAAG,EAAE6H,aAAa,CAAC;EACrD,CAAC,CAAC;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorUtils.d.ts","sourceRoot":"","sources":["../../src/theme/colorUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"colorUtils.d.ts","sourceRoot":"","sources":["../../src/theme/colorUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,WAAW,++FA2Nd,CAAC;AAEX,KAAK,YAAY,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;AAE/D,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAInE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;AACvD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorUtils.js","names":["ColorValues","isDHColorValue","value","includes","colorValueStyle","concat"],"sources":["../../src/theme/colorUtils.ts"],"sourcesContent":["import { CSSProperties } from 'react';\n\n/**\n * Color values for the DH color palette exposed to end users in spectrum components.\n */\nexport const ColorValues = [\n 'gray-50',\n 'gray-75',\n 'gray-100',\n 'gray-200',\n 'gray-300',\n 'gray-400',\n 'gray-500',\n 'gray-600',\n 'gray-700',\n 'gray-800',\n 'gray-900',\n 'red-100',\n 'red-200',\n 'red-300',\n 'red-400',\n 'red-500',\n 'red-600',\n 'red-700',\n 'red-800',\n 'red-900',\n 'red-1000',\n 'red-1100',\n 'red-1200',\n 'red-1300',\n 'red-1400',\n 'orange-100',\n 'orange-200',\n 'orange-300',\n 'orange-400',\n 'orange-500',\n 'orange-600',\n 'orange-700',\n 'orange-800',\n 'orange-900',\n 'orange-1000',\n 'orange-1100',\n 'orange-1200',\n 'orange-1300',\n 'orange-1400',\n 'yellow-100',\n 'yellow-200',\n 'yellow-300',\n 'yellow-400',\n 'yellow-500',\n 'yellow-600',\n 'yellow-700',\n 'yellow-800',\n 'yellow-900',\n 'yellow-1000',\n 'yellow-1100',\n 'yellow-1200',\n 'yellow-1300',\n 'yellow-1400',\n 'chartreuse-100',\n 'chartreuse-200',\n 'chartreuse-300',\n 'chartreuse-400',\n 'chartreuse-500',\n 'chartreuse-600',\n 'chartreuse-700',\n 'chartreuse-800',\n 'chartreuse-900',\n 'chartreuse-1000',\n 'chartreuse-1100',\n 'chartreuse-1200',\n 'chartreuse-1300',\n 'chartreuse-1400',\n 'celery-100',\n 'celery-200',\n 'celery-300',\n 'celery-400',\n 'celery-500',\n 'celery-600',\n 'celery-700',\n 'celery-800',\n 'celery-900',\n 'celery-1000',\n 'celery-1100',\n 'celery-1200',\n 'celery-1300',\n 'celery-1400',\n 'green-100',\n 'green-200',\n 'green-300',\n 'green-400',\n 'green-500',\n 'green-600',\n 'green-700',\n 'green-800',\n 'green-900',\n 'green-1000',\n 'green-1100',\n 'green-1200',\n 'green-1300',\n 'green-1400',\n 'seafoam-100',\n 'seafoam-200',\n 'seafoam-300',\n 'seafoam-400',\n 'seafoam-500',\n 'seafoam-600',\n 'seafoam-700',\n 'seafoam-800',\n 'seafoam-900',\n 'seafoam-1000',\n 'seafoam-1100',\n 'seafoam-1200',\n 'seafoam-1300',\n 'seafoam-1400',\n 'cyan-100',\n 'cyan-200',\n 'cyan-300',\n 'cyan-400',\n 'cyan-500',\n 'cyan-600',\n 'cyan-700',\n 'cyan-800',\n 'cyan-900',\n 'cyan-1000',\n 'cyan-1100',\n 'cyan-1200',\n 'cyan-1300',\n 'cyan-1400',\n 'blue-100',\n 'blue-200',\n 'blue-300',\n 'blue-400',\n 'blue-500',\n 'blue-600',\n 'blue-700',\n 'blue-800',\n 'blue-900',\n 'blue-1000',\n 'blue-1100',\n 'blue-1200',\n 'blue-1300',\n 'blue-1400',\n 'indigo-100',\n 'indigo-200',\n 'indigo-300',\n 'indigo-400',\n 'indigo-500',\n 'indigo-600',\n 'indigo-700',\n 'indigo-800',\n 'indigo-900',\n 'indigo-1000',\n 'indigo-1100',\n 'indigo-1200',\n 'indigo-1300',\n 'indigo-1400',\n 'purple-100',\n 'purple-200',\n 'purple-300',\n 'purple-400',\n 'purple-500',\n 'purple-600',\n 'purple-700',\n 'purple-800',\n 'purple-900',\n 'purple-1000',\n 'purple-1100',\n 'purple-1200',\n 'purple-1300',\n 'purple-1400',\n 'fuchsia-100',\n 'fuchsia-200',\n 'fuchsia-300',\n 'fuchsia-400',\n 'fuchsia-500',\n 'fuchsia-600',\n 'fuchsia-700',\n 'fuchsia-800',\n 'fuchsia-900',\n 'fuchsia-1000',\n 'fuchsia-1100',\n 'fuchsia-1200',\n 'fuchsia-1300',\n 'fuchsia-1400',\n 'magenta-100',\n 'magenta-200',\n 'magenta-300',\n 'magenta-400',\n 'magenta-500',\n 'magenta-600',\n 'magenta-700',\n 'magenta-800',\n 'magenta-900',\n 'magenta-1000',\n 'magenta-1100',\n 'magenta-1200',\n 'magenta-1300',\n 'magenta-1400',\n 'negative',\n 'notice',\n 'positive',\n 'info',\n // Additional DH ColorValues:\n 'accent',\n 'accent-100',\n 'accent-200',\n 'accent-300',\n 'accent-400',\n 'accent-500',\n 'accent-600',\n 'accent-700',\n 'accent-800',\n 'accent-900',\n 'accent-1000',\n 'accent-1100',\n 'accent-1200',\n 'accent-1300',\n 'accent-1400',\n 'bg',\n 'content-bg',\n 'subdued-content-bg',\n 'surface-bg',\n 'fg',\n] as const;\n\ntype DHColorValue = (typeof ColorValues)[number];\n\nexport type ColorValue = DHColorValue | CSSProperties['color'];\n\nexport function isDHColorValue(value: string): value is DHColorValue {\n return (\n typeof value === 'string' && ColorValues.includes(value as DHColorValue)\n );\n}\n\n/**\n * Returns the a css variable color value for a given theme color.\n * If the color value is a DH color value, it returns the CSS variable.\n * Otherwise, it returns the color value as is.\n *\n * @param value a string representing a color value\n * @returns CSS variable for DH color values, otherwise the color value as is\n *\n * ex. colorValueStyle('blue-1000') => 'var(--dh-color-blue-1000)'\n * ex. colorValueStyle('red') => 'red'\n * ex. colorValueStyle('#F00') => '#F00'\n */\nexport function colorValueStyle(value: string): string;\nexport function colorValueStyle(value: string | undefined): string | undefined;\nexport function colorValueStyle(value: string | undefined): string | undefined {\n if (value != null && isDHColorValue(value)) {\n return `var(--dh-color-${value})`;\n }\n\n return value;\n}\n"],"mappings":"AAEA;AACA;AACA;AACA,OAAO,IAAMA,WAAW,GAAG,CACzB,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAg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AAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM;AACN;AACA,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,IAAI,CACI;AAMV,OAAO,SAASC,cAAcA,CAACC,KAAa,EAAyB;EACnE,OACE,OAAOA,KAAK,KAAK,QAAQ,IAAIF,WAAW,CAACG,QAAQ,CAACD,KAAqB,CAAC;AAE5E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,SAASE,eAAeA,CAACF,KAAyB,EAAsB;EAC7E,IAAIA,KAAK,IAAI,IAAI,IAAID,cAAc,CAACC,KAAK,CAAC,EAAE;IAC1C,yBAAAG,MAAA,CAAyBH,KAAK;EAChC;EAEA,OAAOA,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"colorUtils.js","names":["ColorValues","isDHColorValue","value","includes","colorValueStyle","concat"],"sources":["../../src/theme/colorUtils.ts"],"sourcesContent":["import { type CSSProperties } from 'react';\n\n/**\n * Color values for the DH color palette exposed to end users in spectrum components.\n */\nexport const ColorValues = [\n 'gray-50',\n 'gray-75',\n 'gray-100',\n 'gray-200',\n 'gray-300',\n 'gray-400',\n 'gray-500',\n 'gray-600',\n 'gray-700',\n 'gray-800',\n 'gray-900',\n 'red-100',\n 'red-200',\n 'red-300',\n 'red-400',\n 'red-500',\n 'red-600',\n 'red-700',\n 'red-800',\n 'red-900',\n 'red-1000',\n 'red-1100',\n 'red-1200',\n 'red-1300',\n 'red-1400',\n 'orange-100',\n 'orange-200',\n 'orange-300',\n 'orange-400',\n 'orange-500',\n 'orange-600',\n 'orange-700',\n 'orange-800',\n 'orange-900',\n 'orange-1000',\n 'orange-1100',\n 'orange-1200',\n 'orange-1300',\n 'orange-1400',\n 'yellow-100',\n 'yellow-200',\n 'yellow-300',\n 'yellow-400',\n 'yellow-500',\n 'yellow-600',\n 'yellow-700',\n 'yellow-800',\n 'yellow-900',\n 'yellow-1000',\n 'yellow-1100',\n 'yellow-1200',\n 'yellow-1300',\n 'yellow-1400',\n 'chartreuse-100',\n 'chartreuse-200',\n 'chartreuse-300',\n 'chartreuse-400',\n 'chartreuse-500',\n 'chartreuse-600',\n 'chartreuse-700',\n 'chartreuse-800',\n 'chartreuse-900',\n 'chartreuse-1000',\n 'chartreuse-1100',\n 'chartreuse-1200',\n 'chartreuse-1300',\n 'chartreuse-1400',\n 'celery-100',\n 'celery-200',\n 'celery-300',\n 'celery-400',\n 'celery-500',\n 'celery-600',\n 'celery-700',\n 'celery-800',\n 'celery-900',\n 'celery-1000',\n 'celery-1100',\n 'celery-1200',\n 'celery-1300',\n 'celery-1400',\n 'green-100',\n 'green-200',\n 'green-300',\n 'green-400',\n 'green-500',\n 'green-600',\n 'green-700',\n 'green-800',\n 'green-900',\n 'green-1000',\n 'green-1100',\n 'green-1200',\n 'green-1300',\n 'green-1400',\n 'seafoam-100',\n 'seafoam-200',\n 'seafoam-300',\n 'seafoam-400',\n 'seafoam-500',\n 'seafoam-600',\n 'seafoam-700',\n 'seafoam-800',\n 'seafoam-900',\n 'seafoam-1000',\n 'seafoam-1100',\n 'seafoam-1200',\n 'seafoam-1300',\n 'seafoam-1400',\n 'cyan-100',\n 'cyan-200',\n 'cyan-300',\n 'cyan-400',\n 'cyan-500',\n 'cyan-600',\n 'cyan-700',\n 'cyan-800',\n 'cyan-900',\n 'cyan-1000',\n 'cyan-1100',\n 'cyan-1200',\n 'cyan-1300',\n 'cyan-1400',\n 'blue-100',\n 'blue-200',\n 'blue-300',\n 'blue-400',\n 'blue-500',\n 'blue-600',\n 'blue-700',\n 'blue-800',\n 'blue-900',\n 'blue-1000',\n 'blue-1100',\n 'blue-1200',\n 'blue-1300',\n 'blue-1400',\n 'indigo-100',\n 'indigo-200',\n 'indigo-300',\n 'indigo-400',\n 'indigo-500',\n 'indigo-600',\n 'indigo-700',\n 'indigo-800',\n 'indigo-900',\n 'indigo-1000',\n 'indigo-1100',\n 'indigo-1200',\n 'indigo-1300',\n 'indigo-1400',\n 'purple-100',\n 'purple-200',\n 'purple-300',\n 'purple-400',\n 'purple-500',\n 'purple-600',\n 'purple-700',\n 'purple-800',\n 'purple-900',\n 'purple-1000',\n 'purple-1100',\n 'purple-1200',\n 'purple-1300',\n 'purple-1400',\n 'fuchsia-100',\n 'fuchsia-200',\n 'fuchsia-300',\n 'fuchsia-400',\n 'fuchsia-500',\n 'fuchsia-600',\n 'fuchsia-700',\n 'fuchsia-800',\n 'fuchsia-900',\n 'fuchsia-1000',\n 'fuchsia-1100',\n 'fuchsia-1200',\n 'fuchsia-1300',\n 'fuchsia-1400',\n 'magenta-100',\n 'magenta-200',\n 'magenta-300',\n 'magenta-400',\n 'magenta-500',\n 'magenta-600',\n 'magenta-700',\n 'magenta-800',\n 'magenta-900',\n 'magenta-1000',\n 'magenta-1100',\n 'magenta-1200',\n 'magenta-1300',\n 'magenta-1400',\n 'negative',\n 'notice',\n 'positive',\n 'info',\n // Additional DH ColorValues:\n 'accent',\n 'accent-100',\n 'accent-200',\n 'accent-300',\n 'accent-400',\n 'accent-500',\n 'accent-600',\n 'accent-700',\n 'accent-800',\n 'accent-900',\n 'accent-1000',\n 'accent-1100',\n 'accent-1200',\n 'accent-1300',\n 'accent-1400',\n 'bg',\n 'content-bg',\n 'subdued-content-bg',\n 'surface-bg',\n 'fg',\n] as const;\n\ntype DHColorValue = (typeof ColorValues)[number];\n\nexport type ColorValue = DHColorValue | CSSProperties['color'];\n\nexport function isDHColorValue(value: string): value is DHColorValue {\n return (\n typeof value === 'string' && ColorValues.includes(value as DHColorValue)\n );\n}\n\n/**\n * Returns the a css variable color value for a given theme color.\n * If the color value is a DH color value, it returns the CSS variable.\n * Otherwise, it returns the color value as is.\n *\n * @param value a string representing a color value\n * @returns CSS variable for DH color values, otherwise the color value as is\n *\n * ex. colorValueStyle('blue-1000') => 'var(--dh-color-blue-1000)'\n * ex. colorValueStyle('red') => 'red'\n * ex. colorValueStyle('#F00') => '#F00'\n */\nexport function colorValueStyle(value: string): string;\nexport function colorValueStyle(value: string | undefined): string | undefined;\nexport function colorValueStyle(value: string | undefined): string | undefined {\n if (value != null && isDHColorValue(value)) {\n return `var(--dh-color-${value})`;\n }\n\n return value;\n}\n"],"mappings":"AAEA;AACA;AACA;AACA,OAAO,IAAMA,WAAW,GAAG,CACzB,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ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YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM;AACN;AACA,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,IAAI,CACI;AAMV,OAAO,SAASC,cAAcA,CAACC,KAAa,EAAyB;EACnE,OACE,OAAOA,KAAK,KAAK,QAAQ,IAAIF,WAAW,CAACG,QAAQ,CAACD,KAAqB,CAAC;AAE5E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,SAASE,eAAeA,CAACF,KAAyB,EAAsB;EAC7E,IAAIA,KAAK,IAAI,IAAI,IAAID,cAAc,CAACC,KAAK,CAAC,EAAE;IAC1C,yBAAAG,MAAA,CAAyBH,KAAK;EAChC;EAEA,OAAOA,KAAK;AACd"}
|
package/dist/theme/useTheme.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/theme/useTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/theme/useTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEvE;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAK5C;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.js","names":["useContextOrThrow","ThemeContext","useTheme"],"sources":["../../src/theme/useTheme.ts"],"sourcesContent":["import { useContextOrThrow } from '@deephaven/react-hooks';\nimport { ThemeContext, ThemeContextValue } from './ThemeProvider';\n\n/**\n * Hook to get the current `ThemeContextValue`.\n */\nexport function useTheme(): ThemeContextValue {\n return useContextOrThrow(\n ThemeContext,\n 'No ThemeContext value found. Component must be wrapped in a ThemeContext.Provider'\n );\n}\n\nexport default useTheme;\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,wBAAwB;AAAC,SAClDC,YAAY;AAErB;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAA,EAAsB;EAC5C,OAAOF,iBAAiB,CACtBC,YAAY,EACZ,mFACF,CAAC;AACH;AAEA,eAAeC,QAAQ"}
|
|
1
|
+
{"version":3,"file":"useTheme.js","names":["useContextOrThrow","ThemeContext","useTheme"],"sources":["../../src/theme/useTheme.ts"],"sourcesContent":["import { useContextOrThrow } from '@deephaven/react-hooks';\nimport { ThemeContext, type ThemeContextValue } from './ThemeProvider';\n\n/**\n * Hook to get the current `ThemeContextValue`.\n */\nexport function useTheme(): ThemeContextValue {\n return useContextOrThrow(\n ThemeContext,\n 'No ThemeContext value found. Component must be wrapped in a ThemeContext.Provider'\n );\n}\n\nexport default useTheme;\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,wBAAwB;AAAC,SAClDC,YAAY;AAErB;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAA,EAAsB;EAC5C,OAAOF,iBAAiB,CACtBC,YAAY,EACZ,mFACF,CAAC;AACH;AAEA,eAAeC,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.95.0",
|
|
4
4
|
"description": "Deephaven React component library",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@adobe/react-spectrum": "3.35.1",
|
|
28
|
-
"@deephaven/icons": "^0.
|
|
29
|
-
"@deephaven/log": "^0.
|
|
30
|
-
"@deephaven/react-hooks": "^0.
|
|
31
|
-
"@deephaven/utils": "^0.
|
|
28
|
+
"@deephaven/icons": "^0.95.0",
|
|
29
|
+
"@deephaven/log": "^0.95.0",
|
|
30
|
+
"@deephaven/react-hooks": "^0.95.0",
|
|
31
|
+
"@deephaven/utils": "^0.95.0",
|
|
32
32
|
"@fortawesome/fontawesome-svg-core": "^6.2.1",
|
|
33
33
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
34
34
|
"@internationalized/date": "^3.5.5",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"react-is": ">=16.8.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@deephaven/mocks": "^0.
|
|
62
|
-
"@deephaven/test-utils": "^0.
|
|
61
|
+
"@deephaven/mocks": "^0.95.0",
|
|
62
|
+
"@deephaven/test-utils": "^0.95.0",
|
|
63
63
|
"react-redux": "^7.2.4"
|
|
64
64
|
},
|
|
65
65
|
"files": [
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "ec9b41e921e2122879f53e9a266084d529664680"
|
|
78
78
|
}
|