@contentful/field-editor-url 1.2.0 → 1.3.1
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.
- package/dist/cjs/UrlEditor.js +76 -0
- package/dist/cjs/UrlEditor.test.js +141 -0
- package/dist/cjs/index.js +11 -0
- package/dist/esm/UrlEditor.js +27 -0
- package/dist/esm/UrlEditor.test.js +98 -0
- package/dist/esm/index.js +1 -0
- package/dist/{UrlEditor.d.ts → types/UrlEditor.d.ts} +21 -21
- package/dist/types/UrlEditor.test.d.ts +1 -0
- package/dist/{index.d.ts → types/index.d.ts} +1 -1
- package/package.json +26 -13
- package/CHANGELOG.md +0 -192
- package/dist/field-editor-url.cjs.development.js +0 -42
- package/dist/field-editor-url.cjs.development.js.map +0 -1
- package/dist/field-editor-url.cjs.production.min.js +0 -2
- package/dist/field-editor-url.cjs.production.min.js.map +0 -1
- package/dist/field-editor-url.esm.js +0 -38
- package/dist/field-editor-url.esm.js.map +0 -1
- package/dist/index.js +0 -8
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "UrlEditor", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return UrlEditor;
|
|
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
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
15
|
+
if (typeof WeakMap !== "function") return null;
|
|
16
|
+
var cacheBabelInterop = new WeakMap();
|
|
17
|
+
var cacheNodeInterop = new WeakMap();
|
|
18
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
19
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
20
|
+
})(nodeInterop);
|
|
21
|
+
}
|
|
22
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
23
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
27
|
+
return {
|
|
28
|
+
default: obj
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
32
|
+
if (cache && cache.has(obj)) {
|
|
33
|
+
return cache.get(obj);
|
|
34
|
+
}
|
|
35
|
+
var newObj = {};
|
|
36
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
37
|
+
for(var key in obj){
|
|
38
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
39
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
40
|
+
if (desc && (desc.get || desc.set)) {
|
|
41
|
+
Object.defineProperty(newObj, key, desc);
|
|
42
|
+
} else {
|
|
43
|
+
newObj[key] = obj[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
newObj.default = obj;
|
|
48
|
+
if (cache) {
|
|
49
|
+
cache.set(obj, newObj);
|
|
50
|
+
}
|
|
51
|
+
return newObj;
|
|
52
|
+
}
|
|
53
|
+
function UrlEditor(props) {
|
|
54
|
+
const { field } = props;
|
|
55
|
+
return _react.createElement(_fieldeditorshared.FieldConnector, {
|
|
56
|
+
field: field,
|
|
57
|
+
isInitiallyDisabled: props.isInitiallyDisabled
|
|
58
|
+
}, ({ value , errors , disabled , setValue })=>{
|
|
59
|
+
return _react.createElement("div", {
|
|
60
|
+
"data-test-id": "url-editor"
|
|
61
|
+
}, _react.createElement(_f36components.TextInput, {
|
|
62
|
+
isRequired: field.required,
|
|
63
|
+
isInvalid: errors.length > 0,
|
|
64
|
+
isDisabled: disabled,
|
|
65
|
+
value: value || '',
|
|
66
|
+
onChange: (e)=>{
|
|
67
|
+
setValue(e.target.value);
|
|
68
|
+
}
|
|
69
|
+
}), typeof props.children === 'function' ? props.children({
|
|
70
|
+
value
|
|
71
|
+
}) : null);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
UrlEditor.defaultProps = {
|
|
75
|
+
isInitiallyDisabled: true
|
|
76
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
require("@testing-library/jest-dom/extend-expect");
|
|
9
|
+
const _UrlEditor = require("./UrlEditor");
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
11
|
+
if (typeof WeakMap !== "function") return null;
|
|
12
|
+
var cacheBabelInterop = new WeakMap();
|
|
13
|
+
var cacheNodeInterop = new WeakMap();
|
|
14
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
15
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
16
|
+
})(nodeInterop);
|
|
17
|
+
}
|
|
18
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
19
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
23
|
+
return {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
28
|
+
if (cache && cache.has(obj)) {
|
|
29
|
+
return cache.get(obj);
|
|
30
|
+
}
|
|
31
|
+
var newObj = {};
|
|
32
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
33
|
+
for(var key in obj){
|
|
34
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
35
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
36
|
+
if (desc && (desc.get || desc.set)) {
|
|
37
|
+
Object.defineProperty(newObj, key, desc);
|
|
38
|
+
} else {
|
|
39
|
+
newObj[key] = obj[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
newObj.default = obj;
|
|
44
|
+
if (cache) {
|
|
45
|
+
cache.set(obj, newObj);
|
|
46
|
+
}
|
|
47
|
+
return newObj;
|
|
48
|
+
}
|
|
49
|
+
(0, _react1.configure)({
|
|
50
|
+
testIdAttribute: 'data-test-id'
|
|
51
|
+
});
|
|
52
|
+
describe('UrlEditor', ()=>{
|
|
53
|
+
afterEach(_react1.cleanup);
|
|
54
|
+
it('renders without crashing', ()=>{
|
|
55
|
+
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)();
|
|
56
|
+
(0, _react1.render)(_react.createElement(_UrlEditor.UrlEditor, {
|
|
57
|
+
field: field,
|
|
58
|
+
isInitiallyDisabled: false
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
it('reads initial value from field.getValue', ()=>{
|
|
62
|
+
const initialValue = 'initial-value';
|
|
63
|
+
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
64
|
+
return {
|
|
65
|
+
...field,
|
|
66
|
+
id: 'field-id',
|
|
67
|
+
getValue: ()=>{
|
|
68
|
+
return initialValue;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
const { getByTestId } = (0, _react1.render)(_react.createElement(_UrlEditor.UrlEditor, {
|
|
73
|
+
field: field,
|
|
74
|
+
isInitiallyDisabled: false
|
|
75
|
+
}));
|
|
76
|
+
expect(getByTestId('cf-ui-text-input')).toHaveValue(initialValue);
|
|
77
|
+
});
|
|
78
|
+
it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
79
|
+
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
80
|
+
jest.spyOn(field, 'setValue');
|
|
81
|
+
jest.spyOn(field, 'removeValue');
|
|
82
|
+
return {
|
|
83
|
+
...field,
|
|
84
|
+
id: 'field-id'
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
const { getByTestId } = (0, _react1.render)(_react.createElement(_UrlEditor.UrlEditor, {
|
|
88
|
+
field: field,
|
|
89
|
+
isInitiallyDisabled: false
|
|
90
|
+
}));
|
|
91
|
+
const $input = getByTestId('cf-ui-text-input');
|
|
92
|
+
expect($input).toHaveValue('');
|
|
93
|
+
_react1.fireEvent.change($input, {
|
|
94
|
+
target: {
|
|
95
|
+
value: 'new-value'
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
await (0, _react1.waitFor)(()=>{
|
|
99
|
+
expect($input).toHaveValue('new-value');
|
|
100
|
+
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
101
|
+
expect(field.setValue).toHaveBeenLastCalledWith('new-value');
|
|
102
|
+
});
|
|
103
|
+
_react1.fireEvent.change($input, {
|
|
104
|
+
target: {
|
|
105
|
+
value: ''
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
await (0, _react1.waitFor)(()=>{
|
|
109
|
+
expect($input).toHaveValue('');
|
|
110
|
+
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
111
|
+
expect(field.removeValue).toHaveBeenLastCalledWith();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
it('gives an ability to render custom preview', ()=>{
|
|
115
|
+
const initialValue = 'initial-value';
|
|
116
|
+
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
117
|
+
return {
|
|
118
|
+
...field,
|
|
119
|
+
id: 'field-id',
|
|
120
|
+
getValue: ()=>{
|
|
121
|
+
return initialValue;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
const { getByTestId , getByText } = (0, _react1.render)(_react.createElement(_UrlEditor.UrlEditor, {
|
|
126
|
+
field: field,
|
|
127
|
+
isInitiallyDisabled: false
|
|
128
|
+
}, ({ value })=>{
|
|
129
|
+
return _react.createElement("div", null, "Custom preview: ", value);
|
|
130
|
+
}));
|
|
131
|
+
const $input = getByTestId('cf-ui-text-input');
|
|
132
|
+
expect($input).toHaveValue(initialValue);
|
|
133
|
+
expect(getByText('Custom preview: initial-value')).toBeInTheDocument();
|
|
134
|
+
_react1.fireEvent.change($input, {
|
|
135
|
+
target: {
|
|
136
|
+
value: 'new-value'
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
expect(getByText('Custom preview: new-value')).toBeInTheDocument();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TextInput } from '@contentful/f36-components';
|
|
3
|
+
import { FieldConnector } from '@contentful/field-editor-shared';
|
|
4
|
+
export function UrlEditor(props) {
|
|
5
|
+
const { field } = props;
|
|
6
|
+
return React.createElement(FieldConnector, {
|
|
7
|
+
field: field,
|
|
8
|
+
isInitiallyDisabled: props.isInitiallyDisabled
|
|
9
|
+
}, ({ value , errors , disabled , setValue })=>{
|
|
10
|
+
return React.createElement("div", {
|
|
11
|
+
"data-test-id": "url-editor"
|
|
12
|
+
}, React.createElement(TextInput, {
|
|
13
|
+
isRequired: field.required,
|
|
14
|
+
isInvalid: errors.length > 0,
|
|
15
|
+
isDisabled: disabled,
|
|
16
|
+
value: value || '',
|
|
17
|
+
onChange: (e)=>{
|
|
18
|
+
setValue(e.target.value);
|
|
19
|
+
}
|
|
20
|
+
}), typeof props.children === 'function' ? props.children({
|
|
21
|
+
value
|
|
22
|
+
}) : null);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
UrlEditor.defaultProps = {
|
|
26
|
+
isInitiallyDisabled: true
|
|
27
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createFakeFieldAPI } from '@contentful/field-editor-test-utils';
|
|
3
|
+
import { cleanup, configure, fireEvent, render, waitFor } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
+
import { UrlEditor } from './UrlEditor';
|
|
6
|
+
configure({
|
|
7
|
+
testIdAttribute: 'data-test-id'
|
|
8
|
+
});
|
|
9
|
+
describe('UrlEditor', ()=>{
|
|
10
|
+
afterEach(cleanup);
|
|
11
|
+
it('renders without crashing', ()=>{
|
|
12
|
+
const [field] = createFakeFieldAPI();
|
|
13
|
+
render(React.createElement(UrlEditor, {
|
|
14
|
+
field: field,
|
|
15
|
+
isInitiallyDisabled: false
|
|
16
|
+
}));
|
|
17
|
+
});
|
|
18
|
+
it('reads initial value from field.getValue', ()=>{
|
|
19
|
+
const initialValue = 'initial-value';
|
|
20
|
+
const [field] = createFakeFieldAPI((field)=>{
|
|
21
|
+
return {
|
|
22
|
+
...field,
|
|
23
|
+
id: 'field-id',
|
|
24
|
+
getValue: ()=>{
|
|
25
|
+
return initialValue;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
const { getByTestId } = render(React.createElement(UrlEditor, {
|
|
30
|
+
field: field,
|
|
31
|
+
isInitiallyDisabled: false
|
|
32
|
+
}));
|
|
33
|
+
expect(getByTestId('cf-ui-text-input')).toHaveValue(initialValue);
|
|
34
|
+
});
|
|
35
|
+
it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
36
|
+
const [field] = createFakeFieldAPI((field)=>{
|
|
37
|
+
jest.spyOn(field, 'setValue');
|
|
38
|
+
jest.spyOn(field, 'removeValue');
|
|
39
|
+
return {
|
|
40
|
+
...field,
|
|
41
|
+
id: 'field-id'
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
const { getByTestId } = render(React.createElement(UrlEditor, {
|
|
45
|
+
field: field,
|
|
46
|
+
isInitiallyDisabled: false
|
|
47
|
+
}));
|
|
48
|
+
const $input = getByTestId('cf-ui-text-input');
|
|
49
|
+
expect($input).toHaveValue('');
|
|
50
|
+
fireEvent.change($input, {
|
|
51
|
+
target: {
|
|
52
|
+
value: 'new-value'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
await waitFor(()=>{
|
|
56
|
+
expect($input).toHaveValue('new-value');
|
|
57
|
+
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(field.setValue).toHaveBeenLastCalledWith('new-value');
|
|
59
|
+
});
|
|
60
|
+
fireEvent.change($input, {
|
|
61
|
+
target: {
|
|
62
|
+
value: ''
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
await waitFor(()=>{
|
|
66
|
+
expect($input).toHaveValue('');
|
|
67
|
+
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
68
|
+
expect(field.removeValue).toHaveBeenLastCalledWith();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
it('gives an ability to render custom preview', ()=>{
|
|
72
|
+
const initialValue = 'initial-value';
|
|
73
|
+
const [field] = createFakeFieldAPI((field)=>{
|
|
74
|
+
return {
|
|
75
|
+
...field,
|
|
76
|
+
id: 'field-id',
|
|
77
|
+
getValue: ()=>{
|
|
78
|
+
return initialValue;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
const { getByTestId , getByText } = render(React.createElement(UrlEditor, {
|
|
83
|
+
field: field,
|
|
84
|
+
isInitiallyDisabled: false
|
|
85
|
+
}, ({ value })=>{
|
|
86
|
+
return React.createElement("div", null, "Custom preview: ", value);
|
|
87
|
+
}));
|
|
88
|
+
const $input = getByTestId('cf-ui-text-input');
|
|
89
|
+
expect($input).toHaveValue(initialValue);
|
|
90
|
+
expect(getByText('Custom preview: initial-value')).toBeInTheDocument();
|
|
91
|
+
fireEvent.change($input, {
|
|
92
|
+
target: {
|
|
93
|
+
value: 'new-value'
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
expect(getByText('Custom preview: new-value')).toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UrlEditor } from './UrlEditor';
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { FieldAPI } from '@contentful/field-editor-shared';
|
|
3
|
-
export interface UrlEditorProps {
|
|
4
|
-
/**
|
|
5
|
-
* is the field disabled initially
|
|
6
|
-
*/
|
|
7
|
-
isInitiallyDisabled: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* sdk.field
|
|
10
|
-
*/
|
|
11
|
-
field: FieldAPI;
|
|
12
|
-
children?: (props: {
|
|
13
|
-
value: string | null | undefined;
|
|
14
|
-
}) => React.ReactNode;
|
|
15
|
-
}
|
|
16
|
-
export declare function UrlEditor(props: UrlEditorProps): JSX.Element;
|
|
17
|
-
export declare namespace UrlEditor {
|
|
18
|
-
var defaultProps: {
|
|
19
|
-
isInitiallyDisabled: boolean;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FieldAPI } from '@contentful/field-editor-shared';
|
|
3
|
+
export interface UrlEditorProps {
|
|
4
|
+
/**
|
|
5
|
+
* is the field disabled initially
|
|
6
|
+
*/
|
|
7
|
+
isInitiallyDisabled: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* sdk.field
|
|
10
|
+
*/
|
|
11
|
+
field: FieldAPI;
|
|
12
|
+
children?: (props: {
|
|
13
|
+
value: string | null | undefined;
|
|
14
|
+
}) => React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function UrlEditor(props: UrlEditorProps): React.JSX.Element;
|
|
17
|
+
export declare namespace UrlEditor {
|
|
18
|
+
var defaultProps: {
|
|
19
|
+
isInitiallyDisabled: boolean;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { UrlEditor } from './UrlEditor';
|
|
1
|
+
export { UrlEditor } from './UrlEditor';
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-url",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"module": "dist/
|
|
6
|
-
"
|
|
3
|
+
"version": "1.3.1",
|
|
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,30 @@
|
|
|
14
22
|
"url": "https://github.com/contentful/field-editors"
|
|
15
23
|
},
|
|
16
24
|
"scripts": {
|
|
17
|
-
"watch": "
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
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.
|
|
40
|
+
"@contentful/field-editor-shared": "^1.3.1",
|
|
27
41
|
"emotion": "^10.0.17",
|
|
28
|
-
"lodash": "^4.17.15"
|
|
29
|
-
"lodash-es": "^4.17.15"
|
|
42
|
+
"lodash": "^4.17.15"
|
|
30
43
|
},
|
|
31
44
|
"devDependencies": {
|
|
32
|
-
"@contentful/field-editor-test-utils": "^1.
|
|
45
|
+
"@contentful/field-editor-test-utils": "^1.4.1"
|
|
33
46
|
},
|
|
34
47
|
"peerDependencies": {
|
|
35
48
|
"react": ">=16.8.0"
|
|
36
49
|
},
|
|
37
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "ca904b19ca794a2c40d82e1f7ede9e0be3560f22"
|
|
38
51
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,192 +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-url@1.1.11...@contentful/field-editor-url@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-url@1.1.10...@contentful/field-editor-url@1.1.11) (2023-03-14)
|
|
13
|
-
|
|
14
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
15
|
-
|
|
16
|
-
## [1.1.10](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.1.9...@contentful/field-editor-url@1.1.10) (2023-03-10)
|
|
17
|
-
|
|
18
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
19
|
-
|
|
20
|
-
## [1.1.9](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.1.8...@contentful/field-editor-url@1.1.9) (2023-02-21)
|
|
21
|
-
|
|
22
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
23
|
-
|
|
24
|
-
## [1.1.8](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.1.7...@contentful/field-editor-url@1.1.8) (2023-02-07)
|
|
25
|
-
|
|
26
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
27
|
-
|
|
28
|
-
## [1.1.7](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.1.6...@contentful/field-editor-url@1.1.7) (2022-12-08)
|
|
29
|
-
|
|
30
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
31
|
-
|
|
32
|
-
## [1.1.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.1.5...@contentful/field-editor-url@1.1.6) (2022-07-29)
|
|
33
|
-
|
|
34
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
35
|
-
|
|
36
|
-
## [1.1.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.1.4...@contentful/field-editor-url@1.1.5) (2022-07-29)
|
|
37
|
-
|
|
38
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
39
|
-
|
|
40
|
-
## [1.1.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.1.3...@contentful/field-editor-url@1.1.4) (2022-07-11)
|
|
41
|
-
|
|
42
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
43
|
-
|
|
44
|
-
## [1.1.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.1.2...@contentful/field-editor-url@1.1.3) (2022-06-22)
|
|
45
|
-
|
|
46
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
47
|
-
|
|
48
|
-
## [1.1.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.1.1...@contentful/field-editor-url@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-url@1.1.0...@contentful/field-editor-url@1.1.1) (2022-02-14)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
57
|
-
|
|
58
|
-
# [1.1.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.0.3...@contentful/field-editor-url@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-url@1.0.2...@contentful/field-editor-url@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-url@1.0.1...@contentful/field-editor-url@1.0.2) (2021-12-20)
|
|
71
|
-
|
|
72
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
73
|
-
|
|
74
|
-
## [1.0.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@1.0.0...@contentful/field-editor-url@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-url@0.13.0...@contentful/field-editor-url@1.0.0) (2021-11-04)
|
|
81
|
-
|
|
82
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
83
|
-
|
|
84
|
-
# [0.13.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.12.6...@contentful/field-editor-url@0.13.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.12.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.12.5...@contentful/field-editor-url@0.12.6) (2021-10-14)
|
|
95
|
-
|
|
96
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
97
|
-
|
|
98
|
-
## [0.12.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.12.4...@contentful/field-editor-url@0.12.5) (2021-10-06)
|
|
99
|
-
|
|
100
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
101
|
-
|
|
102
|
-
## [0.12.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.12.3...@contentful/field-editor-url@0.12.4) (2021-09-17)
|
|
103
|
-
|
|
104
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
105
|
-
|
|
106
|
-
## [0.12.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.12.2...@contentful/field-editor-url@0.12.3) (2021-09-16)
|
|
107
|
-
|
|
108
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
109
|
-
|
|
110
|
-
## [0.12.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.12.1...@contentful/field-editor-url@0.12.2) (2021-08-19)
|
|
111
|
-
|
|
112
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
113
|
-
|
|
114
|
-
## [0.12.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.12.0...@contentful/field-editor-url@0.12.1) (2021-07-29)
|
|
115
|
-
|
|
116
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
117
|
-
|
|
118
|
-
# [0.12.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.11.6...@contentful/field-editor-url@0.12.0) (2021-07-23)
|
|
119
|
-
|
|
120
|
-
### Features
|
|
121
|
-
|
|
122
|
-
- 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
|
|
123
|
-
|
|
124
|
-
## [0.11.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.11.3...@contentful/field-editor-url@0.11.6) (2021-07-06)
|
|
125
|
-
|
|
126
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
127
|
-
|
|
128
|
-
## [0.11.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.11.3...@contentful/field-editor-url@0.11.5) (2021-07-06)
|
|
129
|
-
|
|
130
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
131
|
-
|
|
132
|
-
## [0.11.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.11.3...@contentful/field-editor-url@0.11.4) (2021-06-23)
|
|
133
|
-
|
|
134
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
135
|
-
|
|
136
|
-
## [0.11.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.11.2...@contentful/field-editor-url@0.11.3) (2021-06-23)
|
|
137
|
-
|
|
138
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
139
|
-
|
|
140
|
-
## [0.11.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.11.1...@contentful/field-editor-url@0.11.2) (2021-06-22)
|
|
141
|
-
|
|
142
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
143
|
-
|
|
144
|
-
## [0.11.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.11.0...@contentful/field-editor-url@0.11.1) (2021-03-05)
|
|
145
|
-
|
|
146
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
147
|
-
|
|
148
|
-
# [0.11.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.10.2...@contentful/field-editor-url@0.11.0) (2021-02-19)
|
|
149
|
-
|
|
150
|
-
### Features
|
|
151
|
-
|
|
152
|
-
- bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
|
|
153
|
-
|
|
154
|
-
## [0.10.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.10.1...@contentful/field-editor-url@0.10.2) (2021-02-09)
|
|
155
|
-
|
|
156
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
157
|
-
|
|
158
|
-
## [0.10.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.10.0...@contentful/field-editor-url@0.10.1) (2021-02-01)
|
|
159
|
-
|
|
160
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
161
|
-
|
|
162
|
-
# [0.10.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.9.0...@contentful/field-editor-url@0.10.0) (2021-01-20)
|
|
163
|
-
|
|
164
|
-
### Features
|
|
165
|
-
|
|
166
|
-
- 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))
|
|
167
|
-
|
|
168
|
-
# [0.9.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.8.5...@contentful/field-editor-url@0.9.0) (2021-01-12)
|
|
169
|
-
|
|
170
|
-
### Features
|
|
171
|
-
|
|
172
|
-
- 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))
|
|
173
|
-
|
|
174
|
-
## [0.8.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.8.4...@contentful/field-editor-url@0.8.5) (2020-12-16)
|
|
175
|
-
|
|
176
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
177
|
-
|
|
178
|
-
## [0.8.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.8.3...@contentful/field-editor-url@0.8.4) (2020-11-06)
|
|
179
|
-
|
|
180
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
181
|
-
|
|
182
|
-
## [0.8.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.8.2...@contentful/field-editor-url@0.8.3) (2020-11-06)
|
|
183
|
-
|
|
184
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
185
|
-
|
|
186
|
-
## [0.8.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.8.1...@contentful/field-editor-url@0.8.2) (2020-10-28)
|
|
187
|
-
|
|
188
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
189
|
-
|
|
190
|
-
## [0.8.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-url@0.8.0...@contentful/field-editor-url@0.8.1) (2020-08-24)
|
|
191
|
-
|
|
192
|
-
**Note:** Version bump only for package @contentful/field-editor-url
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var f36Components = require('@contentful/f36-components');
|
|
7
|
-
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
8
|
-
|
|
9
|
-
function UrlEditor(props) {
|
|
10
|
-
const {
|
|
11
|
-
field
|
|
12
|
-
} = props;
|
|
13
|
-
return React.createElement(fieldEditorShared.FieldConnector, {
|
|
14
|
-
field: field,
|
|
15
|
-
isInitiallyDisabled: props.isInitiallyDisabled
|
|
16
|
-
}, ({
|
|
17
|
-
value,
|
|
18
|
-
errors,
|
|
19
|
-
disabled,
|
|
20
|
-
setValue
|
|
21
|
-
}) => {
|
|
22
|
-
return React.createElement("div", {
|
|
23
|
-
"data-test-id": "url-editor"
|
|
24
|
-
}, React.createElement(f36Components.TextInput, {
|
|
25
|
-
isRequired: field.required,
|
|
26
|
-
isInvalid: errors.length > 0,
|
|
27
|
-
isDisabled: disabled,
|
|
28
|
-
value: value || '',
|
|
29
|
-
onChange: e => {
|
|
30
|
-
setValue(e.target.value);
|
|
31
|
-
}
|
|
32
|
-
}), typeof props.children === 'function' ? props.children({
|
|
33
|
-
value
|
|
34
|
-
}) : null);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
UrlEditor.defaultProps = {
|
|
38
|
-
isInitiallyDisabled: true
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
exports.UrlEditor = UrlEditor;
|
|
42
|
-
//# sourceMappingURL=field-editor-url.cjs.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-url.cjs.development.js","sources":["../src/UrlEditor.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { TextInput } from '@contentful/f36-components';\nimport { FieldAPI, FieldConnector } from '@contentful/field-editor-shared';\n\n\nexport interface UrlEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n children?: (props: { value: string | null | undefined }) => React.ReactNode;\n}\n\nexport function UrlEditor(props: UrlEditorProps) {\n const { field } = props;\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ value, errors, disabled, setValue }) => {\n return (\n <div data-test-id=\"url-editor\">\n <TextInput\n isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n }}\n />\n {typeof props.children === 'function' ? props.children({ value }) : null}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nUrlEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["UrlEditor","props","field","React","FieldConnector","isInitiallyDisabled","value","errors","disabled","setValue","TextInput","isRequired","required","isInvalid","length","isDisabled","onChange","e","target","children","defaultProps"],"mappings":";;;;;;;;SAoBgBA,UAAUC;AACxB,QAAM;AAAEC,IAAAA;AAAF,MAAYD,KAAlB;AAEA,SACEE,mBAAA,CAACC,gCAAD;AAAwBF,IAAAA,KAAK,EAAEA;AAAOG,IAAAA,mBAAmB,EAAEJ,KAAK,CAACI;GAAjE,EACG,CAAC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,MAAT;AAAiBC,IAAAA,QAAjB;AAA2BC,IAAAA;AAA3B,GAAD;AACC,WACEN,mBAAA,MAAA;sBAAkB;KAAlB,EACEA,mBAAA,CAACO,uBAAD;AACEC,MAAAA,UAAU,EAAET,KAAK,CAACU;AAClBC,MAAAA,SAAS,EAAEN,MAAM,CAACO,MAAP,GAAgB;AAC3BC,MAAAA,UAAU,EAAEP;AACZF,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBU,MAAAA,QAAQ,EAAGC,CAAD;AACRR,QAAAA,QAAQ,CAACQ,CAAC,CAACC,MAAF,CAASZ,KAAV,CAAR;AACD;KAPH,CADF,EAUG,OAAOL,KAAK,CAACkB,QAAb,KAA0B,UAA1B,GAAuClB,KAAK,CAACkB,QAAN,CAAe;AAAEb,MAAAA;AAAF,KAAf,CAAvC,GAAmE,IAVtE,CADF;AAcD,GAhBH,CADF;AAoBD;AAEDN,SAAS,CAACoB,YAAV,GAAyB;AACvBf,EAAAA,mBAAmB,EAAE;AADE,CAAzB;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@contentful/f36-components"),i=require("@contentful/field-editor-shared");function l(l){const{field:r}=l;return e.createElement(i.FieldConnector,{field:r,isInitiallyDisabled:l.isInitiallyDisabled},({value:i,errors:n,disabled:a,setValue:d})=>e.createElement("div",{"data-test-id":"url-editor"},e.createElement(t.TextInput,{isRequired:r.required,isInvalid:n.length>0,isDisabled:a,value:i||"",onChange:e=>{d(e.target.value)}}),"function"==typeof l.children?l.children({value:i}):null))}l.defaultProps={isInitiallyDisabled:!0},exports.UrlEditor=l;
|
|
2
|
-
//# sourceMappingURL=field-editor-url.cjs.production.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-url.cjs.production.min.js","sources":["../src/UrlEditor.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { TextInput } from '@contentful/f36-components';\nimport { FieldAPI, FieldConnector } from '@contentful/field-editor-shared';\n\n\nexport interface UrlEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n children?: (props: { value: string | null | undefined }) => React.ReactNode;\n}\n\nexport function UrlEditor(props: UrlEditorProps) {\n const { field } = props;\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ value, errors, disabled, setValue }) => {\n return (\n <div data-test-id=\"url-editor\">\n <TextInput\n isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n }}\n />\n {typeof props.children === 'function' ? props.children({ value }) : null}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nUrlEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["UrlEditor","props","field","React","FieldConnector","isInitiallyDisabled","value","errors","disabled","setValue","TextInput","isRequired","required","isInvalid","length","isDisabled","onChange","e","target","children","defaultProps"],"mappings":"yLAoBgBA,EAAUC,SAClBC,MAAEA,GAAUD,SAGhBE,gBAACC,kBAAuBF,MAAOA,EAAOG,oBAAqBJ,EAAMI,qBAC9D,EAAGC,MAAAA,EAAOC,OAAAA,EAAQC,SAAAA,EAAUC,SAAAA,KAEzBN,sCAAkB,cAChBA,gBAACO,aACCC,WAAYT,EAAMU,SAClBC,UAAWN,EAAOO,OAAS,EAC3BC,WAAYP,EACZF,MAAOA,GAAS,GAChBU,SAAWC,IACTR,EAASQ,EAAEC,OAAOZ,UAGK,mBAAnBL,EAAMkB,SAA0BlB,EAAMkB,SAAS,CAAEb,MAAAA,IAAW,OAQhFN,EAAUoB,aAAe,CACvBf,qBAAqB"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createElement } from 'react';
|
|
2
|
-
import { TextInput } from '@contentful/f36-components';
|
|
3
|
-
import { FieldConnector } from '@contentful/field-editor-shared';
|
|
4
|
-
|
|
5
|
-
function UrlEditor(props) {
|
|
6
|
-
const {
|
|
7
|
-
field
|
|
8
|
-
} = props;
|
|
9
|
-
return createElement(FieldConnector, {
|
|
10
|
-
field: field,
|
|
11
|
-
isInitiallyDisabled: props.isInitiallyDisabled
|
|
12
|
-
}, ({
|
|
13
|
-
value,
|
|
14
|
-
errors,
|
|
15
|
-
disabled,
|
|
16
|
-
setValue
|
|
17
|
-
}) => {
|
|
18
|
-
return createElement("div", {
|
|
19
|
-
"data-test-id": "url-editor"
|
|
20
|
-
}, createElement(TextInput, {
|
|
21
|
-
isRequired: field.required,
|
|
22
|
-
isInvalid: errors.length > 0,
|
|
23
|
-
isDisabled: disabled,
|
|
24
|
-
value: value || '',
|
|
25
|
-
onChange: e => {
|
|
26
|
-
setValue(e.target.value);
|
|
27
|
-
}
|
|
28
|
-
}), typeof props.children === 'function' ? props.children({
|
|
29
|
-
value
|
|
30
|
-
}) : null);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
UrlEditor.defaultProps = {
|
|
34
|
-
isInitiallyDisabled: true
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { UrlEditor };
|
|
38
|
-
//# sourceMappingURL=field-editor-url.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-url.esm.js","sources":["../src/UrlEditor.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { TextInput } from '@contentful/f36-components';\nimport { FieldAPI, FieldConnector } from '@contentful/field-editor-shared';\n\n\nexport interface UrlEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n children?: (props: { value: string | null | undefined }) => React.ReactNode;\n}\n\nexport function UrlEditor(props: UrlEditorProps) {\n const { field } = props;\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ value, errors, disabled, setValue }) => {\n return (\n <div data-test-id=\"url-editor\">\n <TextInput\n isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n }}\n />\n {typeof props.children === 'function' ? props.children({ value }) : null}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nUrlEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["UrlEditor","props","field","React","FieldConnector","isInitiallyDisabled","value","errors","disabled","setValue","TextInput","isRequired","required","isInvalid","length","isDisabled","onChange","e","target","children","defaultProps"],"mappings":";;;;SAoBgBA,UAAUC;AACxB,QAAM;AAAEC,IAAAA;AAAF,MAAYD,KAAlB;AAEA,SACEE,aAAA,CAACC,cAAD;AAAwBF,IAAAA,KAAK,EAAEA;AAAOG,IAAAA,mBAAmB,EAAEJ,KAAK,CAACI;GAAjE,EACG,CAAC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,MAAT;AAAiBC,IAAAA,QAAjB;AAA2BC,IAAAA;AAA3B,GAAD;AACC,WACEN,aAAA,MAAA;sBAAkB;KAAlB,EACEA,aAAA,CAACO,SAAD;AACEC,MAAAA,UAAU,EAAET,KAAK,CAACU;AAClBC,MAAAA,SAAS,EAAEN,MAAM,CAACO,MAAP,GAAgB;AAC3BC,MAAAA,UAAU,EAAEP;AACZF,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBU,MAAAA,QAAQ,EAAGC,CAAD;AACRR,QAAAA,QAAQ,CAACQ,CAAC,CAACC,MAAF,CAASZ,KAAV,CAAR;AACD;KAPH,CADF,EAUG,OAAOL,KAAK,CAACkB,QAAb,KAA0B,UAA1B,GAAuClB,KAAK,CAACkB,QAAN,CAAe;AAAEb,MAAAA;AAAF,KAAf,CAAvC,GAAmE,IAVtE,CADF;AAcD,GAhBH,CADF;AAoBD;AAEDN,SAAS,CAACoB,YAAV,GAAyB;AACvBf,EAAAA,mBAAmB,EAAE;AADE,CAAzB;;;;"}
|