dirk-cfx-react 1.1.64 → 1.1.65

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
@@ -1079,6 +1079,31 @@ function BlipColorSelect({ value, onChange, label: label2 = "Blip Color", size =
1079
1079
  }
1080
1080
  );
1081
1081
  }
1082
+ var BLIP_DISPLAY_DATA = [
1083
+ { value: "2", label: "2 \u2014 Main map + minimap (selectable)" },
1084
+ { value: "3", label: "3 \u2014 Main map only (selectable)" },
1085
+ { value: "4", label: "4 \u2014 Main map only (selectable)" },
1086
+ { value: "5", label: "5 \u2014 Minimap only" },
1087
+ { value: "6", label: "6 \u2014 Main map + minimap (selectable)" },
1088
+ { value: "8", label: "8 \u2014 Main map + minimap (not selectable)" },
1089
+ { value: "9", label: "9 \u2014 Minimap only" },
1090
+ { value: "10", label: "10 \u2014 Main map + minimap (not selectable)" }
1091
+ ];
1092
+ function BlipDisplaySelect({ value, onChange, label: label2 = "Blip Display", size = "xs", ...rest }) {
1093
+ return /* @__PURE__ */ jsxRuntime.jsx(
1094
+ core.Select,
1095
+ {
1096
+ label: label2,
1097
+ size,
1098
+ ...rest,
1099
+ data: BLIP_DISPLAY_DATA,
1100
+ value: value != null ? String(value) : null,
1101
+ onChange: (val) => val != null && onChange(Number(val)),
1102
+ allowDeselect: false,
1103
+ maxDropdownHeight: 300
1104
+ }
1105
+ );
1106
+ }
1082
1107
 
1083
1108
  // src/utils/colorWithAlpha.ts
1084
1109
  var colorNames = {
@@ -1225,11 +1250,11 @@ var colorNames = {
1225
1250
  Yellow: { r: 255, g: 255, b: 0 },
1226
1251
  YellowGreen: { r: 154, g: 205, b: 50 }
1227
1252
  };
1228
- function colorWithAlpha(color, alpha8) {
1253
+ function colorWithAlpha(color, alpha9) {
1229
1254
  const lowerCasedColor = color.toLowerCase();
1230
1255
  if (colorNames[lowerCasedColor]) {
1231
1256
  const rgb = colorNames[lowerCasedColor];
1232
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha8})`;
1257
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha9})`;
1233
1258
  }
1234
1259
  if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
1235
1260
  const hex = color.slice(1);
@@ -1237,12 +1262,12 @@ function colorWithAlpha(color, alpha8) {
1237
1262
  const r = bigint >> 16 & 255;
1238
1263
  const g = bigint >> 8 & 255;
1239
1264
  const b = bigint & 255;
1240
- return `rgba(${r}, ${g}, ${b}, ${alpha8})`;
1265
+ return `rgba(${r}, ${g}, ${b}, ${alpha9})`;
1241
1266
  }
1242
1267
  if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
1243
1268
  const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
1244
1269
  if (result) {
1245
- return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha8})`;
1270
+ return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha9})`;
1246
1271
  }
1247
1272
  }
1248
1273
  return color;
@@ -4752,6 +4777,219 @@ function SelectItem(props) {
4752
4777
  }
4753
4778
  );
4754
4779
  }
4780
+ var ZERO = { x: 0, y: 0, z: 0, w: 0 };
4781
+ function PositionPicker(props) {
4782
+ const {
4783
+ label: label2,
4784
+ value,
4785
+ onChange,
4786
+ relativeTo,
4787
+ fetchEvent = "GET_POSITION",
4788
+ previewEvent = "PREVIEW_POSITION",
4789
+ stopPreviewEvent = "STOP_PREVIEW_POSITION",
4790
+ description: description2,
4791
+ showHeading = true
4792
+ } = props;
4793
+ const theme2 = core.useMantineTheme();
4794
+ const color = theme2.colors[theme2.primaryColor][5];
4795
+ const [previewing, setPreviewing] = React5.useState(false);
4796
+ const previewingRef = React5.useRef(false);
4797
+ React5.useEffect(() => {
4798
+ return () => {
4799
+ if (previewingRef.current) {
4800
+ fetchNui(stopPreviewEvent, { relativeTo }).catch(() => {
4801
+ });
4802
+ }
4803
+ };
4804
+ }, [stopPreviewEvent, relativeTo]);
4805
+ const set = (key, val) => {
4806
+ const next = { ...value, [key]: val };
4807
+ onChange(next);
4808
+ if (previewingRef.current) {
4809
+ fetchNui(previewEvent, { value: next, relativeTo }).catch(() => {
4810
+ });
4811
+ }
4812
+ };
4813
+ const grab = async () => {
4814
+ try {
4815
+ const resp = await fetchNui(fetchEvent, { relativeTo }, value);
4816
+ if (resp && typeof resp === "object") {
4817
+ const next = {
4818
+ x: Number(resp.x ?? 0),
4819
+ y: Number(resp.y ?? 0),
4820
+ z: Number(resp.z ?? 0),
4821
+ w: Number(resp.w ?? 0)
4822
+ };
4823
+ onChange(next);
4824
+ if (previewingRef.current) {
4825
+ fetchNui(previewEvent, { value: next, relativeTo }).catch(() => {
4826
+ });
4827
+ }
4828
+ }
4829
+ } catch {
4830
+ }
4831
+ };
4832
+ const togglePreview = async () => {
4833
+ const nextState = !previewing;
4834
+ setPreviewing(nextState);
4835
+ previewingRef.current = nextState;
4836
+ if (nextState) {
4837
+ await fetchNui(previewEvent, { value, relativeTo }).catch(() => {
4838
+ });
4839
+ } else {
4840
+ await fetchNui(stopPreviewEvent, { relativeTo }).catch(() => {
4841
+ });
4842
+ }
4843
+ };
4844
+ const reset = () => {
4845
+ onChange({ ...ZERO });
4846
+ if (previewingRef.current) {
4847
+ fetchNui(previewEvent, { value: ZERO, relativeTo }).catch(() => {
4848
+ });
4849
+ }
4850
+ };
4851
+ const numberStyles = {
4852
+ input: { textAlign: "right", fontFamily: "monospace" }
4853
+ };
4854
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4855
+ core.Flex,
4856
+ {
4857
+ direction: "column",
4858
+ gap: "xxs",
4859
+ p: "xs",
4860
+ style: {
4861
+ background: core.alpha(theme2.colors.dark[5], 0.35),
4862
+ border: "0.1vh solid rgba(255,255,255,0.05)",
4863
+ borderRadius: theme2.radius.xs
4864
+ },
4865
+ children: [
4866
+ (label2 || description2) && /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { justify: "space-between", align: "center", gap: "xs", children: [
4867
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: 0, style: { minWidth: 0 }, children: [
4868
+ label2 && /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", gap: "xxs", children: [
4869
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { size: "1.4vh", color: core.alpha(color, 0.7) }),
4870
+ /* @__PURE__ */ jsxRuntime.jsx(
4871
+ core.Text,
4872
+ {
4873
+ ff: "Akrobat Bold",
4874
+ size: "xxs",
4875
+ tt: "uppercase",
4876
+ lts: "0.05em",
4877
+ c: "rgba(255,255,255,0.75)",
4878
+ children: locale(label2)
4879
+ }
4880
+ ),
4881
+ relativeTo && /* @__PURE__ */ jsxRuntime.jsxs(core.Text, { ff: "Akrobat Bold", size: "xxs", c: core.alpha(color, 0.5), lts: "0.05em", children: [
4882
+ "\xB7 ",
4883
+ locale("RelativeTo"),
4884
+ " ",
4885
+ relativeTo
4886
+ ] })
4887
+ ] }),
4888
+ description2 && /* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", c: "dimmed", lh: 1.3, children: locale(description2) })
4889
+ ] }),
4890
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xxs", style: { flexShrink: 0 }, children: [
4891
+ /* @__PURE__ */ jsxRuntime.jsx(PickerButton, { tooltip: locale("GrabMyPosition"), onClick: grab, color, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Crosshair, { size: "1.4vh", color }) }),
4892
+ /* @__PURE__ */ jsxRuntime.jsx(
4893
+ PickerButton,
4894
+ {
4895
+ tooltip: previewing ? locale("StopPreview") : locale("PreviewInWorld"),
4896
+ onClick: togglePreview,
4897
+ color,
4898
+ active: previewing,
4899
+ children: previewing ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { size: "1.4vh", color }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { size: "1.4vh", color: core.alpha(color, 0.7) })
4900
+ }
4901
+ ),
4902
+ /* @__PURE__ */ jsxRuntime.jsx(PickerButton, { tooltip: locale("Reset"), onClick: reset, color: "#ef4444", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { size: "1.4vh", color: "#ef4444" }) })
4903
+ ] })
4904
+ ] }),
4905
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xxs", children: [
4906
+ /* @__PURE__ */ jsxRuntime.jsx(
4907
+ core.NumberInput,
4908
+ {
4909
+ size: "xs",
4910
+ label: "X",
4911
+ value: value.x,
4912
+ onChange: (v) => set("x", Number(v)),
4913
+ decimalScale: 4,
4914
+ step: 0.1,
4915
+ style: { flex: 1 },
4916
+ styles: numberStyles
4917
+ }
4918
+ ),
4919
+ /* @__PURE__ */ jsxRuntime.jsx(
4920
+ core.NumberInput,
4921
+ {
4922
+ size: "xs",
4923
+ label: "Y",
4924
+ value: value.y,
4925
+ onChange: (v) => set("y", Number(v)),
4926
+ decimalScale: 4,
4927
+ step: 0.1,
4928
+ style: { flex: 1 },
4929
+ styles: numberStyles
4930
+ }
4931
+ ),
4932
+ /* @__PURE__ */ jsxRuntime.jsx(
4933
+ core.NumberInput,
4934
+ {
4935
+ size: "xs",
4936
+ label: "Z",
4937
+ value: value.z,
4938
+ onChange: (v) => set("z", Number(v)),
4939
+ decimalScale: 4,
4940
+ step: 0.1,
4941
+ style: { flex: 1 },
4942
+ styles: numberStyles
4943
+ }
4944
+ ),
4945
+ showHeading && /* @__PURE__ */ jsxRuntime.jsx(
4946
+ core.NumberInput,
4947
+ {
4948
+ size: "xs",
4949
+ label: "W",
4950
+ value: value.w,
4951
+ onChange: (v) => set("w", Number(v)),
4952
+ decimalScale: 2,
4953
+ step: 1,
4954
+ min: 0,
4955
+ max: 360,
4956
+ style: { flex: 1 },
4957
+ styles: numberStyles
4958
+ }
4959
+ )
4960
+ ] })
4961
+ ]
4962
+ }
4963
+ );
4964
+ }
4965
+ function PickerButton({
4966
+ children,
4967
+ onClick,
4968
+ tooltip,
4969
+ color,
4970
+ active
4971
+ }) {
4972
+ const theme2 = core.useMantineTheme();
4973
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Tooltip, { label: tooltip, position: "top", withArrow: true, children: /* @__PURE__ */ jsxRuntime.jsx(
4974
+ framerMotion.motion.button,
4975
+ {
4976
+ onClick,
4977
+ whileHover: { background: core.alpha(color, 0.18) },
4978
+ whileTap: { scale: 0.95 },
4979
+ style: {
4980
+ background: active ? core.alpha(color, 0.22) : core.alpha(color, 0.08),
4981
+ border: `0.1vh solid ${core.alpha(color, active ? 0.5 : 0.3)}`,
4982
+ borderRadius: theme2.radius.xs,
4983
+ padding: "0.4vh 0.6vh",
4984
+ cursor: "pointer",
4985
+ display: "flex",
4986
+ alignItems: "center",
4987
+ justifyContent: "center"
4988
+ },
4989
+ children
4990
+ }
4991
+ ) });
4992
+ }
4755
4993
  var KeyBindContext = React5.createContext(null);
4756
4994
  function useKeyBindContext() {
4757
4995
  const ctx = React5.useContext(KeyBindContext);
@@ -5343,6 +5581,7 @@ function DirkProvider({ children, overideResourceName, themeOverride }) {
5343
5581
  exports.AdminPageTitle = AdminPageTitle;
5344
5582
  exports.AsyncSaveButton = AsyncSaveButton;
5345
5583
  exports.BlipColorSelect = BlipColorSelect;
5584
+ exports.BlipDisplaySelect = BlipDisplaySelect;
5346
5585
  exports.BlipIconSelect = BlipIconSelect;
5347
5586
  exports.BorderedIcon = BorderedIcon;
5348
5587
  exports.ConfigPanel = ConfigPanel;
@@ -5368,6 +5607,7 @@ exports.MotionText = MotionText;
5368
5607
  exports.NavBar = NavBar;
5369
5608
  exports.NavigationContext = NavigationContext;
5370
5609
  exports.NavigationProvider = NavigationProvider;
5610
+ exports.PositionPicker = PositionPicker;
5371
5611
  exports.PromptModal = PromptModal;
5372
5612
  exports.SegmentedControl = SegmentedControl;
5373
5613
  exports.SegmentedProgress = SegmentedProgress;