@compill/admin 1.0.102 → 1.0.104

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 (153) hide show
  1. package/dist/index.d.ts +50 -50
  2. package/dist/index.js +50 -50
  3. package/dist/lib/SectionTitle.js +4 -0
  4. package/dist/lib/breadcrumbs/BreadCrumbs.js +29 -0
  5. package/dist/lib/buttons/{DialogButton.jsx → DialogButton.js} +2 -4
  6. package/dist/lib/buttons/InvalidateButton.d.ts +1 -1
  7. package/dist/lib/buttons/{InvalidateButton.jsx → InvalidateButton.js} +3 -2
  8. package/dist/lib/buttons/{NavigateButton.jsx → NavigateButton.js} +2 -3
  9. package/dist/lib/buttons/{PublishButton.jsx → PublishButton.js} +3 -4
  10. package/dist/lib/buttons/{UpdateButton.jsx → UpdateButton.js} +3 -4
  11. package/dist/lib/buttons/ViewButton.d.ts +1 -1
  12. package/dist/lib/buttons/{ViewButton.jsx → ViewButton.js} +3 -4
  13. package/dist/lib/cells/{OrderCell.jsx → OrderCell.js} +2 -11
  14. package/dist/lib/json/DetailsView.d.ts +1 -1
  15. package/dist/lib/json/DetailsView.js +69 -0
  16. package/dist/lib/json/EditItemView.d.ts +1 -1
  17. package/dist/lib/json/EditItemView.js +6 -0
  18. package/dist/lib/json/MultiQueryWrapper.d.ts +1 -1
  19. package/dist/lib/json/{MultiQueryWrapper.jsx → MultiQueryWrapper.js} +5 -4
  20. package/dist/lib/json/QueryWrapper.d.ts +1 -1
  21. package/dist/lib/json/{QueryWrapper.jsx → QueryWrapper.js} +3 -2
  22. package/dist/lib/json/ScreenRenderer.d.ts +1 -1
  23. package/dist/lib/json/ScreenRenderer.js +19 -0
  24. package/dist/lib/json/ScreenTopBar.d.ts +2 -2
  25. package/dist/lib/json/ScreenTopBar.js +18 -0
  26. package/dist/lib/json/TabbedView.d.ts +1 -1
  27. package/dist/lib/json/TabbedView.js +21 -0
  28. package/dist/lib/json/buttons/{ActionButton.jsx → ActionButton.js} +2 -4
  29. package/dist/lib/json/buttons/{ConfirmationActionButton.jsx → ConfirmationActionButton.js} +3 -20
  30. package/dist/lib/json/dialog/DialogRenderer.d.ts +3 -3
  31. package/dist/lib/json/dialog/DialogRenderer.js +14 -0
  32. package/dist/lib/json/dialog/ItemDeleteDialog.js +14 -0
  33. package/dist/lib/json/dialog/ItemEditDialog.js +77 -0
  34. package/dist/lib/json/dialog/MultiQueryWrapperDialog.d.ts +1 -1
  35. package/dist/lib/json/dialog/{MultiQueryWrapperDialog.jsx → MultiQueryWrapperDialog.js} +3 -2
  36. package/dist/lib/json/dialog/QueryWrapperDialog.d.ts +2 -2
  37. package/dist/lib/json/dialog/{QueryWrapperDialog.jsx → QueryWrapperDialog.js} +3 -2
  38. package/dist/lib/json/table/{RefreshButton.jsx → RefreshButton.js} +3 -4
  39. package/dist/lib/json/table/TableRowActionsView.d.ts +1 -1
  40. package/dist/lib/json/table/TableRowActionsView.js +36 -0
  41. package/dist/lib/json/table/{TableRowPublishPostButton.jsx → TableRowPublishPostButton.js} +2 -3
  42. package/dist/lib/json/table/TableView.d.ts +1 -1
  43. package/dist/lib/json/table/TableView.js +65 -0
  44. package/dist/lib/json/table/TableViewContext.d.ts +1 -1
  45. package/dist/lib/json/table/{TableViewContext.jsx → TableViewContext.js} +6 -5
  46. package/dist/lib/json/table/useTableProps.d.ts +1 -1
  47. package/dist/lib/json/table/{useTableProps.jsx → useTableProps.js} +4 -3
  48. package/dist/lib/json/types/DetailsView.d.ts +1 -1
  49. package/dist/lib/json/types/EditItemDialog.d.ts +1 -1
  50. package/dist/lib/json/types/MultiQueryWrapper.d.ts +3 -3
  51. package/dist/lib/json/types/MultiQueryWrapperDialog.d.ts +1 -1
  52. package/dist/lib/json/types/QueryWrapper.d.ts +3 -3
  53. package/dist/lib/json/types/QueryWrapperDialog.d.ts +1 -1
  54. package/dist/lib/json/types/ScreenConfig.d.ts +6 -6
  55. package/dist/lib/json/types/TabbedView.d.ts +5 -5
  56. package/dist/lib/json/types/TableView.d.ts +4 -4
  57. package/dist/lib/layout/AdminLayout.d.ts +1 -1
  58. package/dist/lib/layout/AdminLayout.js +15 -0
  59. package/dist/lib/layout/ButtonBar.d.ts +1 -1
  60. package/dist/lib/layout/ButtonBar.js +19 -0
  61. package/dist/lib/layout/Content.js +9 -0
  62. package/dist/lib/layout/PageTitleBar.js +4 -0
  63. package/dist/lib/layout/Sidebar.d.ts +1 -1
  64. package/dist/lib/layout/Sidebar.js +12 -0
  65. package/dist/lib/layout/menu/Menu.d.ts +1 -1
  66. package/dist/lib/layout/menu/Menu.js +23 -0
  67. package/dist/lib/layout/menu/MenuButton.js +5 -0
  68. package/dist/lib/layout/menu/MenuItem.d.ts +1 -1
  69. package/dist/lib/layout/menu/MenuItem.js +11 -0
  70. package/dist/lib/layout/menu/NextMenuItem.d.ts +1 -1
  71. package/dist/lib/layout/menu/NextMenuItem.js +11 -0
  72. package/dist/lib/layout/menu/SelectedIndicator.js +4 -0
  73. package/dist/lib/layout/menu/UserBlock.d.ts +1 -1
  74. package/dist/lib/layout/menu/UserBlock.js +34 -0
  75. package/dist/lib/modal/{AttachDialog.jsx → AttachDialog.js} +4 -40
  76. package/dist/lib/modal/FormActionDialog.js +20 -0
  77. package/dist/lib/page/PageContainer.js +5 -0
  78. package/dist/lib/page/PageContentEditor.js +10 -0
  79. package/dist/lib/page/PageMain.js +5 -0
  80. package/dist/lib/page/{PageQueryStateContainer.jsx → PageQueryStateContainer.js} +5 -4
  81. package/dist/lib/page/PageSectionTitle.js +4 -0
  82. package/dist/lib/page/PageSidebar.js +4 -0
  83. package/dist/lib/page/PageSidebarSection.js +5 -0
  84. package/dist/lib/page/PageStateContainer.js +7 -0
  85. package/dist/lib/page/PageSubSectionTitle.js +4 -0
  86. package/dist/lib/page/PageTitle.js +4 -0
  87. package/dist/lib/page/PageTopBar.d.ts +1 -1
  88. package/dist/lib/page/{PageTopBar.jsx → PageTopBar.js} +6 -20
  89. package/dist/lib/status/{StatusBadge.jsx → StatusBadge.js} +2 -1
  90. package/dist/lib/table/{TableColumnButton.jsx → TableColumnButton.js} +1 -1
  91. package/dist/lib/table/TableContainer.js +6 -0
  92. package/dist/lib/table/{TableContainerContext.jsx → TableContainerContext.js} +2 -1
  93. package/dist/lib/table/TableCreateButton.d.ts +1 -1
  94. package/dist/lib/table/TableCreateButton.js +7 -0
  95. package/dist/lib/table/TableFilterButton.js +8 -0
  96. package/dist/lib/table/{TableFilters.jsx → TableFilters.js} +4 -23
  97. package/dist/lib/table/TableMassActions.d.ts +1 -1
  98. package/dist/lib/table/TableMassActions.js +9 -0
  99. package/dist/lib/table/TableRowActionBar.js +8 -0
  100. package/dist/lib/table/TableRowActionButton.js +5 -0
  101. package/dist/lib/table/TableRowActionDialogButton.d.ts +1 -1
  102. package/dist/lib/table/TableRowActionDialogButton.js +6 -0
  103. package/dist/lib/table/TableRowDeleteButton.d.ts +1 -1
  104. package/dist/lib/table/{TableRowDeleteButton.jsx → TableRowDeleteButton.js} +3 -2
  105. package/dist/lib/table/TableRowEditButton.d.ts +1 -1
  106. package/dist/lib/table/{TableRowEditButton.jsx → TableRowEditButton.js} +3 -4
  107. package/dist/lib/table/{TableRowNavigateButton.jsx → TableRowNavigateButton.js} +3 -2
  108. package/dist/lib/table/{TableRowPublishPostButton.jsx → TableRowPublishPostButton.js} +3 -2
  109. package/dist/lib/table/{TableRowViewButton.jsx → TableRowViewButton.js} +3 -2
  110. package/dist/lib/table/TableTopBar.d.ts +1 -1
  111. package/dist/lib/table/TableTopBar.js +5 -0
  112. package/package.json +17 -17
  113. package/dist/lib/SectionTitle.jsx +0 -3
  114. package/dist/lib/breadcrumbs/BreadCrumbs.jsx +0 -43
  115. package/dist/lib/json/DetailsView.jsx +0 -96
  116. package/dist/lib/json/EditItemView.jsx +0 -5
  117. package/dist/lib/json/ScreenRenderer.jsx +0 -18
  118. package/dist/lib/json/ScreenTopBar.jsx +0 -39
  119. package/dist/lib/json/TabbedView.jsx +0 -28
  120. package/dist/lib/json/dialog/DialogRenderer.jsx +0 -13
  121. package/dist/lib/json/dialog/ItemDeleteDialog.jsx +0 -36
  122. package/dist/lib/json/dialog/ItemEditDialog.jsx +0 -124
  123. package/dist/lib/json/table/TableRowActionsView.jsx +0 -45
  124. package/dist/lib/json/table/TableView.jsx +0 -100
  125. package/dist/lib/layout/AdminLayout.jsx +0 -24
  126. package/dist/lib/layout/ButtonBar.jsx +0 -29
  127. package/dist/lib/layout/Content.jsx +0 -10
  128. package/dist/lib/layout/PageTitleBar.jsx +0 -12
  129. package/dist/lib/layout/Sidebar.jsx +0 -24
  130. package/dist/lib/layout/menu/Menu.jsx +0 -30
  131. package/dist/lib/layout/menu/MenuButton.jsx +0 -7
  132. package/dist/lib/layout/menu/MenuItem.jsx +0 -20
  133. package/dist/lib/layout/menu/NextMenuItem.jsx +0 -20
  134. package/dist/lib/layout/menu/SelectedIndicator.jsx +0 -3
  135. package/dist/lib/layout/menu/UserBlock.jsx +0 -55
  136. package/dist/lib/modal/FormActionDialog.jsx +0 -46
  137. package/dist/lib/page/PageContainer.jsx +0 -4
  138. package/dist/lib/page/PageContentEditor.jsx +0 -11
  139. package/dist/lib/page/PageMain.jsx +0 -4
  140. package/dist/lib/page/PageSectionTitle.jsx +0 -3
  141. package/dist/lib/page/PageSidebar.jsx +0 -3
  142. package/dist/lib/page/PageSidebarSection.jsx +0 -7
  143. package/dist/lib/page/PageStateContainer.jsx +0 -9
  144. package/dist/lib/page/PageSubSectionTitle.jsx +0 -3
  145. package/dist/lib/page/PageTitle.jsx +0 -3
  146. package/dist/lib/table/TableContainer.jsx +0 -11
  147. package/dist/lib/table/TableCreateButton.jsx +0 -9
  148. package/dist/lib/table/TableFilterButton.jsx +0 -16
  149. package/dist/lib/table/TableMassActions.jsx +0 -15
  150. package/dist/lib/table/TableRowActionBar.jsx +0 -14
  151. package/dist/lib/table/TableRowActionButton.jsx +0 -7
  152. package/dist/lib/table/TableRowActionDialogButton.jsx +0 -8
  153. package/dist/lib/table/TableTopBar.jsx +0 -17
@@ -1,4 +1,4 @@
1
- import { DialogButtonProps } from "../buttons/DialogButton";
1
+ import { DialogButtonProps } from "../buttons/DialogButton.js";
2
2
  export declare function TableRowActionDialogButton({ icon, children, ...props }: {
3
3
  icon?: string;
4
4
  } & DialogButtonProps): JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { Icon } from "@valerya/ui";
3
+ import { DialogButton } from "../buttons/DialogButton.js";
4
+ export function TableRowActionDialogButton({ icon, children, ...props }) {
5
+ return (_jsxs(DialogButton, { dflex: true, alignContent: "center", placeContent: "center", py: "2.5", px: "3", h: "full", size: "lg", variant: "borderless", corners: "square", gap: "2", ...props, children: [icon && _jsx(Icon, { path: icon, size: "sm" }), children] }));
6
+ }
@@ -1,2 +1,2 @@
1
- import { DialogButtonProps } from "../buttons/DialogButton";
1
+ import { DialogButtonProps } from "../buttons/DialogButton.js";
2
2
  export declare function TableRowDeleteButton({ children, ...props }: DialogButtonProps): JSX.Element;
@@ -1,5 +1,6 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
1
2
  import { mdiDelete } from "@mdi/js";
2
- import { TableRowActionDialogButton } from "./TableRowActionDialogButton";
3
+ import { TableRowActionDialogButton } from "./TableRowActionDialogButton.js";
3
4
  export function TableRowDeleteButton({ children, ...props }) {
4
- return <TableRowActionDialogButton icon={mdiDelete} {...props}>{children}</TableRowActionDialogButton>;
5
+ return _jsx(TableRowActionDialogButton, { icon: mdiDelete, ...props, children: children });
5
6
  }
@@ -1,2 +1,2 @@
1
- import { DialogButtonProps } from "../buttons/DialogButton";
1
+ import { DialogButtonProps } from "../buttons/DialogButton.js";
2
2
  export declare function TableRowEditButton({ children, ...props }: DialogButtonProps): JSX.Element;
@@ -1,7 +1,6 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
1
2
  import { mdiPencil } from "@mdi/js";
2
- import { TableRowActionDialogButton } from "./TableRowActionDialogButton";
3
+ import { TableRowActionDialogButton } from "./TableRowActionDialogButton.js";
3
4
  export function TableRowEditButton({ children, ...props }) {
4
- return (<TableRowActionDialogButton icon={mdiPencil} {...props}>
5
- {children}
6
- </TableRowActionDialogButton>);
5
+ return (_jsx(TableRowActionDialogButton, { icon: mdiPencil, ...props, children: children }));
7
6
  }
@@ -1,7 +1,8 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
1
2
  import { mdiEye } from "@mdi/js";
2
3
  import React from "react";
3
4
  import { useNavigate } from "react-router-dom";
4
- import { TableRowActionButton } from "./TableRowActionButton";
5
+ import { TableRowActionButton } from "./TableRowActionButton.js";
5
6
  export function TableRowNavigateButton({ path, ...props }) {
6
7
  const navigate = useNavigate();
7
8
  const handleClick = React.useCallback((event) => {
@@ -9,5 +10,5 @@ export function TableRowNavigateButton({ path, ...props }) {
9
10
  event?.stopPropagation();
10
11
  navigate(`${path}`);
11
12
  }, [navigate, path]);
12
- return <TableRowActionButton icon={mdiEye} onClick={handleClick} {...props}/>;
13
+ return _jsx(TableRowActionButton, { icon: mdiEye, onClick: handleClick, ...props });
13
14
  }
@@ -1,8 +1,9 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
1
2
  import { useInvalidateParentMutation } from "@compill/api";
2
3
  import { mdiPublish, mdiPublishOff } from "@mdi/js";
3
4
  import React from "react";
4
5
  import { toast } from "react-toastify";
5
- import { TableRowActionButton } from "./TableRowActionButton";
6
+ import { TableRowActionButton } from "./TableRowActionButton.js";
6
7
  export function TableRowPublishPostButton({ id, api, status, invalidateQueryKey, ...props }) {
7
8
  const isDraft = status == "draft";
8
9
  const mutation = useInvalidateParentMutation(isDraft ? api.publish : api.unpublish, invalidateQueryKey ?? api.queryKey, { networkMode: "always" });
@@ -14,5 +15,5 @@ export function TableRowPublishPostButton({ id, api, status, invalidateQueryKey,
14
15
  .then(() => toast.success(isDraft ? "Published!" : "Unpublished!"))
15
16
  .catch(error => toast.error(`Error: ${error}`));
16
17
  }, [mutation, id]);
17
- return (<TableRowActionButton icon={isDraft ? mdiPublish : mdiPublishOff} onClick={publish} {...props}/>);
18
+ return (_jsx(TableRowActionButton, { icon: isDraft ? mdiPublish : mdiPublishOff, onClick: publish, ...props }));
18
19
  }
@@ -1,6 +1,7 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
1
2
  import { mdiOpenInNew } from "@mdi/js";
2
3
  import React from "react";
3
- import { TableRowActionButton } from "./TableRowActionButton";
4
+ import { TableRowActionButton } from "./TableRowActionButton.js";
4
5
  import { AppEnv } from "@compill/env";
5
6
  export function TableRowViewButton({ path, ...props }) {
6
7
  const openPage = React.useCallback((event) => {
@@ -8,5 +9,5 @@ export function TableRowViewButton({ path, ...props }) {
8
9
  event?.stopPropagation();
9
10
  window.open(`${AppEnv.websiteUrl()}/${path}`, '_blank');
10
11
  }, [path]);
11
- return <TableRowActionButton icon={mdiOpenInNew} onClick={openPage} {...props}/>;
12
+ return _jsx(TableRowActionButton, { icon: mdiOpenInNew, onClick: openPage, ...props });
12
13
  }
@@ -1,5 +1,5 @@
1
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
2
- import { Breadcrumb, QueryBreadcrumbs } from "../breadcrumbs/BreadCrumbs";
2
+ import { Breadcrumb, QueryBreadcrumbs } from "../breadcrumbs/BreadCrumbs.js";
3
3
  interface TableTopBarProps extends SoperioComponent, ParentComponent {
4
4
  title?: string;
5
5
  breadcrumbs?: Breadcrumb[] | QueryBreadcrumbs;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { Breadcrumbs } from "../breadcrumbs/BreadCrumbs.js";
3
+ export function TableTopBar({ title, breadcrumbs, children, ...props }) {
4
+ return (_jsxs("div", { dflex: true, flexRow: true, alignItems: "center", gap: "3", p: "8", ...props, children: [_jsxs("div", { children: [title && _jsx("h2", { textSize: "x2", fontWeight: "600", textColor: "#3f4254", textTransform: "capitalize", children: title }), breadcrumbs && _jsx(Breadcrumbs, { breadcrumbs: breadcrumbs })] }), _jsx("div", { flexGrow: true, children: "\u00A0" }), children] }));
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compill/admin",
3
- "version": "1.0.102",
3
+ "version": "1.0.104",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -15,8 +15,8 @@
15
15
  "typescript": "5.9.2",
16
16
  "@types/react": "^18.3.1",
17
17
  "@types/react-dom": "^18.3.1",
18
- "@repo/eslint-config": "0.0.0",
19
- "@repo/typescript-config": "0.0.0"
18
+ "@repo/typescript-config": "0.0.0",
19
+ "@repo/eslint-config": "0.0.0"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "react": "^18.3.1",
@@ -33,19 +33,19 @@
33
33
  "react-router-dom": "^6.11.2",
34
34
  "react-hotkeys-hook": "^5.0.1",
35
35
  "yup": "^1.1.0",
36
- "@soperio/react": "1.0.14",
37
- "@soperio/jsx-runtime": "1.0.14",
38
- "@valerya/ui": "1.0.9",
39
- "@compill/admin-api": "1.0.55",
40
- "@compill/api": "1.0.57",
41
- "@compill/auth": "1.0.77",
42
- "@compill/env": "1.0.19",
43
- "@compill/components": "1.0.49",
44
- "@compill/form": "1.0.67",
45
- "@compill/hooks": "1.0.43",
46
- "@compill/table": "1.0.80",
47
- "@compill/editor": "1.0.79",
48
- "@compill/form-editor": "1.0.19"
36
+ "@soperio/react": "1.0.16",
37
+ "@compill/admin-api": "1.0.57",
38
+ "@soperio/jsx-runtime": "1.0.16",
39
+ "@compill/api": "1.0.59",
40
+ "@compill/auth": "1.0.79",
41
+ "@valerya/ui": "1.0.17",
42
+ "@compill/env": "1.0.21",
43
+ "@compill/form": "1.0.69",
44
+ "@compill/form-editor": "1.0.21",
45
+ "@compill/hooks": "1.0.45",
46
+ "@compill/table": "1.0.82",
47
+ "@compill/components": "1.0.52",
48
+ "@compill/editor": "1.0.81"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"
@@ -54,7 +54,7 @@
54
54
  "dist"
55
55
  ],
56
56
  "scripts": {
57
- "build": "tsc -p tsconfig.build.json",
57
+ "build": "tsc -p tsconfig.build.json && node ../../fix-imports.js",
58
58
  "dev": "tsup src/index.ts --format esm --dts --watch",
59
59
  "lint": "eslint . --max-warnings 0",
60
60
  "check-types": "tsc --noEmit"
@@ -1,3 +0,0 @@
1
- export function SectionTitle({ children, ...props }) {
2
- return <h2 textSize="xl" fontWeight="600" textColor="slate-800" {...props}>{children}</h2>;
3
- }
@@ -1,43 +0,0 @@
1
- import { useApiQuery } from "@compill/api";
2
- import { Shimmer } from "@compill/components";
3
- import { mdiCircleSmall } from "@mdi/js";
4
- import { Icon } from "@valerya/ui";
5
- import { isArray } from "es-toolkit/compat";
6
- import Link from "next/link";
7
- import { useParams } from "react-router-dom";
8
- export function Breadcrumbs({ breadcrumbs, ...props }) {
9
- if (isArray(breadcrumbs)) {
10
- return (<div dflex alignItems="center" trait="typo.h5" {...props}>
11
- {breadcrumbs.map((b, index) => <BreadcrumbItem key={index} breadcrumb={b} showSeparator={index > 0}/>)}
12
- </div>);
13
- }
14
- return <QueryBreadcrumbs queryFn={breadcrumbs.queryFn} queryField={breadcrumbs.queryField} generate={breadcrumbs.generate}/>;
15
- }
16
- function QueryBreadcrumbs({ queryFn, queryField, generate, ...props }) {
17
- const params = useParams();
18
- const id = queryField ? params[queryField] : undefined;
19
- const { data, isLoading, isError } = useApiQuery([""], queryFn, id);
20
- if (isLoading || isError) {
21
- return (<div dflex alignItems="center">
22
- <Shimmer h="8" w="24"/>
23
- <Icon path={mdiCircleSmall} mx="1"/>
24
- <Shimmer h="8" w="20"/>
25
- </div>);
26
- }
27
- const breadcrumbs = generate(data);
28
- return (<div dflex alignItems="center" trait="typo.h5" {...props}>
29
- {breadcrumbs.map((b, index) => <BreadcrumbItem key={index} breadcrumb={b} showSeparator={index > 0}/>)}
30
- </div>);
31
- }
32
- function BreadcrumbItem({ breadcrumb, showSeparator }) {
33
- return (<>
34
- {showSeparator && <Icon path={mdiCircleSmall} mx="1"/>}
35
- <Link href={`/${breadcrumb.path || "#"}`}>
36
- <span
37
- // onClick={breadcrumb.path ? handleClick : undefined}
38
- hover_textDecoration={breadcrumb.path ? "underline" : undefined} cursor={breadcrumb.path ? "pointer" : undefined}>
39
- {breadcrumb.label}
40
- </span>
41
- </Link>
42
- </>);
43
- }
@@ -1,96 +0,0 @@
1
- import { useInvalidateParentMutation, useMutate } from "@compill/api";
2
- import { FormProvider, FormRenderer, TextArea } from "@compill/form";
3
- import { runIfFn } from "@soperio/react";
4
- import React from "react";
5
- import { useParams } from "react-router-dom";
6
- import { PageContainer } from "../page/PageContainer";
7
- import { PageContentEditor } from "../page/PageContentEditor";
8
- import { PageQueryStateContainer } from "../page/PageQueryStateContainer";
9
- import { PageSidebar } from "../page/PageSidebar";
10
- import { PageSidebarSection } from "../page/PageSidebarSection";
11
- import { ScreenTopBar } from "./ScreenTopBar";
12
- import { useRouter } from "next/router";
13
- import { useInvalidatePage } from "@compill/admin-api";
14
- function useQueryField(queryField, useNextRouter) {
15
- if (useNextRouter) {
16
- const router = useRouter();
17
- return router.query[queryField];
18
- }
19
- const { [queryField]: id } = useParams();
20
- return id;
21
- }
22
- export function DetailsView({ queryField, api, useNextRouter, processInput, screen, tabbed, ...props }) {
23
- const id = useQueryField(queryField, useNextRouter);
24
- const ref = React.useRef(null);
25
- return (<PageQueryStateContainer api={api} apiFn="get" queryId={id} ref={ref} p="5" {...props}>
26
- {(item) => <Internal item={item} screen={screen} api={api} tabbed={tabbed} processInput={processInput} containerRef={ref}/>}
27
- </PageQueryStateContainer>);
28
- }
29
- function Internal({ item, screen, api, processInput, tabbed, containerRef }) {
30
- const pScreen = runIfFn(screen, item);
31
- const { breadcrumbs, schema, initialValues, header, sections, buttonBar, type, invalidateParentQueryKey, invalidatePage } = pScreen;
32
- const mutation = useInvalidateParentMutation((api.update), invalidateParentQueryKey ?? api.queryKey, { networkMode: "always" });
33
- const invalidatePageFn = useInvalidatePage(invalidatePage || "");
34
- const save = useMutate(mutation, {
35
- processInput,
36
- successMsg: (item, values) => `${item.title || item.name} updated.`,
37
- errorMsg: (error, item) => `Error updating ${item.title || item.name}: ${error}`,
38
- onSuccess: () => {
39
- if (invalidatePage)
40
- invalidatePageFn();
41
- }
42
- });
43
- let editorMaxW = undefined;
44
- if (!type || type == "post")
45
- editorMaxW = "calc(1280px - 28rem)";
46
- else if (type == "section")
47
- editorMaxW = "calc(1280px - 22rem)";
48
- return (<FormProvider initialValues={runIfFn(initialValues, item)} validationSchema={schema} onSubmit={save} enableReinitialize>
49
- <ScreenTopBar tabbed={tabbed} api={api} breadcrumbs={breadcrumbs} buttonBar={buttonBar} item={item} isLoading={mutation.isLoading} trackingRef={containerRef?.current}/>
50
-
51
- {type == "form" && sections?.map((section, index) => (<Section key={index} section={section} item={item}/>))}
52
-
53
- {(pScreen.type == "post" || pScreen.type == "section") &&
54
- (<div p="5" bgColor="slate-100" rounded="lg">
55
- <PageContainer w={editorMaxW ? "auto" : "full"} size="x2" id="pagecontainer">
56
- {header}
57
-
58
- <div dflex gap="5">
59
- <div dflex flexCol gap="8" flexGrow>
60
- {pScreen.editor?.type != "textarea" &&
61
- (
62
- // TODO Find a way to make this editor shrink in width when resizing the window...
63
- <PageContentEditor name="content" maxW={editorMaxW} minW="144" shadow rounded="lg"/>)}
64
-
65
- {pScreen.editor?.type == "textarea" &&
66
- (<TextArea name={pScreen.editor?.name} maxW={editorMaxW} minW={editorMaxW} w={editorMaxW} minH="128" rows={25} bgColor="white" border="0" shadow p="5" textColor="slate-800"/>)}
67
-
68
- {pScreen.editorFooter}
69
- </div>
70
-
71
- <PageSidebar>
72
- {sections?.map((section, index) => (<Section key={index} section={section} item={item} cardStyle/>))}
73
- </PageSidebar>
74
- </div>
75
- </PageContainer>
76
- </div>)}
77
- </FormProvider>);
78
- }
79
- function Section({ section, item, cardStyle }) {
80
- if (section.type === "section") {
81
- const style = cardStyle ?
82
- {
83
- bgColor: "white",
84
- rounded: "lg",
85
- p: "5",
86
- textSize: "sm",
87
- shadow: true
88
- } : {};
89
- return (<PageSidebarSection title={section.title} {...style}>
90
- <FormRenderer form={runIfFn(section.form, item)}/>
91
- </PageSidebarSection>);
92
- }
93
- if (section.type === "custom")
94
- return runIfFn(section.component, item);
95
- return null;
96
- }
@@ -1,5 +0,0 @@
1
- import { runIfFn } from "@soperio/react";
2
- import { ItemEditDialog } from "./dialog/ItemEditDialog";
3
- export function EditItemView({ initialValues, ...props }) {
4
- return (<ItemEditDialog {...props} initialValues={runIfFn(initialValues, null)} show/>);
5
- }
@@ -1,18 +0,0 @@
1
- import { DetailsView } from "./DetailsView";
2
- import { QueryWrapper } from "./QueryWrapper";
3
- import { TabbedView } from "./TabbedView";
4
- import { TableView } from "./table/TableView";
5
- import { MultiQueryWrapper } from "./MultiQueryWrapper";
6
- export function ScreenRenderer({ config, tabbed, ...props }) {
7
- if (config.type === "table")
8
- return <TableView {...config} {...props}/>;
9
- if (config.type === "tabbed")
10
- return <TabbedView {...config} {...props}/>;
11
- if (config.type === "details")
12
- return <DetailsView {...config} tabbed={tabbed} {...props}/>;
13
- if (config.type === "query")
14
- return <QueryWrapper {...config} tabbed={tabbed} {...props}/>;
15
- if (config.type === "multiQuery")
16
- return <MultiQueryWrapper {...config} tabbed={tabbed} {...props}/>;
17
- return <></>;
18
- }
@@ -1,39 +0,0 @@
1
- import { API } from "@compill/admin-api";
2
- import { InvalidateButton } from "../buttons/InvalidateButton";
3
- import { PublishButton } from "../buttons/PublishButton";
4
- import { UpdateButton } from "../buttons/UpdateButton";
5
- import { ViewButton } from "../buttons/ViewButton";
6
- import { PageTopBar, PageTopBarToolbar } from "../page/PageTopBar";
7
- import React from "react";
8
- import { ButtonBar } from "../layout/ButtonBar";
9
- export function ScreenTopBar({ tabbed, breadcrumbs, api, item, isLoading, buttonBar, trackingRef }) {
10
- return (<>
11
- {tabbed &&
12
- (<PageTopBarToolbar trackingRef={trackingRef}>
13
- <Buttons api={api} item={item} isLoading={isLoading} buttonBar={buttonBar}/>
14
- </PageTopBarToolbar>)}
15
-
16
- {!tabbed &&
17
- (<PageTopBar breadcrumbs={breadcrumbs}>
18
- <Buttons api={api} item={item} isLoading={isLoading} buttonBar={buttonBar}/>
19
- </PageTopBar>)}
20
- </>);
21
- }
22
- function Buttons({ api, item, isLoading, buttonBar }) {
23
- return (<>
24
- {buttonBar && buttonBar.length > 0 &&
25
- (<ButtonBar>
26
- {buttonBar.map((button, index) => (<React.Fragment key={index}>
27
- {button.type === "link" && <ViewButton label={button.label} path={button.path} icon={button.icon}/>}
28
- {button.type === "invalidate" && <InvalidateButton pathOrPermalink={button.pathOrPermalink}/>}
29
- {button.type == "custom" && button.render(item)}
30
- </React.Fragment>))}
31
- </ButtonBar>)}
32
-
33
- <ButtonBar>
34
- {api instanceof API && <PublishButton api={api} queryId={item.id} status={item.status} disabled={isLoading}/>}
35
-
36
- <UpdateButton disabled={isLoading}/>
37
- </ButtonBar>
38
- </>);
39
- }
@@ -1,28 +0,0 @@
1
- import { useParams } from "react-router-dom";
2
- import { PageQueryStateContainer } from "../page/PageQueryStateContainer";
3
- import { PageTabbedTopBar, PageTabbedTopBarProvider } from "../page/PageTopBar";
4
- import { TabContainer } from "@compill/components";
5
- import { runIfFn } from "@soperio/react";
6
- import { ScreenRenderer } from "./ScreenRenderer";
7
- export function TabbedView({ queryField, api, screen, ...props }) {
8
- const { [queryField]: id } = useParams();
9
- return (<PageQueryStateContainer queryId={id} api={api} apiFn="get" p="5">
10
- {(city) => {
11
- const { breadcrumbs, tabs } = runIfFn(screen, city);
12
- return (<PageTabbedTopBarProvider>
13
- <PageTabbedTopBar breadcrumbs={breadcrumbs} mb="-3"/>
14
-
15
- <TabContainer tabs={tabs.map(tab => tab.label)} saveKey={`tab-${id}`} mt="-3" mb="3" id="fff">
16
- {tabs.map((tab, index) => <TabView key={index} tab={tab}/>)}
17
- </TabContainer>
18
- </PageTabbedTopBarProvider>);
19
- }}
20
- </PageQueryStateContainer>);
21
- }
22
- function TabView({ tab }) {
23
- if (!tab.component && !tab.config)
24
- throw new Error(`Screen config for tabbed view: one of your tabs does not have a component or config declared: ${tab.label}`);
25
- if (tab.component)
26
- return tab.component();
27
- return <ScreenRenderer config={tab.config} tabbed p="0"/>;
28
- }
@@ -1,13 +0,0 @@
1
- import { ItemEditDialog } from "./ItemEditDialog";
2
- import { QueryWrapperDialog } from "./QueryWrapperDialog";
3
- import { MultiQueryWrapperDialog } from "./MultiQueryWrapperDialog";
4
- export function DialogRenderer({ config, onClose, invalidateQueryKey, queryId }) {
5
- const { type, ...props } = config;
6
- if (config.type === "dialog")
7
- return <ItemEditDialog {...props} queryId={queryId} invalidateQueryKey={invalidateQueryKey} show onClose={onClose}/>;
8
- if (config.type === "query")
9
- return <QueryWrapperDialog {...props} queryId={queryId} invalidateQueryKey={invalidateQueryKey} onClose={onClose}/>;
10
- if (config.type === "multiQuery")
11
- return <MultiQueryWrapperDialog {...props} queryId={queryId} invalidateQueryKey={invalidateQueryKey} onClose={onClose}/>;
12
- return null;
13
- }
@@ -1,36 +0,0 @@
1
- import { useApiMutation, useInvalidateParentMutation, useMutate } from "@compill/api";
2
- import { ModalLoadingOverlay } from "@compill/components";
3
- import { runIfFn } from "@soperio/react";
4
- import { Button, Modal } from "@valerya/ui";
5
- import React from "react";
6
- export function ItemDeleteDialog({ title, actionButtonLabel, closeActionButtonLabel = "Cancel", itemLabel, queryId = "", api, apiFn, invalidateQueriesOnSuccess = true, invalidateQueryKey, size = "lg", md_boxSizing, msg, show, onClose, onSuccess, ...props }) {
7
- const fn = apiFn ? api[apiFn] : api.delete;
8
- const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(fn, invalidateQueryKey ?? api.queryKey)
9
- : useApiMutation(fn, api.queryKey);
10
- const mutate = useMutate(mutation, { onSuccess: () => { onClose?.(); onSuccess?.(); } });
11
- const handleDelete = React.useCallback(() => mutate(queryId), [mutate, queryId]);
12
- return (<Modal size={size} show={show} onClose={onClose} scheme="danger" variant="glass" transition
13
- // closeOnMaskClick={false}
14
- {...props}>
15
- <Modal.Header>
16
- {title || `Delete ${itemLabel}`}
17
- </Modal.Header>
18
-
19
-
20
- <Modal.Body pb="6">
21
- {!msg && `Do you really want to delete ${itemLabel}?`}
22
- {msg && runIfFn(msg, itemLabel)}
23
- </Modal.Body>
24
-
25
- <Modal.Footer dflex placeContent="end" spaceX="3">
26
- <Button disabled={mutation.isPending} onClick={onClose} variant="borderless" scheme="dark" me="2">
27
- {closeActionButtonLabel}
28
- </Button>
29
- <Button scheme="danger" disabled={mutation.isPending} onClick={handleDelete}>
30
- {actionButtonLabel || "Delete"}
31
- </Button>
32
- </Modal.Footer>
33
-
34
- {mutation.isPending && <ModalLoadingOverlay />}
35
- </Modal>);
36
- }
@@ -1,124 +0,0 @@
1
- import { useApiMutation, useApiQuery, useInvalidateParentMutation } from "@compill/api";
2
- import { ModalLoadingOverlay, QueryLoadingState, RetryOnError } from "@compill/components";
3
- import { FormRenderer } from "@compill/form";
4
- import { isFunction } from "@soperio/react";
5
- import { Button, Modal } from "@valerya/ui";
6
- import { Form, Formik } from "formik";
7
- import React from "react";
8
- import { toast } from "react-toastify";
9
- const defaultErrorMsg = "Oops, something went wrong...";
10
- function nonNullValues(data) {
11
- if (data) {
12
- const nonNullData = { ...data };
13
- for (const key in data)
14
- nonNullData[key] = nonNullData[key] ?? "";
15
- return nonNullData;
16
- }
17
- return data;
18
- }
19
- export function ItemEditDialog({ initialValues, itemLabel, queryId = "", api, queryFetchOptions, querySaveOptions, onSuccess, onFetchError, fetchErrorMsg = defaultErrorMsg, onSaveError, saveErrorMsg = defaultErrorMsg, fetchToFormData, formToQueryData, invalidateQueriesOnSuccess = true, invalidateQueryKey, retryText = "Retry", cancelLabel = "Cancel", saveLabel, size = "lg", title, form, show, onClose, formikProps, ...props }) {
20
- const { isInitialLoading, isFetching, data, isError, error /*, error*/, refetch } = useApiQuery(api.queryKey, api.get, queryId, {
21
- enabled: !( /*queryId == 0 || */queryId == "" || queryId == null || queryId == undefined), // means than this query is only enabled if the id is defined
22
- onError: onFetchError,
23
- ...queryFetchOptions
24
- });
25
- // const [activeTab, setActiveTab] = React.useState(form && Array.isArray(form) ? form[0].key : "");
26
- // const [showTab, setShowTab] = React.useState(true);
27
- const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(api.upsert, invalidateQueryKey ?? api.queryKey, querySaveOptions)
28
- : useApiMutation(api.upsert, api.queryKey, queryId, querySaveOptions);
29
- const retry = React.useCallback(() => refetch(), [refetch]);
30
- const saveItem = React.useCallback(async (item, actions) => {
31
- // Clear mutation error if any
32
- mutation.reset();
33
- const formItem = formToQueryData ? formToQueryData(item) : { ...item };
34
- await mutation.mutateAsync(formItem)
35
- .then((response) => {
36
- if (onSuccess)
37
- onSuccess(formItem, response);
38
- else
39
- toast.success(`${title ? title(formItem) : formItem.name ?? formItem.title} ${queryId ? "saved" : "created"}`);
40
- // closing delete modal
41
- onClose?.();
42
- })
43
- .catch(error => {
44
- console.error("on error", error);
45
- if (onSaveError)
46
- onSaveError(item);
47
- else
48
- toast.error(`Couldn't save ${title ? title(formItem) : formItem.name ?? formItem.title}`);
49
- actions.setSubmitting(false);
50
- });
51
- }, [mutation, formToQueryData, onSuccess, onSaveError, onClose]);
52
- // const switchTab = React.useCallback((tab: string) =>
53
- // {
54
- // setActiveTab(tab);
55
- // setShowTab(false);
56
- // setTimeout(function ()
57
- // {
58
- // setActiveTab(tab);
59
- // setShowTab(true);
60
- // }, 150);
61
- // }, [setActiveTab])
62
- return (<Modal size={size} show={show} onClose={onClose} scheme="light" transition
63
- // closeOnMaskClick={false}
64
- {...props}>
65
- <Modal.Header>
66
- {!isInitialLoading && queryId && `Edit ${title ? title(data) : data?.["name"] ?? data?.["title"] ?? data?.["name"] ?? ""}`}
67
-
68
- {!queryId && `Create new ${itemLabel ?? "item"}`}
69
-
70
- {Array.isArray(form) && (<></>
71
- // <ul className="nav nav-bold nav-pills">
72
- // {form.map(item =>
73
- // <li key={item.key} className="nav-item cursor-pointer bg-hover-light rounded" onClick={() => switchTab(item.key)}>
74
- // <span className={clsx("nav-link", activeTab === item.key && "active")} data-toggle="tab">{item.label}</span>
75
- // </li>
76
- // )}
77
- // </ul>
78
- )}
79
- {/* <ModalCloseButton /> */}
80
- </Modal.Header>
81
-
82
- {isInitialLoading && (<Modal.Body>
83
- <QueryLoadingState minW="72"/>
84
- </Modal.Body>)}
85
-
86
- {isError && (<Modal.Body>
87
- <RetryOnError label={`${fetchErrorMsg} ${error}`} onClick={retry}/>
88
- </Modal.Body>)}
89
-
90
- {!isInitialLoading && !isError &&
91
- (<>
92
- <Formik
93
- // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
94
- initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(initialValues(data)) ?? {}} onSubmit={saveItem} {...formikProps}>
95
- {({ setFieldValue, dirty, handleSubmit, isValid, values }) => (<>
96
- <Modal.Body pb="6">
97
- <Form>
98
- {React.isValidElement(form) && form}
99
-
100
- {Array.isArray(form) && <FormRenderer form={form}/>}
101
- {isFunction(form) && <FormRenderer form={form(data ?? values)}/>}
102
- {/* {Array.isArray(form) && form.map(item =>
103
- <div key={item.key} className={clsx("tab-pane fade", showTab && "show", activeTab === item.key && "active")}>
104
- {item.form}
105
- </div>
106
- )} */}
107
- </Form>
108
- </Modal.Body>
109
-
110
- <Modal.Footer dflex placeContent="end" spaceX="3">
111
- <Button disabled={mutation.isLoading} onClick={onClose} variant="borderless" me="2">
112
- {cancelLabel}
113
- </Button>
114
- <Button type="submit" disabled={!dirty || mutation.isLoading /* || !isValid*/} onClick={() => handleSubmit()}>
115
- {saveLabel ? saveLabel : (queryId ? "Update" : "Create")}
116
- </Button>
117
- </Modal.Footer>
118
- </>)}
119
- </Formik>
120
- </>)}
121
-
122
- {mutation.isLoading && <ModalLoadingOverlay />}
123
- </Modal>);
124
- }