@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 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 match = reactRouterDom.useMatch("/" + path); // + "/*")
2895
- const selected = match != null;
2896
- return jsxRuntime.jsxs(reactRouterDom.Link, {
2897
- to: path,
2898
- style: {
2899
- position: "relative"
2900
- },
2901
- children: [jsxRuntime.jsxs(ui.Button, Object.assign({
2902
- as: "li",
2903
- minH: "8",
2904
- ms: `${(depth !== null && depth !== void 0 ? depth : 0) * 2}`,
2905
- p: "2",
2906
- font: "title",
2907
- textColor: darkMode ? "white" : "black",
2908
- fontWeight: "600",
2909
- rounded: "lg",
2910
- textSize: "sm",
2911
- variant: "borderless",
2912
- hover_bgColor: darkMode ? "white" : "black",
2913
- hover_bgOpacity: "10",
2914
- hover_textColor: darkMode ? "white" : "zinc-800",
2915
- cursor: "pointer",
2916
- dflex: true,
2917
- alignItems: "center",
2918
- gap: "3"
2919
- }, props, {
2920
- children: [icon && jsxRuntime.jsx(ui.Icon, {
2921
- path: icon,
2922
- opacity: selected ? "100" : "60"
2923
- }), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsxRuntime.jsx(MenuItem, {
2924
- icon: item.icon,
2925
- path: item.path,
2926
- depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
2927
- darkMode: darkMode,
2928
- subMenu: item.children,
2929
- children: item.label
2930
- }, index)), children]
2931
- })), selected && jsxRuntime.jsx("div", {
2932
- position: "absolute",
2933
- bgColor: darkMode ? "white" : "black",
2934
- bgOpacity: "90",
2935
- w: "0.5",
2936
- h: "6",
2937
- top: "1.5",
2938
- start: "-4"
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, jsxRuntime.jsx("h1", {
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, useMatch, Link as Link$1 } from 'react-router-dom';
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 match = useMatch("/" + path); // + "/*")
2886
- const selected = match != null;
2887
- return jsxs(Link$1, {
2888
- to: path,
2889
- style: {
2890
- position: "relative"
2891
- },
2892
- children: [jsxs(Button, Object.assign({
2893
- as: "li",
2894
- minH: "8",
2895
- ms: `${(depth !== null && depth !== void 0 ? depth : 0) * 2}`,
2896
- p: "2",
2897
- font: "title",
2898
- textColor: darkMode ? "white" : "black",
2899
- fontWeight: "600",
2900
- rounded: "lg",
2901
- textSize: "sm",
2902
- variant: "borderless",
2903
- hover_bgColor: darkMode ? "white" : "black",
2904
- hover_bgOpacity: "10",
2905
- hover_textColor: darkMode ? "white" : "zinc-800",
2906
- cursor: "pointer",
2907
- dflex: true,
2908
- alignItems: "center",
2909
- gap: "3"
2910
- }, props, {
2911
- children: [icon && jsx(Icon, {
2912
- path: icon,
2913
- opacity: selected ? "100" : "60"
2914
- }), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsx(MenuItem, {
2915
- icon: item.icon,
2916
- path: item.path,
2917
- depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
2918
- darkMode: darkMode,
2919
- subMenu: item.children,
2920
- children: item.label
2921
- }, index)), children]
2922
- })), selected && jsx("div", {
2923
- position: "absolute",
2924
- bgColor: darkMode ? "white" : "black",
2925
- bgOpacity: "90",
2926
- w: "0.5",
2927
- h: "6",
2928
- top: "1.5",
2929
- start: "-4"
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, jsx("h1", {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compill/admin",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "module": "./index.esm.js",
5
5
  "main": "./index.cjs.js"
6
6
  }
@@ -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: React.ReactNode;
8
- title: string;
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: React.ReactNode;
9
- title: string;
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 {};