dirk-cfx-react 1.1.91 → 1.1.93
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/components/index.cjs +128 -42
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +3 -7
- package/dist/components/index.d.ts +3 -7
- package/dist/components/index.js +129 -43
- package/dist/components/index.js.map +1 -1
- package/dist/hooks/index.cjs +70 -19
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +13 -3
- package/dist/hooks/index.d.ts +13 -3
- package/dist/hooks/index.js +70 -19
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +198 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +199 -68
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +0 -6
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.js +0 -6
- package/dist/providers/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1265,11 +1265,11 @@ var colorNames = {
|
|
|
1265
1265
|
Yellow: { r: 255, g: 255, b: 0 },
|
|
1266
1266
|
YellowGreen: { r: 154, g: 205, b: 50 }
|
|
1267
1267
|
};
|
|
1268
|
-
function colorWithAlpha(color,
|
|
1268
|
+
function colorWithAlpha(color, alpha18) {
|
|
1269
1269
|
const lowerCasedColor = color.toLowerCase();
|
|
1270
1270
|
if (colorNames[lowerCasedColor]) {
|
|
1271
1271
|
const rgb = colorNames[lowerCasedColor];
|
|
1272
|
-
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${
|
|
1272
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha18})`;
|
|
1273
1273
|
}
|
|
1274
1274
|
if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
|
|
1275
1275
|
const hex = color.slice(1);
|
|
@@ -1277,12 +1277,12 @@ function colorWithAlpha(color, alpha17) {
|
|
|
1277
1277
|
const r = bigint >> 16 & 255;
|
|
1278
1278
|
const g = bigint >> 8 & 255;
|
|
1279
1279
|
const b = bigint & 255;
|
|
1280
|
-
return `rgba(${r}, ${g}, ${b}, ${
|
|
1280
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha18})`;
|
|
1281
1281
|
}
|
|
1282
1282
|
if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
|
|
1283
1283
|
const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
|
|
1284
1284
|
if (result) {
|
|
1285
|
-
return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${
|
|
1285
|
+
return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha18})`;
|
|
1286
1286
|
}
|
|
1287
1287
|
}
|
|
1288
1288
|
return color;
|
|
@@ -4452,11 +4452,11 @@ function cloneConfig(value) {
|
|
|
4452
4452
|
return JSON.parse(JSON.stringify(value));
|
|
4453
4453
|
}
|
|
4454
4454
|
function ServerOnlyFetcher() {
|
|
4455
|
-
const {
|
|
4455
|
+
const { fetchServerOnly } = getScriptConfigInstance();
|
|
4456
4456
|
const { reinitialize } = useFormActions();
|
|
4457
4457
|
react.useEffect(() => {
|
|
4458
4458
|
let cancelled = false;
|
|
4459
|
-
|
|
4459
|
+
fetchServerOnly().then((full) => {
|
|
4460
4460
|
if (!cancelled && full) reinitialize(full);
|
|
4461
4461
|
}).catch(() => {
|
|
4462
4462
|
});
|
|
@@ -4480,7 +4480,7 @@ function ConfigPanel(props) {
|
|
|
4480
4480
|
if (isSaving) return;
|
|
4481
4481
|
setIsSaving(true);
|
|
4482
4482
|
try {
|
|
4483
|
-
const result = await updateConfig(form.values);
|
|
4483
|
+
const result = await updateConfig(form.values, form.changedFields);
|
|
4484
4484
|
if (result?.success) {
|
|
4485
4485
|
form.reinitialize(cloneConfig(form.values));
|
|
4486
4486
|
dirkQueryClient.invalidateQueries({ queryKey: ["scriptConfigHistory"] });
|
|
@@ -5907,6 +5907,7 @@ function formatLabel(p) {
|
|
|
5907
5907
|
}
|
|
5908
5908
|
return parts.join(" \xB7 ");
|
|
5909
5909
|
}
|
|
5910
|
+
var COMMON_ACE_GROUPS = ["group.admin", "group.mod", "group.superadmin"];
|
|
5910
5911
|
var t = (key, fallback) => {
|
|
5911
5912
|
const v = locale(key);
|
|
5912
5913
|
return v === key ? fallback : v;
|
|
@@ -5929,7 +5930,6 @@ function AccessOverrideSection({
|
|
|
5929
5930
|
schemaKey = "access",
|
|
5930
5931
|
title,
|
|
5931
5932
|
description,
|
|
5932
|
-
groupType,
|
|
5933
5933
|
includeOffline = true
|
|
5934
5934
|
}) {
|
|
5935
5935
|
const mantineTheme = core.useMantineTheme();
|
|
@@ -5944,14 +5944,19 @@ function AccessOverrideSection({
|
|
|
5944
5944
|
const [addingGroup, setAddingGroup] = react.useState(false);
|
|
5945
5945
|
const [addingPlayer, setAddingPlayer] = react.useState(false);
|
|
5946
5946
|
const commitGroup = (name) => {
|
|
5947
|
-
|
|
5948
|
-
|
|
5947
|
+
const g = name.trim();
|
|
5948
|
+
if (!g) return;
|
|
5949
|
+
if (!value.groups.includes(g)) set("groups", [...value.groups, g]);
|
|
5949
5950
|
setAddingGroup(false);
|
|
5950
5951
|
};
|
|
5951
5952
|
const setGroup = (index, name) => {
|
|
5952
5953
|
const next = [...value.groups];
|
|
5953
5954
|
next[index] = name;
|
|
5954
|
-
set("groups", next
|
|
5955
|
+
set("groups", next);
|
|
5956
|
+
};
|
|
5957
|
+
const quickAddGroup = (name) => {
|
|
5958
|
+
if (value.groups.includes(name)) return;
|
|
5959
|
+
set("groups", [...value.groups, name]);
|
|
5955
5960
|
};
|
|
5956
5961
|
const removeGroup = (index) => set("groups", value.groups.filter((_, i) => i !== index));
|
|
5957
5962
|
const commitIdentifier = (id) => {
|
|
@@ -5983,19 +5988,68 @@ function AccessOverrideSection({
|
|
|
5983
5988
|
),
|
|
5984
5989
|
/* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", c: "rgba(255,255,255,0.4)", children: description || t(
|
|
5985
5990
|
"AccessOverrideDesc",
|
|
5986
|
-
"Grant access to this resource's admin panel to specific groups and players, in addition to your global dirk_lib admins. Enforcement is server-side."
|
|
5991
|
+
"Grant access to this resource's admin panel to specific ACE groups and players, in addition to your global dirk_lib admins. Enforcement is server-side."
|
|
5987
5992
|
) }),
|
|
5988
|
-
/* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { icon: lucideReact.Users, label: t("AccessGroups", "
|
|
5993
|
+
/* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { icon: lucideReact.Users, label: t("AccessGroups", "Admin groups (ACE)") }),
|
|
5994
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Flex, { gap: "xs", wrap: "wrap", children: COMMON_ACE_GROUPS.map((g) => {
|
|
5995
|
+
const added = value.groups.includes(g);
|
|
5996
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5997
|
+
core.Flex,
|
|
5998
|
+
{
|
|
5999
|
+
align: "center",
|
|
6000
|
+
gap: "xxs",
|
|
6001
|
+
onClick: added ? void 0 : () => quickAddGroup(g),
|
|
6002
|
+
role: "button",
|
|
6003
|
+
tabIndex: added ? -1 : 0,
|
|
6004
|
+
"aria-disabled": added,
|
|
6005
|
+
onKeyDown: (e) => {
|
|
6006
|
+
if (added) return;
|
|
6007
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
6008
|
+
e.preventDefault();
|
|
6009
|
+
quickAddGroup(g);
|
|
6010
|
+
}
|
|
6011
|
+
},
|
|
6012
|
+
px: "xs",
|
|
6013
|
+
py: "xxs",
|
|
6014
|
+
style: {
|
|
6015
|
+
cursor: added ? "default" : "pointer",
|
|
6016
|
+
opacity: added ? 0.4 : 1,
|
|
6017
|
+
background: core.alpha(color, 0.12),
|
|
6018
|
+
border: `0.1vh solid ${core.alpha(color, 0.4)}`,
|
|
6019
|
+
borderRadius: "0.4vh",
|
|
6020
|
+
transition: "background 0.15s, border-color 0.15s"
|
|
6021
|
+
},
|
|
6022
|
+
onMouseEnter: (e) => {
|
|
6023
|
+
if (added) return;
|
|
6024
|
+
e.currentTarget.style.background = core.alpha(color, 0.22);
|
|
6025
|
+
},
|
|
6026
|
+
onMouseLeave: (e) => {
|
|
6027
|
+
if (added) return;
|
|
6028
|
+
e.currentTarget.style.background = core.alpha(color, 0.12);
|
|
6029
|
+
},
|
|
6030
|
+
children: [
|
|
6031
|
+
!added && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: "1.2vh", color }),
|
|
6032
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", lts: "0.04em", c: color, children: g })
|
|
6033
|
+
]
|
|
6034
|
+
},
|
|
6035
|
+
g
|
|
6036
|
+
);
|
|
6037
|
+
}) }),
|
|
5989
6038
|
/* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: "xxs", children: [
|
|
5990
|
-
value.groups.length === 0 && !addingGroup && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6039
|
+
value.groups.length === 0 && !addingGroup && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6040
|
+
EmptyHint,
|
|
6041
|
+
{
|
|
6042
|
+
text: t("AccessNoGroups", "No ACE groups added. e.g. group.admin")
|
|
6043
|
+
}
|
|
6044
|
+
),
|
|
5991
6045
|
value.groups.map((name, i) => /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", gap: "xs", children: [
|
|
5992
6046
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5993
|
-
|
|
6047
|
+
core.TextInput,
|
|
5994
6048
|
{
|
|
5995
6049
|
value: name,
|
|
5996
|
-
onChange: (
|
|
5997
|
-
|
|
5998
|
-
|
|
6050
|
+
onChange: (e) => setGroup(i, e.currentTarget.value),
|
|
6051
|
+
placeholder: t("AccessGroupPlaceholder", "ACE group or permission, e.g. group.admin"),
|
|
6052
|
+
size: "xs",
|
|
5999
6053
|
style: { flex: 1 }
|
|
6000
6054
|
}
|
|
6001
6055
|
),
|
|
@@ -6012,30 +6066,15 @@ function AccessOverrideSection({
|
|
|
6012
6066
|
}
|
|
6013
6067
|
)
|
|
6014
6068
|
] }, i)),
|
|
6015
|
-
addingGroup && /* @__PURE__ */ jsxRuntime.
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
}
|
|
6025
|
-
),
|
|
6026
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6027
|
-
core.ActionIcon,
|
|
6028
|
-
{
|
|
6029
|
-
variant: "subtle",
|
|
6030
|
-
color: "red",
|
|
6031
|
-
size: "md",
|
|
6032
|
-
onClick: () => setAddingGroup(false),
|
|
6033
|
-
title: t("Remove", "Remove"),
|
|
6034
|
-
"aria-label": t("Remove", "Remove"),
|
|
6035
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: "1.4vh" })
|
|
6036
|
-
}
|
|
6037
|
-
)
|
|
6038
|
-
] })
|
|
6069
|
+
addingGroup && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6070
|
+
AceGroupAddRow,
|
|
6071
|
+
{
|
|
6072
|
+
placeholder: t("AccessGroupPlaceholder", "ACE group or permission, e.g. group.admin"),
|
|
6073
|
+
onCommit: commitGroup,
|
|
6074
|
+
onCancel: () => setAddingGroup(false),
|
|
6075
|
+
removeLabel: t("Remove", "Remove")
|
|
6076
|
+
}
|
|
6077
|
+
)
|
|
6039
6078
|
] }),
|
|
6040
6079
|
!addingGroup && /* @__PURE__ */ jsxRuntime.jsx(AddRowButton, { label: t("AccessAddGroup", "Add group"), onClick: () => setAddingGroup(true) }),
|
|
6041
6080
|
/* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { icon: lucideReact.UserRound, label: t("AccessPlayers", "Players") }),
|
|
@@ -6135,6 +6174,53 @@ function AddRowButton({ label, onClick }) {
|
|
|
6135
6174
|
}
|
|
6136
6175
|
);
|
|
6137
6176
|
}
|
|
6177
|
+
function AceGroupAddRow({
|
|
6178
|
+
placeholder,
|
|
6179
|
+
onCommit,
|
|
6180
|
+
onCancel,
|
|
6181
|
+
removeLabel
|
|
6182
|
+
}) {
|
|
6183
|
+
const [draft, setDraft] = react.useState("");
|
|
6184
|
+
const commit = () => {
|
|
6185
|
+
if (draft.trim()) onCommit(draft);
|
|
6186
|
+
else onCancel();
|
|
6187
|
+
};
|
|
6188
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", gap: "xs", children: [
|
|
6189
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6190
|
+
core.TextInput,
|
|
6191
|
+
{
|
|
6192
|
+
value: draft,
|
|
6193
|
+
onChange: (e) => setDraft(e.currentTarget.value),
|
|
6194
|
+
onKeyDown: (e) => {
|
|
6195
|
+
if (e.key === "Enter") {
|
|
6196
|
+
e.preventDefault();
|
|
6197
|
+
commit();
|
|
6198
|
+
} else if (e.key === "Escape") {
|
|
6199
|
+
e.preventDefault();
|
|
6200
|
+
onCancel();
|
|
6201
|
+
}
|
|
6202
|
+
},
|
|
6203
|
+
onBlur: commit,
|
|
6204
|
+
placeholder,
|
|
6205
|
+
size: "xs",
|
|
6206
|
+
autoFocus: true,
|
|
6207
|
+
style: { flex: 1 }
|
|
6208
|
+
}
|
|
6209
|
+
),
|
|
6210
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6211
|
+
core.ActionIcon,
|
|
6212
|
+
{
|
|
6213
|
+
variant: "subtle",
|
|
6214
|
+
color: "red",
|
|
6215
|
+
size: "md",
|
|
6216
|
+
onClick: onCancel,
|
|
6217
|
+
title: removeLabel,
|
|
6218
|
+
"aria-label": removeLabel,
|
|
6219
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: "1.4vh" })
|
|
6220
|
+
}
|
|
6221
|
+
)
|
|
6222
|
+
] });
|
|
6223
|
+
}
|
|
6138
6224
|
|
|
6139
6225
|
// src/utils/gtaAnimPostFx.ts
|
|
6140
6226
|
var GTA_ANIM_POST_FX_GROUP_ORDER = [
|