@compill/admin 1.0.103 → 1.0.105

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 (165) hide show
  1. package/dist/index.cjs +2054 -0
  2. package/dist/index.d.cts +565 -0
  3. package/dist/index.d.ts +565 -50
  4. package/dist/index.js +2000 -50
  5. package/package.json +19 -18
  6. package/dist/lib/SectionTitle.d.ts +0 -2
  7. package/dist/lib/SectionTitle.js +0 -4
  8. package/dist/lib/breadcrumbs/BreadCrumbs.d.ts +0 -15
  9. package/dist/lib/breadcrumbs/BreadCrumbs.js +0 -29
  10. package/dist/lib/buttons/DialogButton.d.ts +0 -7
  11. package/dist/lib/buttons/DialogButton.js +0 -15
  12. package/dist/lib/buttons/InvalidateButton.d.ts +0 -6
  13. package/dist/lib/buttons/InvalidateButton.js +0 -11
  14. package/dist/lib/buttons/NavigateButton.d.ts +0 -4
  15. package/dist/lib/buttons/NavigateButton.js +0 -12
  16. package/dist/lib/buttons/PublishButton.d.ts +0 -9
  17. package/dist/lib/buttons/PublishButton.js +0 -17
  18. package/dist/lib/buttons/UpdateButton.d.ts +0 -2
  19. package/dist/lib/buttons/UpdateButton.js +0 -11
  20. package/dist/lib/buttons/ViewButton.d.ts +0 -5
  21. package/dist/lib/buttons/ViewButton.js +0 -13
  22. package/dist/lib/cells/OrderCell.d.ts +0 -11
  23. package/dist/lib/cells/OrderCell.js +0 -26
  24. package/dist/lib/json/DetailsView.d.ts +0 -5
  25. package/dist/lib/json/DetailsView.js +0 -69
  26. package/dist/lib/json/EditItemView.d.ts +0 -2
  27. package/dist/lib/json/EditItemView.js +0 -6
  28. package/dist/lib/json/MultiQueryWrapper.d.ts +0 -5
  29. package/dist/lib/json/MultiQueryWrapper.js +0 -61
  30. package/dist/lib/json/QueryWrapper.d.ts +0 -6
  31. package/dist/lib/json/QueryWrapper.js +0 -29
  32. package/dist/lib/json/ScreenRenderer.d.ts +0 -6
  33. package/dist/lib/json/ScreenRenderer.js +0 -19
  34. package/dist/lib/json/ScreenTopBar.d.ts +0 -15
  35. package/dist/lib/json/ScreenTopBar.js +0 -18
  36. package/dist/lib/json/TabbedView.d.ts +0 -3
  37. package/dist/lib/json/TabbedView.js +0 -21
  38. package/dist/lib/json/buttons/ActionButton.d.ts +0 -14
  39. package/dist/lib/json/buttons/ActionButton.js +0 -11
  40. package/dist/lib/json/buttons/ConfirmationActionButton.d.ts +0 -26
  41. package/dist/lib/json/buttons/ConfirmationActionButton.js +0 -20
  42. package/dist/lib/json/dialog/DialogRenderer.d.ts +0 -11
  43. package/dist/lib/json/dialog/DialogRenderer.js +0 -14
  44. package/dist/lib/json/dialog/ItemDeleteDialog.d.ts +0 -17
  45. package/dist/lib/json/dialog/ItemDeleteDialog.js +0 -14
  46. package/dist/lib/json/dialog/ItemEditDialog.d.ts +0 -32
  47. package/dist/lib/json/dialog/ItemEditDialog.js +0 -77
  48. package/dist/lib/json/dialog/MultiQueryWrapperDialog.d.ts +0 -7
  49. package/dist/lib/json/dialog/MultiQueryWrapperDialog.js +0 -23
  50. package/dist/lib/json/dialog/QueryWrapperDialog.d.ts +0 -13
  51. package/dist/lib/json/dialog/QueryWrapperDialog.js +0 -20
  52. package/dist/lib/json/table/RefreshButton.d.ts +0 -3
  53. package/dist/lib/json/table/RefreshButton.js +0 -11
  54. package/dist/lib/json/table/TableRowActionsView.d.ts +0 -11
  55. package/dist/lib/json/table/TableRowActionsView.js +0 -36
  56. package/dist/lib/json/table/TableRowPublishPostButton.d.ts +0 -8
  57. package/dist/lib/json/table/TableRowPublishPostButton.js +0 -20
  58. package/dist/lib/json/table/TableView.d.ts +0 -3
  59. package/dist/lib/json/table/TableView.js +0 -65
  60. package/dist/lib/json/table/TableViewContext.d.ts +0 -14
  61. package/dist/lib/json/table/TableViewContext.js +0 -58
  62. package/dist/lib/json/table/useTableProps.d.ts +0 -3
  63. package/dist/lib/json/table/useTableProps.js +0 -57
  64. package/dist/lib/json/types/DetailsView.d.ts +0 -57
  65. package/dist/lib/json/types/DetailsView.js +0 -1
  66. package/dist/lib/json/types/EditItemDialog.d.ts +0 -4
  67. package/dist/lib/json/types/EditItemDialog.js +0 -1
  68. package/dist/lib/json/types/MultiQueryWrapper.d.ts +0 -18
  69. package/dist/lib/json/types/MultiQueryWrapper.js +0 -1
  70. package/dist/lib/json/types/MultiQueryWrapperDialog.d.ts +0 -13
  71. package/dist/lib/json/types/MultiQueryWrapperDialog.js +0 -1
  72. package/dist/lib/json/types/QueryWrapper.d.ts +0 -27
  73. package/dist/lib/json/types/QueryWrapper.js +0 -1
  74. package/dist/lib/json/types/QueryWrapperDialog.d.ts +0 -22
  75. package/dist/lib/json/types/QueryWrapperDialog.js +0 -1
  76. package/dist/lib/json/types/ScreenConfig.d.ts +0 -8
  77. package/dist/lib/json/types/ScreenConfig.js +0 -1
  78. package/dist/lib/json/types/TabbedView.d.ts +0 -22
  79. package/dist/lib/json/types/TabbedView.js +0 -1
  80. package/dist/lib/json/types/TableView.d.ts +0 -117
  81. package/dist/lib/json/types/TableView.js +0 -1
  82. package/dist/lib/layout/AdminLayout.d.ts +0 -13
  83. package/dist/lib/layout/AdminLayout.js +0 -15
  84. package/dist/lib/layout/ButtonBar.d.ts +0 -19
  85. package/dist/lib/layout/ButtonBar.js +0 -19
  86. package/dist/lib/layout/Content.d.ts +0 -9
  87. package/dist/lib/layout/Content.js +0 -9
  88. package/dist/lib/layout/PageTitleBar.d.ts +0 -6
  89. package/dist/lib/layout/PageTitleBar.js +0 -4
  90. package/dist/lib/layout/Sidebar.d.ts +0 -20
  91. package/dist/lib/layout/Sidebar.js +0 -12
  92. package/dist/lib/layout/menu/Menu.d.ts +0 -12
  93. package/dist/lib/layout/menu/Menu.js +0 -23
  94. package/dist/lib/layout/menu/MenuButton.d.ts +0 -6
  95. package/dist/lib/layout/menu/MenuButton.js +0 -5
  96. package/dist/lib/layout/menu/MenuConfig.d.ts +0 -13
  97. package/dist/lib/layout/menu/MenuConfig.js +0 -1
  98. package/dist/lib/layout/menu/MenuItem.d.ts +0 -11
  99. package/dist/lib/layout/menu/MenuItem.js +0 -11
  100. package/dist/lib/layout/menu/NextMenuItem.d.ts +0 -11
  101. package/dist/lib/layout/menu/NextMenuItem.js +0 -11
  102. package/dist/lib/layout/menu/SelectedIndicator.d.ts +0 -3
  103. package/dist/lib/layout/menu/SelectedIndicator.js +0 -4
  104. package/dist/lib/layout/menu/UserBlock.d.ts +0 -9
  105. package/dist/lib/layout/menu/UserBlock.js +0 -34
  106. package/dist/lib/modal/AttachDialog.d.ts +0 -30
  107. package/dist/lib/modal/AttachDialog.js +0 -73
  108. package/dist/lib/modal/FormActionDialog.d.ts +0 -23
  109. package/dist/lib/modal/FormActionDialog.js +0 -20
  110. package/dist/lib/page/PageContainer.d.ts +0 -2
  111. package/dist/lib/page/PageContainer.js +0 -5
  112. package/dist/lib/page/PageContentEditor.d.ts +0 -4
  113. package/dist/lib/page/PageContentEditor.js +0 -10
  114. package/dist/lib/page/PageMain.d.ts +0 -2
  115. package/dist/lib/page/PageMain.js +0 -5
  116. package/dist/lib/page/PageQueryStateContainer.d.ts +0 -21
  117. package/dist/lib/page/PageQueryStateContainer.js +0 -16
  118. package/dist/lib/page/PageSectionTitle.d.ts +0 -2
  119. package/dist/lib/page/PageSectionTitle.js +0 -4
  120. package/dist/lib/page/PageSidebar.d.ts +0 -2
  121. package/dist/lib/page/PageSidebar.js +0 -4
  122. package/dist/lib/page/PageSidebarSection.d.ts +0 -4
  123. package/dist/lib/page/PageSidebarSection.js +0 -5
  124. package/dist/lib/page/PageStateContainer.d.ts +0 -7
  125. package/dist/lib/page/PageStateContainer.js +0 -7
  126. package/dist/lib/page/PageSubSectionTitle.d.ts +0 -2
  127. package/dist/lib/page/PageSubSectionTitle.js +0 -4
  128. package/dist/lib/page/PageTitle.d.ts +0 -2
  129. package/dist/lib/page/PageTitle.js +0 -4
  130. package/dist/lib/page/PageTopBar.d.ts +0 -13
  131. package/dist/lib/page/PageTopBar.js +0 -78
  132. package/dist/lib/status/StatusBadge.d.ts +0 -4
  133. package/dist/lib/status/StatusBadge.js +0 -21
  134. package/dist/lib/table/TableColumnButton.d.ts +0 -1
  135. package/dist/lib/table/TableColumnButton.js +0 -53
  136. package/dist/lib/table/TableContainer.d.ts +0 -10
  137. package/dist/lib/table/TableContainer.js +0 -6
  138. package/dist/lib/table/TableContainerContext.d.ts +0 -18
  139. package/dist/lib/table/TableContainerContext.js +0 -40
  140. package/dist/lib/table/TableCreateButton.d.ts +0 -4
  141. package/dist/lib/table/TableCreateButton.js +0 -7
  142. package/dist/lib/table/TableFilterButton.d.ts +0 -2
  143. package/dist/lib/table/TableFilterButton.js +0 -8
  144. package/dist/lib/table/TableFilters.d.ts +0 -9
  145. package/dist/lib/table/TableFilters.js +0 -27
  146. package/dist/lib/table/TableMassActions.d.ts +0 -6
  147. package/dist/lib/table/TableMassActions.js +0 -9
  148. package/dist/lib/table/TableRowActionBar.d.ts +0 -10
  149. package/dist/lib/table/TableRowActionBar.js +0 -8
  150. package/dist/lib/table/TableRowActionButton.d.ts +0 -4
  151. package/dist/lib/table/TableRowActionButton.js +0 -5
  152. package/dist/lib/table/TableRowActionDialogButton.d.ts +0 -4
  153. package/dist/lib/table/TableRowActionDialogButton.js +0 -6
  154. package/dist/lib/table/TableRowDeleteButton.d.ts +0 -2
  155. package/dist/lib/table/TableRowDeleteButton.js +0 -6
  156. package/dist/lib/table/TableRowEditButton.d.ts +0 -2
  157. package/dist/lib/table/TableRowEditButton.js +0 -6
  158. package/dist/lib/table/TableRowNavigateButton.d.ts +0 -4
  159. package/dist/lib/table/TableRowNavigateButton.js +0 -14
  160. package/dist/lib/table/TableRowPublishPostButton.d.ts +0 -8
  161. package/dist/lib/table/TableRowPublishPostButton.js +0 -19
  162. package/dist/lib/table/TableRowViewButton.d.ts +0 -4
  163. package/dist/lib/table/TableRowViewButton.js +0 -13
  164. package/dist/lib/table/TableTopBar.d.ts +0 -8
  165. package/dist/lib/table/TableTopBar.js +0 -5
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@compill/admin",
3
- "version": "1.0.103",
3
+ "version": "1.0.105",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {
9
+ "types": "./dist/index.d.ts",
9
10
  "import": "./dist/index.js",
10
- "types": "./dist/index.d.ts"
11
+ "require": "./dist/index.cjs"
11
12
  }
12
13
  },
13
14
  "devDependencies": {
@@ -15,8 +16,8 @@
15
16
  "typescript": "5.9.2",
16
17
  "@types/react": "^18.3.1",
17
18
  "@types/react-dom": "^18.3.1",
18
- "@repo/eslint-config": "0.0.0",
19
- "@repo/typescript-config": "0.0.0"
19
+ "@repo/typescript-config": "0.0.0",
20
+ "@repo/eslint-config": "0.0.0"
20
21
  },
21
22
  "peerDependencies": {
22
23
  "react": "^18.3.1",
@@ -33,19 +34,19 @@
33
34
  "react-router-dom": "^6.11.2",
34
35
  "react-hotkeys-hook": "^5.0.1",
35
36
  "yup": "^1.1.0",
36
- "@soperio/react": "1.0.14",
37
- "@soperio/jsx-runtime": "1.0.14",
38
- "@valerya/ui": "1.0.11",
39
- "@compill/admin-api": "1.0.56",
40
- "@compill/api": "1.0.57",
41
- "@compill/auth": "1.0.78",
42
- "@compill/env": "1.0.19",
43
- "@compill/components": "1.0.51",
44
- "@compill/editor": "1.0.80",
45
- "@compill/form": "1.0.68",
46
- "@compill/hooks": "1.0.43",
47
- "@compill/form-editor": "1.0.20",
48
- "@compill/table": "1.0.81"
37
+ "@soperio/react": "1.0.19",
38
+ "@compill/admin-api": "1.0.58",
39
+ "@soperio/jsx-runtime": "1.0.19",
40
+ "@compill/api": "1.0.60",
41
+ "@valerya/ui": "1.0.18",
42
+ "@compill/auth": "1.0.80",
43
+ "@compill/components": "1.0.53",
44
+ "@compill/form": "1.0.70",
45
+ "@compill/env": "1.0.22",
46
+ "@compill/form-editor": "1.0.22",
47
+ "@compill/hooks": "1.0.46",
48
+ "@compill/editor": "1.0.82",
49
+ "@compill/table": "1.0.83"
49
50
  },
50
51
  "publishConfig": {
51
52
  "access": "public"
@@ -54,7 +55,7 @@
54
55
  "dist"
55
56
  ],
56
57
  "scripts": {
57
- "build": "tsc -p tsconfig.build.json",
58
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
58
59
  "dev": "tsup src/index.ts --format esm --dts --watch",
59
60
  "lint": "eslint . --max-warnings 0",
60
61
  "check-types": "tsc --noEmit"
@@ -1,2 +0,0 @@
1
- import { ParentComponent, SoperioComponent } from "@soperio/react";
2
- export declare function SectionTitle({ children, ...props }: SoperioComponent & ParentComponent): JSX.Element;
@@ -1,4 +0,0 @@
1
- import { jsx as _jsx } from "@soperio/jsx-runtime";
2
- export function SectionTitle({ children, ...props }) {
3
- return _jsx("h2", { textSize: "xl", fontWeight: "600", textColor: "slate-800", ...props, children: children });
4
- }
@@ -1,15 +0,0 @@
1
- import { SoperioComponent } from "@soperio/react";
2
- export interface Breadcrumb {
3
- label: string;
4
- path?: string;
5
- }
6
- interface BreadcrumbsProps extends SoperioComponent {
7
- breadcrumbs: Breadcrumb[] | QueryBreadcrumbs;
8
- }
9
- export type QueryBreadcrumbs = {
10
- queryFn: (...args: any) => Promise<any>;
11
- queryField?: string;
12
- generate: (results: any) => Breadcrumb[];
13
- };
14
- export declare function Breadcrumbs({ breadcrumbs, ...props }: BreadcrumbsProps): JSX.Element;
15
- export {};
@@ -1,29 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@soperio/jsx-runtime";
2
- import { useApiQuery } from "@compill/api";
3
- import { Shimmer } from "@compill/components";
4
- import { mdiCircleSmall } from "@mdi/js";
5
- import { Icon } from "@valerya/ui";
6
- import { isArray } from "es-toolkit/compat";
7
- import Link from "next/link";
8
- import { useParams } from "react-router-dom";
9
- export function Breadcrumbs({ breadcrumbs, ...props }) {
10
- if (isArray(breadcrumbs)) {
11
- return (_jsx("div", { dflex: true, alignItems: "center", trait: "typo.h5", ...props, children: breadcrumbs.map((b, index) => _jsx(BreadcrumbItem, { breadcrumb: b, showSeparator: index > 0 }, index)) }));
12
- }
13
- return _jsx(QueryBreadcrumbs, { queryFn: breadcrumbs.queryFn, queryField: breadcrumbs.queryField, generate: breadcrumbs.generate });
14
- }
15
- function QueryBreadcrumbs({ queryFn, queryField, generate, ...props }) {
16
- const params = useParams();
17
- const id = queryField ? params[queryField] : undefined;
18
- const { data, isLoading, isError } = useApiQuery([""], queryFn, id);
19
- if (isLoading || isError) {
20
- return (_jsxs("div", { dflex: true, alignItems: "center", children: [_jsx(Shimmer, { h: "8", w: "24" }), _jsx(Icon, { path: mdiCircleSmall, mx: "1" }), _jsx(Shimmer, { h: "8", w: "20" })] }));
21
- }
22
- const breadcrumbs = generate(data);
23
- return (_jsx("div", { dflex: true, alignItems: "center", trait: "typo.h5", ...props, children: breadcrumbs.map((b, index) => _jsx(BreadcrumbItem, { breadcrumb: b, showSeparator: index > 0 }, index)) }));
24
- }
25
- function BreadcrumbItem({ breadcrumb, showSeparator }) {
26
- return (_jsxs(_Fragment, { children: [showSeparator && _jsx(Icon, { path: mdiCircleSmall, mx: "1" }), _jsx(Link, { href: `/${breadcrumb.path || "#"}`, children: _jsx("span", {
27
- // onClick={breadcrumb.path ? handleClick : undefined}
28
- hover_textDecoration: breadcrumb.path ? "underline" : undefined, cursor: breadcrumb.path ? "pointer" : undefined, children: breadcrumb.label }) })] }));
29
- }
@@ -1,7 +0,0 @@
1
- import { ParentComponent, SoperioComponent } from "@soperio/react";
2
- import { ButtonProps } from "@valerya/ui";
3
- import React from "react";
4
- export interface DialogButtonProps extends SoperioComponent, ParentComponent, ButtonProps {
5
- buildDialog: (onClose: () => void) => React.ReactNode;
6
- }
7
- export declare function DialogButton({ buildDialog, ...props }: DialogButtonProps): JSX.Element;
@@ -1,15 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
- import { Button } from "@valerya/ui";
3
- import React from "react";
4
- export function DialogButton({ buildDialog, ...props }) {
5
- const [showDialog, setShowDialog] = React.useState(false);
6
- const onShowDialog = React.useCallback((event) => {
7
- event?.preventDefault();
8
- event?.stopPropagation();
9
- setShowDialog(true);
10
- }, [setShowDialog]);
11
- const onCloseDialog = React.useCallback(() => {
12
- setShowDialog(false);
13
- }, [setShowDialog]);
14
- return (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: onShowDialog, ...props }), showDialog && buildDialog(onCloseDialog)] }));
15
- }
@@ -1,6 +0,0 @@
1
- import { ButtonBarButtonProps } from "../layout/ButtonBar";
2
- interface InvalidateButtonProps extends ButtonBarButtonProps {
3
- pathOrPermalink: string;
4
- }
5
- export declare function InvalidateButton({ pathOrPermalink, ...props }: InvalidateButtonProps): JSX.Element;
6
- export {};
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "@soperio/jsx-runtime";
2
- import { INVALIDATE_API } from "@compill/admin-api";
3
- import { useApiMutation, useMutate } from "@compill/api";
4
- import { mdiDatabaseRefreshOutline } from "@mdi/js";
5
- import { ButtonBarButton } from "../layout/ButtonBar";
6
- export function InvalidateButton({ pathOrPermalink, ...props }) {
7
- const api = INVALIDATE_API.new(pathOrPermalink);
8
- const mutation = useApiMutation(api.invalidate, api.queryKey);
9
- const invalidate = useMutate(mutation, { successMsg: "Page successfully invalidated" });
10
- return (_jsx(ButtonBarButton, { title: "Regenerate", disabled: mutation.isLoading, onClick: invalidate, icon: mdiDatabaseRefreshOutline, ...props }));
11
- }
@@ -1,4 +0,0 @@
1
- import { ButtonProps } from "@valerya/ui";
2
- export declare function NavigateButton({ path, ...props }: {
3
- path: string;
4
- } & ButtonProps): JSX.Element;
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx } from "@soperio/jsx-runtime";
2
- import { mdiPost } from "@mdi/js";
3
- import { Button, Icon } from "@valerya/ui";
4
- import React from "react";
5
- import { useNavigate } from "react-router-dom";
6
- export function NavigateButton({ path, ...props }) {
7
- const navigate = useNavigate();
8
- const handleClick = React.useCallback(() => {
9
- navigate(path);
10
- }, [navigate, path]);
11
- return (_jsx(Button, { type: "submit", scheme: "dark", variant: "glass", corners: "pill", w: "10", h: "10", onClick: handleClick, ...props, children: _jsx(Icon, { path: mdiPost }) }));
12
- }
@@ -1,9 +0,0 @@
1
- import { API } from "@compill/admin-api";
2
- import { ButtonProps } from "@valerya/ui";
3
- interface PublishButtonProps extends ButtonProps {
4
- status: string;
5
- queryId: string;
6
- api: API<any>;
7
- }
8
- export declare function PublishButton({ status, queryId, api, ...props }: PublishButtonProps): JSX.Element;
9
- export {};
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx } from "@soperio/jsx-runtime";
2
- import { useInvalidateMutation } from "@compill/api";
3
- import { mdiEye, mdiEyeOff } from "@mdi/js";
4
- import React from "react";
5
- import { toast } from "react-toastify";
6
- import { ButtonBarButton } from "../layout/ButtonBar";
7
- export function PublishButton({ status, queryId, api, ...props }) {
8
- const isDraft = status == "draft";
9
- const mutation = useInvalidateMutation(isDraft ? api.publish : api.unpublish, api.queryKey, queryId, { networkMode: "always" });
10
- const publish = React.useCallback(() => {
11
- mutation.reset();
12
- mutation.mutateAsync(queryId)
13
- .then(() => toast.success(isDraft ? "Published!" : "Unpublished!"))
14
- .catch(error => toast.error(`Error: ${error}`));
15
- }, [mutation, queryId]);
16
- return (_jsx(ButtonBarButton, { disabled: mutation.isLoading, onClick: publish, icon: isDraft ? mdiEye : mdiEyeOff, ...props, children: isDraft ? "Publish" : "Switch to draft" }));
17
- }
@@ -1,2 +0,0 @@
1
- import { ButtonProps } from "@valerya/ui";
2
- export declare function UpdateButton({ ...props }: ButtonProps): JSX.Element;
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "@soperio/jsx-runtime";
2
- import { mdiCloudUpload } from "@mdi/js";
3
- import { useFormikContext } from "formik";
4
- import { useHotkeys } from "react-hotkeys-hook";
5
- import { ButtonBarSubmitButton } from "../layout/ButtonBar";
6
- export function UpdateButton({ ...props }) {
7
- const { dirty, handleSubmit } = useFormikContext() ?? { dirty: false, handleSubmit: undefined, values: {} };
8
- useHotkeys('ctrl+s', () => { if (dirty && !props.disabled)
9
- handleSubmit(); }, { preventDefault: true }, [dirty, props, handleSubmit]);
10
- return (_jsx(ButtonBarSubmitButton, { icon: mdiCloudUpload, ...props, children: "Update" }));
11
- }
@@ -1,5 +0,0 @@
1
- import { ButtonBarButtonProps } from "../layout/ButtonBar";
2
- export declare function ViewButton({ label, path, icon, ...props }: ButtonBarButtonProps & {
3
- label?: string;
4
- path: string;
5
- }): JSX.Element;
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx } from "@soperio/jsx-runtime";
2
- import { mdiOpenInNew } from "@mdi/js";
3
- import React from "react";
4
- import { ButtonBarButton } from "../layout/ButtonBar";
5
- export function ViewButton({ label, path, icon, ...props }) {
6
- const openPage = React.useCallback(() => {
7
- window.open(path, '_blank');
8
- }, [path]);
9
- return (_jsx(ButtonBarButton, { onClick: openPage, dflex: true, alignItems: "center", gap: "2", icon: icon || mdiOpenInNew, ...props, children: label }));
10
- // return (
11
- // <IconButton icon={icon ? icon : mdiOpenInNew} type="submit" scheme="dark" variant="glass" size="md" onClick={openPage} {...props}/>
12
- // )
13
- }
@@ -1,11 +0,0 @@
1
- interface OrderApi {
2
- moveUp: (id: string) => Promise<any>;
3
- moveDown: (id: string) => Promise<any>;
4
- queryKey: string[];
5
- }
6
- export declare function OrderCell({ api, postId, order }: {
7
- api: OrderApi;
8
- postId: string;
9
- order: number;
10
- }): JSX.Element;
11
- export {};
@@ -1,26 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
- import { FlexCenter } from "@compill/components";
3
- import { useInvalidateMutation } from "@compill/api";
4
- import { mdiArrowDownBoldBox, mdiArrowUpBoldBox } from "@mdi/js";
5
- import { Button, Icon } from "@valerya/ui";
6
- import React from "react";
7
- import { toast } from "react-toastify";
8
- export function OrderCell({ api, postId, order }) {
9
- const mutationDown = useInvalidateMutation(api.moveDown, api.queryKey);
10
- const mutationUp = useInvalidateMutation(api.moveUp, api.queryKey);
11
- const moveDown = React.useCallback((e) => {
12
- e.stopPropagation();
13
- mutationDown.mutateAsync(postId)
14
- .catch(error => {
15
- toast.error(`Error: ${error}`);
16
- });
17
- }, [mutationDown, postId]);
18
- const moveUp = React.useCallback((e) => {
19
- e.stopPropagation();
20
- mutationUp.mutateAsync(postId)
21
- .catch(error => {
22
- toast.error(`Error: ${error}`);
23
- });
24
- }, [mutationUp, postId]);
25
- return (_jsxs(FlexCenter, { placeContent: "start", numericFontVariant: "tabular-nums", children: [order, _jsx(Button, { ms: "3", variant: "borderless", scheme: "dark", onClick: moveUp, children: _jsx(Icon, { path: mdiArrowUpBoldBox }) }), _jsx(Button, { variant: "borderless", scheme: "dark", onClick: moveDown, children: _jsx(Icon, { path: mdiArrowDownBoldBox }) })] }));
26
- }
@@ -1,5 +0,0 @@
1
- import { SoperioComponent } from "@soperio/react";
2
- import { DetailsViewConfig } from "./types/DetailsView";
3
- export declare function DetailsView({ queryField, api, useNextRouter, processInput, screen, tabbed, ...props }: DetailsViewConfig & {
4
- tabbed?: boolean;
5
- } & SoperioComponent): JSX.Element;
@@ -1,69 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
- import { useInvalidateParentMutation, useMutate } from "@compill/api";
3
- import { FormProvider, FormRenderer, TextArea } from "@compill/form";
4
- import { runIfFn } from "@soperio/react";
5
- import React from "react";
6
- import { useParams } from "react-router-dom";
7
- import { PageContainer } from "../page/PageContainer";
8
- import { PageContentEditor } from "../page/PageContentEditor";
9
- import { PageQueryStateContainer } from "../page/PageQueryStateContainer";
10
- import { PageSidebar } from "../page/PageSidebar";
11
- import { PageSidebarSection } from "../page/PageSidebarSection";
12
- import { ScreenTopBar } from "./ScreenTopBar";
13
- import { useRouter } from "next/router";
14
- import { useInvalidatePage } from "@compill/admin-api";
15
- function useQueryField(queryField, useNextRouter) {
16
- if (useNextRouter) {
17
- const router = useRouter();
18
- return router.query[queryField];
19
- }
20
- const { [queryField]: id } = useParams();
21
- return id;
22
- }
23
- export function DetailsView({ queryField, api, useNextRouter, processInput, screen, tabbed, ...props }) {
24
- const id = useQueryField(queryField, useNextRouter);
25
- const ref = React.useRef(null);
26
- return (_jsx(PageQueryStateContainer, { api: api, apiFn: "get", queryId: id, ref: ref, p: "5", ...props, children: (item) => _jsx(Internal, { item: item, screen: screen, api: api, tabbed: tabbed, processInput: processInput, containerRef: ref }) }));
27
- }
28
- function Internal({ item, screen, api, processInput, tabbed, containerRef }) {
29
- const pScreen = runIfFn(screen, item);
30
- const { breadcrumbs, schema, initialValues, header, sections, buttonBar, type, invalidateParentQueryKey, invalidatePage } = pScreen;
31
- const mutation = useInvalidateParentMutation((api.update), invalidateParentQueryKey ?? api.queryKey, { networkMode: "always" });
32
- const invalidatePageFn = useInvalidatePage(invalidatePage || "");
33
- const save = useMutate(mutation, {
34
- processInput,
35
- successMsg: (item, values) => `${item.title || item.name} updated.`,
36
- errorMsg: (error, item) => `Error updating ${item.title || item.name}: ${error}`,
37
- onSuccess: () => {
38
- if (invalidatePage)
39
- invalidatePageFn();
40
- }
41
- });
42
- let editorMaxW = undefined;
43
- if (!type || type == "post")
44
- editorMaxW = "calc(1280px - 28rem)";
45
- else if (type == "section")
46
- editorMaxW = "calc(1280px - 22rem)";
47
- return (_jsxs(FormProvider, { initialValues: runIfFn(initialValues, item), validationSchema: schema, onSubmit: save, enableReinitialize: true, children: [_jsx(ScreenTopBar, { tabbed: tabbed, api: api, breadcrumbs: breadcrumbs, buttonBar: buttonBar, item: item, isLoading: mutation.isLoading, trackingRef: containerRef?.current }), type == "form" && sections?.map((section, index) => (_jsx(Section, { section: section, item: item }, index))), (pScreen.type == "post" || pScreen.type == "section") &&
48
- (_jsx("div", { p: "5", bgColor: "slate-100", rounded: "lg", children: _jsxs(PageContainer, { w: editorMaxW ? "auto" : "full", size: "x2", id: "pagecontainer", children: [header, _jsxs("div", { dflex: true, gap: "5", children: [_jsxs("div", { dflex: true, flexCol: true, gap: "8", flexGrow: true, children: [pScreen.editor?.type != "textarea" &&
49
- (
50
- // TODO Find a way to make this editor shrink in width when resizing the window...
51
- _jsx(PageContentEditor, { name: "content", maxW: editorMaxW, minW: "144", shadow: true, rounded: "lg" })), pScreen.editor?.type == "textarea" &&
52
- (_jsx(TextArea, { name: pScreen.editor?.name, maxW: editorMaxW, minW: editorMaxW, w: editorMaxW, minH: "128", rows: 25, bgColor: "white", border: "0", shadow: true, p: "5", textColor: "slate-800" })), pScreen.editorFooter] }), _jsx(PageSidebar, { children: sections?.map((section, index) => (_jsx(Section, { section: section, item: item, cardStyle: true }, index))) })] })] }) }))] }));
53
- }
54
- function Section({ section, item, cardStyle }) {
55
- if (section.type === "section") {
56
- const style = cardStyle ?
57
- {
58
- bgColor: "white",
59
- rounded: "lg",
60
- p: "5",
61
- textSize: "sm",
62
- shadow: true
63
- } : {};
64
- return (_jsx(PageSidebarSection, { title: section.title, ...style, children: _jsx(FormRenderer, { form: runIfFn(section.form, item) }) }));
65
- }
66
- if (section.type === "custom")
67
- return runIfFn(section.component, item);
68
- return null;
69
- }
@@ -1,2 +0,0 @@
1
- import { ItemEditDialogProps } from "./dialog/ItemEditDialog";
2
- export declare function EditItemView({ initialValues, ...props }: Omit<ItemEditDialogProps, "show">): JSX.Element;
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx } from "@soperio/jsx-runtime";
2
- import { runIfFn } from "@soperio/react";
3
- import { ItemEditDialog } from "./dialog/ItemEditDialog";
4
- export function EditItemView({ initialValues, ...props }) {
5
- return (_jsx(ItemEditDialog, { ...props, initialValues: runIfFn(initialValues, null), show: true }));
6
- }
@@ -1,5 +0,0 @@
1
- import { MultiQueryWrapperConfig } from "./types/MultiQueryWrapper";
2
- import { SoperioComponent } from "@soperio/react";
3
- export declare function MultiQueryWrapper({ queries, config, tabbed, ...props }: Omit<MultiQueryWrapperConfig, "type"> & {
4
- tabbed?: boolean;
5
- } & SoperioComponent): JSX.Element;
@@ -1,61 +0,0 @@
1
- import { jsx as _jsx } from "@soperio/jsx-runtime";
2
- import { useApiQueries } from "@compill/api";
3
- import { useQueryClient } from "@tanstack/react-query";
4
- import React from "react";
5
- import { useParams } from "react-router-dom";
6
- import { ScreenRenderer } from "./ScreenRenderer";
7
- import { isFunction, runIfFn } from "@soperio/react";
8
- import { QueryLoadingState, RetryOnError } from "@compill/components";
9
- function useQueries(queries) {
10
- const params = useParams();
11
- const { data, isFetching, isError } = useApiQueries(queries.map(q => {
12
- if (!q.queryField) {
13
- const api = runIfFn(q.api);
14
- return {
15
- queryKey: api.queryKey,
16
- queryFn: q.fn == "get" ? api.get : api.getAll,
17
- queryParam: q.params
18
- };
19
- }
20
- const id = params[q.queryField];
21
- const api = runIfFn(q.api, id);
22
- return {
23
- queryKey: api.queryKey,
24
- queryFn: q.fn == "get" ? api.get : api.getAll,
25
- queryParam: q.fn == "getAll" ? q.params : isFunction(q.api) ? undefined : id
26
- };
27
- }));
28
- let transformedData = undefined;
29
- if (!isFetching && !isError) {
30
- transformedData = data?.map((d, index) => queries[index].transformFn ? queries[index].transformFn?.(d) : d);
31
- }
32
- return { data: transformedData, isFetching, isError };
33
- }
34
- function useInvalidate(queries) {
35
- const queryClient = useQueryClient();
36
- const params = useParams();
37
- const invalidate = React.useCallback(() => {
38
- const queryKeys = [];
39
- queries.forEach(q => {
40
- if (!q.queryField || !isFunction(q.api)) {
41
- queryKeys.push(q.api.queryKey);
42
- }
43
- else {
44
- const id = params[q.queryField];
45
- const api = runIfFn(q.api, id);
46
- queryKeys.push(api.queryKey);
47
- }
48
- });
49
- queryClient.invalidateQueries({ predicate: (query) => queryKeys.includes(query.queryKey), });
50
- }, [queries, queryClient, params]);
51
- return invalidate;
52
- }
53
- export function MultiQueryWrapper({ queries, config, tabbed, ...props }) {
54
- const { data, isFetching, isError } = useQueries(queries);
55
- const invalidate = useInvalidate(queries);
56
- if (isFetching)
57
- return _jsx(QueryLoadingState, { w: "full", h: "100vh" });
58
- if (isError || !data)
59
- return _jsx(RetryOnError, { p: "0", w: "full", h: "100vh", onClick: invalidate });
60
- return _jsx(ScreenRenderer, { config: config(...data), tabbed: tabbed, ...props });
61
- }
@@ -1,6 +0,0 @@
1
- import { QueryWrapperConfig } from "./types/QueryWrapper";
2
- import { SoperioComponent } from "@soperio/react";
3
- import { CRUD_MODEL } from "@compill/api";
4
- export declare function QueryWrapper<T extends CRUD_MODEL, U>({ api, queryField, fn, transformFn, config, tabbed, ...props }: Omit<QueryWrapperConfig<T, U>, "type"> & {
5
- tabbed?: boolean;
6
- } & SoperioComponent): JSX.Element | null;
@@ -1,29 +0,0 @@
1
- import { jsx as _jsx } from "@soperio/jsx-runtime";
2
- import React from "react";
3
- import { ScreenRenderer } from "./ScreenRenderer";
4
- import { isFunction, runIfFn } from "@soperio/react";
5
- import { useParams } from "react-router-dom";
6
- import { useApiQuery } from "@compill/api";
7
- function useApi(api, queryField) {
8
- const params = useParams();
9
- if (queryField === undefined)
10
- return { id: undefined, api: api };
11
- const { [queryField]: id } = params;
12
- return { id, api: runIfFn(api, id) };
13
- }
14
- export function QueryWrapper({ api, queryField, fn, transformFn, config, tabbed, ...props }) {
15
- const { id, api: mApi } = useApi(api, queryField);
16
- const { data } = useApiQuery(mApi.queryKey, fn === "get" || fn === "getTransformed" ? mApi.get : mApi.getAll, isFunction(api) ? undefined : id);
17
- const transformedData = React.useMemo(() => {
18
- if (data && (fn === "getTransformed" || fn === "getAllTransformed")) {
19
- if (!transformFn)
20
- console.warn(`QueryWrapperDialog: you forgot to pass transformFn as parameter for fn ${fn}`);
21
- return transformFn?.(data);
22
- }
23
- return data;
24
- }, [data]);
25
- // TODO states
26
- if (!data)
27
- return null;
28
- return _jsx(ScreenRenderer, { config: config(transformedData), tabbed: tabbed, ...props });
29
- }
@@ -1,6 +0,0 @@
1
- import { ScreenConfig } from "./types/ScreenConfig";
2
- import { SoperioComponent } from "@soperio/react";
3
- export declare function ScreenRenderer({ config, tabbed, ...props }: {
4
- config: ScreenConfig;
5
- tabbed?: boolean;
6
- } & SoperioComponent): JSX.Element;
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "@soperio/jsx-runtime";
2
- import { DetailsView } from "./DetailsView";
3
- import { QueryWrapper } from "./QueryWrapper";
4
- import { TabbedView } from "./TabbedView";
5
- import { TableView } from "./table/TableView";
6
- import { MultiQueryWrapper } from "./MultiQueryWrapper";
7
- export function ScreenRenderer({ config, tabbed, ...props }) {
8
- if (config.type === "table")
9
- return _jsx(TableView, { ...config, ...props });
10
- if (config.type === "tabbed")
11
- return _jsx(TabbedView, { ...config, ...props });
12
- if (config.type === "details")
13
- return _jsx(DetailsView, { ...config, tabbed: tabbed, ...props });
14
- if (config.type === "query")
15
- return _jsx(QueryWrapper, { ...config, tabbed: tabbed, ...props });
16
- if (config.type === "multiQuery")
17
- return _jsx(MultiQueryWrapper, { ...config, tabbed: tabbed, ...props });
18
- return _jsx(_Fragment, {});
19
- }
@@ -1,15 +0,0 @@
1
- import { API } from "@compill/admin-api";
2
- import { Breadcrumb } from "../breadcrumbs/BreadCrumbs";
3
- import { DetailViewButton } from "./types/DetailsView";
4
- import { CRUDAPI } from "@compill/api";
5
- interface ScreenTopBarProps {
6
- tabbed?: boolean;
7
- breadcrumbs?: Breadcrumb[];
8
- buttonBar?: DetailViewButton[];
9
- api: CRUDAPI<any> | API<any>;
10
- item: any;
11
- isLoading: boolean;
12
- trackingRef?: Element | null;
13
- }
14
- export declare function ScreenTopBar({ tabbed, breadcrumbs, api, item, isLoading, buttonBar, trackingRef }: ScreenTopBarProps): JSX.Element;
15
- export {};
@@ -1,18 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
- import { API } from "@compill/admin-api";
3
- import { InvalidateButton } from "../buttons/InvalidateButton";
4
- import { PublishButton } from "../buttons/PublishButton";
5
- import { UpdateButton } from "../buttons/UpdateButton";
6
- import { ViewButton } from "../buttons/ViewButton";
7
- import { PageTopBar, PageTopBarToolbar } from "../page/PageTopBar";
8
- import React from "react";
9
- import { ButtonBar } from "../layout/ButtonBar";
10
- export function ScreenTopBar({ tabbed, breadcrumbs, api, item, isLoading, buttonBar, trackingRef }) {
11
- return (_jsxs(_Fragment, { children: [tabbed &&
12
- (_jsx(PageTopBarToolbar, { trackingRef: trackingRef, children: _jsx(Buttons, { api: api, item: item, isLoading: isLoading, buttonBar: buttonBar }) })), !tabbed &&
13
- (_jsx(PageTopBar, { breadcrumbs: breadcrumbs, children: _jsx(Buttons, { api: api, item: item, isLoading: isLoading, buttonBar: buttonBar }) }))] }));
14
- }
15
- function Buttons({ api, item, isLoading, buttonBar }) {
16
- return (_jsxs(_Fragment, { children: [buttonBar && buttonBar.length > 0 &&
17
- (_jsx(ButtonBar, { children: buttonBar.map((button, index) => (_jsxs(React.Fragment, { children: [button.type === "link" && _jsx(ViewButton, { label: button.label, path: button.path, icon: button.icon }), button.type === "invalidate" && _jsx(InvalidateButton, { pathOrPermalink: button.pathOrPermalink }), button.type == "custom" && button.render(item)] }, index))) })), _jsxs(ButtonBar, { children: [api instanceof API && _jsx(PublishButton, { api: api, queryId: item.id, status: item.status, disabled: isLoading }), _jsx(UpdateButton, { disabled: isLoading })] })] }));
18
- }
@@ -1,3 +0,0 @@
1
- import { TabbedViewConfig } from "./types/TabbedView";
2
- import { SoperioComponent } from "@soperio/react";
3
- export declare function TabbedView({ queryField, api, screen, ...props }: TabbedViewConfig & SoperioComponent): JSX.Element;
@@ -1,21 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
- import { useParams } from "react-router-dom";
3
- import { PageQueryStateContainer } from "../page/PageQueryStateContainer";
4
- import { PageTabbedTopBar, PageTabbedTopBarProvider } from "../page/PageTopBar";
5
- import { TabContainer } from "@compill/components";
6
- import { runIfFn } from "@soperio/react";
7
- import { ScreenRenderer } from "./ScreenRenderer";
8
- export function TabbedView({ queryField, api, screen, ...props }) {
9
- const { [queryField]: id } = useParams();
10
- return (_jsx(PageQueryStateContainer, { queryId: id, api: api, apiFn: "get", p: "5", children: (city) => {
11
- const { breadcrumbs, tabs } = runIfFn(screen, city);
12
- return (_jsxs(PageTabbedTopBarProvider, { children: [_jsx(PageTabbedTopBar, { breadcrumbs: breadcrumbs, mb: "-3" }), _jsx(TabContainer, { tabs: tabs.map(tab => tab.label), saveKey: `tab-${id}`, mt: "-3", mb: "3", id: "fff", children: tabs.map((tab, index) => _jsx(TabView, { tab: tab }, index)) })] }));
13
- } }));
14
- }
15
- function TabView({ tab }) {
16
- if (!tab.component && !tab.config)
17
- throw new Error(`Screen config for tabbed view: one of your tabs does not have a component or config declared: ${tab.label}`);
18
- if (tab.component)
19
- return tab.component();
20
- return _jsx(ScreenRenderer, { config: tab.config, tabbed: true, p: "0" });
21
- }
@@ -1,14 +0,0 @@
1
- import { MutationQueryFn, MutationQueryKey } from "@compill/api";
2
- import { ButtonProps } from "@valerya/ui";
3
- interface ActionButtonProps {
4
- label: string;
5
- buttonProps?: ButtonProps;
6
- icon?: string;
7
- queryKey: MutationQueryKey;
8
- queryFn: MutationQueryFn<any, any>;
9
- successMsg?: string;
10
- errorMsg?: string;
11
- invalidateParent?: boolean;
12
- }
13
- export declare function ActionButton({ label, buttonProps, icon, queryKey, queryFn, successMsg, errorMsg, invalidateParent }: ActionButtonProps): JSX.Element;
14
- export {};
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
- import { useApiMutation, useInvalidateParentMutation, useMutate } from "@compill/api";
3
- import { Button, Icon } from "@valerya/ui";
4
- export function ActionButton({ label, buttonProps, icon, queryKey, queryFn, successMsg, errorMsg, invalidateParent }) {
5
- const mutation = invalidateParent ? useInvalidateParentMutation(queryFn, queryKey) : useApiMutation(queryFn, queryKey);
6
- const mutate = useMutate(mutation, {
7
- successMsg,
8
- errorMsg
9
- });
10
- return (_jsxs(Button, { display: "flex", alignItems: "center", gap: "3", ...buttonProps, onClick: mutate, disabled: mutation.isLoading, children: [icon && _jsx(Icon, { path: icon }), label] }));
11
- }