UNPKG

@10up/block-components

Version:

10up Components built for the WordPress Block Editor.

135 lines (126 loc) 5.62 kB
/******/ (function() { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "@wordpress/compose": /*!*************************************!*\ !*** external "@wordpress/compose" ***! \*************************************/ /***/ (function(module) { module.exports = require("@wordpress/compose"); /***/ }), /***/ "@wordpress/element": /*!*************************************!*\ !*** external "@wordpress/element" ***! \*************************************/ /***/ (function(module) { module.exports = require("@wordpress/element"); /***/ }) /******/ }); /************************************************************************/ /******/ // 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 */ /******/ !function() { /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function() { return module['default']; } : /******/ function() { return module; }; /******/ __webpack_require__.d(getter, { a: getter }); /******/ return getter; /******/ }; /******/ }(); /******/ /******/ /* webpack/runtime/define property getters */ /******/ !function() { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = function(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 */ /******/ !function() { /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } /******/ }(); /******/ /******/ /* webpack/runtime/make namespace object */ /******/ !function() { /******/ // define __esModule on exports /******/ __webpack_require__.r = function(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 needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. !function() { /*!********************************************!*\ !*** ./hooks/use-debounced-input/index.ts ***! \********************************************/ __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ useDebouncedInput: function() { return /* binding */ useDebouncedInput; } /* harmony export */ }); /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/compose */ "@wordpress/compose"); /* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_compose__WEBPACK_IMPORTED_MODULE_1__); /** * Helper hook for input fields that need to debounce the value before using it. * * @param {string} defaultValue The default value to use. * @param {DebouncedInputOptions} options Set of options for useDebounce, 350ms is the default * * @returns The input value, the setter and the debounced input value. */ function useDebouncedInput(defaultValue = '', options = { delay: 350 }) { const [input, setInput] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(defaultValue); const [debouncedInput, setDebouncedState] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(defaultValue); const { delay } = options; const setDebouncedInput = (0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_1__.useDebounce)(setDebouncedState, delay); (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { setDebouncedInput(input); }, [input, setDebouncedInput]); return [input, setInput, debouncedInput]; } }(); module.exports = __webpack_exports__; /******/ })() ; //# sourceMappingURL=index.js.map