dirk-cfx-react 1.1.65 → 1.1.66
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 +105 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +39 -1
- package/dist/components/index.d.ts +39 -1
- package/dist/components/index.js +103 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.cjs +178 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +108 -3
- package/dist/index.js.map +1 -1
- package/dist/utils/index.cjs +19 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +29 -1
- package/dist/utils/index.d.ts +29 -1
- package/dist/utils/index.js +18 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1360,6 +1360,20 @@ registerInitialFetch("FETCH_ALL_ITEMS", null, {
|
|
|
1360
1360
|
useItems.setState(fetchedItems);
|
|
1361
1361
|
}).catch(() => {
|
|
1362
1362
|
});
|
|
1363
|
+
var useFrameworkGroups = zustand.create(() => ({
|
|
1364
|
+
jobs: [],
|
|
1365
|
+
gangs: [],
|
|
1366
|
+
loaded: false
|
|
1367
|
+
}));
|
|
1368
|
+
registerInitialFetch("GET_FRAMEWORK_GROUPS", void 0).then((data) => {
|
|
1369
|
+
useFrameworkGroups.setState({
|
|
1370
|
+
jobs: Array.isArray(data?.jobs) ? data.jobs : [],
|
|
1371
|
+
gangs: Array.isArray(data?.gangs) ? data.gangs : [],
|
|
1372
|
+
loaded: true
|
|
1373
|
+
});
|
|
1374
|
+
}).catch(() => {
|
|
1375
|
+
useFrameworkGroups.setState({ loaded: true });
|
|
1376
|
+
});
|
|
1363
1377
|
|
|
1364
1378
|
// src/utils/inputMapper.ts
|
|
1365
1379
|
var INPUT_MAPPER_PRIMARY_OPTIONS = [
|
|
@@ -4261,6 +4275,94 @@ function PickerButton({
|
|
|
4261
4275
|
}
|
|
4262
4276
|
) });
|
|
4263
4277
|
}
|
|
4278
|
+
var GroupSelectContext = react.createContext(null);
|
|
4279
|
+
function GroupSelect({
|
|
4280
|
+
value,
|
|
4281
|
+
onChange,
|
|
4282
|
+
type,
|
|
4283
|
+
children,
|
|
4284
|
+
style
|
|
4285
|
+
}) {
|
|
4286
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GroupSelectContext.Provider, { value: { value, onChange, type }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: "0.4vh", ...style }, children }) });
|
|
4287
|
+
}
|
|
4288
|
+
function filterByType(jobs, gangs, type) {
|
|
4289
|
+
if (type === "job") return jobs;
|
|
4290
|
+
if (type === "gang") return gangs;
|
|
4291
|
+
return [...jobs, ...gangs];
|
|
4292
|
+
}
|
|
4293
|
+
function GroupName(props) {
|
|
4294
|
+
const ctx = react.useContext(GroupSelectContext);
|
|
4295
|
+
const jobs = useFrameworkGroups((s) => s.jobs);
|
|
4296
|
+
const gangs = useFrameworkGroups((s) => s.gangs);
|
|
4297
|
+
const inCompound = ctx !== null;
|
|
4298
|
+
const currentValue = inCompound ? ctx.value.name : props.value;
|
|
4299
|
+
const filterType = inCompound ? ctx.type : props.type;
|
|
4300
|
+
const list = filterByType(jobs, gangs, filterType);
|
|
4301
|
+
const data = filterType === void 0 ? [
|
|
4302
|
+
{ group: locale("Jobs") || "Jobs", items: jobs.map((g) => ({ value: g.name, label: g.label })) },
|
|
4303
|
+
{ group: locale("Gangs") || "Gangs", items: gangs.map((g) => ({ value: g.name, label: g.label })) }
|
|
4304
|
+
] : list.map((g) => ({ value: g.name, label: g.label }));
|
|
4305
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4306
|
+
core.Select,
|
|
4307
|
+
{
|
|
4308
|
+
label: props.label,
|
|
4309
|
+
description: props.description,
|
|
4310
|
+
placeholder: props.placeholder ?? (locale("SelectGroup") || "Select\u2026"),
|
|
4311
|
+
size: props.size ?? "xs",
|
|
4312
|
+
disabled: props.disabled,
|
|
4313
|
+
style: props.style,
|
|
4314
|
+
data,
|
|
4315
|
+
value: currentValue ?? null,
|
|
4316
|
+
searchable: true,
|
|
4317
|
+
onChange: (v) => {
|
|
4318
|
+
const name = v ?? "";
|
|
4319
|
+
if (inCompound) {
|
|
4320
|
+
ctx.onChange({ name: name || void 0, grade: void 0 });
|
|
4321
|
+
} else if (props.onChange) {
|
|
4322
|
+
props.onChange(name);
|
|
4323
|
+
}
|
|
4324
|
+
},
|
|
4325
|
+
allowDeselect: false
|
|
4326
|
+
}
|
|
4327
|
+
);
|
|
4328
|
+
}
|
|
4329
|
+
function GroupRank(props) {
|
|
4330
|
+
const ctx = react.useContext(GroupSelectContext);
|
|
4331
|
+
if (ctx === null) {
|
|
4332
|
+
throw new Error("<GroupRank> must be a child of <GroupSelect>");
|
|
4333
|
+
}
|
|
4334
|
+
const jobs = useFrameworkGroups((s) => s.jobs);
|
|
4335
|
+
const gangs = useFrameworkGroups((s) => s.gangs);
|
|
4336
|
+
const all = [...jobs, ...gangs];
|
|
4337
|
+
const selectedGroup = all.find((g) => g.name === ctx.value.name) ?? null;
|
|
4338
|
+
const grades = selectedGroup?.grades ?? [];
|
|
4339
|
+
const data = grades.map((g) => ({
|
|
4340
|
+
value: String(g.grade),
|
|
4341
|
+
label: `${g.grade} \u2014 ${g.label || g.name}${g.isBoss ? " (boss)" : ""}`
|
|
4342
|
+
}));
|
|
4343
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4344
|
+
core.Select,
|
|
4345
|
+
{
|
|
4346
|
+
label: props.label,
|
|
4347
|
+
description: props.description,
|
|
4348
|
+
placeholder: props.placeholder ?? (locale("SelectGrade") || "Select grade\u2026"),
|
|
4349
|
+
size: props.size ?? "xs",
|
|
4350
|
+
style: props.style,
|
|
4351
|
+
data,
|
|
4352
|
+
value: ctx.value.grade != null ? String(ctx.value.grade) : null,
|
|
4353
|
+
onChange: (v) => {
|
|
4354
|
+
ctx.onChange({
|
|
4355
|
+
...ctx.value,
|
|
4356
|
+
grade: v != null ? Number(v) : void 0
|
|
4357
|
+
});
|
|
4358
|
+
},
|
|
4359
|
+
disabled: !selectedGroup || grades.length === 0,
|
|
4360
|
+
allowDeselect: false
|
|
4361
|
+
}
|
|
4362
|
+
);
|
|
4363
|
+
}
|
|
4364
|
+
GroupSelect.Name = GroupName;
|
|
4365
|
+
GroupSelect.Rank = GroupRank;
|
|
4264
4366
|
var KeyBindContext = react.createContext(null);
|
|
4265
4367
|
function useKeyBindContext() {
|
|
4266
4368
|
const ctx = react.useContext(KeyBindContext);
|
|
@@ -4555,6 +4657,9 @@ exports.ConfirmModal = ConfirmModal;
|
|
|
4555
4657
|
exports.Counter = Counter;
|
|
4556
4658
|
exports.FiveMKeyBindInput = FiveMKeyBindInput;
|
|
4557
4659
|
exports.FloatingParticles = FloatingParticles;
|
|
4660
|
+
exports.GroupName = GroupName;
|
|
4661
|
+
exports.GroupRank = GroupRank;
|
|
4662
|
+
exports.GroupSelect = GroupSelect;
|
|
4558
4663
|
exports.InfoBox = InfoBox;
|
|
4559
4664
|
exports.InputContainer = InputContainer;
|
|
4560
4665
|
exports.LevelBanner = LevelBanner;
|