dirk-cfx-react 1.1.69 → 1.1.71

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
@@ -10,6 +10,7 @@ var framerMotion = require('framer-motion');
10
10
  var lucideReact = require('lucide-react');
11
11
  var clickSoundUrl = require('./click_sound-PNCRRTM4.mp3');
12
12
  var hoverSoundUrl = require('./hover_sound-NBUA222C.mp3');
13
+ var notifications = require('@mantine/notifications');
13
14
  var reactQuery = require('@tanstack/react-query');
14
15
  require('@mantine/core/styles.css');
15
16
  require('@mantine/notifications/styles.css');
@@ -4817,12 +4818,25 @@ function ConfigPanel(props) {
4817
4818
  if (result?.success) {
4818
4819
  form.reinitialize(cloneConfig(form.values));
4819
4820
  configPanelQueryClient.invalidateQueries({ queryKey: ["scriptConfigHistory"] });
4821
+ notifications.notifications.show({
4822
+ color: "green",
4823
+ title: locale("ConfigSaveSuccessTitle"),
4824
+ message: locale("ConfigSaveSuccessBody"),
4825
+ autoClose: 3e3
4826
+ });
4820
4827
  return;
4821
4828
  }
4822
4829
  form.reinitialize(cloneConfig(store.getState()));
4823
- if (result?._error) {
4824
- console.warn(`[ConfigPanel] config save failed: ${result._error}`);
4825
- }
4830
+ const err = result?._error || "Unknown";
4831
+ console.warn(`[ConfigPanel] config save failed: ${err}`);
4832
+ const titleKey = err === "NoPermission" ? "ConfigSaveNoPermissionTitle" : err === "VersionConflict" ? "ConfigSaveVersionConflictTitle" : err === "NotReady" ? "ConfigSaveNotReadyTitle" : "ConfigSaveFailedTitle";
4833
+ const bodyKey = err === "NoPermission" ? "ConfigSaveNoPermissionBody" : err === "VersionConflict" ? "ConfigSaveVersionConflictBody" : err === "NotReady" ? "ConfigSaveNotReadyBody" : "ConfigSaveFailedBody";
4834
+ notifications.notifications.show({
4835
+ color: "red",
4836
+ title: locale(titleKey),
4837
+ message: locale(bodyKey, err),
4838
+ autoClose: 6e3
4839
+ });
4826
4840
  } finally {
4827
4841
  setIsSaving(false);
4828
4842
  }
@@ -4841,7 +4855,7 @@ function ConfigPanel(props) {
4841
4855
  }
4842
4856
  ) });
4843
4857
  }
4844
- function LazyImage({ src, alt, style }) {
4858
+ function LazyImage({ src, style }) {
4845
4859
  const [visible, setVisible] = React6.useState(false);
4846
4860
  const ref = React6.useRef(null);
4847
4861
  React6.useEffect(() => {
@@ -4854,7 +4868,7 @@ function LazyImage({ src, alt, style }) {
4854
4868
  if (ref.current) observer.observe(ref.current);
4855
4869
  return () => observer.disconnect();
4856
4870
  }, []);
4857
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, style: { width: "4vh", height: "4vh" }, children: visible && /* @__PURE__ */ jsxRuntime.jsx(core.Image, { src, alt, fit: "contain", style }) });
4871
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, style: { width: "4vh", height: "4vh" }, children: visible && /* @__PURE__ */ jsxRuntime.jsx(core.Image, { src, fit: "contain", style }) });
4858
4872
  }
4859
4873
  function SelectItem(props) {
4860
4874
  const invItems = useItems();
@@ -4882,12 +4896,12 @@ function SelectItem(props) {
4882
4896
  searchable: true,
4883
4897
  comboboxProps: { withinPortal: true, zIndex: 2e3 },
4884
4898
  leftSectionWidth: "4vh",
4899
+ leftSectionPointerEvents: "none",
4885
4900
  leftSection: props.value ? /* @__PURE__ */ jsxRuntime.jsx(
4886
4901
  core.Image,
4887
4902
  {
4888
4903
  fallbackSrc: "/placeholder.png",
4889
4904
  src: invItems[props.value]?.image || "",
4890
- alt: props.value,
4891
4905
  fit: "contain",
4892
4906
  maw: "4vh",
4893
4907
  style: { aspectRatio: "1 / 1" }
@@ -4899,7 +4913,6 @@ function SelectItem(props) {
4899
4913
  LazyImage,
4900
4914
  {
4901
4915
  src: invItems[item.option.value]?.image || "",
4902
- alt: item.option.label,
4903
4916
  style: { aspectRatio: "1 / 1" }
4904
4917
  }
4905
4918
  ),
@@ -5124,6 +5137,148 @@ function PickerButton({
5124
5137
  }
5125
5138
  ) });
5126
5139
  }
5140
+ function fmtV4(n) {
5141
+ return Number.isFinite(n) ? n.toFixed(2) : "0.00";
5142
+ }
5143
+ function Vector4Display({ value }) {
5144
+ const theme2 = core.useMantineTheme();
5145
+ return /* @__PURE__ */ jsxRuntime.jsx(
5146
+ core.Flex,
5147
+ {
5148
+ align: "center",
5149
+ gap: "xs",
5150
+ p: "xs",
5151
+ style: {
5152
+ background: core.alpha(theme2.colors.dark[5], 0.35),
5153
+ border: "0.1vh solid rgba(255,255,255,0.05)",
5154
+ borderRadius: theme2.radius.xs
5155
+ },
5156
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
5157
+ core.Text,
5158
+ {
5159
+ ff: "monospace",
5160
+ size: "xxs",
5161
+ c: "rgba(255,255,255,0.85)",
5162
+ style: { flex: 1, letterSpacing: "0.02em", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" },
5163
+ children: [
5164
+ "vector4(",
5165
+ fmtV4(value.x),
5166
+ ", ",
5167
+ fmtV4(value.y),
5168
+ ", ",
5169
+ fmtV4(value.z),
5170
+ ", ",
5171
+ fmtV4(value.w),
5172
+ ")"
5173
+ ]
5174
+ }
5175
+ )
5176
+ }
5177
+ );
5178
+ }
5179
+ function Vector4ActionButton({
5180
+ icon,
5181
+ label: label2,
5182
+ tooltip,
5183
+ onClick,
5184
+ color,
5185
+ compact
5186
+ }) {
5187
+ const theme2 = core.useMantineTheme();
5188
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Tooltip, { label: tooltip, position: "top", withArrow: true, withinPortal: true, zIndex: 2e3, children: /* @__PURE__ */ jsxRuntime.jsxs(
5189
+ framerMotion.motion.button,
5190
+ {
5191
+ onClick,
5192
+ whileHover: { background: core.alpha(color, 0.18) },
5193
+ whileTap: { scale: 0.95 },
5194
+ style: {
5195
+ background: core.alpha(color, 0.1),
5196
+ border: `0.1vh solid ${core.alpha(color, 0.35)}`,
5197
+ borderRadius: theme2.radius.xs,
5198
+ padding: compact ? "0.25vh 0.6vh" : "0.5vh 0.8vh",
5199
+ cursor: "pointer",
5200
+ display: "flex",
5201
+ alignItems: "center",
5202
+ gap: compact ? "0.3vh" : "0.4vh"
5203
+ },
5204
+ children: [
5205
+ icon,
5206
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", tt: "uppercase", lts: "0.06em", c: color, children: label2 })
5207
+ ]
5208
+ }
5209
+ ) });
5210
+ }
5211
+ function WorldPositionSetButton({
5212
+ value,
5213
+ onChange,
5214
+ compact
5215
+ }) {
5216
+ const theme2 = core.useMantineTheme();
5217
+ const color = theme2.colors[theme2.primaryColor][5];
5218
+ const grab = async () => {
5219
+ try {
5220
+ const resp = await fetchNui("GET_POSITION", {}, value);
5221
+ if (!resp || typeof resp !== "object") return;
5222
+ onChange({
5223
+ x: Number(resp.x ?? 0),
5224
+ y: Number(resp.y ?? 0),
5225
+ z: Number(resp.z ?? 0),
5226
+ w: Number(resp.w ?? 0)
5227
+ });
5228
+ } catch {
5229
+ }
5230
+ };
5231
+ return /* @__PURE__ */ jsxRuntime.jsx(
5232
+ Vector4ActionButton,
5233
+ {
5234
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Crosshair, { size: compact ? "1.1vh" : "1.3vh", color }),
5235
+ label: locale("Set"),
5236
+ tooltip: locale("SetWorldTooltip"),
5237
+ onClick: grab,
5238
+ color,
5239
+ compact
5240
+ }
5241
+ );
5242
+ }
5243
+ function WorldPositionGotoButton({
5244
+ value,
5245
+ compact
5246
+ }) {
5247
+ const theme2 = core.useMantineTheme();
5248
+ const color = theme2.colors[theme2.primaryColor][5];
5249
+ const goto = () => {
5250
+ fetchNui("GOTO_POSITION", value).catch(() => {
5251
+ });
5252
+ };
5253
+ return /* @__PURE__ */ jsxRuntime.jsx(
5254
+ Vector4ActionButton,
5255
+ {
5256
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { size: compact ? "1.1vh" : "1.3vh", color }),
5257
+ label: locale("Goto"),
5258
+ tooltip: locale("GotoWorldTooltip"),
5259
+ onClick: goto,
5260
+ color,
5261
+ compact
5262
+ }
5263
+ );
5264
+ }
5265
+ function Vector4DeleteButton({
5266
+ onClick,
5267
+ compact
5268
+ }) {
5269
+ const color = "#ef4444";
5270
+ return /* @__PURE__ */ jsxRuntime.jsx(
5271
+ Vector4ActionButton,
5272
+ {
5273
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: compact ? "1.1vh" : "1.3vh", color }),
5274
+ label: locale("Delete"),
5275
+ tooltip: locale("Delete"),
5276
+ onClick,
5277
+ color,
5278
+ compact
5279
+ }
5280
+ );
5281
+ }
5127
5282
  var GroupSelectContext = React6.createContext(null);
5128
5283
  function GroupSelect({
5129
5284
  value,
@@ -5924,6 +6079,10 @@ exports.SelectItem = SelectItem;
5924
6079
  exports.TestBed = TestBed;
5925
6080
  exports.Title = Title;
5926
6081
  exports.TornEdgeSVGFilter = TornEdgeSVGFilter;
6082
+ exports.Vector4DeleteButton = Vector4DeleteButton;
6083
+ exports.Vector4Display = Vector4Display;
6084
+ exports.WorldPositionGotoButton = WorldPositionGotoButton;
6085
+ exports.WorldPositionSetButton = WorldPositionSetButton;
5927
6086
  exports.colorWithAlpha = colorWithAlpha;
5928
6087
  exports.copyToClipboard = copyToClipboard;
5929
6088
  exports.createFormStore = createFormStore;