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rBkB,EAAWhC,GAAe,GAE9B,IACAH,EAAgB,EAhBK,CAkBzB,IAOAC,EAAUC,GAAkB,CAC9B,EACAjB,WAAY,CAAEC,MAAO,UAAGb,EAAS,YACjCc,WAAY,CACV,CAAEC,KAAMT,GACR,CAAES,KAAMT,GACR,CAAES,KAAMT,QAMhBT,EAAWU,QAAQD,EAAkB,CACnCE,MAAO,CACLC,SAAU,CACRE,KAAM,cACND,WAAW,EACXS,WAAW,EACXG,eAAe,EACfV,WAAY,CAAEC,MAAO,UAAGb,EAAS,oBAIxC,E,+OCvOD,QAfsC,SAACL,EAAQC,QAAA,IAAAA,IAAAA,EAAA,IAC7C,IAAMmE,EAAO,GACXjE,GAAI,SACJC,MAAO,SACPiE,MAAO,CAAC,EACR/C,MAAO,GACPC,gBAAiB,GACjBjB,YAAa,UACVL,IFlDP,SAAgBD,EAAgBC,GACtB,IAAAoE,EAAqBpE,EAAI,MAAlBG,EAAcH,EAAI,MAAXE,EAAOF,EAAI,GAE7BoE,GACFrE,EAAOsE,OAAOC,IAAIpE,EAAI,EAAF,CAClBqE,MAAO,uOAGPpE,MAAK,EACLqE,SAAU,QACVC,QAAQ,EACRC,QAAS,CAAEvD,KAAMjB,IACdkE,GAGR,CEsCC,CAAWrE,EAAQoE,GACnB,EAAepE,EAAQoE,EACzB,E","sources":["webpack://grapesjs-navbar/webpack/universalModuleDefinition","webpack://grapesjs-navbar/webpack/bootstrap","webpack://grapesjs-navbar/webpack/runtime/define property getters","webpack://grapesjs-navbar/webpack/runtime/hasOwnProperty shorthand","webpack://grapesjs-navbar/webpack/runtime/make namespace object","webpack://grapesjs-navbar/./src/blocks.ts","webpack://grapesjs-navbar/./src/components.ts","webpack://grapesjs-navbar/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"grapesjs-navbar\"] = factory();\n\telse\n\t\troot[\"grapesjs-navbar\"] = factory();\n})(typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : this), () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\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};","import type { Editor } from 'grapesjs';\nimport { RequiredPluginOptions } from '.';\n\nexport default (editor: Editor, opts: RequiredPluginOptions) => {\n const { block, label, id } = opts;\n\n if (block) {\n editor.Blocks.add(id, {\n media: ``,\n label,\n category: 'Extra',\n select: true,\n content: { type: id },\n ...block,\n });\n }\n}\n","import type { Editor } from 'grapesjs';\nimport { RequiredPluginOptions } from '.';\n\nexport default (editor: Editor, opts: RequiredPluginOptions) => {\n const { Components } = editor;\n const { id, label } = opts;\n\n const navbarPfx = opts.classPrefix;\n const idContainer = `${id}-container`;\n const idNavMenu = `${id}-nav-menu`;\n const idNavMenuLink = `${id}-nav-menu-link`;\n const idBurgerMenu = `${id}-burger-menu`;\n const idBurgerMenuLine = `${id}-burger-menu-line`;\n\n Components.addType(id, {\n model: {\n defaults: {\n droppable: false,\n name: label,\n attributes: { class: navbarPfx },\n components: { type: idContainer },\n styles: (opts.style || `\n .${navbarPfx} {\n background-color: #222;\n color: #ddd;\n min-height: 50px;\n width: 100%;\n }\n\n .${navbarPfx}-container {\n max-width: 950px;\n margin: 0 auto;\n width: 95%;\n }\n\n .${navbarPfx}-items-c {\n display: inline-block;\n float: right;\n }\n\n .${navbarPfx}-container::after {\n content: \"\";\n clear: both;\n display: block;\n }\n\n .${navbarPfx}-brand {\n vertical-align: top;\n display: inline-block;\n padding: 5px;\n min-height: 50px;\n min-width: 50px;\n color: inherit;\n text-decoration: none;\n }\n\n .${navbarPfx}-menu {\n padding: 10px 0;\n display: block;\n float: right;\n margin: 0;\n }\n\n .${navbarPfx}-menu-link {\n margin: 0;\n color: inherit;\n text-decoration: none;\n display: inline-block;\n padding: 10px 15px;\n }\n\n .${navbarPfx}-burger {\n margin: 10px 0;\n width: 45px;\n padding: 5px 10px;\n display: none;\n float: right;\n cursor: pointer;\n }\n\n .${navbarPfx}-burger-line {\n padding: 1px;\n background-color: white;\n margin: 5px 0;\n }\n\n @media (max-width: 768px) {\n .${navbarPfx}-items-c {\n display: none;\n width: 100%;\n }\n\n .${navbarPfx}-burger {\n display: block;\n }\n\n .${navbarPfx}-menu {\n width: 100%;\n }\n\n .${navbarPfx}-menu-link {\n display: block;\n }\n }\n `) + opts.styleAdditional,\n },\n }\n });\n\n Components.addType(idContainer, {\n model: {\n defaults: {\n attributes: { class: `${navbarPfx}-container`, 'data-gjs': 'navbar' },\n name: 'Navbar Container',\n droppable: false,\n draggable: false,\n removable: false,\n copyable: false,\n highlightable: false,\n components: [\n {\n type: 'link',\n attributes: { class: `${navbarPfx}-brand`, href: '/' },\n },\n { type: idBurgerMenu },\n {\n attributes: { class: `${navbarPfx}-items-c`, 'data-gjs': 'navbar-items' },\n components: { type: idNavMenu },\n }\n ]\n }\n }\n });\n\n Components.addType(idNavMenu, {\n model: {\n defaults: {\n name: 'Navbar Menu',\n tagName: 'nav',\n attributes: { class: `${navbarPfx}-menu` },\n components: [\n { type: idNavMenuLink, components: 'Home' },\n { type: idNavMenuLink, components: 'About' },\n { type: idNavMenuLink, components: 'Contact' },\n ]\n }\n }\n });\n\n Components.addType(idNavMenuLink, {\n extend: 'link',\n model: {\n defaults: {\n name: 'Menu link',\n draggable: `[data-gjs-type=\"${idNavMenu}\"]`,\n attributes: { class: `${navbarPfx}-menu-link` },\n }\n }\n });\n\n Components.addType(idBurgerMenu, {\n model: {\n defaults: {\n name: 'Burger',\n draggable: false,\n droppable: false,\n copyable: false,\n removable: false,\n script: function () {\n // @ts-ignore\n const currentEl = this as HTMLElement;\n const stringCollapse = 'gjs-collapse';\n const clickEvent = 'click';\n const transitProp = 'max-height';\n let transEndAdded: any;\n let isAnimating = 0;\n\n const getTransitionEvent = function() {\n const el = document.createElement('void');\n const transitions: Record = {\n 'transition': 'transitionend',\n 'OTransition': 'oTransitionEnd',\n 'MozTransition': 'transitionend',\n 'WebkitTransition': 'webkitTransitionEnd'\n }\n\n for (let t in transitions) {\n // @ts-ignore\n if (el.style[t] !== undefined){\n return transitions[t];\n }\n }\n }\n\n const transitEndEvent = getTransitionEvent();\n\n var getElHeight = function(el: HTMLElement): number {\n const style = window.getComputedStyle(el);\n const elDisplay = style.display;\n // @ts-ignore\n const elMaxHeight = parseInt(style[transitProp]);\n\n if (elDisplay !== 'none' && elMaxHeight !== 0) {\n return el.offsetHeight;\n }\n\n el.style.height = 'auto';\n el.style.display = 'block';\n el.style.position = 'absolute';\n el.style.visibility = 'hidden';\n const height = el.offsetHeight;\n el.style.height = '';\n el.style.display = '';\n el.style.position = '';\n el.style.visibility = '';\n\n return height;\n };\n\n var toggleSlide = function(el: HTMLElement) {\n isAnimating = 1;\n var elMaxHeight = getElHeight(el);\n var elStyle: any = el.style;\n elStyle.display = 'block';\n elStyle.transition = `${transitProp} 0.25s ease-in-out`;\n elStyle.overflowY = 'hidden';\n\n if (elStyle[transitProp] == '') {\n elStyle[transitProp] = 0;\n }\n\n if (parseInt(elStyle[transitProp]) == 0) {\n elStyle[transitProp] = '0';\n setTimeout(function() {\n elStyle[transitProp] = elMaxHeight + 'px';\n }, 10);\n } else {\n elStyle[transitProp] = '0';\n }\n }\n\n const toggle = function(ev: Event) {\n ev.preventDefault();\n if (isAnimating) return;\n\n const navParent = currentEl.closest(`[data-gjs=navbar]`);\n const navItems = navParent?.querySelector(`[data-gjs=navbar-items]`) as HTMLElement;\n navItems && toggleSlide(navItems);\n\n if (!transEndAdded) {\n // @ts-ignore\n navItems?.addEventListener(transitEndEvent, function() {\n isAnimating = 0;\n const itemsStyle: any = navItems.style;\n if (parseInt(itemsStyle[transitProp]) == 0) {\n itemsStyle.display = '';\n itemsStyle[transitProp] = '';\n }\n });\n transEndAdded = 1;\n }\n };\n\n if ( !(stringCollapse in currentEl) ) {\n currentEl.addEventListener(clickEvent, toggle);\n }\n\n // @ts-ignore\n currentEl[stringCollapse] = 1;\n },\n attributes: { class: `${navbarPfx}-burger` },\n components: [\n { type: idBurgerMenuLine },\n { type: idBurgerMenuLine },\n { type: idBurgerMenuLine },\n ]\n },\n },\n });\n\n Components.addType(idBurgerMenuLine, {\n model: {\n defaults: {\n name: 'Burger Line',\n droppable: false,\n draggable: false,\n highlightable: false,\n attributes: { class: `${navbarPfx}-burger-line` },\n },\n },\n });\n}\n","import type { BlockProperties, Plugin } from 'grapesjs';\nimport loadBlocks from './blocks';\nimport loadComponents from './components';\n\nexport type PluginOptions = {\n /**\n * The ID used to create the block and component\n * @default 'navbar'\n */\n id?: string;\n\n /**\n * The label used for the block and the component.\n * @default 'Navbar'\n */\n label?: string,\n\n /**\n * Object to extend the default block. Pass a falsy value to avoid adding the block.\n * @example\n * { category: 'Extra', ... }\n */\n block?: Partial;\n\n /**\n * Custom CSS styles for the component. This will replace the default one.\n * @default ''\n */\n style?: string,\n\n /**\n * Additional CSS styles for the component. These will be appended to the default one.\n * @default ''\n */\n styleAdditional?: string,\n\n /**\n * Component class prefix.\n * @default 'navbar'\n */\n classPrefix?: string,\n};\n\nexport type RequiredPluginOptions = Required;\n\nconst plugin: Plugin = (editor, opts = {}) => {\n const options: RequiredPluginOptions = {\n id: 'navbar',\n label: 'Navbar',\n block: {},\n style: '',\n styleAdditional: '',\n classPrefix: 'navbar',\n ...opts,\n };\n\n loadBlocks(editor, options);\n loadComponents(editor, options);\n};\n\nexport default plugin;"],"names":["root","factory","exports","module","define","amd","globalThis","window","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","editor","opts","Components","id","label","navbarPfx","classPrefix","idContainer","idNavMenu","idNavMenuLink","idBurgerMenu","idBurgerMenuLine","addType","model","defaults","droppable","name","attributes","class","components","type","styles","style","styleAdditional","draggable","removable","copyable","highlightable","href","tagName","extend","script","transEndAdded","currentEl","stringCollapse","transitProp","isAnimating","transitEndEvent","el","document","createElement","transitions","t","undefined","getTransitionEvent","toggleSlide","elMaxHeight","getComputedStyle","elDisplay","display","parseInt","offsetHeight","height","position","visibility","getElHeight","elStyle","transition","overflowY","setTimeout","addEventListener","ev","preventDefault","navParent","closest","navItems","querySelector","itemsStyle","options","block","Blocks","add","media","category","select","content"],"sourceRoot":""}