dirk-cfx-react 1.1.73 → 1.1.76

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
@@ -12,6 +12,7 @@ var clickSoundUrl = require('./click_sound-PNCRRTM4.mp3');
12
12
  var hoverSoundUrl = require('./hover_sound-NBUA222C.mp3');
13
13
  var notifications = require('@mantine/notifications');
14
14
  var reactQuery = require('@tanstack/react-query');
15
+ var colorsGenerator = require('@mantine/colors-generator');
15
16
  require('@mantine/core/styles.css');
16
17
  require('@mantine/notifications/styles.css');
17
18
  require('./styles/fonts.css');
@@ -4835,7 +4836,22 @@ function ConfigPanelInner({
4835
4836
  if (result?.success) {
4836
4837
  const { store } = getScriptConfigInstance();
4837
4838
  form.reinitialize(cloneConfig(store.getState()));
4839
+ notifications.notifications.show({
4840
+ color: "green",
4841
+ title: locale("ConfigResetSuccessTitle"),
4842
+ message: locale("ConfigResetSuccessBody"),
4843
+ autoClose: 3e3
4844
+ });
4845
+ return;
4838
4846
  }
4847
+ const err = result?._error || "Unknown";
4848
+ console.warn(`[ConfigPanel] config reset failed: ${err}`);
4849
+ notifications.notifications.show({
4850
+ color: "red",
4851
+ title: locale("ConfigResetFailedTitle"),
4852
+ message: locale("ConfigResetFailedBody", err),
4853
+ autoClose: 6e3
4854
+ });
4839
4855
  },
4840
4856
  onClose: () => setResetOpen(false),
4841
4857
  zIndex: 300
@@ -6010,6 +6026,282 @@ function TestBed({
6010
6026
  }
6011
6027
  );
6012
6028
  }
6029
+ var MANTINE_COLOR_OPTIONS = [
6030
+ "dirk",
6031
+ "red",
6032
+ "pink",
6033
+ "grape",
6034
+ "violet",
6035
+ "indigo",
6036
+ "blue",
6037
+ "cyan",
6038
+ "teal",
6039
+ "green",
6040
+ "lime",
6041
+ "yellow",
6042
+ "orange"
6043
+ ].map((value) => ({ value, label: value }));
6044
+ var DEFAULT_PALETTE = [
6045
+ "#f0f4ff",
6046
+ "#d9e3ff",
6047
+ "#bfcfff",
6048
+ "#a6bbff",
6049
+ "#8ca7ff",
6050
+ "#7393ff",
6051
+ "#5a7fff",
6052
+ "#406bff",
6053
+ "#2547ff",
6054
+ "#0b33ff"
6055
+ ];
6056
+ var DEFAULT_VALUE = {
6057
+ useOverride: false,
6058
+ primaryColor: "dirk",
6059
+ primaryShade: 5,
6060
+ customTheme: DEFAULT_PALETTE
6061
+ };
6062
+ function GroupLabel({ label: label2 }) {
6063
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", gap: "xs", mt: "xxs", children: [
6064
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", tt: "uppercase", lts: "0.07em", c: "rgba(255,255,255,0.2)", children: label2 }),
6065
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, height: "0.05vh", background: "rgba(255,255,255,0.06)" } })
6066
+ ] });
6067
+ }
6068
+ function ThemeOverrideSection({
6069
+ schemaKey = "theme",
6070
+ title
6071
+ }) {
6072
+ const mantineTheme = core.useMantineTheme();
6073
+ const color = mantineTheme.colors[mantineTheme.primaryColor][5];
6074
+ const raw = useFormField(schemaKey);
6075
+ const value = {
6076
+ useOverride: raw?.useOverride ?? DEFAULT_VALUE.useOverride,
6077
+ primaryColor: raw?.primaryColor ?? DEFAULT_VALUE.primaryColor,
6078
+ primaryShade: raw?.primaryShade ?? DEFAULT_VALUE.primaryShade,
6079
+ customTheme: Array.isArray(raw?.customTheme) && raw.customTheme.length === 10 ? raw.customTheme : DEFAULT_VALUE.customTheme
6080
+ };
6081
+ const { setValue } = useFormActions();
6082
+ const set = (key, val) => setValue(schemaKey, { ...value, [key]: val });
6083
+ const useCustom = value.primaryColor === "custom";
6084
+ const editable = value.useOverride;
6085
+ const setSwatch = (index, hex) => {
6086
+ const next = [...value.customTheme];
6087
+ next[index] = hex;
6088
+ set("customTheme", next);
6089
+ };
6090
+ const generateFromBase = (hex) => {
6091
+ try {
6092
+ const generated = colorsGenerator.generateColors(hex);
6093
+ set("customTheme", generated);
6094
+ } catch {
6095
+ }
6096
+ };
6097
+ const resetPalette = () => set("customTheme", DEFAULT_PALETTE);
6098
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6099
+ core.Flex,
6100
+ {
6101
+ direction: "column",
6102
+ gap: "xs",
6103
+ p: "sm",
6104
+ style: { flex: 1, minHeight: 0, overflowY: "auto" },
6105
+ children: [
6106
+ /* @__PURE__ */ jsxRuntime.jsx(
6107
+ AdminPageTitle,
6108
+ {
6109
+ icon: lucideReact.Palette,
6110
+ title: title || locale("Theme") || "Theme",
6111
+ color
6112
+ }
6113
+ ),
6114
+ /* @__PURE__ */ jsxRuntime.jsxs(
6115
+ core.Flex,
6116
+ {
6117
+ align: "center",
6118
+ justify: "space-between",
6119
+ p: "xs",
6120
+ style: {
6121
+ background: `rgba(255,255,255,${editable ? 0.04 : 0.02})`,
6122
+ border: `0.1vh solid ${editable ? color : "rgba(255,255,255,0.08)"}`,
6123
+ borderRadius: mantineTheme.radius.xs,
6124
+ transition: "background 0.15s, border-color 0.15s"
6125
+ },
6126
+ children: [
6127
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: "xxs", style: { flex: 1, minWidth: 0 }, children: [
6128
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xs", c: "rgba(255,255,255,0.9)", children: locale("OverrideGlobalTheme") || "Override global theme" }),
6129
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", c: "rgba(255,255,255,0.4)", children: locale("OverrideGlobalThemeDesc") || "When on, this resource uses its own primary colour and palette instead of dirk_lib's. Turn off to fall back to the global theme \u2014 your custom palette is kept." })
6130
+ ] }),
6131
+ /* @__PURE__ */ jsxRuntime.jsx(
6132
+ core.Switch,
6133
+ {
6134
+ size: "md",
6135
+ checked: value.useOverride,
6136
+ onChange: (e) => set("useOverride", e.currentTarget.checked)
6137
+ }
6138
+ )
6139
+ ]
6140
+ }
6141
+ ),
6142
+ /* @__PURE__ */ jsxRuntime.jsxs(
6143
+ "div",
6144
+ {
6145
+ style: {
6146
+ opacity: editable ? 1 : 0.4,
6147
+ pointerEvents: editable ? "auto" : "none",
6148
+ transition: "opacity 0.15s"
6149
+ },
6150
+ children: [
6151
+ /* @__PURE__ */ jsxRuntime.jsx(GroupLabel, { label: locale("PrimaryColor") || "Primary Colour" }),
6152
+ /* @__PURE__ */ jsxRuntime.jsx(
6153
+ core.Switch,
6154
+ {
6155
+ label: locale("UseCustomPalette") || "Use custom palette",
6156
+ size: "md",
6157
+ mt: "xs",
6158
+ checked: useCustom,
6159
+ onChange: (e) => set("primaryColor", e.currentTarget.checked ? "custom" : "dirk"),
6160
+ styles: {
6161
+ label: {
6162
+ fontFamily: "Akrobat Bold",
6163
+ fontSize: "0.65em",
6164
+ letterSpacing: "0.06em",
6165
+ textTransform: "uppercase",
6166
+ color: "rgba(255,255,255,0.35)"
6167
+ }
6168
+ }
6169
+ }
6170
+ ),
6171
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", mt: "xs", children: [
6172
+ !useCustom && /* @__PURE__ */ jsxRuntime.jsx(
6173
+ core.Select,
6174
+ {
6175
+ label: locale("MantinePalette") || "Mantine palette",
6176
+ size: "xs",
6177
+ style: { flex: 1 },
6178
+ value: value.primaryColor,
6179
+ data: MANTINE_COLOR_OPTIONS,
6180
+ allowDeselect: false,
6181
+ onChange: (v) => v && set("primaryColor", v)
6182
+ }
6183
+ ),
6184
+ /* @__PURE__ */ jsxRuntime.jsx(
6185
+ core.NumberInput,
6186
+ {
6187
+ label: locale("Shade") || "Shade",
6188
+ size: "xs",
6189
+ style: { flex: 1 },
6190
+ min: 0,
6191
+ max: 9,
6192
+ value: value.primaryShade,
6193
+ onChange: (v) => set("primaryShade", Number(v))
6194
+ }
6195
+ )
6196
+ ] }),
6197
+ useCustom && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6198
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", justify: "space-between", mt: "sm", children: [
6199
+ /* @__PURE__ */ jsxRuntime.jsx(
6200
+ core.Text,
6201
+ {
6202
+ ff: "Akrobat Bold",
6203
+ size: "xxs",
6204
+ tt: "uppercase",
6205
+ lts: "0.07em",
6206
+ c: "rgba(255,255,255,0.2)",
6207
+ children: locale("CustomPalette") || "Custom palette"
6208
+ }
6209
+ ),
6210
+ /* @__PURE__ */ jsxRuntime.jsx(
6211
+ core.ActionIcon,
6212
+ {
6213
+ size: "sm",
6214
+ variant: "subtle",
6215
+ onClick: resetPalette,
6216
+ title: locale("ResetPalette") || "Reset palette",
6217
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { size: "1.4vh" })
6218
+ }
6219
+ )
6220
+ ] }),
6221
+ /* @__PURE__ */ jsxRuntime.jsx(
6222
+ core.ColorInput,
6223
+ {
6224
+ label: locale("BaseColor") || "Base colour",
6225
+ size: "xs",
6226
+ value: value.customTheme[value.primaryShade] ?? value.customTheme[5] ?? "#000000",
6227
+ onChange: generateFromBase,
6228
+ eyeDropperIcon: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
6229
+ }
6230
+ ),
6231
+ /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { gap: "xxs", mt: "xxs", children: value.customTheme.map((swatch, i) => /* @__PURE__ */ jsxRuntime.jsx(
6232
+ SwatchTile,
6233
+ {
6234
+ index: i,
6235
+ value: swatch,
6236
+ isPrimary: i === value.primaryShade,
6237
+ onChange: (v) => setSwatch(i, v)
6238
+ },
6239
+ i
6240
+ )) })
6241
+ ] })
6242
+ ]
6243
+ }
6244
+ )
6245
+ ]
6246
+ }
6247
+ );
6248
+ }
6249
+ function SwatchTile({
6250
+ index,
6251
+ value,
6252
+ isPrimary,
6253
+ onChange
6254
+ }) {
6255
+ const [opened, setOpened] = React6.useState(false);
6256
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Popover, { opened, onChange: setOpened, position: "bottom", withArrow: true, zIndex: 1e4, children: [
6257
+ /* @__PURE__ */ jsxRuntime.jsx(core.Popover.Target, { children: /* @__PURE__ */ jsxRuntime.jsx(
6258
+ "button",
6259
+ {
6260
+ onClick: () => setOpened((o) => !o),
6261
+ title: `${index} \xB7 ${value}`,
6262
+ style: {
6263
+ flex: 1,
6264
+ aspectRatio: "1 / 1",
6265
+ background: value,
6266
+ border: isPrimary ? "0.2vh solid rgba(255,255,255,0.85)" : "0.1vh solid rgba(255,255,255,0.15)",
6267
+ borderRadius: "0.4vh",
6268
+ cursor: "pointer",
6269
+ padding: 0,
6270
+ display: "flex",
6271
+ alignItems: "flex-end",
6272
+ justifyContent: "flex-end",
6273
+ position: "relative"
6274
+ },
6275
+ children: /* @__PURE__ */ jsxRuntime.jsx(
6276
+ "span",
6277
+ {
6278
+ style: {
6279
+ fontFamily: "Akrobat Bold",
6280
+ fontSize: "0.9vh",
6281
+ lineHeight: 1,
6282
+ padding: "0.2vh 0.3vh",
6283
+ color: "rgba(0,0,0,0.55)",
6284
+ background: "rgba(255,255,255,0.55)",
6285
+ borderRadius: "0.25vh",
6286
+ margin: "0.2vh"
6287
+ },
6288
+ children: index
6289
+ }
6290
+ )
6291
+ }
6292
+ ) }),
6293
+ /* @__PURE__ */ jsxRuntime.jsx(core.Popover.Dropdown, { p: "xs", children: /* @__PURE__ */ jsxRuntime.jsx(
6294
+ core.ColorInput,
6295
+ {
6296
+ size: "xs",
6297
+ value,
6298
+ onChange,
6299
+ format: "hex",
6300
+ eyeDropperIcon: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
6301
+ }
6302
+ ) })
6303
+ ] });
6304
+ }
6013
6305
  function useTornEdges() {
6014
6306
  const game = useSettings((state) => state.game);
6015
6307
  return game === "rdr3" ? "torn-edge-wrapper" : "";
@@ -6291,6 +6583,12 @@ function DirkProvider({ children, overideResourceName, themeOverride }) {
6291
6583
  }, []);
6292
6584
  useNuiEvent("UPDATE_DIRK_LIB_SETTINGS", (data) => {
6293
6585
  if (!data || typeof data !== "object") return;
6586
+ const current = useSettings.getState();
6587
+ if (current.themeOverride) {
6588
+ const { primaryColor: _pc, primaryShade: _ps, customTheme: _ct, ...rest } = data;
6589
+ useSettings.setState(rest);
6590
+ return;
6591
+ }
6294
6592
  useSettings.setState(data);
6295
6593
  });
6296
6594
  const mergedTheme = React6.useMemo(
@@ -6374,6 +6672,7 @@ exports.SegmentedControl = SegmentedControl;
6374
6672
  exports.SegmentedProgress = SegmentedProgress;
6375
6673
  exports.SelectItem = SelectItem;
6376
6674
  exports.TestBed = TestBed;
6675
+ exports.ThemeOverrideSection = ThemeOverrideSection;
6377
6676
  exports.Title = Title;
6378
6677
  exports.TornEdgeSVGFilter = TornEdgeSVGFilter;
6379
6678
  exports.Vector2Schema = Vector2Schema;