UNPKG

wix-style-react

Version:
114 lines (96 loc) 2.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = exports.radioDriverFactory = void 0; var _constants = require("./constants"); var radioDriverFactory = function radioDriverFactory(_ref) { var element = _ref.element, eventTrigger = _ref.eventTrigger; var byHook = function byHook(hook) { return element.querySelector("[data-hook*=\"".concat(hook, "\"]")); }; var getInput = function getInput() { return byHook(_constants.dataHooks.input); }; var getIcon = function getIcon() { return byHook(_constants.dataHooks.icon); }; var getLabel = function getLabel() { return byHook(_constants.dataHooks.label); }; return { exists: function exists() { return !!element; }, /** /* Triggers a keyDown event on the radio input * @param {string} key * @return {void} */ keyDown: function keyDown(key) { return eventTrigger.keyDown(getInput(), { key: key }); }, /** /* Triggers click event on radio * @return {void} */ click: function click() { return eventTrigger.click(element); }, /** * Gets value of radio input * @return {string} */ getValue: function getValue() { return getInput().getAttribute('value'); }, /** * Gets name of radio input * @return {string} */ getName: function getName() { return getInput().getAttribute('name'); }, /** * Gets id of radio input * @return {string} */ getId: function getId() { return getInput().getAttribute('id'); }, /** * Checks if icon of radio exists * @return {boolean} */ iconExists: function iconExists() { return !!getIcon(); }, /** * Checks if label of radio exists * @return {boolean} */ labelExists: function labelExists() { return !!getLabel(); }, /** * Checks if radio is checked * @return {boolean} */ isChecked: function isChecked() { return element.getAttribute('data-checked') === 'true'; }, /** * Checks if radio is disabled * @return {boolean} */ isDisabled: function isDisabled() { return element.getAttribute('data-disabled') === 'true'; } }; }; exports.radioDriverFactory = radioDriverFactory; var _default = radioDriverFactory; exports["default"] = _default;