UNPKG

@wix/design-system

Version:

@wix/design-system

34 lines 1.91 kB
import { dropdownBaseDriverFactory as publicDriverFactory } from './DropdownBase.uni.driver'; import { dropdownLayoutDriverFactory } from '../DropdownLayout/DropdownLayout.uni.driver'; export const dropdownBasePrivateDriverFactory = (base, body) => { const byDataHook = (dataHook) => body.$(`[data-hook="${dataHook}"]`); const getDataHook = async () => base.attr('data-hook'); const getTargetElement = async () => { const dataHook = await getDataHook(); return byDataHook(`${dataHook}-trigger`); }; const getContentElement = async () => { const dataHook = await getDataHook(); return byDataHook(`${dataHook}-content`); }; const dropdownLayout = dropdownLayoutDriverFactory(base, body); return { ...publicDriverFactory(base, body), /** Returns the native target element */ getTargetElement: async () => (await getTargetElement()).getNative(), /** Returns the native DropdownLayout element */ getDropdownElement: async () => (await getContentElement()).getNative(), /** Return `true` if the option is hovered by the mouse */ isOptionHovered: async (index) => dropdownLayout.isOptionHovered(index), /** Return `true` if the option is selected */ isOptionSelected: async (index) => dropdownLayout.isOptionSelected(index), /** Trigger a keyDown event on the target element */ keyDown: async (key) => (await getTargetElement()).pressKey(key), /** Perform a mouseLeave on the target element */ mouseLeaveTarget: async () => (await getTargetElement()).mouse.leave(), dropdownLayout, keyDownListItem: async (position, key) => dropdownLayout.keyDownListItem(position, key), isListItemFocused: async (position) => dropdownLayout.isListItemFocused(position), }; }; //# sourceMappingURL=DropdownBase.private.uni.driver.js.map