2039 /******/ return module.exports; |
2228 /******/ return module.exports; |
2040 /******/ } |
2229 /******/ } |
2041 /******/ |
2230 /******/ |
2042 /************************************************************************/ |
2231 /************************************************************************/ |
2043 /******/ /* webpack/runtime/compat get default export */ |
2232 /******/ /* webpack/runtime/compat get default export */ |
2044 /******/ !function() { |
2233 /******/ (() => { |
2045 /******/ // getDefaultExport function for compatibility with non-harmony modules |
2234 /******/ // getDefaultExport function for compatibility with non-harmony modules |
2046 /******/ __webpack_require__.n = function(module) { |
2235 /******/ __webpack_require__.n = (module) => { |
2047 /******/ var getter = module && module.__esModule ? |
2236 /******/ var getter = module && module.__esModule ? |
2048 /******/ function() { return module['default']; } : |
2237 /******/ () => (module['default']) : |
2049 /******/ function() { return module; }; |
2238 /******/ () => (module); |
2050 /******/ __webpack_require__.d(getter, { a: getter }); |
2239 /******/ __webpack_require__.d(getter, { a: getter }); |
2051 /******/ return getter; |
2240 /******/ return getter; |
2052 /******/ }; |
2241 /******/ }; |
2053 /******/ }(); |
2242 /******/ })(); |
2054 /******/ |
2243 /******/ |
2055 /******/ /* webpack/runtime/define property getters */ |
2244 /******/ /* webpack/runtime/define property getters */ |
2056 /******/ !function() { |
2245 /******/ (() => { |
2057 /******/ // define getter functions for harmony exports |
2246 /******/ // define getter functions for harmony exports |
2058 /******/ __webpack_require__.d = function(exports, definition) { |
2247 /******/ __webpack_require__.d = (exports, definition) => { |
2059 /******/ for(var key in definition) { |
2248 /******/ for(var key in definition) { |
2060 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
2249 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
2061 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
2250 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
2062 /******/ } |
2251 /******/ } |
2063 /******/ } |
2252 /******/ } |
2064 /******/ }; |
2253 /******/ }; |
2065 /******/ }(); |
2254 /******/ })(); |
2066 /******/ |
2255 /******/ |
2067 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
2256 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
2068 /******/ !function() { |
2257 /******/ (() => { |
2069 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
2258 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
2070 /******/ }(); |
2259 /******/ })(); |
2071 /******/ |
2260 /******/ |
2072 /******/ /* webpack/runtime/make namespace object */ |
2261 /******/ /* webpack/runtime/make namespace object */ |
2073 /******/ !function() { |
2262 /******/ (() => { |
2074 /******/ // define __esModule on exports |
2263 /******/ // define __esModule on exports |
2075 /******/ __webpack_require__.r = function(exports) { |
2264 /******/ __webpack_require__.r = (exports) => { |
2076 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
2265 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
2077 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
2266 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
2078 /******/ } |
2267 /******/ } |
2079 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
2268 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
2080 /******/ }; |
2269 /******/ }; |
2081 /******/ }(); |
2270 /******/ })(); |
2082 /******/ |
2271 /******/ |
2083 /************************************************************************/ |
2272 /************************************************************************/ |
2084 var __webpack_exports__ = {}; |
2273 var __webpack_exports__ = {}; |
2085 // This entry need to be wrapped in an IIFE because it need to be in strict mode. |
2274 // This entry need to be wrapped in an IIFE because it need to be in strict mode. |
2086 !function() { |
2275 (() => { |
2087 "use strict"; |
2276 "use strict"; |
2088 // ESM COMPAT FLAG |
2277 // ESM COMPAT FLAG |
2089 __webpack_require__.r(__webpack_exports__); |
2278 __webpack_require__.r(__webpack_exports__); |
2090 |
2279 |
2091 // EXPORTS |
2280 // EXPORTS |
2092 __webpack_require__.d(__webpack_exports__, { |
2281 __webpack_require__.d(__webpack_exports__, { |
2093 "__experimentalUseDialog": function() { return /* reexport */ use_dialog; }, |
2282 __experimentalUseDialog: () => (/* reexport */ use_dialog), |
2094 "__experimentalUseDisabled": function() { return /* reexport */ useDisabled; }, |
2283 __experimentalUseDragging: () => (/* reexport */ useDragging), |
2095 "__experimentalUseDragging": function() { return /* reexport */ useDragging; }, |
2284 __experimentalUseDropZone: () => (/* reexport */ useDropZone), |
2096 "__experimentalUseDropZone": function() { return /* reexport */ useDropZone; }, |
2285 __experimentalUseFixedWindowList: () => (/* reexport */ useFixedWindowList), |
2097 "__experimentalUseFixedWindowList": function() { return /* reexport */ useFixedWindowList; }, |
2286 __experimentalUseFocusOutside: () => (/* reexport */ useFocusOutside), |
2098 "__experimentalUseFocusOutside": function() { return /* reexport */ useFocusOutside; }, |
2287 compose: () => (/* reexport */ higher_order_compose), |
2099 "compose": function() { return /* reexport */ compose; }, |
2288 createHigherOrderComponent: () => (/* reexport */ createHigherOrderComponent), |
2100 "createHigherOrderComponent": function() { return /* reexport */ create_higher_order_component; }, |
2289 debounce: () => (/* reexport */ debounce), |
2101 "ifCondition": function() { return /* reexport */ if_condition; }, |
2290 ifCondition: () => (/* reexport */ if_condition), |
2102 "pure": function() { return /* reexport */ higher_order_pure; }, |
2291 observableMap: () => (/* reexport */ observableMap), |
2103 "useAsyncList": function() { return /* reexport */ use_async_list; }, |
2292 pipe: () => (/* reexport */ higher_order_pipe), |
2104 "useConstrainedTabbing": function() { return /* reexport */ use_constrained_tabbing; }, |
2293 pure: () => (/* reexport */ higher_order_pure), |
2105 "useCopyOnClick": function() { return /* reexport */ useCopyOnClick; }, |
2294 throttle: () => (/* reexport */ throttle), |
2106 "useCopyToClipboard": function() { return /* reexport */ useCopyToClipboard; }, |
2295 useAsyncList: () => (/* reexport */ use_async_list), |
2107 "useDebounce": function() { return /* reexport */ useDebounce; }, |
2296 useConstrainedTabbing: () => (/* reexport */ use_constrained_tabbing), |
2108 "useFocusOnMount": function() { return /* reexport */ useFocusOnMount; }, |
2297 useCopyOnClick: () => (/* reexport */ useCopyOnClick), |
2109 "useFocusReturn": function() { return /* reexport */ use_focus_return; }, |
2298 useCopyToClipboard: () => (/* reexport */ useCopyToClipboard), |
2110 "useFocusableIframe": function() { return /* reexport */ useFocusableIframe; }, |
2299 useDebounce: () => (/* reexport */ useDebounce), |
2111 "useInstanceId": function() { return /* reexport */ useInstanceId; }, |
2300 useDebouncedInput: () => (/* reexport */ useDebouncedInput), |
2112 "useIsomorphicLayoutEffect": function() { return /* reexport */ use_isomorphic_layout_effect; }, |
2301 useDisabled: () => (/* reexport */ useDisabled), |
2113 "useKeyboardShortcut": function() { return /* reexport */ use_keyboard_shortcut; }, |
2302 useFocusOnMount: () => (/* reexport */ useFocusOnMount), |
2114 "useMediaQuery": function() { return /* reexport */ useMediaQuery; }, |
2303 useFocusReturn: () => (/* reexport */ use_focus_return), |
2115 "useMergeRefs": function() { return /* reexport */ useMergeRefs; }, |
2304 useFocusableIframe: () => (/* reexport */ useFocusableIframe), |
2116 "usePrevious": function() { return /* reexport */ usePrevious; }, |
2305 useInstanceId: () => (/* reexport */ use_instance_id), |
2117 "useReducedMotion": function() { return /* reexport */ use_reduced_motion; }, |
2306 useIsomorphicLayoutEffect: () => (/* reexport */ use_isomorphic_layout_effect), |
2118 "useRefEffect": function() { return /* reexport */ useRefEffect; }, |
2307 useKeyboardShortcut: () => (/* reexport */ use_keyboard_shortcut), |
2119 "useResizeObserver": function() { return /* reexport */ use_resize_observer; }, |
2308 useMediaQuery: () => (/* reexport */ useMediaQuery), |
2120 "useThrottle": function() { return /* reexport */ useThrottle; }, |
2309 useMergeRefs: () => (/* reexport */ useMergeRefs), |
2121 "useViewportMatch": function() { return /* reexport */ use_viewport_match; }, |
2310 useObservableValue: () => (/* reexport */ useObservableValue), |
2122 "useWarnOnChange": function() { return /* reexport */ use_warn_on_change; }, |
2311 usePrevious: () => (/* reexport */ usePrevious), |
2123 "withGlobalEvents": function() { return /* reexport */ withGlobalEvents; }, |
2312 useReducedMotion: () => (/* reexport */ use_reduced_motion), |
2124 "withInstanceId": function() { return /* reexport */ with_instance_id; }, |
2313 useRefEffect: () => (/* reexport */ useRefEffect), |
2125 "withSafeTimeout": function() { return /* reexport */ with_safe_timeout; }, |
2314 useResizeObserver: () => (/* reexport */ useResizeAware), |
2126 "withState": function() { return /* reexport */ withState; } |
2315 useStateWithHistory: () => (/* reexport */ useStateWithHistory), |
|
2316 useThrottle: () => (/* reexport */ useThrottle), |
|
2317 useViewportMatch: () => (/* reexport */ use_viewport_match), |
|
2318 useWarnOnChange: () => (/* reexport */ use_warn_on_change), |
|
2319 withGlobalEvents: () => (/* reexport */ withGlobalEvents), |
|
2320 withInstanceId: () => (/* reexport */ with_instance_id), |
|
2321 withSafeTimeout: () => (/* reexport */ with_safe_timeout), |
|
2322 withState: () => (/* reexport */ withState) |
2127 }); |
2323 }); |
2128 |
2324 |
2129 ;// CONCATENATED MODULE: external "lodash" |
2325 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs |
2130 var external_lodash_namespaceObject = window["lodash"]; |
2326 /****************************************************************************** |
|
2327 Copyright (c) Microsoft Corporation. |
|
2328 |
|
2329 Permission to use, copy, modify, and/or distribute this software for any |
|
2330 purpose with or without fee is hereby granted. |
|
2331 |
|
2332 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
|
2333 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
|
2334 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
|
2335 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
|
2336 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
|
2337 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
2338 PERFORMANCE OF THIS SOFTWARE. |
|
2339 ***************************************************************************** */ |
|
2340 /* global Reflect, Promise, SuppressedError, Symbol */ |
|
2341 |
|
2342 var extendStatics = function(d, b) { |
|
2343 extendStatics = Object.setPrototypeOf || |
|
2344 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
2345 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
|
2346 return extendStatics(d, b); |
|
2347 }; |
|
2348 |
|
2349 function __extends(d, b) { |
|
2350 if (typeof b !== "function" && b !== null) |
|
2351 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
|
2352 extendStatics(d, b); |
|
2353 function __() { this.constructor = d; } |
|
2354 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
2355 } |
|
2356 |
|
2357 var __assign = function() { |
|
2358 __assign = Object.assign || function __assign(t) { |
|
2359 for (var s, i = 1, n = arguments.length; i < n; i++) { |
|
2360 s = arguments[i]; |
|
2361 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
|
2362 } |
|
2363 return t; |
|
2364 } |
|
2365 return __assign.apply(this, arguments); |
|
2366 } |
|
2367 |
|
2368 function __rest(s, e) { |
|
2369 var t = {}; |
|
2370 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) |
|
2371 t[p] = s[p]; |
|
2372 if (s != null && typeof Object.getOwnPropertySymbols === "function") |
|
2373 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { |
|
2374 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) |
|
2375 t[p[i]] = s[p[i]]; |
|
2376 } |
|
2377 return t; |
|
2378 } |
|
2379 |
|
2380 function __decorate(decorators, target, key, desc) { |
|
2381 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; |
|
2382 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); |
|
2383 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; |
|
2384 return c > 3 && r && Object.defineProperty(target, key, r), r; |
|
2385 } |
|
2386 |
|
2387 function __param(paramIndex, decorator) { |
|
2388 return function (target, key) { decorator(target, key, paramIndex); } |
|
2389 } |
|
2390 |
|
2391 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { |
|
2392 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } |
|
2393 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; |
|
2394 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; |
|
2395 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); |
|
2396 var _, done = false; |
|
2397 for (var i = decorators.length - 1; i >= 0; i--) { |
|
2398 var context = {}; |
|
2399 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; |
|
2400 for (var p in contextIn.access) context.access[p] = contextIn.access[p]; |
|
2401 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; |
|
2402 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); |
|
2403 if (kind === "accessor") { |
|
2404 if (result === void 0) continue; |
|
2405 if (result === null || typeof result !== "object") throw new TypeError("Object expected"); |
|
2406 if (_ = accept(result.get)) descriptor.get = _; |
|
2407 if (_ = accept(result.set)) descriptor.set = _; |
|
2408 if (_ = accept(result.init)) initializers.unshift(_); |
|
2409 } |
|
2410 else if (_ = accept(result)) { |
|
2411 if (kind === "field") initializers.unshift(_); |
|
2412 else descriptor[key] = _; |
|
2413 } |
|
2414 } |
|
2415 if (target) Object.defineProperty(target, contextIn.name, descriptor); |
|
2416 done = true; |
|
2417 }; |
|
2418 |
|
2419 function __runInitializers(thisArg, initializers, value) { |
|
2420 var useValue = arguments.length > 2; |
|
2421 for (var i = 0; i < initializers.length; i++) { |
|
2422 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); |
|
2423 } |
|
2424 return useValue ? value : void 0; |
|
2425 }; |
|
2426 |
|
2427 function __propKey(x) { |
|
2428 return typeof x === "symbol" ? x : "".concat(x); |
|
2429 }; |
|
2430 |
|
2431 function __setFunctionName(f, name, prefix) { |
|
2432 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; |
|
2433 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); |
|
2434 }; |
|
2435 |
|
2436 function __metadata(metadataKey, metadataValue) { |
|
2437 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); |
|
2438 } |
|
2439 |
|
2440 function __awaiter(thisArg, _arguments, P, generator) { |
|
2441 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
|
2442 return new (P || (P = Promise))(function (resolve, reject) { |
|
2443 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
|
2444 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
|
2445 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
|
2446 step((generator = generator.apply(thisArg, _arguments || [])).next()); |
|
2447 }); |
|
2448 } |
|
2449 |
|
2450 function __generator(thisArg, body) { |
|
2451 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
|
2452 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
|
2453 function verb(n) { return function (v) { return step([n, v]); }; } |
|
2454 function step(op) { |
|
2455 if (f) throw new TypeError("Generator is already executing."); |
|
2456 while (g && (g = 0, op[0] && (_ = 0)), _) try { |
|
2457 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
|
2458 if (y = 0, t) op = [op[0] & 2, t.value]; |
|
2459 switch (op[0]) { |
|
2460 case 0: case 1: t = op; break; |
|
2461 case 4: _.label++; return { value: op[1], done: false }; |
|
2462 case 5: _.label++; y = op[1]; op = [0]; continue; |
|
2463 case 7: op = _.ops.pop(); _.trys.pop(); continue; |
|
2464 default: |
|
2465 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
|
2466 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
|
2467 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
|
2468 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
|
2469 if (t[2]) _.ops.pop(); |
|
2470 _.trys.pop(); continue; |
|
2471 } |
|
2472 op = body.call(thisArg, _); |
|
2473 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
|
2474 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
|
2475 } |
|
2476 } |
|
2477 |
|
2478 var __createBinding = Object.create ? (function(o, m, k, k2) { |
|
2479 if (k2 === undefined) k2 = k; |
|
2480 var desc = Object.getOwnPropertyDescriptor(m, k); |
|
2481 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |
|
2482 desc = { enumerable: true, get: function() { return m[k]; } }; |
|
2483 } |
|
2484 Object.defineProperty(o, k2, desc); |
|
2485 }) : (function(o, m, k, k2) { |
|
2486 if (k2 === undefined) k2 = k; |
|
2487 o[k2] = m[k]; |
|
2488 }); |
|
2489 |
|
2490 function __exportStar(m, o) { |
|
2491 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); |
|
2492 } |
|
2493 |
|
2494 function __values(o) { |
|
2495 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; |
|
2496 if (m) return m.call(o); |
|
2497 if (o && typeof o.length === "number") return { |
|
2498 next: function () { |
|
2499 if (o && i >= o.length) o = void 0; |
|
2500 return { value: o && o[i++], done: !o }; |
|
2501 } |
|
2502 }; |
|
2503 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); |
|
2504 } |
|
2505 |
|
2506 function __read(o, n) { |
|
2507 var m = typeof Symbol === "function" && o[Symbol.iterator]; |
|
2508 if (!m) return o; |
|
2509 var i = m.call(o), r, ar = [], e; |
|
2510 try { |
|
2511 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); |
|
2512 } |
|
2513 catch (error) { e = { error: error }; } |
|
2514 finally { |
|
2515 try { |
|
2516 if (r && !r.done && (m = i["return"])) m.call(i); |
|
2517 } |
|
2518 finally { if (e) throw e.error; } |
|
2519 } |
|
2520 return ar; |
|
2521 } |
|
2522 |
|
2523 /** @deprecated */ |
|
2524 function __spread() { |
|
2525 for (var ar = [], i = 0; i < arguments.length; i++) |
|
2526 ar = ar.concat(__read(arguments[i])); |
|
2527 return ar; |
|
2528 } |
|
2529 |
|
2530 /** @deprecated */ |
|
2531 function __spreadArrays() { |
|
2532 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; |
|
2533 for (var r = Array(s), k = 0, i = 0; i < il; i++) |
|
2534 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) |
|
2535 r[k] = a[j]; |
|
2536 return r; |
|
2537 } |
|
2538 |
|
2539 function __spreadArray(to, from, pack) { |
|
2540 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { |
|
2541 if (ar || !(i in from)) { |
|
2542 if (!ar) ar = Array.prototype.slice.call(from, 0, i); |
|
2543 ar[i] = from[i]; |
|
2544 } |
|
2545 } |
|
2546 return to.concat(ar || Array.prototype.slice.call(from)); |
|
2547 } |
|
2548 |
|
2549 function __await(v) { |
|
2550 return this instanceof __await ? (this.v = v, this) : new __await(v); |
|
2551 } |
|
2552 |
|
2553 function __asyncGenerator(thisArg, _arguments, generator) { |
|
2554 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
|
2555 var g = generator.apply(thisArg, _arguments || []), i, q = []; |
|
2556 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; |
|
2557 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } |
|
2558 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } |
|
2559 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } |
|
2560 function fulfill(value) { resume("next", value); } |
|
2561 function reject(value) { resume("throw", value); } |
|
2562 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } |
|
2563 } |
|
2564 |
|
2565 function __asyncDelegator(o) { |
|
2566 var i, p; |
|
2567 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; |
|
2568 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } |
|
2569 } |
|
2570 |
|
2571 function __asyncValues(o) { |
|
2572 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
|
2573 var m = o[Symbol.asyncIterator], i; |
|
2574 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); |
|
2575 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } |
|
2576 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } |
|
2577 } |
|
2578 |
|
2579 function __makeTemplateObject(cooked, raw) { |
|
2580 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } |
|
2581 return cooked; |
|
2582 }; |
|
2583 |
|
2584 var __setModuleDefault = Object.create ? (function(o, v) { |
|
2585 Object.defineProperty(o, "default", { enumerable: true, value: v }); |
|
2586 }) : function(o, v) { |
|
2587 o["default"] = v; |
|
2588 }; |
|
2589 |
|
2590 function __importStar(mod) { |
|
2591 if (mod && mod.__esModule) return mod; |
|
2592 var result = {}; |
|
2593 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); |
|
2594 __setModuleDefault(result, mod); |
|
2595 return result; |
|
2596 } |
|
2597 |
|
2598 function __importDefault(mod) { |
|
2599 return (mod && mod.__esModule) ? mod : { default: mod }; |
|
2600 } |
|
2601 |
|
2602 function __classPrivateFieldGet(receiver, state, kind, f) { |
|
2603 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); |
|
2604 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); |
|
2605 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); |
|
2606 } |
|
2607 |
|
2608 function __classPrivateFieldSet(receiver, state, value, kind, f) { |
|
2609 if (kind === "m") throw new TypeError("Private method is not writable"); |
|
2610 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); |
|
2611 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); |
|
2612 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; |
|
2613 } |
|
2614 |
|
2615 function __classPrivateFieldIn(state, receiver) { |
|
2616 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); |
|
2617 return typeof state === "function" ? receiver === state : state.has(receiver); |
|
2618 } |
|
2619 |
|
2620 function __addDisposableResource(env, value, async) { |
|
2621 if (value !== null && value !== void 0) { |
|
2622 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); |
|
2623 var dispose; |
|
2624 if (async) { |
|
2625 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); |
|
2626 dispose = value[Symbol.asyncDispose]; |
|
2627 } |
|
2628 if (dispose === void 0) { |
|
2629 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); |
|
2630 dispose = value[Symbol.dispose]; |
|
2631 } |
|
2632 if (typeof dispose !== "function") throw new TypeError("Object not disposable."); |
|
2633 env.stack.push({ value: value, dispose: dispose, async: async }); |
|
2634 } |
|
2635 else if (async) { |
|
2636 env.stack.push({ async: true }); |
|
2637 } |
|
2638 return value; |
|
2639 } |
|
2640 |
|
2641 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { |
|
2642 var e = new Error(message); |
|
2643 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; |
|
2644 }; |
|
2645 |
|
2646 function __disposeResources(env) { |
|
2647 function fail(e) { |
|
2648 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; |
|
2649 env.hasError = true; |
|
2650 } |
|
2651 function next() { |
|
2652 while (env.stack.length) { |
|
2653 var rec = env.stack.pop(); |
|
2654 try { |
|
2655 var result = rec.dispose && rec.dispose.call(rec.value); |
|
2656 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); |
|
2657 } |
|
2658 catch (e) { |
|
2659 fail(e); |
|
2660 } |
|
2661 } |
|
2662 if (env.hasError) throw env.error; |
|
2663 } |
|
2664 return next(); |
|
2665 } |
|
2666 |
|
2667 /* harmony default export */ const tslib_es6 = ({ |
|
2668 __extends, |
|
2669 __assign, |
|
2670 __rest, |
|
2671 __decorate, |
|
2672 __param, |
|
2673 __metadata, |
|
2674 __awaiter, |
|
2675 __generator, |
|
2676 __createBinding, |
|
2677 __exportStar, |
|
2678 __values, |
|
2679 __read, |
|
2680 __spread, |
|
2681 __spreadArrays, |
|
2682 __spreadArray, |
|
2683 __await, |
|
2684 __asyncGenerator, |
|
2685 __asyncDelegator, |
|
2686 __asyncValues, |
|
2687 __makeTemplateObject, |
|
2688 __importStar, |
|
2689 __importDefault, |
|
2690 __classPrivateFieldGet, |
|
2691 __classPrivateFieldSet, |
|
2692 __classPrivateFieldIn, |
|
2693 __addDisposableResource, |
|
2694 __disposeResources, |
|
2695 }); |
|
2696 |
|
2697 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js |
|
2698 /** |
|
2699 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt |
|
2700 */ |
|
2701 var SUPPORTED_LOCALE = { |
|
2702 tr: { |
|
2703 regexp: /\u0130|\u0049|\u0049\u0307/g, |
|
2704 map: { |
|
2705 İ: "\u0069", |
|
2706 I: "\u0131", |
|
2707 İ: "\u0069", |
|
2708 }, |
|
2709 }, |
|
2710 az: { |
|
2711 regexp: /\u0130/g, |
|
2712 map: { |
|
2713 İ: "\u0069", |
|
2714 I: "\u0131", |
|
2715 İ: "\u0069", |
|
2716 }, |
|
2717 }, |
|
2718 lt: { |
|
2719 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, |
|
2720 map: { |
|
2721 I: "\u0069\u0307", |
|
2722 J: "\u006A\u0307", |
|
2723 Į: "\u012F\u0307", |
|
2724 Ì: "\u0069\u0307\u0300", |
|
2725 Í: "\u0069\u0307\u0301", |
|
2726 Ĩ: "\u0069\u0307\u0303", |
|
2727 }, |
|
2728 }, |
|
2729 }; |
|
2730 /** |
|
2731 * Localized lower case. |
|
2732 */ |
|
2733 function localeLowerCase(str, locale) { |
|
2734 var lang = SUPPORTED_LOCALE[locale.toLowerCase()]; |
|
2735 if (lang) |
|
2736 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; })); |
|
2737 return lowerCase(str); |
|
2738 } |
|
2739 /** |
|
2740 * Lower case as a function. |
|
2741 */ |
|
2742 function lowerCase(str) { |
|
2743 return str.toLowerCase(); |
|
2744 } |
|
2745 |
|
2746 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js |
|
2747 |
|
2748 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). |
|
2749 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; |
|
2750 // Remove all non-word characters. |
|
2751 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; |
|
2752 /** |
|
2753 * Normalize the string into something other libraries can manipulate easier. |
|
2754 */ |
|
2755 function noCase(input, options) { |
|
2756 if (options === void 0) { options = {}; } |
|
2757 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; |
|
2758 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); |
|
2759 var start = 0; |
|
2760 var end = result.length; |
|
2761 // Trim the delimiter from around the output string. |
|
2762 while (result.charAt(start) === "\0") |
|
2763 start++; |
|
2764 while (result.charAt(end - 1) === "\0") |
|
2765 end--; |
|
2766 // Transform each token independently. |
|
2767 return result.slice(start, end).split("\0").map(transform).join(delimiter); |
|
2768 } |
|
2769 /** |
|
2770 * Replace `re` in the input string with the replacement value. |
|
2771 */ |
|
2772 function replace(input, re, value) { |
|
2773 if (re instanceof RegExp) |
|
2774 return input.replace(re, value); |
|
2775 return re.reduce(function (input, re) { return input.replace(re, value); }, input); |
|
2776 } |
|
2777 |
|
2778 ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js |
|
2779 |
|
2780 |
|
2781 function pascalCaseTransform(input, index) { |
|
2782 var firstChar = input.charAt(0); |
|
2783 var lowerChars = input.substr(1).toLowerCase(); |
|
2784 if (index > 0 && firstChar >= "0" && firstChar <= "9") { |
|
2785 return "_" + firstChar + lowerChars; |
|
2786 } |
|
2787 return "" + firstChar.toUpperCase() + lowerChars; |
|
2788 } |
|
2789 function pascalCaseTransformMerge(input) { |
|
2790 return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); |
|
2791 } |
|
2792 function pascalCase(input, options) { |
|
2793 if (options === void 0) { options = {}; } |
|
2794 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); |
|
2795 } |
|
2796 |
2131 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js |
2797 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js |
2132 /** |
2798 /** |
2133 * External dependencies |
2799 * External dependencies |
2134 */ |
2800 */ |
2135 |
|
2136 |
2801 |
2137 /** |
2802 /** |
2138 * Given a function mapping a component to an enhanced component and modifier |
2803 * Given a function mapping a component to an enhanced component and modifier |
2139 * name, returns the enhanced component augmented with a generated displayName. |
2804 * name, returns the enhanced component augmented with a generated displayName. |
2140 * |
2805 * |
2141 * @param mapComponent Function mapping component to enhanced component. |
2806 * @param mapComponent Function mapping component to enhanced component. |
2142 * @param modifierName Seed name from which to generated display name. |
2807 * @param modifierName Seed name from which to generated display name. |
2143 * |
2808 * |
2144 * @return Component class with generated display name assigned. |
2809 * @return Component class with generated display name assigned. |
2145 */ |
2810 */ |
2146 function createHigherOrderComponent(mapComponent, modifierName) { |
2811 function createHigherOrderComponent(mapComponent, modifierName) { |
2147 return Inner => { |
2812 return Inner => { |
2148 const Outer = mapComponent(Inner); |
2813 const Outer = mapComponent(Inner); |
2149 const displayName = Inner.displayName || Inner.name || 'Component'; |
2814 Outer.displayName = hocName(modifierName, Inner); |
2150 Outer.displayName = `${(0,external_lodash_namespaceObject.upperFirst)((0,external_lodash_namespaceObject.camelCase)(modifierName))}(${displayName})`; |
|
2151 return Outer; |
2815 return Outer; |
2152 }; |
2816 }; |
2153 } |
2817 } |
2154 |
2818 |
2155 /* harmony default export */ var create_higher_order_component = (createHigherOrderComponent); |
2819 /** |
|
2820 * Returns a displayName for a higher-order component, given a wrapper name. |
|
2821 * |
|
2822 * @example |
|
2823 * hocName( 'MyMemo', Widget ) === 'MyMemo(Widget)'; |
|
2824 * hocName( 'MyMemo', <div /> ) === 'MyMemo(Component)'; |
|
2825 * |
|
2826 * @param name Name assigned to higher-order component's wrapper component. |
|
2827 * @param Inner Wrapped component inside higher-order component. |
|
2828 * @return Wrapped name of higher-order component. |
|
2829 */ |
|
2830 const hocName = (name, Inner) => { |
|
2831 const inner = Inner.displayName || Inner.name || 'Component'; |
|
2832 const outer = pascalCase(name !== null && name !== void 0 ? name : ''); |
|
2833 return `${outer}(${inner})`; |
|
2834 }; |
|
2835 |
|
2836 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/debounce/index.js |
|
2837 /** |
|
2838 * Parts of this source were derived and modified from lodash, |
|
2839 * released under the MIT license. |
|
2840 * |
|
2841 * https://github.com/lodash/lodash |
|
2842 * |
|
2843 * Copyright JS Foundation and other contributors <https://js.foundation/> |
|
2844 * |
|
2845 * Based on Underscore.js, copyright Jeremy Ashkenas, |
|
2846 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> |
|
2847 * |
|
2848 * This software consists of voluntary contributions made by many |
|
2849 * individuals. For exact contribution history, see the revision history |
|
2850 * available at https://github.com/lodash/lodash |
|
2851 * |
|
2852 * The following license applies to all parts of this software except as |
|
2853 * documented below: |
|
2854 * |
|
2855 * ==== |
|
2856 * |
|
2857 * Permission is hereby granted, free of charge, to any person obtaining |
|
2858 * a copy of this software and associated documentation files (the |
|
2859 * "Software"), to deal in the Software without restriction, including |
|
2860 * without limitation the rights to use, copy, modify, merge, publish, |
|
2861 * distribute, sublicense, and/or sell copies of the Software, and to |
|
2862 * permit persons to whom the Software is furnished to do so, subject to |
|
2863 * the following conditions: |
|
2864 * |
|
2865 * The above copyright notice and this permission notice shall be |
|
2866 * included in all copies or substantial portions of the Software. |
|
2867 * |
|
2868 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
2869 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
2870 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
2871 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
|
2872 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
|
2873 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
2874 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
2875 */ |
|
2876 |
|
2877 /** |
|
2878 * A simplified and properly typed version of lodash's `debounce`, that |
|
2879 * always uses timers instead of sometimes using rAF. |
|
2880 * |
|
2881 * Creates a debounced function that delays invoking `func` until after `wait` |
|
2882 * milliseconds have elapsed since the last time the debounced function was |
|
2883 * invoked. The debounced function comes with a `cancel` method to cancel delayed |
|
2884 * `func` invocations and a `flush` method to immediately invoke them. Provide |
|
2885 * `options` to indicate whether `func` should be invoked on the leading and/or |
|
2886 * trailing edge of the `wait` timeout. The `func` is invoked with the last |
|
2887 * arguments provided to the debounced function. Subsequent calls to the debounced |
|
2888 * function return the result of the last `func` invocation. |
|
2889 * |
|
2890 * **Note:** If `leading` and `trailing` options are `true`, `func` is |
|
2891 * invoked on the trailing edge of the timeout only if the debounced function |
|
2892 * is invoked more than once during the `wait` timeout. |
|
2893 * |
|
2894 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred |
|
2895 * until the next tick, similar to `setTimeout` with a timeout of `0`. |
|
2896 * |
|
2897 * @param {Function} func The function to debounce. |
|
2898 * @param {number} wait The number of milliseconds to delay. |
|
2899 * @param {Partial< DebounceOptions >} options The options object. |
|
2900 * @param {boolean} options.leading Specify invoking on the leading edge of the timeout. |
|
2901 * @param {number} options.maxWait The maximum time `func` is allowed to be delayed before it's invoked. |
|
2902 * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout. |
|
2903 * |
|
2904 * @return Returns the new debounced function. |
|
2905 */ |
|
2906 const debounce = (func, wait, options) => { |
|
2907 let lastArgs; |
|
2908 let lastThis; |
|
2909 let maxWait = 0; |
|
2910 let result; |
|
2911 let timerId; |
|
2912 let lastCallTime; |
|
2913 let lastInvokeTime = 0; |
|
2914 let leading = false; |
|
2915 let maxing = false; |
|
2916 let trailing = true; |
|
2917 if (options) { |
|
2918 leading = !!options.leading; |
|
2919 maxing = 'maxWait' in options; |
|
2920 if (options.maxWait !== undefined) { |
|
2921 maxWait = Math.max(options.maxWait, wait); |
|
2922 } |
|
2923 trailing = 'trailing' in options ? !!options.trailing : trailing; |
|
2924 } |
|
2925 function invokeFunc(time) { |
|
2926 const args = lastArgs; |
|
2927 const thisArg = lastThis; |
|
2928 lastArgs = undefined; |
|
2929 lastThis = undefined; |
|
2930 lastInvokeTime = time; |
|
2931 result = func.apply(thisArg, args); |
|
2932 return result; |
|
2933 } |
|
2934 function startTimer(pendingFunc, waitTime) { |
|
2935 timerId = setTimeout(pendingFunc, waitTime); |
|
2936 } |
|
2937 function cancelTimer() { |
|
2938 if (timerId !== undefined) { |
|
2939 clearTimeout(timerId); |
|
2940 } |
|
2941 } |
|
2942 function leadingEdge(time) { |
|
2943 // Reset any `maxWait` timer. |
|
2944 lastInvokeTime = time; |
|
2945 // Start the timer for the trailing edge. |
|
2946 startTimer(timerExpired, wait); |
|
2947 // Invoke the leading edge. |
|
2948 return leading ? invokeFunc(time) : result; |
|
2949 } |
|
2950 function getTimeSinceLastCall(time) { |
|
2951 return time - (lastCallTime || 0); |
|
2952 } |
|
2953 function remainingWait(time) { |
|
2954 const timeSinceLastCall = getTimeSinceLastCall(time); |
|
2955 const timeSinceLastInvoke = time - lastInvokeTime; |
|
2956 const timeWaiting = wait - timeSinceLastCall; |
|
2957 return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting; |
|
2958 } |
|
2959 function shouldInvoke(time) { |
|
2960 const timeSinceLastCall = getTimeSinceLastCall(time); |
|
2961 const timeSinceLastInvoke = time - lastInvokeTime; |
|
2962 |
|
2963 // Either this is the first call, activity has stopped and we're at the |
|
2964 // trailing edge, the system time has gone backwards and we're treating |
|
2965 // it as the trailing edge, or we've hit the `maxWait` limit. |
|
2966 return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; |
|
2967 } |
|
2968 function timerExpired() { |
|
2969 const time = Date.now(); |
|
2970 if (shouldInvoke(time)) { |
|
2971 return trailingEdge(time); |
|
2972 } |
|
2973 // Restart the timer. |
|
2974 startTimer(timerExpired, remainingWait(time)); |
|
2975 return undefined; |
|
2976 } |
|
2977 function clearTimer() { |
|
2978 timerId = undefined; |
|
2979 } |
|
2980 function trailingEdge(time) { |
|
2981 clearTimer(); |
|
2982 |
|
2983 // Only invoke if we have `lastArgs` which means `func` has been |
|
2984 // debounced at least once. |
|
2985 if (trailing && lastArgs) { |
|
2986 return invokeFunc(time); |
|
2987 } |
|
2988 lastArgs = lastThis = undefined; |
|
2989 return result; |
|
2990 } |
|
2991 function cancel() { |
|
2992 cancelTimer(); |
|
2993 lastInvokeTime = 0; |
|
2994 clearTimer(); |
|
2995 lastArgs = lastCallTime = lastThis = undefined; |
|
2996 } |
|
2997 function flush() { |
|
2998 return pending() ? trailingEdge(Date.now()) : result; |
|
2999 } |
|
3000 function pending() { |
|
3001 return timerId !== undefined; |
|
3002 } |
|
3003 function debounced(...args) { |
|
3004 const time = Date.now(); |
|
3005 const isInvoking = shouldInvoke(time); |
|
3006 lastArgs = args; |
|
3007 lastThis = this; |
|
3008 lastCallTime = time; |
|
3009 if (isInvoking) { |
|
3010 if (!pending()) { |
|
3011 return leadingEdge(lastCallTime); |
|
3012 } |
|
3013 if (maxing) { |
|
3014 // Handle invocations in a tight loop. |
|
3015 startTimer(timerExpired, wait); |
|
3016 return invokeFunc(lastCallTime); |
|
3017 } |
|
3018 } |
|
3019 if (!pending()) { |
|
3020 startTimer(timerExpired, wait); |
|
3021 } |
|
3022 return result; |
|
3023 } |
|
3024 debounced.cancel = cancel; |
|
3025 debounced.flush = flush; |
|
3026 debounced.pending = pending; |
|
3027 return debounced; |
|
3028 }; |
|
3029 |
|
3030 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/throttle/index.js |
|
3031 /** |
|
3032 * Parts of this source were derived and modified from lodash, |
|
3033 * released under the MIT license. |
|
3034 * |
|
3035 * https://github.com/lodash/lodash |
|
3036 * |
|
3037 * Copyright JS Foundation and other contributors <https://js.foundation/> |
|
3038 * |
|
3039 * Based on Underscore.js, copyright Jeremy Ashkenas, |
|
3040 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> |
|
3041 * |
|
3042 * This software consists of voluntary contributions made by many |
|
3043 * individuals. For exact contribution history, see the revision history |
|
3044 * available at https://github.com/lodash/lodash |
|
3045 * |
|
3046 * The following license applies to all parts of this software except as |
|
3047 * documented below: |
|
3048 * |
|
3049 * ==== |
|
3050 * |
|
3051 * Permission is hereby granted, free of charge, to any person obtaining |
|
3052 * a copy of this software and associated documentation files (the |
|
3053 * "Software"), to deal in the Software without restriction, including |
|
3054 * without limitation the rights to use, copy, modify, merge, publish, |
|
3055 * distribute, sublicense, and/or sell copies of the Software, and to |
|
3056 * permit persons to whom the Software is furnished to do so, subject to |
|
3057 * the following conditions: |
|
3058 * |
|
3059 * The above copyright notice and this permission notice shall be |
|
3060 * included in all copies or substantial portions of the Software. |
|
3061 * |
|
3062 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
3063 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
3064 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
3065 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
|
3066 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
|
3067 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
3068 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
3069 */ |
|
3070 |
|
3071 /** |
|
3072 * Internal dependencies |
|
3073 */ |
|
3074 |
|
3075 /** |
|
3076 * A simplified and properly typed version of lodash's `throttle`, that |
|
3077 * always uses timers instead of sometimes using rAF. |
|
3078 * |
|
3079 * Creates a throttled function that only invokes `func` at most once per |
|
3080 * every `wait` milliseconds. The throttled function comes with a `cancel` |
|
3081 * method to cancel delayed `func` invocations and a `flush` method to |
|
3082 * immediately invoke them. Provide `options` to indicate whether `func` |
|
3083 * should be invoked on the leading and/or trailing edge of the `wait` |
|
3084 * timeout. The `func` is invoked with the last arguments provided to the |
|
3085 * throttled function. Subsequent calls to the throttled function return |
|
3086 * the result of the last `func` invocation. |
|
3087 * |
|
3088 * **Note:** If `leading` and `trailing` options are `true`, `func` is |
|
3089 * invoked on the trailing edge of the timeout only if the throttled function |
|
3090 * is invoked more than once during the `wait` timeout. |
|
3091 * |
|
3092 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred |
|
3093 * until the next tick, similar to `setTimeout` with a timeout of `0`. |
|
3094 * |
|
3095 * @param {Function} func The function to throttle. |
|
3096 * @param {number} wait The number of milliseconds to throttle invocations to. |
|
3097 * @param {Partial< ThrottleOptions >} options The options object. |
|
3098 * @param {boolean} options.leading Specify invoking on the leading edge of the timeout. |
|
3099 * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout. |
|
3100 * @return Returns the new throttled function. |
|
3101 */ |
|
3102 const throttle = (func, wait, options) => { |
|
3103 let leading = true; |
|
3104 let trailing = true; |
|
3105 if (options) { |
|
3106 leading = 'leading' in options ? !!options.leading : leading; |
|
3107 trailing = 'trailing' in options ? !!options.trailing : trailing; |
|
3108 } |
|
3109 return debounce(func, wait, { |
|
3110 leading, |
|
3111 trailing, |
|
3112 maxWait: wait |
|
3113 }); |
|
3114 }; |
|
3115 |
|
3116 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/observable-map/index.js |
|
3117 /** |
|
3118 * A constructor (factory) for `ObservableMap`, a map-like key/value data structure |
|
3119 * where the individual entries are observable: using the `subscribe` method, you can |
|
3120 * subscribe to updates for a particular keys. Each subscriber always observes one |
|
3121 * specific key and is not notified about any unrelated changes (for different keys) |
|
3122 * in the `ObservableMap`. |
|
3123 * |
|
3124 * @template K The type of the keys in the map. |
|
3125 * @template V The type of the values in the map. |
|
3126 * @return A new instance of the `ObservableMap` type. |
|
3127 */ |
|
3128 function observableMap() { |
|
3129 const map = new Map(); |
|
3130 const listeners = new Map(); |
|
3131 function callListeners(name) { |
|
3132 const list = listeners.get(name); |
|
3133 if (!list) { |
|
3134 return; |
|
3135 } |
|
3136 for (const listener of list) { |
|
3137 listener(); |
|
3138 } |
|
3139 } |
|
3140 return { |
|
3141 get(name) { |
|
3142 return map.get(name); |
|
3143 }, |
|
3144 set(name, value) { |
|
3145 map.set(name, value); |
|
3146 callListeners(name); |
|
3147 }, |
|
3148 delete(name) { |
|
3149 map.delete(name); |
|
3150 callListeners(name); |
|
3151 }, |
|
3152 subscribe(name, listener) { |
|
3153 let list = listeners.get(name); |
|
3154 if (!list) { |
|
3155 list = new Set(); |
|
3156 listeners.set(name, list); |
|
3157 } |
|
3158 list.add(listener); |
|
3159 return () => { |
|
3160 list.delete(listener); |
|
3161 if (list.size === 0) { |
|
3162 listeners.delete(name); |
|
3163 } |
|
3164 }; |
|
3165 } |
|
3166 }; |
|
3167 } |
|
3168 |
|
3169 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pipe.js |
|
3170 /** |
|
3171 * Parts of this source were derived and modified from lodash, |
|
3172 * released under the MIT license. |
|
3173 * |
|
3174 * https://github.com/lodash/lodash |
|
3175 * |
|
3176 * Copyright JS Foundation and other contributors <https://js.foundation/> |
|
3177 * |
|
3178 * Based on Underscore.js, copyright Jeremy Ashkenas, |
|
3179 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> |
|
3180 * |
|
3181 * This software consists of voluntary contributions made by many |
|
3182 * individuals. For exact contribution history, see the revision history |
|
3183 * available at https://github.com/lodash/lodash |
|
3184 * |
|
3185 * The following license applies to all parts of this software except as |
|
3186 * documented below: |
|
3187 * |
|
3188 * ==== |
|
3189 * |
|
3190 * Permission is hereby granted, free of charge, to any person obtaining |
|
3191 * a copy of this software and associated documentation files (the |
|
3192 * "Software"), to deal in the Software without restriction, including |
|
3193 * without limitation the rights to use, copy, modify, merge, publish, |
|
3194 * distribute, sublicense, and/or sell copies of the Software, and to |
|
3195 * permit persons to whom the Software is furnished to do so, subject to |
|
3196 * the following conditions: |
|
3197 * |
|
3198 * The above copyright notice and this permission notice shall be |
|
3199 * included in all copies or substantial portions of the Software. |
|
3200 * |
|
3201 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
3202 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
3203 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
3204 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
|
3205 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
|
3206 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
3207 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
3208 */ |
|
3209 |
|
3210 /** |
|
3211 * Creates a pipe function. |
|
3212 * |
|
3213 * Allows to choose whether to perform left-to-right or right-to-left composition. |
|
3214 * |
|
3215 * @see https://lodash.com/docs/4#flow |
|
3216 * |
|
3217 * @param {boolean} reverse True if right-to-left, false for left-to-right composition. |
|
3218 */ |
|
3219 const basePipe = (reverse = false) => (...funcs) => (...args) => { |
|
3220 const functions = funcs.flat(); |
|
3221 if (reverse) { |
|
3222 functions.reverse(); |
|
3223 } |
|
3224 return functions.reduce((prev, func) => [func(...prev)], args)[0]; |
|
3225 }; |
|
3226 |
|
3227 /** |
|
3228 * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function |
|
3229 * composition, where each successive invocation is supplied the return value of the previous. |
|
3230 * |
|
3231 * This is inspired by `lodash`'s `flow` function. |
|
3232 * |
|
3233 * @see https://lodash.com/docs/4#flow |
|
3234 */ |
|
3235 const pipe = basePipe(); |
|
3236 |
|
3237 /* harmony default export */ const higher_order_pipe = (pipe); |
2156 |
3238 |
2157 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js |
3239 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js |
2158 /** |
3240 /** |
2159 * External dependencies |
3241 * Internal dependencies |
2160 */ |
3242 */ |
|
3243 |
2161 |
3244 |
2162 /** |
3245 /** |
2163 * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function |
3246 * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function |
2164 * composition, where each successive invocation is supplied the return value of the previous. |
3247 * composition, where each successive invocation is supplied the return value of the previous. |
2165 * |
3248 * |
2166 * This is just a re-export of `lodash`'s `flowRight` function. |
3249 * This is inspired by `lodash`'s `flowRight` function. |
2167 * |
3250 * |
2168 * @see https://docs-lodash.com/v4/flow-right/ |
3251 * @see https://lodash.com/docs/4#flow-right |
2169 */ |
3252 */ |
2170 |
3253 const compose = basePipe(true); |
2171 /* harmony default export */ var compose = (external_lodash_namespaceObject.flowRight); |
3254 /* harmony default export */ const higher_order_compose = (compose); |
2172 |
3255 |
2173 ;// CONCATENATED MODULE: external ["wp","element"] |
3256 ;// CONCATENATED MODULE: external "ReactJSXRuntime" |
2174 var external_wp_element_namespaceObject = window["wp"]["element"]; |
3257 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
2175 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js |
3258 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js |
2176 |
3259 /** |
|
3260 * External dependencies |
|
3261 */ |
2177 |
3262 |
2178 /** |
3263 /** |
2179 * Internal dependencies |
3264 * Internal dependencies |
2180 */ |
3265 */ |
|
3266 |
2181 |
3267 |
2182 /** |
3268 /** |
2183 * Higher-order component creator, creating a new component which renders if |
3269 * Higher-order component creator, creating a new component which renders if |
2184 * the given condition is satisfied or with the given optional prop name. |
3270 * the given condition is satisfied or with the given optional prop name. |
2185 * |
3271 * |
3020 * </div> |
4056 * </div> |
3021 * ); |
4057 * ); |
3022 * } |
4058 * } |
3023 * ``` |
4059 * ``` |
3024 */ |
4060 */ |
3025 |
|
3026 function useFocusReturn(onFocusReturn) { |
4061 function useFocusReturn(onFocusReturn) { |
3027 /** @type {import('react').MutableRefObject<null | HTMLElement>} */ |
4062 /** @type {import('react').MutableRefObject<null | HTMLElement>} */ |
3028 const ref = (0,external_wp_element_namespaceObject.useRef)(null); |
4063 const ref = (0,external_wp_element_namespaceObject.useRef)(null); |
3029 /** @type {import('react').MutableRefObject<null | Element>} */ |
4064 /** @type {import('react').MutableRefObject<null | Element>} */ |
3030 |
|
3031 const focusedBeforeMount = (0,external_wp_element_namespaceObject.useRef)(null); |
4065 const focusedBeforeMount = (0,external_wp_element_namespaceObject.useRef)(null); |
3032 const onFocusReturnRef = (0,external_wp_element_namespaceObject.useRef)(onFocusReturn); |
4066 const onFocusReturnRef = (0,external_wp_element_namespaceObject.useRef)(onFocusReturn); |
3033 (0,external_wp_element_namespaceObject.useEffect)(() => { |
4067 (0,external_wp_element_namespaceObject.useEffect)(() => { |
3034 onFocusReturnRef.current = onFocusReturn; |
4068 onFocusReturnRef.current = onFocusReturn; |
3035 }, [onFocusReturn]); |
4069 }, [onFocusReturn]); |
3036 return (0,external_wp_element_namespaceObject.useCallback)(node => { |
4070 return (0,external_wp_element_namespaceObject.useCallback)(node => { |
3037 if (node) { |
4071 if (node) { |
3038 // Set ref to be used when unmounting. |
4072 // Set ref to be used when unmounting. |
3039 ref.current = node; // Only set when the node mounts. |
4073 ref.current = node; |
3040 |
4074 |
|
4075 // Only set when the node mounts. |
3041 if (focusedBeforeMount.current) { |
4076 if (focusedBeforeMount.current) { |
3042 return; |
4077 return; |
3043 } |
4078 } |
3044 |
|
3045 focusedBeforeMount.current = node.ownerDocument.activeElement; |
4079 focusedBeforeMount.current = node.ownerDocument.activeElement; |
3046 } else if (focusedBeforeMount.current) { |
4080 } else if (focusedBeforeMount.current) { |
3047 var _ref$current, _ref$current2, _ref$current3; |
4081 const isFocused = ref.current?.contains(ref.current?.ownerDocument.activeElement); |
3048 |
4082 if (ref.current?.isConnected && !isFocused) { |
3049 const isFocused = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains((_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.ownerDocument.activeElement); |
4083 var _origin; |
3050 |
4084 (_origin = origin) !== null && _origin !== void 0 ? _origin : origin = focusedBeforeMount.current; |
3051 if ((_ref$current3 = ref.current) !== null && _ref$current3 !== void 0 && _ref$current3.isConnected && !isFocused) { |
|
3052 return; |
4085 return; |
3053 } // Defer to the component's own explicit focus return behavior, if |
4086 } |
|
4087 |
|
4088 // Defer to the component's own explicit focus return behavior, if |
3054 // specified. This allows for support that the `onFocusReturn` |
4089 // specified. This allows for support that the `onFocusReturn` |
3055 // decides to allow the default behavior to occur under some |
4090 // decides to allow the default behavior to occur under some |
3056 // conditions. |
4091 // conditions. |
3057 |
|
3058 |
|
3059 if (onFocusReturnRef.current) { |
4092 if (onFocusReturnRef.current) { |
3060 onFocusReturnRef.current(); |
4093 onFocusReturnRef.current(); |
3061 } else { |
4094 } else { |
3062 var _focusedBeforeMount$c; |
4095 /** @type {null|HTMLElement} */(!focusedBeforeMount.current.isConnected ? origin : focusedBeforeMount.current)?.focus(); |
3063 |
4096 } |
3064 /** @type {null | HTMLElement} */ |
4097 origin = null; |
3065 (_focusedBeforeMount$c = focusedBeforeMount.current) === null || _focusedBeforeMount$c === void 0 ? void 0 : _focusedBeforeMount$c.focus(); |
|
3066 } |
|
3067 } |
4098 } |
3068 }, []); |
4099 }, []); |
3069 } |
4100 } |
3070 |
4101 /* harmony default export */ const use_focus_return = (useFocusReturn); |
3071 /* harmony default export */ var use_focus_return = (useFocusReturn); |
|
3072 |
4102 |
3073 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js |
4103 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js |
3074 /** |
|
3075 * External dependencies |
|
3076 */ |
|
3077 |
|
3078 /** |
4104 /** |
3079 * WordPress dependencies |
4105 * WordPress dependencies |
3080 */ |
4106 */ |
3081 |
4107 |
3082 |
4108 |
3083 /** |
4109 /** |
3084 * Input types which are classified as button types, for use in considering |
4110 * Input types which are classified as button types, for use in considering |
3085 * whether element is a (focus-normalized) button. |
4111 * whether element is a (focus-normalized) button. |
3086 * |
4112 */ |
3087 * @type {string[]} |
|
3088 */ |
|
3089 |
|
3090 const INPUT_BUTTON_TYPES = ['button', 'submit']; |
4113 const INPUT_BUTTON_TYPES = ['button', 'submit']; |
3091 /** |
4114 |
3092 * @typedef {HTMLButtonElement | HTMLLinkElement | HTMLInputElement} FocusNormalizedButton |
4115 /** |
3093 */ |
4116 * List of HTML button elements subject to focus normalization |
3094 // Disable reason: Rule doesn't support predicate return types. |
4117 * |
3095 |
4118 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus |
3096 /* eslint-disable jsdoc/valid-types */ |
4119 */ |
3097 |
4120 |
3098 /** |
4121 /** |
3099 * Returns true if the given element is a button element subject to focus |
4122 * Returns true if the given element is a button element subject to focus |
3100 * normalization, or false otherwise. |
4123 * normalization, or false otherwise. |
3101 * |
4124 * |
3102 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus |
4125 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus |
3103 * |
4126 * |
3104 * @param {EventTarget} eventTarget The target from a mouse or touch event. |
4127 * @param eventTarget The target from a mouse or touch event. |
3105 * |
4128 * |
3106 * @return {eventTarget is FocusNormalizedButton} Whether element is a button. |
4129 * @return Whether the element is a button element subject to focus normalization. |
3107 */ |
4130 */ |
3108 |
|
3109 function isFocusNormalizedButton(eventTarget) { |
4131 function isFocusNormalizedButton(eventTarget) { |
3110 if (!(eventTarget instanceof window.HTMLElement)) { |
4132 if (!(eventTarget instanceof window.HTMLElement)) { |
3111 return false; |
4133 return false; |
3112 } |
4134 } |
3113 |
|
3114 switch (eventTarget.nodeName) { |
4135 switch (eventTarget.nodeName) { |
3115 case 'A': |
4136 case 'A': |
3116 case 'BUTTON': |
4137 case 'BUTTON': |
3117 return true; |
4138 return true; |
3118 |
|
3119 case 'INPUT': |
4139 case 'INPUT': |
3120 return (0,external_lodash_namespaceObject.includes)(INPUT_BUTTON_TYPES, |
4140 return INPUT_BUTTON_TYPES.includes(eventTarget.type); |
3121 /** @type {HTMLInputElement} */ |
|
3122 eventTarget.type); |
|
3123 } |
4141 } |
3124 |
|
3125 return false; |
4142 return false; |
3126 } |
4143 } |
3127 /* eslint-enable jsdoc/valid-types */ |
|
3128 |
|
3129 /** |
|
3130 * @typedef {import('react').SyntheticEvent} SyntheticEvent |
|
3131 */ |
|
3132 |
|
3133 /** |
|
3134 * @callback EventCallback |
|
3135 * @param {SyntheticEvent} event input related event. |
|
3136 */ |
|
3137 |
|
3138 /** |
|
3139 * @typedef FocusOutsideReactElement |
|
3140 * @property {EventCallback} handleFocusOutside callback for a focus outside event. |
|
3141 */ |
|
3142 |
|
3143 /** |
|
3144 * @typedef {import('react').MutableRefObject<FocusOutsideReactElement | undefined>} FocusOutsideRef |
|
3145 */ |
|
3146 |
|
3147 /** |
|
3148 * @typedef {Object} FocusOutsideReturnValue |
|
3149 * @property {EventCallback} onFocus An event handler for focus events. |
|
3150 * @property {EventCallback} onBlur An event handler for blur events. |
|
3151 * @property {EventCallback} onMouseDown An event handler for mouse down events. |
|
3152 * @property {EventCallback} onMouseUp An event handler for mouse up events. |
|
3153 * @property {EventCallback} onTouchStart An event handler for touch start events. |
|
3154 * @property {EventCallback} onTouchEnd An event handler for touch end events. |
|
3155 */ |
|
3156 |
|
3157 /** |
4144 /** |
3158 * A react hook that can be used to check whether focus has moved outside the |
4145 * A react hook that can be used to check whether focus has moved outside the |
3159 * element the event handlers are bound to. |
4146 * element the event handlers are bound to. |
3160 * |
4147 * |
3161 * @param {EventCallback} onFocusOutside A callback triggered when focus moves outside |
4148 * @param onFocusOutside A callback triggered when focus moves outside |
3162 * the element the event handlers are bound to. |
4149 * the element the event handlers are bound to. |
3163 * |
4150 * |
3164 * @return {FocusOutsideReturnValue} An object containing event handlers. Bind the event handlers |
4151 * @return An object containing event handlers. Bind the event handlers to a |
3165 * to a wrapping element element to capture when focus moves |
4152 * wrapping element element to capture when focus moves outside that element. |
3166 * outside that element. |
4153 */ |
3167 */ |
|
3168 |
|
3169 |
|
3170 function useFocusOutside(onFocusOutside) { |
4154 function useFocusOutside(onFocusOutside) { |
3171 const currentOnFocusOutside = (0,external_wp_element_namespaceObject.useRef)(onFocusOutside); |
4155 const currentOnFocusOutside = (0,external_wp_element_namespaceObject.useRef)(onFocusOutside); |
3172 (0,external_wp_element_namespaceObject.useEffect)(() => { |
4156 (0,external_wp_element_namespaceObject.useEffect)(() => { |
3173 currentOnFocusOutside.current = onFocusOutside; |
4157 currentOnFocusOutside.current = onFocusOutside; |
3174 }, [onFocusOutside]); |
4158 }, [onFocusOutside]); |
3175 const preventBlurCheck = (0,external_wp_element_namespaceObject.useRef)(false); |
4159 const preventBlurCheck = (0,external_wp_element_namespaceObject.useRef)(false); |
3176 /** |
|
3177 * @type {import('react').MutableRefObject<number | undefined>} |
|
3178 */ |
|
3179 |
|
3180 const blurCheckTimeoutId = (0,external_wp_element_namespaceObject.useRef)(); |
4160 const blurCheckTimeoutId = (0,external_wp_element_namespaceObject.useRef)(); |
|
4161 |
3181 /** |
4162 /** |
3182 * Cancel a blur check timeout. |
4163 * Cancel a blur check timeout. |
3183 */ |
4164 */ |
3184 |
|
3185 const cancelBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(() => { |
4165 const cancelBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(() => { |
3186 clearTimeout(blurCheckTimeoutId.current); |
4166 clearTimeout(blurCheckTimeoutId.current); |
3187 }, []); // Cancel blur checks on unmount. |
4167 }, []); |
3188 |
4168 |
|
4169 // Cancel blur checks on unmount. |
3189 (0,external_wp_element_namespaceObject.useEffect)(() => { |
4170 (0,external_wp_element_namespaceObject.useEffect)(() => { |
3190 return () => cancelBlurCheck(); |
4171 return () => cancelBlurCheck(); |
3191 }, []); // Cancel a blur check if the callback or ref is no longer provided. |
4172 }, []); |
3192 |
4173 |
|
4174 // Cancel a blur check if the callback or ref is no longer provided. |
3193 (0,external_wp_element_namespaceObject.useEffect)(() => { |
4175 (0,external_wp_element_namespaceObject.useEffect)(() => { |
3194 if (!onFocusOutside) { |
4176 if (!onFocusOutside) { |
3195 cancelBlurCheck(); |
4177 cancelBlurCheck(); |
3196 } |
4178 } |
3197 }, [onFocusOutside, cancelBlurCheck]); |
4179 }, [onFocusOutside, cancelBlurCheck]); |
|
4180 |
3198 /** |
4181 /** |
3199 * Handles a mousedown or mouseup event to respectively assign and |
4182 * Handles a mousedown or mouseup event to respectively assign and |
3200 * unassign a flag for preventing blur check on button elements. Some |
4183 * unassign a flag for preventing blur check on button elements. Some |
3201 * browsers, namely Firefox and Safari, do not emit a focus event on |
4184 * browsers, namely Firefox and Safari, do not emit a focus event on |
3202 * button elements when clicked, while others do. The logic here |
4185 * button elements when clicked, while others do. The logic here |
3203 * intends to normalize this as treating click on buttons as focus. |
4186 * intends to normalize this as treating click on buttons as focus. |
3204 * |
4187 * |
|
4188 * @param event |
3205 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus |
4189 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus |
3206 * |
|
3207 * @param {SyntheticEvent} event Event for mousedown or mouseup. |
|
3208 */ |
4190 */ |
3209 |
|
3210 const normalizeButtonFocus = (0,external_wp_element_namespaceObject.useCallback)(event => { |
4191 const normalizeButtonFocus = (0,external_wp_element_namespaceObject.useCallback)(event => { |
3211 const { |
4192 const { |
3212 type, |
4193 type, |
3213 target |
4194 target |
3214 } = event; |
4195 } = event; |
3215 const isInteractionEnd = (0,external_lodash_namespaceObject.includes)(['mouseup', 'touchend'], type); |
4196 const isInteractionEnd = ['mouseup', 'touchend'].includes(type); |
3216 |
|
3217 if (isInteractionEnd) { |
4197 if (isInteractionEnd) { |
3218 preventBlurCheck.current = false; |
4198 preventBlurCheck.current = false; |
3219 } else if (isFocusNormalizedButton(target)) { |
4199 } else if (isFocusNormalizedButton(target)) { |
3220 preventBlurCheck.current = true; |
4200 preventBlurCheck.current = true; |
3221 } |
4201 } |
3222 }, []); |
4202 }, []); |
|
4203 |
3223 /** |
4204 /** |
3224 * A callback triggered when a blur event occurs on the element the handler |
4205 * A callback triggered when a blur event occurs on the element the handler |
3225 * is bound to. |
4206 * is bound to. |
3226 * |
4207 * |
3227 * Calls the `onFocusOutside` callback in an immediate timeout if focus has |
4208 * Calls the `onFocusOutside` callback in an immediate timeout if focus has |
3228 * move outside the bound element and is still within the document. |
4209 * move outside the bound element and is still within the document. |
3229 * |
|
3230 * @param {SyntheticEvent} event Blur event. |
|
3231 */ |
4210 */ |
3232 |
|
3233 const queueBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(event => { |
4211 const queueBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(event => { |
3234 // React does not allow using an event reference asynchronously |
4212 // React does not allow using an event reference asynchronously |
3235 // due to recycling behavior, except when explicitly persisted. |
4213 // due to recycling behavior, except when explicitly persisted. |
3236 event.persist(); // Skip blur check if clicking button. See `normalizeButtonFocus`. |
4214 event.persist(); |
3237 |
4215 |
|
4216 // Skip blur check if clicking button. See `normalizeButtonFocus`. |
3238 if (preventBlurCheck.current) { |
4217 if (preventBlurCheck.current) { |
3239 return; |
4218 return; |
3240 } |
4219 } |
3241 |
4220 |
|
4221 // The usage of this attribute should be avoided. The only use case |
|
4222 // would be when we load modals that are not React components and |
|
4223 // therefore don't exist in the React tree. An example is opening |
|
4224 // the Media Library modal from another dialog. |
|
4225 // This attribute should contain a selector of the related target |
|
4226 // we want to ignore, because we still need to trigger the blur event |
|
4227 // on all other cases. |
|
4228 const ignoreForRelatedTarget = event.target.getAttribute('data-unstable-ignore-focus-outside-for-relatedtarget'); |
|
4229 if (ignoreForRelatedTarget && event.relatedTarget?.closest(ignoreForRelatedTarget)) { |
|
4230 return; |
|
4231 } |
3242 blurCheckTimeoutId.current = setTimeout(() => { |
4232 blurCheckTimeoutId.current = setTimeout(() => { |
3243 // If document is not focused then focus should remain |
4233 // If document is not focused then focus should remain |
3244 // inside the wrapped component and therefore we cancel |
4234 // inside the wrapped component and therefore we cancel |
3245 // this blur event thereby leaving focus in place. |
4235 // this blur event thereby leaving focus in place. |
3246 // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus. |
4236 // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus. |
3247 if (!document.hasFocus()) { |
4237 if (!document.hasFocus()) { |
3248 event.preventDefault(); |
4238 event.preventDefault(); |
3249 return; |
4239 return; |
3250 } |
4240 } |
3251 |
|
3252 if ('function' === typeof currentOnFocusOutside.current) { |
4241 if ('function' === typeof currentOnFocusOutside.current) { |
3253 currentOnFocusOutside.current(event); |
4242 currentOnFocusOutside.current(event); |
3254 } |
4243 } |
3255 }, 0); |
4244 }, 0); |
3256 }, []); |
4245 }, []); |
3336 * @template {import('react').Ref<any>} TRef |
4322 * @template {import('react').Ref<any>} TRef |
3337 * @param {Array<TRef>} refs The refs to be merged. |
4323 * @param {Array<TRef>} refs The refs to be merged. |
3338 * |
4324 * |
3339 * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback. |
4325 * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback. |
3340 */ |
4326 */ |
3341 |
|
3342 |
|
3343 function useMergeRefs(refs) { |
4327 function useMergeRefs(refs) { |
3344 const element = (0,external_wp_element_namespaceObject.useRef)(); |
4328 const element = (0,external_wp_element_namespaceObject.useRef)(); |
|
4329 const isAttached = (0,external_wp_element_namespaceObject.useRef)(false); |
3345 const didElementChange = (0,external_wp_element_namespaceObject.useRef)(false); |
4330 const didElementChange = (0,external_wp_element_namespaceObject.useRef)(false); |
3346 /* eslint-disable jsdoc/no-undefined-types */ |
4331 /* eslint-disable jsdoc/no-undefined-types */ |
3347 |
|
3348 /** @type {import('react').MutableRefObject<TRef[]>} */ |
4332 /** @type {import('react').MutableRefObject<TRef[]>} */ |
3349 |
|
3350 /* eslint-enable jsdoc/no-undefined-types */ |
4333 /* eslint-enable jsdoc/no-undefined-types */ |
3351 |
|
3352 const previousRefs = (0,external_wp_element_namespaceObject.useRef)([]); |
4334 const previousRefs = (0,external_wp_element_namespaceObject.useRef)([]); |
3353 const currentRefs = (0,external_wp_element_namespaceObject.useRef)(refs); // Update on render before the ref callback is called, so the ref callback |
4335 const currentRefs = (0,external_wp_element_namespaceObject.useRef)(refs); |
|
4336 |
|
4337 // Update on render before the ref callback is called, so the ref callback |
3354 // always has access to the current refs. |
4338 // always has access to the current refs. |
3355 |
4339 currentRefs.current = refs; |
3356 currentRefs.current = refs; // If any of the refs change, call the previous ref with `null` and the new |
4340 |
|
4341 // If any of the refs change, call the previous ref with `null` and the new |
3357 // ref with the node, except when the element changes in the same cycle, in |
4342 // ref with the node, except when the element changes in the same cycle, in |
3358 // which case the ref callbacks will already have been called. |
4343 // which case the ref callbacks will already have been called. |
3359 |
|
3360 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
4344 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
3361 if (didElementChange.current === false) { |
4345 if (didElementChange.current === false && isAttached.current === true) { |
3362 refs.forEach((ref, index) => { |
4346 refs.forEach((ref, index) => { |
3363 const previousRef = previousRefs.current[index]; |
4347 const previousRef = previousRefs.current[index]; |
3364 |
|
3365 if (ref !== previousRef) { |
4348 if (ref !== previousRef) { |
3366 assignRef(previousRef, null); |
4349 assignRef(previousRef, null); |
3367 assignRef(ref, element.current); |
4350 assignRef(ref, element.current); |
3368 } |
4351 } |
3369 }); |
4352 }); |
3370 } |
4353 } |
3371 |
|
3372 previousRefs.current = refs; |
4354 previousRefs.current = refs; |
3373 }, refs); // No dependencies, must be reset after every render so ref callbacks are |
4355 }, refs); |
|
4356 |
|
4357 // No dependencies, must be reset after every render so ref callbacks are |
3374 // correctly called after a ref change. |
4358 // correctly called after a ref change. |
3375 |
|
3376 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
4359 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
3377 didElementChange.current = false; |
4360 didElementChange.current = false; |
3378 }); // There should be no dependencies so that `callback` is only called when |
4361 }); |
|
4362 |
|
4363 // There should be no dependencies so that `callback` is only called when |
3379 // the node changes. |
4364 // the node changes. |
3380 |
|
3381 return (0,external_wp_element_namespaceObject.useCallback)(value => { |
4365 return (0,external_wp_element_namespaceObject.useCallback)(value => { |
3382 // Update the element so it can be used when calling ref callbacks on a |
4366 // Update the element so it can be used when calling ref callbacks on a |
3383 // dependency change. |
4367 // dependency change. |
3384 assignRef(element, value); |
4368 assignRef(element, value); |
3385 didElementChange.current = true; // When an element changes, the current ref callback should be called |
4369 didElementChange.current = true; |
|
4370 isAttached.current = value !== null; |
|
4371 |
|
4372 // When an element changes, the current ref callback should be called |
3386 // with the new element and the previous one with `null`. |
4373 // with the new element and the previous one with `null`. |
3387 |
4374 const refsToAssign = value ? currentRefs.current : previousRefs.current; |
3388 const refsToAssign = value ? currentRefs.current : previousRefs.current; // Update the latest refs. |
4375 |
3389 |
4376 // Update the latest refs. |
3390 for (const ref of refsToAssign) { |
4377 for (const ref of refsToAssign) { |
3391 assignRef(ref, value); |
4378 assignRef(ref, value); |
3392 } |
4379 } |
3393 }, []); |
4380 }, []); |
3394 } |
4381 } |
3395 |
4382 |
3396 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js |
4383 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js |
3397 /** |
4384 /** |
|
4385 * External dependencies |
|
4386 */ |
|
4387 |
|
4388 /** |
3398 * WordPress dependencies |
4389 * WordPress dependencies |
3399 */ |
4390 */ |
3400 |
4391 |
3401 |
4392 |
|
4393 |
3402 /** |
4394 /** |
3403 * Internal dependencies |
4395 * Internal dependencies |
3404 */ |
4396 */ |
3405 |
4397 |
3406 |
4398 |
3407 |
4399 |
3408 |
4400 |
3409 |
|
3410 |
|
3411 /* eslint-disable jsdoc/valid-types */ |
|
3412 |
|
3413 /** |
|
3414 * @typedef DialogOptions |
|
3415 * @property {Parameters<useFocusOnMount>[0]} focusOnMount Focus on mount arguments. |
|
3416 * @property {() => void} onClose Function to call when the dialog is closed. |
|
3417 */ |
|
3418 |
|
3419 /* eslint-enable jsdoc/valid-types */ |
|
3420 |
4401 |
3421 /** |
4402 /** |
3422 * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors: |
4403 * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors: |
3423 * - constrained tabbing. |
4404 * - constrained tabbing. |
3424 * - focus on mount. |
4405 * - focus on mount. |
3425 * - return focus on unmount. |
4406 * - return focus on unmount. |
3426 * - focus outside. |
4407 * - focus outside. |
3427 * |
4408 * |
3428 * @param {DialogOptions} options Dialog Options. |
4409 * @param options Dialog Options. |
3429 */ |
4410 */ |
3430 |
|
3431 function useDialog(options) { |
4411 function useDialog(options) { |
3432 /** |
|
3433 * @type {import('react').MutableRefObject<DialogOptions | undefined>} |
|
3434 */ |
|
3435 const currentOptions = (0,external_wp_element_namespaceObject.useRef)(); |
4412 const currentOptions = (0,external_wp_element_namespaceObject.useRef)(); |
|
4413 const { |
|
4414 constrainTabbing = options.focusOnMount !== false |
|
4415 } = options; |
3436 (0,external_wp_element_namespaceObject.useEffect)(() => { |
4416 (0,external_wp_element_namespaceObject.useEffect)(() => { |
3437 currentOptions.current = options; |
4417 currentOptions.current = options; |
3438 }, Object.values(options)); |
4418 }, Object.values(options)); |
3439 const constrainedTabbingRef = use_constrained_tabbing(); |
4419 const constrainedTabbingRef = use_constrained_tabbing(); |
3440 const focusOnMountRef = useFocusOnMount(options.focusOnMount); |
4420 const focusOnMountRef = useFocusOnMount(options.focusOnMount); |
3441 const focusReturnRef = use_focus_return(); |
4421 const focusReturnRef = use_focus_return(); |
3442 const focusOutsideProps = useFocusOutside(event => { |
4422 const focusOutsideProps = useFocusOutside(event => { |
3443 var _currentOptions$curre, _currentOptions$curre2; |
|
3444 |
|
3445 // This unstable prop is here only to manage backward compatibility |
4423 // This unstable prop is here only to manage backward compatibility |
3446 // for the Popover component otherwise, the onClose should be enough. |
4424 // for the Popover component otherwise, the onClose should be enough. |
3447 // @ts-ignore unstable property |
4425 if (currentOptions.current?.__unstableOnClose) { |
3448 if ((_currentOptions$curre = currentOptions.current) !== null && _currentOptions$curre !== void 0 && _currentOptions$curre.__unstableOnClose) { |
|
3449 // @ts-ignore unstable property |
|
3450 currentOptions.current.__unstableOnClose('focus-outside', event); |
4426 currentOptions.current.__unstableOnClose('focus-outside', event); |
3451 } else if ((_currentOptions$curre2 = currentOptions.current) !== null && _currentOptions$curre2 !== void 0 && _currentOptions$curre2.onClose) { |
4427 } else if (currentOptions.current?.onClose) { |
3452 currentOptions.current.onClose(); |
4428 currentOptions.current.onClose(); |
3453 } |
4429 } |
3454 }); |
4430 }); |
3455 const closeOnEscapeRef = (0,external_wp_element_namespaceObject.useCallback)(node => { |
4431 const closeOnEscapeRef = (0,external_wp_element_namespaceObject.useCallback)(node => { |
3456 if (!node) { |
4432 if (!node) { |
3457 return; |
4433 return; |
3458 } |
4434 } |
3459 |
4435 node.addEventListener('keydown', event => { |
3460 node.addEventListener('keydown', ( |
|
3461 /** @type {KeyboardEvent} */ |
|
3462 event) => { |
|
3463 var _currentOptions$curre3; |
|
3464 |
|
3465 // Close on escape. |
4436 // Close on escape. |
3466 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented && (_currentOptions$curre3 = currentOptions.current) !== null && _currentOptions$curre3 !== void 0 && _currentOptions$curre3.onClose) { |
4437 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) { |
3467 event.preventDefault(); |
4438 event.preventDefault(); |
3468 currentOptions.current.onClose(); |
4439 currentOptions.current.onClose(); |
3469 } |
4440 } |
3470 }); |
4441 }); |
3471 }, []); |
4442 }, []); |
3472 return [useMergeRefs([options.focusOnMount !== false ? constrainedTabbingRef : null, options.focusOnMount !== false ? focusReturnRef : null, options.focusOnMount !== false ? focusOnMountRef : null, closeOnEscapeRef]), { ...focusOutsideProps, |
4443 return [useMergeRefs([constrainTabbing ? constrainedTabbingRef : null, options.focusOnMount !== false ? focusReturnRef : null, options.focusOnMount !== false ? focusOnMountRef : null, closeOnEscapeRef]), { |
3473 tabIndex: '-1' |
4444 ...focusOutsideProps, |
|
4445 tabIndex: -1 |
3474 }]; |
4446 }]; |
3475 } |
4447 } |
3476 |
4448 /* harmony default export */ const use_dialog = (useDialog); |
3477 /* harmony default export */ var use_dialog = (useDialog); |
|
3478 |
4449 |
3479 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-disabled/index.js |
4450 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-disabled/index.js |
3480 /** |
4451 /** |
3481 * External dependencies |
4452 * Internal dependencies |
3482 */ |
4453 */ |
3483 |
4454 |
3484 /** |
4455 |
3485 * WordPress dependencies |
4456 |
3486 */ |
|
3487 |
|
3488 |
|
3489 |
|
3490 /** |
|
3491 * Names of control nodes which qualify for disabled behavior. |
|
3492 * |
|
3493 * See WHATWG HTML Standard: 4.10.18.5: "Enabling and disabling form controls: the disabled attribute". |
|
3494 * |
|
3495 * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute |
|
3496 * |
|
3497 * @type {string[]} |
|
3498 */ |
|
3499 |
|
3500 const DISABLED_ELIGIBLE_NODE_NAMES = ['BUTTON', 'FIELDSET', 'INPUT', 'OPTGROUP', 'OPTION', 'SELECT', 'TEXTAREA']; |
|
3501 /** |
4457 /** |
3502 * In some circumstances, such as block previews, all focusable DOM elements |
4458 * In some circumstances, such as block previews, all focusable DOM elements |
3503 * (input fields, links, buttons, etc.) need to be disabled. This hook adds the |
4459 * (input fields, links, buttons, etc.) need to be disabled. This hook adds the |
3504 * behavior to disable nested DOM elements to the returned ref. |
4460 * behavior to disable nested DOM elements to the returned ref. |
3505 * |
4461 * |
3506 * @return {import('react').RefObject<HTMLElement>} Element Ref. |
4462 * If you can, prefer the use of the inert HTML attribute. |
|
4463 * |
|
4464 * @param {Object} config Configuration object. |
|
4465 * @param {boolean=} config.isDisabled Whether the element should be disabled. |
|
4466 * @return {import('react').RefCallback<HTMLElement>} Element Ref. |
3507 * |
4467 * |
3508 * @example |
4468 * @example |
3509 * ```js |
4469 * ```js |
3510 * import { __experimentalUseDisabled as useDisabled } from '@wordpress/compose'; |
4470 * import { useDisabled } from '@wordpress/compose'; |
|
4471 * |
3511 * const DisabledExample = () => { |
4472 * const DisabledExample = () => { |
3512 * const disabledRef = useDisabled(); |
4473 * const disabledRef = useDisabled(); |
3513 * return ( |
4474 * return ( |
3514 * <div ref={ disabledRef }> |
4475 * <div ref={ disabledRef }> |
3515 * <a href="#">This link will have tabindex set to -1</a> |
4476 * <a href="#">This link will have tabindex set to -1</a> |
3696 * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown. |
4644 * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown. |
3697 * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true. |
4645 * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true. |
3698 * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event. |
4646 * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event. |
3699 */ |
4647 */ |
3700 |
4648 |
3701 /** |
|
3702 * Return true if platform is MacOS. |
|
3703 * |
|
3704 * @param {Window} [_window] window object by default; used for DI testing. |
|
3705 * |
|
3706 * @return {boolean} True if MacOS; false otherwise. |
|
3707 */ |
|
3708 |
|
3709 function isAppleOS() { |
|
3710 let _window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window; |
|
3711 |
|
3712 const { |
|
3713 platform |
|
3714 } = _window.navigator; |
|
3715 return platform.indexOf('Mac') !== -1 || (0,external_lodash_namespaceObject.includes)(['iPad', 'iPhone'], platform); |
|
3716 } |
|
3717 /* eslint-disable jsdoc/valid-types */ |
4649 /* eslint-disable jsdoc/valid-types */ |
3718 |
|
3719 /** |
4650 /** |
3720 * Attach a keyboard shortcut handler. |
4651 * Attach a keyboard shortcut handler. |
3721 * |
4652 * |
3722 * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter. |
4653 * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter. |
3723 * |
4654 * |
3724 * @param {string[]|string} shortcuts Keyboard Shortcuts. |
4655 * @param {string[]|string} shortcuts Keyboard Shortcuts. |
3725 * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback. |
4656 * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback. |
3726 * @param {WPKeyboardShortcutConfig} options Shortcut options. |
4657 * @param {WPKeyboardShortcutConfig} options Shortcut options. |
3727 */ |
4658 */ |
3728 |
4659 function useKeyboardShortcut( /* eslint-enable jsdoc/valid-types */ |
3729 |
4660 shortcuts, callback, { |
3730 function useKeyboardShortcut( |
4661 bindGlobal = false, |
3731 /* eslint-enable jsdoc/valid-types */ |
4662 eventName = 'keydown', |
3732 shortcuts, callback) { |
4663 isDisabled = false, |
3733 let { |
4664 // This is important for performance considerations. |
3734 bindGlobal = false, |
4665 target |
3735 eventName = 'keydown', |
4666 } = {}) { |
3736 isDisabled = false, |
|
3737 // This is important for performance considerations. |
|
3738 target |
|
3739 } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
3740 const currentCallback = (0,external_wp_element_namespaceObject.useRef)(callback); |
4667 const currentCallback = (0,external_wp_element_namespaceObject.useRef)(callback); |
3741 (0,external_wp_element_namespaceObject.useEffect)(() => { |
4668 (0,external_wp_element_namespaceObject.useEffect)(() => { |
3742 currentCallback.current = callback; |
4669 currentCallback.current = callback; |
3743 }, [callback]); |
4670 }, [callback]); |
3744 (0,external_wp_element_namespaceObject.useEffect)(() => { |
4671 (0,external_wp_element_namespaceObject.useEffect)(() => { |
3745 if (isDisabled) { |
4672 if (isDisabled) { |
3746 return; |
4673 return; |
3747 } |
4674 } |
3748 |
4675 const mousetrap = new (mousetrap_default())(target && target.current ? target.current : |
3749 const mousetrap = new (mousetrap_default())(target && target.current ? target.current : // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`. |
4676 // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`. |
3750 // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's |
4677 // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's |
3751 // necessary to maintain the existing behavior. |
4678 // necessary to maintain the existing behavior. |
3752 |
4679 /** @type {Element} */ /** @type {unknown} */ |
3753 /** @type {Element} */ |
|
3754 |
|
3755 /** @type {unknown} */ |
|
3756 document); |
4680 document); |
3757 (0,external_lodash_namespaceObject.castArray)(shortcuts).forEach(shortcut => { |
4681 const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts]; |
3758 const keys = shortcut.split('+'); // Determines whether a key is a modifier by the length of the string. |
4682 shortcutsArray.forEach(shortcut => { |
|
4683 const keys = shortcut.split('+'); |
|
4684 // Determines whether a key is a modifier by the length of the string. |
3759 // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that |
4685 // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that |
3760 // the modifiers are Shift and Cmd because they're not a single character. |
4686 // the modifiers are Shift and Cmd because they're not a single character. |
3761 |
|
3762 const modifiers = new Set(keys.filter(value => value.length > 1)); |
4687 const modifiers = new Set(keys.filter(value => value.length > 1)); |
3763 const hasAlt = modifiers.has('alt'); |
4688 const hasAlt = modifiers.has('alt'); |
3764 const hasShift = modifiers.has('shift'); // This should be better moved to the shortcut registration instead. |
4689 const hasShift = modifiers.has('shift'); |
3765 |
4690 |
3766 if (isAppleOS() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) { |
4691 // This should be better moved to the shortcut registration instead. |
|
4692 if ((0,external_wp_keycodes_namespaceObject.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) { |
3767 throw new Error(`Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`); |
4693 throw new Error(`Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`); |
3768 } |
4694 } |
3769 |
4695 const bindFn = bindGlobal ? 'bindGlobal' : 'bind'; |
3770 const bindFn = bindGlobal ? 'bindGlobal' : 'bind'; // @ts-ignore `bindGlobal` is an undocumented property |
4696 // @ts-ignore `bindGlobal` is an undocumented property |
3771 |
4697 mousetrap[bindFn](shortcut, ( /* eslint-disable jsdoc/valid-types */ |
3772 mousetrap[bindFn](shortcut, function () { |
4698 /** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */...args) => /* eslint-enable jsdoc/valid-types */ |
3773 return ( |
4699 currentCallback.current(...args), eventName); |
3774 /* eslint-enable jsdoc/valid-types */ |
|
3775 currentCallback.current(...arguments) |
|
3776 ); |
|
3777 }, eventName); |
|
3778 }); |
4700 }); |
3779 return () => { |
4701 return () => { |
3780 mousetrap.reset(); |
4702 mousetrap.reset(); |
3781 }; |
4703 }; |
3782 }, [shortcuts, bindGlobal, eventName, target, isDisabled]); |
4704 }, [shortcuts, bindGlobal, eventName, target, isDisabled]); |
3783 } |
4705 } |
3784 |
4706 /* harmony default export */ const use_keyboard_shortcut = (useKeyboardShortcut); |
3785 /* harmony default export */ var use_keyboard_shortcut = (useKeyboardShortcut); |
|
3786 |
4707 |
3787 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js |
4708 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js |
3788 /** |
4709 /** |
3789 * WordPress dependencies |
4710 * WordPress dependencies |
3790 */ |
4711 */ |
|
4712 |
|
4713 const matchMediaCache = new Map(); |
|
4714 |
|
4715 /** |
|
4716 * A new MediaQueryList object for the media query |
|
4717 * |
|
4718 * @param {string} [query] Media Query. |
|
4719 * @return {MediaQueryList|null} A new object for the media query |
|
4720 */ |
|
4721 function getMediaQueryList(query) { |
|
4722 if (!query) { |
|
4723 return null; |
|
4724 } |
|
4725 let match = matchMediaCache.get(query); |
|
4726 if (match) { |
|
4727 return match; |
|
4728 } |
|
4729 if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') { |
|
4730 match = window.matchMedia(query); |
|
4731 matchMediaCache.set(query, match); |
|
4732 return match; |
|
4733 } |
|
4734 return null; |
|
4735 } |
3791 |
4736 |
3792 /** |
4737 /** |
3793 * Runs a media query and returns its value when it changes. |
4738 * Runs a media query and returns its value when it changes. |
3794 * |
4739 * |
3795 * @param {string} [query] Media Query. |
4740 * @param {string} [query] Media Query. |
3796 * @return {boolean} return value of the media query. |
4741 * @return {boolean} return value of the media query. |
3797 */ |
4742 */ |
3798 |
|
3799 function useMediaQuery(query) { |
4743 function useMediaQuery(query) { |
3800 const [match, setMatch] = (0,external_wp_element_namespaceObject.useState)(() => !!(query && typeof window !== 'undefined' && window.matchMedia(query).matches)); |
4744 const source = (0,external_wp_element_namespaceObject.useMemo)(() => { |
3801 (0,external_wp_element_namespaceObject.useEffect)(() => { |
4745 const mediaQueryList = getMediaQueryList(query); |
3802 if (!query) { |
4746 return { |
3803 return; |
4747 /** @type {(onStoreChange: () => void) => () => void} */ |
3804 } |
4748 subscribe(onStoreChange) { |
3805 |
4749 if (!mediaQueryList) { |
3806 const updateMatch = () => setMatch(window.matchMedia(query).matches); |
4750 return () => {}; |
3807 |
4751 } |
3808 updateMatch(); |
4752 |
3809 const list = window.matchMedia(query); |
4753 // Avoid a fatal error when browsers don't support `addEventListener` on MediaQueryList. |
3810 list.addListener(updateMatch); |
4754 mediaQueryList.addEventListener?.('change', onStoreChange); |
3811 return () => { |
4755 return () => { |
3812 list.removeListener(updateMatch); |
4756 mediaQueryList.removeEventListener?.('change', onStoreChange); |
|
4757 }; |
|
4758 }, |
|
4759 getValue() { |
|
4760 var _mediaQueryList$match; |
|
4761 return (_mediaQueryList$match = mediaQueryList?.matches) !== null && _mediaQueryList$match !== void 0 ? _mediaQueryList$match : false; |
|
4762 } |
3813 }; |
4763 }; |
3814 }, [query]); |
4764 }, [query]); |
3815 return !!query && match; |
4765 return (0,external_wp_element_namespaceObject.useSyncExternalStore)(source.subscribe, source.getValue, () => false); |
3816 } |
4766 } |
3817 |
4767 |
3818 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js |
4768 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js |
3819 /** |
4769 /** |
3820 * WordPress dependencies |
4770 * WordPress dependencies |
3821 */ |
4771 */ |
|
4772 |
3822 |
4773 |
3823 /** |
4774 /** |
3824 * Use something's value from the previous render. |
4775 * Use something's value from the previous render. |
3825 * Based on https://usehooks.com/usePrevious/. |
4776 * Based on https://usehooks.com/usePrevious/. |
3826 * |
4777 * |
3827 * @param value The value to track. |
4778 * @param value The value to track. |
3828 * |
4779 * |
3829 * @return The value from the previous render. |
4780 * @return The value from the previous render. |
3830 */ |
4781 */ |
3831 |
|
3832 function usePrevious(value) { |
4782 function usePrevious(value) { |
3833 const ref = (0,external_wp_element_namespaceObject.useRef)(); // Store current value in ref. |
4783 const ref = (0,external_wp_element_namespaceObject.useRef)(); |
3834 |
4784 |
|
4785 // Store current value in ref. |
3835 (0,external_wp_element_namespaceObject.useEffect)(() => { |
4786 (0,external_wp_element_namespaceObject.useEffect)(() => { |
3836 ref.current = value; |
4787 ref.current = value; |
3837 }, [value]); // Re-run when value changes. |
4788 }, [value]); // Re-run when value changes. |
|
4789 |
3838 // Return previous value (happens before update in useEffect above). |
4790 // Return previous value (happens before update in useEffect above). |
3839 |
|
3840 return ref.current; |
4791 return ref.current; |
3841 } |
4792 } |
3842 |
4793 |
3843 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js |
4794 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js |
3844 /** |
4795 /** |
3845 * Internal dependencies |
4796 * Internal dependencies |
3846 */ |
4797 */ |
3847 |
4798 |
|
4799 |
3848 /** |
4800 /** |
3849 * Hook returning whether the user has a preference for reduced motion. |
4801 * Hook returning whether the user has a preference for reduced motion. |
3850 * |
4802 * |
3851 * @return {boolean} Reduced motion preference value. |
4803 * @return {boolean} Reduced motion preference value. |
3852 */ |
4804 */ |
3853 |
|
3854 const useReducedMotion = () => useMediaQuery('(prefers-reduced-motion: reduce)'); |
4805 const useReducedMotion = () => useMediaQuery('(prefers-reduced-motion: reduce)'); |
3855 |
4806 /* harmony default export */ const use_reduced_motion = (useReducedMotion); |
3856 /* harmony default export */ var use_reduced_motion = (useReducedMotion); |
4807 |
|
4808 // EXTERNAL MODULE: ./node_modules/@wordpress/undo-manager/build-module/index.js |
|
4809 var build_module = __webpack_require__(6689); |
|
4810 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-state-with-history/index.js |
|
4811 /** |
|
4812 * WordPress dependencies |
|
4813 */ |
|
4814 |
|
4815 |
|
4816 function undoRedoReducer(state, action) { |
|
4817 switch (action.type) { |
|
4818 case 'UNDO': |
|
4819 { |
|
4820 const undoRecord = state.manager.undo(); |
|
4821 if (undoRecord) { |
|
4822 return { |
|
4823 ...state, |
|
4824 value: undoRecord[0].changes.prop.from |
|
4825 }; |
|
4826 } |
|
4827 return state; |
|
4828 } |
|
4829 case 'REDO': |
|
4830 { |
|
4831 const redoRecord = state.manager.redo(); |
|
4832 if (redoRecord) { |
|
4833 return { |
|
4834 ...state, |
|
4835 value: redoRecord[0].changes.prop.to |
|
4836 }; |
|
4837 } |
|
4838 return state; |
|
4839 } |
|
4840 case 'RECORD': |
|
4841 { |
|
4842 state.manager.addRecord([{ |
|
4843 id: 'object', |
|
4844 changes: { |
|
4845 prop: { |
|
4846 from: state.value, |
|
4847 to: action.value |
|
4848 } |
|
4849 } |
|
4850 }], action.isStaged); |
|
4851 return { |
|
4852 ...state, |
|
4853 value: action.value |
|
4854 }; |
|
4855 } |
|
4856 } |
|
4857 return state; |
|
4858 } |
|
4859 function initReducer(value) { |
|
4860 return { |
|
4861 manager: (0,build_module.createUndoManager)(), |
|
4862 value |
|
4863 }; |
|
4864 } |
|
4865 |
|
4866 /** |
|
4867 * useState with undo/redo history. |
|
4868 * |
|
4869 * @param initialValue Initial value. |
|
4870 * @return Value, setValue, hasUndo, hasRedo, undo, redo. |
|
4871 */ |
|
4872 function useStateWithHistory(initialValue) { |
|
4873 const [state, dispatch] = (0,external_wp_element_namespaceObject.useReducer)(undoRedoReducer, initialValue, initReducer); |
|
4874 return { |
|
4875 value: state.value, |
|
4876 setValue: (0,external_wp_element_namespaceObject.useCallback)((newValue, isStaged) => { |
|
4877 dispatch({ |
|
4878 type: 'RECORD', |
|
4879 value: newValue, |
|
4880 isStaged |
|
4881 }); |
|
4882 }, []), |
|
4883 hasUndo: state.manager.hasUndo(), |
|
4884 hasRedo: state.manager.hasRedo(), |
|
4885 undo: (0,external_wp_element_namespaceObject.useCallback)(() => { |
|
4886 dispatch({ |
|
4887 type: 'UNDO' |
|
4888 }); |
|
4889 }, []), |
|
4890 redo: (0,external_wp_element_namespaceObject.useCallback)(() => { |
|
4891 dispatch({ |
|
4892 type: 'REDO' |
|
4893 }); |
|
4894 }, []) |
|
4895 }; |
|
4896 } |
3857 |
4897 |
3858 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js |
4898 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js |
3859 /** |
4899 /** |
3860 * WordPress dependencies |
4900 * WordPress dependencies |
3861 */ |
4901 */ |
3862 |
4902 |
|
4903 |
3863 /** |
4904 /** |
3864 * Internal dependencies |
4905 * Internal dependencies |
3865 */ |
4906 */ |
3866 |
4907 |
3867 |
4908 |
3925 * useViewportMatch( 'medium' ); |
4964 * useViewportMatch( 'medium' ); |
3926 * ``` |
4965 * ``` |
3927 * |
4966 * |
3928 * @return {boolean} Whether viewport matches query. |
4967 * @return {boolean} Whether viewport matches query. |
3929 */ |
4968 */ |
3930 |
4969 const useViewportMatch = (breakpoint, operator = '>=') => { |
3931 const useViewportMatch = function (breakpoint) { |
|
3932 let operator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '>='; |
|
3933 const simulatedWidth = (0,external_wp_element_namespaceObject.useContext)(ViewportMatchWidthContext); |
4970 const simulatedWidth = (0,external_wp_element_namespaceObject.useContext)(ViewportMatchWidthContext); |
3934 const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`; |
4971 const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`; |
3935 const mediaQueryResult = useMediaQuery(mediaQuery || undefined); |
4972 const mediaQueryResult = useMediaQuery(mediaQuery || undefined); |
3936 |
|
3937 if (simulatedWidth) { |
4973 if (simulatedWidth) { |
3938 return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth); |
4974 return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth); |
3939 } |
4975 } |
3940 |
|
3941 return mediaQueryResult; |
4976 return mediaQueryResult; |
3942 }; |
4977 }; |
3943 |
|
3944 useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider; |
4978 useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider; |
3945 /* harmony default export */ var use_viewport_match = (useViewportMatch); |
4979 /* harmony default export */ const use_viewport_match = (useViewportMatch); |
3946 |
4980 |
3947 // EXTERNAL MODULE: ./node_modules/react-resize-aware/dist/index.js |
|
3948 var dist = __webpack_require__(235); |
|
3949 var dist_default = /*#__PURE__*/__webpack_require__.n(dist); |
|
3950 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js |
4981 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js |
3951 /** |
4982 /** |
3952 * External dependencies |
4983 * External dependencies |
3953 */ |
4984 */ |
3954 |
4985 |
3955 /** |
4986 /** |
|
4987 * WordPress dependencies |
|
4988 */ |
|
4989 |
|
4990 |
|
4991 // This of course could've been more streamlined with internal state instead of |
|
4992 // refs, but then host hooks / components could not opt out of renders. |
|
4993 // This could've been exported to its own module, but the current build doesn't |
|
4994 // seem to work with module imports and I had no more time to spend on this... |
|
4995 function useResolvedElement(subscriber, refOrElement) { |
|
4996 const callbackRefElement = (0,external_wp_element_namespaceObject.useRef)(null); |
|
4997 const lastReportRef = (0,external_wp_element_namespaceObject.useRef)(null); |
|
4998 const cleanupRef = (0,external_wp_element_namespaceObject.useRef)(); |
|
4999 const callSubscriber = (0,external_wp_element_namespaceObject.useCallback)(() => { |
|
5000 let element = null; |
|
5001 if (callbackRefElement.current) { |
|
5002 element = callbackRefElement.current; |
|
5003 } else if (refOrElement) { |
|
5004 if (refOrElement instanceof HTMLElement) { |
|
5005 element = refOrElement; |
|
5006 } else { |
|
5007 element = refOrElement.current; |
|
5008 } |
|
5009 } |
|
5010 if (lastReportRef.current && lastReportRef.current.element === element && lastReportRef.current.reporter === callSubscriber) { |
|
5011 return; |
|
5012 } |
|
5013 if (cleanupRef.current) { |
|
5014 cleanupRef.current(); |
|
5015 // Making sure the cleanup is not called accidentally multiple times. |
|
5016 cleanupRef.current = null; |
|
5017 } |
|
5018 lastReportRef.current = { |
|
5019 reporter: callSubscriber, |
|
5020 element |
|
5021 }; |
|
5022 |
|
5023 // Only calling the subscriber, if there's an actual element to report. |
|
5024 if (element) { |
|
5025 cleanupRef.current = subscriber(element); |
|
5026 } |
|
5027 }, [refOrElement, subscriber]); |
|
5028 |
|
5029 // On each render, we check whether a ref changed, or if we got a new raw |
|
5030 // element. |
|
5031 (0,external_wp_element_namespaceObject.useEffect)(() => { |
|
5032 // With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a |
|
5033 // render accompanying that change as well. |
|
5034 // To guarantee we always have the right element, one must use the ref callback provided instead, but we support |
|
5035 // RefObjects to make the hook API more convenient in certain cases. |
|
5036 callSubscriber(); |
|
5037 }, [callSubscriber]); |
|
5038 return (0,external_wp_element_namespaceObject.useCallback)(element => { |
|
5039 callbackRefElement.current = element; |
|
5040 callSubscriber(); |
|
5041 }, [callSubscriber]); |
|
5042 } |
|
5043 |
|
5044 // Declaring my own type here instead of using the one provided by TS (available since 4.2.2), because this way I'm not |
|
5045 // forcing consumers to use a specific TS version. |
|
5046 |
|
5047 // We're only using the first element of the size sequences, until future versions of the spec solidify on how |
|
5048 // exactly it'll be used for fragments in multi-column scenarios: |
|
5049 // From the spec: |
|
5050 // > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments, |
|
5051 // > which occur in multi-column scenarios. However the current definitions of content rect and border box do not |
|
5052 // > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single |
|
5053 // > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column. |
|
5054 // > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information. |
|
5055 // (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface) |
|
5056 // |
|
5057 // Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback, |
|
5058 // regardless of the "box" option. |
|
5059 // The spec states the following on this: |
|
5060 // > This does not have any impact on which box dimensions are returned to the defined callback when the event |
|
5061 // > is fired, it solely defines which box the author wishes to observe layout changes on. |
|
5062 // (https://drafts.csswg.org/resize-observer/#resize-observer-interface) |
|
5063 // I'm not exactly clear on what this means, especially when you consider a later section stating the following: |
|
5064 // > This section is non-normative. An author may desire to observe more than one CSS box. |
|
5065 // > In this case, author will need to use multiple ResizeObservers. |
|
5066 // (https://drafts.csswg.org/resize-observer/#resize-observer-interface) |
|
5067 // Which is clearly not how current browser implementations behave, and seems to contradict the previous quote. |
|
5068 // For this reason I decided to only return the requested size, |
|
5069 // even though it seems we have access to results for all box types. |
|
5070 // This also means that we get to keep the current api, being able to return a simple { width, height } pair, |
|
5071 // regardless of box option. |
|
5072 const extractSize = (entry, boxProp, sizeType) => { |
|
5073 if (!entry[boxProp]) { |
|
5074 if (boxProp === 'contentBoxSize') { |
|
5075 // The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec. |
|
5076 // See the 6th step in the description for the RO algorithm: |
|
5077 // https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h |
|
5078 // > Set this.contentRect to logical this.contentBoxSize given target and observedBox of "content-box". |
|
5079 // In real browser implementations of course these objects differ, but the width/height values should be equivalent. |
|
5080 return entry.contentRect[sizeType === 'inlineSize' ? 'width' : 'height']; |
|
5081 } |
|
5082 return undefined; |
|
5083 } |
|
5084 |
|
5085 // A couple bytes smaller than calling Array.isArray() and just as effective here. |
|
5086 return entry[boxProp][0] ? entry[boxProp][0][sizeType] : |
|
5087 // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current |
|
5088 // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`. |
|
5089 // @ts-ignore |
|
5090 entry[boxProp][sizeType]; |
|
5091 }; |
|
5092 function useResizeObserver(opts = {}) { |
|
5093 // Saving the callback as a ref. With this, I don't need to put onResize in the |
|
5094 // effect dep array, and just passing in an anonymous function without memoising |
|
5095 // will not reinstantiate the hook's ResizeObserver. |
|
5096 const onResize = opts.onResize; |
|
5097 const onResizeRef = (0,external_wp_element_namespaceObject.useRef)(undefined); |
|
5098 onResizeRef.current = onResize; |
|
5099 const round = opts.round || Math.round; |
|
5100 |
|
5101 // Using a single instance throughout the hook's lifetime |
|
5102 const resizeObserverRef = (0,external_wp_element_namespaceObject.useRef)(); |
|
5103 const [size, setSize] = (0,external_wp_element_namespaceObject.useState)({ |
|
5104 width: undefined, |
|
5105 height: undefined |
|
5106 }); |
|
5107 |
|
5108 // In certain edge cases the RO might want to report a size change just after |
|
5109 // the component unmounted. |
|
5110 const didUnmount = (0,external_wp_element_namespaceObject.useRef)(false); |
|
5111 (0,external_wp_element_namespaceObject.useEffect)(() => { |
|
5112 didUnmount.current = false; |
|
5113 return () => { |
|
5114 didUnmount.current = true; |
|
5115 }; |
|
5116 }, []); |
|
5117 |
|
5118 // Using a ref to track the previous width / height to avoid unnecessary renders. |
|
5119 const previous = (0,external_wp_element_namespaceObject.useRef)({ |
|
5120 width: undefined, |
|
5121 height: undefined |
|
5122 }); |
|
5123 |
|
5124 // This block is kinda like a useEffect, only it's called whenever a new |
|
5125 // element could be resolved based on the ref option. It also has a cleanup |
|
5126 // function. |
|
5127 const refCallback = useResolvedElement((0,external_wp_element_namespaceObject.useCallback)(element => { |
|
5128 // We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe. |
|
5129 // This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option. |
|
5130 if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) { |
|
5131 resizeObserverRef.current = { |
|
5132 box: opts.box, |
|
5133 round, |
|
5134 instance: new ResizeObserver(entries => { |
|
5135 const entry = entries[0]; |
|
5136 let boxProp = 'borderBoxSize'; |
|
5137 if (opts.box === 'border-box') { |
|
5138 boxProp = 'borderBoxSize'; |
|
5139 } else { |
|
5140 boxProp = opts.box === 'device-pixel-content-box' ? 'devicePixelContentBoxSize' : 'contentBoxSize'; |
|
5141 } |
|
5142 const reportedWidth = extractSize(entry, boxProp, 'inlineSize'); |
|
5143 const reportedHeight = extractSize(entry, boxProp, 'blockSize'); |
|
5144 const newWidth = reportedWidth ? round(reportedWidth) : undefined; |
|
5145 const newHeight = reportedHeight ? round(reportedHeight) : undefined; |
|
5146 if (previous.current.width !== newWidth || previous.current.height !== newHeight) { |
|
5147 const newSize = { |
|
5148 width: newWidth, |
|
5149 height: newHeight |
|
5150 }; |
|
5151 previous.current.width = newWidth; |
|
5152 previous.current.height = newHeight; |
|
5153 if (onResizeRef.current) { |
|
5154 onResizeRef.current(newSize); |
|
5155 } else if (!didUnmount.current) { |
|
5156 setSize(newSize); |
|
5157 } |
|
5158 } |
|
5159 }) |
|
5160 }; |
|
5161 } |
|
5162 resizeObserverRef.current.instance.observe(element, { |
|
5163 box: opts.box |
|
5164 }); |
|
5165 return () => { |
|
5166 if (resizeObserverRef.current) { |
|
5167 resizeObserverRef.current.instance.unobserve(element); |
|
5168 } |
|
5169 }; |
|
5170 }, [opts.box, round]), opts.ref); |
|
5171 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ |
|
5172 ref: refCallback, |
|
5173 width: size.width, |
|
5174 height: size.height |
|
5175 }), [refCallback, size ? size.width : null, size ? size.height : null]); |
|
5176 } |
|
5177 |
|
5178 /** |
3956 * Hook which allows to listen the resize event of any target element when it changes sizes. |
5179 * Hook which allows to listen the resize event of any target element when it changes sizes. |
3957 * _Note: `useResizeObserver` will report `null` until after first render_ |
5180 * _Note: `useResizeObserver` will report `null` until after first render. |
3958 * |
|
3959 * Simply a re-export of `react-resize-aware` so refer to its documentation <https://github.com/FezVrasta/react-resize-aware> |
|
3960 * for more details. |
|
3961 * |
|
3962 * @see https://github.com/FezVrasta/react-resize-aware |
|
3963 * |
5181 * |
3964 * @example |
5182 * @example |
3965 * |
5183 * |
3966 * ```js |
5184 * ```js |
3967 * const App = () => { |
5185 * const App = () => { |
4261 // @ts-ignore |
5507 // @ts-ignore |
4262 const ref = (0,external_wp_element_namespaceObject.useRef)(); |
5508 const ref = (0,external_wp_element_namespaceObject.useRef)(); |
4263 ref.current = value; |
5509 ref.current = value; |
4264 return ref; |
5510 return ref; |
4265 } |
5511 } |
|
5512 |
4266 /** |
5513 /** |
4267 * A hook to facilitate drag and drop handling. |
5514 * A hook to facilitate drag and drop handling. |
4268 * |
5515 * |
4269 * @param {Object} props Named parameters. |
5516 * @param {Object} props Named parameters. |
4270 * @param {boolean} props.isDisabled Whether or not to disable the drop zone. |
5517 * @param {?HTMLElement} [props.dropZoneElement] Optional element to be used as the drop zone. |
4271 * @param {(e: DragEvent) => void} props.onDragStart Called when dragging has started. |
5518 * @param {boolean} [props.isDisabled] Whether or not to disable the drop zone. |
4272 * @param {(e: DragEvent) => void} props.onDragEnter Called when the zone is entered. |
5519 * @param {(e: DragEvent) => void} [props.onDragStart] Called when dragging has started. |
4273 * @param {(e: DragEvent) => void} props.onDragOver Called when the zone is moved within. |
5520 * @param {(e: DragEvent) => void} [props.onDragEnter] Called when the zone is entered. |
4274 * @param {(e: DragEvent) => void} props.onDragLeave Called when the zone is left. |
5521 * @param {(e: DragEvent) => void} [props.onDragOver] Called when the zone is moved within. |
4275 * @param {(e: MouseEvent) => void} props.onDragEnd Called when dragging has ended. |
5522 * @param {(e: DragEvent) => void} [props.onDragLeave] Called when the zone is left. |
4276 * @param {(e: DragEvent) => void} props.onDrop Called when dropping in the zone. |
5523 * @param {(e: MouseEvent) => void} [props.onDragEnd] Called when dragging has ended. |
|
5524 * @param {(e: DragEvent) => void} [props.onDrop] Called when dropping in the zone. |
4277 * |
5525 * |
4278 * @return {import('react').RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element. |
5526 * @return {import('react').RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element. |
4279 */ |
5527 */ |
4280 |
5528 function useDropZone({ |
4281 |
5529 dropZoneElement, |
4282 function useDropZone(_ref) { |
5530 isDisabled, |
4283 let { |
5531 onDrop: _onDrop, |
4284 isDisabled, |
5532 onDragStart: _onDragStart, |
4285 onDrop: _onDrop, |
5533 onDragEnter: _onDragEnter, |
4286 onDragStart: _onDragStart, |
5534 onDragLeave: _onDragLeave, |
4287 onDragEnter: _onDragEnter, |
5535 onDragEnd: _onDragEnd, |
4288 onDragLeave: _onDragLeave, |
5536 onDragOver: _onDragOver |
4289 onDragEnd: _onDragEnd, |
5537 }) { |
4290 onDragOver: _onDragOver |
|
4291 } = _ref; |
|
4292 const onDropRef = useFreshRef(_onDrop); |
5538 const onDropRef = useFreshRef(_onDrop); |
4293 const onDragStartRef = useFreshRef(_onDragStart); |
5539 const onDragStartRef = useFreshRef(_onDragStart); |
4294 const onDragEnterRef = useFreshRef(_onDragEnter); |
5540 const onDragEnterRef = useFreshRef(_onDragEnter); |
4295 const onDragLeaveRef = useFreshRef(_onDragLeave); |
5541 const onDragLeaveRef = useFreshRef(_onDragLeave); |
4296 const onDragEndRef = useFreshRef(_onDragEnd); |
5542 const onDragEndRef = useFreshRef(_onDragEnd); |
4297 const onDragOverRef = useFreshRef(_onDragOver); |
5543 const onDragOverRef = useFreshRef(_onDragOver); |
4298 return useRefEffect(element => { |
5544 return useRefEffect(elem => { |
4299 if (isDisabled) { |
5545 if (isDisabled) { |
4300 return; |
5546 return; |
4301 } |
5547 } |
4302 |
5548 |
|
5549 // If a custom dropZoneRef is passed, use that instead of the element. |
|
5550 // This allows the dropzone to cover an expanded area, rather than |
|
5551 // be restricted to the area of the ref returned by this hook. |
|
5552 const element = dropZoneElement !== null && dropZoneElement !== void 0 ? dropZoneElement : elem; |
4303 let isDragging = false; |
5553 let isDragging = false; |
4304 const { |
5554 const { |
4305 ownerDocument |
5555 ownerDocument |
4306 } = element; |
5556 } = element; |
|
5557 |
4307 /** |
5558 /** |
4308 * Checks if an element is in the drop zone. |
5559 * Checks if an element is in the drop zone. |
4309 * |
5560 * |
4310 * @param {EventTarget|null} targetToCheck |
5561 * @param {EventTarget|null} targetToCheck |
4311 * |
5562 * |
4312 * @return {boolean} True if in drop zone, false if not. |
5563 * @return {boolean} True if in drop zone, false if not. |
4313 */ |
5564 */ |
4314 |
|
4315 function isElementInZone(targetToCheck) { |
5565 function isElementInZone(targetToCheck) { |
4316 const { |
5566 const { |
4317 defaultView |
5567 defaultView |
4318 } = ownerDocument; |
5568 } = ownerDocument; |
4319 |
|
4320 if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) { |
5569 if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) { |
4321 return false; |
5570 return false; |
4322 } |
5571 } |
|
5572 |
4323 /** @type {HTMLElement|null} */ |
5573 /** @type {HTMLElement|null} */ |
4324 |
|
4325 |
|
4326 let elementToCheck = targetToCheck; |
5574 let elementToCheck = targetToCheck; |
4327 |
|
4328 do { |
5575 do { |
4329 if (elementToCheck.dataset.isDropZone) { |
5576 if (elementToCheck.dataset.isDropZone) { |
4330 return elementToCheck === element; |
5577 return elementToCheck === element; |
4331 } |
5578 } |
4332 } while (elementToCheck = elementToCheck.parentElement); |
5579 } while (elementToCheck = elementToCheck.parentElement); |
4333 |
|
4334 return false; |
5580 return false; |
4335 } |
5581 } |
4336 |
5582 function maybeDragStart( /** @type {DragEvent} */event) { |
4337 function maybeDragStart( |
|
4338 /** @type {DragEvent} */ |
|
4339 event) { |
|
4340 if (isDragging) { |
5583 if (isDragging) { |
4341 return; |
5584 return; |
4342 } |
5585 } |
4343 |
|
4344 isDragging = true; |
5586 isDragging = true; |
4345 ownerDocument.removeEventListener('dragenter', maybeDragStart); // Note that `dragend` doesn't fire consistently for file and |
5587 |
|
5588 // Note that `dragend` doesn't fire consistently for file and |
4346 // HTML drag events where the drag origin is outside the browser |
5589 // HTML drag events where the drag origin is outside the browser |
4347 // window. In Firefox it may also not fire if the originating |
5590 // window. In Firefox it may also not fire if the originating |
4348 // node is removed. |
5591 // node is removed. |
4349 |
|
4350 ownerDocument.addEventListener('dragend', maybeDragEnd); |
5592 ownerDocument.addEventListener('dragend', maybeDragEnd); |
4351 ownerDocument.addEventListener('mousemove', maybeDragEnd); |
5593 ownerDocument.addEventListener('mousemove', maybeDragEnd); |
4352 |
|
4353 if (onDragStartRef.current) { |
5594 if (onDragStartRef.current) { |
4354 onDragStartRef.current(event); |
5595 onDragStartRef.current(event); |
4355 } |
5596 } |
4356 } |
5597 } |
4357 |
5598 function onDragEnter( /** @type {DragEvent} */event) { |
4358 function onDragEnter( |
5599 event.preventDefault(); |
4359 /** @type {DragEvent} */ |
5600 |
4360 event) { |
5601 // The `dragenter` event will also fire when entering child |
4361 event.preventDefault(); // The `dragenter` event will also fire when entering child |
|
4362 // elements, but we only want to call `onDragEnter` when |
5602 // elements, but we only want to call `onDragEnter` when |
4363 // entering the drop zone, which means the `relatedTarget` |
5603 // entering the drop zone, which means the `relatedTarget` |
4364 // (element that has been left) should be outside the drop zone. |
5604 // (element that has been left) should be outside the drop zone. |
4365 |
5605 if (element.contains( /** @type {Node} */event.relatedTarget)) { |
4366 if (element.contains( |
|
4367 /** @type {Node} */ |
|
4368 event.relatedTarget)) { |
|
4369 return; |
5606 return; |
4370 } |
5607 } |
4371 |
|
4372 if (onDragEnterRef.current) { |
5608 if (onDragEnterRef.current) { |
4373 onDragEnterRef.current(event); |
5609 onDragEnterRef.current(event); |
4374 } |
5610 } |
4375 } |
5611 } |
4376 |
5612 function onDragOver( /** @type {DragEvent} */event) { |
4377 function onDragOver( |
|
4378 /** @type {DragEvent} */ |
|
4379 event) { |
|
4380 // Only call onDragOver for the innermost hovered drop zones. |
5613 // Only call onDragOver for the innermost hovered drop zones. |
4381 if (!event.defaultPrevented && onDragOverRef.current) { |
5614 if (!event.defaultPrevented && onDragOverRef.current) { |
4382 onDragOverRef.current(event); |
5615 onDragOverRef.current(event); |
4383 } // Prevent the browser default while also signalling to parent |
5616 } |
|
5617 |
|
5618 // Prevent the browser default while also signalling to parent |
4384 // drop zones that `onDragOver` is already handled. |
5619 // drop zones that `onDragOver` is already handled. |
4385 |
|
4386 |
|
4387 event.preventDefault(); |
5620 event.preventDefault(); |
4388 } |
5621 } |
4389 |
5622 function onDragLeave( /** @type {DragEvent} */event) { |
4390 function onDragLeave( |
|
4391 /** @type {DragEvent} */ |
|
4392 event) { |
|
4393 // The `dragleave` event will also fire when leaving child |
5623 // The `dragleave` event will also fire when leaving child |
4394 // elements, but we only want to call `onDragLeave` when |
5624 // elements, but we only want to call `onDragLeave` when |
4395 // leaving the drop zone, which means the `relatedTarget` |
5625 // leaving the drop zone, which means the `relatedTarget` |
4396 // (element that has been entered) should be outside the drop |
5626 // (element that has been entered) should be outside the drop |
4397 // zone. |
5627 // zone. |
|
5628 // Note: This is not entirely reliable in Safari due to this bug |
|
5629 // https://bugs.webkit.org/show_bug.cgi?id=66547 |
4398 if (isElementInZone(event.relatedTarget)) { |
5630 if (isElementInZone(event.relatedTarget)) { |
4399 return; |
5631 return; |
4400 } |
5632 } |
4401 |
|
4402 if (onDragLeaveRef.current) { |
5633 if (onDragLeaveRef.current) { |
4403 onDragLeaveRef.current(event); |
5634 onDragLeaveRef.current(event); |
4404 } |
5635 } |
4405 } |
5636 } |
4406 |
5637 function onDrop( /** @type {DragEvent} */event) { |
4407 function onDrop( |
|
4408 /** @type {DragEvent} */ |
|
4409 event) { |
|
4410 // Don't handle drop if an inner drop zone already handled it. |
5638 // Don't handle drop if an inner drop zone already handled it. |
4411 if (event.defaultPrevented) { |
5639 if (event.defaultPrevented) { |
4412 return; |
5640 return; |
4413 } // Prevent the browser default while also signalling to parent |
5641 } |
|
5642 |
|
5643 // Prevent the browser default while also signalling to parent |
4414 // drop zones that `onDrop` is already handled. |
5644 // drop zones that `onDrop` is already handled. |
4415 |
5645 event.preventDefault(); |
4416 |
5646 |
4417 event.preventDefault(); // This seemingly useless line has been shown to resolve a |
5647 // This seemingly useless line has been shown to resolve a |
4418 // Safari issue where files dragged directly from the dock are |
5648 // Safari issue where files dragged directly from the dock are |
4419 // not recognized. |
5649 // not recognized. |
4420 // eslint-disable-next-line no-unused-expressions |
5650 // eslint-disable-next-line no-unused-expressions |
4421 |
|
4422 event.dataTransfer && event.dataTransfer.files.length; |
5651 event.dataTransfer && event.dataTransfer.files.length; |
4423 |
|
4424 if (onDropRef.current) { |
5652 if (onDropRef.current) { |
4425 onDropRef.current(event); |
5653 onDropRef.current(event); |
4426 } |
5654 } |
4427 |
|
4428 maybeDragEnd(event); |
5655 maybeDragEnd(event); |
4429 } |
5656 } |
4430 |
5657 function maybeDragEnd( /** @type {MouseEvent} */event) { |
4431 function maybeDragEnd( |
|
4432 /** @type {MouseEvent} */ |
|
4433 event) { |
|
4434 if (!isDragging) { |
5658 if (!isDragging) { |
4435 return; |
5659 return; |
4436 } |
5660 } |
4437 |
|
4438 isDragging = false; |
5661 isDragging = false; |
4439 ownerDocument.addEventListener('dragenter', maybeDragStart); |
|
4440 ownerDocument.removeEventListener('dragend', maybeDragEnd); |
5662 ownerDocument.removeEventListener('dragend', maybeDragEnd); |
4441 ownerDocument.removeEventListener('mousemove', maybeDragEnd); |
5663 ownerDocument.removeEventListener('mousemove', maybeDragEnd); |
4442 |
|
4443 if (onDragEndRef.current) { |
5664 if (onDragEndRef.current) { |
4444 onDragEndRef.current(event); |
5665 onDragEndRef.current(event); |
4445 } |
5666 } |
4446 } |
5667 } |
4447 |
|
4448 element.dataset.isDropZone = 'true'; |
5668 element.dataset.isDropZone = 'true'; |
4449 element.addEventListener('drop', onDrop); |
5669 element.addEventListener('drop', onDrop); |
4450 element.addEventListener('dragenter', onDragEnter); |
5670 element.addEventListener('dragenter', onDragEnter); |
4451 element.addEventListener('dragover', onDragOver); |
5671 element.addEventListener('dragover', onDragOver); |
4452 element.addEventListener('dragleave', onDragLeave); // The `dragstart` event doesn't fire if the drag started outside |
5672 element.addEventListener('dragleave', onDragLeave); |
|
5673 // The `dragstart` event doesn't fire if the drag started outside |
4453 // the document. |
5674 // the document. |
4454 |
|
4455 ownerDocument.addEventListener('dragenter', maybeDragStart); |
5675 ownerDocument.addEventListener('dragenter', maybeDragStart); |
4456 return () => { |
5676 return () => { |
4457 onDropRef.current = null; |
|
4458 onDragStartRef.current = null; |
|
4459 onDragEnterRef.current = null; |
|
4460 onDragLeaveRef.current = null; |
|
4461 onDragEndRef.current = null; |
|
4462 onDragOverRef.current = null; |
|
4463 delete element.dataset.isDropZone; |
5677 delete element.dataset.isDropZone; |
4464 element.removeEventListener('drop', onDrop); |
5678 element.removeEventListener('drop', onDrop); |
4465 element.removeEventListener('dragenter', onDragEnter); |
5679 element.removeEventListener('dragenter', onDragEnter); |
4466 element.removeEventListener('dragover', onDragOver); |
5680 element.removeEventListener('dragover', onDragOver); |
4467 element.removeEventListener('dragleave', onDragLeave); |
5681 element.removeEventListener('dragleave', onDragLeave); |
4468 ownerDocument.removeEventListener('dragend', maybeDragEnd); |
5682 ownerDocument.removeEventListener('dragend', maybeDragEnd); |
4469 ownerDocument.removeEventListener('mousemove', maybeDragEnd); |
5683 ownerDocument.removeEventListener('mousemove', maybeDragEnd); |
4470 ownerDocument.addEventListener('dragenter', maybeDragStart); |
5684 ownerDocument.removeEventListener('dragenter', maybeDragStart); |
4471 }; |
5685 }; |
4472 }, [isDisabled]); |
5686 }, [isDisabled, dropZoneElement] // Refresh when the passed in dropZoneElement changes. |
|
5687 ); |
4473 } |
5688 } |
4474 |
5689 |
4475 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focusable-iframe/index.js |
5690 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focusable-iframe/index.js |
4476 /** |
5691 /** |
|
5692 * External dependencies |
|
5693 */ |
|
5694 |
|
5695 /** |
4477 * Internal dependencies |
5696 * Internal dependencies |
4478 */ |
5697 */ |
|
5698 |
4479 |
5699 |
4480 /** |
5700 /** |
4481 * Dispatches a bubbling focus event when the iframe receives focus. Use |
5701 * Dispatches a bubbling focus event when the iframe receives focus. Use |
4482 * `onFocus` as usual on the iframe or a parent element. |
5702 * `onFocus` as usual on the iframe or a parent element. |
4483 * |
5703 * |
4484 * @return {Object} Ref to pass to the iframe. |
5704 * @return Ref to pass to the iframe. |
4485 */ |
5705 */ |
4486 |
|
4487 function useFocusableIframe() { |
5706 function useFocusableIframe() { |
4488 return useRefEffect(element => { |
5707 return useRefEffect(element => { |
4489 const { |
5708 const { |
4490 ownerDocument |
5709 ownerDocument |
4491 } = element; |
5710 } = element; |
4492 if (!ownerDocument) return; |
5711 if (!ownerDocument) { |
|
5712 return; |
|
5713 } |
4493 const { |
5714 const { |
4494 defaultView |
5715 defaultView |
4495 } = ownerDocument; |
5716 } = ownerDocument; |
4496 if (!defaultView) return; |
5717 if (!defaultView) { |
|
5718 return; |
|
5719 } |
|
5720 |
4497 /** |
5721 /** |
4498 * Checks whether the iframe is the activeElement, inferring that it has |
5722 * Checks whether the iframe is the activeElement, inferring that it has |
4499 * then received focus, and dispatches a focus event. |
5723 * then received focus, and dispatches a focus event. |
4500 */ |
5724 */ |
4501 |
|
4502 function checkFocus() { |
5725 function checkFocus() { |
4503 if (ownerDocument && ownerDocument.activeElement === element) { |
5726 if (ownerDocument && ownerDocument.activeElement === element) { |
4504 /** @type {HTMLElement} */ |
|
4505 element.focus(); |
5727 element.focus(); |
4506 } |
5728 } |
4507 } |
5729 } |
4508 |
|
4509 defaultView.addEventListener('blur', checkFocus); |
5730 defaultView.addEventListener('blur', checkFocus); |
4510 return () => { |
5731 return () => { |
4511 defaultView.removeEventListener('blur', checkFocus); |
5732 defaultView.removeEventListener('blur', checkFocus); |
4512 }; |
5733 }; |
4513 }, []); |
5734 }, []); |
4514 } |
5735 } |
4515 |
5736 |
4516 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-fixed-window-list/index.js |
5737 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-fixed-window-list/index.js |
4517 /** |
5738 /** |
4518 * External dependencies |
|
4519 */ |
|
4520 |
|
4521 /** |
|
4522 * WordPress dependencies |
5739 * WordPress dependencies |
4523 */ |
5740 */ |
4524 |
5741 |
4525 |
5742 |
4526 |
5743 |
4527 |
5744 |
|
5745 /** |
|
5746 * Internal dependencies |
|
5747 */ |
|
5748 |
4528 const DEFAULT_INIT_WINDOW_SIZE = 30; |
5749 const DEFAULT_INIT_WINDOW_SIZE = 30; |
|
5750 |
4529 /** |
5751 /** |
4530 * @typedef {Object} WPFixedWindowList |
5752 * @typedef {Object} WPFixedWindowList |
4531 * |
5753 * |
4532 * @property {number} visibleItems Items visible in the current viewport |
5754 * @property {number} visibleItems Items visible in the current viewport |
4533 * @property {number} start Start index of the window |
5755 * @property {number} start Start index of the window |
4539 * @typedef {Object} WPFixedWindowListOptions |
5761 * @typedef {Object} WPFixedWindowListOptions |
4540 * |
5762 * |
4541 * @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window. |
5763 * @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window. |
4542 * @property {boolean} [useWindowing] When false avoids calculating the window size |
5764 * @property {boolean} [useWindowing] When false avoids calculating the window size |
4543 * @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size. |
5765 * @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size. |
|
5766 * @property {any} [expandedState] Used to recalculate the window size when the expanded state of a list changes. |
4544 */ |
5767 */ |
4545 |
5768 |
4546 /** |
5769 /** |
4547 * |
5770 * |
4548 * @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element. |
5771 * @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element. |
4549 * @param { number } itemHeight Fixed item height in pixels |
5772 * @param { number } itemHeight Fixed item height in pixels |
4550 * @param { number } totalItems Total items in list |
5773 * @param { number } totalItems Total items in list |
4551 * @param { WPFixedWindowListOptions } [options] Options object |
5774 * @param { WPFixedWindowListOptions } [options] Options object |
4552 * @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter |
5775 * @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter |
4553 */ |
5776 */ |
4554 |
|
4555 function useFixedWindowList(elementRef, itemHeight, totalItems, options) { |
5777 function useFixedWindowList(elementRef, itemHeight, totalItems, options) { |
4556 var _options$initWindowSi, _options$useWindowing; |
5778 var _options$initWindowSi, _options$useWindowing; |
4557 |
5779 const initWindowSize = (_options$initWindowSi = options?.initWindowSize) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT_INIT_WINDOW_SIZE; |
4558 const initWindowSize = (_options$initWindowSi = options === null || options === void 0 ? void 0 : options.initWindowSize) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT_INIT_WINDOW_SIZE; |
5780 const useWindowing = (_options$useWindowing = options?.useWindowing) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true; |
4559 const useWindowing = (_options$useWindowing = options === null || options === void 0 ? void 0 : options.useWindowing) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true; |
|
4560 const [fixedListWindow, setFixedListWindow] = (0,external_wp_element_namespaceObject.useState)({ |
5781 const [fixedListWindow, setFixedListWindow] = (0,external_wp_element_namespaceObject.useState)({ |
4561 visibleItems: initWindowSize, |
5782 visibleItems: initWindowSize, |
4562 start: 0, |
5783 start: 0, |
4563 end: initWindowSize, |
5784 end: initWindowSize, |
4564 itemInView: ( |
5785 itemInView: ( /** @type {number} */index) => { |
4565 /** @type {number} */ |
|
4566 index) => { |
|
4567 return index >= 0 && index <= initWindowSize; |
5786 return index >= 0 && index <= initWindowSize; |
4568 } |
5787 } |
4569 }); |
5788 }); |
4570 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
5789 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
4571 var _scrollContainer$owne, _scrollContainer$owne2, _scrollContainer$owne3, _scrollContainer$owne4; |
|
4572 |
|
4573 if (!useWindowing) { |
5790 if (!useWindowing) { |
4574 return; |
5791 return; |
4575 } |
5792 } |
4576 |
|
4577 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); |
5793 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); |
4578 |
5794 const measureWindow = ( /** @type {boolean | undefined} */initRender) => { |
4579 const measureWindow = ( |
|
4580 /** @type {boolean | undefined} */ |
|
4581 initRender) => { |
|
4582 var _options$windowOversc; |
5795 var _options$windowOversc; |
4583 |
|
4584 if (!scrollContainer) { |
5796 if (!scrollContainer) { |
4585 return; |
5797 return; |
4586 } |
5798 } |
4587 |
5799 const visibleItems = Math.ceil(scrollContainer.clientHeight / itemHeight); |
4588 const visibleItems = Math.ceil(scrollContainer.clientHeight / itemHeight); // Aim to keep opening list view fast, afterward we can optimize for scrolling. |
5800 // Aim to keep opening list view fast, afterward we can optimize for scrolling. |
4589 |
5801 const windowOverscan = initRender ? visibleItems : (_options$windowOversc = options?.windowOverscan) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems; |
4590 const windowOverscan = initRender ? visibleItems : (_options$windowOversc = options === null || options === void 0 ? void 0 : options.windowOverscan) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems; |
|
4591 const firstViewableIndex = Math.floor(scrollContainer.scrollTop / itemHeight); |
5802 const firstViewableIndex = Math.floor(scrollContainer.scrollTop / itemHeight); |
4592 const start = Math.max(0, firstViewableIndex - windowOverscan); |
5803 const start = Math.max(0, firstViewableIndex - windowOverscan); |
4593 const end = Math.min(totalItems - 1, firstViewableIndex + visibleItems + windowOverscan); |
5804 const end = Math.min(totalItems - 1, firstViewableIndex + visibleItems + windowOverscan); |
4594 setFixedListWindow(lastWindow => { |
5805 setFixedListWindow(lastWindow => { |
4595 const nextWindow = { |
5806 const nextWindow = { |
4596 visibleItems, |
5807 visibleItems, |
4597 start, |
5808 start, |
4598 end, |
5809 end, |
4599 itemInView: ( |
5810 itemInView: ( /** @type {number} */index) => { |
4600 /** @type {number} */ |
|
4601 index) => { |
|
4602 return start <= index && index <= end; |
5811 return start <= index && index <= end; |
4603 } |
5812 } |
4604 }; |
5813 }; |
4605 |
|
4606 if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) { |
5814 if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) { |
4607 return nextWindow; |
5815 return nextWindow; |
4608 } |
5816 } |
4609 |
|
4610 return lastWindow; |
5817 return lastWindow; |
4611 }); |
5818 }); |
4612 }; |
5819 }; |
4613 |
|
4614 measureWindow(true); |
5820 measureWindow(true); |
4615 const debounceMeasureList = (0,external_lodash_namespaceObject.debounce)(() => { |
5821 const debounceMeasureList = debounce(() => { |
4616 measureWindow(); |
5822 measureWindow(); |
4617 }, 16); |
5823 }, 16); |
4618 scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.addEventListener('scroll', debounceMeasureList); |
5824 scrollContainer?.addEventListener('scroll', debounceMeasureList); |
4619 scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne = scrollContainer.ownerDocument) === null || _scrollContainer$owne === void 0 ? void 0 : (_scrollContainer$owne2 = _scrollContainer$owne.defaultView) === null || _scrollContainer$owne2 === void 0 ? void 0 : _scrollContainer$owne2.addEventListener('resize', debounceMeasureList); |
5825 scrollContainer?.ownerDocument?.defaultView?.addEventListener('resize', debounceMeasureList); |
4620 scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne3 = scrollContainer.ownerDocument) === null || _scrollContainer$owne3 === void 0 ? void 0 : (_scrollContainer$owne4 = _scrollContainer$owne3.defaultView) === null || _scrollContainer$owne4 === void 0 ? void 0 : _scrollContainer$owne4.addEventListener('resize', debounceMeasureList); |
5826 scrollContainer?.ownerDocument?.defaultView?.addEventListener('resize', debounceMeasureList); |
4621 return () => { |
5827 return () => { |
4622 var _scrollContainer$owne5, _scrollContainer$owne6; |
5828 scrollContainer?.removeEventListener('scroll', debounceMeasureList); |
4623 |
5829 scrollContainer?.ownerDocument?.defaultView?.removeEventListener('resize', debounceMeasureList); |
4624 scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.removeEventListener('scroll', debounceMeasureList); |
|
4625 scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne5 = scrollContainer.ownerDocument) === null || _scrollContainer$owne5 === void 0 ? void 0 : (_scrollContainer$owne6 = _scrollContainer$owne5.defaultView) === null || _scrollContainer$owne6 === void 0 ? void 0 : _scrollContainer$owne6.removeEventListener('resize', debounceMeasureList); |
|
4626 }; |
5830 }; |
4627 }, [itemHeight, elementRef, totalItems]); |
5831 }, [itemHeight, elementRef, totalItems, options?.expandedState, options?.windowOverscan, useWindowing]); |
4628 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
5832 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { |
4629 var _scrollContainer$owne7, _scrollContainer$owne8; |
|
4630 |
|
4631 if (!useWindowing) { |
5833 if (!useWindowing) { |
4632 return; |
5834 return; |
4633 } |
5835 } |
4634 |
|
4635 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); |
5836 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); |
4636 |
5837 const handleKeyDown = ( /** @type {KeyboardEvent} */event) => { |
4637 const handleKeyDown = ( |
|
4638 /** @type {KeyboardEvent} */ |
|
4639 event) => { |
|
4640 switch (event.keyCode) { |
5838 switch (event.keyCode) { |
4641 case external_wp_keycodes_namespaceObject.HOME: |
5839 case external_wp_keycodes_namespaceObject.HOME: |
4642 { |
5840 { |
4643 return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({ |
5841 return scrollContainer?.scrollTo({ |
4644 top: 0 |
5842 top: 0 |
4645 }); |
5843 }); |
4646 } |
5844 } |
4647 |
|
4648 case external_wp_keycodes_namespaceObject.END: |
5845 case external_wp_keycodes_namespaceObject.END: |
4649 { |
5846 { |
4650 return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({ |
5847 return scrollContainer?.scrollTo({ |
4651 top: totalItems * itemHeight |
5848 top: totalItems * itemHeight |
4652 }); |
5849 }); |
4653 } |
5850 } |
4654 |
|
4655 case external_wp_keycodes_namespaceObject.PAGEUP: |
5851 case external_wp_keycodes_namespaceObject.PAGEUP: |
4656 { |
5852 { |
4657 return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({ |
5853 return scrollContainer?.scrollTo({ |
4658 top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight |
5854 top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight |
4659 }); |
5855 }); |
4660 } |
5856 } |
4661 |
|
4662 case external_wp_keycodes_namespaceObject.PAGEDOWN: |
5857 case external_wp_keycodes_namespaceObject.PAGEDOWN: |
4663 { |
5858 { |
4664 return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({ |
5859 return scrollContainer?.scrollTo({ |
4665 top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight |
5860 top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight |
4666 }); |
5861 }); |
4667 } |
5862 } |
4668 } |
5863 } |
4669 }; |
5864 }; |
4670 |
5865 scrollContainer?.ownerDocument?.defaultView?.addEventListener('keydown', handleKeyDown); |
4671 scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne7 = scrollContainer.ownerDocument) === null || _scrollContainer$owne7 === void 0 ? void 0 : (_scrollContainer$owne8 = _scrollContainer$owne7.defaultView) === null || _scrollContainer$owne8 === void 0 ? void 0 : _scrollContainer$owne8.addEventListener('keydown', handleKeyDown); |
|
4672 return () => { |
5866 return () => { |
4673 var _scrollContainer$owne9, _scrollContainer$owne10; |
5867 scrollContainer?.ownerDocument?.defaultView?.removeEventListener('keydown', handleKeyDown); |
4674 |
|
4675 scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne9 = scrollContainer.ownerDocument) === null || _scrollContainer$owne9 === void 0 ? void 0 : (_scrollContainer$owne10 = _scrollContainer$owne9.defaultView) === null || _scrollContainer$owne10 === void 0 ? void 0 : _scrollContainer$owne10.removeEventListener('keydown', handleKeyDown); |
|
4676 }; |
5868 }; |
4677 }, [totalItems, itemHeight, elementRef, fixedListWindow.visibleItems]); |
5869 }, [totalItems, itemHeight, elementRef, fixedListWindow.visibleItems, useWindowing, options?.expandedState]); |
4678 return [fixedListWindow, setFixedListWindow]; |
5870 return [fixedListWindow, setFixedListWindow]; |
4679 } |
5871 } |
4680 |
5872 |
|
5873 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-observable-value/index.js |
|
5874 /** |
|
5875 * WordPress dependencies |
|
5876 */ |
|
5877 |
|
5878 |
|
5879 /** |
|
5880 * Internal dependencies |
|
5881 */ |
|
5882 |
|
5883 /** |
|
5884 * React hook that lets you observe an entry in an `ObservableMap`. The hook returns the |
|
5885 * current value corresponding to the key, or `undefined` when there is no value stored. |
|
5886 * It also observes changes to the value and triggers an update of the calling component |
|
5887 * in case the value changes. |
|
5888 * |
|
5889 * @template K The type of the keys in the map. |
|
5890 * @template V The type of the values in the map. |
|
5891 * @param map The `ObservableMap` to observe. |
|
5892 * @param name The map key to observe. |
|
5893 * @return The value corresponding to the map key requested. |
|
5894 */ |
|
5895 function useObservableValue(map, name) { |
|
5896 const [subscribe, getValue] = (0,external_wp_element_namespaceObject.useMemo)(() => [listener => map.subscribe(name, listener), () => map.get(name)], [map, name]); |
|
5897 return (0,external_wp_element_namespaceObject.useSyncExternalStore)(subscribe, getValue, getValue); |
|
5898 } |
|
5899 |
4681 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js |
5900 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js |
4682 // Utils. |
5901 // The `createHigherOrderComponent` helper and helper types. |
4683 // Compose helper (aliased flowRight from Lodash) |
5902 |
4684 |
5903 // The `debounce` helper and its types. |
4685 // Higher-order components. |
5904 |
4686 |
5905 // The `throttle` helper and its types. |
4687 |
5906 |
4688 |
5907 // The `ObservableMap` data structure |
4689 |
5908 |
4690 |
5909 |
4691 |
5910 // The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash). |
4692 // Hooks. |
5911 |
4693 |
5912 |
4694 |
5913 |
4695 |
5914 // Higher-order components. |
4696 |
5915 |
4697 |
5916 |
4698 |
5917 |
4699 |
5918 |
4700 |
5919 |
4701 |
5920 |
4702 |
5921 |
4703 |
5922 // Hooks. |
4704 |
5923 |
4705 |
5924 |
4706 |
5925 |
4707 |
5926 |
4708 |
5927 |
4709 |
5928 |
4710 |
5929 |
4711 |
5930 |
4712 |
5931 |
4713 |
5932 |
4714 |
5933 |
4715 |
5934 |
4716 |
5935 |
4717 |
5936 |
4718 |
5937 |
4719 |
5938 |
4720 |
5939 |
4721 }(); |
5940 |
|
5941 |
|
5942 |
|
5943 |
|
5944 |
|
5945 |
|
5946 |
|
5947 |
|
5948 |
|
5949 |
|
5950 |
|
5951 |
|
5952 |
|
5953 })(); |
|
5954 |
4722 (window.wp = window.wp || {}).compose = __webpack_exports__; |
5955 (window.wp = window.wp || {}).compose = __webpack_exports__; |
4723 /******/ })() |
5956 /******/ })() |
4724 ; |
5957 ; |