@compill/admin 1.0.101 → 1.0.102
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.js +50 -0
- package/{src → dist}/lib/SectionTitle.d.ts +0 -1
- package/dist/lib/SectionTitle.jsx +3 -0
- package/{src → dist}/lib/breadcrumbs/BreadCrumbs.d.ts +0 -1
- package/dist/lib/breadcrumbs/BreadCrumbs.jsx +43 -0
- package/dist/lib/buttons/DialogButton.jsx +17 -0
- package/{src → dist}/lib/buttons/InvalidateButton.d.ts +0 -1
- package/dist/lib/buttons/InvalidateButton.jsx +10 -0
- package/{src → dist}/lib/buttons/NavigateButton.d.ts +0 -1
- package/dist/lib/buttons/NavigateButton.jsx +13 -0
- package/{src → dist}/lib/buttons/PublishButton.d.ts +0 -1
- package/dist/lib/buttons/PublishButton.jsx +18 -0
- package/{src → dist}/lib/buttons/UpdateButton.d.ts +0 -1
- package/dist/lib/buttons/UpdateButton.jsx +12 -0
- package/{src → dist}/lib/buttons/ViewButton.d.ts +1 -2
- package/dist/lib/buttons/ViewButton.jsx +14 -0
- package/{src → dist}/lib/cells/OrderCell.d.ts +0 -1
- package/dist/lib/cells/OrderCell.jsx +35 -0
- package/{src → dist}/lib/json/DetailsView.d.ts +0 -1
- package/dist/lib/json/DetailsView.jsx +96 -0
- package/{src → dist}/lib/json/EditItemView.d.ts +0 -1
- package/dist/lib/json/EditItemView.jsx +5 -0
- package/{src → dist}/lib/json/MultiQueryWrapper.d.ts +0 -1
- package/dist/lib/json/MultiQueryWrapper.jsx +60 -0
- package/{src → dist}/lib/json/QueryWrapper.d.ts +0 -1
- package/dist/lib/json/QueryWrapper.jsx +28 -0
- package/{src → dist}/lib/json/ScreenRenderer.d.ts +0 -1
- package/dist/lib/json/ScreenRenderer.jsx +18 -0
- package/{src → dist}/lib/json/ScreenTopBar.d.ts +0 -1
- package/dist/lib/json/ScreenTopBar.jsx +39 -0
- package/{src → dist}/lib/json/TabbedView.d.ts +0 -1
- package/dist/lib/json/TabbedView.jsx +28 -0
- package/{src → dist}/lib/json/buttons/ActionButton.d.ts +0 -1
- package/dist/lib/json/buttons/ActionButton.jsx +13 -0
- package/{src → dist}/lib/json/buttons/ConfirmationActionButton.d.ts +0 -1
- package/dist/lib/json/buttons/ConfirmationActionButton.jsx +37 -0
- package/{src → dist}/lib/json/dialog/DialogRenderer.d.ts +0 -1
- package/dist/lib/json/dialog/DialogRenderer.jsx +13 -0
- package/dist/lib/json/dialog/ItemDeleteDialog.jsx +36 -0
- package/dist/lib/json/dialog/ItemEditDialog.jsx +124 -0
- package/{src → dist}/lib/json/dialog/MultiQueryWrapperDialog.d.ts +0 -1
- package/dist/lib/json/dialog/MultiQueryWrapperDialog.jsx +22 -0
- package/{src → dist}/lib/json/dialog/QueryWrapperDialog.d.ts +0 -1
- package/dist/lib/json/dialog/QueryWrapperDialog.jsx +19 -0
- package/{src → dist}/lib/json/table/RefreshButton.d.ts +0 -1
- package/dist/lib/json/table/RefreshButton.jsx +12 -0
- package/{src → dist}/lib/json/table/TableRowActionsView.d.ts +0 -1
- package/dist/lib/json/table/TableRowActionsView.jsx +45 -0
- package/{src → dist}/lib/json/table/TableRowPublishPostButton.d.ts +0 -1
- package/dist/lib/json/table/TableRowPublishPostButton.jsx +21 -0
- package/{src → dist}/lib/json/table/TableView.d.ts +0 -1
- package/dist/lib/json/table/TableView.jsx +100 -0
- package/dist/lib/json/table/TableViewContext.jsx +57 -0
- package/dist/lib/json/table/useTableProps.jsx +56 -0
- package/{src → dist}/lib/json/types/DetailsView.d.ts +0 -1
- package/dist/lib/json/types/DetailsView.js +1 -0
- package/dist/lib/json/types/EditItemDialog.js +1 -0
- package/dist/lib/json/types/MultiQueryWrapper.js +1 -0
- package/dist/lib/json/types/MultiQueryWrapperDialog.js +1 -0
- package/dist/lib/json/types/QueryWrapper.js +1 -0
- package/dist/lib/json/types/QueryWrapperDialog.js +1 -0
- package/dist/lib/json/types/ScreenConfig.js +1 -0
- package/{src → dist}/lib/json/types/TabbedView.d.ts +0 -1
- package/dist/lib/json/types/TabbedView.js +1 -0
- package/{src → dist}/lib/json/types/TableView.d.ts +0 -1
- package/dist/lib/json/types/TableView.js +1 -0
- package/{src → dist}/lib/layout/AdminLayout.d.ts +0 -1
- package/dist/lib/layout/AdminLayout.jsx +24 -0
- package/{src → dist}/lib/layout/ButtonBar.d.ts +1 -1
- package/dist/lib/layout/ButtonBar.jsx +29 -0
- package/{src → dist}/lib/layout/Content.d.ts +0 -1
- package/dist/lib/layout/Content.jsx +10 -0
- package/{src → dist}/lib/layout/PageTitleBar.d.ts +0 -1
- package/dist/lib/layout/PageTitleBar.jsx +12 -0
- package/{src → dist}/lib/layout/Sidebar.d.ts +0 -1
- package/dist/lib/layout/Sidebar.jsx +24 -0
- package/{src → dist}/lib/layout/menu/Menu.d.ts +0 -1
- package/dist/lib/layout/menu/Menu.jsx +30 -0
- package/{src → dist}/lib/layout/menu/MenuButton.d.ts +0 -1
- package/dist/lib/layout/menu/MenuButton.jsx +7 -0
- package/dist/lib/layout/menu/MenuConfig.js +1 -0
- package/{src → dist}/lib/layout/menu/MenuItem.d.ts +0 -1
- package/dist/lib/layout/menu/MenuItem.jsx +20 -0
- package/{src → dist}/lib/layout/menu/NextMenuItem.d.ts +0 -1
- package/dist/lib/layout/menu/NextMenuItem.jsx +20 -0
- package/{src → dist}/lib/layout/menu/SelectedIndicator.d.ts +0 -1
- package/dist/lib/layout/menu/SelectedIndicator.jsx +3 -0
- package/{src → dist}/lib/layout/menu/UserBlock.d.ts +1 -2
- package/dist/lib/layout/menu/UserBlock.jsx +55 -0
- package/{src → dist}/lib/modal/AttachDialog.d.ts +0 -1
- package/dist/lib/modal/AttachDialog.jsx +109 -0
- package/dist/lib/modal/FormActionDialog.jsx +46 -0
- package/{src → dist}/lib/page/PageContainer.d.ts +0 -1
- package/dist/lib/page/PageContainer.jsx +4 -0
- package/{src → dist}/lib/page/PageContentEditor.d.ts +0 -1
- package/dist/lib/page/PageContentEditor.jsx +11 -0
- package/{src → dist}/lib/page/PageMain.d.ts +0 -1
- package/dist/lib/page/PageMain.jsx +4 -0
- package/dist/lib/page/PageQueryStateContainer.jsx +15 -0
- package/{src → dist}/lib/page/PageSectionTitle.d.ts +0 -1
- package/dist/lib/page/PageSectionTitle.jsx +3 -0
- package/{src → dist}/lib/page/PageSidebar.d.ts +0 -1
- package/dist/lib/page/PageSidebar.jsx +3 -0
- package/{src → dist}/lib/page/PageSidebarSection.d.ts +0 -1
- package/dist/lib/page/PageSidebarSection.jsx +7 -0
- package/dist/lib/page/PageStateContainer.jsx +9 -0
- package/{src → dist}/lib/page/PageSubSectionTitle.d.ts +0 -1
- package/dist/lib/page/PageSubSectionTitle.jsx +3 -0
- package/{src → dist}/lib/page/PageTitle.d.ts +0 -1
- package/dist/lib/page/PageTitle.jsx +3 -0
- package/dist/lib/page/PageTopBar.jsx +92 -0
- package/{src → dist}/lib/status/StatusBadge.d.ts +0 -1
- package/dist/lib/status/StatusBadge.jsx +20 -0
- package/dist/lib/table/TableColumnButton.d.ts +1 -0
- package/dist/lib/table/TableColumnButton.jsx +53 -0
- package/{src → dist}/lib/table/TableContainer.d.ts +0 -1
- package/dist/lib/table/TableContainer.jsx +11 -0
- package/dist/lib/table/TableContainerContext.jsx +39 -0
- package/{src → dist}/lib/table/TableCreateButton.d.ts +0 -1
- package/dist/lib/table/TableCreateButton.jsx +9 -0
- package/{src → dist}/lib/table/TableFilterButton.d.ts +0 -1
- package/dist/lib/table/TableFilterButton.jsx +16 -0
- package/{src → dist}/lib/table/TableFilters.d.ts +0 -1
- package/dist/lib/table/TableFilters.jsx +46 -0
- package/{src → dist}/lib/table/TableMassActions.d.ts +0 -1
- package/dist/lib/table/TableMassActions.jsx +15 -0
- package/{src → dist}/lib/table/TableRowActionBar.d.ts +0 -1
- package/dist/lib/table/TableRowActionBar.jsx +14 -0
- package/{src → dist}/lib/table/TableRowActionButton.d.ts +0 -1
- package/dist/lib/table/TableRowActionButton.jsx +7 -0
- package/{src → dist}/lib/table/TableRowActionDialogButton.d.ts +1 -2
- package/dist/lib/table/TableRowActionDialogButton.jsx +8 -0
- package/{src → dist}/lib/table/TableRowDeleteButton.d.ts +0 -1
- package/dist/lib/table/TableRowDeleteButton.jsx +5 -0
- package/{src → dist}/lib/table/TableRowEditButton.d.ts +0 -1
- package/dist/lib/table/TableRowEditButton.jsx +7 -0
- package/{src → dist}/lib/table/TableRowNavigateButton.d.ts +0 -1
- package/dist/lib/table/TableRowNavigateButton.jsx +13 -0
- package/{src → dist}/lib/table/TableRowPublishPostButton.d.ts +0 -1
- package/dist/lib/table/TableRowPublishPostButton.jsx +18 -0
- package/{src → dist}/lib/table/TableRowViewButton.d.ts +0 -1
- package/dist/lib/table/TableRowViewButton.jsx +12 -0
- package/{src → dist}/lib/table/TableTopBar.d.ts +1 -2
- package/dist/lib/table/TableTopBar.jsx +17 -0
- package/package.json +60 -4
- package/README.md +0 -7
- package/index.cjs.d.ts +0 -1
- package/index.cjs.js +0 -3710
- package/index.esm.d.ts +0 -1
- package/index.esm.js +0 -3662
- package/src/lib/table/TableColumnButton.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/lib/buttons/DialogButton.d.ts +0 -0
- /package/{src → dist}/lib/json/dialog/ItemDeleteDialog.d.ts +0 -0
- /package/{src → dist}/lib/json/dialog/ItemEditDialog.d.ts +0 -0
- /package/{src → dist}/lib/json/table/TableViewContext.d.ts +0 -0
- /package/{src → dist}/lib/json/table/useTableProps.d.ts +0 -0
- /package/{src → dist}/lib/json/types/EditItemDialog.d.ts +0 -0
- /package/{src → dist}/lib/json/types/MultiQueryWrapper.d.ts +0 -0
- /package/{src → dist}/lib/json/types/MultiQueryWrapperDialog.d.ts +0 -0
- /package/{src → dist}/lib/json/types/QueryWrapper.d.ts +0 -0
- /package/{src → dist}/lib/json/types/QueryWrapperDialog.d.ts +0 -0
- /package/{src → dist}/lib/json/types/ScreenConfig.d.ts +0 -0
- /package/{src → dist}/lib/layout/menu/MenuConfig.d.ts +0 -0
- /package/{src → dist}/lib/modal/FormActionDialog.d.ts +0 -0
- /package/{src → dist}/lib/page/PageQueryStateContainer.d.ts +0 -0
- /package/{src → dist}/lib/page/PageStateContainer.d.ts +0 -0
- /package/{src → dist}/lib/page/PageTopBar.d.ts +0 -0
- /package/{src → dist}/lib/table/TableContainerContext.d.ts +0 -0
package/index.esm.js
DELETED
|
@@ -1,3662 +0,0 @@
|
|
|
1
|
-
import { __rest, __awaiter } from 'tslib';
|
|
2
|
-
import { jsx, jsxs, Fragment } from '@soperio/jsx-runtime';
|
|
3
|
-
import { useApiQuery, useApiMutation, useMutate, useInvalidateMutation, useInvalidateQuery, useInvalidateParentMutation, useApiQueries } from '@compill/api';
|
|
4
|
-
import { Shimmer, FlexCenter, QueryLoadingState, RetryOnError, TabContainer, ModalLoadingOverlay } from '@compill/components';
|
|
5
|
-
import { Icon, Button, Container, Tile, Popover, Collapse, Modal, Avatar, IconButton, Popup, Checkbox, Badge } from '@valerya/ui';
|
|
6
|
-
import Link from 'next/link';
|
|
7
|
-
import { useParams, useNavigate, Outlet, useLocation, useMatch, Link as Link$1 } from 'react-router-dom';
|
|
8
|
-
import React, { useRef, useCallback, useContext as useContext$2, useLayoutEffect, useEffect, createContext } from 'react';
|
|
9
|
-
import { INVALIDATE_API, API, useInvalidatePage } from '@compill/admin-api';
|
|
10
|
-
import { useFormikContext, Formik, Form } from 'formik';
|
|
11
|
-
import { ButtonBarButton as ButtonBarButton$1, ButtonBarSubmitButton as ButtonBarSubmitButton$1, PageSectionTitle as PageSectionTitle$1, ButtonBar as ButtonBar$1, ButtonBarDialogButton as ButtonBarDialogButton$1, Breadcrumbs as Breadcrumbs$1, TableRowActionButton as TableRowActionButton$1, DialogButton as DialogButton$1 } from '@compill/admin';
|
|
12
|
-
import { toast } from 'react-toastify';
|
|
13
|
-
import 'react/jsx-runtime';
|
|
14
|
-
import { FormProvider, FormRenderer, TextArea, mergeInitialFormValues, FieldLabel, SubmitButton } from '@compill/form';
|
|
15
|
-
import { createContext as createContext$1, runIfFn, isFunction } from '@soperio/react';
|
|
16
|
-
import { FormEditor } from '@compill/form-editor';
|
|
17
|
-
import { ImageExtension } from '@compill/editor';
|
|
18
|
-
import { createPortal } from 'react-dom';
|
|
19
|
-
import { useRouter } from 'next/router';
|
|
20
|
-
import { TableContextProvider, useTableContext, Table } from '@compill/table';
|
|
21
|
-
import { useOpenLink, useBoolean } from '@compill/hooks';
|
|
22
|
-
import { AppEnv } from '@compill/env';
|
|
23
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
24
|
-
import Image from 'next/image';
|
|
25
|
-
import { useSessionUser, useSessionLogout } from '@compill/auth';
|
|
26
|
-
|
|
27
|
-
function SectionTitle(_a) {
|
|
28
|
-
var {
|
|
29
|
-
children
|
|
30
|
-
} = _a,
|
|
31
|
-
props = __rest(_a, ["children"]);
|
|
32
|
-
return jsx("h2", Object.assign({
|
|
33
|
-
textSize: "xl",
|
|
34
|
-
fontWeight: "600",
|
|
35
|
-
textColor: "slate-800"
|
|
36
|
-
}, props, {
|
|
37
|
-
children: children
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Material Design Icons v7.4.47
|
|
42
|
-
var mdiArrowDownBoldBox = "M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3M12,17L17,12H14V8H10V12H7L12,17Z";
|
|
43
|
-
var mdiArrowLeft = "M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z";
|
|
44
|
-
var mdiArrowUpBoldBox = "M19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21M12,7L7,12H10V16H14V12H17L12,7Z";
|
|
45
|
-
var mdiCircleSmall = "M12,10A2,2 0 0,0 10,12C10,13.11 10.9,14 12,14C13.11,14 14,13.11 14,12A2,2 0 0,0 12,10Z";
|
|
46
|
-
var mdiCloudUpload = "M11 20H6.5Q4.22 20 2.61 18.43 1 16.85 1 14.58 1 12.63 2.17 11.1 3.35 9.57 5.25 9.15 5.88 6.85 7.75 5.43 9.63 4 12 4 14.93 4 16.96 6.04 19 8.07 19 11 20.73 11.2 21.86 12.5 23 13.78 23 15.5 23 17.38 21.69 18.69 20.38 20 18.5 20H13V12.85L14.6 14.4L16 13L12 9L8 13L9.4 14.4L11 12.85Z";
|
|
47
|
-
var mdiCog = "M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z";
|
|
48
|
-
var mdiDatabaseRefreshOutline = "M6 12.45V9.64C7.47 10.47 9.61 11 12 11S16.53 10.47 18 9.64V12.03C18.17 12 18.33 12 18.5 12C19 12 19.5 12.07 20 12.18V7C20 4.79 16.42 3 12 3S4 4.79 4 7V17C4 19.21 7.59 21 12 21C12.17 21 12.33 21 12.5 21C12.24 20.37 12.09 19.7 12.03 19L12 19C8.13 19 6 17.5 6 17V14.77C7.61 15.55 9.72 16 12 16C12.17 16 12.34 16 12.5 16C12.85 15.18 13.34 14.46 13.95 13.86C13.32 13.95 12.67 14 12 14C9.58 14 7.3 13.4 6 12.45M12 5C15.87 5 18 6.5 18 7S15.87 9 12 9 6 7.5 6 7 8.13 5 12 5M18 18.5L19.77 16.73C19.32 16.28 18.69 16 18 16C16.62 16 15.5 17.12 15.5 18.5S16.62 21 18 21C18.82 21 19.54 20.61 20 20H21.71C21.12 21.47 19.68 22.5 18 22.5C15.79 22.5 14 20.71 14 18.5S15.79 14.5 18 14.5C19.11 14.5 20.11 14.95 20.83 15.67L22 14.5V18.5H18Z";
|
|
49
|
-
var mdiDelete = "M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z";
|
|
50
|
-
var mdiDotsVertical = "M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z";
|
|
51
|
-
var mdiEye = "M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z";
|
|
52
|
-
var mdiEyeOff = "M11.83,9L15,12.16C15,12.11 15,12.05 15,12A3,3 0 0,0 12,9C11.94,9 11.89,9 11.83,9M7.53,9.8L9.08,11.35C9.03,11.56 9,11.77 9,12A3,3 0 0,0 12,15C12.22,15 12.44,14.97 12.65,14.92L14.2,16.47C13.53,16.8 12.79,17 12,17A5,5 0 0,1 7,12C7,11.21 7.2,10.47 7.53,9.8M2,4.27L4.28,6.55L4.73,7C3.08,8.3 1.78,10 1,12C2.73,16.39 7,19.5 12,19.5C13.55,19.5 15.03,19.2 16.38,18.66L16.81,19.08L19.73,22L21,20.73L3.27,3M12,7A5,5 0 0,1 17,12C17,12.64 16.87,13.26 16.64,13.82L19.57,16.75C21.07,15.5 22.27,13.86 23,12C21.27,7.61 17,4.5 12,4.5C10.6,4.5 9.26,4.75 8,5.2L10.17,7.35C10.74,7.13 11.35,7 12,7Z";
|
|
53
|
-
var mdiFilter = "M14,12V19.88C14.04,20.18 13.94,20.5 13.71,20.71C13.32,21.1 12.69,21.1 12.3,20.71L10.29,18.7C10.06,18.47 9.96,18.16 10,17.87V12H9.97L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L14.03,12H14Z";
|
|
54
|
-
var mdiLogout = "M17 7L15.59 8.41L18.17 11H8V13H18.17L15.59 15.58L17 17L22 12M4 5H12V3H4C2.9 3 2 3.9 2 5V19C2 20.1 2.9 21 4 21H12V19H4V5Z";
|
|
55
|
-
var mdiOpenInNew = "M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z";
|
|
56
|
-
var mdiPencil = "M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z";
|
|
57
|
-
var mdiPlusThick = "M20 14H14V20H10V14H4V10H10V4H14V10H20V14Z";
|
|
58
|
-
var mdiPost = "M3 3V21H21V3H3M18 18H6V17H18V18M18 16H6V15H18V16M18 12H6V6H18V12Z";
|
|
59
|
-
var mdiPublish = "M5,4V6H19V4H5M5,14H9V20H15V14H19L12,7L5,14Z";
|
|
60
|
-
var mdiPublishOff = "M20.8 22.7L15 16.9V20H9V14H5L8.6 10.4L1.1 3L2.4 1.7L22.1 21.4L20.8 22.7M19 6V4H7.2L9.2 6H19M17.2 14H19L12 7L11.1 7.9L17.2 14Z";
|
|
61
|
-
var mdiRefresh = "M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z";
|
|
62
|
-
|
|
63
|
-
function eq(value, other) {
|
|
64
|
-
return value === other || (Number.isNaN(value) && Number.isNaN(other));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function getSymbols(object) {
|
|
68
|
-
return Object.getOwnPropertySymbols(object).filter(symbol => Object.prototype.propertyIsEnumerable.call(object, symbol));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function getTag(value) {
|
|
72
|
-
if (value == null) {
|
|
73
|
-
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
74
|
-
}
|
|
75
|
-
return Object.prototype.toString.call(value);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const regexpTag = '[object RegExp]';
|
|
79
|
-
const stringTag = '[object String]';
|
|
80
|
-
const numberTag = '[object Number]';
|
|
81
|
-
const booleanTag = '[object Boolean]';
|
|
82
|
-
const argumentsTag = '[object Arguments]';
|
|
83
|
-
const symbolTag = '[object Symbol]';
|
|
84
|
-
const dateTag = '[object Date]';
|
|
85
|
-
const mapTag = '[object Map]';
|
|
86
|
-
const setTag = '[object Set]';
|
|
87
|
-
const arrayTag = '[object Array]';
|
|
88
|
-
const functionTag = '[object Function]';
|
|
89
|
-
const arrayBufferTag = '[object ArrayBuffer]';
|
|
90
|
-
const objectTag = '[object Object]';
|
|
91
|
-
const errorTag = '[object Error]';
|
|
92
|
-
const dataViewTag = '[object DataView]';
|
|
93
|
-
const uint8ArrayTag = '[object Uint8Array]';
|
|
94
|
-
const uint8ClampedArrayTag = '[object Uint8ClampedArray]';
|
|
95
|
-
const uint16ArrayTag = '[object Uint16Array]';
|
|
96
|
-
const uint32ArrayTag = '[object Uint32Array]';
|
|
97
|
-
const bigUint64ArrayTag = '[object BigUint64Array]';
|
|
98
|
-
const int8ArrayTag = '[object Int8Array]';
|
|
99
|
-
const int16ArrayTag = '[object Int16Array]';
|
|
100
|
-
const int32ArrayTag = '[object Int32Array]';
|
|
101
|
-
const bigInt64ArrayTag = '[object BigInt64Array]';
|
|
102
|
-
const float32ArrayTag = '[object Float32Array]';
|
|
103
|
-
const float64ArrayTag = '[object Float64Array]';
|
|
104
|
-
|
|
105
|
-
function isArray(value) {
|
|
106
|
-
return Array.isArray(value);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function isPlainObject(value) {
|
|
110
|
-
if (!value || typeof value !== 'object') {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
const proto = Object.getPrototypeOf(value);
|
|
114
|
-
const hasObjectPrototype = proto === null ||
|
|
115
|
-
proto === Object.prototype ||
|
|
116
|
-
Object.getPrototypeOf(proto) === null;
|
|
117
|
-
if (!hasObjectPrototype) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
return Object.prototype.toString.call(value) === '[object Object]';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function isEqualWith(a, b, areValuesEqual) {
|
|
124
|
-
return isEqualWithImpl(a, b, undefined, undefined, undefined, undefined, areValuesEqual);
|
|
125
|
-
}
|
|
126
|
-
function isEqualWithImpl(a, b, property, aParent, bParent, stack, areValuesEqual) {
|
|
127
|
-
const result = areValuesEqual(a, b, property, aParent, bParent, stack);
|
|
128
|
-
if (result !== undefined) {
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
if (typeof a === typeof b) {
|
|
132
|
-
switch (typeof a) {
|
|
133
|
-
case 'bigint':
|
|
134
|
-
case 'string':
|
|
135
|
-
case 'boolean':
|
|
136
|
-
case 'symbol':
|
|
137
|
-
case 'undefined': {
|
|
138
|
-
return a === b;
|
|
139
|
-
}
|
|
140
|
-
case 'number': {
|
|
141
|
-
return a === b || Object.is(a, b);
|
|
142
|
-
}
|
|
143
|
-
case 'function': {
|
|
144
|
-
return a === b;
|
|
145
|
-
}
|
|
146
|
-
case 'object': {
|
|
147
|
-
return areObjectsEqual(a, b, stack, areValuesEqual);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return areObjectsEqual(a, b, stack, areValuesEqual);
|
|
152
|
-
}
|
|
153
|
-
function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
154
|
-
if (Object.is(a, b)) {
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
let aTag = getTag(a);
|
|
158
|
-
let bTag = getTag(b);
|
|
159
|
-
if (aTag === argumentsTag) {
|
|
160
|
-
aTag = objectTag;
|
|
161
|
-
}
|
|
162
|
-
if (bTag === argumentsTag) {
|
|
163
|
-
bTag = objectTag;
|
|
164
|
-
}
|
|
165
|
-
if (aTag !== bTag) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
switch (aTag) {
|
|
169
|
-
case stringTag:
|
|
170
|
-
return a.toString() === b.toString();
|
|
171
|
-
case numberTag: {
|
|
172
|
-
const x = a.valueOf();
|
|
173
|
-
const y = b.valueOf();
|
|
174
|
-
return eq(x, y);
|
|
175
|
-
}
|
|
176
|
-
case booleanTag:
|
|
177
|
-
case dateTag:
|
|
178
|
-
case symbolTag:
|
|
179
|
-
return Object.is(a.valueOf(), b.valueOf());
|
|
180
|
-
case regexpTag: {
|
|
181
|
-
return a.source === b.source && a.flags === b.flags;
|
|
182
|
-
}
|
|
183
|
-
case functionTag: {
|
|
184
|
-
return a === b;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
stack = stack ?? new Map();
|
|
188
|
-
const aStack = stack.get(a);
|
|
189
|
-
const bStack = stack.get(b);
|
|
190
|
-
if (aStack != null && bStack != null) {
|
|
191
|
-
return aStack === b;
|
|
192
|
-
}
|
|
193
|
-
stack.set(a, b);
|
|
194
|
-
stack.set(b, a);
|
|
195
|
-
try {
|
|
196
|
-
switch (aTag) {
|
|
197
|
-
case mapTag: {
|
|
198
|
-
if (a.size !== b.size) {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
for (const [key, value] of a.entries()) {
|
|
202
|
-
if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual)) {
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
208
|
-
case setTag: {
|
|
209
|
-
if (a.size !== b.size) {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
const aValues = Array.from(a.values());
|
|
213
|
-
const bValues = Array.from(b.values());
|
|
214
|
-
for (let i = 0; i < aValues.length; i++) {
|
|
215
|
-
const aValue = aValues[i];
|
|
216
|
-
const index = bValues.findIndex(bValue => {
|
|
217
|
-
return isEqualWithImpl(aValue, bValue, undefined, a, b, stack, areValuesEqual);
|
|
218
|
-
});
|
|
219
|
-
if (index === -1) {
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
bValues.splice(index, 1);
|
|
223
|
-
}
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
case arrayTag:
|
|
227
|
-
case uint8ArrayTag:
|
|
228
|
-
case uint8ClampedArrayTag:
|
|
229
|
-
case uint16ArrayTag:
|
|
230
|
-
case uint32ArrayTag:
|
|
231
|
-
case bigUint64ArrayTag:
|
|
232
|
-
case int8ArrayTag:
|
|
233
|
-
case int16ArrayTag:
|
|
234
|
-
case int32ArrayTag:
|
|
235
|
-
case bigInt64ArrayTag:
|
|
236
|
-
case float32ArrayTag:
|
|
237
|
-
case float64ArrayTag: {
|
|
238
|
-
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
if (a.length !== b.length) {
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
for (let i = 0; i < a.length; i++) {
|
|
245
|
-
if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) {
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return true;
|
|
250
|
-
}
|
|
251
|
-
case arrayBufferTag: {
|
|
252
|
-
if (a.byteLength !== b.byteLength) {
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
256
|
-
}
|
|
257
|
-
case dataViewTag: {
|
|
258
|
-
if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
262
|
-
}
|
|
263
|
-
case errorTag: {
|
|
264
|
-
return a.name === b.name && a.message === b.message;
|
|
265
|
-
}
|
|
266
|
-
case objectTag: {
|
|
267
|
-
const areEqualInstances = areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) ||
|
|
268
|
-
(isPlainObject(a) && isPlainObject(b));
|
|
269
|
-
if (!areEqualInstances) {
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
const aKeys = [...Object.keys(a), ...getSymbols(a)];
|
|
273
|
-
const bKeys = [...Object.keys(b), ...getSymbols(b)];
|
|
274
|
-
if (aKeys.length !== bKeys.length) {
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
for (let i = 0; i < aKeys.length; i++) {
|
|
278
|
-
const propKey = aKeys[i];
|
|
279
|
-
const aProp = a[propKey];
|
|
280
|
-
if (!Object.hasOwn(b, propKey)) {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
const bProp = b[propKey];
|
|
284
|
-
if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) {
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
default: {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
finally {
|
|
296
|
-
stack.delete(a);
|
|
297
|
-
stack.delete(b);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function noop() { }
|
|
302
|
-
|
|
303
|
-
function isEqual(a, b) {
|
|
304
|
-
return isEqualWith(a, b, noop);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function capitalize(str) {
|
|
308
|
-
return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase());
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function Breadcrumbs(_a) {
|
|
312
|
-
var {
|
|
313
|
-
breadcrumbs
|
|
314
|
-
} = _a,
|
|
315
|
-
props = __rest(_a, ["breadcrumbs"]);
|
|
316
|
-
if (isArray(breadcrumbs)) {
|
|
317
|
-
return jsx("div", Object.assign({
|
|
318
|
-
dflex: true,
|
|
319
|
-
alignItems: "center",
|
|
320
|
-
trait: "typo.h5"
|
|
321
|
-
}, props, {
|
|
322
|
-
children: breadcrumbs.map((b, index) => jsx(BreadcrumbItem, {
|
|
323
|
-
breadcrumb: b,
|
|
324
|
-
showSeparator: index > 0
|
|
325
|
-
}, index))
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
return jsx(QueryBreadcrumbs, {
|
|
329
|
-
queryFn: breadcrumbs.queryFn,
|
|
330
|
-
queryField: breadcrumbs.queryField,
|
|
331
|
-
generate: breadcrumbs.generate
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
function QueryBreadcrumbs(_a) {
|
|
335
|
-
var {
|
|
336
|
-
queryFn,
|
|
337
|
-
queryField,
|
|
338
|
-
generate
|
|
339
|
-
} = _a,
|
|
340
|
-
props = __rest(_a, ["queryFn", "queryField", "generate"]);
|
|
341
|
-
const params = useParams();
|
|
342
|
-
const id = queryField ? params[queryField] : undefined;
|
|
343
|
-
const {
|
|
344
|
-
data,
|
|
345
|
-
isLoading,
|
|
346
|
-
isError
|
|
347
|
-
} = useApiQuery([""], queryFn, id);
|
|
348
|
-
if (isLoading || isError) {
|
|
349
|
-
return jsxs("div", {
|
|
350
|
-
dflex: true,
|
|
351
|
-
alignItems: "center",
|
|
352
|
-
children: [jsx(Shimmer, {
|
|
353
|
-
h: "8",
|
|
354
|
-
w: "24"
|
|
355
|
-
}), jsx(Icon, {
|
|
356
|
-
path: mdiCircleSmall,
|
|
357
|
-
mx: "1"
|
|
358
|
-
}), jsx(Shimmer, {
|
|
359
|
-
h: "8",
|
|
360
|
-
w: "20"
|
|
361
|
-
})]
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
const breadcrumbs = generate(data);
|
|
365
|
-
return jsx("div", Object.assign({
|
|
366
|
-
dflex: true,
|
|
367
|
-
alignItems: "center",
|
|
368
|
-
trait: "typo.h5"
|
|
369
|
-
}, props, {
|
|
370
|
-
children: breadcrumbs.map((b, index) => jsx(BreadcrumbItem, {
|
|
371
|
-
breadcrumb: b,
|
|
372
|
-
showSeparator: index > 0
|
|
373
|
-
}, index))
|
|
374
|
-
}));
|
|
375
|
-
}
|
|
376
|
-
function BreadcrumbItem({
|
|
377
|
-
breadcrumb,
|
|
378
|
-
showSeparator
|
|
379
|
-
}) {
|
|
380
|
-
return jsxs(Fragment, {
|
|
381
|
-
children: [showSeparator && jsx(Icon, {
|
|
382
|
-
path: mdiCircleSmall,
|
|
383
|
-
mx: "1"
|
|
384
|
-
}), jsx(Link, {
|
|
385
|
-
href: `/${breadcrumb.path || "#"}`,
|
|
386
|
-
children: jsx("span", {
|
|
387
|
-
// onClick={breadcrumb.path ? handleClick : undefined}
|
|
388
|
-
hover_textDecoration: breadcrumb.path ? "underline" : undefined,
|
|
389
|
-
cursor: breadcrumb.path ? "pointer" : undefined,
|
|
390
|
-
children: breadcrumb.label
|
|
391
|
-
})
|
|
392
|
-
})]
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function DialogButton(_a) {
|
|
397
|
-
var {
|
|
398
|
-
buildDialog
|
|
399
|
-
} = _a,
|
|
400
|
-
props = __rest(_a, ["buildDialog"]);
|
|
401
|
-
const [showDialog, setShowDialog] = React.useState(false);
|
|
402
|
-
const onShowDialog = React.useCallback(event => {
|
|
403
|
-
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
404
|
-
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
405
|
-
setShowDialog(true);
|
|
406
|
-
}, [setShowDialog]);
|
|
407
|
-
const onCloseDialog = React.useCallback(() => {
|
|
408
|
-
setShowDialog(false);
|
|
409
|
-
}, [setShowDialog]);
|
|
410
|
-
return jsxs(Fragment, {
|
|
411
|
-
children: [jsx(Button, Object.assign({
|
|
412
|
-
onClick: onShowDialog
|
|
413
|
-
}, props)), showDialog && buildDialog(onCloseDialog)]
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
function ButtonBar(_a) {
|
|
418
|
-
var {
|
|
419
|
-
children
|
|
420
|
-
} = _a,
|
|
421
|
-
props = __rest(_a, ["children"]);
|
|
422
|
-
return jsx("div", Object.assign({
|
|
423
|
-
dflex: true,
|
|
424
|
-
border: "1px",
|
|
425
|
-
borderColor: "zinc-200",
|
|
426
|
-
divideX: "1px",
|
|
427
|
-
divideColor: "zinc-200",
|
|
428
|
-
rounded: "lg",
|
|
429
|
-
overflow: "hidden"
|
|
430
|
-
}, props, {
|
|
431
|
-
children: children
|
|
432
|
-
}));
|
|
433
|
-
}
|
|
434
|
-
const ButtonBarButton = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
435
|
-
var {
|
|
436
|
-
icon,
|
|
437
|
-
children
|
|
438
|
-
} = _a,
|
|
439
|
-
props = __rest(_a, ["icon", "children"]);
|
|
440
|
-
return jsxs(Button, Object.assign({
|
|
441
|
-
scheme: "dark",
|
|
442
|
-
size: "sm",
|
|
443
|
-
aspectRatio: icon && !children ? "square" : undefined,
|
|
444
|
-
variant: "borderless",
|
|
445
|
-
dflex: true,
|
|
446
|
-
alignItems: "center",
|
|
447
|
-
placeContent: "center",
|
|
448
|
-
corners: "square",
|
|
449
|
-
gap: "2"
|
|
450
|
-
}, props, {
|
|
451
|
-
ref: ref,
|
|
452
|
-
children: [icon && jsx(Icon, {
|
|
453
|
-
path: icon
|
|
454
|
-
}), children]
|
|
455
|
-
}));
|
|
456
|
-
});
|
|
457
|
-
const ButtonBarSubmitButton = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
458
|
-
var _b;
|
|
459
|
-
var {
|
|
460
|
-
useDirty,
|
|
461
|
-
disabled,
|
|
462
|
-
icon,
|
|
463
|
-
children
|
|
464
|
-
} = _a,
|
|
465
|
-
props = __rest(_a, ["useDirty", "disabled", "icon", "children"]);
|
|
466
|
-
const {
|
|
467
|
-
dirty,
|
|
468
|
-
handleSubmit
|
|
469
|
-
} = (_b = useFormikContext()) !== null && _b !== void 0 ? _b : {
|
|
470
|
-
dirty: false,
|
|
471
|
-
handleSubmit: undefined};
|
|
472
|
-
const onSubmit = React.useCallback(() => handleSubmit(), [handleSubmit]);
|
|
473
|
-
return jsxs(Button, Object.assign({
|
|
474
|
-
scheme: "dark",
|
|
475
|
-
size: "sm",
|
|
476
|
-
aspectRatio: icon && !children ? "square" : undefined,
|
|
477
|
-
variant: "borderless",
|
|
478
|
-
dflex: true,
|
|
479
|
-
alignItems: "center",
|
|
480
|
-
placeContent: "center",
|
|
481
|
-
corners: "square",
|
|
482
|
-
gap: "2",
|
|
483
|
-
disabled: useDirty && !dirty || disabled,
|
|
484
|
-
onClick: onSubmit
|
|
485
|
-
}, props, {
|
|
486
|
-
ref: ref,
|
|
487
|
-
children: [icon && jsx(Icon, {
|
|
488
|
-
path: icon
|
|
489
|
-
}), children]
|
|
490
|
-
}));
|
|
491
|
-
});
|
|
492
|
-
function ButtonBarDialogButton(_a) {
|
|
493
|
-
var {
|
|
494
|
-
icon,
|
|
495
|
-
children
|
|
496
|
-
} = _a,
|
|
497
|
-
props = __rest(_a, ["icon", "children"]);
|
|
498
|
-
return jsxs(DialogButton, Object.assign({
|
|
499
|
-
scheme: "dark",
|
|
500
|
-
size: "sm",
|
|
501
|
-
aspectRatio: icon && !children ? "square" : undefined,
|
|
502
|
-
variant: "borderless",
|
|
503
|
-
dflex: true,
|
|
504
|
-
alignItems: "center",
|
|
505
|
-
placeContent: "center",
|
|
506
|
-
corners: "square",
|
|
507
|
-
gap: "2"
|
|
508
|
-
}, props, {
|
|
509
|
-
children: [icon && jsx(Icon, {
|
|
510
|
-
path: icon
|
|
511
|
-
}), children]
|
|
512
|
-
}));
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function InvalidateButton(_a) {
|
|
516
|
-
var {
|
|
517
|
-
pathOrPermalink
|
|
518
|
-
} = _a,
|
|
519
|
-
props = __rest(_a, ["pathOrPermalink"]);
|
|
520
|
-
const api = INVALIDATE_API.new(pathOrPermalink);
|
|
521
|
-
const mutation = useApiMutation(api.invalidate, api.queryKey);
|
|
522
|
-
const invalidate = useMutate(mutation, {
|
|
523
|
-
successMsg: "Page successfully invalidated"
|
|
524
|
-
});
|
|
525
|
-
return jsx(ButtonBarButton, Object.assign({
|
|
526
|
-
title: "Regenerate",
|
|
527
|
-
disabled: mutation.isLoading,
|
|
528
|
-
onClick: invalidate,
|
|
529
|
-
icon: mdiDatabaseRefreshOutline
|
|
530
|
-
}, props));
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
function NavigateButton(_a) {
|
|
534
|
-
var {
|
|
535
|
-
path
|
|
536
|
-
} = _a,
|
|
537
|
-
props = __rest(_a, ["path"]);
|
|
538
|
-
const navigate = useNavigate();
|
|
539
|
-
const handleClick = React.useCallback(() => {
|
|
540
|
-
navigate(path);
|
|
541
|
-
}, [navigate, path]);
|
|
542
|
-
return jsx(Button, Object.assign({
|
|
543
|
-
type: "submit",
|
|
544
|
-
scheme: "dark",
|
|
545
|
-
variant: "glass",
|
|
546
|
-
corners: "pill",
|
|
547
|
-
w: "10",
|
|
548
|
-
h: "10",
|
|
549
|
-
onClick: handleClick
|
|
550
|
-
}, props, {
|
|
551
|
-
children: jsx(Icon, {
|
|
552
|
-
path: mdiPost
|
|
553
|
-
})
|
|
554
|
-
}));
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
function PublishButton(_a) {
|
|
558
|
-
var {
|
|
559
|
-
status,
|
|
560
|
-
queryId,
|
|
561
|
-
api
|
|
562
|
-
} = _a,
|
|
563
|
-
props = __rest(_a, ["status", "queryId", "api"]);
|
|
564
|
-
const isDraft = status == "draft";
|
|
565
|
-
const mutation = useInvalidateMutation(isDraft ? api.publish : api.unpublish, api.queryKey, queryId, {
|
|
566
|
-
networkMode: "always"
|
|
567
|
-
});
|
|
568
|
-
const publish = React.useCallback(() => {
|
|
569
|
-
mutation.reset();
|
|
570
|
-
mutation.mutateAsync(queryId).then(() => toast.success(isDraft ? "Published!" : "Unpublished!")).catch(error => toast.error(`Error: ${error}`));
|
|
571
|
-
}, [mutation, queryId]);
|
|
572
|
-
return jsx(ButtonBarButton$1, Object.assign({
|
|
573
|
-
disabled: mutation.isLoading,
|
|
574
|
-
onClick: publish,
|
|
575
|
-
icon: isDraft ? mdiEye : mdiEyeOff
|
|
576
|
-
}, props, {
|
|
577
|
-
children: isDraft ? "Publish" : "Switch to draft"
|
|
578
|
-
}));
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
const j = ["shift", "alt", "meta", "mod", "ctrl", "control"], Q = {
|
|
582
|
-
esc: "escape",
|
|
583
|
-
return: "enter",
|
|
584
|
-
left: "arrowleft",
|
|
585
|
-
right: "arrowright",
|
|
586
|
-
up: "arrowup",
|
|
587
|
-
down: "arrowdown",
|
|
588
|
-
ShiftLeft: "shift",
|
|
589
|
-
ShiftRight: "shift",
|
|
590
|
-
AltLeft: "alt",
|
|
591
|
-
AltRight: "alt",
|
|
592
|
-
MetaLeft: "meta",
|
|
593
|
-
MetaRight: "meta",
|
|
594
|
-
OSLeft: "meta",
|
|
595
|
-
OSRight: "meta",
|
|
596
|
-
ControlLeft: "ctrl",
|
|
597
|
-
ControlRight: "ctrl"
|
|
598
|
-
};
|
|
599
|
-
function K(e) {
|
|
600
|
-
return (Q[e.trim()] || e.trim()).toLowerCase().replace(/key|digit|numpad/, "");
|
|
601
|
-
}
|
|
602
|
-
function D(e) {
|
|
603
|
-
return j.includes(e);
|
|
604
|
-
}
|
|
605
|
-
function H(e, r = ",") {
|
|
606
|
-
return e.toLowerCase().split(r);
|
|
607
|
-
}
|
|
608
|
-
function P(e, r = "+", o = ">", i = false, u) {
|
|
609
|
-
let n = [], c = false;
|
|
610
|
-
e = e.trim(), e.includes(o) ? (c = true, n = e.toLocaleLowerCase().split(o).map((f) => K(f))) : n = e.toLocaleLowerCase().split(r).map((f) => K(f));
|
|
611
|
-
const y = {
|
|
612
|
-
alt: n.includes("alt"),
|
|
613
|
-
ctrl: n.includes("ctrl") || n.includes("control"),
|
|
614
|
-
shift: n.includes("shift"),
|
|
615
|
-
meta: n.includes("meta"),
|
|
616
|
-
mod: n.includes("mod"),
|
|
617
|
-
useKey: i
|
|
618
|
-
}, d = n.filter((f) => !j.includes(f));
|
|
619
|
-
return {
|
|
620
|
-
...y,
|
|
621
|
-
keys: d,
|
|
622
|
-
description: u,
|
|
623
|
-
isSequence: c,
|
|
624
|
-
hotkey: e
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
typeof document < "u" && (document.addEventListener("keydown", (e) => {
|
|
628
|
-
e.code !== void 0 && I([K(e.code)]);
|
|
629
|
-
}), document.addEventListener("keyup", (e) => {
|
|
630
|
-
e.code !== void 0 && _([K(e.code)]);
|
|
631
|
-
})), typeof window < "u" && (window.addEventListener("blur", () => {
|
|
632
|
-
L.clear();
|
|
633
|
-
}), window.addEventListener("contextmenu", () => {
|
|
634
|
-
setTimeout(() => {
|
|
635
|
-
L.clear();
|
|
636
|
-
}, 0);
|
|
637
|
-
}));
|
|
638
|
-
const L = /* @__PURE__ */ new Set();
|
|
639
|
-
function R(e) {
|
|
640
|
-
return Array.isArray(e);
|
|
641
|
-
}
|
|
642
|
-
function U(e, r = ",") {
|
|
643
|
-
return (R(e) ? e : e.split(r)).every((i) => L.has(i.trim().toLowerCase()));
|
|
644
|
-
}
|
|
645
|
-
function I(e) {
|
|
646
|
-
const r = Array.isArray(e) ? e : [e];
|
|
647
|
-
L.has("meta") && L.forEach((o) => !D(o) && L.delete(o.toLowerCase())), r.forEach((o) => L.add(o.toLowerCase()));
|
|
648
|
-
}
|
|
649
|
-
function _(e) {
|
|
650
|
-
const r = Array.isArray(e) ? e : [e];
|
|
651
|
-
e === "meta" ? L.clear() : r.forEach((o) => L.delete(o.toLowerCase()));
|
|
652
|
-
}
|
|
653
|
-
function V(e, r, o) {
|
|
654
|
-
(typeof o == "function" && o(e, r) || o === true) && e.preventDefault();
|
|
655
|
-
}
|
|
656
|
-
function X(e, r, o) {
|
|
657
|
-
return typeof o == "function" ? o(e, r) : o === true || o === void 0;
|
|
658
|
-
}
|
|
659
|
-
const Y = [
|
|
660
|
-
"input",
|
|
661
|
-
"textarea",
|
|
662
|
-
"select",
|
|
663
|
-
"searchbox",
|
|
664
|
-
"slider",
|
|
665
|
-
"spinbutton",
|
|
666
|
-
"menuitem",
|
|
667
|
-
"menuitemcheckbox",
|
|
668
|
-
"menuitemradio",
|
|
669
|
-
"option",
|
|
670
|
-
"radio",
|
|
671
|
-
"textbox"
|
|
672
|
-
];
|
|
673
|
-
function Z(e) {
|
|
674
|
-
return F(e, Y);
|
|
675
|
-
}
|
|
676
|
-
function F(e, r = false) {
|
|
677
|
-
const { target: o, composed: i } = e;
|
|
678
|
-
let u, n;
|
|
679
|
-
return ee(o) && i ? (u = e.composedPath()[0] && e.composedPath()[0].tagName, n = e.composedPath()[0] && e.composedPath()[0].role) : (u = o && o.tagName, n = o && o.role), R(r) ? !!(u && r && r.some((c) => c.toLowerCase() === u.toLowerCase() || c === n)) : !!(u && r && r);
|
|
680
|
-
}
|
|
681
|
-
function ee(e) {
|
|
682
|
-
return !!e.tagName && !e.tagName.startsWith("-") && e.tagName.includes("-");
|
|
683
|
-
}
|
|
684
|
-
function te(e, r) {
|
|
685
|
-
return e.length === 0 && r ? (console.warn(
|
|
686
|
-
'A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'
|
|
687
|
-
), true) : r ? e.some((o) => r.includes(o)) || e.includes("*") : true;
|
|
688
|
-
}
|
|
689
|
-
const re = (e, r, o = false) => {
|
|
690
|
-
const { alt: i, meta: u, mod: n, shift: c, ctrl: y, keys: d, useKey: f } = r, { code: p, key: t, ctrlKey: a, metaKey: l, shiftKey: g, altKey: k } = e, m = K(p);
|
|
691
|
-
if (f && d?.length === 1 && d.includes(t))
|
|
692
|
-
return true;
|
|
693
|
-
if (!d?.includes(m) && !["ctrl", "control", "unknown", "meta", "alt", "shift", "os"].includes(m))
|
|
694
|
-
return false;
|
|
695
|
-
if (!o) {
|
|
696
|
-
if (i !== k && m !== "alt" || c !== g && m !== "shift")
|
|
697
|
-
return false;
|
|
698
|
-
if (n) {
|
|
699
|
-
if (!l && !a)
|
|
700
|
-
return false;
|
|
701
|
-
} else if (u !== l && m !== "meta" && m !== "os" || y !== a && m !== "ctrl" && m !== "control")
|
|
702
|
-
return false;
|
|
703
|
-
}
|
|
704
|
-
return d && d.length === 1 && d.includes(m) ? true : d ? U(d) : !d;
|
|
705
|
-
}, $ = createContext(void 0), oe = () => useContext$2($);
|
|
706
|
-
function x(e, r) {
|
|
707
|
-
return e && r && typeof e == "object" && typeof r == "object" ? Object.keys(e).length === Object.keys(r).length && // @ts-expect-error TS7053
|
|
708
|
-
Object.keys(e).reduce((o, i) => o && x(e[i], r[i]), true) : e === r;
|
|
709
|
-
}
|
|
710
|
-
const W = createContext({
|
|
711
|
-
hotkeys: [],
|
|
712
|
-
activeScopes: [],
|
|
713
|
-
// This array has to be empty instead of containing '*' as default, to check if the provider is set or not
|
|
714
|
-
toggleScope: () => {
|
|
715
|
-
},
|
|
716
|
-
enableScope: () => {
|
|
717
|
-
},
|
|
718
|
-
disableScope: () => {
|
|
719
|
-
}
|
|
720
|
-
}), se = () => useContext$2(W);
|
|
721
|
-
function ie(e) {
|
|
722
|
-
const r = useRef(void 0);
|
|
723
|
-
return x(r.current, e) || (r.current = e), r.current;
|
|
724
|
-
}
|
|
725
|
-
const N = (e) => {
|
|
726
|
-
e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation();
|
|
727
|
-
}, ue = typeof window < "u" ? useLayoutEffect : useEffect;
|
|
728
|
-
function fe(e, r, o, i) {
|
|
729
|
-
const u = useRef(null), n = useRef(false), c = Array.isArray(o) ? Array.isArray(i) ? void 0 : i : o, y = R(e) ? e.join(c?.delimiter) : e, d = Array.isArray(o) ? o : Array.isArray(i) ? i : void 0, f = useCallback(r, d ?? []), p = useRef(f);
|
|
730
|
-
d ? p.current = f : p.current = r;
|
|
731
|
-
const t = ie(c), { activeScopes: a } = se(), l = oe();
|
|
732
|
-
return ue(() => {
|
|
733
|
-
if (t?.enabled === false || !te(a, t?.scopes))
|
|
734
|
-
return;
|
|
735
|
-
let g = [], k;
|
|
736
|
-
const m = (s, B = false) => {
|
|
737
|
-
if (!(Z(s) && !F(s, t?.enableOnFormTags))) {
|
|
738
|
-
if (u.current !== null) {
|
|
739
|
-
const v = u.current.getRootNode();
|
|
740
|
-
if ((v instanceof Document || v instanceof ShadowRoot) && v.activeElement !== u.current && !u.current.contains(v.activeElement)) {
|
|
741
|
-
N(s);
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
s.target?.isContentEditable && !t?.enableOnContentEditable || H(y, t?.delimiter).forEach((v) => {
|
|
746
|
-
if (v.includes(t?.splitKey ?? "+") && v.includes(t?.sequenceSplitKey ?? ">")) {
|
|
747
|
-
console.warn(
|
|
748
|
-
`Hotkey ${v} contains both ${t?.splitKey ?? "+"} and ${t?.sequenceSplitKey ?? ">"} which is not supported.`
|
|
749
|
-
);
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
const h = P(
|
|
753
|
-
v,
|
|
754
|
-
t?.splitKey,
|
|
755
|
-
t?.sequenceSplitKey,
|
|
756
|
-
t?.useKey,
|
|
757
|
-
t?.description
|
|
758
|
-
);
|
|
759
|
-
if (h.isSequence) {
|
|
760
|
-
k = setTimeout(() => {
|
|
761
|
-
g = [];
|
|
762
|
-
}, t?.sequenceTimeoutMs ?? 1e3);
|
|
763
|
-
const C = h.useKey ? s.key : K(s.code);
|
|
764
|
-
if (D(C.toLowerCase()))
|
|
765
|
-
return;
|
|
766
|
-
g.push(C);
|
|
767
|
-
const G = h.keys?.[g.length - 1];
|
|
768
|
-
if (C !== G) {
|
|
769
|
-
g = [], k && clearTimeout(k);
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
g.length === h.keys?.length && (p.current(s, h), k && clearTimeout(k), g = []);
|
|
773
|
-
} else if (re(s, h, t?.ignoreModifiers) || h.keys?.includes("*")) {
|
|
774
|
-
if (t?.ignoreEventWhen?.(s) || B && n.current)
|
|
775
|
-
return;
|
|
776
|
-
if (V(s, h, t?.preventDefault), !X(s, h, t?.enabled)) {
|
|
777
|
-
N(s);
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
p.current(s, h), B || (n.current = true);
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
}, O = (s) => {
|
|
785
|
-
s.code !== void 0 && (I(K(s.code)), (t?.keydown === void 0 && t?.keyup !== true || t?.keydown) && m(s));
|
|
786
|
-
}, q = (s) => {
|
|
787
|
-
s.code !== void 0 && (_(K(s.code)), n.current = false, t?.keyup && m(s, true));
|
|
788
|
-
}, E = u.current || c?.document || document;
|
|
789
|
-
return E.addEventListener("keyup", q, c?.eventListenerOptions), E.addEventListener("keydown", O, c?.eventListenerOptions), l && H(y, t?.delimiter).forEach(
|
|
790
|
-
(s) => l.addHotkey(
|
|
791
|
-
P(
|
|
792
|
-
s,
|
|
793
|
-
t?.splitKey,
|
|
794
|
-
t?.sequenceSplitKey,
|
|
795
|
-
t?.useKey,
|
|
796
|
-
t?.description
|
|
797
|
-
)
|
|
798
|
-
)
|
|
799
|
-
), () => {
|
|
800
|
-
E.removeEventListener("keyup", q, c?.eventListenerOptions), E.removeEventListener("keydown", O, c?.eventListenerOptions), l && H(y, t?.delimiter).forEach(
|
|
801
|
-
(s) => l.removeHotkey(
|
|
802
|
-
P(
|
|
803
|
-
s,
|
|
804
|
-
t?.splitKey,
|
|
805
|
-
t?.sequenceSplitKey,
|
|
806
|
-
t?.useKey,
|
|
807
|
-
t?.description
|
|
808
|
-
)
|
|
809
|
-
)
|
|
810
|
-
), g = [], k && clearTimeout(k);
|
|
811
|
-
};
|
|
812
|
-
}, [y, t, a]), u;
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
function UpdateButton(_a) {
|
|
816
|
-
var _b;
|
|
817
|
-
var props = __rest(_a, []);
|
|
818
|
-
const {
|
|
819
|
-
dirty,
|
|
820
|
-
handleSubmit
|
|
821
|
-
} = (_b = useFormikContext()) !== null && _b !== void 0 ? _b : {
|
|
822
|
-
dirty: false,
|
|
823
|
-
handleSubmit: undefined};
|
|
824
|
-
fe('ctrl+s', () => {
|
|
825
|
-
if (dirty && !props.disabled) handleSubmit();
|
|
826
|
-
}, {
|
|
827
|
-
preventDefault: true
|
|
828
|
-
}, [dirty, props, handleSubmit]);
|
|
829
|
-
return jsx(ButtonBarSubmitButton$1, Object.assign({
|
|
830
|
-
icon: mdiCloudUpload
|
|
831
|
-
}, props, {
|
|
832
|
-
children: "Update"
|
|
833
|
-
}));
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
function ViewButton(_a) {
|
|
837
|
-
var {
|
|
838
|
-
label,
|
|
839
|
-
path,
|
|
840
|
-
icon
|
|
841
|
-
} = _a,
|
|
842
|
-
props = __rest(_a, ["label", "path", "icon"]);
|
|
843
|
-
const openPage = React.useCallback(() => {
|
|
844
|
-
window.open(path, '_blank');
|
|
845
|
-
}, [path]);
|
|
846
|
-
return jsx(ButtonBarButton$1, Object.assign({
|
|
847
|
-
onClick: openPage,
|
|
848
|
-
dflex: true,
|
|
849
|
-
alignItems: "center",
|
|
850
|
-
gap: "2",
|
|
851
|
-
icon: icon || mdiOpenInNew
|
|
852
|
-
}, props, {
|
|
853
|
-
children: label
|
|
854
|
-
}));
|
|
855
|
-
// return (
|
|
856
|
-
// <IconButton icon={icon ? icon : mdiOpenInNew} type="submit" scheme="dark" variant="glass" size="md" onClick={openPage} {...props}/>
|
|
857
|
-
// )
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
function OrderCell({
|
|
861
|
-
api,
|
|
862
|
-
postId,
|
|
863
|
-
order
|
|
864
|
-
}) {
|
|
865
|
-
const mutationDown = useInvalidateMutation(api.moveDown, api.queryKey);
|
|
866
|
-
const mutationUp = useInvalidateMutation(api.moveUp, api.queryKey);
|
|
867
|
-
const moveDown = React.useCallback(e => {
|
|
868
|
-
e.stopPropagation();
|
|
869
|
-
mutationDown.mutateAsync(postId).catch(error => {
|
|
870
|
-
toast.error(`Error: ${error}`);
|
|
871
|
-
});
|
|
872
|
-
}, [mutationDown, postId]);
|
|
873
|
-
const moveUp = React.useCallback(e => {
|
|
874
|
-
e.stopPropagation();
|
|
875
|
-
mutationUp.mutateAsync(postId).catch(error => {
|
|
876
|
-
toast.error(`Error: ${error}`);
|
|
877
|
-
});
|
|
878
|
-
}, [mutationUp, postId]);
|
|
879
|
-
return jsxs(FlexCenter, {
|
|
880
|
-
placeContent: "start",
|
|
881
|
-
numericFontVariant: "tabular-nums",
|
|
882
|
-
children: [order, jsx(Button, {
|
|
883
|
-
ms: "3",
|
|
884
|
-
variant: "borderless",
|
|
885
|
-
scheme: "dark",
|
|
886
|
-
onClick: moveUp,
|
|
887
|
-
children: jsx(Icon, {
|
|
888
|
-
path: mdiArrowUpBoldBox
|
|
889
|
-
})
|
|
890
|
-
}), jsx(Button, {
|
|
891
|
-
variant: "borderless",
|
|
892
|
-
scheme: "dark",
|
|
893
|
-
onClick: moveDown,
|
|
894
|
-
children: jsx(Icon, {
|
|
895
|
-
path: mdiArrowDownBoldBox
|
|
896
|
-
})
|
|
897
|
-
})]
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
function PageContainer(_a) {
|
|
902
|
-
var {
|
|
903
|
-
children
|
|
904
|
-
} = _a,
|
|
905
|
-
props = __rest(_a, ["children"]);
|
|
906
|
-
return jsx(Container, Object.assign({
|
|
907
|
-
center: true,
|
|
908
|
-
dflex: true,
|
|
909
|
-
flexCol: true,
|
|
910
|
-
gap: "8"
|
|
911
|
-
}, props, {
|
|
912
|
-
children: children
|
|
913
|
-
}));
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
function PageMain(_a) {
|
|
917
|
-
var {
|
|
918
|
-
children
|
|
919
|
-
} = _a,
|
|
920
|
-
props = __rest(_a, ["children"]);
|
|
921
|
-
return jsx(Tile, Object.assign({
|
|
922
|
-
scheme: "light",
|
|
923
|
-
p: "5"
|
|
924
|
-
}, props, {
|
|
925
|
-
children: children
|
|
926
|
-
}));
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
function PageContentEditor(_a) {
|
|
930
|
-
var {
|
|
931
|
-
name
|
|
932
|
-
} = _a,
|
|
933
|
-
props = __rest(_a, ["name"]);
|
|
934
|
-
const extensions = [ImageExtension];
|
|
935
|
-
return jsx(PageMain, Object.assign({
|
|
936
|
-
h: "min"
|
|
937
|
-
}, props, {
|
|
938
|
-
children: jsx(FormEditor, {
|
|
939
|
-
minH: "128",
|
|
940
|
-
minW: "144",
|
|
941
|
-
maxW: props.maxW,
|
|
942
|
-
// w={props.w}
|
|
943
|
-
name: name,
|
|
944
|
-
placeHolder: "Write here...",
|
|
945
|
-
extensions: extensions
|
|
946
|
-
})
|
|
947
|
-
}));
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
function PageQueryStateContainerInner(_a) {
|
|
951
|
-
var {
|
|
952
|
-
queryId,
|
|
953
|
-
api,
|
|
954
|
-
apiFn,
|
|
955
|
-
loadingStyles,
|
|
956
|
-
errorStyles,
|
|
957
|
-
children
|
|
958
|
-
} = _a,
|
|
959
|
-
props = __rest(_a, ["queryId", "api", "apiFn", "loadingStyles", "errorStyles", "children"]);
|
|
960
|
-
// @ts-ignore
|
|
961
|
-
const {
|
|
962
|
-
data,
|
|
963
|
-
isLoading,
|
|
964
|
-
isError
|
|
965
|
-
} = apiFn == "getAll" ? useApiQuery(api.queryKey, api.getAll, props.apiParams) : useApiQuery(api.queryKey, api.get, queryId);
|
|
966
|
-
const invalidate = useInvalidateQuery(api.queryKey, queryId);
|
|
967
|
-
if (isLoading) return jsx(QueryLoadingState, Object.assign({
|
|
968
|
-
w: "full",
|
|
969
|
-
h: "100%"
|
|
970
|
-
}, loadingStyles));
|
|
971
|
-
if (isError) return jsx(RetryOnError, Object.assign({
|
|
972
|
-
p: "0",
|
|
973
|
-
onClick: invalidate
|
|
974
|
-
}, errorStyles));
|
|
975
|
-
return jsx(PageContainer, Object.assign({}, props, {
|
|
976
|
-
children: apiFn == "get" ? children(data) : children(data)
|
|
977
|
-
}));
|
|
978
|
-
}
|
|
979
|
-
const PageQueryStateContainer = /*#__PURE__*/React.forwardRef(PageQueryStateContainerInner);
|
|
980
|
-
|
|
981
|
-
function PageSidebar(_a) {
|
|
982
|
-
var {
|
|
983
|
-
children
|
|
984
|
-
} = _a,
|
|
985
|
-
props = __rest(_a, ["children"]);
|
|
986
|
-
return jsx("div", Object.assign({
|
|
987
|
-
w: "112",
|
|
988
|
-
minW: "112",
|
|
989
|
-
minH: "100%",
|
|
990
|
-
gap: "8",
|
|
991
|
-
dflex: true,
|
|
992
|
-
flexCol: true
|
|
993
|
-
}, props, {
|
|
994
|
-
children: children
|
|
995
|
-
}));
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
function PageSidebarSection(_a) {
|
|
999
|
-
var {
|
|
1000
|
-
title,
|
|
1001
|
-
children
|
|
1002
|
-
} = _a,
|
|
1003
|
-
props = __rest(_a, ["title", "children"]);
|
|
1004
|
-
return jsxs("div", Object.assign({
|
|
1005
|
-
w: "full"
|
|
1006
|
-
}, props, {
|
|
1007
|
-
children: [title && jsx(PageSectionTitle$1, {
|
|
1008
|
-
children: title
|
|
1009
|
-
}), children]
|
|
1010
|
-
}));
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
function PageTitle(_a) {
|
|
1014
|
-
var {
|
|
1015
|
-
children
|
|
1016
|
-
} = _a,
|
|
1017
|
-
props = __rest(_a, ["children"]);
|
|
1018
|
-
return jsx("div", Object.assign({
|
|
1019
|
-
trait: "typo.h5"
|
|
1020
|
-
}, props, {
|
|
1021
|
-
children: children
|
|
1022
|
-
}));
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
function PageTopBar(_a) {
|
|
1026
|
-
var {
|
|
1027
|
-
title,
|
|
1028
|
-
breadcrumbs,
|
|
1029
|
-
children
|
|
1030
|
-
} = _a,
|
|
1031
|
-
props = __rest(_a, ["title", "breadcrumbs", "children"]);
|
|
1032
|
-
return jsxs(FlexCenter, Object.assign({
|
|
1033
|
-
gap: "3",
|
|
1034
|
-
minH: "9"
|
|
1035
|
-
}, props, {
|
|
1036
|
-
children: [title && jsx(PageTitle, {
|
|
1037
|
-
children: title
|
|
1038
|
-
}), breadcrumbs && jsx(Breadcrumbs, {
|
|
1039
|
-
breadcrumbs: breadcrumbs
|
|
1040
|
-
}), jsx("div", {
|
|
1041
|
-
flexGrow: true
|
|
1042
|
-
}), children]
|
|
1043
|
-
}));
|
|
1044
|
-
}
|
|
1045
|
-
const [CP, usePageTabbedTopBarContext] = createContext$1();
|
|
1046
|
-
function PageTabbedTopBarProvider({
|
|
1047
|
-
children
|
|
1048
|
-
}) {
|
|
1049
|
-
const [containerEl, setContainerEl] = React.useState(null);
|
|
1050
|
-
return jsx(CP, {
|
|
1051
|
-
value: {
|
|
1052
|
-
containerEl,
|
|
1053
|
-
setContainerEl
|
|
1054
|
-
},
|
|
1055
|
-
children: children
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
function PageTabbedTopBar(_a) {
|
|
1059
|
-
var {
|
|
1060
|
-
title,
|
|
1061
|
-
breadcrumbs,
|
|
1062
|
-
children
|
|
1063
|
-
} = _a,
|
|
1064
|
-
props = __rest(_a, ["title", "breadcrumbs", "children"]);
|
|
1065
|
-
const ref = /*#__PURE__*/React.createRef();
|
|
1066
|
-
const {
|
|
1067
|
-
setContainerEl
|
|
1068
|
-
} = usePageTabbedTopBarContext();
|
|
1069
|
-
const [isSet, setIsSet] = React.useState(false);
|
|
1070
|
-
React.useEffect(() => {
|
|
1071
|
-
if (!isSet && ref.current) {
|
|
1072
|
-
setContainerEl(ref.current);
|
|
1073
|
-
setIsSet(true);
|
|
1074
|
-
}
|
|
1075
|
-
return () => setContainerEl(null);
|
|
1076
|
-
}, []);
|
|
1077
|
-
return jsx(FlexCenter, Object.assign({
|
|
1078
|
-
gap: "3",
|
|
1079
|
-
minH: "9"
|
|
1080
|
-
}, props, {
|
|
1081
|
-
children: jsxs(Fragment, {
|
|
1082
|
-
children: [title && jsx(PageTitle, {
|
|
1083
|
-
children: title
|
|
1084
|
-
}), breadcrumbs && jsx(Breadcrumbs, {
|
|
1085
|
-
breadcrumbs: breadcrumbs
|
|
1086
|
-
}), jsx("div", {
|
|
1087
|
-
flexGrow: true
|
|
1088
|
-
}), jsx("div", {
|
|
1089
|
-
ref: ref,
|
|
1090
|
-
dflex: true,
|
|
1091
|
-
flexRow: true,
|
|
1092
|
-
gap: "3"
|
|
1093
|
-
}), children]
|
|
1094
|
-
})
|
|
1095
|
-
}));
|
|
1096
|
-
}
|
|
1097
|
-
function PageTopBarToolbar({
|
|
1098
|
-
trackingRef,
|
|
1099
|
-
children
|
|
1100
|
-
}) {
|
|
1101
|
-
const {
|
|
1102
|
-
containerEl
|
|
1103
|
-
} = usePageTabbedTopBarContext();
|
|
1104
|
-
const [visible, setVisible] = React.useState(false);
|
|
1105
|
-
const portal = React.useMemo(() => {
|
|
1106
|
-
const node = containerEl; //?.ownerDocument.createElement("div")
|
|
1107
|
-
// if (node) node.className = PORTAL_CLASSNAME
|
|
1108
|
-
return node;
|
|
1109
|
-
}, [containerEl]);
|
|
1110
|
-
const host = containerEl !== null && containerEl !== void 0 ? containerEl : typeof window !== "undefined" ? document.body : undefined;
|
|
1111
|
-
React.useLayoutEffect(() => {
|
|
1112
|
-
if (!portal || !host) return;
|
|
1113
|
-
try {
|
|
1114
|
-
if (visible) host.appendChild(portal);else host.removeChild(portal);
|
|
1115
|
-
} catch (e) {}
|
|
1116
|
-
return () => {
|
|
1117
|
-
try {
|
|
1118
|
-
host.removeChild(portal);
|
|
1119
|
-
} catch (e) {}
|
|
1120
|
-
};
|
|
1121
|
-
}, [visible, portal, host]);
|
|
1122
|
-
const callback = React.useCallback(entries => {
|
|
1123
|
-
// @ts-ignore
|
|
1124
|
-
setVisible(entries[0].isVisible);
|
|
1125
|
-
}, [children]);
|
|
1126
|
-
React.useEffect(() => {
|
|
1127
|
-
const opts = {
|
|
1128
|
-
root: null,
|
|
1129
|
-
rootMargin: '0px',
|
|
1130
|
-
threshold: 0,
|
|
1131
|
-
/* required options*/
|
|
1132
|
-
trackVisibility: true,
|
|
1133
|
-
delay: 100
|
|
1134
|
-
};
|
|
1135
|
-
const observerScroll = new IntersectionObserver(callback, opts);
|
|
1136
|
-
if (trackingRef) observerScroll.observe(trackingRef);
|
|
1137
|
-
return () => observerScroll.disconnect();
|
|
1138
|
-
}, [trackingRef, callback, children]);
|
|
1139
|
-
if (host && portal) return /*#__PURE__*/createPortal(children, portal);
|
|
1140
|
-
return null;
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
function ScreenTopBar({
|
|
1144
|
-
tabbed,
|
|
1145
|
-
breadcrumbs,
|
|
1146
|
-
api,
|
|
1147
|
-
item,
|
|
1148
|
-
isLoading,
|
|
1149
|
-
buttonBar,
|
|
1150
|
-
trackingRef
|
|
1151
|
-
}) {
|
|
1152
|
-
return jsxs(Fragment, {
|
|
1153
|
-
children: [tabbed && jsx(PageTopBarToolbar, {
|
|
1154
|
-
trackingRef: trackingRef,
|
|
1155
|
-
children: jsx(Buttons$1, {
|
|
1156
|
-
api: api,
|
|
1157
|
-
item: item,
|
|
1158
|
-
isLoading: isLoading,
|
|
1159
|
-
buttonBar: buttonBar
|
|
1160
|
-
})
|
|
1161
|
-
}), !tabbed && jsx(PageTopBar, {
|
|
1162
|
-
breadcrumbs: breadcrumbs,
|
|
1163
|
-
children: jsx(Buttons$1, {
|
|
1164
|
-
api: api,
|
|
1165
|
-
item: item,
|
|
1166
|
-
isLoading: isLoading,
|
|
1167
|
-
buttonBar: buttonBar
|
|
1168
|
-
})
|
|
1169
|
-
})]
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
function Buttons$1({
|
|
1173
|
-
api,
|
|
1174
|
-
item,
|
|
1175
|
-
isLoading,
|
|
1176
|
-
buttonBar
|
|
1177
|
-
}) {
|
|
1178
|
-
return jsxs(Fragment, {
|
|
1179
|
-
children: [buttonBar && buttonBar.length > 0 && jsx(ButtonBar$1, {
|
|
1180
|
-
children: buttonBar.map((button, index) => jsxs(React.Fragment, {
|
|
1181
|
-
children: [button.type === "link" && jsx(ViewButton, {
|
|
1182
|
-
label: button.label,
|
|
1183
|
-
path: button.path,
|
|
1184
|
-
icon: button.icon
|
|
1185
|
-
}), button.type === "invalidate" && jsx(InvalidateButton, {
|
|
1186
|
-
pathOrPermalink: button.pathOrPermalink
|
|
1187
|
-
}), button.type == "custom" && button.render(item)]
|
|
1188
|
-
}, index))
|
|
1189
|
-
}), jsxs(ButtonBar$1, {
|
|
1190
|
-
children: [api instanceof API && jsx(PublishButton, {
|
|
1191
|
-
api: api,
|
|
1192
|
-
queryId: item.id,
|
|
1193
|
-
status: item.status,
|
|
1194
|
-
disabled: isLoading
|
|
1195
|
-
}), jsx(UpdateButton, {
|
|
1196
|
-
disabled: isLoading
|
|
1197
|
-
})]
|
|
1198
|
-
})]
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
function useQueryField(queryField, useNextRouter) {
|
|
1203
|
-
if (useNextRouter) {
|
|
1204
|
-
const router = useRouter();
|
|
1205
|
-
return router.query[queryField];
|
|
1206
|
-
}
|
|
1207
|
-
const {
|
|
1208
|
-
[queryField]: id
|
|
1209
|
-
} = useParams();
|
|
1210
|
-
return id;
|
|
1211
|
-
}
|
|
1212
|
-
function DetailsView(_a) {
|
|
1213
|
-
var {
|
|
1214
|
-
queryField,
|
|
1215
|
-
api,
|
|
1216
|
-
useNextRouter,
|
|
1217
|
-
processInput,
|
|
1218
|
-
screen,
|
|
1219
|
-
tabbed
|
|
1220
|
-
} = _a,
|
|
1221
|
-
props = __rest(_a, ["queryField", "api", "useNextRouter", "processInput", "screen", "tabbed"]);
|
|
1222
|
-
const id = useQueryField(queryField, useNextRouter);
|
|
1223
|
-
const ref = React.useRef(null);
|
|
1224
|
-
return jsx(PageQueryStateContainer, Object.assign({
|
|
1225
|
-
api: api,
|
|
1226
|
-
apiFn: "get",
|
|
1227
|
-
queryId: id,
|
|
1228
|
-
ref: ref,
|
|
1229
|
-
p: "5"
|
|
1230
|
-
}, props, {
|
|
1231
|
-
children: item => jsx(Internal, {
|
|
1232
|
-
item: item,
|
|
1233
|
-
screen: screen,
|
|
1234
|
-
api: api,
|
|
1235
|
-
tabbed: tabbed,
|
|
1236
|
-
processInput: processInput,
|
|
1237
|
-
containerRef: ref
|
|
1238
|
-
})
|
|
1239
|
-
}));
|
|
1240
|
-
}
|
|
1241
|
-
function Internal({
|
|
1242
|
-
item,
|
|
1243
|
-
screen,
|
|
1244
|
-
api,
|
|
1245
|
-
processInput,
|
|
1246
|
-
tabbed,
|
|
1247
|
-
containerRef
|
|
1248
|
-
}) {
|
|
1249
|
-
var _a, _b, _c;
|
|
1250
|
-
const pScreen = runIfFn(screen, item);
|
|
1251
|
-
const {
|
|
1252
|
-
breadcrumbs,
|
|
1253
|
-
schema,
|
|
1254
|
-
initialValues,
|
|
1255
|
-
header,
|
|
1256
|
-
sections,
|
|
1257
|
-
buttonBar,
|
|
1258
|
-
type,
|
|
1259
|
-
invalidateParentQueryKey,
|
|
1260
|
-
invalidatePage
|
|
1261
|
-
} = pScreen;
|
|
1262
|
-
const mutation = useInvalidateParentMutation(api.update, invalidateParentQueryKey !== null && invalidateParentQueryKey !== void 0 ? invalidateParentQueryKey : api.queryKey, {
|
|
1263
|
-
networkMode: "always"
|
|
1264
|
-
});
|
|
1265
|
-
const invalidatePageFn = useInvalidatePage(invalidatePage || "");
|
|
1266
|
-
const save = useMutate(mutation, {
|
|
1267
|
-
processInput,
|
|
1268
|
-
successMsg: (item, values) => `${item.title || item.name} updated.`,
|
|
1269
|
-
errorMsg: (error, item) => `Error updating ${item.title || item.name}: ${error}`,
|
|
1270
|
-
onSuccess: () => {
|
|
1271
|
-
if (invalidatePage) invalidatePageFn();
|
|
1272
|
-
}
|
|
1273
|
-
});
|
|
1274
|
-
let editorMaxW = undefined;
|
|
1275
|
-
if (!type || type == "post") editorMaxW = "calc(1280px - 28rem)";else if (type == "section") editorMaxW = "calc(1280px - 22rem)";
|
|
1276
|
-
return jsxs(FormProvider, {
|
|
1277
|
-
initialValues: runIfFn(initialValues, item),
|
|
1278
|
-
validationSchema: schema,
|
|
1279
|
-
onSubmit: save,
|
|
1280
|
-
enableReinitialize: true,
|
|
1281
|
-
children: [jsx(ScreenTopBar, {
|
|
1282
|
-
tabbed: tabbed,
|
|
1283
|
-
api: api,
|
|
1284
|
-
breadcrumbs: breadcrumbs,
|
|
1285
|
-
buttonBar: buttonBar,
|
|
1286
|
-
item: item,
|
|
1287
|
-
isLoading: mutation.isLoading,
|
|
1288
|
-
trackingRef: containerRef === null || containerRef === void 0 ? void 0 : containerRef.current
|
|
1289
|
-
}), type == "form" && (sections === null || sections === void 0 ? void 0 : sections.map((section, index) => jsx(Section, {
|
|
1290
|
-
section: section,
|
|
1291
|
-
item: item
|
|
1292
|
-
}, index))), (pScreen.type == "post" || pScreen.type == "section") && jsx("div", {
|
|
1293
|
-
p: "5",
|
|
1294
|
-
bgColor: "slate-100",
|
|
1295
|
-
rounded: "lg",
|
|
1296
|
-
children: jsxs(PageContainer, {
|
|
1297
|
-
w: editorMaxW ? "auto" : "full",
|
|
1298
|
-
size: "x2",
|
|
1299
|
-
id: "pagecontainer",
|
|
1300
|
-
children: [header, jsxs("div", {
|
|
1301
|
-
dflex: true,
|
|
1302
|
-
gap: "5",
|
|
1303
|
-
children: [jsxs("div", {
|
|
1304
|
-
dflex: true,
|
|
1305
|
-
flexCol: true,
|
|
1306
|
-
gap: "8",
|
|
1307
|
-
flexGrow: true,
|
|
1308
|
-
children: [((_a = pScreen.editor) === null || _a === void 0 ? void 0 : _a.type) != "textarea" &&
|
|
1309
|
-
// TODO Find a way to make this editor shrink in width when resizing the window...
|
|
1310
|
-
jsx(PageContentEditor, {
|
|
1311
|
-
name: "content",
|
|
1312
|
-
maxW: editorMaxW,
|
|
1313
|
-
minW: "144",
|
|
1314
|
-
shadow: true,
|
|
1315
|
-
rounded: "lg"
|
|
1316
|
-
}), ((_b = pScreen.editor) === null || _b === void 0 ? void 0 : _b.type) == "textarea" && jsx(TextArea, {
|
|
1317
|
-
name: (_c = pScreen.editor) === null || _c === void 0 ? void 0 : _c.name,
|
|
1318
|
-
maxW: editorMaxW,
|
|
1319
|
-
minW: editorMaxW,
|
|
1320
|
-
w: editorMaxW,
|
|
1321
|
-
minH: "128",
|
|
1322
|
-
rows: 25,
|
|
1323
|
-
bgColor: "white",
|
|
1324
|
-
border: "0",
|
|
1325
|
-
shadow: true,
|
|
1326
|
-
p: "5",
|
|
1327
|
-
textColor: "slate-800"
|
|
1328
|
-
}), pScreen.editorFooter]
|
|
1329
|
-
}), jsx(PageSidebar, {
|
|
1330
|
-
children: sections === null || sections === void 0 ? void 0 : sections.map((section, index) => jsx(Section, {
|
|
1331
|
-
section: section,
|
|
1332
|
-
item: item,
|
|
1333
|
-
cardStyle: true
|
|
1334
|
-
}, index))
|
|
1335
|
-
})]
|
|
1336
|
-
})]
|
|
1337
|
-
})
|
|
1338
|
-
})]
|
|
1339
|
-
});
|
|
1340
|
-
}
|
|
1341
|
-
function Section({
|
|
1342
|
-
section,
|
|
1343
|
-
item,
|
|
1344
|
-
cardStyle
|
|
1345
|
-
}) {
|
|
1346
|
-
if (section.type === "section") {
|
|
1347
|
-
const style = cardStyle ? {
|
|
1348
|
-
bgColor: "white",
|
|
1349
|
-
rounded: "lg",
|
|
1350
|
-
p: "5",
|
|
1351
|
-
textSize: "sm",
|
|
1352
|
-
shadow: true
|
|
1353
|
-
} : {};
|
|
1354
|
-
return jsx(PageSidebarSection, Object.assign({
|
|
1355
|
-
title: section.title
|
|
1356
|
-
}, style, {
|
|
1357
|
-
children: jsx(FormRenderer, {
|
|
1358
|
-
form: runIfFn(section.form, item)
|
|
1359
|
-
})
|
|
1360
|
-
}));
|
|
1361
|
-
}
|
|
1362
|
-
if (section.type === "custom") return runIfFn(section.component, item);
|
|
1363
|
-
return null;
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
function useApi(api, queryField) {
|
|
1367
|
-
const params = useParams();
|
|
1368
|
-
if (queryField === undefined) return {
|
|
1369
|
-
id: undefined,
|
|
1370
|
-
api: api
|
|
1371
|
-
};
|
|
1372
|
-
const {
|
|
1373
|
-
[queryField]: id
|
|
1374
|
-
} = params;
|
|
1375
|
-
return {
|
|
1376
|
-
id,
|
|
1377
|
-
api: runIfFn(api, id)
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
function QueryWrapper(_a) {
|
|
1381
|
-
var {
|
|
1382
|
-
api,
|
|
1383
|
-
queryField,
|
|
1384
|
-
fn,
|
|
1385
|
-
transformFn,
|
|
1386
|
-
config,
|
|
1387
|
-
tabbed
|
|
1388
|
-
} = _a,
|
|
1389
|
-
props = __rest(_a, ["api", "queryField", "fn", "transformFn", "config", "tabbed"]);
|
|
1390
|
-
const {
|
|
1391
|
-
id,
|
|
1392
|
-
api: mApi
|
|
1393
|
-
} = useApi(api, queryField);
|
|
1394
|
-
const {
|
|
1395
|
-
data
|
|
1396
|
-
} = useApiQuery(mApi.queryKey, fn === "get" || fn === "getTransformed" ? mApi.get : mApi.getAll, isFunction(api) ? undefined : id);
|
|
1397
|
-
const transformedData = React.useMemo(() => {
|
|
1398
|
-
if (data && (fn === "getTransformed" || fn === "getAllTransformed")) {
|
|
1399
|
-
if (!transformFn) console.warn(`QueryWrapperDialog: you forgot to pass transformFn as parameter for fn ${fn}`);
|
|
1400
|
-
return transformFn === null || transformFn === void 0 ? void 0 : transformFn(data);
|
|
1401
|
-
}
|
|
1402
|
-
return data;
|
|
1403
|
-
}, [data]);
|
|
1404
|
-
// TODO states
|
|
1405
|
-
if (!data) return null;
|
|
1406
|
-
return jsx(ScreenRenderer, Object.assign({
|
|
1407
|
-
config: config(transformedData),
|
|
1408
|
-
tabbed: tabbed
|
|
1409
|
-
}, props));
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
function TabbedView(_a) {
|
|
1413
|
-
var {
|
|
1414
|
-
queryField,
|
|
1415
|
-
api,
|
|
1416
|
-
screen
|
|
1417
|
-
} = _a;
|
|
1418
|
-
__rest(_a, ["queryField", "api", "screen"]);
|
|
1419
|
-
const {
|
|
1420
|
-
[queryField]: id
|
|
1421
|
-
} = useParams();
|
|
1422
|
-
return jsx(PageQueryStateContainer, {
|
|
1423
|
-
queryId: id,
|
|
1424
|
-
api: api,
|
|
1425
|
-
apiFn: "get",
|
|
1426
|
-
p: "5",
|
|
1427
|
-
children: city => {
|
|
1428
|
-
const {
|
|
1429
|
-
breadcrumbs,
|
|
1430
|
-
tabs
|
|
1431
|
-
} = runIfFn(screen, city);
|
|
1432
|
-
return jsxs(PageTabbedTopBarProvider, {
|
|
1433
|
-
children: [jsx(PageTabbedTopBar, {
|
|
1434
|
-
breadcrumbs: breadcrumbs,
|
|
1435
|
-
mb: "-3"
|
|
1436
|
-
}), jsx(TabContainer, {
|
|
1437
|
-
tabs: tabs.map(tab => tab.label),
|
|
1438
|
-
saveKey: `tab-${id}`,
|
|
1439
|
-
mt: "-3",
|
|
1440
|
-
mb: "3",
|
|
1441
|
-
id: "fff",
|
|
1442
|
-
children: tabs.map((tab, index) => jsx(TabView, {
|
|
1443
|
-
tab: tab
|
|
1444
|
-
}, index))
|
|
1445
|
-
})]
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
});
|
|
1449
|
-
}
|
|
1450
|
-
function TabView({
|
|
1451
|
-
tab
|
|
1452
|
-
}) {
|
|
1453
|
-
if (!tab.component && !tab.config) throw new Error(`Screen config for tabbed view: one of your tabs does not have a component or config declared: ${tab.label}`);
|
|
1454
|
-
if (tab.component) return tab.component();
|
|
1455
|
-
return jsx(ScreenRenderer, {
|
|
1456
|
-
config: tab.config,
|
|
1457
|
-
tabbed: true,
|
|
1458
|
-
p: "0"
|
|
1459
|
-
});
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
const [provider$1, useContext$1] = createContext$1();
|
|
1463
|
-
function getColId(column) {
|
|
1464
|
-
var _a;
|
|
1465
|
-
return (_a = column.accessorKey) !== null && _a !== void 0 ? _a : column.id;
|
|
1466
|
-
}
|
|
1467
|
-
function TableContainerContextProvider({
|
|
1468
|
-
initialVisibleColumns,
|
|
1469
|
-
columns,
|
|
1470
|
-
children
|
|
1471
|
-
}) {
|
|
1472
|
-
var _a, _b;
|
|
1473
|
-
const [showFilters, setShowFilters] = React.useState(false);
|
|
1474
|
-
const [showMassActions, setShowMassActions] = React.useState(false);
|
|
1475
|
-
const [visibleColumnIds, setVisibleColumnIds] = React.useState((_a = initialVisibleColumns !== null && initialVisibleColumns !== void 0 ? initialVisibleColumns : columns === null || columns === void 0 ? void 0 : columns.map(col => getColId(col))) !== null && _a !== void 0 ? _a : []);
|
|
1476
|
-
const filteredColumns = (_b = columns === null || columns === void 0 ? void 0 : columns.filter(col => visibleColumnIds.includes(getColId(col)))) !== null && _b !== void 0 ? _b : [];
|
|
1477
|
-
const toggleColumnVisibility = React.useCallback(id => {
|
|
1478
|
-
const index = visibleColumnIds.indexOf(id);
|
|
1479
|
-
if (index > -1) {
|
|
1480
|
-
const newIds = visibleColumnIds.concat();
|
|
1481
|
-
newIds.splice(index, 1);
|
|
1482
|
-
setVisibleColumnIds(newIds);
|
|
1483
|
-
} else {
|
|
1484
|
-
setVisibleColumnIds(visibleColumnIds.concat(id));
|
|
1485
|
-
}
|
|
1486
|
-
}, [visibleColumnIds, setVisibleColumnIds]);
|
|
1487
|
-
const isColumnVisible = React.useCallback(id => {
|
|
1488
|
-
return visibleColumnIds.includes(id);
|
|
1489
|
-
}, [visibleColumnIds]);
|
|
1490
|
-
const Provider = provider$1;
|
|
1491
|
-
const value = {
|
|
1492
|
-
showFilters,
|
|
1493
|
-
setShowFilters,
|
|
1494
|
-
showMassActions,
|
|
1495
|
-
setShowMassActions,
|
|
1496
|
-
columns: columns !== null && columns !== void 0 ? columns : [],
|
|
1497
|
-
filteredColumns,
|
|
1498
|
-
toggleColumnVisibility,
|
|
1499
|
-
isColumnVisible
|
|
1500
|
-
};
|
|
1501
|
-
return jsx(Provider, {
|
|
1502
|
-
value: value,
|
|
1503
|
-
children: children
|
|
1504
|
-
});
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
function TableContainer(_a) {
|
|
1508
|
-
var {
|
|
1509
|
-
initialPageSize,
|
|
1510
|
-
initialVisibleColumns,
|
|
1511
|
-
columns,
|
|
1512
|
-
filtersMethod = "reactRouter",
|
|
1513
|
-
children
|
|
1514
|
-
} = _a,
|
|
1515
|
-
props = __rest(_a, ["initialPageSize", "initialVisibleColumns", "columns", "filtersMethod", "children"]);
|
|
1516
|
-
return jsx("div", Object.assign({
|
|
1517
|
-
w: "full",
|
|
1518
|
-
dflex: true,
|
|
1519
|
-
flexCol: true
|
|
1520
|
-
}, props, {
|
|
1521
|
-
children: jsx(TableContextProvider, {
|
|
1522
|
-
initialPageSize: initialPageSize,
|
|
1523
|
-
filtersMethod: filtersMethod,
|
|
1524
|
-
children: jsx(TableContainerContextProvider, {
|
|
1525
|
-
columns: columns,
|
|
1526
|
-
initialVisibleColumns: initialVisibleColumns,
|
|
1527
|
-
children: children
|
|
1528
|
-
})
|
|
1529
|
-
})
|
|
1530
|
-
}));
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
function TableCreateButton(_a) {
|
|
1534
|
-
var {
|
|
1535
|
-
icon,
|
|
1536
|
-
children
|
|
1537
|
-
} = _a,
|
|
1538
|
-
props = __rest(_a, ["icon", "children"]);
|
|
1539
|
-
return jsxs(ButtonBarDialogButton$1, Object.assign({}, props, {
|
|
1540
|
-
children: [jsx(Icon, {
|
|
1541
|
-
path: icon !== null && icon !== void 0 ? icon : mdiPlusThick
|
|
1542
|
-
}), children]
|
|
1543
|
-
}));
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
function TableFilterButton(_a) {
|
|
1547
|
-
var props = __rest(_a, []);
|
|
1548
|
-
// return <Button scheme="secondary" {...props}><Icon path={mdiFilter} /></Button>
|
|
1549
|
-
return jsxs(Popover, {
|
|
1550
|
-
side: "bottom-end",
|
|
1551
|
-
modal: true,
|
|
1552
|
-
children: [jsx(Button, Object.assign({
|
|
1553
|
-
scheme: "dark",
|
|
1554
|
-
size: "sm",
|
|
1555
|
-
aspectRatio: "square",
|
|
1556
|
-
variant: "borderless",
|
|
1557
|
-
corners: "square"
|
|
1558
|
-
}, props, {
|
|
1559
|
-
children: jsx(Icon, {
|
|
1560
|
-
path: mdiFilter
|
|
1561
|
-
})
|
|
1562
|
-
})), jsxs("div", {
|
|
1563
|
-
bgColor: "white",
|
|
1564
|
-
rounded: true,
|
|
1565
|
-
shadow: true,
|
|
1566
|
-
children: [jsx("div", {
|
|
1567
|
-
py: "3",
|
|
1568
|
-
hover_bgColor: "#ff0000",
|
|
1569
|
-
px: "5",
|
|
1570
|
-
hover_textColor: "white",
|
|
1571
|
-
children: "First Item"
|
|
1572
|
-
}), jsx("div", {
|
|
1573
|
-
py: "3",
|
|
1574
|
-
hover_bgColor: "#ff0000",
|
|
1575
|
-
px: "5",
|
|
1576
|
-
hover_textColor: "white",
|
|
1577
|
-
children: "Second Item"
|
|
1578
|
-
}), jsx("div", {
|
|
1579
|
-
py: "3",
|
|
1580
|
-
hover_bgColor: "#ff0000",
|
|
1581
|
-
px: "5",
|
|
1582
|
-
hover_textColor: "white",
|
|
1583
|
-
children: "Third Item"
|
|
1584
|
-
})]
|
|
1585
|
-
})]
|
|
1586
|
-
});
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
function TableTopBar(_a) {
|
|
1590
|
-
var {
|
|
1591
|
-
title,
|
|
1592
|
-
breadcrumbs,
|
|
1593
|
-
children
|
|
1594
|
-
} = _a,
|
|
1595
|
-
props = __rest(_a, ["title", "breadcrumbs", "children"]);
|
|
1596
|
-
return jsxs("div", Object.assign({
|
|
1597
|
-
dflex: true,
|
|
1598
|
-
flexRow: true,
|
|
1599
|
-
alignItems: "center",
|
|
1600
|
-
gap: "3",
|
|
1601
|
-
p: "8"
|
|
1602
|
-
}, props, {
|
|
1603
|
-
children: [jsxs("div", {
|
|
1604
|
-
children: [title && jsx("h2", {
|
|
1605
|
-
textSize: "x2",
|
|
1606
|
-
fontWeight: "600",
|
|
1607
|
-
textColor: "#3f4254",
|
|
1608
|
-
textTransform: "capitalize",
|
|
1609
|
-
children: title
|
|
1610
|
-
}), breadcrumbs && jsx(Breadcrumbs$1, {
|
|
1611
|
-
breadcrumbs: breadcrumbs
|
|
1612
|
-
})]
|
|
1613
|
-
}), jsx("div", {
|
|
1614
|
-
flexGrow: true,
|
|
1615
|
-
children: "\u00A0"
|
|
1616
|
-
}), children]
|
|
1617
|
-
}));
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
function compareValues(a, b, order) {
|
|
1621
|
-
if (a < b) {
|
|
1622
|
-
return order === 'asc' ? -1 : 1;
|
|
1623
|
-
}
|
|
1624
|
-
if (a > b) {
|
|
1625
|
-
return order === 'asc' ? 1 : -1;
|
|
1626
|
-
}
|
|
1627
|
-
return 0;
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
function orderBy(arr, criteria, orders) {
|
|
1631
|
-
return arr.slice().sort((a, b) => {
|
|
1632
|
-
const ordersLength = orders.length;
|
|
1633
|
-
for (let i = 0; i < criteria.length; i++) {
|
|
1634
|
-
const order = ordersLength > i ? orders[i] : orders[ordersLength - 1];
|
|
1635
|
-
const criterion = criteria[i];
|
|
1636
|
-
const criterionIsFunction = typeof criterion === 'function';
|
|
1637
|
-
const valueA = criterionIsFunction ? criterion(a) : a[criterion];
|
|
1638
|
-
const valueB = criterionIsFunction ? criterion(b) : b[criterion];
|
|
1639
|
-
const result = compareValues(valueA, valueB, order);
|
|
1640
|
-
if (result !== 0) {
|
|
1641
|
-
return result;
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
return 0;
|
|
1645
|
-
});
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
function sortBy(arr, criteria) {
|
|
1649
|
-
return orderBy(arr, criteria, ['asc']);
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
function TableFilters({
|
|
1653
|
-
form,
|
|
1654
|
-
initialValues,
|
|
1655
|
-
schema,
|
|
1656
|
-
processInput
|
|
1657
|
-
}) {
|
|
1658
|
-
const {
|
|
1659
|
-
showFilters
|
|
1660
|
-
} = useContext$1();
|
|
1661
|
-
const {
|
|
1662
|
-
getFilters,
|
|
1663
|
-
setFilters
|
|
1664
|
-
} = useTableContext();
|
|
1665
|
-
const handleSubmit = React.useCallback((values, actions) => {
|
|
1666
|
-
var _a;
|
|
1667
|
-
const params = (_a = processInput === null || processInput === void 0 ? void 0 : processInput(values)) !== null && _a !== void 0 ? _a : values;
|
|
1668
|
-
if (!isEqual(params, getFilters())) setFilters(params);
|
|
1669
|
-
// setFilters(processInput?.(values) ?? values)
|
|
1670
|
-
actions.setSubmitting(false);
|
|
1671
|
-
}, [setFilters, processInput]);
|
|
1672
|
-
const handleReset = React.useCallback(resetForm => {
|
|
1673
|
-
setFilters(initialValues);
|
|
1674
|
-
resetForm();
|
|
1675
|
-
}, [setFilters, initialValues]);
|
|
1676
|
-
React.useEffect(() => setFilters(initialValues), []);
|
|
1677
|
-
return jsx(Collapse, {
|
|
1678
|
-
in: showFilters,
|
|
1679
|
-
style: {
|
|
1680
|
-
overflow: showFilters ? "initial" : "hidden"
|
|
1681
|
-
},
|
|
1682
|
-
children: jsx("div", {
|
|
1683
|
-
p: "8",
|
|
1684
|
-
borderT: "px",
|
|
1685
|
-
borderB: "px",
|
|
1686
|
-
borderColor: "slate-100",
|
|
1687
|
-
children: jsx(FormProvider, {
|
|
1688
|
-
initialValues: mergeInitialFormValues(getFilters(), initialValues),
|
|
1689
|
-
onSubmit: handleSubmit,
|
|
1690
|
-
validationSchema: schema,
|
|
1691
|
-
enableReinitialize: true,
|
|
1692
|
-
children: props => jsxs("div", {
|
|
1693
|
-
dflex: true,
|
|
1694
|
-
gap: "3",
|
|
1695
|
-
placeContent: "start",
|
|
1696
|
-
children: [jsx(FormRenderer, {
|
|
1697
|
-
flexRow: true,
|
|
1698
|
-
w: "auto",
|
|
1699
|
-
form: form
|
|
1700
|
-
}), jsx(Buttons, {
|
|
1701
|
-
handleReset: () => handleReset(props.resetForm)
|
|
1702
|
-
})]
|
|
1703
|
-
})
|
|
1704
|
-
})
|
|
1705
|
-
})
|
|
1706
|
-
});
|
|
1707
|
-
}
|
|
1708
|
-
function Buttons({
|
|
1709
|
-
handleReset
|
|
1710
|
-
}) {
|
|
1711
|
-
return jsxs("div", {
|
|
1712
|
-
dflex: true,
|
|
1713
|
-
gap: "3",
|
|
1714
|
-
children: [jsxs("div", {
|
|
1715
|
-
dflex: true,
|
|
1716
|
-
flexCol: true,
|
|
1717
|
-
children: [jsx(FieldLabel, {
|
|
1718
|
-
name: "",
|
|
1719
|
-
label: "\u00A0"
|
|
1720
|
-
}), jsx(SubmitButton, {
|
|
1721
|
-
children: "Filter"
|
|
1722
|
-
})]
|
|
1723
|
-
}), jsxs("div", {
|
|
1724
|
-
dflex: true,
|
|
1725
|
-
flexCol: true,
|
|
1726
|
-
children: [jsx(FieldLabel, {
|
|
1727
|
-
name: "",
|
|
1728
|
-
label: "\u00A0"
|
|
1729
|
-
}), jsx(Button, {
|
|
1730
|
-
scheme: "neutral",
|
|
1731
|
-
onClick: handleReset,
|
|
1732
|
-
children: "Reset"
|
|
1733
|
-
})]
|
|
1734
|
-
})]
|
|
1735
|
-
});
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
function ActionButton$1({
|
|
1739
|
-
label,
|
|
1740
|
-
buttonProps,
|
|
1741
|
-
icon,
|
|
1742
|
-
queryKey,
|
|
1743
|
-
queryFn,
|
|
1744
|
-
successMsg,
|
|
1745
|
-
errorMsg,
|
|
1746
|
-
invalidateParent
|
|
1747
|
-
}) {
|
|
1748
|
-
const mutation = invalidateParent ? useInvalidateParentMutation(queryFn, queryKey) : useApiMutation(queryFn, queryKey);
|
|
1749
|
-
const mutate = useMutate(mutation, {
|
|
1750
|
-
successMsg,
|
|
1751
|
-
errorMsg
|
|
1752
|
-
});
|
|
1753
|
-
return jsxs(Button, Object.assign({
|
|
1754
|
-
display: "flex",
|
|
1755
|
-
alignItems: "center",
|
|
1756
|
-
gap: "3"
|
|
1757
|
-
}, buttonProps, {
|
|
1758
|
-
onClick: mutate,
|
|
1759
|
-
disabled: mutation.isLoading,
|
|
1760
|
-
children: [icon && jsx(Icon, {
|
|
1761
|
-
path: icon
|
|
1762
|
-
}), label]
|
|
1763
|
-
}));
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
function TableMassActions({
|
|
1767
|
-
actions
|
|
1768
|
-
}) {
|
|
1769
|
-
const {
|
|
1770
|
-
ids
|
|
1771
|
-
} = useTableContext();
|
|
1772
|
-
const showMassActions = ids && ids.length > 0;
|
|
1773
|
-
return jsx(Collapse, {
|
|
1774
|
-
in: showMassActions,
|
|
1775
|
-
style: {
|
|
1776
|
-
overflow: showMassActions ? "initial" : "hidden"
|
|
1777
|
-
},
|
|
1778
|
-
children: jsx("div", {
|
|
1779
|
-
dflex: true,
|
|
1780
|
-
gap: "3",
|
|
1781
|
-
flexWrap: true,
|
|
1782
|
-
alignItems: "center",
|
|
1783
|
-
px: "8",
|
|
1784
|
-
pt: "5",
|
|
1785
|
-
children: actions.map((action, index) => jsx("div", {
|
|
1786
|
-
children: action.type == "button" && !action.showConfirmationDialog && jsx(ActionButton$1, {
|
|
1787
|
-
label: action.label,
|
|
1788
|
-
queryFn: action.queryFn,
|
|
1789
|
-
queryKey: action.queryKey,
|
|
1790
|
-
buttonProps: action.buttonProps
|
|
1791
|
-
})
|
|
1792
|
-
}, index))
|
|
1793
|
-
})
|
|
1794
|
-
});
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
|
-
const defaultErrorMsg$1 = "Oops, something went wrong...";
|
|
1798
|
-
function nonNullValues(data) {
|
|
1799
|
-
var _a;
|
|
1800
|
-
if (data) {
|
|
1801
|
-
const nonNullData = Object.assign({}, data);
|
|
1802
|
-
for (const key in data) nonNullData[key] = (_a = nonNullData[key]) !== null && _a !== void 0 ? _a : "";
|
|
1803
|
-
return nonNullData;
|
|
1804
|
-
}
|
|
1805
|
-
return data;
|
|
1806
|
-
}
|
|
1807
|
-
function ItemEditDialog(_a) {
|
|
1808
|
-
var _b, _c, _d, _e;
|
|
1809
|
-
var {
|
|
1810
|
-
initialValues,
|
|
1811
|
-
itemLabel,
|
|
1812
|
-
queryId = "",
|
|
1813
|
-
api,
|
|
1814
|
-
queryFetchOptions,
|
|
1815
|
-
querySaveOptions,
|
|
1816
|
-
onSuccess,
|
|
1817
|
-
onFetchError,
|
|
1818
|
-
fetchErrorMsg = defaultErrorMsg$1,
|
|
1819
|
-
onSaveError,
|
|
1820
|
-
saveErrorMsg = defaultErrorMsg$1,
|
|
1821
|
-
fetchToFormData,
|
|
1822
|
-
formToQueryData,
|
|
1823
|
-
invalidateQueriesOnSuccess = true,
|
|
1824
|
-
invalidateQueryKey,
|
|
1825
|
-
retryText = "Retry",
|
|
1826
|
-
cancelLabel = "Cancel",
|
|
1827
|
-
saveLabel,
|
|
1828
|
-
size = "lg",
|
|
1829
|
-
title,
|
|
1830
|
-
form,
|
|
1831
|
-
show,
|
|
1832
|
-
onClose,
|
|
1833
|
-
formikProps
|
|
1834
|
-
} = _a,
|
|
1835
|
-
props = __rest(_a, ["initialValues", "itemLabel", "queryId", "api", "queryFetchOptions", "querySaveOptions", "onSuccess", "onFetchError", "fetchErrorMsg", "onSaveError", "saveErrorMsg", "fetchToFormData", "formToQueryData", "invalidateQueriesOnSuccess", "invalidateQueryKey", "retryText", "cancelLabel", "saveLabel", "size", "title", "form", "show", "onClose", "formikProps"]);
|
|
1836
|
-
const {
|
|
1837
|
-
isInitialLoading,
|
|
1838
|
-
isFetching,
|
|
1839
|
-
data,
|
|
1840
|
-
isError,
|
|
1841
|
-
error /*, error*/,
|
|
1842
|
-
refetch
|
|
1843
|
-
} = useApiQuery(api.queryKey, api.get, queryId, Object.assign({
|
|
1844
|
-
enabled: !(/*queryId == 0 || */queryId == "" || queryId == null || queryId == undefined),
|
|
1845
|
-
onError: onFetchError
|
|
1846
|
-
}, queryFetchOptions));
|
|
1847
|
-
// const [activeTab, setActiveTab] = React.useState(form && Array.isArray(form) ? form[0].key : "");
|
|
1848
|
-
// const [showTab, setShowTab] = React.useState(true);
|
|
1849
|
-
const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(api.upsert, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : api.queryKey, querySaveOptions) : useApiMutation(api.upsert, api.queryKey, queryId, querySaveOptions);
|
|
1850
|
-
const retry = React.useCallback(() => refetch(), [refetch]);
|
|
1851
|
-
const saveItem = React.useCallback((item, actions) => __awaiter(this, void 0, void 0, function* () {
|
|
1852
|
-
// Clear mutation error if any
|
|
1853
|
-
mutation.reset();
|
|
1854
|
-
const formItem = formToQueryData ? formToQueryData(item) : Object.assign({}, item);
|
|
1855
|
-
yield mutation.mutateAsync(formItem).then(response => {
|
|
1856
|
-
var _a;
|
|
1857
|
-
if (onSuccess) onSuccess(formItem, response);else toast.success(`${title ? title(formItem) : (_a = formItem.name) !== null && _a !== void 0 ? _a : formItem.title} ${queryId ? "saved" : "created"}`);
|
|
1858
|
-
// closing delete modal
|
|
1859
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
1860
|
-
}).catch(error => {
|
|
1861
|
-
var _a;
|
|
1862
|
-
console.error("on error", error);
|
|
1863
|
-
if (onSaveError) onSaveError(item);else toast.error(`Couldn't save ${title ? title(formItem) : (_a = formItem.name) !== null && _a !== void 0 ? _a : formItem.title}`);
|
|
1864
|
-
actions.setSubmitting(false);
|
|
1865
|
-
});
|
|
1866
|
-
}), [mutation, formToQueryData, onSuccess, onSaveError, onClose]);
|
|
1867
|
-
// const switchTab = React.useCallback((tab: string) =>
|
|
1868
|
-
// {
|
|
1869
|
-
// setActiveTab(tab);
|
|
1870
|
-
// setShowTab(false);
|
|
1871
|
-
// setTimeout(function ()
|
|
1872
|
-
// {
|
|
1873
|
-
// setActiveTab(tab);
|
|
1874
|
-
// setShowTab(true);
|
|
1875
|
-
// }, 150);
|
|
1876
|
-
// }, [setActiveTab])
|
|
1877
|
-
return jsxs(Modal, Object.assign({
|
|
1878
|
-
size: size,
|
|
1879
|
-
show: show,
|
|
1880
|
-
onClose: onClose,
|
|
1881
|
-
scheme: "light",
|
|
1882
|
-
transition: true
|
|
1883
|
-
}, props, {
|
|
1884
|
-
children: [jsxs(Modal.Header, {
|
|
1885
|
-
children: [!isInitialLoading && queryId && `Edit ${title ? title(data) : (_d = (_c = (_b = data === null || data === void 0 ? void 0 : data["name"]) !== null && _b !== void 0 ? _b : data === null || data === void 0 ? void 0 : data["title"]) !== null && _c !== void 0 ? _c : data === null || data === void 0 ? void 0 : data["name"]) !== null && _d !== void 0 ? _d : ""}`, !queryId && `Create new ${itemLabel !== null && itemLabel !== void 0 ? itemLabel : "item"}`, Array.isArray(form) && jsx(Fragment, {})
|
|
1886
|
-
// <ul className="nav nav-bold nav-pills">
|
|
1887
|
-
// {form.map(item =>
|
|
1888
|
-
// <li key={item.key} className="nav-item cursor-pointer bg-hover-light rounded" onClick={() => switchTab(item.key)}>
|
|
1889
|
-
// <span className={clsx("nav-link", activeTab === item.key && "active")} data-toggle="tab">{item.label}</span>
|
|
1890
|
-
// </li>
|
|
1891
|
-
// )}
|
|
1892
|
-
// </ul>
|
|
1893
|
-
]
|
|
1894
|
-
}), isInitialLoading && jsx(Modal.Body, {
|
|
1895
|
-
children: jsx(QueryLoadingState, {
|
|
1896
|
-
minW: "72"
|
|
1897
|
-
})
|
|
1898
|
-
}), isError && jsx(Modal.Body, {
|
|
1899
|
-
children: jsx(RetryOnError, {
|
|
1900
|
-
label: `${fetchErrorMsg} ${error}`,
|
|
1901
|
-
onClick: retry
|
|
1902
|
-
})
|
|
1903
|
-
}), !isInitialLoading && !isError && jsx(Fragment, {
|
|
1904
|
-
children: jsx(Formik
|
|
1905
|
-
// initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
|
|
1906
|
-
, Object.assign({
|
|
1907
|
-
// initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
|
|
1908
|
-
initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : (_e = nonNullValues(initialValues(data))) !== null && _e !== void 0 ? _e : {},
|
|
1909
|
-
onSubmit: saveItem
|
|
1910
|
-
}, formikProps, {
|
|
1911
|
-
children: ({
|
|
1912
|
-
setFieldValue,
|
|
1913
|
-
dirty,
|
|
1914
|
-
handleSubmit,
|
|
1915
|
-
isValid,
|
|
1916
|
-
values
|
|
1917
|
-
}) => jsxs(Fragment, {
|
|
1918
|
-
children: [jsx(Modal.Body, {
|
|
1919
|
-
pb: "6",
|
|
1920
|
-
children: jsxs(Form, {
|
|
1921
|
-
children: [/*#__PURE__*/React.isValidElement(form) && form, Array.isArray(form) && jsx(FormRenderer, {
|
|
1922
|
-
form: form
|
|
1923
|
-
}), isFunction(form) && jsx(FormRenderer, {
|
|
1924
|
-
form: form(data !== null && data !== void 0 ? data : values)
|
|
1925
|
-
})]
|
|
1926
|
-
})
|
|
1927
|
-
}), jsxs(Modal.Footer, {
|
|
1928
|
-
dflex: true,
|
|
1929
|
-
placeContent: "end",
|
|
1930
|
-
spaceX: "3",
|
|
1931
|
-
children: [jsx(Button, {
|
|
1932
|
-
disabled: mutation.isLoading,
|
|
1933
|
-
onClick: onClose,
|
|
1934
|
-
variant: "borderless",
|
|
1935
|
-
me: "2",
|
|
1936
|
-
children: cancelLabel
|
|
1937
|
-
}), jsx(Button, {
|
|
1938
|
-
type: "submit",
|
|
1939
|
-
disabled: !dirty || mutation.isLoading /* || !isValid*/,
|
|
1940
|
-
onClick: () => handleSubmit(),
|
|
1941
|
-
children: saveLabel ? saveLabel : queryId ? "Update" : "Create"
|
|
1942
|
-
})]
|
|
1943
|
-
})]
|
|
1944
|
-
})
|
|
1945
|
-
}))
|
|
1946
|
-
}), mutation.isLoading && jsx(ModalLoadingOverlay, {})]
|
|
1947
|
-
}));
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
function QueryWrapperDialog({
|
|
1951
|
-
api,
|
|
1952
|
-
fn,
|
|
1953
|
-
transformFn,
|
|
1954
|
-
config,
|
|
1955
|
-
onClose,
|
|
1956
|
-
queryId,
|
|
1957
|
-
invalidateQueryKey
|
|
1958
|
-
}) {
|
|
1959
|
-
const {
|
|
1960
|
-
data,
|
|
1961
|
-
isFetching
|
|
1962
|
-
} = useApiQuery(api.queryKey, fn === "get" || fn === "getTransformed" ? api.get : api.getAll, undefined, {
|
|
1963
|
-
retryOnMount: false,
|
|
1964
|
-
refetchOnMount: false,
|
|
1965
|
-
refetchOnWindowFocus: false
|
|
1966
|
-
});
|
|
1967
|
-
const transformedData = React.useMemo(() => {
|
|
1968
|
-
if (data && (fn === "getTransformed" || fn === "getAllTransformed")) {
|
|
1969
|
-
if (!transformFn) console.warn(`QueryWrapperDialog: you forgot to pass transformFn as parameter for fn ${fn}`);
|
|
1970
|
-
// @ts-ignore
|
|
1971
|
-
return transformFn === null || transformFn === void 0 ? void 0 : transformFn(data);
|
|
1972
|
-
}
|
|
1973
|
-
return data;
|
|
1974
|
-
}, [data, fn, transformFn]);
|
|
1975
|
-
if (isFetching) return null;
|
|
1976
|
-
// @ts-ignore
|
|
1977
|
-
return jsx(ItemEditDialog, Object.assign({}, config(transformedData), {
|
|
1978
|
-
queryId: queryId,
|
|
1979
|
-
invalidateQueryKey: invalidateQueryKey,
|
|
1980
|
-
show: true,
|
|
1981
|
-
onClose: onClose
|
|
1982
|
-
}));
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
function MultiQueryWrapperDialog({
|
|
1986
|
-
queries,
|
|
1987
|
-
config,
|
|
1988
|
-
onClose,
|
|
1989
|
-
queryId,
|
|
1990
|
-
invalidateQueryKey
|
|
1991
|
-
}) {
|
|
1992
|
-
const {
|
|
1993
|
-
data,
|
|
1994
|
-
isFetching,
|
|
1995
|
-
isError
|
|
1996
|
-
} = useApiQueries(queries.map(q => ({
|
|
1997
|
-
queryKey: q.api.queryKey,
|
|
1998
|
-
queryFn: q.fn == "get" ? q.api.get : q.api.getAll,
|
|
1999
|
-
queryOptions: {
|
|
2000
|
-
cacheTime: q.cache === false ? 0 : undefined,
|
|
2001
|
-
staleTime: q.cache === false ? 0 : undefined
|
|
2002
|
-
}
|
|
2003
|
-
})));
|
|
2004
|
-
const transformedData = React.useMemo(() => {
|
|
2005
|
-
return data === null || data === void 0 ? void 0 : data.map((d, index) => {
|
|
2006
|
-
var _a, _b;
|
|
2007
|
-
return queries[index].transformFn ? (_b = (_a = queries[index]) === null || _a === void 0 ? void 0 : _a.transformFn) === null || _b === void 0 ? void 0 : _b.call(_a, d) : d;
|
|
2008
|
-
});
|
|
2009
|
-
}, [data, queries]);
|
|
2010
|
-
// TODO This is not really good
|
|
2011
|
-
// So instead, add a isPreloading and isPreloadingError to ItemEditDialog to handle the cases
|
|
2012
|
-
// if (isFetching)
|
|
2013
|
-
// return null
|
|
2014
|
-
// @ts-ignore
|
|
2015
|
-
return jsx(ItemEditDialog, Object.assign({
|
|
2016
|
-
isPreloading: isFetching
|
|
2017
|
-
}, config(...transformedData), {
|
|
2018
|
-
queryId: queryId,
|
|
2019
|
-
invalidateQueryKey: invalidateQueryKey,
|
|
2020
|
-
show: true,
|
|
2021
|
-
onClose: onClose
|
|
2022
|
-
}));
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
function DialogRenderer({
|
|
2026
|
-
config,
|
|
2027
|
-
onClose,
|
|
2028
|
-
invalidateQueryKey,
|
|
2029
|
-
queryId
|
|
2030
|
-
}) {
|
|
2031
|
-
const {
|
|
2032
|
-
type
|
|
2033
|
-
} = config,
|
|
2034
|
-
props = __rest(config, ["type"]);
|
|
2035
|
-
if (config.type === "dialog") return jsx(ItemEditDialog, Object.assign({}, props, {
|
|
2036
|
-
queryId: queryId,
|
|
2037
|
-
invalidateQueryKey: invalidateQueryKey,
|
|
2038
|
-
show: true,
|
|
2039
|
-
onClose: onClose
|
|
2040
|
-
}));
|
|
2041
|
-
if (config.type === "query") return jsx(QueryWrapperDialog, Object.assign({}, props, {
|
|
2042
|
-
queryId: queryId,
|
|
2043
|
-
invalidateQueryKey: invalidateQueryKey,
|
|
2044
|
-
onClose: onClose
|
|
2045
|
-
}));
|
|
2046
|
-
if (config.type === "multiQuery") return jsx(MultiQueryWrapperDialog, Object.assign({}, props, {
|
|
2047
|
-
queryId: queryId,
|
|
2048
|
-
invalidateQueryKey: invalidateQueryKey,
|
|
2049
|
-
onClose: onClose
|
|
2050
|
-
}));
|
|
2051
|
-
return null;
|
|
2052
|
-
}
|
|
2053
|
-
|
|
2054
|
-
function RefreshButton({
|
|
2055
|
-
queryKey
|
|
2056
|
-
}) {
|
|
2057
|
-
const invalidate = useInvalidateQuery(queryKey);
|
|
2058
|
-
fe('ctrl+r', () => invalidate(), {
|
|
2059
|
-
preventDefault: true
|
|
2060
|
-
}, [invalidate]);
|
|
2061
|
-
return jsx(ButtonBarButton, {
|
|
2062
|
-
scheme: "dark",
|
|
2063
|
-
size: "sm",
|
|
2064
|
-
aspectRatio: "square",
|
|
2065
|
-
variant: "borderless",
|
|
2066
|
-
onClick: invalidate,
|
|
2067
|
-
children: jsx(Icon, {
|
|
2068
|
-
path: mdiRefresh
|
|
2069
|
-
})
|
|
2070
|
-
});
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
|
-
function ItemDeleteDialog(_a) {
|
|
2074
|
-
var {
|
|
2075
|
-
title,
|
|
2076
|
-
actionButtonLabel,
|
|
2077
|
-
closeActionButtonLabel = "Cancel",
|
|
2078
|
-
itemLabel,
|
|
2079
|
-
queryId = "",
|
|
2080
|
-
api,
|
|
2081
|
-
apiFn,
|
|
2082
|
-
invalidateQueriesOnSuccess = true,
|
|
2083
|
-
invalidateQueryKey,
|
|
2084
|
-
size = "lg",
|
|
2085
|
-
md_boxSizing,
|
|
2086
|
-
msg,
|
|
2087
|
-
show,
|
|
2088
|
-
onClose,
|
|
2089
|
-
onSuccess
|
|
2090
|
-
} = _a,
|
|
2091
|
-
props = __rest(_a, ["title", "actionButtonLabel", "closeActionButtonLabel", "itemLabel", "queryId", "api", "apiFn", "invalidateQueriesOnSuccess", "invalidateQueryKey", "size", "md_boxSizing", "msg", "show", "onClose", "onSuccess"]);
|
|
2092
|
-
const fn = apiFn ? api[apiFn] : api.delete;
|
|
2093
|
-
const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(fn, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : api.queryKey) : useApiMutation(fn, api.queryKey);
|
|
2094
|
-
const mutate = useMutate(mutation, {
|
|
2095
|
-
onSuccess: () => {
|
|
2096
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
2097
|
-
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
2098
|
-
}
|
|
2099
|
-
});
|
|
2100
|
-
const handleDelete = React.useCallback(() => mutate(queryId), [mutate, queryId]);
|
|
2101
|
-
return jsxs(Modal, Object.assign({
|
|
2102
|
-
size: size,
|
|
2103
|
-
show: show,
|
|
2104
|
-
onClose: onClose,
|
|
2105
|
-
scheme: "danger",
|
|
2106
|
-
variant: "glass",
|
|
2107
|
-
transition: true
|
|
2108
|
-
}, props, {
|
|
2109
|
-
children: [jsx(Modal.Header, {
|
|
2110
|
-
children: title || `Delete ${itemLabel}`
|
|
2111
|
-
}), jsxs(Modal.Body, {
|
|
2112
|
-
pb: "6",
|
|
2113
|
-
children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && runIfFn(msg, itemLabel)]
|
|
2114
|
-
}), jsxs(Modal.Footer, {
|
|
2115
|
-
dflex: true,
|
|
2116
|
-
placeContent: "end",
|
|
2117
|
-
spaceX: "3",
|
|
2118
|
-
children: [jsx(Button, {
|
|
2119
|
-
disabled: mutation.isPending,
|
|
2120
|
-
onClick: onClose,
|
|
2121
|
-
variant: "borderless",
|
|
2122
|
-
scheme: "dark",
|
|
2123
|
-
me: "2",
|
|
2124
|
-
children: closeActionButtonLabel
|
|
2125
|
-
}), jsx(Button, {
|
|
2126
|
-
scheme: "danger",
|
|
2127
|
-
disabled: mutation.isPending,
|
|
2128
|
-
onClick: handleDelete,
|
|
2129
|
-
children: actionButtonLabel || "Delete"
|
|
2130
|
-
})]
|
|
2131
|
-
}), mutation.isPending && jsx(ModalLoadingOverlay, {})]
|
|
2132
|
-
}));
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
const [provider, useContext] = createContext$1();
|
|
2136
|
-
function TableViewProvider({
|
|
2137
|
-
editView,
|
|
2138
|
-
deleteItem,
|
|
2139
|
-
queryKey,
|
|
2140
|
-
children
|
|
2141
|
-
}) {
|
|
2142
|
-
const openLink = useOpenLink();
|
|
2143
|
-
const navigate = useNavigate();
|
|
2144
|
-
const [dialog, setDialog] = React.useState(null);
|
|
2145
|
-
const onCloseDialog = React.useCallback(() => setDialog(null), [setDialog]);
|
|
2146
|
-
const onAction = React.useCallback((action, item) => {
|
|
2147
|
-
switch (action.type) {
|
|
2148
|
-
case "view":
|
|
2149
|
-
{
|
|
2150
|
-
navigate(runIfFn(action.path, item));
|
|
2151
|
-
break;
|
|
2152
|
-
}
|
|
2153
|
-
case "link":
|
|
2154
|
-
{
|
|
2155
|
-
openLink(`${AppEnv.websiteUrl()}/${runIfFn(action.path, item)}`);
|
|
2156
|
-
break;
|
|
2157
|
-
}
|
|
2158
|
-
case "edit":
|
|
2159
|
-
{
|
|
2160
|
-
const editConfig = runIfFn(editView, item);
|
|
2161
|
-
if (editConfig) {
|
|
2162
|
-
if (editConfig.type == "customDialog") {
|
|
2163
|
-
setDialog(editConfig.render({
|
|
2164
|
-
show: true,
|
|
2165
|
-
onClose: onCloseDialog
|
|
2166
|
-
}));
|
|
2167
|
-
} else {
|
|
2168
|
-
setDialog(jsx(DialogRenderer, {
|
|
2169
|
-
onClose: onCloseDialog,
|
|
2170
|
-
config: editConfig,
|
|
2171
|
-
queryId: item.id,
|
|
2172
|
-
invalidateQueryKey: queryKey
|
|
2173
|
-
}));
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
break;
|
|
2177
|
-
}
|
|
2178
|
-
case "delete":
|
|
2179
|
-
{
|
|
2180
|
-
const deleteConfig = runIfFn(deleteItem, item);
|
|
2181
|
-
setDialog(jsx(ItemDeleteDialog, Object.assign({
|
|
2182
|
-
show: true,
|
|
2183
|
-
onClose: onCloseDialog,
|
|
2184
|
-
queryId: item.id,
|
|
2185
|
-
invalidateQueryKey: queryKey,
|
|
2186
|
-
msg: item.msg
|
|
2187
|
-
}, deleteConfig, {
|
|
2188
|
-
itemLabel: runIfFn(deleteConfig.itemLabel, item)
|
|
2189
|
-
})));
|
|
2190
|
-
// TODO
|
|
2191
|
-
// const { initialValues, ...props } = editItem!!
|
|
2192
|
-
// setDialog(<ItemEditDialog {...props} initialValues={runIfFn(initialValues, item)} show queryId={item?.id} onClose={onCloseDialog} />)
|
|
2193
|
-
break;
|
|
2194
|
-
}
|
|
2195
|
-
}
|
|
2196
|
-
}, [navigate, editView, deleteItem]);
|
|
2197
|
-
const Provider = provider;
|
|
2198
|
-
const value = {
|
|
2199
|
-
dialog,
|
|
2200
|
-
onAction
|
|
2201
|
-
};
|
|
2202
|
-
return jsx(Provider, {
|
|
2203
|
-
value: value,
|
|
2204
|
-
children: children
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
|
-
|
|
2208
|
-
/**
|
|
2209
|
-
* table-core
|
|
2210
|
-
*
|
|
2211
|
-
* Copyright (c) TanStack
|
|
2212
|
-
*
|
|
2213
|
-
* This source code is licensed under the MIT license found in the
|
|
2214
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
2215
|
-
*
|
|
2216
|
-
* @license MIT
|
|
2217
|
-
*/
|
|
2218
|
-
// type Person = {
|
|
2219
|
-
// firstName: string
|
|
2220
|
-
// lastName: string
|
|
2221
|
-
// age: number
|
|
2222
|
-
// visits: number
|
|
2223
|
-
// status: string
|
|
2224
|
-
// progress: number
|
|
2225
|
-
// createdAt: Date
|
|
2226
|
-
// nested: {
|
|
2227
|
-
// foo: [
|
|
2228
|
-
// {
|
|
2229
|
-
// bar: 'bar'
|
|
2230
|
-
// }
|
|
2231
|
-
// ]
|
|
2232
|
-
// bar: { subBar: boolean }[]
|
|
2233
|
-
// baz: {
|
|
2234
|
-
// foo: 'foo'
|
|
2235
|
-
// bar: {
|
|
2236
|
-
// baz: 'baz'
|
|
2237
|
-
// }
|
|
2238
|
-
// }
|
|
2239
|
-
// }
|
|
2240
|
-
// }
|
|
2241
|
-
|
|
2242
|
-
// const test: DeepKeys<Person> = 'nested.foo.0.bar'
|
|
2243
|
-
// const test2: DeepKeys<Person> = 'nested.bar'
|
|
2244
|
-
|
|
2245
|
-
// const helper = createColumnHelper<Person>()
|
|
2246
|
-
|
|
2247
|
-
// helper.accessor('nested.foo', {
|
|
2248
|
-
// cell: info => info.getValue(),
|
|
2249
|
-
// })
|
|
2250
|
-
|
|
2251
|
-
// helper.accessor('nested.foo.0.bar', {
|
|
2252
|
-
// cell: info => info.getValue(),
|
|
2253
|
-
// })
|
|
2254
|
-
|
|
2255
|
-
// helper.accessor('nested.bar', {
|
|
2256
|
-
// cell: info => info.getValue(),
|
|
2257
|
-
// })
|
|
2258
|
-
|
|
2259
|
-
function createColumnHelper() {
|
|
2260
|
-
return {
|
|
2261
|
-
accessor: (accessor, column) => {
|
|
2262
|
-
return typeof accessor === 'function' ? {
|
|
2263
|
-
...column,
|
|
2264
|
-
accessorFn: accessor
|
|
2265
|
-
} : {
|
|
2266
|
-
...column,
|
|
2267
|
-
accessorKey: accessor
|
|
2268
|
-
};
|
|
2269
|
-
},
|
|
2270
|
-
display: column => column,
|
|
2271
|
-
group: column => column
|
|
2272
|
-
};
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
|
-
function TableRowPublishPostButton$1(_a) {
|
|
2276
|
-
var {
|
|
2277
|
-
id,
|
|
2278
|
-
api,
|
|
2279
|
-
status,
|
|
2280
|
-
invalidateQueryKey
|
|
2281
|
-
} = _a,
|
|
2282
|
-
props = __rest(_a, ["id", "api", "status", "invalidateQueryKey"]);
|
|
2283
|
-
const isDraft = status == "draft";
|
|
2284
|
-
const mutation = useInvalidateParentMutation(isDraft ? api.publish : api.unpublish, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : api.queryKey, {
|
|
2285
|
-
networkMode: "always"
|
|
2286
|
-
});
|
|
2287
|
-
const publish = React.useCallback(event => {
|
|
2288
|
-
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
2289
|
-
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
2290
|
-
mutation.reset();
|
|
2291
|
-
mutation.mutateAsync(id).then(() => toast.success(isDraft ? "Published!" : "Unpublished!")).catch(error => toast.error(`Error: ${error}`));
|
|
2292
|
-
}, [mutation, id]);
|
|
2293
|
-
return jsx(Button, Object.assign({
|
|
2294
|
-
variant: "borderless",
|
|
2295
|
-
corners: "square",
|
|
2296
|
-
scheme: "dark",
|
|
2297
|
-
onClick: publish
|
|
2298
|
-
}, props, {
|
|
2299
|
-
children: jsx(Icon, {
|
|
2300
|
-
path: isDraft ? mdiPublish : mdiPublishOff,
|
|
2301
|
-
size: "sm"
|
|
2302
|
-
})
|
|
2303
|
-
}));
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
|
-
function TableRowActionsView({
|
|
2307
|
-
row,
|
|
2308
|
-
onAction,
|
|
2309
|
-
rowActions,
|
|
2310
|
-
api,
|
|
2311
|
-
queryKey
|
|
2312
|
-
}) {
|
|
2313
|
-
var _a;
|
|
2314
|
-
const item = row.original;
|
|
2315
|
-
return jsx("div", {
|
|
2316
|
-
dflex: true,
|
|
2317
|
-
w: "full",
|
|
2318
|
-
alignItems: "stretch",
|
|
2319
|
-
placeContent: "end",
|
|
2320
|
-
h: "full",
|
|
2321
|
-
children: (_a = runIfFn(rowActions, item)) === null || _a === void 0 ? void 0 : _a.map((action, index) => {
|
|
2322
|
-
var _a;
|
|
2323
|
-
return jsxs(React.Fragment, {
|
|
2324
|
-
children: [action.type === "publish" && jsx(TableRowPublishPostButton$1, {
|
|
2325
|
-
id: item.id,
|
|
2326
|
-
api: (_a = action.api) !== null && _a !== void 0 ? _a : api,
|
|
2327
|
-
status: item.status,
|
|
2328
|
-
invalidateQueryKey: queryKey
|
|
2329
|
-
}), action.type == "custom" && jsx(Fragment, {
|
|
2330
|
-
children: action.component(item, queryKey, action.icon, action.label)
|
|
2331
|
-
}), !["publish", "custom"].includes(action.type) && jsx(ActionButton, {
|
|
2332
|
-
onClick: () => onAction(action, item),
|
|
2333
|
-
scheme: schemes$1[action.type],
|
|
2334
|
-
children: jsx(Icon, {
|
|
2335
|
-
path: icons[action.type],
|
|
2336
|
-
size: "sm"
|
|
2337
|
-
})
|
|
2338
|
-
})]
|
|
2339
|
-
}, index);
|
|
2340
|
-
})
|
|
2341
|
-
});
|
|
2342
|
-
}
|
|
2343
|
-
function ActionButton(_a) {
|
|
2344
|
-
var {
|
|
2345
|
-
onClick
|
|
2346
|
-
} = _a,
|
|
2347
|
-
props = __rest(_a, ["onClick"]);
|
|
2348
|
-
const handleClick = React.useCallback(event => {
|
|
2349
|
-
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
2350
|
-
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
2351
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
2352
|
-
}, [onClick]);
|
|
2353
|
-
return jsx(TableRowActionButton$1, Object.assign({
|
|
2354
|
-
onClick: handleClick
|
|
2355
|
-
}, props));
|
|
2356
|
-
}
|
|
2357
|
-
const icons = {
|
|
2358
|
-
"link": mdiOpenInNew,
|
|
2359
|
-
"view": mdiEye,
|
|
2360
|
-
"edit": mdiPencil,
|
|
2361
|
-
"delete": mdiDelete,
|
|
2362
|
-
"publish": mdiDelete,
|
|
2363
|
-
"custom": ""
|
|
2364
|
-
};
|
|
2365
|
-
const schemes$1 = {
|
|
2366
|
-
"link": "dark",
|
|
2367
|
-
"view": "dark",
|
|
2368
|
-
"edit": "dark",
|
|
2369
|
-
"delete": "dark",
|
|
2370
|
-
"publish": "dark",
|
|
2371
|
-
"custom": "dark"
|
|
2372
|
-
};
|
|
2373
|
-
|
|
2374
|
-
function useTableProps(api, table, rowActions, queryParams) {
|
|
2375
|
-
const navigate = useNavigate();
|
|
2376
|
-
const nextRouter = useRouter();
|
|
2377
|
-
const openLink = useOpenLink();
|
|
2378
|
-
const {
|
|
2379
|
-
onAction
|
|
2380
|
-
} = useContext();
|
|
2381
|
-
const {
|
|
2382
|
-
onRowClick,
|
|
2383
|
-
columns: c
|
|
2384
|
-
} = table,
|
|
2385
|
-
props = __rest(table, ["onRowClick", "columns"]);
|
|
2386
|
-
const onRowClickHandler = React.useCallback(item => {
|
|
2387
|
-
var _a;
|
|
2388
|
-
const config = runIfFn(onRowClick, item);
|
|
2389
|
-
if (config) {
|
|
2390
|
-
switch (config.type) {
|
|
2391
|
-
case "navigate":
|
|
2392
|
-
{
|
|
2393
|
-
navigate((_a = runIfFn(config.path, item)) !== null && _a !== void 0 ? _a : "");
|
|
2394
|
-
break;
|
|
2395
|
-
}
|
|
2396
|
-
case "nextpush":
|
|
2397
|
-
{
|
|
2398
|
-
nextRouter.push(runIfFn(config.path, item));
|
|
2399
|
-
break;
|
|
2400
|
-
}
|
|
2401
|
-
case "link":
|
|
2402
|
-
{
|
|
2403
|
-
openLink(`${AppEnv.websiteUrl()}/${runIfFn(config.path, item)}`);
|
|
2404
|
-
break;
|
|
2405
|
-
}
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
|
-
}, [navigate, onRowClick]);
|
|
2409
|
-
const columns = React.useMemo(() => {
|
|
2410
|
-
const columns = table.columns.concat([]);
|
|
2411
|
-
if (rowActions) {
|
|
2412
|
-
columns.push(createColumnHelper().display({
|
|
2413
|
-
id: "actions",
|
|
2414
|
-
header: "Actions",
|
|
2415
|
-
cell: props => jsx(TableRowActionsView, {
|
|
2416
|
-
row: props.row,
|
|
2417
|
-
onAction: onAction,
|
|
2418
|
-
rowActions: rowActions,
|
|
2419
|
-
api: api,
|
|
2420
|
-
queryKey: api.queryKey
|
|
2421
|
-
})
|
|
2422
|
-
}));
|
|
2423
|
-
}
|
|
2424
|
-
return columns;
|
|
2425
|
-
}, [table, onAction, rowActions, api]);
|
|
2426
|
-
const tableProps = Object.assign({}, props);
|
|
2427
|
-
tableProps.columns = columns;
|
|
2428
|
-
tableProps.onRowClick = onRowClickHandler;
|
|
2429
|
-
tableProps.queryKey = api.queryKey;
|
|
2430
|
-
tableProps.queryFilters = queryParams;
|
|
2431
|
-
tableProps.queryFn = api.search;
|
|
2432
|
-
return tableProps;
|
|
2433
|
-
}
|
|
2434
|
-
|
|
2435
|
-
function useId(queryField) {
|
|
2436
|
-
const params = useParams();
|
|
2437
|
-
if (queryField === undefined) return undefined;
|
|
2438
|
-
const {
|
|
2439
|
-
[queryField]: id
|
|
2440
|
-
} = params;
|
|
2441
|
-
return id;
|
|
2442
|
-
}
|
|
2443
|
-
function TableView(_a) {
|
|
2444
|
-
var {
|
|
2445
|
-
queryField,
|
|
2446
|
-
title,
|
|
2447
|
-
subtitle,
|
|
2448
|
-
screen
|
|
2449
|
-
} = _a,
|
|
2450
|
-
props = __rest(_a, ["queryField", "title", "subtitle", "screen"]);
|
|
2451
|
-
const id = useId(queryField);
|
|
2452
|
-
const _screen = runIfFn(screen, id);
|
|
2453
|
-
return jsx(PageContainer, Object.assign({
|
|
2454
|
-
bgColor: "white"
|
|
2455
|
-
}, props, {
|
|
2456
|
-
children: jsx(TableContainer, {
|
|
2457
|
-
columns: _screen.table.columns,
|
|
2458
|
-
initialVisibleColumns: _screen.table.initialVisibleColumns,
|
|
2459
|
-
filtersMethod: _screen.table.filtersMethod,
|
|
2460
|
-
children: jsx(TT, {
|
|
2461
|
-
id: id,
|
|
2462
|
-
title: title,
|
|
2463
|
-
subtitle: subtitle,
|
|
2464
|
-
screen: _screen
|
|
2465
|
-
})
|
|
2466
|
-
})
|
|
2467
|
-
}));
|
|
2468
|
-
}
|
|
2469
|
-
function TT({
|
|
2470
|
-
id,
|
|
2471
|
-
title,
|
|
2472
|
-
subtitle,
|
|
2473
|
-
screen
|
|
2474
|
-
}) {
|
|
2475
|
-
const {
|
|
2476
|
-
setRowSelection
|
|
2477
|
-
} = useTableContext();
|
|
2478
|
-
const {
|
|
2479
|
-
api,
|
|
2480
|
-
table,
|
|
2481
|
-
filters,
|
|
2482
|
-
massActions,
|
|
2483
|
-
buttonBar,
|
|
2484
|
-
rowActions,
|
|
2485
|
-
createView,
|
|
2486
|
-
editView,
|
|
2487
|
-
deleteItem,
|
|
2488
|
-
breadcrumbs
|
|
2489
|
-
} = screen;
|
|
2490
|
-
const tableApi = runIfFn(api, id !== null && id !== void 0 ? id : "");
|
|
2491
|
-
return jsxs(Fragment, {
|
|
2492
|
-
children: [jsx(TableTopBar, {
|
|
2493
|
-
title: title,
|
|
2494
|
-
breadcrumbs: breadcrumbs,
|
|
2495
|
-
children: jsx(TableButtonBar, {
|
|
2496
|
-
buttonBar: buttonBar,
|
|
2497
|
-
createView: createView,
|
|
2498
|
-
editView: editView,
|
|
2499
|
-
api: tableApi,
|
|
2500
|
-
queryKey: tableApi.queryKey,
|
|
2501
|
-
children: filters && jsx(TableFilterButton, {})
|
|
2502
|
-
})
|
|
2503
|
-
}), filters && jsx(TableFilters, {
|
|
2504
|
-
form: filters.form,
|
|
2505
|
-
initialValues: filters.initialValues,
|
|
2506
|
-
schema: filters.schema,
|
|
2507
|
-
processInput: filters.processInput
|
|
2508
|
-
}), massActions && jsx(TableMassActions, {
|
|
2509
|
-
actions: massActions.items
|
|
2510
|
-
}), jsxs(TableViewProvider, {
|
|
2511
|
-
queryKey: tableApi.queryKey,
|
|
2512
|
-
editView: editView,
|
|
2513
|
-
deleteItem: deleteItem,
|
|
2514
|
-
children: [jsx(TableWrapper, {
|
|
2515
|
-
table: Object.assign(Object.assign({}, table), {
|
|
2516
|
-
onSelectionChange: setRowSelection
|
|
2517
|
-
}),
|
|
2518
|
-
rowActions: rowActions,
|
|
2519
|
-
api: tableApi,
|
|
2520
|
-
subtitle: subtitle,
|
|
2521
|
-
queryParams: screen.queryParams
|
|
2522
|
-
}), jsx(TableDialogManager, {})]
|
|
2523
|
-
})]
|
|
2524
|
-
});
|
|
2525
|
-
}
|
|
2526
|
-
function TableButtonBar({
|
|
2527
|
-
buttonBar,
|
|
2528
|
-
queryKey,
|
|
2529
|
-
createView,
|
|
2530
|
-
editView,
|
|
2531
|
-
api,
|
|
2532
|
-
children
|
|
2533
|
-
}) {
|
|
2534
|
-
const createDialogFn = React.useCallback(data => {
|
|
2535
|
-
return onClose => {
|
|
2536
|
-
var _a;
|
|
2537
|
-
const view = (_a = runIfFn(createView, data)) !== null && _a !== void 0 ? _a : runIfFn(editView, null);
|
|
2538
|
-
if (view.type == "customDialog") return view.render({
|
|
2539
|
-
show: true,
|
|
2540
|
-
onClose
|
|
2541
|
-
});else return jsx(DialogRenderer, {
|
|
2542
|
-
config: view,
|
|
2543
|
-
onClose: onClose,
|
|
2544
|
-
invalidateQueryKey: api.queryKey
|
|
2545
|
-
});
|
|
2546
|
-
};
|
|
2547
|
-
}, [createView, editView, api]);
|
|
2548
|
-
return jsxs(ButtonBar, {
|
|
2549
|
-
children: [jsx(RefreshButton, {
|
|
2550
|
-
queryKey: queryKey
|
|
2551
|
-
}), buttonBar && buttonBar.map((button, index) => jsxs(React.Fragment, {
|
|
2552
|
-
children: [button.type === "create" && editView && jsx(TableCreateButton, {
|
|
2553
|
-
buildDialog: createDialogFn(button.data),
|
|
2554
|
-
icon: button.icon,
|
|
2555
|
-
children: button.label
|
|
2556
|
-
}), button.type === "invalidate" && jsx(InvalidateButton, {
|
|
2557
|
-
pathOrPermalink: button.pathOrPermalink
|
|
2558
|
-
}), button.type === "custom" && button.render()]
|
|
2559
|
-
}, index)), children]
|
|
2560
|
-
});
|
|
2561
|
-
}
|
|
2562
|
-
function TableWrapper({
|
|
2563
|
-
table,
|
|
2564
|
-
subtitle,
|
|
2565
|
-
rowActions,
|
|
2566
|
-
api,
|
|
2567
|
-
queryParams
|
|
2568
|
-
}) {
|
|
2569
|
-
const tableProps = useTableProps(api, table, rowActions, queryParams);
|
|
2570
|
-
const _subtitle = React.useMemo(() => {
|
|
2571
|
-
if (!subtitle) return undefined;
|
|
2572
|
-
return data => {
|
|
2573
|
-
return jsx("div", {
|
|
2574
|
-
textSize: "lg",
|
|
2575
|
-
textColor: "#475569",
|
|
2576
|
-
fontWeight: "600",
|
|
2577
|
-
children: isFunction(subtitle) ? subtitle(data) : subtitle
|
|
2578
|
-
});
|
|
2579
|
-
};
|
|
2580
|
-
}, [subtitle]);
|
|
2581
|
-
return jsx(Table, Object.assign({}, tableProps, {
|
|
2582
|
-
p: "8",
|
|
2583
|
-
title: _subtitle
|
|
2584
|
-
}));
|
|
2585
|
-
}
|
|
2586
|
-
function TableDialogManager() {
|
|
2587
|
-
const {
|
|
2588
|
-
dialog
|
|
2589
|
-
} = useContext();
|
|
2590
|
-
return dialog;
|
|
2591
|
-
}
|
|
2592
|
-
|
|
2593
|
-
function useQueries(queries) {
|
|
2594
|
-
const params = useParams();
|
|
2595
|
-
const {
|
|
2596
|
-
data,
|
|
2597
|
-
isFetching,
|
|
2598
|
-
isError
|
|
2599
|
-
} = useApiQueries(queries.map(q => {
|
|
2600
|
-
if (!q.queryField) {
|
|
2601
|
-
const _api = runIfFn(q.api);
|
|
2602
|
-
return {
|
|
2603
|
-
queryKey: _api.queryKey,
|
|
2604
|
-
queryFn: q.fn == "get" ? _api.get : _api.getAll,
|
|
2605
|
-
queryParam: q.params
|
|
2606
|
-
};
|
|
2607
|
-
}
|
|
2608
|
-
const id = params[q.queryField];
|
|
2609
|
-
const api = runIfFn(q.api, id);
|
|
2610
|
-
return {
|
|
2611
|
-
queryKey: api.queryKey,
|
|
2612
|
-
queryFn: q.fn == "get" ? api.get : api.getAll,
|
|
2613
|
-
queryParam: q.fn == "getAll" ? q.params : isFunction(q.api) ? undefined : id
|
|
2614
|
-
};
|
|
2615
|
-
}));
|
|
2616
|
-
let transformedData = undefined;
|
|
2617
|
-
if (!isFetching && !isError) {
|
|
2618
|
-
transformedData = data === null || data === void 0 ? void 0 : data.map((d, index) => {
|
|
2619
|
-
var _a, _b;
|
|
2620
|
-
return queries[index].transformFn ? (_b = (_a = queries[index]).transformFn) === null || _b === void 0 ? void 0 : _b.call(_a, d) : d;
|
|
2621
|
-
});
|
|
2622
|
-
}
|
|
2623
|
-
return {
|
|
2624
|
-
data: transformedData,
|
|
2625
|
-
isFetching,
|
|
2626
|
-
isError
|
|
2627
|
-
};
|
|
2628
|
-
}
|
|
2629
|
-
function useInvalidate(queries) {
|
|
2630
|
-
const queryClient = useQueryClient();
|
|
2631
|
-
const params = useParams();
|
|
2632
|
-
const invalidate = React.useCallback(() => {
|
|
2633
|
-
const queryKeys = [];
|
|
2634
|
-
queries.forEach(q => {
|
|
2635
|
-
if (!q.queryField || !isFunction(q.api)) {
|
|
2636
|
-
queryKeys.push(q.api.queryKey);
|
|
2637
|
-
} else {
|
|
2638
|
-
const id = params[q.queryField];
|
|
2639
|
-
const api = runIfFn(q.api, id);
|
|
2640
|
-
queryKeys.push(api.queryKey);
|
|
2641
|
-
}
|
|
2642
|
-
});
|
|
2643
|
-
queryClient.invalidateQueries({
|
|
2644
|
-
predicate: query => queryKeys.includes(query.queryKey)
|
|
2645
|
-
});
|
|
2646
|
-
}, [queries, queryClient, params]);
|
|
2647
|
-
return invalidate;
|
|
2648
|
-
}
|
|
2649
|
-
function MultiQueryWrapper(_a) {
|
|
2650
|
-
var {
|
|
2651
|
-
queries,
|
|
2652
|
-
config,
|
|
2653
|
-
tabbed
|
|
2654
|
-
} = _a,
|
|
2655
|
-
props = __rest(_a, ["queries", "config", "tabbed"]);
|
|
2656
|
-
const {
|
|
2657
|
-
data,
|
|
2658
|
-
isFetching,
|
|
2659
|
-
isError
|
|
2660
|
-
} = useQueries(queries);
|
|
2661
|
-
const invalidate = useInvalidate(queries);
|
|
2662
|
-
if (isFetching) return jsx(QueryLoadingState, {
|
|
2663
|
-
w: "full",
|
|
2664
|
-
h: "100vh"
|
|
2665
|
-
});
|
|
2666
|
-
if (isError || !data) return jsx(RetryOnError, {
|
|
2667
|
-
p: "0",
|
|
2668
|
-
w: "full",
|
|
2669
|
-
h: "100vh",
|
|
2670
|
-
onClick: invalidate
|
|
2671
|
-
});
|
|
2672
|
-
return jsx(ScreenRenderer, Object.assign({
|
|
2673
|
-
config: config(...data),
|
|
2674
|
-
tabbed: tabbed
|
|
2675
|
-
}, props));
|
|
2676
|
-
}
|
|
2677
|
-
|
|
2678
|
-
function ScreenRenderer(_a) {
|
|
2679
|
-
var {
|
|
2680
|
-
config,
|
|
2681
|
-
tabbed
|
|
2682
|
-
} = _a,
|
|
2683
|
-
props = __rest(_a, ["config", "tabbed"]);
|
|
2684
|
-
if (config.type === "table") return jsx(TableView, Object.assign({}, config, props));
|
|
2685
|
-
if (config.type === "tabbed") return jsx(TabbedView, Object.assign({}, config, props));
|
|
2686
|
-
if (config.type === "details") return jsx(DetailsView, Object.assign({}, config, {
|
|
2687
|
-
tabbed: tabbed
|
|
2688
|
-
}, props));
|
|
2689
|
-
if (config.type === "query") return jsx(QueryWrapper, Object.assign({}, config, {
|
|
2690
|
-
tabbed: tabbed
|
|
2691
|
-
}, props));
|
|
2692
|
-
if (config.type === "multiQuery") return jsx(MultiQueryWrapper, Object.assign({}, config, {
|
|
2693
|
-
tabbed: tabbed
|
|
2694
|
-
}, props));
|
|
2695
|
-
return jsx(Fragment, {});
|
|
2696
|
-
}
|
|
2697
|
-
|
|
2698
|
-
/**
|
|
2699
|
-
*
|
|
2700
|
-
*
|
|
2701
|
-
*/
|
|
2702
|
-
function Content(_a) {
|
|
2703
|
-
var props = __rest(_a, []);
|
|
2704
|
-
return jsx("div", Object.assign({
|
|
2705
|
-
w: "100%",
|
|
2706
|
-
h: "100%",
|
|
2707
|
-
overflowY: "auto"
|
|
2708
|
-
}, props, {
|
|
2709
|
-
children: jsx(Outlet, {})
|
|
2710
|
-
}));
|
|
2711
|
-
}
|
|
2712
|
-
|
|
2713
|
-
function SelectedIndicator({
|
|
2714
|
-
darkMode
|
|
2715
|
-
}) {
|
|
2716
|
-
return jsx("div", {
|
|
2717
|
-
position: "absolute",
|
|
2718
|
-
bgColor: darkMode ? "white" : "black",
|
|
2719
|
-
bgOpacity: "90",
|
|
2720
|
-
w: "0.5",
|
|
2721
|
-
h: "6",
|
|
2722
|
-
top: "1.5",
|
|
2723
|
-
start: "-4"
|
|
2724
|
-
});
|
|
2725
|
-
}
|
|
2726
|
-
|
|
2727
|
-
function MenuButton(_a) {
|
|
2728
|
-
var {
|
|
2729
|
-
depth,
|
|
2730
|
-
darkMode,
|
|
2731
|
-
icon,
|
|
2732
|
-
selected,
|
|
2733
|
-
children
|
|
2734
|
-
} = _a,
|
|
2735
|
-
props = __rest(_a, ["depth", "darkMode", "icon", "selected", "children"]);
|
|
2736
|
-
return jsxs(Button, Object.assign({
|
|
2737
|
-
as: "li",
|
|
2738
|
-
minH: "8",
|
|
2739
|
-
ms: `${(depth !== null && depth !== void 0 ? depth : 0) * 2}`,
|
|
2740
|
-
p: "2",
|
|
2741
|
-
font: "title",
|
|
2742
|
-
textColor: darkMode ? "white" : "black",
|
|
2743
|
-
fontWeight: "600",
|
|
2744
|
-
rounded: "lg",
|
|
2745
|
-
textSize: "sm",
|
|
2746
|
-
variant: "borderless",
|
|
2747
|
-
hover_bgColor: darkMode ? "white" : "black",
|
|
2748
|
-
hover_bgOpacity: "10",
|
|
2749
|
-
hover_textColor: darkMode ? "white" : "zinc-800",
|
|
2750
|
-
cursor: "pointer",
|
|
2751
|
-
dflex: true,
|
|
2752
|
-
alignItems: "center",
|
|
2753
|
-
gap: "3"
|
|
2754
|
-
}, props, {
|
|
2755
|
-
children: [icon && jsx(Icon, {
|
|
2756
|
-
path: icon,
|
|
2757
|
-
opacity: selected ? "100" : "60"
|
|
2758
|
-
}), children]
|
|
2759
|
-
}));
|
|
2760
|
-
}
|
|
2761
|
-
|
|
2762
|
-
function MenuItem$1(_a) {
|
|
2763
|
-
var {
|
|
2764
|
-
icon,
|
|
2765
|
-
path,
|
|
2766
|
-
depth,
|
|
2767
|
-
darkMode,
|
|
2768
|
-
subMenu
|
|
2769
|
-
} = _a,
|
|
2770
|
-
props = __rest(_a, ["icon", "path", "depth", "darkMode", "subMenu"]);
|
|
2771
|
-
const location = useLocation();
|
|
2772
|
-
const selected = path == "/" ? location.pathname == "/" : location.pathname.startsWith(path.startsWith("/") ? path : `/${path}`);
|
|
2773
|
-
const match = useMatch("/" + path) != null;
|
|
2774
|
-
// const selected = match != null
|
|
2775
|
-
return jsxs(Fragment, {
|
|
2776
|
-
children: [jsxs(Link$1, {
|
|
2777
|
-
to: path,
|
|
2778
|
-
style: {
|
|
2779
|
-
position: "relative"
|
|
2780
|
-
},
|
|
2781
|
-
children: [jsx(MenuButton, Object.assign({
|
|
2782
|
-
depth: depth,
|
|
2783
|
-
darkMode: darkMode,
|
|
2784
|
-
icon: icon,
|
|
2785
|
-
selected: selected
|
|
2786
|
-
}, props)), match && jsx(SelectedIndicator, {
|
|
2787
|
-
darkMode: darkMode
|
|
2788
|
-
})]
|
|
2789
|
-
}), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsx(MenuItem$1, {
|
|
2790
|
-
icon: item.icon,
|
|
2791
|
-
path: item.path,
|
|
2792
|
-
depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
|
|
2793
|
-
darkMode: darkMode,
|
|
2794
|
-
subMenu: item.children,
|
|
2795
|
-
children: item.label
|
|
2796
|
-
}, index))]
|
|
2797
|
-
});
|
|
2798
|
-
}
|
|
2799
|
-
|
|
2800
|
-
function NextMenuItem(_a) {
|
|
2801
|
-
var {
|
|
2802
|
-
icon,
|
|
2803
|
-
path,
|
|
2804
|
-
depth,
|
|
2805
|
-
darkMode,
|
|
2806
|
-
subMenu
|
|
2807
|
-
} = _a,
|
|
2808
|
-
props = __rest(_a, ["icon", "path", "depth", "darkMode", "subMenu"]);
|
|
2809
|
-
const {
|
|
2810
|
-
pathname
|
|
2811
|
-
} = useRouter();
|
|
2812
|
-
const selected = path == "/" ? pathname == "/" : pathname.startsWith(path.startsWith("/") ? path : `/${path}`);
|
|
2813
|
-
const match = path == "/" ? pathname == "/" : pathname == (path.startsWith("/") ? path : `/${path}`);
|
|
2814
|
-
return jsxs(Fragment, {
|
|
2815
|
-
children: [jsxs(Link, {
|
|
2816
|
-
href: path,
|
|
2817
|
-
style: {
|
|
2818
|
-
position: "relative"
|
|
2819
|
-
},
|
|
2820
|
-
children: [jsx(MenuButton, Object.assign({
|
|
2821
|
-
depth: depth,
|
|
2822
|
-
darkMode: darkMode,
|
|
2823
|
-
icon: icon,
|
|
2824
|
-
selected: selected
|
|
2825
|
-
}, props)), match && jsx(SelectedIndicator, {
|
|
2826
|
-
darkMode: darkMode
|
|
2827
|
-
})]
|
|
2828
|
-
}), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsx(NextMenuItem, {
|
|
2829
|
-
icon: item.icon,
|
|
2830
|
-
path: item.path,
|
|
2831
|
-
depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
|
|
2832
|
-
darkMode: darkMode,
|
|
2833
|
-
subMenu: item.children,
|
|
2834
|
-
children: item.label
|
|
2835
|
-
}, index))]
|
|
2836
|
-
});
|
|
2837
|
-
}
|
|
2838
|
-
|
|
2839
|
-
/**
|
|
2840
|
-
*
|
|
2841
|
-
*
|
|
2842
|
-
*/
|
|
2843
|
-
function Menu(_a) {
|
|
2844
|
-
var {
|
|
2845
|
-
darkMode,
|
|
2846
|
-
config,
|
|
2847
|
-
useNextRouter
|
|
2848
|
-
} = _a,
|
|
2849
|
-
props = __rest(_a, ["darkMode", "config", "useNextRouter"]);
|
|
2850
|
-
const Comp = useNextRouter ? NextMenuItem : MenuItem$1;
|
|
2851
|
-
return jsx("ul", Object.assign({}, props, {
|
|
2852
|
-
children: config.map((item, index) => {
|
|
2853
|
-
if (item.type == "divider") return jsx(Divider, {
|
|
2854
|
-
title: item.label
|
|
2855
|
-
}, index);
|
|
2856
|
-
if (item.type == "item") {
|
|
2857
|
-
return jsx(Comp, {
|
|
2858
|
-
icon: item.icon,
|
|
2859
|
-
path: item.path,
|
|
2860
|
-
depth: 0,
|
|
2861
|
-
darkMode: darkMode,
|
|
2862
|
-
subMenu: item.children,
|
|
2863
|
-
children: item.label
|
|
2864
|
-
}, index);
|
|
2865
|
-
}
|
|
2866
|
-
})
|
|
2867
|
-
}));
|
|
2868
|
-
}
|
|
2869
|
-
function Divider({
|
|
2870
|
-
title
|
|
2871
|
-
}) {
|
|
2872
|
-
return jsx("div", {
|
|
2873
|
-
px: "2",
|
|
2874
|
-
mt: "5",
|
|
2875
|
-
mb: "2",
|
|
2876
|
-
opacity: "75",
|
|
2877
|
-
textTransform: "capitalize",
|
|
2878
|
-
letterSpacing: "widest",
|
|
2879
|
-
fontWeight: "700",
|
|
2880
|
-
textSize: "xs",
|
|
2881
|
-
children: title
|
|
2882
|
-
});
|
|
2883
|
-
}
|
|
2884
|
-
|
|
2885
|
-
function UserBlock({
|
|
2886
|
-
color,
|
|
2887
|
-
darkMode,
|
|
2888
|
-
menuConfig,
|
|
2889
|
-
path
|
|
2890
|
-
}) {
|
|
2891
|
-
var _a, _b;
|
|
2892
|
-
const {
|
|
2893
|
-
isLoading,
|
|
2894
|
-
user
|
|
2895
|
-
} = useSessionUser();
|
|
2896
|
-
const navigate = useNavigate();
|
|
2897
|
-
const handleClick = React.useCallback(() => navigate(path), [navigate, path]);
|
|
2898
|
-
if (isLoading) return null;
|
|
2899
|
-
return jsxs("div", {
|
|
2900
|
-
dflex: true,
|
|
2901
|
-
alignItems: "center",
|
|
2902
|
-
border: "0.5",
|
|
2903
|
-
borderColor: `${color}-${darkMode ? "800" : "200"}`,
|
|
2904
|
-
ps: "3",
|
|
2905
|
-
py: "1.5",
|
|
2906
|
-
textSize: "md",
|
|
2907
|
-
rounded: "lg",
|
|
2908
|
-
hover_bgColor: `${color}-${darkMode ? "800" : "200"}`,
|
|
2909
|
-
cursor: "pointer",
|
|
2910
|
-
textColor: darkMode ? "white" : "slate-800",
|
|
2911
|
-
onClick: handleClick,
|
|
2912
|
-
children: [jsx(Avatar, {
|
|
2913
|
-
size: "sm",
|
|
2914
|
-
src: (_b = (_a = user === null || user === void 0 ? void 0 : user.media) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : "",
|
|
2915
|
-
name: `${user === null || user === void 0 ? void 0 : user.firstname} ${user === null || user === void 0 ? void 0 : user.lastname}`
|
|
2916
|
-
}), jsx("span", {
|
|
2917
|
-
flexGrow: true,
|
|
2918
|
-
ms: "2",
|
|
2919
|
-
children: `${capitalize((user === null || user === void 0 ? void 0 : user.firstname) || (user === null || user === void 0 ? void 0 : user.lastname) || "")}`
|
|
2920
|
-
}), jsx(IconButton, {
|
|
2921
|
-
variant: "borderless",
|
|
2922
|
-
corners: "pill",
|
|
2923
|
-
scheme: "dark",
|
|
2924
|
-
textColor: darkMode ? "white" : "slate-800",
|
|
2925
|
-
hover_textColor: darkMode ? "white" : "slate-800",
|
|
2926
|
-
hover_bgColor: `${color}-${darkMode ? "900" : "200"}`,
|
|
2927
|
-
icon: mdiCog,
|
|
2928
|
-
onClick: handleClick
|
|
2929
|
-
}), jsx(OverflowMenu, {
|
|
2930
|
-
color: color,
|
|
2931
|
-
darkMode: darkMode,
|
|
2932
|
-
menuConfig: menuConfig
|
|
2933
|
-
})]
|
|
2934
|
-
});
|
|
2935
|
-
}
|
|
2936
|
-
function OverflowMenu({
|
|
2937
|
-
color,
|
|
2938
|
-
darkMode,
|
|
2939
|
-
menuConfig
|
|
2940
|
-
}) {
|
|
2941
|
-
const [showPopup, setShowPopup] = React.useState(false);
|
|
2942
|
-
const navigate = useNavigate();
|
|
2943
|
-
const logout = useSessionLogout(false);
|
|
2944
|
-
return jsx(Fragment, {
|
|
2945
|
-
children: jsxs(Popup, {
|
|
2946
|
-
show: showPopup,
|
|
2947
|
-
position: "relative",
|
|
2948
|
-
side: "bottom-end",
|
|
2949
|
-
onClick: e => {
|
|
2950
|
-
e.preventDefault();
|
|
2951
|
-
e.stopPropagation();
|
|
2952
|
-
setShowPopup(show => !show);
|
|
2953
|
-
},
|
|
2954
|
-
onHide: () => setShowPopup(false),
|
|
2955
|
-
children: [jsx(IconButton, {
|
|
2956
|
-
icon: mdiDotsVertical,
|
|
2957
|
-
variant: "borderless",
|
|
2958
|
-
corners: "pill",
|
|
2959
|
-
scheme: "dark",
|
|
2960
|
-
textColor: darkMode ? "white" : "slate-800",
|
|
2961
|
-
hover_textColor: darkMode ? "white" : "slate-800",
|
|
2962
|
-
hover_bgColor: `${color}-${darkMode ? "900" : "200"}`
|
|
2963
|
-
}), jsxs("div", {
|
|
2964
|
-
bgColor: "white",
|
|
2965
|
-
rounded: "sm",
|
|
2966
|
-
overflow: "hidden",
|
|
2967
|
-
shadow: true,
|
|
2968
|
-
mt: "1",
|
|
2969
|
-
border: "px",
|
|
2970
|
-
borderColor: "gray-200",
|
|
2971
|
-
divideColor: "gray-200",
|
|
2972
|
-
divideY: "px",
|
|
2973
|
-
minW: "40",
|
|
2974
|
-
children: [menuConfig && menuConfig.length > 0 && menuConfig.map((item, index) => {
|
|
2975
|
-
if (item.type == "item") {
|
|
2976
|
-
return jsx(MenuItem, {
|
|
2977
|
-
icon: item.icon,
|
|
2978
|
-
onClick: () => navigate(item.path),
|
|
2979
|
-
children: item.label
|
|
2980
|
-
}, index);
|
|
2981
|
-
}
|
|
2982
|
-
return null;
|
|
2983
|
-
}), jsx(MenuItem, {
|
|
2984
|
-
icon: mdiLogout,
|
|
2985
|
-
onClick: logout,
|
|
2986
|
-
children: "Logout"
|
|
2987
|
-
})]
|
|
2988
|
-
})]
|
|
2989
|
-
})
|
|
2990
|
-
});
|
|
2991
|
-
}
|
|
2992
|
-
function MenuItem(_a) {
|
|
2993
|
-
var {
|
|
2994
|
-
icon,
|
|
2995
|
-
onClick,
|
|
2996
|
-
children
|
|
2997
|
-
} = _a,
|
|
2998
|
-
props = __rest(_a, ["icon", "onClick", "children"]);
|
|
2999
|
-
const handleClick = React.useCallback(e => {
|
|
3000
|
-
e.preventDefault();
|
|
3001
|
-
e.stopPropagation();
|
|
3002
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
3003
|
-
}, []);
|
|
3004
|
-
return jsxs(Button, Object.assign({
|
|
3005
|
-
variant: "borderless",
|
|
3006
|
-
scheme: "dark",
|
|
3007
|
-
size: "sm",
|
|
3008
|
-
alignItems: "center",
|
|
3009
|
-
dflex: true,
|
|
3010
|
-
gap: "2",
|
|
3011
|
-
px: "2",
|
|
3012
|
-
py: "1.5",
|
|
3013
|
-
w: "full",
|
|
3014
|
-
onClick: handleClick,
|
|
3015
|
-
textColor: "slate-700"
|
|
3016
|
-
}, props, {
|
|
3017
|
-
children: [icon && jsx(Icon, {
|
|
3018
|
-
path: icon,
|
|
3019
|
-
size: "md"
|
|
3020
|
-
}), children]
|
|
3021
|
-
}));
|
|
3022
|
-
}
|
|
3023
|
-
|
|
3024
|
-
function Sidebar(_a) {
|
|
3025
|
-
var {
|
|
3026
|
-
show,
|
|
3027
|
-
logo,
|
|
3028
|
-
title,
|
|
3029
|
-
menuConfig,
|
|
3030
|
-
userMenuConfig,
|
|
3031
|
-
userSettingsPath,
|
|
3032
|
-
color,
|
|
3033
|
-
darkMode
|
|
3034
|
-
} = _a,
|
|
3035
|
-
props = __rest(_a, ["show", "logo", "title", "menuConfig", "userMenuConfig", "userSettingsPath", "color", "darkMode"]);
|
|
3036
|
-
return jsxs("div", Object.assign({
|
|
3037
|
-
dflex: true,
|
|
3038
|
-
flexCol: true,
|
|
3039
|
-
w: "full",
|
|
3040
|
-
md_w: "64",
|
|
3041
|
-
minH: "screen",
|
|
3042
|
-
p: "0",
|
|
3043
|
-
textColor: darkMode ? "white" : "slate-800"
|
|
3044
|
-
}, props, {
|
|
3045
|
-
children: [jsxs(FlexCenter, {
|
|
3046
|
-
placeContent: "start",
|
|
3047
|
-
p: "4",
|
|
3048
|
-
font: "title",
|
|
3049
|
-
gap: "3",
|
|
3050
|
-
borderB: "px",
|
|
3051
|
-
borderBColor: "slate-900",
|
|
3052
|
-
borderOpacity: "5",
|
|
3053
|
-
children: [logo !== null && logo !== void 0 ? logo : jsx(Logo, {
|
|
3054
|
-
width: 40,
|
|
3055
|
-
height: 40,
|
|
3056
|
-
darkMode: darkMode
|
|
3057
|
-
}), jsx("h1", {
|
|
3058
|
-
textSize: "md",
|
|
3059
|
-
children: title || AppEnv.appName()
|
|
3060
|
-
})]
|
|
3061
|
-
}), jsx(Menu, {
|
|
3062
|
-
overflowY: "auto",
|
|
3063
|
-
flexGrow: "1",
|
|
3064
|
-
p: "4",
|
|
3065
|
-
darkMode: darkMode,
|
|
3066
|
-
config: menuConfig
|
|
3067
|
-
}), jsx("div", {
|
|
3068
|
-
p: "2",
|
|
3069
|
-
children: jsx(UserBlock, {
|
|
3070
|
-
darkMode: darkMode,
|
|
3071
|
-
color: color,
|
|
3072
|
-
menuConfig: userMenuConfig,
|
|
3073
|
-
path: userSettingsPath
|
|
3074
|
-
})
|
|
3075
|
-
})]
|
|
3076
|
-
}));
|
|
3077
|
-
}
|
|
3078
|
-
function Logo(_a) {
|
|
3079
|
-
var {
|
|
3080
|
-
width,
|
|
3081
|
-
height,
|
|
3082
|
-
darkMode
|
|
3083
|
-
} = _a,
|
|
3084
|
-
props = __rest(_a, ["width", "height", "darkMode"]);
|
|
3085
|
-
return jsx("div", Object.assign({}, props, {
|
|
3086
|
-
children: jsx(Image, {
|
|
3087
|
-
src: `/logo_${darkMode ? "light" : "dark"}.png`,
|
|
3088
|
-
alt: AppEnv.appName(),
|
|
3089
|
-
width: width,
|
|
3090
|
-
height: height,
|
|
3091
|
-
priority: true,
|
|
3092
|
-
unoptimized: true
|
|
3093
|
-
})
|
|
3094
|
-
}));
|
|
3095
|
-
}
|
|
3096
|
-
|
|
3097
|
-
function AdminLayout(_a) {
|
|
3098
|
-
var {
|
|
3099
|
-
color,
|
|
3100
|
-
darkMode,
|
|
3101
|
-
logo,
|
|
3102
|
-
title,
|
|
3103
|
-
menuConfig,
|
|
3104
|
-
userMenuConfig,
|
|
3105
|
-
userSettingsPath
|
|
3106
|
-
} = _a,
|
|
3107
|
-
props = __rest(_a, ["color", "darkMode", "logo", "title", "menuConfig", "userMenuConfig", "userSettingsPath"]);
|
|
3108
|
-
return jsxs("div", Object.assign({
|
|
3109
|
-
w: "full",
|
|
3110
|
-
h: "screen",
|
|
3111
|
-
dflex: true,
|
|
3112
|
-
flexRow: true,
|
|
3113
|
-
bgColor: `${color}-${darkMode ? "900" : "100"}`
|
|
3114
|
-
}, props, {
|
|
3115
|
-
children: [jsx(LeftPanel, {
|
|
3116
|
-
color: color,
|
|
3117
|
-
darkMode: darkMode,
|
|
3118
|
-
logo: logo,
|
|
3119
|
-
title: title,
|
|
3120
|
-
menuConfig: menuConfig,
|
|
3121
|
-
userMenuConfig: userMenuConfig,
|
|
3122
|
-
userSettingsPath: userSettingsPath
|
|
3123
|
-
}), jsx("div", {
|
|
3124
|
-
w: "screen",
|
|
3125
|
-
py: "2",
|
|
3126
|
-
pe: "2",
|
|
3127
|
-
children: jsx(Content, {
|
|
3128
|
-
bgColor: "white",
|
|
3129
|
-
rounded: "lg",
|
|
3130
|
-
shadow: true
|
|
3131
|
-
})
|
|
3132
|
-
})]
|
|
3133
|
-
}));
|
|
3134
|
-
}
|
|
3135
|
-
function LeftPanel({
|
|
3136
|
-
color,
|
|
3137
|
-
darkMode,
|
|
3138
|
-
logo,
|
|
3139
|
-
title,
|
|
3140
|
-
menuConfig,
|
|
3141
|
-
userMenuConfig,
|
|
3142
|
-
userSettingsPath
|
|
3143
|
-
}) {
|
|
3144
|
-
const [isOpen, __, toggle] = useBoolean(true);
|
|
3145
|
-
fe('ctrl+t', () => toggle(), [toggle]);
|
|
3146
|
-
return jsxs("div", {
|
|
3147
|
-
ms: isOpen ? "0" : "-14.5rem",
|
|
3148
|
-
transition: "all",
|
|
3149
|
-
duration: "500",
|
|
3150
|
-
transform: true,
|
|
3151
|
-
children: [jsx(Sidebar, {
|
|
3152
|
-
flexShrink: "0",
|
|
3153
|
-
color: color,
|
|
3154
|
-
darkMode: darkMode,
|
|
3155
|
-
logo: logo,
|
|
3156
|
-
title: title,
|
|
3157
|
-
menuConfig: menuConfig,
|
|
3158
|
-
userMenuConfig: userMenuConfig,
|
|
3159
|
-
userSettingsPath: userSettingsPath
|
|
3160
|
-
}), jsx(IconButton, {
|
|
3161
|
-
icon: mdiArrowLeft,
|
|
3162
|
-
transition: "all",
|
|
3163
|
-
duration: "500",
|
|
3164
|
-
transform: true,
|
|
3165
|
-
rotate: isOpen ? "0" : "180",
|
|
3166
|
-
position: "absolute",
|
|
3167
|
-
bottom: "14",
|
|
3168
|
-
end: "-5",
|
|
3169
|
-
size: "lg",
|
|
3170
|
-
corners: "pill",
|
|
3171
|
-
onClick: toggle,
|
|
3172
|
-
z: "100"
|
|
3173
|
-
})]
|
|
3174
|
-
});
|
|
3175
|
-
}
|
|
3176
|
-
|
|
3177
|
-
const defaultErrorMsg = "Oops, something went wrong...";
|
|
3178
|
-
function AttachDialog(_a) {
|
|
3179
|
-
var {
|
|
3180
|
-
queryId,
|
|
3181
|
-
queryKey,
|
|
3182
|
-
queryFetchFn,
|
|
3183
|
-
queryFetchAllKey,
|
|
3184
|
-
queryFetchAllFn,
|
|
3185
|
-
querySaveFn,
|
|
3186
|
-
matchKey,
|
|
3187
|
-
size = "lg",
|
|
3188
|
-
show,
|
|
3189
|
-
onClose,
|
|
3190
|
-
itemLabel,
|
|
3191
|
-
onSuccess,
|
|
3192
|
-
onFetchError,
|
|
3193
|
-
fetchErrorMsg = defaultErrorMsg,
|
|
3194
|
-
onSaveError,
|
|
3195
|
-
saveErrorMsg = defaultErrorMsg,
|
|
3196
|
-
invalidateQueriesOnSuccess = true,
|
|
3197
|
-
retryText = "Retry",
|
|
3198
|
-
cancelLabel = "Cancel",
|
|
3199
|
-
saveLabel,
|
|
3200
|
-
formikProps,
|
|
3201
|
-
getItemName
|
|
3202
|
-
} = _a,
|
|
3203
|
-
props = __rest(_a, ["queryId", "queryKey", "queryFetchFn", "queryFetchAllKey", "queryFetchAllFn", "querySaveFn", "matchKey", "size", "show", "onClose", "itemLabel", "onSuccess", "onFetchError", "fetchErrorMsg", "onSaveError", "saveErrorMsg", "invalidateQueriesOnSuccess", "retryText", "cancelLabel", "saveLabel", "formikProps", "getItemName"]);
|
|
3204
|
-
const queryClient = useQueryClient();
|
|
3205
|
-
const {
|
|
3206
|
-
data: attached,
|
|
3207
|
-
isInitialLoading: fetchLoading,
|
|
3208
|
-
isError: fetchError,
|
|
3209
|
-
refetch,
|
|
3210
|
-
error
|
|
3211
|
-
} = useApiQuery(queryKey, queryFetchFn);
|
|
3212
|
-
const {
|
|
3213
|
-
data,
|
|
3214
|
-
isInitialLoading: fetchAllLoading,
|
|
3215
|
-
isError: fetchAllError,
|
|
3216
|
-
refetch: refetchAll,
|
|
3217
|
-
error: errorAll
|
|
3218
|
-
} = useApiQuery(queryFetchAllKey, queryFetchAllFn);
|
|
3219
|
-
const [selectedResources, setSelectedResources] = React.useState([]);
|
|
3220
|
-
const isLoading = fetchLoading || fetchAllLoading;
|
|
3221
|
-
const isError = fetchError || fetchAllError;
|
|
3222
|
-
const mutation = useApiMutation(querySaveFn, queryKey, queryId);
|
|
3223
|
-
const handleClick = React.useCallback(event => {
|
|
3224
|
-
var _a;
|
|
3225
|
-
const id = (_a = event === null || event === void 0 ? void 0 : event.currentTarget.dataset.id) !== null && _a !== void 0 ? _a : "";
|
|
3226
|
-
const arr = selectedResources.concat([]);
|
|
3227
|
-
const i = selectedResources.indexOf(id);
|
|
3228
|
-
if (i != -1) arr.splice(i, 1);else arr.push(id);
|
|
3229
|
-
setSelectedResources(arr);
|
|
3230
|
-
}, [selectedResources, setSelectedResources]);
|
|
3231
|
-
const retry = React.useCallback(() => {
|
|
3232
|
-
if (fetchError) refetch();
|
|
3233
|
-
if (fetchAllError) refetchAll();
|
|
3234
|
-
}, [refetch, refetchAll, fetchError, fetchAllError]);
|
|
3235
|
-
const saveItem = React.useCallback(() => {
|
|
3236
|
-
// Clear mutation error if any
|
|
3237
|
-
mutation.reset();
|
|
3238
|
-
mutation.mutateAsync({
|
|
3239
|
-
resources: selectedResources
|
|
3240
|
-
}).then(response => {
|
|
3241
|
-
if (onSuccess) onSuccess(response);else toast.success(`${itemLabel} saved`);
|
|
3242
|
-
if (invalidateQueriesOnSuccess) queryClient.invalidateQueries({
|
|
3243
|
-
queryKey: queryKey
|
|
3244
|
-
});
|
|
3245
|
-
// closing delete modal
|
|
3246
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
3247
|
-
}).catch(error => {
|
|
3248
|
-
console.error("on error", error);
|
|
3249
|
-
if (onSaveError) onSaveError();else toast.error(`Error adding ${itemLabel}`);
|
|
3250
|
-
});
|
|
3251
|
-
}, [mutation, queryId, onSuccess, queryClient, onSaveError, onClose]);
|
|
3252
|
-
const resources = React.useMemo(() => {
|
|
3253
|
-
let r = [];
|
|
3254
|
-
if (attached && data) {
|
|
3255
|
-
r = [].concat(data);
|
|
3256
|
-
attached.forEach(attachedItem => r.splice(r.findIndex(item => item.id == attachedItem[matchKey]), 1));
|
|
3257
|
-
// TODO set keyField for name (could be title for example)
|
|
3258
|
-
if (getItemName) r = r.map(item => {
|
|
3259
|
-
return Object.assign(Object.assign({}, item), {
|
|
3260
|
-
name: getItemName(item)
|
|
3261
|
-
});
|
|
3262
|
-
});
|
|
3263
|
-
r = sortBy(r, ["name"]);
|
|
3264
|
-
}
|
|
3265
|
-
return r;
|
|
3266
|
-
}, [attached, data]);
|
|
3267
|
-
return jsxs(Modal, Object.assign({
|
|
3268
|
-
size: size,
|
|
3269
|
-
show: show,
|
|
3270
|
-
onClose: onClose,
|
|
3271
|
-
scheme: "light",
|
|
3272
|
-
transition: true
|
|
3273
|
-
}, props, {
|
|
3274
|
-
children: [jsx(Modal.Header, {
|
|
3275
|
-
children: `Add ${itemLabel}`
|
|
3276
|
-
}), isLoading && jsx(Modal.Body, {
|
|
3277
|
-
children: jsx(QueryLoadingState, {
|
|
3278
|
-
minW: "72"
|
|
3279
|
-
})
|
|
3280
|
-
}), isError && jsx(Modal.Body, {
|
|
3281
|
-
children: jsx(RetryOnError, {
|
|
3282
|
-
label: `${fetchErrorMsg} ${error}`,
|
|
3283
|
-
onClick: retry
|
|
3284
|
-
})
|
|
3285
|
-
}), !isLoading && !isError && jsxs(Fragment, {
|
|
3286
|
-
children: [jsx(Modal.Body, {
|
|
3287
|
-
px: "0",
|
|
3288
|
-
pb: "6",
|
|
3289
|
-
maxH: "750px",
|
|
3290
|
-
overflow: "auto",
|
|
3291
|
-
children: jsx("div", {
|
|
3292
|
-
dflex: true,
|
|
3293
|
-
flexCol: true,
|
|
3294
|
-
overflow: "auto",
|
|
3295
|
-
children: resources.map(item => jsx(ListItem, {
|
|
3296
|
-
label: item.name,
|
|
3297
|
-
value: item.id,
|
|
3298
|
-
"data-id": item.id,
|
|
3299
|
-
checked: selectedResources.includes(`${item.id}`),
|
|
3300
|
-
onClick: handleClick
|
|
3301
|
-
}, item.id))
|
|
3302
|
-
})
|
|
3303
|
-
}), jsxs(Modal.Footer, {
|
|
3304
|
-
dflex: true,
|
|
3305
|
-
placeContent: "end",
|
|
3306
|
-
spaceX: "3",
|
|
3307
|
-
children: [jsx(Button, {
|
|
3308
|
-
disabled: mutation.isLoading,
|
|
3309
|
-
onClick: onClose,
|
|
3310
|
-
variant: "borderless",
|
|
3311
|
-
me: "2",
|
|
3312
|
-
children: cancelLabel
|
|
3313
|
-
}), jsx(Button, {
|
|
3314
|
-
type: "submit",
|
|
3315
|
-
disabled: selectedResources.length == 0 || mutation.isLoading /* || !isValid*/,
|
|
3316
|
-
onClick: saveItem,
|
|
3317
|
-
children: saveLabel ? saveLabel : queryId ? "Update" : "Create"
|
|
3318
|
-
})]
|
|
3319
|
-
})]
|
|
3320
|
-
}), mutation.isLoading && jsx(ModalLoadingOverlay, {})]
|
|
3321
|
-
}));
|
|
3322
|
-
}
|
|
3323
|
-
function ListItem(_a) {
|
|
3324
|
-
var {
|
|
3325
|
-
label,
|
|
3326
|
-
value,
|
|
3327
|
-
checked
|
|
3328
|
-
} = _a,
|
|
3329
|
-
props = __rest(_a, ["label", "value", "checked"]);
|
|
3330
|
-
return jsxs("div", Object.assign({
|
|
3331
|
-
dflex: true,
|
|
3332
|
-
alignItems: "center",
|
|
3333
|
-
hover_bgColor: "slate-100",
|
|
3334
|
-
px: "5",
|
|
3335
|
-
py: "2",
|
|
3336
|
-
cursor: "pointer"
|
|
3337
|
-
}, props, {
|
|
3338
|
-
children: [jsx("span", {
|
|
3339
|
-
flexGrow: true,
|
|
3340
|
-
children: label
|
|
3341
|
-
}), jsx(Checkbox, {
|
|
3342
|
-
name: `resources.${value}`,
|
|
3343
|
-
value: value,
|
|
3344
|
-
checked: checked
|
|
3345
|
-
})]
|
|
3346
|
-
}));
|
|
3347
|
-
}
|
|
3348
|
-
|
|
3349
|
-
function FormActionDialog(_a) {
|
|
3350
|
-
var {
|
|
3351
|
-
initialValues,
|
|
3352
|
-
itemLabel,
|
|
3353
|
-
queryId = "",
|
|
3354
|
-
queryKey,
|
|
3355
|
-
queryFn,
|
|
3356
|
-
queryOptions,
|
|
3357
|
-
onSuccess,
|
|
3358
|
-
successMsg,
|
|
3359
|
-
showSuccessMsg,
|
|
3360
|
-
onError,
|
|
3361
|
-
errorMsg,
|
|
3362
|
-
showErrorMsg,
|
|
3363
|
-
processInput,
|
|
3364
|
-
invalidateQueriesOnSuccess = true,
|
|
3365
|
-
cancelLabel = "Cancel",
|
|
3366
|
-
saveLabel = "Send",
|
|
3367
|
-
size = "lg",
|
|
3368
|
-
title,
|
|
3369
|
-
form,
|
|
3370
|
-
show,
|
|
3371
|
-
onClose,
|
|
3372
|
-
formikProps
|
|
3373
|
-
} = _a,
|
|
3374
|
-
props = __rest(_a, ["initialValues", "itemLabel", "queryId", "queryKey", "queryFn", "queryOptions", "onSuccess", "successMsg", "showSuccessMsg", "onError", "errorMsg", "showErrorMsg", "processInput", "invalidateQueriesOnSuccess", "cancelLabel", "saveLabel", "size", "title", "form", "show", "onClose", "formikProps"]);
|
|
3375
|
-
const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(queryFn, queryKey, queryOptions) : useApiMutation(queryFn, queryKey, queryId, queryOptions);
|
|
3376
|
-
const mutate = useMutate(mutation, {
|
|
3377
|
-
onSuccess,
|
|
3378
|
-
successMsg,
|
|
3379
|
-
showSuccessMsg,
|
|
3380
|
-
onError,
|
|
3381
|
-
errorMsg,
|
|
3382
|
-
showErrorMsg,
|
|
3383
|
-
processInput
|
|
3384
|
-
});
|
|
3385
|
-
return jsxs(Modal, Object.assign({
|
|
3386
|
-
size: size,
|
|
3387
|
-
show: show,
|
|
3388
|
-
onClose: onClose,
|
|
3389
|
-
scheme: "light",
|
|
3390
|
-
transition: true
|
|
3391
|
-
}, props, {
|
|
3392
|
-
children: [jsx(Modal.Header, {
|
|
3393
|
-
children: title
|
|
3394
|
-
}), jsxs(FormProvider, Object.assign({
|
|
3395
|
-
initialValues: initialValues !== null && initialValues !== void 0 ? initialValues : {},
|
|
3396
|
-
onSubmit: mutate
|
|
3397
|
-
}, formikProps, {
|
|
3398
|
-
children: [jsxs(Modal.Body, {
|
|
3399
|
-
pb: "6",
|
|
3400
|
-
children: [/*#__PURE__*/React.isValidElement(form) && form, Array.isArray(form) && jsx(FormRenderer, {
|
|
3401
|
-
form: form
|
|
3402
|
-
})]
|
|
3403
|
-
}), jsxs(Modal.Footer, {
|
|
3404
|
-
dflex: true,
|
|
3405
|
-
placeContent: "end",
|
|
3406
|
-
spaceX: "3",
|
|
3407
|
-
children: [jsx(Button, {
|
|
3408
|
-
disabled: mutation.isLoading,
|
|
3409
|
-
onClick: onClose,
|
|
3410
|
-
variant: "borderless",
|
|
3411
|
-
me: "2",
|
|
3412
|
-
children: cancelLabel
|
|
3413
|
-
}), jsx(SubmitButton, {
|
|
3414
|
-
disabled: mutation.isLoading,
|
|
3415
|
-
children: saveLabel
|
|
3416
|
-
})]
|
|
3417
|
-
})]
|
|
3418
|
-
})), mutation.isLoading && jsx(ModalLoadingOverlay, {})]
|
|
3419
|
-
}));
|
|
3420
|
-
}
|
|
3421
|
-
|
|
3422
|
-
function PageSectionTitle(_a) {
|
|
3423
|
-
var {
|
|
3424
|
-
children
|
|
3425
|
-
} = _a,
|
|
3426
|
-
props = __rest(_a, ["children"]);
|
|
3427
|
-
return jsx("div", Object.assign({
|
|
3428
|
-
trait: "typo.h6",
|
|
3429
|
-
mb: "5"
|
|
3430
|
-
}, props, {
|
|
3431
|
-
children: children
|
|
3432
|
-
}));
|
|
3433
|
-
}
|
|
3434
|
-
|
|
3435
|
-
const PageStateContainer = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
3436
|
-
var {
|
|
3437
|
-
loading = false,
|
|
3438
|
-
children
|
|
3439
|
-
} = _a,
|
|
3440
|
-
props = __rest(_a, ["loading", "children"]);
|
|
3441
|
-
return jsxs(Fragment, {
|
|
3442
|
-
children: [loading && jsx(QueryLoadingState, {
|
|
3443
|
-
w: "full",
|
|
3444
|
-
h: "100%"
|
|
3445
|
-
}), !loading && jsx(Container, Object.assign({
|
|
3446
|
-
ref: ref,
|
|
3447
|
-
center: true,
|
|
3448
|
-
size: "x2",
|
|
3449
|
-
dflex: true,
|
|
3450
|
-
flexCol: true,
|
|
3451
|
-
gap: "8"
|
|
3452
|
-
}, props, {
|
|
3453
|
-
children: children
|
|
3454
|
-
}))]
|
|
3455
|
-
});
|
|
3456
|
-
});
|
|
3457
|
-
|
|
3458
|
-
function PageSubSectionTitle(_a) {
|
|
3459
|
-
var {
|
|
3460
|
-
children
|
|
3461
|
-
} = _a,
|
|
3462
|
-
props = __rest(_a, ["children"]);
|
|
3463
|
-
return jsx("div", Object.assign({
|
|
3464
|
-
trait: "typo.h6",
|
|
3465
|
-
mb: "3"
|
|
3466
|
-
}, props, {
|
|
3467
|
-
children: children
|
|
3468
|
-
}));
|
|
3469
|
-
}
|
|
3470
|
-
|
|
3471
|
-
const labels = {
|
|
3472
|
-
draft: "Draft",
|
|
3473
|
-
published: "Published",
|
|
3474
|
-
pending: "Pending",
|
|
3475
|
-
approved: "Approved",
|
|
3476
|
-
partially_approved: "Partially Approved",
|
|
3477
|
-
rejected: "Rejected"
|
|
3478
|
-
};
|
|
3479
|
-
const schemes = {
|
|
3480
|
-
draft: "warning",
|
|
3481
|
-
published: "success",
|
|
3482
|
-
pending: "secondary",
|
|
3483
|
-
approved: "success",
|
|
3484
|
-
partially_approved: "warning",
|
|
3485
|
-
rejected: "danger"
|
|
3486
|
-
};
|
|
3487
|
-
function StatusBadge(_a) {
|
|
3488
|
-
var {
|
|
3489
|
-
status
|
|
3490
|
-
} = _a,
|
|
3491
|
-
props = __rest(_a, ["status"]);
|
|
3492
|
-
return jsx(Badge, Object.assign({
|
|
3493
|
-
size: "sm",
|
|
3494
|
-
variant: "glass",
|
|
3495
|
-
whiteSpace: "nowrap",
|
|
3496
|
-
rounded: "full",
|
|
3497
|
-
px: "3",
|
|
3498
|
-
scheme: schemes[status]
|
|
3499
|
-
}, props, {
|
|
3500
|
-
children: labels[status]
|
|
3501
|
-
}));
|
|
3502
|
-
}
|
|
3503
|
-
|
|
3504
|
-
function TableRowActionButton(_a) {
|
|
3505
|
-
var {
|
|
3506
|
-
icon,
|
|
3507
|
-
children
|
|
3508
|
-
} = _a,
|
|
3509
|
-
props = __rest(_a, ["icon", "children"]);
|
|
3510
|
-
return jsxs(Button, Object.assign({
|
|
3511
|
-
dflex: true,
|
|
3512
|
-
alignContent: "center",
|
|
3513
|
-
placeContent: "center",
|
|
3514
|
-
py: "2.5",
|
|
3515
|
-
px: "3",
|
|
3516
|
-
h: "full",
|
|
3517
|
-
size: "lg",
|
|
3518
|
-
variant: "borderless",
|
|
3519
|
-
corners: "square",
|
|
3520
|
-
gap: "2"
|
|
3521
|
-
}, props, {
|
|
3522
|
-
children: [icon && jsx(Icon, {
|
|
3523
|
-
path: icon,
|
|
3524
|
-
size: "sm"
|
|
3525
|
-
}), children]
|
|
3526
|
-
}));
|
|
3527
|
-
}
|
|
3528
|
-
|
|
3529
|
-
function TableRowViewButton(_a) {
|
|
3530
|
-
var {
|
|
3531
|
-
path
|
|
3532
|
-
} = _a,
|
|
3533
|
-
props = __rest(_a, ["path"]);
|
|
3534
|
-
const openPage = React.useCallback(event => {
|
|
3535
|
-
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
3536
|
-
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
3537
|
-
window.open(`${AppEnv.websiteUrl()}/${path}`, '_blank');
|
|
3538
|
-
}, [path]);
|
|
3539
|
-
return jsx(TableRowActionButton, Object.assign({
|
|
3540
|
-
icon: mdiOpenInNew,
|
|
3541
|
-
onClick: openPage
|
|
3542
|
-
}, props));
|
|
3543
|
-
}
|
|
3544
|
-
|
|
3545
|
-
function TableRowNavigateButton(_a) {
|
|
3546
|
-
var {
|
|
3547
|
-
path
|
|
3548
|
-
} = _a,
|
|
3549
|
-
props = __rest(_a, ["path"]);
|
|
3550
|
-
const navigate = useNavigate();
|
|
3551
|
-
const handleClick = React.useCallback(event => {
|
|
3552
|
-
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
3553
|
-
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
3554
|
-
navigate(`${path}`);
|
|
3555
|
-
}, [navigate, path]);
|
|
3556
|
-
return jsx(TableRowActionButton, Object.assign({
|
|
3557
|
-
icon: mdiEye,
|
|
3558
|
-
onClick: handleClick
|
|
3559
|
-
}, props));
|
|
3560
|
-
}
|
|
3561
|
-
|
|
3562
|
-
function TableRowActionDialogButton(_a) {
|
|
3563
|
-
var {
|
|
3564
|
-
icon,
|
|
3565
|
-
children
|
|
3566
|
-
} = _a,
|
|
3567
|
-
props = __rest(_a, ["icon", "children"]);
|
|
3568
|
-
return jsxs(DialogButton$1, Object.assign({
|
|
3569
|
-
dflex: true,
|
|
3570
|
-
alignContent: "center",
|
|
3571
|
-
placeContent: "center",
|
|
3572
|
-
py: "2.5",
|
|
3573
|
-
px: "3",
|
|
3574
|
-
h: "full",
|
|
3575
|
-
size: "lg",
|
|
3576
|
-
variant: "borderless",
|
|
3577
|
-
corners: "square",
|
|
3578
|
-
gap: "2"
|
|
3579
|
-
}, props, {
|
|
3580
|
-
children: [icon && jsx(Icon, {
|
|
3581
|
-
path: icon,
|
|
3582
|
-
size: "sm"
|
|
3583
|
-
}), children]
|
|
3584
|
-
}));
|
|
3585
|
-
}
|
|
3586
|
-
|
|
3587
|
-
function TableRowEditButton(_a) {
|
|
3588
|
-
var {
|
|
3589
|
-
children
|
|
3590
|
-
} = _a,
|
|
3591
|
-
props = __rest(_a, ["children"]);
|
|
3592
|
-
return jsx(TableRowActionDialogButton, Object.assign({
|
|
3593
|
-
icon: mdiPencil
|
|
3594
|
-
}, props, {
|
|
3595
|
-
children: children
|
|
3596
|
-
}));
|
|
3597
|
-
}
|
|
3598
|
-
|
|
3599
|
-
function TableRowDeleteButton(_a) {
|
|
3600
|
-
var {
|
|
3601
|
-
children
|
|
3602
|
-
} = _a,
|
|
3603
|
-
props = __rest(_a, ["children"]);
|
|
3604
|
-
return jsx(TableRowActionDialogButton, Object.assign({
|
|
3605
|
-
icon: mdiDelete
|
|
3606
|
-
}, props, {
|
|
3607
|
-
children: children
|
|
3608
|
-
}));
|
|
3609
|
-
}
|
|
3610
|
-
|
|
3611
|
-
function TableRowActionBar(_a) {
|
|
3612
|
-
var {
|
|
3613
|
-
publishId,
|
|
3614
|
-
viewPath,
|
|
3615
|
-
navigatePath,
|
|
3616
|
-
editDialog,
|
|
3617
|
-
deleteDialog,
|
|
3618
|
-
children
|
|
3619
|
-
} = _a,
|
|
3620
|
-
props = __rest(_a, ["publishId", "viewPath", "navigatePath", "editDialog", "deleteDialog", "children"]);
|
|
3621
|
-
return jsxs("div", Object.assign({
|
|
3622
|
-
dflex: true,
|
|
3623
|
-
spaceX: "1",
|
|
3624
|
-
placeContent: "end"
|
|
3625
|
-
}, props, {
|
|
3626
|
-
children: [viewPath && jsx(TableRowViewButton, {
|
|
3627
|
-
path: viewPath
|
|
3628
|
-
}), navigatePath && jsx(TableRowNavigateButton, {
|
|
3629
|
-
path: navigatePath
|
|
3630
|
-
}), editDialog && jsx(TableRowEditButton, {
|
|
3631
|
-
buildDialog: editDialog
|
|
3632
|
-
}), deleteDialog && jsx(TableRowDeleteButton, {
|
|
3633
|
-
buildDialog: deleteDialog
|
|
3634
|
-
}), children]
|
|
3635
|
-
}));
|
|
3636
|
-
}
|
|
3637
|
-
|
|
3638
|
-
function TableRowPublishPostButton(_a) {
|
|
3639
|
-
var {
|
|
3640
|
-
id,
|
|
3641
|
-
api,
|
|
3642
|
-
status,
|
|
3643
|
-
invalidateQueryKey
|
|
3644
|
-
} = _a,
|
|
3645
|
-
props = __rest(_a, ["id", "api", "status", "invalidateQueryKey"]);
|
|
3646
|
-
const isDraft = status == "draft";
|
|
3647
|
-
const mutation = useInvalidateParentMutation(isDraft ? api.publish : api.unpublish, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : api.queryKey, {
|
|
3648
|
-
networkMode: "always"
|
|
3649
|
-
});
|
|
3650
|
-
const publish = React.useCallback(event => {
|
|
3651
|
-
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
3652
|
-
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
3653
|
-
mutation.reset();
|
|
3654
|
-
mutation.mutateAsync(id).then(() => toast.success(isDraft ? "Published!" : "Unpublished!")).catch(error => toast.error(`Error: ${error}`));
|
|
3655
|
-
}, [mutation, id]);
|
|
3656
|
-
return jsx(TableRowActionButton, Object.assign({
|
|
3657
|
-
icon: isDraft ? mdiPublish : mdiPublishOff,
|
|
3658
|
-
onClick: publish
|
|
3659
|
-
}, props));
|
|
3660
|
-
}
|
|
3661
|
-
|
|
3662
|
-
export { AdminLayout, AttachDialog, Breadcrumbs, ButtonBar, ButtonBarButton, ButtonBarDialogButton, ButtonBarSubmitButton, DialogButton, FormActionDialog, InvalidateButton, ItemDeleteDialog, ItemEditDialog, Menu, NavigateButton, OrderCell, PageContainer, PageContentEditor, PageMain, PageQueryStateContainer, PageSectionTitle, PageSidebar, PageSidebarSection, PageStateContainer, PageSubSectionTitle, PageTabbedTopBar, PageTabbedTopBarProvider, PageTitle, PageTopBar, PageTopBarToolbar, PublishButton, ScreenRenderer, SectionTitle, StatusBadge, TableContainer, TableCreateButton, TableFilterButton, TableRowActionBar, TableRowActionButton, TableRowActionDialogButton, TableRowDeleteButton, TableRowEditButton, TableRowNavigateButton, TableRowPublishPostButton, TableRowViewButton, TableTopBar, UpdateButton, ViewButton };
|