@compill/admin 1.0.104 → 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.
- package/dist/index.cjs +2054 -0
- package/dist/index.d.cts +565 -0
- package/dist/index.d.ts +565 -50
- package/dist/index.js +2000 -50
- package/package.json +17 -16
- package/dist/lib/SectionTitle.d.ts +0 -2
- package/dist/lib/SectionTitle.js +0 -4
- package/dist/lib/breadcrumbs/BreadCrumbs.d.ts +0 -15
- package/dist/lib/breadcrumbs/BreadCrumbs.js +0 -29
- package/dist/lib/buttons/DialogButton.d.ts +0 -7
- package/dist/lib/buttons/DialogButton.js +0 -15
- package/dist/lib/buttons/InvalidateButton.d.ts +0 -6
- package/dist/lib/buttons/InvalidateButton.js +0 -11
- package/dist/lib/buttons/NavigateButton.d.ts +0 -4
- package/dist/lib/buttons/NavigateButton.js +0 -12
- package/dist/lib/buttons/PublishButton.d.ts +0 -9
- package/dist/lib/buttons/PublishButton.js +0 -17
- package/dist/lib/buttons/UpdateButton.d.ts +0 -2
- package/dist/lib/buttons/UpdateButton.js +0 -11
- package/dist/lib/buttons/ViewButton.d.ts +0 -5
- package/dist/lib/buttons/ViewButton.js +0 -13
- package/dist/lib/cells/OrderCell.d.ts +0 -11
- package/dist/lib/cells/OrderCell.js +0 -26
- package/dist/lib/json/DetailsView.d.ts +0 -5
- package/dist/lib/json/DetailsView.js +0 -69
- package/dist/lib/json/EditItemView.d.ts +0 -2
- package/dist/lib/json/EditItemView.js +0 -6
- package/dist/lib/json/MultiQueryWrapper.d.ts +0 -5
- package/dist/lib/json/MultiQueryWrapper.js +0 -61
- package/dist/lib/json/QueryWrapper.d.ts +0 -6
- package/dist/lib/json/QueryWrapper.js +0 -29
- package/dist/lib/json/ScreenRenderer.d.ts +0 -6
- package/dist/lib/json/ScreenRenderer.js +0 -19
- package/dist/lib/json/ScreenTopBar.d.ts +0 -15
- package/dist/lib/json/ScreenTopBar.js +0 -18
- package/dist/lib/json/TabbedView.d.ts +0 -3
- package/dist/lib/json/TabbedView.js +0 -21
- package/dist/lib/json/buttons/ActionButton.d.ts +0 -14
- package/dist/lib/json/buttons/ActionButton.js +0 -11
- package/dist/lib/json/buttons/ConfirmationActionButton.d.ts +0 -26
- package/dist/lib/json/buttons/ConfirmationActionButton.js +0 -20
- package/dist/lib/json/dialog/DialogRenderer.d.ts +0 -11
- package/dist/lib/json/dialog/DialogRenderer.js +0 -14
- package/dist/lib/json/dialog/ItemDeleteDialog.d.ts +0 -17
- package/dist/lib/json/dialog/ItemDeleteDialog.js +0 -14
- package/dist/lib/json/dialog/ItemEditDialog.d.ts +0 -32
- package/dist/lib/json/dialog/ItemEditDialog.js +0 -77
- package/dist/lib/json/dialog/MultiQueryWrapperDialog.d.ts +0 -7
- package/dist/lib/json/dialog/MultiQueryWrapperDialog.js +0 -23
- package/dist/lib/json/dialog/QueryWrapperDialog.d.ts +0 -13
- package/dist/lib/json/dialog/QueryWrapperDialog.js +0 -20
- package/dist/lib/json/table/RefreshButton.d.ts +0 -3
- package/dist/lib/json/table/RefreshButton.js +0 -11
- package/dist/lib/json/table/TableRowActionsView.d.ts +0 -11
- package/dist/lib/json/table/TableRowActionsView.js +0 -36
- package/dist/lib/json/table/TableRowPublishPostButton.d.ts +0 -8
- package/dist/lib/json/table/TableRowPublishPostButton.js +0 -20
- package/dist/lib/json/table/TableView.d.ts +0 -3
- package/dist/lib/json/table/TableView.js +0 -65
- package/dist/lib/json/table/TableViewContext.d.ts +0 -14
- package/dist/lib/json/table/TableViewContext.js +0 -58
- package/dist/lib/json/table/useTableProps.d.ts +0 -3
- package/dist/lib/json/table/useTableProps.js +0 -57
- package/dist/lib/json/types/DetailsView.d.ts +0 -57
- package/dist/lib/json/types/DetailsView.js +0 -1
- package/dist/lib/json/types/EditItemDialog.d.ts +0 -4
- package/dist/lib/json/types/EditItemDialog.js +0 -1
- package/dist/lib/json/types/MultiQueryWrapper.d.ts +0 -18
- package/dist/lib/json/types/MultiQueryWrapper.js +0 -1
- package/dist/lib/json/types/MultiQueryWrapperDialog.d.ts +0 -13
- package/dist/lib/json/types/MultiQueryWrapperDialog.js +0 -1
- package/dist/lib/json/types/QueryWrapper.d.ts +0 -27
- package/dist/lib/json/types/QueryWrapper.js +0 -1
- package/dist/lib/json/types/QueryWrapperDialog.d.ts +0 -22
- package/dist/lib/json/types/QueryWrapperDialog.js +0 -1
- package/dist/lib/json/types/ScreenConfig.d.ts +0 -8
- package/dist/lib/json/types/ScreenConfig.js +0 -1
- package/dist/lib/json/types/TabbedView.d.ts +0 -22
- package/dist/lib/json/types/TabbedView.js +0 -1
- package/dist/lib/json/types/TableView.d.ts +0 -117
- package/dist/lib/json/types/TableView.js +0 -1
- package/dist/lib/layout/AdminLayout.d.ts +0 -13
- package/dist/lib/layout/AdminLayout.js +0 -15
- package/dist/lib/layout/ButtonBar.d.ts +0 -19
- package/dist/lib/layout/ButtonBar.js +0 -19
- package/dist/lib/layout/Content.d.ts +0 -9
- package/dist/lib/layout/Content.js +0 -9
- package/dist/lib/layout/PageTitleBar.d.ts +0 -6
- package/dist/lib/layout/PageTitleBar.js +0 -4
- package/dist/lib/layout/Sidebar.d.ts +0 -20
- package/dist/lib/layout/Sidebar.js +0 -12
- package/dist/lib/layout/menu/Menu.d.ts +0 -12
- package/dist/lib/layout/menu/Menu.js +0 -23
- package/dist/lib/layout/menu/MenuButton.d.ts +0 -6
- package/dist/lib/layout/menu/MenuButton.js +0 -5
- package/dist/lib/layout/menu/MenuConfig.d.ts +0 -13
- package/dist/lib/layout/menu/MenuConfig.js +0 -1
- package/dist/lib/layout/menu/MenuItem.d.ts +0 -11
- package/dist/lib/layout/menu/MenuItem.js +0 -11
- package/dist/lib/layout/menu/NextMenuItem.d.ts +0 -11
- package/dist/lib/layout/menu/NextMenuItem.js +0 -11
- package/dist/lib/layout/menu/SelectedIndicator.d.ts +0 -3
- package/dist/lib/layout/menu/SelectedIndicator.js +0 -4
- package/dist/lib/layout/menu/UserBlock.d.ts +0 -9
- package/dist/lib/layout/menu/UserBlock.js +0 -34
- package/dist/lib/modal/AttachDialog.d.ts +0 -30
- package/dist/lib/modal/AttachDialog.js +0 -73
- package/dist/lib/modal/FormActionDialog.d.ts +0 -23
- package/dist/lib/modal/FormActionDialog.js +0 -20
- package/dist/lib/page/PageContainer.d.ts +0 -2
- package/dist/lib/page/PageContainer.js +0 -5
- package/dist/lib/page/PageContentEditor.d.ts +0 -4
- package/dist/lib/page/PageContentEditor.js +0 -10
- package/dist/lib/page/PageMain.d.ts +0 -2
- package/dist/lib/page/PageMain.js +0 -5
- package/dist/lib/page/PageQueryStateContainer.d.ts +0 -21
- package/dist/lib/page/PageQueryStateContainer.js +0 -16
- package/dist/lib/page/PageSectionTitle.d.ts +0 -2
- package/dist/lib/page/PageSectionTitle.js +0 -4
- package/dist/lib/page/PageSidebar.d.ts +0 -2
- package/dist/lib/page/PageSidebar.js +0 -4
- package/dist/lib/page/PageSidebarSection.d.ts +0 -4
- package/dist/lib/page/PageSidebarSection.js +0 -5
- package/dist/lib/page/PageStateContainer.d.ts +0 -7
- package/dist/lib/page/PageStateContainer.js +0 -7
- package/dist/lib/page/PageSubSectionTitle.d.ts +0 -2
- package/dist/lib/page/PageSubSectionTitle.js +0 -4
- package/dist/lib/page/PageTitle.d.ts +0 -2
- package/dist/lib/page/PageTitle.js +0 -4
- package/dist/lib/page/PageTopBar.d.ts +0 -13
- package/dist/lib/page/PageTopBar.js +0 -78
- package/dist/lib/status/StatusBadge.d.ts +0 -4
- package/dist/lib/status/StatusBadge.js +0 -21
- package/dist/lib/table/TableColumnButton.d.ts +0 -1
- package/dist/lib/table/TableColumnButton.js +0 -53
- package/dist/lib/table/TableContainer.d.ts +0 -10
- package/dist/lib/table/TableContainer.js +0 -6
- package/dist/lib/table/TableContainerContext.d.ts +0 -18
- package/dist/lib/table/TableContainerContext.js +0 -40
- package/dist/lib/table/TableCreateButton.d.ts +0 -4
- package/dist/lib/table/TableCreateButton.js +0 -7
- package/dist/lib/table/TableFilterButton.d.ts +0 -2
- package/dist/lib/table/TableFilterButton.js +0 -8
- package/dist/lib/table/TableFilters.d.ts +0 -9
- package/dist/lib/table/TableFilters.js +0 -27
- package/dist/lib/table/TableMassActions.d.ts +0 -6
- package/dist/lib/table/TableMassActions.js +0 -9
- package/dist/lib/table/TableRowActionBar.d.ts +0 -10
- package/dist/lib/table/TableRowActionBar.js +0 -8
- package/dist/lib/table/TableRowActionButton.d.ts +0 -4
- package/dist/lib/table/TableRowActionButton.js +0 -5
- package/dist/lib/table/TableRowActionDialogButton.d.ts +0 -4
- package/dist/lib/table/TableRowActionDialogButton.js +0 -6
- package/dist/lib/table/TableRowDeleteButton.d.ts +0 -2
- package/dist/lib/table/TableRowDeleteButton.js +0 -6
- package/dist/lib/table/TableRowEditButton.d.ts +0 -2
- package/dist/lib/table/TableRowEditButton.js +0 -6
- package/dist/lib/table/TableRowNavigateButton.d.ts +0 -4
- package/dist/lib/table/TableRowNavigateButton.js +0 -14
- package/dist/lib/table/TableRowPublishPostButton.d.ts +0 -8
- package/dist/lib/table/TableRowPublishPostButton.js +0 -19
- package/dist/lib/table/TableRowViewButton.d.ts +0 -4
- package/dist/lib/table/TableRowViewButton.js +0 -13
- package/dist/lib/table/TableTopBar.d.ts +0 -8
- package/dist/lib/table/TableTopBar.js +0 -5
|
@@ -1,34 +0,0 @@
|
|
|
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,30 +0,0 @@
|
|
|
1
|
-
import { QueryFunctionContext } from "@tanstack/react-query";
|
|
2
|
-
import { ModalProps } from "@valerya/ui";
|
|
3
|
-
import { FormikConfig } from "formik";
|
|
4
|
-
interface AttachDialogProps<T> extends Omit<ModalProps, "id" | "children" | "title" | "position"> {
|
|
5
|
-
queryId?: string;
|
|
6
|
-
queryKey: string[];
|
|
7
|
-
queryFetchFn: (context: QueryFunctionContext) => Promise<T>;
|
|
8
|
-
queryFetchAllFn: (context: QueryFunctionContext) => Promise<T>;
|
|
9
|
-
queryFetchAllKey: string[];
|
|
10
|
-
querySaveFn: ({ resources }: {
|
|
11
|
-
resources: string[];
|
|
12
|
-
}) => Promise<any>;
|
|
13
|
-
matchKey: string;
|
|
14
|
-
show: boolean;
|
|
15
|
-
onClose: () => void;
|
|
16
|
-
itemLabel?: string;
|
|
17
|
-
onSuccess?: (response: any) => void;
|
|
18
|
-
onFetchError?: () => void;
|
|
19
|
-
fetchErrorMsg?: string;
|
|
20
|
-
onSaveError?: () => void;
|
|
21
|
-
saveErrorMsg?: string;
|
|
22
|
-
invalidateQueriesOnSuccess?: boolean;
|
|
23
|
-
retryText?: string;
|
|
24
|
-
cancelLabel?: string;
|
|
25
|
-
saveLabel?: string;
|
|
26
|
-
formikProps?: Omit<FormikConfig<any>, "initialValues" | "onSubmit">;
|
|
27
|
-
getItemName?: (item: any) => string;
|
|
28
|
-
}
|
|
29
|
-
export declare function AttachDialog({ queryId, queryKey, queryFetchFn, queryFetchAllKey, queryFetchAllFn, querySaveFn, matchKey, size, show, onClose, itemLabel, onSuccess, onFetchError, fetchErrorMsg, onSaveError, saveErrorMsg, invalidateQueriesOnSuccess, retryText, cancelLabel, saveLabel, formikProps, getItemName, ...props }: AttachDialogProps<any>): JSX.Element;
|
|
30
|
-
export {};
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { UseMutateOptions } from "@compill/api";
|
|
2
|
-
import { FormRendererConfig } from "@compill/form";
|
|
3
|
-
import { UseMutationOptions } from "@tanstack/react-query";
|
|
4
|
-
import { ModalProps } from "@valerya/ui";
|
|
5
|
-
import { FormikConfig } from "formik";
|
|
6
|
-
import React from "react";
|
|
7
|
-
export interface FormActionDialogProps<TFormData extends {} = any, TResultData extends {} = any> extends Omit<ModalProps, "id" | "children" | "title" | "position" | "onError">, UseMutateOptions<TResultData, TFormData> {
|
|
8
|
-
itemLabel?: string;
|
|
9
|
-
queryId?: string;
|
|
10
|
-
queryKey: string[];
|
|
11
|
-
initialValues: any;
|
|
12
|
-
queryFn: (item: TFormData) => Promise<TResultData>;
|
|
13
|
-
queryOptions?: UseMutationOptions<TResultData, unknown, TFormData>;
|
|
14
|
-
invalidateQueriesOnSuccess?: boolean;
|
|
15
|
-
cancelLabel?: string;
|
|
16
|
-
saveLabel?: string;
|
|
17
|
-
title: string;
|
|
18
|
-
formikProps?: Omit<FormikConfig<TFormData>, "initialValues" | "onSubmit">;
|
|
19
|
-
form: React.ReactNode | FormRendererConfig;
|
|
20
|
-
show: boolean;
|
|
21
|
-
onClose: () => void;
|
|
22
|
-
}
|
|
23
|
-
export declare function FormActionDialog<TFormData extends {}, TResultData extends {}>({ initialValues, itemLabel, queryId, queryKey, queryFn, queryOptions, onSuccess, successMsg, showSuccessMsg, onError, errorMsg, showErrorMsg, processInput, invalidateQueriesOnSuccess, cancelLabel, saveLabel, size, title, form, show, onClose, formikProps, ...props }: FormActionDialogProps<TFormData, TResultData>): JSX.Element;
|
|
@@ -1,20 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
2
|
-
import { FormEditor } from "@compill/form-editor";
|
|
3
|
-
import { PageMain } from "./PageMain.js";
|
|
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,21 +0,0 @@
|
|
|
1
|
-
import { CRUDAPI, CRUD_MODEL } from "@compill/api";
|
|
2
|
-
import { ContainerProps } from "@valerya/ui";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { SoperioComponent } from "@soperio/react";
|
|
5
|
-
type PageQueryContainerProps<T extends CRUD_MODEL> = Omit<ContainerProps, "children"> & ({
|
|
6
|
-
api: CRUDAPI<T>;
|
|
7
|
-
queryId?: string;
|
|
8
|
-
loadingStyles?: SoperioComponent;
|
|
9
|
-
errorStyles?: SoperioComponent;
|
|
10
|
-
} & ({
|
|
11
|
-
apiFn: "get";
|
|
12
|
-
children: (data: T) => React.ReactElement;
|
|
13
|
-
} | {
|
|
14
|
-
apiFn: "getAll";
|
|
15
|
-
apiParams?: any;
|
|
16
|
-
children: (data: T[]) => React.ReactElement;
|
|
17
|
-
}));
|
|
18
|
-
export declare const PageQueryStateContainer: <T extends CRUD_MODEL>(p: PageQueryContainerProps<T> & {
|
|
19
|
-
ref?: React.Ref<HTMLDivElement>;
|
|
20
|
-
}) => React.ReactElement;
|
|
21
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
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.js";
|
|
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,5 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
2
|
-
import { PageSectionTitle } from "./PageSectionTitle.js";
|
|
3
|
-
export function PageSidebarSection({ title, children, ...props }) {
|
|
4
|
-
return (_jsxs("div", { w: "full", ...props, children: [title && _jsx(PageSectionTitle, { children: title }), children] }));
|
|
5
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ContainerProps } from "@valerya/ui";
|
|
2
|
-
import React from "react";
|
|
3
|
-
interface PageStateContainerProps extends ContainerProps {
|
|
4
|
-
loading?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare const PageStateContainer: React.ForwardRefExoticComponent<PageStateContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
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,13 +0,0 @@
|
|
|
1
|
-
import { ParentComponent, SoperioComponent } from "@soperio/react";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Breadcrumb, QueryBreadcrumbs } from "../breadcrumbs/BreadCrumbs.js";
|
|
4
|
-
export interface PageTopBarProps extends SoperioComponent, ParentComponent {
|
|
5
|
-
title?: string;
|
|
6
|
-
breadcrumbs?: Breadcrumb[] | QueryBreadcrumbs;
|
|
7
|
-
}
|
|
8
|
-
export declare function PageTopBar({ title, breadcrumbs, children, ...props }: PageTopBarProps): JSX.Element;
|
|
9
|
-
export declare function PageTabbedTopBarProvider({ children }: ParentComponent): JSX.Element;
|
|
10
|
-
export declare function PageTabbedTopBar({ title, breadcrumbs, children, ...props }: PageTopBarProps): JSX.Element;
|
|
11
|
-
export declare function PageTopBarToolbar({ trackingRef, children }: {
|
|
12
|
-
trackingRef?: Element | null;
|
|
13
|
-
} & ParentComponent): React.ReactPortal | null;
|
|
@@ -1,78 +0,0 @@
|
|
|
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.js";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { createPortal } from "react-dom";
|
|
6
|
-
import { FlexCenter } from "@compill/components";
|
|
7
|
-
import { Breadcrumbs } from "../breadcrumbs/BreadCrumbs.js";
|
|
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,21 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// import { mdiViewColumn } from "@mdi/js";
|
|
2
|
-
// import { useTableContainerContext } from "./TableContainerContext.js";
|
|
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,10 +0,0 @@
|
|
|
1
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
-
import { TileProps } from "@valerya/ui";
|
|
3
|
-
interface TableContainerProps extends TileProps {
|
|
4
|
-
filtersMethod?: "internal" | "nextRouter" | "reactRouter";
|
|
5
|
-
initialPageSize?: number;
|
|
6
|
-
columns?: ColumnDef<any>[];
|
|
7
|
-
initialVisibleColumns?: string[];
|
|
8
|
-
}
|
|
9
|
-
export declare function TableContainer({ initialPageSize, initialVisibleColumns, columns, filtersMethod, children, ...props }: TableContainerProps): JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
2
|
-
import { TableContextProvider } from "@compill/table";
|
|
3
|
-
import { TableContainerContextProvider } from "./TableContainerContext.js";
|
|
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
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
3
|
-
type TableContainerContextProps = {
|
|
4
|
-
showFilters?: boolean;
|
|
5
|
-
setShowFilters: (show: boolean) => void;
|
|
6
|
-
showMassActions?: boolean;
|
|
7
|
-
setShowMassActions: (show: boolean) => void;
|
|
8
|
-
columns: ColumnDef<any, any>[];
|
|
9
|
-
filteredColumns: ColumnDef<any, any>[];
|
|
10
|
-
toggleColumnVisibility: (id: string) => void;
|
|
11
|
-
isColumnVisible: (id: string) => boolean;
|
|
12
|
-
};
|
|
13
|
-
declare const useContext: () => TableContainerContextProps;
|
|
14
|
-
declare function TableContainerContextProvider({ initialVisibleColumns, columns, children }: {
|
|
15
|
-
initialVisibleColumns?: string[];
|
|
16
|
-
columns?: ColumnDef<any, any>[];
|
|
17
|
-
} & React.PropsWithChildren): JSX.Element;
|
|
18
|
-
export { TableContainerContextProvider, useContext as useTableContainerContext };
|
|
@@ -1,40 +0,0 @@
|
|
|
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,7 +0,0 @@
|
|
|
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.js";
|
|
5
|
-
export function TableCreateButton({ icon, children, ...props }) {
|
|
6
|
-
return (_jsxs(ButtonBarDialogButton, { ...props, children: [_jsx(Icon, { path: icon ?? mdiPlusThick }), children] }));
|
|
7
|
-
}
|