@manuscripts/style-guide 3.4.2 → 3.4.4
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/colors.js +49 -0
- package/dist/cjs/defaultTheme.js +235 -0
- package/dist/cjs/index.js +26 -9
- package/dist/es/colors.js +46 -0
- package/dist/es/defaultTheme.js +199 -0
- package/dist/es/index.js +2 -6
- package/dist/types/colors.d.ts +46 -0
- package/dist/types/{hooks/use-deep-compare.d.ts → defaultTheme.d.ts} +3 -3
- package/dist/types/index.d.ts +2 -6
- package/dist/types/theme.d.ts +2 -0
- package/package.json +1 -1
- package/dist/cjs/components/AutoSaveInput.js +0 -45
- package/dist/cjs/components/RichText/RichText.js +0 -24
- package/dist/cjs/components/RichText/RichTextField.js +0 -68
- package/dist/cjs/components/RichText/index.js +0 -7
- package/dist/cjs/components/RichText/schema.js +0 -111
- package/dist/cjs/components/TextFieldContainer.js +0 -15
- package/dist/cjs/components/TextFieldError.js +0 -34
- package/dist/cjs/components/TextFieldGroupContainer.js +0 -11
- package/dist/cjs/hooks/use-deep-compare.js +0 -31
- package/dist/es/components/AutoSaveInput.js +0 -38
- package/dist/es/components/RichText/RichText.js +0 -20
- package/dist/es/components/RichText/RichTextField.js +0 -61
- package/dist/es/components/RichText/index.js +0 -2
- package/dist/es/components/RichText/schema.js +0 -106
- package/dist/es/components/TextFieldContainer.js +0 -8
- package/dist/es/components/TextFieldError.js +0 -27
- package/dist/es/components/TextFieldGroupContainer.js +0 -7
- package/dist/es/hooks/use-deep-compare.js +0 -26
- package/dist/types/components/AutoSaveInput.d.ts +0 -42
- package/dist/types/components/RichText/RichText.d.ts +0 -6
- package/dist/types/components/RichText/RichTextField.d.ts +0 -6
- package/dist/types/components/RichText/index.d.ts +0 -2
- package/dist/types/components/RichText/schema.d.ts +0 -7
- package/dist/types/components/TextFieldContainer.d.ts +0 -24
- package/dist/types/components/TextFieldError.d.ts +0 -20
- package/dist/types/components/TextFieldGroupContainer.d.ts +0 -25
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ©
|
|
2
|
+
* © 2026 Atypon Systems LLC
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
export declare const
|
|
16
|
+
import type { Theme } from './theme';
|
|
17
|
+
export declare const defaultTheme: Theme;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export { Theme } from './theme';
|
|
17
|
+
export { defaultTheme } from './defaultTheme';
|
|
18
|
+
export * as colors from './colors';
|
|
17
19
|
export * from './components/AlertMessage';
|
|
18
20
|
export * from './components/Message';
|
|
19
21
|
export * from './components/Button';
|
|
20
22
|
export * from './components/ContextMenu';
|
|
21
23
|
export * from './components/RadioButton';
|
|
22
|
-
export * from './components/AutoSaveInput';
|
|
23
24
|
export * from './components/Avatar';
|
|
24
25
|
export * from './components/Dialog';
|
|
25
26
|
export * from './components/DraggableModal';
|
|
@@ -30,11 +31,7 @@ export * from './components/Resizer';
|
|
|
30
31
|
export * from './components/SaveStatus';
|
|
31
32
|
export * from './components/StyledModal';
|
|
32
33
|
export * from './components/Sidebar';
|
|
33
|
-
export * from './components/RichText';
|
|
34
34
|
export * from './components/TextField';
|
|
35
|
-
export * from './components/TextFieldContainer';
|
|
36
|
-
export * from './components/TextFieldError';
|
|
37
|
-
export * from './components/TextFieldGroupContainer';
|
|
38
35
|
export * from './components/ToggleSwitch';
|
|
39
36
|
export { ToggleHeader, ToggleIcon } from './components/ToggleHeader';
|
|
40
37
|
export * from './components/Tooltip';
|
|
@@ -54,6 +51,5 @@ export * from './components/SelectedItemsBox';
|
|
|
54
51
|
export * from './hooks/use-dropdown';
|
|
55
52
|
export * from './hooks/use-menus';
|
|
56
53
|
export * from './hooks/use-scroll-detection';
|
|
57
|
-
export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
|
|
58
54
|
export * from './lib/files';
|
|
59
55
|
export * from './lib/menus';
|
package/dist/types/theme.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/style-guide",
|
|
3
3
|
"description": "Shared components for Manuscripts applications",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.4",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AutoSaveInput = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const react_1 = __importDefault(require("react"));
|
|
9
|
-
class AutoSaveInput extends react_1.default.Component {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
this.state = {
|
|
13
|
-
focused: false,
|
|
14
|
-
};
|
|
15
|
-
this.handleSubmit = () => {
|
|
16
|
-
window.setTimeout(this.props.form.submitForm, 10);
|
|
17
|
-
};
|
|
18
|
-
this.handleFocus = () => {
|
|
19
|
-
this.setState({ focused: true });
|
|
20
|
-
};
|
|
21
|
-
this.handleBlur = (event) => {
|
|
22
|
-
this.setState({ focused: false });
|
|
23
|
-
this.props.field.onBlur(event);
|
|
24
|
-
if (this.props.saveOn === 'blur') {
|
|
25
|
-
this.handleSubmit();
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
this.handleChange = (event) => {
|
|
29
|
-
this.props.field.onChange(event);
|
|
30
|
-
if (this.props.saveOn === 'change') {
|
|
31
|
-
this.handleSubmit();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
componentWillUnmount() {
|
|
36
|
-
if (this.state.focused) {
|
|
37
|
-
this.handleSubmit();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
render() {
|
|
41
|
-
const { component: Component, field, placeholder, disabled, testId, } = this.props;
|
|
42
|
-
return ((0, jsx_runtime_1.jsx)(Component, { ...field, placeholder: placeholder, disabled: disabled, checked: !!field.value, onFocus: this.handleFocus, onBlur: this.handleBlur, onChange: this.handleChange, "data-testid": testId && `${testId}__input`, "aria-invalid": this.props.isInvalid || undefined }));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.AutoSaveInput = AutoSaveInput;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RichText = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const prosemirror_state_1 = require("prosemirror-state");
|
|
6
|
-
const prosemirror_view_1 = require("prosemirror-view");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const schema_1 = require("./schema");
|
|
9
|
-
const RichText = ({ className, value }) => {
|
|
10
|
-
const editorRef = (0, react_1.useRef)(null);
|
|
11
|
-
(0, react_1.useEffect)(() => {
|
|
12
|
-
const state = prosemirror_state_1.EditorState.create({
|
|
13
|
-
doc: (0, schema_1.parseRichText)(value),
|
|
14
|
-
schema: schema_1.schema,
|
|
15
|
-
});
|
|
16
|
-
const view = new prosemirror_view_1.EditorView(null, {
|
|
17
|
-
editable: () => false,
|
|
18
|
-
state,
|
|
19
|
-
});
|
|
20
|
-
editorRef.current && editorRef.current.replaceChildren(view.dom);
|
|
21
|
-
}, [value]);
|
|
22
|
-
return (0, jsx_runtime_1.jsx)("div", { className: className, ref: editorRef });
|
|
23
|
-
};
|
|
24
|
-
exports.RichText = RichText;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RichTextField = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const prosemirror_commands_1 = require("prosemirror-commands");
|
|
9
|
-
const prosemirror_history_1 = require("prosemirror-history");
|
|
10
|
-
const prosemirror_keymap_1 = require("prosemirror-keymap");
|
|
11
|
-
const prosemirror_state_1 = require("prosemirror-state");
|
|
12
|
-
const prosemirror_view_1 = require("prosemirror-view");
|
|
13
|
-
const react_1 = require("react");
|
|
14
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
15
|
-
const schema_1 = require("./schema");
|
|
16
|
-
const Container = styled_components_1.default.div `
|
|
17
|
-
& .ProseMirror {
|
|
18
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
19
|
-
font-size: ${(props) => props.theme.font.size.medium};
|
|
20
|
-
line-height: 1.25;
|
|
21
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
22
|
-
border-radius: ${(props) => props.theme.grid.radius.small};
|
|
23
|
-
border: 1px solid ${(props) => props.theme.colors.text.muted};
|
|
24
|
-
padding: ${(props) => props.theme.grid.unit * 2}px
|
|
25
|
-
${(props) => props.theme.grid.unit * 3}px;
|
|
26
|
-
|
|
27
|
-
&:focus {
|
|
28
|
-
outline: none;
|
|
29
|
-
border-color: ${(props) => props.theme.colors.border.field.hover};
|
|
30
|
-
background-color: ${(props) => props.theme.colors.background.fifth};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
const RichTextField = ({ value, onChange, }) => {
|
|
35
|
-
const editorRef = (0, react_1.useRef)(null);
|
|
36
|
-
(0, react_1.useEffect)(() => {
|
|
37
|
-
const dispatch = (view, tr) => {
|
|
38
|
-
const { state, transactions } = view.state.applyTransaction(tr);
|
|
39
|
-
view.updateState(state);
|
|
40
|
-
if (onChange && transactions.some((tr) => tr.docChanged)) {
|
|
41
|
-
const value = (0, schema_1.serializeRichText)(state.doc);
|
|
42
|
-
onChange(value);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const state = prosemirror_state_1.EditorState.create({
|
|
46
|
-
doc: (0, schema_1.parseRichText)(value),
|
|
47
|
-
plugins: [
|
|
48
|
-
(0, prosemirror_history_1.history)(),
|
|
49
|
-
(0, prosemirror_keymap_1.keymap)(prosemirror_commands_1.baseKeymap),
|
|
50
|
-
(0, prosemirror_keymap_1.keymap)({
|
|
51
|
-
'Mod-b': (0, prosemirror_commands_1.toggleMark)(schema_1.schema.marks.bold),
|
|
52
|
-
'Mod-i': (0, prosemirror_commands_1.toggleMark)(schema_1.schema.marks.italic),
|
|
53
|
-
'Mod-y': prosemirror_history_1.redo,
|
|
54
|
-
'Mod-z': prosemirror_history_1.undo,
|
|
55
|
-
}),
|
|
56
|
-
],
|
|
57
|
-
schema: schema_1.schema,
|
|
58
|
-
});
|
|
59
|
-
const view = new prosemirror_view_1.EditorView(null, {
|
|
60
|
-
editable: () => true,
|
|
61
|
-
state,
|
|
62
|
-
dispatchTransaction: (tr) => dispatch(view, tr),
|
|
63
|
-
});
|
|
64
|
-
editorRef.current && editorRef.current.appendChild(view.dom);
|
|
65
|
-
}, [value, onChange]);
|
|
66
|
-
return (0, jsx_runtime_1.jsx)(Container, { ref: editorRef });
|
|
67
|
-
};
|
|
68
|
-
exports.RichTextField = RichTextField;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RichTextField = exports.RichText = void 0;
|
|
4
|
-
var RichText_1 = require("./RichText");
|
|
5
|
-
Object.defineProperty(exports, "RichText", { enumerable: true, get: function () { return RichText_1.RichText; } });
|
|
6
|
-
var RichTextField_1 = require("./RichTextField");
|
|
7
|
-
Object.defineProperty(exports, "RichTextField", { enumerable: true, get: function () { return RichTextField_1.RichTextField; } });
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeRichText = exports.parseRichText = exports.schema = void 0;
|
|
4
|
-
const prosemirror_model_1 = require("prosemirror-model");
|
|
5
|
-
exports.schema = new prosemirror_model_1.Schema({
|
|
6
|
-
marks: {
|
|
7
|
-
bold: {
|
|
8
|
-
parseDOM: [
|
|
9
|
-
{
|
|
10
|
-
tag: 'b',
|
|
11
|
-
getAttrs: (dom) => dom.style.fontWeight !== 'normal' && null,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
tag: 'strong',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
style: 'font-weight',
|
|
18
|
-
getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null,
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
toDOM() {
|
|
22
|
-
return ['b'];
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
italic: {
|
|
26
|
-
parseDOM: [
|
|
27
|
-
{
|
|
28
|
-
tag: 'i',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
tag: 'em',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
style: 'font-style=italic',
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
toDOM() {
|
|
38
|
-
return ['i'];
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
smallcaps: {
|
|
42
|
-
parseDOM: [
|
|
43
|
-
{
|
|
44
|
-
style: 'font-variant=small-caps',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
style: 'font-variant-caps=small-caps',
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
toDOM: () => [
|
|
51
|
-
'span',
|
|
52
|
-
{
|
|
53
|
-
style: 'font-variant:small-caps',
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
subscript: {
|
|
58
|
-
excludes: 'superscript',
|
|
59
|
-
group: 'position',
|
|
60
|
-
parseDOM: [
|
|
61
|
-
{
|
|
62
|
-
tag: 'sub',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
style: 'vertical-align=sub',
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
toDOM: () => ['sub'],
|
|
69
|
-
},
|
|
70
|
-
superscript: {
|
|
71
|
-
excludes: 'subscript',
|
|
72
|
-
group: 'position',
|
|
73
|
-
parseDOM: [
|
|
74
|
-
{
|
|
75
|
-
tag: 'sup',
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
style: 'vertical-align=super',
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
toDOM: () => ['sup'],
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
nodes: {
|
|
85
|
-
text: {},
|
|
86
|
-
rich: {
|
|
87
|
-
content: 'text*',
|
|
88
|
-
marks: 'bold italic smallcaps subscript superscript',
|
|
89
|
-
parseDOM: [
|
|
90
|
-
{
|
|
91
|
-
tag: 'div',
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
toDOM: () => ['div', 0],
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
topNode: 'rich',
|
|
98
|
-
});
|
|
99
|
-
const parser = prosemirror_model_1.DOMParser.fromSchema(exports.schema);
|
|
100
|
-
const serializer = prosemirror_model_1.DOMSerializer.fromSchema(exports.schema);
|
|
101
|
-
const parseRichText = (value) => {
|
|
102
|
-
const node = document.createElement('div');
|
|
103
|
-
node.innerHTML = value;
|
|
104
|
-
return parser.parse(node);
|
|
105
|
-
};
|
|
106
|
-
exports.parseRichText = parseRichText;
|
|
107
|
-
const serializeRichText = (node) => {
|
|
108
|
-
const element = serializer.serializeNode(node);
|
|
109
|
-
return element.innerHTML;
|
|
110
|
-
};
|
|
111
|
-
exports.serializeRichText = serializeRichText;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TextFieldContainer = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const TextField_1 = require("./TextField");
|
|
10
|
-
const TextFieldError_1 = require("./TextFieldError");
|
|
11
|
-
const TextFieldContainer = ({ label, error, children }) => {
|
|
12
|
-
const childrenWithErrorProp = react_1.default.Children.map(children, (child) => react_1.default.cloneElement(child, { error: String(error) }));
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [label ? ((0, jsx_runtime_1.jsxs)(TextField_1.TextFieldLabel, { children: [label, " ", childrenWithErrorProp] })) : (childrenWithErrorProp), error && ((0, jsx_runtime_1.jsx)(TextFieldError_1.TextFieldError, { children: (0, jsx_runtime_1.jsx)(TextFieldError_1.TextFieldErrorItem, { children: error }) }))] }));
|
|
14
|
-
};
|
|
15
|
-
exports.TextFieldContainer = TextFieldContainer;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TextFieldError = exports.TextFieldErrorItem = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
const Arrow = styled_components_1.default.div `
|
|
10
|
-
width: 0;
|
|
11
|
-
height: 0;
|
|
12
|
-
position: absolute;
|
|
13
|
-
border: 5px solid transparent;
|
|
14
|
-
top: -5px;
|
|
15
|
-
left: calc(16px);
|
|
16
|
-
border-bottom-color: ${(props) => props.theme.colors.background.error};
|
|
17
|
-
border-top-width: 0;
|
|
18
|
-
margin: 0 5px;
|
|
19
|
-
`;
|
|
20
|
-
const Container = styled_components_1.default.div `
|
|
21
|
-
background: ${(props) => props.theme.colors.background.error};
|
|
22
|
-
border-radius: 2px;
|
|
23
|
-
color: ${(props) => props.theme.colors.text.error};
|
|
24
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
25
|
-
margin-top: 5px;
|
|
26
|
-
margin-bottom: 5px;
|
|
27
|
-
position: relative;
|
|
28
|
-
padding: 4px;
|
|
29
|
-
`;
|
|
30
|
-
exports.TextFieldErrorItem = styled_components_1.default.div `
|
|
31
|
-
margin: 8px;
|
|
32
|
-
`;
|
|
33
|
-
const TextFieldError = ({ children }) => ((0, jsx_runtime_1.jsxs)(Container, { children: [(0, jsx_runtime_1.jsx)(Arrow, {}), children] }));
|
|
34
|
-
exports.TextFieldError = TextFieldError;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextFieldGroupContainer = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const TextField_1 = require("./TextField");
|
|
6
|
-
const TextFieldError_1 = require("./TextFieldError");
|
|
7
|
-
const hasErrors = (errors) => Object.values(errors).some((error) => !!error);
|
|
8
|
-
const TextFieldGroupContainer = ({ children, errors }) => {
|
|
9
|
-
return ((0, jsx_runtime_1.jsxs)(TextField_1.TextFieldGroup, { children: [children, errors && hasErrors(errors) && ((0, jsx_runtime_1.jsx)(TextFieldError_1.TextFieldError, { children: Object.entries(errors).map(([key, error]) => error && ((0, jsx_runtime_1.jsx)(TextFieldError_1.TextFieldErrorItem, { id: `${key}-text-field-error`, children: error }, key))) }))] }));
|
|
10
|
-
};
|
|
11
|
-
exports.TextFieldGroupContainer = TextFieldGroupContainer;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2022 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.useDeepCompareCallback = exports.useDeepCompareMemo = void 0;
|
|
19
|
-
const lodash_1 = require("lodash");
|
|
20
|
-
const react_1 = require("react");
|
|
21
|
-
const useDeepCompare = (deps) => {
|
|
22
|
-
const ref = (0, react_1.useRef)(deps);
|
|
23
|
-
if (!(0, lodash_1.isEqual)(deps, ref.current)) {
|
|
24
|
-
ref.current = deps;
|
|
25
|
-
}
|
|
26
|
-
return ref.current;
|
|
27
|
-
};
|
|
28
|
-
const useDeepCompareMemo = (callback, deps) => (0, react_1.useMemo)(callback, [useDeepCompare(deps)]);
|
|
29
|
-
exports.useDeepCompareMemo = useDeepCompareMemo;
|
|
30
|
-
const useDeepCompareCallback = (callback, deps) => (0, react_1.useCallback)(callback, [useDeepCompare(deps)]);
|
|
31
|
-
exports.useDeepCompareCallback = useDeepCompareCallback;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export class AutoSaveInput extends React.Component {
|
|
4
|
-
constructor() {
|
|
5
|
-
super(...arguments);
|
|
6
|
-
this.state = {
|
|
7
|
-
focused: false,
|
|
8
|
-
};
|
|
9
|
-
this.handleSubmit = () => {
|
|
10
|
-
window.setTimeout(this.props.form.submitForm, 10);
|
|
11
|
-
};
|
|
12
|
-
this.handleFocus = () => {
|
|
13
|
-
this.setState({ focused: true });
|
|
14
|
-
};
|
|
15
|
-
this.handleBlur = (event) => {
|
|
16
|
-
this.setState({ focused: false });
|
|
17
|
-
this.props.field.onBlur(event);
|
|
18
|
-
if (this.props.saveOn === 'blur') {
|
|
19
|
-
this.handleSubmit();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
this.handleChange = (event) => {
|
|
23
|
-
this.props.field.onChange(event);
|
|
24
|
-
if (this.props.saveOn === 'change') {
|
|
25
|
-
this.handleSubmit();
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
componentWillUnmount() {
|
|
30
|
-
if (this.state.focused) {
|
|
31
|
-
this.handleSubmit();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
render() {
|
|
35
|
-
const { component: Component, field, placeholder, disabled, testId, } = this.props;
|
|
36
|
-
return (_jsx(Component, { ...field, placeholder: placeholder, disabled: disabled, checked: !!field.value, onFocus: this.handleFocus, onBlur: this.handleBlur, onChange: this.handleChange, "data-testid": testId && `${testId}__input`, "aria-invalid": this.props.isInvalid || undefined }));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { EditorState } from 'prosemirror-state';
|
|
3
|
-
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
import { useEffect, useRef } from 'react';
|
|
5
|
-
import { parseRichText, schema } from './schema';
|
|
6
|
-
export const RichText = ({ className, value }) => {
|
|
7
|
-
const editorRef = useRef(null);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
const state = EditorState.create({
|
|
10
|
-
doc: parseRichText(value),
|
|
11
|
-
schema,
|
|
12
|
-
});
|
|
13
|
-
const view = new EditorView(null, {
|
|
14
|
-
editable: () => false,
|
|
15
|
-
state,
|
|
16
|
-
});
|
|
17
|
-
editorRef.current && editorRef.current.replaceChildren(view.dom);
|
|
18
|
-
}, [value]);
|
|
19
|
-
return _jsx("div", { className: className, ref: editorRef });
|
|
20
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { baseKeymap, toggleMark } from 'prosemirror-commands';
|
|
3
|
-
import { history, redo, undo } from 'prosemirror-history';
|
|
4
|
-
import { keymap } from 'prosemirror-keymap';
|
|
5
|
-
import { EditorState } from 'prosemirror-state';
|
|
6
|
-
import { EditorView } from 'prosemirror-view';
|
|
7
|
-
import { useEffect, useRef } from 'react';
|
|
8
|
-
import styled from 'styled-components';
|
|
9
|
-
import { parseRichText, schema, serializeRichText } from './schema';
|
|
10
|
-
const Container = styled.div `
|
|
11
|
-
& .ProseMirror {
|
|
12
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
13
|
-
font-size: ${(props) => props.theme.font.size.medium};
|
|
14
|
-
line-height: 1.25;
|
|
15
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
16
|
-
border-radius: ${(props) => props.theme.grid.radius.small};
|
|
17
|
-
border: 1px solid ${(props) => props.theme.colors.text.muted};
|
|
18
|
-
padding: ${(props) => props.theme.grid.unit * 2}px
|
|
19
|
-
${(props) => props.theme.grid.unit * 3}px;
|
|
20
|
-
|
|
21
|
-
&:focus {
|
|
22
|
-
outline: none;
|
|
23
|
-
border-color: ${(props) => props.theme.colors.border.field.hover};
|
|
24
|
-
background-color: ${(props) => props.theme.colors.background.fifth};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
export const RichTextField = ({ value, onChange, }) => {
|
|
29
|
-
const editorRef = useRef(null);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const dispatch = (view, tr) => {
|
|
32
|
-
const { state, transactions } = view.state.applyTransaction(tr);
|
|
33
|
-
view.updateState(state);
|
|
34
|
-
if (onChange && transactions.some((tr) => tr.docChanged)) {
|
|
35
|
-
const value = serializeRichText(state.doc);
|
|
36
|
-
onChange(value);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const state = EditorState.create({
|
|
40
|
-
doc: parseRichText(value),
|
|
41
|
-
plugins: [
|
|
42
|
-
history(),
|
|
43
|
-
keymap(baseKeymap),
|
|
44
|
-
keymap({
|
|
45
|
-
'Mod-b': toggleMark(schema.marks.bold),
|
|
46
|
-
'Mod-i': toggleMark(schema.marks.italic),
|
|
47
|
-
'Mod-y': redo,
|
|
48
|
-
'Mod-z': undo,
|
|
49
|
-
}),
|
|
50
|
-
],
|
|
51
|
-
schema,
|
|
52
|
-
});
|
|
53
|
-
const view = new EditorView(null, {
|
|
54
|
-
editable: () => true,
|
|
55
|
-
state,
|
|
56
|
-
dispatchTransaction: (tr) => dispatch(view, tr),
|
|
57
|
-
});
|
|
58
|
-
editorRef.current && editorRef.current.appendChild(view.dom);
|
|
59
|
-
}, [value, onChange]);
|
|
60
|
-
return _jsx(Container, { ref: editorRef });
|
|
61
|
-
};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { DOMParser, DOMSerializer, Schema, } from 'prosemirror-model';
|
|
2
|
-
export const schema = new Schema({
|
|
3
|
-
marks: {
|
|
4
|
-
bold: {
|
|
5
|
-
parseDOM: [
|
|
6
|
-
{
|
|
7
|
-
tag: 'b',
|
|
8
|
-
getAttrs: (dom) => dom.style.fontWeight !== 'normal' && null,
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
tag: 'strong',
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
style: 'font-weight',
|
|
15
|
-
getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null,
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
toDOM() {
|
|
19
|
-
return ['b'];
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
italic: {
|
|
23
|
-
parseDOM: [
|
|
24
|
-
{
|
|
25
|
-
tag: 'i',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
tag: 'em',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
style: 'font-style=italic',
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
toDOM() {
|
|
35
|
-
return ['i'];
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
smallcaps: {
|
|
39
|
-
parseDOM: [
|
|
40
|
-
{
|
|
41
|
-
style: 'font-variant=small-caps',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
style: 'font-variant-caps=small-caps',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
toDOM: () => [
|
|
48
|
-
'span',
|
|
49
|
-
{
|
|
50
|
-
style: 'font-variant:small-caps',
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
subscript: {
|
|
55
|
-
excludes: 'superscript',
|
|
56
|
-
group: 'position',
|
|
57
|
-
parseDOM: [
|
|
58
|
-
{
|
|
59
|
-
tag: 'sub',
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
style: 'vertical-align=sub',
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
toDOM: () => ['sub'],
|
|
66
|
-
},
|
|
67
|
-
superscript: {
|
|
68
|
-
excludes: 'subscript',
|
|
69
|
-
group: 'position',
|
|
70
|
-
parseDOM: [
|
|
71
|
-
{
|
|
72
|
-
tag: 'sup',
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
style: 'vertical-align=super',
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
toDOM: () => ['sup'],
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
nodes: {
|
|
82
|
-
text: {},
|
|
83
|
-
rich: {
|
|
84
|
-
content: 'text*',
|
|
85
|
-
marks: 'bold italic smallcaps subscript superscript',
|
|
86
|
-
parseDOM: [
|
|
87
|
-
{
|
|
88
|
-
tag: 'div',
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
toDOM: () => ['div', 0],
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
topNode: 'rich',
|
|
95
|
-
});
|
|
96
|
-
const parser = DOMParser.fromSchema(schema);
|
|
97
|
-
const serializer = DOMSerializer.fromSchema(schema);
|
|
98
|
-
export const parseRichText = (value) => {
|
|
99
|
-
const node = document.createElement('div');
|
|
100
|
-
node.innerHTML = value;
|
|
101
|
-
return parser.parse(node);
|
|
102
|
-
};
|
|
103
|
-
export const serializeRichText = (node) => {
|
|
104
|
-
const element = serializer.serializeNode(node);
|
|
105
|
-
return element.innerHTML;
|
|
106
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { TextFieldLabel } from './TextField';
|
|
4
|
-
import { TextFieldError, TextFieldErrorItem } from './TextFieldError';
|
|
5
|
-
export const TextFieldContainer = ({ label, error, children }) => {
|
|
6
|
-
const childrenWithErrorProp = React.Children.map(children, (child) => React.cloneElement(child, { error: String(error) }));
|
|
7
|
-
return (_jsxs(React.Fragment, { children: [label ? (_jsxs(TextFieldLabel, { children: [label, " ", childrenWithErrorProp] })) : (childrenWithErrorProp), error && (_jsx(TextFieldError, { children: _jsx(TextFieldErrorItem, { children: error }) }))] }));
|
|
8
|
-
};
|