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-alpha.29 to 0.0.2

19

dist/field-editor-shared.cjs.development.js

@@ -98,10 +98,12 @@ 'use strict';

_this.setValue = throttle(function (value) {
if (value) {
if (_this.props.isEmptyValue(value === undefined ? null : value)) {
_this.props.field.removeValue();
} else {
_this.props.field.setValue(value);
} else {
_this.props.field.removeValue();
}
}, _this.props.throttle);
}, _this.props.throttle, {
leading: _this.props.throttle === 0
});
_this.state = {
value: props.field.getValue() || '',
value: props.field.getValue(),
disabled: props.initialDisabled,

@@ -131,3 +133,3 @@ errors: []

_this2.setState({
value: value || ''
value: value
});

@@ -163,2 +165,7 @@ });

},
// eslint-disable-next-line
isEmptyValue: function isEmptyValue(value) {
// @ts-ignore
return value === null || value === '';
},
throttle: 300

@@ -165,0 +172,0 @@ };

@@ -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){e?n.props.field.setValue(e):n.props.field.removeValue()},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},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 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)};
//# sourceMappingURL=field-editor-shared.cjs.production.min.js.map

@@ -94,10 +94,12 @@ import mitt from 'mitt';

_this.setValue = throttle(function (value) {
if (value) {
if (_this.props.isEmptyValue(value === undefined ? null : value)) {
_this.props.field.removeValue();
} else {
_this.props.field.setValue(value);
} else {
_this.props.field.removeValue();
}
}, _this.props.throttle);
}, _this.props.throttle, {
leading: _this.props.throttle === 0
});
_this.state = {
value: props.field.getValue() || '',
value: props.field.getValue(),
disabled: props.initialDisabled,

@@ -127,3 +129,3 @@ errors: []

_this2.setState({
value: value || ''
value: value
});

@@ -159,2 +161,7 @@ });

},
// eslint-disable-next-line
isEmptyValue: function isEmptyValue(value) {
// @ts-ignore
return value === null || value === '';
},
throttle: 300

@@ -161,0 +168,0 @@ };

/// <reference types="lodash" />
import React from 'react';
import { FieldAPI } from 'contentful-ui-extensions-sdk';
interface FieldConnectorState {
value: string;
declare type Nullable = null | undefined;
interface FieldConnectorState<ValueType> {
value: ValueType | Nullable;
disabled: boolean;
errors: string[];
}
interface FieldConnectorProps {
interface FieldConnectorProps<ValueType> {
field: FieldAPI;
initialDisabled: boolean;
children: (state: FieldConnectorState & {
setValue: (value: string) => void;
children: (state: FieldConnectorState<ValueType> & {
setValue: (value: ValueType | Nullable) => void;
}) => React.ReactNode;
isEmptyValue: (value: ValueType | null) => boolean;
throttle: number;
}
export declare class FieldConnector extends React.Component<FieldConnectorProps, FieldConnectorState> {
static defaultProps: Pick<FieldConnectorProps, 'children' | 'throttle'>;
constructor(props: FieldConnectorProps);
export declare class FieldConnector<ValueType> extends React.Component<FieldConnectorProps<ValueType>, FieldConnectorState<ValueType>> {
static defaultProps: {
children: () => null;
isEmptyValue: (value: any) => boolean;
throttle: number;
};
constructor(props: FieldConnectorProps<ValueType>);
unsubscribeErrors: Function | null;
unsubscribeDisabled: Function | null;
unsubscribeValue: Function | null;
setValue: ((value: any) => void) & import("lodash").Cancelable;
setValue: ((value: ValueType | null | undefined) => void) & import("lodash").Cancelable;
componentDidMount(): void;

@@ -25,0 +31,0 @@ componentWillUnmount(): void;

{
"name": "@contentful/field-editor-shared",
"version": "0.0.2-alpha.29+1a6014f",
"version": "0.0.2",
"main": "dist/index.js",

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

"dependencies": {
"contentful-ui-extensions-sdk": "^3.9.1",
"contentful-ui-extensions-sdk": "^3.9.2",
"lodash": "^4.17.15",

@@ -31,3 +31,3 @@ "lodash-es": "^4.17.15"

},
"gitHead": "1a6014fdacc01554a972ea27201ff2b549fe861c"
"gitHead": "3871ffbe350e303e49eec249f17c0220f5fdf917"
}
# @contentful/field-editor-shared
This package contains shared code (components, utilities, test utilities) that is used by all other field editor packages.
## Commands
Uses [`tsdx`](https://github.com/palmerhq/tsdx) - a zero-config CLI that helps you develop, test, and publish modern TypeScript packages with ease.
### `yarn watch`
Runs the project in development/watch mode. Your library will be rebuilt if you make edits.
### `yarn build`
Bundles the package to the `dist` folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
### `yarn test`
Runs the test watcher (Jest) in an interactive mode.
By default, runs tests related to files changed since the last commit.
For more information check [`tsdx` documentation](https://github.com/palmerhq/tsdx) out.

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