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/index.cjs CHANGED
@@ -7,9 +7,9 @@ var zustand = require('zustand');
7
7
  var axios = require('axios');
8
8
  var reactFontawesome = require('@fortawesome/react-fontawesome');
9
9
  var framerMotion = require('framer-motion');
10
+ var lucideReact = require('lucide-react');
10
11
  var clickSoundUrl = require('./click_sound-PNCRRTM4.mp3');
11
12
  var hoverSoundUrl = require('./hover_sound-NBUA222C.mp3');
12
- var lucideReact = require('lucide-react');
13
13
  var reactQuery = require('@tanstack/react-query');
14
14
  require('@mantine/core/styles.css');
15
15
  require('@mantine/notifications/styles.css');
@@ -1315,8 +1315,12 @@ async function fetchNui(eventName, data, mockData) {
1315
1315
  }
1316
1316
  const overrideResourceName = useSettings.getState().overideResourceName;
1317
1317
  const resourceName = window.GetParentResourceName ? window.GetParentResourceName() : overrideResourceName ? overrideResourceName : "dirk-cfx-react";
1318
- const resp = await fetch(`https://${resourceName}/${eventName}`, options);
1319
- return await resp.json();
1318
+ try {
1319
+ const resp = await fetch(`https://${resourceName}/${eventName}`, options);
1320
+ return await resp.json();
1321
+ } catch {
1322
+ return mockData ?? {};
1323
+ }
1320
1324
  }
1321
1325
  var initialFetches = {};
1322
1326
  async function registerInitialFetch(eventName, data, mockData) {
@@ -1363,6 +1367,13 @@ var internalEvent = (events, timer = 1e3) => {
1363
1367
  }
1364
1368
  }
1365
1369
  };
1370
+ var reportedMissing = /* @__PURE__ */ new Set();
1371
+ function reportMissingLocale(key) {
1372
+ if (!key || reportedMissing.has(key)) return;
1373
+ reportedMissing.add(key);
1374
+ fetchNui("REPORT_MISSING_LOCALE", { key }).catch(() => {
1375
+ });
1376
+ }
1366
1377
  var localeStore = zustand.create((set, get) => {
1367
1378
  return {
1368
1379
  locales: {
@@ -1370,6 +1381,7 @@ var localeStore = zustand.create((set, get) => {
1370
1381
  },
1371
1382
  locale: (key, ...args) => {
1372
1383
  const exists = get().locales[key];
1384
+ if (!exists) reportMissingLocale(key);
1373
1385
  let translation = exists || key;
1374
1386
  if (args.length) {
1375
1387
  translation = translation.replace(/%s/g, () => String(args.shift() || ""));
@@ -1383,6 +1395,14 @@ registerInitialFetch("GET_LOCALES", void 0).then((data) => {
1383
1395
  localeStore.setState({ locales: data });
1384
1396
  }).catch(() => {
1385
1397
  });
1398
+ if (typeof window !== "undefined") {
1399
+ window.addEventListener("message", (event) => {
1400
+ const msg = event.data;
1401
+ if (!msg || msg.action !== "UPDATE_DIRK_LIB_LOCALES") return;
1402
+ if (!msg.data || typeof msg.data !== "object") return;
1403
+ localeStore.setState({ locales: msg.data });
1404
+ });
1405
+ }
1386
1406
 
1387
1407
  // src/utils/map.ts
1388
1408
  var mapCenter = [-119.43, 58.84];
@@ -2545,8 +2565,8 @@ function InputContainer(props) {
2545
2565
  (props.title || props.description) && /* @__PURE__ */ jsxRuntime.jsxs(
2546
2566
  core.Flex,
2547
2567
  {
2548
- direction: "column",
2549
- gap: "xxs",
2568
+ align: "center",
2569
+ flex: 1,
2550
2570
  p: props.p == "0" ? "sm" : 0,
2551
2571
  children: [
2552
2572
  props.title && /* @__PURE__ */ jsxRuntime.jsx(
@@ -2563,12 +2583,26 @@ function InputContainer(props) {
2563
2583
  }
2564
2584
  ),
2565
2585
  props.description && /* @__PURE__ */ jsxRuntime.jsx(
2566
- core.Text,
2586
+ core.Tooltip,
2567
2587
  {
2568
- size: "xs",
2569
- c: "rgba(255, 255, 255, 0.8)",
2570
- fw: 400,
2571
- children: props.description
2588
+ label: props.description,
2589
+ position: "top-end",
2590
+ withArrow: true,
2591
+ multiline: true,
2592
+ maw: "22vh",
2593
+ styles: {
2594
+ tooltip: {
2595
+ background: core.alpha(theme2.colors.dark[7], 0.95),
2596
+ border: `0.1vh solid rgba(255,255,255,0.1)`,
2597
+ color: "rgba(255,255,255,0.75)",
2598
+ fontFamily: "Akrobat Bold",
2599
+ fontSize: "1.3vh",
2600
+ lineHeight: 1.3,
2601
+ padding: "0.6vh 0.8vh",
2602
+ letterSpacing: "0.03em"
2603
+ }
2604
+ },
2605
+ children: /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { align: "center", justify: "center", style: { marginLeft: "auto", cursor: "help" }, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { size: "1.6vh", color: core.alpha(theme2.colors[theme2.primaryColor][5], 0.45) }) })
2572
2606
  }
2573
2607
  )
2574
2608
  ]
@@ -2585,13 +2619,7 @@ function InputContainer(props) {
2585
2619
  children: props.error
2586
2620
  }
2587
2621
  ),
2588
- /* @__PURE__ */ jsxRuntime.jsx(
2589
- core.Flex,
2590
- {
2591
- ml: "auto",
2592
- children: props.rightSection
2593
- }
2594
- )
2622
+ props.rightSection && /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { children: props.rightSection })
2595
2623
  ]
2596
2624
  }
2597
2625
  ),
@@ -5186,6 +5214,11 @@ function mergeMantineThemeSafe(base, custom, override) {
5186
5214
  const colors = { ...base.colors };
5187
5215
  if (custom && isValidColorScale(custom)) {
5188
5216
  colors["custom"] = custom;
5217
+ } else if (!colors["custom"]) {
5218
+ const fallback = base.colors && base.colors.dirk;
5219
+ if (fallback && isValidColorScale(fallback)) {
5220
+ colors["custom"] = fallback;
5221
+ }
5189
5222
  }
5190
5223
  return {
5191
5224
  ...base,
@@ -5259,6 +5292,7 @@ function DirkProvider({ children, overideResourceName, themeOverride }) {
5259
5292
  customTheme,
5260
5293
  game
5261
5294
  } = useSettings();
5295
+ localeStore((s) => s.locales);
5262
5296
  React5.useLayoutEffect(() => {
5263
5297
  useSettings.setState({
5264
5298
  overideResourceName
@@ -5279,6 +5313,10 @@ function DirkProvider({ children, overideResourceName, themeOverride }) {
5279
5313
  console.error("Failed to fetch initial settings within dirk-cfx-react:", err);
5280
5314
  });
5281
5315
  }, []);
5316
+ useNuiEvent("UPDATE_DIRK_LIB_SETTINGS", (data) => {
5317
+ if (!data || typeof data !== "object") return;
5318
+ useSettings.setState(data);
5319
+ });
5282
5320
  const mergedTheme = React5.useMemo(
5283
5321
  () => mergeMantineThemeSafe(
5284
5322
  { ...theme_default, primaryColor, primaryShade },