@rulab/adminjs-components 0.1.0-alpha.8 → 0.1.0-beta.1

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 (159) hide show
  1. package/dist/components/ColorStatus/ColorStatusEdit.d.ts +2 -2
  2. package/dist/components/ColorStatus/ColorStatusEdit.js +3 -3
  3. package/dist/components/ColorStatus/ColorStatusFeature.d.ts +9 -0
  4. package/dist/components/ColorStatus/ColorStatusFeature.js +23 -0
  5. package/dist/components/ColorStatus/ColorStatusList.d.ts +1 -1
  6. package/dist/components/ColorStatus/ColorStatusList.js +4 -2
  7. package/dist/components/ColorStatus/ColorStatusShow.d.ts +1 -1
  8. package/dist/components/ColorStatus/ColorStatusShow.js +5 -3
  9. package/dist/components/ColorStatus/index.d.ts +4 -3
  10. package/dist/components/ColorStatus/index.js +4 -3
  11. package/dist/components/ColorStatus/styles.js +2 -1
  12. package/dist/components/Editor/Editor.d.ts +4 -2
  13. package/dist/components/Editor/Editor.js +79 -16
  14. package/dist/components/Editor/EditorFeature.d.ts +10 -0
  15. package/dist/components/Editor/EditorFeature.js +82 -0
  16. package/dist/components/Editor/EditorList.d.ts +2 -2
  17. package/dist/components/Editor/EditorList.js +1 -1
  18. package/dist/components/Editor/EditorShow.d.ts +2 -2
  19. package/dist/components/Editor/EditorShow.js +2 -2
  20. package/dist/components/Editor/index.d.ts +4 -3
  21. package/dist/components/Editor/index.js +4 -3
  22. package/dist/components/FeatureTabs/FeatureTabsEdit.d.ts +4 -0
  23. package/dist/components/FeatureTabs/FeatureTabsEdit.js +105 -0
  24. package/dist/components/FeatureTabs/FeatureTabsFeature.d.ts +8 -0
  25. package/dist/components/FeatureTabs/FeatureTabsFeature.js +28 -0
  26. package/dist/components/FeatureTabs/FeatureTabsShow.d.ts +4 -0
  27. package/dist/components/FeatureTabs/FeatureTabsShow.js +61 -0
  28. package/dist/components/FeatureTabs/index.d.ts +4 -0
  29. package/dist/components/FeatureTabs/index.js +4 -0
  30. package/dist/components/Preview/PreviewAction.d.ts +4 -0
  31. package/dist/components/Preview/PreviewAction.js +22 -0
  32. package/dist/components/Preview/PreviewFeature.d.ts +9 -0
  33. package/dist/components/Preview/PreviewFeature.js +31 -0
  34. package/dist/components/Preview/index.d.ts +2 -0
  35. package/dist/components/Preview/index.js +2 -0
  36. package/dist/components/Slug/SlugEdit.d.ts +1 -1
  37. package/dist/components/Slug/SlugEdit.js +9 -3
  38. package/dist/components/Slug/SlugFeature.d.ts +3 -6
  39. package/dist/components/Slug/SlugFeature.js +12 -14
  40. package/dist/components/Slug/SlugOptions.type.d.ts +7 -0
  41. package/dist/components/StringList/StringList.d.ts +1 -1
  42. package/dist/components/StringList/StringList.js +4 -4
  43. package/dist/components/StringList/StringListFeature.d.ts +7 -0
  44. package/dist/components/StringList/StringListFeature.js +20 -0
  45. package/dist/components/StringList/StringListShow.d.ts +1 -1
  46. package/dist/components/StringList/StringListShow.js +2 -2
  47. package/dist/components/StringList/index.d.ts +3 -2
  48. package/dist/components/StringList/index.js +3 -2
  49. package/dist/components/StringList/styles.js +2 -1
  50. package/dist/components/Tabs/TabsEdit.d.ts +4 -0
  51. package/dist/components/Tabs/TabsEdit.js +103 -0
  52. package/dist/components/Tabs/TabsFeature.d.ts +7 -0
  53. package/dist/components/Tabs/TabsFeature.js +26 -0
  54. package/dist/components/Tabs/TabsShow.d.ts +4 -0
  55. package/dist/components/Tabs/TabsShow.js +61 -0
  56. package/dist/components/Tabs/index.d.ts +3 -0
  57. package/dist/components/Tabs/index.js +3 -0
  58. package/dist/components/index.d.ts +15 -7
  59. package/dist/components/index.js +15 -10
  60. package/dist/index.d.ts +1 -0
  61. package/dist/index.js +1 -0
  62. package/dist/types/upload-provider.d.ts +13 -0
  63. package/dist/utils/bundle-component.d.ts +1 -1
  64. package/dist/utils/bundle-component.js +5 -8
  65. package/dist/utils/component-loader.d.ts +3 -0
  66. package/dist/utils/component-loader.js +10 -0
  67. package/dist/utils/index.d.ts +1 -0
  68. package/dist/utils/index.js +1 -0
  69. package/package.json +12 -11
  70. package/src/components/ColorStatus/ColorStatusEdit.d.ts +0 -5
  71. package/src/components/ColorStatus/ColorStatusEdit.js +0 -58
  72. package/src/components/ColorStatus/ColorStatusEdit.tsx +0 -94
  73. package/src/components/ColorStatus/ColorStatusList.d.ts +0 -4
  74. package/src/components/ColorStatus/ColorStatusList.js +0 -7
  75. package/src/components/ColorStatus/ColorStatusList.tsx +0 -20
  76. package/src/components/ColorStatus/ColorStatusShow.d.ts +0 -4
  77. package/src/components/ColorStatus/ColorStatusShow.js +0 -9
  78. package/src/components/ColorStatus/ColorStatusShow.tsx +0 -23
  79. package/src/components/ColorStatus/index.d.ts +0 -3
  80. package/src/components/ColorStatus/index.js +0 -3
  81. package/src/components/ColorStatus/index.ts +0 -3
  82. package/src/components/ColorStatus/styles.d.ts +0 -5
  83. package/src/components/ColorStatus/styles.js +0 -25
  84. package/src/components/ColorStatus/styles.ts +0 -30
  85. package/src/components/ColorStatus/types.d.ts +0 -5
  86. package/src/components/ColorStatus/types.ts +0 -5
  87. package/src/components/Editor/Editor.d.ts +0 -8
  88. package/src/components/Editor/Editor.js +0 -36
  89. package/src/components/Editor/Editor.jsx +0 -49
  90. package/src/components/Editor/EditorList.d.ts +0 -6
  91. package/src/components/Editor/EditorList.js +0 -11
  92. package/src/components/Editor/EditorList.jsx +0 -22
  93. package/src/components/Editor/EditorShow.d.ts +0 -6
  94. package/src/components/Editor/EditorShow.js +0 -13
  95. package/src/components/Editor/EditorShow.jsx +0 -24
  96. package/src/components/Editor/config.d.ts +0 -29
  97. package/src/components/Editor/config.js +0 -34
  98. package/src/components/Editor/config.ts +0 -35
  99. package/src/components/Editor/index.d.ts +0 -3
  100. package/src/components/Editor/index.js +0 -3
  101. package/src/components/Editor/index.ts +0 -3
  102. package/src/components/Editor/styles.d.ts +0 -6
  103. package/src/components/Editor/styles.js +0 -145
  104. package/src/components/Editor/styles.ts +0 -151
  105. package/src/components/Slug/SlugEdit.d.ts +0 -5
  106. package/src/components/Slug/SlugEdit.js +0 -27
  107. package/src/components/Slug/SlugEdit.tsx +0 -68
  108. package/src/components/Slug/SlugFeature.d.ts +0 -7
  109. package/src/components/Slug/SlugFeature.js +0 -21
  110. package/src/components/Slug/SlugFeature.ts +0 -30
  111. package/src/components/Slug/index.d.ts +0 -1
  112. package/src/components/Slug/index.js +0 -1
  113. package/src/components/Slug/index.ts +0 -1
  114. package/src/components/Slug/styles.d.ts +0 -4
  115. package/src/components/Slug/styles.js +0 -20
  116. package/src/components/Slug/styles.ts +0 -24
  117. package/src/components/StringList/SortableList/SortableList.d.ts +0 -18
  118. package/src/components/StringList/SortableList/SortableList.js +0 -37
  119. package/src/components/StringList/SortableList/SortableList.tsx +0 -98
  120. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +0 -7
  121. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.js +0 -8
  122. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx +0 -20
  123. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +0 -8
  124. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.js +0 -28
  125. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx +0 -59
  126. package/src/components/StringList/SortableList/components/SortableItem/styles.d.ts +0 -2
  127. package/src/components/StringList/SortableList/components/SortableItem/styles.js +0 -20
  128. package/src/components/StringList/SortableList/components/SortableItem/styles.ts +0 -22
  129. package/src/components/StringList/SortableList/components/SortableItem/types.d.ts +0 -6
  130. package/src/components/StringList/SortableList/components/SortableItem/types.ts +0 -7
  131. package/src/components/StringList/SortableList/components/index.d.ts +0 -2
  132. package/src/components/StringList/SortableList/components/index.js +0 -2
  133. package/src/components/StringList/SortableList/components/index.ts +0 -2
  134. package/src/components/StringList/SortableList/index.d.ts +0 -1
  135. package/src/components/StringList/SortableList/index.js +0 -1
  136. package/src/components/StringList/SortableList/index.ts +0 -1
  137. package/src/components/StringList/SortableList/styles.d.ts +0 -1
  138. package/src/components/StringList/SortableList/styles.js +0 -8
  139. package/src/components/StringList/SortableList/styles.ts +0 -9
  140. package/src/components/StringList/StringList.d.ts +0 -8
  141. package/src/components/StringList/StringList.js +0 -60
  142. package/src/components/StringList/StringList.tsx +0 -136
  143. package/src/components/StringList/StringListShow.d.ts +0 -7
  144. package/src/components/StringList/StringListShow.js +0 -14
  145. package/src/components/StringList/StringListShow.tsx +0 -37
  146. package/src/components/StringList/constants.d.ts +0 -1
  147. package/src/components/StringList/constants.js +0 -1
  148. package/src/components/StringList/constants.ts +0 -1
  149. package/src/components/StringList/index.d.ts +0 -2
  150. package/src/components/StringList/index.js +0 -2
  151. package/src/components/StringList/index.ts +0 -2
  152. package/src/components/StringList/styles.d.ts +0 -8
  153. package/src/components/StringList/styles.js +0 -33
  154. package/src/components/StringList/styles.ts +0 -41
  155. package/src/components/index.d.ts +0 -7
  156. package/src/components/index.js +0 -10
  157. package/src/components/index.ts +0 -10
  158. /package/{src/components/ColorStatus/types.js → dist/components/Slug/SlugOptions.type.js} +0 -0
  159. /package/{src/components/StringList/SortableList/components/SortableItem/types.js → dist/types/upload-provider.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./components/index.js";
2
2
  export { parseHtml } from "./utils/parseHtml.js";
3
+ export { getComponentLoader, setComponentLoader } from "./utils/component-loader.js";
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./components/index.js";
2
2
  export { parseHtml } from "./utils/parseHtml.js";
3
+ export { getComponentLoader, setComponentLoader } from "./utils/component-loader.js";
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ export type UploadProviderFile = {
3
+ buffer: Buffer;
4
+ filename: string;
5
+ mimeType: string;
6
+ };
7
+ export type UploadProviderResult = {
8
+ url: string;
9
+ [key: string]: any;
10
+ };
11
+ export interface BaseProvider {
12
+ upload(file: UploadProviderFile): Promise<UploadProviderResult | string>;
13
+ }
@@ -1,2 +1,2 @@
1
1
  import type { ComponentLoader } from 'adminjs';
2
- export declare const bundleComponent: (loader: ComponentLoader, componentName: string, componentFile: string) => string;
2
+ export declare const bundleComponent: (loader: ComponentLoader | undefined, componentName: string, componentFile: string) => string;
@@ -1,13 +1,10 @@
1
1
  import path from 'path';
2
2
  import * as url from 'url';
3
+ import { getComponentLoader } from './component-loader.js';
3
4
  const dirname = url.fileURLToPath(new URL('.', import.meta.url));
4
- //const __filename = url.fileURLToPath(new URL('.', import.meta.url))
5
- //const __dirname = path.dirname(__filename)
6
- //const require = createRequire(import.meta.url)
7
- //const basePath = path.dirname(require.resolve('@rulab/adminjs-components'))
8
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
9
5
  export const bundleComponent = (loader, componentName, componentFile) => {
10
- const componentPath = path.join(dirname, '../dist/components', componentName, componentFile);
11
- console.log('[bundleComponent] Registering:', componentPath);
12
- return loader.add(componentName, componentPath);
6
+ const resolvedLoader = loader ?? getComponentLoader();
7
+ const componentPath = path.join(dirname, '../components', componentName, componentFile);
8
+ const componentId = componentFile.replace(/\.[^.]+$/, '');
9
+ return resolvedLoader.add(componentId, componentPath);
13
10
  };
@@ -0,0 +1,3 @@
1
+ import type { ComponentLoader } from "adminjs";
2
+ export declare const setComponentLoader: (loader: ComponentLoader | unknown) => void;
3
+ export declare const getComponentLoader: () => ComponentLoader;
@@ -0,0 +1,10 @@
1
+ let defaultComponentLoader = null;
2
+ export const setComponentLoader = (loader) => {
3
+ defaultComponentLoader = loader;
4
+ };
5
+ export const getComponentLoader = () => {
6
+ if (!defaultComponentLoader) {
7
+ throw new Error("ComponentLoader is not set. Call setComponentLoader(loader) before using features without explicit loader.");
8
+ }
9
+ return defaultComponentLoader;
10
+ };
@@ -1,2 +1,3 @@
1
1
  export { parseHtml } from "./parseHtml.js";
2
2
  export { slugifyTitle } from "./slugifyTitle.js";
3
+ export { getComponentLoader, setComponentLoader } from "./component-loader.js";
@@ -1,2 +1,3 @@
1
1
  export { parseHtml } from "./parseHtml.js";
2
2
  export { slugifyTitle } from "./slugifyTitle.js";
3
+ export { getComponentLoader, setComponentLoader } from "./component-loader.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulab/adminjs-components",
3
- "version": "0.1.0-alpha.8",
3
+ "version": "0.1.0-beta.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -10,14 +10,21 @@
10
10
  "adminjs"
11
11
  ],
12
12
  "repository": {
13
- "url": "https://github.com/rulab/adminjs-components"
13
+ "url": "git+https://github.com/rulab/adminjs-components.git"
14
+ },
15
+ "scripts": {
16
+ "build": "tsc && node scripts/fix-import-extensions.js",
17
+ "build-tsup": "tsup",
18
+ "lint": "tsc"
14
19
  },
15
20
  "dependencies": {
16
21
  "@adminjs/design-system": "^4.1.1",
22
+ "@adminjs/upload": "^4.0.2",
17
23
  "@dnd-kit/core": "^6.1.0",
18
24
  "@dnd-kit/sortable": "^8.0.0",
19
25
  "@editorjs/editorjs": "2.30.2",
20
26
  "@editorjs/header": "^2.8.7",
27
+ "@editorjs/image": "^2.9.2",
21
28
  "@editorjs/list": "^1.9.0",
22
29
  "@editorjs/paragraph": "^2.11.6",
23
30
  "@editorjs/quote": "^2.7.2",
@@ -44,13 +51,7 @@
44
51
  "node": ">=18"
45
52
  },
46
53
  "files": [
47
- "dist",
48
- "src/components"
54
+ "dist"
49
55
  ],
50
- "packageManager": "pnpm@8.15.6",
51
- "scripts": {
52
- "build": "tsc && node scripts/fix-import-extensions.js",
53
- "build-tsup": "tsup",
54
- "lint": "tsc"
55
- }
56
- }
56
+ "packageManager": "pnpm@8.15.6"
57
+ }
@@ -1,5 +0,0 @@
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;
@@ -1,58 +0,0 @@
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;
@@ -1,94 +0,0 @@
1
- import React, { FC, useState, useEffect } from "react";
2
-
3
- import { EditPropertyProps } from "adminjs";
4
- import Select, { MultiValue, SingleValue, StylesConfig } from "react-select";
5
- import chroma from "chroma-js";
6
-
7
- import { ColorStatusWrapper, Label } from "./styles";
8
-
9
- import type { AvailableValueType } from "./types";
10
-
11
- type ColorStatusTypes = Omit<EditPropertyProps, "where" | "resource">;
12
-
13
- const dot = (color = "transparent") => ({
14
- alignItems: "center",
15
- display: "flex",
16
-
17
- ":before": {
18
- backgroundColor: color,
19
- borderRadius: 10,
20
- content: '" "',
21
- display: "block",
22
- marginRight: 8,
23
- height: 10,
24
- width: 10,
25
- },
26
- });
27
-
28
- const colorStyles: StylesConfig<AvailableValueType> = {
29
- control: (styles) => ({ ...styles, backgroundColor: "white" }),
30
- option: (styles, { data, isDisabled, isFocused, isSelected }) => {
31
- const color = chroma(data.color);
32
- return {
33
- ...styles,
34
- backgroundColor: isSelected
35
- ? data.color
36
- : isFocused
37
- ? color.alpha(0.1).css()
38
- : undefined,
39
- color: isSelected
40
- ? chroma.contrast(color, "white") > 2
41
- ? "white"
42
- : "black"
43
- : data.color,
44
-
45
- ":active": {
46
- ...styles[":active"],
47
- backgroundColor: isSelected ? data.color : color.alpha(0.3).css(),
48
- },
49
- };
50
- },
51
- input: (styles) => ({ ...styles, ...dot() }),
52
- placeholder: (styles) => ({ ...styles, ...dot("#ccc") }),
53
- singleValue: (styles, { data }) => ({ ...styles, ...dot(data.color) }),
54
- };
55
-
56
- const ColorStatus: FC<ColorStatusTypes> = ({ property, record, onChange }) => {
57
- const availableValues = property.availableValues as AvailableValueType[];
58
-
59
- const currentOption = availableValues.find(
60
- (item) => item.value === record.params[property.path],
61
- ) as AvailableValueType;
62
-
63
- const [selectOption, setCurrentOption] = useState<
64
- SingleValue<AvailableValueType> | undefined
65
- >(currentOption);
66
-
67
- const handleSelectChange = (
68
- option: SingleValue<AvailableValueType> | MultiValue<AvailableValueType>,
69
- ) => {
70
- setCurrentOption(option as SingleValue<AvailableValueType>);
71
- };
72
-
73
- useEffect(() => {
74
- onChange(property.path, selectOption?.value);
75
- }, [selectOption]);
76
-
77
- return (
78
- <ColorStatusWrapper>
79
- <Label>{property.path}</Label>
80
- <Select
81
- className="basic-single"
82
- classNamePrefix="select"
83
- defaultValue={selectOption ?? availableValues[0]}
84
- onChange={handleSelectChange}
85
- isClearable={true}
86
- name="color"
87
- options={availableValues}
88
- styles={colorStyles}
89
- />
90
- </ColorStatusWrapper>
91
- );
92
- };
93
-
94
- export default ColorStatus;
@@ -1,4 +0,0 @@
1
- import { FC } from "react";
2
- import { ShowPropertyProps } from "adminjs";
3
- declare const ColorStatusList: FC<ShowPropertyProps>;
4
- export default ColorStatusList;
@@ -1,7 +0,0 @@
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;
@@ -1,20 +0,0 @@
1
- import React, { FC } from "react";
2
- import { ShowPropertyProps } from "adminjs";
3
-
4
- import { ColorStatusBadge } from "./styles";
5
-
6
- import type { AvailableValueType } from "./types";
7
-
8
- const ColorStatusList: FC<ShowPropertyProps> = ({ property, record }) => {
9
- const currentOption = property.availableValues?.find(
10
- (item) => item.value === record.params[property.path],
11
- ) as AvailableValueType;
12
-
13
- return (
14
- <ColorStatusBadge color={currentOption.color}>
15
- {record.params[property.path]}
16
- </ColorStatusBadge>
17
- );
18
- };
19
-
20
- export default ColorStatusList;
@@ -1,4 +0,0 @@
1
- import { FC } from "react";
2
- import { ShowPropertyProps } from "adminjs";
3
- declare const ColorStatusShow: FC<ShowPropertyProps>;
4
- export default ColorStatusShow;
@@ -1,9 +0,0 @@
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;
@@ -1,23 +0,0 @@
1
- import React, { FC } from "react";
2
- import { ShowPropertyProps } from "adminjs";
3
-
4
- import { ColorStatusBadgeWrapper, ColorStatusBadge, ShowLabel } from "./styles";
5
-
6
- import type { AvailableValueType } from "./types";
7
-
8
- const ColorStatusShow: FC<ShowPropertyProps> = ({ property, record }) => {
9
- const currentOption = property.availableValues?.find(
10
- (item) => item.value === record.params[property.path],
11
- ) as AvailableValueType;
12
-
13
- return (
14
- <ColorStatusBadgeWrapper>
15
- <ShowLabel>{property.path}</ShowLabel>
16
- <ColorStatusBadge color={currentOption.color}>
17
- {record.params[property.path]}
18
- </ColorStatusBadge>
19
- </ColorStatusBadgeWrapper>
20
- );
21
- };
22
-
23
- export default ColorStatusShow;
@@ -1,3 +0,0 @@
1
- export * from "./ColorStatusEdit.js";
2
- export * from "./ColorStatusShow.js";
3
- export * from "./ColorStatusList.js";
@@ -1,3 +0,0 @@
1
- export * from "./ColorStatusEdit.js";
2
- export * from "./ColorStatusShow.js";
3
- export * from "./ColorStatusList.js";
@@ -1,3 +0,0 @@
1
- export * from "./ColorStatusEdit.js";
2
- export * from "./ColorStatusShow.js";
3
- export * from "./ColorStatusList.js";
@@ -1,5 +0,0 @@
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;
@@ -1,25 +0,0 @@
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
- `;
@@ -1,30 +0,0 @@
1
- import { styled } from "@adminjs/design-system/styled-components";
2
-
3
- export const ColorStatusWrapper = styled.div`
4
- margin-bottom: 24px;
5
- `;
6
-
7
- export const Label = styled.div`
8
- font-size: 12px;
9
- margin-bottom: 8px;
10
- `;
11
-
12
- export const ShowLabel = styled.div`
13
- font-size: 12px;
14
- margin-bottom: 8px;
15
- color: rgb(137, 138, 154);
16
- `;
17
-
18
- export const ColorStatusBadgeWrapper = styled.div`
19
- margin-bottom: 20px;
20
- `;
21
-
22
- export const ColorStatusBadge = styled.div`
23
- background-color: ${(props: any) => props.color};
24
- width: fit-content;
25
- padding: 5px 10px;
26
- border-radius: 20px;
27
- font-size: 12px;
28
- color: white;
29
- white-space: nowrap;
30
- `;
@@ -1,5 +0,0 @@
1
- export type AvailableValueType = {
2
- value: string;
3
- label: string;
4
- color: string;
5
- };
@@ -1,5 +0,0 @@
1
- export type AvailableValueType = {
2
- value: string;
3
- label: string;
4
- color: string;
5
- };
@@ -1,8 +0,0 @@
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.JSX.Element;
8
- import React from "react";
@@ -1,36 +0,0 @@
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 },
32
- React.createElement(StyledLabel, null, property.path),
33
- React.createElement(StyledEditorWrapper, null,
34
- React.createElement(StyledEditor, { id: editorId }))));
35
- };
36
- export default Editor;
@@ -1,49 +0,0 @@
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
-
6
- import { StyledLabel, StyledEditor, StyledEditorWrapper } from "./styles";
7
-
8
- import { EDITOR_TOOLS } from "./config";
9
-
10
- const Editor = ({ property, record, onChangeAdmin, editorId }) => {
11
- const [jsonData, setJsonData] = useState();
12
- const isSavedData = Boolean(record.params[property.path]);
13
-
14
- const ref = useRef();
15
-
16
- useEffect(() => {
17
- onChangeAdmin(property.path, jsonData);
18
- }, [jsonData]);
19
-
20
- useEffect(() => {
21
- if (!ref.current) {
22
- const editor = new EditorJS({
23
- holder: editorId,
24
- tools: EDITOR_TOOLS,
25
- data: isSavedData ? JSON.parse(record.params[property.path]) : "",
26
- async onChange(api, event) {
27
- const data = await api.saver.save();
28
- setJsonData(JSON.stringify(data));
29
- },
30
- });
31
- ref.current = editor;
32
- }
33
-
34
- return () => {
35
- ref?.current?.destroy?.();
36
- };
37
- }, []);
38
-
39
- return (
40
- <ThemeProvider theme={theme}>
41
- <StyledLabel>{property.path}</StyledLabel>
42
- <StyledEditorWrapper>
43
- <StyledEditor id={editorId} />
44
- </StyledEditorWrapper>
45
- </ThemeProvider>
46
- );
47
- };
48
-
49
- export default Editor;
@@ -1,6 +0,0 @@
1
- export default EditorList;
2
- declare function EditorList({ property, record }: {
3
- property: any;
4
- record: any;
5
- }): React.JSX.Element;
6
- import React from "react";
@@ -1,11 +0,0 @@
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 },
9
- React.createElement(StyledEditorViewWrapper, null, htmlContent && (React.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })))));
10
- };
11
- export default EditorList;
@@ -1,22 +0,0 @@
1
- import React from "react";
2
-
3
- import { theme } from "@adminjs/design-system";
4
- import { ThemeProvider } from "styled-components";
5
- import { parseHtml } from "../../utils/parseHtml";
6
- import { StyledEditorViewWrapper } from "./styles";
7
-
8
- const EditorList = ({ property, record }) => {
9
- const htmlContent = parseHtml(record.params[property.path]);
10
-
11
- return (
12
- <ThemeProvider theme={theme}>
13
- <StyledEditorViewWrapper>
14
- {htmlContent && (
15
- <div dangerouslySetInnerHTML={{ __html: htmlContent }} />
16
- )}
17
- </StyledEditorViewWrapper>
18
- </ThemeProvider>
19
- );
20
- };
21
-
22
- export default EditorList;
@@ -1,6 +0,0 @@
1
- export default EditorShow;
2
- declare function EditorShow({ property, record }: {
3
- property: any;
4
- record: any;
5
- }): React.JSX.Element;
6
- import React from "react";
@@ -1,13 +0,0 @@
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 },
9
- React.createElement(StyledEditorShowWrapper, null,
10
- React.createElement(StyledShowLabel, null, property.path),
11
- htmlContent && (React.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })))));
12
- };
13
- export default EditorShow;
@@ -1,24 +0,0 @@
1
- import React from "react";
2
- import { ThemeProvider } from "styled-components";
3
- import { theme } from "@adminjs/design-system";
4
-
5
- import { parseHtml } from "../../utils/parseHtml";
6
-
7
- import { StyledEditorShowWrapper, StyledShowLabel } from "./styles";
8
-
9
- const EditorShow = ({ property, record }) => {
10
- const htmlContent = parseHtml(record.params[property.path]);
11
-
12
- return (
13
- <ThemeProvider theme={theme}>
14
- <StyledEditorShowWrapper>
15
- <StyledShowLabel>{property.path}</StyledShowLabel>
16
- {htmlContent && (
17
- <div dangerouslySetInnerHTML={{ __html: htmlContent }} />
18
- )}
19
- </StyledEditorShowWrapper>
20
- </ThemeProvider>
21
- );
22
- };
23
-
24
- export default EditorShow;