dirk-cfx-react 1.1.82 → 1.1.84
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 +180 -3
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +32 -1
- package/dist/components/index.d.ts +32 -1
- package/dist/components/index.js +180 -4
- package/dist/components/index.js.map +1 -1
- package/dist/index.cjs +180 -3
- 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 +180 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -3091,11 +3091,11 @@ function ConfirmModal({
|
|
|
3091
3091
|
placeholder: confirmText,
|
|
3092
3092
|
value: typed,
|
|
3093
3093
|
onChange: (e) => setTyped(e.currentTarget.value),
|
|
3094
|
-
styles: (
|
|
3094
|
+
styles: (t2) => ({
|
|
3095
3095
|
input: {
|
|
3096
|
-
backgroundColor: core.alpha(
|
|
3096
|
+
backgroundColor: core.alpha(t2.colors.dark[7], 0.5),
|
|
3097
3097
|
border: `0.1vh solid ${core.alpha(
|
|
3098
|
-
typed === confirmText ? "#ef4444" :
|
|
3098
|
+
typed === confirmText ? "#ef4444" : t2.colors.dark[5],
|
|
3099
3099
|
0.5
|
|
3100
3100
|
)}`,
|
|
3101
3101
|
color: "rgba(255,255,255,0.85)",
|
|
@@ -6204,6 +6204,182 @@ function ScenarioSelect({
|
|
|
6204
6204
|
}
|
|
6205
6205
|
);
|
|
6206
6206
|
}
|
|
6207
|
+
var t = (key, fallback) => {
|
|
6208
|
+
const v = locale(key);
|
|
6209
|
+
return v === key ? fallback : v;
|
|
6210
|
+
};
|
|
6211
|
+
function decimalToHex(color) {
|
|
6212
|
+
if (!color || color === 0) return null;
|
|
6213
|
+
return "#" + color.toString(16).padStart(6, "0");
|
|
6214
|
+
}
|
|
6215
|
+
function RoleOption({ role }) {
|
|
6216
|
+
const swatch = decimalToHex(role.color) || "rgba(255,255,255,0.25)";
|
|
6217
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", gap: "0.6vh", children: [
|
|
6218
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6219
|
+
"div",
|
|
6220
|
+
{
|
|
6221
|
+
style: {
|
|
6222
|
+
width: "1vh",
|
|
6223
|
+
height: "1vh",
|
|
6224
|
+
borderRadius: "50%",
|
|
6225
|
+
background: swatch,
|
|
6226
|
+
flexShrink: 0,
|
|
6227
|
+
boxShadow: role.color ? `0 0 0.4vh ${swatch}` : void 0
|
|
6228
|
+
}
|
|
6229
|
+
}
|
|
6230
|
+
),
|
|
6231
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xs", c: "rgba(255,255,255,0.9)", children: role.name })
|
|
6232
|
+
] });
|
|
6233
|
+
}
|
|
6234
|
+
var NOT_CONFIGURED_TINT = "rgba(255,184,0,0.35)";
|
|
6235
|
+
var NOT_CONFIGURED_FILL = "rgba(255,184,0,0.05)";
|
|
6236
|
+
function DiscordRoleSelect(props) {
|
|
6237
|
+
const { endpoint, label, size = "xs", placeholder, disabled, style, styles } = props;
|
|
6238
|
+
const [roles, setRoles] = react.useState(null);
|
|
6239
|
+
const [loading, setLoading] = react.useState(false);
|
|
6240
|
+
const [errorCode, setErrorCode] = react.useState(null);
|
|
6241
|
+
const refresh = async () => {
|
|
6242
|
+
setLoading(true);
|
|
6243
|
+
try {
|
|
6244
|
+
const res = await fetchNui(endpoint, {}, {
|
|
6245
|
+
// Browser dev fallback so the component renders something useful
|
|
6246
|
+
// outside FiveM.
|
|
6247
|
+
ok: true,
|
|
6248
|
+
roles: [
|
|
6249
|
+
{ id: "1", name: "Admin", color: 15548997, position: 5 },
|
|
6250
|
+
{ id: "2", name: "VIP Gold", color: 16426522, position: 4 },
|
|
6251
|
+
{ id: "3", name: "Member", color: 5763719, position: 3 },
|
|
6252
|
+
{ id: "4", name: "Guest", color: 0, position: 2 }
|
|
6253
|
+
]
|
|
6254
|
+
});
|
|
6255
|
+
if (res?.ok) {
|
|
6256
|
+
setRoles(res.roles ?? []);
|
|
6257
|
+
setErrorCode(null);
|
|
6258
|
+
} else {
|
|
6259
|
+
setRoles(null);
|
|
6260
|
+
setErrorCode(res?._error || "FetchFailed");
|
|
6261
|
+
}
|
|
6262
|
+
} finally {
|
|
6263
|
+
setLoading(false);
|
|
6264
|
+
}
|
|
6265
|
+
};
|
|
6266
|
+
react.useEffect(() => {
|
|
6267
|
+
refresh();
|
|
6268
|
+
}, [endpoint]);
|
|
6269
|
+
const rolesById = react.useMemo(() => {
|
|
6270
|
+
const map = {};
|
|
6271
|
+
for (const r of roles ?? []) map[r.id] = r;
|
|
6272
|
+
return map;
|
|
6273
|
+
}, [roles]);
|
|
6274
|
+
if (errorCode === "NotConfigured") {
|
|
6275
|
+
const notConfiguredPlaceholder = t(
|
|
6276
|
+
"DiscordNotConfigured",
|
|
6277
|
+
"Not configured \u2014 set in /dirk_lib"
|
|
6278
|
+
);
|
|
6279
|
+
const notConfiguredStyles = {
|
|
6280
|
+
...styles,
|
|
6281
|
+
input: {
|
|
6282
|
+
...styles?.input ?? {},
|
|
6283
|
+
borderColor: NOT_CONFIGURED_TINT,
|
|
6284
|
+
backgroundColor: NOT_CONFIGURED_FILL
|
|
6285
|
+
}
|
|
6286
|
+
};
|
|
6287
|
+
const warnIcon = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { size: "1.2vh", color: NOT_CONFIGURED_TINT.replace(/0\.35\)$/, "0.85)") });
|
|
6288
|
+
if (props.multi) {
|
|
6289
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6290
|
+
core.MultiSelect,
|
|
6291
|
+
{
|
|
6292
|
+
label,
|
|
6293
|
+
size,
|
|
6294
|
+
placeholder: notConfiguredPlaceholder,
|
|
6295
|
+
data: [],
|
|
6296
|
+
value: [],
|
|
6297
|
+
onChange: () => {
|
|
6298
|
+
},
|
|
6299
|
+
disabled: true,
|
|
6300
|
+
rightSection: warnIcon,
|
|
6301
|
+
style,
|
|
6302
|
+
styles: notConfiguredStyles
|
|
6303
|
+
}
|
|
6304
|
+
);
|
|
6305
|
+
}
|
|
6306
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6307
|
+
core.Select,
|
|
6308
|
+
{
|
|
6309
|
+
label,
|
|
6310
|
+
size,
|
|
6311
|
+
placeholder: notConfiguredPlaceholder,
|
|
6312
|
+
data: [],
|
|
6313
|
+
value: null,
|
|
6314
|
+
onChange: () => {
|
|
6315
|
+
},
|
|
6316
|
+
disabled: true,
|
|
6317
|
+
rightSection: warnIcon,
|
|
6318
|
+
style,
|
|
6319
|
+
styles: notConfiguredStyles
|
|
6320
|
+
}
|
|
6321
|
+
);
|
|
6322
|
+
}
|
|
6323
|
+
const data = (roles ?? []).map((r) => ({
|
|
6324
|
+
value: r.id,
|
|
6325
|
+
label: r.name
|
|
6326
|
+
}));
|
|
6327
|
+
const renderOption = ({ option }) => {
|
|
6328
|
+
const role = rolesById[option.value];
|
|
6329
|
+
return role ? /* @__PURE__ */ jsxRuntime.jsx(RoleOption, { role }) : /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xs", children: option.label });
|
|
6330
|
+
};
|
|
6331
|
+
const refreshButton = /* @__PURE__ */ jsxRuntime.jsx(
|
|
6332
|
+
core.ActionIcon,
|
|
6333
|
+
{
|
|
6334
|
+
size: "xs",
|
|
6335
|
+
variant: "subtle",
|
|
6336
|
+
onClick: refresh,
|
|
6337
|
+
title: t("Refresh", "Refresh"),
|
|
6338
|
+
loading,
|
|
6339
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { size: "1.2vh" })
|
|
6340
|
+
}
|
|
6341
|
+
);
|
|
6342
|
+
if (props.multi) {
|
|
6343
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6344
|
+
core.MultiSelect,
|
|
6345
|
+
{
|
|
6346
|
+
label,
|
|
6347
|
+
size,
|
|
6348
|
+
placeholder: placeholder || t("PickRoles", "Pick roles..."),
|
|
6349
|
+
data,
|
|
6350
|
+
value: props.value || [],
|
|
6351
|
+
onChange: (ids) => props.onChange(ids),
|
|
6352
|
+
renderOption,
|
|
6353
|
+
searchable: true,
|
|
6354
|
+
clearable: true,
|
|
6355
|
+
disabled: disabled || loading && !roles,
|
|
6356
|
+
rightSection: refreshButton,
|
|
6357
|
+
style,
|
|
6358
|
+
styles,
|
|
6359
|
+
nothingFoundMessage: errorCode ? `${t("Error", "Error")} (${errorCode})` : t("NoRoles", "No roles found")
|
|
6360
|
+
}
|
|
6361
|
+
);
|
|
6362
|
+
}
|
|
6363
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6364
|
+
core.Select,
|
|
6365
|
+
{
|
|
6366
|
+
label,
|
|
6367
|
+
size,
|
|
6368
|
+
placeholder: placeholder || t("PickRole", "Pick a role..."),
|
|
6369
|
+
data,
|
|
6370
|
+
value: props.value || null,
|
|
6371
|
+
onChange: (id) => props.onChange(id),
|
|
6372
|
+
renderOption,
|
|
6373
|
+
searchable: true,
|
|
6374
|
+
clearable: true,
|
|
6375
|
+
disabled: disabled || loading && !roles,
|
|
6376
|
+
rightSection: refreshButton,
|
|
6377
|
+
style,
|
|
6378
|
+
styles,
|
|
6379
|
+
nothingFoundMessage: errorCode ? `${t("Error", "Error")} (${errorCode})` : t("NoRoles", "No roles found")
|
|
6380
|
+
}
|
|
6381
|
+
);
|
|
6382
|
+
}
|
|
6207
6383
|
|
|
6208
6384
|
exports.AdminPageTitle = AdminPageTitle;
|
|
6209
6385
|
exports.AnimPostFxSelect = AnimPostFxSelect;
|
|
@@ -6217,6 +6393,7 @@ exports.ConfirmModal = ConfirmModal;
|
|
|
6217
6393
|
exports.ControlMultiSelect = ControlMultiSelect;
|
|
6218
6394
|
exports.ControlSelect = ControlSelect;
|
|
6219
6395
|
exports.Counter = Counter;
|
|
6396
|
+
exports.DiscordRoleSelect = DiscordRoleSelect;
|
|
6220
6397
|
exports.FiveMKeyBindInput = FiveMKeyBindInput;
|
|
6221
6398
|
exports.FloatingParticles = FloatingParticles;
|
|
6222
6399
|
exports.GroupName = GroupName;
|