UNPKG

@danilandreev/material-docs

Version:

material-docs - react framework for easy creating documentation site in material design style.

62 lines (48 loc) 4.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.searchDataItemValidate = searchDataItemValidate; exports.default = void 0; var _createChainableTypeChecker = _interopRequireDefault(require("../utils/createChainableTypeChecker")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } /** * searchDataItemValidate - PropTypes validator for SearchDataItem interface. * @function * @param {object} props * @param {string} propName * @param {string} componentName * @returns Error */ function searchDataItemValidate(prop, propName, componentName) { if (!(typeof prop.redirect === "string" || _typeof(prop.redirect) === "object" || typeof prop.redirect === "function")) return Error("Incorrect field 'redirect' type on prop ".concat(propName, " in component ").concat(componentName, ", expected \"string | (() => void) | object\", got \"").concat(_typeof(prop.redirect), "\"")); if (typeof prop.label !== "string") return Error("Incorrect field 'label' type on prop ".concat(propName, " in component ").concat(componentName, ", expected \"string\", got \"").concat(_typeof(prop.label), "\"")); if (typeof prop.description !== "string") return Error("Incorrect field 'description' type on prop ".concat(propName, " in component ").concat(componentName, ", expected \"string\", got \"").concat(_typeof(prop.description), "\"")); if (!Array.isArray(prop.tags)) return Error("Incorrect field 'tags' type on prop ".concat(propName, " in component ").concat(componentName, ", expected \"string[]\", got \"").concat(_typeof(prop.tags), "\"")); var _iterator = _createForOfIteratorHelper(prop.tags), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var item = _step.value; if (typeof item !== "string") return Error("Incorrect field 'tags' type on prop ".concat(propName, " in component ").concat(componentName, ", expected \"string[]\", got \"").concat(_typeof(item), "[]\"")); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } function SearchDataItemValidator(props, propName, componentName) { var prop = props[propName]; if (!prop) return null; return searchDataItemValidate(prop, propName, componentName); } /** * SearchDataItemValidator - PropTypes validator for SearchDataItem interface. */ var _default = (0, _createChainableTypeChecker.default)(SearchDataItemValidator); exports.default = _default;