@rulab/adminjs-components 0.1.0-alpha.2 → 0.1.0-alpha.3

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.
Files changed (138) hide show
  1. package/dist/components/ColorStatus/ColorStatusEdit.d.ts +5 -0
  2. package/dist/components/ColorStatus/ColorStatusEdit.js +58 -0
  3. package/dist/components/ColorStatus/ColorStatusList.d.ts +4 -0
  4. package/dist/components/ColorStatus/ColorStatusList.js +7 -0
  5. package/dist/components/ColorStatus/ColorStatusShow.d.ts +4 -0
  6. package/dist/components/ColorStatus/ColorStatusShow.js +9 -0
  7. package/dist/components/ColorStatus/index.d.ts +3 -0
  8. package/dist/components/ColorStatus/index.js +3 -0
  9. package/dist/components/ColorStatus/styles.d.ts +5 -0
  10. package/dist/components/ColorStatus/styles.js +25 -0
  11. package/dist/components/ColorStatus/types.d.ts +5 -0
  12. package/dist/components/ColorStatus/types.js +1 -0
  13. package/dist/components/Editor/Editor.d.ts +11 -0
  14. package/dist/components/Editor/Editor.js +33 -0
  15. package/dist/components/Editor/EditorList.d.ts +9 -0
  16. package/dist/components/Editor/EditorList.js +10 -0
  17. package/dist/components/Editor/EditorShow.d.ts +9 -0
  18. package/dist/components/Editor/EditorShow.js +10 -0
  19. package/dist/components/Editor/config.d.ts +29 -0
  20. package/dist/components/Editor/config.js +34 -0
  21. package/dist/components/Editor/index.d.ts +3 -0
  22. package/dist/components/Editor/index.js +3 -0
  23. package/dist/components/Editor/styles.d.ts +6 -0
  24. package/dist/components/Editor/styles.js +145 -0
  25. package/dist/components/Slug/SlugEdit.d.ts +5 -0
  26. package/dist/components/Slug/SlugEdit.js +27 -0
  27. package/dist/components/Slug/SlugFeature.d.ts +7 -0
  28. package/dist/components/Slug/SlugFeature.js +21 -0
  29. package/dist/components/Slug/index.d.ts +1 -0
  30. package/dist/components/Slug/index.js +1 -0
  31. package/dist/components/Slug/styles.d.ts +4 -0
  32. package/dist/components/Slug/styles.js +20 -0
  33. package/dist/components/StringList/SortableList/SortableList.d.ts +18 -0
  34. package/dist/components/StringList/SortableList/SortableList.js +37 -0
  35. package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +7 -0
  36. package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.js +8 -0
  37. package/dist/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +8 -0
  38. package/dist/components/StringList/SortableList/components/SortableItem/SortableItem.js +28 -0
  39. package/dist/components/StringList/SortableList/components/SortableItem/styles.d.ts +2 -0
  40. package/dist/components/StringList/SortableList/components/SortableItem/styles.js +20 -0
  41. package/dist/components/StringList/SortableList/components/SortableItem/types.d.ts +6 -0
  42. package/dist/components/StringList/SortableList/components/SortableItem/types.js +1 -0
  43. package/dist/components/StringList/SortableList/components/index.d.ts +2 -0
  44. package/dist/components/StringList/SortableList/components/index.js +2 -0
  45. package/dist/components/StringList/SortableList/index.d.ts +1 -0
  46. package/dist/components/StringList/SortableList/index.js +1 -0
  47. package/dist/components/StringList/SortableList/styles.d.ts +1 -0
  48. package/dist/components/StringList/SortableList/styles.js +8 -0
  49. package/dist/components/StringList/StringList.d.ts +8 -0
  50. package/dist/components/StringList/StringList.js +60 -0
  51. package/dist/components/StringList/StringListShow.d.ts +7 -0
  52. package/dist/components/StringList/StringListShow.js +14 -0
  53. package/dist/components/StringList/constants.d.ts +1 -0
  54. package/dist/components/StringList/constants.js +1 -0
  55. package/dist/components/StringList/index.d.ts +2 -0
  56. package/dist/components/StringList/index.js +2 -0
  57. package/dist/components/StringList/styles.d.ts +8 -0
  58. package/dist/components/StringList/styles.js +33 -0
  59. package/dist/components/index.d.ts +7 -0
  60. package/dist/components/index.js +10 -0
  61. package/dist/index.d.ts +2 -33
  62. package/dist/index.js +1 -5
  63. package/dist/utils/bundle-component.d.ts +2 -0
  64. package/dist/utils/bundle-component.js +13 -0
  65. package/dist/utils/index.d.ts +2 -0
  66. package/dist/utils/index.js +2 -0
  67. package/dist/utils/parseHtml.d.ts +1 -0
  68. package/dist/utils/parseHtml.js +37 -0
  69. package/dist/utils/slugifyImport.d.ts +3 -0
  70. package/dist/utils/slugifyImport.js +3 -0
  71. package/dist/utils/slugifyTitle.d.ts +1 -0
  72. package/dist/utils/slugifyTitle.js +10 -0
  73. package/package.json +2 -2
  74. package/src/components/ColorStatus/ColorStatusEdit.d.ts +5 -0
  75. package/src/components/ColorStatus/ColorStatusEdit.js +58 -0
  76. package/src/components/ColorStatus/ColorStatusList.d.ts +4 -0
  77. package/src/components/ColorStatus/ColorStatusList.js +7 -0
  78. package/src/components/ColorStatus/ColorStatusShow.d.ts +4 -0
  79. package/src/components/ColorStatus/ColorStatusShow.js +9 -0
  80. package/src/components/ColorStatus/index.d.ts +3 -0
  81. package/src/components/ColorStatus/index.js +3 -0
  82. package/src/components/ColorStatus/styles.d.ts +5 -0
  83. package/src/components/ColorStatus/styles.js +25 -0
  84. package/src/components/ColorStatus/types.d.ts +5 -0
  85. package/src/components/ColorStatus/types.js +1 -0
  86. package/src/components/Editor/Editor.d.ts +8 -0
  87. package/src/components/Editor/Editor.js +36 -0
  88. package/src/components/Editor/EditorList.d.ts +6 -0
  89. package/src/components/Editor/EditorList.js +11 -0
  90. package/src/components/Editor/EditorShow.d.ts +6 -0
  91. package/src/components/Editor/EditorShow.js +13 -0
  92. package/src/components/Editor/config.d.ts +29 -0
  93. package/src/components/Editor/config.js +34 -0
  94. package/src/components/Editor/index.d.ts +3 -0
  95. package/src/components/Editor/index.js +3 -0
  96. package/src/components/Editor/styles.d.ts +6 -0
  97. package/src/components/Editor/styles.js +145 -0
  98. package/src/components/Slug/SlugEdit.d.ts +5 -0
  99. package/src/components/Slug/SlugEdit.js +27 -0
  100. package/src/components/Slug/SlugFeature.d.ts +7 -0
  101. package/src/components/Slug/SlugFeature.js +21 -0
  102. package/src/components/Slug/SlugFeature.ts +1 -1
  103. package/src/components/Slug/index.d.ts +1 -0
  104. package/src/components/Slug/index.js +1 -0
  105. package/src/components/Slug/styles.d.ts +4 -0
  106. package/src/components/Slug/styles.js +20 -0
  107. package/src/components/StringList/SortableList/SortableList.d.ts +18 -0
  108. package/src/components/StringList/SortableList/SortableList.js +37 -0
  109. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +7 -0
  110. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.js +8 -0
  111. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +8 -0
  112. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.js +28 -0
  113. package/src/components/StringList/SortableList/components/SortableItem/styles.d.ts +2 -0
  114. package/src/components/StringList/SortableList/components/SortableItem/styles.js +20 -0
  115. package/src/components/StringList/SortableList/components/SortableItem/types.d.ts +6 -0
  116. package/src/components/StringList/SortableList/components/SortableItem/types.js +1 -0
  117. package/src/components/StringList/SortableList/components/index.d.ts +2 -0
  118. package/src/components/StringList/SortableList/components/index.js +2 -0
  119. package/src/components/StringList/SortableList/index.d.ts +1 -0
  120. package/src/components/StringList/SortableList/index.js +1 -0
  121. package/src/components/StringList/SortableList/styles.d.ts +1 -0
  122. package/src/components/StringList/SortableList/styles.js +8 -0
  123. package/src/components/StringList/StringList.d.ts +8 -0
  124. package/src/components/StringList/StringList.js +60 -0
  125. package/src/components/StringList/StringListShow.d.ts +7 -0
  126. package/src/components/StringList/StringListShow.js +14 -0
  127. package/src/components/StringList/constants.d.ts +1 -0
  128. package/src/components/StringList/constants.js +1 -0
  129. package/src/components/StringList/index.d.ts +2 -0
  130. package/src/components/StringList/index.js +2 -0
  131. package/src/components/StringList/styles.d.ts +8 -0
  132. package/src/components/StringList/styles.js +33 -0
  133. package/src/components/index.d.ts +7 -0
  134. package/src/components/index.js +10 -0
  135. package/dist/index.cjs +0 -32
  136. package/dist/index.cjs.map +0 -1
  137. package/dist/index.d.cts +0 -33
  138. package/dist/index.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ import { FC } from "react";
2
+ import { EditPropertyProps } from "adminjs";
3
+ type ColorStatusTypes = Omit<EditPropertyProps, "where" | "resource">;
4
+ declare const ColorStatus: FC<ColorStatusTypes>;
5
+ export default ColorStatus;
@@ -0,0 +1,58 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import Select from "react-select";
3
+ import chroma from "chroma-js";
4
+ import { ColorStatusWrapper, Label } from "./styles";
5
+ const dot = (color = "transparent") => ({
6
+ alignItems: "center",
7
+ display: "flex",
8
+ ":before": {
9
+ backgroundColor: color,
10
+ borderRadius: 10,
11
+ content: '" "',
12
+ display: "block",
13
+ marginRight: 8,
14
+ height: 10,
15
+ width: 10,
16
+ },
17
+ });
18
+ const colorStyles = {
19
+ control: (styles) => ({ ...styles, backgroundColor: "white" }),
20
+ option: (styles, { data, isDisabled, isFocused, isSelected }) => {
21
+ const color = chroma(data.color);
22
+ return {
23
+ ...styles,
24
+ backgroundColor: isSelected
25
+ ? data.color
26
+ : isFocused
27
+ ? color.alpha(0.1).css()
28
+ : undefined,
29
+ color: isSelected
30
+ ? chroma.contrast(color, "white") > 2
31
+ ? "white"
32
+ : "black"
33
+ : data.color,
34
+ ":active": {
35
+ ...styles[":active"],
36
+ backgroundColor: isSelected ? data.color : color.alpha(0.3).css(),
37
+ },
38
+ };
39
+ },
40
+ input: (styles) => ({ ...styles, ...dot() }),
41
+ placeholder: (styles) => ({ ...styles, ...dot("#ccc") }),
42
+ singleValue: (styles, { data }) => ({ ...styles, ...dot(data.color) }),
43
+ };
44
+ const ColorStatus = ({ property, record, onChange }) => {
45
+ const availableValues = property.availableValues;
46
+ const currentOption = availableValues.find((item) => item.value === record.params[property.path]);
47
+ const [selectOption, setCurrentOption] = useState(currentOption);
48
+ const handleSelectChange = (option) => {
49
+ setCurrentOption(option);
50
+ };
51
+ useEffect(() => {
52
+ onChange(property.path, selectOption?.value);
53
+ }, [selectOption]);
54
+ return (React.createElement(ColorStatusWrapper, null,
55
+ React.createElement(Label, null, property.path),
56
+ React.createElement(Select, { className: "basic-single", classNamePrefix: "select", defaultValue: selectOption ?? availableValues[0], onChange: handleSelectChange, isClearable: true, name: "color", options: availableValues, styles: colorStyles })));
57
+ };
58
+ export default ColorStatus;
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { ShowPropertyProps } from "adminjs";
3
+ declare const ColorStatusList: FC<ShowPropertyProps>;
4
+ export default ColorStatusList;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { ColorStatusBadge } from "./styles";
3
+ const ColorStatusList = ({ property, record }) => {
4
+ const currentOption = property.availableValues?.find((item) => item.value === record.params[property.path]);
5
+ return (React.createElement(ColorStatusBadge, { color: currentOption.color }, record.params[property.path]));
6
+ };
7
+ export default ColorStatusList;
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { ShowPropertyProps } from "adminjs";
3
+ declare const ColorStatusShow: FC<ShowPropertyProps>;
4
+ export default ColorStatusShow;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { ColorStatusBadgeWrapper, ColorStatusBadge, ShowLabel } from "./styles";
3
+ const ColorStatusShow = ({ property, record }) => {
4
+ const currentOption = property.availableValues?.find((item) => item.value === record.params[property.path]);
5
+ return (React.createElement(ColorStatusBadgeWrapper, null,
6
+ React.createElement(ShowLabel, null, property.path),
7
+ React.createElement(ColorStatusBadge, { color: currentOption.color }, record.params[property.path])));
8
+ };
9
+ export default ColorStatusShow;
@@ -0,0 +1,3 @@
1
+ export * from "./ColorStatusEdit.js";
2
+ export * from "./ColorStatusShow.js";
3
+ export * from "./ColorStatusList.js";
@@ -0,0 +1,3 @@
1
+ export * from "./ColorStatusEdit.js";
2
+ export * from "./ColorStatusShow.js";
3
+ export * from "./ColorStatusList.js";
@@ -0,0 +1,5 @@
1
+ export declare const ColorStatusWrapper: any;
2
+ export declare const Label: any;
3
+ export declare const ShowLabel: any;
4
+ export declare const ColorStatusBadgeWrapper: any;
5
+ export declare const ColorStatusBadge: any;
@@ -0,0 +1,25 @@
1
+ import { styled } from "@adminjs/design-system/styled-components";
2
+ export const ColorStatusWrapper = styled.div `
3
+ margin-bottom: 24px;
4
+ `;
5
+ export const Label = styled.div `
6
+ font-size: 12px;
7
+ margin-bottom: 8px;
8
+ `;
9
+ export const ShowLabel = styled.div `
10
+ font-size: 12px;
11
+ margin-bottom: 8px;
12
+ color: rgb(137, 138, 154);
13
+ `;
14
+ export const ColorStatusBadgeWrapper = styled.div `
15
+ margin-bottom: 20px;
16
+ `;
17
+ export const ColorStatusBadge = styled.div `
18
+ background-color: ${(props) => props.color};
19
+ width: fit-content;
20
+ padding: 5px 10px;
21
+ border-radius: 20px;
22
+ font-size: 12px;
23
+ color: white;
24
+ white-space: nowrap;
25
+ `;
@@ -0,0 +1,5 @@
1
+ export type AvailableValueType = {
2
+ value: string;
3
+ label: string;
4
+ color: string;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ export default Editor;
2
+ declare function Editor({ property, record, onChangeAdmin, editorId }: {
3
+ property: any;
4
+ record: any;
5
+ onChangeAdmin: any;
6
+ editorId: any;
7
+ }): React.FunctionComponentElement<{
8
+ children?: React.ReactNode;
9
+ theme: import("styled-components").DefaultTheme | ((outerTheme?: import("styled-components").DefaultTheme | undefined) => import("styled-components").DefaultTheme);
10
+ }>;
11
+ import React from "react";
@@ -0,0 +1,33 @@
1
+ import React, { memo, useState, useEffect, useRef } from "react";
2
+ import { ThemeProvider } from "styled-components";
3
+ import EditorJS from "@editorjs/editorjs";
4
+ import { theme } from "@adminjs/design-system";
5
+ import { StyledLabel, StyledEditor, StyledEditorWrapper } from "./styles";
6
+ import { EDITOR_TOOLS } from "./config";
7
+ const Editor = ({ property, record, onChangeAdmin, editorId }) => {
8
+ const [jsonData, setJsonData] = useState();
9
+ const isSavedData = Boolean(record.params[property.path]);
10
+ const ref = useRef();
11
+ useEffect(() => {
12
+ onChangeAdmin(property.path, jsonData);
13
+ }, [jsonData]);
14
+ useEffect(() => {
15
+ if (!ref.current) {
16
+ const editor = new EditorJS({
17
+ holder: editorId,
18
+ tools: EDITOR_TOOLS,
19
+ data: isSavedData ? JSON.parse(record.params[property.path]) : "",
20
+ async onChange(api, event) {
21
+ const data = await api.saver.save();
22
+ setJsonData(JSON.stringify(data));
23
+ },
24
+ });
25
+ ref.current = editor;
26
+ }
27
+ return () => {
28
+ ref?.current?.destroy?.();
29
+ };
30
+ }, []);
31
+ return (React.createElement(ThemeProvider, { theme: theme }, React.createElement(StyledLabel, null, property.path), React.createElement(StyledEditorWrapper, null, React.createElement(StyledEditor, { id: editorId }))));
32
+ };
33
+ export default Editor;
@@ -0,0 +1,9 @@
1
+ export default EditorList;
2
+ declare function EditorList({ property, record }: {
3
+ property: any;
4
+ record: any;
5
+ }): React.FunctionComponentElement<{
6
+ children?: React.ReactNode;
7
+ theme: import("styled-components").DefaultTheme | ((outerTheme?: import("styled-components").DefaultTheme | undefined) => import("styled-components").DefaultTheme);
8
+ }>;
9
+ import React from "react";
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { theme } from "@adminjs/design-system";
3
+ import { ThemeProvider } from "styled-components";
4
+ import { parseHtml } from "../../utils/parseHtml";
5
+ import { StyledEditorViewWrapper } from "./styles";
6
+ const EditorList = ({ property, record }) => {
7
+ const htmlContent = parseHtml(record.params[property.path]);
8
+ return (React.createElement(ThemeProvider, { theme: theme }, React.createElement(StyledEditorViewWrapper, null, htmlContent && (React.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })))));
9
+ };
10
+ export default EditorList;
@@ -0,0 +1,9 @@
1
+ export default EditorShow;
2
+ declare function EditorShow({ property, record }: {
3
+ property: any;
4
+ record: any;
5
+ }): React.FunctionComponentElement<{
6
+ children?: React.ReactNode;
7
+ theme: import("styled-components").DefaultTheme | ((outerTheme?: import("styled-components").DefaultTheme | undefined) => import("styled-components").DefaultTheme);
8
+ }>;
9
+ import React from "react";
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { ThemeProvider } from "styled-components";
3
+ import { theme } from "@adminjs/design-system";
4
+ import { parseHtml } from "../../utils/parseHtml";
5
+ import { StyledEditorShowWrapper, StyledShowLabel } from "./styles";
6
+ const EditorShow = ({ property, record }) => {
7
+ const htmlContent = parseHtml(record.params[property.path]);
8
+ return (React.createElement(ThemeProvider, { theme: theme }, React.createElement(StyledEditorShowWrapper, null, React.createElement(StyledShowLabel, null, property.path), htmlContent && (React.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })))));
9
+ };
10
+ export default EditorShow;
@@ -0,0 +1,29 @@
1
+ import Quote from "@editorjs/quote";
2
+ import Table from "@editorjs/table";
3
+ export declare const EDITOR_TOOLS: {
4
+ paragraph: {
5
+ class: any;
6
+ inlineToolbar: boolean;
7
+ };
8
+ list: {
9
+ class: any;
10
+ inlineToolbar: boolean;
11
+ };
12
+ header: {
13
+ class: any;
14
+ config: {
15
+ placeholder: string;
16
+ levels: number[];
17
+ defaultLevel: number;
18
+ };
19
+ };
20
+ table: {
21
+ class: typeof Table;
22
+ inlineToolbar: boolean;
23
+ };
24
+ quote: {
25
+ class: typeof Quote;
26
+ inlineToolbar: boolean;
27
+ };
28
+ audioPlayer: any;
29
+ };
@@ -0,0 +1,34 @@
1
+ import Header from "@editorjs/header";
2
+ import List from "@editorjs/list";
3
+ import Paragraph from "@editorjs/paragraph";
4
+ import Quote from "@editorjs/quote";
5
+ import Table from "@editorjs/table";
6
+ // @ts-ignore
7
+ import AudioPlayer from "editorjs-audio-player";
8
+ export const EDITOR_TOOLS = {
9
+ paragraph: {
10
+ class: Paragraph,
11
+ inlineToolbar: true,
12
+ },
13
+ list: {
14
+ class: List,
15
+ inlineToolbar: true,
16
+ },
17
+ header: {
18
+ class: Header,
19
+ config: {
20
+ placeholder: "Enter a header",
21
+ levels: [2, 3, 4],
22
+ defaultLevel: 2,
23
+ },
24
+ },
25
+ table: {
26
+ class: Table,
27
+ inlineToolbar: true,
28
+ },
29
+ quote: {
30
+ class: Quote,
31
+ inlineToolbar: true,
32
+ },
33
+ audioPlayer: AudioPlayer,
34
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./Editor.jsx";
2
+ export * from "./EditorShow.jsx";
3
+ export * from "./EditorList.jsx";
@@ -0,0 +1,3 @@
1
+ export * from "./Editor.jsx";
2
+ export * from "./EditorShow.jsx";
3
+ export * from "./EditorList.jsx";
@@ -0,0 +1,6 @@
1
+ export declare const StyledLabel: any;
2
+ export declare const StyledShowLabel: any;
3
+ export declare const StyledEditorWrapper: any;
4
+ export declare const StyledEditorViewWrapper: any;
5
+ export declare const StyledEditorShowWrapper: any;
6
+ export declare const StyledEditor: any;
@@ -0,0 +1,145 @@
1
+ import { Box } from "@adminjs/design-system";
2
+ import { styled } from "@adminjs/design-system/styled-components";
3
+ export const StyledLabel = styled.div `
4
+ font-size: 12px;
5
+ margin-bottom: 8px;
6
+ text-transform: capitalize;
7
+ `;
8
+ export const StyledShowLabel = styled(StyledLabel) `
9
+ color: rgb(137, 138, 154);
10
+ font-weight: 300;
11
+ `;
12
+ export const StyledEditorWrapper = styled(Box) `
13
+ padding: 12px;
14
+ margin-bottom: 24px;
15
+ border: 1px solid rgb(187, 195, 203);
16
+ `;
17
+ export const StyledEditorViewWrapper = styled(Box) `
18
+ h1,
19
+ h2,
20
+ h3 {
21
+ margin-bottom: 5px;
22
+ font-weight: bold;
23
+ }
24
+
25
+ h1 {
26
+ font-size: 18px;
27
+ }
28
+
29
+ h2 {
30
+ font-size: 16px;
31
+ }
32
+
33
+ h3 {
34
+ font-size: 14px;
35
+ }
36
+
37
+ p {
38
+ margin-bottom: 8px;
39
+ }
40
+
41
+ ol,
42
+ ul {
43
+ margin-left: 20px;
44
+ margin-bottom: 8px;
45
+ }
46
+
47
+ ol {
48
+ list-style: auto;
49
+ }
50
+
51
+ ul {
52
+ list-style: inherit;
53
+ }
54
+
55
+ table,
56
+ audio {
57
+ margin: 16px 0;
58
+ }
59
+
60
+ table,
61
+ th,
62
+ td {
63
+ border: 1px solid;
64
+ }
65
+
66
+ th {
67
+ font-weight: bold;
68
+ }
69
+
70
+ th,
71
+ td {
72
+ padding: 4px;
73
+ }
74
+
75
+ blockquote {
76
+ display: block;
77
+ padding: 5px 8px;
78
+ width: fit-content;
79
+ border-radius: 4px;
80
+ background-color: #e6e6e6;
81
+ }
82
+ `;
83
+ export const StyledEditorShowWrapper = styled(StyledEditorViewWrapper) `
84
+ margin-bottom: 24px;
85
+ `;
86
+ export const StyledEditor = styled.div `
87
+ audio,
88
+ .cdx-block,
89
+ .ce-header {
90
+ padding-left: 58px;
91
+ }
92
+
93
+ input {
94
+ margin-left: 58px;
95
+ width: auto;
96
+ }
97
+
98
+ .cdx-list {
99
+ padding-left: 85px;
100
+ }
101
+
102
+ .ce-block__content {
103
+ width: 100%;
104
+ max-width: none;
105
+ }
106
+
107
+ .ce-toolbar__content {
108
+ max-width: none;
109
+ left: 0;
110
+ }
111
+
112
+ .ce-toolbar__actions {
113
+ left: 0;
114
+ }
115
+
116
+ h1.ce-header {
117
+ font-size: 22px;
118
+ font-weight: bold;
119
+ }
120
+
121
+ h2.ce-header {
122
+ font-size: 20px;
123
+ font-weight: bold;
124
+ }
125
+
126
+ h3.ce-header {
127
+ font-size: 18px;
128
+ font-weight: bold;
129
+ }
130
+
131
+ h4.ce-header {
132
+ font-size: 16px;
133
+ font-weight: bold;
134
+ }
135
+
136
+ h5.ce-header {
137
+ font-size: 15px;
138
+ font-weight: bold;
139
+ }
140
+
141
+ h6.ce-header {
142
+ font-size: 14px;
143
+ font-weight: bold;
144
+ }
145
+ `;
@@ -0,0 +1,5 @@
1
+ import { EditPropertyProps } from "adminjs";
2
+ import { FC } from "react";
3
+ type CustomSlugTypes = Omit<EditPropertyProps, "where">;
4
+ declare const SlugEdit: FC<CustomSlugTypes>;
5
+ export default SlugEdit;
@@ -0,0 +1,27 @@
1
+ import React, { useEffect, useState, } from "react";
2
+ import { ThemeProvider } from "styled-components";
3
+ import { theme } from "@adminjs/design-system";
4
+ import { slugifyTitle } from "../../utils";
5
+ import { StyledCustomInput, StyledGenerateButton, StyledInputWrapper, StyledLabel, } from "./styles.js";
6
+ const SlugEdit = ({ property, record, resource, onChange, }) => {
7
+ const [inputValue, setInputValue] = useState(record.params.slug);
8
+ useEffect(() => {
9
+ onChange(property.path, inputValue);
10
+ }, [inputValue]);
11
+ return (React.createElement(ThemeProvider, { theme: theme },
12
+ React.createElement(StyledLabel, { htmlFor: "customSlug" }, property.path),
13
+ React.createElement(StyledInputWrapper, null,
14
+ React.createElement(StyledCustomInput, { id: property.path, name: property.path, value: inputValue, onChange: handleInput }),
15
+ React.createElement(StyledGenerateButton, { variant: "outlined", onClick: generateSlug }, "Generate Slug"))));
16
+ function handleInput(e) {
17
+ setInputValue(e.target.value);
18
+ }
19
+ function generateSlug(e) {
20
+ e.preventDefault();
21
+ const slugSource = record.params[property.props.sourceField ?? resource.titleProperty.name];
22
+ if (slugSource) {
23
+ setInputValue(slugifyTitle(slugSource));
24
+ }
25
+ }
26
+ };
27
+ export default SlugEdit;
@@ -0,0 +1,7 @@
1
+ import { ComponentLoader, FeatureType } from "adminjs";
2
+ type SlugOptions = {
3
+ componentLoader: ComponentLoader;
4
+ key: string;
5
+ };
6
+ declare const SlugFeature: (config: SlugOptions) => FeatureType;
7
+ export default SlugFeature;
@@ -0,0 +1,21 @@
1
+ import { buildFeature } from "adminjs";
2
+ import { bundleComponent } from "../../utils/bundle-component";
3
+ const COMPONENT_NAME = 'Slug';
4
+ const SlugFeature = (config) => {
5
+ const { componentLoader, key } = config;
6
+ const slugFeature = () => {
7
+ const editComponent = bundleComponent(componentLoader, COMPONENT_NAME, 'SlugEdit.js');
8
+ return buildFeature({
9
+ properties: {
10
+ [key]: {
11
+ isVisible: { show: false, edit: true, list: false, filter: false },
12
+ components: {
13
+ edit: editComponent,
14
+ },
15
+ },
16
+ },
17
+ });
18
+ };
19
+ return slugFeature();
20
+ };
21
+ export default SlugFeature;
@@ -0,0 +1 @@
1
+ export { default } from "./SlugFeature.js";
@@ -0,0 +1 @@
1
+ export { default } from "./SlugFeature.js";
@@ -0,0 +1,4 @@
1
+ export declare const StyledInputWrapper: any;
2
+ export declare const StyledCustomInput: any;
3
+ export declare const StyledGenerateButton: any;
4
+ export declare const StyledLabel: any;
@@ -0,0 +1,20 @@
1
+ // @ts-ignore
2
+ import { styled } from "@adminjs/design-system/styled-components";
3
+ // @ts-ignore
4
+ import { Box, Button, Input } from "@adminjs/design-system";
5
+ export const StyledInputWrapper = styled(Box) `
6
+ display: flex;
7
+ margin-bottom: 40px;
8
+ `;
9
+ export const StyledCustomInput = styled(Input) `
10
+ width: 100%;
11
+ margin-right: 10px;
12
+ `;
13
+ export const StyledGenerateButton = styled(Button) `
14
+ white-space: nowrap;
15
+ `;
16
+ export const StyledLabel = styled.div `
17
+ font-size: 12px;
18
+ margin-bottom: 8px;
19
+ text-transform: capitalize;
20
+ `;
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import type { ReactNode } from "react";
3
+ import { SortableItem } from "./components/index.js";
4
+ import type { UniqueIdentifier } from "@dnd-kit/core";
5
+ interface BaseItem {
6
+ id: UniqueIdentifier;
7
+ value: string;
8
+ }
9
+ interface Props<T extends BaseItem> {
10
+ items: T[];
11
+ onChange(items: T[]): void;
12
+ renderItem(item: T): ReactNode;
13
+ }
14
+ export declare function SortableList<T extends BaseItem>({ items, onChange, renderItem, }: Props<T>): React.JSX.Element;
15
+ export declare namespace SortableList {
16
+ var Item: typeof SortableItem;
17
+ }
18
+ export {};
@@ -0,0 +1,37 @@
1
+ import React, { Fragment, useMemo, useState } from "react";
2
+ import { DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors, DragOverlay, defaultDropAnimationSideEffects, } from "@dnd-kit/core";
3
+ import { SortableContext, arrayMove, sortableKeyboardCoordinates, verticalListSortingStrategy, } from "@dnd-kit/sortable";
4
+ import { SortableItem } from "./components/index.js";
5
+ import { StyledListWrapper } from "./styles.js";
6
+ const dropAnimationConfig = {
7
+ sideEffects: defaultDropAnimationSideEffects({
8
+ styles: {
9
+ active: {
10
+ opacity: "0.4",
11
+ },
12
+ },
13
+ }),
14
+ };
15
+ export function SortableList({ items, onChange, renderItem, }) {
16
+ const [active, setActive] = useState(null);
17
+ const activeItem = useMemo(() => items.find((item) => item.id === active?.id), [active, items]);
18
+ const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
19
+ coordinateGetter: sortableKeyboardCoordinates,
20
+ }));
21
+ return (React.createElement(DndContext, { sensors: sensors, onDragStart: ({ active }) => {
22
+ setActive(active);
23
+ }, onDragEnd: ({ active, over }) => {
24
+ if (over && active.id !== over?.id) {
25
+ const activeIndex = items.findIndex(({ id }) => id === active.id);
26
+ const overIndex = items.findIndex(({ id }) => id === over.id);
27
+ onChange(arrayMove(items, activeIndex, overIndex));
28
+ }
29
+ setActive(null);
30
+ }, onDragCancel: () => {
31
+ setActive(null);
32
+ } },
33
+ React.createElement(SortableContext, { items: items, strategy: verticalListSortingStrategy },
34
+ React.createElement(StyledListWrapper, { role: "application" }, items.map((item, index) => (React.createElement(Fragment, { key: index }, renderItem(item)))))),
35
+ React.createElement(DragOverlay, { dropAnimation: dropAnimationConfig }, activeItem ? renderItem(activeItem) : null)));
36
+ }
37
+ SortableList.Item = SortableItem;
@@ -0,0 +1,7 @@
1
+ import { Context, FC } from "react";
2
+ import type { DragContext } from "./types.js";
3
+ interface DragHandlePropsType {
4
+ context: Context<DragContext>;
5
+ }
6
+ export declare const DragHandle: FC<DragHandlePropsType>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import React, { useContext } from "react";
2
+ import { StyledDragButton } from "./styles.js";
3
+ export const DragHandle = ({ context }) => {
4
+ const { attributes, listeners, ref } = useContext(context);
5
+ return (React.createElement(StyledDragButton, { ...attributes, ...listeners, ref: ref },
6
+ React.createElement("svg", { viewBox: "0 0 20 20", width: "13" },
7
+ React.createElement("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }))));
8
+ };
@@ -0,0 +1,8 @@
1
+ import React, { ChangeEvent } from 'react';
2
+ import type { PropsWithChildren } from 'react';
3
+ interface SortableItemPropsType {
4
+ id: string;
5
+ onDelete: (e: ChangeEvent<HTMLInputElement>, id: string) => void;
6
+ }
7
+ export declare function SortableItem({ children, id, onDelete, }: PropsWithChildren<SortableItemPropsType>): React.JSX.Element;
8
+ export {};