UNPKG

wix-style-react

Version:
101 lines (79 loc) 2.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _utils = require("../../test/utils"); var emptyStateDriverFactory = function emptyStateDriverFactory(_ref) { var _element = _ref.element; var byDataHook = function byDataHook(dataHook) { return _element.querySelector("[data-hook=\"".concat(dataHook, "\"]")); }; var getTitleContainer = function getTitleContainer() { return byDataHook('empty-state-title-container'); }; var getSubtitleContainer = function getSubtitleContainer() { return byDataHook('empty-state-subtitle-container'); }; var getImageContainer = function getImageContainer() { return byDataHook('empty-state-image-container'); }; var getChildrenContainer = function getChildrenContainer() { return byDataHook('empty-state-children-container'); }; var getTitle = function getTitle() { return getTitleContainer().firstChild; }; var getSubtitle = function getSubtitle() { return getSubtitleContainer().firstChild; }; var getImageElement = function getImageElement() { return getImageContainer().querySelector('[data-hook="image-element"]'); }; var getImageNode = function getImageNode() { return getImageContainer().querySelector('[data-hook="image-node"]'); }; return { /** Returns `true` whether the element exists or not */ exists: function exists() { return !!_element; }, /** Returns the element */ element: function element() { return _element; }, /** Returns the text of the title */ getTitleText: function getTitleText() { return getTitle().textContent; }, /** Returns the text of the subtitle */ getSubtitleText: function getSubtitleText() { return getSubtitle().textContent; }, /** Returns true if the component was configured with given theme */ hasTheme: function hasTheme(themeName) { return _element.getAttribute('data-theme') === themeName; }, /** Returns the URL of the image element (if persist) */ getImageUrl: function getImageUrl() { return getImageElement().src || ''; }, getImageContainerClassName: function getImageContainerClassName() { return getImageContainer().className; }, /** Returns `true` if a node passed via the `image` prop exists */ imageNodeExists: function imageNodeExists() { return !!getImageNode(); }, /** Returns `true` if children content exists */ childrenContentExists: function childrenContentExists() { return !!getChildrenContainer(); }, /** Returns true if the component was configured with given align */ hasAlign: function hasAlign(align) { return _element.getAttribute('data-align') === align; } }; }; var _default = emptyStateDriverFactory; exports["default"] = _default;