@rulab/adminjs-components 0.0.13 → 0.1.0-alpha.10

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 (180) hide show
  1. package/LICENSE +21 -21
  2. package/dist/components/ColorStatus/ColorStatusEdit.d.ts +5 -0
  3. package/dist/components/ColorStatus/ColorStatusEdit.js +58 -0
  4. package/dist/components/ColorStatus/ColorStatusList.d.ts +4 -0
  5. package/dist/components/ColorStatus/ColorStatusList.js +7 -0
  6. package/dist/components/ColorStatus/ColorStatusShow.d.ts +4 -0
  7. package/dist/components/ColorStatus/ColorStatusShow.js +9 -0
  8. package/dist/components/ColorStatus/index.d.ts +3 -0
  9. package/dist/components/ColorStatus/index.js +3 -0
  10. package/dist/components/ColorStatus/styles.d.ts +5 -0
  11. package/dist/components/ColorStatus/styles.js +25 -0
  12. package/dist/components/ColorStatus/types.d.ts +5 -0
  13. package/dist/components/ColorStatus/types.js +1 -0
  14. package/dist/components/Editor/Editor.d.ts +11 -0
  15. package/dist/components/Editor/Editor.js +33 -0
  16. package/dist/components/Editor/EditorList.d.ts +9 -0
  17. package/dist/components/Editor/EditorList.js +10 -0
  18. package/dist/components/Editor/EditorShow.d.ts +9 -0
  19. package/dist/components/Editor/EditorShow.js +10 -0
  20. package/dist/components/Editor/config.d.ts +29 -0
  21. package/dist/components/Editor/config.js +26 -3
  22. package/dist/components/Editor/index.d.ts +3 -0
  23. package/dist/components/Editor/index.js +3 -1
  24. package/dist/components/Editor/styles.d.ts +6 -0
  25. package/dist/components/Editor/styles.js +140 -59
  26. package/dist/components/Slug/SlugEdit.d.ts +5 -0
  27. package/dist/components/Slug/SlugEdit.js +27 -0
  28. package/dist/components/Slug/SlugFeature.d.ts +7 -0
  29. package/dist/components/Slug/SlugFeature.js +21 -0
  30. package/dist/components/Slug/index.d.ts +1 -0
  31. package/dist/components/Slug/index.js +1 -0
  32. package/dist/components/Slug/styles.d.ts +4 -0
  33. package/dist/components/{CustomSlug → Slug}/styles.js +14 -9
  34. package/dist/components/StringList/SortableList/SortableList.d.ts +18 -0
  35. package/dist/components/StringList/SortableList/{SortableList.jsx → SortableList.js} +13 -19
  36. package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +7 -0
  37. package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.js +8 -0
  38. package/dist/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +8 -0
  39. package/dist/components/StringList/SortableList/components/SortableItem/{SortableItem.jsx → SortableItem.js} +7 -11
  40. package/dist/components/StringList/SortableList/components/SortableItem/styles.d.ts +2 -0
  41. package/dist/components/StringList/SortableList/components/SortableItem/styles.js +18 -18
  42. package/dist/components/StringList/SortableList/components/SortableItem/types.d.ts +6 -0
  43. package/dist/components/StringList/SortableList/components/index.d.ts +2 -0
  44. package/dist/components/StringList/SortableList/index.d.ts +1 -0
  45. package/dist/components/StringList/SortableList/styles.d.ts +1 -0
  46. package/dist/components/StringList/SortableList/styles.js +6 -6
  47. package/dist/components/StringList/StringList.d.ts +8 -0
  48. package/dist/components/StringList/StringList.js +60 -0
  49. package/dist/components/StringList/StringListShow.d.ts +7 -0
  50. package/dist/components/StringList/StringListShow.js +14 -0
  51. package/dist/components/StringList/constants.d.ts +1 -0
  52. package/dist/components/StringList/constants.js +1 -0
  53. package/dist/components/StringList/index.d.ts +2 -0
  54. package/dist/components/StringList/index.js +2 -1
  55. package/dist/components/StringList/styles.d.ts +8 -0
  56. package/dist/components/StringList/styles.js +28 -11
  57. package/dist/components/index.d.ts +7 -0
  58. package/dist/components/index.js +9 -2
  59. package/dist/index.d.ts +2 -44
  60. package/dist/index.js +2 -757
  61. package/dist/scripts/fix-import-extensions.d.ts +1 -0
  62. package/dist/scripts/fix-import-extensions.js +39 -0
  63. package/dist/utils/bundle-component.d.ts +2 -0
  64. package/dist/utils/bundle-component.js +8 -0
  65. package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -1
  66. package/dist/utils/index.js +1 -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 +1 -1
  71. package/dist/utils/slugifyTitle.d.ts +1 -0
  72. package/dist/utils/slugifyTitle.js +3 -3
  73. package/package.json +14 -8
  74. package/src/components/ColorStatus/ColorStatusEdit.d.ts +5 -0
  75. package/src/components/ColorStatus/ColorStatusEdit.js +58 -0
  76. package/src/components/ColorStatus/ColorStatusEdit.tsx +94 -94
  77. package/src/components/ColorStatus/ColorStatusList.d.ts +4 -0
  78. package/src/components/ColorStatus/ColorStatusList.js +7 -0
  79. package/src/components/ColorStatus/ColorStatusList.tsx +20 -20
  80. package/src/components/ColorStatus/ColorStatusShow.d.ts +4 -0
  81. package/src/components/ColorStatus/ColorStatusShow.js +9 -0
  82. package/src/components/ColorStatus/ColorStatusShow.tsx +23 -23
  83. package/src/components/ColorStatus/index.d.ts +3 -0
  84. package/src/components/ColorStatus/index.js +3 -0
  85. package/src/components/ColorStatus/index.ts +3 -3
  86. package/src/components/ColorStatus/styles.d.ts +5 -0
  87. package/src/components/ColorStatus/styles.js +25 -0
  88. package/src/components/ColorStatus/styles.ts +30 -30
  89. package/src/components/ColorStatus/types.d.ts +5 -0
  90. package/src/components/ColorStatus/types.js +1 -0
  91. package/src/components/ColorStatus/types.ts +5 -5
  92. package/src/components/Editor/Editor.d.ts +8 -0
  93. package/src/components/Editor/Editor.js +36 -0
  94. package/src/components/Editor/Editor.jsx +49 -49
  95. package/src/components/Editor/EditorList.d.ts +6 -0
  96. package/src/components/Editor/EditorList.js +11 -0
  97. package/src/components/Editor/EditorList.jsx +22 -22
  98. package/src/components/Editor/EditorShow.d.ts +6 -0
  99. package/src/components/Editor/EditorShow.js +13 -0
  100. package/src/components/Editor/EditorShow.jsx +24 -24
  101. package/src/components/Editor/config.d.ts +29 -0
  102. package/src/components/Editor/config.js +34 -0
  103. package/src/components/Editor/config.ts +35 -35
  104. package/src/components/Editor/index.d.ts +3 -0
  105. package/src/components/Editor/index.js +3 -0
  106. package/src/components/Editor/index.ts +3 -3
  107. package/src/components/Editor/styles.d.ts +6 -0
  108. package/src/components/Editor/styles.js +145 -0
  109. package/src/components/Editor/styles.ts +151 -151
  110. package/src/components/Slug/SlugEdit.d.ts +5 -0
  111. package/src/components/Slug/SlugEdit.js +27 -0
  112. package/src/components/{CustomSlug/CustomSlug.tsx → Slug/SlugEdit.tsx} +68 -68
  113. package/src/components/Slug/SlugFeature.d.ts +7 -0
  114. package/src/components/Slug/SlugFeature.js +21 -0
  115. package/src/components/Slug/SlugFeature.ts +30 -0
  116. package/src/components/Slug/index.d.ts +1 -0
  117. package/src/components/Slug/index.js +1 -0
  118. package/src/components/Slug/index.ts +1 -0
  119. package/src/components/Slug/styles.d.ts +4 -0
  120. package/src/components/Slug/styles.js +20 -0
  121. package/src/components/{CustomSlug → Slug}/styles.ts +24 -24
  122. package/src/components/StringList/SortableList/SortableList.d.ts +18 -0
  123. package/src/components/StringList/SortableList/SortableList.js +37 -0
  124. package/src/components/StringList/SortableList/SortableList.tsx +98 -98
  125. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +7 -0
  126. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.js +8 -0
  127. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx +20 -20
  128. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +8 -0
  129. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.js +28 -0
  130. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx +59 -59
  131. package/src/components/StringList/SortableList/components/SortableItem/styles.d.ts +2 -0
  132. package/src/components/StringList/SortableList/components/SortableItem/styles.js +20 -0
  133. package/src/components/StringList/SortableList/components/SortableItem/styles.ts +22 -22
  134. package/src/components/StringList/SortableList/components/SortableItem/types.d.ts +6 -0
  135. package/src/components/StringList/SortableList/components/SortableItem/types.js +1 -0
  136. package/src/components/StringList/SortableList/components/SortableItem/types.ts +7 -7
  137. package/src/components/StringList/SortableList/components/index.d.ts +2 -0
  138. package/src/components/StringList/SortableList/components/index.js +2 -0
  139. package/src/components/StringList/SortableList/components/index.ts +2 -2
  140. package/src/components/StringList/SortableList/index.d.ts +1 -0
  141. package/src/components/StringList/SortableList/index.js +1 -0
  142. package/src/components/StringList/SortableList/index.ts +1 -1
  143. package/src/components/StringList/SortableList/styles.d.ts +1 -0
  144. package/src/components/StringList/SortableList/styles.js +8 -0
  145. package/src/components/StringList/SortableList/styles.ts +9 -9
  146. package/src/components/StringList/StringList.d.ts +8 -0
  147. package/src/components/StringList/StringList.js +60 -0
  148. package/src/components/StringList/StringList.tsx +136 -136
  149. package/src/components/StringList/StringListShow.d.ts +7 -0
  150. package/src/components/StringList/StringListShow.js +14 -0
  151. package/src/components/StringList/StringListShow.tsx +37 -37
  152. package/src/components/StringList/constants.d.ts +1 -0
  153. package/src/components/StringList/constants.js +1 -0
  154. package/src/components/StringList/constants.ts +1 -1
  155. package/src/components/StringList/index.d.ts +2 -0
  156. package/src/components/StringList/index.js +2 -0
  157. package/src/components/StringList/index.ts +2 -2
  158. package/src/components/StringList/styles.d.ts +8 -0
  159. package/src/components/StringList/styles.js +33 -0
  160. package/src/components/StringList/styles.ts +41 -41
  161. package/src/components/index.d.ts +7 -0
  162. package/src/components/index.js +10 -0
  163. package/src/components/index.ts +10 -9
  164. package/dist/bundle.js +0 -8
  165. package/dist/components/CustomSlug/CustomSlug.jsx +0 -29
  166. package/dist/components/CustomSlug/index.js +0 -1
  167. package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.jsx +0 -10
  168. package/dist/components/StringList/StringList.jsx +0 -67
  169. package/dist/editorFeature.js +0 -16
  170. package/dist/index.cjs +0 -784
  171. package/dist/index.d.cts +0 -44
  172. package/dist/index.d.mts +0 -8
  173. package/dist/index.mjs +0 -37
  174. package/src/components/CustomSlug/index.ts +0 -1
  175. package/src/index.ts +0 -2
  176. package/src/types.d.ts +0 -3
  177. package/src/utils/parseHtml.ts +0 -56
  178. package/src/utils/slugifyImport.ts +0 -4
  179. package/src/utils/slugifyTitle.ts +0 -11
  180. package/tsconfig.json +0 -17
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Roman Daud
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Roman Daud
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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.js";
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.js";
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.js";
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.js";
6
+ import { EDITOR_TOOLS } from "./config.js";
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.js";
5
+ import { StyledEditorViewWrapper } from "./styles.js";
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.js";
5
+ import { StyledEditorShowWrapper, StyledShowLabel } from "./styles.js";
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
+ };
@@ -1,11 +1,34 @@
1
1
  import Header from "@editorjs/header";
2
- import Paragraph from "@editorjs/paragraph";
3
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";
4
8
  export const EDITOR_TOOLS = {
5
9
  paragraph: {
6
10
  class: Paragraph,
7
11
  inlineToolbar: true,
8
12
  },
9
- list: List,
10
- header: Header,
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,
11
34
  };
@@ -0,0 +1,3 @@
1
+ export * from "./Editor.jsx";
2
+ export * from "./EditorShow.jsx";
3
+ export * from "./EditorList.jsx";
@@ -1 +1,3 @@
1
- export { default } from "./Editor.jsx";
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;
@@ -1,64 +1,145 @@
1
1
  import { Box } from "@adminjs/design-system";
2
2
  import { styled } from "@adminjs/design-system/styled-components";
3
- export const Label = styled.div `
4
- font-size: 12px;
5
- margin-bottom: 8px;
3
+ export const StyledLabel = styled.div `
4
+ font-size: 12px;
5
+ margin-bottom: 8px;
6
+ text-transform: capitalize;
6
7
  `;
7
- export const EditorWrapper = styled(Box) `
8
- padding: 12px;
9
- border: 1px solid rgb(187, 195, 203);
8
+ export const StyledShowLabel = styled(StyledLabel) `
9
+ color: rgb(137, 138, 154);
10
+ font-weight: 300;
10
11
  `;
11
- export const StyledEditor = styled.div `
12
- .cdx-block,
13
- .ce-header {
14
- padding-left: 58px;
15
- }
16
-
17
- .cdx-list {
18
- padding-left: 85px;
19
- }
20
-
21
- .ce-block__content {
22
- width: 100%;
23
- max-width: none;
24
- }
25
-
26
- .ce-toolbar__content {
27
- max-width: none;
28
- left: 0;
29
- }
30
-
31
- .ce-toolbar__actions {
32
- left: 0;
33
- }
34
-
35
- h1.ce-header {
36
- font-size: 22px;
37
- font-weight: bold;
38
- }
39
-
40
- h2.ce-header {
41
- font-size: 20px;
42
- font-weight: bold;
43
- }
44
-
45
- h3.ce-header {
46
- font-size: 18px;
47
- font-weight: bold;
48
- }
49
-
50
- h4.ce-header {
51
- font-size: 16px;
52
- font-weight: bold;
53
- }
54
-
55
- h5.ce-header {
56
- font-size: 15px;
57
- font-weight: bold;
58
- }
59
-
60
- h6.ce-header {
61
- font-size: 14px;
62
- font-weight: bold;
63
- }
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
+ }
64
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/index.js";
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.js";
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;