Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contentful/field-editor-shared

Package Overview
Dependencies
Maintainers
57
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contentful/field-editor-shared - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

2

dist/createFakeFieldAPI.d.ts
import mitt from 'mitt';
import { FieldAPI } from 'contentful-ui-extensions-sdk';
declare type CustomizeMockFn = (fieldApi: FieldAPI, emitter: mitt.Emitter) => FieldAPI;
export declare function createFakeFieldAPI(customizeMock?: CustomizeMockFn): FieldAPI;
export declare function createFakeFieldAPI<T>(customizeMock?: CustomizeMockFn, initialValue?: T): FieldAPI;
export {};

@@ -13,3 +13,3 @@ 'use strict';

function createFakeFieldAPI(customizeMock) {
function createFakeFieldAPI(customizeMock, initialValue) {
if (customizeMock === void 0) {

@@ -19,4 +19,5 @@ customizeMock = identity;

var emitter = new mitt();
var _value = undefined;
var emitter = new mitt(); // eslint-disable-next-line
var _value = initialValue;
return customizeMock({

@@ -23,0 +24,0 @@ id: 'fake-id',

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("mitt")),n=e(require("react")),r=e(require("lodash/throttle"));function o(e){return e}function u(){return(u=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 i=function(e){var t,n;function o(t){var n;return(n=e.call(this,t)||this).unsubscribeErrors=null,n.unsubscribeDisabled=null,n.unsubscribeValue=null,n.setValue=r(function(e){n.props.isEmptyValue(void 0===e?null:e)?n.props.field.removeValue():n.props.field.setValue(e)},n.props.throttle,{leading:0===n.props.throttle}),n.state={value:t.field.getValue(),disabled:t.initialDisabled,errors:[]},n}n=e,(t=o).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;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({value:t})})},i.componentWillUnmount=function(){"function"==typeof this.unsubscribeErrors&&this.unsubscribeErrors(),"function"==typeof this.unsubscribeDisabled&&this.unsubscribeDisabled(),"function"==typeof this.unsubscribeValue&&this.unsubscribeValue()},i.render=function(){return this.props.children(u({},this.state,{setValue:this.setValue}))},o}(n.Component);i.defaultProps={children:function(){return null},isEmptyValue:function(e){return null===e||""===e},throttle:300},exports.FieldConnector=i,exports.createFakeFieldAPI=function(e){void 0===e&&(e=o);var n=new t,r=void 0;return e({id:"fake-id",locale:"en-US",type:"",validations:[],required:!1,onValueChanged:function(e){return n.on("value_changed",e),function(){n.off("value_changed",e)}},onIsDisabledChanged:function(e){return n.on("disable_changed",e),function(){n.off("disable_changed",e)}},onSchemaErrorsChanged:function(e){return n.on("errors_changed",e),function(){n.off("errors_changed",e)}},getValue:function(){return r},setInvalid:function(){},setValue:function(e){return n.emit("value_changed",r=e),Promise.resolve()},removeValue:function(){return r="",n.emit("value_changed",""),Promise.resolve()}},n)};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("mitt")),n=e(require("react")),r=e(require("lodash/throttle"));function u(e){return e}function o(){return(o=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 i=function(e){var t,n;function u(t){var n;return(n=e.call(this,t)||this).unsubscribeErrors=null,n.unsubscribeDisabled=null,n.unsubscribeValue=null,n.setValue=r(function(e){n.props.isEmptyValue(void 0===e?null:e)?n.props.field.removeValue():n.props.field.setValue(e)},n.props.throttle,{leading:0===n.props.throttle}),n.state={value:t.field.getValue(),disabled:t.initialDisabled,errors:[]},n}n=e,(t=u).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var i=u.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({value:t})})},i.componentWillUnmount=function(){"function"==typeof this.unsubscribeErrors&&this.unsubscribeErrors(),"function"==typeof this.unsubscribeDisabled&&this.unsubscribeDisabled(),"function"==typeof this.unsubscribeValue&&this.unsubscribeValue()},i.render=function(){return this.props.children(o({},this.state,{setValue:this.setValue}))},u}(n.Component);i.defaultProps={children:function(){return null},isEmptyValue:function(e){return null===e||""===e},throttle:300},exports.FieldConnector=i,exports.createFakeFieldAPI=function(e,n){void 0===e&&(e=u);var r=new t,o=n;return e({id:"fake-id",locale:"en-US",type:"",validations:[],required:!1,onValueChanged:function(e){return r.on("value_changed",e),function(){r.off("value_changed",e)}},onIsDisabledChanged:function(e){return r.on("disable_changed",e),function(){r.off("disable_changed",e)}},onSchemaErrorsChanged:function(e){return r.on("errors_changed",e),function(){r.off("errors_changed",e)}},getValue:function(){return o},setInvalid:function(){},setValue:function(e){return r.emit("value_changed",o=e),Promise.resolve()},removeValue:function(){return o="",r.emit("value_changed",""),Promise.resolve()}},r)};
//# sourceMappingURL=field-editor-shared.cjs.production.min.js.map

@@ -9,3 +9,3 @@ import mitt from 'mitt';

function createFakeFieldAPI(customizeMock) {
function createFakeFieldAPI(customizeMock, initialValue) {
if (customizeMock === void 0) {

@@ -15,4 +15,5 @@ customizeMock = identity;

var emitter = new mitt();
var _value = undefined;
var emitter = new mitt(); // eslint-disable-next-line
var _value = initialValue;
return customizeMock({

@@ -19,0 +20,0 @@ id: 'fake-id',

{
"name": "@contentful/field-editor-shared",
"version": "0.0.2",
"version": "0.1.0",
"main": "dist/index.js",

@@ -30,3 +30,3 @@ "module": "dist/field-editor-shared.esm.js",

},
"gitHead": "3871ffbe350e303e49eec249f17c0220f5fdf917"
"gitHead": "4320861d2d63937aff1a714c4873a4b821774394"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc