formvuelatte
Advanced tools
Comparing version 0.2.4 to 2.0.0-alpha.1
@@ -90,42 +90,84 @@ module.exports = | ||
/***/ "f6fd": | ||
/***/ (function(module, exports) { | ||
/***/ "8875": | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// document.currentScript polyfill by Adam Miller | ||
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// addapted from the document.currentScript polyfill by Adam Miller | ||
// MIT license | ||
// source: https://github.com/amiller-gh/currentScript-polyfill | ||
(function(document){ | ||
var currentScript = "currentScript", | ||
scripts = document.getElementsByTagName('script'); // Live NodeList collection | ||
// added support for Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1620505 | ||
// If browser needs currentScript polyfill, add get currentScript() to the document object | ||
if (!(currentScript in document)) { | ||
Object.defineProperty(document, currentScript, { | ||
get: function(){ | ||
(function (root, factory) { | ||
if (true) { | ||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), | ||
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? | ||
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} else {} | ||
}(typeof self !== 'undefined' ? self : this, function () { | ||
function getCurrentScript () { | ||
if (document.currentScript) { | ||
return document.currentScript | ||
} | ||
// IE 8-10 support script readyState | ||
// IE 11+ & Firefox support stack trace | ||
try { | ||
throw new Error(); | ||
} | ||
catch (err) { | ||
// Find the second match for the "at" string to get file src url from stack. | ||
var ieStackRegExp = /.*at [^(]*\((.*):(.+):(.+)\)$/ig, | ||
ffStackRegExp = /@([^@]*):(\d+):(\d+)\s*$/ig, | ||
stackDetails = ieStackRegExp.exec(err.stack) || ffStackRegExp.exec(err.stack), | ||
scriptLocation = (stackDetails && stackDetails[1]) || false, | ||
line = (stackDetails && stackDetails[2]) || false, | ||
currentLocation = document.location.href.replace(document.location.hash, ''), | ||
pageSource, | ||
inlineScriptSourceRegExp, | ||
inlineScriptSource, | ||
scripts = document.getElementsByTagName('script'); // Live NodeList collection | ||
if (scriptLocation === currentLocation) { | ||
pageSource = document.documentElement.outerHTML; | ||
inlineScriptSourceRegExp = new RegExp('(?:[^\\n]+?\\n){0,' + (line - 2) + '}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*', 'i'); | ||
inlineScriptSource = pageSource.replace(inlineScriptSourceRegExp, '$1').trim(); | ||
} | ||
for (var i = 0; i < scripts.length; i++) { | ||
// If ready state is interactive, return the script tag | ||
if (scripts[i].readyState === 'interactive') { | ||
return scripts[i]; | ||
} | ||
// If src matches, return the script tag | ||
if (scripts[i].src === scriptLocation) { | ||
return scripts[i]; | ||
} | ||
// If inline source matches, return the script tag | ||
if ( | ||
scriptLocation === currentLocation && | ||
scripts[i].innerHTML && | ||
scripts[i].innerHTML.trim() === inlineScriptSource | ||
) { | ||
return scripts[i]; | ||
} | ||
} | ||
// If no match, return null | ||
return null; | ||
} | ||
}; | ||
// IE 6-10 supports script readyState | ||
// IE 10+ support stack trace | ||
try { throw new Error(); } | ||
catch (err) { | ||
return getCurrentScript | ||
})); | ||
// Find the second match for the "at" string to get file src url from stack. | ||
// Specifically works with the format of stack traces in IE. | ||
var i, res = ((/.*at [^\(]*\((.*):.+:.+\)$/ig).exec(err.stack) || [false])[1]; | ||
// For all scripts on the page, if src matches or if ready state is interactive, return the script tag | ||
for(i in scripts){ | ||
if(scripts[i].src == res || scripts[i].readyState == "interactive"){ | ||
return scripts[i]; | ||
} | ||
} | ||
/***/ }), | ||
// If no match, return null | ||
return null; | ||
} | ||
} | ||
}); | ||
} | ||
})(document); | ||
/***/ "8bbf": | ||
/***/ (function(module, exports) { | ||
module.exports = require("vue"); | ||
@@ -144,9 +186,16 @@ /***/ }), | ||
if (typeof window !== 'undefined') { | ||
var currentScript = window.document.currentScript | ||
if (true) { | ||
__webpack_require__("f6fd") | ||
var getCurrentScript = __webpack_require__("8875") | ||
currentScript = getCurrentScript() | ||
// for backward compatibility, because previously we directly included the polyfill | ||
if (!('currentScript' in document)) { | ||
Object.defineProperty(document, 'currentScript', { get: getCurrentScript }) | ||
} | ||
} | ||
var i | ||
if ((i = window.document.currentScript) && (i = i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))) { | ||
__webpack_require__.p = i[1] // eslint-disable-line | ||
var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/) | ||
if (src) { | ||
__webpack_require__.p = src[1] // eslint-disable-line | ||
} | ||
@@ -158,36 +207,44 @@ } | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8337181c-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/SchemaForm.vue?vue&type=template&id=0e12d6ff& | ||
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_vm._t("beforeForm"),_c('form',{staticClass:"schema-form"},[_vm._l((_vm.parsedSchema),function(field){return _c(field.component,_vm._b({key:field.model,tag:"component",attrs:{"value":_vm.val(field)},on:{"input":function($event){return _vm.update(field.model, $event)},"update-batch":function($event){return _vm.updateBatch(field.model, $event)}}},'component',_vm.binds(field),false))}),_vm._t("default")],2),_vm._t("afterForm")],2)} | ||
var staticRenderFns = [] | ||
// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"} | ||
var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf"); | ||
// 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: ./src/SchemaForm.vue?vue&type=template&id=0e12d6ff& | ||
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")]); | ||
} | ||
// CONCATENATED MODULE: ./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/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/SchemaForm.vue?vue&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/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaForm.vue?vue&type=script&lang=js | ||
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } 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 it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
/* harmony default export */ var SchemaFormvue_type_script_lang_js_ = ({ | ||
/* harmony default export */ var SchemaFormvue_type_script_lang_js = ({ | ||
props: { | ||
@@ -204,3 +261,3 @@ schema: { | ||
}, | ||
value: { | ||
modelValue: { | ||
type: Object, | ||
@@ -211,12 +268,19 @@ required: true | ||
type: Object, | ||
required: false | ||
default: function _default() { | ||
return {}; | ||
} | ||
}, | ||
preventModelCleanupOnSchemaChange: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
computed: { | ||
parsedSchema: function parsedSchema() { | ||
if (Array.isArray(this.schema)) return this.schema; | ||
setup: function setup(props, _ref) { | ||
var emit = _ref.emit; | ||
var parsedSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
if (Array.isArray(props.schema)) return props.schema; | ||
var arraySchema = []; | ||
for (var model in this.schema) { | ||
arraySchema.push(_objectSpread({}, this.schema[model], { | ||
for (var model in props.schema) { | ||
arraySchema.push(_objectSpread(_objectSpread({}, props.schema[model]), {}, { | ||
model: model | ||
@@ -227,122 +291,67 @@ })); | ||
return arraySchema; | ||
} | ||
}, | ||
methods: { | ||
update: function update(property, value) { | ||
this.$emit('input', _objectSpread({}, this.value, _defineProperty({}, property, value))); | ||
}, | ||
updateBatch: function updateBatch(property, values) { | ||
this.$emit('input', _objectSpread({}, this.value, {}, values)); | ||
}, | ||
binds: function binds(field) { | ||
return field.schema ? { | ||
schema: field.schema | ||
} : _objectSpread({}, this.sharedConfig, {}, field); | ||
}, | ||
val: function val(field) { | ||
if (field.schema && !this.value[field.model]) { | ||
return {}; | ||
} | ||
}); | ||
Object(external_commonjs_vue_commonjs2_vue_root_Vue_["watch"])(parsedSchema, function (schema, oldSchema) { | ||
if (props.preventModelCleanupOnSchemaChange) return; | ||
var newKeys = schema.map(function (i) { | ||
return i.model; | ||
}); | ||
var diff = oldSchema.map(function (i) { | ||
return i.model; | ||
}).filter(function (i) { | ||
return !newKeys.includes(i); | ||
}); | ||
if (!diff.length) return; | ||
return this.value[field.model]; | ||
} | ||
} | ||
}); | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue?vue&type=script&lang=js& | ||
/* harmony default export */ var src_SchemaFormvue_type_script_lang_js_ = (SchemaFormvue_type_script_lang_js_); | ||
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js | ||
/* globals __VUE_SSR_CONTEXT__ */ | ||
var val = _objectSpread({}, props.modelValue); | ||
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules). | ||
// This module is a runtime utility for cleaner component module output and will | ||
// be included in the final webpack user bundle. | ||
var _iterator = _createForOfIteratorHelper(diff), | ||
_step; | ||
function normalizeComponent ( | ||
scriptExports, | ||
render, | ||
staticRenderFns, | ||
functionalTemplate, | ||
injectStyles, | ||
scopeId, | ||
moduleIdentifier, /* server only */ | ||
shadowMode /* vue-cli only */ | ||
) { | ||
// Vue.extend constructor export interop | ||
var options = typeof scriptExports === 'function' | ||
? scriptExports.options | ||
: scriptExports | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var key = _step.value; | ||
delete val[key]; | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
// render functions | ||
if (render) { | ||
options.render = render | ||
options.staticRenderFns = staticRenderFns | ||
options._compiled = true | ||
} | ||
emit('update:modelValue', val); | ||
}); | ||
// functional template | ||
if (functionalTemplate) { | ||
options.functional = true | ||
} | ||
var update = function update(property, value) { | ||
emit('update:modelValue', _objectSpread(_objectSpread({}, props.modelValue), {}, _defineProperty({}, property, value))); | ||
}; | ||
// scopedId | ||
if (scopeId) { | ||
options._scopeId = 'data-v-' + scopeId | ||
} | ||
var updateBatch = function updateBatch(property, values) { | ||
emit('update:modelValue', _objectSpread(_objectSpread({}, props.modelValue), values)); | ||
}; | ||
var hook | ||
if (moduleIdentifier) { // server build | ||
hook = function (context) { | ||
// 2.3 injection | ||
context = | ||
context || // cached call | ||
(this.$vnode && this.$vnode.ssrContext) || // stateful | ||
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional | ||
// 2.2 with runInNewContext: true | ||
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { | ||
context = __VUE_SSR_CONTEXT__ | ||
} | ||
// inject component styles | ||
if (injectStyles) { | ||
injectStyles.call(this, context) | ||
} | ||
// register component module identifier for async chunk inferrence | ||
if (context && context._registeredComponents) { | ||
context._registeredComponents.add(moduleIdentifier) | ||
} | ||
} | ||
// used by ssr in case component is cached and beforeCreate | ||
// never gets called | ||
options._ssrRegister = hook | ||
} else if (injectStyles) { | ||
hook = shadowMode | ||
? function () { injectStyles.call(this, this.$root.$options.shadowRoot) } | ||
: injectStyles | ||
} | ||
var binds = function binds(field) { | ||
return field.schema ? { | ||
schema: field.schema | ||
} : _objectSpread(_objectSpread({}, props.sharedConfig), field); | ||
}; | ||
if (hook) { | ||
if (options.functional) { | ||
// for template-only hot-reload because in that case the render fn doesn't | ||
// go through the normalizer | ||
options._injectStyles = hook | ||
// register for functioal component in vue file | ||
var originalRender = options.render | ||
options.render = function renderWithStyleInjection (h, context) { | ||
hook.call(context) | ||
return originalRender(h, context) | ||
var val = function val(field) { | ||
if (field.schema && !props.modelValue[field.model]) { | ||
return {}; | ||
} | ||
} else { | ||
// inject component registration as beforeCreate hook | ||
var existing = options.beforeCreate | ||
options.beforeCreate = existing | ||
? [].concat(existing, hook) | ||
: [hook] | ||
} | ||
} | ||
return { | ||
exports: scriptExports, | ||
options: options | ||
return props.modelValue[field.model]; | ||
}; | ||
return { | ||
parsedSchema: parsedSchema, | ||
val: val, | ||
binds: binds, | ||
update: update, | ||
updateBatch: updateBatch | ||
}; | ||
} | ||
} | ||
}); | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue?vue&type=script&lang=js | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue | ||
@@ -352,48 +361,36 @@ | ||
SchemaFormvue_type_script_lang_js.render = render | ||
/* 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 | ||
/* normalize component */ | ||
function SchemaWizardvue_type_template_id_68d96300_render(_ctx, _cache) { | ||
var _component_SchemaForm = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("SchemaForm"); | ||
var component = normalizeComponent( | ||
src_SchemaFormvue_type_script_lang_js_, | ||
render, | ||
staticRenderFns, | ||
false, | ||
null, | ||
null, | ||
null | ||
) | ||
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, { | ||
schema: _ctx.currentSchema, | ||
value: _ctx.modelValue[_ctx.step] || {}, | ||
onInput: _cache[1] || (_cache[1] = function ($event) { | ||
return _ctx.update($event); | ||
}) | ||
}, null, 8, ["schema", "value"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "default")]); | ||
} | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=template&id=68d96300 | ||
/* harmony default export */ var SchemaForm = (component.exports); | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8337181c-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/SchemaWizard.vue?vue&type=template&id=e92b45c6& | ||
var SchemaWizardvue_type_template_id_e92b45c6_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('SchemaForm',{attrs:{"schema":_vm.currentSchema,"value":_vm.value[_vm.step] || {}},on:{"input":_vm.update}}),_vm._t("default")],2)} | ||
var SchemaWizardvue_type_template_id_e92b45c6_staticRenderFns = [] | ||
// 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 | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || SchemaWizardvue_type_script_lang_js_unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=template&id=e92b45c6& | ||
function SchemaWizardvue_type_script_lang_js_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return SchemaWizardvue_type_script_lang_js_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return SchemaWizardvue_type_script_lang_js_arrayLikeToArray(o, minLen); } | ||
// 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/lib??vue-loader-options!./src/SchemaWizard.vue?vue&type=script&lang=js& | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return SchemaWizardvue_type_script_lang_js_arrayLikeToArray(arr); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function SchemaWizardvue_type_script_lang_js_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
/* harmony default export */ var SchemaWizardvue_type_script_lang_js_ = ({ | ||
/* harmony default export */ var SchemaWizardvue_type_script_lang_js = ({ | ||
components: { | ||
@@ -412,3 +409,3 @@ SchemaForm: SchemaForm | ||
}, | ||
value: { | ||
modelValue: { | ||
type: Array, | ||
@@ -418,18 +415,22 @@ required: true | ||
}, | ||
computed: { | ||
currentSchema: function currentSchema() { | ||
return this.schema[this.step]; | ||
} | ||
}, | ||
methods: { | ||
update: function update(data) { | ||
var value = _toConsumableArray(this.value); | ||
setup: function setup(props, context) { | ||
var currentSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
return props.schema[props.step]; | ||
}); | ||
value[this.step] = data; | ||
this.$emit('input', value); | ||
} | ||
var update = function update(data) { | ||
var value = _toConsumableArray(props.modelValue); | ||
value[props.step] = data; | ||
context.emit('update:modelValue', value); | ||
}; | ||
return { | ||
currentSchema: currentSchema, | ||
update: update | ||
}; | ||
} | ||
}); | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=script&lang=js& | ||
/* harmony default export */ var src_SchemaWizardvue_type_script_lang_js_ = (SchemaWizardvue_type_script_lang_js_); | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=script&lang=js | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue | ||
@@ -439,39 +440,36 @@ | ||
SchemaWizardvue_type_script_lang_js.render = SchemaWizardvue_type_template_id_68d96300_render | ||
/* harmony default export */ var SchemaWizard = (SchemaWizardvue_type_script_lang_js); | ||
// CONCATENATED MODULE: ./src/SchemaFormFactory.js | ||
function SchemaFormFactory_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
/* normalize component */ | ||
function SchemaFormFactory_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { SchemaFormFactory_ownKeys(Object(source), true).forEach(function (key) { SchemaFormFactory_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { SchemaFormFactory_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var SchemaWizard_component = normalizeComponent( | ||
src_SchemaWizardvue_type_script_lang_js_, | ||
SchemaWizardvue_type_template_id_e92b45c6_render, | ||
SchemaWizardvue_type_template_id_e92b45c6_staticRenderFns, | ||
false, | ||
null, | ||
null, | ||
null | ||
) | ||
function SchemaFormFactory_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/* harmony default export */ var SchemaWizard = (SchemaWizard_component.exports); | ||
// CONCATENATED MODULE: ./src/FormMixin.js | ||
/* harmony default export */ var FormMixin = ({ | ||
props: { | ||
value: { | ||
required: true | ||
}, | ||
required: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
config: { | ||
type: Object, | ||
default: function _default() {} | ||
function SchemaFormFactory() { | ||
var plugins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
// Copy the original SchemaForm setup | ||
var originalSetup = SchemaForm.setup; | ||
function setup(props, context) { | ||
// Call the original setup and preserve its results | ||
var baseSchemaFormReturns = originalSetup(props, context); | ||
if (!plugins.length) return baseSchemaFormReturns;else { | ||
// Apply plugins on the data returned | ||
// by the original Schemaform | ||
return plugins.reduce(function (schemaFormReturns, plugin) { | ||
return plugin(schemaFormReturns, props, context); | ||
}, baseSchemaFormReturns); | ||
} | ||
}, | ||
methods: { | ||
update: function update(value) { | ||
this.$emit('input', value); | ||
} | ||
} | ||
}); | ||
return SchemaFormFactory_objectSpread(SchemaFormFactory_objectSpread({}, SchemaForm), {}, { | ||
// Return a customized setup function with plugins | ||
// as the new SchemaForm setup | ||
setup: setup | ||
}); | ||
} | ||
// CONCATENATED MODULE: ./src/index.js | ||
@@ -481,3 +479,3 @@ | ||
/* harmony default export */ var src = (SchemaForm); | ||
/* harmony default export */ var src_0 = (SchemaForm); | ||
@@ -487,6 +485,6 @@ // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js | ||
/* concated harmony reexport SchemaWizard */__webpack_require__.d(__webpack_exports__, "SchemaWizard", function() { return SchemaWizard; }); | ||
/* concated harmony reexport FormMixin */__webpack_require__.d(__webpack_exports__, "FormMixin", function() { return FormMixin; }); | ||
/* concated harmony reexport SchemaFormFactory */__webpack_require__.d(__webpack_exports__, "SchemaFormFactory", function() { return SchemaFormFactory; }); | ||
/* harmony default export */ var entry_lib = __webpack_exports__["default"] = (src); | ||
/* harmony default export */ var entry_lib = __webpack_exports__["default"] = (src_0); | ||
@@ -493,0 +491,0 @@ |
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
module.exports = factory(require("vue")); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
exports["formvuelatte"] = factory(); | ||
exports["formvuelatte"] = factory(require("vue")); | ||
else | ||
root["formvuelatte"] = factory(); | ||
})((typeof self !== 'undefined' ? self : this), function() { | ||
root["formvuelatte"] = factory(root["Vue"]); | ||
})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__8bbf__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
@@ -99,42 +99,84 @@ /******/ // The module cache | ||
/***/ "f6fd": | ||
/***/ (function(module, exports) { | ||
/***/ "8875": | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// document.currentScript polyfill by Adam Miller | ||
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// addapted from the document.currentScript polyfill by Adam Miller | ||
// MIT license | ||
// source: https://github.com/amiller-gh/currentScript-polyfill | ||
(function(document){ | ||
var currentScript = "currentScript", | ||
scripts = document.getElementsByTagName('script'); // Live NodeList collection | ||
// added support for Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1620505 | ||
// If browser needs currentScript polyfill, add get currentScript() to the document object | ||
if (!(currentScript in document)) { | ||
Object.defineProperty(document, currentScript, { | ||
get: function(){ | ||
(function (root, factory) { | ||
if (true) { | ||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), | ||
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? | ||
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} else {} | ||
}(typeof self !== 'undefined' ? self : this, function () { | ||
function getCurrentScript () { | ||
if (document.currentScript) { | ||
return document.currentScript | ||
} | ||
// IE 8-10 support script readyState | ||
// IE 11+ & Firefox support stack trace | ||
try { | ||
throw new Error(); | ||
} | ||
catch (err) { | ||
// Find the second match for the "at" string to get file src url from stack. | ||
var ieStackRegExp = /.*at [^(]*\((.*):(.+):(.+)\)$/ig, | ||
ffStackRegExp = /@([^@]*):(\d+):(\d+)\s*$/ig, | ||
stackDetails = ieStackRegExp.exec(err.stack) || ffStackRegExp.exec(err.stack), | ||
scriptLocation = (stackDetails && stackDetails[1]) || false, | ||
line = (stackDetails && stackDetails[2]) || false, | ||
currentLocation = document.location.href.replace(document.location.hash, ''), | ||
pageSource, | ||
inlineScriptSourceRegExp, | ||
inlineScriptSource, | ||
scripts = document.getElementsByTagName('script'); // Live NodeList collection | ||
if (scriptLocation === currentLocation) { | ||
pageSource = document.documentElement.outerHTML; | ||
inlineScriptSourceRegExp = new RegExp('(?:[^\\n]+?\\n){0,' + (line - 2) + '}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*', 'i'); | ||
inlineScriptSource = pageSource.replace(inlineScriptSourceRegExp, '$1').trim(); | ||
} | ||
for (var i = 0; i < scripts.length; i++) { | ||
// If ready state is interactive, return the script tag | ||
if (scripts[i].readyState === 'interactive') { | ||
return scripts[i]; | ||
} | ||
// If src matches, return the script tag | ||
if (scripts[i].src === scriptLocation) { | ||
return scripts[i]; | ||
} | ||
// If inline source matches, return the script tag | ||
if ( | ||
scriptLocation === currentLocation && | ||
scripts[i].innerHTML && | ||
scripts[i].innerHTML.trim() === inlineScriptSource | ||
) { | ||
return scripts[i]; | ||
} | ||
} | ||
// If no match, return null | ||
return null; | ||
} | ||
}; | ||
// IE 6-10 supports script readyState | ||
// IE 10+ support stack trace | ||
try { throw new Error(); } | ||
catch (err) { | ||
return getCurrentScript | ||
})); | ||
// Find the second match for the "at" string to get file src url from stack. | ||
// Specifically works with the format of stack traces in IE. | ||
var i, res = ((/.*at [^\(]*\((.*):.+:.+\)$/ig).exec(err.stack) || [false])[1]; | ||
// For all scripts on the page, if src matches or if ready state is interactive, return the script tag | ||
for(i in scripts){ | ||
if(scripts[i].src == res || scripts[i].readyState == "interactive"){ | ||
return scripts[i]; | ||
} | ||
} | ||
/***/ }), | ||
// If no match, return null | ||
return null; | ||
} | ||
} | ||
}); | ||
} | ||
})(document); | ||
/***/ "8bbf": | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE__8bbf__; | ||
@@ -153,9 +195,16 @@ /***/ }), | ||
if (typeof window !== 'undefined') { | ||
var currentScript = window.document.currentScript | ||
if (true) { | ||
__webpack_require__("f6fd") | ||
var getCurrentScript = __webpack_require__("8875") | ||
currentScript = getCurrentScript() | ||
// for backward compatibility, because previously we directly included the polyfill | ||
if (!('currentScript' in document)) { | ||
Object.defineProperty(document, 'currentScript', { get: getCurrentScript }) | ||
} | ||
} | ||
var i | ||
if ((i = window.document.currentScript) && (i = i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))) { | ||
__webpack_require__.p = i[1] // eslint-disable-line | ||
var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/) | ||
if (src) { | ||
__webpack_require__.p = src[1] // eslint-disable-line | ||
} | ||
@@ -167,36 +216,44 @@ } | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8337181c-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/SchemaForm.vue?vue&type=template&id=0e12d6ff& | ||
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_vm._t("beforeForm"),_c('form',{staticClass:"schema-form"},[_vm._l((_vm.parsedSchema),function(field){return _c(field.component,_vm._b({key:field.model,tag:"component",attrs:{"value":_vm.val(field)},on:{"input":function($event){return _vm.update(field.model, $event)},"update-batch":function($event){return _vm.updateBatch(field.model, $event)}}},'component',_vm.binds(field),false))}),_vm._t("default")],2),_vm._t("afterForm")],2)} | ||
var staticRenderFns = [] | ||
// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"} | ||
var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf"); | ||
// 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: ./src/SchemaForm.vue?vue&type=template&id=0e12d6ff& | ||
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")]); | ||
} | ||
// CONCATENATED MODULE: ./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/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/SchemaForm.vue?vue&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/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/dist??ref--0-1!./src/SchemaForm.vue?vue&type=script&lang=js | ||
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } 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 it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
/* harmony default export */ var SchemaFormvue_type_script_lang_js_ = ({ | ||
/* harmony default export */ var SchemaFormvue_type_script_lang_js = ({ | ||
props: { | ||
@@ -213,3 +270,3 @@ schema: { | ||
}, | ||
value: { | ||
modelValue: { | ||
type: Object, | ||
@@ -220,12 +277,19 @@ required: true | ||
type: Object, | ||
required: false | ||
default: function _default() { | ||
return {}; | ||
} | ||
}, | ||
preventModelCleanupOnSchemaChange: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
computed: { | ||
parsedSchema: function parsedSchema() { | ||
if (Array.isArray(this.schema)) return this.schema; | ||
setup: function setup(props, _ref) { | ||
var emit = _ref.emit; | ||
var parsedSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
if (Array.isArray(props.schema)) return props.schema; | ||
var arraySchema = []; | ||
for (var model in this.schema) { | ||
arraySchema.push(_objectSpread({}, this.schema[model], { | ||
for (var model in props.schema) { | ||
arraySchema.push(_objectSpread(_objectSpread({}, props.schema[model]), {}, { | ||
model: model | ||
@@ -236,122 +300,67 @@ })); | ||
return arraySchema; | ||
} | ||
}, | ||
methods: { | ||
update: function update(property, value) { | ||
this.$emit('input', _objectSpread({}, this.value, _defineProperty({}, property, value))); | ||
}, | ||
updateBatch: function updateBatch(property, values) { | ||
this.$emit('input', _objectSpread({}, this.value, {}, values)); | ||
}, | ||
binds: function binds(field) { | ||
return field.schema ? { | ||
schema: field.schema | ||
} : _objectSpread({}, this.sharedConfig, {}, field); | ||
}, | ||
val: function val(field) { | ||
if (field.schema && !this.value[field.model]) { | ||
return {}; | ||
} | ||
}); | ||
Object(external_commonjs_vue_commonjs2_vue_root_Vue_["watch"])(parsedSchema, function (schema, oldSchema) { | ||
if (props.preventModelCleanupOnSchemaChange) return; | ||
var newKeys = schema.map(function (i) { | ||
return i.model; | ||
}); | ||
var diff = oldSchema.map(function (i) { | ||
return i.model; | ||
}).filter(function (i) { | ||
return !newKeys.includes(i); | ||
}); | ||
if (!diff.length) return; | ||
return this.value[field.model]; | ||
} | ||
} | ||
}); | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue?vue&type=script&lang=js& | ||
/* harmony default export */ var src_SchemaFormvue_type_script_lang_js_ = (SchemaFormvue_type_script_lang_js_); | ||
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js | ||
/* globals __VUE_SSR_CONTEXT__ */ | ||
var val = _objectSpread({}, props.modelValue); | ||
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules). | ||
// This module is a runtime utility for cleaner component module output and will | ||
// be included in the final webpack user bundle. | ||
var _iterator = _createForOfIteratorHelper(diff), | ||
_step; | ||
function normalizeComponent ( | ||
scriptExports, | ||
render, | ||
staticRenderFns, | ||
functionalTemplate, | ||
injectStyles, | ||
scopeId, | ||
moduleIdentifier, /* server only */ | ||
shadowMode /* vue-cli only */ | ||
) { | ||
// Vue.extend constructor export interop | ||
var options = typeof scriptExports === 'function' | ||
? scriptExports.options | ||
: scriptExports | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var key = _step.value; | ||
delete val[key]; | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
// render functions | ||
if (render) { | ||
options.render = render | ||
options.staticRenderFns = staticRenderFns | ||
options._compiled = true | ||
} | ||
emit('update:modelValue', val); | ||
}); | ||
// functional template | ||
if (functionalTemplate) { | ||
options.functional = true | ||
} | ||
var update = function update(property, value) { | ||
emit('update:modelValue', _objectSpread(_objectSpread({}, props.modelValue), {}, _defineProperty({}, property, value))); | ||
}; | ||
// scopedId | ||
if (scopeId) { | ||
options._scopeId = 'data-v-' + scopeId | ||
} | ||
var updateBatch = function updateBatch(property, values) { | ||
emit('update:modelValue', _objectSpread(_objectSpread({}, props.modelValue), values)); | ||
}; | ||
var hook | ||
if (moduleIdentifier) { // server build | ||
hook = function (context) { | ||
// 2.3 injection | ||
context = | ||
context || // cached call | ||
(this.$vnode && this.$vnode.ssrContext) || // stateful | ||
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional | ||
// 2.2 with runInNewContext: true | ||
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { | ||
context = __VUE_SSR_CONTEXT__ | ||
} | ||
// inject component styles | ||
if (injectStyles) { | ||
injectStyles.call(this, context) | ||
} | ||
// register component module identifier for async chunk inferrence | ||
if (context && context._registeredComponents) { | ||
context._registeredComponents.add(moduleIdentifier) | ||
} | ||
} | ||
// used by ssr in case component is cached and beforeCreate | ||
// never gets called | ||
options._ssrRegister = hook | ||
} else if (injectStyles) { | ||
hook = shadowMode | ||
? function () { injectStyles.call(this, this.$root.$options.shadowRoot) } | ||
: injectStyles | ||
} | ||
var binds = function binds(field) { | ||
return field.schema ? { | ||
schema: field.schema | ||
} : _objectSpread(_objectSpread({}, props.sharedConfig), field); | ||
}; | ||
if (hook) { | ||
if (options.functional) { | ||
// for template-only hot-reload because in that case the render fn doesn't | ||
// go through the normalizer | ||
options._injectStyles = hook | ||
// register for functioal component in vue file | ||
var originalRender = options.render | ||
options.render = function renderWithStyleInjection (h, context) { | ||
hook.call(context) | ||
return originalRender(h, context) | ||
var val = function val(field) { | ||
if (field.schema && !props.modelValue[field.model]) { | ||
return {}; | ||
} | ||
} else { | ||
// inject component registration as beforeCreate hook | ||
var existing = options.beforeCreate | ||
options.beforeCreate = existing | ||
? [].concat(existing, hook) | ||
: [hook] | ||
} | ||
} | ||
return { | ||
exports: scriptExports, | ||
options: options | ||
return props.modelValue[field.model]; | ||
}; | ||
return { | ||
parsedSchema: parsedSchema, | ||
val: val, | ||
binds: binds, | ||
update: update, | ||
updateBatch: updateBatch | ||
}; | ||
} | ||
} | ||
}); | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue?vue&type=script&lang=js | ||
// CONCATENATED MODULE: ./src/SchemaForm.vue | ||
@@ -361,48 +370,36 @@ | ||
SchemaFormvue_type_script_lang_js.render = render | ||
/* 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 | ||
/* normalize component */ | ||
function SchemaWizardvue_type_template_id_68d96300_render(_ctx, _cache) { | ||
var _component_SchemaForm = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("SchemaForm"); | ||
var component = normalizeComponent( | ||
src_SchemaFormvue_type_script_lang_js_, | ||
render, | ||
staticRenderFns, | ||
false, | ||
null, | ||
null, | ||
null | ||
) | ||
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, { | ||
schema: _ctx.currentSchema, | ||
value: _ctx.modelValue[_ctx.step] || {}, | ||
onInput: _cache[1] || (_cache[1] = function ($event) { | ||
return _ctx.update($event); | ||
}) | ||
}, null, 8, ["schema", "value"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "default")]); | ||
} | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=template&id=68d96300 | ||
/* harmony default export */ var SchemaForm = (component.exports); | ||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8337181c-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/SchemaWizard.vue?vue&type=template&id=e92b45c6& | ||
var SchemaWizardvue_type_template_id_e92b45c6_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('SchemaForm',{attrs:{"schema":_vm.currentSchema,"value":_vm.value[_vm.step] || {}},on:{"input":_vm.update}}),_vm._t("default")],2)} | ||
var SchemaWizardvue_type_template_id_e92b45c6_staticRenderFns = [] | ||
// 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 | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || SchemaWizardvue_type_script_lang_js_unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=template&id=e92b45c6& | ||
function SchemaWizardvue_type_script_lang_js_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return SchemaWizardvue_type_script_lang_js_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return SchemaWizardvue_type_script_lang_js_arrayLikeToArray(o, minLen); } | ||
// 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/lib??vue-loader-options!./src/SchemaWizard.vue?vue&type=script&lang=js& | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return SchemaWizardvue_type_script_lang_js_arrayLikeToArray(arr); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function SchemaWizardvue_type_script_lang_js_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
/* harmony default export */ var SchemaWizardvue_type_script_lang_js_ = ({ | ||
/* harmony default export */ var SchemaWizardvue_type_script_lang_js = ({ | ||
components: { | ||
@@ -421,3 +418,3 @@ SchemaForm: SchemaForm | ||
}, | ||
value: { | ||
modelValue: { | ||
type: Array, | ||
@@ -427,18 +424,22 @@ required: true | ||
}, | ||
computed: { | ||
currentSchema: function currentSchema() { | ||
return this.schema[this.step]; | ||
} | ||
}, | ||
methods: { | ||
update: function update(data) { | ||
var value = _toConsumableArray(this.value); | ||
setup: function setup(props, context) { | ||
var currentSchema = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { | ||
return props.schema[props.step]; | ||
}); | ||
value[this.step] = data; | ||
this.$emit('input', value); | ||
} | ||
var update = function update(data) { | ||
var value = _toConsumableArray(props.modelValue); | ||
value[props.step] = data; | ||
context.emit('update:modelValue', value); | ||
}; | ||
return { | ||
currentSchema: currentSchema, | ||
update: update | ||
}; | ||
} | ||
}); | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=script&lang=js& | ||
/* harmony default export */ var src_SchemaWizardvue_type_script_lang_js_ = (SchemaWizardvue_type_script_lang_js_); | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue?vue&type=script&lang=js | ||
// CONCATENATED MODULE: ./src/SchemaWizard.vue | ||
@@ -448,39 +449,36 @@ | ||
SchemaWizardvue_type_script_lang_js.render = SchemaWizardvue_type_template_id_68d96300_render | ||
/* harmony default export */ var SchemaWizard = (SchemaWizardvue_type_script_lang_js); | ||
// CONCATENATED MODULE: ./src/SchemaFormFactory.js | ||
function SchemaFormFactory_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
/* normalize component */ | ||
function SchemaFormFactory_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { SchemaFormFactory_ownKeys(Object(source), true).forEach(function (key) { SchemaFormFactory_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { SchemaFormFactory_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var SchemaWizard_component = normalizeComponent( | ||
src_SchemaWizardvue_type_script_lang_js_, | ||
SchemaWizardvue_type_template_id_e92b45c6_render, | ||
SchemaWizardvue_type_template_id_e92b45c6_staticRenderFns, | ||
false, | ||
null, | ||
null, | ||
null | ||
) | ||
function SchemaFormFactory_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/* harmony default export */ var SchemaWizard = (SchemaWizard_component.exports); | ||
// CONCATENATED MODULE: ./src/FormMixin.js | ||
/* harmony default export */ var FormMixin = ({ | ||
props: { | ||
value: { | ||
required: true | ||
}, | ||
required: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
config: { | ||
type: Object, | ||
default: function _default() {} | ||
function SchemaFormFactory() { | ||
var plugins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
// Copy the original SchemaForm setup | ||
var originalSetup = SchemaForm.setup; | ||
function setup(props, context) { | ||
// Call the original setup and preserve its results | ||
var baseSchemaFormReturns = originalSetup(props, context); | ||
if (!plugins.length) return baseSchemaFormReturns;else { | ||
// Apply plugins on the data returned | ||
// by the original Schemaform | ||
return plugins.reduce(function (schemaFormReturns, plugin) { | ||
return plugin(schemaFormReturns, props, context); | ||
}, baseSchemaFormReturns); | ||
} | ||
}, | ||
methods: { | ||
update: function update(value) { | ||
this.$emit('input', value); | ||
} | ||
} | ||
}); | ||
return SchemaFormFactory_objectSpread(SchemaFormFactory_objectSpread({}, SchemaForm), {}, { | ||
// Return a customized setup function with plugins | ||
// as the new SchemaForm setup | ||
setup: setup | ||
}); | ||
} | ||
// CONCATENATED MODULE: ./src/index.js | ||
@@ -490,3 +488,3 @@ | ||
/* harmony default export */ var src = (SchemaForm); | ||
/* harmony default export */ var src_0 = (SchemaForm); | ||
@@ -496,6 +494,6 @@ // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js | ||
/* concated harmony reexport SchemaWizard */__webpack_require__.d(__webpack_exports__, "SchemaWizard", function() { return SchemaWizard; }); | ||
/* concated harmony reexport FormMixin */__webpack_require__.d(__webpack_exports__, "FormMixin", function() { return FormMixin; }); | ||
/* concated harmony reexport SchemaFormFactory */__webpack_require__.d(__webpack_exports__, "SchemaFormFactory", function() { return SchemaFormFactory; }); | ||
/* harmony default export */ var entry_lib = __webpack_exports__["default"] = (src); | ||
/* harmony default export */ var entry_lib = __webpack_exports__["default"] = (src_0); | ||
@@ -502,0 +500,0 @@ |
@@ -1,2 +0,2 @@ | ||
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["formvuelatte"]=t():e["formvuelatte"]=t()})("undefined"!==typeof self?self:this,(function(){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")}({f6fd:function(e,t){(function(e){var t="currentScript",r=e.getElementsByTagName("script");t in e||Object.defineProperty(e,t,{get:function(){try{throw new Error}catch(n){var e,t=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(n.stack)||[!1])[1];for(e in r)if(r[e].src==t||"interactive"==r[e].readyState)return r[e];return null}}})})(document)},fb15:function(e,t,r){"use strict";var n;(r.r(t),"undefined"!==typeof window)&&(r("f6fd"),(n=window.document.currentScript)&&(n=n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(r.p=n[1]));var o=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",[e._t("beforeForm"),r("form",{staticClass:"schema-form"},[e._l(e.parsedSchema,(function(t){return r(t.component,e._b({key:t.model,tag:"component",attrs:{value:e.val(t)},on:{input:function(r){return e.update(t.model,r)},"update-batch":function(r){return e.updateBatch(t.model,r)}}},"component",e.binds(t),!1))})),e._t("default")],2),e._t("afterForm")],2)},i=[];function u(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?u(r,!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(r).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(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={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}},value:{type:Object,required:!0},sharedConfig:{type:Object,required:!1}},computed:{parsedSchema:function(){if(Array.isArray(this.schema))return this.schema;var e=[];for(var t in this.schema)e.push(a({},this.schema[t],{model:t}));return e}},methods:{update:function(e,t){this.$emit("input",a({},this.value,c({},e,t)))},updateBatch:function(e,t){this.$emit("input",a({},this.value,{},t))},binds:function(e){return e.schema?{schema:e.schema}:a({},this.sharedConfig,{},e)},val:function(e){return e.schema&&!this.value[e.model]?{}:this.value[e.model]}}},f=s;function l(e,t,r,n,o,i,u,a){var c,s="function"===typeof e?e.options:e;if(t&&(s.render=t,s.staticRenderFns=r,s._compiled=!0),n&&(s.functional=!0),i&&(s._scopeId="data-v-"+i),u?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(u)},s._ssrRegister=c):o&&(c=a?function(){o.call(this,this.$root.$options.shadowRoot)}:o),c)if(s.functional){s._injectStyles=c;var f=s.render;s.render=function(e,t){return c.call(t),f(e,t)}}else{var l=s.beforeCreate;s.beforeCreate=l?[].concat(l,c):[c]}return{exports:e,options:s}}var p=l(f,o,i,!1,null,null,null),d=p.exports,m=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",[r("SchemaForm",{attrs:{schema:e.currentSchema,value:e.value[e.step]||{}},on:{input:e.update}}),e._t("default")],2)},h=[];function y(e){return _(e)||b(e)||v()}function v(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function b(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}var O={components:{SchemaForm:d},props:{schema:{type:Array,required:!0},step:{type:Number,required:!0,default:0},value:{type:Array,required:!0}},computed:{currentSchema:function(){return this.schema[this.step]}},methods:{update:function(e){var t=y(this.value);t[this.step]=e,this.$emit("input",t)}}},g=O,j=l(g,m,h,!1,null,null,null),S=j.exports,w={props:{value:{required:!0},required:{type:Boolean,default:!1},config:{type:Object,default:function(){}}},methods:{update:function(e){this.$emit("input",e)}}},x=d;r.d(t,"SchemaForm",(function(){return d})),r.d(t,"SchemaWizard",(function(){return S})),r.d(t,"FormMixin",(function(){return w}));t["default"]=x}})})); | ||
(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}})})); | ||
//# sourceMappingURL=formvuelatte.umd.min.js.map |
{ | ||
"name": "formvuelatte", | ||
"version": "0.2.4", | ||
"version": "v2.0.0-alpha.1", | ||
"description": "Schema Form Generator", | ||
@@ -16,2 +16,5 @@ "author": "Marina Mosti <marina@mosti.com.mx>", | ||
], | ||
"engines": { | ||
"node": ">=13.0.0" | ||
}, | ||
"main": "dist/formvuelatte.common.js", | ||
@@ -32,4 +35,4 @@ "unpkg": "dist/formvuelatte.umd.js", | ||
"lint": "vue-cli-service lint", | ||
"docs:build": "vuepress build docs", | ||
"docs:dev": "vuepress dev docs", | ||
"docs:build": "vitepress build", | ||
"docs:dev": "vitepress", | ||
"test:e2e": "vue-cli-service test:e2e", | ||
@@ -42,11 +45,8 @@ "test:unit": "vue-cli-service test:unit" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@vue/cli-plugin-babel": "^4.0.0", | ||
"@vue/cli-plugin-e2e-cypress": "^4.0.3", | ||
"@vue/cli-plugin-eslint": "^4.0.1", | ||
"@vue/cli-plugin-unit-jest": "^4.0.3", | ||
"@vue/cli-service": "^4.0.3", | ||
"@vue/eslint-config-standard": "^4.0.0", | ||
"@vue/test-utils": "1.0.0-beta.30", | ||
"@vue/cli-plugin-babel": "^4.2.0", | ||
"@vue/cli-plugin-eslint": "^4.2.0", | ||
"@vue/cli-service": "^4.2.0", | ||
"@vue/compiler-sfc": "^3.0.0-beta.12", | ||
"@vue/eslint-config-standard": "^5.1.0", | ||
"babel-core": "7.0.0-bridge.0", | ||
@@ -56,10 +56,9 @@ "babel-eslint": "^10.0.3", | ||
"eslint": "^6.7.2", | ||
"eslint-plugin-vue": "^6.0.0", | ||
"stylus": "^0.54.5", | ||
"stylus-loader": "^3.0.2", | ||
"vue": "^2.6.6", | ||
"vue-json-pretty": "^1.6.2", | ||
"vue-template-compiler": "^2.5.21", | ||
"vuepress": "^1.1.0" | ||
"eslint-plugin-vue": "next", | ||
"stylus": "^0.54.7", | ||
"vitepress": "^0.1.1", | ||
"vite": "^0.15.3", | ||
"vue": "v3.0.0-beta.12", | ||
"vue-cli-plugin-vue-next": "^0.1.2" | ||
} | ||
} | ||
} |
342
README.md
# FormVueLatte | ||
For the full guide with examples, visit [https://formvuelatte.netlify.com](https://formvuelatte.netlify.com) | ||
Full guide with examples is WIP for V2.0 | ||
@@ -9,3 +9,3 @@ ## Getting Started | ||
The schema that you use for your form can be as flexible as you need it to be, it can be modified at run-time with an expected reactive result, and can even be fetched directly from you backend's API. | ||
The schema that you use for your form can be as flexible as you need it to be, it can be modified at run-time with an expected reactive result, and can even be fetched directly from you backend’s API. | ||
@@ -18,5 +18,3 @@ ### Installation | ||
yarn add formvuelatte | ||
// OR | ||
npm install formvuelatte | ||
@@ -27,7 +25,7 @@ ``` | ||
```js | ||
```javascript | ||
import { SchemaForm } from 'formvuelatte' | ||
``` | ||
The `SchemaForm` requires two `props`. The first is the `schema`, which is the configuration of your form. The second one is `value`, which will hold the state of the form. | ||
The `SchemaForm` requires two `props`. The first is the `schema`, which is the meta-data of your form. The second one is `value`, which will hold the state of the form. | ||
@@ -38,7 +36,10 @@ ```html | ||
The `SchemaForm` will `$emit` **input** events when your components update. This means that you are able to either use `v-model` on it, or manually capture the `@input` event with a method of your own, as well as inject the `:value` property. Either or. | ||
The `SchemaForm` will `$emit` **update:modelValue** events when your components update. This means that you are able to either: | ||
Below you will find an example of the previous concepts. | ||
- use `v-model` on it | ||
- or, manually capture the `@update:modelValue` event with a method of your own while injecting the `:value` property. | ||
```html | ||
Example with `v-model`: | ||
```javascript | ||
<template> | ||
@@ -49,77 +50,310 @@ <SchemaForm :schema="mySchema" v-model="formData" /> | ||
<script> | ||
import { reactive } from 'vue' | ||
export default { | ||
data() { | ||
return { | ||
formData: {}, | ||
mySchema: { | ||
//some schema here | ||
} | ||
} | ||
} | ||
} | ||
setup() { | ||
const formData = reactive({}) | ||
const mySchema = reactive({ | ||
// some schema here | ||
}) | ||
return { | ||
formData, | ||
mySchema | ||
} | ||
} | ||
}} | ||
</script> | ||
``` | ||
Example with manual bindings: | ||
```javascript | ||
<template> | ||
<SchemaForm | ||
:schema="mySchema" | ||
:data="formData" | ||
@update:modelValue="updateForm" | ||
/> | ||
</template> | ||
<script> | ||
import { reactive } from 'vue' | ||
export default { | ||
setup() { | ||
const formData = reactive({}) | ||
const mySchema = reactive({ | ||
// some schema here | ||
}) | ||
const updateForm = form => { | ||
formData = form | ||
} | ||
return { | ||
formData, | ||
mySchema, | ||
updateForm | ||
} | ||
} | ||
}} | ||
</script> | ||
``` | ||
## The schema prop | ||
The `SchemaForm` component requires you to pass it a `schema` property. This `schema` can be both an `object` or an `array`, although under the hood it will be transformed to an `array`. | ||
In its simplest form, the `schema` requires you to provide a `name: value` pair for each of the form components you want to add to your form. Let's assume for this example that you have a component in your project called `FormText` which exposes an `<input>` tag with some CSS. | ||
In its simplest form, the `schema` requires you to provide a `name: value` pair for each of the form components you want to add to your form. Let’s assume for this example that you have a component in your project called `FormText` which exposes an `<input>` tag with some CSS. | ||
```html | ||
```javascript | ||
<template> | ||
<SchemaForm :schema="schema" /> | ||
<SchemaForm :schema="schema" v-model="formData" /> | ||
</template> | ||
<script> | ||
import { SchemaForm } from 'formvuelatte' | ||
import FormText from 'path/to/FormText'; | ||
import { SchemaForm } from 'formvuelatte' | ||
import FormText from 'path/to/FormText' | ||
import { reactive } from 'vue' | ||
export default { | ||
components: { SchemaForm }, | ||
data() { | ||
return { | ||
schema: { | ||
name: { | ||
component: FormText // Note that is NOT a string | ||
}, | ||
lastName: { | ||
component: FormText // We pass the component that we imported directly | ||
} | ||
} | ||
} | ||
} | ||
} | ||
export default { | ||
components: { SchemaForm }, | ||
setup() { | ||
const schema = reactive({ | ||
name: { | ||
component: FormText // Note that is NOT a string | ||
}, | ||
lastName: { | ||
component: FormText // We pass the component that we imported directly | ||
} | ||
}) | ||
const formData = reactive({}) | ||
return { | ||
schema, | ||
formData | ||
} | ||
} | ||
} | ||
</script> | ||
``` | ||
## Component Requirements and the FormMixin | ||
## Component Requirements | ||
Now that you have your schema bound into the `schema` prop, you need to make sure that your components are understood by `SchemaForm`. | ||
In order for `SchemaForm` to understand **your components**, they need to use the `FormMixin` mixin that FormVueLatte provides. | ||
First, make sure that your component accepts a `modelValue` property. `SchemaForm` will bind into this property to pass down the current value of the input. | ||
```js | ||
// FormText.vue | ||
import { FormMixin } from 'formvuelatte' | ||
Next, make sure that your component `$emit`s an `update:modelValue` event with the payload of the new input's value whenever it changes. This will allow `SchemaForm` to update the data internally and emit the update event to the parent. | ||
Example of a simple input component: | ||
```javascript | ||
<template> | ||
<input type="text" :value="modelValue" @input="update" /> | ||
</template> | ||
<script> | ||
export default { | ||
props: { | ||
modelValue: { | ||
required: true, | ||
type: [String, Number] | ||
} | ||
}, | ||
setup(props, context) { | ||
const update = event => { | ||
context.emit('update:modelValue', event.target.value) | ||
} | ||
} | ||
} | ||
</script> | ||
``` | ||
## SchemaWizard | ||
FormVueLatte also ships with a component called `SchemaWizard`, that allows you to easily build stepped, wizard-like, forms. | ||
The `SchemaWizard` component exposes and requires three props. | ||
### Prop: Schema | ||
The schema that the `SchemaWizard` will use to render the form. This is a required property. | ||
The schema that the `SchemaWizard` uses varies from the one used in `SchemaForm` in one major difference — it is strictly an array, in which each of the array elements is a `SchemaForm` ready schema. | ||
Example wizard schema: | ||
( Note that the components used are only for purposes of the example and are not part of FormVueLatte ) | ||
```javascript | ||
const wizardSchema = [ | ||
// Step 1 - user's name | ||
{ | ||
firstName: { component: FormText }, | ||
lastName: { component: FormText } | ||
}, | ||
// Step 2 - user's email and agree to terms | ||
{ | ||
email: { component: FormEmail }, | ||
terms: { component: FormCheckbox } | ||
} | ||
] | ||
``` | ||
In the previous example we have two different form steps, the first will display two inputs — one for the firstName, and one for the lastName. In the second step, the first two elements for the user's name will not be displayed, and the email and terms checkbox will. | ||
### Prop: Step | ||
This property is required, and numeric. | ||
The step is the index of the currently displayed part of the stepped schema. In the previous schema example, step `0` will indicate that the `SchemaWizard` should display the index `0` of the form — the user's name. | ||
Step `1` will indicate that the `SchemaWizard` should display index `1` of the form — the email and terms checkbox. | ||
### Props: modelValue | ||
This property is required, and an array. | ||
This is the property that the `SchemaWizard` component will use for `v-model` binding and to inject form values into subcomponents. | ||
Example output from the example schema above: | ||
```javascript | ||
[ | ||
{ | ||
fistName: 'Jane', | ||
lastName: 'Doe' | ||
}, | ||
{ | ||
email: 'jane@gmail.com', | ||
terms: true | ||
} | ||
] | ||
``` | ||
## Plugins | ||
FormVueLatte ships with the ability to import and use plugins to extend it's capabilities. | ||
In order to use a plugin with `SchemaForm`, you have to use the provided `SchemaFormFactory` higher order function. | ||
First, import the `SchemaFormFactory` into your application. | ||
```javascript | ||
import SchemaFormFactory from 'formvuelatte/SchemaFormFactory' | ||
``` | ||
`SchemaFormFactory` accepts an array of plugins that will be used to generate the `SchemaForm`. | ||
The order in which you pass the plugins is *important*, as they will be applied in the order they are received. | ||
```javascript | ||
import useVuelidate from '@vuelidate' | ||
import VuelidatePlugin from 'formvuelatte/useVuelidatePlugin' | ||
const SchemaFormWithPlugins = SchemaFormFactory([ | ||
VuelidatePlugin(useVuelidate) | ||
]) | ||
``` | ||
Now that we have defined a new component called `SchemaFormWithPlugins`, you can use it as you normally use any other component in your application. | ||
```javascript | ||
<template> | ||
[...] | ||
mixins: [ FormMixin ], | ||
<SchemaFormWithValidations /> | ||
[...] | ||
</template> | ||
export default { | ||
components: { SchemaFormWithValidations }, | ||
[...] | ||
} | ||
``` | ||
In its simplest form, make sure that when your `form element` wants to make a change to the `value`, it calls the `update` method with the new value. | ||
## VuelidatePlugin | ||
Here's an example using the `<input>` tag. | ||
In order to seamlessly validate FormVueLatte by using Vuelidate, we provide a `VuelidatePlugin` that will allow you to easily accomplish this. | ||
```html | ||
<input | ||
:value="value" | ||
@input="update($event.target.value)" | ||
/> | ||
Your schema will need some changes in order to work with the `VuelidatePlugin`. Each element in your schema will need to contain a `validations` property which is an object, with each of the validations that you want to apply to it. | ||
```javascript | ||
import { required, email } from '@vuelidate/validators/withMessages' | ||
const SCHEMA = { | ||
firstName: { | ||
component: FormText, | ||
label: 'First Name', | ||
validations: { | ||
required | ||
} | ||
}, | ||
lastName: { | ||
component: FormText, | ||
label: 'Last Name', | ||
validations: { | ||
required | ||
} | ||
}, | ||
email: { | ||
component: FormText, | ||
label: 'Your email', | ||
validations: { | ||
email, | ||
required | ||
} | ||
} | ||
} | ||
``` | ||
The `FormMixin` adds a required `value` property to your component (for it to comply with v-model capabilities). | ||
Next, create your new `SchemaForm` by using the factory to inject the `VuelidatePlugin`. | ||
Once you've imported the mixin to your components, make sure your component makes use of the `update` method provided by the mixin. | ||
```javascript | ||
import useVuelidate from '@vuelidate' | ||
import VuelidatePlugin from 'formvuelatte/useVuelidatePlugin' | ||
The `update` method `$emit`s the `input` event with whatever value you pass to it. | ||
const SchemaFormWithPlugins = SchemaFormFactory([ | ||
VuelidatePlugin(useVuelidate) | ||
]) | ||
``` | ||
Now that we have the component ready, we can jump into the `setup` function, where we need to get our `v-model` data ready, as well as a function to handle the `update:validations` event that our Vuelidate-powered form will `emit`. | ||
```javascript | ||
setup (props, context) { | ||
const userData = ref({ | ||
firstName: 'John', | ||
lastName: '', | ||
email: '' | ||
}) | ||
const validations = ref({}) | ||
const updateValidations = v => { | ||
validations.value = v.value | ||
} | ||
return { | ||
schema: SCHEMA, | ||
userData, | ||
validations, | ||
updateValidations | ||
} | ||
} | ||
``` | ||
Finally, we can go to our template and pass down both the `userData` and the listener for our `update:validations` event. | ||
```html | ||
<template> | ||
<SchemaFormWithValidations | ||
:schema="schema" | ||
v-model="userData" | ||
@update:validations="updateValidations" | ||
/> | ||
</template> | ||
``` | ||
## Contributors | ||
- [Marina Mosti](https://twitter.com/MarinaMosti) | ||
- [Damian Dulisz](https://twitter.com/DamianDulisz) |
export default { | ||
props: { | ||
value: { required: true }, | ||
modelValue: { | ||
required: true | ||
}, | ||
required: { | ||
type: Boolean, | ||
default: false | ||
default: () => false | ||
}, | ||
@@ -15,5 +17,5 @@ config: { | ||
update (value) { | ||
this.$emit('input', value) | ||
this.$emit('update:modelValue', value) | ||
} | ||
} | ||
} |
import SchemaForm from './SchemaForm' | ||
import SchemaWizard from './SchemaWizard' | ||
import FormMixin from './FormMixin' | ||
import SchemaFormFactory from './SchemaFormFactory' | ||
@@ -10,3 +10,3 @@ export default SchemaForm | ||
SchemaWizard, | ||
FormMixin | ||
SchemaFormFactory | ||
} |
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
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
131733
15
17
999
0
354
3
2