UNPKG

hotelier-lib-test

Version:

A skeleton to create your own React component library using Rollup, TypeScript, Sass and Storybook

1,564 lines (1,417 loc) 646 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var React = require('react'); var ReactDOM = require('react-dom'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n["default"] = e; return Object.freeze(n); } var React__default = /*#__PURE__*/_interopDefaultLegacy(React); var React__namespace = /*#__PURE__*/_interopNamespace(React); var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM); var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM); /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest$7(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; function createCommonjsModule(fn) { var module = { exports: {} }; return fn(module, module.exports), module.exports; } /*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ var classnames = createCommonjsModule(function (module) { /* global define */ (function () { var hasOwn = {}.hasOwnProperty; function classNames() { var classes = []; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; if (!arg) continue; var argType = typeof arg; if (argType === 'string' || argType === 'number') { classes.push(arg); } else if (Array.isArray(arg)) { if (arg.length) { var inner = classNames.apply(null, arg); if (inner) { classes.push(inner); } } } else if (argType === 'object') { if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) { classes.push(arg.toString()); continue; } for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes.push(key); } } } } return classes.join(' '); } if (module.exports) { classNames.default = classNames; module.exports = classNames; } else { window.classNames = classNames; } }()); }); function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /** * @license React * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference"); function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}var ContextConsumer=h;var ContextProvider=g;var Element$1=b;var ForwardRef=l;var Fragment=d;var Lazy=q;var Memo=p;var Portal=c;var Profiler=f;var StrictMode=e;var Suspense=m; var SuspenseList=n;var isAsyncMode=function(){return !1};var isConcurrentMode=function(){return !1};var isContextConsumer=function(a){return v(a)===h};var isContextProvider=function(a){return v(a)===g};var isElement$1=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};var isForwardRef=function(a){return v(a)===l};var isFragment$1=function(a){return v(a)===d};var isLazy=function(a){return v(a)===q};var isMemo=function(a){return v(a)===p}; var isPortal=function(a){return v(a)===c};var isProfiler=function(a){return v(a)===f};var isStrictMode=function(a){return v(a)===e};var isSuspense=function(a){return v(a)===m};var isSuspenseList=function(a){return v(a)===n}; var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?!0:!1};var typeOf=v; var reactIs_production_min = { ContextConsumer: ContextConsumer, ContextProvider: ContextProvider, Element: Element$1, ForwardRef: ForwardRef, Fragment: Fragment, Lazy: Lazy, Memo: Memo, Portal: Portal, Profiler: Profiler, StrictMode: StrictMode, Suspense: Suspense, SuspenseList: SuspenseList, isAsyncMode: isAsyncMode, isConcurrentMode: isConcurrentMode, isContextConsumer: isContextConsumer, isContextProvider: isContextProvider, isElement: isElement$1, isForwardRef: isForwardRef, isFragment: isFragment$1, isLazy: isLazy, isMemo: isMemo, isPortal: isPortal, isProfiler: isProfiler, isStrictMode: isStrictMode, isSuspense: isSuspense, isSuspenseList: isSuspenseList, isValidElementType: isValidElementType, typeOf: typeOf }; /** * @license React * react-is.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var reactIs_development = createCommonjsModule(function (module, exports) { if (process.env.NODE_ENV !== "production") { (function() { // ATTENTION // When adding new symbols to this file, // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' // The Symbol used to tag the ReactElement-like types. var REACT_ELEMENT_TYPE = Symbol.for('react.element'); var REACT_PORTAL_TYPE = Symbol.for('react.portal'); var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); var REACT_PROFILER_TYPE = Symbol.for('react.profiler'); var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); var REACT_CONTEXT_TYPE = Symbol.for('react.context'); var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context'); var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); var REACT_MEMO_TYPE = Symbol.for('react.memo'); var REACT_LAZY_TYPE = Symbol.for('react.lazy'); var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); // ----------------------------------------------------------------------------- var enableScopeAPI = false; // Experimental Create Event Handle API. var enableCacheElement = false; var enableTransitionTracing = false; // No known bugs, but needs performance testing var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber // stuff. Intended to enable React core members to more easily debug scheduling // issues in DEV builds. var enableDebugTracing = false; // Track which Fiber(s) schedule render work. var REACT_MODULE_REFERENCE; { REACT_MODULE_REFERENCE = Symbol.for('react.module.reference'); } function isValidElementType(type) { if (typeof type === 'string' || typeof type === 'function') { return true; } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) { return true; } if (typeof type === 'object' && type !== null) { if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object // types supported by any Flight configuration anywhere since // we don't know which Flight build this will end up being used // with. type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) { return true; } } return false; } function typeOf(object) { if (typeof object === 'object' && object !== null) { var $$typeof = object.$$typeof; switch ($$typeof) { case REACT_ELEMENT_TYPE: var type = object.type; switch (type) { case REACT_FRAGMENT_TYPE: case REACT_PROFILER_TYPE: case REACT_STRICT_MODE_TYPE: case REACT_SUSPENSE_TYPE: case REACT_SUSPENSE_LIST_TYPE: return type; default: var $$typeofType = type && type.$$typeof; switch ($$typeofType) { case REACT_SERVER_CONTEXT_TYPE: case REACT_CONTEXT_TYPE: case REACT_FORWARD_REF_TYPE: case REACT_LAZY_TYPE: case REACT_MEMO_TYPE: case REACT_PROVIDER_TYPE: return $$typeofType; default: return $$typeof; } } case REACT_PORTAL_TYPE: return $$typeof; } } return undefined; } var ContextConsumer = REACT_CONTEXT_TYPE; var ContextProvider = REACT_PROVIDER_TYPE; var Element = REACT_ELEMENT_TYPE; var ForwardRef = REACT_FORWARD_REF_TYPE; var Fragment = REACT_FRAGMENT_TYPE; var Lazy = REACT_LAZY_TYPE; var Memo = REACT_MEMO_TYPE; var Portal = REACT_PORTAL_TYPE; var Profiler = REACT_PROFILER_TYPE; var StrictMode = REACT_STRICT_MODE_TYPE; var Suspense = REACT_SUSPENSE_TYPE; var SuspenseList = REACT_SUSPENSE_LIST_TYPE; var hasWarnedAboutDeprecatedIsAsyncMode = false; var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated function isAsyncMode(object) { { if (!hasWarnedAboutDeprecatedIsAsyncMode) { hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.'); } } return false; } function isConcurrentMode(object) { { if (!hasWarnedAboutDeprecatedIsConcurrentMode) { hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.'); } } return false; } function isContextConsumer(object) { return typeOf(object) === REACT_CONTEXT_TYPE; } function isContextProvider(object) { return typeOf(object) === REACT_PROVIDER_TYPE; } function isElement(object) { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; } function isForwardRef(object) { return typeOf(object) === REACT_FORWARD_REF_TYPE; } function isFragment(object) { return typeOf(object) === REACT_FRAGMENT_TYPE; } function isLazy(object) { return typeOf(object) === REACT_LAZY_TYPE; } function isMemo(object) { return typeOf(object) === REACT_MEMO_TYPE; } function isPortal(object) { return typeOf(object) === REACT_PORTAL_TYPE; } function isProfiler(object) { return typeOf(object) === REACT_PROFILER_TYPE; } function isStrictMode(object) { return typeOf(object) === REACT_STRICT_MODE_TYPE; } function isSuspense(object) { return typeOf(object) === REACT_SUSPENSE_TYPE; } function isSuspenseList(object) { return typeOf(object) === REACT_SUSPENSE_LIST_TYPE; } exports.ContextConsumer = ContextConsumer; exports.ContextProvider = ContextProvider; exports.Element = Element; exports.ForwardRef = ForwardRef; exports.Fragment = Fragment; exports.Lazy = Lazy; exports.Memo = Memo; exports.Portal = Portal; exports.Profiler = Profiler; exports.StrictMode = StrictMode; exports.Suspense = Suspense; exports.SuspenseList = SuspenseList; exports.isAsyncMode = isAsyncMode; exports.isConcurrentMode = isConcurrentMode; exports.isContextConsumer = isContextConsumer; exports.isContextProvider = isContextProvider; exports.isElement = isElement; exports.isForwardRef = isForwardRef; exports.isFragment = isFragment; exports.isLazy = isLazy; exports.isMemo = isMemo; exports.isPortal = isPortal; exports.isProfiler = isProfiler; exports.isStrictMode = isStrictMode; exports.isSuspense = isSuspense; exports.isSuspenseList = isSuspenseList; exports.isValidElementType = isValidElementType; exports.typeOf = typeOf; })(); } }); var reactIs = createCommonjsModule(function (module) { if (process.env.NODE_ENV === 'production') { module.exports = reactIs_production_min; } else { module.exports = reactIs_development; } }); function toArray(children) { var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var ret = []; React__default["default"].Children.forEach(children, function (child) { if ((child === undefined || child === null) && !option.keepEmpty) { return; } if (Array.isArray(child)) { ret = ret.concat(toArray(child)); } else if (reactIs.isFragment(child) && child.props) { ret = ret.concat(toArray(child.props.children, option)); } else { ret.push(child); } }); return ret; } /* eslint-disable no-console */ var warned = {}; var preWarningFns = []; /** * Pre warning enable you to parse content before console.error. * Modify to null will prevent warning. */ var preMessage = function preMessage(fn) { preWarningFns.push(fn); }; function warning$3(valid, message) { // Support uglify if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) { var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) { return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'warning'); }, message); if (finalMessage) { console.error("Warning: ".concat(finalMessage)); } } } function note(valid, message) { // Support uglify if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) { var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) { return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'note'); }, message); if (finalMessage) { console.warn("Note: ".concat(finalMessage)); } } } function resetWarned$1() { warned = {}; } function call(method, valid, message) { if (!valid && !warned[message]) { method(false, message); warned[message] = true; } } function warningOnce(valid, message) { call(warning$3, valid, message); } function noteOnce(valid, message) { call(note, valid, message); } warningOnce.preMessage = preMessage; warningOnce.resetWarned = resetWarned$1; warningOnce.noteOnce = noteOnce; /* eslint-enable */ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function isDOM(node) { // https://developer.mozilla.org/en-US/docs/Web/API/Element // Since XULElement is also subclass of Element, we only need HTMLElement and SVGElement return node instanceof HTMLElement || node instanceof SVGElement; } /** * Return if a node is a DOM node. Else will return by `findDOMNode` */ function findDOMNode(node) { if (isDOM(node)) { return node; } if (node instanceof React__default["default"].Component) { return ReactDOM__default["default"].findDOMNode(node); } return null; } function useMemo(getValue, condition, shouldUpdate) { var cacheRef = React__namespace.useRef({}); if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) { cacheRef.current.value = getValue(); cacheRef.current.condition = condition; } return cacheRef.current.value; } function fillRef(ref, node) { if (typeof ref === 'function') { ref(node); } else if (_typeof(ref) === 'object' && ref && 'current' in ref) { ref.current = node; } } /** * Merge refs into one ref function to support ref passing. */ function composeRef() { for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { refs[_key] = arguments[_key]; } var refList = refs.filter(function (ref) { return ref; }); if (refList.length <= 1) { return refList[0]; } return function (node) { refs.forEach(function (ref) { fillRef(ref, node); }); }; } function supportRef(nodeOrComponent) { var _type$prototype, _nodeOrComponent$prot; var type = reactIs.isMemo(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type; // Function component node if (typeof type === 'function' && !((_type$prototype = type.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render)) { return false; } // Class component if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render)) { return false; } return true; } /* eslint-enable */ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function omit(obj, fields) { var clone = _objectSpread2({}, obj); if (Array.isArray(fields)) { fields.forEach(function (key) { delete clone[key]; }); } return clone; } 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 _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } 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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } var raf = function raf(callback) { return +setTimeout(callback, 16); }; var caf = function caf(num) { return clearTimeout(num); }; if (typeof window !== 'undefined' && 'requestAnimationFrame' in window) { raf = function raf(callback) { return window.requestAnimationFrame(callback); }; caf = function caf(handle) { return window.cancelAnimationFrame(handle); }; } var rafUUID = 0; var rafIds = new Map(); function cleanup(id) { rafIds.delete(id); } var wrapperRaf = function wrapperRaf(callback) { var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; rafUUID += 1; var id = rafUUID; function callRef(leftTimes) { if (leftTimes === 0) { // Clean up cleanup(id); // Trigger callback(); } else { // Next raf var realId = raf(function () { callRef(leftTimes - 1); }); // Bind real raf id rafIds.set(id, realId); } } callRef(times); return id; }; wrapperRaf.cancel = function (id) { var realId = rafIds.get(id); cleanup(id); return caf(realId); }; if (process.env.NODE_ENV !== 'production') { wrapperRaf.ids = function () { return rafIds; }; } /* eslint-disable */ // Inspired by https://github.com/garycourt/murmurhash-js // Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86 function murmur2(str) { // 'm' and 'r' are mixing constants generated offline. // They're not really 'magic', they just happen to work well. // const m = 0x5bd1e995; // const r = 24; // Initialize the hash var h = 0; // Mix 4 bytes at a time into the hash var k, i = 0, len = str.length; for (; len >= 4; ++i, len -= 4) { k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24; k = /* Math.imul(k, m): */ (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16); k ^= /* k >>> r: */ k >>> 24; h = /* Math.imul(k, m): */ (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^ /* Math.imul(h, m): */ (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16); } // Handle the last few bytes of the input array switch (len) { case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16; case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8; case 1: h ^= str.charCodeAt(i) & 0xff; h = /* Math.imul(h, m): */ (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16); } // Do a few final mixes of the hash to ensure the last few // bytes are well-incorporated. h ^= h >>> 13; h = /* Math.imul(h, m): */ (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16); return ((h ^ h >>> 15) >>> 0).toString(36); } function _objectWithoutPropertiesLoose$1(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$1(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } /** * Deeply compares two object literals. * @param obj1 object 1 * @param obj2 object 2 * @param shallow shallow compare * @returns */ function isEqual(obj1, obj2) { var shallow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; // https://github.com/mapbox/mapbox-gl-js/pull/5979/files#diff-fde7145050c47cc3a306856efd5f9c3016e86e859de9afbd02c879be5067e58f var refSet = new Set(); function deepEqual(a, b) { var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; var circular = refSet.has(a); warningOnce(!circular, 'Warning: There may be circular references'); if (circular) { return false; } if (a === b) { return true; } if (shallow && level > 1) { return false; } refSet.add(a); var newLevel = level + 1; if (Array.isArray(a)) { if (!Array.isArray(b) || a.length !== b.length) { return false; } for (var i = 0; i < a.length; i++) { if (!deepEqual(a[i], b[i], newLevel)) { return false; } } return true; } if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') { var keys = Object.keys(a); if (keys.length !== Object.keys(b).length) { return false; } return keys.every(function (key) { return deepEqual(a[key], b[key], newLevel); }); } // other return false; } return deepEqual(obj1, obj2); } // [times, realValue] var SPLIT = '%'; var Entity = /*#__PURE__*/function () { function Entity(instanceId) { _classCallCheck(this, Entity); _defineProperty(this, "instanceId", void 0); /** @private Internal cache map. Do not access this directly */ _defineProperty(this, "cache", new Map()); this.instanceId = instanceId; } _createClass(Entity, [{ key: "get", value: function get(keys) { return this.cache.get(keys.join(SPLIT)) || null; } }, { key: "update", value: function update(keys, valueFn) { var path = keys.join(SPLIT); var prevValue = this.cache.get(path); var nextValue = valueFn(prevValue); if (nextValue === null) { this.cache.delete(path); } else { this.cache.set(path, nextValue); } } }]); return Entity; }(); var ATTR_TOKEN = 'data-token-hash'; var ATTR_MARK = 'data-css-hash'; var ATTR_CACHE_PATH = 'data-cache-path'; // Mark css-in-js instance in style element var CSS_IN_JS_INSTANCE = '__cssinjs_instance__'; function createCache() { var cssinjsInstanceId = Math.random().toString(12).slice(2); // Tricky SSR: Move all inline style to the head. // PS: We do not recommend tricky mode. if (typeof document !== 'undefined' && document.head && document.body) { var styles = document.body.querySelectorAll("style[".concat(ATTR_MARK, "]")) || []; var firstChild = document.head.firstChild; Array.from(styles).forEach(function (style) { style[CSS_IN_JS_INSTANCE] = style[CSS_IN_JS_INSTANCE] || cssinjsInstanceId; // Not force move if no head if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) { document.head.insertBefore(style, firstChild); } }); // Deduplicate of moved styles var styleHash = {}; Array.from(document.querySelectorAll("style[".concat(ATTR_MARK, "]"))).forEach(function (style) { var hash = style.getAttribute(ATTR_MARK); if (styleHash[hash]) { if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) { var _style$parentNode; (_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 ? void 0 : _style$parentNode.removeChild(style); } } else { styleHash[hash] = true; } }); } return new Entity(cssinjsInstanceId); } var StyleContext = /*#__PURE__*/React__namespace.createContext({ hashPriority: 'low', cache: createCache(), defaultCache: true }); var StyleContext$1 = StyleContext; function canUseDom() { return !!(typeof window !== 'undefined' && window.document && window.document.createElement); } function contains(root, n) { if (!root) { return false; } // Use native if support if (root.contains) { return root.contains(n); } // `document.contains` not support with IE11 var node = n; while (node) { if (node === root) { return true; } node = node.parentNode; } return false; } var APPEND_ORDER = 'data-rc-order'; var APPEND_PRIORITY = 'data-rc-priority'; var MARK_KEY = "rc-util-key"; var containerCache = new Map(); function getMark() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, mark = _ref.mark; if (mark) { return mark.startsWith('data-') ? mark : "data-".concat(mark); } return MARK_KEY; } function getContainer(option) { if (option.attachTo) { return option.attachTo; } var head = document.querySelector('head'); return head || document.body; } function getOrder(prepend) { if (prepend === 'queue') { return 'prependQueue'; } return prepend ? 'prepend' : 'append'; } /** * Find style which inject by rc-util */ function findStyles(container) { return Array.from((containerCache.get(container) || container).children).filter(function (node) { return node.tagName === 'STYLE'; }); } function injectCSS(css) { var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (!canUseDom()) { return null; } var csp = option.csp, prepend = option.prepend, _option$priority = option.priority, priority = _option$priority === void 0 ? 0 : _option$priority; var mergedOrder = getOrder(prepend); var isPrependQueue = mergedOrder === 'prependQueue'; var styleNode = document.createElement('style'); styleNode.setAttribute(APPEND_ORDER, mergedOrder); if (isPrependQueue && priority) { styleNode.setAttribute(APPEND_PRIORITY, "".concat(priority)); } if (csp !== null && csp !== void 0 && csp.nonce) { styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce; } styleNode.innerHTML = css; var container = getContainer(option); var firstChild = container.firstChild; if (prepend) { // If is queue `prepend`, it will prepend first style and then append rest style if (isPrependQueue) { var existStyle = findStyles(container).filter(function (node) { // Ignore style which not injected by rc-util with prepend if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) { return false; } // Ignore style which priority less then new style var nodePriority = Number(node.getAttribute(APPEND_PRIORITY) || 0); return priority >= nodePriority; }); if (existStyle.length) { container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling); return styleNode; } } // Use `insertBefore` as `prepend` container.insertBefore(styleNode, firstChild); } else { container.appendChild(styleNode); } return styleNode; } function findExistNode(key) { var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var container = getContainer(option); return findStyles(container).find(function (node) { return node.getAttribute(getMark(option)) === key; }); } function removeCSS(key) { var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var existNode = findExistNode(key, option); if (existNode) { var container = getContainer(option); container.removeChild(existNode); } } /** * qiankun will inject `appendChild` to insert into other */ function syncRealContainer(container, option) { var cachedRealContainer = containerCache.get(container); // Find real container when not cached or cached container removed if (!cachedRealContainer || !contains(document, cachedRealContainer)) { var placeholderStyle = injectCSS('', option); var parentNode = placeholderStyle.parentNode; containerCache.set(container, parentNode); container.removeChild(placeholderStyle); } } function updateCSS(css, key) { var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var container = getContainer(option); // Sync real parent syncRealContainer(container, option); var existNode = findExistNode(key, option); if (existNode) { var _option$csp, _option$csp2; if ((_option$csp = option.csp) !== null && _option$csp !== void 0 && _option$csp.nonce && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) { var _option$csp3; existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce; } if (existNode.innerHTML !== css) { existNode.innerHTML = css; } return existNode; } var newNode = injectCSS(css, option); newNode.setAttribute(getMark(option), key); return newNode; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } // ================================== Cache ================================== function sameDerivativeOption(left, right) { if (left.length !== right.length) { return false; } for (var i = 0; i < left.length; i++) { if (left[i] !== right[i]) { return false; } } return true; } var ThemeCache = /*#__PURE__*/function () { function ThemeCache() { _classCallCheck(this, ThemeCache); _defineProperty(this, "cache", void 0); _defineProperty(this, "keys", void 0); _defineProperty(this, "cacheCallTimes", void 0); this.cache = new Map(); this.keys = []; this.cacheCallTimes = 0; } _createClass(ThemeCache, [{ key: "size", value: function size() { return this.keys.length; } }, { key: "internalGet", value: function internalGet(derivativeOption) { var _cache2, _cache3; var updateCallTimes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var cache = { map: this.cache }; derivativeOption.forEach(function (derivative) { if (!cache) { cache = undefined; } else { var _cache, _cache$map; cache = (_cache = cache) === null || _cache === void 0 ? void 0 : (_cache$map = _cache.map) === null || _cache$map === void 0 ? void 0 : _cache$map.get(derivative); } }); if ((_cache2 = cache) !== null && _cache2 !== void 0 && _cache2.value && updateCallTimes) { cache.value[1] = this.cacheCallTimes++; } return (_cache3 = cache) === null || _cache3 === void 0 ? void 0 : _cache3.value; } }, { key: "get", value: function get(derivativeOption) { var _this$internalGet; return (_this$internalGet = this.internalGet(derivativeOption, true)) === null || _this$internalGet === void 0 ? void 0 : _this$internalGet[0]; } }, { key: "has", value: function has(derivativeOption) { return !!this.internalGet(derivativeOption); } }, { key: "set", value: function set(derivativeOption, value) { var _this = this; // New cache if (!this.has(derivativeOption)) { if (this.size() + 1 > ThemeCache.MAX_CACHE_SIZE + ThemeCache.MAX_CACHE_OFFSET) { var _this$keys$reduce = this.keys.reduce(function (result, key) { var _result = _slicedToArray(result, 2), callTimes = _result[1]; if (_this.internalGet(key)[1] < callTimes) { return [key, _this.internalGet(key)[1]]; } return result; }, [this.keys[0], this.cacheCallTimes]), _this$keys$reduce2 = _slicedToArray(_this$keys$reduce, 1), targetKey = _this$keys$reduce2[0]; this.delete(targetKey); } this.keys.push(derivativeOption); } var cache = this.cache; derivativeOption.forEach(function (derivative, index) { if (index === derivativeOption.length - 1) { cache.set(derivative, { value: [value, _this.cacheCallTimes++] }); } else { var cacheValue = cache.get(derivative); if (!cacheValue) { cache.set(derivative, { map: new Map() }); } else if (!cacheValue.map) { cacheValue.map = new Map(); } cache = cache.get(derivative).map; } }); } }, { key: "deleteByPath", value: function deleteByPath(currentCache, derivatives) { var cache = currentCache.get(derivatives[0]); if (derivatives.length === 1) { var _cache$value; if (!cache.map) { currentCache.delete(derivatives[0]); } else { currentCache.set(derivatives[0], { map: cache.map }); } return (_cache$value = cache.value) === null || _cache$value === void 0 ? void 0 : _cache$value[0]; } var result = this.deleteByPath(cache.map, derivatives.slice(1)); if ((!cache.map || cache.map.size === 0) && !cache.value) { currentCache.delete(derivatives[0]); } return result; } }, { key: "delete", value: function _delete(derivativeOption) { // If cache exists if (this.has(derivativeOption)) { this.keys = this.keys.filter(function (item) { return !sameDerivativeOption(item, derivativeOption); }); return this.deleteByPath(this.cache, derivativeOption); } return undefined; } }]); return ThemeCache; }(); _defineProperty(ThemeCache, "MAX_CACHE_SIZE", 20); _defineProperty(ThemeCache, "MAX_CACHE_OFFSET", 5); var uuid = 0; /** * Theme with algorithms to derive tokens from design tokens. * Use `createTheme` first which will help to manage the theme instance cache. */ var Theme = /*#__PURE__*/function () { function Theme(derivatives) { _classCallCheck(this, Theme); _defineProperty(this, "derivatives", void 0); _defineProperty(this, "id", void 0); this.derivatives = Array.isArray(derivatives) ? derivatives : [derivatives]; this.id = uuid; if (derivatives.length === 0) { warning$3(derivatives.length > 0, '[Ant Design CSS-in-JS] Theme should have at least one derivative function.'); } uuid += 1; } _createClass(Theme, [{ key: "getDerivativeToken", value: function getDerivativeToken(token) { return this.derivatives.reduce(function (result, derivative) { return derivative(token, result); }, undefined); } }]); return Theme; }(); var cacheThemes = new ThemeCache(); /** * Same as new Theme, but will always return same one if `derivative` not changed. */ function createTheme(derivatives) { var derivativeArr = Array.isArray(derivatives) ? derivatives : [derivatives]; // Create new theme if not exist if (!cacheThemes.has(derivativeArr)) { cacheThemes.set(derivativeArr, new Theme(derivativeArr)); } // Get theme from cache and return return cacheThemes.get(derivativeArr); } // Create a cache for memo concat var resultCache = new WeakMap(); var RESULT_VALUE = {}; function memoResult(callback, deps) { var current = resultCache; for (var i = 0; i < deps.length; i += 1) { var dep = deps[i]; if (!current.has(dep)) { current.set(dep, new WeakMap()); } current = current.get(dep); } if (!current.has(RESULT_VALUE)) { current.set(RESULT_VALUE, callback()); } return current.get(RESULT_VALUE); } // Create a cache here to avoid always loop generate var flattenTokenCache = new WeakMap(); /** * Flatten token to string, this will auto cache the result when token not change */ function flattenToken(token) { var str = flattenTokenCache.get(token) || ''; if (!str) { Object.keys(token).forEach(function (key) { var value = token[key]; str += key; if (value instanceof Theme) { str += value.id; } else if (value && _typeof(value) === 'object') { str += flattenToken(value); } else { str += value; } }); // Put in cache flattenTokenCache.set(token, str); } return str; } /** * Convert derivative token to key string */ function token2key(token, salt) { return murmur2("".concat(salt, "_").concat(flattenToken(token))); } var randomSelectorKey = "random-".concat(Date.now(), "-").concat(Math.random()).replace(/\./g, ''); // Magic `content` for detect selector support var checkContent = '_bAmBoO_'; function supportSelector(styleStr, handleElement, supportCheck) { if (canUseDom()) { var _getComputedStyle$con, _ele$parentNode; updateCSS(styleStr, randomSelectorKey); var _ele = document.createElement('div'); _ele.style.position = 'fixed'; _ele.style.left = '0'; _ele.style.top = '0'; handleElement === null || handleElement === void 0 ? void 0 : handleElement(_ele); document.body.appendChild(_ele); if (process.env.NODE_ENV !== 'production') { _ele.innerHTML = 'Test'; _ele.style.zIndex = '9999999'; } var support = supportCheck ? supportCheck(_ele) : (_getComputedStyle$con = getComputedStyle(_ele).content) === null || _getComputedStyle$con === void 0 ? void 0 : _getComputedStyle$con.includes(checkContent); (_ele$parentNode = _ele.parentNode) === null || _ele$parentNode === void 0 ? void 0 : _ele$parentNode.removeChild(_ele); removeCSS(randomSelectorKey); return support; } return false; } var canLayer = undefined; function supportLayer() { if (canLayer === undefined) { canLayer = supportSelector("@layer ".concat(randomSelectorKey, " { .").concat(randomSelectorKey, " { content: \"").concat(checkContent, "\"!important; } }"), function (ele) { ele.className = randomSelectorKey; }); } return canLayer; } /** * Wrap `React.useLayoutEffect` which will not throw warning message in test env */ var useInternalLayoutEffect = process.env.NODE_ENV !== 'test' && canUseDom() ? React__namespace.useLayoutEffect : React__namespace.useEffect; var useLayoutEffect = function useLayoutEffect(callback, deps) { var firstMountRef = React__namespace.useRef(true); useInternalLayoutEffect(function () { return callback(firstMountRef.current); }, deps); // We tell react that first mount has passed useInternalLayoutEffect(function () { firstMountRef.current = false; return function () { firstMountRef.current = true; }; }, []); }; // We need fully clone React function here // to avoid webpack warning React 17 do not export `useId` var fullClone$2 = _objectSpread2({}, React__namespace); var useInsertionEffect$1 = fullClone$2.useInsertionEffect; /** * Polyfill `useInsertionEffect` for React < 18 * @param renderEffect will be executed in `useMemo`, and do not have callback * @param effect will be executed in `useLayoutEffect` * @param deps */ var useInsertionEffectPolyfill = function useInsertionEffectPolyfill(renderEffect, effect, deps) { React__namespace.useMemo(renderEffect, deps); useLayoutEffect(function () { return effect(true); }, deps); }; /** * Compatible `useInsertionEffect` * will use `useInsertionEffect` if React version >= 18, * otherwise use `useInsertionEffectPolyfill`.