dirk-cfx-react 1.1.72 → 1.1.73

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.
@@ -1299,7 +1299,11 @@ async function fetchNui(eventName, data, mockData) {
1299
1299
  return {};
1300
1300
  }
1301
1301
  const overrideResourceName = useSettings.getState().overideResourceName;
1302
- const resourceName = window.GetParentResourceName ? window.GetParentResourceName() : overrideResourceName ? overrideResourceName : "dirk-cfx-react";
1302
+ const hasResourceContext = typeof window.GetParentResourceName === "function" || !!overrideResourceName;
1303
+ if (!hasResourceContext) {
1304
+ return mockData ?? {};
1305
+ }
1306
+ const resourceName = window.GetParentResourceName ? window.GetParentResourceName() : overrideResourceName;
1303
1307
  try {
1304
1308
  const resp = await fetch(`https://${resourceName}/${eventName}`, options);
1305
1309
  return await resp.json();
@@ -2472,9 +2476,25 @@ function SegmentedProgress(props) {
2472
2476
  }
2473
2477
  );
2474
2478
  }
2479
+ function getSizePreset(size, themeMdFontSize) {
2480
+ switch (size) {
2481
+ case "xs":
2482
+ return { iconFontSize: "1.2vh", iconPadding: "xxs", titleSize: "xxs", titleLineHeight: "1.2vh", descriptionSize: "xxs", innerGap: "xs", bottomPad: "xs" };
2483
+ case "sm":
2484
+ return { iconFontSize: "1.6vh", iconPadding: "xxs", titleSize: "xs", titleLineHeight: "1.6vh", descriptionSize: "xxs", innerGap: "xs", bottomPad: "xs" };
2485
+ case "lg":
2486
+ return { iconFontSize: "2.6vh", iconPadding: "sm", titleSize: "md", titleLineHeight: "2.6vh", descriptionSize: "sm", innerGap: "sm", bottomPad: "sm" };
2487
+ case "xl":
2488
+ return { iconFontSize: "3.2vh", iconPadding: "sm", titleSize: "lg", titleLineHeight: "3.2vh", descriptionSize: "md", innerGap: "md", bottomPad: "md" };
2489
+ case "md":
2490
+ default:
2491
+ return { iconFontSize: themeMdFontSize, iconPadding: "xs", titleSize: "sm", titleLineHeight: themeMdFontSize, descriptionSize: "xs", innerGap: "sm", bottomPad: "sm" };
2492
+ }
2493
+ }
2475
2494
  function Title(props) {
2476
2495
  const game = useSettings((state) => state.game);
2477
2496
  const theme = core.useMantineTheme();
2497
+ const preset = getSizePreset(props.size ?? "md", theme.fontSizes.md);
2478
2498
  return /* @__PURE__ */ jsxRuntime.jsx(
2479
2499
  core.Flex,
2480
2500
  {
@@ -2483,71 +2503,50 @@ function Title(props) {
2483
2503
  gap: "xs",
2484
2504
  w: props.w || "100%",
2485
2505
  p: props.p || "unset",
2486
- pb: !props.p ? "sm" : props.p,
2506
+ pb: !props.p ? preset.bottomPad : props.p,
2487
2507
  style: {
2488
2508
  userSelect: "none",
2489
2509
  borderBottom: props.removeBorder ? "none" : `0.3vh solid ${props.borderColor || colorWithAlpha(theme.colors[theme.primaryColor][9], 0.5)}`
2490
2510
  },
2491
- children: /* @__PURE__ */ jsxRuntime.jsxs(
2492
- core.Flex,
2493
- {
2494
- align: "center",
2495
- justify: "center",
2496
- children: [
2497
- /* @__PURE__ */ jsxRuntime.jsxs(
2498
- core.Flex,
2511
+ children: /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", justify: "center", children: [
2512
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", gap: preset.innerGap, pr: "xs", children: [
2513
+ /* @__PURE__ */ jsxRuntime.jsx(
2514
+ BorderedIcon,
2515
+ {
2516
+ icon: props.icon,
2517
+ fontSize: preset.iconFontSize,
2518
+ color: props.iconColor,
2519
+ p: preset.iconPadding
2520
+ }
2521
+ ),
2522
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: "0.25vh", children: [
2523
+ /* @__PURE__ */ jsxRuntime.jsx(
2524
+ core.Text,
2499
2525
  {
2500
- align: "center",
2501
- gap: "sm",
2502
- pr: "xs",
2503
- children: [
2504
- /* @__PURE__ */ jsxRuntime.jsx(
2505
- BorderedIcon,
2506
- {
2507
- icon: props.icon,
2508
- fontSize: theme.fontSizes.md,
2509
- color: props.iconColor
2510
- }
2511
- ),
2512
- /* @__PURE__ */ jsxRuntime.jsxs(
2513
- core.Flex,
2514
- {
2515
- direction: "column",
2516
- gap: "0.25vh",
2517
- children: [
2518
- /* @__PURE__ */ jsxRuntime.jsx(core.Text, { p: "0", size: "sm", style: {
2519
- lineHeight: theme.fontSizes.md,
2520
- fontFamily: game == "fivem" ? "Akrobat Bold" : "Red Dead",
2521
- letterSpacing: "0.05em",
2522
- textTransform: "uppercase"
2523
- }, children: props.title }),
2524
- /* @__PURE__ */ jsxRuntime.jsx(
2525
- core.Text,
2526
- {
2527
- size: "xs",
2528
- c: "grey",
2529
- style: { whiteSpace: "normal", wordWrap: "break-word" },
2530
- children: props.description
2531
- }
2532
- )
2533
- ]
2534
- }
2535
- )
2536
- ]
2526
+ p: "0",
2527
+ size: preset.titleSize,
2528
+ style: {
2529
+ lineHeight: preset.titleLineHeight,
2530
+ fontFamily: game == "fivem" ? "Akrobat Bold" : "Red Dead",
2531
+ letterSpacing: "0.05em",
2532
+ textTransform: "uppercase"
2533
+ },
2534
+ children: props.title
2537
2535
  }
2538
2536
  ),
2539
2537
  /* @__PURE__ */ jsxRuntime.jsx(
2540
- core.Flex,
2538
+ core.Text,
2541
2539
  {
2542
- ml: "auto",
2543
- align: "center",
2544
- gap: "xs",
2545
- children: props.rightSection
2540
+ size: preset.descriptionSize,
2541
+ c: "grey",
2542
+ style: { whiteSpace: "normal", wordWrap: "break-word" },
2543
+ children: props.description
2546
2544
  }
2547
2545
  )
2548
- ]
2549
- }
2550
- )
2546
+ ] })
2547
+ ] }),
2548
+ /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { ml: "auto", align: "center", gap: "xs", children: props.rightSection })
2549
+ ] })
2551
2550
  }
2552
2551
  );
2553
2552
  }
@@ -4168,8 +4167,8 @@ function ConfigPanelInner({
4168
4167
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { size: "1.4vh", color })
4169
4168
  }
4170
4169
  ),
4171
- /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", style: { minWidth: 0, lineHeight: 1 }, children: [
4172
- /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "lg", ff: "Akrobat Bold", tt: "uppercase", lts: "0.04em", truncate: true, children: title }),
4170
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", style: { minWidth: 0, flex: 1, lineHeight: 1, overflow: "hidden" }, children: [
4171
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "md", ff: "Akrobat Bold", tt: "uppercase", lts: "0.04em", truncate: true, children: title }),
4173
4172
  subtitle && /* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", tt: "uppercase", lts: "0.08em", c: color, truncate: true, children: subtitle })
4174
4173
  ] })
4175
4174
  ] }),
@@ -5110,6 +5109,17 @@ function AdminPageTitle(props) {
5110
5109
  /* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", tt: "uppercase", lts: "0.1em", size: "sm", c: "rgba(255,255,255,0.6)", children: locale(props.title) })
5111
5110
  ] });
5112
5111
  }
5112
+ var placementStyle = (placement) => {
5113
+ switch (placement) {
5114
+ case "top-center":
5115
+ return { top: "1vh", left: "50%", transform: "translateX(-50%)" };
5116
+ case "top-right":
5117
+ return { top: "1vh", right: "1vh" };
5118
+ case "top-left":
5119
+ default:
5120
+ return { top: "1vh", left: "1vh" };
5121
+ }
5122
+ };
5113
5123
  var loadPersistedState = (storageKey) => {
5114
5124
  try {
5115
5125
  const raw = localStorage.getItem(storageKey);
@@ -5128,7 +5138,8 @@ function TestBed({
5128
5138
  items,
5129
5139
  storageKey = "testbed:open-state",
5130
5140
  disablePersistence = false,
5131
- title = "TestBed"
5141
+ title = "TestBed",
5142
+ placement = "top-left"
5132
5143
  }) {
5133
5144
  const [open, setOpen] = react.useState(false);
5134
5145
  const itemsRef = react.useRef(items);
@@ -5158,8 +5169,7 @@ function TestBed({
5158
5169
  {
5159
5170
  style: {
5160
5171
  position: "fixed",
5161
- top: "1vh",
5162
- left: "1vh",
5172
+ ...placementStyle(placement),
5163
5173
  zIndex: 2147483647,
5164
5174
  pointerEvents: "auto",
5165
5175
  fontSize: "1.4vh"