UNPKG

@blockstack/ui

Version:

Blockstack UI components built using React and styled-components with styled-system.

138 lines (114 loc) 3.85 kB
import { createForOfIteratorHelperLoose as _createForOfIteratorHelperLoose } from '../_virtual/_rollupPluginBabelHelpers.js'; import React__default from 'react'; var _window = undefined; try { _window = window; } catch (e) {} function getWindow(node) { var _node$ownerDocument$d, _node$ownerDocument; return (_node$ownerDocument$d = node === null || node === void 0 ? void 0 : (_node$ownerDocument = node.ownerDocument) === null || _node$ownerDocument === void 0 ? void 0 : _node$ownerDocument.defaultView) !== null && _node$ownerDocument$d !== void 0 ? _node$ownerDocument$d : _window; } function checkIsBrowser() { var _window = getWindow(); return Boolean(typeof _window !== 'undefined' && _window.document && _window.document.createElement); } var isBrowser = /*#__PURE__*/checkIsBrowser(); function isFunction(value) { return typeof value === 'function'; } function createContext(options) { if (options === void 0) { options = {}; } var _options = options, _options$strict = _options.strict, strict = _options$strict === void 0 ? true : _options$strict, _options$errorMessage = _options.errorMessage, errorMessage = _options$errorMessage === void 0 ? 'useContext must be inside a Provider with a value' : _options$errorMessage, name = _options.name; var Context = React__default.createContext(undefined); Context.displayName = name; function useContext() { var context = React__default.useContext(Context); if (!context && strict) throw new Error(errorMessage); return context; } return [Context.Provider, useContext, Context]; } function assignRef(ref, value) { if (ref == null) return; if (isFunction(ref)) { ref(value); return; } try { ref.current = value; } catch (error) { throw new Error("Cannot assign value '" + value + "' to ref '" + ref + "'"); } } function mergeRefs() { for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { refs[_key] = arguments[_key]; } return function (value) { refs.forEach(function (ref) { return assignRef(ref, value); }); }; } var __DEV__ = process.env.NODE_ENV !== 'production'; function runIfFn(valueOrFn) { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } return isFunction(valueOrFn) ? valueOrFn.apply(void 0, args) : valueOrFn; } function warn(options) { if (options.condition && __DEV__) { console.warn(options.message); } } function callAllHandlers() { for (var _len3 = arguments.length, fns = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { fns[_key3] = arguments[_key3]; } return function (event) { fns.some(function (fn) { fn && fn(event); return event && event.defaultPrevented; }); }; } function isString(value) { return Object.prototype.toString.call(value) === '[object String]'; } function omit(object, keys) { var result = {}; for (var key in object) { if (keys.includes(key)) continue; result[key] = object[key]; } return result; } function pick(object, keys) { var result = {}; for (var _iterator = _createForOfIteratorHelperLoose(keys), _step; !(_step = _iterator()).done;) { var key = _step.value; if (key in object) { result[key] = object[key]; } } return result; } var startPad = function startPad(n, z, s) { if (z === void 0) { z = 2; } if (s === void 0) { s = '0'; } return (n + '').length <= z ? ['', '-'][+(n < 0)] + (s.repeat(z) + Math.abs(n)).slice(-1 * z) : n + ''; }; export { __DEV__, assignRef, callAllHandlers, createContext, getWindow, isBrowser, isFunction, isString, mergeRefs, omit, pick, runIfFn, startPad, warn }; //# sourceMappingURL=index.esm.js.map