dirk-cfx-react 1.0.37 → 1.0.40

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.cjs CHANGED
@@ -17,6 +17,7 @@ var jsxRuntime = require('react/jsx-runtime');
17
17
  var framerMotion = require('framer-motion');
18
18
  var clickSoundUrl = require('./click_sound-PNCRRTM4.mp3');
19
19
  var hoverSoundUrl = require('./hover_sound-NBUA222C.mp3');
20
+ var hooks = require('@mantine/hooks');
20
21
 
21
22
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
22
23
 
@@ -721,7 +722,7 @@ function getLevelFromXP(xp, levelMap, settings) {
721
722
  return settings.maxLevel;
722
723
  }
723
724
  function createSkill(defaultSettings) {
724
- const useStore2 = zustand.create((set) => ({
725
+ const useStore3 = zustand.create((set) => ({
725
726
  settings: defaultSettings,
726
727
  levelMap: generateLevelMap(defaultSettings),
727
728
  setSettings: (updater) => set((state) => {
@@ -733,7 +734,7 @@ function createSkill(defaultSettings) {
733
734
  })
734
735
  }));
735
736
  const useSkill = (xp) => {
736
- const { settings, levelMap } = useStore2();
737
+ const { settings, levelMap } = useStore3();
737
738
  return react.useMemo(() => {
738
739
  const currentLevel = getLevelFromXP(xp, levelMap, settings);
739
740
  const nextLevel = Math.min(currentLevel + 1, settings.maxLevel);
@@ -755,12 +756,12 @@ function createSkill(defaultSettings) {
755
756
  };
756
757
  const skill = {
757
758
  get settings() {
758
- return useStore2.getState().settings;
759
+ return useStore3.getState().settings;
759
760
  },
760
761
  setSettings: (updater) => {
761
- useStore2.getState().setSettings(updater);
762
+ useStore3.getState().setSettings(updater);
762
763
  },
763
- useSettings: () => useStore2((state) => state.settings)
764
+ useSettings: () => useStore3((state) => state.settings)
764
765
  };
765
766
  return {
766
767
  skill,
@@ -1756,6 +1757,155 @@ function Title(props) {
1756
1757
  }
1757
1758
  );
1758
1759
  }
1760
+ var ModalContext = react.createContext(null);
1761
+ function useModal(selector) {
1762
+ const modal = react.useContext(ModalContext);
1763
+ if (!modal) {
1764
+ throw new Error("useModal must be used within a ModalProvider");
1765
+ }
1766
+ return zustand.useStore(modal, selector);
1767
+ }
1768
+ function ModalProvider({ children, defaultPage }) {
1769
+ const storeRef = react.useRef(
1770
+ zustand.create(() => ({
1771
+ active: null
1772
+ }))
1773
+ );
1774
+ return /* @__PURE__ */ jsxRuntime.jsxs(ModalContext.Provider, { value: storeRef.current, children: [
1775
+ /* @__PURE__ */ jsxRuntime.jsx(Modal, {}),
1776
+ children
1777
+ ] });
1778
+ }
1779
+ function useModalActions() {
1780
+ const modal = react.useContext(ModalContext);
1781
+ if (!modal) throw new Error("useModalActions must be used within a ModalProvider");
1782
+ const showModal = (openModal) => {
1783
+ modal.setState({ active: openModal });
1784
+ };
1785
+ const hideModal = () => {
1786
+ modal.setState({ active: null });
1787
+ };
1788
+ return { showModal, hideModal };
1789
+ }
1790
+ function Modal() {
1791
+ const active = useModal((state) => state.active);
1792
+ const { hideModal } = useModalActions();
1793
+ const ref = hooks.useClickOutside(() => {
1794
+ if (!active) return;
1795
+ if (active.clickOutside == false) return;
1796
+ if (active) {
1797
+ hideModal();
1798
+ }
1799
+ });
1800
+ const theme2 = core.useMantineTheme();
1801
+ return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: active && /* @__PURE__ */ jsxRuntime.jsx(
1802
+ MotionFlex,
1803
+ {
1804
+ h: "100%",
1805
+ w: "100%",
1806
+ bg: "rgba(0, 0, 0, 0.3)",
1807
+ pos: "absolute",
1808
+ style: {
1809
+ zIndex: 2e3,
1810
+ filter: "drop-shadow(0 0 2vh black)"
1811
+ },
1812
+ initial: { opacity: 0 },
1813
+ animate: { opacity: 1 },
1814
+ exit: { opacity: 0 },
1815
+ align: "center",
1816
+ justify: "center",
1817
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1818
+ MotionFlex,
1819
+ {
1820
+ pos: "absolute",
1821
+ top: "50%",
1822
+ left: "50%",
1823
+ ref,
1824
+ w: active.width || "40%",
1825
+ style: {
1826
+ transform: "translate(-50%, -50%)",
1827
+ borderRadius: theme2.radius.xs,
1828
+ boxShadow: theme2.shadows.xl,
1829
+ zIndex: 2100
1830
+ },
1831
+ bg: "rgba(48, 48, 48, 0.84)",
1832
+ initial: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
1833
+ animate: { scale: 1, opacity: 1, transform: "translate(-50%, -50%)" },
1834
+ exit: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
1835
+ p: "sm",
1836
+ direction: "column",
1837
+ maw: "70%",
1838
+ gap: "xs",
1839
+ children: [
1840
+ /* @__PURE__ */ jsxRuntime.jsxs(
1841
+ core.Flex,
1842
+ {
1843
+ direction: "column",
1844
+ w: "100%",
1845
+ children: [
1846
+ /* @__PURE__ */ jsxRuntime.jsxs(
1847
+ core.Flex,
1848
+ {
1849
+ w: "100%",
1850
+ align: "center",
1851
+ gap: "xs",
1852
+ children: [
1853
+ active.icon && /* @__PURE__ */ jsxRuntime.jsx(
1854
+ reactFontawesome.FontAwesomeIcon,
1855
+ {
1856
+ icon: active.icon,
1857
+ style: {
1858
+ fontSize: theme2.fontSizes.xs
1859
+ }
1860
+ }
1861
+ ),
1862
+ /* @__PURE__ */ jsxRuntime.jsx(
1863
+ core.Text,
1864
+ {
1865
+ size: "sm",
1866
+ children: active.title
1867
+ }
1868
+ ),
1869
+ /* @__PURE__ */ jsxRuntime.jsx(
1870
+ MotionIcon,
1871
+ {
1872
+ icon: "times",
1873
+ color: "rgba(255, 255, 255, 0.7)",
1874
+ whileHover: {
1875
+ scale: 1.1,
1876
+ filter: "brightness(1.2)"
1877
+ },
1878
+ style: {
1879
+ marginLeft: "auto",
1880
+ cursor: "pointer",
1881
+ fontSize: theme2.fontSizes.sm
1882
+ },
1883
+ onClick: () => {
1884
+ hideModal();
1885
+ }
1886
+ }
1887
+ )
1888
+ ]
1889
+ }
1890
+ ),
1891
+ active.description && /* @__PURE__ */ jsxRuntime.jsx(
1892
+ core.Text,
1893
+ {
1894
+ size: "xs",
1895
+ c: "rgba(255, 255, 255, 0.7)",
1896
+ children: active.description
1897
+ }
1898
+ )
1899
+ ]
1900
+ }
1901
+ ),
1902
+ active.children
1903
+ ]
1904
+ }
1905
+ )
1906
+ }
1907
+ ) });
1908
+ }
1759
1909
 
1760
1910
  exports.BorderedIcon = BorderedIcon;
1761
1911
  exports.Counter = Counter;
@@ -1763,6 +1913,8 @@ exports.DirkProvider = DirkProvider;
1763
1913
  exports.FloatingParticles = FloatingParticles;
1764
1914
  exports.InfoBox = InfoBox;
1765
1915
  exports.InputContainer = InputContainer;
1916
+ exports.ModalContext = ModalContext;
1917
+ exports.ModalProvider = ModalProvider;
1766
1918
  exports.MotionFlex = MotionFlex;
1767
1919
  exports.MotionIcon = MotionIcon;
1768
1920
  exports.MotionImage = MotionImage;
@@ -1791,6 +1943,8 @@ exports.registerInitialFetch = registerInitialFetch;
1791
1943
  exports.runFetches = runFetches;
1792
1944
  exports.splitFAString = splitFAString;
1793
1945
  exports.useAutoFetcher = useAutoFetcher;
1946
+ exports.useModal = useModal;
1947
+ exports.useModalActions = useModalActions;
1794
1948
  exports.useNavigation = useNavigation;
1795
1949
  exports.useNavigationStore = useNavigationStore;
1796
1950
  exports.useNuiEvent = useNuiEvent;