@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
@@ -0,0 +1,77 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { useApiMutation, useApiQuery, useInvalidateParentMutation } from "@compill/api";
3
+ import { ModalLoadingOverlay, QueryLoadingState, RetryOnError } from "@compill/components";
4
+ import { FormRenderer } from "@compill/form";
5
+ import { isFunction } from "@soperio/react";
6
+ import { Button, Modal } from "@valerya/ui";
7
+ import { Form, Formik } from "formik";
8
+ import React from "react";
9
+ import { toast } from "react-toastify";
10
+ const defaultErrorMsg = "Oops, something went wrong...";
11
+ function nonNullValues(data) {
12
+ if (data) {
13
+ const nonNullData = { ...data };
14
+ for (const key in data)
15
+ nonNullData[key] = nonNullData[key] ?? "";
16
+ return nonNullData;
17
+ }
18
+ return data;
19
+ }
20
+ export function ItemEditDialog({ initialValues, itemLabel, queryId = "", api, queryFetchOptions, querySaveOptions, onSuccess, onFetchError, fetchErrorMsg = defaultErrorMsg, onSaveError, saveErrorMsg = defaultErrorMsg, fetchToFormData, formToQueryData, invalidateQueriesOnSuccess = true, invalidateQueryKey, retryText = "Retry", cancelLabel = "Cancel", saveLabel, size = "lg", title, form, show, onClose, formikProps, ...props }) {
21
+ const { isInitialLoading, isFetching, data, isError, error /*, error*/, refetch } = useApiQuery(api.queryKey, api.get, queryId, {
22
+ enabled: !( /*queryId == 0 || */queryId == "" || queryId == null || queryId == undefined), // means than this query is only enabled if the id is defined
23
+ onError: onFetchError,
24
+ ...queryFetchOptions
25
+ });
26
+ // const [activeTab, setActiveTab] = React.useState(form && Array.isArray(form) ? form[0].key : "");
27
+ // const [showTab, setShowTab] = React.useState(true);
28
+ const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(api.upsert, invalidateQueryKey ?? api.queryKey, querySaveOptions)
29
+ : useApiMutation(api.upsert, api.queryKey, queryId, querySaveOptions);
30
+ const retry = React.useCallback(() => refetch(), [refetch]);
31
+ const saveItem = React.useCallback(async (item, actions) => {
32
+ // Clear mutation error if any
33
+ mutation.reset();
34
+ const formItem = formToQueryData ? formToQueryData(item) : { ...item };
35
+ await mutation.mutateAsync(formItem)
36
+ .then((response) => {
37
+ if (onSuccess)
38
+ onSuccess(formItem, response);
39
+ else
40
+ toast.success(`${title ? title(formItem) : formItem.name ?? formItem.title} ${queryId ? "saved" : "created"}`);
41
+ // closing delete modal
42
+ onClose?.();
43
+ })
44
+ .catch(error => {
45
+ console.error("on error", error);
46
+ if (onSaveError)
47
+ onSaveError(item);
48
+ else
49
+ toast.error(`Couldn't save ${title ? title(formItem) : formItem.name ?? formItem.title}`);
50
+ actions.setSubmitting(false);
51
+ });
52
+ }, [mutation, formToQueryData, onSuccess, onSaveError, onClose]);
53
+ // const switchTab = React.useCallback((tab: string) =>
54
+ // {
55
+ // setActiveTab(tab);
56
+ // setShowTab(false);
57
+ // setTimeout(function ()
58
+ // {
59
+ // setActiveTab(tab);
60
+ // setShowTab(true);
61
+ // }, 150);
62
+ // }, [setActiveTab])
63
+ return (_jsxs(Modal, { size: size, show: show, onClose: onClose, scheme: "light", transition: true, ...props, children: [_jsxs(Modal.Header, { children: [!isInitialLoading && queryId && `Edit ${title ? title(data) : data?.["name"] ?? data?.["title"] ?? data?.["name"] ?? ""}`, !queryId && `Create new ${itemLabel ?? "item"}`, Array.isArray(form) && (_jsx(_Fragment, {})
64
+ // <ul className="nav nav-bold nav-pills">
65
+ // {form.map(item =>
66
+ // <li key={item.key} className="nav-item cursor-pointer bg-hover-light rounded" onClick={() => switchTab(item.key)}>
67
+ // <span className={clsx("nav-link", activeTab === item.key && "active")} data-toggle="tab">{item.label}</span>
68
+ // </li>
69
+ // )}
70
+ // </ul>
71
+ )] }), isInitialLoading && (_jsx(Modal.Body, { children: _jsx(QueryLoadingState, { minW: "72" }) })), isError && (_jsx(Modal.Body, { children: _jsx(RetryOnError, { label: `${fetchErrorMsg} ${error}`, onClick: retry }) })), !isInitialLoading && !isError &&
72
+ (_jsx(_Fragment, { children: _jsx(Formik
73
+ // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
74
+ , {
75
+ // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
76
+ initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(initialValues(data)) ?? {}, onSubmit: saveItem, ...formikProps, children: ({ setFieldValue, dirty, handleSubmit, isValid, values }) => (_jsxs(_Fragment, { children: [_jsx(Modal.Body, { pb: "6", children: _jsxs(Form, { children: [React.isValidElement(form) && form, Array.isArray(form) && _jsx(FormRenderer, { form: form }), isFunction(form) && _jsx(FormRenderer, { form: form(data ?? values) })] }) }), _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: !dirty || mutation.isLoading /* || !isValid*/, onClick: () => handleSubmit(), children: saveLabel ? saveLabel : (queryId ? "Update" : "Create") })] })] })) }) })), mutation.isLoading && _jsx(ModalLoadingOverlay, {})] }));
77
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { MultiQueryWrapperDialogConfig } from "../types/MultiQueryWrapperDialog";
3
2
  export type MultiQueryWrapperDialogProps = Omit<MultiQueryWrapperDialogConfig, "type"> & {
4
3
  queryId?: string;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { useApiQueries } from "@compill/api";
3
+ import React from "react";
4
+ import { ItemEditDialog } from "./ItemEditDialog";
5
+ export function MultiQueryWrapperDialog({ queries, config, onClose, queryId, invalidateQueryKey }) {
6
+ const { data, isFetching, isError } = useApiQueries(queries.map(q => ({
7
+ queryKey: q.api.queryKey,
8
+ queryFn: q.fn == "get" ? q.api.get : q.api.getAll,
9
+ queryOptions: {
10
+ cacheTime: q.cache === false ? 0 : undefined,
11
+ staleTime: q.cache === false ? 0 : undefined
12
+ }
13
+ })));
14
+ const transformedData = React.useMemo(() => {
15
+ return data?.map((d, index) => queries[index]?.transformFn ? queries[index]?.transformFn?.(d) : d);
16
+ }, [data, queries]);
17
+ // TODO This is not really good
18
+ // So instead, add a isPreloading and isPreloadingError to ItemEditDialog to handle the cases
19
+ // if (isFetching)
20
+ // return null
21
+ // @ts-ignore
22
+ return _jsx(ItemEditDialog, { isPreloading: isFetching, ...config(...transformedData), queryId: queryId, invalidateQueryKey: invalidateQueryKey, show: true, onClose: onClose });
23
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CRUDAPI, CRUD_MODEL } from "@compill/api";
3
2
  import { QueryWrapperDialogConfig } from "../types/QueryWrapperDialog";
4
3
  import { EditItemDialogConfig } from "../types/EditItemDialog";
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { useApiQuery } from "@compill/api";
3
+ import React from "react";
4
+ import { ItemEditDialog } from "./ItemEditDialog";
5
+ export function QueryWrapperDialog({ api, fn, transformFn, config, onClose, queryId, invalidateQueryKey }) {
6
+ const { data, isFetching } = useApiQuery(api.queryKey, fn === "get" || fn === "getTransformed" ? api.get : api.getAll, undefined, { retryOnMount: false, refetchOnMount: false, refetchOnWindowFocus: false });
7
+ const transformedData = React.useMemo(() => {
8
+ if (data && (fn === "getTransformed" || fn === "getAllTransformed")) {
9
+ if (!transformFn)
10
+ console.warn(`QueryWrapperDialog: you forgot to pass transformFn as parameter for fn ${fn}`);
11
+ // @ts-ignore
12
+ return transformFn?.(data);
13
+ }
14
+ return data;
15
+ }, [data, fn, transformFn]);
16
+ if (isFetching)
17
+ return null;
18
+ // @ts-ignore
19
+ return _jsx(ItemEditDialog, { ...config(transformedData), queryId: queryId, invalidateQueryKey: invalidateQueryKey, show: true, onClose: onClose });
20
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare function RefreshButton({ queryKey }: {
3
2
  queryKey: string[];
4
3
  }): JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { useInvalidateQuery } from "@compill/api";
3
+ import { mdiRefresh } from "@mdi/js";
4
+ import { Icon } from "@valerya/ui";
5
+ import { ButtonBarButton } from "../../layout/ButtonBar";
6
+ import { useHotkeys } from "react-hotkeys-hook";
7
+ export function RefreshButton({ queryKey }) {
8
+ const invalidate = useInvalidateQuery(queryKey);
9
+ useHotkeys('ctrl+r', () => invalidate(), { preventDefault: true }, [invalidate]);
10
+ return (_jsx(ButtonBarButton, { scheme: "dark", size: "sm", aspectRatio: "square", variant: "borderless", onClick: invalidate, children: _jsx(Icon, { path: mdiRefresh }) }));
11
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { TableRowAction } from "../types/TableView";
3
2
  import { API } from "@compill/admin-api";
4
3
  interface TableRowActionViewProps {
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { mdiDelete, mdiEye, mdiOpenInNew, mdiPencil } from "@mdi/js";
3
+ import { Icon } from "@valerya/ui";
4
+ import { TableRowPublishPostButton } from "./TableRowPublishPostButton";
5
+ import React from "react";
6
+ import { TableRowActionButton } from "@compill/admin";
7
+ import { runIfFn } from "@soperio/react";
8
+ export function TableRowActionsView({ row, onAction, rowActions, api, queryKey }) {
9
+ const item = row.original;
10
+ return (_jsx("div", { dflex: true, w: "full", alignItems: "stretch", placeContent: "end", h: "full", children: runIfFn(rowActions, item)?.map((action, index) => (_jsxs(React.Fragment, { children: [action.type === "publish" && _jsx(TableRowPublishPostButton, { id: item.id, api: action.api ?? api, status: item.status, invalidateQueryKey: queryKey }), action.type == "custom" && _jsx(_Fragment, { children: action.component(item, queryKey, action.icon, action.label) }), !["publish", "custom"].includes(action.type) &&
11
+ (_jsx(ActionButton, { onClick: () => onAction(action, item), scheme: schemes[action.type], children: _jsx(Icon, { path: icons[action.type], size: "sm" }) }))] }, index))) }));
12
+ }
13
+ function ActionButton({ onClick, ...props }) {
14
+ const handleClick = React.useCallback((event) => {
15
+ event?.preventDefault();
16
+ event?.stopPropagation();
17
+ onClick?.(event);
18
+ }, [onClick]);
19
+ return (_jsx(TableRowActionButton, { onClick: handleClick, ...props }));
20
+ }
21
+ const icons = {
22
+ "link": mdiOpenInNew,
23
+ "view": mdiEye,
24
+ "edit": mdiPencil,
25
+ "delete": mdiDelete,
26
+ "publish": mdiDelete,
27
+ "custom": ""
28
+ };
29
+ const schemes = {
30
+ "link": "dark",
31
+ "view": "dark",
32
+ "edit": "dark",
33
+ "delete": "dark",
34
+ "publish": "dark",
35
+ "custom": "dark"
36
+ };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ButtonProps } from "@valerya/ui";
3
2
  import { API } from "@compill/admin-api";
4
3
  export declare function TableRowPublishPostButton({ id, api, status, invalidateQueryKey, ...props }: {
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { Icon } from "@valerya/ui";
3
+ import { mdiPublish, mdiPublishOff } from "@mdi/js";
4
+ import { Button } from "@valerya/ui";
5
+ import React from "react";
6
+ import { useInvalidateParentMutation } from "@compill/api";
7
+ import { toast } from "react-toastify";
8
+ export function TableRowPublishPostButton({ id, api, status, invalidateQueryKey, ...props }) {
9
+ const isDraft = status == "draft";
10
+ const mutation = useInvalidateParentMutation(isDraft ? api.publish : api.unpublish, invalidateQueryKey ?? api.queryKey, { networkMode: "always" });
11
+ const publish = React.useCallback((event) => {
12
+ event?.preventDefault();
13
+ event?.stopPropagation();
14
+ mutation.reset();
15
+ mutation.mutateAsync(id)
16
+ .then(() => toast.success(isDraft ? "Published!" : "Unpublished!"))
17
+ .catch(error => toast.error(`Error: ${error}`));
18
+ }, [mutation, id]);
19
+ return (_jsx(Button, { variant: "borderless", corners: "square", scheme: "dark", onClick: publish, ...props, children: _jsx(Icon, { path: isDraft ? mdiPublish : mdiPublishOff, size: "sm" }) }));
20
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { SoperioComponent } from "@soperio/react";
3
2
  import { TableViewConfig } from "../types/TableView";
4
3
  export declare function TableView({ queryField, title, subtitle, screen, ...props }: Omit<TableViewConfig, "type"> & SoperioComponent): JSX.Element;
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@soperio/jsx-runtime";
2
+ import { Table, useTableContext } from "@compill/table";
3
+ import { isFunction, runIfFn } from "@soperio/react";
4
+ import React from "react";
5
+ import { useParams } from "react-router-dom";
6
+ import { InvalidateButton } from "../../buttons/InvalidateButton";
7
+ import { PageContainer } from "../../page/PageContainer";
8
+ import { TableContainer } from "../../table/TableContainer";
9
+ import { TableCreateButton } from "../../table/TableCreateButton";
10
+ import { TableFilterButton } from "../../table/TableFilterButton";
11
+ import { TableTopBar } from "../../table/TableTopBar";
12
+ import { ButtonBar } from "../../layout/ButtonBar";
13
+ import { TableFilters } from "../../table/TableFilters";
14
+ import { TableMassActions } from "../../table/TableMassActions";
15
+ import { DialogRenderer } from "../dialog/DialogRenderer";
16
+ import { RefreshButton } from "./RefreshButton";
17
+ import { TableViewProvider, useTableViewContext } from "./TableViewContext";
18
+ import { useTableProps } from "./useTableProps";
19
+ function useId(queryField) {
20
+ const params = useParams();
21
+ if (queryField === undefined)
22
+ return undefined;
23
+ const { [queryField]: id } = params;
24
+ return id;
25
+ }
26
+ export function TableView({ queryField, title, subtitle, screen, ...props }) {
27
+ const id = useId(queryField);
28
+ const _screen = runIfFn(screen, id);
29
+ return (_jsx(PageContainer, { bgColor: "white", ...props, children: _jsx(TableContainer, { columns: _screen.table.columns, initialVisibleColumns: _screen.table.initialVisibleColumns, filtersMethod: _screen.table.filtersMethod, children: _jsx(TT, { id: id, title: title, subtitle: subtitle, screen: _screen }) }) }));
30
+ }
31
+ function TT({ id, title, subtitle, screen }) {
32
+ const { setRowSelection } = useTableContext();
33
+ const { api, table, filters, massActions, buttonBar, rowActions, createView, editView, deleteItem, breadcrumbs } = screen;
34
+ const tableApi = runIfFn(api, id ?? "");
35
+ return (_jsxs(_Fragment, { children: [_jsx(TableTopBar, { title: title, breadcrumbs: breadcrumbs, children: _jsx(TableButtonBar, { buttonBar: buttonBar, createView: createView, editView: editView, api: tableApi, queryKey: tableApi.queryKey, children: filters && _jsx(TableFilterButton, {}) }) }), filters &&
36
+ (_jsx(TableFilters, { form: filters.form, initialValues: filters.initialValues, schema: filters.schema, processInput: filters.processInput })), massActions && _jsx(TableMassActions, { actions: massActions.items }), _jsxs(TableViewProvider, { queryKey: tableApi.queryKey, editView: editView, deleteItem: deleteItem, children: [_jsx(TableWrapper, { table: { ...table, onSelectionChange: setRowSelection }, rowActions: rowActions, api: tableApi, subtitle: subtitle, queryParams: screen.queryParams }), _jsx(TableDialogManager, {})] })] }));
37
+ }
38
+ function TableButtonBar({ buttonBar, queryKey, createView, editView, api, children }) {
39
+ const createDialogFn = React.useCallback((data) => {
40
+ return (onClose) => {
41
+ const view = runIfFn(createView, data) ?? runIfFn(editView, null);
42
+ if (view.type == "customDialog")
43
+ return view.render({ show: true, onClose });
44
+ else
45
+ return _jsx(DialogRenderer, { config: view, onClose: onClose, invalidateQueryKey: api.queryKey });
46
+ };
47
+ }, [createView, editView, api]);
48
+ return (_jsxs(ButtonBar, { children: [_jsx(RefreshButton, { queryKey: queryKey }), buttonBar && buttonBar.map((button, index) => _jsxs(React.Fragment, { children: [button.type === "create" && editView &&
49
+ (_jsx(TableCreateButton, { buildDialog: createDialogFn(button.data), icon: button.icon, children: button.label })), button.type === "invalidate" && _jsx(InvalidateButton, { pathOrPermalink: button.pathOrPermalink }), button.type === "custom" && button.render()] }, index)), children] }));
50
+ }
51
+ function TableWrapper({ table, subtitle, rowActions, api, queryParams }) {
52
+ const tableProps = useTableProps(api, table, rowActions, queryParams);
53
+ const _subtitle = React.useMemo(() => {
54
+ if (!subtitle)
55
+ return undefined;
56
+ return (data) => {
57
+ return (_jsx("div", { textSize: "lg", textColor: "#475569", fontWeight: "600", children: isFunction(subtitle) ? subtitle(data) : subtitle }));
58
+ };
59
+ }, [subtitle]);
60
+ return _jsx(Table, { ...tableProps, p: "8", title: _subtitle });
61
+ }
62
+ function TableDialogManager() {
63
+ const { dialog } = useTableViewContext();
64
+ return dialog;
65
+ }
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { useOpenLink } from "@compill/hooks";
3
+ import { createContext, runIfFn } from "@soperio/react";
4
+ import React from "react";
5
+ import { useNavigate } from "react-router-dom";
6
+ import { DialogRenderer } from "../dialog/DialogRenderer";
7
+ import { ItemDeleteDialog } from "../dialog/ItemDeleteDialog";
8
+ import { AppEnv } from "@compill/env";
9
+ const [provider, useContext] = createContext();
10
+ function TableViewProvider({ editView, deleteItem, queryKey, children }) {
11
+ const openLink = useOpenLink();
12
+ const navigate = useNavigate();
13
+ const [dialog, setDialog] = React.useState(null);
14
+ const onCloseDialog = React.useCallback(() => setDialog(null), [setDialog]);
15
+ const onAction = React.useCallback((action, item) => {
16
+ switch (action.type) {
17
+ case "view":
18
+ {
19
+ navigate(runIfFn(action.path, item));
20
+ break;
21
+ }
22
+ case "link":
23
+ {
24
+ openLink(`${AppEnv.websiteUrl()}/${runIfFn(action.path, item)}`);
25
+ break;
26
+ }
27
+ case "edit":
28
+ {
29
+ const editConfig = runIfFn(editView, item);
30
+ if (editConfig) {
31
+ if (editConfig.type == "customDialog") {
32
+ setDialog(editConfig.render({ show: true, onClose: onCloseDialog }));
33
+ }
34
+ else {
35
+ setDialog(_jsx(DialogRenderer, { onClose: onCloseDialog, config: editConfig, queryId: item.id, invalidateQueryKey: queryKey }));
36
+ }
37
+ }
38
+ break;
39
+ }
40
+ case "delete":
41
+ {
42
+ const deleteConfig = runIfFn(deleteItem, item);
43
+ setDialog(_jsx(ItemDeleteDialog, { show: true, onClose: onCloseDialog, queryId: item.id, invalidateQueryKey: queryKey, msg: item.msg, ...deleteConfig, itemLabel: runIfFn(deleteConfig.itemLabel, item) }));
44
+ // TODO
45
+ // const { initialValues, ...props } = editItem!!
46
+ // setDialog(<ItemEditDialog {...props} initialValues={runIfFn(initialValues, item)} show queryId={item?.id} onClose={onCloseDialog} />)
47
+ break;
48
+ }
49
+ }
50
+ }, [navigate, editView, deleteItem]);
51
+ const Provider = provider;
52
+ const value = {
53
+ dialog,
54
+ onAction
55
+ };
56
+ return _jsx(Provider, { value: value, children: children });
57
+ }
58
+ export { TableViewProvider, useContext as useTableViewContext };
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { useOpenLink } from "@compill/hooks";
3
+ import { runIfFn } from "@soperio/react";
4
+ import { createColumnHelper } from "@tanstack/react-table";
5
+ import React from "react";
6
+ import { useNavigate } from "react-router-dom";
7
+ import { TableRowActionsView } from "./TableRowActionsView";
8
+ import { useTableViewContext } from "./TableViewContext";
9
+ import { useRouter } from "next/router";
10
+ import { AppEnv } from "@compill/env";
11
+ export function useTableProps(api, table, rowActions, queryParams) {
12
+ const navigate = useNavigate();
13
+ const nextRouter = useRouter();
14
+ const openLink = useOpenLink();
15
+ const { onAction } = useTableViewContext();
16
+ const { onRowClick, columns: c, ...props } = table;
17
+ const onRowClickHandler = React.useCallback((item) => {
18
+ const config = runIfFn(onRowClick, item);
19
+ if (config) {
20
+ switch (config.type) {
21
+ case "navigate":
22
+ {
23
+ navigate(runIfFn(config.path, item) ?? "");
24
+ break;
25
+ }
26
+ case "nextpush":
27
+ {
28
+ nextRouter.push(runIfFn(config.path, item));
29
+ break;
30
+ }
31
+ case "link":
32
+ {
33
+ openLink(`${AppEnv.websiteUrl()}/${runIfFn(config.path, item)}`);
34
+ break;
35
+ }
36
+ }
37
+ }
38
+ }, [navigate, onRowClick]);
39
+ const columns = React.useMemo(() => {
40
+ const columns = table.columns.concat([]);
41
+ if (rowActions) {
42
+ columns.push(createColumnHelper().display({
43
+ id: "actions",
44
+ header: "Actions",
45
+ cell: props => _jsx(TableRowActionsView, { row: props.row, onAction: onAction, rowActions: rowActions, api: api, queryKey: api.queryKey })
46
+ }));
47
+ }
48
+ return columns;
49
+ }, [table, onAction, rowActions, api]);
50
+ const tableProps = { ...props };
51
+ tableProps.columns = columns;
52
+ tableProps.onRowClick = onRowClickHandler;
53
+ tableProps.queryKey = api.queryKey;
54
+ tableProps.queryFilters = queryParams;
55
+ tableProps.queryFn = api.search;
56
+ return tableProps;
57
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { API } from "@compill/admin-api";
3
2
  import * as Yup from "yup";
4
3
  import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CRUDAPI } from "@compill/api";
3
2
  import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs";
4
3
  import { DetailsViewConfig } from "./DetailsView";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { API } from "@compill/admin-api";
3
2
  import { FormRendererConfig } from "@compill/form";
4
3
  import { TableProps } from "@compill/table";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Color, ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  import { MenuConfig } from "./menu/MenuConfig";
4
3
  interface LayoutProps extends SoperioComponent, ParentComponent {
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { useBoolean } from "@compill/hooks";
3
+ import { mdiArrowLeft } from "@mdi/js";
4
+ import { IconButton } from "@valerya/ui";
5
+ import { useHotkeys } from "react-hotkeys-hook";
6
+ import Content from "./Content";
7
+ import { Sidebar } from "./Sidebar";
8
+ export function AdminLayout({ color, darkMode, logo, title, menuConfig, userMenuConfig, userSettingsPath, ...props }) {
9
+ return (_jsxs("div", { w: "full", h: "screen", dflex: true, flexRow: true, bgColor: `${color}-${darkMode ? "900" : "100"}`, ...props, children: [_jsx(LeftPanel, { color: color, darkMode: darkMode, logo: logo, title: title, menuConfig: menuConfig, userMenuConfig: userMenuConfig, userSettingsPath: userSettingsPath }), _jsx("div", { w: "screen", py: "2", pe: "2", children: _jsx(Content, { bgColor: "white", rounded: "lg", shadow: true }) })] }));
10
+ }
11
+ function LeftPanel({ color, darkMode, logo, title, menuConfig, userMenuConfig, userSettingsPath }) {
12
+ const [isOpen, __, toggle] = useBoolean(true);
13
+ useHotkeys('ctrl+t', () => toggle(), [toggle]);
14
+ return (_jsxs("div", { ms: isOpen ? "0" : "-14.5rem", transition: "all", duration: "500", transform: true, children: [_jsx(Sidebar, { flexShrink: "0", color: color, darkMode: darkMode, logo: logo, title: title, menuConfig: menuConfig, userMenuConfig: userMenuConfig, userSettingsPath: userSettingsPath }), _jsx(IconButton, { icon: mdiArrowLeft, transition: "all", duration: "500", transform: true, rotate: isOpen ? "0" : "180", position: "absolute", bottom: "14", end: "-5", size: "lg", corners: "pill", onClick: toggle, z: "100" })] }));
15
+ }
@@ -7,7 +7,7 @@ export type ButtonBarButtonProps = {
7
7
  icon?: string;
8
8
  } & ButtonProps;
9
9
  export declare const ButtonBarButton: React.ForwardRefExoticComponent<{
10
- icon?: string | undefined;
10
+ icon?: string;
11
11
  } & ButtonProps & React.RefAttributes<HTMLDivElement>>;
12
12
  export interface ButtonBarSubmitButtonProps extends ButtonBarButtonProps {
13
13
  useDirty?: boolean;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { DialogButton } from "../buttons/DialogButton";
3
+ import { Button, Icon } from "@valerya/ui";
4
+ import { useFormikContext } from "formik";
5
+ import React from "react";
6
+ export function ButtonBar({ children, ...props }) {
7
+ return (_jsx("div", { dflex: true, border: "1px", borderColor: "zinc-200", divideX: "1px", divideColor: "zinc-200", rounded: "lg", overflow: "hidden", ...props, children: children }));
8
+ }
9
+ export const ButtonBarButton = React.forwardRef(function ({ icon, children, ...props }, ref) {
10
+ return (_jsxs(Button, { scheme: "dark", size: "sm", aspectRatio: icon && !children ? "square" : undefined, variant: "borderless", dflex: true, alignItems: "center", placeContent: "center", corners: "square", gap: "2", ...props, ref: ref, children: [icon && _jsx(Icon, { path: icon }), children] }));
11
+ });
12
+ export const ButtonBarSubmitButton = React.forwardRef(function ({ useDirty, disabled, icon, children, ...props }, ref) {
13
+ const { dirty, handleSubmit } = useFormikContext() ?? { dirty: false, handleSubmit: undefined, values: {} };
14
+ const onSubmit = React.useCallback(() => handleSubmit(), [handleSubmit]);
15
+ return (_jsxs(Button, { scheme: "dark", size: "sm", aspectRatio: icon && !children ? "square" : undefined, variant: "borderless", dflex: true, alignItems: "center", placeContent: "center", corners: "square", gap: "2", disabled: (useDirty && !dirty) || disabled, onClick: onSubmit, ...props, ref: ref, children: [icon && _jsx(Icon, { path: icon }), children] }));
16
+ });
17
+ export function ButtonBarDialogButton({ icon, children, ...props }) {
18
+ return (_jsxs(DialogButton, { scheme: "dark", size: "sm", aspectRatio: icon && !children ? "square" : undefined, variant: "borderless", dflex: true, alignItems: "center", placeContent: "center", corners: "square", gap: "2", ...props, children: [icon && _jsx(Icon, { path: icon }), children] }));
19
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { SoperioComponent, ParentComponent } from "@soperio/react";
3
2
  interface ContentProps extends SoperioComponent, ParentComponent {
4
3
  }
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { Outlet } from "react-router-dom";
3
+ /**
4
+ *
5
+ *
6
+ */
7
+ export default function Content({ ...props }) {
8
+ return (_jsx("div", { w: "100%", h: "100%", overflowY: "auto", ...props, children: _jsx(Outlet, {}) }));
9
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  interface TableTopBarProps extends SoperioComponent, ParentComponent {
4
3
  title?: string;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ export function PageTitleBar({ title, children, ...props }) {
3
+ return (_jsxs("div", { dflex: true, flexRow: true, alignItems: "center", gap: "3", p: "8", ...props, children: [title && _jsx("h2", { textSize: "x2", fontWeight: "600", textColor: "#3f4254", textTransform: "capitalize", children: title }), _jsx("div", { flexGrow: true, children: "\u00A0" }), children] }));
4
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Color, ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  import { MenuConfig } from "./menu/MenuConfig";
4
3
  interface SidebarProps extends SoperioComponent, ParentComponent {
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { FlexCenter } from "@compill/components";
3
+ import { Menu } from "./menu/Menu";
4
+ import { AppEnv } from "@compill/env";
5
+ import Image from "next/image";
6
+ import { UserBlock } from "./menu/UserBlock";
7
+ export function Sidebar({ show, logo, title, menuConfig, userMenuConfig, userSettingsPath, color, darkMode, ...props }) {
8
+ return (_jsxs("div", { dflex: true, flexCol: true, w: "full", md_w: "64", minH: "screen", p: "0", textColor: darkMode ? "white" : "slate-800", ...props, children: [_jsxs(FlexCenter, { placeContent: "start", p: "4", font: "title", gap: "3", borderB: "px", borderBColor: "slate-900", borderOpacity: "5", children: [logo ?? _jsx(Logo, { width: 40, height: 40, darkMode: darkMode }), _jsx("h1", { textSize: "md", children: title || AppEnv.appName() })] }), _jsx(Menu, { overflowY: "auto", flexGrow: "1", p: "4", darkMode: darkMode, config: menuConfig }), _jsx("div", { p: "2", children: _jsx(UserBlock, { darkMode: darkMode, color: color, menuConfig: userMenuConfig, path: userSettingsPath }) })] }));
9
+ }
10
+ export default function Logo({ width, height, darkMode, ...props }) {
11
+ return (_jsx("div", { ...props, children: _jsx(Image, { src: `/logo_${darkMode ? "light" : "dark"}.png`, alt: AppEnv.appName() || "", width: width, height: height, priority: true, unoptimized: true }) }));
12
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ParentComponent, SoperioComponent } from "@soperio/react";
3
2
  import { MenuConfig } from "./MenuConfig";
4
3
  export interface MenuProps extends SoperioComponent, ParentComponent {
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "@soperio/jsx-runtime";
2
+ import { MenuItem } from "./MenuItem";
3
+ import { NextMenuItem } from "./NextMenuItem";
4
+ /**
5
+ *
6
+ *
7
+ */
8
+ export function Menu({ darkMode, config, useNextRouter, ...props }) {
9
+ const Comp = useNextRouter ? NextMenuItem : MenuItem;
10
+ return (_jsx("ul", { ...props, children: config.map((item, index) => {
11
+ if (item.type == "divider")
12
+ return _jsx(Divider, { title: item.label }, index);
13
+ if (item.type == "item") {
14
+ return (_jsx(Comp, { icon: item.icon, path: item.path, depth: 0, darkMode: darkMode, subMenu: item.children, children: item.label }, index));
15
+ }
16
+ }) }));
17
+ }
18
+ function Divider({ title }) {
19
+ return (_jsx("div", { px: "2", mt: "5", mb: "2", opacity: "75", textTransform: "capitalize", letterSpacing: "widest", fontWeight: "700", textSize: "xs", children: title }));
20
+ }
21
+ function CategoryItem({ children, ...props }) {
22
+ return (_jsx("li", { ps: "5", py: "2", mt: "5", textSize: "sm", textColor: "white", textOpacity: "80", fontWeight: "600", textTransform: "uppercase", children: children }));
23
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ButtonProps } from "@valerya/ui";
3
2
  export declare function MenuButton({ depth, darkMode, icon, selected, children, ...props }: {
4
3
  depth?: number;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
2
+ import { Button, Icon } from "@valerya/ui";
3
+ export function MenuButton({ depth, darkMode, icon, selected, children, ...props }) {
4
+ return (_jsxs(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: true, alignItems: "center", gap: "3", ...props, children: [icon && _jsx(Icon, { path: icon, opacity: selected ? "100" : "60" }), children] }));
5
+ }
@@ -0,0 +1 @@
1
+ export {};