UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

227 lines (226 loc) 8.16 kB
/** * Web DrawerList Provider * * This is a legacy component. * For referencing while developing new features, please use a Functional component. */ import React from 'react'; import Context from '../../shared/Context'; import { DetectOutsideClickClass } from '../../shared/component-helper'; import { DrawerListContextState } from './DrawerListContext'; import type { SpacingProps } from '../../shared/types'; import type { DrawerListProps } from './DrawerList'; export type DrawerListProviderProps = Omit<DrawerListProps, 'children'> & Omit<React.HTMLProps<HTMLElement>, 'data' | 'role' | 'size' | 'value'> & SpacingProps & { hasFocusOnElement?: boolean; setData?: (data: any, cb?: any, { overwriteOriginalData, }?: { overwriteOriginalData?: boolean; }) => DrawerListProvider; setState?: (state: any, cb?: any) => void; setWrapperElement?: (wrapper_element?: string | HTMLElement) => DrawerListProvider; setHidden?: (args?: any[], onStateComplete?: any) => void; selectItemAndClose?: (itemToSelect: any, args?: { fireSelectEvent?: boolean; event: any; }) => any; selected_item?: string | number; active_item?: string | number; showFocusRing?: boolean; closestToTop?: string; closestToBottom?: string; skipPortal?: boolean; addObservers?: () => void; removeObservers?: () => void; setVisible?: (args?: Record<string, any>, onStateComplete?: any) => void; toggleVisible?: (...args: any[]) => void; selectItem?: (itemToSelect: any, args?: { fireSelectEvent?: boolean; event?: any; closeOnSelection?: boolean; }) => any; scrollToItem?: (active_item: any, opt?: { scrollTo?: boolean; element?: any; }) => void; setActiveItemAndScrollToIt?: (active_item: any, args?: { fireSelectEvent?: boolean; scrollTo?: boolean; event?: any; }) => void; _refShell?: React.RefObject<HTMLSpanElement>; _refTriangle?: React.RefObject<HTMLLIElement & HTMLSpanElement>; _refUl?: React.RefObject<HTMLUListElement>; _refRoot?: React.RefObject<HTMLSpanElement>; _rootElem?: Window | Element; attributes?: Record<string, any>; children: React.ReactNode; }; export default class DrawerListProvider extends React.PureComponent<DrawerListProviderProps, DrawerListContextState> { static contextType: React.Context<import("../../shared/Context").ContextProps>; context: React.ContextType<typeof Context>; static defaultProps: { enable_body_lock: boolean; page_offset: any; observer_element: any; min_height: number; id: any; role: string; cache_hash: any; triangle_position: string; scrollable: boolean; focusable: boolean; max_height: any; direction: string; size: string; no_animation: boolean; no_scroll_animation: boolean; prevent_selection: boolean; action_menu: boolean; is_popup: boolean; align_drawer: string; wrapper_element: any; default_value: any; value: string; portal_class: any; list_class: any; skip_portal: any; prevent_close: boolean; keep_open: boolean; prevent_focus: boolean; fixed_position: boolean; independent_width: boolean; skip_keysearch: boolean; opened: any; data: any; raw_data: any; ignore_events: any; className: any; children: any; on_show: any; on_hide: any; handle_dismiss_focus: any; on_change: any; on_pre_change: any; on_resize: any; on_select: any; on_state_update: any; options_render: any; }; static blurDelay: number; static isOpen: boolean; static getDerivedStateFromProps(props: any, state: any): DrawerListContextState; attributes: object; _refRoot: React.RefObject<HTMLSpanElement>; _refShell: React.RefObject<HTMLSpanElement>; _refUl: React.RefObject<HTMLUListElement>; _refTriangle: React.RefObject<HTMLLIElement & HTMLSpanElement>; _showTimeout: NodeJS.Timeout; _hideTimeout: NodeJS.Timeout; _scrollTimeout: NodeJS.Timeout; _directionTimeout: NodeJS.Timeout; itemSpots: { [customProperty: number]: { id: string; }; }; itemSpotsCount: number; setOnScroll: () => void; _bodyLockIsEnabled: boolean; setDirection: () => void; _rootElem: Window | Element; changedOrderFor: string; searchCache: Record<string, { i: number; }[]>; meta: { cmd: any; ctrl: any; shift: any; alt: any; }; outsideClick: DetectOutsideClickClass; constructor(props: any); componentDidMount(): void; componentDidUpdate(prevProps: any): void; componentWillUnmount(): void; refreshScrollObserver(): void; setScrollObserver(): void; removeScrollObserver(): void; enableBodyLock: () => void; disableBodyLock: () => void; setDirectionObserver(): void; /** * Deprecated * We should replace all the logic of handling left/right aligned * and setting the position, with a PopupMenu component, * which uses the logic form Tooltip. * * EDS-246 */ correctHiddenView: () => void; findItemByValue(value: any): number; scrollToItem: (active_item: any, { scrollTo, element }?: { scrollTo?: boolean; element?: any; }) => void; /** * During opening (Dropdown, Autocomplete), * and if noting is selected, * set scroll to item. * * @param {number} active_item The item to set as active * @param {object} param1 * @property {boolean} fireSelectEvent Whether the onSelect event should get emitted * @property {boolean} scrollTo Whether the list should animate the scroll to the new active item or not * @property {event} event The event object to forward to the emitted events */ setActiveItemAndScrollToIt: (active_item: any, { fireSelectEvent, scrollTo, event }?: { fireSelectEvent?: boolean; scrollTo?: boolean; event?: any; }) => void; removeDirectionObserver(): void; setWrapperElement: (wrapper_element?: string | HTMLElement) => this; getAnchorElem(activeElement: any): any; setMetaKey: (e: any) => void; onKeyUpHandler: (e: any) => void; onKeyDownHandler: (e: any) => void; /** * Gets the currently selected element inside the DrawerList. Or the list element if nothing is selected. */ getSelectedElement: () => HTMLLIElement | HTMLUListElement; getCurrentSelectedItem: () => number; /** * Gets the currently focused element inside the DrawerList. Or `null` if nothing is focused. */ getActiveElement: () => HTMLLIElement; getElementGroup: (element: HTMLLIElement) => HTMLUListElement; getCurrentActiveItem: () => number; getNextActiveItem: () => number; getPrevActiveItem: () => number; getFirstItem: () => number; getLastItem: () => number; getItemData: (element: Element) => number; setOutsideClickObserver: () => void; removeOutsideClickObserver(): void; addObservers: () => void; removeObservers: () => void; toggleVisible: (...args: any[]) => void; setVisible: (args?: {}, onStateComplete?: any) => void; setHidden: (args?: {}, onStateComplete?: any) => void; setActiveState(active: any): void; setDataHandler: (data: any, cb?: any, { overwriteOriginalData }?: { overwriteOriginalData?: boolean; }) => this; setStateHandler: (state: any, cb?: any) => this; selectItemAndClose: (itemToSelect: any, args?: { fireSelectEvent?: boolean; event?: any; closeOnSelection?: boolean; }) => any; selectItem: (itemToSelect: any, { fireSelectEvent, event, closeOnSelection, }?: { fireSelectEvent?: boolean; event?: any; closeOnSelection?: boolean; }) => any; render(): import("react/jsx-runtime").JSX.Element; }