@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,45 +0,0 @@
1
- import { mdiDelete, mdiEye, mdiOpenInNew, mdiPencil } from "@mdi/js";
2
- import { Icon } from "@valerya/ui";
3
- import { TableRowPublishPostButton } from "./TableRowPublishPostButton";
4
- import React from "react";
5
- import { TableRowActionButton } from "@compill/admin";
6
- import { runIfFn } from "@soperio/react";
7
- export function TableRowActionsView({ row, onAction, rowActions, api, queryKey }) {
8
- const item = row.original;
9
- return (<div dflex w="full" alignItems="stretch" placeContent="end" h="full">
10
- {runIfFn(rowActions, item)?.map((action, index) => (<React.Fragment key={index}>
11
- {action.type === "publish" && <TableRowPublishPostButton id={item.id} api={action.api ?? api} status={item.status} invalidateQueryKey={queryKey}/>}
12
-
13
- {action.type == "custom" && <>{action.component(item, queryKey, action.icon, action.label)}</>}
14
-
15
- {!["publish", "custom"].includes(action.type) &&
16
- (<ActionButton onClick={() => onAction(action, item)} scheme={schemes[action.type]}>
17
- <Icon path={icons[action.type]} size="sm"/>
18
- </ActionButton>)}
19
- </React.Fragment>))}
20
- </div>);
21
- }
22
- function ActionButton({ onClick, ...props }) {
23
- const handleClick = React.useCallback((event) => {
24
- event?.preventDefault();
25
- event?.stopPropagation();
26
- onClick?.(event);
27
- }, [onClick]);
28
- return (<TableRowActionButton onClick={handleClick} {...props}/>);
29
- }
30
- const icons = {
31
- "link": mdiOpenInNew,
32
- "view": mdiEye,
33
- "edit": mdiPencil,
34
- "delete": mdiDelete,
35
- "publish": mdiDelete,
36
- "custom": ""
37
- };
38
- const schemes = {
39
- "link": "dark",
40
- "view": "dark",
41
- "edit": "dark",
42
- "delete": "dark",
43
- "publish": "dark",
44
- "custom": "dark"
45
- };
@@ -1,100 +0,0 @@
1
- import { Table, useTableContext } from "@compill/table";
2
- import { isFunction, runIfFn } from "@soperio/react";
3
- import React from "react";
4
- import { useParams } from "react-router-dom";
5
- import { InvalidateButton } from "../../buttons/InvalidateButton";
6
- import { PageContainer } from "../../page/PageContainer";
7
- import { TableContainer } from "../../table/TableContainer";
8
- import { TableCreateButton } from "../../table/TableCreateButton";
9
- import { TableFilterButton } from "../../table/TableFilterButton";
10
- import { TableTopBar } from "../../table/TableTopBar";
11
- import { ButtonBar } from "../../layout/ButtonBar";
12
- import { TableFilters } from "../../table/TableFilters";
13
- import { TableMassActions } from "../../table/TableMassActions";
14
- import { DialogRenderer } from "../dialog/DialogRenderer";
15
- import { RefreshButton } from "./RefreshButton";
16
- import { TableViewProvider, useTableViewContext } from "./TableViewContext";
17
- import { useTableProps } from "./useTableProps";
18
- function useId(queryField) {
19
- const params = useParams();
20
- if (queryField === undefined)
21
- return undefined;
22
- const { [queryField]: id } = params;
23
- return id;
24
- }
25
- export function TableView({ queryField, title, subtitle, screen, ...props }) {
26
- const id = useId(queryField);
27
- const _screen = runIfFn(screen, id);
28
- return (<PageContainer bgColor="white" {...props}>
29
- <TableContainer columns={_screen.table.columns} initialVisibleColumns={_screen.table.initialVisibleColumns} filtersMethod={_screen.table.filtersMethod}>
30
- <TT id={id} title={title} subtitle={subtitle} screen={_screen}/>
31
- </TableContainer>
32
- </PageContainer>);
33
- }
34
- function TT({ id, title, subtitle, screen }) {
35
- const { setRowSelection } = useTableContext();
36
- const { api, table, filters, massActions, buttonBar, rowActions, createView, editView, deleteItem, breadcrumbs } = screen;
37
- const tableApi = runIfFn(api, id ?? "");
38
- return (<>
39
- {/* {breadcrumbs && <PageTopBar breadcrumbs={breadcrumbs} />} */}
40
- <TableTopBar title={title} breadcrumbs={breadcrumbs}>
41
- <TableButtonBar buttonBar={buttonBar} createView={createView} editView={editView} api={tableApi} queryKey={tableApi.queryKey}>
42
- {filters && <TableFilterButton />}
43
- </TableButtonBar>
44
- {/* <TableColumnButton /> */}
45
- </TableTopBar>
46
-
47
- {filters &&
48
- (<TableFilters form={filters.form} initialValues={filters.initialValues} schema={filters.schema} processInput={filters.processInput}/>)}
49
- {massActions && <TableMassActions actions={massActions.items}/>}
50
-
51
- <TableViewProvider queryKey={tableApi.queryKey} editView={editView} deleteItem={deleteItem}>
52
- <TableWrapper table={{ ...table, onSelectionChange: setRowSelection }} rowActions={rowActions} api={tableApi} subtitle={subtitle} queryParams={screen.queryParams}/>
53
- <TableDialogManager />
54
- </TableViewProvider>
55
- </>);
56
- }
57
- function TableButtonBar({ buttonBar, queryKey, createView, editView, api, children }) {
58
- const createDialogFn = React.useCallback((data) => {
59
- return (onClose) => {
60
- const view = runIfFn(createView, data) ?? runIfFn(editView, null);
61
- if (view.type == "customDialog")
62
- return view.render({ show: true, onClose });
63
- else
64
- return <DialogRenderer config={view} onClose={onClose} invalidateQueryKey={api.queryKey}/>;
65
- };
66
- }, [createView, editView, api]);
67
- return (<ButtonBar>
68
- <RefreshButton queryKey={queryKey}/>
69
-
70
- {buttonBar && buttonBar.map((button, index) => <React.Fragment key={index}>
71
- {button.type === "create" && editView &&
72
- (<TableCreateButton buildDialog={createDialogFn(button.data)} icon={button.icon}>
73
- {button.label}
74
- </TableCreateButton>)}
75
-
76
- {button.type === "invalidate" && <InvalidateButton pathOrPermalink={button.pathOrPermalink}/>}
77
-
78
- {button.type === "custom" && button.render()}
79
- </React.Fragment>)}
80
-
81
- {children}
82
- </ButtonBar>);
83
- }
84
- function TableWrapper({ table, subtitle, rowActions, api, queryParams }) {
85
- const tableProps = useTableProps(api, table, rowActions, queryParams);
86
- const _subtitle = React.useMemo(() => {
87
- if (!subtitle)
88
- return undefined;
89
- return (data) => {
90
- return (<div textSize="lg" textColor="#475569" fontWeight="600">
91
- {isFunction(subtitle) ? subtitle(data) : subtitle}
92
- </div>);
93
- };
94
- }, [subtitle]);
95
- return <Table {...tableProps} p="8" title={_subtitle}/>;
96
- }
97
- function TableDialogManager() {
98
- const { dialog } = useTableViewContext();
99
- return dialog;
100
- }
@@ -1,24 +0,0 @@
1
- import { useBoolean } from "@compill/hooks";
2
- import { mdiArrowLeft } from "@mdi/js";
3
- import { IconButton } from "@valerya/ui";
4
- import { useHotkeys } from "react-hotkeys-hook";
5
- import Content from "./Content";
6
- import { Sidebar } from "./Sidebar";
7
- export function AdminLayout({ color, darkMode, logo, title, menuConfig, userMenuConfig, userSettingsPath, ...props }) {
8
- return (<div w="full" h="screen" dflex flexRow bgColor={`${color}-${darkMode ? "900" : "100"}`} {...props}>
9
- <LeftPanel color={color} darkMode={darkMode} logo={logo} title={title} menuConfig={menuConfig} userMenuConfig={userMenuConfig} userSettingsPath={userSettingsPath}/>
10
-
11
- <div w="screen" py="2" pe="2">
12
- <Content bgColor="white" rounded="lg" shadow/>
13
- </div>
14
- </div>);
15
- }
16
- function LeftPanel({ color, darkMode, logo, title, menuConfig, userMenuConfig, userSettingsPath }) {
17
- const [isOpen, __, toggle] = useBoolean(true);
18
- useHotkeys('ctrl+t', () => toggle(), [toggle]);
19
- return (<div ms={isOpen ? "0" : "-14.5rem"} transition="all" duration="500" transform>
20
- <Sidebar flexShrink="0" color={color} darkMode={darkMode} logo={logo} title={title} menuConfig={menuConfig} userMenuConfig={userMenuConfig} userSettingsPath={userSettingsPath}/>
21
-
22
- <IconButton icon={mdiArrowLeft} transition="all" duration="500" transform rotate={isOpen ? "0" : "180"} position="absolute" bottom="14" end="-5" size="lg" corners="pill" onClick={toggle} z="100"/>
23
- </div>);
24
- }
@@ -1,29 +0,0 @@
1
- import { DialogButton } from "../buttons/DialogButton";
2
- import { Button, Icon } from "@valerya/ui";
3
- import { useFormikContext } from "formik";
4
- import React from "react";
5
- export function ButtonBar({ children, ...props }) {
6
- return (<div dflex border="1px" borderColor="zinc-200" divideX="1px" divideColor="zinc-200" rounded="lg" overflow="hidden" {...props}>
7
- {children}
8
- </div>);
9
- }
10
- export const ButtonBarButton = React.forwardRef(function ({ icon, children, ...props }, ref) {
11
- return (<Button scheme="dark" size="sm" aspectRatio={icon && !children ? "square" : undefined} variant="borderless" dflex alignItems="center" placeContent="center" corners="square" gap="2" {...props} ref={ref}>
12
- {icon && <Icon path={icon}/>}
13
- {children}
14
- </Button>);
15
- });
16
- export const ButtonBarSubmitButton = React.forwardRef(function ({ useDirty, disabled, icon, children, ...props }, ref) {
17
- const { dirty, handleSubmit } = useFormikContext() ?? { dirty: false, handleSubmit: undefined, values: {} };
18
- const onSubmit = React.useCallback(() => handleSubmit(), [handleSubmit]);
19
- return (<Button scheme="dark" size="sm" aspectRatio={icon && !children ? "square" : undefined} variant="borderless" dflex alignItems="center" placeContent="center" corners="square" gap="2" disabled={(useDirty && !dirty) || disabled} onClick={onSubmit} {...props} ref={ref}>
20
- {icon && <Icon path={icon}/>}
21
- {children}
22
- </Button>);
23
- });
24
- export function ButtonBarDialogButton({ icon, children, ...props }) {
25
- return (<DialogButton scheme="dark" size="sm" aspectRatio={icon && !children ? "square" : undefined} variant="borderless" dflex alignItems="center" placeContent="center" corners="square" gap="2" {...props}>
26
- {icon && <Icon path={icon}/>}
27
- {children}
28
- </DialogButton>);
29
- }
@@ -1,10 +0,0 @@
1
- import { Outlet } from "react-router-dom";
2
- /**
3
- *
4
- *
5
- */
6
- export default function Content({ ...props }) {
7
- return (<div w="100%" h="100%" overflowY="auto" {...props}>
8
- <Outlet />
9
- </div>);
10
- }
@@ -1,12 +0,0 @@
1
- export function PageTitleBar({ title, children, ...props }) {
2
- return (<div dflex flexRow alignItems="center" gap="3" p="8"
3
- // borderB="0.5"
4
- // borderBColor="--bg-2"
5
- {...props}>
6
- {title && <h2 textSize="x2" fontWeight="600" textColor="#3f4254" textTransform="capitalize">{title}</h2>}
7
-
8
- <div flexGrow>&nbsp;</div>
9
-
10
- {children}
11
- </div>);
12
- }
@@ -1,24 +0,0 @@
1
- import { FlexCenter } from "@compill/components";
2
- import { Menu } from "./menu/Menu";
3
- import { AppEnv } from "@compill/env";
4
- import Image from "next/image";
5
- import { UserBlock } from "./menu/UserBlock";
6
- export function Sidebar({ show, logo, title, menuConfig, userMenuConfig, userSettingsPath, color, darkMode, ...props }) {
7
- return (<div dflex flexCol w="full" md_w="64" minH="screen" p="0" textColor={darkMode ? "white" : "slate-800"} {...props}>
8
- <FlexCenter placeContent="start" p="4" font="title" gap="3" borderB="px" borderBColor="slate-900" borderOpacity="5">
9
- {logo ?? <Logo width={40} height={40} darkMode={darkMode}/>}
10
- <h1 textSize="md">{title || AppEnv.appName()}</h1>
11
- </FlexCenter>
12
-
13
- <Menu overflowY="auto" flexGrow="1" p="4" darkMode={darkMode} config={menuConfig}/>
14
-
15
- <div p="2">
16
- <UserBlock darkMode={darkMode} color={color} menuConfig={userMenuConfig} path={userSettingsPath}/>
17
- </div>
18
- </div>);
19
- }
20
- export default function Logo({ width, height, darkMode, ...props }) {
21
- return (<div {...props}>
22
- <Image src={`/logo_${darkMode ? "light" : "dark"}.png`} alt={AppEnv.appName() || ""} width={width} height={height} priority unoptimized/>
23
- </div>);
24
- }
@@ -1,30 +0,0 @@
1
- import { MenuItem } from "./MenuItem";
2
- import { NextMenuItem } from "./NextMenuItem";
3
- /**
4
- *
5
- *
6
- */
7
- export function Menu({ darkMode, config, useNextRouter, ...props }) {
8
- const Comp = useNextRouter ? NextMenuItem : MenuItem;
9
- return (<ul {...props}>
10
- {config.map((item, index) => {
11
- if (item.type == "divider")
12
- return <Divider key={index} title={item.label}/>;
13
- if (item.type == "item") {
14
- return (<Comp key={index} icon={item.icon} path={item.path} depth={0} darkMode={darkMode} subMenu={item.children}>
15
- {item.label}
16
- </Comp>);
17
- }
18
- })}
19
- </ul>);
20
- }
21
- function Divider({ title }) {
22
- return (<div px="2" mt="5" mb="2" opacity="75" textTransform="capitalize" letterSpacing="widest" fontWeight="700" textSize="xs">
23
- {title}
24
- </div>);
25
- }
26
- function CategoryItem({ children, ...props }) {
27
- return (<li ps="5" py="2" mt="5" textSize="sm" textColor="white" textOpacity="80" fontWeight="600" textTransform="uppercase">
28
- {children}
29
- </li>);
30
- }
@@ -1,7 +0,0 @@
1
- import { Button, Icon } from "@valerya/ui";
2
- export function MenuButton({ depth, darkMode, icon, selected, children, ...props }) {
3
- return (<Button as="li" minH="8" ms={`${(depth ?? 0) * 2}`} p="2" font="title" textColor={darkMode ? "white" : "black"} fontWeight="600" rounded="lg" textSize="sm" variant="borderless" hover_bgColor={darkMode ? "white" : "black"} hover_bgOpacity="10" hover_textColor={darkMode ? "white" : "zinc-800"} cursor="pointer" dflex alignItems="center" gap="3" {...props}>
4
- {icon && <Icon path={icon} opacity={selected ? "100" : "60"}/>}
5
- {children}
6
- </Button>);
7
- }
@@ -1,20 +0,0 @@
1
- import { SelectedIndicator } from "./SelectedIndicator";
2
- import { Link, useLocation, useMatch } from "react-router-dom";
3
- import { MenuButton } from "./MenuButton";
4
- export function MenuItem({ icon, path, depth, darkMode, subMenu, ...props }) {
5
- const location = useLocation();
6
- const selected = path == "/" ? location.pathname == "/" : location.pathname.startsWith(path.startsWith("/") ? path : `/${path}`);
7
- const match = useMatch("/" + path) != null;
8
- // const selected = match != null
9
- return (<>
10
- <Link to={path} style={{ position: "relative" }}>
11
- <MenuButton depth={depth} darkMode={darkMode} icon={icon} selected={selected} {...props}/>
12
-
13
- {match && <SelectedIndicator darkMode={darkMode}/>}
14
- </Link>
15
-
16
- {subMenu?.map((item, index) => (<MenuItem key={index} icon={item.icon} path={item.path} depth={(depth ?? 0) + 1} darkMode={darkMode} subMenu={item.children}>
17
- {item.label}
18
- </MenuItem>))}
19
- </>);
20
- }
@@ -1,20 +0,0 @@
1
- import { MenuButton } from "./MenuButton";
2
- import { SelectedIndicator } from "./SelectedIndicator";
3
- import Link from "next/link";
4
- import { useRouter } from "next/router";
5
- export function NextMenuItem({ icon, path, depth, darkMode, subMenu, ...props }) {
6
- const { pathname } = useRouter();
7
- const selected = path == "/" ? pathname == "/" : pathname.startsWith(path.startsWith("/") ? path : `/${path}`);
8
- const match = path == "/" ? pathname == "/" : pathname == (path.startsWith("/") ? path : `/${path}`);
9
- return (<>
10
- <Link href={path} style={{ position: "relative" }}>
11
- <MenuButton depth={depth} darkMode={darkMode} icon={icon} selected={selected} {...props}/>
12
-
13
- {match && <SelectedIndicator darkMode={darkMode}/>}
14
- </Link>
15
-
16
- {subMenu?.map((item, index) => (<NextMenuItem key={index} icon={item.icon} path={item.path} depth={(depth ?? 0) + 1} darkMode={darkMode} subMenu={item.children}>
17
- {item.label}
18
- </NextMenuItem>))}
19
- </>);
20
- }
@@ -1,3 +0,0 @@
1
- export function SelectedIndicator({ darkMode }) {
2
- return (<div position="absolute" bgColor={darkMode ? "white" : "black"} bgOpacity="90" w="0.5" h="6" top="1.5" start="-4"/>);
3
- }
@@ -1,55 +0,0 @@
1
- import { useSessionLogout, useSessionUser } from "@compill/auth";
2
- import { mdiCog, mdiDotsVertical, mdiLogout } from "@mdi/js";
3
- import { Avatar, Button, Icon, IconButton, Popup } from "@valerya/ui";
4
- import { capitalize } from "es-toolkit";
5
- import React from "react";
6
- import { useNavigate } from "react-router-dom";
7
- export function UserBlock({ color, darkMode, menuConfig, path }) {
8
- const { isLoading, user } = useSessionUser();
9
- const navigate = useNavigate();
10
- const handleClick = React.useCallback(() => navigate(path), [navigate, path]);
11
- if (isLoading)
12
- return null;
13
- return (<div dflex alignItems="center" border="0.5" borderColor={`${color}-${darkMode ? "800" : "200"}`} ps="3" py="1.5" textSize="md" rounded="lg" hover_bgColor={`${color}-${darkMode ? "800" : "200"}`} cursor="pointer" textColor={darkMode ? "white" : "slate-800"} onClick={handleClick}>
14
- <Avatar size="sm" src={user?.media?.url ?? ""} name={`${user?.firstname} ${user?.lastname}`}/>
15
-
16
- <span flexGrow ms="2">{`${capitalize(user?.firstname || user?.lastname || "")}`}</span>
17
-
18
- <IconButton variant="borderless" corners="pill" scheme="dark" textColor={darkMode ? "white" : "slate-800"} hover_textColor={darkMode ? "white" : "slate-800"} hover_bgColor={`${color}-${darkMode ? "900" : "200"}`} icon={mdiCog} onClick={handleClick}/>
19
-
20
- <OverflowMenu color={color} darkMode={darkMode} menuConfig={menuConfig}/>
21
- </div>);
22
- }
23
- function OverflowMenu({ color, darkMode, menuConfig }) {
24
- const [showPopup, setShowPopup] = React.useState(false);
25
- const navigate = useNavigate();
26
- const logout = useSessionLogout(false);
27
- return (<>
28
- <Popup show={showPopup} position="relative" side="bottom-end" onClick={(e) => { e.preventDefault(); e.stopPropagation(); setShowPopup((show) => !show); }} onHide={() => setShowPopup(false)}>
29
- <IconButton icon={mdiDotsVertical} variant="borderless" corners="pill" scheme="dark" textColor={darkMode ? "white" : "slate-800"} hover_textColor={darkMode ? "white" : "slate-800"} hover_bgColor={`${color}-${darkMode ? "900" : "200"}`}/>
30
-
31
- <div bgColor="white" rounded="sm" overflow="hidden" shadow mt="1" border="px" borderColor="gray-200" divideColor="gray-200" divideY="px" minW="40">
32
- {menuConfig && menuConfig.length > 0 && menuConfig.map((item, index) => {
33
- if (item.type == "item") {
34
- return (<MenuItem key={index} icon={item.icon} onClick={() => navigate(item.path)}>
35
- {item.label}
36
- </MenuItem>);
37
- }
38
- return null;
39
- })}
40
- <MenuItem icon={mdiLogout} onClick={logout}>Logout</MenuItem>
41
- </div>
42
- </Popup>
43
- </>);
44
- }
45
- function MenuItem({ icon, onClick, children, ...props }) {
46
- const handleClick = React.useCallback((e) => {
47
- e.preventDefault();
48
- e.stopPropagation();
49
- onClick?.(e);
50
- }, []);
51
- return (<Button variant="borderless" scheme="dark" size="sm" alignItems="center" dflex gap="2" px="2" py="1.5" w="full" onClick={handleClick} textColor="slate-700" {...props}>
52
- {icon && <Icon path={icon} size="md"/>}
53
- {children}
54
- </Button>);
55
- }
@@ -1,46 +0,0 @@
1
- import { useMutate } from "@compill/api";
2
- import { ModalLoadingOverlay } from "@compill/components";
3
- import { SubmitButton, FormRenderer, FormProvider } from "@compill/form";
4
- import { useApiMutation, useInvalidateParentMutation } from "@compill/api";
5
- import { Button, Modal } from "@valerya/ui";
6
- import React from "react";
7
- export function FormActionDialog({ initialValues, itemLabel, queryId = "", queryKey, queryFn, queryOptions, onSuccess, successMsg, showSuccessMsg, onError, errorMsg, showErrorMsg, processInput, invalidateQueriesOnSuccess = true, cancelLabel = "Cancel", saveLabel = "Send", size = "lg", title, form, show, onClose, formikProps, ...props }) {
8
- const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(queryFn, queryKey, queryOptions) : useApiMutation(queryFn, queryKey, queryId, queryOptions);
9
- const mutate = useMutate(mutation, {
10
- onSuccess,
11
- successMsg,
12
- showSuccessMsg,
13
- onError,
14
- errorMsg,
15
- showErrorMsg,
16
- processInput,
17
- });
18
- return (<Modal size={size} show={show} onClose={onClose} scheme="light" transition
19
- // closeOnMaskClick={false}
20
- {...props}>
21
- <Modal.Header>
22
- {title}
23
- </Modal.Header>
24
-
25
- {/* @ts-ignore */}
26
- <FormProvider initialValues={initialValues ?? {}} onSubmit={mutate} {...formikProps}>
27
- <Modal.Body pb="6">
28
- {React.isValidElement(form) && form}
29
-
30
- {Array.isArray(form) && <FormRenderer form={form}/>}
31
- </Modal.Body>
32
-
33
- <Modal.Footer dflex placeContent="end" spaceX="3">
34
- <Button disabled={mutation.isLoading} onClick={onClose} variant="borderless" me="2">
35
- {cancelLabel}
36
- </Button>
37
-
38
- <SubmitButton disabled={mutation.isLoading}>
39
- {saveLabel}
40
- </SubmitButton>
41
- </Modal.Footer>
42
- </FormProvider>
43
-
44
- {mutation.isLoading && <ModalLoadingOverlay />}
45
- </Modal>);
46
- }
@@ -1,4 +0,0 @@
1
- import { Container } from "@valerya/ui";
2
- export function PageContainer({ children, ...props }) {
3
- return <Container center dflex flexCol gap="8" {...props}>{children}</Container>;
4
- }
@@ -1,11 +0,0 @@
1
- import { FormEditor } from "@compill/form-editor";
2
- import { PageMain } from "./PageMain";
3
- import { ImageExtension } from "@compill/editor";
4
- export function PageContentEditor({ name, ...props }) {
5
- const extensions = [ImageExtension];
6
- return (<PageMain h="min" {...props}>
7
- <FormEditor minH="128" minW="144" maxW={props.maxW}
8
- // w={props.w}
9
- name={name} placeHolder="Write here..." extensions={extensions}/>
10
- </PageMain>);
11
- }
@@ -1,4 +0,0 @@
1
- import { Tile } from "@valerya/ui";
2
- export function PageMain({ children, ...props }) {
3
- return <Tile scheme="light" p="5" {...props}>{children}</Tile>;
4
- }
@@ -1,3 +0,0 @@
1
- export function PageSectionTitle({ children, ...props }) {
2
- return <div trait="typo.h6" mb="5" {...props}>{children}</div>;
3
- }
@@ -1,3 +0,0 @@
1
- export function PageSidebar({ children, ...props }) {
2
- return <div w="112" minW="112" minH="100%" gap="8" dflex flexCol {...props}>{children}</div>;
3
- }
@@ -1,7 +0,0 @@
1
- import { PageSectionTitle } from "./PageSectionTitle";
2
- export function PageSidebarSection({ title, children, ...props }) {
3
- return (<div w="full" {...props}>
4
- {title && <PageSectionTitle>{title}</PageSectionTitle>}
5
- {children}
6
- </div>);
7
- }
@@ -1,9 +0,0 @@
1
- import { QueryLoadingState } from "@compill/components";
2
- import { Container } from "@valerya/ui";
3
- import React from "react";
4
- export const PageStateContainer = React.forwardRef(({ loading = false, children, ...props }, ref) => {
5
- return (<>
6
- {loading && <QueryLoadingState w="full" h="100%"/>}
7
- {!loading && <Container ref={ref} center size="x2" dflex flexCol gap="8" {...props}>{children}</Container>}
8
- </>);
9
- });
@@ -1,3 +0,0 @@
1
- export function PageSubSectionTitle({ children, ...props }) {
2
- return <div trait="typo.h6" mb="3" {...props}>{children}</div>;
3
- }
@@ -1,3 +0,0 @@
1
- export function PageTitle({ children, ...props }) {
2
- return <div trait="typo.h5" {...props}>{children}</div>;
3
- }
@@ -1,11 +0,0 @@
1
- import { TableContextProvider } from "@compill/table";
2
- import { TableContainerContextProvider } from "./TableContainerContext";
3
- export function TableContainer({ initialPageSize, initialVisibleColumns, columns, filtersMethod = "reactRouter", children, ...props }) {
4
- return (<div w="full" dflex flexCol {...props}>
5
- <TableContextProvider initialPageSize={initialPageSize} filtersMethod={filtersMethod}>
6
- <TableContainerContextProvider columns={columns} initialVisibleColumns={initialVisibleColumns}>
7
- {children}
8
- </TableContainerContextProvider>
9
- </TableContextProvider>
10
- </div>);
11
- }
@@ -1,9 +0,0 @@
1
- import { mdiPlusThick } from "@mdi/js";
2
- import { Icon } from "@valerya/ui";
3
- import { ButtonBarDialogButton } from "../layout/ButtonBar";
4
- export function TableCreateButton({ icon, children, ...props }) {
5
- return (<ButtonBarDialogButton {...props}>
6
- <Icon path={icon ?? mdiPlusThick}/>
7
- {children}
8
- </ButtonBarDialogButton>);
9
- }
@@ -1,16 +0,0 @@
1
- import { Icon } from "@valerya/ui";
2
- import { Button, Popover } from "@valerya/ui";
3
- import { mdiFilter } from "@mdi/js";
4
- export function TableFilterButton({ ...props }) {
5
- // return <Button scheme="secondary" {...props}><Icon path={mdiFilter} /></Button>
6
- return (<Popover side="bottom-end" modal>
7
- <Button scheme="dark" size="sm" aspectRatio="square" variant="borderless" corners="square" {...props}>
8
- <Icon path={mdiFilter}/>
9
- </Button>
10
- <div bgColor="white" rounded shadow>
11
- <div py="3" hover_bgColor="#ff0000" px="5" hover_textColor="white">First Item</div>
12
- <div py="3" hover_bgColor="#ff0000" px="5" hover_textColor="white">Second Item</div>
13
- <div py="3" hover_bgColor="#ff0000" px="5" hover_textColor="white">Third Item</div>
14
- </div>
15
- </Popover>);
16
- }
@@ -1,15 +0,0 @@
1
- import { useTableContext } from "@compill/table";
2
- import { Collapse } from "@valerya/ui";
3
- import { ActionButton } from "../json/buttons/ActionButton";
4
- export function TableMassActions({ actions }) {
5
- const { ids } = useTableContext();
6
- const showMassActions = ids && ids.length > 0;
7
- return (<Collapse in={showMassActions} style={{ overflow: showMassActions ? "initial" : "hidden" }}>
8
- <div dflex gap="3" flexWrap alignItems="center" px="8" pt="5">
9
- {actions.map((action, index) => (<div key={index}>
10
- {/* {action.type == "custom" && action.render(rows)} */}
11
- {action.type == "button" && !action.showConfirmationDialog && (<ActionButton label={action.label} queryFn={action.queryFn} queryKey={action.queryKey} buttonProps={action.buttonProps}/>)}
12
- </div>))}
13
- </div>
14
- </Collapse>);
15
- }
@@ -1,14 +0,0 @@
1
- import { TableRowViewButton } from "./TableRowViewButton";
2
- import { TableRowNavigateButton } from "./TableRowNavigateButton";
3
- import { TableRowEditButton } from "./TableRowEditButton";
4
- import { TableRowDeleteButton } from "./TableRowDeleteButton";
5
- export function TableRowActionBar({ publishId, viewPath, navigatePath, editDialog, deleteDialog, children, ...props }) {
6
- return (<div dflex spaceX="1" placeContent="end" {...props}>
7
- {viewPath && <TableRowViewButton path={viewPath}/>}
8
- {navigatePath && <TableRowNavigateButton path={navigatePath}/>}
9
- {editDialog && <TableRowEditButton buildDialog={editDialog}/>}
10
- {deleteDialog && <TableRowDeleteButton buildDialog={deleteDialog}/>}
11
-
12
- {children}
13
- </div>);
14
- }
@@ -1,7 +0,0 @@
1
- import { Button, Icon } from "@valerya/ui";
2
- export function TableRowActionButton({ icon, children, ...props }) {
3
- return (<Button dflex alignContent="center" placeContent="center" py="2.5" px="3" h="full" size="lg" variant="borderless" corners="square" gap="2" {...props}>
4
- {icon && <Icon path={icon} size="sm"/>}
5
- {children}
6
- </Button>);
7
- }
@@ -1,8 +0,0 @@
1
- import { Icon } from "@valerya/ui";
2
- import { DialogButton } from "../buttons/DialogButton";
3
- export function TableRowActionDialogButton({ icon, children, ...props }) {
4
- return (<DialogButton dflex alignContent="center" placeContent="center" py="2.5" px="3" h="full" size="lg" variant="borderless" corners="square" gap="2" {...props}>
5
- {icon && <Icon path={icon} size="sm"/>}
6
- {children}
7
- </DialogButton>);
8
- }
@@ -1,17 +0,0 @@
1
- import { Breadcrumbs } from "../breadcrumbs/BreadCrumbs";
2
- export function TableTopBar({ title, breadcrumbs, children, ...props }) {
3
- return (<div dflex flexRow alignItems="center" gap="3" p="8"
4
- // borderB="0.5"
5
- // borderBColor="--bg-2"
6
- {...props}>
7
- <div>
8
-
9
- {title && <h2 textSize="x2" fontWeight="600" textColor="#3f4254" textTransform="capitalize">{title}</h2>}
10
- {breadcrumbs && <Breadcrumbs breadcrumbs={breadcrumbs}/>}
11
- </div>
12
-
13
- <div flexGrow>&nbsp;</div>
14
-
15
- {children}
16
- </div>);
17
- }