@contentful/field-editor-shared 1.4.8 → 1.4.9

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,17 +63,15 @@ const styles = {
63
63
  })
64
64
  };
65
65
  function CharCounter(props) {
66
- const { constraints, value, checkConstraint } = props;
67
66
  let count = 0;
68
- if (value) {
69
- count = value.length;
67
+ if (props.value) {
68
+ count = props.value.length;
70
69
  }
71
- const valid = count === 0 || checkConstraint(count);
70
+ const valid = count === 0 || props.checkConstraint(count);
72
71
  return _react.createElement("span", {
73
72
  "data-status-code": valid ? null : 'invalid-size',
74
- "data-test-id": "cf-ui-char-counter",
75
73
  className: (0, _emotion.cx)({
76
74
  [styles.invalid]: !valid
77
75
  })
78
- }, constraints.type === 'min' ? `${count}` : `${count} / ${constraints.max}`);
76
+ }, count, " characters");
79
77
  }
@@ -0,0 +1,62 @@
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 } = props;
55
+ if (constraints.type === 'max') {
56
+ return _react.createElement("span", null, "Maximum ", constraints.max, " characters");
57
+ } else if (constraints.type === 'min') {
58
+ return _react.createElement("span", null, "Requires at least ", constraints.min, " characters");
59
+ } else {
60
+ return _react.createElement("span", null, "Requires between ", constraints.min, " and ", constraints.max, " characters");
61
+ }
62
+ }
package/dist/cjs/index.js CHANGED
@@ -24,6 +24,9 @@ _export(exports, {
24
24
  CharCounter: function() {
25
25
  return _CharCounter.CharCounter;
26
26
  },
27
+ CharValidation: function() {
28
+ return _CharValidation.CharValidation;
29
+ },
27
30
  ConstraintsUtils: function() {
28
31
  return _constraints;
29
32
  },
@@ -102,6 +105,7 @@ _export(exports, {
102
105
  });
103
106
  const _appsdk = require("@contentful/app-sdk");
104
107
  const _CharCounter = require("./CharCounter");
108
+ const _CharValidation = require("./CharValidation");
105
109
  const _FieldConnector = require("./FieldConnector");
106
110
  const _PredefinedValuesError = require("./PredefinedValuesError");
107
111
  const _typesEntity = require("./typesEntity");
@@ -7,17 +7,15 @@ const styles = {
7
7
  })
8
8
  };
9
9
  export function CharCounter(props) {
10
- const { constraints, value, checkConstraint } = props;
11
10
  let count = 0;
12
- if (value) {
13
- count = value.length;
11
+ if (props.value) {
12
+ count = props.value.length;
14
13
  }
15
- const valid = count === 0 || checkConstraint(count);
14
+ const valid = count === 0 || props.checkConstraint(count);
16
15
  return React.createElement("span", {
17
16
  "data-status-code": valid ? null : 'invalid-size',
18
- "data-test-id": "cf-ui-char-counter",
19
17
  className: cx({
20
18
  [styles.invalid]: !valid
21
19
  })
22
- }, constraints.type === 'min' ? `${count}` : `${count} / ${constraints.max}`);
20
+ }, count, " characters");
23
21
  }
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ export function CharValidation(props) {
3
+ const { constraints } = props;
4
+ if (constraints.type === 'max') {
5
+ return React.createElement("span", null, "Maximum ", constraints.max, " characters");
6
+ } else if (constraints.type === 'min') {
7
+ return React.createElement("span", null, "Requires at least ", constraints.min, " characters");
8
+ } else {
9
+ return React.createElement("span", null, "Requires between ", constraints.min, " and ", constraints.max, " characters");
10
+ }
11
+ }
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
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';
3
4
  export { FieldConnector } from './FieldConnector';
4
5
  export { PredefinedValuesError } from './PredefinedValuesError';
5
6
  export { Asset, Entry, File } from './typesEntity';
@@ -1,9 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { ValidationType } from 'types';
3
2
  interface CharCounterProps {
4
3
  value?: string;
5
4
  checkConstraint: (n: number) => boolean;
6
- constraints: ValidationType;
7
5
  }
8
6
  export declare function CharCounter(props: CharCounterProps): JSX.Element;
9
7
  export {};
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { ValidationType } from './types';
3
+ interface CharValidationProps {
4
+ constraints: ValidationType;
5
+ }
6
+ export declare function CharValidation(props: CharValidationProps): JSX.Element;
7
+ export {};
@@ -1,5 +1,6 @@
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';
3
4
  export { FieldConnector } from './FieldConnector';
4
5
  export type { FieldConnectorChildProps } from './FieldConnector';
5
6
  export { PredefinedValuesError } from './PredefinedValuesError';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-shared",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
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": "1d7d630fe6f9576ee4cf35feed8badc8440acbf1"
54
+ "gitHead": "29cf5fb16a8d61f6c23678dad618c61aceec320d"
55
55
  }