UNPKG

funda-ui

Version:

React components using pure Bootstrap 5+ which does not contain any external style and script libraries.

217 lines (203 loc) 9.13 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react")); else if(typeof define === 'function' && define.amd) define(["react"], factory); else if(typeof exports === 'object') exports["RPB"] = factory(require("react")); else root["RPB"] = factory(root["React"]); })(this, (__WEBPACK_EXTERNAL_MODULE__787__) => { return /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ 318: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "debounce": () => (/* binding */ debounce), /* harmony export */ "throttle": () => (/* binding */ throttle) /* harmony export */ }); /* * Debounce * * @param {Function} fn - A function to be executed within the time limit. * @param {Number} limit - Waiting time. * @return {*} - Returns a new function. */ function debounce(fn) { var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300; var timer; return function () { clearTimeout(timer); timer = setTimeout(function () { fn.apply(this, arguments); }, limit); }; } /* * Throttle * * @param {Function} fn - A function to be executed within the time limit. * @param {Number} limit - Waiting time. * @return {*} - Returns a new function. */ function throttle(fn) { var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300; var waiting = false; return function () { if (!waiting) { fn.apply(this, arguments); waiting = true; setTimeout(function () { waiting = false; }, limit); } }; } /***/ }), /***/ 787: /***/ ((module) => { module.exports = __WEBPACK_EXTERNAL_MODULE__787__; /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ // no module.id needed /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/compat get default export */ /******/ (() => { /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = (module) => { /******/ var getter = module && module.__esModule ? /******/ () => (module['default']) : /******/ () => (module); /******/ __webpack_require__.d(getter, { a: getter }); /******/ return getter; /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /******/ /* webpack/runtime/make namespace object */ /******/ (() => { /******/ // define __esModule on exports /******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _libs_performance__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(318); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } 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 _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 _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 _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /** * Listens for scrolls the window to a particular place in the document * * @usage: const App = () => { const [scrollData, windowScrollUpdate] = useWindowScroll({ performance: ['debounce', 500], // "['debounce', 500]" or "['throttle', 500]" handle: (scrollData) => { // do something console.log(scrollData); } }); }; */ var useWindowScroll = function useWindowScroll(_ref) { var enabled = _ref.enabled, performance = _ref.performance, handle = _ref.handle; var windowScrollUpdate; var _performance = _slicedToArray(performance, 2), performanceName = _performance[0], performanceLimit = _performance[1]; var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)({ x: 0, y: 0 }), _useState2 = _slicedToArray(_useState, 2), scrollData = _useState2[0], setScrollData = _useState2[1]; var eventHandlerScroll = function eventHandlerScroll(e) { var doc = document.documentElement; var left = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0); var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); var res = { x: left, y: top }; setScrollData(res); if (typeof handle === "function") handle(res); }; if (performanceName === "debounce") windowScrollUpdate = (0,_libs_performance__WEBPACK_IMPORTED_MODULE_1__.debounce)(eventHandlerScroll, parseFloat(performanceLimit)); if (performanceName === "throttle") windowScrollUpdate = (0,_libs_performance__WEBPACK_IMPORTED_MODULE_1__.throttle)(eventHandlerScroll, parseFloat(performanceLimit)); (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () { window.addEventListener("scroll", windowScrollUpdate); window.addEventListener("touchmove", windowScrollUpdate); return function () { window.removeEventListener("scroll", windowScrollUpdate); window.removeEventListener("touchmove", windowScrollUpdate); }; }, []); return [scrollData, windowScrollUpdate]; }; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useWindowScroll); })(); /******/ return __webpack_exports__; /******/ })() ; });