warqadui 0.0.60 → 0.0.61

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 CHANGED
@@ -4763,6 +4763,7 @@ var import_react23 = require("react");
4763
4763
 
4764
4764
  // src/components/Dropdown.tsx
4765
4765
  var import_react22 = require("react");
4766
+ var import_react_dom3 = require("react-dom");
4766
4767
  var import_jsx_runtime32 = require("react/jsx-runtime");
4767
4768
  var Dropdown = ({
4768
4769
  children,
@@ -4775,20 +4776,45 @@ var Dropdown = ({
4775
4776
  onOpenChange
4776
4777
  }) => {
4777
4778
  const [isOpen, setIsOpen] = (0, import_react22.useState)(false);
4778
- const dropdownRef = (0, import_react22.useRef)(null);
4779
+ const triggerRef = (0, import_react22.useRef)(null);
4780
+ const [coords, setCoords] = (0, import_react22.useState)({ top: 0, left: 0, right: 0 });
4779
4781
  const [loadingItems, setLoadingItems] = (0, import_react22.useState)({});
4782
+ const updateCoords = () => {
4783
+ if (triggerRef.current) {
4784
+ const rect = triggerRef.current.getBoundingClientRect();
4785
+ setCoords({
4786
+ top: rect.bottom,
4787
+ left: rect.left,
4788
+ right: rect.right
4789
+ });
4790
+ }
4791
+ };
4792
+ (0, import_react22.useLayoutEffect)(() => {
4793
+ if (isOpen) {
4794
+ updateCoords();
4795
+ }
4796
+ }, [isOpen]);
4780
4797
  (0, import_react22.useEffect)(() => {
4781
4798
  onOpenChange?.(isOpen);
4799
+ const handleScrollAndResize = () => {
4800
+ if (isOpen) {
4801
+ updateCoords();
4802
+ }
4803
+ };
4782
4804
  const handleClickOutside = (event) => {
4783
- if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
4805
+ if (triggerRef.current && !triggerRef.current.contains(event.target) && !event.target.closest(".dropdown-portal-menu")) {
4784
4806
  setIsOpen(false);
4785
4807
  }
4786
4808
  };
4787
4809
  if (isOpen) {
4788
4810
  document.addEventListener("mousedown", handleClickOutside);
4811
+ window.addEventListener("scroll", handleScrollAndResize, true);
4812
+ window.addEventListener("resize", handleScrollAndResize);
4789
4813
  }
4790
4814
  return () => {
4791
4815
  document.removeEventListener("mousedown", handleClickOutside);
4816
+ window.removeEventListener("scroll", handleScrollAndResize, true);
4817
+ window.removeEventListener("resize", handleScrollAndResize);
4792
4818
  };
4793
4819
  }, [isOpen, onOpenChange]);
4794
4820
  const toggleDropdown = () => setIsOpen(!isOpen);
@@ -4816,7 +4842,7 @@ var Dropdown = ({
4816
4842
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
4817
4843
  "div",
4818
4844
  {
4819
- ref: dropdownRef,
4845
+ ref: triggerRef,
4820
4846
  className: cn("relative inline-block text-left", className),
4821
4847
  onMouseEnter: openDropdown,
4822
4848
  onMouseLeave: closeDropdown,
@@ -4837,46 +4863,53 @@ var Dropdown = ({
4837
4863
  children
4838
4864
  }
4839
4865
  ),
4840
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4841
- "div",
4842
- {
4843
- className: cn(
4844
- "absolute top-full pt-2 z-[9999] origin-top animate-in fade-in zoom-in-95 duration-200",
4845
- align === "right" ? "right-0" : "left-0",
4846
- width,
4847
- menuClassName
4848
- ),
4849
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "rounded-2xl bg-white dark:bg-gray-900 shadow-2xl ring-1 ring-black/5 dark:ring-white/10 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "py-2", children: items.map((item, index) => {
4850
- const isLoading = loadingItems[index];
4851
- const isDanger = item.variant === "danger";
4852
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
4853
- "button",
4854
- {
4855
- onClick: () => handleItemClick(item, index),
4856
- disabled: item.disabled || isLoading,
4857
- className: cn(
4858
- "flex w-full items-center gap-3 px-4 py-3 text-sm transition-all duration-150",
4859
- isDanger ? "text-red-600 dark:text-red-400" : "text-gray-700 dark:text-gray-200",
4860
- !item.disabled && !isLoading ? isDanger ? "hover:bg-red-50 dark:hover:bg-red-900/10 active:bg-red-100 dark:active:bg-red-900/20" : "hover:bg-blue-50/50 dark:hover:bg-blue-900/10 active:bg-blue-100 dark:active:bg-blue-900/20" : "opacity-40 cursor-not-allowed grayscale",
4861
- item.className
4862
- ),
4863
- children: [
4864
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "flex-shrink-0 flex items-center justify-center w-5 h-5", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4865
- LoadingSpin,
4866
- {
4867
- size: "sm",
4868
- className: cn(
4869
- isDanger ? "text-red-500" : "text-blue-500"
4870
- )
4871
- }
4872
- ) : item.icon }),
4873
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "flex-grow text-left font-medium", children: item.label })
4874
- ]
4875
- },
4876
- index
4877
- );
4878
- }) }) })
4879
- }
4866
+ isOpen && (0, import_react_dom3.createPortal)(
4867
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4868
+ "div",
4869
+ {
4870
+ className: cn(
4871
+ "dropdown-portal-menu fixed z-[10000] pt-2 origin-top",
4872
+ width,
4873
+ menuClassName
4874
+ ),
4875
+ style: {
4876
+ top: `${coords.top}px`,
4877
+ left: align === "right" ? `${coords.right}px` : `${coords.left}px`,
4878
+ transform: align === "right" ? "translateX(-100%)" : "none"
4879
+ },
4880
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "rounded-2xl bg-white dark:bg-gray-900 shadow-2xl ring-1 ring-black/5 dark:ring-white/10 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "py-2", children: items.map((item, index) => {
4881
+ const isLoading = loadingItems[index];
4882
+ const isDanger = item.variant === "danger";
4883
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
4884
+ "button",
4885
+ {
4886
+ onClick: () => handleItemClick(item, index),
4887
+ disabled: item.disabled || isLoading,
4888
+ className: cn(
4889
+ "flex w-full items-center gap-3 px-4 py-3 text-sm transition-all duration-150",
4890
+ isDanger ? "text-red-600 dark:text-red-400" : "text-gray-700 dark:text-gray-200",
4891
+ !item.disabled && !isLoading ? isDanger ? "hover:bg-red-50 dark:hover:bg-red-900/10 active:bg-red-100 dark:active:bg-red-900/20" : "hover:bg-blue-50/50 dark:hover:bg-blue-900/10 active:bg-blue-100 dark:active:bg-blue-900/20" : "opacity-40 cursor-not-allowed grayscale",
4892
+ item.className
4893
+ ),
4894
+ children: [
4895
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "flex-shrink-0 flex items-center justify-center w-5 h-5", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4896
+ LoadingSpin,
4897
+ {
4898
+ size: "sm",
4899
+ className: cn(
4900
+ isDanger ? "text-red-500" : "text-blue-500"
4901
+ )
4902
+ }
4903
+ ) : item.icon }),
4904
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "flex-grow text-left font-medium", children: item.label })
4905
+ ]
4906
+ },
4907
+ index
4908
+ );
4909
+ }) }) })
4910
+ }
4911
+ ),
4912
+ document.body
4880
4913
  )
4881
4914
  ]
4882
4915
  }
package/dist/index.mjs CHANGED
@@ -4731,7 +4731,8 @@ var useLogin = (props) => {
4731
4731
  import { useState as useState18 } from "react";
4732
4732
 
4733
4733
  // src/components/Dropdown.tsx
4734
- import { useState as useState17, useRef as useRef6, useEffect as useEffect11 } from "react";
4734
+ import { useState as useState17, useRef as useRef6, useEffect as useEffect11, useLayoutEffect } from "react";
4735
+ import { createPortal as createPortal3 } from "react-dom";
4735
4736
  import { jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
4736
4737
  var Dropdown = ({
4737
4738
  children,
@@ -4744,20 +4745,45 @@ var Dropdown = ({
4744
4745
  onOpenChange
4745
4746
  }) => {
4746
4747
  const [isOpen, setIsOpen] = useState17(false);
4747
- const dropdownRef = useRef6(null);
4748
+ const triggerRef = useRef6(null);
4749
+ const [coords, setCoords] = useState17({ top: 0, left: 0, right: 0 });
4748
4750
  const [loadingItems, setLoadingItems] = useState17({});
4751
+ const updateCoords = () => {
4752
+ if (triggerRef.current) {
4753
+ const rect = triggerRef.current.getBoundingClientRect();
4754
+ setCoords({
4755
+ top: rect.bottom,
4756
+ left: rect.left,
4757
+ right: rect.right
4758
+ });
4759
+ }
4760
+ };
4761
+ useLayoutEffect(() => {
4762
+ if (isOpen) {
4763
+ updateCoords();
4764
+ }
4765
+ }, [isOpen]);
4749
4766
  useEffect11(() => {
4750
4767
  onOpenChange?.(isOpen);
4768
+ const handleScrollAndResize = () => {
4769
+ if (isOpen) {
4770
+ updateCoords();
4771
+ }
4772
+ };
4751
4773
  const handleClickOutside = (event) => {
4752
- if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
4774
+ if (triggerRef.current && !triggerRef.current.contains(event.target) && !event.target.closest(".dropdown-portal-menu")) {
4753
4775
  setIsOpen(false);
4754
4776
  }
4755
4777
  };
4756
4778
  if (isOpen) {
4757
4779
  document.addEventListener("mousedown", handleClickOutside);
4780
+ window.addEventListener("scroll", handleScrollAndResize, true);
4781
+ window.addEventListener("resize", handleScrollAndResize);
4758
4782
  }
4759
4783
  return () => {
4760
4784
  document.removeEventListener("mousedown", handleClickOutside);
4785
+ window.removeEventListener("scroll", handleScrollAndResize, true);
4786
+ window.removeEventListener("resize", handleScrollAndResize);
4761
4787
  };
4762
4788
  }, [isOpen, onOpenChange]);
4763
4789
  const toggleDropdown = () => setIsOpen(!isOpen);
@@ -4785,7 +4811,7 @@ var Dropdown = ({
4785
4811
  return /* @__PURE__ */ jsxs23(
4786
4812
  "div",
4787
4813
  {
4788
- ref: dropdownRef,
4814
+ ref: triggerRef,
4789
4815
  className: cn("relative inline-block text-left", className),
4790
4816
  onMouseEnter: openDropdown,
4791
4817
  onMouseLeave: closeDropdown,
@@ -4806,46 +4832,53 @@ var Dropdown = ({
4806
4832
  children
4807
4833
  }
4808
4834
  ),
4809
- isOpen && /* @__PURE__ */ jsx32(
4810
- "div",
4811
- {
4812
- className: cn(
4813
- "absolute top-full pt-2 z-[9999] origin-top animate-in fade-in zoom-in-95 duration-200",
4814
- align === "right" ? "right-0" : "left-0",
4815
- width,
4816
- menuClassName
4817
- ),
4818
- children: /* @__PURE__ */ jsx32("div", { className: "rounded-2xl bg-white dark:bg-gray-900 shadow-2xl ring-1 ring-black/5 dark:ring-white/10 overflow-hidden", children: /* @__PURE__ */ jsx32("div", { className: "py-2", children: items.map((item, index) => {
4819
- const isLoading = loadingItems[index];
4820
- const isDanger = item.variant === "danger";
4821
- return /* @__PURE__ */ jsxs23(
4822
- "button",
4823
- {
4824
- onClick: () => handleItemClick(item, index),
4825
- disabled: item.disabled || isLoading,
4826
- className: cn(
4827
- "flex w-full items-center gap-3 px-4 py-3 text-sm transition-all duration-150",
4828
- isDanger ? "text-red-600 dark:text-red-400" : "text-gray-700 dark:text-gray-200",
4829
- !item.disabled && !isLoading ? isDanger ? "hover:bg-red-50 dark:hover:bg-red-900/10 active:bg-red-100 dark:active:bg-red-900/20" : "hover:bg-blue-50/50 dark:hover:bg-blue-900/10 active:bg-blue-100 dark:active:bg-blue-900/20" : "opacity-40 cursor-not-allowed grayscale",
4830
- item.className
4831
- ),
4832
- children: [
4833
- /* @__PURE__ */ jsx32("span", { className: "flex-shrink-0 flex items-center justify-center w-5 h-5", children: isLoading ? /* @__PURE__ */ jsx32(
4834
- LoadingSpin,
4835
- {
4836
- size: "sm",
4837
- className: cn(
4838
- isDanger ? "text-red-500" : "text-blue-500"
4839
- )
4840
- }
4841
- ) : item.icon }),
4842
- /* @__PURE__ */ jsx32("span", { className: "flex-grow text-left font-medium", children: item.label })
4843
- ]
4844
- },
4845
- index
4846
- );
4847
- }) }) })
4848
- }
4835
+ isOpen && createPortal3(
4836
+ /* @__PURE__ */ jsx32(
4837
+ "div",
4838
+ {
4839
+ className: cn(
4840
+ "dropdown-portal-menu fixed z-[10000] pt-2 origin-top",
4841
+ width,
4842
+ menuClassName
4843
+ ),
4844
+ style: {
4845
+ top: `${coords.top}px`,
4846
+ left: align === "right" ? `${coords.right}px` : `${coords.left}px`,
4847
+ transform: align === "right" ? "translateX(-100%)" : "none"
4848
+ },
4849
+ children: /* @__PURE__ */ jsx32("div", { className: "rounded-2xl bg-white dark:bg-gray-900 shadow-2xl ring-1 ring-black/5 dark:ring-white/10 overflow-hidden", children: /* @__PURE__ */ jsx32("div", { className: "py-2", children: items.map((item, index) => {
4850
+ const isLoading = loadingItems[index];
4851
+ const isDanger = item.variant === "danger";
4852
+ return /* @__PURE__ */ jsxs23(
4853
+ "button",
4854
+ {
4855
+ onClick: () => handleItemClick(item, index),
4856
+ disabled: item.disabled || isLoading,
4857
+ className: cn(
4858
+ "flex w-full items-center gap-3 px-4 py-3 text-sm transition-all duration-150",
4859
+ isDanger ? "text-red-600 dark:text-red-400" : "text-gray-700 dark:text-gray-200",
4860
+ !item.disabled && !isLoading ? isDanger ? "hover:bg-red-50 dark:hover:bg-red-900/10 active:bg-red-100 dark:active:bg-red-900/20" : "hover:bg-blue-50/50 dark:hover:bg-blue-900/10 active:bg-blue-100 dark:active:bg-blue-900/20" : "opacity-40 cursor-not-allowed grayscale",
4861
+ item.className
4862
+ ),
4863
+ children: [
4864
+ /* @__PURE__ */ jsx32("span", { className: "flex-shrink-0 flex items-center justify-center w-5 h-5", children: isLoading ? /* @__PURE__ */ jsx32(
4865
+ LoadingSpin,
4866
+ {
4867
+ size: "sm",
4868
+ className: cn(
4869
+ isDanger ? "text-red-500" : "text-blue-500"
4870
+ )
4871
+ }
4872
+ ) : item.icon }),
4873
+ /* @__PURE__ */ jsx32("span", { className: "flex-grow text-left font-medium", children: item.label })
4874
+ ]
4875
+ },
4876
+ index
4877
+ );
4878
+ }) }) })
4879
+ }
4880
+ ),
4881
+ document.body
4849
4882
  )
4850
4883
  ]
4851
4884
  }
@@ -7573,7 +7606,7 @@ var Views = {
7573
7606
  var Views_default = Views;
7574
7607
 
7575
7608
  // src/components/Guard.tsx
7576
- import { useEffect as useEffect16, useLayoutEffect } from "react";
7609
+ import { useEffect as useEffect16, useLayoutEffect as useLayoutEffect2 } from "react";
7577
7610
  import { Navigate, Outlet, useLocation as useLocation2 } from "react-router-dom";
7578
7611
  import { message as message3 } from "antd";
7579
7612
 
@@ -7672,7 +7705,7 @@ var Guard = () => {
7672
7705
  const { get } = useApis_default();
7673
7706
  const location = useLocation2();
7674
7707
  const { login, setIsLoggedIn, setIsFetched, isFetched } = useAuth();
7675
- useLayoutEffect(() => {
7708
+ useLayoutEffect2(() => {
7676
7709
  const fetchProfile = async () => {
7677
7710
  try {
7678
7711
  const res = await get({
package/dist/styles.js CHANGED
@@ -523,8 +523,8 @@ select:-webkit-autofill:focus {
523
523
  .z-50 {
524
524
  z-index: 50;
525
525
  }
526
- .z-\\[9999\\] {
527
- z-index: 9999;
526
+ .z-\\[10000\\] {
527
+ z-index: 10000;
528
528
  }
529
529
  .mx-0\\.5 {
530
530
  margin-left: 0.125rem;
package/dist/styles.mjs CHANGED
@@ -521,8 +521,8 @@ select:-webkit-autofill:focus {
521
521
  .z-50 {
522
522
  z-index: 50;
523
523
  }
524
- .z-\\[9999\\] {
525
- z-index: 9999;
524
+ .z-\\[10000\\] {
525
+ z-index: 10000;
526
526
  }
527
527
  .mx-0\\.5 {
528
528
  margin-left: 0.125rem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warqadui",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",