@contentful/field-editor-shared
Advanced tools
Comparing version 0.10.3 to 0.10.4
@@ -140,3 +140,3 @@ 'use strict'; | ||
delete childProps.lastSetValue; | ||
return this.props.children(_extends({}, childProps, { | ||
return this.props.children(_extends(_extends({}, childProps), {}, { | ||
setValue: this.setValue | ||
@@ -232,3 +232,3 @@ })); | ||
function onClose() { | ||
currentConfig = _extends({}, currentConfig, { | ||
currentConfig = _extends(_extends({}, currentConfig), {}, { | ||
isShown: false | ||
@@ -235,0 +235,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),n=e(require("lodash/throttle")),r=e(require("lodash/isEqual")),o=require("@contentful/forma-36-react-components"),i=e(require("@contentful/forma-36-tokens")),l=require("emotion"),a=e(require("lodash/isNumber")),u=e(require("react-dom")),s=e(require("lodash/get")),d=e(require("lodash/isObject")),c=e(require("lodash/isString"));function f(){return(f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var p=function(e){var t,r;function o(t){var r;(r=e.call(this,t)||this).unsubscribeErrors=null,r.unsubscribeDisabled=null,r.unsubscribeValue=null,r.setValue=n((function(e){return r.props.isEmptyValue(void 0===e?null:e)?new Promise((function(e,t){r.setState({lastSetValue:void 0},(function(){r.props.field.removeValue().then(e).catch(t)}))})):new Promise((function(t,n){r.setState({lastSetValue:e},(function(){r.props.field.setValue(e).then(t).catch(n)}))}))}),r.props.throttle,{leading:0===r.props.throttle});var o=t.field.getValue();return r.state={isLocalValueChange:!1,externalReset:0,value:o,lastSetValue:o,lastRemoteValue:o,disabled:t.isInitiallyDisabled,errors:[]},r}r=e,(t=o).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=o.prototype;return i.componentDidMount=function(){var e=this,t=this.props.field;this.unsubscribeErrors=t.onSchemaErrorsChanged((function(t){e.setState({errors:t||[]})})),this.unsubscribeDisabled=t.onIsDisabledChanged((function(t){e.setState({disabled:t})})),this.unsubscribeValue=t.onValueChanged((function(t){e.setState((function(n){var r=e.props.isEqualValues(t,n.lastSetValue);return{value:t,lastSetValue:t,lastRemoteValue:r?n.lastRemoteValue:t,isLocalValueChange:r,externalReset:n.externalReset+(r?0:1)}}))}))},i.componentWillUnmount=function(){"function"==typeof this.unsubscribeErrors&&this.unsubscribeErrors(),"function"==typeof this.unsubscribeDisabled&&this.unsubscribeDisabled(),"function"==typeof this.unsubscribeValue&&this.unsubscribeValue()},i.render=function(){var e=f({},this.state);return delete e.lastSetValue,this.props.children(f({},e,{setValue:this.setValue}))},o}(t.Component);p.defaultProps={children:function(){return null},isEmptyValue:function(e){return null===e||""===e},isEqualValues:function(e,t){return r(e,t)},throttle:300};var m=l.css({color:i.colorRedBase});function h(e){var t=null,n=function(){return null===t&&((t=document.createElement("div")).setAttribute("id","field-editor-modal-root"),document.body.appendChild(t)),t};return new Promise((function(t){var r={onClose:function(){o(r=f({},r,{isShown:!1})),t.apply(void 0,arguments),n().remove()},isShown:!0};function o(t){u.render(e({onClose:t.onClose,isShown:t.isShown}),n())}o(r)}))}function y(e,n){var r=Date.now(),i=a(e.width)?e.width+"px":e.width;return h((function(l){var a=l.onClose,u=function(){return a()};return t.createElement(o.Modal,{key:r,shouldCloseOnOverlayClick:e.shouldCloseOnOverlayClick||!1,shouldCloseOnEscapePress:e.shouldCloseOnEscapePress||!1,allowHeightOverflow:e.allowHeightOverflow||!1,position:e.position||"center",isShown:l.isShown,onClose:u,size:i||"700px"},(function(){return t.createElement(t.Fragment,null,e.title&&t.createElement(o.Modal.Header,{testId:"dialog-title",title:e.title,onClose:u}),t.createElement("div",{style:{minHeight:e.minHeight||"auto"}},t.createElement(n,{onClose:a})))}))}))}var v={__proto__:null,open:h,openDialog:y,default:{openDialog:y}};function b(e,t){if(!c(e))return t;if(e){var n=e.trim();return 0===n.length?t:n}return t}function C(e){var t=e.localeCode,n=e.defaultLocaleCode,r=s(e.entity,["fields",e.fieldId]);if(d(r)){var o=Object.keys(r)[0];return r[t]||r[n]||r[o]}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var g={__proto__:null,getFieldValue:C,getAssetTitle:function(e){var t=e.defaultTitle;return b(C({entity:e.asset,fieldId:"title",localeCode:e.localeCode,defaultLocaleCode:e.defaultLocaleCode}),t)},getEntityDescription:function(e){var t=e.entity,n=e.contentType,r=e.localeCode,o=e.defaultLocaleCode;if(!n)return"";var i=n.fields.find((function(e){return function(e){return["Symbol","Text"].includes(e.type)}(e)&&!function(e){return e.id===n.displayField}(e)&&!function(e){return/\bslug\b/.test(e.name)}(e)}));return i&&C({entity:t,fieldId:i.id,localeCode:r,defaultLocaleCode:o})||""},getEntryTitle:function(e){var t,n=e.entry,r=e.contentType,o=e.localeCode,i=e.defaultLocaleCode,l=e.defaultTitle;if(!r)return l;var a=r.displayField;if(!a)return l;var u=r.fields.find((function(e){return e.id===a}));return u?(u.localized?(t=C({entity:n,fieldId:a,localeCode:o,defaultLocaleCode:i}))||(t=C({entity:n,fieldId:u.id,localeCode:o,defaultLocaleCode:i})):(t=C({entity:n,fieldId:a,defaultLocaleCode:i,localeCode:""}))||(t=C({entity:n,fieldId:u.id,defaultLocaleCode:i,localeCode:""})),b(t,l)):l},getEntryStatus:function(e){if(!e||"Entry"!==e.type&&"Asset"!==e.type)throw new TypeError("Invalid entity metadata object");return e.deletedVersion?"deleted":e.archivedVersion?"archived":e.publishedVersion?e.version>e.publishedVersion+1?"changed":"published":"draft"},getEntryImage:function(e,t){var n=e.entry,r=e.contentType,o=e.localeCode;try{if(!r)return Promise.resolve(null);var i=r.fields.find((function(e){return"Link"===e.type&&"Asset"===e.linkType}));if(!i)return Promise.resolve(null);var l=s(n.fields,[i.id,o,"sys","id"]);return Promise.resolve(l?function(e,n){try{var r=Promise.resolve(t(l)).then((function(e){var t=s(e,["fields","file",o]);return Boolean(s(t,["details","image"],!1))?t:null}))}catch(e){return null}return r&&r.then?r.then(void 0,(function(){return null})):r}():null)}catch(e){return Promise.reject(e)}}},V={__proto__:null,fromFieldValidations:function(e,t){void 0===e&&(e=[]);var n=e.find((function(e){return"size"in e})),r=n&&n.size||{},o=r.min,i=r.max;return a(o)&&a(i)?{type:"min-max",min:o,max:i}:a(o)?{type:"min",min:o}:a(i)?{type:"max",max:i}:{type:"max",max:"Symbol"===t?256:5e4}},makeChecker:function(e){return function(t){return"max"===e.type?t<=e.max:"min"===e.type?t>=e.min:t>=e.min&&t<=e.max}}};exports.CharCounter=function(e){var n,r=0;e.value&&(r=e.value.length);var o=0===r||e.checkConstraint(r);return t.createElement("span",{"data-status-code":o?null:"invalid-size",className:l.cx((n={},n[m]=!o,n))},r," characters")},exports.CharValidation=function(e){var n=e.constraints;return"max"===n.type?t.createElement("span",null,"Maximum ",n.max," characters"):"min"===n.type?t.createElement("span",null,"Requires at least ",n.min," characters"):t.createElement("span",null,"Requires between ",n.min," and ",n.max," characters")},exports.ConstraintsUtils=V,exports.FieldConnector=p,exports.ModalDialogLauncher=v,exports.PredefinedValuesError=function(){return t.createElement(o.Note,{noteType:"warning",testId:"predefined-values-warning"},"The widget failed to initialize. You can fix the problem by providing predefined values under the validations tab in the field settings.")},exports.entityHelpers=g; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),n=e(require("lodash/throttle")),r=e(require("lodash/isEqual")),o=require("@contentful/forma-36-react-components"),i=e(require("@contentful/forma-36-tokens")),l=require("emotion"),a=e(require("lodash/isNumber")),u=e(require("react-dom")),s=e(require("lodash/get")),d=e(require("lodash/isObject")),c=e(require("lodash/isString"));function f(){return(f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var p=function(e){var t,r;function o(t){var r;(r=e.call(this,t)||this).unsubscribeErrors=null,r.unsubscribeDisabled=null,r.unsubscribeValue=null,r.setValue=n((function(e){return r.props.isEmptyValue(void 0===e?null:e)?new Promise((function(e,t){r.setState({lastSetValue:void 0},(function(){r.props.field.removeValue().then(e).catch(t)}))})):new Promise((function(t,n){r.setState({lastSetValue:e},(function(){r.props.field.setValue(e).then(t).catch(n)}))}))}),r.props.throttle,{leading:0===r.props.throttle});var o=t.field.getValue();return r.state={isLocalValueChange:!1,externalReset:0,value:o,lastSetValue:o,lastRemoteValue:o,disabled:t.isInitiallyDisabled,errors:[]},r}r=e,(t=o).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var i=o.prototype;return i.componentDidMount=function(){var e=this,t=this.props.field;this.unsubscribeErrors=t.onSchemaErrorsChanged((function(t){e.setState({errors:t||[]})})),this.unsubscribeDisabled=t.onIsDisabledChanged((function(t){e.setState({disabled:t})})),this.unsubscribeValue=t.onValueChanged((function(t){e.setState((function(n){var r=e.props.isEqualValues(t,n.lastSetValue);return{value:t,lastSetValue:t,lastRemoteValue:r?n.lastRemoteValue:t,isLocalValueChange:r,externalReset:n.externalReset+(r?0:1)}}))}))},i.componentWillUnmount=function(){"function"==typeof this.unsubscribeErrors&&this.unsubscribeErrors(),"function"==typeof this.unsubscribeDisabled&&this.unsubscribeDisabled(),"function"==typeof this.unsubscribeValue&&this.unsubscribeValue()},i.render=function(){var e=f({},this.state);return delete e.lastSetValue,this.props.children(f(f({},e),{},{setValue:this.setValue}))},o}(t.Component);p.defaultProps={children:function(){return null},isEmptyValue:function(e){return null===e||""===e},isEqualValues:function(e,t){return r(e,t)},throttle:300};var m=l.css({color:i.colorRedBase});function h(e){var t=null,n=function(){return null===t&&((t=document.createElement("div")).setAttribute("id","field-editor-modal-root"),document.body.appendChild(t)),t};return new Promise((function(t){var r={onClose:function(){o(r=f(f({},r),{},{isShown:!1})),t.apply(void 0,arguments),n().remove()},isShown:!0};function o(t){u.render(e({onClose:t.onClose,isShown:t.isShown}),n())}o(r)}))}function y(e,n){var r=Date.now(),i=a(e.width)?e.width+"px":e.width;return h((function(l){var a=l.onClose,u=function(){return a()};return t.createElement(o.Modal,{key:r,shouldCloseOnOverlayClick:e.shouldCloseOnOverlayClick||!1,shouldCloseOnEscapePress:e.shouldCloseOnEscapePress||!1,allowHeightOverflow:e.allowHeightOverflow||!1,position:e.position||"center",isShown:l.isShown,onClose:u,size:i||"700px"},(function(){return t.createElement(t.Fragment,null,e.title&&t.createElement(o.Modal.Header,{testId:"dialog-title",title:e.title,onClose:u}),t.createElement("div",{style:{minHeight:e.minHeight||"auto"}},t.createElement(n,{onClose:a})))}))}))}var v={__proto__:null,open:h,openDialog:y,default:{openDialog:y}};function b(e,t){if(!c(e))return t;if(e){var n=e.trim();return 0===n.length?t:n}return t}function C(e){var t=e.localeCode,n=e.defaultLocaleCode,r=s(e.entity,["fields",e.fieldId]);if(d(r)){var o=Object.keys(r)[0];return r[t]||r[n]||r[o]}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var g={__proto__:null,getFieldValue:C,getAssetTitle:function(e){var t=e.defaultTitle;return b(C({entity:e.asset,fieldId:"title",localeCode:e.localeCode,defaultLocaleCode:e.defaultLocaleCode}),t)},getEntityDescription:function(e){var t=e.entity,n=e.contentType,r=e.localeCode,o=e.defaultLocaleCode;if(!n)return"";var i=n.fields.find((function(e){return function(e){return["Symbol","Text"].includes(e.type)}(e)&&!function(e){return e.id===n.displayField}(e)&&!function(e){return/\bslug\b/.test(e.name)}(e)}));return i&&C({entity:t,fieldId:i.id,localeCode:r,defaultLocaleCode:o})||""},getEntryTitle:function(e){var t,n=e.entry,r=e.contentType,o=e.localeCode,i=e.defaultLocaleCode,l=e.defaultTitle;if(!r)return l;var a=r.displayField;if(!a)return l;var u=r.fields.find((function(e){return e.id===a}));return u?(u.localized?(t=C({entity:n,fieldId:a,localeCode:o,defaultLocaleCode:i}))||(t=C({entity:n,fieldId:u.id,localeCode:o,defaultLocaleCode:i})):(t=C({entity:n,fieldId:a,defaultLocaleCode:i,localeCode:""}))||(t=C({entity:n,fieldId:u.id,defaultLocaleCode:i,localeCode:""})),b(t,l)):l},getEntryStatus:function(e){if(!e||"Entry"!==e.type&&"Asset"!==e.type)throw new TypeError("Invalid entity metadata object");return e.deletedVersion?"deleted":e.archivedVersion?"archived":e.publishedVersion?e.version>e.publishedVersion+1?"changed":"published":"draft"},getEntryImage:function(e,t){var n=e.entry,r=e.contentType,o=e.localeCode;try{if(!r)return Promise.resolve(null);var i=r.fields.find((function(e){return"Link"===e.type&&"Asset"===e.linkType}));if(!i)return Promise.resolve(null);var l=s(n.fields,[i.id,o,"sys","id"]);return Promise.resolve(l?function(e,n){try{var r=Promise.resolve(t(l)).then((function(e){var t=s(e,["fields","file",o]);return Boolean(s(t,["details","image"],!1))?t:null}))}catch(e){return null}return r&&r.then?r.then(void 0,(function(){return null})):r}():null)}catch(e){return Promise.reject(e)}}},V={__proto__:null,fromFieldValidations:function(e,t){void 0===e&&(e=[]);var n=e.find((function(e){return"size"in e})),r=n&&n.size||{},o=r.min,i=r.max;return a(o)&&a(i)?{type:"min-max",min:o,max:i}:a(o)?{type:"min",min:o}:a(i)?{type:"max",max:i}:{type:"max",max:"Symbol"===t?256:5e4}},makeChecker:function(e){return function(t){return"max"===e.type?t<=e.max:"min"===e.type?t>=e.min:t>=e.min&&t<=e.max}}};exports.CharCounter=function(e){var n,r=0;e.value&&(r=e.value.length);var o=0===r||e.checkConstraint(r);return t.createElement("span",{"data-status-code":o?null:"invalid-size",className:l.cx((n={},n[m]=!o,n))},r," characters")},exports.CharValidation=function(e){var n=e.constraints;return"max"===n.type?t.createElement("span",null,"Maximum ",n.max," characters"):"min"===n.type?t.createElement("span",null,"Requires at least ",n.min," characters"):t.createElement("span",null,"Requires between ",n.min," and ",n.max," characters")},exports.ConstraintsUtils=V,exports.FieldConnector=p,exports.ModalDialogLauncher=v,exports.PredefinedValuesError=function(){return t.createElement(o.Note,{noteType:"warning",testId:"predefined-values-warning"},"The widget failed to initialize. You can fix the problem by providing predefined values under the validations tab in the field settings.")},exports.entityHelpers=g; | ||
//# sourceMappingURL=field-editor-shared.cjs.production.min.js.map |
@@ -134,3 +134,3 @@ import React from 'react'; | ||
delete childProps.lastSetValue; | ||
return this.props.children(_extends({}, childProps, { | ||
return this.props.children(_extends(_extends({}, childProps), {}, { | ||
setValue: this.setValue | ||
@@ -226,3 +226,3 @@ })); | ||
function onClose() { | ||
currentConfig = _extends({}, currentConfig, { | ||
currentConfig = _extends(_extends({}, currentConfig), {}, { | ||
isShown: false | ||
@@ -229,0 +229,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
export { FieldAPI, ParametersAPI, LocalesAPI, BaseExtensionSDK, OpenCustomWidgetOptions } from 'contentful-ui-extensions-sdk'; | ||
export { FieldAPI, ParametersAPI, LocalesAPI, BaseExtensionSDK, OpenCustomWidgetOptions, } from 'contentful-ui-extensions-sdk'; | ||
export { FieldConnector } from './FieldConnector'; | ||
@@ -3,0 +3,0 @@ export { PredefinedValuesError } from './PredefinedValuesError'; |
{ | ||
"name": "@contentful/field-editor-shared", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"main": "dist/index.js", | ||
@@ -23,3 +23,3 @@ "module": "dist/field-editor-shared.esm.js", | ||
"@contentful/forma-36-tokens": "^0.5.1", | ||
"contentful-ui-extensions-sdk": "^3.14.3", | ||
"contentful-ui-extensions-sdk": "^3.15.0", | ||
"emotion": "^10.0.17", | ||
@@ -37,3 +37,3 @@ "lodash": "^4.17.15", | ||
}, | ||
"gitHead": "d7351c3d1739b9bb03eef482465ea257485b989e" | ||
"gitHead": "f776ed47666471fe8bfa70e955e509bd139582ac" | ||
} |
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
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
201671
1227