PluginProbe
Gutenberg / 18.6.1
Gutenberg v18.6.1
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / interactivity / query.js

query.js in Gutenberg 18.6.1, at build/interactivity/query.js

133 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import * as __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__ from "@wordpress/interactivity";
2 /******/ var __webpack_modules__ = ({
3
4 /***/ 978:
5 /***/ ((module) => {
6
7 module.exports = import("@wordpress/interactivity-router");;
8
9 /***/ })
10
11 /******/ });
12 /************************************************************************/
13 /******/ // The module cache
14 /******/ var __webpack_module_cache__ = {};
15 /******/
16 /******/ // The require function
17 /******/ function __webpack_require__(moduleId) {
18 /******/ // Check if module is in cache
19 /******/ var cachedModule = __webpack_module_cache__[moduleId];
20 /******/ if (cachedModule !== undefined) {
21 /******/ return cachedModule.exports;
22 /******/ }
23 /******/ // Create a new module (and put it into the cache)
24 /******/ var module = __webpack_module_cache__[moduleId] = {
25 /******/ // no module.id needed
26 /******/ // no module.loaded needed
27 /******/ exports: {}
28 /******/ };
29 /******/
30 /******/ // Execute the module function
31 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
32 /******/
33 /******/ // Return the exports of the module
34 /******/ return module.exports;
35 /******/ }
36 /******/
37 /************************************************************************/
38 /******/ /* webpack/runtime/define property getters */
39 /******/ (() => {
40 /******/ // define getter functions for harmony exports
41 /******/ __webpack_require__.d = (exports, definition) => {
42 /******/ for(var key in definition) {
43 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
44 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
45 /******/ }
46 /******/ }
47 /******/ };
48 /******/ })();
49 /******/
50 /******/ /* webpack/runtime/hasOwnProperty shorthand */
51 /******/ (() => {
52 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
53 /******/ })();
54 /******/
55 /************************************************************************/
56 var __webpack_exports__ = {};
57 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
58 (() => {
59
60 ;// CONCATENATED MODULE: external "@wordpress/interactivity"
61 var x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
62 var y = x => () => x
63 const interactivity_namespaceObject = x({ ["getContext"]: () => __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getContext, ["getElement"]: () => __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getElement, ["store"]: () => __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store });
64 ;// CONCATENATED MODULE: ./packages/block-library/src/query/view.js
65 /**
66 * WordPress dependencies
67 */
68
69 const isValidLink = ref => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === '_self') && ref.origin === window.location.origin;
70 const isValidEvent = event => event.button === 0 &&
71 // Left clicks only.
72 !event.metaKey &&
73 // Open in new tab (Mac).
74 !event.ctrlKey &&
75 // Open in new tab (Windows).
76 !event.altKey &&
77 // Download.
78 !event.shiftKey && !event.defaultPrevented;
79 (0,interactivity_namespaceObject.store)('core/query', {
80 actions: {
81 *navigate(event) {
82 const ctx = (0,interactivity_namespaceObject.getContext)();
83 const {
84 ref
85 } = (0,interactivity_namespaceObject.getElement)();
86 const queryRef = ref.closest('.wp-block-query[data-wp-router-region]');
87 if (isValidLink(ref) && isValidEvent(event)) {
88 event.preventDefault();
89 const {
90 actions
91 } = yield Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 978));
92 yield actions.navigate(ref.href);
93 ctx.url = ref.href;
94
95 // Focus the first anchor of the Query block.
96 const firstAnchor = `.wp-block-post-template a[href]`;
97 queryRef.querySelector(firstAnchor)?.focus();
98 }
99 },
100 *prefetch() {
101 const {
102 ref
103 } = (0,interactivity_namespaceObject.getElement)();
104 if (isValidLink(ref)) {
105 const {
106 actions
107 } = yield Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 978));
108 yield actions.prefetch(ref.href);
109 }
110 }
111 },
112 callbacks: {
113 *prefetch() {
114 const {
115 url
116 } = (0,interactivity_namespaceObject.getContext)();
117 const {
118 ref
119 } = (0,interactivity_namespaceObject.getElement)();
120 if (url && isValidLink(ref)) {
121 const {
122 actions
123 } = yield Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 978));
124 yield actions.prefetch(ref.href);
125 }
126 }
127 }
128 }, {
129 lock: true
130 });
131 })();
132
133