wix-style-react
Version:
wix-style-react
41 lines (40 loc) • 2.02 kB
JavaScript
;
exports.__esModule = true;
exports.default = void 0;
var emptyStateDriverFactory = _ref => {
var {
element: _element
} = _ref;
var byDataHook = dataHook => _element.querySelector("[data-hook=\"".concat(dataHook, "\"]"));
var getTitleContainer = () => byDataHook('empty-state-title-container');
var getSubtitleContainer = () => byDataHook('empty-state-subtitle-container');
var getImageContainer = () => byDataHook('empty-state-image-container');
var getChildrenContainer = () => byDataHook('empty-state-children-container');
var getTitle = () => getTitleContainer().firstChild;
var getSubtitle = () => getSubtitleContainer().firstChild;
var getImageElement = () => getImageContainer().querySelector('[data-hook="image-element"]');
var getImageNode = () => getImageContainer().querySelector('[data-hook="image-node"]');
return {
/** Returns `true` whether the element exists or not */
exists: () => !!_element,
/** Returns the element */
element: () => _element,
/** Returns the text of the title */
getTitleText: () => getTitle().textContent,
/** Returns the text of the subtitle */
getSubtitleText: () => getSubtitle().textContent,
/** Returns true if the component was configured with given theme */
hasTheme: themeName => _element.getAttribute('data-theme') === themeName,
/** Returns the URL of the image element (if persist) */
getImageUrl: () => getImageElement().src || '',
getImageContainerClassName: () => getImageContainer().className,
/** Returns `true` if a node passed via the `image` prop exists */
imageNodeExists: () => !!getImageNode(),
/** Returns `true` if children content exists */
childrenContentExists: () => !!getChildrenContainer(),
/** Returns true if the component was configured with given align */
hasAlign: align => _element.getAttribute('data-align') === align
};
};
var _default = exports.default = emptyStateDriverFactory;
//# sourceMappingURL=EmptyState.driver.js.map