@pnkx-lib/ui 1.9.403 → 1.9.404

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.
@@ -4,10 +4,11 @@ import { useState, useMemo } from 'react';
4
4
  import { t as twMerge } from '../chunks/bundle-mjs-BBFHkixS.js';
5
5
  import { AutoComplete, Divider, Dropdown, Flex } from 'antd';
6
6
  import { useLocation, useNavigate, Link } from 'react-router';
7
- import { Layout, Input } from '@pnkx-lib/ui';
8
7
  import { u as useDebounce, l as logoHeaderText, S as SearchIcon, V as VietNamIcon, D as DownOutlinedIcon, R as RefIcon$1 } from '../chunks/logo-header-DG8abRGF.js';
8
+ import { Layout } from './Layout.js';
9
9
  import { R as RefIcon$2 } from '../chunks/DownOutlined-CkHKgaSi.js';
10
10
  import { I as Icon, _ as _extends } from '../chunks/AntdIcon-gUuMvf83.js';
11
+ import { Input } from '../fields/Input.js';
11
12
 
12
13
  // This icon file is generated automatically.
13
14
  var DoubleLeftOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M272.9 512l265.4-339.1c4.1-5.2.4-12.9-6.3-12.9h-77.3c-4.9 0-9.6 2.3-12.6 6.1L186.8 492.3a31.99 31.99 0 000 39.5l255.3 326.1c3 3.9 7.7 6.1 12.6 6.1H532c6.7 0 10.4-7.7 6.3-12.9L272.9 512zm304 0l265.4-339.1c4.1-5.2.4-12.9-6.3-12.9h-77.3c-4.9 0-9.6 2.3-12.6 6.1L490.8 492.3a31.99 31.99 0 000 39.5l255.3 326.1c3 3.9 7.7 6.1 12.6 6.1H836c6.7 0 10.4-7.7 6.3-12.9L576.9 512z" } }] }, "name": "double-left", "theme": "outlined" };
@@ -98,7 +99,7 @@ const SidebarV2 = ({ menu, children }) => {
98
99
  const searchSidebar = useDebounce(valueSearch, 300);
99
100
  const [showSubmenu, setShowSubmenu] = useState(false);
100
101
  const [activeModule, setActiveModule] = useState("");
101
- const [openDropdownMenu, setOpenDropdownMenu] = useState(false);
102
+ const [openDropdownMenu, setOpenDropdownMenu] = useState(null);
102
103
  const location = useLocation();
103
104
  const pathName = location.pathname;
104
105
  const sidebarMenu = useMemo(
@@ -118,13 +119,17 @@ const SidebarV2 = ({ menu, children }) => {
118
119
  if (showSubmenu) return "ml-[279px]";
119
120
  return "ml-[62px]";
120
121
  };
121
- const handleClickDropdownMenu = (isDropdown, pathUrl) => {
122
+ const handleClickDropdownMenu = (isDropdown, item) => {
122
123
  if (isDropdown) {
123
- setOpenDropdownMenu(!openDropdownMenu);
124
+ setOpenDropdownMenu((prev) => prev === item.path ? null : item.path);
124
125
  return;
125
126
  }
126
- console.log("pathUrl", pathUrl);
127
- navigate(pathUrl);
127
+ navigate(item.path);
128
+ };
129
+ const handleNavigateModule = (item) => {
130
+ setShowSubmenu(true);
131
+ setHoverOpenMenu(false);
132
+ setActiveModule(item.path);
128
133
  };
129
134
  return /* @__PURE__ */ jsxs(Fragment, { children: [
130
135
  /* @__PURE__ */ jsx(
@@ -212,9 +217,7 @@ const SidebarV2 = ({ menu, children }) => {
212
217
  "a",
213
218
  {
214
219
  onClick: () => {
215
- setShowSubmenu(true);
216
- setHoverOpenMenu(false);
217
- setActiveModule(item.path);
220
+ handleNavigateModule(item);
218
221
  },
219
222
  className: classNames(
220
223
  item.path === activeModule ? "bg-[#007BE5] text-white" : "text-gray-400 hover:text-white hover:bg-[#007BE5]",
@@ -246,8 +249,8 @@ const SidebarV2 = ({ menu, children }) => {
246
249
  ),
247
250
  onMouseLeave: () => setShowSubmenu(true),
248
251
  children: [
249
- sidebarMenu.map((submenu) => {
250
- const isActiveMainMenu = activeModule === submenu.path;
252
+ sidebarMenu.map((moduleMenu) => {
253
+ const isActiveMainMenu = activeModule === moduleMenu.path;
251
254
  if (!isActiveMainMenu) return null;
252
255
  const normalizePath = (path) => {
253
256
  return path.trim().replace(/^\/+|\/+$/g, "").replace(/\/{2,}/g, "/").toLowerCase();
@@ -256,46 +259,51 @@ const SidebarV2 = ({ menu, children }) => {
256
259
  return normalizePath(a) === normalizePath(b);
257
260
  };
258
261
  return /* @__PURE__ */ jsxs("div", { children: [
259
- /* @__PURE__ */ jsx("span", { className: "block px-4 h-[42px] shadow-[0px_4px_6px_0px_#0006241f] py-2 text-[16px] font-semibold text-[#1F1F1F]", children: submenu.name }),
260
- /* @__PURE__ */ jsx("ul", { className: "mt-4", children: submenu.children?.map((item) => {
261
- const pathActive = comparePaths(pathName, item.path);
262
- const isDropwdown = item.isShow;
262
+ /* @__PURE__ */ jsx("span", { className: "block px-4 h-[42px] shadow-[0px_4px_6px_0px_#0006241f] py-2 text-[16px] font-semibold text-[#1F1F1F]", children: moduleMenu.name }),
263
+ /* @__PURE__ */ jsx("ul", { className: "mt-4", children: moduleMenu.children?.map((subMenu) => {
264
+ const pathActive = comparePaths(pathName, subMenu.path);
265
+ const isDropwdown = subMenu.isShow;
266
+ const activeMenu = pathName.startsWith(subMenu.path);
263
267
  return /* @__PURE__ */ jsxs("li", { children: [
264
268
  /* @__PURE__ */ jsxs(
265
269
  "div",
266
270
  {
267
- onClick: () => handleClickDropdownMenu(isDropwdown, item.path),
271
+ onClick: () => handleClickDropdownMenu(isDropwdown, subMenu),
268
272
  className: twMerge(
269
- "px-4 py-2 mt-1 items-center cursor-pointer flex text-sm hover:bg-[#E5F4FF] hover:text-[#007BE5]",
270
- pathActive && !isDropwdown ? "!text-[#007BE5] !bg-[#E5F4FF]" : isDropwdown && pathActive ? "!text-[#007BE5]" : "text-[#1F1F1F]"
273
+ "px-4 py-2 mt-1 items-center gap-2 cursor-pointer flex text-sm hover:bg-[#E5F4FF] hover:text-[#007BE5]",
274
+ pathActive && !isDropwdown ? "!text-[#007BE5] !bg-[#E5F4FF]" : isDropwdown && (pathActive || activeMenu) ? "!text-[#007BE5]" : "text-[#1F1F1F]"
271
275
  ),
272
276
  children: [
273
- item.name,
274
- isDropwdown && (openDropdownMenu ? /* @__PURE__ */ jsx(RefIcon$1, { className: "w-4 h-4 ml-auto" }) : /* @__PURE__ */ jsx(RefIcon$2, { className: "w-4 h-4 ml-auto" }))
277
+ subMenu.icon,
278
+ subMenu.name,
279
+ isDropwdown && openDropdownMenu === subMenu.path ? /* @__PURE__ */ jsx(RefIcon$1, { className: "w-4 h-4 ml-auto" }) : isDropwdown && /* @__PURE__ */ jsx(RefIcon$2, { className: "w-4 h-4 ml-auto" })
275
280
  ]
276
281
  }
277
282
  ),
278
- isDropwdown && openDropdownMenu && item.children?.map((dropdownItem) => {
283
+ isDropwdown && openDropdownMenu === subMenu.path && subMenu.children?.map((dropdownItem) => {
279
284
  const pathActiveDropdown = comparePaths(
280
285
  pathName,
281
- item.path
286
+ subMenu.path
282
287
  );
283
- const path = `${item.path}/${dropdownItem.path}`;
284
- return /* @__PURE__ */ jsx(
288
+ const path = `${subMenu.path}/${dropdownItem.path}`;
289
+ return /* @__PURE__ */ jsxs(
285
290
  Link,
286
291
  {
287
292
  to: path,
288
293
  className: twMerge(
289
- "px-4 py-2 mt-1 items-center flex text-sm hover:bg-[#E5F4FF] hover:text-[#007BE5]",
290
- pathActiveDropdown ? "!text-[#007BE5] !bg-[#E5F4FF]" : "text-[#1F1F1F]"
294
+ "px-4 py-2 mt-1 items-center gap-2 flex text-sm hover:bg-[#E5F4FF] hover:text-[#007BE5]",
295
+ pathActiveDropdown || activeMenu ? "!text-[#007BE5] !bg-[#E5F4FF]" : "text-[#1F1F1F]"
291
296
  ),
292
- children: dropdownItem.name
297
+ children: [
298
+ dropdownItem.icon,
299
+ dropdownItem.name
300
+ ]
293
301
  }
294
302
  );
295
303
  })
296
- ] }, item.path);
304
+ ] }, subMenu.path);
297
305
  }) })
298
- ] }, submenu.path);
306
+ ] }, moduleMenu.path);
299
307
  }),
300
308
  /* @__PURE__ */ jsxs(
301
309
  "div",
@@ -304,7 +312,7 @@ const SidebarV2 = ({ menu, children }) => {
304
312
  onClick: () => setShowSubmenu(false),
305
313
  children: [
306
314
  /* @__PURE__ */ jsx(RefIcon, {}),
307
- /* @__PURE__ */ jsx("span", { className: "text-[#131313] text-[16px]", children: "Thu gọn menu" })
315
+ /* @__PURE__ */ jsx("span", { className: "text-[#131313]", children: "Thu gọn menu" })
308
316
  ]
309
317
  }
310
318
  )
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pnkx-lib/ui",
3
3
  "private": false,
4
- "version": "1.9.403",
4
+ "version": "1.9.404",
5
5
  "type": "module",
6
6
  "main": "./es/index.js",
7
7
  "module": "./es/index.js",
@@ -7,6 +7,7 @@ export type MenuTypeV2 = {
7
7
  icon?: ReactNode;
8
8
  code?: string;
9
9
  isShowLabel?: boolean;
10
+ isModule?: boolean;
10
11
  component?: React.LazyExoticComponent<React.MemoExoticComponent<any>> | React.ExoticComponent<any> | ReactNode | React.FC;
11
12
  componentProps?: Record<string, any>;
12
13
  children?: MenuTypeV2[];