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/components/index.cjs +220 -6
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +19 -2
- package/dist/components/index.d.ts +19 -2
- package/dist/components/index.js +220 -8
- package/dist/components/index.js.map +1 -1
- package/dist/index.cjs +214 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +211 -7
- package/dist/index.js.map +1 -1
- package/dist/utils/index.cjs +46 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +11 -1
- package/dist/utils/index.d.ts +11 -1
- package/dist/utils/index.js +40 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
var zustand = require('zustand');
|
|
5
|
+
var axios = require('axios');
|
|
5
6
|
var reactFontawesome = require('@fortawesome/react-fontawesome');
|
|
6
7
|
var core = require('@mantine/core');
|
|
7
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -22,6 +23,7 @@ var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
|
|
|
22
23
|
|
|
23
24
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
25
|
|
|
26
|
+
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
25
27
|
var clickSoundUrl__default = /*#__PURE__*/_interopDefault(clickSoundUrl);
|
|
26
28
|
var hoverSoundUrl__default = /*#__PURE__*/_interopDefault(hoverSoundUrl);
|
|
27
29
|
|
|
@@ -170,11 +172,11 @@ var colorNames = {
|
|
|
170
172
|
Yellow: { r: 255, g: 255, b: 0 },
|
|
171
173
|
YellowGreen: { r: 154, g: 205, b: 50 }
|
|
172
174
|
};
|
|
173
|
-
function colorWithAlpha(color,
|
|
175
|
+
function colorWithAlpha(color, alpha3) {
|
|
174
176
|
const lowerCasedColor = color.toLowerCase();
|
|
175
177
|
if (colorNames[lowerCasedColor]) {
|
|
176
178
|
const rgb = colorNames[lowerCasedColor];
|
|
177
|
-
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${
|
|
179
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha3})`;
|
|
178
180
|
}
|
|
179
181
|
if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
|
|
180
182
|
const hex = color.slice(1);
|
|
@@ -182,12 +184,12 @@ function colorWithAlpha(color, alpha2) {
|
|
|
182
184
|
const r = bigint >> 16 & 255;
|
|
183
185
|
const g = bigint >> 8 & 255;
|
|
184
186
|
const b = bigint & 255;
|
|
185
|
-
return `rgba(${r}, ${g}, ${b}, ${
|
|
187
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha3})`;
|
|
186
188
|
}
|
|
187
189
|
if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
|
|
188
190
|
const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
|
|
189
191
|
if (result) {
|
|
190
|
-
return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${
|
|
192
|
+
return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha3})`;
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
return color;
|
|
@@ -725,10 +727,12 @@ function createSkill(defaultSettings) {
|
|
|
725
727
|
const xpRequiredForLevel = nextLevelXP - currentLevelXP;
|
|
726
728
|
const progressToLevel = xpRequiredForLevel > 0 ? xpInCurrentLevel / xpRequiredForLevel * 100 : 100;
|
|
727
729
|
const xpToNextLevel = Math.max(0, nextLevelXP - xp);
|
|
730
|
+
const prevLevelXP = calculateXPForLevel(currentLevel - 1, settings);
|
|
728
731
|
return {
|
|
729
732
|
currentLevel,
|
|
730
733
|
nextLevel,
|
|
731
734
|
currentLevelXP,
|
|
735
|
+
prevLevelXP,
|
|
732
736
|
nextLevelXP,
|
|
733
737
|
progressToLevel: Math.min(100, Math.max(0, progressToLevel)),
|
|
734
738
|
xpToNextLevel
|
|
@@ -749,6 +753,42 @@ function createSkill(defaultSettings) {
|
|
|
749
753
|
useSkill
|
|
750
754
|
};
|
|
751
755
|
}
|
|
756
|
+
var dummyURL = "https://fmapi.net/api/v2/presigned-url/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJON0UxM0tzejFRM0NuSzRHWFBPbmUiLCJ0ZWFtSWQiOiJlMDQ1YnpwZzg5TGpoaUFTaURIdVoiLCJmaWxlVHlwZSI6ImltYWdlIiwidG9rZW5JZCI6ImpwczJ4Z0M1eFZqcnRoeWZTZnFsYSIsInNldHRpbmdzIjp7IlRlYW1JRCI6ImUwNDVienBnODlMamhpQVNpREh1WiIsIkltYWdlTm90aWZpY2F0aW9uVHlwZSI6IiIsIkRpc2NvcmRXZWJob29rIjoiIiwiRGlzY29yZEltYWdlQ2hhbm5lbCI6IiIsIlZpZGVvTm90aWZpY2F0aW9uVHlwZSI6IiIsIkRpc2NvcmRWaWRlb1dlYmhvb2siOiIiLCJEaXNjb3JkVmlkZW9DaGFubmVsIjoiIiwiQXVkaW9Ob3RpZmljYXRpb25UeXBlIjoiIiwiRGlzY29yZEF1ZGlvV2ViaG9vayI6IiIsIkRpc2NvcmRBdWRpb0NoYW5uZWwiOiIiLCJEaXNjb3JkQm90VG9rZW4iOiIiLCJSZXRlbnRpb25FbmFibGVkIjpmYWxzZSwiUmV0ZW50aW9uRGF5cyI6NywiVmlkZW9SZXRlbnRpb25FbmFibGVkIjpmYWxzZSwiVmlkZW9SZXRlbnRpb25EYXlzIjo3LCJBdWRpb1JldGVudGlvbkVuYWJsZWQiOmZhbHNlLCJBdWRpb1JldGVudGlvbkRheXMiOjcsIkxvZ0FsZXJ0RW5hYmxlZCI6ZmFsc2UsIkxvZ0FsZXJ0TGV2ZWxzIjpbXSwiTG9nQWxlcnREaXNjb3JkV2ViaG9vayI6IiIsIk92ZXJyaWRlSW1hZ2VRdWFsaXR5IjpmYWxzZSwiSW1hZ2VRdWFsaXR5Ijo1MH0sImV4cCI6MTc2MTg1MTEzNH0.fpPeQ0GCm5GNTddjttUQ78VMqRUAufXoOvv5C7Vh3WA";
|
|
757
|
+
async function updatePresignedURL() {
|
|
758
|
+
return await fetchNui("GET_PRESIGNED_URL", void 0, dummyURL);
|
|
759
|
+
}
|
|
760
|
+
async function uploadImage(props) {
|
|
761
|
+
const uploadURL = await updatePresignedURL();
|
|
762
|
+
const response = await fetch(props.fileURL);
|
|
763
|
+
const blob = await response.blob();
|
|
764
|
+
const file = new File([blob], "upload.png", { type: blob.type });
|
|
765
|
+
const formData = new FormData();
|
|
766
|
+
formData.append("file", file);
|
|
767
|
+
formData.append(
|
|
768
|
+
"metadata",
|
|
769
|
+
JSON.stringify({
|
|
770
|
+
name: props.name || file.name,
|
|
771
|
+
description: props.description || "Uploaded via DirkScripts"
|
|
772
|
+
})
|
|
773
|
+
);
|
|
774
|
+
const uploadRes = await axios__default.default.post(uploadURL, formData, {
|
|
775
|
+
headers: { "Content-Type": "multipart/form-data" }
|
|
776
|
+
});
|
|
777
|
+
const finalUrl = uploadRes.data?.data?.url ?? uploadRes.data?.url;
|
|
778
|
+
if (!finalUrl) throw new Error("Upload succeeded but no URL returned");
|
|
779
|
+
return finalUrl;
|
|
780
|
+
}
|
|
781
|
+
async function getImageShape(file) {
|
|
782
|
+
return new Promise((resolve, reject) => {
|
|
783
|
+
const img = new Image();
|
|
784
|
+
img.onload = () => {
|
|
785
|
+
if (img.width > img.height) resolve("wide");
|
|
786
|
+
else resolve("square");
|
|
787
|
+
};
|
|
788
|
+
img.onerror = () => reject(new Error("Failed to load image"));
|
|
789
|
+
img.src = typeof file === "string" ? file : URL.createObjectURL(file);
|
|
790
|
+
});
|
|
791
|
+
}
|
|
752
792
|
function BorderedIcon(props) {
|
|
753
793
|
const theme2 = core.useMantineTheme();
|
|
754
794
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1516,6 +1556,171 @@ function Title(props) {
|
|
|
1516
1556
|
}
|
|
1517
1557
|
);
|
|
1518
1558
|
}
|
|
1559
|
+
function LevelBanner(props) {
|
|
1560
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1561
|
+
MotionFlex,
|
|
1562
|
+
{
|
|
1563
|
+
w: "35vh",
|
|
1564
|
+
pos: "absolute",
|
|
1565
|
+
left: "50%",
|
|
1566
|
+
align: "center",
|
|
1567
|
+
gap: "xs",
|
|
1568
|
+
style: {
|
|
1569
|
+
borderRadius: core.useMantineTheme().radius.xxs
|
|
1570
|
+
},
|
|
1571
|
+
initial: { opacity: 0, y: -10, transform: "translateX(-50%)" },
|
|
1572
|
+
animate: { opacity: 1, y: 0, transform: "translateX(-50%)" },
|
|
1573
|
+
exit: { opacity: 0, y: -10, transform: "translateX(-50%)" },
|
|
1574
|
+
transition: { duration: 0.3 },
|
|
1575
|
+
direction: "column",
|
|
1576
|
+
children: [
|
|
1577
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1578
|
+
core.Flex,
|
|
1579
|
+
{
|
|
1580
|
+
w: "100%",
|
|
1581
|
+
justify: "space-between",
|
|
1582
|
+
children: [
|
|
1583
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1584
|
+
core.Text,
|
|
1585
|
+
{
|
|
1586
|
+
size: "xxs",
|
|
1587
|
+
c: "rgba(255, 255, 255, 0.9)",
|
|
1588
|
+
style: {
|
|
1589
|
+
fontFamily: "Akrobat Bold",
|
|
1590
|
+
letterSpacing: "0.1em"
|
|
1591
|
+
},
|
|
1592
|
+
children: [
|
|
1593
|
+
"LVL ",
|
|
1594
|
+
props.level
|
|
1595
|
+
]
|
|
1596
|
+
}
|
|
1597
|
+
),
|
|
1598
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1599
|
+
core.Text,
|
|
1600
|
+
{
|
|
1601
|
+
size: "xxs",
|
|
1602
|
+
c: "rgba(255, 255, 255, 0.7)",
|
|
1603
|
+
style: {
|
|
1604
|
+
fontFamily: "Akrobat Bold",
|
|
1605
|
+
letterSpacing: "0.1em"
|
|
1606
|
+
},
|
|
1607
|
+
children: [
|
|
1608
|
+
props.exp,
|
|
1609
|
+
"/",
|
|
1610
|
+
props.nextLevelXP,
|
|
1611
|
+
" XP"
|
|
1612
|
+
]
|
|
1613
|
+
}
|
|
1614
|
+
),
|
|
1615
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1616
|
+
core.Text,
|
|
1617
|
+
{
|
|
1618
|
+
size: "xxs",
|
|
1619
|
+
c: "rgba(255, 255, 255, 0.7)",
|
|
1620
|
+
style: {
|
|
1621
|
+
fontFamily: "Akrobat Bold",
|
|
1622
|
+
letterSpacing: "0.1em"
|
|
1623
|
+
},
|
|
1624
|
+
children: [
|
|
1625
|
+
"LVL ",
|
|
1626
|
+
props.level + 1
|
|
1627
|
+
]
|
|
1628
|
+
}
|
|
1629
|
+
)
|
|
1630
|
+
]
|
|
1631
|
+
}
|
|
1632
|
+
),
|
|
1633
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1634
|
+
core.Progress,
|
|
1635
|
+
{
|
|
1636
|
+
color: props.color,
|
|
1637
|
+
w: "100%",
|
|
1638
|
+
size: "sm",
|
|
1639
|
+
value: props.progressToLevel
|
|
1640
|
+
}
|
|
1641
|
+
)
|
|
1642
|
+
]
|
|
1643
|
+
}
|
|
1644
|
+
);
|
|
1645
|
+
}
|
|
1646
|
+
function LevelPanel(props) {
|
|
1647
|
+
const theme2 = core.useMantineTheme();
|
|
1648
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1649
|
+
core.Flex,
|
|
1650
|
+
{
|
|
1651
|
+
w: "fit-content",
|
|
1652
|
+
pr: "8vh",
|
|
1653
|
+
pl: "8vh",
|
|
1654
|
+
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%)",
|
|
1655
|
+
style: {
|
|
1656
|
+
borderRadius: theme2.radius.xs,
|
|
1657
|
+
boxShadow: theme2.shadows.sm,
|
|
1658
|
+
outline: "0.2vh solid rgba(255,255,255,0.1)"
|
|
1659
|
+
},
|
|
1660
|
+
justify: "center",
|
|
1661
|
+
align: "center",
|
|
1662
|
+
direction: "column",
|
|
1663
|
+
p: "sm",
|
|
1664
|
+
children: [
|
|
1665
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1666
|
+
core.RingProgress,
|
|
1667
|
+
{
|
|
1668
|
+
size: 190,
|
|
1669
|
+
roundCaps: true,
|
|
1670
|
+
thickness: 10,
|
|
1671
|
+
sections: [{ value: props.progressToLevel, color: core.alpha(props.color || theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.9) }],
|
|
1672
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1673
|
+
core.Flex,
|
|
1674
|
+
{
|
|
1675
|
+
justify: "center",
|
|
1676
|
+
align: "center",
|
|
1677
|
+
direction: "column",
|
|
1678
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1679
|
+
core.Text,
|
|
1680
|
+
{
|
|
1681
|
+
size: "6vh",
|
|
1682
|
+
c: core.alpha(props.color || theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.9),
|
|
1683
|
+
style: {
|
|
1684
|
+
fontFamily: "Akrobat Black",
|
|
1685
|
+
textShadow: `0 0 10px ${core.alpha(props.color || theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.7)}`
|
|
1686
|
+
},
|
|
1687
|
+
children: props.level
|
|
1688
|
+
}
|
|
1689
|
+
)
|
|
1690
|
+
}
|
|
1691
|
+
)
|
|
1692
|
+
}
|
|
1693
|
+
),
|
|
1694
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1695
|
+
core.Text,
|
|
1696
|
+
{
|
|
1697
|
+
size: "sm",
|
|
1698
|
+
style: {
|
|
1699
|
+
fontFamily: "Akrobat Black",
|
|
1700
|
+
letterSpacing: "0.05em",
|
|
1701
|
+
textTransform: "uppercase"
|
|
1702
|
+
},
|
|
1703
|
+
children: props.text || locale("Level")
|
|
1704
|
+
}
|
|
1705
|
+
),
|
|
1706
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1707
|
+
core.Text,
|
|
1708
|
+
{
|
|
1709
|
+
size: "xs",
|
|
1710
|
+
c: "rgba(255,255,255,0.6)",
|
|
1711
|
+
children: [
|
|
1712
|
+
props.exp,
|
|
1713
|
+
"/",
|
|
1714
|
+
props.nextLevelXP,
|
|
1715
|
+
" ",
|
|
1716
|
+
locale("EXP")
|
|
1717
|
+
]
|
|
1718
|
+
}
|
|
1719
|
+
)
|
|
1720
|
+
]
|
|
1721
|
+
}
|
|
1722
|
+
);
|
|
1723
|
+
}
|
|
1519
1724
|
var ModalContext = react.createContext(null);
|
|
1520
1725
|
function useModal(selector) {
|
|
1521
1726
|
const modal = react.useContext(ModalContext);
|
|
@@ -2139,6 +2344,8 @@ exports.FloatingParticles = FloatingParticles;
|
|
|
2139
2344
|
exports.FormProvider = FormProvider;
|
|
2140
2345
|
exports.InfoBox = InfoBox;
|
|
2141
2346
|
exports.InputContainer = InputContainer;
|
|
2347
|
+
exports.LevelBanner = LevelBanner;
|
|
2348
|
+
exports.LevelPanel = LevelPanel;
|
|
2142
2349
|
exports.ModalContext = ModalContext;
|
|
2143
2350
|
exports.ModalProvider = ModalProvider;
|
|
2144
2351
|
exports.MotionFlex = MotionFlex;
|
|
@@ -2157,6 +2364,7 @@ exports.copyToClipboard = copyToClipboard;
|
|
|
2157
2364
|
exports.createFormStore = createFormStore;
|
|
2158
2365
|
exports.createSkill = createSkill;
|
|
2159
2366
|
exports.fetchNui = fetchNui;
|
|
2367
|
+
exports.getImageShape = getImageShape;
|
|
2160
2368
|
exports.initialFetches = initialFetches;
|
|
2161
2369
|
exports.internalEvent = internalEvent;
|
|
2162
2370
|
exports.isEnvBrowser = isEnvBrowser;
|
|
@@ -2169,6 +2377,8 @@ exports.openLink = openLink;
|
|
|
2169
2377
|
exports.registerInitialFetch = registerInitialFetch;
|
|
2170
2378
|
exports.runFetches = runFetches;
|
|
2171
2379
|
exports.splitFAString = splitFAString;
|
|
2380
|
+
exports.updatePresignedURL = updatePresignedURL;
|
|
2381
|
+
exports.uploadImage = uploadImage;
|
|
2172
2382
|
exports.useAutoFetcher = useAutoFetcher;
|
|
2173
2383
|
exports.useForm = useForm;
|
|
2174
2384
|
exports.useModal = useModal;
|