dirk-cfx-react 1.1.82 → 1.1.83
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 +149 -0
- 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 +150 -2
- package/dist/components/index.js.map +1 -1
- package/dist/index.cjs +149 -0
- 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 +150 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6933,6 +6933,154 @@ function ScenarioSelect({
|
|
|
6933
6933
|
}
|
|
6934
6934
|
);
|
|
6935
6935
|
}
|
|
6936
|
+
function decimalToHex(color) {
|
|
6937
|
+
if (!color || color === 0) return null;
|
|
6938
|
+
return "#" + color.toString(16).padStart(6, "0");
|
|
6939
|
+
}
|
|
6940
|
+
function RoleOption({ role }) {
|
|
6941
|
+
const swatch = decimalToHex(role.color) || "rgba(255,255,255,0.25)";
|
|
6942
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", gap: "0.6vh", children: [
|
|
6943
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6944
|
+
"div",
|
|
6945
|
+
{
|
|
6946
|
+
style: {
|
|
6947
|
+
width: "1vh",
|
|
6948
|
+
height: "1vh",
|
|
6949
|
+
borderRadius: "50%",
|
|
6950
|
+
background: swatch,
|
|
6951
|
+
flexShrink: 0,
|
|
6952
|
+
boxShadow: role.color ? `0 0 0.4vh ${swatch}` : void 0
|
|
6953
|
+
}
|
|
6954
|
+
}
|
|
6955
|
+
),
|
|
6956
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xs", c: "rgba(255,255,255,0.9)", children: role.name })
|
|
6957
|
+
] });
|
|
6958
|
+
}
|
|
6959
|
+
function NotConfiguredBanner({ label: label2 }) {
|
|
6960
|
+
const theme2 = core.useMantineTheme();
|
|
6961
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: "xxs", children: [
|
|
6962
|
+
label2 && /* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", tt: "uppercase", lts: "0.05em", c: "rgba(255,255,255,0.55)", children: label2 }),
|
|
6963
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
6964
|
+
core.Flex,
|
|
6965
|
+
{
|
|
6966
|
+
align: "center",
|
|
6967
|
+
gap: "xs",
|
|
6968
|
+
px: "xs",
|
|
6969
|
+
py: "xxs",
|
|
6970
|
+
style: {
|
|
6971
|
+
background: "rgba(0,0,0,0.3)",
|
|
6972
|
+
border: "0.1vh dashed rgba(255,255,255,0.12)",
|
|
6973
|
+
borderRadius: theme2.radius.xs
|
|
6974
|
+
},
|
|
6975
|
+
children: [
|
|
6976
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { size: "1.4vh", color: "rgba(255,255,255,0.4)" }),
|
|
6977
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", c: "rgba(255,255,255,0.55)", style: { flex: 1 }, children: locale("DiscordNotConfigured") || "Discord bot not configured \u2014 run /dirk_lib and set a bot token + guild ID." })
|
|
6978
|
+
]
|
|
6979
|
+
}
|
|
6980
|
+
)
|
|
6981
|
+
] });
|
|
6982
|
+
}
|
|
6983
|
+
function DiscordRoleSelect(props) {
|
|
6984
|
+
const { endpoint, label: label2, size = "xs", placeholder, disabled, style, styles } = props;
|
|
6985
|
+
const [roles, setRoles] = React6.useState(null);
|
|
6986
|
+
const [loading, setLoading] = React6.useState(false);
|
|
6987
|
+
const [errorCode, setErrorCode] = React6.useState(null);
|
|
6988
|
+
const refresh = async () => {
|
|
6989
|
+
setLoading(true);
|
|
6990
|
+
try {
|
|
6991
|
+
const res = await fetchNui(endpoint, {}, {
|
|
6992
|
+
// Browser dev fallback so the component renders something useful
|
|
6993
|
+
// outside FiveM.
|
|
6994
|
+
ok: true,
|
|
6995
|
+
roles: [
|
|
6996
|
+
{ id: "1", name: "Admin", color: 15548997, position: 5 },
|
|
6997
|
+
{ id: "2", name: "VIP Gold", color: 16426522, position: 4 },
|
|
6998
|
+
{ id: "3", name: "Member", color: 5763719, position: 3 },
|
|
6999
|
+
{ id: "4", name: "Guest", color: 0, position: 2 }
|
|
7000
|
+
]
|
|
7001
|
+
});
|
|
7002
|
+
if (res?.ok) {
|
|
7003
|
+
setRoles(res.roles ?? []);
|
|
7004
|
+
setErrorCode(null);
|
|
7005
|
+
} else {
|
|
7006
|
+
setRoles(null);
|
|
7007
|
+
setErrorCode(res?._error || "FetchFailed");
|
|
7008
|
+
}
|
|
7009
|
+
} finally {
|
|
7010
|
+
setLoading(false);
|
|
7011
|
+
}
|
|
7012
|
+
};
|
|
7013
|
+
React6.useEffect(() => {
|
|
7014
|
+
refresh();
|
|
7015
|
+
}, [endpoint]);
|
|
7016
|
+
const rolesById = React6.useMemo(() => {
|
|
7017
|
+
const map = {};
|
|
7018
|
+
for (const r of roles ?? []) map[r.id] = r;
|
|
7019
|
+
return map;
|
|
7020
|
+
}, [roles]);
|
|
7021
|
+
if (errorCode === "NotConfigured") {
|
|
7022
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NotConfiguredBanner, { label: label2 });
|
|
7023
|
+
}
|
|
7024
|
+
const data = (roles ?? []).map((r) => ({
|
|
7025
|
+
value: r.id,
|
|
7026
|
+
label: r.name
|
|
7027
|
+
}));
|
|
7028
|
+
const renderOption = ({ option }) => {
|
|
7029
|
+
const role = rolesById[option.value];
|
|
7030
|
+
return role ? /* @__PURE__ */ jsxRuntime.jsx(RoleOption, { role }) : /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xs", children: option.label });
|
|
7031
|
+
};
|
|
7032
|
+
const refreshButton = /* @__PURE__ */ jsxRuntime.jsx(
|
|
7033
|
+
core.ActionIcon,
|
|
7034
|
+
{
|
|
7035
|
+
size: "xs",
|
|
7036
|
+
variant: "subtle",
|
|
7037
|
+
onClick: refresh,
|
|
7038
|
+
title: locale("Refresh") || "Refresh",
|
|
7039
|
+
loading,
|
|
7040
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { size: "1.2vh" })
|
|
7041
|
+
}
|
|
7042
|
+
);
|
|
7043
|
+
if (props.multi) {
|
|
7044
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7045
|
+
core.MultiSelect,
|
|
7046
|
+
{
|
|
7047
|
+
label: label2,
|
|
7048
|
+
size,
|
|
7049
|
+
placeholder: placeholder || locale("PickRoles") || "Pick roles...",
|
|
7050
|
+
data,
|
|
7051
|
+
value: props.value || [],
|
|
7052
|
+
onChange: (ids) => props.onChange(ids),
|
|
7053
|
+
renderOption,
|
|
7054
|
+
searchable: true,
|
|
7055
|
+
clearable: true,
|
|
7056
|
+
disabled: disabled || loading && !roles,
|
|
7057
|
+
rightSection: refreshButton,
|
|
7058
|
+
style,
|
|
7059
|
+
styles,
|
|
7060
|
+
nothingFoundMessage: errorCode ? `${locale("Error") || "Error"} (${errorCode})` : locale("NoRoles") || "No roles found"
|
|
7061
|
+
}
|
|
7062
|
+
);
|
|
7063
|
+
}
|
|
7064
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7065
|
+
core.Select,
|
|
7066
|
+
{
|
|
7067
|
+
label: label2,
|
|
7068
|
+
size,
|
|
7069
|
+
placeholder: placeholder || locale("PickRole") || "Pick a role...",
|
|
7070
|
+
data,
|
|
7071
|
+
value: props.value || null,
|
|
7072
|
+
onChange: (id) => props.onChange(id),
|
|
7073
|
+
renderOption,
|
|
7074
|
+
searchable: true,
|
|
7075
|
+
clearable: true,
|
|
7076
|
+
disabled: disabled || loading && !roles,
|
|
7077
|
+
rightSection: refreshButton,
|
|
7078
|
+
style,
|
|
7079
|
+
styles,
|
|
7080
|
+
nothingFoundMessage: errorCode ? `${locale("Error") || "Error"} (${errorCode})` : locale("NoRoles") || "No roles found"
|
|
7081
|
+
}
|
|
7082
|
+
);
|
|
7083
|
+
}
|
|
6936
7084
|
function useTornEdges() {
|
|
6937
7085
|
const game = useSettings((state) => state.game);
|
|
6938
7086
|
return game === "rdr3" ? "torn-edge-wrapper" : "";
|
|
@@ -7306,6 +7454,7 @@ exports.ControlMultiSelect = ControlMultiSelect;
|
|
|
7306
7454
|
exports.ControlSelect = ControlSelect;
|
|
7307
7455
|
exports.Counter = Counter;
|
|
7308
7456
|
exports.DirkProvider = DirkProvider;
|
|
7457
|
+
exports.DiscordRoleSelect = DiscordRoleSelect;
|
|
7309
7458
|
exports.FiveMKeyBindInput = FiveMKeyBindInput;
|
|
7310
7459
|
exports.FloatingParticles = FloatingParticles;
|
|
7311
7460
|
exports.FormProvider = FormProvider;
|