@evenicanpm/portal-editor-ui 1.4.0 → 1.5.0

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 (35) hide show
  1. package/{src/editor.tsx → dist/editor.d.ts} +10 -14
  2. package/dist/features/editor/components/column-list/column-card/column-card-options.d.ts +9 -0
  3. package/dist/features/editor/components/column-list/column-card/column-card-title.d.ts +4 -0
  4. package/dist/features/editor/components/column-list/column-card/column-card.d.ts +8 -0
  5. package/dist/features/editor/components/column-list/column-card/drag-handle.d.ts +6 -0
  6. package/dist/features/editor/components/column-list/column-card/editable-label.d.ts +11 -0
  7. package/dist/features/editor/components/column-list/column-list-section.d.ts +12 -0
  8. package/dist/features/editor/components/column-list/column-list-skeleton.d.ts +1 -0
  9. package/dist/features/editor/components/column-list/column-list-state.d.ts +33 -0
  10. package/dist/features/editor/components/column-list/column-list-title.d.ts +5 -0
  11. package/dist/features/editor/components/column-list/column-list.d.ts +8 -0
  12. package/dist/features/editor/components/editor-dms-card.d.ts +14 -0
  13. package/dist/features/editor/components/editor-tabs.d.ts +13 -0
  14. package/dist/features/editor/components/editor.d.ts +28 -0
  15. package/{src/index.ts → dist/index.d.ts} +0 -1
  16. package/dist/tsconfig.tsbuildinfo +1 -0
  17. package/package.json +6 -3
  18. package/src/features/editor/components/column-list/column-card/column-card-options.tsx +0 -48
  19. package/src/features/editor/components/column-list/column-card/column-card-title.tsx +0 -13
  20. package/src/features/editor/components/column-list/column-card/column-card.tsx +0 -134
  21. package/src/features/editor/components/column-list/column-card/drag-handle.tsx +0 -32
  22. package/src/features/editor/components/column-list/column-card/editable-label.tsx +0 -132
  23. package/src/features/editor/components/column-list/column-list-section.tsx +0 -49
  24. package/src/features/editor/components/column-list/column-list-skeleton.tsx +0 -49
  25. package/src/features/editor/components/column-list/column-list-state.ts +0 -92
  26. package/src/features/editor/components/column-list/column-list-title.tsx +0 -18
  27. package/src/features/editor/components/column-list/column-list.tsx +0 -212
  28. package/src/features/editor/components/editor-dms-card.tsx +0 -79
  29. package/src/features/editor/components/editor-tabs.tsx +0 -42
  30. package/src/features/editor/components/editor.tsx +0 -62
  31. package/tsconfig.json +0 -28
  32. package/typedoc.json +0 -10
  33. /package/{src/features/editor/components/column-list/column-card/index.ts → dist/features/editor/components/column-list/column-card/index.d.ts} +0 -0
  34. /package/{src/features/editor/components/column-list/index.ts → dist/features/editor/components/column-list/index.d.ts} +0 -0
  35. /package/{src/features/editor/index.ts → dist/features/editor/index.d.ts} +0 -0
@@ -1,212 +0,0 @@
1
- import {
2
- closestCenter,
3
- DndContext,
4
- type DragEndEvent,
5
- PointerSensor,
6
- TouchSensor,
7
- useSensor,
8
- useSensors,
9
- } from "@dnd-kit/core";
10
- import {
11
- arrayMove,
12
- SortableContext,
13
- verticalListSortingStrategy,
14
- } from "@dnd-kit/sortable";
15
- import type { Column, ViewConfig } from "@evenicanpm/portal-types-schemas";
16
- import AddCircleOutlineIcon from "@mui/icons-material/AddCircleOutline";
17
- import {
18
- Box,
19
- Button,
20
- Card,
21
- CardContent,
22
- Chip,
23
- Menu,
24
- MenuItem,
25
- Typography,
26
- } from "@mui/material";
27
- import { useMutation, useQueryClient } from "@tanstack/react-query";
28
- import { useState } from "react";
29
- import type { EditorQueries } from "../editor";
30
- import { ColumnCard } from "./column-card";
31
- import {
32
- addFieldToEnd,
33
- getRemovedFields,
34
- getVisibleFields,
35
- patchField,
36
- removeField,
37
- reorderVisibleFields,
38
- } from "./column-list-state";
39
-
40
- export type ColumnListProps = {
41
- resourceKey: string;
42
- initialState: ViewConfig;
43
- editorQueries: EditorQueries;
44
- };
45
-
46
- export function ColumnList({
47
- resourceKey,
48
- initialState,
49
- editorQueries,
50
- }: Readonly<ColumnListProps>) {
51
- const columns = initialState.Columns;
52
- const actions = initialState.Actions;
53
- const [fields, setFields] = useState<Column[]>(columns ?? []);
54
- const [addAnchor, setAddAnchor] = useState<null | HTMLElement>(null);
55
- const addOpen = Boolean(addAnchor);
56
-
57
- const sensors = useSensors(
58
- useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),
59
- useSensor(TouchSensor, {
60
- activationConstraint: { delay: 150, tolerance: 5 },
61
- }),
62
- );
63
-
64
- const qc = useQueryClient();
65
-
66
- const saveConfig = useMutation({
67
- ...editorQueries.saveViewConfigMutation(resourceKey),
68
- onSuccess: () => {
69
- qc.invalidateQueries({ queryKey: ["viewConfig", resourceKey] });
70
- },
71
- });
72
-
73
- const visibleFields = getVisibleFields(fields);
74
- const removedFields = getRemovedFields(fields);
75
-
76
- const onDragEnd = (event: DragEndEvent) => {
77
- const { active, over } = event;
78
- if (!over) return;
79
- if (active.id === over.id) return;
80
-
81
- setFields((prev) =>
82
- reorderVisibleFields(prev, String(active.id), String(over.id), arrayMove),
83
- );
84
- };
85
-
86
- const onChangeField = (id: string, patch: Partial<Column>) => {
87
- setFields((prev) => patchField(prev, id, patch));
88
- };
89
-
90
- const onRemoveField = (id: string) => {
91
- setFields((prev) => removeField(prev, id));
92
- };
93
-
94
- const onAddField = (id: string) => {
95
- setFields((prev) => addFieldToEnd(prev, id));
96
- };
97
-
98
- const isDirty =
99
- JSON.stringify(initialState.Columns) !== JSON.stringify(fields);
100
-
101
- const onSaveClick = () => {
102
- if (!isDirty) return;
103
-
104
- saveConfig.mutate({
105
- key: resourceKey,
106
- viewConfig: { Columns: fields, Actions: actions },
107
- });
108
- };
109
-
110
- return (
111
- <>
112
- <Box
113
- sx={{
114
- display: "flex",
115
- justifyContent: "flex-end",
116
- alignItems: "center",
117
- position: "relative",
118
- mb: 2,
119
- height: 40,
120
- }}
121
- >
122
- {isDirty && (
123
- <Chip
124
- label="Unsaved Changes"
125
- size="small"
126
- color="warning"
127
- variant="outlined"
128
- sx={{
129
- fontWeight: "bold",
130
- height: 20,
131
- position: "absolute",
132
- left: 0,
133
- }}
134
- />
135
- )}
136
- <Button
137
- variant="contained"
138
- onClick={onSaveClick}
139
- disabled={!isDirty}
140
- sx={{ minWidth: 150 }}
141
- >
142
- Save Changes
143
- </Button>
144
- </Box>
145
-
146
- <DndContext
147
- sensors={sensors}
148
- collisionDetection={closestCenter}
149
- onDragEnd={onDragEnd}
150
- >
151
- {fields.length === 0 ? (
152
- <Card
153
- variant="outlined"
154
- sx={{
155
- textAlign: "center",
156
- color: "text.secondary",
157
- }}
158
- >
159
- <CardContent>
160
- <Typography variant="subtitle1">No fields found</Typography>
161
- </CardContent>
162
- </Card>
163
- ) : (
164
- <SortableContext
165
- items={visibleFields.map((f) => f.Data)}
166
- strategy={verticalListSortingStrategy}
167
- >
168
- <Box>
169
- {visibleFields.map((field) => (
170
- <ColumnCard
171
- key={field.Data}
172
- field={field}
173
- onChange={onChangeField}
174
- onRemove={onRemoveField}
175
- />
176
- ))}
177
-
178
- <Box sx={{ display: "flex", justifyContent: "center", mt: 1 }}>
179
- <Button
180
- variant="outlined"
181
- startIcon={<AddCircleOutlineIcon />}
182
- onClick={(e) => setAddAnchor(e.currentTarget)}
183
- disabled={removedFields.length === 0}
184
- >
185
- Add column
186
- </Button>
187
- </Box>
188
-
189
- <Menu
190
- anchorEl={addAnchor}
191
- open={addOpen}
192
- onClose={() => setAddAnchor(null)}
193
- >
194
- {removedFields.map((f) => (
195
- <MenuItem
196
- key={f.Data}
197
- onClick={() => {
198
- onAddField(f.Data);
199
- setAddAnchor(null);
200
- }}
201
- >
202
- {f.Label || f.Data}
203
- </MenuItem>
204
- ))}
205
- </Menu>
206
- </Box>
207
- </SortableContext>
208
- )}
209
- </DndContext>
210
- </>
211
- );
212
- }
@@ -1,79 +0,0 @@
1
- "use client";
2
-
3
- import { CheckCircle } from "@mui/icons-material";
4
- import { Avatar, Box, Paper, Stack, Typography } from "@mui/material";
5
-
6
- interface Props {
7
- /** Currently selected resource */
8
- selectedResourceKey: string;
9
- /** A pojo with providers -> images */
10
- providerImageMap: Record<string, string>;
11
- /** A pojo with resources -> providers */
12
- resourceProviderMap: Record<string, string>;
13
- }
14
-
15
- /**
16
- * Editor view header contains provider details and other
17
- * resource/view config data not related to the column list.
18
- */
19
- export function EditorDMSCard({
20
- selectedResourceKey,
21
- providerImageMap,
22
- resourceProviderMap,
23
- }: Readonly<Props>) {
24
- const selectedResourceProvider = resourceProviderMap[selectedResourceKey];
25
- const logoUrl = providerImageMap[selectedResourceProvider];
26
- return (
27
- <Paper
28
- elevation={1}
29
- sx={{
30
- p: { xs: 2, sm: 3 },
31
- mb: 3,
32
- borderRadius: 2,
33
- }}
34
- >
35
- <Stack
36
- direction={{ xs: "column", sm: "row" }}
37
- justifyContent="space-between"
38
- alignItems={{ xs: "stretch", sm: "center" }}
39
- spacing={2}
40
- >
41
- <Stack direction="row" spacing={2} alignItems="center">
42
- <Avatar
43
- src={logoUrl}
44
- alt={`${selectedResourceKey}-${logoUrl}`}
45
- sx={{
46
- width: 56,
47
- height: 56,
48
- }}
49
- />
50
- <Box>
51
- <Typography variant="h5" fontWeight={700}>
52
- Resource: {selectedResourceKey || "None"}
53
- </Typography>
54
- <Stack
55
- direction="row"
56
- spacing={1}
57
- alignItems="center"
58
- sx={{ mt: 0.5 }}
59
- >
60
- <Typography variant="body2" color="text.secondary">
61
- provider: {selectedResourceProvider}
62
- </Typography>
63
-
64
- <Stack direction="row" spacing={0.5} alignItems="center">
65
- <CheckCircle sx={{ fontSize: 16, color: "success.main" }} />
66
- <Typography
67
- variant="body2"
68
- sx={{ color: "success.main", fontWeight: 600 }}
69
- >
70
- enabled
71
- </Typography>
72
- </Stack>
73
- </Stack>
74
- </Box>
75
- </Stack>
76
- </Stack>
77
- </Paper>
78
- );
79
- }
@@ -1,42 +0,0 @@
1
- "use client";
2
-
3
- import { Box, Paper, Tab, Tabs, Typography } from "@mui/material";
4
-
5
- interface Props {
6
- /** List of resource keys to select from */
7
- resourceList: string[];
8
- /** Currently selected key */
9
- selectedResourceKey: string;
10
- /** Action to take when resource changes. */
11
- handleChangeResource: (id: string) => void;
12
- }
13
-
14
- /**
15
- * Tab-based selection menu for resource keys on the editor page.
16
- */
17
- function EditorResourceTabs({
18
- resourceList,
19
- selectedResourceKey,
20
- handleChangeResource,
21
- }: Readonly<Props>) {
22
- return (
23
- <Box sx={{ my: 3 }}>
24
- <Typography variant="subtitle1" fontWeight={600} gutterBottom>
25
- Selected Resource
26
- </Typography>
27
- <Paper>
28
- <Tabs
29
- value={selectedResourceKey}
30
- onChange={(_, v) => handleChangeResource(v)}
31
- variant="fullWidth"
32
- >
33
- {resourceList.map((docType) => (
34
- <Tab key={docType} label={docType} value={docType} />
35
- ))}
36
- </Tabs>
37
- </Paper>
38
- </Box>
39
- );
40
- }
41
-
42
- export { EditorResourceTabs };
@@ -1,62 +0,0 @@
1
- "use client";
2
- import type { ViewConfig } from "@evenicanpm/portal-types-schemas";
3
- import { Box } from "@mui/material";
4
- import type { QueryKey } from "@tanstack/react-query";
5
- import { useState } from "react";
6
- import { ColumnListSection } from "./column-list";
7
- import { EditorDMSCard } from "./editor-dms-card";
8
- import { EditorResourceTabs } from "./editor-tabs";
9
-
10
- export type SaveInput = { key: string; viewConfig: ViewConfig };
11
-
12
- export type ViewConfigQuery = (resourceKey: string) => {
13
- queryKey: QueryKey;
14
- queryFn: () => Promise<ViewConfig>;
15
- };
16
-
17
- export type SaveViewConfigMutation = (resourceKey: string) => {
18
- mutationKey: QueryKey;
19
- mutationFn: (input: SaveInput) => Promise<ViewConfig>;
20
- };
21
-
22
- export type EditorQueries = {
23
- viewConfigQuery: ViewConfigQuery;
24
- saveViewConfigMutation: SaveViewConfigMutation;
25
- };
26
-
27
- export interface EditorProps {
28
- resourceList: string[];
29
- providerMetaData: Record<string, string>;
30
- resourceProviderMap: Record<string, string>;
31
- editorQueries: EditorQueries;
32
- }
33
- /**
34
- * Top-Level editor component.
35
- */
36
- export function Editor({
37
- resourceList,
38
- providerMetaData,
39
- resourceProviderMap,
40
- editorQueries,
41
- }: Readonly<EditorProps>) {
42
- const [currentResource, setCurrentResource] = useState(resourceList[0]);
43
-
44
- return (
45
- <Box sx={{ p: { sm: 3 }, maxWidth: 1200, mx: "auto" }}>
46
- <EditorResourceTabs
47
- resourceList={resourceList}
48
- handleChangeResource={setCurrentResource}
49
- selectedResourceKey={currentResource}
50
- />
51
- <EditorDMSCard
52
- selectedResourceKey={currentResource}
53
- providerImageMap={providerMetaData}
54
- resourceProviderMap={resourceProviderMap}
55
- />
56
- <ColumnListSection
57
- currentResourceKey={currentResource}
58
- editorQueries={editorQueries}
59
- />
60
- </Box>
61
- );
62
- }
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES6",
4
- "useDefineForClassFields": true,
5
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
6
- "module": "ESNext",
7
- "sourceMap": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "declaration": true,
11
- "preserveSymlinks": true,
12
- "moduleResolution": "Node",
13
- "resolveJsonModule": true,
14
- "isolatedModules": true,
15
- "emitDeclarationOnly": true,
16
- "jsx": "preserve",
17
- "strict": true,
18
- "noUnusedLocals": true,
19
- "noUnusedParameters": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "allowJs": true,
22
- "forceConsistentCasingInFileNames": true,
23
- "incremental": true,
24
- "baseUrl": "./",
25
- "outDir": "./dist"
26
- },
27
- "include": ["src"]
28
- }
package/typedoc.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "highlightLanguages": [
3
- "bash",
4
- "typescript",
5
- "tsx",
6
- "javascript",
7
- "html",
8
- "css"
9
- ]
10
- }