@helpwave/hightide
Version:
helpwave's component and theming library
1 lines • 1.28 MB
Source Map (JSON)
{"version":3,"sources":["../src/components/branding/AppZumDocBadge.tsx","../src/components/branding/AppZumDocLogo.tsx","../src/components/branding/HelpwaveLogo.tsx","../src/components/branding/HelpwaveBadge.tsx","../src/components/chat/ChatAttachmentCard.tsx","../src/components/user-interaction/IconButton.tsx","../src/components/user-interaction/Tooltip.tsx","../src/hooks/useOverlayRegistry.ts","../src/hooks/useTransitionState.ts","../src/global-contexts/HightideConfigContext.tsx","../src/components/utils/Portal.tsx","../src/components/layout/AnchoredFloatingContainer.tsx","../src/hooks/useAnchoredPosition.ts","../src/utils/math.ts","../src/hooks/useWindowResizeObserver.ts","../src/hooks/useResizeObserver.ts","../src/hooks/useScrollObserver.ts","../src/utils/reactRefs.ts","../src/utils/bagFunctions.ts","../src/components/layout/Visibility.tsx","../src/hooks/useLogOnce.ts","../src/components/chat/ChatConversationList.tsx","../src/components/layout/ScrollableList.tsx","../src/components/chat/ChatConversationRow.tsx","../src/components/display-and-visualization/Avatar.tsx","../src/utils/array.ts","../src/utils/propsUtil.ts","../src/components/chat/ChatDateDivider.tsx","../src/components/chat/ChatMessageBubble.tsx","../src/components/chat/ChatMessageCard.tsx","../src/components/chat/ChatMessageComposer.tsx","../src/hooks/useControlledState.ts","../src/utils/resolveSetState.ts","../src/hooks/useEventCallbackStabelizer.ts","../src/components/chat/ChatMessageList.tsx","../src/components/chat/ChatQuickReplyChip.tsx","../src/components/chat/ChatSystemLine.tsx","../src/components/chat/ChatThreadHeader.tsx","../src/components/display-and-visualization/Card.tsx","../src/hooks/useChangingNumber.ts","../src/utils/curve.ts","../src/components/display-and-visualization/ChangingNumber.tsx","../src/components/user-interaction/Button.tsx","../src/components/display-and-visualization/Chip.tsx","../src/components/display-and-visualization/ExpansionIcon.tsx","../src/components/display-and-visualization/ProgressIndicator.tsx","../src/components/display-and-visualization/process-model/ProcessModelActivityNode.tsx","../src/components/display-and-visualization/process-model/ProcessModelCanvas.tsx","../src/components/display-and-visualization/process-model/layoutProcessModel.ts","../src/components/display-and-visualization/process-model/ProcessModelTerminalNode.tsx","../src/components/display-and-visualization/process-model/ProcessModelTraceReplay.tsx","../src/global-contexts/LocaleContext.tsx","../src/hooks/useStorage.ts","../src/utils/StorageListener.ts","../src/i18n/translations.ts","../src/i18n/util.ts","../src/i18n/useHightideTranslation.ts","../src/components/user-interaction/Select/Select.tsx","../src/components/user-interaction/Select/SelectRoot.tsx","../src/components/user-interaction/Select/SelectContext.tsx","../src/components/user-interaction/Select/useSelect.ts","../src/hooks/useSingleSelection.ts","../src/hooks/useListNavigation.tsx","../src/hooks/useSearch.ts","../src/utils/simpleSearch.ts","../src/hooks/useTypeAheadSearch.ts","../src/utils/dom.ts","../src/components/layout/popup/PopUpContext.tsx","../src/components/user-interaction/Select/SelectButton.tsx","../src/components/user-interaction/Select/SelectOption.tsx","../src/components/user-interaction/Select/SelectContent.tsx","../src/components/layout/popup/PopUp.tsx","../src/components/utils/FocusTrap.tsx","../src/hooks/focus/useFocusTrap.ts","../src/hooks/useOutsideClick.ts","../src/hooks/usePresenceRef.ts","../src/components/user-interaction/input/Input.tsx","../src/hooks/useDelay.ts","../src/hooks/focus/useFocusManagement.ts","../src/components/display-and-visualization/process-model/processModelLibrary.ts","../src/components/form/FieldLayout.tsx","../src/components/form/FormContext.tsx","../src/components/form/FormField.tsx","../src/components/form/FormObserver.tsx","../src/components/form/FormStore.ts","../src/components/form/useCreateForm.tsx","../src/components/layout/Carousel.tsx","../src/components/layout/DividerInserter.tsx","../src/components/layout/Expandable.tsx","../src/components/layout/FAQSection.tsx","../src/components/layout/InifiniteScroll.tsx","../src/components/layout/MarkdownInterpreter.tsx","../src/components/layout/TabSwitcher.tsx","../src/components/layout/TextImage.tsx","../src/components/layout/VerticalDivider.tsx","../src/components/layout/app/AppPage.tsx","../src/hooks/trees/treeUtilities.ts","../src/hooks/trees/useTreeExpansion.ts","../src/components/layout/navigation/navigation-menus/NavigationContext.tsx","../src/components/layout/navigation/navigation-menus/VerticalNavigationMenuItem.tsx","../src/components/layout/navigation/navigation-menus/types.ts","../src/components/layout/navigation/navigation-menus/VerticalNavigationMenu.tsx","../src/components/layout/dialog/Dialog.tsx","../src/components/layout/dialog/DialogContext.tsx","../src/components/layout/dialog/DialogOpener.tsx","../src/components/layout/dialog/DialogRoot.tsx","../src/components/layout/dialog/premade/ConfirmDialog.tsx","../src/components/layout/dialog/premade/DiscardChangesDialog.tsx","../src/components/layout/dialog/premade/InputDialog.tsx","../src/components/layout/dialog/premade/LanguageDialog.tsx","../src/components/layout/dialog/premade/ThemeDialog.tsx","../src/global-contexts/ThemeContext.tsx","../src/components/layout/drawer/Drawer.tsx","../src/components/layout/drawer/DrawerContainer.tsx","../src/components/layout/drawer/DrawerContext.tsx","../src/components/layout/drawer/DrawerCloseButton.tsx","../src/components/layout/drawer/DrawerRoot.tsx","../src/components/layout/loading/ErrorComponent.tsx","../src/components/layout/loading/LoadingAndErrorComponent.tsx","../src/components/layout/loading/LoadingContainer.tsx","../src/components/layout/loading/LoadingAnimation.tsx","../src/components/layout/navigation/BreadCrumbs.tsx","../src/components/layout/navigation/Navigation.tsx","../src/components/layout/navigation/Pagination.tsx","../src/components/layout/navigation/StepperBar.tsx","../src/components/layout/popup/PopUpOpener.tsx","../src/components/layout/popup/PopUpRoot.tsx","../src/components/layout/table/AutoColumnOrderFeature.ts","../src/components/layout/table/columnSizeUtil.ts","../src/components/layout/table/ColumnSizingWithTargetFeature.ts","../src/components/layout/table/FillerCell.tsx","../src/components/layout/table/TableProvider.tsx","../src/components/layout/table/TableContext.tsx","../src/components/user-interaction/data/FilterOperator.tsx","../src/components/user-interaction/data/filter-function.ts","../src/utils/date.ts","../src/components/layout/table/TableFilter.ts","../src/components/layout/table/TableCell.tsx","../src/components/layout/table/placeholderColumn.ts","../src/components/layout/table/TableDisplay.tsx","../src/components/layout/table/TableBody.tsx","../src/components/layout/table/TableHeader.tsx","../src/components/layout/table/TableSortButton.tsx","../src/components/layout/table/TableFilterButton.tsx","../src/components/user-interaction/data/FilterPopUp.tsx","../src/components/user-interaction/input/DateTimeInput.tsx","../src/components/user-interaction/date/TimeInput.tsx","../src/components/user-interaction/input/NumberStepperInput.tsx","../src/hooks/useStepperHold.ts","../src/components/user-interaction/input/NumberInput.tsx","../src/components/user-interaction/date/DatePicker.tsx","../src/components/user-interaction/date/DayPicker.tsx","../src/components/user-interaction/date/YearMonthPicker.tsx","../src/components/user-interaction/date/DateTimePicker.tsx","../src/components/user-interaction/date/DateTimePickerDialog.tsx","../src/components/user-interaction/input/DateTimeField.tsx","../src/components/user-interaction/input/dateTimeSegments.ts","../src/components/user-interaction/MultiSelect/MultiSelect.tsx","../src/components/user-interaction/MultiSelect/MultiSelectRoot.tsx","../src/components/user-interaction/MultiSelect/MultiSelectContext.tsx","../src/components/user-interaction/MultiSelect/useMultiSelect.ts","../src/hooks/useMultiSelection.ts","../src/components/user-interaction/MultiSelect/MultiSelectButton.tsx","../src/components/user-interaction/MultiSelect/MultiSelectOption.tsx","../src/components/user-interaction/MultiSelect/MultiSelectContent.tsx","../src/components/user-interaction/data/FilterOperatorLabel.tsx","../src/components/user-interaction/data/data-types.tsx","../src/components/layout/table/VirtualizedTableBody.tsx","../src/components/layout/virtualization/useVirtualizedRows.ts","../src/components/layout/virtualization/virtualizationScroll.ts","../src/hooks/useScrollbarState.ts","../src/components/layout/table/useNaturalColumnWidthLock.ts","../src/components/layout/table/TablePagination.tsx","../src/components/user-interaction/Checkbox.tsx","../src/components/layout/table/TableWithSelectionProvider.tsx","../src/components/layout/table/Table.tsx","../src/components/layout/table/TableColumn.tsx","../src/components/layout/table/TableColumnSwitcher.tsx","../src/components/layout/virtualization/VirtualizedCardGrid.tsx","../src/components/layout/virtualization/gridLayout.ts","../src/components/user-interaction/Combobox/Combobox.tsx","../src/components/user-interaction/Combobox/ComboboxRoot.tsx","../src/components/user-interaction/Combobox/ComboboxContext.tsx","../src/components/user-interaction/Combobox/useCombobox.ts","../src/components/user-interaction/Combobox/ComboboxInput.tsx","../src/components/user-interaction/Combobox/ComboboxList.tsx","../src/components/user-interaction/Combobox/ComboboxOption.tsx","../src/components/user-interaction/CopyToClipboardWrapper.tsx","../src/utils/writeToClipboard.ts","../src/components/user-interaction/LabelledCheckbox.tsx","../src/components/user-interaction/Menu.tsx","../src/components/user-interaction/MultiSelect/MultiSelectChipDisplay.tsx","../src/components/user-interaction/ScrollPicker.tsx","../src/components/user-interaction/Switch.tsx","../src/components/user-interaction/Textarea.tsx","../src/components/user-interaction/data/FilterList.tsx","../src/components/user-interaction/data/SortingList.tsx","../src/components/user-interaction/date/TimeDisplay.tsx","../src/components/user-interaction/date/TimePicker.tsx","../src/components/user-interaction/input/FlexibleDateTimeInput.tsx","../src/components/user-interaction/input/InsideLabelInput.tsx","../src/components/user-interaction/input/SearchBar.tsx","../src/components/user-interaction/input/ToggleableInput.tsx","../src/components/user-interaction/properties/CheckboxProperty.tsx","../src/components/user-interaction/properties/PropertyBase.tsx","../src/components/user-interaction/properties/DateProperty.tsx","../src/components/user-interaction/properties/MultiSelectProperty.tsx","../src/components/user-interaction/properties/NumberProperty.tsx","../src/components/user-interaction/properties/SelectProperty.tsx","../src/components/user-interaction/properties/TextProperty.tsx","../src/components/utils/Transition.tsx","../src/global-contexts/HightideProvider.tsx","../src/hooks/focus/useFocusGuards.ts","../src/hooks/focus/useFocusOnceVisible.ts","../src/hooks/trees/useTreeFocusNavigation.ts","../src/hooks/trees/useTreeNavigation.ts","../src/hooks/useDebouncer.ts","../src/hooks/useHandleRefs.ts","../src/hooks/useIsMounted.ts","../src/hooks/useLogUnstableDependencies.ts","../src/hooks/useOverwritableState.ts","../src/hooks/useRerender.ts","../src/hooks/useSwipeGesture.ts","../src/hooks/useThrottle.ts","../src/hooks/useUpdatingDateString.ts","../src/utils/emailValidation.ts","../src/hooks/useValidators.ts","../src/utils/builder.ts","../src/utils/duration.ts","../src/utils/loopingArray.ts","../src/utils/match.ts","../src/utils/noop.ts","../src/utils/promise.ts"],"sourcesContent":["import type { HTMLAttributes } from 'react'\nimport clsx from 'clsx'\nimport { AppZumDocLogo } from './AppZumDocLogo'\n\ntype Size = 'sm' | 'md' | 'lg'\n\nexport type AppZumDocBadgeProps = HTMLAttributes<HTMLSpanElement> & {\n size?: Size,\n}\n\nexport const AppZumDocBadge = ({\n size = 'sm',\n ...props\n}: AppZumDocBadgeProps) => {\n return (\n <span\n {...props}\n className={clsx(\n 'flex flex-row items-center font-bold font-space rounded-md text-[#057986]',\n {\n 'gap-x-1': size === 'sm',\n 'gap-x-2 text-lg': size === 'md',\n 'gap-x-2 text-xl': size === 'lg'\n },\n props.className\n )}\n >\n <AppZumDocLogo size={size}/>\n App zum Doc\n </span>\n )\n}\n","import type { CSSProperties, SVGProps } from 'react'\nimport { useId } from 'react'\nimport { clsx } from 'clsx'\n\nconst backFillPath = 'M33.1817 37.511L29.7804 37.511C21.7695 37.511 15.2754 44.0051 15.2754 52.016C15.2754 60.0268 21.7695 66.5209 29.7804 66.5209H35.4017C35.4208 66.5209 35.4274 66.5239 35.4301 66.5251C35.436 66.5275 35.4456 66.5331 35.4559 66.5434C35.4662 66.5536 35.4717 66.5633 35.4742 66.5691C35.4754 66.5719 35.4783 66.5785 35.4783 66.5975L35.4783 72.852C35.4783 80.8628 41.9724 87.3569 49.9833 87.3569C57.9942 87.3569 64.4883 80.8628 64.4883 72.852L64.4883 54.7684C64.4883 45.2374 56.7619 37.511 47.2309 37.511L43.6515 37.511V42.1072L47.2309 42.1072C54.2235 42.1072 59.8921 47.7758 59.8921 54.7684V72.852C59.8921 78.3244 55.4558 82.7608 49.9833 82.7608C44.5108 82.7608 40.0745 78.3244 40.0745 72.852L40.0745 66.5975C40.0745 64.0168 37.9824 61.9248 35.4017 61.9248L29.7804 61.9248C24.3079 61.9248 19.8716 57.4884 19.8716 52.016C19.8716 46.5435 24.3079 42.1072 29.7804 42.1072L33.1817 42.1072V37.511Z'\n\nconst frontFillPath = 'M65.0734 29.3412C65.0734 21.3303 58.5793 14.8362 50.5685 14.8362C42.5576 14.8362 36.0635 21.3303 36.0635 29.3412V47.4247C36.0635 56.9557 43.7899 64.6821 53.3209 64.6821H57.4673V60.086H53.3209C46.3283 60.086 40.6597 54.4173 40.6597 47.4247V29.3412C40.6597 23.8687 45.096 19.4324 50.5685 19.4324C56.0409 19.4324 60.4773 23.8687 60.4773 29.3412V35.5956C60.4773 38.1763 62.5693 40.2684 65.15 40.2684H70.7714C76.2439 40.2684 80.6802 44.7047 80.6802 50.1772C80.6802 55.6496 76.2439 60.086 70.7714 60.086H66.7949V64.6821H70.7714C78.7823 64.6821 85.2764 58.188 85.2764 50.1772C85.2764 42.1663 78.7823 35.6722 70.7714 35.6722H65.15C65.131 35.6722 65.1244 35.6692 65.1216 35.668C65.1158 35.6656 65.1061 35.66 65.0959 35.6497C65.0856 35.6395 65.08 35.6298 65.0776 35.624L65.0775 35.6238C65.0763 35.6209 65.0734 35.6142 65.0734 35.5956V29.3412Z'\n\nconst backStrokePath = 'M43.65 39.81 L47.23 39.81 A14.96 14.96 0 0 1 62.19 54.77 L62.19 72.85 A12.21 12.21 0 0 1 37.78 72.85 L37.78 66.6 Q37.78 64.22 35.4 64.22 L29.78 64.22 A12.21 12.21 0 0 1 29.78 39.81 L33.18 39.81'\n\nconst frontStrokePath = 'M57.47 62.38 L53.32 62.38 A14.96 14.96 0 0 1 38.36 47.42 L38.36 29.34 A12.21 12.21 0 0 1 62.78 29.34 L62.78 35.6 Q62.78 37.97 65.15 37.97 L70.77 37.97 A12.21 12.21 0 0 1 70.77 62.38 L66.79 62.38'\n\nexport type AppZumDocLogoProps = SVGProps<SVGSVGElement> & {\n frontColor?: string,\n backColor?: string,\n animate?: 'none' | 'loading' | 'pulse' | 'bounce',\n size?: 'sm' | 'md' | 'lg',\n animationDuration?: number,\n}\n\nexport const AppZumDocLogo = ({\n frontColor = '#095763',\n backColor = '#4E97A2',\n animate = 'none',\n size,\n animationDuration = 1.7,\n ...props\n}: AppZumDocLogoProps) => {\n const id = useId()\n const isLoadingAnimation = animate === 'loading'\n let svgAnimationKey = ''\n\n if (animate === 'pulse') {\n svgAnimationKey = 'animate-pulse'\n } else if (animate === 'bounce') {\n svgAnimationKey = 'animate-bounce'\n }\n\n const style = animationDuration !== undefined && isLoadingAnimation\n ? { ...props.style, '--helpwave-loading-duration': `${animationDuration}s` } as CSSProperties\n : props.style\n\n return (\n <svg\n {...props}\n style={style}\n viewBox=\"14 14 72 74\"\n fill=\"none\"\n className={clsx({\n 'max-w-16 max-h-16 min-w-16 min-h-16': size === 'lg',\n 'max-w-12 max-h-12 min-w-12 min-h-12': size === 'md',\n 'max-w-8 max-h-8 min-w-8 min-h-8': size === 'sm',\n }, props.className)}\n >\n <g className={clsx(svgAnimationKey)}>\n {isLoadingAnimation ? (\n <>\n <clipPath id={`${id}-back`}>\n <path d={backFillPath}/>\n </clipPath>\n <clipPath id={`${id}-front`}>\n <path d={frontFillPath}/>\n </clipPath>\n <g clipPath={`url(#${id}-back)`}>\n <path\n className=\"animate-azd-fill-back\"\n d={backStrokePath}\n stroke={backColor}\n strokeWidth={7}\n strokeLinecap=\"round\"\n pathLength={1000}\n strokeDasharray=\"1000 2000\"\n />\n </g>\n <g clipPath={`url(#${id}-front)`}>\n <path\n className=\"animate-azd-fill-front\"\n d={frontStrokePath}\n stroke={frontColor}\n strokeWidth={7}\n strokeLinecap=\"round\"\n pathLength={1000}\n strokeDasharray=\"1000 2000\"\n />\n </g>\n </>\n ) : (\n <>\n <path fillRule=\"evenodd\" clipRule=\"evenodd\" d={backFillPath} fill={backColor}/>\n <path fillRule=\"evenodd\" clipRule=\"evenodd\" d={frontFillPath} fill={frontColor}/>\n </>\n )}\n </g>\n </svg>\n )\n}\n","import type { CSSProperties, SVGProps } from 'react'\nimport { clsx } from 'clsx'\n\nexport type HelpwaveProps = SVGProps<SVGSVGElement> & {\n color?: string,\n animate?: 'none' | 'loading' | 'pulse' | 'bounce',\n size?: 'sm' | 'md' | 'lg',\n animationDuration?: number,\n}\n\n/**\n * The helpwave loading spinner based on the svg logo.\n */\nexport const HelpwaveLogo = ({\n color = 'currentColor',\n size,\n animate = 'none',\n animationDuration = 1.7,\n ...props\n}: HelpwaveProps) => {\n const isLoadingAnimation = animate === 'loading'\n let svgAnimationKey = ''\n\n if (animate === 'pulse') {\n svgAnimationKey = 'animate-pulse'\n } else if (animate === 'bounce') {\n svgAnimationKey = 'animate-bounce'\n }\n\n const style = animationDuration !== undefined && isLoadingAnimation\n ? { ...props.style, '--helpwave-loading-duration': `${animationDuration}s` } as CSSProperties\n : props.style\n\n return (\n <svg\n {...props}\n style={style}\n viewBox=\"0 0 1024 1024\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeWidth={65}\n className={clsx({\n 'max-w-16 max-h-16 min-w-16 min-h-16': size === 'lg',\n 'max-w-12 max-h-12 min-w-12 min-h-12': size === 'md',\n 'max-w-8 max-h-8 min-w-8 min-h-8': size === 'sm',\n }, props.className)}\n >\n <g className={clsx(svgAnimationKey)}>\n <path className={clsx({ 'animate-wave-big-left-up': isLoadingAnimation })}\n d=\"M146 644.214C146 498.088 253.381 379.629 385.843 379.629\" stroke={color} strokeDasharray=\"1000 1000\"/>\n <path className={clsx({ 'animate-wave-big-right-down': isLoadingAnimation })}\n d=\"M625.686 645.272C493.224 645.272 385.843 526.813 385.843 380.687\" stroke={color}\n strokeDasharray=\"1000 1000\"/>\n <path className={clsx({ 'animate-wave-small-left-up': isLoadingAnimation })}\n d=\"M533.585 613.522C533.585 508.895 610.47 424.079 705.312 424.079\" stroke={color}\n strokeDasharray=\"1000 1000\"/>\n <path className={clsx({ 'animate-wave-small-right-down': isLoadingAnimation })}\n d=\"M878 615.639C782.628 615.639 705.313 530.822 705.313 426.196\" stroke={color}\n strokeDasharray=\"1000 1000\"/>\n </g>\n </svg>\n )\n}\n","import { HelpwaveLogo } from './HelpwaveLogo'\nimport type { HTMLAttributes } from 'react'\nimport clsx from 'clsx'\n\ntype Size = 'sm' | 'md' | 'lg'\n\nexport type HelpwaveBadgeProps = HTMLAttributes<HTMLSpanElement> & {\n size?: Size,\n}\n\n/**\n * A Badge with the helpwave logo and the helpwave name\n */\nexport const HelpwaveBadge = ({\n size = 'sm',\n ...props\n}: HelpwaveBadgeProps) => {\n return (\n <span\n {...props}\n className={clsx(\n 'flex flex-row items-center font-bold font-space rounded-md',\n {\n 'gap-x-1': size === 'sm',\n 'gap-x-2 text-lg': size === 'md',\n 'gap-x-2 text-xl': size === 'lg'\n },\n props.className\n )}\n >\n <HelpwaveLogo size={size}/>\n helpwave\n </span>\n )\n}\n","import type { HTMLAttributes, ReactNode } from 'react'\nimport clsx from 'clsx'\nimport { Download, FileText } from 'lucide-react'\nimport { IconButton } from '../user-interaction/IconButton'\nimport type { ChatMessageDirection } from './ChatMessageBubble'\n\nexport type ChatAttachmentCardProps = HTMLAttributes<HTMLDivElement> & {\n name: ReactNode,\n metadata?: ReactNode,\n icon?: ReactNode,\n direction?: ChatMessageDirection,\n downloadLabel?: string,\n onDownload?: () => void,\n}\n\nexport const ChatAttachmentCard = ({\n name,\n metadata,\n icon,\n direction = 'incoming',\n downloadLabel = 'Download',\n onDownload,\n ...props\n}: ChatAttachmentCardProps) => {\n return (\n <div\n {...props}\n className={clsx('chat-attachment-card', props.className)}\n data-direction={direction}\n >\n <span className=\"chat-attachment-card-icon\">\n {icon ?? <FileText/>}\n </span>\n <span className=\"chat-attachment-card-info\">\n <span className=\"chat-attachment-card-filename\">{name}</span>\n {metadata && (\n <span className=\"chat-attachment-card-metadata\">{metadata}</span>\n )}\n </span>\n {onDownload && (\n <IconButton\n tooltip={downloadLabel}\n size=\"sm\"\n color=\"primary\"\n coloringStyle=\"text\"\n onClick={onDownload}\n >\n <Download/>\n </IconButton>\n )}\n </div>\n )\n}\n","import type { ForwardedRef, ReactNode } from 'react'\nimport { forwardRef,type ButtonHTMLAttributes } from 'react'\nimport type { TooltipDisplayProps } from './Tooltip'\nimport { TooltipContext, TooltipDisplay, TooltipRoot, useTooltip } from './Tooltip'\nimport { Visibility } from '../layout/Visibility'\nimport { useLogOnce } from '@/src/hooks/useLogOnce'\nimport { ReactRefsUtil } from '@/src/utils/reactRefs'\nimport clsx from 'clsx'\n\n/**\n * The different sizes for a icon button\n */\ntype IconButtonSize = 'xs' | 'sm' | 'md' | 'lg' | null\n\ntype IconButtonColoringStyle = 'outline' | 'solid' | 'text' | 'tonal' | 'tonal-outline' | null\n\n\n\nexport interface IconButtonBaseProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * @default 'medium'\n */\n size?: IconButtonSize,\n /**\n * @default 'solid'\n */\n coloringStyle?: IconButtonColoringStyle,\n}\n\nexport const IconButtonBase = forwardRef<HTMLButtonElement, IconButtonBaseProps>(function IconButtonBase({\n children,\n size = 'md',\n color = 'primary',\n coloringStyle = 'solid',\n disabled,\n ...props\n}, ref) {\n return (\n <button\n {...props}\n ref={ref}\n disabled={disabled}\n type={props['type'] ?? 'button'}\n\n\n onClick={event => {\n props.onClick?.(event)\n }}\n\n className={clsx('icon-button', props.className)}\n data-disabled={disabled ? '': undefined}\n data-size={size ?? undefined}\n data-color={color ?? undefined}\n data-coloringstyle={coloringStyle ?? undefined}\n >\n {children}\n </button>\n )\n})\n\n\n\n\n\n\ntype IconButtonTooltipTriggerProps = IconButtonBaseProps\n\n\nconst IconButtonTooltipTrigger = forwardRef<HTMLButtonElement, IconButtonTooltipTriggerProps>(function IconButtonTooltipTrigger({\n disabled,\n ...props\n}, ref) {\n const { trigger: { ref: triggerRef, props: tooltipTriggerProps } } = useTooltip()\n\n return (\n <IconButtonBase\n {...props}\n ref={ReactRefsUtil.assingRefsBuilder([ref, triggerRef as ForwardedRef<HTMLButtonElement>])}\n disabled={disabled}\n type={props['type'] ?? 'button'}\n\n onClick={event => {\n if(!disabled) {\n tooltipTriggerProps.onClick()\n }\n props.onClick?.(event)\n }}\n onKeyDown={(e) => {\n if(!disabled) {\n if(e.key === 'Enter' || e.key === ' ') {\n tooltipTriggerProps.onClick()\n }\n }\n props.onKeyDown?.(e)\n }}\n onPointerEnter={(e) => {\n if(!disabled) {\n tooltipTriggerProps.onPointerEnter()\n }\n props.onPointerEnter?.(e)\n }}\n onPointerLeave={(e) => {\n if(!disabled) {\n tooltipTriggerProps.onPointerLeave()\n }\n props.onPointerLeave?.(e)\n }}\n onPointerCancel={(e) => {\n if(!disabled) {\n tooltipTriggerProps.onPointerCancel()\n }\n props.onPointerCancel?.(e)\n }}\n onBlur={(e) => {\n if(!disabled) {\n tooltipTriggerProps.onBlur()\n }\n props.onBlur?.(e)\n }}\n />\n )\n})\n\n\n\nexport interface IconButtonProps extends IconButtonBaseProps {\n useTooltipAsLabel?: boolean,\n tooltip?: ReactNode,\n tooltipProps?: Omit<TooltipDisplayProps, 'children' | 'isShown'>,\n}\n\n/**\n * A icon button with a tooltip\n */\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton({\n tooltip,\n tooltipProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n useTooltipAsLabel = true,\n color = 'neutral',\n disabled,\n ...props\n}, ref) {\n const isLabeled = !!ariaLabel || !!ariaLabelledby\n const isTooltipLabel = useTooltipAsLabel && !!tooltip\n\n useLogOnce('IconButton: Either provide \"aria-label\" or \"aria-labelledby\" or use ' +\n '\"useTooltipAsLabel\" and \"tooltip\" to give the icon button a semantic meaning',\n !isLabeled && !isTooltipLabel, { type: 'warning' })\n\n return (\n <TooltipRoot disabled={disabled}>\n <TooltipContext.Consumer>\n {(context) => {\n const id = context?.tooltip.id\n return (\n <IconButtonTooltipTrigger\n {...props}\n ref={ref}\n\n color={color}\n disabled={disabled}\n\n aria-describedby={props['aria-describedby'] ?? (isLabeled && !!tooltip ? id : undefined)}\n aria-labelledby={isLabeled ? ariaLabelledby : (isTooltipLabel ? id : undefined)}\n aria-label={ariaLabel}\n />\n )}}\n </TooltipContext.Consumer>\n <Visibility isVisible={!!tooltip}>\n <TooltipDisplay aria-hidden={!useTooltipAsLabel && !!props['aria-hidden']} {...tooltipProps}>\n {tooltip}\n </TooltipDisplay>\n </Visibility>\n </TooltipRoot>\n )\n})","import type { PropsWithChildren, ReactNode, RefObject } from 'react'\nimport { forwardRef, useContext, useEffect } from 'react'\nimport { useId } from 'react'\nimport { useCallback, useMemo, useRef, useState } from 'react'\nimport type { FloatingElementAlignment, UseAnchoredPositionOptions } from '@/src/hooks/useAnchoredPosition'\nimport { useOverlayRegistry } from '@/src/hooks/useOverlayRegistry'\nimport { useTransitionState } from '@/src/hooks/useTransitionState'\nimport type { TooltipConfig } from '@/src/global-contexts/HightideConfigContext'\nimport { useHightideConfig } from '@/src/global-contexts/HightideConfigContext'\nimport { Portal } from '@/src/components/utils/Portal'\nimport type { AnchoredFloatingContainerProps } from '../layout/AnchoredFloatingContainer'\nimport { AnchoredFloatingContainer } from '../layout/AnchoredFloatingContainer'\nimport { createContext } from 'react'\nimport { BagFunctionUtil } from '@/src/utils/bagFunctions'\nimport { ReactRefsUtil } from '@/src/utils/reactRefs'\n\nexport interface TooltipTriggerContextValue {\n ref: RefObject<HTMLElement | null>,\n callbackRef: (el: HTMLElement | null) => void,\n props: {\n 'onPointerEnter': () => void,\n 'onPointerLeave': () => void,\n 'onPointerCancel': () => void,\n 'onClick': () => void,\n 'onBlur': () => void,\n 'aria-describedby'?: string,\n },\n}\n\nexport interface TooltipContextType {\n tooltip: {\n id: string,\n setId: (id: string) => void,\n },\n trigger: TooltipTriggerContextValue,\n disabled: boolean,\n isShown: boolean,\n open: () => void,\n close: () => void,\n}\n\nexport const TooltipContext = createContext<TooltipContextType | null>(null)\n\nexport const useTooltip = () => {\n const context = useContext(TooltipContext)\n if(!context) {\n throw new Error('useTooltip must be used within a TooltipContext.Provider or TooltipRoot')\n }\n return context\n}\n\nexport interface TooltipRootProps extends PropsWithChildren {\n isInitiallyShown?: boolean,\n onIsShownChange?: (isShown: boolean) => void,\n appearDelay?: number,\n disabled?: boolean,\n}\n\nexport const TooltipRoot = ({\n children,\n isInitiallyShown = false,\n onIsShownChange,\n appearDelay: appearOverwrite,\n disabled = false,\n}: TooltipRootProps) => {\n const generatedId = 'tooltip-' + useId()\n const [tooltipId, setTooltipId] = useState<string>(generatedId)\n const [isShown, setIsShown] = useState(isInitiallyShown)\n\n const timeoutRef = useRef<NodeJS.Timeout>(undefined)\n\n const { config } = useHightideConfig()\n\n const appearDelay = useMemo(() =>\n appearOverwrite ?? config.tooltip.appearDelay,\n [appearOverwrite, config.tooltip.appearDelay])\n\n const triggerRef = useRef<HTMLElement | null>(null)\n\n useEffect(() => {\n onIsShownChange?.(isShown)\n }, [isShown, onIsShownChange])\n\n const openWithDelay = useCallback(() => {\n if (timeoutRef.current || isShown) return\n\n if(appearDelay < 0) {\n setIsShown(true)\n return\n }\n\n timeoutRef.current = setTimeout(() => {\n timeoutRef.current = undefined\n setIsShown(true)\n }, appearDelay)\n }, [appearDelay, isShown])\n\n\n const close = useCallback(() => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }\n setIsShown(false)\n }, [])\n\n useEffect(() => {\n if (!isShown) return\n\n const closeOnBlur = () => close()\n const closeOnScroll = () => close()\n\n window.addEventListener('blur', closeOnBlur)\n window.addEventListener('scroll', closeOnScroll, true)\n\n return () => {\n window.removeEventListener('blur', closeOnBlur)\n window.removeEventListener('scroll', closeOnScroll, true)\n }\n }, [isShown, close])\n\n useEffect(() => {\n if(disabled) {\n setIsShown(false)\n if(timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }\n }\n }, [disabled])\n\n const contextValue: TooltipContextType = useMemo(() => ({\n tooltip: {\n id: tooltipId,\n setId: setTooltipId,\n },\n trigger: {\n ref: triggerRef,\n callbackRef: (el: HTMLElement | null) => triggerRef.current = el,\n props: {\n 'onPointerEnter': openWithDelay,\n 'onPointerLeave': close,\n 'onPointerCancel': close,\n 'onClick': openWithDelay,\n 'onBlur': close,\n 'aria-describedby': tooltipId,\n },\n },\n disabled,\n isShown,\n open: openWithDelay,\n close,\n }), [tooltipId, openWithDelay, close, isShown, disabled])\n\n return (\n <TooltipContext.Provider value={contextValue}>\n {children}\n </TooltipContext.Provider>\n )\n}\n\n\n\n\n\n\n\ntype TooltipAligment = 'top' | 'bottom' | 'left' | 'right'\n\nexport interface TooltipDisplayProps extends Omit<AnchoredFloatingContainerProps, 'options' | 'anchor'>, Partial<TooltipConfig> {\n 'alignment'?: TooltipAligment,\n 'disabled'?: boolean,\n 'anchor'?: RefObject<HTMLElement | null>,\n 'isShown'?: boolean,\n 'options'?: Omit<UseAnchoredPositionOptions, 'verticalAlignment' | 'horizontalAlignment'>,\n 'data-name'?: string,\n}\n\nexport const TooltipDisplay = forwardRef<HTMLDivElement, TooltipDisplayProps>(function TooltipAnchoredFloatingContainer({\n children,\n alignment = 'bottom',\n disabled: disabledOverwrite,\n isShown: isShownOverwrite,\n isAnimated: isAnimatedOverwrite,\n anchor: anchorOverwrite,\n ...props\n}, forwardRef) {\n const { config } = useHightideConfig()\n const tooltipContext = useContext(TooltipContext)\n const anchorFallback = useRef(null)\n\n const disabled = disabledOverwrite ?? tooltipContext?.disabled\n const isShown = isShownOverwrite ?? tooltipContext?.isShown ?? false\n const anchor = anchorOverwrite ?? tooltipContext?.trigger.ref ?? anchorFallback\n const id = tooltipContext?.tooltip.id ?? props.id\n\n useEffect(() => {\n if(!tooltipContext || !props.id) return\n tooltipContext?.tooltip.setId(props.id)\n }, [props.id, tooltipContext])\n\n const isAnimated = useMemo(() =>\n isAnimatedOverwrite ?? config.tooltip.isAnimated,\n [isAnimatedOverwrite, config.tooltip.isAnimated])\n\n const container = useRef<HTMLDivElement | null>(null)\n\n const isActive = !disabled && isShown\n\n const { isVisible, transitionState } = useTransitionState(\n useMemo(() => ({ isOpen: isShown, ref: container }), [isShown])\n )\n\n const verticalAlignment: FloatingElementAlignment = useMemo(() =>\n alignment === 'top' ? 'beforeStart' : alignment === 'bottom' ? 'afterEnd' : 'center',\n [alignment])\n\n const horizontalAlignment: FloatingElementAlignment = useMemo(() =>\n alignment === 'left' ? 'beforeStart' : alignment === 'right' ? 'afterEnd' : 'center',\n [alignment])\n\n const { zIndex } = useOverlayRegistry({ isActive })\n\n if(disabled) return null\n\n return (\n <Portal>\n <AnchoredFloatingContainer\n {...props}\n id={id}\n ref={ReactRefsUtil.assingRefsBuilder([container, forwardRef])}\n active={isVisible}\n anchor={anchor}\n options={{\n verticalAlignment,\n horizontalAlignment,\n avoidOverlap: true,\n screenPadding: config.tooltip.screenPadding,\n ...props.options,\n }}\n\n data-name={props['data-name'] ?? 'tooltip'}\n data-state={transitionState}\n data-animated={isAnimated ? '': undefined}\n\n role=\"tooltip\"\n\n style={{\n zIndex,\n position: 'fixed',\n opacity: isVisible ? undefined : 0,\n ...props.style\n }}\n >\n {children}\n </AnchoredFloatingContainer>\n </Portal>\n )\n})\n\n\n\nexport interface TooltipTriggerBag extends TooltipTriggerContextValue {\n disabled: boolean,\n isShown: boolean,\n}\n\nexport interface TooltipTriggerProps {\n children: (bag: TooltipTriggerBag) => ReactNode,\n}\n\nexport const TooltipTrigger = ({\n children,\n}: TooltipTriggerProps) => {\n const context = useTooltip()\n const bag: TooltipTriggerBag = { ...context.trigger, disabled: context.disabled, isShown: context.isShown }\n\n return BagFunctionUtil.resolve(children, bag)\n}\n\n\n\n\nexport interface TooltipProps extends TooltipRootProps, Pick<TooltipDisplayProps, 'alignment' |'isAnimated'> {\n tooltip: ReactNode,\n containerClassName?: string,\n displayProps?: Omit<TooltipDisplayProps, 'alignment' |'isAnimated'>,\n}\n\n/**\n * A Component for showing a tooltip when hovering over Content\n */\nexport const Tooltip = ({\n tooltip,\n children,\n isInitiallyShown,\n appearDelay,\n disabled,\n containerClassName,\n alignment,\n isAnimated,\n onIsShownChange,\n displayProps,\n}: TooltipProps) => {\n\n return (\n <TooltipRoot\n isInitiallyShown={isInitiallyShown}\n onIsShownChange={onIsShownChange}\n appearDelay={appearDelay}\n disabled={disabled}\n >\n <TooltipTrigger>\n {({ props, callbackRef, disabled }) => (\n <div\n ref={callbackRef}\n className={containerClassName}\n {...(disabled ? undefined : props)}\n >\n {children}\n </div>\n )}\n </TooltipTrigger>\n <TooltipDisplay\n alignment={alignment}\n isAnimated={isAnimated}\n {...displayProps}\n >\n {tooltip}\n </TooltipDisplay>\n </TooltipRoot>\n )\n}\n","import { useEffect, useId, useMemo, useState } from 'react'\n\nexport type OverlayItem = {\n id: string,\n tags?: string[],\n}\n\ntype OverlayItemInformation = OverlayItem & {\n zIndex: number,\n position: number,\n tagPositions: Record<string, number>,\n}\n\ntype OverlayRegistryValue = {\n itemInformation: Record<string, OverlayItemInformation>,\n tagItemCounts: Record<string, number>,\n activeId: string | null,\n}\n\ntype OverlayRegistryListenerCallback = (value: OverlayRegistryValue) => void\n\nexport class OverlayRegistry {\n private static instance: OverlayRegistry | null = null\n\n static getInstance(): OverlayRegistry {\n if (!OverlayRegistry.instance) {\n OverlayRegistry.instance = new OverlayRegistry()\n }\n return OverlayRegistry.instance\n }\n\n // The frontmost overlay is at the end of the array\n private overlayIds: string[] = []\n private overlayItems: Record<string, OverlayItem> = {}\n private listeners = new Set<OverlayRegistryListenerCallback>()\n\n register(item: OverlayItem) {\n this.overlayIds = this.overlayIds.filter(id => id !== item.id)\n this.overlayIds.push(item.id)\n this.overlayItems[item.id] = item\n this.notify()\n return () => {\n this.overlayIds = this.overlayIds.filter(id => id !== item.id)\n delete this.overlayItems[item.id]\n this.notify()\n }\n }\n\n update(item: OverlayItem) {\n this.overlayItems[item.id] = item\n this.notify()\n }\n\n addListener(callback: OverlayRegistryListenerCallback) {\n this.listeners.add(callback)\n return () => {\n this.listeners.delete(callback)\n }\n }\n\n private notify() {\n const itemInformation: Record<string, OverlayItemInformation> = {}\n const ids = [...this.overlayIds]\n const startZIndex = 100\n const tagCount: Record<string, number> = {}\n for (let index = ids.length - 1; index >= 0; index--) {\n const id = ids[index]\n const item = this.overlayItems[id]\n itemInformation[id] = {\n ...item,\n position: index,\n tagPositions: {},\n zIndex: startZIndex + index,\n }\n for(const tag of item.tags ?? []) {\n const count = tagCount[tag] ?? 0\n const nextPosition = count\n tagCount[tag] = count + 1\n itemInformation[id].tagPositions[tag] = nextPosition\n }\n }\n for (const callback of this.listeners) {\n callback({ activeId: ids[ids.length - 1] ?? null, itemInformation, tagItemCounts: tagCount })\n }\n }\n}\n\nexport type UseOverlayRegistryProps = Partial<OverlayItem> & {\n isActive?: boolean,\n /** Tags cannot change on every render, thus make sure they are wrapped in a useMemo or similar */\n tags?: string[],\n}\n\nexport type UseOverlayRegistryResult = {\n isInFront: boolean,\n zIndex?: number,\n position?: number,\n tagPositions?: Record<string, number>,\n tagItemCounts: Record<string, number>,\n}\n\nexport const useOverlayRegistry = (props: UseOverlayRegistryProps = {}): UseOverlayRegistryResult => {\n const generatedId = useId()\n const item: OverlayItem = useMemo(() => ({\n id: props.id ?? generatedId,\n tags: props.tags,\n }), [props.id, generatedId, props.tags])\n const [value, setValue] = useState<OverlayRegistryValue>({\n activeId: null,\n itemInformation: {},\n tagItemCounts: {}\n })\n const registry = useMemo(() => OverlayRegistry.getInstance(), [])\n\n useEffect(() => {\n if(!props.isActive) {\n return\n }\n function callback(value: OverlayRegistryValue) {\n setValue(value)\n }\n\n const removeListener = registry.addListener(callback)\n const unregister = registry.register(item)\n return () => {\n removeListener()\n unregister()\n setValue({\n activeId: null,\n itemInformation: {},\n tagItemCounts: {}\n })\n }\n }, [props.isActive, item, registry])\n\n const itemInformation = value.itemInformation[item.id]\n\n return {\n isInFront: value.activeId === item.id,\n zIndex: itemInformation?.zIndex,\n position: itemInformation?.position,\n tagPositions: itemInformation?.tagPositions,\n tagItemCounts: value.tagItemCounts,\n }\n}","'use client'\n\nimport type { RefObject } from 'react'\nimport { useCallback, useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react'\n\nexport type TransitionState = 'opened' | 'closed' | 'opening' | 'closing'\n\nconst reducer = (state: TransitionState, action: 'open' | 'close' | 'finished') : TransitionState => {\n switch (action) {\n case 'open':\n return 'opening'\n case 'close':\n return 'closing'\n case 'finished':{\n if(state === 'opening') {\n return 'opened'\n }\n if(state === 'closing') {\n return 'closed'\n }\n return state\n }\n default:\n return state\n }\n}\n\ntype UseTransitionStateResult = {\n transitionState: TransitionState,\n isVisible: boolean,\n}\n\ntype UseTransitionStateProps = {\n isOpen: boolean,\n initialState?: TransitionState,\n ref: RefObject<HTMLElement | null>,\n timeout?: number,\n}\n\nexport const useTransitionState = ({\n isOpen,\n initialState = 'closed',\n ref,\n timeout: initialTimeout = 1000,\n}: UseTransitionStateProps): UseTransitionStateResult => {\n const [state, dispatch] = useReducer(reducer, initialState)\n\n const timer = useRef<NodeJS.Timeout | undefined>(undefined)\n const hasAnimation = useRef<boolean>(false)\n const [timeout] = useState<number>(initialTimeout)\n\n useEffect(() => {\n if (isOpen && (state !== 'opened' && state !== 'opening')) {\n dispatch('open')\n } else if (!isOpen && (state !== 'closed' && state !== 'closing')) {\n dispatch('close')\n }\n }, [isOpen, state])\n\n\n useEffect(() => {\n if (state === 'opening' || state === 'closing') {\n if (timer.current) {\n clearTimeout(timer.current)\n }\n if(timeout > 0) {\n timer.current = setTimeout(() => {\n dispatch('finished')\n }, timeout)\n }\n } else {\n if (timer.current) {\n clearTimeout(timer.current)\n }\n }\n }, [state, timeout])\n\n useLayoutEffect(() => {\n if (state === 'opening' || state === 'closing') {\n let element = ref.current\n if(!element) {\n console.warn('useTransitionState: ref is not set to an element using window instead')\n element = window.document.body\n }\n const animations = element.getAnimations({ subtree: true })\n .filter(animation => animation.effect?.getTiming().duration !== '0s')\n if (animations.length > 0) {\n hasAnimation.current = true\n Promise.all(animations.map(animation => animation.finished))\n .then(() => {\n dispatch('finished')\n })\n .catch(() => {\n dispatch('finished')\n })\n } else {\n dispatch('finished')\n hasAnimation.current = false\n clearTimeout(timer.current)\n }\n }\n }, [ref, state])\n\n const onStart = useCallback(() => {\n hasAnimation.current = true\n }, [])\n\n const onEnd = useCallback(() => {\n dispatch('finished')\n hasAnimation.current = false\n }, [])\n\n useEffect(() => {\n if (ref?.current && (state === 'opening' || state === 'closing')) {\n const element = ref.current\n element.addEventListener('animationstart', onStart)\n element.addEventListener('animationend', onEnd)\n element.addEventListener('transitionstart', onStart)\n element.addEventListener('transitionend', onEnd)\n element.addEventListener('transitioncancel', onEnd)\n return () => {\n element.removeEventListener('animationstart', onStart)\n element.removeEventListener('animationend', onEnd)\n element.removeEventListener('transitionstart', onStart)\n element.removeEventListener('transitionend', onEnd)\n element.removeEventListener('transitioncancel', onEnd)\n }\n }\n }, [state, ref, onStart, onEnd])\n\n return {\n transitionState: state,\n isVisible: state !== 'closed',\n }\n}","import { createContext, type PropsWithChildren, useContext, useState } from 'react'\nimport type { ResolvedTheme } from '@/src/global-contexts/ThemeContext'\nimport type { HightideTranslationLocales } from '@/src/i18n/translations'\nimport type { DeepPartial } from '@/src/utils/typing'\n\nexport type TooltipConfig = {\n appearDelay: number,\n isAnimated: boolean,\n screenPadding: number,\n}\n\nexport type ThemeConfig = {\n initialTheme: ResolvedTheme,\n}\n\nexport type LocalizationConfig = {\n defaultLocale: HightideTranslationLocales,\n defaultTimeZone?: string,\n defaultIs24HourFormat?: boolean,\n}\n\nexport type HightideConfig = {\n tooltip: TooltipConfig,\n theme: ThemeConfig,\n locale: LocalizationConfig,\n}\n\nconst defaultConfig: HightideConfig = {\n tooltip: {\n appearDelay: 0,\n isAnimated: false,\n screenPadding: 1,\n },\n theme: {\n initialTheme: 'light'\n },\n locale: {\n defaultLocale: 'de-DE',\n }\n}\n\nfunction mergeConfig(config: HightideConfig, overwrite: DeepPartial<HightideConfig>): HightideConfig {\n return {\n locale: {\n ...config.locale,\n ...overwrite?.locale\n },\n theme: {\n ...config.theme,\n ...overwrite.theme,\n },\n tooltip: {\n ...config.tooltip,\n ...overwrite.tooltip,\n }\n }\n}\n\ntype ConfigType = {\n config: HightideConfig,\n setConfig: (configOverwrite: DeepPartial<HightideConfig>) => void,\n}\n\nexport const HightideConfigContext = createContext<ConfigType | null>(null)\n\nexport type HightideConfigProviderProps = PropsWithChildren & DeepPartial<HightideConfig>\n\nexport const HightideConfigProvider = ({\n children,\n ...initialOverwrite\n}: HightideConfigProviderProps) => {\n const [config, setConfig] = useState<HightideConfig>(mergeConfig(defaultConfig, initialOverwrite))\n\n return (\n <HightideConfigContext.Provider\n value={{\n config,\n setConfig: (value) => setConfig(prevState => mergeConfig(prevState, value)),\n }}\n >\n {children}\n </HightideConfigContext.Provider>\n )\n}\n\nexport const useHightideConfig = () => {\n const context = useContext(HightideConfigContext)\n if (!context) {\n return {\n config: defaultConfig,\n setConfig: () => {\n console.error('useHightideConfig.setConfig is not available without a HightideConfigProvider. Try wrapping your app a HightideConfigProvider.')\n }\n }\n }\n return context\n}","import type { PropsWithChildren } from 'react'\nimport { createPortal } from 'react-dom'\n\nexport interface PortalProps extends PropsWithChildren {\n container?: HTMLElement,\n}\n\nexport const Portal = ({ children, container }: PortalProps) => {\n return createPortal(children, container ?? document.body)\n}","import type { HTMLAttributes, RefObject } from 'react'\nimport { forwardRef, useRef } from 'react'\nimport type { UseAnchoredPositionOptions } from '@/src/hooks/useAnchoredPosition'\nimport { useAnchoredPosition as useAnchoredPosition } from '@/src/hooks/useAnchoredPosition'\nimport { ReactRefsUtil } from '@/src/utils/reactRefs'\n\nexport type BackgroundOverlayProps = HTMLAttributes<HTMLDivElement>\n\nexport interface AnchoredFloatingContainerProps extends HTMLAttributes<HTMLDivElement> {\n anchor: RefObject<HTMLElement | null>,\n options?: UseAnchoredPositionOptions,\n active?: boolean,\n}\n\nexport const AnchoredFloatingContainer = forwardRef<HTMLDivElement, AnchoredFloatingContainerProps>(function FloatingContainer({\n children,\n anchor,\n options = {},\n active = true,\n ...props\n}, forwardRef) {\n const innerRef = useRef<HTMLDivElement>(null)\n\n const position = useAnchoredPosition({\n ...options,\n container: innerRef,\n anchor: anchor,\n active,\n })\n\n return (\n <div\n {...props}\n ref={ReactRefsUtil.assingRefsBuilder([innerRef, forwardRef])}\n\n data-positioned={position ? '' : undefined}\n\n style={{\n overflow: 'hidden',\n ...position,\n ...props.style\n }}\n >\n {children}\n </div>\n )\n})","'use client'\n\nimport type { CSSProperties, RefObject } from 'react'\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\nimport { MathUtil } from '@/src/utils/math'\nimport { useWindowResizeObserver } from './useWindowResizeObserver'\nimport { useResizeObserver } from './useResizeObserver'\nimport { useScrollObserver } from './useScrollObserver'\n\nexport type FloatingElementAlignment = 'beforeStart' | 'afterStart' | 'center' | 'beforeEnd' | 'afterEnd'\n\ntype RectangleBounds = {\n top: number,\n right: number,\n bottom: number,\n left: number,\n width: number,\n height: number,\n}\n\ntype CalculatePositionOptionsResolved = {\n verticalAlignment: FloatingElementAlignment,\n horizontalAlignment: FloatingElementAlignment,\n screenPadding: number,\n gap: number,\n avoidOverlap: boolean,\n}\n\ntype CalculatePositionOptions = Partial<CalculatePositionOptionsResolved>\n\ntype CalculatePositionProps = {\n windowRect: RectangleBounds,\n containerRect: RectangleBounds,\n anchorRect: RectangleBounds,\n options: CalculatePositionOptionsResolved,\n}\n\n\nfunction calculatePosition({\n windowRect,\n containerRect,\n anchorRect,\n options,\n}: CalculatePositionProps): CSSProperties {\n const { verticalAlignment, horizontalAlignment, gap, screenPadding,