@rulab/adminjs-components 0.0.4 → 0.0.6
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/index.cjs +101 -22
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +94 -16
- package/package.json +1 -1
- package/src/components/Editor/EditorShow.jsx +8 -4
- package/src/components/Editor/styles.ts +43 -0
- package/src/components/StringList/StringList.tsx +13 -3
- package/src/components/StringList/StringListShow.tsx +37 -0
- package/src/components/StringList/constants.ts +1 -0
- package/src/components/StringList/index.ts +2 -1
- package/src/components/StringList/styles.ts +17 -0
- package/src/components/index.ts +1 -0
package/dist/index.cjs
CHANGED
|
@@ -33,7 +33,8 @@ __export(src_exports, {
|
|
|
33
33
|
CustomSlug: () => CustomSlug_default,
|
|
34
34
|
Editor: () => Editor_default,
|
|
35
35
|
EditorShow: () => EditorShow_default,
|
|
36
|
-
StringList: () => StringList_default
|
|
36
|
+
StringList: () => StringList_default,
|
|
37
|
+
StringListShow: () => StringListShow_default
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(src_exports);
|
|
39
40
|
|
|
@@ -111,6 +112,7 @@ var import_design_system3 = require("@adminjs/design-system");
|
|
|
111
112
|
var StyledWrapper = (0, import_styled_components3.styled)(import_design_system3.Box)`
|
|
112
113
|
display: flex;
|
|
113
114
|
flex-direction: column;
|
|
115
|
+
margin-bottom: 45px;
|
|
114
116
|
`;
|
|
115
117
|
var StyledCustomInput2 = (0, import_styled_components3.styled)(import_design_system3.Input)`
|
|
116
118
|
width: 100%;
|
|
@@ -122,6 +124,19 @@ var StyledInputWrapper2 = (0, import_styled_components3.styled)(import_design_sy
|
|
|
122
124
|
var StyledListWrapper = (0, import_styled_components3.styled)(import_design_system3.Box)`
|
|
123
125
|
margin-bottom: 15px;
|
|
124
126
|
`;
|
|
127
|
+
var StringListShowLabel = import_styled_components3.styled.div`
|
|
128
|
+
font-size: 12px;
|
|
129
|
+
margin-bottom: 8px;
|
|
130
|
+
text-transform: capitalize;
|
|
131
|
+
line-height: 16px;
|
|
132
|
+
color: rgb(137, 138, 154);
|
|
133
|
+
`;
|
|
134
|
+
var StringListShowWrapper = (0, import_styled_components3.styled)(import_design_system3.Box)`
|
|
135
|
+
margin-bottom: 35px;
|
|
136
|
+
`;
|
|
137
|
+
var ListItem = import_styled_components3.styled.li`
|
|
138
|
+
margin-bottom: 5px;
|
|
139
|
+
`;
|
|
125
140
|
|
|
126
141
|
// src/components/StringList/SortableList/SortableList.tsx
|
|
127
142
|
var import_react4 = __toESM(require("react"), 1);
|
|
@@ -261,8 +276,16 @@ function SortableList({
|
|
|
261
276
|
}
|
|
262
277
|
SortableList.Item = SortableItem;
|
|
263
278
|
|
|
279
|
+
// src/components/StringList/constants.ts
|
|
280
|
+
var separator = "|";
|
|
281
|
+
|
|
264
282
|
// src/components/StringList/StringList.tsx
|
|
265
|
-
var StringList = ({
|
|
283
|
+
var StringList = ({
|
|
284
|
+
record,
|
|
285
|
+
onChange,
|
|
286
|
+
property,
|
|
287
|
+
stringListSeparator = separator
|
|
288
|
+
}) => {
|
|
266
289
|
const stringListValue = record.params?.[property.path] ?? property.props.value ?? "";
|
|
267
290
|
const initialList = stringListValue ? prepareDataForList(stringListValue) : [];
|
|
268
291
|
const [inputValue, setInputValue] = (0, import_react5.useState)("");
|
|
@@ -317,10 +340,10 @@ var StringList = ({ record, onChange, property }) => {
|
|
|
317
340
|
setList(newData);
|
|
318
341
|
}
|
|
319
342
|
function prepareDataForDatabase(list2) {
|
|
320
|
-
return list2.map(({ value }) => value).join(
|
|
343
|
+
return list2.map(({ value }) => value).join(stringListSeparator);
|
|
321
344
|
}
|
|
322
345
|
function prepareDataForList(str) {
|
|
323
|
-
return str.split(
|
|
346
|
+
return str.split(stringListSeparator).map((item) => createListObject(item));
|
|
324
347
|
}
|
|
325
348
|
function createListObject(value) {
|
|
326
349
|
return {
|
|
@@ -331,24 +354,79 @@ var StringList = ({ record, onChange, property }) => {
|
|
|
331
354
|
};
|
|
332
355
|
var StringList_default = StringList;
|
|
333
356
|
|
|
334
|
-
// src/components/
|
|
357
|
+
// src/components/StringList/StringListShow.tsx
|
|
335
358
|
var import_react6 = __toESM(require("react"), 1);
|
|
336
|
-
var
|
|
359
|
+
var import_styled_components7 = require("styled-components");
|
|
360
|
+
var import_design_system6 = require("@adminjs/design-system");
|
|
361
|
+
var StringListShow = ({
|
|
362
|
+
property,
|
|
363
|
+
record,
|
|
364
|
+
stringListSeparator = separator
|
|
365
|
+
}) => {
|
|
366
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_styled_components7.ThemeProvider, { theme: import_design_system6.theme }, /* @__PURE__ */ import_react6.default.createElement(StringListShowWrapper, null, /* @__PURE__ */ import_react6.default.createElement(StringListShowLabel, null, property.name), record.params.facts && /* @__PURE__ */ import_react6.default.createElement("ul", null, record.params.facts.split(stringListSeparator).map((item, index) => /* @__PURE__ */ import_react6.default.createElement(ListItem, { key: index }, `- ${item}`)))));
|
|
367
|
+
};
|
|
368
|
+
var StringListShow_default = StringListShow;
|
|
369
|
+
|
|
370
|
+
// src/components/Editor/Editor.jsx
|
|
371
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
372
|
+
var import_styled_components9 = require("styled-components");
|
|
337
373
|
var import_editorjs = __toESM(require("@editorjs/editorjs"), 1);
|
|
338
|
-
var
|
|
374
|
+
var import_design_system8 = require("@adminjs/design-system");
|
|
339
375
|
|
|
340
376
|
// src/components/Editor/styles.ts
|
|
341
|
-
var
|
|
342
|
-
var
|
|
343
|
-
var Label3 =
|
|
377
|
+
var import_design_system7 = require("@adminjs/design-system");
|
|
378
|
+
var import_styled_components8 = require("@adminjs/design-system/styled-components");
|
|
379
|
+
var Label3 = import_styled_components8.styled.div`
|
|
344
380
|
font-size: 12px;
|
|
345
381
|
margin-bottom: 8px;
|
|
382
|
+
color: rgb(137, 138, 154);
|
|
346
383
|
`;
|
|
347
|
-
var EditorWrapper = (0,
|
|
384
|
+
var EditorWrapper = (0, import_styled_components8.styled)(import_design_system7.Box)`
|
|
348
385
|
padding: 12px;
|
|
386
|
+
margin-bottom: 24px;
|
|
349
387
|
border: 1px solid rgb(187, 195, 203);
|
|
350
388
|
`;
|
|
351
|
-
var
|
|
389
|
+
var EditorShowWrapper = (0, import_styled_components8.styled)(import_design_system7.Box)`
|
|
390
|
+
margin-bottom: 24px;
|
|
391
|
+
|
|
392
|
+
h1,
|
|
393
|
+
h2,
|
|
394
|
+
h3 {
|
|
395
|
+
margin-bottom: 5px;
|
|
396
|
+
font-weight: bold;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
h1 {
|
|
400
|
+
font-size: 18px;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
h2 {
|
|
404
|
+
font-size: 16px;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
h3 {
|
|
408
|
+
font-size: 14px;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
p {
|
|
412
|
+
margin-bottom: 8px;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
ol,
|
|
416
|
+
ul {
|
|
417
|
+
margin-left: 20px;
|
|
418
|
+
margin-bottom: 8px;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
ol {
|
|
422
|
+
list-style: auto;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
ul {
|
|
426
|
+
list-style: inherit;
|
|
427
|
+
}
|
|
428
|
+
`;
|
|
429
|
+
var StyledEditor = import_styled_components8.styled.div`
|
|
352
430
|
.cdx-block,
|
|
353
431
|
.ce-header {
|
|
354
432
|
padding-left: 58px;
|
|
@@ -418,13 +496,13 @@ var EDITOR_TOOLS = {
|
|
|
418
496
|
|
|
419
497
|
// src/components/Editor/Editor.jsx
|
|
420
498
|
var Editor = ({ property, record, onChangeAdmin, editorId }) => {
|
|
421
|
-
const [jsonData, setJsonData] = (0,
|
|
499
|
+
const [jsonData, setJsonData] = (0, import_react7.useState)();
|
|
422
500
|
const isSavedData = Boolean(record.params[property.path]);
|
|
423
|
-
const ref = (0,
|
|
424
|
-
(0,
|
|
501
|
+
const ref = (0, import_react7.useRef)();
|
|
502
|
+
(0, import_react7.useEffect)(() => {
|
|
425
503
|
onChangeAdmin(property.path, jsonData);
|
|
426
504
|
}, [jsonData]);
|
|
427
|
-
(0,
|
|
505
|
+
(0, import_react7.useEffect)(() => {
|
|
428
506
|
if (!ref.current) {
|
|
429
507
|
const editor = new import_editorjs.default({
|
|
430
508
|
holder: editorId,
|
|
@@ -441,14 +519,14 @@ var Editor = ({ property, record, onChangeAdmin, editorId }) => {
|
|
|
441
519
|
ref?.current?.destroy?.();
|
|
442
520
|
};
|
|
443
521
|
}, []);
|
|
444
|
-
return /* @__PURE__ */
|
|
522
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_styled_components9.ThemeProvider, { theme: import_design_system8.theme }, /* @__PURE__ */ import_react7.default.createElement(Label3, null, "Text"), /* @__PURE__ */ import_react7.default.createElement(EditorWrapper, null, /* @__PURE__ */ import_react7.default.createElement(StyledEditor, { id: editorId })));
|
|
445
523
|
};
|
|
446
524
|
var Editor_default = Editor;
|
|
447
525
|
|
|
448
526
|
// src/components/Editor/EditorShow.jsx
|
|
449
|
-
var
|
|
450
|
-
var
|
|
451
|
-
var
|
|
527
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
528
|
+
var import_styled_components10 = require("styled-components");
|
|
529
|
+
var import_design_system9 = require("@adminjs/design-system");
|
|
452
530
|
|
|
453
531
|
// src/utils/parseHtml.ts
|
|
454
532
|
var import_editorjs_html = __toESM(require("editorjs-html"), 1);
|
|
@@ -465,7 +543,7 @@ var parseHtml = (jsonData) => {
|
|
|
465
543
|
// src/components/Editor/EditorShow.jsx
|
|
466
544
|
var EditorShow = ({ property, record }) => {
|
|
467
545
|
const htmlContent = parseHtml(record.params[property.path]);
|
|
468
|
-
return /* @__PURE__ */
|
|
546
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_styled_components10.ThemeProvider, { theme: import_design_system9.theme }, /* @__PURE__ */ import_react8.default.createElement(EditorShowWrapper, null, /* @__PURE__ */ import_react8.default.createElement(Label3, null, "Content"), htmlContent && /* @__PURE__ */ import_react8.default.createElement("div", { dangerouslySetInnerHTML: { __html: String(htmlContent) } })));
|
|
469
547
|
};
|
|
470
548
|
var EditorShow_default = EditorShow;
|
|
471
549
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -473,5 +551,6 @@ var EditorShow_default = EditorShow;
|
|
|
473
551
|
CustomSlug,
|
|
474
552
|
Editor,
|
|
475
553
|
EditorShow,
|
|
476
|
-
StringList
|
|
554
|
+
StringList,
|
|
555
|
+
StringListShow
|
|
477
556
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { EditPropertyProps } from 'adminjs';
|
|
2
|
+
import { EditPropertyProps, ShowPropertyProps } from 'adminjs';
|
|
3
3
|
|
|
4
4
|
type CustomSlugTypes = Omit<EditPropertyProps, "where" | "resource">;
|
|
5
5
|
declare const CustomSlug: FC<CustomSlugTypes>;
|
|
6
6
|
|
|
7
7
|
type StringListTypes = Omit<EditPropertyProps, "where" | "resource">;
|
|
8
|
-
|
|
8
|
+
interface StringListShowPropsType$1 extends StringListTypes {
|
|
9
|
+
stringListSeparator?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const StringList: FC<StringListShowPropsType$1>;
|
|
12
|
+
|
|
13
|
+
interface StringListShowPropsType extends ShowPropertyProps {
|
|
14
|
+
stringListSeparator?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const StringListShow: FC<StringListShowPropsType>;
|
|
9
17
|
|
|
10
18
|
declare function Editor({ property, record, onChangeAdmin, editorId }: {
|
|
11
19
|
property: any;
|
|
@@ -19,4 +27,4 @@ declare function EditorShow({ property, record }: {
|
|
|
19
27
|
record: any;
|
|
20
28
|
}): React.JSX.Element;
|
|
21
29
|
|
|
22
|
-
export { CustomSlug, Editor, EditorShow, StringList };
|
|
30
|
+
export { CustomSlug, Editor, EditorShow, StringList, StringListShow };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { EditPropertyProps } from 'adminjs';
|
|
2
|
+
import { EditPropertyProps, ShowPropertyProps } from 'adminjs';
|
|
3
3
|
|
|
4
4
|
type CustomSlugTypes = Omit<EditPropertyProps, "where" | "resource">;
|
|
5
5
|
declare const CustomSlug: FC<CustomSlugTypes>;
|
|
6
6
|
|
|
7
7
|
type StringListTypes = Omit<EditPropertyProps, "where" | "resource">;
|
|
8
|
-
|
|
8
|
+
interface StringListShowPropsType$1 extends StringListTypes {
|
|
9
|
+
stringListSeparator?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const StringList: FC<StringListShowPropsType$1>;
|
|
12
|
+
|
|
13
|
+
interface StringListShowPropsType extends ShowPropertyProps {
|
|
14
|
+
stringListSeparator?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const StringListShow: FC<StringListShowPropsType>;
|
|
9
17
|
|
|
10
18
|
declare function Editor({ property, record, onChangeAdmin, editorId }: {
|
|
11
19
|
property: any;
|
|
@@ -19,4 +27,4 @@ declare function EditorShow({ property, record }: {
|
|
|
19
27
|
record: any;
|
|
20
28
|
}): React.JSX.Element;
|
|
21
29
|
|
|
22
|
-
export { CustomSlug, Editor, EditorShow, StringList };
|
|
30
|
+
export { CustomSlug, Editor, EditorShow, StringList, StringListShow };
|
package/dist/index.js
CHANGED
|
@@ -78,6 +78,7 @@ import { Box as Box2, Input as Input2 } from "@adminjs/design-system";
|
|
|
78
78
|
var StyledWrapper = styled2(Box2)`
|
|
79
79
|
display: flex;
|
|
80
80
|
flex-direction: column;
|
|
81
|
+
margin-bottom: 45px;
|
|
81
82
|
`;
|
|
82
83
|
var StyledCustomInput2 = styled2(Input2)`
|
|
83
84
|
width: 100%;
|
|
@@ -89,6 +90,19 @@ var StyledInputWrapper2 = styled2(Box2)`
|
|
|
89
90
|
var StyledListWrapper = styled2(Box2)`
|
|
90
91
|
margin-bottom: 15px;
|
|
91
92
|
`;
|
|
93
|
+
var StringListShowLabel = styled2.div`
|
|
94
|
+
font-size: 12px;
|
|
95
|
+
margin-bottom: 8px;
|
|
96
|
+
text-transform: capitalize;
|
|
97
|
+
line-height: 16px;
|
|
98
|
+
color: rgb(137, 138, 154);
|
|
99
|
+
`;
|
|
100
|
+
var StringListShowWrapper = styled2(Box2)`
|
|
101
|
+
margin-bottom: 35px;
|
|
102
|
+
`;
|
|
103
|
+
var ListItem = styled2.li`
|
|
104
|
+
margin-bottom: 5px;
|
|
105
|
+
`;
|
|
92
106
|
|
|
93
107
|
// src/components/StringList/SortableList/SortableList.tsx
|
|
94
108
|
import React4, { Fragment, useMemo as useMemo2, useState as useState2 } from "react";
|
|
@@ -241,8 +255,16 @@ function SortableList({
|
|
|
241
255
|
}
|
|
242
256
|
SortableList.Item = SortableItem;
|
|
243
257
|
|
|
258
|
+
// src/components/StringList/constants.ts
|
|
259
|
+
var separator = "|";
|
|
260
|
+
|
|
244
261
|
// src/components/StringList/StringList.tsx
|
|
245
|
-
var StringList = ({
|
|
262
|
+
var StringList = ({
|
|
263
|
+
record,
|
|
264
|
+
onChange,
|
|
265
|
+
property,
|
|
266
|
+
stringListSeparator = separator
|
|
267
|
+
}) => {
|
|
246
268
|
const stringListValue = record.params?.[property.path] ?? property.props.value ?? "";
|
|
247
269
|
const initialList = stringListValue ? prepareDataForList(stringListValue) : [];
|
|
248
270
|
const [inputValue, setInputValue] = useState3("");
|
|
@@ -297,10 +319,10 @@ var StringList = ({ record, onChange, property }) => {
|
|
|
297
319
|
setList(newData);
|
|
298
320
|
}
|
|
299
321
|
function prepareDataForDatabase(list2) {
|
|
300
|
-
return list2.map(({ value }) => value).join(
|
|
322
|
+
return list2.map(({ value }) => value).join(stringListSeparator);
|
|
301
323
|
}
|
|
302
324
|
function prepareDataForList(str) {
|
|
303
|
-
return str.split(
|
|
325
|
+
return str.split(stringListSeparator).map((item) => createListObject(item));
|
|
304
326
|
}
|
|
305
327
|
function createListObject(value) {
|
|
306
328
|
return {
|
|
@@ -311,11 +333,24 @@ var StringList = ({ record, onChange, property }) => {
|
|
|
311
333
|
};
|
|
312
334
|
var StringList_default = StringList;
|
|
313
335
|
|
|
314
|
-
// src/components/
|
|
315
|
-
import React6
|
|
336
|
+
// src/components/StringList/StringListShow.tsx
|
|
337
|
+
import React6 from "react";
|
|
316
338
|
import { ThemeProvider as ThemeProvider3 } from "styled-components";
|
|
317
|
-
import EditorJS from "@editorjs/editorjs";
|
|
318
339
|
import { theme as theme3 } from "@adminjs/design-system";
|
|
340
|
+
var StringListShow = ({
|
|
341
|
+
property,
|
|
342
|
+
record,
|
|
343
|
+
stringListSeparator = separator
|
|
344
|
+
}) => {
|
|
345
|
+
return /* @__PURE__ */ React6.createElement(ThemeProvider3, { theme: theme3 }, /* @__PURE__ */ React6.createElement(StringListShowWrapper, null, /* @__PURE__ */ React6.createElement(StringListShowLabel, null, property.name), record.params.facts && /* @__PURE__ */ React6.createElement("ul", null, record.params.facts.split(stringListSeparator).map((item, index) => /* @__PURE__ */ React6.createElement(ListItem, { key: index }, `- ${item}`)))));
|
|
346
|
+
};
|
|
347
|
+
var StringListShow_default = StringListShow;
|
|
348
|
+
|
|
349
|
+
// src/components/Editor/Editor.jsx
|
|
350
|
+
import React7, { memo as memo2, useState as useState5, useEffect as useEffect4, useRef as useRef2 } from "react";
|
|
351
|
+
import { ThemeProvider as ThemeProvider4 } from "styled-components";
|
|
352
|
+
import EditorJS from "@editorjs/editorjs";
|
|
353
|
+
import { theme as theme4 } from "@adminjs/design-system";
|
|
319
354
|
|
|
320
355
|
// src/components/Editor/styles.ts
|
|
321
356
|
import { Box as Box3 } from "@adminjs/design-system";
|
|
@@ -323,11 +358,53 @@ import { styled as styled5 } from "@adminjs/design-system/styled-components";
|
|
|
323
358
|
var Label3 = styled5.div`
|
|
324
359
|
font-size: 12px;
|
|
325
360
|
margin-bottom: 8px;
|
|
361
|
+
color: rgb(137, 138, 154);
|
|
326
362
|
`;
|
|
327
363
|
var EditorWrapper = styled5(Box3)`
|
|
328
364
|
padding: 12px;
|
|
365
|
+
margin-bottom: 24px;
|
|
329
366
|
border: 1px solid rgb(187, 195, 203);
|
|
330
367
|
`;
|
|
368
|
+
var EditorShowWrapper = styled5(Box3)`
|
|
369
|
+
margin-bottom: 24px;
|
|
370
|
+
|
|
371
|
+
h1,
|
|
372
|
+
h2,
|
|
373
|
+
h3 {
|
|
374
|
+
margin-bottom: 5px;
|
|
375
|
+
font-weight: bold;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
h1 {
|
|
379
|
+
font-size: 18px;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
h2 {
|
|
383
|
+
font-size: 16px;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
h3 {
|
|
387
|
+
font-size: 14px;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
p {
|
|
391
|
+
margin-bottom: 8px;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
ol,
|
|
395
|
+
ul {
|
|
396
|
+
margin-left: 20px;
|
|
397
|
+
margin-bottom: 8px;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
ol {
|
|
401
|
+
list-style: auto;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
ul {
|
|
405
|
+
list-style: inherit;
|
|
406
|
+
}
|
|
407
|
+
`;
|
|
331
408
|
var StyledEditor = styled5.div`
|
|
332
409
|
.cdx-block,
|
|
333
410
|
.ce-header {
|
|
@@ -398,13 +475,13 @@ var EDITOR_TOOLS = {
|
|
|
398
475
|
|
|
399
476
|
// src/components/Editor/Editor.jsx
|
|
400
477
|
var Editor = ({ property, record, onChangeAdmin, editorId }) => {
|
|
401
|
-
const [jsonData, setJsonData] =
|
|
478
|
+
const [jsonData, setJsonData] = useState5();
|
|
402
479
|
const isSavedData = Boolean(record.params[property.path]);
|
|
403
|
-
const ref =
|
|
404
|
-
|
|
480
|
+
const ref = useRef2();
|
|
481
|
+
useEffect4(() => {
|
|
405
482
|
onChangeAdmin(property.path, jsonData);
|
|
406
483
|
}, [jsonData]);
|
|
407
|
-
|
|
484
|
+
useEffect4(() => {
|
|
408
485
|
if (!ref.current) {
|
|
409
486
|
const editor = new EditorJS({
|
|
410
487
|
holder: editorId,
|
|
@@ -421,14 +498,14 @@ var Editor = ({ property, record, onChangeAdmin, editorId }) => {
|
|
|
421
498
|
ref?.current?.destroy?.();
|
|
422
499
|
};
|
|
423
500
|
}, []);
|
|
424
|
-
return /* @__PURE__ */
|
|
501
|
+
return /* @__PURE__ */ React7.createElement(ThemeProvider4, { theme: theme4 }, /* @__PURE__ */ React7.createElement(Label3, null, "Text"), /* @__PURE__ */ React7.createElement(EditorWrapper, null, /* @__PURE__ */ React7.createElement(StyledEditor, { id: editorId })));
|
|
425
502
|
};
|
|
426
503
|
var Editor_default = Editor;
|
|
427
504
|
|
|
428
505
|
// src/components/Editor/EditorShow.jsx
|
|
429
|
-
import
|
|
430
|
-
import { ThemeProvider as
|
|
431
|
-
import { theme as
|
|
506
|
+
import React8, { memo as memo3, useState as useState6, useEffect as useEffect5, useRef as useRef3 } from "react";
|
|
507
|
+
import { ThemeProvider as ThemeProvider5 } from "styled-components";
|
|
508
|
+
import { theme as theme5 } from "@adminjs/design-system";
|
|
432
509
|
|
|
433
510
|
// src/utils/parseHtml.ts
|
|
434
511
|
import edjsHTML from "editorjs-html";
|
|
@@ -445,12 +522,13 @@ var parseHtml = (jsonData) => {
|
|
|
445
522
|
// src/components/Editor/EditorShow.jsx
|
|
446
523
|
var EditorShow = ({ property, record }) => {
|
|
447
524
|
const htmlContent = parseHtml(record.params[property.path]);
|
|
448
|
-
return /* @__PURE__ */
|
|
525
|
+
return /* @__PURE__ */ React8.createElement(ThemeProvider5, { theme: theme5 }, /* @__PURE__ */ React8.createElement(EditorShowWrapper, null, /* @__PURE__ */ React8.createElement(Label3, null, "Content"), htmlContent && /* @__PURE__ */ React8.createElement("div", { dangerouslySetInnerHTML: { __html: String(htmlContent) } })));
|
|
449
526
|
};
|
|
450
527
|
var EditorShow_default = EditorShow;
|
|
451
528
|
export {
|
|
452
529
|
CustomSlug_default as CustomSlug,
|
|
453
530
|
Editor_default as Editor,
|
|
454
531
|
EditorShow_default as EditorShow,
|
|
455
|
-
StringList_default as StringList
|
|
532
|
+
StringList_default as StringList,
|
|
533
|
+
StringListShow_default as StringListShow
|
|
456
534
|
};
|
package/package.json
CHANGED
|
@@ -4,6 +4,8 @@ import { theme } from "@adminjs/design-system";
|
|
|
4
4
|
|
|
5
5
|
import { parseHtml } from "../../utils/parseHtml";
|
|
6
6
|
|
|
7
|
+
import { EditorShowWrapper } from "./styles";
|
|
8
|
+
|
|
7
9
|
import { Label } from "./styles";
|
|
8
10
|
|
|
9
11
|
const EditorShow = ({ property, record }) => {
|
|
@@ -11,10 +13,12 @@ const EditorShow = ({ property, record }) => {
|
|
|
11
13
|
|
|
12
14
|
return (
|
|
13
15
|
<ThemeProvider theme={theme}>
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
<EditorShowWrapper>
|
|
17
|
+
<Label>Content</Label>
|
|
18
|
+
{htmlContent && (
|
|
19
|
+
<div dangerouslySetInnerHTML={{ __html: htmlContent }} />
|
|
20
|
+
)}
|
|
21
|
+
</EditorShowWrapper>
|
|
18
22
|
</ThemeProvider>
|
|
19
23
|
);
|
|
20
24
|
};
|
|
@@ -4,13 +4,56 @@ import { styled } from "@adminjs/design-system/styled-components";
|
|
|
4
4
|
export const Label = styled.div`
|
|
5
5
|
font-size: 12px;
|
|
6
6
|
margin-bottom: 8px;
|
|
7
|
+
color: rgb(137, 138, 154);
|
|
7
8
|
`;
|
|
8
9
|
|
|
9
10
|
export const EditorWrapper = styled(Box)`
|
|
10
11
|
padding: 12px;
|
|
12
|
+
margin-bottom: 24px;
|
|
11
13
|
border: 1px solid rgb(187, 195, 203);
|
|
12
14
|
`;
|
|
13
15
|
|
|
16
|
+
export const EditorShowWrapper = styled(Box)`
|
|
17
|
+
margin-bottom: 24px;
|
|
18
|
+
|
|
19
|
+
h1,
|
|
20
|
+
h2,
|
|
21
|
+
h3 {
|
|
22
|
+
margin-bottom: 5px;
|
|
23
|
+
font-weight: bold;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
h1 {
|
|
27
|
+
font-size: 18px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
h2 {
|
|
31
|
+
font-size: 16px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h3 {
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
p {
|
|
39
|
+
margin-bottom: 8px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ol,
|
|
43
|
+
ul {
|
|
44
|
+
margin-left: 20px;
|
|
45
|
+
margin-bottom: 8px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ol {
|
|
49
|
+
list-style: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ul {
|
|
53
|
+
list-style: inherit;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
|
|
14
57
|
export const StyledEditor = styled.div`
|
|
15
58
|
.cdx-block,
|
|
16
59
|
.ce-header {
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from "./styles.js";
|
|
19
19
|
|
|
20
20
|
import { SortableList } from "./SortableList/SortableList.js";
|
|
21
|
+
import { separator } from "./constants.js";
|
|
21
22
|
|
|
22
23
|
type ListDataTypes = {
|
|
23
24
|
id: string;
|
|
@@ -26,7 +27,16 @@ type ListDataTypes = {
|
|
|
26
27
|
|
|
27
28
|
type StringListTypes = Omit<EditPropertyProps, "where" | "resource">;
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
interface StringListShowPropsType extends StringListTypes {
|
|
31
|
+
stringListSeparator?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const StringList: FC<StringListShowPropsType> = ({
|
|
35
|
+
record,
|
|
36
|
+
onChange,
|
|
37
|
+
property,
|
|
38
|
+
stringListSeparator = separator,
|
|
39
|
+
}) => {
|
|
30
40
|
const stringListValue =
|
|
31
41
|
record.params?.[property.path] ?? property.props.value ?? "";
|
|
32
42
|
|
|
@@ -107,11 +117,11 @@ const StringList: FC<StringListTypes> = ({ record, onChange, property }) => {
|
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
function prepareDataForDatabase(list: ListDataTypes[]) {
|
|
110
|
-
return list.map(({ value }) => value).join(
|
|
120
|
+
return list.map(({ value }) => value).join(stringListSeparator);
|
|
111
121
|
}
|
|
112
122
|
|
|
113
123
|
function prepareDataForList(str: string) {
|
|
114
|
-
return str.split(
|
|
124
|
+
return str.split(stringListSeparator).map((item) => createListObject(item));
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
function createListObject(value: string) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { memo, useState, useEffect, useRef, FC } from "react";
|
|
2
|
+
import { ShowPropertyProps } from "adminjs";
|
|
3
|
+
|
|
4
|
+
import { ThemeProvider } from "styled-components";
|
|
5
|
+
import { theme } from "@adminjs/design-system";
|
|
6
|
+
|
|
7
|
+
import { StringListShowLabel, StringListShowWrapper, ListItem } from "./styles";
|
|
8
|
+
import { separator } from "./constants";
|
|
9
|
+
|
|
10
|
+
interface StringListShowPropsType extends ShowPropertyProps {
|
|
11
|
+
stringListSeparator?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const StringListShow: FC<StringListShowPropsType> = ({
|
|
15
|
+
property,
|
|
16
|
+
record,
|
|
17
|
+
stringListSeparator = separator,
|
|
18
|
+
}) => {
|
|
19
|
+
return (
|
|
20
|
+
<ThemeProvider theme={theme}>
|
|
21
|
+
<StringListShowWrapper>
|
|
22
|
+
<StringListShowLabel>{property.name}</StringListShowLabel>
|
|
23
|
+
{record.params.facts && (
|
|
24
|
+
<ul>
|
|
25
|
+
{record.params.facts
|
|
26
|
+
.split(stringListSeparator)
|
|
27
|
+
.map((item: string, index: number) => (
|
|
28
|
+
<ListItem key={index}>{`- ${item}`}</ListItem>
|
|
29
|
+
))}
|
|
30
|
+
</ul>
|
|
31
|
+
)}
|
|
32
|
+
</StringListShowWrapper>
|
|
33
|
+
</ThemeProvider>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default StringListShow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const separator = "|";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./StringList.js";
|
|
2
|
+
export * from "./StringListShow.js";
|
|
@@ -4,6 +4,7 @@ import { Box, Input } from "@adminjs/design-system";
|
|
|
4
4
|
export const StyledWrapper = styled(Box)`
|
|
5
5
|
display: flex;
|
|
6
6
|
flex-direction: column;
|
|
7
|
+
margin-bottom: 45px;
|
|
7
8
|
`;
|
|
8
9
|
|
|
9
10
|
export const StyledCustomInput = styled(Input)`
|
|
@@ -18,3 +19,19 @@ export const StyledInputWrapper = styled(Box)`
|
|
|
18
19
|
export const StyledListWrapper = styled(Box)`
|
|
19
20
|
margin-bottom: 15px;
|
|
20
21
|
`;
|
|
22
|
+
|
|
23
|
+
export const StringListShowLabel = styled.div`
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
margin-bottom: 8px;
|
|
26
|
+
text-transform: capitalize;
|
|
27
|
+
line-height: 16px;
|
|
28
|
+
color: rgb(137, 138, 154);
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export const StringListShowWrapper = styled(Box)`
|
|
32
|
+
margin-bottom: 35px;
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export const ListItem = styled.li`
|
|
36
|
+
margin-bottom: 5px;
|
|
37
|
+
`;
|
package/src/components/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as CustomSlug } from "./CustomSlug/CustomSlug.js";
|
|
2
2
|
export { default as StringList } from "./StringList/StringList.js";
|
|
3
|
+
export { default as StringListShow } from "./StringList/StringListShow.js";
|
|
3
4
|
export { default as Editor } from "./Editor/Editor.jsx";
|
|
4
5
|
export { default as EditorShow } from "./Editor/EditorShow.jsx";
|