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/components/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { createContext, useRef, useState, useEffect, useContext } from 'react';
|
|
2
|
+
import { create, useStore } from 'zustand';
|
|
1
3
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
2
|
-
import { Flex, Text, Image, useMantineTheme, alpha } from '@mantine/core';
|
|
4
|
+
import { Flex, Text, Image, useMantineTheme, alpha, Progress, RingProgress } from '@mantine/core';
|
|
3
5
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
6
|
import { motion, AnimatePresence, useMotionValue } from 'framer-motion';
|
|
5
|
-
import { createContext, useRef, useState, useEffect, useContext } from 'react';
|
|
6
|
-
import { create, useStore } from 'zustand';
|
|
7
7
|
import clickSoundUrl from '../click_sound-PNCRRTM4.mp3';
|
|
8
8
|
import hoverSoundUrl from '../hover_sound-NBUA222C.mp3';
|
|
9
9
|
import '@mantine/core/styles.css';
|
|
@@ -163,11 +163,11 @@ var colorNames = {
|
|
|
163
163
|
Yellow: { r: 255, g: 255, b: 0 },
|
|
164
164
|
YellowGreen: { r: 154, g: 205, b: 50 }
|
|
165
165
|
};
|
|
166
|
-
function colorWithAlpha(color,
|
|
166
|
+
function colorWithAlpha(color, alpha3) {
|
|
167
167
|
const lowerCasedColor = color.toLowerCase();
|
|
168
168
|
if (colorNames[lowerCasedColor]) {
|
|
169
169
|
const rgb = colorNames[lowerCasedColor];
|
|
170
|
-
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${
|
|
170
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha3})`;
|
|
171
171
|
}
|
|
172
172
|
if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
|
|
173
173
|
const hex = color.slice(1);
|
|
@@ -175,16 +175,63 @@ function colorWithAlpha(color, alpha2) {
|
|
|
175
175
|
const r = bigint >> 16 & 255;
|
|
176
176
|
const g = bigint >> 8 & 255;
|
|
177
177
|
const b = bigint & 255;
|
|
178
|
-
return `rgba(${r}, ${g}, ${b}, ${
|
|
178
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha3})`;
|
|
179
179
|
}
|
|
180
180
|
if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
|
|
181
181
|
const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
|
|
182
182
|
if (result) {
|
|
183
|
-
return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${
|
|
183
|
+
return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha3})`;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
return color;
|
|
187
187
|
}
|
|
188
|
+
|
|
189
|
+
// src/utils/misc.ts
|
|
190
|
+
var isEnvBrowser = () => !window.invokeNative;
|
|
191
|
+
|
|
192
|
+
// src/utils/fetchNui.ts
|
|
193
|
+
async function fetchNui(eventName, data, mockData) {
|
|
194
|
+
const options = {
|
|
195
|
+
method: "post",
|
|
196
|
+
headers: {
|
|
197
|
+
"Content-Type": "application/json; charset=UTF-8"
|
|
198
|
+
},
|
|
199
|
+
body: JSON.stringify(data)
|
|
200
|
+
};
|
|
201
|
+
console.log(mockData);
|
|
202
|
+
if (isEnvBrowser() && mockData === void 0) {
|
|
203
|
+
console.warn(
|
|
204
|
+
`[fetchNui] Called fetchNui for event "${eventName}" in browser environment without mockData. Returning empty object.`
|
|
205
|
+
);
|
|
206
|
+
return {};
|
|
207
|
+
}
|
|
208
|
+
const resourceName = window.GetParentResourceName ? window.GetParentResourceName() : "nui-frame-app";
|
|
209
|
+
const resp = await fetch(`https://${resourceName}/${eventName}`, options);
|
|
210
|
+
return await resp.json();
|
|
211
|
+
}
|
|
212
|
+
async function registerInitialFetch(eventName, data, mockData) {
|
|
213
|
+
const fetcher = () => fetchNui(eventName, data, mockData);
|
|
214
|
+
return fetcher();
|
|
215
|
+
}
|
|
216
|
+
var localeStore = create((set, get) => {
|
|
217
|
+
return {
|
|
218
|
+
locales: {
|
|
219
|
+
"OccupantsDesc": "Here you can view and manage the occupants of your traphouse. These occupants can be used mainly for selling drugs to the NPCs surrounding your traphouse. However they have other uses to so be careful who you add as an occupant."
|
|
220
|
+
},
|
|
221
|
+
locale: (key, ...args) => {
|
|
222
|
+
const exists = get().locales[key];
|
|
223
|
+
let translation = exists || key;
|
|
224
|
+
if (args.length) {
|
|
225
|
+
translation = translation.replace(/%s/g, () => String(args.shift() || ""));
|
|
226
|
+
}
|
|
227
|
+
return translation;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
var locale = localeStore.getState().locale;
|
|
232
|
+
registerInitialFetch("GET_LOCALES", void 0).then((data) => {
|
|
233
|
+
localeStore.setState({ locales: data });
|
|
234
|
+
});
|
|
188
235
|
function BorderedIcon(props) {
|
|
189
236
|
const theme = useMantineTheme();
|
|
190
237
|
return /* @__PURE__ */ jsx(
|
|
@@ -960,6 +1007,171 @@ function Title(props) {
|
|
|
960
1007
|
}
|
|
961
1008
|
);
|
|
962
1009
|
}
|
|
1010
|
+
function LevelBanner(props) {
|
|
1011
|
+
return /* @__PURE__ */ jsxs(
|
|
1012
|
+
MotionFlex,
|
|
1013
|
+
{
|
|
1014
|
+
w: "35vh",
|
|
1015
|
+
pos: "absolute",
|
|
1016
|
+
left: "50%",
|
|
1017
|
+
align: "center",
|
|
1018
|
+
gap: "xs",
|
|
1019
|
+
style: {
|
|
1020
|
+
borderRadius: useMantineTheme().radius.xxs
|
|
1021
|
+
},
|
|
1022
|
+
initial: { opacity: 0, y: -10, transform: "translateX(-50%)" },
|
|
1023
|
+
animate: { opacity: 1, y: 0, transform: "translateX(-50%)" },
|
|
1024
|
+
exit: { opacity: 0, y: -10, transform: "translateX(-50%)" },
|
|
1025
|
+
transition: { duration: 0.3 },
|
|
1026
|
+
direction: "column",
|
|
1027
|
+
children: [
|
|
1028
|
+
/* @__PURE__ */ jsxs(
|
|
1029
|
+
Flex,
|
|
1030
|
+
{
|
|
1031
|
+
w: "100%",
|
|
1032
|
+
justify: "space-between",
|
|
1033
|
+
children: [
|
|
1034
|
+
/* @__PURE__ */ jsxs(
|
|
1035
|
+
Text,
|
|
1036
|
+
{
|
|
1037
|
+
size: "xxs",
|
|
1038
|
+
c: "rgba(255, 255, 255, 0.9)",
|
|
1039
|
+
style: {
|
|
1040
|
+
fontFamily: "Akrobat Bold",
|
|
1041
|
+
letterSpacing: "0.1em"
|
|
1042
|
+
},
|
|
1043
|
+
children: [
|
|
1044
|
+
"LVL ",
|
|
1045
|
+
props.level
|
|
1046
|
+
]
|
|
1047
|
+
}
|
|
1048
|
+
),
|
|
1049
|
+
/* @__PURE__ */ jsxs(
|
|
1050
|
+
Text,
|
|
1051
|
+
{
|
|
1052
|
+
size: "xxs",
|
|
1053
|
+
c: "rgba(255, 255, 255, 0.7)",
|
|
1054
|
+
style: {
|
|
1055
|
+
fontFamily: "Akrobat Bold",
|
|
1056
|
+
letterSpacing: "0.1em"
|
|
1057
|
+
},
|
|
1058
|
+
children: [
|
|
1059
|
+
props.exp,
|
|
1060
|
+
"/",
|
|
1061
|
+
props.nextLevelXP,
|
|
1062
|
+
" XP"
|
|
1063
|
+
]
|
|
1064
|
+
}
|
|
1065
|
+
),
|
|
1066
|
+
/* @__PURE__ */ jsxs(
|
|
1067
|
+
Text,
|
|
1068
|
+
{
|
|
1069
|
+
size: "xxs",
|
|
1070
|
+
c: "rgba(255, 255, 255, 0.7)",
|
|
1071
|
+
style: {
|
|
1072
|
+
fontFamily: "Akrobat Bold",
|
|
1073
|
+
letterSpacing: "0.1em"
|
|
1074
|
+
},
|
|
1075
|
+
children: [
|
|
1076
|
+
"LVL ",
|
|
1077
|
+
props.level + 1
|
|
1078
|
+
]
|
|
1079
|
+
}
|
|
1080
|
+
)
|
|
1081
|
+
]
|
|
1082
|
+
}
|
|
1083
|
+
),
|
|
1084
|
+
/* @__PURE__ */ jsx(
|
|
1085
|
+
Progress,
|
|
1086
|
+
{
|
|
1087
|
+
color: props.color,
|
|
1088
|
+
w: "100%",
|
|
1089
|
+
size: "sm",
|
|
1090
|
+
value: props.progressToLevel
|
|
1091
|
+
}
|
|
1092
|
+
)
|
|
1093
|
+
]
|
|
1094
|
+
}
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1097
|
+
function LevelPanel(props) {
|
|
1098
|
+
const theme = useMantineTheme();
|
|
1099
|
+
return /* @__PURE__ */ jsxs(
|
|
1100
|
+
Flex,
|
|
1101
|
+
{
|
|
1102
|
+
w: "fit-content",
|
|
1103
|
+
pr: "8vh",
|
|
1104
|
+
pl: "8vh",
|
|
1105
|
+
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%)",
|
|
1106
|
+
style: {
|
|
1107
|
+
borderRadius: theme.radius.xs,
|
|
1108
|
+
boxShadow: theme.shadows.sm,
|
|
1109
|
+
outline: "0.2vh solid rgba(255,255,255,0.1)"
|
|
1110
|
+
},
|
|
1111
|
+
justify: "center",
|
|
1112
|
+
align: "center",
|
|
1113
|
+
direction: "column",
|
|
1114
|
+
p: "sm",
|
|
1115
|
+
children: [
|
|
1116
|
+
/* @__PURE__ */ jsx(
|
|
1117
|
+
RingProgress,
|
|
1118
|
+
{
|
|
1119
|
+
size: 190,
|
|
1120
|
+
roundCaps: true,
|
|
1121
|
+
thickness: 10,
|
|
1122
|
+
sections: [{ value: props.progressToLevel, color: alpha(props.color || theme.colors[theme.primaryColor][theme.primaryShade], 0.9) }],
|
|
1123
|
+
label: /* @__PURE__ */ jsx(
|
|
1124
|
+
Flex,
|
|
1125
|
+
{
|
|
1126
|
+
justify: "center",
|
|
1127
|
+
align: "center",
|
|
1128
|
+
direction: "column",
|
|
1129
|
+
children: /* @__PURE__ */ jsx(
|
|
1130
|
+
Text,
|
|
1131
|
+
{
|
|
1132
|
+
size: "6vh",
|
|
1133
|
+
c: alpha(props.color || theme.colors[theme.primaryColor][theme.primaryShade], 0.9),
|
|
1134
|
+
style: {
|
|
1135
|
+
fontFamily: "Akrobat Black",
|
|
1136
|
+
textShadow: `0 0 10px ${alpha(props.color || theme.colors[theme.primaryColor][theme.primaryShade], 0.7)}`
|
|
1137
|
+
},
|
|
1138
|
+
children: props.level
|
|
1139
|
+
}
|
|
1140
|
+
)
|
|
1141
|
+
}
|
|
1142
|
+
)
|
|
1143
|
+
}
|
|
1144
|
+
),
|
|
1145
|
+
/* @__PURE__ */ jsx(
|
|
1146
|
+
Text,
|
|
1147
|
+
{
|
|
1148
|
+
size: "sm",
|
|
1149
|
+
style: {
|
|
1150
|
+
fontFamily: "Akrobat Black",
|
|
1151
|
+
letterSpacing: "0.05em",
|
|
1152
|
+
textTransform: "uppercase"
|
|
1153
|
+
},
|
|
1154
|
+
children: props.text || locale("Level")
|
|
1155
|
+
}
|
|
1156
|
+
),
|
|
1157
|
+
/* @__PURE__ */ jsxs(
|
|
1158
|
+
Text,
|
|
1159
|
+
{
|
|
1160
|
+
size: "xs",
|
|
1161
|
+
c: "rgba(255,255,255,0.6)",
|
|
1162
|
+
children: [
|
|
1163
|
+
props.exp,
|
|
1164
|
+
"/",
|
|
1165
|
+
props.nextLevelXP,
|
|
1166
|
+
" ",
|
|
1167
|
+
locale("EXP")
|
|
1168
|
+
]
|
|
1169
|
+
}
|
|
1170
|
+
)
|
|
1171
|
+
]
|
|
1172
|
+
}
|
|
1173
|
+
);
|
|
1174
|
+
}
|
|
963
1175
|
var ModalContext = createContext(null);
|
|
964
1176
|
function useModal(selector) {
|
|
965
1177
|
const modal = useContext(ModalContext);
|
|
@@ -1110,6 +1322,6 @@ function Modal() {
|
|
|
1110
1322
|
) });
|
|
1111
1323
|
}
|
|
1112
1324
|
|
|
1113
|
-
export { BorderedIcon, Counter, FloatingParticles, InfoBox, InputContainer, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, SegmentedControl, SegmentedProgress, Title, useModal, useModalActions, useNavigation, useNavigationStore };
|
|
1325
|
+
export { BorderedIcon, Counter, FloatingParticles, InfoBox, InputContainer, LevelBanner, LevelPanel, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, SegmentedControl, SegmentedProgress, Title, useModal, useModalActions, useNavigation, useNavigationStore };
|
|
1114
1326
|
//# sourceMappingURL=index.js.map
|
|
1115
1327
|
//# sourceMappingURL=index.js.map
|