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
|
@@ -1061,4 +1061,35 @@ type ScenarioSelectProps = Omit<SelectProps, "data" | "value" | "onChange"> & {
|
|
|
1061
1061
|
};
|
|
1062
1062
|
declare function ScenarioSelect({ value, onChange, label, size, searchable, clearable, ...rest }: ScenarioSelectProps): react_jsx_runtime.JSX.Element;
|
|
1063
1063
|
|
|
1064
|
-
|
|
1064
|
+
type DiscordRole = {
|
|
1065
|
+
id: string;
|
|
1066
|
+
name: string;
|
|
1067
|
+
color: number;
|
|
1068
|
+
position?: number;
|
|
1069
|
+
};
|
|
1070
|
+
type SharedProps = {
|
|
1071
|
+
/** NUI callback name registered by the consumer that returns ListResponse. */
|
|
1072
|
+
endpoint: string;
|
|
1073
|
+
/** Optional label / size / placeholder forwarded to the underlying Mantine Select. */
|
|
1074
|
+
label?: React.ReactNode;
|
|
1075
|
+
size?: SelectProps["size"];
|
|
1076
|
+
placeholder?: string;
|
|
1077
|
+
disabled?: boolean;
|
|
1078
|
+
/** Style props applied to the wrapping Select/MultiSelect. */
|
|
1079
|
+
style?: React.CSSProperties;
|
|
1080
|
+
styles?: SelectProps["styles"];
|
|
1081
|
+
};
|
|
1082
|
+
type SingleProps = SharedProps & {
|
|
1083
|
+
multi?: false;
|
|
1084
|
+
value: string | null;
|
|
1085
|
+
onChange: (id: string | null) => void;
|
|
1086
|
+
};
|
|
1087
|
+
type MultiProps = SharedProps & {
|
|
1088
|
+
multi: true;
|
|
1089
|
+
value: string[];
|
|
1090
|
+
onChange: (ids: string[]) => void;
|
|
1091
|
+
};
|
|
1092
|
+
type DiscordRoleSelectProps = SingleProps | MultiProps;
|
|
1093
|
+
declare function DiscordRoleSelect(props: DiscordRoleSelectProps): react_jsx_runtime.JSX.Element;
|
|
1094
|
+
|
|
1095
|
+
export { AdminPageTitle, type AdminPageTitleProps, AnimPostFxSelect, type AnimPostFxSelectProps, AsyncSaveButton, BlipColorSelect, type BlipColorSelectProps, BlipDisplaySelect, type BlipDisplaySelectProps, BlipIconSelect, type BlipIconSelectProps, BorderedIcon, type BorderedIconProps, type ButtonProps, ConfigPanel, type ConfigPanelProps, ConfirmModal, type ConfirmModalProps, ControlMultiSelect, type ControlMultiSelectProps, ControlSelect, type ControlSelectProps, Counter, type DiscordRole, DiscordRoleSelect, type DiscordRoleSelectProps, type FiveMControls, FiveMKeyBindInput, FloatingParticles, type FloatingParticlesProps, GroupName, type GroupNameProps, GroupRank, type GroupRankProps, GroupSelect, type GroupSelectProps, type GroupType, type GroupValue, InfoBox, type InfoBoxProps, InputContainer, type InputContainerProps, LevelBanner, LevelPanel, MissingItemsBanner, Modal, ModalContext, type ModalProps, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, type NavItem, NavigationContext, NavigationProvider, type NavigationStore, type ParticleState, PositionPicker, type PositionPickerProps, type ProgressProps, type Prompt, type PromptButton, PromptModal, ScenarioSelect, type ScenarioSelectProps, type SegmentProps, SegmentedControl, type SegmentedControlProps, SegmentedProgress, SelectItem, type SelectItemProps, type StoreModalProps, SwitchPanel, type SwitchPanelProps, TestBed, type TestBedItem, type TestBedPlacement, type TestBedProps, ThemeOverrideSection, type ThemeOverrideSectionProps, type ThemeOverrideValue, Title, type TitleProps, type TitleSize, Vector4DeleteButton, Vector4Display, type Vector4Value, WorldPositionGotoButton, WorldPositionSetButton, useMissingItemsAudit, useModal, useModalActions, useNavigation, useNavigationStore };
|
|
@@ -1061,4 +1061,35 @@ type ScenarioSelectProps = Omit<SelectProps, "data" | "value" | "onChange"> & {
|
|
|
1061
1061
|
};
|
|
1062
1062
|
declare function ScenarioSelect({ value, onChange, label, size, searchable, clearable, ...rest }: ScenarioSelectProps): react_jsx_runtime.JSX.Element;
|
|
1063
1063
|
|
|
1064
|
-
|
|
1064
|
+
type DiscordRole = {
|
|
1065
|
+
id: string;
|
|
1066
|
+
name: string;
|
|
1067
|
+
color: number;
|
|
1068
|
+
position?: number;
|
|
1069
|
+
};
|
|
1070
|
+
type SharedProps = {
|
|
1071
|
+
/** NUI callback name registered by the consumer that returns ListResponse. */
|
|
1072
|
+
endpoint: string;
|
|
1073
|
+
/** Optional label / size / placeholder forwarded to the underlying Mantine Select. */
|
|
1074
|
+
label?: React.ReactNode;
|
|
1075
|
+
size?: SelectProps["size"];
|
|
1076
|
+
placeholder?: string;
|
|
1077
|
+
disabled?: boolean;
|
|
1078
|
+
/** Style props applied to the wrapping Select/MultiSelect. */
|
|
1079
|
+
style?: React.CSSProperties;
|
|
1080
|
+
styles?: SelectProps["styles"];
|
|
1081
|
+
};
|
|
1082
|
+
type SingleProps = SharedProps & {
|
|
1083
|
+
multi?: false;
|
|
1084
|
+
value: string | null;
|
|
1085
|
+
onChange: (id: string | null) => void;
|
|
1086
|
+
};
|
|
1087
|
+
type MultiProps = SharedProps & {
|
|
1088
|
+
multi: true;
|
|
1089
|
+
value: string[];
|
|
1090
|
+
onChange: (ids: string[]) => void;
|
|
1091
|
+
};
|
|
1092
|
+
type DiscordRoleSelectProps = SingleProps | MultiProps;
|
|
1093
|
+
declare function DiscordRoleSelect(props: DiscordRoleSelectProps): react_jsx_runtime.JSX.Element;
|
|
1094
|
+
|
|
1095
|
+
export { AdminPageTitle, type AdminPageTitleProps, AnimPostFxSelect, type AnimPostFxSelectProps, AsyncSaveButton, BlipColorSelect, type BlipColorSelectProps, BlipDisplaySelect, type BlipDisplaySelectProps, BlipIconSelect, type BlipIconSelectProps, BorderedIcon, type BorderedIconProps, type ButtonProps, ConfigPanel, type ConfigPanelProps, ConfirmModal, type ConfirmModalProps, ControlMultiSelect, type ControlMultiSelectProps, ControlSelect, type ControlSelectProps, Counter, type DiscordRole, DiscordRoleSelect, type DiscordRoleSelectProps, type FiveMControls, FiveMKeyBindInput, FloatingParticles, type FloatingParticlesProps, GroupName, type GroupNameProps, GroupRank, type GroupRankProps, GroupSelect, type GroupSelectProps, type GroupType, type GroupValue, InfoBox, type InfoBoxProps, InputContainer, type InputContainerProps, LevelBanner, LevelPanel, MissingItemsBanner, Modal, ModalContext, type ModalProps, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, type NavItem, NavigationContext, NavigationProvider, type NavigationStore, type ParticleState, PositionPicker, type PositionPickerProps, type ProgressProps, type Prompt, type PromptButton, PromptModal, ScenarioSelect, type ScenarioSelectProps, type SegmentProps, SegmentedControl, type SegmentedControlProps, SegmentedProgress, SelectItem, type SelectItemProps, type StoreModalProps, SwitchPanel, type SwitchPanelProps, TestBed, type TestBedItem, type TestBedPlacement, type TestBedProps, ThemeOverrideSection, type ThemeOverrideSectionProps, type ThemeOverrideValue, Title, type TitleProps, type TitleSize, Vector4DeleteButton, Vector4Display, type Vector4Value, WorldPositionGotoButton, WorldPositionSetButton, useMissingItemsAudit, useModal, useModalActions, useNavigation, useNavigationStore };
|
package/dist/components/index.js
CHANGED
|
@@ -3084,11 +3084,11 @@ function ConfirmModal({
|
|
|
3084
3084
|
placeholder: confirmText,
|
|
3085
3085
|
value: typed,
|
|
3086
3086
|
onChange: (e) => setTyped(e.currentTarget.value),
|
|
3087
|
-
styles: (
|
|
3087
|
+
styles: (t2) => ({
|
|
3088
3088
|
input: {
|
|
3089
|
-
backgroundColor: alpha(
|
|
3089
|
+
backgroundColor: alpha(t2.colors.dark[7], 0.5),
|
|
3090
3090
|
border: `0.1vh solid ${alpha(
|
|
3091
|
-
typed === confirmText ? "#ef4444" :
|
|
3091
|
+
typed === confirmText ? "#ef4444" : t2.colors.dark[5],
|
|
3092
3092
|
0.5
|
|
3093
3093
|
)}`,
|
|
3094
3094
|
color: "rgba(255,255,255,0.85)",
|
|
@@ -6197,7 +6197,183 @@ function ScenarioSelect({
|
|
|
6197
6197
|
}
|
|
6198
6198
|
);
|
|
6199
6199
|
}
|
|
6200
|
+
var t = (key, fallback) => {
|
|
6201
|
+
const v = locale(key);
|
|
6202
|
+
return v === key ? fallback : v;
|
|
6203
|
+
};
|
|
6204
|
+
function decimalToHex(color) {
|
|
6205
|
+
if (!color || color === 0) return null;
|
|
6206
|
+
return "#" + color.toString(16).padStart(6, "0");
|
|
6207
|
+
}
|
|
6208
|
+
function RoleOption({ role }) {
|
|
6209
|
+
const swatch = decimalToHex(role.color) || "rgba(255,255,255,0.25)";
|
|
6210
|
+
return /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "0.6vh", children: [
|
|
6211
|
+
/* @__PURE__ */ jsx(
|
|
6212
|
+
"div",
|
|
6213
|
+
{
|
|
6214
|
+
style: {
|
|
6215
|
+
width: "1vh",
|
|
6216
|
+
height: "1vh",
|
|
6217
|
+
borderRadius: "50%",
|
|
6218
|
+
background: swatch,
|
|
6219
|
+
flexShrink: 0,
|
|
6220
|
+
boxShadow: role.color ? `0 0 0.4vh ${swatch}` : void 0
|
|
6221
|
+
}
|
|
6222
|
+
}
|
|
6223
|
+
),
|
|
6224
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "rgba(255,255,255,0.9)", children: role.name })
|
|
6225
|
+
] });
|
|
6226
|
+
}
|
|
6227
|
+
var NOT_CONFIGURED_TINT = "rgba(255,184,0,0.35)";
|
|
6228
|
+
var NOT_CONFIGURED_FILL = "rgba(255,184,0,0.05)";
|
|
6229
|
+
function DiscordRoleSelect(props) {
|
|
6230
|
+
const { endpoint, label, size = "xs", placeholder, disabled, style, styles } = props;
|
|
6231
|
+
const [roles, setRoles] = useState(null);
|
|
6232
|
+
const [loading, setLoading] = useState(false);
|
|
6233
|
+
const [errorCode, setErrorCode] = useState(null);
|
|
6234
|
+
const refresh = async () => {
|
|
6235
|
+
setLoading(true);
|
|
6236
|
+
try {
|
|
6237
|
+
const res = await fetchNui(endpoint, {}, {
|
|
6238
|
+
// Browser dev fallback so the component renders something useful
|
|
6239
|
+
// outside FiveM.
|
|
6240
|
+
ok: true,
|
|
6241
|
+
roles: [
|
|
6242
|
+
{ id: "1", name: "Admin", color: 15548997, position: 5 },
|
|
6243
|
+
{ id: "2", name: "VIP Gold", color: 16426522, position: 4 },
|
|
6244
|
+
{ id: "3", name: "Member", color: 5763719, position: 3 },
|
|
6245
|
+
{ id: "4", name: "Guest", color: 0, position: 2 }
|
|
6246
|
+
]
|
|
6247
|
+
});
|
|
6248
|
+
if (res?.ok) {
|
|
6249
|
+
setRoles(res.roles ?? []);
|
|
6250
|
+
setErrorCode(null);
|
|
6251
|
+
} else {
|
|
6252
|
+
setRoles(null);
|
|
6253
|
+
setErrorCode(res?._error || "FetchFailed");
|
|
6254
|
+
}
|
|
6255
|
+
} finally {
|
|
6256
|
+
setLoading(false);
|
|
6257
|
+
}
|
|
6258
|
+
};
|
|
6259
|
+
useEffect(() => {
|
|
6260
|
+
refresh();
|
|
6261
|
+
}, [endpoint]);
|
|
6262
|
+
const rolesById = useMemo(() => {
|
|
6263
|
+
const map = {};
|
|
6264
|
+
for (const r of roles ?? []) map[r.id] = r;
|
|
6265
|
+
return map;
|
|
6266
|
+
}, [roles]);
|
|
6267
|
+
if (errorCode === "NotConfigured") {
|
|
6268
|
+
const notConfiguredPlaceholder = t(
|
|
6269
|
+
"DiscordNotConfigured",
|
|
6270
|
+
"Not configured \u2014 set in /dirk_lib"
|
|
6271
|
+
);
|
|
6272
|
+
const notConfiguredStyles = {
|
|
6273
|
+
...styles,
|
|
6274
|
+
input: {
|
|
6275
|
+
...styles?.input ?? {},
|
|
6276
|
+
borderColor: NOT_CONFIGURED_TINT,
|
|
6277
|
+
backgroundColor: NOT_CONFIGURED_FILL
|
|
6278
|
+
}
|
|
6279
|
+
};
|
|
6280
|
+
const warnIcon = /* @__PURE__ */ jsx(AlertTriangle, { size: "1.2vh", color: NOT_CONFIGURED_TINT.replace(/0\.35\)$/, "0.85)") });
|
|
6281
|
+
if (props.multi) {
|
|
6282
|
+
return /* @__PURE__ */ jsx(
|
|
6283
|
+
MultiSelect,
|
|
6284
|
+
{
|
|
6285
|
+
label,
|
|
6286
|
+
size,
|
|
6287
|
+
placeholder: notConfiguredPlaceholder,
|
|
6288
|
+
data: [],
|
|
6289
|
+
value: [],
|
|
6290
|
+
onChange: () => {
|
|
6291
|
+
},
|
|
6292
|
+
disabled: true,
|
|
6293
|
+
rightSection: warnIcon,
|
|
6294
|
+
style,
|
|
6295
|
+
styles: notConfiguredStyles
|
|
6296
|
+
}
|
|
6297
|
+
);
|
|
6298
|
+
}
|
|
6299
|
+
return /* @__PURE__ */ jsx(
|
|
6300
|
+
Select,
|
|
6301
|
+
{
|
|
6302
|
+
label,
|
|
6303
|
+
size,
|
|
6304
|
+
placeholder: notConfiguredPlaceholder,
|
|
6305
|
+
data: [],
|
|
6306
|
+
value: null,
|
|
6307
|
+
onChange: () => {
|
|
6308
|
+
},
|
|
6309
|
+
disabled: true,
|
|
6310
|
+
rightSection: warnIcon,
|
|
6311
|
+
style,
|
|
6312
|
+
styles: notConfiguredStyles
|
|
6313
|
+
}
|
|
6314
|
+
);
|
|
6315
|
+
}
|
|
6316
|
+
const data = (roles ?? []).map((r) => ({
|
|
6317
|
+
value: r.id,
|
|
6318
|
+
label: r.name
|
|
6319
|
+
}));
|
|
6320
|
+
const renderOption = ({ option }) => {
|
|
6321
|
+
const role = rolesById[option.value];
|
|
6322
|
+
return role ? /* @__PURE__ */ jsx(RoleOption, { role }) : /* @__PURE__ */ jsx(Text, { size: "xs", children: option.label });
|
|
6323
|
+
};
|
|
6324
|
+
const refreshButton = /* @__PURE__ */ jsx(
|
|
6325
|
+
ActionIcon,
|
|
6326
|
+
{
|
|
6327
|
+
size: "xs",
|
|
6328
|
+
variant: "subtle",
|
|
6329
|
+
onClick: refresh,
|
|
6330
|
+
title: t("Refresh", "Refresh"),
|
|
6331
|
+
loading,
|
|
6332
|
+
children: /* @__PURE__ */ jsx(RefreshCw, { size: "1.2vh" })
|
|
6333
|
+
}
|
|
6334
|
+
);
|
|
6335
|
+
if (props.multi) {
|
|
6336
|
+
return /* @__PURE__ */ jsx(
|
|
6337
|
+
MultiSelect,
|
|
6338
|
+
{
|
|
6339
|
+
label,
|
|
6340
|
+
size,
|
|
6341
|
+
placeholder: placeholder || t("PickRoles", "Pick roles..."),
|
|
6342
|
+
data,
|
|
6343
|
+
value: props.value || [],
|
|
6344
|
+
onChange: (ids) => props.onChange(ids),
|
|
6345
|
+
renderOption,
|
|
6346
|
+
searchable: true,
|
|
6347
|
+
clearable: true,
|
|
6348
|
+
disabled: disabled || loading && !roles,
|
|
6349
|
+
rightSection: refreshButton,
|
|
6350
|
+
style,
|
|
6351
|
+
styles,
|
|
6352
|
+
nothingFoundMessage: errorCode ? `${t("Error", "Error")} (${errorCode})` : t("NoRoles", "No roles found")
|
|
6353
|
+
}
|
|
6354
|
+
);
|
|
6355
|
+
}
|
|
6356
|
+
return /* @__PURE__ */ jsx(
|
|
6357
|
+
Select,
|
|
6358
|
+
{
|
|
6359
|
+
label,
|
|
6360
|
+
size,
|
|
6361
|
+
placeholder: placeholder || t("PickRole", "Pick a role..."),
|
|
6362
|
+
data,
|
|
6363
|
+
value: props.value || null,
|
|
6364
|
+
onChange: (id) => props.onChange(id),
|
|
6365
|
+
renderOption,
|
|
6366
|
+
searchable: true,
|
|
6367
|
+
clearable: true,
|
|
6368
|
+
disabled: disabled || loading && !roles,
|
|
6369
|
+
rightSection: refreshButton,
|
|
6370
|
+
style,
|
|
6371
|
+
styles,
|
|
6372
|
+
nothingFoundMessage: errorCode ? `${t("Error", "Error")} (${errorCode})` : t("NoRoles", "No roles found")
|
|
6373
|
+
}
|
|
6374
|
+
);
|
|
6375
|
+
}
|
|
6200
6376
|
|
|
6201
|
-
export { AdminPageTitle, AnimPostFxSelect, AsyncSaveButton, BlipColorSelect, BlipDisplaySelect, BlipIconSelect, BorderedIcon, ConfigPanel, ConfirmModal, ControlMultiSelect, ControlSelect, Counter, FiveMKeyBindInput, FloatingParticles, GroupName, GroupRank, GroupSelect, InfoBox, InputContainer, LevelBanner, LevelPanel, MissingItemsBanner, Modal, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, PositionPicker, PromptModal, ScenarioSelect, SegmentedControl, SegmentedProgress, SelectItem, SwitchPanel, TestBed, ThemeOverrideSection, Title, Vector4DeleteButton, Vector4Display, WorldPositionGotoButton, WorldPositionSetButton, useMissingItemsAudit, useModal, useModalActions, useNavigation, useNavigationStore };
|
|
6377
|
+
export { AdminPageTitle, AnimPostFxSelect, AsyncSaveButton, BlipColorSelect, BlipDisplaySelect, BlipIconSelect, BorderedIcon, ConfigPanel, ConfirmModal, ControlMultiSelect, ControlSelect, Counter, DiscordRoleSelect, FiveMKeyBindInput, FloatingParticles, GroupName, GroupRank, GroupSelect, InfoBox, InputContainer, LevelBanner, LevelPanel, MissingItemsBanner, Modal, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, PositionPicker, PromptModal, ScenarioSelect, SegmentedControl, SegmentedProgress, SelectItem, SwitchPanel, TestBed, ThemeOverrideSection, Title, Vector4DeleteButton, Vector4Display, WorldPositionGotoButton, WorldPositionSetButton, useMissingItemsAudit, useModal, useModalActions, useNavigation, useNavigationStore };
|
|
6202
6378
|
//# sourceMappingURL=index.js.map
|
|
6203
6379
|
//# sourceMappingURL=index.js.map
|