dirk-cfx-react 1.1.65 → 1.1.67

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.
@@ -853,6 +853,44 @@ type PositionPickerProps = {
853
853
  };
854
854
  declare function PositionPicker(props: PositionPickerProps): react_jsx_runtime.JSX.Element;
855
855
 
856
+ type GroupValue = {
857
+ name?: string;
858
+ grade?: number;
859
+ };
860
+ type GroupType = "job" | "gang";
861
+ type GroupSelectProps = {
862
+ value: GroupValue;
863
+ onChange: (next: GroupValue) => void;
864
+ type?: GroupType;
865
+ children: React__default.ReactNode;
866
+ style?: React__default.CSSProperties;
867
+ };
868
+ declare function GroupSelect({ value, onChange, type, children, style, }: GroupSelectProps): react_jsx_runtime.JSX.Element;
869
+ declare namespace GroupSelect {
870
+ var Name: typeof GroupName;
871
+ var Rank: typeof GroupRank;
872
+ }
873
+ type GroupNameProps = {
874
+ value?: string;
875
+ onChange?: (name: string) => void;
876
+ type?: GroupType;
877
+ label?: string;
878
+ description?: string;
879
+ placeholder?: string;
880
+ size?: string;
881
+ disabled?: boolean;
882
+ style?: React__default.CSSProperties;
883
+ };
884
+ declare function GroupName(props: GroupNameProps): react_jsx_runtime.JSX.Element;
885
+ type GroupRankProps = {
886
+ label?: string;
887
+ description?: string;
888
+ placeholder?: string;
889
+ size?: string;
890
+ style?: React__default.CSSProperties;
891
+ };
892
+ declare function GroupRank(props: GroupRankProps): react_jsx_runtime.JSX.Element;
893
+
856
894
  type FiveMControls = {
857
895
  _type: string;
858
896
  _key: string;
@@ -907,4 +945,4 @@ interface TestBedProps {
907
945
  }
908
946
  declare function TestBed({ items, storageKey, disablePersistence, title, }: TestBedProps): react_jsx_runtime.JSX.Element | null;
909
947
 
910
- export { AdminPageTitle, type AdminPageTitleProps, AsyncSaveButton, BlipColorSelect, type BlipColorSelectProps, BlipDisplaySelect, type BlipDisplaySelectProps, BlipIconSelect, type BlipIconSelectProps, BorderedIcon, type BorderedIconProps, type ButtonProps, ConfigPanel, type ConfigPanelProps, ConfirmModal, type ConfirmModalProps, Counter, type FiveMControls, FiveMKeyBindInput, FloatingParticles, type FloatingParticlesProps, InfoBox, type InfoBoxProps, InputContainer, type InputContainerProps, LevelBanner, LevelPanel, 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, type SegmentProps, SegmentedControl, type SegmentedControlProps, SegmentedProgress, SelectItem, type SelectItemProps, type StoreModalProps, TestBed, type TestBedItem, type TestBedProps, Title, type TitleProps, type Vector4Value, useModal, useModalActions, useNavigation, useNavigationStore };
948
+ export { AdminPageTitle, type AdminPageTitleProps, AsyncSaveButton, BlipColorSelect, type BlipColorSelectProps, BlipDisplaySelect, type BlipDisplaySelectProps, BlipIconSelect, type BlipIconSelectProps, BorderedIcon, type BorderedIconProps, type ButtonProps, ConfigPanel, type ConfigPanelProps, ConfirmModal, type ConfirmModalProps, Counter, 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, 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, type SegmentProps, SegmentedControl, type SegmentedControlProps, SegmentedProgress, SelectItem, type SelectItemProps, type StoreModalProps, TestBed, type TestBedItem, type TestBedProps, Title, type TitleProps, type Vector4Value, useModal, useModalActions, useNavigation, useNavigationStore };
@@ -853,6 +853,44 @@ type PositionPickerProps = {
853
853
  };
854
854
  declare function PositionPicker(props: PositionPickerProps): react_jsx_runtime.JSX.Element;
855
855
 
856
+ type GroupValue = {
857
+ name?: string;
858
+ grade?: number;
859
+ };
860
+ type GroupType = "job" | "gang";
861
+ type GroupSelectProps = {
862
+ value: GroupValue;
863
+ onChange: (next: GroupValue) => void;
864
+ type?: GroupType;
865
+ children: React__default.ReactNode;
866
+ style?: React__default.CSSProperties;
867
+ };
868
+ declare function GroupSelect({ value, onChange, type, children, style, }: GroupSelectProps): react_jsx_runtime.JSX.Element;
869
+ declare namespace GroupSelect {
870
+ var Name: typeof GroupName;
871
+ var Rank: typeof GroupRank;
872
+ }
873
+ type GroupNameProps = {
874
+ value?: string;
875
+ onChange?: (name: string) => void;
876
+ type?: GroupType;
877
+ label?: string;
878
+ description?: string;
879
+ placeholder?: string;
880
+ size?: string;
881
+ disabled?: boolean;
882
+ style?: React__default.CSSProperties;
883
+ };
884
+ declare function GroupName(props: GroupNameProps): react_jsx_runtime.JSX.Element;
885
+ type GroupRankProps = {
886
+ label?: string;
887
+ description?: string;
888
+ placeholder?: string;
889
+ size?: string;
890
+ style?: React__default.CSSProperties;
891
+ };
892
+ declare function GroupRank(props: GroupRankProps): react_jsx_runtime.JSX.Element;
893
+
856
894
  type FiveMControls = {
857
895
  _type: string;
858
896
  _key: string;
@@ -907,4 +945,4 @@ interface TestBedProps {
907
945
  }
908
946
  declare function TestBed({ items, storageKey, disablePersistence, title, }: TestBedProps): react_jsx_runtime.JSX.Element | null;
909
947
 
910
- export { AdminPageTitle, type AdminPageTitleProps, AsyncSaveButton, BlipColorSelect, type BlipColorSelectProps, BlipDisplaySelect, type BlipDisplaySelectProps, BlipIconSelect, type BlipIconSelectProps, BorderedIcon, type BorderedIconProps, type ButtonProps, ConfigPanel, type ConfigPanelProps, ConfirmModal, type ConfirmModalProps, Counter, type FiveMControls, FiveMKeyBindInput, FloatingParticles, type FloatingParticlesProps, InfoBox, type InfoBoxProps, InputContainer, type InputContainerProps, LevelBanner, LevelPanel, 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, type SegmentProps, SegmentedControl, type SegmentedControlProps, SegmentedProgress, SelectItem, type SelectItemProps, type StoreModalProps, TestBed, type TestBedItem, type TestBedProps, Title, type TitleProps, type Vector4Value, useModal, useModalActions, useNavigation, useNavigationStore };
948
+ export { AdminPageTitle, type AdminPageTitleProps, AsyncSaveButton, BlipColorSelect, type BlipColorSelectProps, BlipDisplaySelect, type BlipDisplaySelectProps, BlipIconSelect, type BlipIconSelectProps, BorderedIcon, type BorderedIconProps, type ButtonProps, ConfigPanel, type ConfigPanelProps, ConfirmModal, type ConfirmModalProps, Counter, 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, 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, type SegmentProps, SegmentedControl, type SegmentedControlProps, SegmentedProgress, SelectItem, type SelectItemProps, type StoreModalProps, TestBed, type TestBedItem, type TestBedProps, Title, type TitleProps, type Vector4Value, useModal, useModalActions, useNavigation, useNavigationStore };
@@ -1353,6 +1353,20 @@ registerInitialFetch("FETCH_ALL_ITEMS", null, {
1353
1353
  useItems.setState(fetchedItems);
1354
1354
  }).catch(() => {
1355
1355
  });
1356
+ var useFrameworkGroups = create(() => ({
1357
+ jobs: [],
1358
+ gangs: [],
1359
+ loaded: false
1360
+ }));
1361
+ registerInitialFetch("GET_FRAMEWORK_GROUPS", void 0).then((data) => {
1362
+ useFrameworkGroups.setState({
1363
+ jobs: Array.isArray(data?.jobs) ? data.jobs : [],
1364
+ gangs: Array.isArray(data?.gangs) ? data.gangs : [],
1365
+ loaded: true
1366
+ });
1367
+ }).catch(() => {
1368
+ useFrameworkGroups.setState({ loaded: true });
1369
+ });
1356
1370
 
1357
1371
  // src/utils/inputMapper.ts
1358
1372
  var INPUT_MAPPER_PRIMARY_OPTIONS = [
@@ -4011,6 +4025,7 @@ function SelectItem(props) {
4011
4025
  data: formattedItems,
4012
4026
  allowDeselect: false,
4013
4027
  searchable: true,
4028
+ comboboxProps: { withinPortal: true, zIndex: 2e3 },
4014
4029
  leftSectionWidth: "4vh",
4015
4030
  leftSection: props.value ? /* @__PURE__ */ jsx(
4016
4031
  Image,
@@ -4254,6 +4269,94 @@ function PickerButton({
4254
4269
  }
4255
4270
  ) });
4256
4271
  }
4272
+ var GroupSelectContext = createContext(null);
4273
+ function GroupSelect({
4274
+ value,
4275
+ onChange,
4276
+ type,
4277
+ children,
4278
+ style
4279
+ }) {
4280
+ return /* @__PURE__ */ jsx(GroupSelectContext.Provider, { value: { value, onChange, type }, children: /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "0.4vh", ...style }, children }) });
4281
+ }
4282
+ function filterByType(jobs, gangs, type) {
4283
+ if (type === "job") return jobs;
4284
+ if (type === "gang") return gangs;
4285
+ return [...jobs, ...gangs];
4286
+ }
4287
+ function GroupName(props) {
4288
+ const ctx = useContext(GroupSelectContext);
4289
+ const jobs = useFrameworkGroups((s) => s.jobs);
4290
+ const gangs = useFrameworkGroups((s) => s.gangs);
4291
+ const inCompound = ctx !== null;
4292
+ const currentValue = inCompound ? ctx.value.name : props.value;
4293
+ const filterType = inCompound ? ctx.type : props.type;
4294
+ const list = filterByType(jobs, gangs, filterType);
4295
+ const data = filterType === void 0 ? [
4296
+ { group: locale("Jobs") || "Jobs", items: jobs.map((g) => ({ value: g.name, label: g.label })) },
4297
+ { group: locale("Gangs") || "Gangs", items: gangs.map((g) => ({ value: g.name, label: g.label })) }
4298
+ ] : list.map((g) => ({ value: g.name, label: g.label }));
4299
+ return /* @__PURE__ */ jsx(
4300
+ Select,
4301
+ {
4302
+ label: props.label,
4303
+ description: props.description,
4304
+ placeholder: props.placeholder ?? (locale("SelectGroup") || "Select\u2026"),
4305
+ size: props.size ?? "xs",
4306
+ disabled: props.disabled,
4307
+ style: props.style,
4308
+ data,
4309
+ value: currentValue ?? null,
4310
+ searchable: true,
4311
+ onChange: (v) => {
4312
+ const name = v ?? "";
4313
+ if (inCompound) {
4314
+ ctx.onChange({ name: name || void 0, grade: void 0 });
4315
+ } else if (props.onChange) {
4316
+ props.onChange(name);
4317
+ }
4318
+ },
4319
+ allowDeselect: false
4320
+ }
4321
+ );
4322
+ }
4323
+ function GroupRank(props) {
4324
+ const ctx = useContext(GroupSelectContext);
4325
+ if (ctx === null) {
4326
+ throw new Error("<GroupRank> must be a child of <GroupSelect>");
4327
+ }
4328
+ const jobs = useFrameworkGroups((s) => s.jobs);
4329
+ const gangs = useFrameworkGroups((s) => s.gangs);
4330
+ const all = [...jobs, ...gangs];
4331
+ const selectedGroup = all.find((g) => g.name === ctx.value.name) ?? null;
4332
+ const grades = selectedGroup?.grades ?? [];
4333
+ const data = grades.map((g) => ({
4334
+ value: String(g.grade),
4335
+ label: `${g.grade} \u2014 ${g.label || g.name}${g.isBoss ? " (boss)" : ""}`
4336
+ }));
4337
+ return /* @__PURE__ */ jsx(
4338
+ Select,
4339
+ {
4340
+ label: props.label,
4341
+ description: props.description,
4342
+ placeholder: props.placeholder ?? (locale("SelectGrade") || "Select grade\u2026"),
4343
+ size: props.size ?? "xs",
4344
+ style: props.style,
4345
+ data,
4346
+ value: ctx.value.grade != null ? String(ctx.value.grade) : null,
4347
+ onChange: (v) => {
4348
+ ctx.onChange({
4349
+ ...ctx.value,
4350
+ grade: v != null ? Number(v) : void 0
4351
+ });
4352
+ },
4353
+ disabled: !selectedGroup || grades.length === 0,
4354
+ allowDeselect: false
4355
+ }
4356
+ );
4357
+ }
4358
+ GroupSelect.Name = GroupName;
4359
+ GroupSelect.Rank = GroupRank;
4257
4360
  var KeyBindContext = createContext(null);
4258
4361
  function useKeyBindContext() {
4259
4362
  const ctx = useContext(KeyBindContext);
@@ -4537,6 +4640,6 @@ function TestBed({
4537
4640
  );
4538
4641
  }
4539
4642
 
4540
- export { AdminPageTitle, AsyncSaveButton, BlipColorSelect, BlipDisplaySelect, BlipIconSelect, BorderedIcon, ConfigPanel, ConfirmModal, Counter, FiveMKeyBindInput, FloatingParticles, InfoBox, InputContainer, LevelBanner, LevelPanel, Modal, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, PositionPicker, PromptModal, SegmentedControl, SegmentedProgress, SelectItem, TestBed, Title, useModal, useModalActions, useNavigation, useNavigationStore };
4643
+ export { AdminPageTitle, AsyncSaveButton, BlipColorSelect, BlipDisplaySelect, BlipIconSelect, BorderedIcon, ConfigPanel, ConfirmModal, Counter, FiveMKeyBindInput, FloatingParticles, GroupName, GroupRank, GroupSelect, InfoBox, InputContainer, LevelBanner, LevelPanel, Modal, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, PositionPicker, PromptModal, SegmentedControl, SegmentedProgress, SelectItem, TestBed, Title, useModal, useModalActions, useNavigation, useNavigationStore };
4541
4644
  //# sourceMappingURL=index.js.map
4542
4645
  //# sourceMappingURL=index.js.map