payload 0.14.2-beta.0 → 0.14.7-beta.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.
- package/CHANGELOG.md +17 -2
- package/components/index.js +2 -2
- package/dist/admin/components/forms/field-types/Checkbox/index.js +2 -1
- package/dist/admin/components/forms/field-types/Code/Code.js +2 -1
- package/dist/admin/components/forms/field-types/DateTime/index.js +2 -1
- package/dist/admin/components/forms/field-types/Email/index.js +2 -1
- package/dist/admin/components/forms/field-types/Group/index.js +2 -1
- package/dist/admin/components/forms/field-types/Number/index.js +2 -1
- package/dist/admin/components/forms/field-types/Password/index.js +2 -1
- package/dist/admin/components/forms/field-types/Password/types.d.ts +1 -0
- package/dist/admin/components/forms/field-types/Point/index.js +2 -1
- package/dist/admin/components/forms/field-types/RadioGroup/index.js +2 -1
- package/dist/admin/components/forms/field-types/Relationship/index.js +2 -1
- package/dist/admin/components/forms/field-types/RichText/RichText.d.ts +2 -2
- package/dist/admin/components/forms/field-types/RichText/RichText.js +6 -6
- package/dist/admin/components/forms/field-types/RichText/buttons.scss +4 -0
- package/dist/admin/components/forms/field-types/RichText/elements/Button.d.ts +1 -0
- package/dist/admin/components/forms/field-types/RichText/elements/Button.js +1 -1
- package/dist/admin/components/forms/field-types/RichText/elements/ListButton.d.ts +6 -0
- package/dist/admin/components/forms/field-types/RichText/elements/ListButton.js +19 -0
- package/dist/admin/components/forms/field-types/RichText/elements/indent/index.d.ts +9 -0
- package/dist/admin/components/forms/field-types/RichText/elements/indent/index.js +69 -0
- package/dist/admin/components/forms/field-types/RichText/elements/index.d.ts +7 -3
- package/dist/admin/components/forms/field-types/RichText/elements/index.js +4 -1
- package/dist/admin/components/forms/field-types/RichText/elements/isActive.js +6 -3
- package/dist/admin/components/forms/field-types/RichText/elements/isListActive.d.ts +3 -0
- package/dist/admin/components/forms/field-types/RichText/elements/isListActive.js +21 -0
- package/dist/admin/components/forms/field-types/RichText/elements/li/index.d.ts +1 -4
- package/dist/admin/components/forms/field-types/RichText/elements/li/index.js +7 -1
- package/dist/admin/components/forms/field-types/RichText/elements/link/index.d.ts +1 -1
- package/dist/admin/components/forms/field-types/RichText/elements/ol/index.js +2 -2
- package/dist/admin/components/forms/field-types/RichText/elements/toggle.js +2 -1
- package/dist/admin/components/forms/field-types/RichText/elements/ul/index.js +2 -2
- package/dist/admin/components/forms/field-types/RichText/types.d.ts +4 -0
- package/dist/admin/components/forms/field-types/Select/Input.d.ts +1 -0
- package/dist/admin/components/forms/field-types/Select/Input.js +2 -1
- package/dist/admin/components/forms/field-types/Select/index.js +2 -2
- package/dist/admin/components/forms/field-types/Text/Input.d.ts +1 -0
- package/dist/admin/components/forms/field-types/Text/Input.js +2 -1
- package/dist/admin/components/forms/field-types/Text/index.js +2 -2
- package/dist/admin/components/forms/field-types/Textarea/Input.d.ts +1 -0
- package/dist/admin/components/forms/field-types/Textarea/Input.js +2 -1
- package/dist/admin/components/forms/field-types/Textarea/index.js +2 -2
- package/dist/admin/components/forms/field-types/Upload/Input.d.ts +1 -0
- package/dist/admin/components/forms/field-types/Upload/Input.js +2 -1
- package/dist/admin/components/forms/field-types/Upload/index.js +2 -2
- package/dist/admin/components/forms/useField/index.js +1 -0
- package/dist/admin/components/forms/useField/types.d.ts +1 -0
- package/dist/admin/components/icons/IndentLeft/index.d.ts +4 -0
- package/dist/admin/components/icons/IndentLeft/index.js +8 -0
- package/dist/admin/components/icons/IndentLeft/index.scss +16 -0
- package/dist/admin/components/icons/IndentRight/index.d.ts +4 -0
- package/dist/admin/components/icons/IndentRight/index.js +8 -0
- package/dist/admin/components/icons/IndentRight/index.scss +16 -0
- package/dist/admin/components/icons/Swap/index.d.ts +4 -0
- package/dist/admin/components/icons/Swap/index.js +8 -0
- package/dist/admin/components/icons/Swap/index.scss +12 -0
- package/dist/collections/config/sanitize.js +1 -1
- package/dist/fields/config/schema.js +2 -1
- package/dist/fields/config/types.d.ts +2 -1
- package/dist/fields/config/types.js +1 -1
- package/dist/fields/richText/defaultValue.d.ts +1 -0
- package/dist/fields/richText/defaultValue.js +2 -1
- package/dist/fields/traverseFields.js +4 -3
- package/dist/fields/validations.js +5 -5
- package/dist/mongoose/buildSchema.js +7 -3
- package/dist/mongoose/sanitizeFormattedValue.js +7 -7
- package/dist/preferences/model.d.ts +1 -2
- package/dist/webpack/components.config.d.ts +2 -1
- package/docs/fields/overview.mdx +2 -0
- package/docs/fields/point.mdx +1 -1
- package/docs/fields/rich-text.mdx +1 -0
- package/package.json +3 -3
- package/types.d.ts +1 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useSlate, ReactEditor } from 'slate-react';
|
|
3
|
+
import { Editor, Element, Transforms } from 'slate';
|
|
4
|
+
import IndentLeft from '../../../../../icons/IndentLeft';
|
|
5
|
+
import IndentRight from '../../../../../icons/IndentRight';
|
|
6
|
+
import { baseClass } from '../Button';
|
|
7
|
+
import isElementActive from '../isActive';
|
|
8
|
+
import listTypes from '../listTypes';
|
|
9
|
+
const indentType = 'indent';
|
|
10
|
+
const IndentWithPadding = ({ attributes, children }) => (React.createElement("div", { style: { paddingLeft: 25 }, ...attributes }, children));
|
|
11
|
+
const indent = {
|
|
12
|
+
Button: () => {
|
|
13
|
+
const editor = useSlate();
|
|
14
|
+
const handleIndent = useCallback((e, dir) => {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
if (editor.blurSelection) {
|
|
17
|
+
Transforms.select(editor, editor.blurSelection);
|
|
18
|
+
}
|
|
19
|
+
if (dir === 'left') {
|
|
20
|
+
Transforms.unwrapNodes(editor, {
|
|
21
|
+
match: (n) => Element.isElement(n) && [indentType, ...listTypes].includes(n.type),
|
|
22
|
+
split: true,
|
|
23
|
+
mode: 'lowest',
|
|
24
|
+
});
|
|
25
|
+
if (isElementActive(editor, 'li')) {
|
|
26
|
+
const [, parentLocation] = Editor.parent(editor, editor.selection);
|
|
27
|
+
const [, parentDepth] = parentLocation;
|
|
28
|
+
if (parentDepth > 0 || parentDepth === 0) {
|
|
29
|
+
Transforms.unwrapNodes(editor, {
|
|
30
|
+
match: (n) => Element.isElement(n) && n.type === 'li',
|
|
31
|
+
split: true,
|
|
32
|
+
mode: 'lowest',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
Transforms.unsetNodes(editor, ['type']);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (dir === 'right') {
|
|
41
|
+
const isCurrentlyOL = isElementActive(editor, 'ol');
|
|
42
|
+
const isCurrentlyUL = isElementActive(editor, 'ul');
|
|
43
|
+
if (isCurrentlyOL || isCurrentlyUL) {
|
|
44
|
+
Transforms.wrapNodes(editor, {
|
|
45
|
+
type: 'li',
|
|
46
|
+
children: [],
|
|
47
|
+
});
|
|
48
|
+
Transforms.wrapNodes(editor, { type: isCurrentlyOL ? 'ol' : 'ul', children: [{ text: ' ' }] });
|
|
49
|
+
Transforms.setNodes(editor, { type: 'li' });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
Transforms.wrapNodes(editor, { type: indentType, children: [] });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
ReactEditor.focus(editor);
|
|
56
|
+
}, [editor]);
|
|
57
|
+
const canDeIndent = isElementActive(editor, 'li') || isElementActive(editor, indentType);
|
|
58
|
+
return (React.createElement(React.Fragment, null,
|
|
59
|
+
React.createElement("button", { type: "button", className: [
|
|
60
|
+
baseClass,
|
|
61
|
+
!canDeIndent && `${baseClass}--disabled`,
|
|
62
|
+
].filter(Boolean).join(' '), onClick: canDeIndent ? (e) => handleIndent(e, 'left') : undefined },
|
|
63
|
+
React.createElement(IndentLeft, null)),
|
|
64
|
+
React.createElement("button", { type: "button", className: baseClass, onClick: (e) => handleIndent(e, 'right') },
|
|
65
|
+
React.createElement(IndentRight, null))));
|
|
66
|
+
},
|
|
67
|
+
Element: IndentWithPadding,
|
|
68
|
+
};
|
|
69
|
+
export default indent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const
|
|
2
|
+
declare const elements: {
|
|
3
3
|
h1: {
|
|
4
4
|
Button: () => JSX.Element;
|
|
5
5
|
Element: ({ attributes, children }: {
|
|
@@ -49,7 +49,7 @@ declare const _default: {
|
|
|
49
49
|
children: any;
|
|
50
50
|
element: any;
|
|
51
51
|
}) => JSX.Element;
|
|
52
|
-
plugins: ((incomingEditor: import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor) => import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor)[];
|
|
52
|
+
plugins: ((incomingEditor: import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor & import("../types").BlurSelectionEditor) => import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor & import("../types").BlurSelectionEditor)[];
|
|
53
53
|
};
|
|
54
54
|
ol: {
|
|
55
55
|
Button: () => JSX.Element;
|
|
@@ -66,6 +66,10 @@ declare const _default: {
|
|
|
66
66
|
}) => JSX.Element;
|
|
67
67
|
};
|
|
68
68
|
li: {
|
|
69
|
+
Element: (props: any) => JSX.Element;
|
|
70
|
+
};
|
|
71
|
+
indent: {
|
|
72
|
+
Button: () => JSX.Element;
|
|
69
73
|
Element: ({ attributes, children }: {
|
|
70
74
|
attributes: any;
|
|
71
75
|
children: any;
|
|
@@ -91,4 +95,4 @@ declare const _default: {
|
|
|
91
95
|
plugins: ((incomingEditor: any) => any)[];
|
|
92
96
|
};
|
|
93
97
|
};
|
|
94
|
-
export default
|
|
98
|
+
export default elements;
|
|
@@ -8,9 +8,10 @@ import link from './link';
|
|
|
8
8
|
import ol from './ol';
|
|
9
9
|
import ul from './ul';
|
|
10
10
|
import li from './li';
|
|
11
|
+
import indent from './indent';
|
|
11
12
|
import relationship from './relationship';
|
|
12
13
|
import upload from './upload';
|
|
13
|
-
|
|
14
|
+
const elements = {
|
|
14
15
|
h1,
|
|
15
16
|
h2,
|
|
16
17
|
h3,
|
|
@@ -21,6 +22,8 @@ export default {
|
|
|
21
22
|
ol,
|
|
22
23
|
ul,
|
|
23
24
|
li,
|
|
25
|
+
indent,
|
|
24
26
|
relationship,
|
|
25
27
|
upload,
|
|
26
28
|
};
|
|
29
|
+
export default elements;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Editor, Element } from 'slate';
|
|
2
2
|
const isElementActive = (editor, format) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
if (!editor.selection)
|
|
4
|
+
return false;
|
|
5
|
+
const [match] = Array.from(Editor.nodes(editor, {
|
|
6
|
+
at: Editor.unhangRange(editor, editor.selection),
|
|
7
|
+
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.type === format,
|
|
8
|
+
}));
|
|
6
9
|
return !!match;
|
|
7
10
|
};
|
|
8
11
|
export default isElementActive;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Editor, Element } from 'slate';
|
|
2
|
+
const isListActive = (editor, format) => {
|
|
3
|
+
if (!editor.selection
|
|
4
|
+
// If focus or anchor is at root of editor,
|
|
5
|
+
// Return false - as Editor.parent will fail
|
|
6
|
+
|| editor.selection.focus.path[1] === 0
|
|
7
|
+
// || editor.selection.focus.path.length === 0
|
|
8
|
+
|| editor.selection.anchor.path[1] === 0
|
|
9
|
+
// || editor.selection.anchor.path.length === 0
|
|
10
|
+
)
|
|
11
|
+
return false;
|
|
12
|
+
const parentLI = Editor.parent(editor, editor.selection);
|
|
13
|
+
if (parentLI[1].length > 0) {
|
|
14
|
+
const ancestor = Editor.above(editor, {
|
|
15
|
+
at: parentLI[1],
|
|
16
|
+
});
|
|
17
|
+
return Element.isElement(ancestor[0]) && ancestor[0].type === format;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
export default isListActive;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
import listTypes from '../listTypes';
|
|
3
|
+
const LI = (props) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const { attributes, element, children } = props;
|
|
6
|
+
const disableListStyle = element.children.length >= 1 && listTypes.includes((_b = (_a = element.children) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.type);
|
|
7
|
+
return (React.createElement("li", { style: { listStyle: disableListStyle ? 'none' : undefined }, ...attributes }, children));
|
|
8
|
+
};
|
|
3
9
|
export default {
|
|
4
10
|
Element: LI,
|
|
5
11
|
};
|
|
@@ -8,6 +8,6 @@ declare const link: {
|
|
|
8
8
|
children: any;
|
|
9
9
|
element: any;
|
|
10
10
|
}) => JSX.Element;
|
|
11
|
-
plugins: ((incomingEditor: import("slate").BaseEditor & ReactEditor & import("slate-history").HistoryEditor) => import("slate").BaseEditor & ReactEditor & import("slate-history").HistoryEditor)[];
|
|
11
|
+
plugins: ((incomingEditor: import("slate").BaseEditor & ReactEditor & import("slate-history").HistoryEditor & import("../../types").BlurSelectionEditor) => import("slate").BaseEditor & ReactEditor & import("slate-history").HistoryEditor & import("../../types").BlurSelectionEditor)[];
|
|
12
12
|
};
|
|
13
13
|
export default link;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import ListButton from '../ListButton';
|
|
3
3
|
import OLIcon from '../../../../../icons/OrderedList';
|
|
4
4
|
const OL = ({ attributes, children }) => (React.createElement("ol", { ...attributes }, children));
|
|
5
5
|
const ol = {
|
|
6
|
-
Button: () => (React.createElement(
|
|
6
|
+
Button: () => (React.createElement(ListButton, { format: "ol" },
|
|
7
7
|
React.createElement(OLIcon, null))),
|
|
8
8
|
Element: OL,
|
|
9
9
|
};
|
|
@@ -7,7 +7,7 @@ const toggleElement = (editor, format) => {
|
|
|
7
7
|
const isList = listTypes.includes(format);
|
|
8
8
|
let type = format;
|
|
9
9
|
if (isActive) {
|
|
10
|
-
type =
|
|
10
|
+
type = undefined;
|
|
11
11
|
}
|
|
12
12
|
else if (isList) {
|
|
13
13
|
type = 'li';
|
|
@@ -18,6 +18,7 @@ const toggleElement = (editor, format) => {
|
|
|
18
18
|
Transforms.unwrapNodes(editor, {
|
|
19
19
|
match: (n) => Element.isElement(n) && listTypes.includes(n.type),
|
|
20
20
|
split: true,
|
|
21
|
+
mode: 'lowest',
|
|
21
22
|
});
|
|
22
23
|
Transforms.setNodes(editor, { type });
|
|
23
24
|
if (!isActive && isList) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import ElementButton from '../Button';
|
|
3
2
|
import ULIcon from '../../../../../icons/UnorderedList';
|
|
3
|
+
import ListButton from '../ListButton';
|
|
4
4
|
const UL = ({ attributes, children }) => (React.createElement("ul", { ...attributes }, children));
|
|
5
5
|
const ul = {
|
|
6
|
-
Button: () => (React.createElement(
|
|
6
|
+
Button: () => (React.createElement(ListButton, { format: "ul" },
|
|
7
7
|
React.createElement(ULIcon, null))),
|
|
8
8
|
Element: UL,
|
|
9
9
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { BaseEditor, Selection } from 'slate';
|
|
1
2
|
import { RichTextField } from '../../../../../fields/config/types';
|
|
2
3
|
export declare type Props = Omit<RichTextField, 'type'> & {
|
|
3
4
|
path?: string;
|
|
4
5
|
};
|
|
6
|
+
export interface BlurSelectionEditor extends BaseEditor {
|
|
7
|
+
blurSelection?: Selection;
|
|
8
|
+
}
|
|
@@ -13,6 +13,7 @@ export declare type SelectInputProps = Omit<SelectField, 'type' | 'value' | 'opt
|
|
|
13
13
|
description?: Description;
|
|
14
14
|
onChange?: (value: ReactSelectValue) => void;
|
|
15
15
|
style?: React.CSSProperties;
|
|
16
|
+
className?: string;
|
|
16
17
|
width?: string;
|
|
17
18
|
hasMany?: boolean;
|
|
18
19
|
options?: OptionObject[];
|
|
@@ -6,10 +6,11 @@ import ReactSelect from '../../../elements/ReactSelect';
|
|
|
6
6
|
// import { FieldType } from '../../useField/types';
|
|
7
7
|
import './index.scss';
|
|
8
8
|
const SelectInput = (props) => {
|
|
9
|
-
const { showError, errorMessage, readOnly, path, label, required, value, onChange, description, style, width, options, hasMany, } = props;
|
|
9
|
+
const { showError, errorMessage, readOnly, path, label, required, value, onChange, description, style, className, width, options, hasMany, } = props;
|
|
10
10
|
const classes = [
|
|
11
11
|
'field-type',
|
|
12
12
|
'select',
|
|
13
|
+
className,
|
|
13
14
|
showError && 'error',
|
|
14
15
|
readOnly && 'read-only',
|
|
15
16
|
].filter(Boolean).join(' ');
|
|
@@ -13,7 +13,7 @@ const formatOptions = (options) => options.map((option) => {
|
|
|
13
13
|
};
|
|
14
14
|
});
|
|
15
15
|
const Select = (props) => {
|
|
16
|
-
const { path: pathFromProps, name, required, validate = select, label, options: optionsFromProps, hasMany, admin: { readOnly, style, width, description, condition, } = {}, } = props;
|
|
16
|
+
const { path: pathFromProps, name, required, validate = select, label, options: optionsFromProps, hasMany, admin: { readOnly, style, className, width, description, condition, } = {}, } = props;
|
|
17
17
|
const path = pathFromProps || name;
|
|
18
18
|
const [options] = useState(formatOptions(optionsFromProps));
|
|
19
19
|
const memoizedValidate = useCallback((value) => {
|
|
@@ -46,6 +46,6 @@ const Select = (props) => {
|
|
|
46
46
|
hasMany,
|
|
47
47
|
setValue,
|
|
48
48
|
]);
|
|
49
|
-
return (React.createElement(SelectInput, { path: path, onChange: onChange, value: value, name: name, options: options, label: label, showError: showError, errorMessage: errorMessage, description: description, style: style, width: width, hasMany: hasMany }));
|
|
49
|
+
return (React.createElement(SelectInput, { path: path, onChange: onChange, value: value, name: name, options: options, label: label, showError: showError, errorMessage: errorMessage, description: description, style: style, className: className, width: width, hasMany: hasMany }));
|
|
50
50
|
};
|
|
51
51
|
export default withCondition(Select);
|
|
@@ -13,6 +13,7 @@ export declare type TextInputProps = Omit<TextField, 'type'> & {
|
|
|
13
13
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
14
14
|
placeholder?: string;
|
|
15
15
|
style?: React.CSSProperties;
|
|
16
|
+
className?: string;
|
|
16
17
|
width?: string;
|
|
17
18
|
};
|
|
18
19
|
declare const TextInput: React.FC<TextInputProps>;
|
|
@@ -5,10 +5,11 @@ import FieldDescription from '../../FieldDescription';
|
|
|
5
5
|
// import { FieldType } from '../../useField/types';
|
|
6
6
|
import './index.scss';
|
|
7
7
|
const TextInput = (props) => {
|
|
8
|
-
const { showError, errorMessage, placeholder, readOnly, path, label, required, value, onChange, description, style, width, } = props;
|
|
8
|
+
const { showError, errorMessage, placeholder, readOnly, path, label, required, value, onChange, description, style, className, width, } = props;
|
|
9
9
|
const classes = [
|
|
10
10
|
'field-type',
|
|
11
11
|
'text',
|
|
12
|
+
className,
|
|
12
13
|
showError && 'error',
|
|
13
14
|
readOnly && 'read-only',
|
|
14
15
|
].filter(Boolean).join(' ');
|
|
@@ -4,7 +4,7 @@ import withCondition from '../../withCondition';
|
|
|
4
4
|
import { text } from '../../../../../fields/validations';
|
|
5
5
|
import TextInput from './Input';
|
|
6
6
|
const Text = (props) => {
|
|
7
|
-
const { path: pathFromProps, name, required, validate = text, label, admin: { placeholder, readOnly, style, width, description, condition, } = {}, } = props;
|
|
7
|
+
const { path: pathFromProps, name, required, validate = text, label, admin: { placeholder, readOnly, style, className, width, description, condition, } = {}, } = props;
|
|
8
8
|
const path = pathFromProps || name;
|
|
9
9
|
const field = useField({
|
|
10
10
|
path,
|
|
@@ -15,6 +15,6 @@ const Text = (props) => {
|
|
|
15
15
|
const { value, showError, setValue, errorMessage, } = field;
|
|
16
16
|
return (React.createElement(TextInput, { path: path, name: name, onChange: (e) => {
|
|
17
17
|
setValue(e.target.value);
|
|
18
|
-
}, showError: showError, errorMessage: errorMessage, required: required, label: label, value: value, placeholder: placeholder, readOnly: readOnly, style: style, width: width, description: description }));
|
|
18
|
+
}, showError: showError, errorMessage: errorMessage, required: required, label: label, value: value, placeholder: placeholder, readOnly: readOnly, style: style, className: className, width: width, description: description }));
|
|
19
19
|
};
|
|
20
20
|
export default withCondition(Text);
|
|
@@ -4,10 +4,11 @@ import Error from '../../Error';
|
|
|
4
4
|
import FieldDescription from '../../FieldDescription';
|
|
5
5
|
import './index.scss';
|
|
6
6
|
const TextareaInput = (props) => {
|
|
7
|
-
const { path, required, readOnly, style, width, placeholder, description, label, showError, value, errorMessage, onChange, rows, } = props;
|
|
7
|
+
const { path, required, readOnly, style, className, width, placeholder, description, label, showError, value, errorMessage, onChange, rows, } = props;
|
|
8
8
|
const classes = [
|
|
9
9
|
'field-type',
|
|
10
10
|
'textarea',
|
|
11
|
+
className,
|
|
11
12
|
showError && 'error',
|
|
12
13
|
readOnly && 'read-only',
|
|
13
14
|
].filter(Boolean).join(' ');
|
|
@@ -5,7 +5,7 @@ import { textarea } from '../../../../../fields/validations';
|
|
|
5
5
|
import './index.scss';
|
|
6
6
|
import TextareaInput from './Input';
|
|
7
7
|
const Textarea = (props) => {
|
|
8
|
-
const { path: pathFromProps, name, required, validate = textarea, admin: { readOnly, style, width, placeholder, rows, description, condition, } = {}, label, minLength, maxLength, } = props;
|
|
8
|
+
const { path: pathFromProps, name, required, validate = textarea, admin: { readOnly, style, className, width, placeholder, rows, description, condition, } = {}, label, minLength, maxLength, } = props;
|
|
9
9
|
const path = pathFromProps || name;
|
|
10
10
|
const memoizedValidate = useCallback((value) => {
|
|
11
11
|
const validationResult = validate(value, { minLength, maxLength, required });
|
|
@@ -19,6 +19,6 @@ const Textarea = (props) => {
|
|
|
19
19
|
});
|
|
20
20
|
return (React.createElement(TextareaInput, { path: path, name: name, onChange: (e) => {
|
|
21
21
|
setValue(e.target.value);
|
|
22
|
-
}, showError: showError, errorMessage: errorMessage, required: required, label: label, value: value, placeholder: placeholder, readOnly: readOnly, style: style, width: width, description: description, rows: rows }));
|
|
22
|
+
}, showError: showError, errorMessage: errorMessage, required: required, label: label, value: value, placeholder: placeholder, readOnly: readOnly, style: style, className: className, width: width, description: description, rows: rows }));
|
|
23
23
|
};
|
|
24
24
|
export default withCondition(Textarea);
|
|
@@ -15,6 +15,7 @@ export declare type UploadInputProps = Omit<UploadField, 'type'> & {
|
|
|
15
15
|
onChange?: (e: any) => void;
|
|
16
16
|
placeholder?: string;
|
|
17
17
|
style?: React.CSSProperties;
|
|
18
|
+
className?: string;
|
|
18
19
|
width?: string;
|
|
19
20
|
fieldTypes?: FieldTypes;
|
|
20
21
|
collection?: SanitizedCollectionConfig;
|
|
@@ -10,7 +10,7 @@ import SelectExistingModal from './SelectExisting';
|
|
|
10
10
|
import './index.scss';
|
|
11
11
|
const baseClass = 'upload';
|
|
12
12
|
const UploadInput = (props) => {
|
|
13
|
-
const { path, required, readOnly, style, width, description, label, relationTo, fieldTypes, value, onChange, showError, serverURL = 'http://localhost:3000', api = '/api', collection, errorMessage, } = props;
|
|
13
|
+
const { path, required, readOnly, style, className, width, description, label, relationTo, fieldTypes, value, onChange, showError, serverURL = 'http://localhost:3000', api = '/api', collection, errorMessage, } = props;
|
|
14
14
|
const { toggle } = useModal();
|
|
15
15
|
const addModalSlug = `${path}-add`;
|
|
16
16
|
const selectExistingModalSlug = `${path}-select-existing`;
|
|
@@ -19,6 +19,7 @@ const UploadInput = (props) => {
|
|
|
19
19
|
const classes = [
|
|
20
20
|
'field-type',
|
|
21
21
|
baseClass,
|
|
22
|
+
className,
|
|
22
23
|
showError && 'error',
|
|
23
24
|
readOnly && 'read-only',
|
|
24
25
|
].filter(Boolean).join(' ');
|
|
@@ -7,7 +7,7 @@ import UploadInput from './Input';
|
|
|
7
7
|
import './index.scss';
|
|
8
8
|
const Upload = (props) => {
|
|
9
9
|
const { collections, serverURL, routes: { api, }, } = useConfig();
|
|
10
|
-
const { path, name, required, admin: { readOnly, style, width, description, condition, } = {}, label, validate = upload, relationTo, fieldTypes, } = props;
|
|
10
|
+
const { path, name, required, admin: { readOnly, style, className, width, description, condition, } = {}, label, validate = upload, relationTo, fieldTypes, } = props;
|
|
11
11
|
const collection = collections.find((coll) => coll.slug === relationTo);
|
|
12
12
|
const memoizedValidate = useCallback((value) => {
|
|
13
13
|
const validationResult = validate(value, { required });
|
|
@@ -26,7 +26,7 @@ const Upload = (props) => {
|
|
|
26
26
|
setValue,
|
|
27
27
|
]);
|
|
28
28
|
if (collection.upload) {
|
|
29
|
-
return (React.createElement(UploadInput, { path: path, value: value, onChange: onChange, description: description, label: label, required: required, showError: showError, serverURL: serverURL, api: api, errorMessage: errorMessage, readOnly: readOnly, style: style, width: width, collection: collection, fieldTypes: fieldTypes, name: name, relationTo: relationTo }));
|
|
29
|
+
return (React.createElement(UploadInput, { path: path, value: value, onChange: onChange, description: description, label: label, required: required, showError: showError, serverURL: serverURL, api: api, errorMessage: errorMessage, readOnly: readOnly, style: style, className: className, width: width, collection: collection, fieldTypes: fieldTypes, name: name, relationTo: relationTo }));
|
|
30
30
|
}
|
|
31
31
|
return null;
|
|
32
32
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
const IndentLeft = () => (React.createElement("svg", { className: "icon icon--indent-left", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 25 25" },
|
|
4
|
+
React.createElement("path", { d: "M16.005 9.61502L21.005 13.1864L21.005 6.04361L16.005 9.61502Z", className: "fill" }),
|
|
5
|
+
React.createElement("rect", { x: "5", y: "5.68199", width: "9.0675", height: "2.15625", className: "fill" }),
|
|
6
|
+
React.createElement("rect", { x: "5", y: "11.4738", width: "9.0675", height: "2.15625", className: "fill" }),
|
|
7
|
+
React.createElement("rect", { x: "5", y: "17.2656", width: "16.005", height: "2.15625", className: "fill" })));
|
|
8
|
+
export default IndentLeft;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@import '../../../scss/styles';
|
|
2
|
+
|
|
3
|
+
.icon--indent-left {
|
|
4
|
+
height: $baseline;
|
|
5
|
+
width: $baseline;
|
|
6
|
+
|
|
7
|
+
.stroke {
|
|
8
|
+
fill: none;
|
|
9
|
+
stroke: $color-dark-gray;
|
|
10
|
+
stroke-width: $style-stroke-width-m;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.fill {
|
|
14
|
+
fill: $color-dark-gray;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
const IndentRight = () => (React.createElement("svg", { className: "icon icon--indent-right", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 25 25" },
|
|
4
|
+
React.createElement("path", { d: "M10 9.61502L5 6.04361L5 13.1864L10 9.61502Z", fill: "#333333" }),
|
|
5
|
+
React.createElement("rect", { x: "11.9375", y: "5.68199", width: "9.0675", height: "2.15625", className: "fill" }),
|
|
6
|
+
React.createElement("rect", { x: "11.9375", y: "11.4738", width: "9.0675", height: "2.15625", className: "fill" }),
|
|
7
|
+
React.createElement("rect", { x: "5", y: "17.2656", width: "16.005", height: "2.15625", className: "fill" })));
|
|
8
|
+
export default IndentRight;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@import '../../../scss/styles';
|
|
2
|
+
|
|
3
|
+
.icon--indent-right {
|
|
4
|
+
height: $baseline;
|
|
5
|
+
width: $baseline;
|
|
6
|
+
|
|
7
|
+
.stroke {
|
|
8
|
+
fill: none;
|
|
9
|
+
stroke: $color-dark-gray;
|
|
10
|
+
stroke-width: $style-stroke-width-m;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.fill {
|
|
14
|
+
fill: $color-dark-gray;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
const Swap = () => (React.createElement("svg", { className: "icon icon--swap", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 25 25" },
|
|
4
|
+
React.createElement("path", { d: "M9.84631 4.78679L6.00004 8.63306L9.84631 12.4793", className: "stroke" }),
|
|
5
|
+
React.createElement("path", { d: "M15.1537 20.1059L19 16.2596L15.1537 12.4133", className: "stroke" }),
|
|
6
|
+
React.createElement("line", { x1: "7", y1: "8.7013", x2: "15", y2: "8.7013", stroke: "#333333", className: "stroke" }),
|
|
7
|
+
React.createElement("line", { x1: "18", y1: "16.1195", x2: "10", y2: "16.1195", className: "stroke" })));
|
|
8
|
+
export default Swap;
|
|
@@ -96,4 +96,4 @@ const sanitizeCollection = (config, collection) => {
|
|
|
96
96
|
return sanitized;
|
|
97
97
|
};
|
|
98
98
|
exports.default = sanitizeCollection;
|
|
99
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
99
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2FuaXRpemUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY29sbGVjdGlvbnMvY29uZmlnL3Nhbml0aXplLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsMERBQThCO0FBRTlCLDRFQUEwRDtBQUMxRCw4RUFBc0Q7QUFDdEQsNEZBQW9FO0FBQ3BFLGdHQUF3RTtBQUN4RSw0R0FBb0Y7QUFDcEYsMEdBQWtGO0FBQ2xGLHNHQUE4RTtBQUM5RSwrREFBNEQ7QUFDNUQseUNBQW9EO0FBR3BELE1BQU0sZUFBZSxHQUFHLENBQUMsTUFBTSxFQUFFLFVBQVUsRUFBRSxFQUFFO0lBQzdDLE1BQU0sWUFBWSxHQUFHLEVBQUUsQ0FBQztJQUV4QixJQUFJLE1BQU0sRUFBRTtRQUNWLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxTQUFTLEVBQUUsRUFBRTtZQUMvQixJQUFJLFlBQVksR0FBRyxJQUFJLENBQUM7WUFFeEIsTUFBTSxLQUFLLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDLEVBQUUsRU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