@tinacms/core
Advanced tools
Comparing version 0.1.2 to 0.2.0-alpha.0
@@ -20,3 +20,5 @@ /// <reference types="react" /> | ||
}; | ||
initialValues: any; | ||
constructor({ id, label, fields, actions, ...options }: FormOptions<S>); | ||
updateFields(fields: Field[]): void; | ||
private discoverHiddenFields; | ||
@@ -23,0 +25,0 @@ private removeDeclaredFieldsFromHiddenLookup; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("final-form-arrays"),require("final-form")):"function"==typeof define&&define.amd?define(["exports","final-form-arrays","final-form"],t):t((e=e||self)["@tinacms/core"]={},e.arrayMutators,e.finalForm)}(this,function(e,a,c){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a;var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function t(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var l=function(){return(l=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function f(r,n){var i,o,s,e,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,o&&(s=2&t[0]?o.return:t[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,t[1])).done)return s;switch(o=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return u.label++,{value:t[1],done:!1};case 5:u.label++,o=t[1],t=[0];continue;case 7:t=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){u=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){u.label=t[1];break}if(6===t[0]&&u.label<s[1]){u.label=s[1],s=t;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(t);break}s[2]&&u.ops.pop(),u.trys.pop();continue}t=n.call(r,u)}catch(e){t=[6,e],o=0}finally{i=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}var r=(i.prototype.subscribe=function(e){var t=this;return this.__subscribers.push(e),function(){return t.unsubscribe(e)}},i.prototype.unsubscribe=function(e){var t=this.__subscribers.indexOf(e);this.__subscribers.splice(t,1)},i.prototype.notifiySubscribers=function(){this.__subscribers.forEach(function(e){return e()})},i);function i(){this.__subscribers=[]}var o=(s.prototype.discoverHiddenFields=function(e,o){var s=this;Object.entries(e).map(function(e){var t=e[0],r=e[1],n=o?o+"."+t:t;if(Array.isArray(r))if(r.find(function(e){return"object"==typeof e})){var i=n+".INDEX";r.forEach(function(e){s.discoverHiddenFields(e,i)})}else s.hiddenFields[n]={path:n,field:{name:n,component:null},unsubscribe:s.finalForm.registerField(n,function(){},{})};else"object"==typeof r&&null!==r?s.discoverHiddenFields(r,n):s.hiddenFields[n]={path:n,field:{name:n,component:null},unsubscribe:s.finalForm.registerField(n,function(){},{})}})},s.prototype.removeDeclaredFieldsFromHiddenLookup=function(){var r=this;Object.keys(this.fieldSubscriptions).forEach(function(e){var t=r.hiddenFields[e];t&&(t.unsubscribe(),delete r.hiddenFields[e])})},s.prototype.registerFields=function(e,i){var o=this;e.forEach(function(e){var t=i?i+"."+e.name:e.name,r=["group"].includes(e.component);if(["group-list","blocks"].includes(e.component)){var n=e.fields||[];o.registerFields(n,t+".INDEX")}else r?(n=e.fields||[],o.registerFields(n,t)):o.fieldSubscriptions[t]={path:t,field:e,unsubscribe:o.finalForm.registerField(t,function(){},{})}})},Object.defineProperty(s.prototype,"values",{get:function(){return this.finalForm.getState().values},enumerable:!0,configurable:!0}),s);function s(e){var r=this,t=e.id,n=e.label,i=e.fields,o=e.actions,s=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(e,["id","label","fields","actions"]);this.fieldSubscriptions={},this.hiddenFields={},this.subscribe=function(e,t){return r.finalForm.subscribe(e,t)},this.submit=function(){return r.finalForm.submit()};var u=s.initialValues||{};this.id=t,this.label=n,this.fields=i,this.finalForm=c.createForm(l({},s,{initialValues:u,onSubmit:function(r,n,i){return function(o,s,u,a){return new(u=u||Promise)(function(e,t){function r(e){try{i(a.next(e))}catch(e){t(e)}}function n(e){try{i(a.throw(e))}catch(e){t(e)}}function i(t){t.done?e(t.value):new u(function(e){e(t.value)}).then(r,n)}i((a=a.apply(o,s||[])).next())})}(this,void 0,void 0,function(){var t;return f(this,function(e){switch(e.label){case 0:return[4,s.onSubmit(r,n,i)];case 1:return t=e.sent(),n.initialize(r),[2,t]}})})},mutators:l({},a,s.mutators)})),this.registerFields(this.fields),this.discoverHiddenFields(u),this.removeDeclaredFieldsFromHiddenLookup(),this.actions=o||[]}var u,p=(t(d,u=r),d.prototype.findForm=function(e){return this.__forms[e]},d.prototype.all=function(){var t=this;return Object.keys(this.__forms).map(function(e){return t.__forms[e]})},d);function d(){var r=null!==u&&u.apply(this,arguments)||this;return r.__forms={},r.createForm=function(e){var t=new o(e);return r.__forms[e.id]=t,r.notifiySubscribers(),t},r.removeForm=function(e){delete r.__forms[e],r.notifiySubscribers()},r}var h=(b.prototype.findOrCreateMap=function(e){return this.plugins[e]=this.plugins[e]||new m(e)},b.prototype.add=function(e){this.findOrCreateMap(e.__type).add(e)},b.prototype.remove=function(e){this.findOrCreateMap(e.__type).remove(e)},b.prototype.all=function(e){return this.findOrCreateMap(e).all()},b);function b(){this.plugins={}}var y,m=(t(_,y=r),_.prototype.add=function(e){var t=e;t.__type||(t.__type=this.__type),this.__plugins[t.name]=t,this.notifiySubscribers()},_.prototype.all=function(){var t=this;return Object.keys(this.__plugins).map(function(e){return t.__plugins[e]})},_.prototype.find=function(e){return this.__plugins[e]},_.prototype.remove=function(e){var t="string"==typeof e?e:e.name,r=this.__plugins[t];return delete this.__plugins[t],this.notifiySubscribers(),r},_);function _(e){var t=y.call(this)||this;return t.__type=e,t.__plugins={},t}var v=(g.prototype.registerApi=function(e,t){this.api[e]=t},g);function g(){this.api={},this.forms=new p,this.plugins=new h}e.CMS=v,e.Form=o,e.FormManager=p,e.PluginManager=h,e.PluginType=m,e.Subscribable=r,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("final-form-arrays"),require("final-form")):"function"==typeof define&&define.amd?define(["exports","final-form-arrays","final-form"],e):e((t=t||self)["@tinacms/core"]={},t.arrayMutators,t.finalForm)}(this,function(t,a,l){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a;var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};function e(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var c=function(){return(c=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function f(i,n){var r,o,s,t,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,o=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){u.label=e[1];break}if(6===e[0]&&u.label<s[1]){u.label=s[1],s=e;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(e);break}s[2]&&u.ops.pop(),u.trys.pop();continue}e=n.call(i,u)}catch(t){e=[6,t],o=0}finally{r=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}var i=(r.prototype.subscribe=function(t){var e=this;return this.__subscribers.push(t),function(){return e.unsubscribe(t)}},r.prototype.unsubscribe=function(t){var e=this.__subscribers.indexOf(t);this.__subscribers.splice(e,1)},r.prototype.notifiySubscribers=function(){this.__subscribers.forEach(function(t){return t()})},r);function r(){this.__subscribers=[]}var o=(s.prototype.updateFields=function(t){this.fields=t,this.registerFields(this.fields),this.discoverHiddenFields(this.initialValues),this.removeDeclaredFieldsFromHiddenLookup()},s.prototype.discoverHiddenFields=function(t,o){var s=this;Object.entries(t).map(function(t){var e=t[0],i=t[1],n=o?o+"."+e:e;if(Array.isArray(i))if(i.find(function(t){return"object"==typeof t})){var r=n+".INDEX";i.forEach(function(t){s.discoverHiddenFields(t,r)})}else s.hiddenFields[n]={path:n,field:{name:n,component:null},unsubscribe:s.finalForm.registerField(n,function(){},{})};else"object"==typeof i&&null!==i?s.discoverHiddenFields(i,n):s.hiddenFields[n]={path:n,field:{name:n,component:null},unsubscribe:s.finalForm.registerField(n,function(){},{})}})},s.prototype.removeDeclaredFieldsFromHiddenLookup=function(){var i=this;Object.keys(this.fieldSubscriptions).forEach(function(t){var e=i.hiddenFields[t];e&&(e.unsubscribe(),delete i.hiddenFields[t])})},s.prototype.registerFields=function(t,r){var o=this;t.forEach(function(t){var e=r?r+"."+t.name:t.name,i=["group"].includes(t.component);if(["group-list","blocks"].includes(t.component)){var n=t.fields||[];o.registerFields(n,e+".INDEX")}else i?(n=t.fields||[],o.registerFields(n,e)):o.fieldSubscriptions[e]={path:e,field:t,unsubscribe:o.finalForm.registerField(e,function(){},{})}})},Object.defineProperty(s.prototype,"values",{get:function(){return this.finalForm.getState().values},enumerable:!0,configurable:!0}),s);function s(t){var i=this,e=t.id,n=t.label,r=t.fields,o=t.actions,s=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(i[n[r]]=t[n[r]])}return i}(t,["id","label","fields","actions"]);this.fieldSubscriptions={},this.hiddenFields={},this.subscribe=function(t,e){return i.finalForm.subscribe(t,e)},this.submit=function(){return i.finalForm.submit()};var u=s.initialValues||{};this.id=e,this.label=n,this.fields=r,this.finalForm=l.createForm(c({},s,{initialValues:u,onSubmit:function(i,n,r){return function(o,s,u,a){return new(u=u||Promise)(function(t,e){function i(t){try{r(a.next(t))}catch(t){e(t)}}function n(t){try{r(a.throw(t))}catch(t){e(t)}}function r(e){e.done?t(e.value):new u(function(t){t(e.value)}).then(i,n)}r((a=a.apply(o,s||[])).next())})}(this,void 0,void 0,function(){var e;return f(this,function(t){switch(t.label){case 0:return[4,s.onSubmit(i,n,r)];case 1:return e=t.sent(),n.initialize(i),[2,e]}})})},mutators:c({},a,s.mutators)})),this.actions=o||[],this.initialValues=u,this.updateFields(this.fields)}var u,p=(e(d,u=i),d.prototype.findForm=function(t){return this.__forms[t]},d.prototype.all=function(){var e=this;return Object.keys(this.__forms).map(function(t){return e.__forms[t]})},d);function d(){var i=null!==u&&u.apply(this,arguments)||this;return i.__forms={},i.createForm=function(t){var e=new o(t);return i.__forms[t.id]=e,i.notifiySubscribers(),e},i.removeForm=function(t){delete i.__forms[t],i.notifiySubscribers()},i}var h=(b.prototype.findOrCreateMap=function(t){return this.plugins[t]=this.plugins[t]||new m(t)},b.prototype.add=function(t){this.findOrCreateMap(t.__type).add(t)},b.prototype.remove=function(t){this.findOrCreateMap(t.__type).remove(t)},b.prototype.all=function(t){return this.findOrCreateMap(t).all()},b);function b(){this.plugins={}}var y,m=(e(_,y=i),_.prototype.add=function(t){var e=t;e.__type||(e.__type=this.__type),this.__plugins[e.name]=e,this.notifiySubscribers()},_.prototype.all=function(){var e=this;return Object.keys(this.__plugins).map(function(t){return e.__plugins[t]})},_.prototype.find=function(t){return this.__plugins[t]},_.prototype.remove=function(t){var e="string"==typeof t?t:t.name,i=this.__plugins[e];return delete this.__plugins[e],this.notifiySubscribers(),i},_);function _(t){var e=y.call(this)||this;return e.__type=t,e.__plugins={},e}var v=(g.prototype.registerApi=function(t,e){this.api[t]=e},g);function g(){this.api={},this.forms=new p,this.plugins=new h}t.CMS=v,t.Form=o,t.FormManager=p,t.PluginManager=h,t.PluginType=m,t.Subscribable=i,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -6,2 +6,18 @@ # Change Log | ||
# [0.2.0-alpha.0](https://github.com/tinacms/tinacms/compare/@tinacms/core@0.1.1...@tinacms/core@0.2.0-alpha.0) (2019-10-07) | ||
### Bug Fixes | ||
* initialValues defualts to empty object ([5088086](https://github.com/tinacms/tinacms/commit/5088086)) | ||
### Features | ||
* form fields can be updated ([7f4818b](https://github.com/tinacms/tinacms/commit/7f4818b)) | ||
## [0.1.2](https://github.com/tinacms/tinacms/compare/@tinacms/core@0.1.2-alpha.0...@tinacms/core@0.1.2) (2019-10-04) | ||
@@ -8,0 +24,0 @@ |
{ | ||
"name": "@tinacms/core", | ||
"version": "0.1.2", | ||
"version": "0.2.0-alpha.0", | ||
"main": "build/index.js", | ||
@@ -32,3 +32,3 @@ "types": "build/index.d.ts", | ||
"@types/react": "^16.8.23", | ||
"cms-scripts": "^0.1.0", | ||
"cms-scripts": "^0.1.2-alpha.0", | ||
"jest": "^24.8.0", | ||
@@ -45,3 +45,3 @@ "react": "^16.8.6", | ||
}, | ||
"gitHead": "6c2ea24da6ea3146ced7eb3c687170b4eae3a18a" | ||
"gitHead": "c0156f0f4478059e7e6da9a0c336565877e91f3f" | ||
} |
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
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
14783
135