drf-react-by-schema 0.28.23 → 0.28.25
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/@types/index.d.ts +2 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/api.d.ts +2 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +16 -8
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.js +1 -4
- package/dist/components/HtmlContent.d.ts +13 -0
- package/dist/components/HtmlContent.d.ts.map +1 -0
- package/dist/components/HtmlContent.js +148 -0
- package/dist/components/details/DetailFieldBySchema.d.ts.map +1 -1
- package/dist/components/details/DetailFieldBySchema.js +7 -0
- package/dist/components/forms/FieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/FieldBySchema.js +5 -0
- package/dist/components/forms/FormBySchema.d.ts.map +1 -1
- package/dist/components/forms/FormBySchema.js +12 -1
- package/dist/components/forms/inputs/HtmlFieldBySchema.d.ts +9 -0
- package/dist/components/forms/inputs/HtmlFieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/HtmlFieldBySchema.js +55 -0
- package/dist/components/forms/inputs/RichTextEditorInput.d.ts +24 -0
- package/dist/components/forms/inputs/RichTextEditorInput.d.ts.map +1 -0
- package/dist/components/forms/inputs/RichTextEditorInput.js +252 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/styles/texts.d.ts +25 -0
- package/dist/styles/texts.d.ts.map +1 -1
- package/dist/styles/texts.js +25 -0
- package/dist/utils/utils.d.ts +23 -0
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +88 -2
- package/package.json +20 -3
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = RichTextEditorInput;
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const styles_1 = require("@mui/material/styles");
|
|
42
|
+
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
43
|
+
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
44
|
+
const Dialog_1 = __importDefault(require("@mui/material/Dialog"));
|
|
45
|
+
const DialogActions_1 = __importDefault(require("@mui/material/DialogActions"));
|
|
46
|
+
const DialogContent_1 = __importDefault(require("@mui/material/DialogContent"));
|
|
47
|
+
const DialogTitle_1 = __importDefault(require("@mui/material/DialogTitle"));
|
|
48
|
+
const FormControl_1 = __importDefault(require("@mui/material/FormControl"));
|
|
49
|
+
const FormHelperText_1 = __importDefault(require("@mui/material/FormHelperText"));
|
|
50
|
+
const MenuItem_1 = __importDefault(require("@mui/material/MenuItem"));
|
|
51
|
+
const Select_1 = __importDefault(require("@mui/material/Select"));
|
|
52
|
+
const Stack_1 = __importDefault(require("@mui/material/Stack"));
|
|
53
|
+
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
54
|
+
const ToggleButton_1 = __importDefault(require("@mui/material/ToggleButton"));
|
|
55
|
+
const Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
56
|
+
const Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
57
|
+
const FormatBold_1 = __importDefault(require("@mui/icons-material/FormatBold"));
|
|
58
|
+
const FormatItalic_1 = __importDefault(require("@mui/icons-material/FormatItalic"));
|
|
59
|
+
const FormatUnderlined_1 = __importDefault(require("@mui/icons-material/FormatUnderlined"));
|
|
60
|
+
const StrikethroughS_1 = __importDefault(require("@mui/icons-material/StrikethroughS"));
|
|
61
|
+
const FormatListBulleted_1 = __importDefault(require("@mui/icons-material/FormatListBulleted"));
|
|
62
|
+
const FormatListNumbered_1 = __importDefault(require("@mui/icons-material/FormatListNumbered"));
|
|
63
|
+
const FormatQuote_1 = __importDefault(require("@mui/icons-material/FormatQuote"));
|
|
64
|
+
const Code_1 = __importDefault(require("@mui/icons-material/Code"));
|
|
65
|
+
const Link_1 = __importDefault(require("@mui/icons-material/Link"));
|
|
66
|
+
const LinkOff_1 = __importDefault(require("@mui/icons-material/LinkOff"));
|
|
67
|
+
const Undo_1 = __importDefault(require("@mui/icons-material/Undo"));
|
|
68
|
+
const Redo_1 = __importDefault(require("@mui/icons-material/Redo"));
|
|
69
|
+
const FormatClear_1 = __importDefault(require("@mui/icons-material/FormatClear"));
|
|
70
|
+
const HorizontalRule_1 = __importDefault(require("@mui/icons-material/HorizontalRule"));
|
|
71
|
+
const texts_1 = require("../../../styles/texts");
|
|
72
|
+
const editorSx = {
|
|
73
|
+
px: 2,
|
|
74
|
+
py: 1.5,
|
|
75
|
+
minHeight: 160,
|
|
76
|
+
'& .ProseMirror': { outline: 'none', minHeight: 140 },
|
|
77
|
+
'& .ProseMirror > * + *': { mt: 1 },
|
|
78
|
+
'& .ProseMirror p': { m: 0 },
|
|
79
|
+
'& .ProseMirror h1': { typography: 'h5', m: 0 },
|
|
80
|
+
'& .ProseMirror h2': { typography: 'h6', m: 0 },
|
|
81
|
+
'& .ProseMirror h3': { typography: 'subtitle1', m: 0 },
|
|
82
|
+
'& .ProseMirror ul, & .ProseMirror ol': { pl: 3, my: 0 },
|
|
83
|
+
'& .ProseMirror blockquote': {
|
|
84
|
+
borderLeft: 3,
|
|
85
|
+
borderColor: 'divider',
|
|
86
|
+
pl: 2,
|
|
87
|
+
ml: 0,
|
|
88
|
+
color: 'text.secondary',
|
|
89
|
+
},
|
|
90
|
+
'& .ProseMirror pre': {
|
|
91
|
+
p: 1,
|
|
92
|
+
borderRadius: 1,
|
|
93
|
+
backgroundColor: 'action.hover',
|
|
94
|
+
overflowX: 'auto',
|
|
95
|
+
},
|
|
96
|
+
'& .ProseMirror a': { color: 'primary.main', textDecoration: 'underline' },
|
|
97
|
+
'& .ProseMirror hr': { border: 0, borderTop: 1, borderColor: 'divider' },
|
|
98
|
+
};
|
|
99
|
+
/** Empty editor content comes back as `<p></p>`; the form expects an empty string. */
|
|
100
|
+
function normalizeHtml(value) {
|
|
101
|
+
const html = (value !== null && value !== void 0 ? value : '').trim();
|
|
102
|
+
return html === '<p></p>' ? '' : html;
|
|
103
|
+
}
|
|
104
|
+
function Toolbar({ editor, disabled, texts }) {
|
|
105
|
+
const [linkOpen, setLinkOpen] = (0, react_1.useState)(false);
|
|
106
|
+
const [linkUrl, setLinkUrl] = (0, react_1.useState)('');
|
|
107
|
+
if (!editor) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const isActive = (name, attrs) => editor.isActive(name, attrs);
|
|
111
|
+
const blockValue = isActive('heading', { level: 1 })
|
|
112
|
+
? 'h1'
|
|
113
|
+
: isActive('heading', { level: 2 })
|
|
114
|
+
? 'h2'
|
|
115
|
+
: isActive('heading', { level: 3 })
|
|
116
|
+
? 'h3'
|
|
117
|
+
: 'p';
|
|
118
|
+
const setBlock = (value) => {
|
|
119
|
+
const chain = editor.chain().focus();
|
|
120
|
+
if (value === 'p') {
|
|
121
|
+
chain.setParagraph().run();
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
chain.setHeading({ level: Number(value.slice(1)) }).run();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const openLinkDialog = () => {
|
|
128
|
+
setLinkUrl(editor.getAttributes('link').href || '');
|
|
129
|
+
setLinkOpen(true);
|
|
130
|
+
};
|
|
131
|
+
const applyLink = () => {
|
|
132
|
+
const href = linkUrl.trim();
|
|
133
|
+
if (!href) {
|
|
134
|
+
editor.chain().focus().extendMarkRange('link').unsetLink().run();
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
editor.chain().focus().extendMarkRange('link').setLink({ href }).run();
|
|
138
|
+
}
|
|
139
|
+
setLinkOpen(false);
|
|
140
|
+
};
|
|
141
|
+
const button = (title, icon, active, onClick, activeValue = title) => (react_1.default.createElement(Tooltip_1.default, { title: title, key: title },
|
|
142
|
+
react_1.default.createElement("span", null,
|
|
143
|
+
react_1.default.createElement(ToggleButton_1.default, { value: activeValue, size: "small", selected: active, disabled: disabled, onChange: onClick, sx: { border: 0, borderRadius: 1, p: 0.5 } }, icon))));
|
|
144
|
+
return (react_1.default.createElement(Stack_1.default, { direction: "row", flexWrap: "wrap", alignItems: "center", gap: 0.25, sx: {
|
|
145
|
+
p: 0.5,
|
|
146
|
+
borderBottom: 1,
|
|
147
|
+
borderColor: 'divider',
|
|
148
|
+
backgroundColor: 'action.hover',
|
|
149
|
+
} },
|
|
150
|
+
react_1.default.createElement(FormControl_1.default, { size: "small", variant: "standard", sx: { minWidth: 110, mx: 0.5 } },
|
|
151
|
+
react_1.default.createElement(Select_1.default, { value: blockValue, disabled: disabled, disableUnderline: true, onChange: (event) => setBlock(event.target.value), inputProps: { 'aria-label': texts.paragraph }, sx: { fontSize: '0.8rem' } },
|
|
152
|
+
react_1.default.createElement(MenuItem_1.default, { value: "p" }, texts.paragraph),
|
|
153
|
+
react_1.default.createElement(MenuItem_1.default, { value: "h1" }, texts.heading1),
|
|
154
|
+
react_1.default.createElement(MenuItem_1.default, { value: "h2" }, texts.heading2),
|
|
155
|
+
react_1.default.createElement(MenuItem_1.default, { value: "h3" }, texts.heading3))),
|
|
156
|
+
button(texts.bold, react_1.default.createElement(FormatBold_1.default, { fontSize: "small" }), isActive('bold'), () => editor.chain().focus().toggleBold().run()),
|
|
157
|
+
button(texts.italic, react_1.default.createElement(FormatItalic_1.default, { fontSize: "small" }), isActive('italic'), () => editor.chain().focus().toggleItalic().run()),
|
|
158
|
+
button(texts.underline, react_1.default.createElement(FormatUnderlined_1.default, { fontSize: "small" }), isActive('underline'), () => editor.chain().focus().toggleUnderline().run()),
|
|
159
|
+
button(texts.strike, react_1.default.createElement(StrikethroughS_1.default, { fontSize: "small" }), isActive('strike'), () => editor.chain().focus().toggleStrike().run()),
|
|
160
|
+
button(texts.bulletList, react_1.default.createElement(FormatListBulleted_1.default, { fontSize: "small" }), isActive('bulletList'), () => editor.chain().focus().toggleBulletList().run()),
|
|
161
|
+
button(texts.orderedList, react_1.default.createElement(FormatListNumbered_1.default, { fontSize: "small" }), isActive('orderedList'), () => editor.chain().focus().toggleOrderedList().run()),
|
|
162
|
+
button(texts.blockquote, react_1.default.createElement(FormatQuote_1.default, { fontSize: "small" }), isActive('blockquote'), () => editor.chain().focus().toggleBlockquote().run()),
|
|
163
|
+
button(texts.codeBlock, react_1.default.createElement(Code_1.default, { fontSize: "small" }), isActive('codeBlock'), () => editor.chain().focus().toggleCodeBlock().run()),
|
|
164
|
+
button(texts.horizontalRule, react_1.default.createElement(HorizontalRule_1.default, { fontSize: "small" }), false, () => editor.chain().focus().setHorizontalRule().run()),
|
|
165
|
+
button(texts.link, react_1.default.createElement(Link_1.default, { fontSize: "small" }), isActive('link'), openLinkDialog),
|
|
166
|
+
button(texts.clearFormatting, react_1.default.createElement(FormatClear_1.default, { fontSize: "small" }), false, () => editor.chain().focus().unsetAllMarks().clearNodes().run()),
|
|
167
|
+
button(texts.undo, react_1.default.createElement(Undo_1.default, { fontSize: "small" }), false, () => editor.chain().focus().undo().run(), 'undo'),
|
|
168
|
+
button(texts.redo, react_1.default.createElement(Redo_1.default, { fontSize: "small" }), false, () => editor.chain().focus().redo().run(), 'redo'),
|
|
169
|
+
button(texts.linkRemove, react_1.default.createElement(LinkOff_1.default, { fontSize: "small" }), false, () => editor.chain().focus().extendMarkRange('link').unsetLink().run(), 'unlink'),
|
|
170
|
+
react_1.default.createElement(Dialog_1.default, { open: linkOpen, onClose: () => setLinkOpen(false), fullWidth: true, maxWidth: "xs" },
|
|
171
|
+
react_1.default.createElement(DialogTitle_1.default, null, texts.linkTitle),
|
|
172
|
+
react_1.default.createElement(DialogContent_1.default, null,
|
|
173
|
+
react_1.default.createElement(TextField_1.default, { autoFocus: true, fullWidth: true, margin: "dense", label: texts.linkUrl, value: linkUrl, onChange: (event) => setLinkUrl(event.target.value), onKeyDown: (event) => {
|
|
174
|
+
if (event.key === 'Enter') {
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
applyLink();
|
|
177
|
+
}
|
|
178
|
+
} })),
|
|
179
|
+
react_1.default.createElement(DialogActions_1.default, null,
|
|
180
|
+
react_1.default.createElement(Button_1.default, { onClick: () => setLinkOpen(false) }, texts.linkCancel),
|
|
181
|
+
react_1.default.createElement(Button_1.default, { variant: "contained", onClick: applyLink }, texts.linkApply)))));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* WYSIWYG editor for `model_html` fields: Tiptap with an MUI toolbar. The value
|
|
185
|
+
* is HTML, the same format the Django admin (Summernote) writes to the column.
|
|
186
|
+
*/
|
|
187
|
+
function RichTextEditorInput({ libraries, id, label, required, disabled, error, helperText, value, onChange, onBlur, sx = { mt: 2, mb: 1 }, autoFocus, }) {
|
|
188
|
+
const theme = (0, styles_1.useTheme)();
|
|
189
|
+
const texts = (0, react_1.useMemo)(() => (0, texts_1.getThemeTexts)(theme).richText, [theme]);
|
|
190
|
+
// Toolbar state depends on the current selection, which is not a React state.
|
|
191
|
+
const [, setTick] = (0, react_1.useState)(0);
|
|
192
|
+
const refreshToolbar = () => setTick((tick) => tick + 1);
|
|
193
|
+
const onChangeRef = (0, react_1.useRef)(onChange);
|
|
194
|
+
onChangeRef.current = onChange;
|
|
195
|
+
const { useEditor, EditorContent, StarterKit } = libraries;
|
|
196
|
+
const editor = useEditor({
|
|
197
|
+
extensions: [StarterKit.configure({ link: { openOnClick: false } })],
|
|
198
|
+
content: normalizeHtml(value),
|
|
199
|
+
editable: !disabled,
|
|
200
|
+
onUpdate: ({ editor: current }) => {
|
|
201
|
+
onChangeRef.current(current.isEmpty ? '' : current.getHTML());
|
|
202
|
+
},
|
|
203
|
+
onSelectionUpdate: () => refreshToolbar(),
|
|
204
|
+
});
|
|
205
|
+
// Keep the editor in sync when the form value changes from the outside
|
|
206
|
+
// (e.g. loading an existing record), without emitting an update back.
|
|
207
|
+
(0, react_1.useEffect)(() => {
|
|
208
|
+
if (!editor) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const incoming = normalizeHtml(value);
|
|
212
|
+
if (incoming === normalizeHtml(editor.getHTML())) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
editor.commands.setContent(incoming, { emitUpdate: false });
|
|
216
|
+
}, [editor, value]);
|
|
217
|
+
(0, react_1.useEffect)(() => {
|
|
218
|
+
if (editor) {
|
|
219
|
+
editor.setEditable(!disabled);
|
|
220
|
+
}
|
|
221
|
+
}, [editor, disabled]);
|
|
222
|
+
(0, react_1.useEffect)(() => {
|
|
223
|
+
if (editor && autoFocus) {
|
|
224
|
+
editor.commands.focus('end');
|
|
225
|
+
}
|
|
226
|
+
}, [editor, autoFocus]);
|
|
227
|
+
if (!editor) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
return (react_1.default.createElement(Box_1.default, { sx: sx },
|
|
231
|
+
label && (react_1.default.createElement(Typography_1.default, { component: "label", htmlFor: id, variant: "caption", sx: {
|
|
232
|
+
display: 'block',
|
|
233
|
+
fontWeight: 600,
|
|
234
|
+
mb: 0.5,
|
|
235
|
+
color: error ? 'error.main' : 'text.secondary',
|
|
236
|
+
} },
|
|
237
|
+
label,
|
|
238
|
+
required ? ' *' : '')),
|
|
239
|
+
react_1.default.createElement(Box_1.default, { onBlur: onBlur, sx: {
|
|
240
|
+
border: 1,
|
|
241
|
+
borderColor: error ? 'error.main' : 'divider',
|
|
242
|
+
borderRadius: 1,
|
|
243
|
+
backgroundColor: disabled ? 'action.disabledBackground' : 'background.paper',
|
|
244
|
+
'&:focus-within': {
|
|
245
|
+
borderColor: error ? 'error.main' : 'primary.main',
|
|
246
|
+
},
|
|
247
|
+
} },
|
|
248
|
+
react_1.default.createElement(Toolbar, { editor: editor, disabled: disabled, texts: texts }),
|
|
249
|
+
react_1.default.createElement(Box_1.default, { sx: editorSx },
|
|
250
|
+
react_1.default.createElement(EditorContent, { editor: editor, id: id }))),
|
|
251
|
+
helperText && react_1.default.createElement(FormHelperText_1.default, { error: error }, helperText)));
|
|
252
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { setAuthToken, hasJWT, clearJWT, AUTH_EXPIRED_EVENT } from './api';
|
|
2
|
-
import { emptyByType, getChoiceByValue, populateValues, enrichChoices, buildGenericYupValidationSchema, errorProps, getFieldErrorsFromResponse, getTmpId, isTmpId, getPatternFormat, slugToCamelCase } from './utils';
|
|
1
|
+
import { setAuthToken, hasJWT, clearJWT, AUTH_EXPIRED_EVENT, getDataGridColumns } from './api';
|
|
2
|
+
import { emptyByType, getChoiceByValue, populateValues, enrichChoices, buildGenericYupValidationSchema, errorProps, getFieldErrorsFromResponse, getTmpId, isTmpId, getPatternFormat, slugToCamelCase, isReadOnlyField, isRelationField } from './utils';
|
|
3
3
|
import DRFReactBySchemaProvider from './context/DRFReactBySchemaProvider';
|
|
4
4
|
import { useAPIWrapper } from './context/APIWrapperContext';
|
|
5
5
|
import Form from './components/forms/Form';
|
|
@@ -21,6 +21,8 @@ import FormWatcher from './components/forms/FormWatcher';
|
|
|
21
21
|
import FormBySchema from './components/forms/FormBySchema';
|
|
22
22
|
import FieldBySchema from './components/forms/FieldBySchema';
|
|
23
23
|
import TextFieldBySchema from './components/forms/inputs/TextFieldBySchema';
|
|
24
|
+
import HtmlFieldBySchema from './components/forms/inputs/HtmlFieldBySchema';
|
|
25
|
+
import HtmlContent from './components/HtmlContent';
|
|
24
26
|
import BooleanFieldBySchema from './components/forms/inputs/BooleanFieldBySchema';
|
|
25
27
|
import DesktopDatePickerBySchema from './components/forms/inputs/DesktopDatePickerBySchema';
|
|
26
28
|
import DesktopDateTimePickerBySchema from './components/forms/inputs/DesktopDateTimePickerBySchema';
|
|
@@ -30,9 +32,9 @@ import FloatFieldBySchema from './components/forms/inputs/FloatFieldBySchema';
|
|
|
30
32
|
export { applyDefaultLeafletIcon, applyThemeMarkerIcon, DRF_REACT_BY_SCHEMA_MARKER_ICON, } from './components/forms/inputs/leafletMarker';
|
|
31
33
|
export { DEFAULT_LAYERS } from './components/forms/inputs/MapGeometryPicker';
|
|
32
34
|
export { getThemeTexts } from './styles/texts';
|
|
33
|
-
export type { DRFReactBySchemaTexts, GeometryTexts, FormTexts, AuthTexts } from './styles/texts';
|
|
35
|
+
export type { DRFReactBySchemaTexts, GeometryTexts, FormTexts, AuthTexts, RichTextTexts, } from './styles/texts';
|
|
34
36
|
import DetailBySchema from './components/details/DetailBySchema';
|
|
35
37
|
import DetailFieldBySchema from './components/details/DetailFieldBySchema';
|
|
36
|
-
export { DRFReactBySchemaProvider, useAPIWrapper, Form, DialogFormBySchema, ChangePasswordForm, ForgotPasswordForm, DataGridBySchemaEditable, GenericModelList, GenericRelatedModelList, DataTotals, DialogActions, FileTypeIcon, SelectEditInputCell, GridDateInput, GridDecimalInput, GridPatternInput, BooleanInputCell, FormWatcher, FormBySchema, FieldBySchema, TextFieldBySchema, BooleanFieldBySchema, DesktopDatePickerBySchema, DesktopDateTimePickerBySchema, EditableAutocompleteFieldBySchema, AutocompleteFieldBySchema, FloatFieldBySchema, DetailBySchema, DetailFieldBySchema, setAuthToken, emptyByType, getChoiceByValue, populateValues, enrichChoices, buildGenericYupValidationSchema, errorProps, getFieldErrorsFromResponse, getTmpId, isTmpId, getPatternFormat, clearJWT, hasJWT, slugToCamelCase, AUTH_EXPIRED_EVENT, };
|
|
38
|
+
export { DRFReactBySchemaProvider, useAPIWrapper, Form, DialogFormBySchema, ChangePasswordForm, ForgotPasswordForm, DataGridBySchemaEditable, GenericModelList, GenericRelatedModelList, DataTotals, DialogActions, FileTypeIcon, HtmlContent, SelectEditInputCell, GridDateInput, GridDecimalInput, GridPatternInput, BooleanInputCell, FormWatcher, FormBySchema, FieldBySchema, TextFieldBySchema, HtmlFieldBySchema, BooleanFieldBySchema, DesktopDatePickerBySchema, DesktopDateTimePickerBySchema, EditableAutocompleteFieldBySchema, AutocompleteFieldBySchema, FloatFieldBySchema, DetailBySchema, DetailFieldBySchema, setAuthToken, emptyByType, getChoiceByValue, populateValues, enrichChoices, buildGenericYupValidationSchema, getDataGridColumns, errorProps, getFieldErrorsFromResponse, getTmpId, isTmpId, isReadOnlyField, isRelationField, getPatternFormat, clearJWT, hasJWT, slugToCamelCase, AUTH_EXPIRED_EVENT, };
|
|
37
39
|
export * from './@types/index';
|
|
38
40
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC/F,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,+BAA+B,EAC/B,UAAU,EACV,0BAA0B,EAC1B,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,wBAAwB,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AACvE,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AACvE,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AAGvE,OAAO,wBAAwB,MAAM,uCAAuC,CAAC;AAC7E,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,uBAAuB,MAAM,sCAAsC,CAAC;AAC3E,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,YAAY,MAAM,2BA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AGb,YAAY,EACZ,WAAW,EAGX,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAGhB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,6BAA6B,EAC7B,iCAAiC,EACjC,yBAAyB,EACzB,kBAAkB,EAGlB,cAAc,EACd,mBAAmB,EAGnB,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,+BAA+B,EAC/B,kBAAkB,EAClB,UAAU,EACV,0BAA0B,EAC1B,QAAQ,EACR,OAAO,EACP,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,eAAe,EACf,kBAAkB,GACnB,CAAC;AAEF,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,13 +17,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.getPatternFormat = exports.isRelationField = exports.isReadOnlyField = exports.isTmpId = exports.getTmpId = exports.getFieldErrorsFromResponse = exports.errorProps = exports.getDataGridColumns = exports.buildGenericYupValidationSchema = exports.enrichChoices = exports.populateValues = exports.getChoiceByValue = exports.emptyByType = exports.setAuthToken = exports.DetailFieldBySchema = exports.DetailBySchema = exports.FloatFieldBySchema = exports.AutocompleteFieldBySchema = exports.EditableAutocompleteFieldBySchema = exports.DesktopDateTimePickerBySchema = exports.DesktopDatePickerBySchema = exports.BooleanFieldBySchema = exports.HtmlFieldBySchema = exports.TextFieldBySchema = exports.FieldBySchema = exports.FormBySchema = exports.FormWatcher = exports.BooleanInputCell = exports.GridPatternInput = exports.GridDecimalInput = exports.GridDateInput = exports.SelectEditInputCell = exports.HtmlContent = exports.FileTypeIcon = exports.DialogActions = exports.DataTotals = exports.GenericRelatedModelList = exports.GenericModelList = exports.DataGridBySchemaEditable = exports.ForgotPasswordForm = exports.ChangePasswordForm = exports.DialogFormBySchema = exports.Form = exports.useAPIWrapper = exports.DRFReactBySchemaProvider = exports.getThemeTexts = exports.DEFAULT_LAYERS = exports.DRF_REACT_BY_SCHEMA_MARKER_ICON = exports.applyThemeMarkerIcon = exports.applyDefaultLeafletIcon = void 0;
|
|
21
|
+
exports.AUTH_EXPIRED_EVENT = exports.slugToCamelCase = exports.hasJWT = exports.clearJWT = void 0;
|
|
21
22
|
// Methods:
|
|
22
23
|
const api_1 = require("./api");
|
|
23
24
|
Object.defineProperty(exports, "setAuthToken", { enumerable: true, get: function () { return api_1.setAuthToken; } });
|
|
24
25
|
Object.defineProperty(exports, "hasJWT", { enumerable: true, get: function () { return api_1.hasJWT; } });
|
|
25
26
|
Object.defineProperty(exports, "clearJWT", { enumerable: true, get: function () { return api_1.clearJWT; } });
|
|
26
27
|
Object.defineProperty(exports, "AUTH_EXPIRED_EVENT", { enumerable: true, get: function () { return api_1.AUTH_EXPIRED_EVENT; } });
|
|
28
|
+
Object.defineProperty(exports, "getDataGridColumns", { enumerable: true, get: function () { return api_1.getDataGridColumns; } });
|
|
27
29
|
const utils_1 = require("./utils");
|
|
28
30
|
Object.defineProperty(exports, "emptyByType", { enumerable: true, get: function () { return utils_1.emptyByType; } });
|
|
29
31
|
Object.defineProperty(exports, "getChoiceByValue", { enumerable: true, get: function () { return utils_1.getChoiceByValue; } });
|
|
@@ -36,6 +38,8 @@ Object.defineProperty(exports, "getTmpId", { enumerable: true, get: function ()
|
|
|
36
38
|
Object.defineProperty(exports, "isTmpId", { enumerable: true, get: function () { return utils_1.isTmpId; } });
|
|
37
39
|
Object.defineProperty(exports, "getPatternFormat", { enumerable: true, get: function () { return utils_1.getPatternFormat; } });
|
|
38
40
|
Object.defineProperty(exports, "slugToCamelCase", { enumerable: true, get: function () { return utils_1.slugToCamelCase; } });
|
|
41
|
+
Object.defineProperty(exports, "isReadOnlyField", { enumerable: true, get: function () { return utils_1.isReadOnlyField; } });
|
|
42
|
+
Object.defineProperty(exports, "isRelationField", { enumerable: true, get: function () { return utils_1.isRelationField; } });
|
|
39
43
|
// Overall Provider:
|
|
40
44
|
const DRFReactBySchemaProvider_1 = __importDefault(require("./context/DRFReactBySchemaProvider"));
|
|
41
45
|
exports.DRFReactBySchemaProvider = DRFReactBySchemaProvider_1.default;
|
|
@@ -84,6 +88,10 @@ const FieldBySchema_1 = __importDefault(require("./components/forms/FieldBySchem
|
|
|
84
88
|
exports.FieldBySchema = FieldBySchema_1.default;
|
|
85
89
|
const TextFieldBySchema_1 = __importDefault(require("./components/forms/inputs/TextFieldBySchema"));
|
|
86
90
|
exports.TextFieldBySchema = TextFieldBySchema_1.default;
|
|
91
|
+
const HtmlFieldBySchema_1 = __importDefault(require("./components/forms/inputs/HtmlFieldBySchema"));
|
|
92
|
+
exports.HtmlFieldBySchema = HtmlFieldBySchema_1.default;
|
|
93
|
+
const HtmlContent_1 = __importDefault(require("./components/HtmlContent"));
|
|
94
|
+
exports.HtmlContent = HtmlContent_1.default;
|
|
87
95
|
const BooleanFieldBySchema_1 = __importDefault(require("./components/forms/inputs/BooleanFieldBySchema"));
|
|
88
96
|
exports.BooleanFieldBySchema = BooleanFieldBySchema_1.default;
|
|
89
97
|
const DesktopDatePickerBySchema_1 = __importDefault(require("./components/forms/inputs/DesktopDatePickerBySchema"));
|
package/dist/styles/texts.d.ts
CHANGED
|
@@ -42,6 +42,30 @@ export interface FormTexts {
|
|
|
42
42
|
dialogCancel: string;
|
|
43
43
|
dialogSave: string;
|
|
44
44
|
}
|
|
45
|
+
export interface RichTextTexts {
|
|
46
|
+
paragraph: string;
|
|
47
|
+
heading1: string;
|
|
48
|
+
heading2: string;
|
|
49
|
+
heading3: string;
|
|
50
|
+
bold: string;
|
|
51
|
+
italic: string;
|
|
52
|
+
underline: string;
|
|
53
|
+
strike: string;
|
|
54
|
+
bulletList: string;
|
|
55
|
+
orderedList: string;
|
|
56
|
+
blockquote: string;
|
|
57
|
+
codeBlock: string;
|
|
58
|
+
horizontalRule: string;
|
|
59
|
+
link: string;
|
|
60
|
+
linkTitle: string;
|
|
61
|
+
linkUrl: string;
|
|
62
|
+
linkApply: string;
|
|
63
|
+
linkRemove: string;
|
|
64
|
+
linkCancel: string;
|
|
65
|
+
clearFormatting: string;
|
|
66
|
+
undo: string;
|
|
67
|
+
redo: string;
|
|
68
|
+
}
|
|
45
69
|
export interface AuthTexts {
|
|
46
70
|
email: string;
|
|
47
71
|
currentPassword: string;
|
|
@@ -63,6 +87,7 @@ export interface DRFReactBySchemaTexts {
|
|
|
63
87
|
geometry: GeometryTexts;
|
|
64
88
|
forms: FormTexts;
|
|
65
89
|
auth: AuthTexts;
|
|
90
|
+
richText: RichTextTexts;
|
|
66
91
|
}
|
|
67
92
|
export declare const DEFAULT_TEXTS: DRFReactBySchemaTexts;
|
|
68
93
|
export declare function getThemeTexts(theme: Theme): DRFReactBySchemaTexts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texts.d.ts","sourceRoot":"","sources":["../../src/styles/texts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IAEd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,E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;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IAErB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAE5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC;CACzB;AAGD,eAAO,MAAM,aAAa,EAAE,qBAsF3B,CAAC;AAGF,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,qBAAqB,CAQjE"}
|
package/dist/styles/texts.js
CHANGED
|
@@ -64,6 +64,30 @@ exports.DEFAULT_TEXTS = {
|
|
|
64
64
|
forgotConfirmError: 'Invalid or expired reset link. Request a new one.',
|
|
65
65
|
forgotConfirmSuccess: 'Password updated. You can now sign in with your new password.',
|
|
66
66
|
},
|
|
67
|
+
richText: {
|
|
68
|
+
paragraph: 'Paragraph',
|
|
69
|
+
heading1: 'Heading 1',
|
|
70
|
+
heading2: 'Heading 2',
|
|
71
|
+
heading3: 'Heading 3',
|
|
72
|
+
bold: 'Bold',
|
|
73
|
+
italic: 'Italic',
|
|
74
|
+
underline: 'Underline',
|
|
75
|
+
strike: 'Strikethrough',
|
|
76
|
+
bulletList: 'Bullet list',
|
|
77
|
+
orderedList: 'Ordered list',
|
|
78
|
+
blockquote: 'Quote',
|
|
79
|
+
codeBlock: 'Code block',
|
|
80
|
+
horizontalRule: 'Horizontal rule',
|
|
81
|
+
link: 'Link',
|
|
82
|
+
linkTitle: 'Insert link',
|
|
83
|
+
linkUrl: 'URL',
|
|
84
|
+
linkApply: 'Apply',
|
|
85
|
+
linkRemove: 'Remove link',
|
|
86
|
+
linkCancel: 'Cancel',
|
|
87
|
+
clearFormatting: 'Clear formatting',
|
|
88
|
+
undo: 'Undo',
|
|
89
|
+
redo: 'Redo',
|
|
90
|
+
},
|
|
67
91
|
};
|
|
68
92
|
// Merge theme.texts over the defaults; theme.texts is absent under a bare ThemeProvider.
|
|
69
93
|
function getThemeTexts(theme) {
|
|
@@ -72,5 +96,6 @@ function getThemeTexts(theme) {
|
|
|
72
96
|
geometry: Object.assign(Object.assign({}, exports.DEFAULT_TEXTS.geometry), ((custom === null || custom === void 0 ? void 0 : custom.geometry) || {})),
|
|
73
97
|
forms: Object.assign(Object.assign({}, exports.DEFAULT_TEXTS.forms), ((custom === null || custom === void 0 ? void 0 : custom.forms) || {})),
|
|
74
98
|
auth: Object.assign(Object.assign({}, exports.DEFAULT_TEXTS.auth), ((custom === null || custom === void 0 ? void 0 : custom.auth) || {})),
|
|
99
|
+
richText: Object.assign(Object.assign({}, exports.DEFAULT_TEXTS.richText), ((custom === null || custom === void 0 ? void 0 : custom.richText) || {})),
|
|
75
100
|
};
|
|
76
101
|
}
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -10,6 +10,17 @@ export declare function populateValues({ data, schema }: {
|
|
|
10
10
|
data: Item;
|
|
11
11
|
schema: SchemaType;
|
|
12
12
|
}): Record<string, any>;
|
|
13
|
+
/**
|
|
14
|
+
* Relation fields (FK/M2M) are serialized with `read_only: true` by DRF, but the
|
|
15
|
+
* backend still writes them from the raw request body (`update_related`).
|
|
16
|
+
* They must stay editable and be sent, unlike derived (method) fields.
|
|
17
|
+
*/
|
|
18
|
+
export declare const isRelationField: (field?: Field | null) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a field is read-only for the client: derived values (SerializerMethod
|
|
21
|
+
* fields, ids, timestamps) must not be validated, sent or edited inline.
|
|
22
|
+
*/
|
|
23
|
+
export declare const isReadOnlyField: (field?: Field | null) => boolean;
|
|
13
24
|
export declare function buildGenericYupValidationSchema({ data, schema, many, skipFields, extraValidators, uiFields, }: {
|
|
14
25
|
data: Item;
|
|
15
26
|
schema: SchemaType;
|
|
@@ -106,6 +117,18 @@ export declare function showConditionalVisibleFieldObj<T extends TField = void>(
|
|
|
106
117
|
* absent; returns null so callers can fall back to text inputs.
|
|
107
118
|
*/
|
|
108
119
|
export declare function getMapLibraries(): any;
|
|
120
|
+
/**
|
|
121
|
+
* Detect whether the consuming app has installed `@tiptap/react` +
|
|
122
|
+
* `@tiptap/starter-kit`. Returns the pieces the editor needs, or null so
|
|
123
|
+
* callers can fall back to plain text editing.
|
|
124
|
+
*/
|
|
125
|
+
export declare function getRichTextLibraries(): any;
|
|
126
|
+
/**
|
|
127
|
+
* Detect whether the consuming app has installed `dompurify`. HTML from the
|
|
128
|
+
* backend is only injected into the DOM when a sanitizer is available; without
|
|
129
|
+
* it, values are rendered as plain text.
|
|
130
|
+
*/
|
|
131
|
+
export declare function getHtmlSanitizer(): any;
|
|
109
132
|
/** Normalize a GeoJSON value (object, JSON string or null) to a string. */
|
|
110
133
|
export declare function geometryValueToString(value: GenericValue): string;
|
|
111
134
|
/** Parse a GeoJSON value (object or JSON string) into an object, or null. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,OAAO,EACL,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,2BAA2B,EAE3B,eAAe,EACf,eAAe,EACf,KAAK,EAEL,eAAe,EACf,YAAY,EAEZ,iBAAiB,EACjB,0BAA0B,EAC1B,IAAI,EACJ,UAAU,EACV,MA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C,EAAE,kBAAkB,EAAE,EACzC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,WAWjB;AAOD;;;;GAIG;AAEH,wBAAgB,eAAe,IAAI,GAAG,CAerC;AASD;;;;GAIG;AAEH,wBAAgB,oBAAoB,IAAI,GAAG,CA8B1C;AAID;;;;GAIG;AAEH,wBAAgB,gBAAgB,IAAI,GAAG,CActC;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAQjE;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAC1B,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,CAaxD"}
|
package/dist/utils/utils.js
CHANGED
|
@@ -45,7 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.convertToFormData = exports.slugify = exports.slugToCamelCase = exports.getPatternFormat = exports.isTmpId = exports.getTmpId = exports.errorProps = exports.toChoiceItem = exports.getChoiceByValue = exports.emptyByType = void 0;
|
|
48
|
+
exports.convertToFormData = exports.slugify = exports.slugToCamelCase = exports.getPatternFormat = exports.isTmpId = exports.getTmpId = exports.errorProps = exports.isReadOnlyField = exports.isRelationField = exports.toChoiceItem = exports.getChoiceByValue = exports.emptyByType = void 0;
|
|
49
49
|
exports.enrichChoices = enrichChoices;
|
|
50
50
|
exports.populateValues = populateValues;
|
|
51
51
|
exports.buildGenericYupValidationSchema = buildGenericYupValidationSchema;
|
|
@@ -67,6 +67,8 @@ exports.buildConditionalVisibleBySchema = buildConditionalVisibleBySchema;
|
|
|
67
67
|
exports.showConditionalVisibleField = showConditionalVisibleField;
|
|
68
68
|
exports.showConditionalVisibleFieldObj = showConditionalVisibleFieldObj;
|
|
69
69
|
exports.getMapLibraries = getMapLibraries;
|
|
70
|
+
exports.getRichTextLibraries = getRichTextLibraries;
|
|
71
|
+
exports.getHtmlSanitizer = getHtmlSanitizer;
|
|
70
72
|
exports.geometryValueToString = geometryValueToString;
|
|
71
73
|
exports.parseGeoJSON = parseGeoJSON;
|
|
72
74
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
@@ -271,6 +273,19 @@ const getYupValidator = (type) => {
|
|
|
271
273
|
}
|
|
272
274
|
return yupFunc.transform((v) => (v === '' ? null : v)).nullable();
|
|
273
275
|
};
|
|
276
|
+
/**
|
|
277
|
+
* Relation fields (FK/M2M) are serialized with `read_only: true` by DRF, but the
|
|
278
|
+
* backend still writes them from the raw request body (`update_related`).
|
|
279
|
+
* They must stay editable and be sent, unlike derived (method) fields.
|
|
280
|
+
*/
|
|
281
|
+
const isRelationField = (field) => !!field && ['field', 'nested object'].includes(field.type);
|
|
282
|
+
exports.isRelationField = isRelationField;
|
|
283
|
+
/**
|
|
284
|
+
* Whether a field is read-only for the client: derived values (SerializerMethod
|
|
285
|
+
* fields, ids, timestamps) must not be validated, sent or edited inline.
|
|
286
|
+
*/
|
|
287
|
+
const isReadOnlyField = (field) => !!(field === null || field === void 0 ? void 0 : field.read_only) && !(0, exports.isRelationField)(field);
|
|
288
|
+
exports.isReadOnlyField = isReadOnlyField;
|
|
274
289
|
// Applies the "required" rules (including the at-least-one rule for many-fields)
|
|
275
290
|
// to an already built schema, used both statically and inside `when` conditions.
|
|
276
291
|
const buildRequiredSchema = (fieldSchema, schema) => {
|
|
@@ -290,7 +305,11 @@ function buildGenericYupValidationSchema({ data, schema, many = false, skipField
|
|
|
290
305
|
const conditionalVisible = buildConditionalVisibleBySchema(schema);
|
|
291
306
|
for (const entry of Object.entries(schema)) {
|
|
292
307
|
const [field, fieldSchema] = entry;
|
|
293
|
-
if (!data ||
|
|
308
|
+
if (!data ||
|
|
309
|
+
!(field in data) ||
|
|
310
|
+
field === 'id' ||
|
|
311
|
+
skipFields.includes(field) ||
|
|
312
|
+
(0, exports.isReadOnlyField)(fieldSchema)) {
|
|
294
313
|
continue;
|
|
295
314
|
}
|
|
296
315
|
// OneToMany or ManyToMany (built as an array-of-object schema):
|
|
@@ -992,6 +1011,73 @@ function getMapLibraries() {
|
|
|
992
1011
|
}
|
|
993
1012
|
return null;
|
|
994
1013
|
}
|
|
1014
|
+
// --- Optional rich-text (Tiptap) support ------------------------------------
|
|
1015
|
+
// Fields flagged as ``model_html`` by the backend hold HTML. Editing them uses
|
|
1016
|
+
// Tiptap when the consuming app has it installed; otherwise the form falls back
|
|
1017
|
+
// to the multiline text field.
|
|
1018
|
+
let richTextLibraries;
|
|
1019
|
+
/**
|
|
1020
|
+
* Detect whether the consuming app has installed `@tiptap/react` +
|
|
1021
|
+
* `@tiptap/starter-kit`. Returns the pieces the editor needs, or null so
|
|
1022
|
+
* callers can fall back to plain text editing.
|
|
1023
|
+
*/
|
|
1024
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1025
|
+
function getRichTextLibraries() {
|
|
1026
|
+
var _a;
|
|
1027
|
+
if (richTextLibraries !== undefined) {
|
|
1028
|
+
return richTextLibraries;
|
|
1029
|
+
}
|
|
1030
|
+
try {
|
|
1031
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1032
|
+
const react = require('@tiptap/react');
|
|
1033
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1034
|
+
const starterKit = require('@tiptap/starter-kit');
|
|
1035
|
+
const editor = react.useEditor;
|
|
1036
|
+
const starterKitExtension = (_a = starterKit.default) !== null && _a !== void 0 ? _a : starterKit.StarterKit;
|
|
1037
|
+
if (typeof editor === 'function' &&
|
|
1038
|
+
typeof react.EditorContent !== 'undefined' &&
|
|
1039
|
+
typeof starterKitExtension !== 'undefined') {
|
|
1040
|
+
richTextLibraries = {
|
|
1041
|
+
useEditor: react.useEditor,
|
|
1042
|
+
useEditorState: react.useEditorState,
|
|
1043
|
+
EditorContent: react.EditorContent,
|
|
1044
|
+
StarterKit: starterKitExtension,
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
else {
|
|
1048
|
+
richTextLibraries = null;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
catch (_b) {
|
|
1052
|
+
// @tiptap/react / @tiptap/starter-kit not installed -> plain text fallback
|
|
1053
|
+
richTextLibraries = null;
|
|
1054
|
+
}
|
|
1055
|
+
return richTextLibraries;
|
|
1056
|
+
}
|
|
1057
|
+
let htmlSanitizer;
|
|
1058
|
+
/**
|
|
1059
|
+
* Detect whether the consuming app has installed `dompurify`. HTML from the
|
|
1060
|
+
* backend is only injected into the DOM when a sanitizer is available; without
|
|
1061
|
+
* it, values are rendered as plain text.
|
|
1062
|
+
*/
|
|
1063
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1064
|
+
function getHtmlSanitizer() {
|
|
1065
|
+
var _a;
|
|
1066
|
+
if (htmlSanitizer !== undefined) {
|
|
1067
|
+
return htmlSanitizer;
|
|
1068
|
+
}
|
|
1069
|
+
try {
|
|
1070
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1071
|
+
const dompurify = require('dompurify');
|
|
1072
|
+
const sanitizer = (_a = dompurify.default) !== null && _a !== void 0 ? _a : dompurify;
|
|
1073
|
+
htmlSanitizer = typeof (sanitizer === null || sanitizer === void 0 ? void 0 : sanitizer.sanitize) === 'function' ? sanitizer : null;
|
|
1074
|
+
}
|
|
1075
|
+
catch (_b) {
|
|
1076
|
+
// dompurify not installed -> render HTML as plain text
|
|
1077
|
+
htmlSanitizer = null;
|
|
1078
|
+
}
|
|
1079
|
+
return htmlSanitizer;
|
|
1080
|
+
}
|
|
995
1081
|
/** Normalize a GeoJSON value (object, JSON string or null) to a string. */
|
|
996
1082
|
function geometryValueToString(value) {
|
|
997
1083
|
if (value === null || value === undefined)
|