dirk-cfx-react 1.0.47 → 1.0.50

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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- export { BorderedIcon, BorderedIconProps, ButtonProps, Counter, FloatingParticles, FloatingParticlesProps, InfoBox, InfoBoxProps, InputContainer, InputContainerProps, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, NavigationStore, ParticleState, ProgressProps, SegmentProps, SegmentedControl, SegmentedControlProps, SegmentedProgress, Title, TitleProps, useModal, useModalActions, useNavigation, useNavigationStore } from './components/index.cjs';
2
- export { InitialFetch, InternalEvent, SkillSettings, colorWithAlpha, copyToClipboard, createSkill, fetchNui, initialFetches, internalEvent, isEnvBrowser, isProfanity, locale, localeStore, noop, numberToRoman, openLink, registerInitialFetch, runFetches, splitFAString, useAutoFetcher, useProfanityStore } from './utils/index.cjs';
1
+ export { BorderedIcon, BorderedIconProps, ButtonProps, Counter, FloatingParticles, FloatingParticlesProps, InfoBox, InfoBoxProps, InputContainer, InputContainerProps, LevelBanner, LevelPanel, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, NavigationStore, ParticleState, ProgressProps, SegmentProps, SegmentedControl, SegmentedControlProps, SegmentedProgress, Title, TitleProps, useModal, useModalActions, useNavigation, useNavigationStore } from './components/index.cjs';
2
+ export { InitialFetch, InternalEvent, SkillSettings, UploadImageProps, colorWithAlpha, copyToClipboard, createSkill, fetchNui, getImageShape, initialFetches, internalEvent, isEnvBrowser, isProfanity, locale, localeStore, noop, numberToRoman, openLink, registerInitialFetch, runFetches, splitFAString, updatePresignedURL, uploadImage, useAutoFetcher, useProfanityStore } from './utils/index.cjs';
3
3
  export { FormProvider, FormState, TornEdgeSVGFilter, ValidationRules, createFormStore, useForm, useNuiEvent, useTornEdges } from './hooks/index.cjs';
4
4
  export { DirkProvider, DirkProviderProps, useSettings } from './providers/index.cjs';
5
5
  import 'react/jsx-runtime';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { BorderedIcon, BorderedIconProps, ButtonProps, Counter, FloatingParticles, FloatingParticlesProps, InfoBox, InfoBoxProps, InputContainer, InputContainerProps, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, NavigationStore, ParticleState, ProgressProps, SegmentProps, SegmentedControl, SegmentedControlProps, SegmentedProgress, Title, TitleProps, useModal, useModalActions, useNavigation, useNavigationStore } from './components/index.js';
2
- export { InitialFetch, InternalEvent, SkillSettings, colorWithAlpha, copyToClipboard, createSkill, fetchNui, initialFetches, internalEvent, isEnvBrowser, isProfanity, locale, localeStore, noop, numberToRoman, openLink, registerInitialFetch, runFetches, splitFAString, useAutoFetcher, useProfanityStore } from './utils/index.js';
1
+ export { BorderedIcon, BorderedIconProps, ButtonProps, Counter, FloatingParticles, FloatingParticlesProps, InfoBox, InfoBoxProps, InputContainer, InputContainerProps, LevelBanner, LevelPanel, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, NavigationStore, ParticleState, ProgressProps, SegmentProps, SegmentedControl, SegmentedControlProps, SegmentedProgress, Title, TitleProps, useModal, useModalActions, useNavigation, useNavigationStore } from './components/index.js';
2
+ export { InitialFetch, InternalEvent, SkillSettings, UploadImageProps, colorWithAlpha, copyToClipboard, createSkill, fetchNui, getImageShape, initialFetches, internalEvent, isEnvBrowser, isProfanity, locale, localeStore, noop, numberToRoman, openLink, registerInitialFetch, runFetches, splitFAString, updatePresignedURL, uploadImage, useAutoFetcher, useProfanityStore } from './utils/index.js';
3
3
  export { FormProvider, FormState, TornEdgeSVGFilter, ValidationRules, createFormStore, useForm, useNuiEvent, useTornEdges } from './hooks/index.js';
4
4
  export { DirkProvider, DirkProviderProps, useSettings } from './providers/index.js';
5
5
  import 'react/jsx-runtime';
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { createContext, useEffect, useRef, useState, useContext, useMemo } from 'react';
2
2
  import { create, useStore, createStore } from 'zustand';
3
+ import axios from 'axios';
3
4
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
- import { Flex, Text, Image, createTheme, useMantineTheme, alpha, MantineProvider, BackgroundImage } from '@mantine/core';
5
+ import { Flex, Text, Image as Image$1, createTheme, useMantineTheme, alpha, Progress, RingProgress, MantineProvider, BackgroundImage } from '@mantine/core';
5
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
7
  import { motion, AnimatePresence, useMotionValue } from 'framer-motion';
7
8
  import clickSoundUrl from './click_sound-PNCRRTM4.mp3';
@@ -163,11 +164,11 @@ var colorNames = {
163
164
  Yellow: { r: 255, g: 255, b: 0 },
164
165
  YellowGreen: { r: 154, g: 205, b: 50 }
165
166
  };
166
- function colorWithAlpha(color, alpha2) {
167
+ function colorWithAlpha(color, alpha3) {
167
168
  const lowerCasedColor = color.toLowerCase();
168
169
  if (colorNames[lowerCasedColor]) {
169
170
  const rgb = colorNames[lowerCasedColor];
170
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha2})`;
171
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha3})`;
171
172
  }
172
173
  if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
173
174
  const hex = color.slice(1);
@@ -175,12 +176,12 @@ function colorWithAlpha(color, alpha2) {
175
176
  const r = bigint >> 16 & 255;
176
177
  const g = bigint >> 8 & 255;
177
178
  const b = bigint & 255;
178
- return `rgba(${r}, ${g}, ${b}, ${alpha2})`;
179
+ return `rgba(${r}, ${g}, ${b}, ${alpha3})`;
179
180
  }
180
181
  if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
181
182
  const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
182
183
  if (result) {
183
- return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha2})`;
184
+ return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha3})`;
184
185
  }
185
186
  }
186
187
  return color;
@@ -718,10 +719,12 @@ function createSkill(defaultSettings) {
718
719
  const xpRequiredForLevel = nextLevelXP - currentLevelXP;
719
720
  const progressToLevel = xpRequiredForLevel > 0 ? xpInCurrentLevel / xpRequiredForLevel * 100 : 100;
720
721
  const xpToNextLevel = Math.max(0, nextLevelXP - xp);
722
+ const prevLevelXP = calculateXPForLevel(currentLevel - 1, settings);
721
723
  return {
722
724
  currentLevel,
723
725
  nextLevel,
724
726
  currentLevelXP,
727
+ prevLevelXP,
725
728
  nextLevelXP,
726
729
  progressToLevel: Math.min(100, Math.max(0, progressToLevel)),
727
730
  xpToNextLevel
@@ -742,6 +745,42 @@ function createSkill(defaultSettings) {
742
745
  useSkill
743
746
  };
744
747
  }
748
+ var dummyURL = "https://fmapi.net/api/v2/presigned-url/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJON0UxM0tzejFRM0NuSzRHWFBPbmUiLCJ0ZWFtSWQiOiJlMDQ1YnpwZzg5TGpoaUFTaURIdVoiLCJmaWxlVHlwZSI6ImltYWdlIiwidG9rZW5JZCI6ImpwczJ4Z0M1eFZqcnRoeWZTZnFsYSIsInNldHRpbmdzIjp7IlRlYW1JRCI6ImUwNDVienBnODlMamhpQVNpREh1WiIsIkltYWdlTm90aWZpY2F0aW9uVHlwZSI6IiIsIkRpc2NvcmRXZWJob29rIjoiIiwiRGlzY29yZEltYWdlQ2hhbm5lbCI6IiIsIlZpZGVvTm90aWZpY2F0aW9uVHlwZSI6IiIsIkRpc2NvcmRWaWRlb1dlYmhvb2siOiIiLCJEaXNjb3JkVmlkZW9DaGFubmVsIjoiIiwiQXVkaW9Ob3RpZmljYXRpb25UeXBlIjoiIiwiRGlzY29yZEF1ZGlvV2ViaG9vayI6IiIsIkRpc2NvcmRBdWRpb0NoYW5uZWwiOiIiLCJEaXNjb3JkQm90VG9rZW4iOiIiLCJSZXRlbnRpb25FbmFibGVkIjpmYWxzZSwiUmV0ZW50aW9uRGF5cyI6NywiVmlkZW9SZXRlbnRpb25FbmFibGVkIjpmYWxzZSwiVmlkZW9SZXRlbnRpb25EYXlzIjo3LCJBdWRpb1JldGVudGlvbkVuYWJsZWQiOmZhbHNlLCJBdWRpb1JldGVudGlvbkRheXMiOjcsIkxvZ0FsZXJ0RW5hYmxlZCI6ZmFsc2UsIkxvZ0FsZXJ0TGV2ZWxzIjpbXSwiTG9nQWxlcnREaXNjb3JkV2ViaG9vayI6IiIsIk92ZXJyaWRlSW1hZ2VRdWFsaXR5IjpmYWxzZSwiSW1hZ2VRdWFsaXR5Ijo1MH0sImV4cCI6MTc2MTg1MTEzNH0.fpPeQ0GCm5GNTddjttUQ78VMqRUAufXoOvv5C7Vh3WA";
749
+ async function updatePresignedURL() {
750
+ return await fetchNui("GET_PRESIGNED_URL", void 0, dummyURL);
751
+ }
752
+ async function uploadImage(props) {
753
+ const uploadURL = await updatePresignedURL();
754
+ const response = await fetch(props.fileURL);
755
+ const blob = await response.blob();
756
+ const file = new File([blob], "upload.png", { type: blob.type });
757
+ const formData = new FormData();
758
+ formData.append("file", file);
759
+ formData.append(
760
+ "metadata",
761
+ JSON.stringify({
762
+ name: props.name || file.name,
763
+ description: props.description || "Uploaded via DirkScripts"
764
+ })
765
+ );
766
+ const uploadRes = await axios.post(uploadURL, formData, {
767
+ headers: { "Content-Type": "multipart/form-data" }
768
+ });
769
+ const finalUrl = uploadRes.data?.data?.url ?? uploadRes.data?.url;
770
+ if (!finalUrl) throw new Error("Upload succeeded but no URL returned");
771
+ return finalUrl;
772
+ }
773
+ async function getImageShape(file) {
774
+ return new Promise((resolve, reject) => {
775
+ const img = new Image();
776
+ img.onload = () => {
777
+ if (img.width > img.height) resolve("wide");
778
+ else resolve("square");
779
+ };
780
+ img.onerror = () => reject(new Error("Failed to load image"));
781
+ img.src = typeof file === "string" ? file : URL.createObjectURL(file);
782
+ });
783
+ }
745
784
  function BorderedIcon(props) {
746
785
  const theme2 = useMantineTheme();
747
786
  return /* @__PURE__ */ jsx(
@@ -766,7 +805,7 @@ function BorderedIcon(props) {
766
805
  }
767
806
  var MotionFlex = motion.create(Flex);
768
807
  var MotionText = motion.create(Text);
769
- var MotionImage = motion.create(Image);
808
+ var MotionImage = motion.create(Image$1);
770
809
  var MotionIcon = motion.create(FontAwesomeIcon);
771
810
  function Counter(props) {
772
811
  return /* @__PURE__ */ jsx(AnimatePresence, { children: props.count > 0 && /* @__PURE__ */ jsx(
@@ -1509,6 +1548,171 @@ function Title(props) {
1509
1548
  }
1510
1549
  );
1511
1550
  }
1551
+ function LevelBanner(props) {
1552
+ return /* @__PURE__ */ jsxs(
1553
+ MotionFlex,
1554
+ {
1555
+ w: "35vh",
1556
+ pos: "absolute",
1557
+ left: "50%",
1558
+ align: "center",
1559
+ gap: "xs",
1560
+ style: {
1561
+ borderRadius: useMantineTheme().radius.xxs
1562
+ },
1563
+ initial: { opacity: 0, y: -10, transform: "translateX(-50%)" },
1564
+ animate: { opacity: 1, y: 0, transform: "translateX(-50%)" },
1565
+ exit: { opacity: 0, y: -10, transform: "translateX(-50%)" },
1566
+ transition: { duration: 0.3 },
1567
+ direction: "column",
1568
+ children: [
1569
+ /* @__PURE__ */ jsxs(
1570
+ Flex,
1571
+ {
1572
+ w: "100%",
1573
+ justify: "space-between",
1574
+ children: [
1575
+ /* @__PURE__ */ jsxs(
1576
+ Text,
1577
+ {
1578
+ size: "xxs",
1579
+ c: "rgba(255, 255, 255, 0.9)",
1580
+ style: {
1581
+ fontFamily: "Akrobat Bold",
1582
+ letterSpacing: "0.1em"
1583
+ },
1584
+ children: [
1585
+ "LVL ",
1586
+ props.level
1587
+ ]
1588
+ }
1589
+ ),
1590
+ /* @__PURE__ */ jsxs(
1591
+ Text,
1592
+ {
1593
+ size: "xxs",
1594
+ c: "rgba(255, 255, 255, 0.7)",
1595
+ style: {
1596
+ fontFamily: "Akrobat Bold",
1597
+ letterSpacing: "0.1em"
1598
+ },
1599
+ children: [
1600
+ props.exp,
1601
+ "/",
1602
+ props.nextLevelXP,
1603
+ " XP"
1604
+ ]
1605
+ }
1606
+ ),
1607
+ /* @__PURE__ */ jsxs(
1608
+ Text,
1609
+ {
1610
+ size: "xxs",
1611
+ c: "rgba(255, 255, 255, 0.7)",
1612
+ style: {
1613
+ fontFamily: "Akrobat Bold",
1614
+ letterSpacing: "0.1em"
1615
+ },
1616
+ children: [
1617
+ "LVL ",
1618
+ props.level + 1
1619
+ ]
1620
+ }
1621
+ )
1622
+ ]
1623
+ }
1624
+ ),
1625
+ /* @__PURE__ */ jsx(
1626
+ Progress,
1627
+ {
1628
+ color: props.color,
1629
+ w: "100%",
1630
+ size: "sm",
1631
+ value: props.progressToLevel
1632
+ }
1633
+ )
1634
+ ]
1635
+ }
1636
+ );
1637
+ }
1638
+ function LevelPanel(props) {
1639
+ const theme2 = useMantineTheme();
1640
+ return /* @__PURE__ */ jsxs(
1641
+ Flex,
1642
+ {
1643
+ w: "fit-content",
1644
+ pr: "8vh",
1645
+ pl: "8vh",
1646
+ bg: "linear-gradient(180deg, rgba(30, 30, 30, 0.82) 0%, rgba(30, 30, 30, 0.3) 50%, rgba(30, 30, 30, 0.6) 100%)",
1647
+ style: {
1648
+ borderRadius: theme2.radius.xs,
1649
+ boxShadow: theme2.shadows.sm,
1650
+ outline: "0.2vh solid rgba(255,255,255,0.1)"
1651
+ },
1652
+ justify: "center",
1653
+ align: "center",
1654
+ direction: "column",
1655
+ p: "sm",
1656
+ children: [
1657
+ /* @__PURE__ */ jsx(
1658
+ RingProgress,
1659
+ {
1660
+ size: 190,
1661
+ roundCaps: true,
1662
+ thickness: 10,
1663
+ sections: [{ value: props.progressToLevel, color: alpha(props.color || theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.9) }],
1664
+ label: /* @__PURE__ */ jsx(
1665
+ Flex,
1666
+ {
1667
+ justify: "center",
1668
+ align: "center",
1669
+ direction: "column",
1670
+ children: /* @__PURE__ */ jsx(
1671
+ Text,
1672
+ {
1673
+ size: "6vh",
1674
+ c: alpha(props.color || theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.9),
1675
+ style: {
1676
+ fontFamily: "Akrobat Black",
1677
+ textShadow: `0 0 10px ${alpha(props.color || theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.7)}`
1678
+ },
1679
+ children: props.level
1680
+ }
1681
+ )
1682
+ }
1683
+ )
1684
+ }
1685
+ ),
1686
+ /* @__PURE__ */ jsx(
1687
+ Text,
1688
+ {
1689
+ size: "sm",
1690
+ style: {
1691
+ fontFamily: "Akrobat Black",
1692
+ letterSpacing: "0.05em",
1693
+ textTransform: "uppercase"
1694
+ },
1695
+ children: props.text || locale("Level")
1696
+ }
1697
+ ),
1698
+ /* @__PURE__ */ jsxs(
1699
+ Text,
1700
+ {
1701
+ size: "xs",
1702
+ c: "rgba(255,255,255,0.6)",
1703
+ children: [
1704
+ props.exp,
1705
+ "/",
1706
+ props.nextLevelXP,
1707
+ " ",
1708
+ locale("EXP")
1709
+ ]
1710
+ }
1711
+ )
1712
+ ]
1713
+ }
1714
+ );
1715
+ }
1512
1716
  var ModalContext = createContext(null);
1513
1717
  function useModal(selector) {
1514
1718
  const modal = useContext(ModalContext);
@@ -2125,6 +2329,6 @@ function TornEdgeSVGFilter() {
2125
2329
  );
2126
2330
  }
2127
2331
 
2128
- export { BorderedIcon, Counter, DirkProvider, FloatingParticles, FormProvider, InfoBox, InputContainer, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, SegmentedControl, SegmentedProgress, Title, TornEdgeSVGFilter, colorWithAlpha, copyToClipboard, createFormStore, createSkill, fetchNui, initialFetches, internalEvent, isEnvBrowser, isProfanity, locale, localeStore, noop, numberToRoman, openLink, registerInitialFetch, runFetches, splitFAString, useAutoFetcher, useForm, useModal, useModalActions, useNavigation, useNavigationStore, useNuiEvent, useProfanityStore, useSettings, useTornEdges };
2332
+ export { BorderedIcon, Counter, DirkProvider, FloatingParticles, FormProvider, InfoBox, InputContainer, LevelBanner, LevelPanel, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, SegmentedControl, SegmentedProgress, Title, TornEdgeSVGFilter, colorWithAlpha, copyToClipboard, createFormStore, createSkill, fetchNui, getImageShape, initialFetches, internalEvent, isEnvBrowser, isProfanity, locale, localeStore, noop, numberToRoman, openLink, registerInitialFetch, runFetches, splitFAString, updatePresignedURL, uploadImage, useAutoFetcher, useForm, useModal, useModalActions, useNavigation, useNavigationStore, useNuiEvent, useProfanityStore, useSettings, useTornEdges };
2129
2333
  //# sourceMappingURL=index.js.map
2130
2334
  //# sourceMappingURL=index.js.map