dirk-cfx-react 1.1.84 → 1.1.86

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.
@@ -1237,11 +1237,11 @@ var colorNames = {
1237
1237
  Yellow: { r: 255, g: 255, b: 0 },
1238
1238
  YellowGreen: { r: 154, g: 205, b: 50 }
1239
1239
  };
1240
- function colorWithAlpha(color, alpha11) {
1240
+ function colorWithAlpha(color, alpha12) {
1241
1241
  const lowerCasedColor = color.toLowerCase();
1242
1242
  if (colorNames[lowerCasedColor]) {
1243
1243
  const rgb = colorNames[lowerCasedColor];
1244
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha11})`;
1244
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha12})`;
1245
1245
  }
1246
1246
  if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
1247
1247
  const hex = color.slice(1);
@@ -1249,12 +1249,12 @@ function colorWithAlpha(color, alpha11) {
1249
1249
  const r = bigint >> 16 & 255;
1250
1250
  const g = bigint >> 8 & 255;
1251
1251
  const b = bigint & 255;
1252
- return `rgba(${r}, ${g}, ${b}, ${alpha11})`;
1252
+ return `rgba(${r}, ${g}, ${b}, ${alpha12})`;
1253
1253
  }
1254
1254
  if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
1255
1255
  const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
1256
1256
  if (result) {
1257
- return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha11})`;
1257
+ return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha12})`;
1258
1258
  }
1259
1259
  }
1260
1260
  return color;
@@ -3091,11 +3091,11 @@ function ConfirmModal({
3091
3091
  placeholder: confirmText,
3092
3092
  value: typed,
3093
3093
  onChange: (e) => setTyped(e.currentTarget.value),
3094
- styles: (t2) => ({
3094
+ styles: (t3) => ({
3095
3095
  input: {
3096
- backgroundColor: core.alpha(t2.colors.dark[7], 0.5),
3096
+ backgroundColor: core.alpha(t3.colors.dark[7], 0.5),
3097
3097
  border: `0.1vh solid ${core.alpha(
3098
- typed === confirmText ? "#ef4444" : t2.colors.dark[5],
3098
+ typed === confirmText ? "#ef4444" : t3.colors.dark[5],
3099
3099
  0.5
3100
3100
  )}`,
3101
3101
  color: "rgba(255,255,255,0.85)",
@@ -6333,9 +6333,16 @@ function DiscordRoleSelect(props) {
6333
6333
  {
6334
6334
  size: "xs",
6335
6335
  variant: "subtle",
6336
- onClick: refresh,
6336
+ onMouseDown: (e) => {
6337
+ e.stopPropagation();
6338
+ },
6339
+ onClick: (e) => {
6340
+ e.stopPropagation();
6341
+ refresh();
6342
+ },
6337
6343
  title: t("Refresh", "Refresh"),
6338
6344
  loading,
6345
+ "aria-label": t("Refresh", "Refresh"),
6339
6346
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { size: "1.2vh" })
6340
6347
  }
6341
6348
  );
@@ -6354,6 +6361,7 @@ function DiscordRoleSelect(props) {
6354
6361
  clearable: true,
6355
6362
  disabled: disabled || loading && !roles,
6356
6363
  rightSection: refreshButton,
6364
+ rightSectionPointerEvents: "all",
6357
6365
  style,
6358
6366
  styles,
6359
6367
  nothingFoundMessage: errorCode ? `${t("Error", "Error")} (${errorCode})` : t("NoRoles", "No roles found")
@@ -6374,13 +6382,165 @@ function DiscordRoleSelect(props) {
6374
6382
  clearable: true,
6375
6383
  disabled: disabled || loading && !roles,
6376
6384
  rightSection: refreshButton,
6385
+ rightSectionPointerEvents: "all",
6377
6386
  style,
6378
6387
  styles,
6379
6388
  nothingFoundMessage: errorCode ? `${t("Error", "Error")} (${errorCode})` : t("NoRoles", "No roles found")
6380
6389
  }
6381
6390
  );
6382
6391
  }
6392
+ var t2 = (key, fallback) => {
6393
+ const v = locale(key);
6394
+ return v === key ? fallback : v;
6395
+ };
6396
+ var FRAMEWORK_HINTS = {
6397
+ "es_extended": "from ESX Config.Accounts",
6398
+ "qb-core": "from QBCore Money.MoneyTypes",
6399
+ "qbx_core": "default QBox trio (cash/bank/crypto) \u2014 server may have custom names, add them manually",
6400
+ "nd-framework": "ND_Core only supports cash + bank",
6401
+ "unknown": "no framework detected \u2014 type account names manually"
6402
+ };
6403
+ function AccountOption({ account }) {
6404
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: "0", children: [
6405
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xs", c: "rgba(255,255,255,0.9)", ff: "Akrobat Bold", tt: "uppercase", lts: "0.04em", children: account.name }),
6406
+ account.label && /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xxs", c: "rgba(255,255,255,0.4)", children: account.label })
6407
+ ] });
6408
+ }
6409
+ function FrameworkHint({ framework }) {
6410
+ const theme = core.useMantineTheme();
6411
+ if (!framework) return null;
6412
+ const hintKey = `AccountFrameworkHint_${framework}`;
6413
+ const text = t2(hintKey, FRAMEWORK_HINTS[framework] || FRAMEWORK_HINTS.unknown);
6414
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6415
+ core.Flex,
6416
+ {
6417
+ align: "center",
6418
+ gap: "xs",
6419
+ px: "xs",
6420
+ py: "0.3vh",
6421
+ style: {
6422
+ background: core.alpha(theme.colors.dark[5], 0.4),
6423
+ border: "0.1vh solid rgba(255,255,255,0.04)",
6424
+ borderRadius: theme.radius.xs
6425
+ },
6426
+ children: [
6427
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xxs", ff: "Akrobat Bold", c: "rgba(255,255,255,0.45)", tt: "uppercase", lts: "0.04em", children: framework }),
6428
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xxs", ff: "Akrobat", c: "rgba(255,255,255,0.35)", style: { flex: 1 }, lineClamp: 2, children: text })
6429
+ ]
6430
+ }
6431
+ );
6432
+ }
6433
+ function AccountSelect(props) {
6434
+ const { endpoint, label, size = "xs", placeholder, disabled, style, styles, hideFrameworkHint } = props;
6435
+ const [accounts, setAccounts] = react.useState(null);
6436
+ const [framework, setFramework] = react.useState(void 0);
6437
+ const [loading, setLoading] = react.useState(false);
6438
+ const refresh = async () => {
6439
+ setLoading(true);
6440
+ try {
6441
+ const res = await fetchNui(endpoint, {}, {
6442
+ // Browser dev fallback. Shows a recognisable ESX-style list.
6443
+ ok: true,
6444
+ framework: "es_extended",
6445
+ accounts: [
6446
+ { name: "money", label: "Cash" },
6447
+ { name: "bank", label: "Bank" },
6448
+ { name: "black_money", label: "Dirty Money" }
6449
+ ]
6450
+ });
6451
+ if (res?.ok) {
6452
+ setAccounts(res.accounts ?? []);
6453
+ setFramework(res.framework);
6454
+ } else {
6455
+ setAccounts([]);
6456
+ setFramework(res?.framework);
6457
+ }
6458
+ } finally {
6459
+ setLoading(false);
6460
+ }
6461
+ };
6462
+ react.useEffect(() => {
6463
+ refresh();
6464
+ }, [endpoint]);
6465
+ const accountsByName = react.useMemo(() => {
6466
+ const map = {};
6467
+ for (const a of accounts ?? []) map[a.name] = a;
6468
+ if (props.multi) {
6469
+ for (const n of props.value ?? []) {
6470
+ if (n && !map[n]) map[n] = { name: n };
6471
+ }
6472
+ } else if (props.value && !map[props.value]) {
6473
+ map[props.value] = { name: props.value };
6474
+ }
6475
+ return map;
6476
+ }, [accounts, props.multi, props.multi ? props.value?.join(",") : props.value]);
6477
+ const data = Object.values(accountsByName).map((a) => ({
6478
+ value: a.name,
6479
+ label: a.label ? `${a.name} \u2014 ${a.label}` : a.name
6480
+ }));
6481
+ const renderOption = ({ option }) => {
6482
+ const acc = accountsByName[option.value];
6483
+ return acc ? /* @__PURE__ */ jsxRuntime.jsx(AccountOption, { account: acc }) : /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xs", children: option.label });
6484
+ };
6485
+ const refreshButton = /* @__PURE__ */ jsxRuntime.jsx(
6486
+ core.ActionIcon,
6487
+ {
6488
+ size: "xs",
6489
+ variant: "subtle",
6490
+ onMouseDown: (e) => {
6491
+ e.stopPropagation();
6492
+ },
6493
+ onClick: (e) => {
6494
+ e.stopPropagation();
6495
+ refresh();
6496
+ },
6497
+ title: t2("Refresh", "Refresh"),
6498
+ loading,
6499
+ "aria-label": t2("Refresh", "Refresh"),
6500
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { size: "1.2vh" })
6501
+ }
6502
+ );
6503
+ const sharedSelectProps = {
6504
+ label,
6505
+ size,
6506
+ data,
6507
+ searchable: true,
6508
+ clearable: true,
6509
+ disabled: disabled || loading && !accounts,
6510
+ rightSection: refreshButton,
6511
+ rightSectionPointerEvents: "all",
6512
+ style,
6513
+ nothingFoundMessage: t2("NoAccounts", "No accounts available")
6514
+ };
6515
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: "0.3vh", style, children: [
6516
+ props.multi ? /* @__PURE__ */ jsxRuntime.jsx(
6517
+ core.MultiSelect,
6518
+ {
6519
+ ...sharedSelectProps,
6520
+ placeholder: placeholder || t2("PickAccounts", "Pick accounts (or type custom)..."),
6521
+ value: props.value || [],
6522
+ onChange: (names) => props.onChange(names),
6523
+ renderOption,
6524
+ searchable: true,
6525
+ hidePickedOptions: true,
6526
+ styles
6527
+ }
6528
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
6529
+ core.Select,
6530
+ {
6531
+ ...sharedSelectProps,
6532
+ placeholder: placeholder || t2("PickAccount", "Pick an account..."),
6533
+ value: props.value || null,
6534
+ onChange: (name) => props.onChange(name),
6535
+ renderOption,
6536
+ styles
6537
+ }
6538
+ ),
6539
+ !hideFrameworkHint && /* @__PURE__ */ jsxRuntime.jsx(FrameworkHint, { framework })
6540
+ ] });
6541
+ }
6383
6542
 
6543
+ exports.AccountSelect = AccountSelect;
6384
6544
  exports.AdminPageTitle = AdminPageTitle;
6385
6545
  exports.AnimPostFxSelect = AnimPostFxSelect;
6386
6546
  exports.AsyncSaveButton = AsyncSaveButton;