@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.
- package/dist/components/ColorStatus/ColorStatusEdit.d.ts +2 -2
- package/dist/components/ColorStatus/ColorStatusEdit.js +3 -3
- package/dist/components/ColorStatus/ColorStatusFeature.d.ts +9 -0
- package/dist/components/ColorStatus/ColorStatusFeature.js +23 -0
- package/dist/components/ColorStatus/ColorStatusList.d.ts +1 -1
- package/dist/components/ColorStatus/ColorStatusList.js +4 -2
- package/dist/components/ColorStatus/ColorStatusShow.d.ts +1 -1
- package/dist/components/ColorStatus/ColorStatusShow.js +5 -3
- package/dist/components/ColorStatus/index.d.ts +4 -3
- package/dist/components/ColorStatus/index.js +4 -3
- package/dist/components/ColorStatus/styles.js +2 -1
- package/dist/components/Editor/Editor.d.ts +4 -2
- package/dist/components/Editor/Editor.js +79 -16
- package/dist/components/Editor/EditorFeature.d.ts +10 -0
- package/dist/components/Editor/EditorFeature.js +82 -0
- package/dist/components/Editor/EditorList.d.ts +2 -2
- package/dist/components/Editor/EditorList.js +1 -1
- package/dist/components/Editor/EditorShow.d.ts +2 -2
- package/dist/components/Editor/EditorShow.js +2 -2
- package/dist/components/Editor/index.d.ts +4 -3
- package/dist/components/Editor/index.js +4 -3
- package/dist/components/FeatureTabs/FeatureTabsEdit.d.ts +4 -0
- package/dist/components/FeatureTabs/FeatureTabsEdit.js +105 -0
- package/dist/components/FeatureTabs/FeatureTabsFeature.d.ts +8 -0
- package/dist/components/FeatureTabs/FeatureTabsFeature.js +28 -0
- package/dist/components/FeatureTabs/FeatureTabsShow.d.ts +4 -0
- package/dist/components/FeatureTabs/FeatureTabsShow.js +61 -0
- package/dist/components/FeatureTabs/index.d.ts +4 -0
- package/dist/components/FeatureTabs/index.js +4 -0
- package/dist/components/Preview/PreviewAction.d.ts +4 -0
- package/dist/components/Preview/PreviewAction.js +22 -0
- package/dist/components/Preview/PreviewFeature.d.ts +9 -0
- package/dist/components/Preview/PreviewFeature.js +31 -0
- package/dist/components/Preview/index.d.ts +2 -0
- package/dist/components/Preview/index.js +2 -0
- package/dist/components/Slug/SlugEdit.d.ts +1 -1
- package/dist/components/Slug/SlugEdit.js +9 -3
- package/dist/components/Slug/SlugFeature.d.ts +3 -6
- package/dist/components/Slug/SlugFeature.js +12 -14
- package/dist/components/Slug/SlugOptions.type.d.ts +7 -0
- package/dist/components/StringList/StringList.d.ts +1 -1
- package/dist/components/StringList/StringList.js +4 -4
- package/dist/components/StringList/StringListFeature.d.ts +7 -0
- package/dist/components/StringList/StringListFeature.js +20 -0
- package/dist/components/StringList/StringListShow.d.ts +1 -1
- package/dist/components/StringList/StringListShow.js +2 -2
- package/dist/components/StringList/index.d.ts +3 -2
- package/dist/components/StringList/index.js +3 -2
- package/dist/components/StringList/styles.js +2 -1
- package/dist/components/Tabs/TabsEdit.d.ts +4 -0
- package/dist/components/Tabs/TabsEdit.js +103 -0
- package/dist/components/Tabs/TabsFeature.d.ts +7 -0
- package/dist/components/Tabs/TabsFeature.js +26 -0
- package/dist/components/Tabs/TabsShow.d.ts +4 -0
- package/dist/components/Tabs/TabsShow.js +61 -0
- package/dist/components/Tabs/index.d.ts +3 -0
- package/dist/components/Tabs/index.js +3 -0
- package/dist/components/index.d.ts +15 -7
- package/dist/components/index.js +15 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/upload-provider.d.ts +13 -0
- package/dist/utils/bundle-component.d.ts +1 -1
- package/dist/utils/bundle-component.js +5 -8
- package/dist/utils/component-loader.d.ts +3 -0
- package/dist/utils/component-loader.js +10 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +12 -11
- package/src/components/ColorStatus/ColorStatusEdit.d.ts +0 -5
- package/src/components/ColorStatus/ColorStatusEdit.js +0 -58
- package/src/components/ColorStatus/ColorStatusEdit.tsx +0 -94
- package/src/components/ColorStatus/ColorStatusList.d.ts +0 -4
- package/src/components/ColorStatus/ColorStatusList.js +0 -7
- package/src/components/ColorStatus/ColorStatusList.tsx +0 -20
- package/src/components/ColorStatus/ColorStatusShow.d.ts +0 -4
- package/src/components/ColorStatus/ColorStatusShow.js +0 -9
- package/src/components/ColorStatus/ColorStatusShow.tsx +0 -23
- package/src/components/ColorStatus/index.d.ts +0 -3
- package/src/components/ColorStatus/index.js +0 -3
- package/src/components/ColorStatus/index.ts +0 -3
- package/src/components/ColorStatus/styles.d.ts +0 -5
- package/src/components/ColorStatus/styles.js +0 -25
- package/src/components/ColorStatus/styles.ts +0 -30
- package/src/components/ColorStatus/types.d.ts +0 -5
- package/src/components/ColorStatus/types.ts +0 -5
- package/src/components/Editor/Editor.d.ts +0 -8
- package/src/components/Editor/Editor.js +0 -36
- package/src/components/Editor/Editor.jsx +0 -49
- package/src/components/Editor/EditorList.d.ts +0 -6
- package/src/components/Editor/EditorList.js +0 -11
- package/src/components/Editor/EditorList.jsx +0 -22
- package/src/components/Editor/EditorShow.d.ts +0 -6
- package/src/components/Editor/EditorShow.js +0 -13
- package/src/components/Editor/EditorShow.jsx +0 -24
- package/src/components/Editor/config.d.ts +0 -29
- package/src/components/Editor/config.js +0 -34
- package/src/components/Editor/config.ts +0 -35
- package/src/components/Editor/index.d.ts +0 -3
- package/src/components/Editor/index.js +0 -3
- package/src/components/Editor/index.ts +0 -3
- package/src/components/Editor/styles.d.ts +0 -6
- package/src/components/Editor/styles.js +0 -145
- package/src/components/Editor/styles.ts +0 -151
- package/src/components/Slug/SlugEdit.d.ts +0 -5
- package/src/components/Slug/SlugEdit.js +0 -27
- package/src/components/Slug/SlugEdit.tsx +0 -68
- package/src/components/Slug/SlugFeature.d.ts +0 -7
- package/src/components/Slug/SlugFeature.js +0 -21
- package/src/components/Slug/SlugFeature.ts +0 -30
- package/src/components/Slug/index.d.ts +0 -1
- package/src/components/Slug/index.js +0 -1
- package/src/components/Slug/index.ts +0 -1
- package/src/components/Slug/styles.d.ts +0 -4
- package/src/components/Slug/styles.js +0 -20
- package/src/components/Slug/styles.ts +0 -24
- package/src/components/StringList/SortableList/SortableList.d.ts +0 -18
- package/src/components/StringList/SortableList/SortableList.js +0 -37
- package/src/components/StringList/SortableList/SortableList.tsx +0 -98
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +0 -7
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.js +0 -8
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx +0 -20
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +0 -8
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.js +0 -28
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx +0 -59
- package/src/components/StringList/SortableList/components/SortableItem/styles.d.ts +0 -2
- package/src/components/StringList/SortableList/components/SortableItem/styles.js +0 -20
- package/src/components/StringList/SortableList/components/SortableItem/styles.ts +0 -22
- package/src/components/StringList/SortableList/components/SortableItem/types.d.ts +0 -6
- package/src/components/StringList/SortableList/components/SortableItem/types.ts +0 -7
- package/src/components/StringList/SortableList/components/index.d.ts +0 -2
- package/src/components/StringList/SortableList/components/index.js +0 -2
- package/src/components/StringList/SortableList/components/index.ts +0 -2
- package/src/components/StringList/SortableList/index.d.ts +0 -1
- package/src/components/StringList/SortableList/index.js +0 -1
- package/src/components/StringList/SortableList/index.ts +0 -1
- package/src/components/StringList/SortableList/styles.d.ts +0 -1
- package/src/components/StringList/SortableList/styles.js +0 -8
- package/src/components/StringList/SortableList/styles.ts +0 -9
- package/src/components/StringList/StringList.d.ts +0 -8
- package/src/components/StringList/StringList.js +0 -60
- package/src/components/StringList/StringList.tsx +0 -136
- package/src/components/StringList/StringListShow.d.ts +0 -7
- package/src/components/StringList/StringListShow.js +0 -14
- package/src/components/StringList/StringListShow.tsx +0 -37
- package/src/components/StringList/constants.d.ts +0 -1
- package/src/components/StringList/constants.js +0 -1
- package/src/components/StringList/constants.ts +0 -1
- package/src/components/StringList/index.d.ts +0 -2
- package/src/components/StringList/index.js +0 -2
- package/src/components/StringList/index.ts +0 -2
- package/src/components/StringList/styles.d.ts +0 -8
- package/src/components/StringList/styles.js +0 -33
- package/src/components/StringList/styles.ts +0 -41
- package/src/components/index.d.ts +0 -7
- package/src/components/index.js +0 -10
- package/src/components/index.ts +0 -10
- /package/{src/components/ColorStatus/types.js → dist/components/Slug/SlugOptions.type.js} +0 -0
- /package/{src/components/StringList/SortableList/components/SortableItem/types.js → dist/types/upload-provider.js} +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
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;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import React, { Fragment, useMemo, useState } from "react";
|
|
2
|
-
import type { ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
DndContext,
|
|
6
|
-
KeyboardSensor,
|
|
7
|
-
PointerSensor,
|
|
8
|
-
useSensor,
|
|
9
|
-
useSensors,
|
|
10
|
-
DragOverlay,
|
|
11
|
-
defaultDropAnimationSideEffects,
|
|
12
|
-
} from "@dnd-kit/core";
|
|
13
|
-
import {
|
|
14
|
-
SortableContext,
|
|
15
|
-
arrayMove,
|
|
16
|
-
sortableKeyboardCoordinates,
|
|
17
|
-
verticalListSortingStrategy,
|
|
18
|
-
} from "@dnd-kit/sortable";
|
|
19
|
-
|
|
20
|
-
import type { DropAnimation } from "@dnd-kit/core";
|
|
21
|
-
|
|
22
|
-
import { SortableItem } from "./components/index.js";
|
|
23
|
-
import { StyledListWrapper } from "./styles.js";
|
|
24
|
-
|
|
25
|
-
import type { Active, UniqueIdentifier } from "@dnd-kit/core";
|
|
26
|
-
|
|
27
|
-
interface BaseItem {
|
|
28
|
-
id: UniqueIdentifier;
|
|
29
|
-
value: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface Props<T extends BaseItem> {
|
|
33
|
-
items: T[];
|
|
34
|
-
onChange(items: T[]): void;
|
|
35
|
-
renderItem(item: T): ReactNode;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const dropAnimationConfig: DropAnimation = {
|
|
39
|
-
sideEffects: defaultDropAnimationSideEffects({
|
|
40
|
-
styles: {
|
|
41
|
-
active: {
|
|
42
|
-
opacity: "0.4",
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
}),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export function SortableList<T extends BaseItem>({
|
|
49
|
-
items,
|
|
50
|
-
onChange,
|
|
51
|
-
renderItem,
|
|
52
|
-
}: Props<T>) {
|
|
53
|
-
const [active, setActive] = useState<Active | null>(null);
|
|
54
|
-
const activeItem = useMemo(
|
|
55
|
-
() => items.find((item) => item.id === active?.id),
|
|
56
|
-
[active, items],
|
|
57
|
-
);
|
|
58
|
-
const sensors = useSensors(
|
|
59
|
-
useSensor(PointerSensor),
|
|
60
|
-
useSensor(KeyboardSensor, {
|
|
61
|
-
coordinateGetter: sortableKeyboardCoordinates,
|
|
62
|
-
}),
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<DndContext
|
|
67
|
-
sensors={sensors}
|
|
68
|
-
onDragStart={({ active }) => {
|
|
69
|
-
setActive(active);
|
|
70
|
-
}}
|
|
71
|
-
onDragEnd={({ active, over }) => {
|
|
72
|
-
if (over && active.id !== over?.id) {
|
|
73
|
-
const activeIndex = items.findIndex(({ id }) => id === active.id);
|
|
74
|
-
const overIndex = items.findIndex(({ id }) => id === over.id);
|
|
75
|
-
|
|
76
|
-
onChange(arrayMove(items, activeIndex, overIndex));
|
|
77
|
-
}
|
|
78
|
-
setActive(null);
|
|
79
|
-
}}
|
|
80
|
-
onDragCancel={() => {
|
|
81
|
-
setActive(null);
|
|
82
|
-
}}
|
|
83
|
-
>
|
|
84
|
-
<SortableContext items={items} strategy={verticalListSortingStrategy}>
|
|
85
|
-
<StyledListWrapper role="application">
|
|
86
|
-
{items.map((item, index) => (
|
|
87
|
-
<Fragment key={index}>{renderItem(item)}</Fragment>
|
|
88
|
-
))}
|
|
89
|
-
</StyledListWrapper>
|
|
90
|
-
</SortableContext>
|
|
91
|
-
<DragOverlay dropAnimation={dropAnimationConfig}>
|
|
92
|
-
{activeItem ? renderItem(activeItem) : null}
|
|
93
|
-
</DragOverlay>
|
|
94
|
-
</DndContext>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
SortableList.Item = SortableItem;
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React, { Context, FC, useContext } from "react";
|
|
2
|
-
|
|
3
|
-
import { StyledDragButton } from "./styles.js";
|
|
4
|
-
import type { DragContext } from "./types.js";
|
|
5
|
-
|
|
6
|
-
interface DragHandlePropsType {
|
|
7
|
-
context: Context<DragContext>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const DragHandle: FC<DragHandlePropsType> = ({ context }) => {
|
|
11
|
-
const { attributes, listeners, ref } = useContext(context);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<StyledDragButton {...attributes} {...listeners} ref={ref}>
|
|
15
|
-
<svg viewBox="0 0 20 20" width="13">
|
|
16
|
-
<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"></path>
|
|
17
|
-
</svg>
|
|
18
|
-
</StyledDragButton>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,28 +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 (React.createElement(SortableItemContext.Provider, { value: context },
|
|
22
|
-
React.createElement(StyledListItem, { ref: setNodeRef, style: style },
|
|
23
|
-
React.createElement("div", null,
|
|
24
|
-
React.createElement(DragHandle, { context: SortableItemContext }),
|
|
25
|
-
children),
|
|
26
|
-
React.createElement(Button, { variant: "outlined", color: "danger", size: "icon", onClick: (e) => onDelete(e, id) },
|
|
27
|
-
React.createElement(Icon, { icon: "X", color: "red" })))));
|
|
28
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useMemo, ChangeEvent } from 'react';
|
|
2
|
-
import type { CSSProperties, PropsWithChildren } from 'react';
|
|
3
|
-
import { useSortable } from '@dnd-kit/sortable';
|
|
4
|
-
import { Button, Icon } from '@adminjs/design-system';
|
|
5
|
-
|
|
6
|
-
import { DragHandle } from './DragHandle.js';
|
|
7
|
-
import { StyledListItem } from './styles.js';
|
|
8
|
-
import type { DragContext } from './types.js';
|
|
9
|
-
|
|
10
|
-
interface SortableItemPropsType {
|
|
11
|
-
id: string;
|
|
12
|
-
onDelete: (e: ChangeEvent<HTMLInputElement>, id: string) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const SortableItemContext = createContext<DragContext>({
|
|
16
|
-
attributes: {},
|
|
17
|
-
listeners: undefined,
|
|
18
|
-
ref() {},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export function SortableItem({
|
|
22
|
-
children,
|
|
23
|
-
id,
|
|
24
|
-
onDelete,
|
|
25
|
-
}: PropsWithChildren<SortableItemPropsType>) {
|
|
26
|
-
const { attributes, isDragging, listeners, setNodeRef, setActivatorNodeRef } =
|
|
27
|
-
useSortable({ id });
|
|
28
|
-
const context = useMemo(
|
|
29
|
-
() => ({
|
|
30
|
-
attributes,
|
|
31
|
-
listeners,
|
|
32
|
-
ref: setActivatorNodeRef,
|
|
33
|
-
}),
|
|
34
|
-
[attributes, listeners, setActivatorNodeRef],
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const style: CSSProperties = {
|
|
38
|
-
opacity: isDragging ? 0.4 : undefined,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<SortableItemContext.Provider value={context}>
|
|
43
|
-
<StyledListItem ref={setNodeRef} style={style}>
|
|
44
|
-
<div>
|
|
45
|
-
<DragHandle context={SortableItemContext} />
|
|
46
|
-
{children}
|
|
47
|
-
</div>
|
|
48
|
-
<Button
|
|
49
|
-
variant="outlined"
|
|
50
|
-
color="danger"
|
|
51
|
-
size="icon"
|
|
52
|
-
onClick={(e: ChangeEvent<HTMLInputElement>) => onDelete(e, id)}
|
|
53
|
-
>
|
|
54
|
-
<Icon icon="X" color="red" />
|
|
55
|
-
</Button>
|
|
56
|
-
</StyledListItem>
|
|
57
|
-
</SortableItemContext.Provider>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
@@ -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 StyledDragButton = styled.button `
|
|
15
|
-
padding: 3px;
|
|
16
|
-
margin-right: 15px;
|
|
17
|
-
cursor: move;
|
|
18
|
-
background: none;
|
|
19
|
-
border: none;
|
|
20
|
-
`;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { styled } from "@adminjs/design-system/styled-components";
|
|
2
|
-
|
|
3
|
-
export const StyledListItem = styled.li`
|
|
4
|
-
display: flex;
|
|
5
|
-
justify-content: space-between;
|
|
6
|
-
align-items: center;
|
|
7
|
-
background-color: #fff;
|
|
8
|
-
padding: 10px 20px 10px 15px;
|
|
9
|
-
box-shadow:
|
|
10
|
-
0 0 0 calc(1px / var(--scale-x, 1)) rgba(63, 63, 68, 0.05),
|
|
11
|
-
0 1px calc(3px / var(--scale-x, 1)) 0 rgba(34, 33, 81, 0.15);
|
|
12
|
-
border-radius: 5px;
|
|
13
|
-
list-style: none;
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
export const StyledDragButton = styled.button`
|
|
17
|
-
padding: 3px;
|
|
18
|
-
margin-right: 15px;
|
|
19
|
-
cursor: move;
|
|
20
|
-
background: none;
|
|
21
|
-
border: none;
|
|
22
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SortableList } from './SortableList.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SortableList } from './SortableList.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SortableList } from './SortableList.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const StyledListWrapper: any;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EditPropertyProps } from "adminjs";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
type StringListTypes = Omit<EditPropertyProps, "where" | "resource">;
|
|
4
|
-
interface StringListShowPropsType extends StringListTypes {
|
|
5
|
-
stringListSeparator?: string;
|
|
6
|
-
}
|
|
7
|
-
declare const StringList: FC<StringListShowPropsType>;
|
|
8
|
-
export default StringList;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Button, Input, theme } from "@adminjs/design-system";
|
|
2
|
-
import React, { useEffect, useState, } from "react";
|
|
3
|
-
import { ThemeProvider } from "styled-components";
|
|
4
|
-
import { StyledCustomInput, StyledInputWrapper, StyledLabel, StyledListWrapper, StyledWrapper, } from "./styles.js";
|
|
5
|
-
import { SortableList } from "./SortableList/SortableList.js";
|
|
6
|
-
import { separator } from "./constants.js";
|
|
7
|
-
const StringList = ({ record, onChange, property, stringListSeparator = separator, }) => {
|
|
8
|
-
const stringListValue = record.params?.[property.path] ?? property.props.value ?? "";
|
|
9
|
-
const initialList = stringListValue
|
|
10
|
-
? prepareDataForList(stringListValue)
|
|
11
|
-
: [];
|
|
12
|
-
const [inputValue, setInputValue] = useState("");
|
|
13
|
-
const [list, setList] = useState(initialList);
|
|
14
|
-
const serializedData = prepareDataForDatabase(list);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
onChange(property.path, serializedData);
|
|
17
|
-
}, [serializedData]);
|
|
18
|
-
return (React.createElement(ThemeProvider, { theme: theme },
|
|
19
|
-
React.createElement(StyledLabel, { htmlFor: "custom" }, property.path),
|
|
20
|
-
React.createElement(StyledWrapper, null,
|
|
21
|
-
React.createElement(StyledListWrapper, null,
|
|
22
|
-
React.createElement(SortableList, { items: list, onChange: setList, renderItem: (item) => (React.createElement(SortableList.Item, { id: item.id, onDelete: handleDeleteButton }, item.value)) })),
|
|
23
|
-
React.createElement(StyledInputWrapper, null,
|
|
24
|
-
React.createElement(Input, { id: "stringList", name: property.path, value: serializedData, hidden: true }),
|
|
25
|
-
React.createElement(StyledCustomInput, { id: "custom", name: "customInput", value: inputValue, onChange: handleInput, onKeyPress: handleEnterPress }),
|
|
26
|
-
React.createElement(Button, { variant: "outlined", onClick: handleAddButton }, "Add")))));
|
|
27
|
-
function handleInput(e) {
|
|
28
|
-
setInputValue(e.target.value);
|
|
29
|
-
}
|
|
30
|
-
function handleEnterPress(e) {
|
|
31
|
-
if (e.key === "Enter") {
|
|
32
|
-
handleAddButton(e);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function handleAddButton(e) {
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
if (Boolean(inputValue)) {
|
|
38
|
-
setList([...list, createListObject(inputValue)]);
|
|
39
|
-
setInputValue("");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function handleDeleteButton(e, id) {
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
const newData = list.filter((item) => item.id !== id);
|
|
45
|
-
setList(newData);
|
|
46
|
-
}
|
|
47
|
-
function prepareDataForDatabase(list) {
|
|
48
|
-
return list.map(({ value }) => value).join(stringListSeparator);
|
|
49
|
-
}
|
|
50
|
-
function prepareDataForList(str) {
|
|
51
|
-
return str.split(stringListSeparator).map((item) => createListObject(item));
|
|
52
|
-
}
|
|
53
|
-
function createListObject(value) {
|
|
54
|
-
return {
|
|
55
|
-
id: `${Date.now()}-${Math.floor(Math.random() * 1000)}`,
|
|
56
|
-
value: value,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
export default StringList;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { Button, Input, theme } from "@adminjs/design-system";
|
|
2
|
-
import { EditPropertyProps } from "adminjs";
|
|
3
|
-
import React, {
|
|
4
|
-
ChangeEvent,
|
|
5
|
-
FC,
|
|
6
|
-
KeyboardEvent,
|
|
7
|
-
SyntheticEvent,
|
|
8
|
-
useEffect,
|
|
9
|
-
useState,
|
|
10
|
-
} from "react";
|
|
11
|
-
import { ThemeProvider } from "styled-components";
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
StyledCustomInput,
|
|
15
|
-
StyledInputWrapper,
|
|
16
|
-
StyledLabel,
|
|
17
|
-
StyledListWrapper,
|
|
18
|
-
StyledWrapper,
|
|
19
|
-
} from "./styles.js";
|
|
20
|
-
|
|
21
|
-
import { SortableList } from "./SortableList/SortableList.js";
|
|
22
|
-
import { separator } from "./constants.js";
|
|
23
|
-
|
|
24
|
-
type ListDataTypes = {
|
|
25
|
-
id: string;
|
|
26
|
-
value: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type StringListTypes = Omit<EditPropertyProps, "where" | "resource">;
|
|
30
|
-
|
|
31
|
-
interface StringListShowPropsType extends StringListTypes {
|
|
32
|
-
stringListSeparator?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const StringList: FC<StringListShowPropsType> = ({
|
|
36
|
-
record,
|
|
37
|
-
onChange,
|
|
38
|
-
property,
|
|
39
|
-
stringListSeparator = separator,
|
|
40
|
-
}) => {
|
|
41
|
-
const stringListValue =
|
|
42
|
-
record.params?.[property.path] ?? property.props.value ?? "";
|
|
43
|
-
|
|
44
|
-
const initialList = stringListValue
|
|
45
|
-
? prepareDataForList(stringListValue)
|
|
46
|
-
: [];
|
|
47
|
-
|
|
48
|
-
const [inputValue, setInputValue] = useState("");
|
|
49
|
-
const [list, setList] = useState<ListDataTypes[]>(initialList);
|
|
50
|
-
|
|
51
|
-
const serializedData = prepareDataForDatabase(list);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
onChange(property.path, serializedData);
|
|
55
|
-
}, [serializedData]);
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<ThemeProvider theme={theme}>
|
|
59
|
-
<StyledLabel htmlFor="custom">{property.path}</StyledLabel>
|
|
60
|
-
<StyledWrapper>
|
|
61
|
-
<StyledListWrapper>
|
|
62
|
-
<SortableList
|
|
63
|
-
items={list}
|
|
64
|
-
onChange={setList}
|
|
65
|
-
renderItem={(item) => (
|
|
66
|
-
<SortableList.Item id={item.id} onDelete={handleDeleteButton}>
|
|
67
|
-
{item.value}
|
|
68
|
-
</SortableList.Item>
|
|
69
|
-
)}
|
|
70
|
-
/>
|
|
71
|
-
</StyledListWrapper>
|
|
72
|
-
<StyledInputWrapper>
|
|
73
|
-
<Input
|
|
74
|
-
id="stringList"
|
|
75
|
-
name={property.path}
|
|
76
|
-
value={serializedData}
|
|
77
|
-
hidden
|
|
78
|
-
/>
|
|
79
|
-
<StyledCustomInput
|
|
80
|
-
id="custom"
|
|
81
|
-
name="customInput"
|
|
82
|
-
value={inputValue}
|
|
83
|
-
onChange={handleInput}
|
|
84
|
-
onKeyPress={handleEnterPress}
|
|
85
|
-
/>
|
|
86
|
-
<Button variant="outlined" onClick={handleAddButton}>
|
|
87
|
-
Add
|
|
88
|
-
</Button>
|
|
89
|
-
</StyledInputWrapper>
|
|
90
|
-
</StyledWrapper>
|
|
91
|
-
</ThemeProvider>
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
function handleInput(e: ChangeEvent<HTMLInputElement>) {
|
|
95
|
-
setInputValue(e.target.value);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function handleEnterPress(e: KeyboardEvent<HTMLInputElement>) {
|
|
99
|
-
if (e.key === "Enter") {
|
|
100
|
-
handleAddButton(e);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function handleAddButton(e: SyntheticEvent<HTMLInputElement>) {
|
|
105
|
-
e.preventDefault();
|
|
106
|
-
|
|
107
|
-
if (Boolean(inputValue)) {
|
|
108
|
-
setList([...list, createListObject(inputValue)]);
|
|
109
|
-
|
|
110
|
-
setInputValue("");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function handleDeleteButton(e: ChangeEvent<HTMLInputElement>, id: string) {
|
|
115
|
-
e.preventDefault();
|
|
116
|
-
const newData = list.filter((item: ListDataTypes) => item.id !== id);
|
|
117
|
-
setList(newData);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function prepareDataForDatabase(list: ListDataTypes[]) {
|
|
121
|
-
return list.map(({ value }) => value).join(stringListSeparator);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function prepareDataForList(str: string) {
|
|
125
|
-
return str.split(stringListSeparator).map((item) => createListObject(item));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function createListObject(value: string) {
|
|
129
|
-
return {
|
|
130
|
-
id: `${Date.now()}-${Math.floor(Math.random() * 1000)}`,
|
|
131
|
-
value: value,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export default StringList;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
import { ShowPropertyProps } from "adminjs";
|
|
3
|
-
interface StringListShowPropsType extends ShowPropertyProps {
|
|
4
|
-
stringListSeparator?: string;
|
|
5
|
-
}
|
|
6
|
-
declare const StringListShow: FC<StringListShowPropsType>;
|
|
7
|
-
export default StringListShow;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ThemeProvider } from "styled-components";
|
|
3
|
-
import { theme } from "@adminjs/design-system";
|
|
4
|
-
import { StyledShowLabel, StyledShowWrapper, StyledListItem } from "./styles";
|
|
5
|
-
import { separator } from "./constants";
|
|
6
|
-
const StringListShow = ({ property, record, stringListSeparator = separator, }) => {
|
|
7
|
-
return (React.createElement(ThemeProvider, { theme: theme },
|
|
8
|
-
React.createElement(StyledShowWrapper, null,
|
|
9
|
-
React.createElement(StyledShowLabel, null, property.path),
|
|
10
|
-
record.params.facts && (React.createElement("ul", null, record.params.facts
|
|
11
|
-
.split(stringListSeparator)
|
|
12
|
-
.map((item, index) => (React.createElement(StyledListItem, { key: index }, `- ${item}`))))))));
|
|
13
|
-
};
|
|
14
|
-
export default StringListShow;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { memo, useState, useEffect, useRef, FC } from "react";
|
|
2
|
-
import { ShowPropertyProps } from "adminjs";
|
|
3
|
-
|
|
4
|
-
import { ThemeProvider } from "styled-components";
|
|
5
|
-
import { theme } from "@adminjs/design-system";
|
|
6
|
-
|
|
7
|
-
import { StyledShowLabel, StyledShowWrapper, StyledListItem } from "./styles";
|
|
8
|
-
import { separator } from "./constants";
|
|
9
|
-
|
|
10
|
-
interface StringListShowPropsType extends ShowPropertyProps {
|
|
11
|
-
stringListSeparator?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const StringListShow: FC<StringListShowPropsType> = ({
|
|
15
|
-
property,
|
|
16
|
-
record,
|
|
17
|
-
stringListSeparator = separator,
|
|
18
|
-
}) => {
|
|
19
|
-
return (
|
|
20
|
-
<ThemeProvider theme={theme}>
|
|
21
|
-
<StyledShowWrapper>
|
|
22
|
-
<StyledShowLabel>{property.path}</StyledShowLabel>
|
|
23
|
-
{record.params.facts && (
|
|
24
|
-
<ul>
|
|
25
|
-
{record.params.facts
|
|
26
|
-
.split(stringListSeparator)
|
|
27
|
-
.map((item: string, index: number) => (
|
|
28
|
-
<StyledListItem key={index}>{`- ${item}`}</StyledListItem>
|
|
29
|
-
))}
|
|
30
|
-
</ul>
|
|
31
|
-
)}
|
|
32
|
-
</StyledShowWrapper>
|
|
33
|
-
</ThemeProvider>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default StringListShow;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const separator = "|";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const separator = "|";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const separator = "|";
|