@contentful/field-editor-shared 1.4.7 → 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,7 +63,6 @@ const styles = {
63
63
  })
64
64
  };
65
65
  function CharCounter(props) {
66
- const { constraints } = props;
67
66
  let count = 0;
68
67
  if (props.value) {
69
68
  count = props.value.length;
@@ -71,9 +70,8 @@ function CharCounter(props) {
71
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
  }
@@ -51,12 +51,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
51
  return newObj;
52
52
  }
53
53
  function CharValidation(props) {
54
- const { constraints, enabled } = props;
55
- if (!enabled) {
56
- return null;
57
- }
54
+ const { constraints } = props;
58
55
  if (constraints.type === 'max') {
59
- return _react.createElement("span", null, constraints.isDefaultConstraint ? '' : `Max. ${constraints.max} characters`);
56
+ return _react.createElement("span", null, "Maximum ", constraints.max, " characters");
60
57
  } else if (constraints.type === 'min') {
61
58
  return _react.createElement("span", null, "Requires at least ", constraints.min, " characters");
62
59
  } else {
@@ -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,7 +7,6 @@ const styles = {
7
7
  })
8
8
  };
9
9
  export function CharCounter(props) {
10
- const { constraints } = props;
11
10
  let count = 0;
12
11
  if (props.value) {
13
12
  count = props.value.length;
@@ -15,9 +14,8 @@ export function CharCounter(props) {
15
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
  }
@@ -1,11 +1,8 @@
1
1
  import * as React from 'react';
2
2
  export function CharValidation(props) {
3
- const { constraints, enabled } = props;
4
- if (!enabled) {
5
- return null;
6
- }
3
+ const { constraints } = props;
7
4
  if (constraints.type === 'max') {
8
- return React.createElement("span", null, constraints.isDefaultConstraint ? '' : `Max. ${constraints.max} characters`);
5
+ return React.createElement("span", null, "Maximum ", constraints.max, " characters");
9
6
  } else if (constraints.type === 'min') {
10
7
  return React.createElement("span", null, "Requires at least ", constraints.min, " characters");
11
8
  } else {
@@ -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,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 {};
@@ -2,7 +2,6 @@
2
2
  import { ValidationType } from './types';
3
3
  interface CharValidationProps {
4
4
  constraints: ValidationType;
5
- enabled: boolean;
6
5
  }
7
- export declare function CharValidation(props: CharValidationProps): JSX.Element | null;
6
+ export declare function CharValidation(props: CharValidationProps): JSX.Element;
8
7
  export {};
@@ -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.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": "129510a558258ae7eb0c53e7845868048a465ca7"
54
+ "gitHead": "29cf5fb16a8d61f6c23678dad618c61aceec320d"
55
55
  }