@contentful/field-editor-shared 1.4.7 → 1.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,12 +63,12 @@ const styles = {
63
63
  })
64
64
  };
65
65
  function CharCounter(props) {
66
- const { constraints } = props;
66
+ const { constraints, value, checkConstraint } = props;
67
67
  let count = 0;
68
- if (props.value) {
69
- count = props.value.length;
68
+ if (value) {
69
+ count = value.length;
70
70
  }
71
- const valid = count === 0 || props.checkConstraint(count);
71
+ const valid = count === 0 || checkConstraint(count);
72
72
  return _react.createElement("span", {
73
73
  "data-status-code": valid ? null : 'invalid-size',
74
74
  "data-test-id": "cf-ui-char-counter",
package/dist/cjs/index.js CHANGED
@@ -24,9 +24,6 @@ _export(exports, {
24
24
  CharCounter: function() {
25
25
  return _CharCounter.CharCounter;
26
26
  },
27
- CharValidation: function() {
28
- return _CharValidation.CharValidation;
29
- },
30
27
  ConstraintsUtils: function() {
31
28
  return _constraints;
32
29
  },
@@ -105,7 +102,6 @@ _export(exports, {
105
102
  });
106
103
  const _appsdk = require("@contentful/app-sdk");
107
104
  const _CharCounter = require("./CharCounter");
108
- const _CharValidation = require("./CharValidation");
109
105
  const _FieldConnector = require("./FieldConnector");
110
106
  const _PredefinedValuesError = require("./PredefinedValuesError");
111
107
  const _typesEntity = require("./typesEntity");
@@ -46,8 +46,7 @@ function fromFieldValidations(validations = [], fieldType) {
46
46
  } else {
47
47
  return {
48
48
  type: 'max',
49
- max: fieldType === 'Symbol' ? 256 : 50000,
50
- isDefaultConstraint: true
49
+ max: fieldType === 'Symbol' ? 256 : 50000
51
50
  };
52
51
  }
53
52
  }
@@ -7,12 +7,12 @@ const styles = {
7
7
  })
8
8
  };
9
9
  export function CharCounter(props) {
10
- const { constraints } = props;
10
+ const { constraints, value, checkConstraint } = props;
11
11
  let count = 0;
12
- if (props.value) {
13
- count = props.value.length;
12
+ if (value) {
13
+ count = value.length;
14
14
  }
15
- const valid = count === 0 || props.checkConstraint(count);
15
+ const valid = count === 0 || checkConstraint(count);
16
16
  return React.createElement("span", {
17
17
  "data-status-code": valid ? null : 'invalid-size',
18
18
  "data-test-id": "cf-ui-char-counter",
package/dist/esm/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  export { AccessAPI, AppConfigAPI, BaseAppSDK, ContentType, DialogsAPI, EntryAPI, EntryFieldAPI, FieldAPI, FieldAppSDK, IdsAPI, LocalesAPI, LocationAPI, NavigatorAPI, NotifierAPI, OpenCustomWidgetOptions, ParametersAPI, SpaceAPI, WindowAPI } from '@contentful/app-sdk';
2
2
  export { CharCounter } from './CharCounter';
3
- export { CharValidation } from './CharValidation';
4
3
  export { FieldConnector } from './FieldConnector';
5
4
  export { PredefinedValuesError } from './PredefinedValuesError';
6
5
  export { Asset, Entry, File } from './typesEntity';
@@ -23,8 +23,7 @@ export function fromFieldValidations(validations = [], fieldType) {
23
23
  } else {
24
24
  return {
25
25
  type: 'max',
26
- max: fieldType === 'Symbol' ? 256 : 50000,
27
- isDefaultConstraint: true
26
+ max: fieldType === 'Symbol' ? 256 : 50000
28
27
  };
29
28
  }
30
29
  }
@@ -1,6 +1,5 @@
1
1
  export { AccessAPI, AppConfigAPI, BaseAppSDK, ContentType, DialogsAPI, EntryAPI, EntryFieldAPI, FieldAPI, FieldAppSDK, IdsAPI, LocalesAPI, LocationAPI, NavigatorAPI, NotifierAPI, OpenCustomWidgetOptions, ParametersAPI, SpaceAPI, WindowAPI, } from '@contentful/app-sdk';
2
2
  export { CharCounter } from './CharCounter';
3
- export { CharValidation } from './CharValidation';
4
3
  export { FieldConnector } from './FieldConnector';
5
4
  export type { FieldConnectorChildProps } from './FieldConnector';
6
5
  export { PredefinedValuesError } from './PredefinedValuesError';
@@ -1,7 +1,6 @@
1
1
  export type ValidationType = {
2
2
  type: 'max';
3
3
  max: number;
4
- isDefaultConstraint?: boolean;
5
4
  } | {
6
5
  type: 'min';
7
6
  min: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-shared",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -51,5 +51,5 @@
51
51
  "publishConfig": {
52
52
  "registry": "https://npm.pkg.github.com/"
53
53
  },
54
- "gitHead": "129510a558258ae7eb0c53e7845868048a465ca7"
54
+ "gitHead": "1d7d630fe6f9576ee4cf35feed8badc8440acbf1"
55
55
  }
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "CharValidation", {
6
- enumerable: true,
7
- get: function() {
8
- return CharValidation;
9
- }
10
- });
11
- const _react = _interop_require_wildcard(require("react"));
12
- function _getRequireWildcardCache(nodeInterop) {
13
- if (typeof WeakMap !== "function") return null;
14
- var cacheBabelInterop = new WeakMap();
15
- var cacheNodeInterop = new WeakMap();
16
- return (_getRequireWildcardCache = function(nodeInterop) {
17
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
18
- })(nodeInterop);
19
- }
20
- function _interop_require_wildcard(obj, nodeInterop) {
21
- if (!nodeInterop && obj && obj.__esModule) {
22
- return obj;
23
- }
24
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
25
- return {
26
- default: obj
27
- };
28
- }
29
- var cache = _getRequireWildcardCache(nodeInterop);
30
- if (cache && cache.has(obj)) {
31
- return cache.get(obj);
32
- }
33
- var newObj = {
34
- __proto__: null
35
- };
36
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
37
- for(var key in obj){
38
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
39
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
40
- if (desc && (desc.get || desc.set)) {
41
- Object.defineProperty(newObj, key, desc);
42
- } else {
43
- newObj[key] = obj[key];
44
- }
45
- }
46
- }
47
- newObj.default = obj;
48
- if (cache) {
49
- cache.set(obj, newObj);
50
- }
51
- return newObj;
52
- }
53
- function CharValidation(props) {
54
- const { constraints, enabled } = props;
55
- if (!enabled) {
56
- return null;
57
- }
58
- if (constraints.type === 'max') {
59
- return _react.createElement("span", null, constraints.isDefaultConstraint ? '' : `Max. ${constraints.max} characters`);
60
- } else if (constraints.type === 'min') {
61
- return _react.createElement("span", null, "Requires at least ", constraints.min, " characters");
62
- } else {
63
- return _react.createElement("span", null, "Requires between ", constraints.min, " and ", constraints.max, " characters");
64
- }
65
- }
@@ -1,14 +0,0 @@
1
- import * as React from 'react';
2
- export function CharValidation(props) {
3
- const { constraints, enabled } = props;
4
- if (!enabled) {
5
- return null;
6
- }
7
- if (constraints.type === 'max') {
8
- return React.createElement("span", null, constraints.isDefaultConstraint ? '' : `Max. ${constraints.max} characters`);
9
- } else if (constraints.type === 'min') {
10
- return React.createElement("span", null, "Requires at least ", constraints.min, " characters");
11
- } else {
12
- return React.createElement("span", null, "Requires between ", constraints.min, " and ", constraints.max, " characters");
13
- }
14
- }
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import { ValidationType } from './types';
3
- interface CharValidationProps {
4
- constraints: ValidationType;
5
- enabled: boolean;
6
- }
7
- export declare function CharValidation(props: CharValidationProps): JSX.Element | null;
8
- export {};