@rulab/adminjs-components 0.0.13 → 0.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/dist/index.cjs +10 -762
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -21
- package/dist/index.d.ts +10 -21
- package/dist/index.js +3 -754
- package/dist/index.js.map +1 -0
- package/package.json +12 -8
- package/src/components/ColorStatus/ColorStatusEdit.tsx +94 -94
- package/src/components/ColorStatus/ColorStatusList.tsx +20 -20
- package/src/components/ColorStatus/ColorStatusShow.tsx +23 -23
- package/src/components/ColorStatus/index.ts +3 -3
- package/src/components/ColorStatus/styles.ts +30 -30
- package/src/components/ColorStatus/types.ts +5 -5
- package/src/components/Editor/Editor.jsx +49 -49
- package/src/components/Editor/EditorList.jsx +22 -22
- package/src/components/Editor/EditorShow.jsx +24 -24
- package/src/components/Editor/config.ts +35 -35
- package/src/components/Editor/index.ts +3 -3
- package/src/components/Editor/styles.ts +151 -151
- package/src/components/{CustomSlug/CustomSlug.tsx → Slug/SlugEdit.tsx} +68 -68
- package/src/components/Slug/SlugFeature.ts +30 -0
- package/src/components/Slug/index.ts +1 -0
- package/src/components/{CustomSlug → Slug}/styles.ts +24 -24
- package/src/components/StringList/SortableList/SortableList.tsx +98 -98
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx +20 -20
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx +59 -59
- package/src/components/StringList/SortableList/components/SortableItem/styles.ts +22 -22
- package/src/components/StringList/SortableList/components/SortableItem/types.ts +7 -7
- package/src/components/StringList/SortableList/components/index.ts +2 -2
- package/src/components/StringList/SortableList/index.ts +1 -1
- package/src/components/StringList/SortableList/styles.ts +9 -9
- package/src/components/StringList/StringList.tsx +136 -136
- package/src/components/StringList/StringListShow.tsx +37 -37
- package/src/components/StringList/constants.ts +1 -1
- package/src/components/StringList/index.ts +2 -2
- package/src/components/StringList/styles.ts +41 -41
- package/src/components/index.ts +10 -9
- package/dist/bundle.js +0 -8
- package/dist/components/CustomSlug/CustomSlug.jsx +0 -29
- package/dist/components/CustomSlug/index.js +0 -1
- package/dist/components/CustomSlug/styles.js +0 -15
- package/dist/components/Editor/config.js +0 -11
- package/dist/components/Editor/index.js +0 -1
- package/dist/components/Editor/styles.js +0 -64
- package/dist/components/StringList/SortableList/SortableList.jsx +0 -43
- package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.jsx +0 -10
- package/dist/components/StringList/SortableList/components/SortableItem/SortableItem.jsx +0 -32
- package/dist/components/StringList/SortableList/components/SortableItem/styles.js +0 -20
- package/dist/components/StringList/SortableList/components/SortableItem/types.js +0 -1
- package/dist/components/StringList/SortableList/components/index.js +0 -2
- package/dist/components/StringList/SortableList/index.js +0 -1
- package/dist/components/StringList/SortableList/styles.js +0 -8
- package/dist/components/StringList/StringList.jsx +0 -67
- package/dist/components/StringList/index.js +0 -1
- package/dist/components/StringList/styles.js +0 -16
- package/dist/components/index.js +0 -3
- package/dist/editorFeature.js +0 -16
- package/dist/index.d.mts +0 -8
- package/dist/index.mjs +0 -37
- package/dist/utils/index.js +0 -1
- package/dist/utils/slugifyImport.js +0 -3
- package/dist/utils/slugifyTitle.js +0 -10
- package/src/components/CustomSlug/index.ts +0 -1
- package/src/index.ts +0 -2
- package/src/types.d.ts +0 -3
- package/src/utils/index.ts +0 -3
- package/src/utils/parseHtml.ts +0 -56
- package/src/utils/slugifyImport.ts +0 -4
- package/src/utils/slugifyTitle.ts +0 -11
- package/tsconfig.json +0 -17
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useMemo } from 'react';
|
|
2
|
-
import { useSortable } from '@dnd-kit/sortable';
|
|
3
|
-
import { Button, Icon } from '@adminjs/design-system';
|
|
4
|
-
import { DragHandle } from './DragHandle.js';
|
|
5
|
-
import { StyledListItem } from './styles.js';
|
|
6
|
-
const SortableItemContext = createContext({
|
|
7
|
-
attributes: {},
|
|
8
|
-
listeners: undefined,
|
|
9
|
-
ref() { },
|
|
10
|
-
});
|
|
11
|
-
export function SortableItem({ children, id, onDelete, }) {
|
|
12
|
-
const { attributes, isDragging, listeners, setNodeRef, setActivatorNodeRef } = useSortable({ id });
|
|
13
|
-
const context = useMemo(() => ({
|
|
14
|
-
attributes,
|
|
15
|
-
listeners,
|
|
16
|
-
ref: setActivatorNodeRef,
|
|
17
|
-
}), [attributes, listeners, setActivatorNodeRef]);
|
|
18
|
-
const style = {
|
|
19
|
-
opacity: isDragging ? 0.4 : undefined,
|
|
20
|
-
};
|
|
21
|
-
return (<SortableItemContext.Provider value={context}>
|
|
22
|
-
<StyledListItem ref={setNodeRef} style={style}>
|
|
23
|
-
<div>
|
|
24
|
-
<DragHandle context={SortableItemContext}/>
|
|
25
|
-
{children}
|
|
26
|
-
</div>
|
|
27
|
-
<Button variant="outlined" color="danger" size="icon" onClick={(e) => onDelete(e, id)}>
|
|
28
|
-
<Icon icon="X" color="red"/>
|
|
29
|
-
</Button>
|
|
30
|
-
</StyledListItem>
|
|
31
|
-
</SortableItemContext.Provider>);
|
|
32
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { styled } from '@adminjs/design-system/styled-components';
|
|
2
|
-
export const StyledListItem = styled.li `
|
|
3
|
-
display: flex;
|
|
4
|
-
justify-content: space-between;
|
|
5
|
-
align-items: center;
|
|
6
|
-
background-color: #fff;
|
|
7
|
-
padding: 10px 20px 10px 15px;
|
|
8
|
-
box-shadow:
|
|
9
|
-
0 0 0 calc(1px / var(--scale-x, 1)) rgba(63, 63, 68, 0.05),
|
|
10
|
-
0 1px calc(3px / var(--scale-x, 1)) 0 rgba(34, 33, 81, 0.15);
|
|
11
|
-
border-radius: 5px;
|
|
12
|
-
list-style: none;
|
|
13
|
-
`;
|
|
14
|
-
export const DragButton = styled.button `
|
|
15
|
-
padding: 3px;
|
|
16
|
-
margin-right: 15px;
|
|
17
|
-
cursor: move;
|
|
18
|
-
background: none;
|
|
19
|
-
border: none;
|
|
20
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SortableList } from './SortableList.js';
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, } from "react";
|
|
2
|
-
import { ThemeProvider } from "styled-components";
|
|
3
|
-
import { theme, Button, Input, Label } from "@adminjs/design-system";
|
|
4
|
-
import { StyledWrapper, StyledCustomInput, StyledListWrapper, StyledInputWrapper, } from "./styles.js";
|
|
5
|
-
import { SortableList } from "./SortableList/SortableList.js";
|
|
6
|
-
const StringList = ({ record, onChange, property }) => {
|
|
7
|
-
const stringListValue = record.params?.[property.path] ?? property.props.value ?? "";
|
|
8
|
-
const initialList = stringListValue
|
|
9
|
-
? prepareDataForList(stringListValue)
|
|
10
|
-
: [];
|
|
11
|
-
const [inputValue, setInputValue] = useState("");
|
|
12
|
-
const [list, setList] = useState(initialList);
|
|
13
|
-
const serializedData = prepareDataForDatabase(list);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
onChange(property.path, serializedData);
|
|
16
|
-
}, [serializedData]);
|
|
17
|
-
return (<ThemeProvider theme={theme}>
|
|
18
|
-
<Label htmlFor="custom">String List</Label>
|
|
19
|
-
<StyledWrapper>
|
|
20
|
-
<StyledListWrapper>
|
|
21
|
-
<SortableList items={list} onChange={setList} renderItem={(item) => (<SortableList.Item id={item.id} onDelete={handleDeleteButton}>
|
|
22
|
-
{item.value}
|
|
23
|
-
</SortableList.Item>)}/>
|
|
24
|
-
</StyledListWrapper>
|
|
25
|
-
<StyledInputWrapper>
|
|
26
|
-
<Input id="stringList" name={property.path} value={serializedData} hidden/>
|
|
27
|
-
<StyledCustomInput id="custom" name="customInput" value={inputValue} onChange={handleInput} onKeyPress={handleEnterPress}/>
|
|
28
|
-
<Button variant="outlined" onClick={handleAddButton}>
|
|
29
|
-
Add
|
|
30
|
-
</Button>
|
|
31
|
-
</StyledInputWrapper>
|
|
32
|
-
</StyledWrapper>
|
|
33
|
-
</ThemeProvider>);
|
|
34
|
-
function handleInput(e) {
|
|
35
|
-
setInputValue(e.target.value);
|
|
36
|
-
}
|
|
37
|
-
function handleEnterPress(e) {
|
|
38
|
-
if (e.key === "Enter") {
|
|
39
|
-
handleAddButton(e);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function handleAddButton(e) {
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
if (Boolean(inputValue)) {
|
|
45
|
-
setList([...list, createListObject(inputValue)]);
|
|
46
|
-
setInputValue("");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function handleDeleteButton(e, id) {
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
const newData = list.filter((item) => item.id !== id);
|
|
52
|
-
setList(newData);
|
|
53
|
-
}
|
|
54
|
-
function prepareDataForDatabase(list) {
|
|
55
|
-
return list.map(({ value }) => value).join("|");
|
|
56
|
-
}
|
|
57
|
-
function prepareDataForList(str) {
|
|
58
|
-
return str.split("|").map((item) => createListObject(item));
|
|
59
|
-
}
|
|
60
|
-
function createListObject(value) {
|
|
61
|
-
return {
|
|
62
|
-
id: `${Date.now()}-${Math.floor(Math.random() * 1000)}`,
|
|
63
|
-
value: value,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
export default StringList;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./StringList.js";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { styled } from "@adminjs/design-system/styled-components";
|
|
2
|
-
import { Box, Input } from "@adminjs/design-system";
|
|
3
|
-
export const StyledWrapper = styled(Box) `
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
`;
|
|
7
|
-
export const StyledCustomInput = styled(Input) `
|
|
8
|
-
width: 100%;
|
|
9
|
-
margin-right: 10px;
|
|
10
|
-
`;
|
|
11
|
-
export const StyledInputWrapper = styled(Box) `
|
|
12
|
-
display: flex;
|
|
13
|
-
`;
|
|
14
|
-
export const StyledListWrapper = styled(Box) `
|
|
15
|
-
margin-bottom: 15px;
|
|
16
|
-
`;
|
package/dist/components/index.js
DELETED
package/dist/editorFeature.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { buildFeature, } from "adminjs";
|
|
2
|
-
import bundleComponent from "./bundle.js";
|
|
3
|
-
const editorFeature = (options) => {
|
|
4
|
-
const { componentLoader, name } = options;
|
|
5
|
-
const editComponent = bundleComponent(componentLoader, "Editor");
|
|
6
|
-
return buildFeature({
|
|
7
|
-
properties: {
|
|
8
|
-
[name]: {
|
|
9
|
-
components: {
|
|
10
|
-
edit: editComponent,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
export default editorFeature;
|
package/dist/index.d.mts
DELETED
package/dist/index.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// src/features/editorFeature.ts
|
|
2
|
-
import {
|
|
3
|
-
buildFeature
|
|
4
|
-
} from "adminjs";
|
|
5
|
-
|
|
6
|
-
// src/bundle.ts
|
|
7
|
-
import path from "path";
|
|
8
|
-
import * as url from "url";
|
|
9
|
-
var __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
10
|
-
var bundle = (loader, componentName) => {
|
|
11
|
-
const componentPath = path.join(__dirname, `./components/${componentName}`);
|
|
12
|
-
return loader.add(componentName, componentPath);
|
|
13
|
-
};
|
|
14
|
-
var bundle_default = bundle;
|
|
15
|
-
|
|
16
|
-
// src/features/editorFeature.ts
|
|
17
|
-
var editorFeature = (options) => {
|
|
18
|
-
const { componentLoader } = options;
|
|
19
|
-
const editComponent = bundle_default(componentLoader, "Editor");
|
|
20
|
-
return buildFeature({
|
|
21
|
-
properties: {
|
|
22
|
-
editor: {
|
|
23
|
-
components: {
|
|
24
|
-
edit: editComponent
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var editorFeature_default = editorFeature;
|
|
31
|
-
|
|
32
|
-
// src/index.ts
|
|
33
|
-
var src_default = editorFeature_default;
|
|
34
|
-
export {
|
|
35
|
-
src_default as default,
|
|
36
|
-
editorFeature_default as editorFeature
|
|
37
|
-
};
|
package/dist/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { slugifyTitle } from "./slugifyTitle.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./CustomSlug.js";
|
package/src/index.ts
DELETED
package/src/types.d.ts
DELETED
package/src/utils/index.ts
DELETED
package/src/utils/parseHtml.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import edjsHTML from "editorjs-html";
|
|
2
|
-
|
|
3
|
-
type TableBlockType = {
|
|
4
|
-
type: "table";
|
|
5
|
-
data: {
|
|
6
|
-
content: string[][];
|
|
7
|
-
withHeadings: boolean;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type AudioPlayerBlockType = {
|
|
12
|
-
type: "audioPlayer";
|
|
13
|
-
data: {
|
|
14
|
-
src: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const tableParser = (block: TableBlockType) => {
|
|
19
|
-
const rows = block.data.content.map((row, index) => {
|
|
20
|
-
const tableHtml = [];
|
|
21
|
-
if (block.data.withHeadings && index === 0) {
|
|
22
|
-
tableHtml.push(`<tr>${row.map((cell) => `<th>${cell}</th>`)}</tr>`);
|
|
23
|
-
} else {
|
|
24
|
-
tableHtml.push(`<tr>${row.map((cell) => `<td>${cell}</td>`)}</tr>`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return tableHtml;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
if (block.data.withHeadings) {
|
|
31
|
-
const heading = rows[0] as string[];
|
|
32
|
-
const [, ...content] = rows;
|
|
33
|
-
|
|
34
|
-
return `<table><thead>${heading.join("")}</thead><tbody>${content.join("")}</tbody></table>`;
|
|
35
|
-
} else {
|
|
36
|
-
return `<table><tbody>${rows.join("")}</tbody></table>`;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const audioPlayerParser = (block: AudioPlayerBlockType) => {
|
|
41
|
-
return `<audio controls src={${block.data.src}} />`;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const parseHtml = (jsonData: string) => {
|
|
45
|
-
const edjsParser = edjsHTML({
|
|
46
|
-
table: tableParser,
|
|
47
|
-
audioPlayer: audioPlayerParser,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
const data = edjsParser.parse(JSON.parse(jsonData));
|
|
52
|
-
return String(data).replace(/>,</g, "><");
|
|
53
|
-
} catch (e) {
|
|
54
|
-
console.log("error", e);
|
|
55
|
-
}
|
|
56
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"esModuleInterop": true,
|
|
4
|
-
"skipLibCheck": true,
|
|
5
|
-
"target": "es2022",
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"resolveJsonModule": true,
|
|
8
|
-
"moduleDetection": "force",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"noUncheckedIndexedAccess": true,
|
|
11
|
-
"moduleResolution": "Bundler",
|
|
12
|
-
"module": "ESNext",
|
|
13
|
-
"lib": ["es2022", "dom", "dom.iterable"],
|
|
14
|
-
"jsx": "react",
|
|
15
|
-
"noEmit": true
|
|
16
|
-
}
|
|
17
|
-
}
|