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MlB,EAAcqB,WAAY,CAAE1B,MAAO,MAC3C,CAAEuB,KAAMf,EAAW6C,WAAY,KAC/B,CAAE9B,KAAMlB,EAAcqB,WAAY,CAAE1B,MAAO,MAC3C,CAAEuB,KAAMf,EAAW6C,WAAY,OAEhC,CACDA,WAAY,CACV,CAAE9B,KAAMf,EAAW6C,WAAY,WAC/B,CAAE9B,KAAMpB,KAET,CACDkD,WAAY,CAAC,CAAE9B,KAAMhB,SAM7B0F,EAAS/F,EAAW,CAClBc,MAAO,QACPsF,MAAO,4MACP7E,QAAS,CAAEF,KAAMrB,KAGnB+F,EAAS9F,EAAc,CACrBa,MAAO,WACPsF,MAAO,qQACP7E,QAAS,CAAEF,KAAMpB,KAGnB8F,EAAS7F,EAAY,CACnBY,MAAO,SACPsF,MAAO,iOACP7E,QAAS,CAAEF,KAAMnB,KAGnB6F,EAAS1F,EAAY,CACnBS,MAAO,SACPsF,MAAO,+MACP7E,QAAS,CAAEF,KAAMhB,KAGnB0F,EAASzF,EAAW,CAClBQ,MAAO,QACPsF,MAAO,yQACP7E,QAAS,CAAEF,KAAMf,KAGnByF,EAAS5F,EAAc,CACrBW,MAAO,WACPsF,MAAO,gNACP7E,QAAS,CAAEF,KAAMlB,KAGnB4F,EAAS3F,EAAW,CAClBU,MAAO,QACPsF,MAAO,2QACP7E,QAAS,CAAEF,KAAMjB,IAErB,CFlEE,CAAWI,EAAQE,EACrB,E","sources":["webpack://grapesjs-plugin-forms/webpack/universalModuleDefinition","webpack://grapesjs-plugin-forms/webpack/bootstrap","webpack://grapesjs-plugin-forms/webpack/runtime/define property getters","webpack://grapesjs-plugin-forms/webpack/runtime/hasOwnProperty shorthand","webpack://grapesjs-plugin-forms/webpack/runtime/make namespace object","webpack://grapesjs-plugin-forms/./src/components.ts","webpack://grapesjs-plugin-forms/./src/index.ts","webpack://grapesjs-plugin-forms/./src/traits.ts","webpack://grapesjs-plugin-forms/./src/blocks.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-plugin-forms\"] = factory();\n\telse\n\t\troot[\"grapesjs-plugin-forms\"] = 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';\n\nexport const typeForm = 'form';\nexport const typeInput = 'input';\nexport const typeTextarea = 'textarea';\nexport const typeSelect = 'select';\nexport const typeCheckbox = 'checkbox';\nexport const typeRadio = 'radio';\nexport const typeButton = 'button';\nexport const typeLabel = 'label';\nexport const typeOption = 'option';\n\nexport default function(editor: Editor) {\n const { Components } = editor;\n\n const idTrait = {\n name: 'id',\n };\n\n const forTrait = {\n name: 'for',\n };\n\n const nameTrait = {\n name: 'name',\n };\n\n const placeholderTrait = {\n name: 'placeholder',\n };\n\n const valueTrait = {\n name: 'value',\n };\n\n const requiredTrait = {\n type: 'checkbox',\n name: 'required',\n };\n\n const checkedTrait = {\n type: 'checkbox',\n name: 'checked',\n };\n\n const createOption = (value: string, content: string) => {\n return { type: typeOption, content, attributes: { value } };\n };\n\n const checkIfInPreview = (ev: Event) => {\n if (!editor.Commands.isActive('preview')) {\n ev.preventDefault();\n }\n };\n\n Components.addType(typeForm, {\n isComponent: el => el.tagName == 'FORM',\n\n model: {\n defaults: {\n tagName: 'form',\n droppable: ':not(form)',\n draggable: ':not(form)',\n attributes: { method: 'get' },\n traits: [{\n type: 'select',\n name: 'method',\n options: [\n {value: 'get', name: 'GET'},\n {value: 'post', name: 'POST'},\n ],\n }, {\n name: 'action',\n }],\n },\n },\n\n view: {\n events: {\n // The submit of the form might redirect the user from the editor so\n // we should always prevent the default here.\n submit: (e: Event) => e.preventDefault(),\n } as any\n },\n });\n\n\n\n\n\n // INPUT\n Components.addType(typeInput, {\n isComponent: el => el.tagName == 'INPUT',\n\n model: {\n defaults: {\n tagName: 'input',\n droppable: false,\n highlightable: false,\n attributes: { type: 'text' },\n traits: [\n nameTrait,\n placeholderTrait,\n {\n type: 'select',\n name: 'type',\n options: [\n { value: 'text' },\n { value: 'email' },\n { value: 'password' },\n { value: 'number' },\n ]\n },\n requiredTrait\n ],\n },\n },\n\n extendFnView: ['updateAttributes'],\n view: {\n updateAttributes() {\n this.el.setAttribute('autocomplete', 'off');\n },\n }\n });\n\n\n\n\n\n // TEXTAREA\n Components.addType(typeTextarea, {\n extend: typeInput,\n isComponent: el => el.tagName == 'TEXTAREA',\n\n model: {\n defaults: {\n tagName: 'textarea',\n attributes: {},\n traits: [\n nameTrait,\n placeholderTrait,\n requiredTrait\n ]\n },\n },\n });\n\n\n\n\n\n // OPTION\n Components.addType(typeOption, {\n isComponent: el => el.tagName == 'OPTION',\n\n model: {\n defaults: {\n tagName: 'option',\n layerable: false,\n droppable: false,\n draggable: false,\n highlightable: false,\n },\n },\n });\n\n\n\n\n\n // SELECT\n Components.addType(typeSelect, {\n isComponent: el => el.tagName == 'SELECT',\n\n model: {\n defaults: {\n tagName: 'select',\n droppable: false,\n highlightable: false,\n components: [\n createOption('opt1', 'Option 1'),\n createOption('opt2', 'Option 2'),\n ],\n traits: [\n nameTrait,\n {\n name: 'options',\n type: 'select-options'\n },\n requiredTrait\n ],\n },\n },\n\n view: {\n events: {\n mousedown: checkIfInPreview,\n } as any,\n },\n });\n\n\n\n\n\n // CHECKBOX\n Components.addType(typeCheckbox, {\n extend: typeInput,\n isComponent: (el) => el.tagName == 'INPUT' && (el as HTMLInputElement).type == 'checkbox',\n\n model: {\n defaults: {\n copyable: false,\n attributes: { type: 'checkbox' },\n traits: [\n idTrait,\n nameTrait,\n valueTrait,\n requiredTrait,\n checkedTrait\n ],\n },\n },\n\n view: {\n events: {\n click: checkIfInPreview,\n } as any,\n\n init() {\n this.listenTo(this.model, 'change:attributes:checked', this.handleChecked);\n },\n\n handleChecked() {\n (this.el as any).checked = !!this.model.get('attributes')?.checked;\n },\n },\n });\n\n\n\n\n\n // RADIO\n Components.addType(typeRadio, {\n extend: typeCheckbox,\n isComponent: el => el.tagName == 'INPUT' && (el as HTMLInputElement).type == 'radio',\n\n model: {\n defaults: {\n attributes: { type: 'radio' },\n },\n },\n });\n\n\n\n\n\n Components.addType(typeButton, {\n extend: typeInput,\n isComponent: el => el.tagName == 'BUTTON',\n\n model: {\n defaults: {\n tagName: 'button',\n attributes: { type: 'button' },\n text: 'Send',\n traits: [\n {\n name: 'text',\n changeProp: true,\n }, {\n type: 'select',\n name: 'type',\n options: [\n { value: 'button' },\n { value: 'submit' },\n { value: 'reset' },\n ]\n }]\n },\n\n init() {\n const comps = this.components();\n const tChild = comps.length === 1 && comps.models[0];\n const chCnt = (tChild && tChild.is('textnode') && tChild.get('content')) || '';\n const text = chCnt || this.get('text');\n this.set('text', text);\n this.on('change:text', this.__onTextChange);\n (text !== chCnt) && this.__onTextChange();\n },\n\n __onTextChange() {\n this.components(this.get('text'));\n },\n },\n\n view: {\n events: {\n click: checkIfInPreview,\n } as any,\n },\n });\n\n\n\n\n\n // LABEL\n Components.addType(typeLabel, {\n extend: 'text',\n isComponent: el => el.tagName == 'LABEL',\n\n model: {\n defaults: {\n tagName: 'label',\n components: 'Label' as any,\n traits: [forTrait],\n },\n },\n });\n}\n","import type { BlockProperties, Plugin } from 'grapesjs';\nimport loadBlocks from './blocks';\nimport loadComponents from './components';\nimport loadTraits from './traits';\n\nexport type PluginOptions = {\n /**\n * Which blocks to add.\n * @default ['form', 'input', 'textarea', 'select', 'button', 'label', 'checkbox', 'radio']\n */\n blocks?: string[];\n\n /**\n * Category name for blocks.\n * @default 'Forms'\n */\n category?: BlockProperties[\"category\"];\n\n /**\n * Add custom block options, based on block id.\n * @default (blockId) => ({})\n * @example (blockId) => blockId === 'input' ? { attributes: {...} } : {};\n */\n block?: (blockId: string) => ({});\n};\n\nconst plugin: Plugin = (editor, opts = {}) => {\n const config: Required = {\n blocks: ['form', 'input', 'textarea', 'select', 'button', 'label', 'checkbox', 'radio'],\n category: { id: 'forms', label: 'Forms' },\n block: () => ({}),\n ...opts\n };\n\n loadComponents(editor);\n loadTraits(editor);\n loadBlocks(editor, config);\n};\n\nexport default plugin;\n","import type { Editor } from 'grapesjs';\nimport { typeOption } from './components';\n\nexport default function (editor: Editor) {\n const trm = editor.TraitManager;\n\n trm.addType('select-options', {\n events:{\n keyup: 'onChange',\n },\n\n onValueChange() {\n const { model, target } = this;\n const optionsStr = model.get('value').trim();\n const options = optionsStr.split('\\n');\n const optComps = [];\n\n for (let i = 0; i < options.length; i++) {\n const optionStr = options[i];\n const option = optionStr.split('::');\n optComps.push({\n type: typeOption,\n components: option[1] || option[0],\n attributes: { value: option[0] },\n });\n }\n\n target.components().reset(optComps);\n target.view?.render();\n },\n\n getInputEl() {\n if (!this.$input) {\n const optionsArr = [];\n const options = this.target.components();\n\n for (let i = 0; i < options.length; i++) {\n const option = options.models[i];\n const optAttr = option.get('attributes');\n const optValue = optAttr?.value || '';\n const optTxtNode = option.components().models[0];\n const optLabel = optTxtNode && optTxtNode.get('content') || '';\n optionsArr.push(`${optValue}::${optLabel}`);\n }\n\n const el = document.createElement('textarea');\n el.value = optionsArr.join(\"\\n\");\n this.$input = el as any;\n }\n\n return this.$input;\n \t},\n });\n}\n","import type { BlockProperties, Editor } from 'grapesjs';\nimport { PluginOptions } from '.';\nimport {\n typeButton,\n typeCheckbox,\n typeForm,\n typeInput,\n typeLabel,\n typeRadio,\n typeSelect,\n typeTextarea,\n} from './components';\n\nexport default function (editor: Editor, opt: Required) {\n const opts = opt;\n const bm = editor.BlockManager;\n const addBlock = (id: string, def: BlockProperties) => {\n opts.blocks?.indexOf(id)! >= 0 && bm.add(id, {\n ...def,\n category: opts.category,\n select: true,\n ...opt.block(id),\n });\n }\n\n addBlock(typeForm, {\n label: 'Form',\n media: '',\n content: {\n type: typeForm,\n components: [\n {\n components: [\n { type: typeLabel, components: 'Name' },\n { type: typeInput },\n ]\n }, {\n components: [\n { type: typeLabel, components: 'Email' },\n { type: typeInput, attributes: { type: 'email' } },\n ]\n }, {\n components: [\n { type: typeLabel, components: 'Gender' },\n { type: typeCheckbox, attributes: { value: 'M' } },\n { type: typeLabel, components: 'M' },\n { type: typeCheckbox, attributes: { value: 'F' } },\n { type: typeLabel, components: 'F' },\n ]\n }, {\n components: [\n { type: typeLabel, components: 'Message' },\n { type: typeTextarea },\n ]\n }, {\n components: [{ type: typeButton }]\n },\n ]\n }\n });\n\n addBlock(typeInput, {\n label: 'Input',\n media: '',\n content: { type: typeInput },\n });\n\n addBlock(typeTextarea, {\n label: 'Textarea',\n media: '',\n content: { type: typeTextarea },\n });\n\n addBlock(typeSelect, {\n label: 'Select',\n media: '',\n content: { type: typeSelect },\n });\n\n addBlock(typeButton, {\n label: 'Button',\n media: '',\n content: { type: typeButton },\n });\n\n addBlock(typeLabel, {\n label: 'Label',\n media: '',\n content: { type: typeLabel },\n });\n\n addBlock(typeCheckbox, {\n label: 'Checkbox',\n media: '',\n content: { type: typeCheckbox },\n });\n\n addBlock(typeRadio, {\n label: 'Radio',\n media: '',\n content: { type: typeRadio },\n });\n}\n"],"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","typeForm","typeInput","typeTextarea","typeSelect","typeCheckbox","typeRadio","typeButton","typeLabel","typeOption","editor","opts","config","blocks","category","id","label","block","Components","nameTrait","name","placeholderTrait","requiredTrait","type","createOption","content","attributes","checkIfInPreview","ev","Commands","isActive","preventDefault","addType","isComponent","el","tagName","model","defaults","droppable","draggable","method","traits","options","view","events","submit","e","highlightable","extendFnView","updateAttributes","setAttribute","extend","layerable","components","mousedown","copyable","click","init","listenTo","handleChecked","checked","text","changeProp","comps","tChild","length","models","chCnt","is","set","on","__onTextChange","TraitManager","keyup","onValueChange","target","trim","split","optComps","i","option","push","reset","render","getInputEl","$input","optionsArr","optAttr","optValue","optTxtNode","optLabel","document","createElement","join","opt","bm","BlockManager","addBlock","def","indexOf","add","select","media"],"sourceRoot":""}