wix-style-react
Version:
139 lines (118 loc) • 4.62 kB
JavaScript
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _regeneratorRuntime from "@babel/runtime/regenerator";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
import { baseUniDriverFactory } from '../../test/utils/unidriver';
export var textUniDriverFactory = function textUniDriverFactory(base) {
return _objectSpread(_objectSpread({}, baseUniDriverFactory(base)), {}, {
/**
* Get the root element's tagName
* @return {Promise<string>} html tagName
*/
getTagName: function () {
var _getTagName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return base._prop('tagName');
case 2:
return _context.abrupt("return", _context.sent.toLowerCase());
case 3:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function getTagName() {
return _getTagName.apply(this, arguments);
}
return getTagName;
}(),
/**
* Get text content (innerHTML)
* @return {Promise<string>} innerHTML content
*/
getText: function getText() {
return base._prop('innerHTML');
},
/**
* Get size
* @return {Promise<'tiny' | 'small' | 'medium'>}
*/
getSize: function getSize() {
return base.attr('data-size');
},
/**
* Get skin
* @return {Promise<'standard'| 'error'| 'success'| 'premium'| 'disabled'>}
*/
getSkin: function getSkin() {
return base.attr('data-skin');
},
/**
* Get weight
* @return {Promise<'thin' | 'normal' | 'bold'>}
*/
getWeight: function getWeight() {
return base.attr('data-weight');
},
/**
* Is light
* @return {Promise<boolean>}
*/
isLight: function () {
var _isLight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return base.attr('data-light');
case 2:
_context2.t0 = _context2.sent;
return _context2.abrupt("return", _context2.t0 === 'true');
case 4:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
function isLight() {
return _isLight.apply(this, arguments);
}
return isLight;
}(),
/**
* Is secondary
* @return {Promise<boolean>}
*/
isSecondary: function () {
var _isSecondary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return base.attr('data-secondary');
case 2:
_context3.t0 = _context3.sent;
return _context3.abrupt("return", _context3.t0 === 'true');
case 4:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
function isSecondary() {
return _isSecondary.apply(this, arguments);
}
return isSecondary;
}()
});
};