@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.
Files changed (71) hide show
  1. package/LICENSE +21 -21
  2. package/dist/index.cjs +10 -762
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +10 -21
  5. package/dist/index.d.ts +10 -21
  6. package/dist/index.js +3 -754
  7. package/dist/index.js.map +1 -0
  8. package/package.json +12 -8
  9. package/src/components/ColorStatus/ColorStatusEdit.tsx +94 -94
  10. package/src/components/ColorStatus/ColorStatusList.tsx +20 -20
  11. package/src/components/ColorStatus/ColorStatusShow.tsx +23 -23
  12. package/src/components/ColorStatus/index.ts +3 -3
  13. package/src/components/ColorStatus/styles.ts +30 -30
  14. package/src/components/ColorStatus/types.ts +5 -5
  15. package/src/components/Editor/Editor.jsx +49 -49
  16. package/src/components/Editor/EditorList.jsx +22 -22
  17. package/src/components/Editor/EditorShow.jsx +24 -24
  18. package/src/components/Editor/config.ts +35 -35
  19. package/src/components/Editor/index.ts +3 -3
  20. package/src/components/Editor/styles.ts +151 -151
  21. package/src/components/{CustomSlug/CustomSlug.tsx → Slug/SlugEdit.tsx} +68 -68
  22. package/src/components/Slug/SlugFeature.ts +30 -0
  23. package/src/components/Slug/index.ts +1 -0
  24. package/src/components/{CustomSlug → Slug}/styles.ts +24 -24
  25. package/src/components/StringList/SortableList/SortableList.tsx +98 -98
  26. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx +20 -20
  27. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx +59 -59
  28. package/src/components/StringList/SortableList/components/SortableItem/styles.ts +22 -22
  29. package/src/components/StringList/SortableList/components/SortableItem/types.ts +7 -7
  30. package/src/components/StringList/SortableList/components/index.ts +2 -2
  31. package/src/components/StringList/SortableList/index.ts +1 -1
  32. package/src/components/StringList/SortableList/styles.ts +9 -9
  33. package/src/components/StringList/StringList.tsx +136 -136
  34. package/src/components/StringList/StringListShow.tsx +37 -37
  35. package/src/components/StringList/constants.ts +1 -1
  36. package/src/components/StringList/index.ts +2 -2
  37. package/src/components/StringList/styles.ts +41 -41
  38. package/src/components/index.ts +10 -9
  39. package/dist/bundle.js +0 -8
  40. package/dist/components/CustomSlug/CustomSlug.jsx +0 -29
  41. package/dist/components/CustomSlug/index.js +0 -1
  42. package/dist/components/CustomSlug/styles.js +0 -15
  43. package/dist/components/Editor/config.js +0 -11
  44. package/dist/components/Editor/index.js +0 -1
  45. package/dist/components/Editor/styles.js +0 -64
  46. package/dist/components/StringList/SortableList/SortableList.jsx +0 -43
  47. package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.jsx +0 -10
  48. package/dist/components/StringList/SortableList/components/SortableItem/SortableItem.jsx +0 -32
  49. package/dist/components/StringList/SortableList/components/SortableItem/styles.js +0 -20
  50. package/dist/components/StringList/SortableList/components/SortableItem/types.js +0 -1
  51. package/dist/components/StringList/SortableList/components/index.js +0 -2
  52. package/dist/components/StringList/SortableList/index.js +0 -1
  53. package/dist/components/StringList/SortableList/styles.js +0 -8
  54. package/dist/components/StringList/StringList.jsx +0 -67
  55. package/dist/components/StringList/index.js +0 -1
  56. package/dist/components/StringList/styles.js +0 -16
  57. package/dist/components/index.js +0 -3
  58. package/dist/editorFeature.js +0 -16
  59. package/dist/index.d.mts +0 -8
  60. package/dist/index.mjs +0 -37
  61. package/dist/utils/index.js +0 -1
  62. package/dist/utils/slugifyImport.js +0 -3
  63. package/dist/utils/slugifyTitle.js +0 -10
  64. package/src/components/CustomSlug/index.ts +0 -1
  65. package/src/index.ts +0 -2
  66. package/src/types.d.ts +0 -3
  67. package/src/utils/index.ts +0 -3
  68. package/src/utils/parseHtml.ts +0 -56
  69. package/src/utils/slugifyImport.ts +0 -4
  70. package/src/utils/slugifyTitle.ts +0 -11
  71. package/tsconfig.json +0 -17
@@ -1,98 +1,98 @@
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
+ 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,20 +1,20 @@
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
+ 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,59 +1,59 @@
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
+ 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,22 +1,22 @@
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
+ 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,7 +1,7 @@
1
- import type { DraggableSyntheticListeners } from '@dnd-kit/core';
2
-
3
- export interface DragContext {
4
- attributes: Record<string, any>;
5
- listeners: DraggableSyntheticListeners;
6
- ref(node: HTMLElement | null): void;
7
- }
1
+ import type { DraggableSyntheticListeners } from '@dnd-kit/core';
2
+
3
+ export interface DragContext {
4
+ attributes: Record<string, any>;
5
+ listeners: DraggableSyntheticListeners;
6
+ ref(node: HTMLElement | null): void;
7
+ }
@@ -1,2 +1,2 @@
1
- export { SortableItem } from './SortableItem/SortableItem.js';
2
- export { DragHandle } from './SortableItem/DragHandle.js';
1
+ export { SortableItem } from './SortableItem/SortableItem.js';
2
+ export { DragHandle } from './SortableItem/DragHandle.js';
@@ -1 +1 @@
1
- export { SortableList } from './SortableList.js';
1
+ export { SortableList } from './SortableList.js';
@@ -1,9 +1,9 @@
1
- import { styled } from '@adminjs/design-system/styled-components';
2
-
3
- export const StyledListWrapper = styled.ul`
4
- display: flex;
5
- flex-direction: column;
6
- gap: 12px;
7
- padding: 0;
8
- list-style: none;
9
- `;
1
+ import { styled } from '@adminjs/design-system/styled-components';
2
+
3
+ export const StyledListWrapper = styled.ul`
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: 12px;
7
+ padding: 0;
8
+ list-style: none;
9
+ `;