@contentful/field-editor-multiple-line 1.1.11 → 1.3.0

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.
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "MultipleLineEditor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return MultipleLineEditor;
9
+ }
10
+ });
11
+ const _react = _interop_require_wildcard(require("react"));
12
+ const _f36components = require("@contentful/f36-components");
13
+ const _fieldeditorshared = require("@contentful/field-editor-shared");
14
+ const _styles = _interop_require_wildcard(require("./styles"));
15
+ function _getRequireWildcardCache(nodeInterop) {
16
+ if (typeof WeakMap !== "function") return null;
17
+ var cacheBabelInterop = new WeakMap();
18
+ var cacheNodeInterop = new WeakMap();
19
+ return (_getRequireWildcardCache = function(nodeInterop) {
20
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
21
+ })(nodeInterop);
22
+ }
23
+ function _interop_require_wildcard(obj, nodeInterop) {
24
+ if (!nodeInterop && obj && obj.__esModule) {
25
+ return obj;
26
+ }
27
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
28
+ return {
29
+ default: obj
30
+ };
31
+ }
32
+ var cache = _getRequireWildcardCache(nodeInterop);
33
+ if (cache && cache.has(obj)) {
34
+ return cache.get(obj);
35
+ }
36
+ var newObj = {};
37
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
38
+ for(var key in obj){
39
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
40
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
41
+ if (desc && (desc.get || desc.set)) {
42
+ Object.defineProperty(newObj, key, desc);
43
+ } else {
44
+ newObj[key] = obj[key];
45
+ }
46
+ }
47
+ }
48
+ newObj.default = obj;
49
+ if (cache) {
50
+ cache.set(obj, newObj);
51
+ }
52
+ return newObj;
53
+ }
54
+ function MultipleLineEditor(props) {
55
+ const { field , locales , isInitiallyDisabled , withCharValidation } = props;
56
+ const constraints = _fieldeditorshared.ConstraintsUtils.fromFieldValidations(field.validations, field.type);
57
+ const checkConstraint = _fieldeditorshared.ConstraintsUtils.makeChecker(constraints);
58
+ const direction = locales.direction[field.locale] || 'ltr';
59
+ return _react.createElement(_fieldeditorshared.FieldConnector, {
60
+ field: field,
61
+ isInitiallyDisabled: isInitiallyDisabled
62
+ }, ({ errors , disabled , value , setValue })=>{
63
+ return _react.createElement("div", {
64
+ "data-test-id": "multiple-line-editor"
65
+ }, _react.createElement(_f36components.Textarea, {
66
+ className: direction === 'rtl' ? _styles.rightToLeft : '',
67
+ rows: 3,
68
+ isRequired: field.required,
69
+ isInvalid: errors.length > 0,
70
+ isDisabled: disabled,
71
+ value: value || '',
72
+ onChange: (e)=>{
73
+ setValue(e.target.value);
74
+ }
75
+ }), withCharValidation && _react.createElement("div", {
76
+ className: _styles.validationRow
77
+ }, _react.createElement(_fieldeditorshared.CharCounter, {
78
+ value: value || '',
79
+ checkConstraint: checkConstraint
80
+ }), _react.createElement(_fieldeditorshared.CharValidation, {
81
+ constraints: constraints
82
+ })), !withCharValidation && _react.createElement("div", {
83
+ className: _styles.validationRow
84
+ }, _react.createElement(_fieldeditorshared.CharCounter, {
85
+ value: value || '',
86
+ checkConstraint: ()=>true
87
+ })));
88
+ });
89
+ }
90
+ MultipleLineEditor.defaultProps = {
91
+ isInitiallyDisabled: true,
92
+ withCharValidation: true
93
+ };
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _react = _interop_require_wildcard(require("react"));
6
+ const _fieldeditortestutils = require("@contentful/field-editor-test-utils");
7
+ const _react1 = require("@testing-library/react");
8
+ const _identity = _interop_require_default(require("lodash/identity"));
9
+ require("@testing-library/jest-dom/extend-expect");
10
+ const _MultipleLineEditor = require("./MultipleLineEditor");
11
+ function _interop_require_default(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ function _getRequireWildcardCache(nodeInterop) {
17
+ if (typeof WeakMap !== "function") return null;
18
+ var cacheBabelInterop = new WeakMap();
19
+ var cacheNodeInterop = new WeakMap();
20
+ return (_getRequireWildcardCache = function(nodeInterop) {
21
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
22
+ })(nodeInterop);
23
+ }
24
+ function _interop_require_wildcard(obj, nodeInterop) {
25
+ if (!nodeInterop && obj && obj.__esModule) {
26
+ return obj;
27
+ }
28
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
29
+ return {
30
+ default: obj
31
+ };
32
+ }
33
+ var cache = _getRequireWildcardCache(nodeInterop);
34
+ if (cache && cache.has(obj)) {
35
+ return cache.get(obj);
36
+ }
37
+ var newObj = {};
38
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
39
+ for(var key in obj){
40
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
41
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
42
+ if (desc && (desc.get || desc.set)) {
43
+ Object.defineProperty(newObj, key, desc);
44
+ } else {
45
+ newObj[key] = obj[key];
46
+ }
47
+ }
48
+ }
49
+ newObj.default = obj;
50
+ if (cache) {
51
+ cache.set(obj, newObj);
52
+ }
53
+ return newObj;
54
+ }
55
+ (0, _react1.configure)({
56
+ testIdAttribute: 'data-test-id'
57
+ });
58
+ jest.mock('lodash/throttle', ()=>({
59
+ default: _identity.default
60
+ }), {
61
+ virtual: true
62
+ });
63
+ describe('MultipleLineEditor', ()=>{
64
+ afterEach(_react1.cleanup);
65
+ it('renders without crashing', ()=>{
66
+ const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)();
67
+ (0, _react1.render)(_react.createElement(_MultipleLineEditor.MultipleLineEditor, {
68
+ field: field,
69
+ locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
70
+ isInitiallyDisabled: false
71
+ }));
72
+ });
73
+ it('reads initial value from field.getValue', ()=>{
74
+ const initialValue = 'initial-value';
75
+ const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
76
+ return {
77
+ ...field,
78
+ id: 'field-id',
79
+ getValue: ()=>{
80
+ return initialValue;
81
+ }
82
+ };
83
+ });
84
+ const { getByTestId } = (0, _react1.render)(_react.createElement(_MultipleLineEditor.MultipleLineEditor, {
85
+ field: field,
86
+ locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
87
+ isInitiallyDisabled: false
88
+ }));
89
+ expect(getByTestId('cf-ui-textarea')).toHaveValue(initialValue);
90
+ });
91
+ it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
92
+ const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
93
+ jest.spyOn(field, 'setValue');
94
+ jest.spyOn(field, 'removeValue');
95
+ return {
96
+ ...field,
97
+ id: 'field-id'
98
+ };
99
+ });
100
+ const { getByTestId } = (0, _react1.render)(_react.createElement(_MultipleLineEditor.MultipleLineEditor, {
101
+ field: field,
102
+ locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
103
+ isInitiallyDisabled: false
104
+ }));
105
+ const $input = getByTestId('cf-ui-textarea');
106
+ expect($input).toHaveValue('');
107
+ _react1.fireEvent.change($input, {
108
+ target: {
109
+ value: 'new-value'
110
+ }
111
+ });
112
+ expect($input).toHaveValue('new-value');
113
+ await (0, _react1.waitFor)(()=>{
114
+ expect(field.setValue).toHaveBeenCalledTimes(1);
115
+ expect(field.setValue).toHaveBeenLastCalledWith('new-value');
116
+ });
117
+ _react1.fireEvent.change($input, {
118
+ target: {
119
+ value: ''
120
+ }
121
+ });
122
+ await (0, _react1.waitFor)(()=>{
123
+ expect($input).toHaveValue('');
124
+ expect(field.removeValue).toHaveBeenCalledTimes(1);
125
+ expect(field.removeValue).toHaveBeenLastCalledWith();
126
+ });
127
+ });
128
+ });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "MultipleLineEditor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _MultipleLineEditor.MultipleLineEditor;
9
+ }
10
+ });
11
+ const _MultipleLineEditor = require("./MultipleLineEditor");
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ validationRow: function() {
13
+ return validationRow;
14
+ },
15
+ rightToLeft: function() {
16
+ return rightToLeft;
17
+ }
18
+ });
19
+ const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
20
+ const _emotion = require("emotion");
21
+ function _interop_require_default(obj) {
22
+ return obj && obj.__esModule ? obj : {
23
+ default: obj
24
+ };
25
+ }
26
+ const validationRow = (0, _emotion.css)({
27
+ display: 'flex',
28
+ justifyContent: 'space-between',
29
+ fontSize: _f36tokens.default.fontSizeM,
30
+ marginTop: _f36tokens.default.spacingXs,
31
+ color: _f36tokens.default.gray700
32
+ });
33
+ const rightToLeft = (0, _emotion.css)({
34
+ direction: 'rtl'
35
+ });
@@ -0,0 +1,44 @@
1
+ import * as React from 'react';
2
+ import { Textarea } from '@contentful/f36-components';
3
+ import { FieldConnector, CharCounter, CharValidation, ConstraintsUtils } from '@contentful/field-editor-shared';
4
+ import * as styles from './styles';
5
+ export function MultipleLineEditor(props) {
6
+ const { field , locales , isInitiallyDisabled , withCharValidation } = props;
7
+ const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);
8
+ const checkConstraint = ConstraintsUtils.makeChecker(constraints);
9
+ const direction = locales.direction[field.locale] || 'ltr';
10
+ return React.createElement(FieldConnector, {
11
+ field: field,
12
+ isInitiallyDisabled: isInitiallyDisabled
13
+ }, ({ errors , disabled , value , setValue })=>{
14
+ return React.createElement("div", {
15
+ "data-test-id": "multiple-line-editor"
16
+ }, React.createElement(Textarea, {
17
+ className: direction === 'rtl' ? styles.rightToLeft : '',
18
+ rows: 3,
19
+ isRequired: field.required,
20
+ isInvalid: errors.length > 0,
21
+ isDisabled: disabled,
22
+ value: value || '',
23
+ onChange: (e)=>{
24
+ setValue(e.target.value);
25
+ }
26
+ }), withCharValidation && React.createElement("div", {
27
+ className: styles.validationRow
28
+ }, React.createElement(CharCounter, {
29
+ value: value || '',
30
+ checkConstraint: checkConstraint
31
+ }), React.createElement(CharValidation, {
32
+ constraints: constraints
33
+ })), !withCharValidation && React.createElement("div", {
34
+ className: styles.validationRow
35
+ }, React.createElement(CharCounter, {
36
+ value: value || '',
37
+ checkConstraint: ()=>true
38
+ })));
39
+ });
40
+ }
41
+ MultipleLineEditor.defaultProps = {
42
+ isInitiallyDisabled: true,
43
+ withCharValidation: true
44
+ };
@@ -0,0 +1,80 @@
1
+ import * as React from 'react';
2
+ import { createFakeFieldAPI, createFakeLocalesAPI } from '@contentful/field-editor-test-utils';
3
+ import { cleanup, configure, fireEvent, render, waitFor } from '@testing-library/react';
4
+ import identity from 'lodash/identity';
5
+ import '@testing-library/jest-dom/extend-expect';
6
+ import { MultipleLineEditor } from './MultipleLineEditor';
7
+ configure({
8
+ testIdAttribute: 'data-test-id'
9
+ });
10
+ jest.mock('lodash/throttle', ()=>({
11
+ default: identity
12
+ }), {
13
+ virtual: true
14
+ });
15
+ describe('MultipleLineEditor', ()=>{
16
+ afterEach(cleanup);
17
+ it('renders without crashing', ()=>{
18
+ const [field] = createFakeFieldAPI();
19
+ render(React.createElement(MultipleLineEditor, {
20
+ field: field,
21
+ locales: createFakeLocalesAPI(),
22
+ isInitiallyDisabled: false
23
+ }));
24
+ });
25
+ it('reads initial value from field.getValue', ()=>{
26
+ const initialValue = 'initial-value';
27
+ const [field] = createFakeFieldAPI((field)=>{
28
+ return {
29
+ ...field,
30
+ id: 'field-id',
31
+ getValue: ()=>{
32
+ return initialValue;
33
+ }
34
+ };
35
+ });
36
+ const { getByTestId } = render(React.createElement(MultipleLineEditor, {
37
+ field: field,
38
+ locales: createFakeLocalesAPI(),
39
+ isInitiallyDisabled: false
40
+ }));
41
+ expect(getByTestId('cf-ui-textarea')).toHaveValue(initialValue);
42
+ });
43
+ it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
44
+ const [field] = createFakeFieldAPI((field)=>{
45
+ jest.spyOn(field, 'setValue');
46
+ jest.spyOn(field, 'removeValue');
47
+ return {
48
+ ...field,
49
+ id: 'field-id'
50
+ };
51
+ });
52
+ const { getByTestId } = render(React.createElement(MultipleLineEditor, {
53
+ field: field,
54
+ locales: createFakeLocalesAPI(),
55
+ isInitiallyDisabled: false
56
+ }));
57
+ const $input = getByTestId('cf-ui-textarea');
58
+ expect($input).toHaveValue('');
59
+ fireEvent.change($input, {
60
+ target: {
61
+ value: 'new-value'
62
+ }
63
+ });
64
+ expect($input).toHaveValue('new-value');
65
+ await waitFor(()=>{
66
+ expect(field.setValue).toHaveBeenCalledTimes(1);
67
+ expect(field.setValue).toHaveBeenLastCalledWith('new-value');
68
+ });
69
+ fireEvent.change($input, {
70
+ target: {
71
+ value: ''
72
+ }
73
+ });
74
+ await waitFor(()=>{
75
+ expect($input).toHaveValue('');
76
+ expect(field.removeValue).toHaveBeenCalledTimes(1);
77
+ expect(field.removeValue).toHaveBeenLastCalledWith();
78
+ });
79
+ });
80
+ });
@@ -0,0 +1 @@
1
+ export { MultipleLineEditor } from './MultipleLineEditor';
@@ -0,0 +1,12 @@
1
+ import tokens from '@contentful/f36-tokens';
2
+ import { css } from 'emotion';
3
+ export const validationRow = css({
4
+ display: 'flex',
5
+ justifyContent: 'space-between',
6
+ fontSize: tokens.fontSizeM,
7
+ marginTop: tokens.spacingXs,
8
+ color: tokens.gray700
9
+ });
10
+ export const rightToLeft = css({
11
+ direction: 'rtl'
12
+ });
@@ -1,27 +1,27 @@
1
- /// <reference types="react" />
2
- import { FieldAPI, LocalesAPI } from '@contentful/field-editor-shared';
3
- export interface MultipleLineEditorProps {
4
- /**
5
- * is the field disabled initially
6
- */
7
- isInitiallyDisabled: boolean;
8
- /**
9
- * whether char validation should be shown or not
10
- */
11
- withCharValidation: boolean;
12
- /**
13
- * sdk.field
14
- */
15
- field: FieldAPI;
16
- /**
17
- * sdk.locales
18
- */
19
- locales: LocalesAPI;
20
- }
21
- export declare function MultipleLineEditor(props: MultipleLineEditorProps): JSX.Element;
22
- export declare namespace MultipleLineEditor {
23
- var defaultProps: {
24
- isInitiallyDisabled: boolean;
25
- withCharValidation: boolean;
26
- };
27
- }
1
+ import * as React from 'react';
2
+ import { FieldAPI, LocalesAPI } from '@contentful/field-editor-shared';
3
+ export interface MultipleLineEditorProps {
4
+ /**
5
+ * is the field disabled initially
6
+ */
7
+ isInitiallyDisabled: boolean;
8
+ /**
9
+ * whether char validation should be shown or not
10
+ */
11
+ withCharValidation: boolean;
12
+ /**
13
+ * sdk.field
14
+ */
15
+ field: FieldAPI;
16
+ /**
17
+ * sdk.locales
18
+ */
19
+ locales: LocalesAPI;
20
+ }
21
+ export declare function MultipleLineEditor(props: MultipleLineEditorProps): React.JSX.Element;
22
+ export declare namespace MultipleLineEditor {
23
+ var defaultProps: {
24
+ isInitiallyDisabled: boolean;
25
+ withCharValidation: boolean;
26
+ };
27
+ }
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom/extend-expect';
@@ -1 +1 @@
1
- export { MultipleLineEditor } from './MultipleLineEditor';
1
+ export { MultipleLineEditor } from './MultipleLineEditor';
@@ -1,2 +1,2 @@
1
- export declare const validationRow: string;
2
- export declare const rightToLeft: string;
1
+ export declare const validationRow: string;
2
+ export declare const rightToLeft: string;
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-multiple-line",
3
- "version": "1.1.11",
4
- "main": "dist/index.js",
5
- "module": "dist/field-editor-multiple-line.esm.js",
6
- "typings": "dist/index.d.ts",
3
+ "version": "1.3.0",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/types/index.d.ts",
10
+ "require": "./dist/cjs/index.js",
11
+ "default": "./dist/cjs/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
7
15
  "files": [
8
16
  "dist"
9
17
  ],
@@ -14,25 +22,31 @@
14
22
  "url": "https://github.com/contentful/field-editors"
15
23
  },
16
24
  "scripts": {
17
- "watch": "tsdx watch",
18
- "build": "tsdx build",
19
- "test": "tsdx test --env=jsdom --watch",
20
- "test:ci": "tsdx test --env=jsdom --ci",
25
+ "watch": "yarn concurrently \"yarn:watch:*\"",
26
+ "watch:cjs": "yarn build:cjs -w",
27
+ "watch:esm": "yarn build:esm -w",
28
+ "watch:types": "yarn build:types --watch",
29
+ "build": "yarn build:types && yarn build:cjs && yarn build:esm",
30
+ "build:types": "tsc --outDir dist/types --emitDeclarationOnly",
31
+ "build:cjs": "swc src --config-file ../../.swcrc -d dist/cjs -C module.type=commonjs",
32
+ "build:esm": "swc src --config-file ../../.swcrc -d dist/esm",
33
+ "test": "jest --watch",
34
+ "test:ci": "jest --ci",
21
35
  "tsc": "tsc -p ./ --noEmit"
22
36
  },
23
37
  "dependencies": {
24
38
  "@contentful/f36-components": "^4.0.27",
25
39
  "@contentful/f36-tokens": "^4.0.0",
26
- "@contentful/field-editor-shared": "^1.1.8",
40
+ "@contentful/field-editor-shared": "^1.3.0",
27
41
  "emotion": "^10.0.17",
28
42
  "lodash": "^4.17.15",
29
43
  "lodash-es": "^4.17.15"
30
44
  },
31
45
  "devDependencies": {
32
- "@contentful/field-editor-test-utils": "^1.2.7"
46
+ "@contentful/field-editor-test-utils": "^1.4.0"
33
47
  },
34
48
  "peerDependencies": {
35
49
  "react": ">=16.8.0"
36
50
  },
37
- "gitHead": "4fff7b9534374dcc44cb477240d369fc34f46415"
51
+ "gitHead": "543e02672a8dd4edc810f9f3568d6b69c454e1f9"
38
52
  }
package/CHANGELOG.md DELETED
@@ -1,194 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [1.1.11](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.10...@contentful/field-editor-multiple-line@1.1.11) (2023-03-14)
7
-
8
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
9
-
10
- ## [1.1.10](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.9...@contentful/field-editor-multiple-line@1.1.10) (2023-03-10)
11
-
12
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
13
-
14
- ## [1.1.9](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.8...@contentful/field-editor-multiple-line@1.1.9) (2023-02-21)
15
-
16
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
17
-
18
- ## [1.1.8](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.7...@contentful/field-editor-multiple-line@1.1.8) (2023-02-07)
19
-
20
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
21
-
22
- ## [1.1.7](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.6...@contentful/field-editor-multiple-line@1.1.7) (2022-12-08)
23
-
24
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
25
-
26
- ## [1.1.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.5...@contentful/field-editor-multiple-line@1.1.6) (2022-07-29)
27
-
28
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
29
-
30
- ## [1.1.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.4...@contentful/field-editor-multiple-line@1.1.5) (2022-07-29)
31
-
32
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
33
-
34
- ## [1.1.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.3...@contentful/field-editor-multiple-line@1.1.4) (2022-07-11)
35
-
36
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
37
-
38
- ## [1.1.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.2...@contentful/field-editor-multiple-line@1.1.3) (2022-06-22)
39
-
40
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
41
-
42
- ## [1.1.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.1...@contentful/field-editor-multiple-line@1.1.2) (2022-02-15)
43
-
44
- ### Bug Fixes
45
-
46
- - bump f36 packages ([#1025](https://github.com/contentful/field-editors/issues/1025)) ([ec37a40](https://github.com/contentful/field-editors/commit/ec37a4000db7cd75c66dd9621136b2272c9feeea))
47
-
48
- ## [1.1.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.0...@contentful/field-editor-multiple-line@1.1.1) (2022-02-14)
49
-
50
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
51
-
52
- # [1.1.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.0.3...@contentful/field-editor-multiple-line@1.1.0) (2022-01-11)
53
-
54
- ### Features
55
-
56
- - bump f36 packages to stable v4 [BAU-521] ([#988](https://github.com/contentful/field-editors/issues/988)) ([419cf56](https://github.com/contentful/field-editors/commit/419cf56692179b074fcfa2743469d5265ed98429))
57
-
58
- ## [1.0.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.0.2...@contentful/field-editor-multiple-line@1.0.3) (2021-12-23)
59
-
60
- ### Bug Fixes
61
-
62
- - markdown buttons ([#968](https://github.com/contentful/field-editors/issues/968)) ([9803b98](https://github.com/contentful/field-editors/commit/9803b98c25d92df6148686ffe2749a77f7efdbb9))
63
-
64
- ## [1.0.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.0.1...@contentful/field-editor-multiple-line@1.0.2) (2021-12-20)
65
-
66
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
67
-
68
- ## [1.0.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.0.0...@contentful/field-editor-multiple-line@1.0.1) (2021-11-17)
69
-
70
- ### Bug Fixes
71
-
72
- - **card-actions:** update forma 36 to fix card actions click issue ([#927](https://github.com/contentful/field-editors/issues/927)) ([3dfdef2](https://github.com/contentful/field-editors/commit/3dfdef2c2b0045f12ea94ddafca89a8e9f25e7d0))
73
-
74
- # [1.0.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.16.0...@contentful/field-editor-multiple-line@1.0.0) (2021-11-04)
75
-
76
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
77
-
78
- # [0.16.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.15.1...@contentful/field-editor-multiple-line@0.16.0) (2021-11-04)
79
-
80
- ### Features
81
-
82
- - Forma v4 components adoption ([#805](https://github.com/contentful/field-editors/issues/805)) ([526bde6](https://github.com/contentful/field-editors/commit/526bde6e10e0ee3789705ec10fb31489af7ca59e))
83
-
84
- ### BREAKING CHANGES
85
-
86
- - adopts a new Forma v4 beta
87
-
88
- ## [0.15.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.15.0...@contentful/field-editor-multiple-line@0.15.1) (2021-10-14)
89
-
90
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
91
-
92
- # [0.15.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.14.3...@contentful/field-editor-multiple-line@0.15.0) (2021-10-06)
93
-
94
- ### Features
95
-
96
- - [EXT-3161] bump app sdk to v4 ([#881](https://github.com/contentful/field-editors/issues/881)) ([9c4a2af](https://github.com/contentful/field-editors/commit/9c4a2af07da203d59fb5f15c3a5188ecc64b1d44))
97
-
98
- ## [0.14.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.14.2...@contentful/field-editor-multiple-line@0.14.3) (2021-09-17)
99
-
100
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
101
-
102
- ## [0.14.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.14.1...@contentful/field-editor-multiple-line@0.14.2) (2021-09-16)
103
-
104
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
105
-
106
- ## [0.14.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.14.0...@contentful/field-editor-multiple-line@0.14.1) (2021-08-19)
107
-
108
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
109
-
110
- # [0.14.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.13.1...@contentful/field-editor-multiple-line@0.14.0) (2021-08-05)
111
-
112
- ### Features
113
-
114
- - 🎸 add char counter ([#795](https://github.com/contentful/field-editors/issues/795)) ([3237f6c](https://github.com/contentful/field-editors/commit/3237f6ce51cf5d29880e641858a61ffcd9c61fa4)), closes [#491](https://github.com/contentful/field-editors/issues/491)
115
-
116
- ## [0.13.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.13.0...@contentful/field-editor-multiple-line@0.13.1) (2021-07-29)
117
-
118
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
119
-
120
- # [0.13.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.12.6...@contentful/field-editor-multiple-line@0.13.0) (2021-07-23)
121
-
122
- ### Features
123
-
124
- - 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
125
-
126
- ## [0.12.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.12.3...@contentful/field-editor-multiple-line@0.12.6) (2021-07-06)
127
-
128
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
129
-
130
- ## [0.12.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.12.3...@contentful/field-editor-multiple-line@0.12.5) (2021-07-06)
131
-
132
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
133
-
134
- ## [0.12.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.12.3...@contentful/field-editor-multiple-line@0.12.4) (2021-06-23)
135
-
136
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
137
-
138
- ## [0.12.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.12.2...@contentful/field-editor-multiple-line@0.12.3) (2021-06-23)
139
-
140
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
141
-
142
- ## [0.12.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.12.1...@contentful/field-editor-multiple-line@0.12.2) (2021-06-22)
143
-
144
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
145
-
146
- ## [0.12.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.12.0...@contentful/field-editor-multiple-line@0.12.1) (2021-03-05)
147
-
148
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
149
-
150
- # [0.12.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.11.2...@contentful/field-editor-multiple-line@0.12.0) (2021-02-19)
151
-
152
- ### Features
153
-
154
- - bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
155
-
156
- ## [0.11.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.11.1...@contentful/field-editor-multiple-line@0.11.2) (2021-02-09)
157
-
158
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
159
-
160
- ## [0.11.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.11.0...@contentful/field-editor-multiple-line@0.11.1) (2021-02-01)
161
-
162
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
163
-
164
- # [0.11.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.10.0...@contentful/field-editor-multiple-line@0.11.0) (2021-01-20)
165
-
166
- ### Features
167
-
168
- - update minimal forma-36 versions to use updated design ([#565](https://github.com/contentful/field-editors/issues/565)) ([332c734](https://github.com/contentful/field-editors/commit/332c734bfaf54f0e9773fcbb460d743b1f5459ec))
169
-
170
- # [0.10.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.9.5...@contentful/field-editor-multiple-line@0.10.0) (2021-01-12)
171
-
172
- ### Features
173
-
174
- - update minimal required Forma version to the 3.73.12 ([#552](https://github.com/contentful/field-editors/issues/552)) ([2816fd9](https://github.com/contentful/field-editors/commit/2816fd960c28815faebf49a9ef8f4c4c0d91fc36))
175
-
176
- ## [0.9.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.9.4...@contentful/field-editor-multiple-line@0.9.5) (2020-12-16)
177
-
178
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
179
-
180
- ## [0.9.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.9.3...@contentful/field-editor-multiple-line@0.9.4) (2020-11-06)
181
-
182
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
183
-
184
- ## [0.9.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.9.2...@contentful/field-editor-multiple-line@0.9.3) (2020-11-06)
185
-
186
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
187
-
188
- ## [0.9.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.9.1...@contentful/field-editor-multiple-line@0.9.2) (2020-10-28)
189
-
190
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
191
-
192
- ## [0.9.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.9.0...@contentful/field-editor-multiple-line@0.9.1) (2020-08-24)
193
-
194
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
@@ -1,75 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var React = require('react');
8
- var fieldEditorShared = require('@contentful/field-editor-shared');
9
- var emotion = require('emotion');
10
- var tokens = _interopDefault(require('@contentful/f36-tokens'));
11
- var f36Components = require('@contentful/f36-components');
12
-
13
- var validationRow = /*#__PURE__*/emotion.css({
14
- display: 'flex',
15
- justifyContent: 'space-between',
16
- fontSize: tokens.fontSizeM,
17
- marginTop: tokens.spacingXs,
18
- color: tokens.gray700
19
- });
20
- var rightToLeft = /*#__PURE__*/emotion.css({
21
- direction: 'rtl'
22
- });
23
-
24
- function MultipleLineEditor(props) {
25
- var field = props.field,
26
- locales = props.locales,
27
- isInitiallyDisabled = props.isInitiallyDisabled,
28
- withCharValidation = props.withCharValidation;
29
- var constraints = fieldEditorShared.ConstraintsUtils.fromFieldValidations(field.validations, field.type);
30
- var checkConstraint = fieldEditorShared.ConstraintsUtils.makeChecker(constraints);
31
- var direction = locales.direction[field.locale] || 'ltr';
32
- return React.createElement(fieldEditorShared.FieldConnector, {
33
- field: field,
34
- isInitiallyDisabled: isInitiallyDisabled
35
- }, function (_ref) {
36
- var errors = _ref.errors,
37
- disabled = _ref.disabled,
38
- value = _ref.value,
39
- setValue = _ref.setValue;
40
- return React.createElement("div", {
41
- "data-test-id": "multiple-line-editor"
42
- }, React.createElement(f36Components.Textarea, {
43
- className: direction === 'rtl' ? rightToLeft : '',
44
- rows: 3,
45
- isRequired: field.required,
46
- isInvalid: errors.length > 0,
47
- isDisabled: disabled,
48
- value: value || '',
49
- onChange: function onChange(e) {
50
- setValue(e.target.value);
51
- }
52
- }), withCharValidation && React.createElement("div", {
53
- className: validationRow
54
- }, React.createElement(fieldEditorShared.CharCounter, {
55
- value: value || '',
56
- checkConstraint: checkConstraint
57
- }), React.createElement(fieldEditorShared.CharValidation, {
58
- constraints: constraints
59
- })), !withCharValidation && React.createElement("div", {
60
- className: validationRow
61
- }, React.createElement(fieldEditorShared.CharCounter, {
62
- value: value || '',
63
- checkConstraint: function checkConstraint() {
64
- return true;
65
- }
66
- })));
67
- });
68
- }
69
- MultipleLineEditor.defaultProps = {
70
- isInitiallyDisabled: true,
71
- withCharValidation: true
72
- };
73
-
74
- exports.MultipleLineEditor = MultipleLineEditor;
75
- //# sourceMappingURL=field-editor-multiple-line.cjs.development.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field-editor-multiple-line.cjs.development.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const validationRow = css({\n display: 'flex',\n justifyContent: 'space-between',\n fontSize: tokens.fontSizeM,\n marginTop: tokens.spacingXs,\n color: tokens.gray700,\n});\n\nexport const rightToLeft = css({\n direction: 'rtl',\n});\n","import * as React from 'react';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nimport { Textarea } from '@contentful/f36-components';\n\nexport interface MultipleLineEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * whether char validation should be shown or not\n */\n withCharValidation: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function MultipleLineEditor(props: MultipleLineEditorProps) {\n const { field, locales, isInitiallyDisabled, withCharValidation } = props;\n\n const constraints = ConstraintsUtils.fromFieldValidations(\n field.validations,\n field.type as 'Text'\n );\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={isInitiallyDisabled}>\n {({ errors, disabled, value, setValue }) => {\n return (\n <div data-test-id=\"multiple-line-editor\">\n <Textarea\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n rows={3}\n isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setValue(e.target.value);\n }}\n />\n {withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {!withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nMultipleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","MultipleLineEditor","props","field","locales","isInitiallyDisabled","withCharValidation","constraints","ConstraintsUtils","fromFieldValidations","validations","type","checkConstraint","makeChecker","locale","React","FieldConnector","errors","disabled","value","setValue","Textarea","className","styles","rows","isRequired","required","isInvalid","length","isDisabled","onChange","e","target","CharCounter","CharValidation","defaultProps"],"mappings":";;;;;;;;;;;;AAGO,IAAMA,aAAa,gBAAGC,WAAG,CAAC;AAC/BC,EAAAA,OAAO,EAAE,MADsB;AAE/BC,EAAAA,cAAc,EAAE,eAFe;AAG/BC,EAAAA,QAAQ,EAAEC,MAAM,CAACC,SAHc;AAI/BC,EAAAA,SAAS,EAAEF,MAAM,CAACG,SAJa;AAK/BC,EAAAA,KAAK,EAAEJ,MAAM,CAACK;AALiB,CAAD,CAAzB;AAQA,IAAMC,WAAW,gBAAGV,WAAG,CAAC;AAC7BW,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;;SCwBSC,mBAAmBC;AACjC,MAAQC,KAAR,GAAoED,KAApE,CAAQC,KAAR;AAAA,MAAeC,OAAf,GAAoEF,KAApE,CAAeE,OAAf;AAAA,MAAwBC,mBAAxB,GAAoEH,KAApE,CAAwBG,mBAAxB;AAAA,MAA6CC,kBAA7C,GAAoEJ,KAApE,CAA6CI,kBAA7C;AAEA,MAAMC,WAAW,GAAGC,kCAAgB,CAACC,oBAAjB,CAClBN,KAAK,CAACO,WADY,EAElBP,KAAK,CAACQ,IAFY,CAApB;AAIA,MAAMC,eAAe,GAAGJ,kCAAgB,CAACK,WAAjB,CAA6BN,WAA7B,CAAxB;AACA,MAAMP,SAAS,GAAGI,OAAO,CAACJ,SAAR,CAAkBG,KAAK,CAACW,MAAxB,KAAmC,KAArD;AAEA,SACEC,mBAAA,CAACC,gCAAD;AAAwBb,IAAAA,KAAK,EAAEA;AAAOE,IAAAA,mBAAmB,EAAEA;GAA3D,EACG;QAAGY,cAAAA;QAAQC,gBAAAA;QAAUC,aAAAA;QAAOC,gBAAAA;AAC3B,WACEL,mBAAA,MAAA;sBAAkB;KAAlB,EACEA,mBAAA,CAACM,sBAAD;AACEC,MAAAA,SAAS,EAAEtB,SAAS,KAAK,KAAd,GAAsBuB,WAAtB,GAA2C;AACtDC,MAAAA,IAAI,EAAE;AACNC,MAAAA,UAAU,EAAEtB,KAAK,CAACuB;AAClBC,MAAAA,SAAS,EAAEV,MAAM,CAACW,MAAP,GAAgB;AAC3BC,MAAAA,UAAU,EAAEX;AACZC,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBW,MAAAA,QAAQ,EAAE,kBAACC,CAAD;AACRX,QAAAA,QAAQ,CAACW,CAAC,CAACC,MAAF,CAASb,KAAV,CAAR;AACD;KATH,CADF,EAYGb,kBAAkB,IACjBS,mBAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,mBAAA,CAACkB,6BAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,mBAAA,CAACmB,gCAAD;AAAgB3B,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAbJ,EAkBG,CAACD,kBAAD,IACCS,mBAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,mBAAA,CAACkB,6BAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAE;AAAA,eAAM,IAAN;AAAA;KAAlD,CADF,CAnBJ,CADF;AA0BD,GA5BH,CADF;AAgCD;AAEDX,kBAAkB,CAACkC,YAAnB,GAAkC;AAChC9B,EAAAA,mBAAmB,EAAE,IADW;AAEhCC,EAAAA,kBAAkB,EAAE;AAFY,CAAlC;;;;"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),i=require("@contentful/field-editor-shared"),a=require("emotion"),r=(e=require("@contentful/f36-tokens"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("@contentful/f36-components"),l=a.css({display:"flex",justifyContent:"space-between",fontSize:r.fontSizeM,marginTop:r.spacingXs,color:r.gray700}),s=a.css({direction:"rtl"});function o(e){var a=e.field,r=e.locales,o=e.isInitiallyDisabled,c=e.withCharValidation,d=i.ConstraintsUtils.fromFieldValidations(a.validations,a.type),u=i.ConstraintsUtils.makeChecker(d),f=r.direction[a.locale]||"ltr";return t.createElement(i.FieldConnector,{field:a,isInitiallyDisabled:o},(function(e){var r=e.value,o=e.setValue;return t.createElement("div",{"data-test-id":"multiple-line-editor"},t.createElement(n.Textarea,{className:"rtl"===f?s:"",rows:3,isRequired:a.required,isInvalid:e.errors.length>0,isDisabled:e.disabled,value:r||"",onChange:function(e){o(e.target.value)}}),c&&t.createElement("div",{className:l},t.createElement(i.CharCounter,{value:r||"",checkConstraint:u}),t.createElement(i.CharValidation,{constraints:d})),!c&&t.createElement("div",{className:l},t.createElement(i.CharCounter,{value:r||"",checkConstraint:function(){return!0}})))}))}o.defaultProps={isInitiallyDisabled:!0,withCharValidation:!0},exports.MultipleLineEditor=o;
2
- //# sourceMappingURL=field-editor-multiple-line.cjs.production.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field-editor-multiple-line.cjs.production.min.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const validationRow = css({\n display: 'flex',\n justifyContent: 'space-between',\n fontSize: tokens.fontSizeM,\n marginTop: tokens.spacingXs,\n color: tokens.gray700,\n});\n\nexport const rightToLeft = css({\n direction: 'rtl',\n});\n","import * as React from 'react';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nimport { Textarea } from '@contentful/f36-components';\n\nexport interface MultipleLineEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * whether char validation should be shown or not\n */\n withCharValidation: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function MultipleLineEditor(props: MultipleLineEditorProps) {\n const { field, locales, isInitiallyDisabled, withCharValidation } = props;\n\n const constraints = ConstraintsUtils.fromFieldValidations(\n field.validations,\n field.type as 'Text'\n );\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={isInitiallyDisabled}>\n {({ errors, disabled, value, setValue }) => {\n return (\n <div data-test-id=\"multiple-line-editor\">\n <Textarea\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n rows={3}\n isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setValue(e.target.value);\n }}\n />\n {withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {!withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nMultipleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","MultipleLineEditor","props","field","locales","isInitiallyDisabled","withCharValidation","constraints","ConstraintsUtils","fromFieldValidations","validations","type","checkConstraint","makeChecker","locale","React","FieldConnector","value","setValue","Textarea","className","styles","rows","isRequired","required","isInvalid","errors","length","isDisabled","disabled","onChange","e","target","CharCounter","CharValidation","defaultProps"],"mappings":"8RAGaA,EAAgBC,MAAI,CAC/BC,QAAS,OACTC,eAAgB,gBAChBC,SAAUC,EAAOC,UACjBC,UAAWF,EAAOG,UAClBC,MAAOJ,EAAOK,UAGHC,EAAcV,MAAI,CAC7BW,UAAW,iBCuBGC,EAAmBC,OACzBC,EAA4DD,EAA5DC,MAAOC,EAAqDF,EAArDE,QAASC,EAA4CH,EAA5CG,oBAAqBC,EAAuBJ,EAAvBI,mBAEvCC,EAAcC,mBAAiBC,qBACnCN,EAAMO,YACNP,EAAMQ,MAEFC,EAAkBJ,mBAAiBK,YAAYN,GAC/CP,EAAYI,EAAQJ,UAAUG,EAAMW,SAAW,aAGnDC,gBAACC,kBAAuBb,MAAOA,EAAOE,oBAAqBA,IACxD,gBAAqBY,IAAAA,MAAOC,IAAAA,gBAEzBH,sCAAkB,wBAChBA,gBAACI,YACCC,UAAyB,QAAdpB,EAAsBqB,EAAqB,GACtDC,KAAM,EACNC,WAAYpB,EAAMqB,SAClBC,YAPJC,OAOsBC,OAAS,EAC3BC,aARIC,SASJZ,MAAOA,GAAS,GAChBa,SAAU,SAACC,GACTb,EAASa,EAAEC,OAAOf,UAGrBX,GACCS,uBAAKK,UAAWC,GACdN,gBAACkB,eAAYhB,MAAOA,GAAS,GAAIL,gBAAiBA,IAClDG,gBAACmB,kBAAe3B,YAAaA,MAG/BD,GACAS,uBAAKK,UAAWC,GACdN,gBAACkB,eAAYhB,MAAOA,GAAS,GAAIL,gBAAiB,kBAAM,UAUxEX,EAAmBkC,aAAe,CAChC9B,qBAAqB,EACrBC,oBAAoB"}
@@ -1,69 +0,0 @@
1
- import { createElement } from 'react';
2
- import { ConstraintsUtils, FieldConnector, CharCounter, CharValidation } from '@contentful/field-editor-shared';
3
- import { css } from 'emotion';
4
- import tokens from '@contentful/f36-tokens';
5
- import { Textarea } from '@contentful/f36-components';
6
-
7
- var validationRow = /*#__PURE__*/css({
8
- display: 'flex',
9
- justifyContent: 'space-between',
10
- fontSize: tokens.fontSizeM,
11
- marginTop: tokens.spacingXs,
12
- color: tokens.gray700
13
- });
14
- var rightToLeft = /*#__PURE__*/css({
15
- direction: 'rtl'
16
- });
17
-
18
- function MultipleLineEditor(props) {
19
- var field = props.field,
20
- locales = props.locales,
21
- isInitiallyDisabled = props.isInitiallyDisabled,
22
- withCharValidation = props.withCharValidation;
23
- var constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);
24
- var checkConstraint = ConstraintsUtils.makeChecker(constraints);
25
- var direction = locales.direction[field.locale] || 'ltr';
26
- return createElement(FieldConnector, {
27
- field: field,
28
- isInitiallyDisabled: isInitiallyDisabled
29
- }, function (_ref) {
30
- var errors = _ref.errors,
31
- disabled = _ref.disabled,
32
- value = _ref.value,
33
- setValue = _ref.setValue;
34
- return createElement("div", {
35
- "data-test-id": "multiple-line-editor"
36
- }, createElement(Textarea, {
37
- className: direction === 'rtl' ? rightToLeft : '',
38
- rows: 3,
39
- isRequired: field.required,
40
- isInvalid: errors.length > 0,
41
- isDisabled: disabled,
42
- value: value || '',
43
- onChange: function onChange(e) {
44
- setValue(e.target.value);
45
- }
46
- }), withCharValidation && createElement("div", {
47
- className: validationRow
48
- }, createElement(CharCounter, {
49
- value: value || '',
50
- checkConstraint: checkConstraint
51
- }), createElement(CharValidation, {
52
- constraints: constraints
53
- })), !withCharValidation && createElement("div", {
54
- className: validationRow
55
- }, createElement(CharCounter, {
56
- value: value || '',
57
- checkConstraint: function checkConstraint() {
58
- return true;
59
- }
60
- })));
61
- });
62
- }
63
- MultipleLineEditor.defaultProps = {
64
- isInitiallyDisabled: true,
65
- withCharValidation: true
66
- };
67
-
68
- export { MultipleLineEditor };
69
- //# sourceMappingURL=field-editor-multiple-line.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field-editor-multiple-line.esm.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const validationRow = css({\n display: 'flex',\n justifyContent: 'space-between',\n fontSize: tokens.fontSizeM,\n marginTop: tokens.spacingXs,\n color: tokens.gray700,\n});\n\nexport const rightToLeft = css({\n direction: 'rtl',\n});\n","import * as React from 'react';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nimport { Textarea } from '@contentful/f36-components';\n\nexport interface MultipleLineEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * whether char validation should be shown or not\n */\n withCharValidation: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function MultipleLineEditor(props: MultipleLineEditorProps) {\n const { field, locales, isInitiallyDisabled, withCharValidation } = props;\n\n const constraints = ConstraintsUtils.fromFieldValidations(\n field.validations,\n field.type as 'Text'\n );\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={isInitiallyDisabled}>\n {({ errors, disabled, value, setValue }) => {\n return (\n <div data-test-id=\"multiple-line-editor\">\n <Textarea\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n rows={3}\n isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setValue(e.target.value);\n }}\n />\n {withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {!withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nMultipleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","MultipleLineEditor","props","field","locales","isInitiallyDisabled","withCharValidation","constraints","ConstraintsUtils","fromFieldValidations","validations","type","checkConstraint","makeChecker","locale","React","FieldConnector","errors","disabled","value","setValue","Textarea","className","styles","rows","isRequired","required","isInvalid","length","isDisabled","onChange","e","target","CharCounter","CharValidation","defaultProps"],"mappings":";;;;;;AAGO,IAAMA,aAAa,gBAAGC,GAAG,CAAC;AAC/BC,EAAAA,OAAO,EAAE,MADsB;AAE/BC,EAAAA,cAAc,EAAE,eAFe;AAG/BC,EAAAA,QAAQ,EAAEC,MAAM,CAACC,SAHc;AAI/BC,EAAAA,SAAS,EAAEF,MAAM,CAACG,SAJa;AAK/BC,EAAAA,KAAK,EAAEJ,MAAM,CAACK;AALiB,CAAD,CAAzB;AAQA,IAAMC,WAAW,gBAAGV,GAAG,CAAC;AAC7BW,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;;SCwBSC,mBAAmBC;AACjC,MAAQC,KAAR,GAAoED,KAApE,CAAQC,KAAR;AAAA,MAAeC,OAAf,GAAoEF,KAApE,CAAeE,OAAf;AAAA,MAAwBC,mBAAxB,GAAoEH,KAApE,CAAwBG,mBAAxB;AAAA,MAA6CC,kBAA7C,GAAoEJ,KAApE,CAA6CI,kBAA7C;AAEA,MAAMC,WAAW,GAAGC,gBAAgB,CAACC,oBAAjB,CAClBN,KAAK,CAACO,WADY,EAElBP,KAAK,CAACQ,IAFY,CAApB;AAIA,MAAMC,eAAe,GAAGJ,gBAAgB,CAACK,WAAjB,CAA6BN,WAA7B,CAAxB;AACA,MAAMP,SAAS,GAAGI,OAAO,CAACJ,SAAR,CAAkBG,KAAK,CAACW,MAAxB,KAAmC,KAArD;AAEA,SACEC,aAAA,CAACC,cAAD;AAAwBb,IAAAA,KAAK,EAAEA;AAAOE,IAAAA,mBAAmB,EAAEA;GAA3D,EACG;QAAGY,cAAAA;QAAQC,gBAAAA;QAAUC,aAAAA;QAAOC,gBAAAA;AAC3B,WACEL,aAAA,MAAA;sBAAkB;KAAlB,EACEA,aAAA,CAACM,QAAD;AACEC,MAAAA,SAAS,EAAEtB,SAAS,KAAK,KAAd,GAAsBuB,WAAtB,GAA2C;AACtDC,MAAAA,IAAI,EAAE;AACNC,MAAAA,UAAU,EAAEtB,KAAK,CAACuB;AAClBC,MAAAA,SAAS,EAAEV,MAAM,CAACW,MAAP,GAAgB;AAC3BC,MAAAA,UAAU,EAAEX;AACZC,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBW,MAAAA,QAAQ,EAAE,kBAACC,CAAD;AACRX,QAAAA,QAAQ,CAACW,CAAC,CAACC,MAAF,CAASb,KAAV,CAAR;AACD;KATH,CADF,EAYGb,kBAAkB,IACjBS,aAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,aAAA,CAACkB,WAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,aAAA,CAACmB,cAAD;AAAgB3B,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAbJ,EAkBG,CAACD,kBAAD,IACCS,aAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,aAAA,CAACkB,WAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAE;AAAA,eAAM,IAAN;AAAA;KAAlD,CADF,CAnBJ,CADF;AA0BD,GA5BH,CADF;AAgCD;AAEDX,kBAAkB,CAACkC,YAAnB,GAAkC;AAChC9B,EAAAA,mBAAmB,EAAE,IADW;AAEhCC,EAAAA,kBAAkB,EAAE;AAFY,CAAlC;;;;"}
package/dist/index.js DELETED
@@ -1,8 +0,0 @@
1
-
2
- 'use strict'
3
-
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./field-editor-multiple-line.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./field-editor-multiple-line.cjs.development.js')
8
- }