@compill/admin 1.0.61 → 1.0.63
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/index.cjs.js +76 -48
- package/index.esm.js +76 -49
- package/package.json +1 -1
- package/src/lib/layout/AdminLayout.d.ts +2 -2
- package/src/lib/layout/Sidebar.d.ts +8 -2
package/index.cjs.js
CHANGED
@@ -23,11 +23,13 @@ var hooks = require('@compill/hooks');
|
|
23
23
|
var env = require('@compill/env');
|
24
24
|
var router = require('next/router');
|
25
25
|
var reactQuery = require('@tanstack/react-query');
|
26
|
+
var Image = require('next/image');
|
26
27
|
|
27
28
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
28
29
|
|
29
30
|
var Link__default = /*#__PURE__*/_interopDefaultLegacy(Link);
|
30
31
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
32
|
+
var Image__default = /*#__PURE__*/_interopDefaultLegacy(Image);
|
31
33
|
|
32
34
|
/******************************************************************************
|
33
35
|
Copyright (c) Microsoft Corporation.
|
@@ -2891,52 +2893,56 @@ function MenuItem(_a) {
|
|
2891
2893
|
children
|
2892
2894
|
} = _a,
|
2893
2895
|
props = __rest$1(_a, ["icon", "path", "depth", "darkMode", "subMenu", "children"]);
|
2894
|
-
const
|
2895
|
-
const selected =
|
2896
|
-
|
2897
|
-
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2901
|
-
|
2902
|
-
|
2903
|
-
|
2904
|
-
|
2905
|
-
|
2906
|
-
|
2907
|
-
|
2908
|
-
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2912
|
-
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2896
|
+
const location = reactRouterDom.useLocation();
|
2897
|
+
const selected = location.pathname.startsWith(path.startsWith("/") ? path : `/${path}`);
|
2898
|
+
// const match = useMatch("/" + path)// + "/*")
|
2899
|
+
// const selected = match != null
|
2900
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
2901
|
+
children: [jsxRuntime.jsxs(reactRouterDom.Link, {
|
2902
|
+
to: path,
|
2903
|
+
style: {
|
2904
|
+
position: "relative"
|
2905
|
+
},
|
2906
|
+
children: [jsxRuntime.jsxs(ui.Button, Object.assign({
|
2907
|
+
as: "li",
|
2908
|
+
minH: "8",
|
2909
|
+
ms: `${(depth !== null && depth !== void 0 ? depth : 0) * 2}`,
|
2910
|
+
p: "2",
|
2911
|
+
font: "title",
|
2912
|
+
textColor: darkMode ? "white" : "black",
|
2913
|
+
fontWeight: "600",
|
2914
|
+
rounded: "lg",
|
2915
|
+
textSize: "sm",
|
2916
|
+
variant: "borderless",
|
2917
|
+
hover_bgColor: darkMode ? "white" : "black",
|
2918
|
+
hover_bgOpacity: "10",
|
2919
|
+
hover_textColor: darkMode ? "white" : "zinc-800",
|
2920
|
+
cursor: "pointer",
|
2921
|
+
dflex: true,
|
2922
|
+
alignItems: "center",
|
2923
|
+
gap: "3"
|
2924
|
+
}, props, {
|
2925
|
+
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
2926
|
+
path: icon,
|
2927
|
+
opacity: selected ? "100" : "60"
|
2928
|
+
}), children]
|
2929
|
+
})), selected && jsxRuntime.jsx("div", {
|
2930
|
+
position: "absolute",
|
2931
|
+
bgColor: darkMode ? "white" : "black",
|
2932
|
+
bgOpacity: "90",
|
2933
|
+
w: "0.5",
|
2934
|
+
h: "6",
|
2935
|
+
top: "1.5",
|
2936
|
+
start: "-4"
|
2937
|
+
})]
|
2938
|
+
}), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsxRuntime.jsx(MenuItem, {
|
2939
|
+
icon: item.icon,
|
2940
|
+
path: item.path,
|
2941
|
+
depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
|
2942
|
+
darkMode: darkMode,
|
2943
|
+
subMenu: item.children,
|
2944
|
+
children: item.label
|
2945
|
+
}, index))]
|
2940
2946
|
});
|
2941
2947
|
}
|
2942
2948
|
|
@@ -2964,9 +2970,13 @@ function Sidebar(_a) {
|
|
2964
2970
|
borderB: "px",
|
2965
2971
|
borderBColor: "slate-900",
|
2966
2972
|
borderOpacity: "5",
|
2967
|
-
children: [logo
|
2973
|
+
children: [logo !== null && logo !== void 0 ? logo : jsxRuntime.jsx(Logo, {
|
2974
|
+
width: 40,
|
2975
|
+
height: 40,
|
2976
|
+
darkMode: darkMode
|
2977
|
+
}), jsxRuntime.jsx("h1", {
|
2968
2978
|
textSize: "md",
|
2969
|
-
children: title
|
2979
|
+
children: title !== null && title !== void 0 ? title : env.Env.appName()
|
2970
2980
|
})]
|
2971
2981
|
}), jsxRuntime.jsx(Menu, {
|
2972
2982
|
overflowY: "auto",
|
@@ -2977,6 +2987,24 @@ function Sidebar(_a) {
|
|
2977
2987
|
})]
|
2978
2988
|
}));
|
2979
2989
|
}
|
2990
|
+
function Logo(_a) {
|
2991
|
+
var {
|
2992
|
+
width,
|
2993
|
+
height,
|
2994
|
+
darkMode
|
2995
|
+
} = _a,
|
2996
|
+
props = __rest$1(_a, ["width", "height", "darkMode"]);
|
2997
|
+
return jsxRuntime.jsx("div", Object.assign({}, props, {
|
2998
|
+
children: jsxRuntime.jsx(Image__default["default"], {
|
2999
|
+
src: `/logo_${darkMode ? "light" : "dark"}.png`,
|
3000
|
+
alt: env.Env.appName(),
|
3001
|
+
width: width,
|
3002
|
+
height: height,
|
3003
|
+
priority: true,
|
3004
|
+
unoptimized: true
|
3005
|
+
})
|
3006
|
+
}));
|
3007
|
+
}
|
2980
3008
|
|
2981
3009
|
function AdminLayout(_a) {
|
2982
3010
|
var {
|
package/index.esm.js
CHANGED
@@ -4,7 +4,7 @@ import Link from 'next/link';
|
|
4
4
|
import React, { useRef, useCallback, useContext as useContext$2, useLayoutEffect, useEffect, createContext } from 'react';
|
5
5
|
import { INVALIDATE_API } from '@compill/admin-api';
|
6
6
|
import { useApiMutation, useMutate, useInvalidateMutation, useApiQuery, useInvalidateQuery, useInvalidateParentMutation, useApiQueries } from '@compill/api';
|
7
|
-
import { useNavigate, useParams, Outlet,
|
7
|
+
import { useNavigate, useParams, Outlet, useLocation, Link as Link$1 } from 'react-router-dom';
|
8
8
|
import { toast } from 'react-toastify';
|
9
9
|
import { SubmitButton, FormProvider, TextArea, FormRenderer, mergeInitialFormValues, FieldLabel } from '@compill/form';
|
10
10
|
import { useFormikContext, Field, Formik, Form } from 'formik';
|
@@ -19,6 +19,7 @@ import { useOpenLink, useBoolean } from '@compill/hooks';
|
|
19
19
|
import { Env } from '@compill/env';
|
20
20
|
import { useRouter } from 'next/router';
|
21
21
|
import { useQueryClient } from '@tanstack/react-query';
|
22
|
+
import Image from 'next/image';
|
22
23
|
|
23
24
|
/******************************************************************************
|
24
25
|
Copyright (c) Microsoft Corporation.
|
@@ -2882,52 +2883,56 @@ function MenuItem(_a) {
|
|
2882
2883
|
children
|
2883
2884
|
} = _a,
|
2884
2885
|
props = __rest$1(_a, ["icon", "path", "depth", "darkMode", "subMenu", "children"]);
|
2885
|
-
const
|
2886
|
-
const selected =
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2890
|
-
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
|
2895
|
-
|
2896
|
-
|
2897
|
-
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2901
|
-
|
2902
|
-
|
2903
|
-
|
2904
|
-
|
2905
|
-
|
2906
|
-
|
2907
|
-
|
2908
|
-
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2912
|
-
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2886
|
+
const location = useLocation();
|
2887
|
+
const selected = location.pathname.startsWith(path.startsWith("/") ? path : `/${path}`);
|
2888
|
+
// const match = useMatch("/" + path)// + "/*")
|
2889
|
+
// const selected = match != null
|
2890
|
+
return jsxs(Fragment, {
|
2891
|
+
children: [jsxs(Link$1, {
|
2892
|
+
to: path,
|
2893
|
+
style: {
|
2894
|
+
position: "relative"
|
2895
|
+
},
|
2896
|
+
children: [jsxs(Button, Object.assign({
|
2897
|
+
as: "li",
|
2898
|
+
minH: "8",
|
2899
|
+
ms: `${(depth !== null && depth !== void 0 ? depth : 0) * 2}`,
|
2900
|
+
p: "2",
|
2901
|
+
font: "title",
|
2902
|
+
textColor: darkMode ? "white" : "black",
|
2903
|
+
fontWeight: "600",
|
2904
|
+
rounded: "lg",
|
2905
|
+
textSize: "sm",
|
2906
|
+
variant: "borderless",
|
2907
|
+
hover_bgColor: darkMode ? "white" : "black",
|
2908
|
+
hover_bgOpacity: "10",
|
2909
|
+
hover_textColor: darkMode ? "white" : "zinc-800",
|
2910
|
+
cursor: "pointer",
|
2911
|
+
dflex: true,
|
2912
|
+
alignItems: "center",
|
2913
|
+
gap: "3"
|
2914
|
+
}, props, {
|
2915
|
+
children: [icon && jsx(Icon, {
|
2916
|
+
path: icon,
|
2917
|
+
opacity: selected ? "100" : "60"
|
2918
|
+
}), children]
|
2919
|
+
})), selected && jsx("div", {
|
2920
|
+
position: "absolute",
|
2921
|
+
bgColor: darkMode ? "white" : "black",
|
2922
|
+
bgOpacity: "90",
|
2923
|
+
w: "0.5",
|
2924
|
+
h: "6",
|
2925
|
+
top: "1.5",
|
2926
|
+
start: "-4"
|
2927
|
+
})]
|
2928
|
+
}), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsx(MenuItem, {
|
2929
|
+
icon: item.icon,
|
2930
|
+
path: item.path,
|
2931
|
+
depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
|
2932
|
+
darkMode: darkMode,
|
2933
|
+
subMenu: item.children,
|
2934
|
+
children: item.label
|
2935
|
+
}, index))]
|
2931
2936
|
});
|
2932
2937
|
}
|
2933
2938
|
|
@@ -2955,9 +2960,13 @@ function Sidebar(_a) {
|
|
2955
2960
|
borderB: "px",
|
2956
2961
|
borderBColor: "slate-900",
|
2957
2962
|
borderOpacity: "5",
|
2958
|
-
children: [logo
|
2963
|
+
children: [logo !== null && logo !== void 0 ? logo : jsx(Logo, {
|
2964
|
+
width: 40,
|
2965
|
+
height: 40,
|
2966
|
+
darkMode: darkMode
|
2967
|
+
}), jsx("h1", {
|
2959
2968
|
textSize: "md",
|
2960
|
-
children: title
|
2969
|
+
children: title !== null && title !== void 0 ? title : Env.appName()
|
2961
2970
|
})]
|
2962
2971
|
}), jsx(Menu, {
|
2963
2972
|
overflowY: "auto",
|
@@ -2968,6 +2977,24 @@ function Sidebar(_a) {
|
|
2968
2977
|
})]
|
2969
2978
|
}));
|
2970
2979
|
}
|
2980
|
+
function Logo(_a) {
|
2981
|
+
var {
|
2982
|
+
width,
|
2983
|
+
height,
|
2984
|
+
darkMode
|
2985
|
+
} = _a,
|
2986
|
+
props = __rest$1(_a, ["width", "height", "darkMode"]);
|
2987
|
+
return jsx("div", Object.assign({}, props, {
|
2988
|
+
children: jsx(Image, {
|
2989
|
+
src: `/logo_${darkMode ? "light" : "dark"}.png`,
|
2990
|
+
alt: Env.appName(),
|
2991
|
+
width: width,
|
2992
|
+
height: height,
|
2993
|
+
priority: true,
|
2994
|
+
unoptimized: true
|
2995
|
+
})
|
2996
|
+
}));
|
2997
|
+
}
|
2971
2998
|
|
2972
2999
|
function AdminLayout(_a) {
|
2973
3000
|
var {
|
package/package.json
CHANGED
@@ -4,8 +4,8 @@ import { MenuConfig } from "./Menu";
|
|
4
4
|
interface LayoutProps extends SoperioComponent, ParentComponent {
|
5
5
|
color: Color;
|
6
6
|
darkMode?: boolean;
|
7
|
-
logo
|
8
|
-
title
|
7
|
+
logo?: React.ReactNode;
|
8
|
+
title?: string;
|
9
9
|
menuConfig: MenuConfig;
|
10
10
|
}
|
11
11
|
export declare function AdminLayout({ color, darkMode, logo, title, menuConfig, ...props }: LayoutProps): JSX.Element;
|
@@ -5,9 +5,15 @@ interface SidebarProps extends SoperioComponent, ParentComponent {
|
|
5
5
|
show?: boolean;
|
6
6
|
color: Color;
|
7
7
|
darkMode?: boolean;
|
8
|
-
logo
|
9
|
-
title
|
8
|
+
logo?: React.ReactNode;
|
9
|
+
title?: string;
|
10
10
|
menuConfig: MenuConfig;
|
11
11
|
}
|
12
12
|
export declare function Sidebar({ show, logo, title, menuConfig, color, darkMode, ...props }: SidebarProps): JSX.Element;
|
13
|
+
interface LogoProps extends SoperioComponent, ParentComponent {
|
14
|
+
width: number;
|
15
|
+
height: number;
|
16
|
+
darkMode?: boolean;
|
17
|
+
}
|
18
|
+
export default function Logo({ width, height, darkMode, ...props }: LogoProps): JSX.Element;
|
13
19
|
export {};
|