diff --git a/.stylelintignore b/.stylelintignore new file mode 100644 index 0000000..3e90af5 --- /dev/null +++ b/.stylelintignore @@ -0,0 +1,5 @@ +build/ +node_modules/ +vendor/ +*.min.css +*.min.scss \ No newline at end of file diff --git a/.stylelintrc.json b/.stylelintrc.json new file mode 100644 index 0000000..aec83c0 --- /dev/null +++ b/.stylelintrc.json @@ -0,0 +1,10 @@ +{ + "extends": ["@wordpress/stylelint-config/scss"], + "rules": { + "at-rule-empty-line-before": null, + "at-rule-no-unknown": null, + "rule-empty-line-before": null, + "selector-class-pattern": null, + "scss/at-rule-no-unknown": true + } +} diff --git a/build/block.json b/build/block.json deleted file mode 100644 index a36f3f9..0000000 --- a/build/block.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "https://schemas.wp.org/trunk/block.json", - "apiVersion": 3, - "name": "lumen/priority-nav", - "version": "0.1.0", - "title": "Priority+ Navigation", - "category": "theme", - "icon": "menu-alt", - "description": "A responsive navigation wrapper that implements the Priority+ pattern, automatically moving items to a More dropdown.", - "keywords": [ - "navigation", - "menu", - "priority", - "responsive" - ], - "attributes": { - "moreLabel": { - "type": "string", - "default": "More" - }, - "moreIcon": { - "type": "string", - "default": "dots" - } - }, - "editorScript": "file:./index.js", - "editorStyle": "file:./index.css", - "style": "file:./style-index.css", - "viewScript": "file:./view.js", - "textdomain": "priority-nav" -} \ No newline at end of file diff --git a/build/blocks-manifest.php b/build/blocks-manifest.php deleted file mode 100644 index 3948506..0000000 --- a/build/blocks-manifest.php +++ /dev/null @@ -1,35 +0,0 @@ - array( - '$schema' => 'https://schemas.wp.org/trunk/block.json', - 'apiVersion' => 3, - 'name' => 'lumen/priority-nav', - 'version' => '0.1.0', - 'title' => 'Priority+ Navigation', - 'category' => 'theme', - 'icon' => 'menu-alt', - 'description' => 'A responsive navigation wrapper that implements the Priority+ pattern, automatically moving items to a More dropdown.', - 'keywords' => array( - 'navigation', - 'menu', - 'priority', - 'responsive' - ), - 'attributes' => array( - 'moreLabel' => array( - 'type' => 'string', - 'default' => 'More' - ), - 'moreIcon' => array( - 'type' => 'string', - 'default' => 'dots' - ) - ), - 'editorScript' => 'file:./index.js', - 'editorStyle' => 'file:./index.css', - 'style' => 'file:./style-index.css', - 'viewScript' => 'file:./view.js', - 'textdomain' => 'priority-nav' - ) -); diff --git a/build/index.js b/build/index.js deleted file mode 100644 index 764dd8b..0000000 --- a/build/index.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{"use strict";var r,o={698(){const r=window.wp.i18n,o=window.wp.hooks,e=window.wp.blockEditor,i=window.wp.components,t=window.wp.compose,n=window.wp.blocks,a=window.wp.primitives,l=window.ReactJSXRuntime;var v=(0,l.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,l.jsx)(a.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M7.404 16.596a6.5 6.5 0 1 0 9.192-9.192 6.5 6.5 0 0 0-9.192 9.192ZM6.344 6.343a8 8 0 1 0 11.313 11.314A8 8 0 0 0 6.343 6.343Zm4.906 9.407v-3h-3v-1.5h3v-3h1.5v3h3v1.5h-3v3h-1.5Z"})});(0,o.addFilter)("blocks.registerBlockType","priority-nav/extend-core-navigation",(r,o)=>"core/navigation"!==o?r:{...r,attributes:{...r.attributes,priorityNavEnabled:{type:"boolean",default:!1},priorityNavMoreLabel:{type:"string",default:"Browse"},priorityNavMoreIcon:{type:"string",default:"none"}}});const s=(0,t.createHigherOrderComponent)(o=>t=>{const{name:n,attributes:a,setAttributes:v}=t;if("core/navigation"!==n)return(0,l.jsx)(o,{...t});const{priorityNavEnabled:s,priorityNavMoreLabel:p,priorityNavMoreIcon:c}=a;return s?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o,{...t}),(0,l.jsx)(e.InspectorControls,{children:(0,l.jsxs)(i.PanelBody,{title:(0,r.__)("Priority+ Settings","priority-nav"),children:[(0,l.jsx)(i.TextControl,{label:(0,r.__)("More Button Label","priority-nav"),value:p,onChange:r=>v({priorityNavMoreLabel:r}),help:(0,r.__)('Text displayed on the "More" button',"priority-nav")}),(0,l.jsx)(i.SelectControl,{label:(0,r.__)("More Button Icon","priority-nav"),value:c,options:[{label:(0,r.__)("None","priority-nav"),value:"none"},{label:(0,r.__)("Chevron Down (▼)","priority-nav"),value:"chevron"},{label:(0,r.__)("Plus (+)","priority-nav"),value:"plus"},{label:(0,r.__)("Menu (≡)","priority-nav"),value:"menu"}],onChange:r=>v({priorityNavMoreIcon:r})})]})})]}):(0,l.jsx)(o,{...t})},"withPriorityNavControls");(0,o.addFilter)("editor.BlockEdit","priority-nav/add-priority-nav-controls",s),(0,n.registerBlockVariation)("core/navigation",{name:"lumen-priority-nav",title:(0,r.__)("Priority+ Nav","priority-nav"),description:(0,r.__)('A responsive navigation that automatically moves overflow items to a "More" dropdown.',"priority-nav"),icon:v,attributes:{priorityNavEnabled:!0,priorityNavMoreLabel:"Browse",priorityNavMoreIcon:"none"},scope:["inserter","block"],isActive:r=>!!r.priorityNavEnabled})}},e={};function i(r){var t=e[r];if(void 0!==t)return t.exports;var n=e[r]={exports:{}};return o[r](n,n.exports,i),n.exports}i.m=o,r=[],i.O=(o,e,t,n)=>{if(!e){var a=1/0;for(p=0;p=n)&&Object.keys(i.O).every(r=>i.O[r](e[v]))?e.splice(v--,1):(l=!1,n0&&r[p-1][2]>n;p--)r[p]=r[p-1];r[p]=[e,t,n]},i.o=(r,o)=>Object.prototype.hasOwnProperty.call(r,o),(()=>{var r={57:0,350:0};i.O.j=o=>0===r[o];var o=(o,e)=>{var t,n,[a,l,v]=e,s=0;if(a.some(o=>0!==r[o])){for(t in l)i.o(l,t)&&(i.m[t]=l[t]);if(v)var p=v(i)}for(o&&o(e);si(698));t=i.O(t)})(); \ No newline at end of file diff --git a/build/index.js.map b/build/index.js.map deleted file mode 100644 index 3d451f2..0000000 --- a/build/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;AAAA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AW;WAC5C;WACA,E;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA,4G;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://priority-plus-nav-block/./node_modules/@wordpress/icons/build-module/library/plus-circle.js","webpack://priority-plus-nav-block/./src/extend.js","webpack://priority-plus-nav-block/./src/index.js","webpack://priority-plus-nav-block/./src/style.scss","webpack://priority-plus-nav-block/external window [\"wp\",\"blockEditor\"]","webpack://priority-plus-nav-block/external window [\"wp\",\"blocks\"]","webpack://priority-plus-nav-block/external window [\"wp\",\"components\"]","webpack://priority-plus-nav-block/external window [\"wp\",\"compose\"]","webpack://priority-plus-nav-block/external window [\"wp\",\"hooks\"]","webpack://priority-plus-nav-block/external window [\"wp\",\"i18n\"]","webpack://priority-plus-nav-block/external window [\"wp\",\"primitives\"]","webpack://priority-plus-nav-block/external window \"ReactJSXRuntime\"","webpack://priority-plus-nav-block/webpack/bootstrap","webpack://priority-plus-nav-block/webpack/runtime/chunk loaded","webpack://priority-plus-nav-block/webpack/runtime/compat get default export","webpack://priority-plus-nav-block/webpack/runtime/define property getters","webpack://priority-plus-nav-block/webpack/runtime/hasOwnProperty shorthand","webpack://priority-plus-nav-block/webpack/runtime/make namespace object","webpack://priority-plus-nav-block/webpack/runtime/jsonp chunk loading","webpack://priority-plus-nav-block/webpack/before-startup","webpack://priority-plus-nav-block/webpack/startup","webpack://priority-plus-nav-block/webpack/after-startup"],"sourcesContent":["// packages/icons/src/library/plus-circle.tsx\nimport { Path, SVG } from \"@wordpress/primitives\";\nimport { jsx } from \"react/jsx-runtime\";\nvar plus_circle_default = /* @__PURE__ */ jsx(SVG, { xmlns: \"http://www.w3.org/2000/svg\", viewBox: \"0 0 24 24\", children: /* @__PURE__ */ jsx(\n Path,\n {\n fillRule: \"evenodd\",\n clipRule: \"evenodd\",\n d: \"M7.404 16.596a6.5 6.5 0 1 0 9.192-9.192 6.5 6.5 0 0 0-9.192 9.192ZM6.344 6.343a8 8 0 1 0 11.313 11.314A8 8 0 0 0 6.343 6.343Zm4.906 9.407v-3h-3v-1.5h3v-3h1.5v3h3v1.5h-3v3h-1.5Z\"\n }\n) });\nexport {\n plus_circle_default as default\n};\n//# sourceMappingURL=plus-circle.js.map\n","/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { addFilter } from '@wordpress/hooks';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { PanelBody, TextControl, SelectControl } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { registerBlockVariation } from '@wordpress/blocks';\nimport { plusCircle } from '@wordpress/icons';\n\n/**\n * Add Priority+ attributes to core/navigation block\n */\naddFilter(\n\t'blocks.registerBlockType',\n\t'priority-nav/extend-core-navigation',\n\t( settings, name ) => {\n\t\tif ( name !== 'core/navigation' ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\treturn {\n\t\t\t...settings,\n\t\t\tattributes: {\n\t\t\t\t...settings.attributes,\n\t\t\t\tpriorityNavEnabled: {\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t},\n\t\t\t\tpriorityNavMoreLabel: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'More',\n\t\t\t\t},\n\t\t\t\tpriorityNavMoreIcon: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'dots',\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n);\n\n/**\n * Add Inspector Controls to core/navigation block\n */\nconst withPriorityNavControls = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn ( props ) => {\n\t\tconst { name, attributes, setAttributes } = props;\n\n\t\tif ( name !== 'core/navigation' ) {\n\t\t\treturn ;\n\t\t}\n\n\t\tconst {\n\t\t\tpriorityNavEnabled,\n\t\t\tpriorityNavMoreLabel,\n\t\t\tpriorityNavMoreIcon,\n\t\t} = attributes;\n\n\t\t// Only show controls if Priority Nav is enabled\n\t\tif ( ! priorityNavEnabled ) {\n\t\t\treturn ;\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tsetAttributes( { priorityNavMoreLabel: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Text displayed on the \"More\" button',\n\t\t\t\t\t\t\t\t'priority-nav'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tsetAttributes( { priorityNavMoreIcon: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t);\n\t};\n}, 'withPriorityNavControls' );\n\naddFilter(\n\t'editor.BlockEdit',\n\t'priority-nav/add-priority-nav-controls',\n\twithPriorityNavControls\n);\n\n/**\n * Register block variation for Priority+ Navigation\n */\nregisterBlockVariation( 'core/navigation', {\n\tname: 'lumen-priority-nav',\n\ttitle: __( 'Priority+ Nav', 'priority-nav' ),\n\tdescription: __(\n\t\t'A responsive navigation that automatically moves overflow items to a \"More\" dropdown.',\n\t\t'priority-nav'\n\t),\n\ticon: plusCircle,\n\tattributes: {\n\t\tpriorityNavEnabled: true,\n\t\tpriorityNavMoreLabel: 'Browse',\n\t\tpriorityNavMoreIcon: 'none',\n\t},\n\tscope: [ 'inserter', 'block' ],\n\tisActive: ( blockAttributes ) => {\n\t\treturn !! blockAttributes.priorityNavEnabled;\n\t},\n} );\n","import './extend';\nimport './style.scss';\n","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"compose\"];","module.exports = window[\"wp\"][\"hooks\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"primitives\"];","module.exports = window[\"ReactJSXRuntime\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Check if module exists (development only)\n\tif (__webpack_modules__[moduleId] === undefined) {\n\t\tvar e = new Error(\"Cannot find module '\" + moduleId + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkpriority_plus_nav_block\"] = globalThis[\"webpackChunkpriority_plus_nav_block\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["__","addFilter","InspectorControls","PanelBody","TextControl","SelectControl","createHigherOrderComponent","registerBlockVariation","plusCircle","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","settings","name","attributes","priorityNavEnabled","type","default","priorityNavMoreLabel","priorityNavMoreIcon","withPriorityNavControls","BlockEdit","props","setAttributes","children","title","label","value","onChange","help","options","description","icon","scope","isActive","blockAttributes"],"ignoreList":[],"sourceRoot":""} \ No newline at end of file diff --git a/build/index.asset.php b/build/priority-editor.asset.php similarity index 62% rename from build/index.asset.php rename to build/priority-editor.asset.php index 99e860e..99a410e 100644 --- a/build/index.asset.php +++ b/build/priority-editor.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-hooks', 'wp-i18n', 'wp-primitives'), 'version' => 'ef033ea779e09cc8622b'); + array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-hooks', 'wp-i18n', 'wp-primitives'), 'version' => '8329a80772c4c16c8436'); diff --git a/build/priority-editor.js b/build/priority-editor.js new file mode 100644 index 0000000..9320099 --- /dev/null +++ b/build/priority-editor.js @@ -0,0 +1 @@ +(()=>{"use strict";const o=window.wp.i18n,e=window.wp.blocks,r=window.wp.primitives,i=window.ReactJSXRuntime;var t=(0,i.jsx)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(r.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M7.404 16.596a6.5 6.5 0 1 0 9.192-9.192 6.5 6.5 0 0 0-9.192 9.192ZM6.344 6.343a8 8 0 1 0 11.313 11.314A8 8 0 0 0 6.343 6.343Zm4.906 9.407v-3h-3v-1.5h3v-3h1.5v3h3v1.5h-3v3h-1.5Z"})});const n=window.wp.hooks;(0,e.registerBlockVariation)("core/navigation",{name:"priority-nav",title:(0,o.__)("Priority+ Nav","priority-nav"),description:(0,o.__)('A responsive navigation that automatically moves overflow items to a "More" dropdown.',"priority-nav"),icon:t,scope:["inserter","transform"],attributes:{className:"is-style-priority-nav",overlayMenu:"never",priorityNavEnabled:!0,priorityNavMoreLabel:"Browse",priorityNavMoreIcon:"none"},isActive:(o,e)=>o.className?.includes(e.className)}),(0,n.addFilter)("blocks.registerBlockType","priority-nav/extend-core-navigation",(o,e)=>"core/navigation"!==e?o:{...o,attributes:{...o.attributes,priorityNavEnabled:{type:"boolean",default:!1},priorityNavMoreLabel:{type:"string",default:"Browse"},priorityNavMoreIcon:{type:"string",default:"none"}}});const a=window.wp.blockEditor,l=window.wp.components,s=(0,window.wp.compose.createHigherOrderComponent)(e=>r=>{const{name:t,attributes:n,setAttributes:s}=r;if("core/navigation"!==t)return(0,i.jsx)(e,{...r});const{priorityNavEnabled:v,priorityNavMoreLabel:p,priorityNavMoreIcon:c}=n;return(0,i.jsxs)(i.Fragment,{children:[v&&(0,i.jsx)("div",{className:"priority-nav-editor-wrapper",children:(0,i.jsx)(e,{...r})}),!v&&(0,i.jsx)(e,{...r}),(0,i.jsx)(a.InspectorControls,{children:(0,i.jsxs)(l.PanelBody,{title:(0,o.__)("Priority+ Settings","priority-nav"),children:[(0,i.jsx)(l.TextControl,{label:(0,o.__)("More Button Label","priority-nav"),value:p,onChange:o=>s({priorityNavMoreLabel:o}),help:(0,o.__)('Text displayed on the "More" button',"priority-nav")}),(0,i.jsx)(l.SelectControl,{label:(0,o.__)("More Button Icon","priority-nav"),value:c,options:[{label:(0,o.__)("None","priority-nav"),value:"none"},{label:(0,o.__)("Chevron Down (▼)","priority-nav"),value:"chevron"},{label:(0,o.__)("Plus (+)","priority-nav"),value:"plus"},{label:(0,o.__)("Menu (≡)","priority-nav"),value:"menu"}],onChange:o=>s({priorityNavMoreIcon:o})})]})})]})},"withPriorityNavControls");(0,n.addFilter)("editor.BlockEdit","priority-nav/add-priority-nav-controls",s)})(); \ No newline at end of file diff --git a/build/priority-plus-nav.asset.php b/build/priority-plus-nav.asset.php new file mode 100644 index 0000000..8d819ce --- /dev/null +++ b/build/priority-plus-nav.asset.php @@ -0,0 +1 @@ + array(), 'version' => '51fcd302839f0a1322ce'); diff --git a/build/priority-plus-nav.js b/build/priority-plus-nav.js new file mode 100644 index 0000000..a34549d --- /dev/null +++ b/build/priority-plus-nav.js @@ -0,0 +1 @@ +(()=>{"use strict";var t,e={103(){class t{static instanceCounter=0;static DEFAULT_MORE_LABEL="Browse";static DEFAULT_MORE_ICON="none";static DEFAULT_GAP=8;static RETRY_INTERVAL=100;static MAX_RETRY_ATTEMPTS=20;constructor(e){"true"!==e.dataset.priorityNavInitialized&&(this.instanceId="priority-nav-"+t.instanceCounter++,e.classList.contains("wp-block-navigation")&&e.classList.contains("is-style-priority-nav")&&(e.dataset.priorityNavInitialized="true",this.nav=e,this.wrapper=e,this.nav&&(this.list=this.nav.querySelector(".wp-block-navigation__container"),this.moreLabel=this.nav.getAttribute("data-more-label")||t.DEFAULT_MORE_LABEL,this.moreIcon=this.nav.getAttribute("data-more-icon")||t.DEFAULT_MORE_ICON,this.openSubmenusOnClick=this.detectOpenSubmenusOnClick(),this.list&&(this.createMoreButton(),this.items=Array.from(this.list.children),this.itemWidths=[],this.isOpen=!1,this.isCalculating=!1,this.openAccordions=[],this.submenuCounter=0,this.responsiveContainer=this.nav.querySelector(".wp-block-navigation__responsive-container"),this.mutationObserver=null,this.retryTimeout=null,this.isEnabled=!0,this.moreButtonWidth=null,this.init()))))}detectOpenSubmenusOnClick(){let t=null;if(this.nav.attributes)for(let e=0;e0&&i.height>0}getElementWidth(t){return this.isElementVisible(t)?t.getBoundingClientRect().width:0}createMoreButton(){this.moreContainer=document.createElement("div"),this.moreContainer.className="priority-nav-more",this.moreButton=document.createElement("button"),this.moreButton.type="button",this.moreButton.className="priority-nav-more-button wp-block-navigation-item",this.moreButton.setAttribute("aria-expanded","false"),this.moreButton.setAttribute("aria-haspopup","true"),this.moreButton.setAttribute("aria-label",this.moreLabel);const t={chevron:"▼",plus:"+",menu:"≡"},e=t[this.moreIcon]?`${t[this.moreIcon]}`:"";this.moreButton.innerHTML=`\n\t\t\t${this.moreLabel}\n\t\t\t${e}\n\t\t`,this.dropdown=document.createElement("ul"),this.dropdown.className="priority-nav-dropdown wp-block-navigation__submenu-container",this.dropdown.setAttribute("role","menu"),this.moreContainer.appendChild(this.moreButton),this.moreContainer.appendChild(this.dropdown),this.list.parentNode.appendChild(this.moreContainer),this.moreContainer.style.display="none"}init(){this.wrapper&&document.body.contains(this.wrapper)&&(this.setupEventListeners(),this.setupResponsiveObserver(),this.isInHamburgerMode()?this.disablePriorityNav():this.enablePriorityNav(),"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(()=>{if(document.body.contains(this.wrapper)&&!this.isCalculating){const t=this.isEnabled,e=this.isInHamburgerMode();e&&t?this.disablePriorityNav():e||t?!e&&t&&requestAnimationFrame(()=>this.checkOverflow()):this.enablePriorityNav()}}),this.resizeObserver.observe(this.wrapper)))}isInHamburgerMode(){return!(!this.responsiveContainer||this.isElementVisible(this.responsiveContainer)&&"true"!==this.responsiveContainer.getAttribute("aria-hidden"))||!(!this.list||this.isElementVisible(this.list))}isMeasurable(){return this.isElementVisible(this.list)}disablePriorityNav(){this.items&&Array.isArray(this.items)&&(this.isEnabled=!1,this.items.forEach(t=>{t&&t.style&&(t.style.display="")}),this.moreContainer&&this.moreContainer.style&&(this.moreContainer.style.display="none"),this.closeDropdown())}enablePriorityNav(){this.isEnabled=!0,this.isMeasurable()?((0===this.itemWidths.length||this.itemWidths.some(t=>0===t))&&this.cacheItemWidths(),requestAnimationFrame(()=>{this.checkOverflow()})):this.scheduleRetry()}scheduleRetry(e=t.MAX_RETRY_ATTEMPTS){this.retryTimeout&&clearTimeout(this.retryTimeout);let i=0;const s=()=>{i++,this.isMeasurable()&&!this.isInHamburgerMode()?(this.enablePriorityNav(),this.retryTimeout=null):this.retryTimeout=i{if(!document.body.contains(this.nav))return;let e=!1;if(t.forEach(t=>{"attributes"!==t.type||"aria-hidden"!==t.attributeName&&"class"!==t.attributeName||(e=!0)}),e){const t=this.isInHamburgerMode();t&&this.isEnabled?this.disablePriorityNav():t||this.isEnabled||this.enablePriorityNav()}}),this.mutationObserver.observe(this.responsiveContainer,{attributes:!0,attributeFilter:["aria-hidden","class"]}),this.list&&document.body.contains(this.list)&&this.mutationObserver.observe(this.list,{attributes:!0,attributeFilter:["style","class"],attributeOldValue:!1}))}hasValidWidthCache(){return this.itemWidths.length===this.items.length&&!this.itemWidths.some(t=>0===t)}cacheItemWidths(){this.isMeasurable()&&(this.items.forEach(t=>{t.style.display=""}),this.list.offsetHeight,this.itemWidths=this.items.map(t=>{const e=this.getElementWidth(t);return e>0?e:0}),this.itemWidths.some(t=>0===t)&&this.scheduleRetry())}cacheMoreButtonWidth(){if(null!==this.moreButtonWidth)return this.moreButtonWidth;const t="none"===this.moreContainer.style.display;return t&&(this.moreContainer.style.display=""),this.moreButton.offsetHeight,this.moreButtonWidth=this.getElementWidth(this.moreButton),t&&(this.moreContainer.style.display="none"),this.moreButtonWidth}setupEventListeners(){this.moreButtonClickHandler=t=>{t.preventDefault(),t.stopPropagation(),this.toggleDropdown()},this.moreButton.addEventListener("click",this.moreButtonClickHandler),this.documentClickHandler=t=>{this.moreContainer&&!this.moreContainer.contains(t.target)&&this.isOpen&&this.closeDropdown()},document.addEventListener("click",this.documentClickHandler,!0),this.documentKeydownHandler=t=>{"Escape"===t.key&&this.isOpen&&(this.openAccordions.length>0?(this.closeAllAccordions(),t.preventDefault()):this.closeDropdown())},document.addEventListener("keydown",this.documentKeydownHandler),this.dropdownClickHandler=t=>{const e=t.target.closest(".priority-nav-accordion-toggle");if(e){t.preventDefault(),t.stopPropagation();const i=e.getAttribute("aria-controls"),s=this.dropdown.querySelector(`#${i}`);s&&this.toggleAccordionItem(e,s)}},this.dropdown.addEventListener("click",this.dropdownClickHandler)}calculateAvailableWidth(){const t=this.nav.getBoundingClientRect(),e=window.getComputedStyle(this.nav),i=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight),s=t.width>0?t.width:this.getElementWidth(this.wrapper);return s>0?s-i:0}getGap(){const e=window.getComputedStyle(this.list),i=window.getComputedStyle(this.nav);return parseFloat(e.gap)||parseFloat(i.gap)||t.DEFAULT_GAP}calculateVisibleItems(t,e,i){let s=0;for(let t=0;t0?i:0)+this.itemWidths[t];if(s<=t)return this.items.length;let n=0,r=0;for(let s=0;s0?i:0)+this.itemWidths[s];if(!(n+o+i+e<=t)&&0!==s)break;n+=o,r++}return r}buildDropdownFromOverflow(t){this.dropdown.innerHTML="",this.submenuCounter=0;for(let e=t;e=t)return this.items.forEach(t=>t.style.display="none"),this.moreContainer.style.display="",void(this.isCalculating=!1);const i=this.getGap(),s=this.calculateVisibleItems(t,e,i);if(s===this.items.length)this.items.forEach(t=>t.style.display=""),this.moreContainer.style.display="none",this.closeDropdown();else{this.moreContainer.style.display="none";for(let t=s;tt.remove());let s=i.textContent.trim();if(!s){const e=Array.from(t.childNodes).filter(t=>t.nodeType===Node.TEXT_NODE);e.length>0&&(s=e.map(t=>t.textContent.trim()).filter(t=>t).join(" "))}return s}removeChildTextFromParent(t,e){if(!t||!e)return t;const i=[];if(e.querySelectorAll("li a").forEach(e=>{const s=e.textContent.trim();s&&t.includes(s)&&i.push(s)}),i.length>0){let e=t;return i.forEach(t=>{e=e.replace(t,"").trim()}),e}return t}extractNavItemData(t){const e={text:"",url:"#",hasSubmenu:!1,children:[]},i=t.querySelector(":scope > .wp-block-navigation__submenu-container");let s=t.querySelector(":scope > a");if(s||(s=t.querySelector(":scope > .wp-block-navigation-item__content a")),!s){if(i){const i=t.cloneNode(!0),s=i.querySelector(".wp-block-navigation__submenu-container");s&&s.remove(),e.text=i.textContent.trim()}else e.text=t.textContent.trim();return i&&(e.hasSubmenu=!0,i.querySelectorAll(":scope > li").forEach(t=>{e.children.push(this.extractNavItemData(t))})),e}return e.text=this.extractLinkText(s),i&&e.text&&(e.text=this.removeChildTextFromParent(e.text,i)),e.url=s.getAttribute("href")||"#",i&&(e.hasSubmenu=!0,i.querySelectorAll(":scope > li").forEach(t=>{e.children.push(this.extractNavItemData(t))})),e}buildAccordionHTML(t,e){const i=`${this.instanceId}-submenu-${this.submenuCounter++}`;let s="";return t.hasSubmenu?(s=this.openSubmenusOnClick?`\n\t\t\t\t\t\n\t\t\t\t\t