dirk-cfx-react 1.0.36 → 1.0.38
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 +166 -12
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +27 -6
- package/dist/components/index.d.ts +27 -6
- package/dist/components/index.js +164 -13
- package/dist/components/index.js.map +1 -1
- package/dist/index.cjs +171 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +169 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BorderedIcon, BorderedIconProps, ButtonProps, Counter, FloatingParticles, FloatingParticlesProps, InfoBox, InfoBoxProps, InputContainer, InputContainerProps, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, NavigationStore, ParticleState, ProgressProps,
|
|
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
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';
|
|
3
3
|
export { TornEdgeSVGFilter, useNuiEvent, useTornEdges } from './hooks/index.cjs';
|
|
4
4
|
export { DirkProvider, DirkProviderProps, useSettings } from './providers/index.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BorderedIcon, BorderedIconProps, ButtonProps, Counter, FloatingParticles, FloatingParticlesProps, InfoBox, InfoBoxProps, InputContainer, InputContainerProps, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, NavigationStore, ParticleState, ProgressProps,
|
|
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
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';
|
|
3
3
|
export { TornEdgeSVGFilter, useNuiEvent, useTornEdges } from './hooks/index.js';
|
|
4
4
|
export { DirkProvider, DirkProviderProps, useSettings } from './providers/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
2
|
-
import { createTheme, Flex, Text, Image, MantineProvider, BackgroundImage, useMantineTheme } from '@mantine/core';
|
|
2
|
+
import { createTheme, Flex, Text, Image, MantineProvider, BackgroundImage, useMantineTheme, alpha } from '@mantine/core';
|
|
3
3
|
import { createContext, useRef, useEffect, useMemo, useState, useContext } from 'react';
|
|
4
4
|
import '@mantine/core/styles.css';
|
|
5
5
|
import '@mantine/notifications/styles.css';
|
|
@@ -15,6 +15,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
|
15
15
|
import { motion, AnimatePresence, useMotionValue } from 'framer-motion';
|
|
16
16
|
import clickSoundUrl from './click_sound-PNCRRTM4.mp3';
|
|
17
17
|
import hoverSoundUrl from './hover_sound-NBUA222C.mp3';
|
|
18
|
+
import { useClickOutside } from '@mantine/hooks';
|
|
18
19
|
|
|
19
20
|
// src/components/BorderedIcon.tsx
|
|
20
21
|
|
|
@@ -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,
|
|
167
|
+
function colorWithAlpha(color, alpha2) {
|
|
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}, ${
|
|
171
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha2})`;
|
|
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, alpha) {
|
|
|
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}, ${
|
|
179
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha2})`;
|
|
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]}, ${
|
|
184
|
+
return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha2})`;
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
return color;
|
|
@@ -714,7 +715,7 @@ function getLevelFromXP(xp, levelMap, settings) {
|
|
|
714
715
|
return settings.maxLevel;
|
|
715
716
|
}
|
|
716
717
|
function createSkill(defaultSettings) {
|
|
717
|
-
const
|
|
718
|
+
const useStore3 = create((set) => ({
|
|
718
719
|
settings: defaultSettings,
|
|
719
720
|
levelMap: generateLevelMap(defaultSettings),
|
|
720
721
|
setSettings: (updater) => set((state) => {
|
|
@@ -726,7 +727,7 @@ function createSkill(defaultSettings) {
|
|
|
726
727
|
})
|
|
727
728
|
}));
|
|
728
729
|
const useSkill = (xp) => {
|
|
729
|
-
const { settings, levelMap } =
|
|
730
|
+
const { settings, levelMap } = useStore3();
|
|
730
731
|
return useMemo(() => {
|
|
731
732
|
const currentLevel = getLevelFromXP(xp, levelMap, settings);
|
|
732
733
|
const nextLevel = Math.min(currentLevel + 1, settings.maxLevel);
|
|
@@ -748,12 +749,12 @@ function createSkill(defaultSettings) {
|
|
|
748
749
|
};
|
|
749
750
|
const skill = {
|
|
750
751
|
get settings() {
|
|
751
|
-
return
|
|
752
|
+
return useStore3.getState().settings;
|
|
752
753
|
},
|
|
753
754
|
setSettings: (updater) => {
|
|
754
|
-
|
|
755
|
+
useStore3.getState().setSettings(updater);
|
|
755
756
|
},
|
|
756
|
-
useSettings: () =>
|
|
757
|
+
useSettings: () => useStore3((state) => state.settings)
|
|
757
758
|
};
|
|
758
759
|
return {
|
|
759
760
|
skill,
|
|
@@ -1414,7 +1415,7 @@ function SegmentedControl(props) {
|
|
|
1414
1415
|
bg: "rgba(33, 33, 33, 0.6)",
|
|
1415
1416
|
w: props.w || "fit-content",
|
|
1416
1417
|
style: {
|
|
1417
|
-
borderRadius: theme2.radius.xs,
|
|
1418
|
+
borderRadius: props.enableRadius !== false ? theme2.radius.xs : 0,
|
|
1418
1419
|
overflow: "hidden"
|
|
1419
1420
|
},
|
|
1420
1421
|
...props,
|
|
@@ -1438,6 +1439,7 @@ function SegmentedControl(props) {
|
|
|
1438
1439
|
icon: item.icon,
|
|
1439
1440
|
rightSection: item.rightSection,
|
|
1440
1441
|
fz: props.fz,
|
|
1442
|
+
color: props.color,
|
|
1441
1443
|
selected: !props.multi ? props.value === item.value : Array.isArray(props.value) && props.value.includes(item.value),
|
|
1442
1444
|
onClick: () => {
|
|
1443
1445
|
if (props.multi) {
|
|
@@ -1466,7 +1468,7 @@ function Segment(props) {
|
|
|
1466
1468
|
direction: "column",
|
|
1467
1469
|
align: "center",
|
|
1468
1470
|
h: "100%",
|
|
1469
|
-
bg: props.selected ? colorWithAlpha(theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.2) : "transparent",
|
|
1471
|
+
bg: props.selected ? props.color ? alpha(props.color, 0.2) : colorWithAlpha(theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.2) : "transparent",
|
|
1470
1472
|
pos: "relative",
|
|
1471
1473
|
style: {
|
|
1472
1474
|
// position: "relative",
|
|
@@ -1488,10 +1490,10 @@ function Segment(props) {
|
|
|
1488
1490
|
{
|
|
1489
1491
|
icon: props.icon,
|
|
1490
1492
|
initial: {
|
|
1491
|
-
color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
|
|
1493
|
+
color: props.selected ? props.color || theme2.colors[theme2.primaryColor][5] : "inherit"
|
|
1492
1494
|
},
|
|
1493
1495
|
animate: {
|
|
1494
|
-
color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
|
|
1496
|
+
color: props.selected ? props.color || theme2.colors[theme2.primaryColor][5] : "inherit"
|
|
1495
1497
|
},
|
|
1496
1498
|
exit: {
|
|
1497
1499
|
color: "inherit"
|
|
@@ -1507,10 +1509,10 @@ function Segment(props) {
|
|
|
1507
1509
|
{
|
|
1508
1510
|
size: props.fz || "xs",
|
|
1509
1511
|
initial: {
|
|
1510
|
-
color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
|
|
1512
|
+
color: props.selected ? props.color || theme2.colors[theme2.primaryColor][5] : "inherit"
|
|
1511
1513
|
},
|
|
1512
1514
|
animate: {
|
|
1513
|
-
color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
|
|
1515
|
+
color: props.selected ? props.color || theme2.colors[theme2.primaryColor][5] : "inherit"
|
|
1514
1516
|
},
|
|
1515
1517
|
exit: {
|
|
1516
1518
|
color: "inherit"
|
|
@@ -1546,7 +1548,7 @@ function Segment(props) {
|
|
|
1546
1548
|
left: 0,
|
|
1547
1549
|
right: 0,
|
|
1548
1550
|
height: "0.2vh",
|
|
1549
|
-
backgroundColor: theme2.colors[theme2.primaryColor][5],
|
|
1551
|
+
backgroundColor: props.color || theme2.colors[theme2.primaryColor][5],
|
|
1550
1552
|
transformOrigin: "center"
|
|
1551
1553
|
}
|
|
1552
1554
|
}
|
|
@@ -1748,7 +1750,156 @@ function Title(props) {
|
|
|
1748
1750
|
}
|
|
1749
1751
|
);
|
|
1750
1752
|
}
|
|
1753
|
+
function Modal() {
|
|
1754
|
+
const active = useModal((state) => state.active);
|
|
1755
|
+
const { hideModal } = useModalActions();
|
|
1756
|
+
const ref = useClickOutside(() => {
|
|
1757
|
+
if (!active) return;
|
|
1758
|
+
if (active.clickOutside == false) return;
|
|
1759
|
+
if (active) {
|
|
1760
|
+
hideModal();
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
const theme2 = useMantineTheme();
|
|
1764
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: active && /* @__PURE__ */ jsx(
|
|
1765
|
+
MotionFlex,
|
|
1766
|
+
{
|
|
1767
|
+
h: "100%",
|
|
1768
|
+
w: "100%",
|
|
1769
|
+
bg: "rgba(0, 0, 0, 0.3)",
|
|
1770
|
+
pos: "absolute",
|
|
1771
|
+
style: {
|
|
1772
|
+
zIndex: 2e3,
|
|
1773
|
+
filter: "drop-shadow(0 0 2vh black)"
|
|
1774
|
+
},
|
|
1775
|
+
initial: { opacity: 0 },
|
|
1776
|
+
animate: { opacity: 1 },
|
|
1777
|
+
exit: { opacity: 0 },
|
|
1778
|
+
align: "center",
|
|
1779
|
+
justify: "center",
|
|
1780
|
+
children: /* @__PURE__ */ jsxs(
|
|
1781
|
+
MotionFlex,
|
|
1782
|
+
{
|
|
1783
|
+
pos: "absolute",
|
|
1784
|
+
top: "50%",
|
|
1785
|
+
left: "50%",
|
|
1786
|
+
ref,
|
|
1787
|
+
w: active.width || "40%",
|
|
1788
|
+
style: {
|
|
1789
|
+
transform: "translate(-50%, -50%)",
|
|
1790
|
+
borderRadius: theme2.radius.xs,
|
|
1791
|
+
boxShadow: theme2.shadows.xl,
|
|
1792
|
+
zIndex: 2100
|
|
1793
|
+
},
|
|
1794
|
+
bg: "rgba(48, 48, 48, 0.84)",
|
|
1795
|
+
initial: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
|
|
1796
|
+
animate: { scale: 1, opacity: 1, transform: "translate(-50%, -50%)" },
|
|
1797
|
+
exit: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
|
|
1798
|
+
p: "sm",
|
|
1799
|
+
direction: "column",
|
|
1800
|
+
maw: "70%",
|
|
1801
|
+
gap: "xs",
|
|
1802
|
+
children: [
|
|
1803
|
+
/* @__PURE__ */ jsxs(
|
|
1804
|
+
Flex,
|
|
1805
|
+
{
|
|
1806
|
+
direction: "column",
|
|
1807
|
+
w: "100%",
|
|
1808
|
+
children: [
|
|
1809
|
+
/* @__PURE__ */ jsxs(
|
|
1810
|
+
Flex,
|
|
1811
|
+
{
|
|
1812
|
+
w: "100%",
|
|
1813
|
+
align: "center",
|
|
1814
|
+
gap: "xs",
|
|
1815
|
+
children: [
|
|
1816
|
+
active.icon && /* @__PURE__ */ jsx(
|
|
1817
|
+
FontAwesomeIcon,
|
|
1818
|
+
{
|
|
1819
|
+
icon: active.icon,
|
|
1820
|
+
style: {
|
|
1821
|
+
fontSize: theme2.fontSizes.xs
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
),
|
|
1825
|
+
/* @__PURE__ */ jsx(
|
|
1826
|
+
Text,
|
|
1827
|
+
{
|
|
1828
|
+
size: "sm",
|
|
1829
|
+
children: active.title
|
|
1830
|
+
}
|
|
1831
|
+
),
|
|
1832
|
+
/* @__PURE__ */ jsx(
|
|
1833
|
+
MotionIcon,
|
|
1834
|
+
{
|
|
1835
|
+
icon: "times",
|
|
1836
|
+
color: "rgba(255, 255, 255, 0.7)",
|
|
1837
|
+
whileHover: {
|
|
1838
|
+
scale: 1.1,
|
|
1839
|
+
filter: "brightness(1.2)"
|
|
1840
|
+
},
|
|
1841
|
+
style: {
|
|
1842
|
+
marginLeft: "auto",
|
|
1843
|
+
cursor: "pointer",
|
|
1844
|
+
fontSize: theme2.fontSizes.sm
|
|
1845
|
+
},
|
|
1846
|
+
onClick: () => {
|
|
1847
|
+
hideModal();
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
)
|
|
1851
|
+
]
|
|
1852
|
+
}
|
|
1853
|
+
),
|
|
1854
|
+
active.description && /* @__PURE__ */ jsx(
|
|
1855
|
+
Text,
|
|
1856
|
+
{
|
|
1857
|
+
size: "xs",
|
|
1858
|
+
c: "rgba(255, 255, 255, 0.7)",
|
|
1859
|
+
children: active.description
|
|
1860
|
+
}
|
|
1861
|
+
)
|
|
1862
|
+
]
|
|
1863
|
+
}
|
|
1864
|
+
),
|
|
1865
|
+
active.children
|
|
1866
|
+
]
|
|
1867
|
+
}
|
|
1868
|
+
)
|
|
1869
|
+
}
|
|
1870
|
+
) });
|
|
1871
|
+
}
|
|
1872
|
+
var ModalContext = createContext(null);
|
|
1873
|
+
function useModal(selector) {
|
|
1874
|
+
const modal = useContext(ModalContext);
|
|
1875
|
+
if (!modal) {
|
|
1876
|
+
throw new Error("useModal must be used within a ModalProvider");
|
|
1877
|
+
}
|
|
1878
|
+
return useStore(modal, selector);
|
|
1879
|
+
}
|
|
1880
|
+
function ModalProvider({ children, defaultPage }) {
|
|
1881
|
+
const storeRef = useRef(
|
|
1882
|
+
create(() => ({
|
|
1883
|
+
active: null
|
|
1884
|
+
}))
|
|
1885
|
+
);
|
|
1886
|
+
return /* @__PURE__ */ jsxs(ModalContext.Provider, { value: storeRef.current, children: [
|
|
1887
|
+
/* @__PURE__ */ jsx(Modal, {}),
|
|
1888
|
+
children
|
|
1889
|
+
] });
|
|
1890
|
+
}
|
|
1891
|
+
function useModalActions() {
|
|
1892
|
+
const modal = useContext(ModalContext);
|
|
1893
|
+
if (!modal) throw new Error("useModalActions must be used within a ModalProvider");
|
|
1894
|
+
const showModal = (openModal) => {
|
|
1895
|
+
modal.setState({ active: openModal });
|
|
1896
|
+
};
|
|
1897
|
+
const hideModal = () => {
|
|
1898
|
+
modal.setState({ active: null });
|
|
1899
|
+
};
|
|
1900
|
+
return { showModal, hideModal };
|
|
1901
|
+
}
|
|
1751
1902
|
|
|
1752
|
-
export { BorderedIcon, Counter, DirkProvider, FloatingParticles, InfoBox, InputContainer, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider,
|
|
1903
|
+
export { BorderedIcon, Counter, DirkProvider, FloatingParticles, InfoBox, InputContainer, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, SegmentedControl, SegmentedProgress, Title, TornEdgeSVGFilter, colorWithAlpha, copyToClipboard, createSkill, fetchNui, initialFetches, internalEvent, isEnvBrowser, isProfanity, locale, localeStore, noop, numberToRoman, openLink, registerInitialFetch, runFetches, splitFAString, useAutoFetcher, useModal, useModalActions, useNavigation, useNavigationStore, useNuiEvent, useProfanityStore, useSettings, useTornEdges };
|
|
1753
1904
|
//# sourceMappingURL=index.js.map
|
|
1754
1905
|
//# sourceMappingURL=index.js.map
|