diff --git a/dist/js/field.js b/dist/js/field.js index 3b3ea28..efec7ab 100644 --- a/dist/js/field.js +++ b/dist/js/field.js @@ -1 +1 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){t.exports=function(t,e,n,r,o,i){var a,u=t=t||{},s=typeof t.default;"object"!==s&&"function"!==s||(a=t,u=t.default);var c,l="function"==typeof u?u.options:u;if(e&&(l.render=e.render,l.staticRenderFns=e.staticRenderFns,l._compiled=!0),n&&(l.functional=!0),o&&(l._scopeId=o),i?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},l._ssrRegister=c):r&&(c=r),c){var f=l.functional,d=f?l.render:l.beforeCreate;f?(l._injectStyles=c,l.render=function(t,e){return c.call(e),d(t,e)}):l.beforeCreate=d?[].concat(d,c):[c]}return{esModule:a,exports:u,options:l}}},function(t,e,n){"use strict";e.a={data:function(){return{detailVisible:!1}},computed:{value:function(){return this.field.value?JSON.parse(this.field.value):[]},toggleText:function(){return this.detailVisible?this.__("Hide detail"):this.__("Show detail")},summaryText:function(){return this.summaryTextNumber+" "+this.summaryTextLabel},summaryTextNumber:function(){return this.field.value?this.value.length:0},summaryTextLabel:function(){return this.field.summary_label?this.field.summary_label:"rows"},rows:function(){var t=this;return this.value.map(function(e){return Object.keys(e).map(function(n){var r=t.field.sub_fields.find(function(t){return t.name===n}),o=["select"].some(function(t){return t===r.type})?r.options[e[n]]:e[n];return{label:r.label,value:o}})})}},methods:{toggleDetail:function(){this.detailVisible=!this.detailVisible}}}},function(t,e,n){n(3),t.exports=n(34)},function(t,e,n){Nova.booting(function(t,e){t.component("index-nova-repeatable-fields",n(4)),t.component("detail-nova-repeatable-fields",n(7)),t.component("form-nova-repeatable-fields",n(10))})},function(t,e,n){var r=n(0)(n(5),n(6),!1,null,null,null);t.exports=r.exports},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1);e.default={mixins:[r.a],props:["resourceName","field"]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"py-4"},[n("p",{staticClass:"mb-4"},[n("strong",{domProps:{textContent:t._s(t.summaryText)}})]),t._v(" "),n("ul",{directives:[{name:"show",rawName:"v-show",value:t.detailVisible,expression:"detailVisible"}],staticClass:"list-reset"},t._l(t.rows,function(e){return n("li",[n("ul",{staticClass:"list-reset mb-4"},t._l(e,function(e){return n("li",{staticClass:"flex items-top mb-1"},[n("span",{staticClass:"block w-1/6 mr-2"},[t._v(t._s(e.label)+":")]),t._v(" "),n("span",{staticClass:"block"},[n("strong",[t._v(t._s(e.value))])])])}),0)])}),0),t._v(" "),n("a",{staticClass:"cursor-pointer dim inline-block text-primary font-bold",attrs:{"aria-role":"button"},domProps:{textContent:t._s(t.toggleText)},on:{click:function(e){return e.preventDefault(),t.toggleDetail(e)}}})])},staticRenderFns:[]}},function(t,e,n){var r=n(0)(n(8),n(9),!1,null,null,null);t.exports=r.exports},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1);e.default={mixins:[r.a],props:["resource","resourceName","resourceId","field"]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("panel-item",{attrs:{field:t.field}},[n("div",{attrs:{slot:"value"},slot:"value"},[n("p",{staticClass:"mb-4"},[n("strong",{domProps:{textContent:t._s(t.summaryText)}})]),t._v(" "),n("ul",{directives:[{name:"show",rawName:"v-show",value:t.detailVisible,expression:"detailVisible"}],staticClass:"list-reset"},t._l(t.rows,function(e){return n("li",[n("ul",{staticClass:"list-reset mb-4"},t._l(e,function(e){return n("li",{staticClass:"flex items-top mb-1"},[n("span",{staticClass:"block w-1/6 mr-2"},[t._v(t._s(e.label)+":")]),t._v(" "),n("span",{staticClass:"block"},[n("strong",[t._v(t._s(e.value))])])])}),0)])}),0),t._v(" "),n("a",{staticClass:"cursor-pointer dim inline-block text-primary font-bold",attrs:{"aria-role":"button"},domProps:{textContent:t._s(t.toggleText)},on:{click:function(e){return e.preventDefault(),t.toggleDetail(e)}}})])])},staticRenderFns:[]}},function(t,e,n){var r=n(0)(n(11),n(33),!1,null,null,null);t.exports=r.exports},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(12),o=n.n(r),i=n(14),a=(n.n(i),n(15)),u=n.n(a),s=Object.assign||function(t){for(var e=1;e=this.field.maximum_rows},shouldAddInitialRows:function(){return this.field.initial_rows&&this.field.initial_rows>this.rows.length}},methods:{setInitialValue:function(){var t=this;this.value=this.field.value||"",this.$nextTick(function(){if(t.rows=t.value?JSON.parse(t.value):[],t.shouldAddInitialRows)for(var e=t.field.initial_rows-t.rows.length,n=1;n<=e;n++)t.addNewRow()})},fill:function(t){t.append(this.field.attribute,this.value||"")},addNewRow:function(){if(!this.hasReachedMaximumRows){var t=this.field.sub_fields.map(function(t){return t.name}).reduce(function(t,e){return s({},t,function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}({},e,null))},{});this.rows.push(t)}},deleteRow:function(t){this.rows.splice(t,1)}},watch:{rows:{handler:function(t){this.value=JSON.stringify(t)},deep:!0}}}},function(t,e,n){t.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"02f4":function(t,e,n){var r=n("4588"),o=n("be13");t.exports=function(t){return function(e,n){var i,a,u=String(o(e)),s=r(n),c=u.length;return s<0||s>=c?t?"":void 0:(i=u.charCodeAt(s))<55296||i>56319||s+1===c||(a=u.charCodeAt(s+1))<56320||a>57343?t?u.charAt(s):i:t?u.slice(s,s+2):a-56320+(i-55296<<10)+65536}}},"0390":function(t,e,n){"use strict";var r=n("02f4")(!0);t.exports=function(t,e,n){return e+(n?r(t,e).length:1)}},"07e3":function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},"0bfb":function(t,e,n){"use strict";var r=n("cb7c");t.exports=function(){var t=r(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},"0fc9":function(t,e,n){var r=n("3a38"),o=Math.max,i=Math.min;t.exports=function(t,e){return(t=r(t))<0?o(t+e,0):i(t,e)}},1654:function(t,e,n){"use strict";var r=n("71c1")(!0);n("30f1")(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=r(e,n),this._i+=t.length,{value:t,done:!1})})},1691:function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},"1af6":function(t,e,n){var r=n("63b6");r(r.S,"Array",{isArray:n("9003")})},"1bc3":function(t,e,n){var r=n("f772");t.exports=function(t,e){if(!r(t))return t;var n,o;if(e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!r(o=n.call(t)))return o;if(!e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},"1ec9":function(t,e,n){var r=n("f772"),o=n("e53d").document,i=r(o)&&r(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},"20fd":function(t,e,n){"use strict";var r=n("d9f6"),o=n("aebd");t.exports=function(t,e,n){e in t?r.f(t,e,o(0,n)):t[e]=n}},"214f":function(t,e,n){"use strict";n("b0c5");var r=n("2aba"),o=n("32e9"),i=n("79e5"),a=n("be13"),u=n("2b4c"),s=n("520a"),c=u("species"),l=!i(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$")}),f=function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2===n.length&&"a"===n[0]&&"b"===n[1]}();t.exports=function(t,e,n){var d=u(t),p=!i(function(){var e={};return e[d]=function(){return 7},7!=""[t](e)}),h=p?!i(function(){var e=!1,n=/a/;return n.exec=function(){return e=!0,null},"split"===t&&(n.constructor={},n.constructor[c]=function(){return n}),n[d](""),!e}):void 0;if(!p||!h||"replace"===t&&!l||"split"===t&&!f){var v=/./[d],g=n(a,d,""[t],function(t,e,n,r,o){return e.exec===s?p&&!o?{done:!0,value:v.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}}),m=g[0],y=g[1];r(String.prototype,t,m),o(RegExp.prototype,d,2==e?function(t,e){return y.call(t,this,e)}:function(t){return y.call(t,this)})}}},"230e":function(t,e,n){var r=n("d3f4"),o=n("7726").document,i=r(o)&&r(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},"23c6":function(t,e,n){var r=n("2d95"),o=n("2b4c")("toStringTag"),i="Arguments"==r(function(){return arguments}());t.exports=function(t){var e,n,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),o))?n:i?r(e):"Object"==(a=r(e))&&"function"==typeof e.callee?"Arguments":a}},"241e":function(t,e,n){var r=n("25eb");t.exports=function(t){return Object(r(t))}},"25eb":function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},"294c":function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},"2aba":function(t,e,n){var r=n("7726"),o=n("32e9"),i=n("69a8"),a=n("ca5a")("src"),u=n("fa5b"),s=(""+u).split("toString");n("8378").inspectSource=function(t){return u.call(t)},(t.exports=function(t,e,n,u){var c="function"==typeof n;c&&(i(n,"name")||o(n,"name",e)),t[e]!==n&&(c&&(i(n,a)||o(n,a,t[e]?""+t[e]:s.join(String(e)))),t===r?t[e]=n:u?t[e]?t[e]=n:o(t,e,n):(delete t[e],o(t,e,n)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[a]||u.call(this)})},"2b4c":function(t,e,n){var r=n("5537")("wks"),o=n("ca5a"),i=n("7726").Symbol,a="function"==typeof i;(t.exports=function(t){return r[t]||(r[t]=a&&i[t]||(a?i:o)("Symbol."+t))}).store=r},"2d00":function(t,e){t.exports=!1},"2d95":function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},"2fdb":function(t,e,n){"use strict";var r=n("5ca1"),o=n("d2c8");r(r.P+r.F*n("5147")("includes"),"String",{includes:function(t){return!!~o(this,t,"includes").indexOf(t,arguments.length>1?arguments[1]:void 0)}})},"30f1":function(t,e,n){"use strict";var r=n("b8e3"),o=n("63b6"),i=n("9138"),a=n("35e8"),u=n("481b"),s=n("8f60"),c=n("45f2"),l=n("53e2"),f=n("5168")("iterator"),d=!([].keys&&"next"in[].keys()),p=function(){return this};t.exports=function(t,e,n,h,v,g,m){s(n,e,h);var y,b,x,w=function(t){if(!d&&t in E)return E[t];switch(t){case"keys":case"values":return function(){return new n(this,t)}}return function(){return new n(this,t)}},_=e+" Iterator",S="values"==v,O=!1,E=t.prototype,j=E[f]||E["@@iterator"]||v&&E[v],T=j||w(v),P=v?S?w("entries"):T:void 0,C="Array"==e&&E.entries||j;if(C&&(x=l(C.call(new t)))!==Object.prototype&&x.next&&(c(x,_,!0),r||"function"==typeof x[f]||a(x,f,p)),S&&j&&"values"!==j.name&&(O=!0,T=function(){return j.call(this)}),r&&!m||!d&&!O&&E[f]||a(E,f,T),u[e]=T,u[_]=p,v)if(y={values:S?T:w("values"),keys:g?T:w("keys"),entries:P},m)for(b in y)b in E||i(E,b,y[b]);else o(o.P+o.F*(d||O),e,y);return y}},"32a6":function(t,e,n){var r=n("241e"),o=n("c3a1");n("ce7e")("keys",function(){return function(t){return o(r(t))}})},"32e9":function(t,e,n){var r=n("86cc"),o=n("4630");t.exports=n("9e1e")?function(t,e,n){return r.f(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},"32fc":function(t,e,n){var r=n("e53d").document;t.exports=r&&r.documentElement},"335c":function(t,e,n){var r=n("6b4c");t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},"355d":function(t,e){e.f={}.propertyIsEnumerable},"35e8":function(t,e,n){var r=n("d9f6"),o=n("aebd");t.exports=n("8e60")?function(t,e,n){return r.f(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},"36c3":function(t,e,n){var r=n("335c"),o=n("25eb");t.exports=function(t){return r(o(t))}},3702:function(t,e,n){var r=n("481b"),o=n("5168")("iterator"),i=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||i[o]===t)}},"3a38":function(t,e){var n=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:n)(t)}},"40c3":function(t,e,n){var r=n("6b4c"),o=n("5168")("toStringTag"),i="Arguments"==r(function(){return arguments}());t.exports=function(t){var e,n,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),o))?n:i?r(e):"Object"==(a=r(e))&&"function"==typeof e.callee?"Arguments":a}},4588:function(t,e){var n=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:n)(t)}},"45f2":function(t,e,n){var r=n("d9f6").f,o=n("07e3"),i=n("5168")("toStringTag");t.exports=function(t,e,n){t&&!o(t=n?t:t.prototype,i)&&r(t,i,{configurable:!0,value:e})}},4630:function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},"469f":function(t,e,n){n("6c1c"),n("1654"),t.exports=n("7d7b")},"481b":function(t,e){t.exports={}},"4aa6":function(t,e,n){t.exports=n("dc62")},"4bf8":function(t,e,n){var r=n("be13");t.exports=function(t){return Object(r(t))}},"4ee1":function(t,e,n){var r=n("5168")("iterator"),o=!1;try{var i=[7][r]();i.return=function(){o=!0},Array.from(i,function(){throw 2})}catch(t){}t.exports=function(t,e){if(!e&&!o)return!1;var n=!1;try{var i=[7],a=i[r]();a.next=function(){return{done:n=!0}},i[r]=function(){return a},t(i)}catch(t){}return n}},"50ed":function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},5147:function(t,e,n){var r=n("2b4c")("match");t.exports=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[r]=!1,!"/./"[t](e)}catch(t){}}return!0}},5168:function(t,e,n){var r=n("dbdb")("wks"),o=n("62a0"),i=n("e53d").Symbol,a="function"==typeof i;(t.exports=function(t){return r[t]||(r[t]=a&&i[t]||(a?i:o)("Symbol."+t))}).store=r},5176:function(t,e,n){t.exports=n("51b6")},"51b6":function(t,e,n){n("a3c3"),t.exports=n("584a").Object.assign},"520a":function(t,e,n){"use strict";var r,o,i=n("0bfb"),a=RegExp.prototype.exec,u=String.prototype.replace,s=a,c=(r=/a/,o=/b*/g,a.call(r,"a"),a.call(o,"a"),0!==r.lastIndex||0!==o.lastIndex),l=void 0!==/()??/.exec("")[1];(c||l)&&(s=function(t){var e,n,r,o,s=this;return l&&(n=new RegExp("^"+s.source+"$(?!\\s)",i.call(s))),c&&(e=s.lastIndex),r=a.call(s,t),c&&r&&(s.lastIndex=s.global?r.index+r[0].length:e),l&&r&&r.length>1&&u.call(r[0],n,function(){for(o=1;o1?arguments[1]:void 0,g=void 0!==v,m=0,y=l(d);if(g&&(v=r(v,h>2?arguments[2]:void 0,2)),void 0==y||p==Array&&u(y))for(n=new p(e=s(d.length));e>m;m++)c(n,m,g?v(d[m],m):d[m]);else for(f=y.call(d),n=new p;!(o=f.next()).done;m++)c(n,m,g?a(f,v,[o.value,m],!0):o.value);return n.length=m,n}})},"54a1":function(t,e,n){n("6c1c"),n("1654"),t.exports=n("95d5")},5537:function(t,e,n){var r=n("8378"),o=n("7726"),i=o["__core-js_shared__"]||(o["__core-js_shared__"]={});(t.exports=function(t,e){return i[t]||(i[t]=void 0!==e?e:{})})("versions",[]).push({version:r.version,mode:n("2d00")?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},5559:function(t,e,n){var r=n("dbdb")("keys"),o=n("62a0");t.exports=function(t){return r[t]||(r[t]=o(t))}},"584a":function(t,e){var n=t.exports={version:"2.6.5"};"number"==typeof __e&&(__e=n)},"5b4e":function(t,e,n){var r=n("36c3"),o=n("b447"),i=n("0fc9");t.exports=function(t){return function(e,n,a){var u,s=r(e),c=o(s.length),l=i(a,c);if(t&&n!=n){for(;c>l;)if((u=s[l++])!=u)return!0}else for(;c>l;l++)if((t||l in s)&&s[l]===n)return t||l||0;return!t&&-1}}},"5ca1":function(t,e,n){var r=n("7726"),o=n("8378"),i=n("32e9"),a=n("2aba"),u=n("9b43"),s=function(t,e,n){var c,l,f,d,p=t&s.F,h=t&s.G,v=t&s.S,g=t&s.P,m=t&s.B,y=h?r:v?r[e]||(r[e]={}):(r[e]||{}).prototype,b=h?o:o[e]||(o[e]={}),x=b.prototype||(b.prototype={});for(c in h&&(n=e),n)f=((l=!p&&y&&void 0!==y[c])?y:n)[c],d=m&&l?u(f,r):g&&"function"==typeof f?u(Function.call,f):f,y&&a(y,c,f,t&s.U),b[c]!=f&&i(b,c,d),g&&x[c]!=f&&(x[c]=f)};r.core=o,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,t.exports=s},"5d73":function(t,e,n){t.exports=n("469f")},"5f1b":function(t,e,n){"use strict";var r=n("23c6"),o=RegExp.prototype.exec;t.exports=function(t,e){var n=t.exec;if("function"==typeof n){var i=n.call(t,e);if("object"!=typeof i)throw new TypeError("RegExp exec method returned something other than an Object or null");return i}if("RegExp"!==r(t))throw new TypeError("RegExp#exec called on incompatible receiver");return o.call(t,e)}},"626a":function(t,e,n){var r=n("2d95");t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},"62a0":function(t,e){var n=0,r=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+r).toString(36))}},"63b6":function(t,e,n){var r=n("e53d"),o=n("584a"),i=n("d864"),a=n("35e8"),u=n("07e3"),s=function(t,e,n){var c,l,f,d=t&s.F,p=t&s.G,h=t&s.S,v=t&s.P,g=t&s.B,m=t&s.W,y=p?o:o[e]||(o[e]={}),b=y.prototype,x=p?r:h?r[e]:(r[e]||{}).prototype;for(c in p&&(n=e),n)(l=!d&&x&&void 0!==x[c])&&u(y,c)||(f=l?x[c]:n[c],y[c]=p&&"function"!=typeof x[c]?n[c]:g&&l?i(f,r):m&&x[c]==f?function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(f):v&&"function"==typeof f?i(Function.call,f):f,v&&((y.virtual||(y.virtual={}))[c]=f,t&s.R&&b&&!b[c]&&a(b,c,f)))};s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,t.exports=s},6762:function(t,e,n){"use strict";var r=n("5ca1"),o=n("c366")(!0);r(r.P,"Array",{includes:function(t){return o(this,t,arguments.length>1?arguments[1]:void 0)}}),n("9c6c")("includes")},6821:function(t,e,n){var r=n("626a"),o=n("be13");t.exports=function(t){return r(o(t))}},"69a8":function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},"6a99":function(t,e,n){var r=n("d3f4");t.exports=function(t,e){if(!r(t))return t;var n,o;if(e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!r(o=n.call(t)))return o;if(!e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},"6b4c":function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},"6c1c":function(t,e,n){n("c367");for(var r=n("e53d"),o=n("35e8"),i=n("481b"),a=n("5168")("toStringTag"),u="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),s=0;s=c?t?"":void 0:(i=u.charCodeAt(s))<55296||i>56319||s+1===c||(a=u.charCodeAt(s+1))<56320||a>57343?t?u.charAt(s):i:t?u.slice(s,s+2):a-56320+(i-55296<<10)+65536}}},7726:function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},"774e":function(t,e,n){t.exports=n("d2d5")},"77f1":function(t,e,n){var r=n("4588"),o=Math.max,i=Math.min;t.exports=function(t,e){return(t=r(t))<0?o(t+e,0):i(t,e)}},"794b":function(t,e,n){t.exports=!n("8e60")&&!n("294c")(function(){return 7!=Object.defineProperty(n("1ec9")("div"),"a",{get:function(){return 7}}).a})},"79aa":function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},"79e5":function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},"7cd6":function(t,e,n){var r=n("40c3"),o=n("5168")("iterator"),i=n("481b");t.exports=n("584a").getIteratorMethod=function(t){if(void 0!=t)return t[o]||t["@@iterator"]||i[r(t)]}},"7d7b":function(t,e,n){var r=n("e4ae"),o=n("7cd6");t.exports=n("584a").getIterator=function(t){var e=o(t);if("function"!=typeof e)throw TypeError(t+" is not iterable!");return r(e.call(t))}},"7e90":function(t,e,n){var r=n("d9f6"),o=n("e4ae"),i=n("c3a1");t.exports=n("8e60")?Object.defineProperties:function(t,e){o(t);for(var n,a=i(e),u=a.length,s=0;u>s;)r.f(t,n=a[s++],e[n]);return t}},8378:function(t,e){var n=t.exports={version:"2.6.5"};"number"==typeof __e&&(__e=n)},8436:function(t,e){t.exports=function(){}},"86cc":function(t,e,n){var r=n("cb7c"),o=n("c69a"),i=n("6a99"),a=Object.defineProperty;e.f=n("9e1e")?Object.defineProperty:function(t,e,n){if(r(t),e=i(e,!0),r(n),o)try{return a(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},"8aae":function(t,e,n){n("32a6"),t.exports=n("584a").Object.keys},"8e60":function(t,e,n){t.exports=!n("294c")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},"8f60":function(t,e,n){"use strict";var r=n("a159"),o=n("aebd"),i=n("45f2"),a={};n("35e8")(a,n("5168")("iterator"),function(){return this}),t.exports=function(t,e,n){t.prototype=r(a,{next:o(1,n)}),i(t,e+" Iterator")}},9003:function(t,e,n){var r=n("6b4c");t.exports=Array.isArray||function(t){return"Array"==r(t)}},9138:function(t,e,n){t.exports=n("35e8")},9306:function(t,e,n){"use strict";var r=n("c3a1"),o=n("9aa9"),i=n("355d"),a=n("241e"),u=n("335c"),s=Object.assign;t.exports=!s||n("294c")(function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=s({},t)[n]||Object.keys(s({},e)).join("")!=r})?function(t,e){for(var n=a(t),s=arguments.length,c=1,l=o.f,f=i.f;s>c;)for(var d,p=u(arguments[c++]),h=l?r(p).concat(l(p)):r(p),v=h.length,g=0;v>g;)f.call(p,d=h[g++])&&(n[d]=p[d]);return n}:s},9427:function(t,e,n){var r=n("63b6");r(r.S,"Object",{create:n("a159")})},"95d5":function(t,e,n){var r=n("40c3"),o=n("5168")("iterator"),i=n("481b");t.exports=n("584a").isIterable=function(t){var e=Object(t);return void 0!==e[o]||"@@iterator"in e||i.hasOwnProperty(r(e))}},"9aa9":function(t,e){e.f=Object.getOwnPropertySymbols},"9b43":function(t,e,n){var r=n("d8e8");t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}},"9c6c":function(t,e,n){var r=n("2b4c")("unscopables"),o=Array.prototype;void 0==o[r]&&n("32e9")(o,r,{}),t.exports=function(t){o[r][t]=!0}},"9def":function(t,e,n){var r=n("4588"),o=Math.min;t.exports=function(t){return t>0?o(r(t),9007199254740991):0}},"9e1e":function(t,e,n){t.exports=!n("79e5")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},a159:function(t,e,n){var r=n("e4ae"),o=n("7e90"),i=n("1691"),a=n("5559")("IE_PROTO"),u=function(){},s=function(){var t,e=n("1ec9")("iframe"),r=i.length;for(e.style.display="none",n("32fc").appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write(" \ No newline at end of file + diff --git a/resources/js/components/sub-fields/NumberSubField.vue b/resources/js/components/sub-fields/NumberSubField.vue index 17b9ff8..c0877bc 100644 --- a/resources/js/components/sub-fields/NumberSubField.vue +++ b/resources/js/components/sub-fields/NumberSubField.vue @@ -1,27 +1,43 @@ \ No newline at end of file + diff --git a/resources/js/components/sub-fields/SelectSubField.vue b/resources/js/components/sub-fields/SelectSubField.vue index fadfa79..ca86af3 100644 --- a/resources/js/components/sub-fields/SelectSubField.vue +++ b/resources/js/components/sub-fields/SelectSubField.vue @@ -1,45 +1,58 @@ diff --git a/resources/js/components/sub-fields/TextSubField.vue b/resources/js/components/sub-fields/TextSubField.vue index cc6b50c..a2b60cc 100644 --- a/resources/js/components/sub-fields/TextSubField.vue +++ b/resources/js/components/sub-fields/TextSubField.vue @@ -1,27 +1,42 @@ \ No newline at end of file + diff --git a/resources/js/components/sub-fields/TextareaSubField.vue b/resources/js/components/sub-fields/TextareaSubField.vue index 3be086c..6fd1742 100644 --- a/resources/js/components/sub-fields/TextareaSubField.vue +++ b/resources/js/components/sub-fields/TextareaSubField.vue @@ -1,26 +1,41 @@ \ No newline at end of file + diff --git a/src/ArrayRules.php b/src/ArrayRules.php new file mode 100644 index 0000000..821a715 --- /dev/null +++ b/src/ArrayRules.php @@ -0,0 +1,98 @@ +rules = $rules; + $this->field = $field; + } + + /** + * Determine if the validation rule passes. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + public function passes($attribute, $value) + { + $input = [$attribute => json_decode($value, JSON_OBJECT_AS_ARRAY)]; + $rules = $this->prefixRules(); + $attributes = $this->getAttributes(); + + $validator = \Validator::make($input, $rules, [], $attributes); + + $this->message = $validator->errors(); + + return $validator->passes(); + } + + /** + * Get the validation error message. + * + * @return string + */ + public function message() + { + return $this->message; + } + + /** + * @return array + */ + private function prefixRules(): array + { + $rules = []; + $attribute = $this->field->attribute; + + foreach ($this->rules as $key => $rule) { + $rules["{$attribute}.*.{$key}"] = $rule; + } + + return $rules; + } + + /** + * @return array + */ + private function getAttributes(): array + { + $attributes = []; + $subFields = $this->field->meta()['sub_fields'] ?? []; + $attribute = $this->field->attribute; + + foreach ($subFields as $field) { + $key = $field['name']; + $attributes["{$attribute}.*.{$key}"] = strtolower($field['label']); + } + + return $attributes; + } +} diff --git a/src/Repeater.php b/src/Repeater.php index c7e348c..3e74ee5 100644 --- a/src/Repeater.php +++ b/src/Repeater.php @@ -111,4 +111,15 @@ private function normaliseFieldConfig($fieldConfig) return $config; } + + public function rules($rules) + { + if (!is_array($rules)) { + abort(500, 'Nova Items Field requires array of validation rules'); + } + + $this->rules = [ new ArrayRules($this, $rules) ]; + + return $this; + } }