dirk-cfx-react 1.1.85 → 1.1.87

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/index.cjs CHANGED
@@ -1253,11 +1253,11 @@ var colorNames = {
1253
1253
  Yellow: { r: 255, g: 255, b: 0 },
1254
1254
  YellowGreen: { r: 154, g: 205, b: 50 }
1255
1255
  };
1256
- function colorWithAlpha(color, alpha11) {
1256
+ function colorWithAlpha(color, alpha12) {
1257
1257
  const lowerCasedColor = color.toLowerCase();
1258
1258
  if (colorNames[lowerCasedColor]) {
1259
1259
  const rgb = colorNames[lowerCasedColor];
1260
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha11})`;
1260
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha12})`;
1261
1261
  }
1262
1262
  if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
1263
1263
  const hex = color.slice(1);
@@ -1265,12 +1265,12 @@ function colorWithAlpha(color, alpha11) {
1265
1265
  const r = bigint >> 16 & 255;
1266
1266
  const g = bigint >> 8 & 255;
1267
1267
  const b = bigint & 255;
1268
- return `rgba(${r}, ${g}, ${b}, ${alpha11})`;
1268
+ return `rgba(${r}, ${g}, ${b}, ${alpha12})`;
1269
1269
  }
1270
1270
  if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
1271
1271
  const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
1272
1272
  if (result) {
1273
- return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha11})`;
1273
+ return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha12})`;
1274
1274
  }
1275
1275
  }
1276
1276
  return color;
@@ -3703,11 +3703,11 @@ function ConfirmModal({
3703
3703
  placeholder: confirmText,
3704
3704
  value: typed,
3705
3705
  onChange: (e) => setTyped(e.currentTarget.value),
3706
- styles: (t2) => ({
3706
+ styles: (t3) => ({
3707
3707
  input: {
3708
- backgroundColor: core.alpha(t2.colors.dark[7], 0.5),
3708
+ backgroundColor: core.alpha(t3.colors.dark[7], 0.5),
3709
3709
  border: `0.1vh solid ${core.alpha(
3710
- typed === confirmText ? "#ef4444" : t2.colors.dark[5],
3710
+ typed === confirmText ? "#ef4444" : t3.colors.dark[5],
3711
3711
  0.5
3712
3712
  )}`,
3713
3713
  color: "rgba(255,255,255,0.85)",
@@ -7118,6 +7118,156 @@ function DiscordRoleSelect(props) {
7118
7118
  }
7119
7119
  );
7120
7120
  }
7121
+ var t2 = (key, fallback) => {
7122
+ const v = locale(key);
7123
+ return v === key ? fallback : v;
7124
+ };
7125
+ var FRAMEWORK_HINTS = {
7126
+ "es_extended": "from ESX Config.Accounts",
7127
+ "qb-core": "from QBCore Money.MoneyTypes",
7128
+ "qbx_core": "from QBox player session (or default trio if no one is online) \u2014 log in once to capture custom accounts",
7129
+ "nd-framework": "ND_Core only supports cash + bank",
7130
+ "unknown": "no framework detected \u2014 type account names manually"
7131
+ };
7132
+ function AccountOption({ account }) {
7133
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: "0", children: [
7134
+ /* @__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 }),
7135
+ account.label && /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xxs", c: "rgba(255,255,255,0.4)", children: account.label })
7136
+ ] });
7137
+ }
7138
+ function FrameworkHint({ framework }) {
7139
+ const theme2 = core.useMantineTheme();
7140
+ if (!framework) return null;
7141
+ const hintKey = `AccountFrameworkHint_${framework}`;
7142
+ const text = t2(hintKey, FRAMEWORK_HINTS[framework] || FRAMEWORK_HINTS.unknown);
7143
+ return /* @__PURE__ */ jsxRuntime.jsxs(
7144
+ core.Flex,
7145
+ {
7146
+ align: "center",
7147
+ gap: "xs",
7148
+ px: "xs",
7149
+ py: "0.3vh",
7150
+ style: {
7151
+ background: core.alpha(theme2.colors.dark[5], 0.4),
7152
+ border: "0.1vh solid rgba(255,255,255,0.04)",
7153
+ borderRadius: theme2.radius.xs
7154
+ },
7155
+ children: [
7156
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xxs", ff: "Akrobat Bold", c: "rgba(255,255,255,0.45)", tt: "uppercase", lts: "0.04em", children: framework }),
7157
+ /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xxs", ff: "Akrobat", c: "rgba(255,255,255,0.35)", style: { flex: 1 }, lineClamp: 2, children: text })
7158
+ ]
7159
+ }
7160
+ );
7161
+ }
7162
+ function AccountSelect(props) {
7163
+ const { endpoint, label: label2, size = "xs", placeholder, disabled, style, styles, hideFrameworkHint } = props;
7164
+ const [accounts, setAccounts] = React6.useState(null);
7165
+ const [framework, setFramework] = React6.useState(void 0);
7166
+ const [loading, setLoading] = React6.useState(false);
7167
+ const refresh = async () => {
7168
+ setLoading(true);
7169
+ try {
7170
+ const res = await fetchNui(endpoint, {}, {
7171
+ // Browser dev fallback. Shows a recognisable ESX-style list.
7172
+ ok: true,
7173
+ framework: "es_extended",
7174
+ accounts: [
7175
+ { name: "money", label: "Cash" },
7176
+ { name: "bank", label: "Bank" },
7177
+ { name: "black_money", label: "Dirty Money" }
7178
+ ]
7179
+ });
7180
+ if (res?.ok) {
7181
+ setAccounts(res.accounts ?? []);
7182
+ setFramework(res.framework);
7183
+ } else {
7184
+ setAccounts([]);
7185
+ setFramework(res?.framework);
7186
+ }
7187
+ } finally {
7188
+ setLoading(false);
7189
+ }
7190
+ };
7191
+ React6.useEffect(() => {
7192
+ refresh();
7193
+ }, [endpoint]);
7194
+ const accountsByName = React6.useMemo(() => {
7195
+ const map = {};
7196
+ for (const a of accounts ?? []) map[a.name] = a;
7197
+ if (props.multi) {
7198
+ for (const n of props.value ?? []) {
7199
+ if (n && !map[n]) map[n] = { name: n };
7200
+ }
7201
+ } else if (props.value && !map[props.value]) {
7202
+ map[props.value] = { name: props.value };
7203
+ }
7204
+ return map;
7205
+ }, [accounts, props.multi, props.multi ? props.value?.join(",") : props.value]);
7206
+ const data = Object.values(accountsByName).map((a) => ({
7207
+ value: a.name,
7208
+ label: a.label ? `${a.name} \u2014 ${a.label}` : a.name
7209
+ }));
7210
+ const renderOption = ({ option }) => {
7211
+ const acc = accountsByName[option.value];
7212
+ return acc ? /* @__PURE__ */ jsxRuntime.jsx(AccountOption, { account: acc }) : /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xs", children: option.label });
7213
+ };
7214
+ const refreshButton = /* @__PURE__ */ jsxRuntime.jsx(
7215
+ core.ActionIcon,
7216
+ {
7217
+ size: "xs",
7218
+ variant: "subtle",
7219
+ onMouseDown: (e) => {
7220
+ e.stopPropagation();
7221
+ },
7222
+ onClick: (e) => {
7223
+ e.stopPropagation();
7224
+ refresh();
7225
+ },
7226
+ title: t2("Refresh", "Refresh"),
7227
+ loading,
7228
+ "aria-label": t2("Refresh", "Refresh"),
7229
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { size: "1.2vh" })
7230
+ }
7231
+ );
7232
+ const sharedSelectProps = {
7233
+ label: label2,
7234
+ size,
7235
+ data,
7236
+ searchable: true,
7237
+ clearable: true,
7238
+ disabled: disabled || loading && !accounts,
7239
+ rightSection: refreshButton,
7240
+ rightSectionPointerEvents: "all",
7241
+ style,
7242
+ nothingFoundMessage: t2("NoAccounts", "No accounts available")
7243
+ };
7244
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: "0.3vh", style, children: [
7245
+ props.multi ? /* @__PURE__ */ jsxRuntime.jsx(
7246
+ core.MultiSelect,
7247
+ {
7248
+ ...sharedSelectProps,
7249
+ placeholder: placeholder || t2("PickAccounts", "Pick accounts (or type custom)..."),
7250
+ value: props.value || [],
7251
+ onChange: (names) => props.onChange(names),
7252
+ renderOption,
7253
+ searchable: true,
7254
+ hidePickedOptions: true,
7255
+ styles
7256
+ }
7257
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
7258
+ core.Select,
7259
+ {
7260
+ ...sharedSelectProps,
7261
+ placeholder: placeholder || t2("PickAccount", "Pick an account..."),
7262
+ value: props.value || null,
7263
+ onChange: (name) => props.onChange(name),
7264
+ renderOption,
7265
+ styles
7266
+ }
7267
+ ),
7268
+ !hideFrameworkHint && /* @__PURE__ */ jsxRuntime.jsx(FrameworkHint, { framework })
7269
+ ] });
7270
+ }
7121
7271
  function useTornEdges() {
7122
7272
  const game = useSettings((state) => state.game);
7123
7273
  return game === "rdr3" ? "torn-edge-wrapper" : "";
@@ -7478,6 +7628,7 @@ var Vector4Schema = zod.z.object({
7478
7628
  w: zod.z.number()
7479
7629
  });
7480
7630
 
7631
+ exports.AccountSelect = AccountSelect;
7481
7632
  exports.AdminPageTitle = AdminPageTitle;
7482
7633
  exports.AnimPostFxSelect = AnimPostFxSelect;
7483
7634
  exports.AsyncSaveButton = AsyncSaveButton;