@compill/admin 1.0.60 → 1.0.62

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.
@@ -1051,9 +1053,7 @@ function PageTopBarToolbar({
1051
1053
  if (!portal || !host) return;
1052
1054
  try {
1053
1055
  if (visible) host.appendChild(portal);else host.removeChild(portal);
1054
- } catch (e) {
1055
- // console.log(e)
1056
- }
1056
+ } catch (e) {}
1057
1057
  return () => {
1058
1058
  try {
1059
1059
  host.removeChild(portal);
@@ -2895,50 +2895,52 @@ function MenuItem(_a) {
2895
2895
  props = __rest$1(_a, ["icon", "path", "depth", "darkMode", "subMenu", "children"]);
2896
2896
  const match = reactRouterDom.useMatch("/" + path); // + "/*")
2897
2897
  const selected = match != null;
2898
- return jsxRuntime.jsxs(reactRouterDom.Link, {
2899
- to: path,
2900
- style: {
2901
- position: "relative"
2902
- },
2903
- children: [jsxRuntime.jsxs(ui.Button, Object.assign({
2904
- as: "li",
2905
- minH: "8",
2906
- ms: `${(depth !== null && depth !== void 0 ? depth : 0) * 2}`,
2907
- p: "2",
2908
- font: "title",
2909
- textColor: darkMode ? "white" : "black",
2910
- fontWeight: "600",
2911
- rounded: "lg",
2912
- textSize: "sm",
2913
- variant: "borderless",
2914
- hover_bgColor: darkMode ? "white" : "black",
2915
- hover_bgOpacity: "10",
2916
- hover_textColor: darkMode ? "white" : "zinc-800",
2917
- cursor: "pointer",
2918
- dflex: true,
2919
- alignItems: "center",
2920
- gap: "3"
2921
- }, props, {
2922
- children: [icon && jsxRuntime.jsx(ui.Icon, {
2923
- path: icon,
2924
- opacity: selected ? "100" : "60"
2925
- }), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsxRuntime.jsx(MenuItem, {
2926
- icon: item.icon,
2927
- path: item.path,
2928
- depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
2929
- darkMode: darkMode,
2930
- subMenu: item.children,
2931
- children: item.label
2932
- }, index)), children]
2933
- })), selected && jsxRuntime.jsx("div", {
2934
- position: "absolute",
2935
- bgColor: darkMode ? "white" : "black",
2936
- bgOpacity: "90",
2937
- w: "0.5",
2938
- h: "6",
2939
- top: "1.5",
2940
- start: "-4"
2941
- })]
2898
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
2899
+ children: [jsxRuntime.jsxs(reactRouterDom.Link, {
2900
+ to: path,
2901
+ style: {
2902
+ position: "relative"
2903
+ },
2904
+ children: [jsxRuntime.jsxs(ui.Button, Object.assign({
2905
+ as: "li",
2906
+ minH: "8",
2907
+ ms: `${(depth !== null && depth !== void 0 ? depth : 0) * 2}`,
2908
+ p: "2",
2909
+ font: "title",
2910
+ textColor: darkMode ? "white" : "black",
2911
+ fontWeight: "600",
2912
+ rounded: "lg",
2913
+ textSize: "sm",
2914
+ variant: "borderless",
2915
+ hover_bgColor: darkMode ? "white" : "black",
2916
+ hover_bgOpacity: "10",
2917
+ hover_textColor: darkMode ? "white" : "zinc-800",
2918
+ cursor: "pointer",
2919
+ dflex: true,
2920
+ alignItems: "center",
2921
+ gap: "3"
2922
+ }, props, {
2923
+ children: [icon && jsxRuntime.jsx(ui.Icon, {
2924
+ path: icon,
2925
+ opacity: selected ? "100" : "60"
2926
+ }), children]
2927
+ })), selected && jsxRuntime.jsx("div", {
2928
+ position: "absolute",
2929
+ bgColor: darkMode ? "white" : "black",
2930
+ bgOpacity: "90",
2931
+ w: "0.5",
2932
+ h: "6",
2933
+ top: "1.5",
2934
+ start: "-4"
2935
+ })]
2936
+ }), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsxRuntime.jsx(MenuItem, {
2937
+ icon: item.icon,
2938
+ path: item.path,
2939
+ depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
2940
+ darkMode: darkMode,
2941
+ subMenu: item.children,
2942
+ children: item.label
2943
+ }, index))]
2942
2944
  });
2943
2945
  }
2944
2946
 
@@ -2966,9 +2968,12 @@ function Sidebar(_a) {
2966
2968
  borderB: "px",
2967
2969
  borderBColor: "slate-900",
2968
2970
  borderOpacity: "5",
2969
- children: [logo, jsxRuntime.jsx("h1", {
2971
+ children: [logo !== null && logo !== void 0 ? logo : jsxRuntime.jsx(Logo, {
2972
+ width: 40,
2973
+ height: 40
2974
+ }), jsxRuntime.jsx("h1", {
2970
2975
  textSize: "md",
2971
- children: title
2976
+ children: title !== null && title !== void 0 ? title : env.Env.appName()
2972
2977
  })]
2973
2978
  }), jsxRuntime.jsx(Menu, {
2974
2979
  overflowY: "auto",
@@ -2979,6 +2984,24 @@ function Sidebar(_a) {
2979
2984
  })]
2980
2985
  }));
2981
2986
  }
2987
+ function Logo(_a) {
2988
+ var {
2989
+ width,
2990
+ height,
2991
+ darkMode
2992
+ } = _a,
2993
+ props = __rest$1(_a, ["width", "height", "darkMode"]);
2994
+ return jsxRuntime.jsx("div", Object.assign({}, props, {
2995
+ children: jsxRuntime.jsx(Image__default["default"], {
2996
+ src: `/logo_${darkMode ? "light" : "dark"}.png`,
2997
+ alt: env.Env.appName(),
2998
+ width: width,
2999
+ height: height,
3000
+ priority: true,
3001
+ unoptimized: true
3002
+ })
3003
+ }));
3004
+ }
2982
3005
 
2983
3006
  function AdminLayout(_a) {
2984
3007
  var {
package/index.esm.js CHANGED
@@ -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.
@@ -1042,9 +1043,7 @@ function PageTopBarToolbar({
1042
1043
  if (!portal || !host) return;
1043
1044
  try {
1044
1045
  if (visible) host.appendChild(portal);else host.removeChild(portal);
1045
- } catch (e) {
1046
- // console.log(e)
1047
- }
1046
+ } catch (e) {}
1048
1047
  return () => {
1049
1048
  try {
1050
1049
  host.removeChild(portal);
@@ -2886,50 +2885,52 @@ function MenuItem(_a) {
2886
2885
  props = __rest$1(_a, ["icon", "path", "depth", "darkMode", "subMenu", "children"]);
2887
2886
  const match = useMatch("/" + path); // + "/*")
2888
2887
  const selected = match != null;
2889
- return jsxs(Link$1, {
2890
- to: path,
2891
- style: {
2892
- position: "relative"
2893
- },
2894
- children: [jsxs(Button, Object.assign({
2895
- as: "li",
2896
- minH: "8",
2897
- ms: `${(depth !== null && depth !== void 0 ? depth : 0) * 2}`,
2898
- p: "2",
2899
- font: "title",
2900
- textColor: darkMode ? "white" : "black",
2901
- fontWeight: "600",
2902
- rounded: "lg",
2903
- textSize: "sm",
2904
- variant: "borderless",
2905
- hover_bgColor: darkMode ? "white" : "black",
2906
- hover_bgOpacity: "10",
2907
- hover_textColor: darkMode ? "white" : "zinc-800",
2908
- cursor: "pointer",
2909
- dflex: true,
2910
- alignItems: "center",
2911
- gap: "3"
2912
- }, props, {
2913
- children: [icon && jsx(Icon, {
2914
- path: icon,
2915
- opacity: selected ? "100" : "60"
2916
- }), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsx(MenuItem, {
2917
- icon: item.icon,
2918
- path: item.path,
2919
- depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
2920
- darkMode: darkMode,
2921
- subMenu: item.children,
2922
- children: item.label
2923
- }, index)), children]
2924
- })), selected && jsx("div", {
2925
- position: "absolute",
2926
- bgColor: darkMode ? "white" : "black",
2927
- bgOpacity: "90",
2928
- w: "0.5",
2929
- h: "6",
2930
- top: "1.5",
2931
- start: "-4"
2932
- })]
2888
+ return jsxs(Fragment, {
2889
+ children: [jsxs(Link$1, {
2890
+ to: path,
2891
+ style: {
2892
+ position: "relative"
2893
+ },
2894
+ children: [jsxs(Button, Object.assign({
2895
+ as: "li",
2896
+ minH: "8",
2897
+ ms: `${(depth !== null && depth !== void 0 ? depth : 0) * 2}`,
2898
+ p: "2",
2899
+ font: "title",
2900
+ textColor: darkMode ? "white" : "black",
2901
+ fontWeight: "600",
2902
+ rounded: "lg",
2903
+ textSize: "sm",
2904
+ variant: "borderless",
2905
+ hover_bgColor: darkMode ? "white" : "black",
2906
+ hover_bgOpacity: "10",
2907
+ hover_textColor: darkMode ? "white" : "zinc-800",
2908
+ cursor: "pointer",
2909
+ dflex: true,
2910
+ alignItems: "center",
2911
+ gap: "3"
2912
+ }, props, {
2913
+ children: [icon && jsx(Icon, {
2914
+ path: icon,
2915
+ opacity: selected ? "100" : "60"
2916
+ }), children]
2917
+ })), selected && jsx("div", {
2918
+ position: "absolute",
2919
+ bgColor: darkMode ? "white" : "black",
2920
+ bgOpacity: "90",
2921
+ w: "0.5",
2922
+ h: "6",
2923
+ top: "1.5",
2924
+ start: "-4"
2925
+ })]
2926
+ }), subMenu === null || subMenu === void 0 ? void 0 : subMenu.map((item, index) => jsx(MenuItem, {
2927
+ icon: item.icon,
2928
+ path: item.path,
2929
+ depth: (depth !== null && depth !== void 0 ? depth : 0) + 1,
2930
+ darkMode: darkMode,
2931
+ subMenu: item.children,
2932
+ children: item.label
2933
+ }, index))]
2933
2934
  });
2934
2935
  }
2935
2936
 
@@ -2957,9 +2958,12 @@ function Sidebar(_a) {
2957
2958
  borderB: "px",
2958
2959
  borderBColor: "slate-900",
2959
2960
  borderOpacity: "5",
2960
- children: [logo, jsx("h1", {
2961
+ children: [logo !== null && logo !== void 0 ? logo : jsx(Logo, {
2962
+ width: 40,
2963
+ height: 40
2964
+ }), jsx("h1", {
2961
2965
  textSize: "md",
2962
- children: title
2966
+ children: title !== null && title !== void 0 ? title : Env.appName()
2963
2967
  })]
2964
2968
  }), jsx(Menu, {
2965
2969
  overflowY: "auto",
@@ -2970,6 +2974,24 @@ function Sidebar(_a) {
2970
2974
  })]
2971
2975
  }));
2972
2976
  }
2977
+ function Logo(_a) {
2978
+ var {
2979
+ width,
2980
+ height,
2981
+ darkMode
2982
+ } = _a,
2983
+ props = __rest$1(_a, ["width", "height", "darkMode"]);
2984
+ return jsx("div", Object.assign({}, props, {
2985
+ children: jsx(Image, {
2986
+ src: `/logo_${darkMode ? "light" : "dark"}.png`,
2987
+ alt: Env.appName(),
2988
+ width: width,
2989
+ height: height,
2990
+ priority: true,
2991
+ unoptimized: true
2992
+ })
2993
+ }));
2994
+ }
2973
2995
 
2974
2996
  function AdminLayout(_a) {
2975
2997
  var {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compill/admin",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
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 {};