formvuelatte
Advanced tools
Comparing version 2.0.0-alpha.1 to 2.0.0-alpha.2
@@ -208,25 +208,31 @@ module.exports = | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaForm.vue?vue&type=template&id=ca301692 | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaForm.vue?vue&type=template&id=458d5d8c | ||
var _hoisted_1 = { | ||
class: "schema-form" | ||
}; | ||
function render(_ctx, _cache) { | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", _hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "beforeForm"), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.parsedSchema, function (field) { | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDynamicComponent"])(field.component), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["mergeProps"])({ | ||
key: field.model | ||
}, _ctx.binds(field), { | ||
modelValue: _ctx.val(field), | ||
"onUpdate:modelValue": function onUpdateModelValue($event) { | ||
return _ctx.update(field.model, $event); | ||
}, | ||
"onUpdate-batch": function onUpdateBatch($event) { | ||
return _ctx.updateBatch(field.model, $event); | ||
} | ||
}), null, 16, ["modelValue", "onUpdate:modelValue", "onUpdate-batch"]); | ||
}), 128 | ||
/* KEYED_FRAGMENT */ | ||
)), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "afterForm")]); | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDynamicComponent"])(!_ctx.hasParentSchema ? 'form' : 'div'), _ctx.formBinds, { | ||
default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { | ||
return [!_ctx.hasParentSchema ? Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "beforeForm", { | ||
key: 0 | ||
}) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.parsedSchema, function (field) { | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDynamicComponent"])(field.component), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["mergeProps"])({ | ||
key: field.model | ||
}, _ctx.binds(field), { | ||
modelValue: _ctx.val(field), | ||
"onUpdate:modelValue": function onUpdateModelValue($event) { | ||
return _ctx.update(field.model, $event); | ||
}, | ||
"onUpdate-batch": function onUpdateBatch($event) { | ||
return _ctx.updateBatch(field.model, $event); | ||
} | ||
}), null, 16, ["modelValue", "onUpdate:modelValue", "onUpdate-batch"]); | ||
}), 128 | ||
/* KEYED_FRAGMENT */ | ||
)), !_ctx.hasParentSchema ? Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "afterForm", { | ||
key: 0 | ||
}) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]; | ||
}), | ||
_: 1 | ||
}, 16); | ||
} | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue?vue&type=template&id=ca301692 | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue?vue&type=template&id=458d5d8c | ||
@@ -248,2 +254,3 @@ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaForm.vue?vue&type=script&lang=js | ||
/* harmony default export */ var SchemaFormvue_type_script_lang_js = ({ | ||
emits: ['submit'], | ||
props: { | ||
@@ -276,3 +283,10 @@ schema: { | ||
setup: function setup(props, _ref) { | ||
var emit = _ref.emit; | ||
var emit = _ref.emit, | ||
attrs = _ref.attrs; | ||
var hasParentSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["inject"])('parentSchemaExists', false); | ||
if (!hasParentSchema) { | ||
Object(external_commonjs_vue_commonjs2_vue_root_Vue_["provide"])('parentSchemaExists', true); | ||
} | ||
var parsedSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
@@ -343,2 +357,11 @@ if (Array.isArray(props.schema)) return props.schema; | ||
var formBinds = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
if (hasParentSchema) return {}; | ||
return { | ||
'onSubmit': function onSubmit(event) { | ||
event.preventDefault(); | ||
emit('submit', event); | ||
} | ||
}; | ||
}); | ||
return { | ||
@@ -349,3 +372,5 @@ parsedSchema: parsedSchema, | ||
update: update, | ||
updateBatch: updateBatch | ||
updateBatch: updateBatch, | ||
hasParentSchema: hasParentSchema, | ||
formBinds: formBinds | ||
}; | ||
@@ -363,8 +388,12 @@ } | ||
/* harmony default export */ var SchemaForm = (SchemaFormvue_type_script_lang_js); | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaWizard.vue?vue&type=template&id=68d96300 | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaWizard.vue?vue&type=template&id=65a11896 | ||
function SchemaWizardvue_type_template_id_68d96300_render(_ctx, _cache) { | ||
function SchemaWizardvue_type_template_id_65a11896_render(_ctx, _cache) { | ||
var _component_SchemaForm = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("SchemaForm"); | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_SchemaForm, { | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("form", { | ||
onSubmit: _cache[2] || (_cache[2] = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withModifiers"])(function ($event) { | ||
return _ctx.$emit('submit', $event); | ||
}, ["prevent"])) | ||
}, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "beforeForm"), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_SchemaForm, { | ||
schema: _ctx.currentSchema, | ||
@@ -375,5 +404,5 @@ value: _ctx.modelValue[_ctx.step] || {}, | ||
}) | ||
}, null, 8, ["schema", "value"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "default")]); | ||
}, null, 8, ["schema", "value"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "afterForm")], 32); | ||
} | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=template&id=68d96300 | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=template&id=65a11896 | ||
@@ -415,2 +444,3 @@ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaWizard.vue?vue&type=script&lang=js | ||
setup: function setup(props, context) { | ||
Object(external_commonjs_vue_commonjs2_vue_root_Vue_["provide"])('parentSchemaExists', true); | ||
var currentSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
@@ -439,3 +469,3 @@ return props.schema[props.step]; | ||
SchemaWizardvue_type_script_lang_js.render = SchemaWizardvue_type_template_id_68d96300_render | ||
SchemaWizardvue_type_script_lang_js.render = SchemaWizardvue_type_template_id_65a11896_render | ||
@@ -442,0 +472,0 @@ /* harmony default export */ var SchemaWizard = (SchemaWizardvue_type_script_lang_js); |
@@ -217,25 +217,31 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaForm.vue?vue&type=template&id=ca301692 | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaForm.vue?vue&type=template&id=458d5d8c | ||
var _hoisted_1 = { | ||
class: "schema-form" | ||
}; | ||
function render(_ctx, _cache) { | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", _hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "beforeForm"), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.parsedSchema, function (field) { | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDynamicComponent"])(field.component), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["mergeProps"])({ | ||
key: field.model | ||
}, _ctx.binds(field), { | ||
modelValue: _ctx.val(field), | ||
"onUpdate:modelValue": function onUpdateModelValue($event) { | ||
return _ctx.update(field.model, $event); | ||
}, | ||
"onUpdate-batch": function onUpdateBatch($event) { | ||
return _ctx.updateBatch(field.model, $event); | ||
} | ||
}), null, 16, ["modelValue", "onUpdate:modelValue", "onUpdate-batch"]); | ||
}), 128 | ||
/* KEYED_FRAGMENT */ | ||
)), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "afterForm")]); | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDynamicComponent"])(!_ctx.hasParentSchema ? 'form' : 'div'), _ctx.formBinds, { | ||
default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { | ||
return [!_ctx.hasParentSchema ? Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "beforeForm", { | ||
key: 0 | ||
}) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.parsedSchema, function (field) { | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDynamicComponent"])(field.component), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["mergeProps"])({ | ||
key: field.model | ||
}, _ctx.binds(field), { | ||
modelValue: _ctx.val(field), | ||
"onUpdate:modelValue": function onUpdateModelValue($event) { | ||
return _ctx.update(field.model, $event); | ||
}, | ||
"onUpdate-batch": function onUpdateBatch($event) { | ||
return _ctx.updateBatch(field.model, $event); | ||
} | ||
}), null, 16, ["modelValue", "onUpdate:modelValue", "onUpdate-batch"]); | ||
}), 128 | ||
/* KEYED_FRAGMENT */ | ||
)), !_ctx.hasParentSchema ? Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "afterForm", { | ||
key: 0 | ||
}) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]; | ||
}), | ||
_: 1 | ||
}, 16); | ||
} | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue?vue&type=template&id=ca301692 | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue?vue&type=template&id=458d5d8c | ||
@@ -257,2 +263,3 @@ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaForm.vue?vue&type=script&lang=js | ||
/* harmony default export */ var SchemaFormvue_type_script_lang_js = ({ | ||
emits: ['submit'], | ||
props: { | ||
@@ -285,3 +292,10 @@ schema: { | ||
setup: function setup(props, _ref) { | ||
var emit = _ref.emit; | ||
var emit = _ref.emit, | ||
attrs = _ref.attrs; | ||
var hasParentSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["inject"])('parentSchemaExists', false); | ||
if (!hasParentSchema) { | ||
Object(external_commonjs_vue_commonjs2_vue_root_Vue_["provide"])('parentSchemaExists', true); | ||
} | ||
var parsedSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
@@ -352,2 +366,11 @@ if (Array.isArray(props.schema)) return props.schema; | ||
var formBinds = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
if (hasParentSchema) return {}; | ||
return { | ||
'onSubmit': function onSubmit(event) { | ||
event.preventDefault(); | ||
emit('submit', event); | ||
} | ||
}; | ||
}); | ||
return { | ||
@@ -358,3 +381,5 @@ parsedSchema: parsedSchema, | ||
update: update, | ||
updateBatch: updateBatch | ||
updateBatch: updateBatch, | ||
hasParentSchema: hasParentSchema, | ||
formBinds: formBinds | ||
}; | ||
@@ -372,8 +397,12 @@ } | ||
/* harmony default export */ var SchemaForm = (SchemaFormvue_type_script_lang_js); | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaWizard.vue?vue&type=template&id=68d96300 | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaWizard.vue?vue&type=template&id=65a11896 | ||
function SchemaWizardvue_type_template_id_68d96300_render(_ctx, _cache) { | ||
function SchemaWizardvue_type_template_id_65a11896_render(_ctx, _cache) { | ||
var _component_SchemaForm = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("SchemaForm"); | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_SchemaForm, { | ||
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("form", { | ||
onSubmit: _cache[2] || (_cache[2] = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withModifiers"])(function ($event) { | ||
return _ctx.$emit('submit', $event); | ||
}, ["prevent"])) | ||
}, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "beforeForm"), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_SchemaForm, { | ||
schema: _ctx.currentSchema, | ||
@@ -384,5 +413,5 @@ value: _ctx.modelValue[_ctx.step] || {}, | ||
}) | ||
}, null, 8, ["schema", "value"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "default")]); | ||
}, null, 8, ["schema", "value"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "afterForm")], 32); | ||
} | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=template&id=68d96300 | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=template&id=65a11896 | ||
@@ -424,2 +453,3 @@ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaWizard.vue?vue&type=script&lang=js | ||
setup: function setup(props, context) { | ||
Object(external_commonjs_vue_commonjs2_vue_root_Vue_["provide"])('parentSchemaExists', true); | ||
var currentSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
@@ -448,3 +478,3 @@ return props.schema[props.step]; | ||
SchemaWizardvue_type_script_lang_js.render = SchemaWizardvue_type_template_id_68d96300_render | ||
SchemaWizardvue_type_script_lang_js.render = SchemaWizardvue_type_template_id_65a11896_render | ||
@@ -451,0 +481,0 @@ /* harmony default export */ var SchemaWizard = (SchemaWizardvue_type_script_lang_js); |
@@ -1,2 +0,2 @@ | ||
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["formvuelatte"]=t(require("vue")):e["formvuelatte"]=t(e["Vue"])})("undefined"!==typeof self?self:this,(function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="fb15")}({8875:function(e,t,r){var n,o,u;(function(r,c){o=[],n=c,u="function"===typeof n?n.apply(t,o):n,void 0===u||(e.exports=u)})("undefined"!==typeof self&&self,(function(){function e(){if(document.currentScript)return document.currentScript;try{throw new Error}catch(d){var e,t,r,n=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,o=/@([^@]*):(\d+):(\d+)\s*$/gi,u=n.exec(d.stack)||o.exec(d.stack),c=u&&u[1]||!1,a=u&&u[2]||!1,i=document.location.href.replace(document.location.hash,""),l=document.getElementsByTagName("script");c===i&&(e=document.documentElement.outerHTML,t=new RegExp("(?:[^\\n]+?\\n){0,"+(a-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),r=e.replace(t,"$1").trim());for(var f=0;f<l.length;f++){if("interactive"===l[f].readyState)return l[f];if(l[f].src===c)return l[f];if(c===i&&l[f].innerHTML&&l[f].innerHTML.trim()===r)return l[f]}return null}}return e}))},"8bbf":function(t,r){t.exports=e},fb15:function(e,t,r){"use strict";if(r.r(t),"undefined"!==typeof window){var n=window.document.currentScript,o=r("8875");n=o(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:o});var u=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);u&&(r.p=u[1])}var c=r("8bbf"),a={class:"schema-form"};function i(e,t){return Object(c["openBlock"])(),Object(c["createBlock"])("div",a,[Object(c["renderSlot"])(e.$slots,"beforeForm"),(Object(c["openBlock"])(!0),Object(c["createBlock"])(c["Fragment"],null,Object(c["renderList"])(e.parsedSchema,(function(t){return Object(c["openBlock"])(),Object(c["createBlock"])(Object(c["resolveDynamicComponent"])(t.component),Object(c["mergeProps"])({key:t.model},e.binds(t),{modelValue:e.val(t),"onUpdate:modelValue":function(r){return e.update(t.model,r)},"onUpdate-batch":function(r){return e.updateBatch(t.model,r)}}),null,16,["modelValue","onUpdate:modelValue","onUpdate-batch"])})),128)),Object(c["renderSlot"])(e.$slots,"afterForm")])}function l(e){if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=f(e))){var t=0,r=function(){};return{s:r,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o,u=!0,c=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return u=e.done,e},e:function(e){c=!0,o=e},f:function(){try{u||null==n.return||n.return()}finally{if(c)throw o}}}}function f(e,t){if(e){if("string"===typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var b={props:{schema:{type:[Object,Array],required:!0,validator:function(e){return!Array.isArray(e)||0===e.filter((function(e){return!e.model&&!e.schema})).length}},modelValue:{type:Object,required:!0},sharedConfig:{type:Object,default:function(){return{}}},preventModelCleanupOnSchemaChange:{type:Boolean,default:!1}},setup:function(e,t){var r=t.emit,n=Object(c["computed"])((function(){if(Array.isArray(e.schema))return e.schema;var t=[];for(var r in e.schema)t.push(m(m({},e.schema[r]),{},{model:r}));return t}));Object(c["watch"])(n,(function(t,n){if(!e.preventModelCleanupOnSchemaChange){var o=t.map((function(e){return e.model})),u=n.map((function(e){return e.model})).filter((function(e){return!o.includes(e)}));if(u.length){var c,a=m({},e.modelValue),i=l(u);try{for(i.s();!(c=i.n()).done;){var f=c.value;delete a[f]}}catch(d){i.e(d)}finally{i.f()}r("update:modelValue",a)}}}));var o=function(t,n){r("update:modelValue",m(m({},e.modelValue),{},s({},t,n)))},u=function(t,n){r("update:modelValue",m(m({},e.modelValue),n))},a=function(t){return t.schema?{schema:t.schema}:m(m({},e.sharedConfig),t)},i=function(t){return t.schema&&!e.modelValue[t.model]?{}:e.modelValue[t.model]};return{parsedSchema:n,val:i,binds:a,update:o,updateBatch:u}}};b.render=i;var y=b;function v(e,t){var r=Object(c["resolveComponent"])("SchemaForm");return Object(c["openBlock"])(),Object(c["createBlock"])("div",null,[Object(c["createVNode"])(r,{schema:e.currentSchema,value:e.modelValue[e.step]||{},onInput:t[1]||(t[1]=function(t){return e.update(t)})},null,8,["schema","value"]),Object(c["renderSlot"])(e.$slots,"default")])}function O(e){return S(e)||g(e)||j(e)||h()}function h(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function j(e,t){if(e){if("string"===typeof e)return w(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(e,t):void 0}}function g(e){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function S(e){if(Array.isArray(e))return w(e)}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var P={components:{SchemaForm:y},props:{schema:{type:Array,required:!0},step:{type:Number,required:!0,default:0},modelValue:{type:Array,required:!0}},setup:function(e,t){var r=Object(c["computed"])((function(){return e.schema[e.step]})),n=function(r){var n=O(e.modelValue);n[e.step]=r,t.emit("update:modelValue",n)};return{currentSchema:r,update:n}}};P.render=v;var A=P;function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach((function(t){k(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function k(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function B(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=y.setup;function r(r,n){var o=t(r,n);return e.length?e.reduce((function(e,t){return t(e,r,n)}),o):o}return x(x({},y),{},{setup:r})}var D=y;r.d(t,"SchemaForm",(function(){return y})),r.d(t,"SchemaWizard",(function(){return A})),r.d(t,"SchemaFormFactory",(function(){return B}));t["default"]=D}})})); | ||
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["formvuelatte"]=t(require("vue")):e["formvuelatte"]=t(e["Vue"])})("undefined"!==typeof self?self:this,(function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="fb15")}({8875:function(e,t,r){var n,o,c;(function(r,u){o=[],n=u,c="function"===typeof n?n.apply(t,o):n,void 0===c||(e.exports=c)})("undefined"!==typeof self&&self,(function(){function e(){if(document.currentScript)return document.currentScript;try{throw new Error}catch(d){var e,t,r,n=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,o=/@([^@]*):(\d+):(\d+)\s*$/gi,c=n.exec(d.stack)||o.exec(d.stack),u=c&&c[1]||!1,a=c&&c[2]||!1,i=document.location.href.replace(document.location.hash,""),l=document.getElementsByTagName("script");u===i&&(e=document.documentElement.outerHTML,t=new RegExp("(?:[^\\n]+?\\n){0,"+(a-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),r=e.replace(t,"$1").trim());for(var f=0;f<l.length;f++){if("interactive"===l[f].readyState)return l[f];if(l[f].src===u)return l[f];if(u===i&&l[f].innerHTML&&l[f].innerHTML.trim()===r)return l[f]}return null}}return e}))},"8bbf":function(t,r){t.exports=e},fb15:function(e,t,r){"use strict";if(r.r(t),"undefined"!==typeof window){var n=window.document.currentScript,o=r("8875");n=o(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:o});var c=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);c&&(r.p=c[1])}var u=r("8bbf");function a(e,t){return Object(u["openBlock"])(),Object(u["createBlock"])(Object(u["resolveDynamicComponent"])(e.hasParentSchema?"div":"form"),e.formBinds,{default:Object(u["withCtx"])((function(){return[e.hasParentSchema?Object(u["createCommentVNode"])("",!0):Object(u["renderSlot"])(e.$slots,"beforeForm",{key:0}),(Object(u["openBlock"])(!0),Object(u["createBlock"])(u["Fragment"],null,Object(u["renderList"])(e.parsedSchema,(function(t){return Object(u["openBlock"])(),Object(u["createBlock"])(Object(u["resolveDynamicComponent"])(t.component),Object(u["mergeProps"])({key:t.model},e.binds(t),{modelValue:e.val(t),"onUpdate:modelValue":function(r){return e.update(t.model,r)},"onUpdate-batch":function(r){return e.updateBatch(t.model,r)}}),null,16,["modelValue","onUpdate:modelValue","onUpdate-batch"])})),128)),e.hasParentSchema?Object(u["createCommentVNode"])("",!0):Object(u["renderSlot"])(e.$slots,"afterForm",{key:0})]})),_:1},16)}function i(e){if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=l(e))){var t=0,r=function(){};return{s:r,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o,c=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return c=e.done,e},e:function(e){u=!0,o=e},f:function(){try{c||null==n.return||n.return()}finally{if(u)throw o}}}}function l(e,t){if(e){if("string"===typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,t):void 0}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){m(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function m(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s={emits:["submit"],props:{schema:{type:[Object,Array],required:!0,validator:function(e){return!Array.isArray(e)||0===e.filter((function(e){return!e.model&&!e.schema})).length}},modelValue:{type:Object,required:!0},sharedConfig:{type:Object,default:function(){return{}}},preventModelCleanupOnSchemaChange:{type:Boolean,default:!1}},setup:function(e,t){var r=t.emit,n=(t.attrs,Object(u["inject"])("parentSchemaExists",!1));n||Object(u["provide"])("parentSchemaExists",!0);var o=Object(u["computed"])((function(){if(Array.isArray(e.schema))return e.schema;var t=[];for(var r in e.schema)t.push(p(p({},e.schema[r]),{},{model:r}));return t}));Object(u["watch"])(o,(function(t,n){if(!e.preventModelCleanupOnSchemaChange){var o=t.map((function(e){return e.model})),c=n.map((function(e){return e.model})).filter((function(e){return!o.includes(e)}));if(c.length){var u,a=p({},e.modelValue),l=i(c);try{for(l.s();!(u=l.n()).done;){var f=u.value;delete a[f]}}catch(d){l.e(d)}finally{l.f()}r("update:modelValue",a)}}}));var c=function(t,n){r("update:modelValue",p(p({},e.modelValue),{},m({},t,n)))},a=function(t,n){r("update:modelValue",p(p({},e.modelValue),n))},l=function(t){return t.schema?{schema:t.schema}:p(p({},e.sharedConfig),t)},f=function(t){return t.schema&&!e.modelValue[t.model]?{}:e.modelValue[t.model]},d=Object(u["computed"])((function(){return n?{}:{onSubmit:function(e){e.preventDefault(),r("submit",e)}}}));return{parsedSchema:o,val:f,binds:l,update:c,updateBatch:a,hasParentSchema:n,formBinds:d}}};s.render=a;var b=s;function y(e,t){var r=Object(u["resolveComponent"])("SchemaForm");return Object(u["openBlock"])(),Object(u["createBlock"])("form",{onSubmit:t[2]||(t[2]=Object(u["withModifiers"])((function(t){return e.$emit("submit",t)}),["prevent"]))},[Object(u["renderSlot"])(e.$slots,"beforeForm"),Object(u["createVNode"])(r,{schema:e.currentSchema,value:e.modelValue[e.step]||{},onInput:t[1]||(t[1]=function(t){return e.update(t)})},null,8,["schema","value"]),Object(u["renderSlot"])(e.$slots,"afterForm")],32)}function h(e){return g(e)||j(e)||v(e)||O()}function O(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(e,t){if(e){if("string"===typeof e)return S(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(e,t):void 0}}function j(e){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function g(e){if(Array.isArray(e))return S(e)}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var w={components:{SchemaForm:b},props:{schema:{type:Array,required:!0},step:{type:Number,required:!0,default:0},modelValue:{type:Array,required:!0}},setup:function(e,t){Object(u["provide"])("parentSchemaExists",!0);var r=Object(u["computed"])((function(){return e.schema[e.step]})),n=function(r){var n=h(e.modelValue);n[e.step]=r,t.emit("update:modelValue",n)};return{currentSchema:r,update:n}}};w.render=y;var P=w;function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function A(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach((function(t){x(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function x(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function k(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=b.setup;function r(r,n){var o=t(r,n);return e.length?e.reduce((function(e,t){return t(e,r,n)}),o):o}return A(A({},b),{},{setup:r})}var B=b;r.d(t,"SchemaForm",(function(){return b})),r.d(t,"SchemaWizard",(function(){return P})),r.d(t,"SchemaFormFactory",(function(){return k}));t["default"]=B}})})); | ||
//# sourceMappingURL=formvuelatte.umd.min.js.map |
{ | ||
"name": "formvuelatte", | ||
"version": "v2.0.0-alpha.1", | ||
"version": "v2.0.0-alpha.2", | ||
"description": "Schema Form Generator", | ||
@@ -56,3 +56,2 @@ "author": "Marina Mosti <marina@mosti.com.mx>", | ||
"vitepress": "^0.1.1", | ||
"vite": "^0.15.3", | ||
"vue": "v3.0.0-beta.12", | ||
@@ -59,0 +58,0 @@ "vue-cli-plugin-vue-next": "^0.1.2" |
237
README.md
@@ -270,4 +270,224 @@ # FormVueLatte | ||
## VuelidatePlugin | ||
### Lookup Plugin | ||
[Repository for Lookup Plugin](https://github.com/vuelidate/formvuelatte-plugin-lookup). | ||
Whenever you find yourself working with a `schema` that has already been generated or created with a specific structure that does not comply to the requirements of `SchemaForm`, it becomes a necessary step to parse it to modify the structure. | ||
In order to make this task easier, `FormVueLatte` provides a core plugin called `@formvuelatte/plugin-lookup`. | ||
#### Installation | ||
To install the plugin, simply add it to your `package.json` via terminal. | ||
```bash | ||
yarn add @formvuelatte/plugin-lookup | ||
// OR | ||
npm i @formvuelatte/plugin-lookup | ||
``` | ||
#### Usage | ||
To use the plugin, first import both the plugin itself, and the `SchemaFormFactory` to your application. | ||
```js | ||
import { SchemaFormFactory } from 'formvuelatte' | ||
import LookupPlugin from '@formvuelatte/plugin-lookup' | ||
``` | ||
Now that we have both imported, we can create our plugin-enabled `SchemaForm` component by using the `SchemaFormFactory` | ||
```js | ||
const SchemaFormWithPlugin = SchemaFormFactory([ | ||
LookupPlugin({ | ||
// plugin configuration here | ||
}) | ||
]) | ||
``` | ||
Now that we have created our new component, we can pass it to our instance's `components` object, and use it as we normally would in our template. | ||
```js | ||
export default { | ||
name: 'App', | ||
components: { | ||
SchemaFormWithPlugin | ||
}, | ||
setup () { | ||
[...] | ||
} | ||
} | ||
``` | ||
```html | ||
<template> | ||
<div id="app"> | ||
<SchemaFormWithPlugin | ||
:schema="mySchema" | ||
v-model="myData" | ||
/> | ||
</div> | ||
</template> | ||
``` | ||
**Important: ** Remember that `SchemaFormFactory` returns an extended version of `SchemaForm`, so all the props required by `SchemaForm` like `schema` and `modelValue`/`v-model` are still required. | ||
#### Configuration | ||
`LookupPlugin` takes one parameter, an object, as it's source of configuration. | ||
Let's look at the properties that we can use in this object. | ||
**componentProp** | ||
`SchemaForm` schemas expect each component inside of them to be defined with a `component` property, like in the following example. | ||
```json | ||
{ | ||
"firstName": { | ||
"component": "FormText", | ||
"label": "First name" | ||
} | ||
} | ||
``` | ||
In some cases the schema might define your `component` property with something else, like `type` like in the following example: | ||
```json | ||
{ | ||
"firstName": { | ||
"type": "FormText", | ||
"label": "First name" | ||
} | ||
} | ||
``` | ||
If this is the case, you can pass into the configuration the `componentProp` property with the name of what YOUR schema uses to define the component for each node. | ||
```js | ||
LookupPlugin({ | ||
componentProp: 'type' | ||
}) | ||
``` | ||
The plugin will handle parsing the schema from `type` into `component` for you now. | ||
**mapComponents** | ||
If your schema does not provide component names as your Vue application needs them, `mapComponents` is another property of the configuration object that can allow you to rename or remap these values with ease. | ||
Consider the following example schema. | ||
```json | ||
{ | ||
"firstName": { | ||
"component": "string", | ||
"label": "First name" | ||
}, | ||
"favoriteThingAboutVue": { | ||
"component": "array", | ||
"label": "Favorite thing about Vue", | ||
"required": true, | ||
"options": [ | ||
"Ease of use", | ||
"Documentation", | ||
"Community" | ||
] | ||
}, | ||
} | ||
``` | ||
In this case, the `component` definition is not `FormText`, or `FormSelect`, or whichever other components we may be using in our application. So we need to map them. | ||
Let's add this mapping into our configuration object. | ||
```js | ||
LookupPlugin({ | ||
mapComponents: { | ||
string: 'FormText', | ||
array: 'FormSelect' | ||
} | ||
}) | ||
``` | ||
`LookupPlugin` will now look inside your schema and parse all the `component` definitions into their respective components. So `string` will become `FormText` and `array` will become a `FormSelect` component. | ||
**mapProps** | ||
If your schema needs to parse additional props for your own component's needs, `mapProps` provides an easy way of parsing any property in your component's object definition to something else. | ||
Consider the following schema. | ||
```json | ||
{ | ||
"firstName": { | ||
"component": "FormText", | ||
"info": "First name" | ||
} | ||
} | ||
``` | ||
If we needed to map `info` to `label` because of what our component is expecting, by using `mapProps` in our configuration we can easily ask the plugin to do it for us. | ||
```js | ||
const SchemaFormWithPlugin = SchemaFormFactory([ | ||
LookupPlugin({ | ||
mapProps: { | ||
info: 'label' | ||
} | ||
}) | ||
]) | ||
``` | ||
Now our schema will correctly pass the `label` property into our `FormText` component. | ||
#### Nested Schema Caveats | ||
When dealing with schemas that have sub-schemas like the following: | ||
```json | ||
{ | ||
"firstName": { | ||
"component": "string", | ||
"info": "First Name" | ||
}, | ||
"work": { | ||
"component": "SchemaForm", | ||
"schema": { | ||
"address": { | ||
"type": "FormText", | ||
"label": "Work address" | ||
}, | ||
"details": { | ||
"component": "SchemaForm", | ||
"schema": { | ||
"position": { | ||
"type": "FormText", | ||
"label": "Work position" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
Make sure that you `mapComponents` and change `SchemaForm` for whatever you named the output of your `SchemaFormFactory` function call. | ||
```js | ||
// Note "SchemaFormWithPlugin" getting remapped | ||
const SchemaFormWithPlugin = SchemaFormFactory([ | ||
LookupPlugin({ | ||
SchemaForm: 'SchemaFormWithPlugin', | ||
[...] | ||
} | ||
}) | ||
]) | ||
``` | ||
### Vuelidate Plugin | ||
In order to seamlessly validate FormVueLatte by using Vuelidate, we provide a `VuelidatePlugin` that will allow you to easily accomplish this. | ||
@@ -313,3 +533,3 @@ | ||
const SchemaFormWithPlugins = SchemaFormFactory([ | ||
VuelidatePlugin(useVuelidate) | ||
VuelidatePlugin(useVuelidate) | ||
]) | ||
@@ -346,7 +566,7 @@ ``` | ||
<template> | ||
<SchemaFormWithValidations | ||
:schema="schema" | ||
v-model="userData" | ||
@update:validations="updateValidations" | ||
/> | ||
<SchemaFormWithValidations | ||
:schema="schema" | ||
v-model="userData" | ||
@update:validations="updateValidations" | ||
/> | ||
</template> | ||
@@ -357,2 +577,3 @@ ``` | ||
- [Marina Mosti](https://twitter.com/MarinaMosti) | ||
- [Damian Dulisz](https://twitter.com/DamianDulisz) | ||
- [Damian Dulisz](https://twitter.com/DamianDulisz) | ||
- [Tonina Zhelyazkova](https://twitter.com/tonina_zh) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
146255
14
18
1058
576
1