dirk-cfx-react 1.1.62 → 1.1.64
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 +45 -17
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +46 -18
- package/dist/components/index.js.map +1 -1
- package/dist/hooks/index.cjs +6 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.js +6 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +55 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +56 -18
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +78 -2
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.js +79 -3
- package/dist/providers/index.js.map +1 -1
- package/dist/utils/index.cjs +22 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +3 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +22 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +113 -112
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Flex, Text, Image as Image$1, createTheme, Box, Stack, Title as Title$1, Code, TextInput, Select, useMantineTheme, alpha, Progress, RingProgress, Portal, Button, Loader, ActionIcon, MantineProvider, BackgroundImage, Group, JsonInput } from '@mantine/core';
|
|
1
|
+
import { Flex, Text, Image as Image$1, createTheme, Box, Stack, Title as Title$1, Code, TextInput, Select, useMantineTheme, Tooltip, alpha, Progress, RingProgress, Portal, Button, Loader, ActionIcon, MantineProvider, BackgroundImage, Group, JsonInput } from '@mantine/core';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import React5, { createContext, useContext, useEffect, useRef, useState, useMemo, useLayoutEffect } from 'react';
|
|
4
4
|
import { create, useStore, createStore } from 'zustand';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
7
|
import { motion, AnimatePresence, useMotionValue } from 'framer-motion';
|
|
8
|
+
import { Info, X, AlertTriangle, Trash2, Check, FlaskConical, ChevronUp, ChevronDown, ArrowLeft, Undo2, Redo2, Save, History, XCircle, Code2, RotateCcw, Search, Filter, User } from 'lucide-react';
|
|
8
9
|
import clickSoundUrl from './click_sound-PNCRRTM4.mp3';
|
|
9
10
|
import hoverSoundUrl from './hover_sound-NBUA222C.mp3';
|
|
10
|
-
import { X, AlertTriangle, Trash2, Check, FlaskConical, ChevronUp, ChevronDown, ArrowLeft, Undo2, Redo2, Save, History, XCircle, Code2, RotateCcw, Search, Filter, User } from 'lucide-react';
|
|
11
11
|
import { QueryClient, QueryClientProvider, useInfiniteQuery } from '@tanstack/react-query';
|
|
12
12
|
import '@mantine/core/styles.css';
|
|
13
13
|
import '@mantine/notifications/styles.css';
|
|
@@ -1306,8 +1306,12 @@ async function fetchNui(eventName, data, mockData) {
|
|
|
1306
1306
|
}
|
|
1307
1307
|
const overrideResourceName = useSettings.getState().overideResourceName;
|
|
1308
1308
|
const resourceName = window.GetParentResourceName ? window.GetParentResourceName() : overrideResourceName ? overrideResourceName : "dirk-cfx-react";
|
|
1309
|
-
|
|
1310
|
-
|
|
1309
|
+
try {
|
|
1310
|
+
const resp = await fetch(`https://${resourceName}/${eventName}`, options);
|
|
1311
|
+
return await resp.json();
|
|
1312
|
+
} catch {
|
|
1313
|
+
return mockData ?? {};
|
|
1314
|
+
}
|
|
1311
1315
|
}
|
|
1312
1316
|
var initialFetches = {};
|
|
1313
1317
|
async function registerInitialFetch(eventName, data, mockData) {
|
|
@@ -1354,6 +1358,13 @@ var internalEvent = (events, timer = 1e3) => {
|
|
|
1354
1358
|
}
|
|
1355
1359
|
}
|
|
1356
1360
|
};
|
|
1361
|
+
var reportedMissing = /* @__PURE__ */ new Set();
|
|
1362
|
+
function reportMissingLocale(key) {
|
|
1363
|
+
if (!key || reportedMissing.has(key)) return;
|
|
1364
|
+
reportedMissing.add(key);
|
|
1365
|
+
fetchNui("REPORT_MISSING_LOCALE", { key }).catch(() => {
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1357
1368
|
var localeStore = create((set, get) => {
|
|
1358
1369
|
return {
|
|
1359
1370
|
locales: {
|
|
@@ -1361,6 +1372,7 @@ var localeStore = create((set, get) => {
|
|
|
1361
1372
|
},
|
|
1362
1373
|
locale: (key, ...args) => {
|
|
1363
1374
|
const exists = get().locales[key];
|
|
1375
|
+
if (!exists) reportMissingLocale(key);
|
|
1364
1376
|
let translation = exists || key;
|
|
1365
1377
|
if (args.length) {
|
|
1366
1378
|
translation = translation.replace(/%s/g, () => String(args.shift() || ""));
|
|
@@ -1374,6 +1386,14 @@ registerInitialFetch("GET_LOCALES", void 0).then((data) => {
|
|
|
1374
1386
|
localeStore.setState({ locales: data });
|
|
1375
1387
|
}).catch(() => {
|
|
1376
1388
|
});
|
|
1389
|
+
if (typeof window !== "undefined") {
|
|
1390
|
+
window.addEventListener("message", (event) => {
|
|
1391
|
+
const msg = event.data;
|
|
1392
|
+
if (!msg || msg.action !== "UPDATE_DIRK_LIB_LOCALES") return;
|
|
1393
|
+
if (!msg.data || typeof msg.data !== "object") return;
|
|
1394
|
+
localeStore.setState({ locales: msg.data });
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1377
1397
|
|
|
1378
1398
|
// src/utils/map.ts
|
|
1379
1399
|
var mapCenter = [-119.43, 58.84];
|
|
@@ -2536,8 +2556,8 @@ function InputContainer(props) {
|
|
|
2536
2556
|
(props.title || props.description) && /* @__PURE__ */ jsxs(
|
|
2537
2557
|
Flex,
|
|
2538
2558
|
{
|
|
2539
|
-
|
|
2540
|
-
|
|
2559
|
+
align: "center",
|
|
2560
|
+
flex: 1,
|
|
2541
2561
|
p: props.p == "0" ? "sm" : 0,
|
|
2542
2562
|
children: [
|
|
2543
2563
|
props.title && /* @__PURE__ */ jsx(
|
|
@@ -2554,12 +2574,26 @@ function InputContainer(props) {
|
|
|
2554
2574
|
}
|
|
2555
2575
|
),
|
|
2556
2576
|
props.description && /* @__PURE__ */ jsx(
|
|
2557
|
-
|
|
2577
|
+
Tooltip,
|
|
2558
2578
|
{
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2579
|
+
label: props.description,
|
|
2580
|
+
position: "top-end",
|
|
2581
|
+
withArrow: true,
|
|
2582
|
+
multiline: true,
|
|
2583
|
+
maw: "22vh",
|
|
2584
|
+
styles: {
|
|
2585
|
+
tooltip: {
|
|
2586
|
+
background: alpha(theme2.colors.dark[7], 0.95),
|
|
2587
|
+
border: `0.1vh solid rgba(255,255,255,0.1)`,
|
|
2588
|
+
color: "rgba(255,255,255,0.75)",
|
|
2589
|
+
fontFamily: "Akrobat Bold",
|
|
2590
|
+
fontSize: "1.3vh",
|
|
2591
|
+
lineHeight: 1.3,
|
|
2592
|
+
padding: "0.6vh 0.8vh",
|
|
2593
|
+
letterSpacing: "0.03em"
|
|
2594
|
+
}
|
|
2595
|
+
},
|
|
2596
|
+
children: /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", style: { marginLeft: "auto", cursor: "help" }, children: /* @__PURE__ */ jsx(Info, { size: "1.6vh", color: alpha(theme2.colors[theme2.primaryColor][5], 0.45) }) })
|
|
2563
2597
|
}
|
|
2564
2598
|
)
|
|
2565
2599
|
]
|
|
@@ -2576,13 +2610,7 @@ function InputContainer(props) {
|
|
|
2576
2610
|
children: props.error
|
|
2577
2611
|
}
|
|
2578
2612
|
),
|
|
2579
|
-
/* @__PURE__ */ jsx(
|
|
2580
|
-
Flex,
|
|
2581
|
-
{
|
|
2582
|
-
ml: "auto",
|
|
2583
|
-
children: props.rightSection
|
|
2584
|
-
}
|
|
2585
|
-
)
|
|
2613
|
+
props.rightSection && /* @__PURE__ */ jsx(Flex, { children: props.rightSection })
|
|
2586
2614
|
]
|
|
2587
2615
|
}
|
|
2588
2616
|
),
|
|
@@ -5177,6 +5205,11 @@ function mergeMantineThemeSafe(base, custom, override) {
|
|
|
5177
5205
|
const colors = { ...base.colors };
|
|
5178
5206
|
if (custom && isValidColorScale(custom)) {
|
|
5179
5207
|
colors["custom"] = custom;
|
|
5208
|
+
} else if (!colors["custom"]) {
|
|
5209
|
+
const fallback = base.colors && base.colors.dirk;
|
|
5210
|
+
if (fallback && isValidColorScale(fallback)) {
|
|
5211
|
+
colors["custom"] = fallback;
|
|
5212
|
+
}
|
|
5180
5213
|
}
|
|
5181
5214
|
return {
|
|
5182
5215
|
...base,
|
|
@@ -5250,6 +5283,7 @@ function DirkProvider({ children, overideResourceName, themeOverride }) {
|
|
|
5250
5283
|
customTheme,
|
|
5251
5284
|
game
|
|
5252
5285
|
} = useSettings();
|
|
5286
|
+
localeStore((s) => s.locales);
|
|
5253
5287
|
useLayoutEffect(() => {
|
|
5254
5288
|
useSettings.setState({
|
|
5255
5289
|
overideResourceName
|
|
@@ -5270,6 +5304,10 @@ function DirkProvider({ children, overideResourceName, themeOverride }) {
|
|
|
5270
5304
|
console.error("Failed to fetch initial settings within dirk-cfx-react:", err);
|
|
5271
5305
|
});
|
|
5272
5306
|
}, []);
|
|
5307
|
+
useNuiEvent("UPDATE_DIRK_LIB_SETTINGS", (data) => {
|
|
5308
|
+
if (!data || typeof data !== "object") return;
|
|
5309
|
+
useSettings.setState(data);
|
|
5310
|
+
});
|
|
5273
5311
|
const mergedTheme = useMemo(
|
|
5274
5312
|
() => mergeMantineThemeSafe(
|
|
5275
5313
|
{ ...theme_default, primaryColor, primaryShade },
|