@compill/admin 1.0.101 → 1.0.103

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 (169) hide show
  1. package/dist/index.js +50 -0
  2. package/{src → dist}/lib/SectionTitle.d.ts +0 -1
  3. package/dist/lib/SectionTitle.js +4 -0
  4. package/{src → dist}/lib/breadcrumbs/BreadCrumbs.d.ts +0 -1
  5. package/dist/lib/breadcrumbs/BreadCrumbs.js +29 -0
  6. package/dist/lib/buttons/DialogButton.js +15 -0
  7. package/{src → dist}/lib/buttons/InvalidateButton.d.ts +0 -1
  8. package/dist/lib/buttons/InvalidateButton.js +11 -0
  9. package/{src → dist}/lib/buttons/NavigateButton.d.ts +0 -1
  10. package/dist/lib/buttons/NavigateButton.js +12 -0
  11. package/{src → dist}/lib/buttons/PublishButton.d.ts +0 -1
  12. package/dist/lib/buttons/PublishButton.js +17 -0
  13. package/{src → dist}/lib/buttons/UpdateButton.d.ts +0 -1
  14. package/dist/lib/buttons/UpdateButton.js +11 -0
  15. package/{src → dist}/lib/buttons/ViewButton.d.ts +1 -2
  16. package/dist/lib/buttons/ViewButton.js +13 -0
  17. package/{src → dist}/lib/cells/OrderCell.d.ts +0 -1
  18. package/dist/lib/cells/OrderCell.js +26 -0
  19. package/{src → dist}/lib/json/DetailsView.d.ts +0 -1
  20. package/dist/lib/json/DetailsView.js +69 -0
  21. package/{src → dist}/lib/json/EditItemView.d.ts +0 -1
  22. package/dist/lib/json/EditItemView.js +6 -0
  23. package/{src → dist}/lib/json/MultiQueryWrapper.d.ts +0 -1
  24. package/dist/lib/json/MultiQueryWrapper.js +61 -0
  25. package/{src → dist}/lib/json/QueryWrapper.d.ts +0 -1
  26. package/dist/lib/json/QueryWrapper.js +29 -0
  27. package/{src → dist}/lib/json/ScreenRenderer.d.ts +0 -1
  28. package/dist/lib/json/ScreenRenderer.js +19 -0
  29. package/{src → dist}/lib/json/ScreenTopBar.d.ts +0 -1
  30. package/dist/lib/json/ScreenTopBar.js +18 -0
  31. package/{src → dist}/lib/json/TabbedView.d.ts +0 -1
  32. package/dist/lib/json/TabbedView.js +21 -0
  33. package/{src → dist}/lib/json/buttons/ActionButton.d.ts +0 -1
  34. package/dist/lib/json/buttons/ActionButton.js +11 -0
  35. package/{src → dist}/lib/json/buttons/ConfirmationActionButton.d.ts +0 -1
  36. package/dist/lib/json/buttons/ConfirmationActionButton.js +20 -0
  37. package/{src → dist}/lib/json/dialog/DialogRenderer.d.ts +0 -1
  38. package/dist/lib/json/dialog/DialogRenderer.js +14 -0
  39. package/dist/lib/json/dialog/ItemDeleteDialog.js +14 -0
  40. package/dist/lib/json/dialog/ItemEditDialog.js +77 -0
  41. package/{src → dist}/lib/json/dialog/MultiQueryWrapperDialog.d.ts +0 -1
  42. package/dist/lib/json/dialog/MultiQueryWrapperDialog.js +23 -0
  43. package/{src → dist}/lib/json/dialog/QueryWrapperDialog.d.ts +0 -1
  44. package/dist/lib/json/dialog/QueryWrapperDialog.js +20 -0
  45. package/{src → dist}/lib/json/table/RefreshButton.d.ts +0 -1
  46. package/dist/lib/json/table/RefreshButton.js +11 -0
  47. package/{src → dist}/lib/json/table/TableRowActionsView.d.ts +0 -1
  48. package/dist/lib/json/table/TableRowActionsView.js +36 -0
  49. package/{src → dist}/lib/json/table/TableRowPublishPostButton.d.ts +0 -1
  50. package/dist/lib/json/table/TableRowPublishPostButton.js +20 -0
  51. package/{src → dist}/lib/json/table/TableView.d.ts +0 -1
  52. package/dist/lib/json/table/TableView.js +65 -0
  53. package/dist/lib/json/table/TableViewContext.js +58 -0
  54. package/dist/lib/json/table/useTableProps.js +57 -0
  55. package/{src → dist}/lib/json/types/DetailsView.d.ts +0 -1
  56. package/dist/lib/json/types/DetailsView.js +1 -0
  57. package/dist/lib/json/types/EditItemDialog.js +1 -0
  58. package/dist/lib/json/types/MultiQueryWrapper.js +1 -0
  59. package/dist/lib/json/types/MultiQueryWrapperDialog.js +1 -0
  60. package/dist/lib/json/types/QueryWrapper.js +1 -0
  61. package/dist/lib/json/types/QueryWrapperDialog.js +1 -0
  62. package/dist/lib/json/types/ScreenConfig.js +1 -0
  63. package/{src → dist}/lib/json/types/TabbedView.d.ts +0 -1
  64. package/dist/lib/json/types/TabbedView.js +1 -0
  65. package/{src → dist}/lib/json/types/TableView.d.ts +0 -1
  66. package/dist/lib/json/types/TableView.js +1 -0
  67. package/{src → dist}/lib/layout/AdminLayout.d.ts +0 -1
  68. package/dist/lib/layout/AdminLayout.js +15 -0
  69. package/{src → dist}/lib/layout/ButtonBar.d.ts +1 -1
  70. package/dist/lib/layout/ButtonBar.js +19 -0
  71. package/{src → dist}/lib/layout/Content.d.ts +0 -1
  72. package/dist/lib/layout/Content.js +9 -0
  73. package/{src → dist}/lib/layout/PageTitleBar.d.ts +0 -1
  74. package/dist/lib/layout/PageTitleBar.js +4 -0
  75. package/{src → dist}/lib/layout/Sidebar.d.ts +0 -1
  76. package/dist/lib/layout/Sidebar.js +12 -0
  77. package/{src → dist}/lib/layout/menu/Menu.d.ts +0 -1
  78. package/dist/lib/layout/menu/Menu.js +23 -0
  79. package/{src → dist}/lib/layout/menu/MenuButton.d.ts +0 -1
  80. package/dist/lib/layout/menu/MenuButton.js +5 -0
  81. package/dist/lib/layout/menu/MenuConfig.js +1 -0
  82. package/{src → dist}/lib/layout/menu/MenuItem.d.ts +0 -1
  83. package/dist/lib/layout/menu/MenuItem.js +11 -0
  84. package/{src → dist}/lib/layout/menu/NextMenuItem.d.ts +0 -1
  85. package/dist/lib/layout/menu/NextMenuItem.js +11 -0
  86. package/{src → dist}/lib/layout/menu/SelectedIndicator.d.ts +0 -1
  87. package/dist/lib/layout/menu/SelectedIndicator.js +4 -0
  88. package/{src → dist}/lib/layout/menu/UserBlock.d.ts +1 -2
  89. package/dist/lib/layout/menu/UserBlock.js +34 -0
  90. package/{src → dist}/lib/modal/AttachDialog.d.ts +0 -1
  91. package/dist/lib/modal/AttachDialog.js +73 -0
  92. package/dist/lib/modal/FormActionDialog.js +20 -0
  93. package/{src → dist}/lib/page/PageContainer.d.ts +0 -1
  94. package/dist/lib/page/PageContainer.js +5 -0
  95. package/{src → dist}/lib/page/PageContentEditor.d.ts +0 -1
  96. package/dist/lib/page/PageContentEditor.js +10 -0
  97. package/{src → dist}/lib/page/PageMain.d.ts +0 -1
  98. package/dist/lib/page/PageMain.js +5 -0
  99. package/dist/lib/page/PageQueryStateContainer.js +16 -0
  100. package/{src → dist}/lib/page/PageSectionTitle.d.ts +0 -1
  101. package/dist/lib/page/PageSectionTitle.js +4 -0
  102. package/{src → dist}/lib/page/PageSidebar.d.ts +0 -1
  103. package/dist/lib/page/PageSidebar.js +4 -0
  104. package/{src → dist}/lib/page/PageSidebarSection.d.ts +0 -1
  105. package/dist/lib/page/PageSidebarSection.js +5 -0
  106. package/dist/lib/page/PageStateContainer.js +7 -0
  107. package/{src → dist}/lib/page/PageSubSectionTitle.d.ts +0 -1
  108. package/dist/lib/page/PageSubSectionTitle.js +4 -0
  109. package/{src → dist}/lib/page/PageTitle.d.ts +0 -1
  110. package/dist/lib/page/PageTitle.js +4 -0
  111. package/dist/lib/page/PageTopBar.js +78 -0
  112. package/{src → dist}/lib/status/StatusBadge.d.ts +0 -1
  113. package/dist/lib/status/StatusBadge.js +21 -0
  114. package/dist/lib/table/TableColumnButton.d.ts +1 -0
  115. package/dist/lib/table/TableColumnButton.js +53 -0
  116. package/{src → dist}/lib/table/TableContainer.d.ts +0 -1
  117. package/dist/lib/table/TableContainer.js +6 -0
  118. package/dist/lib/table/TableContainerContext.js +40 -0
  119. package/{src → dist}/lib/table/TableCreateButton.d.ts +0 -1
  120. package/dist/lib/table/TableCreateButton.js +7 -0
  121. package/{src → dist}/lib/table/TableFilterButton.d.ts +0 -1
  122. package/dist/lib/table/TableFilterButton.js +8 -0
  123. package/{src → dist}/lib/table/TableFilters.d.ts +0 -1
  124. package/dist/lib/table/TableFilters.js +27 -0
  125. package/{src → dist}/lib/table/TableMassActions.d.ts +0 -1
  126. package/dist/lib/table/TableMassActions.js +9 -0
  127. package/{src → dist}/lib/table/TableRowActionBar.d.ts +0 -1
  128. package/dist/lib/table/TableRowActionBar.js +8 -0
  129. package/{src → dist}/lib/table/TableRowActionButton.d.ts +0 -1
  130. package/dist/lib/table/TableRowActionButton.js +5 -0
  131. package/{src → dist}/lib/table/TableRowActionDialogButton.d.ts +1 -2
  132. package/dist/lib/table/TableRowActionDialogButton.js +6 -0
  133. package/{src → dist}/lib/table/TableRowDeleteButton.d.ts +0 -1
  134. package/dist/lib/table/TableRowDeleteButton.js +6 -0
  135. package/{src → dist}/lib/table/TableRowEditButton.d.ts +0 -1
  136. package/dist/lib/table/TableRowEditButton.js +6 -0
  137. package/{src → dist}/lib/table/TableRowNavigateButton.d.ts +0 -1
  138. package/dist/lib/table/TableRowNavigateButton.js +14 -0
  139. package/{src → dist}/lib/table/TableRowPublishPostButton.d.ts +0 -1
  140. package/dist/lib/table/TableRowPublishPostButton.js +19 -0
  141. package/{src → dist}/lib/table/TableRowViewButton.d.ts +0 -1
  142. package/dist/lib/table/TableRowViewButton.js +13 -0
  143. package/{src → dist}/lib/table/TableTopBar.d.ts +1 -2
  144. package/dist/lib/table/TableTopBar.js +5 -0
  145. package/package.json +60 -4
  146. package/README.md +0 -7
  147. package/index.cjs.d.ts +0 -1
  148. package/index.cjs.js +0 -3710
  149. package/index.esm.d.ts +0 -1
  150. package/index.esm.js +0 -3662
  151. package/src/lib/table/TableColumnButton.d.ts +0 -0
  152. /package/{src → dist}/index.d.ts +0 -0
  153. /package/{src → dist}/lib/buttons/DialogButton.d.ts +0 -0
  154. /package/{src → dist}/lib/json/dialog/ItemDeleteDialog.d.ts +0 -0
  155. /package/{src → dist}/lib/json/dialog/ItemEditDialog.d.ts +0 -0
  156. /package/{src → dist}/lib/json/table/TableViewContext.d.ts +0 -0
  157. /package/{src → dist}/lib/json/table/useTableProps.d.ts +0 -0
  158. /package/{src → dist}/lib/json/types/EditItemDialog.d.ts +0 -0
  159. /package/{src → dist}/lib/json/types/MultiQueryWrapper.d.ts +0 -0
  160. /package/{src → dist}/lib/json/types/MultiQueryWrapperDialog.d.ts +0 -0
  161. /package/{src → dist}/lib/json/types/QueryWrapper.d.ts +0 -0
  162. /package/{src → dist}/lib/json/types/QueryWrapperDialog.d.ts +0 -0
  163. /package/{src → dist}/lib/json/types/ScreenConfig.d.ts +0 -0
  164. /package/{src → dist}/lib/layout/menu/MenuConfig.d.ts +0 -0
  165. /package/{src → dist}/lib/modal/FormActionDialog.d.ts +0 -0
  166. /package/{src → dist}/lib/page/PageQueryStateContainer.d.ts +0 -0
  167. /package/{src → dist}/lib/page/PageStateContainer.d.ts +0 -0
  168. /package/{src → dist}/lib/page/PageTopBar.d.ts +0 -0
  169. /package/{src → dist}/lib/table/TableContainerContext.d.ts +0 -0
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  import { Item } from "./MenuConfig";
4
3
  interface MenuItemProps extends SoperioComponent, ParentComponent {
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@soperio/jsx-runtime";
2
+ import { SelectedIndicator } from "./SelectedIndicator";
3
+ import { Link, useLocation, useMatch } from "react-router-dom";
4
+ import { MenuButton } from "./MenuButton";
5
+ export function MenuItem({ icon, path, depth, darkMode, subMenu, ...props }) {
6
+ const location = useLocation();
7
+ const selected = path == "/" ? location.pathname == "/" : location.pathname.startsWith(path.startsWith("/") ? path : `/${path}`);
8
+ const match = useMatch("/" + path) != null;
9
+ // const selected = match != null
10
+ return (_jsxs(_Fragment, { children: [_jsxs(Link, { to: path, style: { position: "relative" }, children: [_jsx(MenuButton, { depth: depth, darkMode: darkMode, icon: icon, selected: selected, ...props }), match && _jsx(SelectedIndicator, { darkMode: darkMode })] }), subMenu?.map((item, index) => (_jsx(MenuItem, { icon: item.icon, path: item.path, depth: (depth ?? 0) + 1, darkMode: darkMode, subMenu: item.children, children: item.label }, index)))] }));
11
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  import { Item } from "./MenuConfig";
4
3
  interface NextMenuItemProps extends SoperioComponent, ParentComponent {
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@soperio/jsx-runtime";
2
+ import { MenuButton } from "./MenuButton";
3
+ import { SelectedIndicator } from "./SelectedIndicator";
4
+ import Link from "next/link";
5
+ import { useRouter } from "next/router";
6
+ export function NextMenuItem({ icon, path, depth, darkMode, subMenu, ...props }) {
7
+ const { pathname } = useRouter();
8
+ const selected = path == "/" ? pathname == "/" : pathname.startsWith(path.startsWith("/") ? path : `/${path}`);
9
+ const match = path == "/" ? pathname == "/" : pathname == (path.startsWith("/") ? path : `/${path}`);
10
+ return (_jsxs(_Fragment, { children: [_jsxs(Link, { href: path, style: { position: "relative" }, children: [_jsx(MenuButton, { depth: depth, darkMode: darkMode, icon: icon, selected: selected, ...props }), match && _jsx(SelectedIndicator, { darkMode: darkMode })] }), subMenu?.map((item, index) => (_jsx(NextMenuItem, { icon: item.icon, path: item.path, depth: (depth ?? 0) + 1, darkMode: darkMode, subMenu: item.children, children: item.label }, index)))] }));
11
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare function SelectedIndicator({ darkMode }: {
3
2
  darkMode?: boolean;
4
3
  }): JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ export function SelectedIndicator({ darkMode }) {
3
+ return (_jsx("div", { position: "absolute", bgColor: darkMode ? "white" : "black", bgOpacity: "90", w: "0.5", h: "6", top: "1.5", start: "-4" }));
4
+ }
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
- import { MenuConfig } from "@compill/admin";
1
+ import { MenuConfig } from "./MenuConfig";
3
2
  interface UserBlockProps {
4
3
  color: string;
5
4
  darkMode?: boolean;
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@soperio/jsx-runtime";
2
+ import { useSessionLogout, useSessionUser } from "@compill/auth";
3
+ import { mdiCog, mdiDotsVertical, mdiLogout } from "@mdi/js";
4
+ import { Avatar, Button, Icon, IconButton, Popup } from "@valerya/ui";
5
+ import { capitalize } from "es-toolkit";
6
+ import React from "react";
7
+ import { useNavigate } from "react-router-dom";
8
+ export function UserBlock({ color, darkMode, menuConfig, path }) {
9
+ const { isLoading, user } = useSessionUser();
10
+ const navigate = useNavigate();
11
+ const handleClick = React.useCallback(() => navigate(path), [navigate, path]);
12
+ if (isLoading)
13
+ return null;
14
+ return (_jsxs("div", { dflex: true, 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, children: [_jsx(Avatar, { size: "sm", src: user?.media?.url ?? "", name: `${user?.firstname} ${user?.lastname}` }), _jsx("span", { flexGrow: true, ms: "2", children: `${capitalize(user?.firstname || user?.lastname || "")}` }), _jsx(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 }), _jsx(OverflowMenu, { color: color, darkMode: darkMode, menuConfig: menuConfig })] }));
15
+ }
16
+ function OverflowMenu({ color, darkMode, menuConfig }) {
17
+ const [showPopup, setShowPopup] = React.useState(false);
18
+ const navigate = useNavigate();
19
+ const logout = useSessionLogout(false);
20
+ return (_jsx(_Fragment, { children: _jsxs(Popup, { show: showPopup, position: "relative", side: "bottom-end", onClick: (e) => { e.preventDefault(); e.stopPropagation(); setShowPopup((show) => !show); }, onHide: () => setShowPopup(false), children: [_jsx(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"}` }), _jsxs("div", { bgColor: "white", rounded: "sm", overflow: "hidden", shadow: true, mt: "1", border: "px", borderColor: "gray-200", divideColor: "gray-200", divideY: "px", minW: "40", children: [menuConfig && menuConfig.length > 0 && menuConfig.map((item, index) => {
21
+ if (item.type == "item") {
22
+ return (_jsx(MenuItem, { icon: item.icon, onClick: () => navigate(item.path), children: item.label }, index));
23
+ }
24
+ return null;
25
+ }), _jsx(MenuItem, { icon: mdiLogout, onClick: logout, children: "Logout" })] })] }) }));
26
+ }
27
+ function MenuItem({ icon, onClick, children, ...props }) {
28
+ const handleClick = React.useCallback((e) => {
29
+ e.preventDefault();
30
+ e.stopPropagation();
31
+ onClick?.(e);
32
+ }, []);
33
+ return (_jsxs(Button, { variant: "borderless", scheme: "dark", size: "sm", alignItems: "center", dflex: true, gap: "2", px: "2", py: "1.5", w: "full", onClick: handleClick, textColor: "slate-700", ...props, children: [icon && _jsx(Icon, { path: icon, size: "md" }), children] }));
34
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { QueryFunctionContext } from "@tanstack/react-query";
3
2
  import { ModalProps } from "@valerya/ui";
4
3
  import { FormikConfig } from "formik";
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@soperio/jsx-runtime";
2
+ import { useApiMutation, useApiQuery } from "@compill/api";
3
+ import { ModalLoadingOverlay, QueryLoadingState, RetryOnError } from "@compill/components";
4
+ import { useQueryClient } from "@tanstack/react-query";
5
+ import { Button, Checkbox, Modal } from "@valerya/ui";
6
+ import { sortBy } from "es-toolkit";
7
+ import React from "react";
8
+ import { toast } from "react-toastify";
9
+ const defaultErrorMsg = "Oops, something went wrong...";
10
+ export function AttachDialog({ queryId, queryKey, queryFetchFn, queryFetchAllKey, queryFetchAllFn, querySaveFn, matchKey, size = "lg", show, onClose, itemLabel, onSuccess, onFetchError, fetchErrorMsg = defaultErrorMsg, onSaveError, saveErrorMsg = defaultErrorMsg, invalidateQueriesOnSuccess = true, retryText = "Retry", cancelLabel = "Cancel", saveLabel, formikProps, getItemName, ...props }) {
11
+ const queryClient = useQueryClient();
12
+ const { data: attached, isInitialLoading: fetchLoading, isError: fetchError, refetch, error } = useApiQuery(queryKey, queryFetchFn);
13
+ const { data, isInitialLoading: fetchAllLoading, isError: fetchAllError, refetch: refetchAll, error: errorAll } = useApiQuery(queryFetchAllKey, queryFetchAllFn);
14
+ const [selectedResources, setSelectedResources] = React.useState([]);
15
+ const isLoading = fetchLoading || fetchAllLoading;
16
+ const isError = fetchError || fetchAllError;
17
+ const mutation = useApiMutation(querySaveFn, queryKey, queryId);
18
+ const handleClick = React.useCallback((event) => {
19
+ const id = event?.currentTarget.dataset.id ?? "";
20
+ const arr = selectedResources.concat([]);
21
+ const i = selectedResources.indexOf(id);
22
+ if (i != -1)
23
+ arr.splice(i, 1);
24
+ else
25
+ arr.push(id);
26
+ setSelectedResources(arr);
27
+ }, [selectedResources, setSelectedResources]);
28
+ const retry = React.useCallback(() => {
29
+ if (fetchError)
30
+ refetch();
31
+ if (fetchAllError)
32
+ refetchAll();
33
+ }, [refetch, refetchAll, fetchError, fetchAllError]);
34
+ const saveItem = React.useCallback(() => {
35
+ // Clear mutation error if any
36
+ mutation.reset();
37
+ mutation.mutateAsync({ resources: selectedResources })
38
+ .then((response) => {
39
+ if (onSuccess)
40
+ onSuccess(response);
41
+ else
42
+ toast.success(`${itemLabel} saved`);
43
+ if (invalidateQueriesOnSuccess)
44
+ queryClient.invalidateQueries({ queryKey: queryKey });
45
+ // closing delete modal
46
+ onClose?.();
47
+ })
48
+ .catch(error => {
49
+ console.error("on error", error);
50
+ if (onSaveError)
51
+ onSaveError();
52
+ else
53
+ toast.error(`Error adding ${itemLabel}`);
54
+ });
55
+ }, [mutation, queryId, onSuccess, queryClient, onSaveError, onClose]);
56
+ const resources = React.useMemo(() => {
57
+ let r = [];
58
+ if (attached && data) {
59
+ r = [].concat(data);
60
+ attached.forEach((attachedItem) => r.splice(r.findIndex((item) => item.id == attachedItem[matchKey]), 1));
61
+ // TODO set keyField for name (could be title for example)
62
+ if (getItemName)
63
+ r = r.map((item) => { return { ...item, name: getItemName(item) }; });
64
+ r = sortBy(r, ["name"]);
65
+ }
66
+ return r;
67
+ }, [attached, data]);
68
+ return (_jsxs(Modal, { size: size, show: show, onClose: onClose, scheme: "light", transition: true, ...props, children: [_jsx(Modal.Header, { children: `Add ${itemLabel}` }), isLoading && (_jsx(Modal.Body, { children: _jsx(QueryLoadingState, { minW: "72" }) })), isError && (_jsx(Modal.Body, { children: _jsx(RetryOnError, { label: `${fetchErrorMsg} ${error}`, onClick: retry }) })), !isLoading && !isError &&
69
+ (_jsxs(_Fragment, { children: [_jsx(Modal.Body, { px: "0", pb: "6", maxH: "750px", overflow: "auto", children: _jsx("div", { dflex: true, flexCol: true, overflow: "auto", children: resources.map(item => (_jsx(ListItem, { label: item.name, value: item.id, "data-id": item.id, checked: selectedResources.includes(`${item.id}`), onClick: handleClick }, item.id))) }) }), _jsxs(Modal.Footer, { dflex: true, placeContent: "end", spaceX: "3", children: [_jsx(Button, { disabled: mutation.isLoading, onClick: onClose, variant: "borderless", me: "2", children: cancelLabel }), _jsx(Button, { type: "submit", disabled: selectedResources.length == 0 || mutation.isLoading /* || !isValid*/, onClick: saveItem, children: saveLabel ? saveLabel : (queryId ? "Update" : "Create") })] })] })), mutation.isLoading && _jsx(ModalLoadingOverlay, {})] }));
70
+ }
71
+ function ListItem({ label, value, checked, ...props }) {
72
+ return (_jsxs("div", { dflex: true, alignItems: "center", hover_bgColor: "slate-100", px: "5", py: "2", cursor: "pointer", ...props, children: [_jsx("span", { flexGrow: true, children: label }), _jsx(Checkbox, { name: `resources.${value}`, value: value, checked: checked })] }));
73
+ }
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { useMutate } from "@compill/api";
3
+ import { ModalLoadingOverlay } from "@compill/components";
4
+ import { SubmitButton, FormRenderer, FormProvider } from "@compill/form";
5
+ import { useApiMutation, useInvalidateParentMutation } from "@compill/api";
6
+ import { Button, Modal } from "@valerya/ui";
7
+ import React from "react";
8
+ 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 }) {
9
+ const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(queryFn, queryKey, queryOptions) : useApiMutation(queryFn, queryKey, queryId, queryOptions);
10
+ const mutate = useMutate(mutation, {
11
+ onSuccess,
12
+ successMsg,
13
+ showSuccessMsg,
14
+ onError,
15
+ errorMsg,
16
+ showErrorMsg,
17
+ processInput,
18
+ });
19
+ return (_jsxs(Modal, { size: size, show: show, onClose: onClose, scheme: "light", transition: true, ...props, children: [_jsx(Modal.Header, { children: title }), _jsxs(FormProvider, { initialValues: initialValues ?? {}, onSubmit: mutate, ...formikProps, children: [_jsxs(Modal.Body, { pb: "6", children: [React.isValidElement(form) && form, Array.isArray(form) && _jsx(FormRenderer, { form: form })] }), _jsxs(Modal.Footer, { dflex: true, placeContent: "end", spaceX: "3", children: [_jsx(Button, { disabled: mutation.isLoading, onClick: onClose, variant: "borderless", me: "2", children: cancelLabel }), _jsx(SubmitButton, { disabled: mutation.isLoading, children: saveLabel })] })] }), mutation.isLoading && _jsx(ModalLoadingOverlay, {})] }));
20
+ }
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { ContainerProps } from "@valerya/ui";
3
2
  export declare function PageContainer({ children, ...props }: ContainerProps): JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { Container } from "@valerya/ui";
3
+ export function PageContainer({ children, ...props }) {
4
+ return _jsx(Container, { center: true, dflex: true, flexCol: true, gap: "8", ...props, children: children });
5
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { SoperioComponent } from "@soperio/react";
3
2
  export declare function PageContentEditor({ name, ...props }: {
4
3
  name: string;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { FormEditor } from "@compill/form-editor";
3
+ import { PageMain } from "./PageMain";
4
+ import { ImageExtension } from "@compill/editor";
5
+ export function PageContentEditor({ name, ...props }) {
6
+ const extensions = [ImageExtension];
7
+ return (_jsx(PageMain, { h: "min", ...props, children: _jsx(FormEditor, { minH: "128", minW: "144", maxW: props.maxW,
8
+ // w={props.w}
9
+ name: name, placeHolder: "Write here...", extensions: extensions }) }));
10
+ }
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  export declare function PageMain({ children, ...props }: SoperioComponent & ParentComponent): JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { Tile } from "@valerya/ui";
3
+ export function PageMain({ children, ...props }) {
4
+ return _jsx(Tile, { scheme: "light", p: "5", ...props, children: children });
5
+ }
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { QueryLoadingState, RetryOnError } from "@compill/components";
3
+ import { useApiQuery, useInvalidateQuery } from "@compill/api";
4
+ import React from "react";
5
+ import { PageContainer } from "./PageContainer";
6
+ function PageQueryStateContainerInner({ queryId, api, apiFn, loadingStyles, errorStyles, children, ...props }) {
7
+ // @ts-ignore
8
+ const { data, isLoading, isError } = apiFn == "getAll" ? useApiQuery(api.queryKey, api.getAll, props.apiParams) : useApiQuery(api.queryKey, api.get, queryId);
9
+ const invalidate = useInvalidateQuery(api.queryKey, queryId);
10
+ if (isLoading)
11
+ return _jsx(QueryLoadingState, { w: "full", h: "100%", ...loadingStyles });
12
+ if (isError)
13
+ return _jsx(RetryOnError, { p: "0", onClick: invalidate, ...errorStyles });
14
+ return _jsx(PageContainer, { ...props, children: apiFn == "get" ? children(data) : children(data) });
15
+ }
16
+ export const PageQueryStateContainer = React.forwardRef(PageQueryStateContainerInner);
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  export declare function PageSectionTitle({ children, ...props }: SoperioComponent & ParentComponent): JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ export function PageSectionTitle({ children, ...props }) {
3
+ return _jsx("div", { trait: "typo.h6", mb: "5", ...props, children: children });
4
+ }
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  export declare function PageSidebar({ children, ...props }: SoperioComponent & ParentComponent): JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ export function PageSidebar({ children, ...props }) {
3
+ return _jsx("div", { w: "112", minW: "112", minH: "100%", gap: "8", dflex: true, flexCol: true, ...props, children: children });
4
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  export declare function PageSidebarSection({ title, children, ...props }: {
4
3
  title?: string;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { PageSectionTitle } from "./PageSectionTitle";
3
+ export function PageSidebarSection({ title, children, ...props }) {
4
+ return (_jsxs("div", { w: "full", ...props, children: [title && _jsx(PageSectionTitle, { children: title }), children] }));
5
+ }
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { QueryLoadingState } from "@compill/components";
3
+ import { Container } from "@valerya/ui";
4
+ import React from "react";
5
+ export const PageStateContainer = React.forwardRef(({ loading = false, children, ...props }, ref) => {
6
+ return (_jsxs(_Fragment, { children: [loading && _jsx(QueryLoadingState, { w: "full", h: "100%" }), !loading && _jsx(Container, { ref: ref, center: true, size: "x2", dflex: true, flexCol: true, gap: "8", ...props, children: children })] }));
7
+ });
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  export declare function PageSubSectionTitle({ children, ...props }: SoperioComponent & ParentComponent): JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ export function PageSubSectionTitle({ children, ...props }) {
3
+ return _jsx("div", { trait: "typo.h6", mb: "3", ...props, children: children });
4
+ }
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  export declare function PageTitle({ children, ...props }: SoperioComponent & ParentComponent): JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ export function PageTitle({ children, ...props }) {
3
+ return _jsx("div", { trait: "typo.h5", ...props, children: children });
4
+ }
@@ -0,0 +1,78 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@soperio/jsx-runtime";
2
+ import { createContext } from "@soperio/react";
3
+ import { PageTitle } from "./PageTitle";
4
+ import React from "react";
5
+ import { createPortal } from "react-dom";
6
+ import { FlexCenter } from "@compill/components";
7
+ import { Breadcrumbs } from "../breadcrumbs/BreadCrumbs";
8
+ export function PageTopBar({ title, breadcrumbs, children, ...props }) {
9
+ return (_jsxs(FlexCenter, { gap: "3", minH: "9", ...props, children: [title && _jsx(PageTitle, { children: title }), breadcrumbs && _jsx(Breadcrumbs, { breadcrumbs: breadcrumbs }), _jsx("div", { flexGrow: true }), children] }));
10
+ }
11
+ const [CP, usePageTabbedTopBarContext] = createContext();
12
+ export function PageTabbedTopBarProvider({ children }) {
13
+ const [containerEl, setContainerEl] = React.useState(null);
14
+ const r = React.createRef();
15
+ return (_jsx(CP, { value: { containerEl, setContainerEl }, children: children }));
16
+ }
17
+ export function PageTabbedTopBar({ title, breadcrumbs, children, ...props }) {
18
+ const ref = React.createRef();
19
+ const { setContainerEl } = usePageTabbedTopBarContext();
20
+ const [isSet, setIsSet] = React.useState(false);
21
+ React.useEffect(() => {
22
+ if (!isSet && ref.current) {
23
+ setContainerEl(ref.current);
24
+ setIsSet(true);
25
+ }
26
+ return () => setContainerEl(null);
27
+ }, []);
28
+ return (_jsx(FlexCenter, { gap: "3", minH: "9", ...props, children: _jsxs(_Fragment, { children: [title && _jsx(PageTitle, { children: title }), breadcrumbs && _jsx(Breadcrumbs, { breadcrumbs: breadcrumbs }), _jsx("div", { flexGrow: true }), _jsx("div", { ref: ref, dflex: true, flexRow: true, gap: "3" }), children] }) }));
29
+ }
30
+ export function PageTopBarToolbar({ trackingRef, children }) {
31
+ const { containerEl } = usePageTabbedTopBarContext();
32
+ const [visible, setVisible] = React.useState(false);
33
+ const portal = React.useMemo(() => {
34
+ const node = containerEl; //?.ownerDocument.createElement("div")
35
+ // if (node) node.className = PORTAL_CLASSNAME
36
+ return node;
37
+ }, [containerEl]);
38
+ const host = containerEl ?? (typeof window !== "undefined" ? document.body : undefined);
39
+ React.useLayoutEffect(() => {
40
+ if (!portal || !host)
41
+ return;
42
+ try {
43
+ if (visible)
44
+ host.appendChild(portal);
45
+ else
46
+ host.removeChild(portal);
47
+ }
48
+ catch (e) {
49
+ }
50
+ return () => {
51
+ try {
52
+ host.removeChild(portal);
53
+ }
54
+ catch (e) { }
55
+ };
56
+ }, [visible, portal, host]);
57
+ const callback = React.useCallback((entries) => {
58
+ // @ts-ignore
59
+ setVisible(entries[0].isVisible);
60
+ }, [children]);
61
+ React.useEffect(() => {
62
+ const opts = {
63
+ root: null,
64
+ rootMargin: '0px',
65
+ threshold: 0,
66
+ /* required options*/
67
+ trackVisibility: true,
68
+ delay: 100
69
+ };
70
+ const observerScroll = new IntersectionObserver(callback, opts);
71
+ if (trackingRef)
72
+ observerScroll.observe(trackingRef);
73
+ return () => observerScroll.disconnect();
74
+ }, [trackingRef, callback, children]);
75
+ if (host && portal)
76
+ return createPortal(children, portal);
77
+ return null;
78
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { SoperioComponent } from "@soperio/react";
3
2
  export declare function StatusBadge({ status, ...props }: {
4
3
  status: "draft" | "published";
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { Badge } from "@valerya/ui";
3
+ const labels = {
4
+ draft: "Draft",
5
+ published: "Published",
6
+ pending: "Pending",
7
+ approved: "Approved",
8
+ partially_approved: "Partially Approved",
9
+ rejected: "Rejected"
10
+ };
11
+ const schemes = {
12
+ draft: "warning",
13
+ published: "success",
14
+ pending: "secondary",
15
+ approved: "success",
16
+ partially_approved: "warning",
17
+ rejected: "danger",
18
+ };
19
+ export function StatusBadge({ status, ...props }) {
20
+ return (_jsx(Badge, { size: "sm", variant: "glass", whiteSpace: "nowrap", rounded: "full", px: "3", scheme: schemes[status], ...props, children: labels[status] }));
21
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ // import { mdiViewColumn } from "@mdi/js";
2
+ // import { useTableContainerContext } from "./TableContainerContext";
3
+ // import { ColumnDef, ColumnDefResolved } from "@tanstack/react-table";
4
+ // import { ButtonProps } from "@valerya/ui";
5
+ export {};
6
+ // function getColId(column: ColumnDef<any, any>)
7
+ // {
8
+ // return (column as ColumnDefResolved<any>).accessorKey ?? column.id ?? ""
9
+ // }
10
+ // export function TableColumnButton({ ...props }: ButtonProps)
11
+ // {
12
+ // const t = useTranslation()
13
+ // const { columns, isColumnVisible, toggleColumnVisibility } = useTableContainerContext()
14
+ // const ids = columns.filter(col => isColumnVisible(getColId(col))).map(col => getColId(col))
15
+ // return (
16
+ // <Menu isLazy closeOnSelect={false}>
17
+ // <MenuButton
18
+ // as={Button}
19
+ // leftIcon={<SVGIcon path={mdiViewColumn} me="-1" w="5" />}
20
+ // colorScheme="pink"
21
+ // outline="0"
22
+ // border="0"
23
+ // title={t("toggle-columns-visibility") ?? ""}
24
+ // display="flex"
25
+ // gap="2"
26
+ // alignItems="center"
27
+ // placeContent="center"
28
+ // {...props}
29
+ // >
30
+ // {ids.length == columns.length && t("columns")}
31
+ // {ids.length != columns.length && t("columns-with-count", {visible: ids.length, total: columns.length })}
32
+ // </MenuButton>
33
+ // <MenuList minWidth="240px" zIndex={2}>
34
+ // <MenuOptionGroup type="checkbox" value={ids}>
35
+ // {
36
+ // columns.map((col, index) =>
37
+ // (
38
+ // <MenuItemOption
39
+ // key={getColId(col)}
40
+ // value={getColId(col)}
41
+ // isChecked={isColumnVisible(getColId(col))}
42
+ // onClick={() => toggleColumnVisibility(getColId(col))}
43
+ // isDisabled={col.enableHiding == false}
44
+ // >
45
+ // {col.header?.toString() ?? ""}
46
+ // </MenuItemOption>
47
+ // ))
48
+ // }
49
+ // </MenuOptionGroup>
50
+ // </MenuList>
51
+ // </Menu>
52
+ // )
53
+ // }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ColumnDef } from "@tanstack/react-table";
3
2
  import { TileProps } from "@valerya/ui";
4
3
  interface TableContainerProps extends TileProps {
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { TableContextProvider } from "@compill/table";
3
+ import { TableContainerContextProvider } from "./TableContainerContext";
4
+ export function TableContainer({ initialPageSize, initialVisibleColumns, columns, filtersMethod = "reactRouter", children, ...props }) {
5
+ return (_jsx("div", { w: "full", dflex: true, flexCol: true, ...props, children: _jsx(TableContextProvider, { initialPageSize: initialPageSize, filtersMethod: filtersMethod, children: _jsx(TableContainerContextProvider, { columns: columns, initialVisibleColumns: initialVisibleColumns, children: children }) }) }));
6
+ }
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import React from "react";
3
+ import { createContext } from "@soperio/react";
4
+ const [provider, useContext] = createContext();
5
+ function getColId(column) {
6
+ return column.accessorKey ?? column.id;
7
+ }
8
+ function TableContainerContextProvider({ initialVisibleColumns, columns, children }) {
9
+ const [showFilters, setShowFilters] = React.useState(false);
10
+ const [showMassActions, setShowMassActions] = React.useState(false);
11
+ const [visibleColumnIds, setVisibleColumnIds] = React.useState(initialVisibleColumns ?? columns?.map(col => getColId(col)) ?? []);
12
+ const filteredColumns = columns?.filter(col => visibleColumnIds.includes(getColId(col))) ?? [];
13
+ const toggleColumnVisibility = React.useCallback((id) => {
14
+ const index = visibleColumnIds.indexOf(id);
15
+ if (index > -1) {
16
+ const newIds = visibleColumnIds.concat();
17
+ newIds.splice(index, 1);
18
+ setVisibleColumnIds(newIds);
19
+ }
20
+ else {
21
+ setVisibleColumnIds(visibleColumnIds.concat(id));
22
+ }
23
+ }, [visibleColumnIds, setVisibleColumnIds]);
24
+ const isColumnVisible = React.useCallback((id) => {
25
+ return visibleColumnIds.includes(id);
26
+ }, [visibleColumnIds]);
27
+ const Provider = provider;
28
+ const value = {
29
+ showFilters,
30
+ setShowFilters,
31
+ showMassActions,
32
+ setShowMassActions,
33
+ columns: columns ?? [],
34
+ filteredColumns,
35
+ toggleColumnVisibility,
36
+ isColumnVisible
37
+ };
38
+ return _jsx(Provider, { value: value, children: children });
39
+ }
40
+ export { TableContainerContextProvider, useContext as useTableContainerContext };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { DialogButtonProps } from "../buttons/DialogButton";
3
2
  export declare function TableCreateButton({ icon, children, ...props }: {
4
3
  icon?: string;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { mdiPlusThick } from "@mdi/js";
3
+ import { Icon } from "@valerya/ui";
4
+ import { ButtonBarDialogButton } from "../layout/ButtonBar";
5
+ export function TableCreateButton({ icon, children, ...props }) {
6
+ return (_jsxs(ButtonBarDialogButton, { ...props, children: [_jsx(Icon, { path: icon ?? mdiPlusThick }), children] }));
7
+ }
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { ButtonProps } from "@valerya/ui";
3
2
  export declare function TableFilterButton({ ...props }: ButtonProps): JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { Icon } from "@valerya/ui";
3
+ import { Button, Popover } from "@valerya/ui";
4
+ import { mdiFilter } from "@mdi/js";
5
+ export function TableFilterButton({ ...props }) {
6
+ // return <Button scheme="secondary" {...props}><Icon path={mdiFilter} /></Button>
7
+ return (_jsxs(Popover, { side: "bottom-end", modal: true, children: [_jsx(Button, { scheme: "dark", size: "sm", aspectRatio: "square", variant: "borderless", corners: "square", ...props, children: _jsx(Icon, { path: mdiFilter }) }), _jsxs("div", { bgColor: "white", rounded: true, shadow: true, children: [_jsx("div", { py: "3", hover_bgColor: "#ff0000", px: "5", hover_textColor: "white", children: "First Item" }), _jsx("div", { py: "3", hover_bgColor: "#ff0000", px: "5", hover_textColor: "white", children: "Second Item" }), _jsx("div", { py: "3", hover_bgColor: "#ff0000", px: "5", hover_textColor: "white", children: "Third Item" })] })] }));
8
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { FormRendererConfig } from "@compill/form";
3
2
  interface TableFiltersProps {
4
3
  form: FormRendererConfig;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { useTableContext } from "@compill/table";
3
+ import React from "react";
4
+ import { useTableContainerContext } from "./TableContainerContext";
5
+ import { FieldLabel, FormProvider, FormRenderer, mergeInitialFormValues, SubmitButton } from "@compill/form";
6
+ import { Button, Collapse } from "@valerya/ui";
7
+ import { isEqual } from "es-toolkit";
8
+ export function TableFilters({ form, initialValues, schema, processInput }) {
9
+ const { showFilters } = useTableContainerContext();
10
+ const { getFilters, setFilters } = useTableContext();
11
+ const handleSubmit = React.useCallback((values, actions) => {
12
+ const params = processInput?.(values) ?? values;
13
+ if (!isEqual(params, getFilters()))
14
+ setFilters(params);
15
+ // setFilters(processInput?.(values) ?? values)
16
+ actions.setSubmitting(false);
17
+ }, [setFilters, processInput]);
18
+ const handleReset = React.useCallback((resetForm) => {
19
+ setFilters(initialValues);
20
+ resetForm();
21
+ }, [setFilters, initialValues]);
22
+ React.useEffect(() => setFilters(initialValues), []);
23
+ return (_jsx(Collapse, { in: showFilters, style: { overflow: showFilters ? "initial" : "hidden" }, children: _jsx("div", { p: "8", borderT: "px", borderB: "px", borderColor: "slate-100", children: _jsx(FormProvider, { initialValues: mergeInitialFormValues(getFilters(), initialValues), onSubmit: handleSubmit, validationSchema: schema, enableReinitialize: true, children: (props) => (_jsxs("div", { dflex: true, gap: "3", placeContent: "start", children: [_jsx(FormRenderer, { flexRow: true, w: "auto", form: form }), _jsx(Buttons, { handleReset: () => handleReset(props.resetForm) })] })) }) }) }));
24
+ }
25
+ function Buttons({ handleReset }) {
26
+ return (_jsxs("div", { dflex: true, gap: "3", children: [_jsxs("div", { dflex: true, flexCol: true, children: [_jsx(FieldLabel, { name: "", label: "\u00A0" }), _jsx(SubmitButton, { children: "Filter" })] }), _jsxs("div", { dflex: true, flexCol: true, children: [_jsx(FieldLabel, { name: "", label: "\u00A0" }), _jsx(Button, { scheme: "neutral", onClick: handleReset, children: "Reset" })] })] }));
27
+ }