@contentful/field-editor-multiple-line 1.2.0 → 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.2.0",
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.2.0",
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.3.0"
46
+ "@contentful/field-editor-test-utils": "^1.4.0"
33
47
  },
34
48
  "peerDependencies": {
35
49
  "react": ">=16.8.0"
36
50
  },
37
- "gitHead": "de7e74e3485dd69c240cfe9c545e6e50e41fb295"
51
+ "gitHead": "543e02672a8dd4edc810f9f3568d6b69c454e1f9"
38
52
  }
package/CHANGELOG.md DELETED
@@ -1,200 +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.2.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.11...@contentful/field-editor-multiple-line@1.2.0) (2023-04-19)
7
-
8
- ### Features
9
-
10
- - upgrade cypress [TOL-1036] ([#1391](https://github.com/contentful/field-editors/issues/1391)) ([9c1aec9](https://github.com/contentful/field-editors/commit/9c1aec98aabbe464cdc3f1236c3bb1cc29b8208d))
11
-
12
- ## [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)
13
-
14
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
15
-
16
- ## [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)
17
-
18
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
19
-
20
- ## [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)
21
-
22
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
23
-
24
- ## [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)
25
-
26
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
27
-
28
- ## [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)
29
-
30
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
31
-
32
- ## [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)
33
-
34
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
35
-
36
- ## [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)
37
-
38
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
39
-
40
- ## [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)
41
-
42
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
43
-
44
- ## [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)
45
-
46
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
47
-
48
- ## [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)
49
-
50
- ### Bug Fixes
51
-
52
- - bump f36 packages ([#1025](https://github.com/contentful/field-editors/issues/1025)) ([ec37a40](https://github.com/contentful/field-editors/commit/ec37a4000db7cd75c66dd9621136b2272c9feeea))
53
-
54
- ## [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)
55
-
56
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
57
-
58
- # [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)
59
-
60
- ### Features
61
-
62
- - 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))
63
-
64
- ## [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)
65
-
66
- ### Bug Fixes
67
-
68
- - markdown buttons ([#968](https://github.com/contentful/field-editors/issues/968)) ([9803b98](https://github.com/contentful/field-editors/commit/9803b98c25d92df6148686ffe2749a77f7efdbb9))
69
-
70
- ## [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)
71
-
72
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
73
-
74
- ## [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)
75
-
76
- ### Bug Fixes
77
-
78
- - **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))
79
-
80
- # [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)
81
-
82
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
83
-
84
- # [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)
85
-
86
- ### Features
87
-
88
- - Forma v4 components adoption ([#805](https://github.com/contentful/field-editors/issues/805)) ([526bde6](https://github.com/contentful/field-editors/commit/526bde6e10e0ee3789705ec10fb31489af7ca59e))
89
-
90
- ### BREAKING CHANGES
91
-
92
- - adopts a new Forma v4 beta
93
-
94
- ## [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)
95
-
96
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
97
-
98
- # [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)
99
-
100
- ### Features
101
-
102
- - [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))
103
-
104
- ## [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)
105
-
106
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
107
-
108
- ## [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)
109
-
110
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
111
-
112
- ## [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)
113
-
114
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
115
-
116
- # [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)
117
-
118
- ### Features
119
-
120
- - 🎸 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)
121
-
122
- ## [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)
123
-
124
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
125
-
126
- # [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)
127
-
128
- ### Features
129
-
130
- - 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
131
-
132
- ## [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)
133
-
134
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
135
-
136
- ## [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)
137
-
138
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
139
-
140
- ## [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)
141
-
142
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
143
-
144
- ## [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)
145
-
146
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
147
-
148
- ## [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)
149
-
150
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
151
-
152
- ## [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)
153
-
154
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
155
-
156
- # [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)
157
-
158
- ### Features
159
-
160
- - bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
161
-
162
- ## [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)
163
-
164
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
165
-
166
- ## [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)
167
-
168
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
169
-
170
- # [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)
171
-
172
- ### Features
173
-
174
- - 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))
175
-
176
- # [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)
177
-
178
- ### Features
179
-
180
- - 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))
181
-
182
- ## [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)
183
-
184
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
185
-
186
- ## [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)
187
-
188
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
189
-
190
- ## [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)
191
-
192
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
193
-
194
- ## [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)
195
-
196
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
197
-
198
- ## [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)
199
-
200
- **Note:** Version bump only for package @contentful/field-editor-multiple-line
@@ -1,76 +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 f36Components = require('@contentful/f36-components');
9
- var fieldEditorShared = require('@contentful/field-editor-shared');
10
- var tokens = _interopDefault(require('@contentful/f36-tokens'));
11
- var emotion = require('emotion');
12
-
13
- const 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
- const rightToLeft = /*#__PURE__*/emotion.css({
21
- direction: 'rtl'
22
- });
23
-
24
- function MultipleLineEditor(props) {
25
- const {
26
- field,
27
- locales,
28
- isInitiallyDisabled,
29
- withCharValidation
30
- } = props;
31
- const constraints = fieldEditorShared.ConstraintsUtils.fromFieldValidations(field.validations, field.type);
32
- const checkConstraint = fieldEditorShared.ConstraintsUtils.makeChecker(constraints);
33
- const direction = locales.direction[field.locale] || 'ltr';
34
- return React.createElement(fieldEditorShared.FieldConnector, {
35
- field: field,
36
- isInitiallyDisabled: isInitiallyDisabled
37
- }, ({
38
- errors,
39
- disabled,
40
- value,
41
- setValue
42
- }) => {
43
- return React.createElement("div", {
44
- "data-test-id": "multiple-line-editor"
45
- }, React.createElement(f36Components.Textarea, {
46
- className: direction === 'rtl' ? rightToLeft : '',
47
- rows: 3,
48
- isRequired: field.required,
49
- isInvalid: errors.length > 0,
50
- isDisabled: disabled,
51
- value: value || '',
52
- onChange: e => {
53
- setValue(e.target.value);
54
- }
55
- }), withCharValidation && React.createElement("div", {
56
- className: validationRow
57
- }, React.createElement(fieldEditorShared.CharCounter, {
58
- value: value || '',
59
- checkConstraint: checkConstraint
60
- }), React.createElement(fieldEditorShared.CharValidation, {
61
- constraints: constraints
62
- })), !withCharValidation && React.createElement("div", {
63
- className: validationRow
64
- }, React.createElement(fieldEditorShared.CharCounter, {
65
- value: value || '',
66
- checkConstraint: () => true
67
- })));
68
- });
69
- }
70
- MultipleLineEditor.defaultProps = {
71
- isInitiallyDisabled: true,
72
- withCharValidation: true
73
- };
74
-
75
- exports.MultipleLineEditor = MultipleLineEditor;
76
- //# 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 tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\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';\n\nimport { Textarea } from '@contentful/f36-components';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils,\n} from '@contentful/field-editor-shared';\n\nimport * as styles from './styles';\n\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,MAAMA,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,MAAMC,WAAW,gBAAGV,WAAG,CAAC;AAC7BW,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;;SC0BSC,mBAAmBC;AACjC,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA,OAAT;AAAkBC,IAAAA,mBAAlB;AAAuCC,IAAAA;AAAvC,MAA8DJ,KAApE;AAEA,QAAMK,WAAW,GAAGC,kCAAgB,CAACC,oBAAjB,CAClBN,KAAK,CAACO,WADY,EAElBP,KAAK,CAACQ,IAFY,CAApB;AAIA,QAAMC,eAAe,GAAGJ,kCAAgB,CAACK,WAAjB,CAA6BN,WAA7B,CAAxB;AACA,QAAMP,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,CAAC;AAAEY,IAAAA,MAAF;AAAUC,IAAAA,QAAV;AAAoBC,IAAAA,KAApB;AAA2BC,IAAAA;AAA3B,GAAD;AACC,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,EAAGC,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,MAAM;KAAxD,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/f36-components"),a=require("@contentful/field-editor-shared"),l=(e=require("@contentful/f36-tokens"))&&"object"==typeof e&&"default"in e?e.default:e,r=require("emotion");const n=r.css({display:"flex",justifyContent:"space-between",fontSize:l.fontSizeM,marginTop:l.spacingXs,color:l.gray700}),s=r.css({direction:"rtl"});function o(e){const{field:l,locales:r,isInitiallyDisabled:o,withCharValidation:c}=e,d=a.ConstraintsUtils.fromFieldValidations(l.validations,l.type),u=a.ConstraintsUtils.makeChecker(d),f=r.direction[l.locale]||"ltr";return t.createElement(a.FieldConnector,{field:l,isInitiallyDisabled:o},({errors:e,disabled:r,value:o,setValue:m})=>t.createElement("div",{"data-test-id":"multiple-line-editor"},t.createElement(i.Textarea,{className:"rtl"===f?s:"",rows:3,isRequired:l.required,isInvalid:e.length>0,isDisabled:r,value:o||"",onChange:e=>{m(e.target.value)}}),c&&t.createElement("div",{className:n},t.createElement(a.CharCounter,{value:o||"",checkConstraint:u}),t.createElement(a.CharValidation,{constraints:d})),!c&&t.createElement("div",{className:n},t.createElement(a.CharCounter,{value:o||"",checkConstraint:()=>!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 tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\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';\n\nimport { Textarea } from '@contentful/f36-components';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils,\n} from '@contentful/field-editor-shared';\n\nimport * as styles from './styles';\n\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":"8RAGO,MAAMA,EAAgBC,MAAI,CAC/BC,QAAS,OACTC,eAAgB,gBAChBC,SAAUC,EAAOC,UACjBC,UAAWF,EAAOG,UAClBC,MAAOJ,EAAOK,UAGHC,EAAcV,MAAI,CAC7BW,UAAW,iBCyBGC,EAAmBC,SAC3BC,MAAEA,EAAFC,QAASA,EAATC,oBAAkBA,EAAlBC,mBAAuCA,GAAuBJ,EAE9DK,EAAcC,mBAAiBC,qBACnCN,EAAMO,YACNP,EAAMQ,MAEFC,EAAkBJ,mBAAiBK,YAAYN,GAC/CP,EAAYI,EAAQJ,UAAUG,EAAMW,SAAW,aAGnDC,gBAACC,kBAAuBb,MAAOA,EAAOE,oBAAqBA,GACxD,EAAGY,OAAAA,EAAQC,SAAAA,EAAUC,MAAAA,EAAOC,SAAAA,KAEzBL,sCAAkB,wBAChBA,gBAACM,YACCC,UAAyB,QAAdtB,EAAsBuB,EAAqB,GACtDC,KAAM,EACNC,WAAYtB,EAAMuB,SAClBC,UAAWV,EAAOW,OAAS,EAC3BC,WAAYX,EACZC,MAAOA,GAAS,GAChBW,SAAWC,IACTX,EAASW,EAAEC,OAAOb,UAGrBb,GACCS,uBAAKO,UAAWC,GACdR,gBAACkB,eAAYd,MAAOA,GAAS,GAAIP,gBAAiBA,IAClDG,gBAACmB,kBAAe3B,YAAaA,MAG/BD,GACAS,uBAAKO,UAAWC,GACdR,gBAACkB,eAAYd,MAAOA,GAAS,GAAIP,gBAAiB,KAAM,OAUxEX,EAAmBkC,aAAe,CAChC9B,qBAAqB,EACrBC,oBAAoB"}
@@ -1,70 +0,0 @@
1
- import { createElement } from 'react';
2
- import { Textarea } from '@contentful/f36-components';
3
- import { ConstraintsUtils, FieldConnector, CharCounter, CharValidation } from '@contentful/field-editor-shared';
4
- import tokens from '@contentful/f36-tokens';
5
- import { css } from 'emotion';
6
-
7
- const validationRow = /*#__PURE__*/css({
8
- display: 'flex',
9
- justifyContent: 'space-between',
10
- fontSize: tokens.fontSizeM,
11
- marginTop: tokens.spacingXs,
12
- color: tokens.gray700
13
- });
14
- const rightToLeft = /*#__PURE__*/css({
15
- direction: 'rtl'
16
- });
17
-
18
- function MultipleLineEditor(props) {
19
- const {
20
- field,
21
- locales,
22
- isInitiallyDisabled,
23
- withCharValidation
24
- } = props;
25
- const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);
26
- const checkConstraint = ConstraintsUtils.makeChecker(constraints);
27
- const direction = locales.direction[field.locale] || 'ltr';
28
- return createElement(FieldConnector, {
29
- field: field,
30
- isInitiallyDisabled: isInitiallyDisabled
31
- }, ({
32
- errors,
33
- disabled,
34
- value,
35
- setValue
36
- }) => {
37
- return createElement("div", {
38
- "data-test-id": "multiple-line-editor"
39
- }, createElement(Textarea, {
40
- className: direction === 'rtl' ? rightToLeft : '',
41
- rows: 3,
42
- isRequired: field.required,
43
- isInvalid: errors.length > 0,
44
- isDisabled: disabled,
45
- value: value || '',
46
- onChange: e => {
47
- setValue(e.target.value);
48
- }
49
- }), withCharValidation && createElement("div", {
50
- className: validationRow
51
- }, createElement(CharCounter, {
52
- value: value || '',
53
- checkConstraint: checkConstraint
54
- }), createElement(CharValidation, {
55
- constraints: constraints
56
- })), !withCharValidation && createElement("div", {
57
- className: validationRow
58
- }, createElement(CharCounter, {
59
- value: value || '',
60
- checkConstraint: () => true
61
- })));
62
- });
63
- }
64
- MultipleLineEditor.defaultProps = {
65
- isInitiallyDisabled: true,
66
- withCharValidation: true
67
- };
68
-
69
- export { MultipleLineEditor };
70
- //# 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 tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\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';\n\nimport { Textarea } from '@contentful/f36-components';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils,\n} from '@contentful/field-editor-shared';\n\nimport * as styles from './styles';\n\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,MAAMA,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,MAAMC,WAAW,gBAAGV,GAAG,CAAC;AAC7BW,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;;SC0BSC,mBAAmBC;AACjC,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA,OAAT;AAAkBC,IAAAA,mBAAlB;AAAuCC,IAAAA;AAAvC,MAA8DJ,KAApE;AAEA,QAAMK,WAAW,GAAGC,gBAAgB,CAACC,oBAAjB,CAClBN,KAAK,CAACO,WADY,EAElBP,KAAK,CAACQ,IAFY,CAApB;AAIA,QAAMC,eAAe,GAAGJ,gBAAgB,CAACK,WAAjB,CAA6BN,WAA7B,CAAxB;AACA,QAAMP,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,CAAC;AAAEY,IAAAA,MAAF;AAAUC,IAAAA,QAAV;AAAoBC,IAAAA,KAApB;AAA2BC,IAAAA;AAA3B,GAAD;AACC,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,EAAGC,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,MAAM;KAAxD,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
- }