@contentful/field-editor-shared 4.4.1-canary.5 → 4.4.2-canary.11

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.
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "CharCounter", {
11
11
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
12
  const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
13
13
  const _css = require("@emotion/css");
14
+ const _core = require("@lingui/core");
14
15
  function _interop_require_default(obj) {
15
16
  return obj && obj.__esModule ? obj : {
16
17
  default: obj
@@ -73,5 +74,11 @@ function CharCounter(props) {
73
74
  className: (0, _css.cx)({
74
75
  [styles.invalid]: !valid
75
76
  })
76
- }, count, " characters");
77
+ }, _core.i18n._({
78
+ id: "FieldEditors.Shared.CharCounter.Counter",
79
+ message: "{count, plural, one {1 character} other {{count} characters}}",
80
+ values: {
81
+ count: count
82
+ }
83
+ }));
77
84
  }
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "CharValidation", {
9
9
  }
10
10
  });
11
11
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _core = require("@lingui/core");
12
13
  function _getRequireWildcardCache(nodeInterop) {
13
14
  if (typeof WeakMap !== "function") return null;
14
15
  var cacheBabelInterop = new WeakMap();
@@ -53,10 +54,32 @@ function _interop_require_wildcard(obj, nodeInterop) {
53
54
  function CharValidation(props) {
54
55
  const { constraints } = props;
55
56
  if (constraints.type === 'max') {
56
- return /*#__PURE__*/ _react.createElement("span", null, "Maximum ", constraints.max, " characters");
57
+ const { max } = constraints;
58
+ return /*#__PURE__*/ _react.createElement("span", null, _core.i18n._({
59
+ id: "FieldEditors.Shared.CharValidation.MaximumConstraint",
60
+ message: "Maximum {max} characters",
61
+ values: {
62
+ max: max
63
+ }
64
+ }));
57
65
  } else if (constraints.type === 'min') {
58
- return /*#__PURE__*/ _react.createElement("span", null, "Requires at least ", constraints.min, " characters");
66
+ const { min } = constraints;
67
+ return /*#__PURE__*/ _react.createElement("span", null, _core.i18n._({
68
+ id: "FieldEditors.Shared.CharValidation.MinimumConstraint",
69
+ message: "Requires at least {min} characters",
70
+ values: {
71
+ min: min
72
+ }
73
+ }));
59
74
  } else {
60
- return /*#__PURE__*/ _react.createElement("span", null, "Requires between ", constraints.min, " and ", constraints.max, " characters");
75
+ const { max, min } = constraints;
76
+ return /*#__PURE__*/ _react.createElement("span", null, _core.i18n._({
77
+ id: "FieldEditors.Shared.CharValidation.MinMaxConstraint",
78
+ message: "Requires between {min} and {max} characters",
79
+ values: {
80
+ min: min,
81
+ max: max
82
+ }
83
+ }));
61
84
  }
62
85
  }
@@ -36,7 +36,7 @@ function fromFieldValidations(validations = [], fieldType) {
36
36
  return {
37
37
  type: 'min-max',
38
38
  min,
39
- max
39
+ max: Math.min(max, MAX_LIMITS[fieldType])
40
40
  };
41
41
  } else if ((0, _isNumber.default)(min)) {
42
42
  return {
@@ -46,7 +46,7 @@ function fromFieldValidations(validations = [], fieldType) {
46
46
  } else if ((0, _isNumber.default)(max)) {
47
47
  return {
48
48
  type: 'max',
49
- max
49
+ max: Math.min(max, MAX_LIMITS[fieldType])
50
50
  };
51
51
  } else {
52
52
  return {
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
3
  import { css, cx } from '@emotion/css';
4
+ import { i18n as $_i18n } from "@lingui/core";
4
5
  const styles = {
5
6
  invalid: css({
6
7
  color: tokens.red600
@@ -17,5 +18,11 @@ export function CharCounter(props) {
17
18
  className: cx({
18
19
  [styles.invalid]: !valid
19
20
  })
20
- }, count, " characters");
21
+ }, $_i18n._({
22
+ id: "FieldEditors.Shared.CharCounter.Counter",
23
+ message: "{count, plural, one {1 character} other {{count} characters}}",
24
+ values: {
25
+ count: count
26
+ }
27
+ }));
21
28
  }
@@ -1,11 +1,34 @@
1
1
  import * as React from 'react';
2
+ import { i18n as $_i18n } from "@lingui/core";
2
3
  export function CharValidation(props) {
3
4
  const { constraints } = props;
4
5
  if (constraints.type === 'max') {
5
- return /*#__PURE__*/ React.createElement("span", null, "Maximum ", constraints.max, " characters");
6
+ const { max } = constraints;
7
+ return /*#__PURE__*/ React.createElement("span", null, $_i18n._({
8
+ id: "FieldEditors.Shared.CharValidation.MaximumConstraint",
9
+ message: "Maximum {max} characters",
10
+ values: {
11
+ max: max
12
+ }
13
+ }));
6
14
  } else if (constraints.type === 'min') {
7
- return /*#__PURE__*/ React.createElement("span", null, "Requires at least ", constraints.min, " characters");
15
+ const { min } = constraints;
16
+ return /*#__PURE__*/ React.createElement("span", null, $_i18n._({
17
+ id: "FieldEditors.Shared.CharValidation.MinimumConstraint",
18
+ message: "Requires at least {min} characters",
19
+ values: {
20
+ min: min
21
+ }
22
+ }));
8
23
  } else {
9
- return /*#__PURE__*/ React.createElement("span", null, "Requires between ", constraints.min, " and ", constraints.max, " characters");
24
+ const { max, min } = constraints;
25
+ return /*#__PURE__*/ React.createElement("span", null, $_i18n._({
26
+ id: "FieldEditors.Shared.CharValidation.MinMaxConstraint",
27
+ message: "Requires between {min} and {max} characters",
28
+ values: {
29
+ min: min,
30
+ max: max
31
+ }
32
+ }));
10
33
  }
11
34
  }
@@ -13,7 +13,7 @@ export function fromFieldValidations(validations = [], fieldType) {
13
13
  return {
14
14
  type: 'min-max',
15
15
  min,
16
- max
16
+ max: Math.min(max, MAX_LIMITS[fieldType])
17
17
  };
18
18
  } else if (isNumber(min)) {
19
19
  return {
@@ -23,7 +23,7 @@ export function fromFieldValidations(validations = [], fieldType) {
23
23
  } else if (isNumber(max)) {
24
24
  return {
25
25
  type: 'max',
26
- max
26
+ max: Math.min(max, MAX_LIMITS[fieldType])
27
27
  };
28
28
  } else {
29
29
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-shared",
3
- "version": "4.4.1-canary.5+3e29f973",
3
+ "version": "4.4.2-canary.11+811c078e",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@contentful/app-sdk": "^4.42.0",
46
- "@contentful/field-editor-test-utils": "^3.1.1-canary.5+3e29f973",
46
+ "@contentful/field-editor-test-utils": "^3.1.2-canary.11+811c078e",
47
47
  "@lingui/core": "5.3.0",
48
48
  "@tanstack/react-query": "^4.3.9",
49
49
  "@testing-library/react": "16.3.0"
@@ -73,5 +73,5 @@
73
73
  "publishConfig": {
74
74
  "registry": "https://npm.pkg.github.com/"
75
75
  },
76
- "gitHead": "3e29f9734b46d8ca738457c87cc76a0aeca459e9"
76
+ "gitHead": "811c078e63fa54aecc9dee1775de9d8122a9cb04"
77
77
  }