git-stack-cli 1.6.0 → 1.6.2

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.
@@ -28561,11 +28561,13 @@ function MultiSelect(props) {
28561
28561
  return;
28562
28562
  }
28563
28563
  const space = input === " ";
28564
- if (key.return || space) {
28565
- selectRef.current = true;
28566
- const item = props.items[index];
28567
- if (!item.disabled) {
28568
- return select(index);
28564
+ if (!props.disableSelect) {
28565
+ if (key.return || space) {
28566
+ selectRef.current = true;
28567
+ const item = props.items[index];
28568
+ if (!item.disabled) {
28569
+ return select(index);
28570
+ }
28569
28571
  }
28570
28572
  }
28571
28573
  if (key.upArrow) {
@@ -28700,10 +28702,17 @@ function SelectCommitRanges() {
28700
28702
  function SelectCommitRangesInternal(props) {
28701
28703
  const actions = Store.useActions();
28702
28704
  const argv = Store.useState((state) => state.argv);
28703
- const [selected_group_id, set_selected_group_id] = reactExports.useState(props.commit_range.UNASSIGNED);
28705
+ const [selected_group_id, set_selected_group_id] = reactExports.useState(() => {
28706
+ const first_group = props.commit_range.group_list.find((g) => g.id !== props.commit_range.UNASSIGNED);
28707
+ if (first_group) {
28708
+ return first_group.id;
28709
+ }
28710
+ return props.commit_range.UNASSIGNED;
28711
+ });
28704
28712
  const [group_input, set_group_input] = reactExports.useState(false);
28705
28713
  const [new_group_list, create_group] = reactExports.useReducer((group_list, group) => {
28706
- return group_list.concat(group);
28714
+ const next_group_list = group_list.concat(group);
28715
+ return next_group_list;
28707
28716
  }, []);
28708
28717
  const [commit_map, update_commit_map] = reactExports.useReducer((map, args) => {
28709
28718
  map.set(args.key, args.value);
@@ -28724,9 +28733,10 @@ function SelectCommitRangesInternal(props) {
28724
28733
  unassigned_count++;
28725
28734
  }
28726
28735
  }
28727
- group_list.push(...new_group_list);
28728
28736
  const total_group_count = new_group_list.length + props.commit_range.group_list.length;
28729
- for (const group of props.commit_range.group_list) {
28737
+ for (let i = 0; i < props.commit_range.group_list.length; i++) {
28738
+ const index = props.commit_range.group_list.length - i - 1;
28739
+ const group = props.commit_range.group_list[index];
28730
28740
  if (group.pr?.state === "MERGED")
28731
28741
  continue;
28732
28742
  if (group.id === props.commit_range.UNASSIGNED) {
@@ -28744,6 +28754,7 @@ function SelectCommitRangesInternal(props) {
28744
28754
  title: group.pr?.title || group.title || group.id,
28745
28755
  });
28746
28756
  }
28757
+ group_list.push(...new_group_list);
28747
28758
  let current_index = group_list.findIndex((g) => g.id === selected_group_id);
28748
28759
  if (current_index === -1) {
28749
28760
  current_index = 0;
@@ -28788,6 +28799,8 @@ function SelectCommitRangesInternal(props) {
28788
28799
  }
28789
28800
  });
28790
28801
  const group = group_list[current_index];
28802
+ const multiselect_disabled = group_input;
28803
+ const multiselect_disableSelect = group.id === props.commit_range.UNASSIGNED;
28791
28804
  const items = props.commit_range.commit_list.map((commit) => {
28792
28805
  const commit_metadata_id = commit_map.get(commit.sha);
28793
28806
  const selected = commit_metadata_id !== null;
@@ -28795,9 +28808,6 @@ function SelectCommitRangesInternal(props) {
28795
28808
  if (group_input) {
28796
28809
  disabled = true;
28797
28810
  }
28798
- else if (group.id === props.commit_range.UNASSIGNED) {
28799
- disabled = true;
28800
- }
28801
28811
  else {
28802
28812
  disabled = Boolean(selected && commit_metadata_id !== group.id);
28803
28813
  }
@@ -28823,7 +28833,7 @@ function SelectCommitRangesInternal(props) {
28823
28833
  const [focused, set_focused] = reactExports.useState("");
28824
28834
  return (reactExports.createElement(Box, { flexDirection: "column" },
28825
28835
  reactExports.createElement(Box, { height: 1 }),
28826
- reactExports.createElement(MultiSelect, { key: group.id, items: items, maxWidth: max_item_width, disabled: group_input, onFocus: (args) => {
28836
+ reactExports.createElement(MultiSelect, { items: items, maxWidth: max_item_width, disabled: multiselect_disabled, disableSelect: multiselect_disableSelect, onFocus: (args) => {
28827
28837
  // console.debug("onFocus", args);
28828
28838
  set_focused(args.item.subject_line);
28829
28839
  }, onSelect: (args) => {
@@ -34452,7 +34462,7 @@ async function command() {
34452
34462
  .wrap(123)
34453
34463
  // disallow unknown options
34454
34464
  .strict()
34455
- .version("1.6.0" )
34465
+ .version("1.6.2" )
34456
34466
  .showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
34457
34467
  .help("help", "Show usage via `git stack help`").argv);
34458
34468
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -12,6 +12,7 @@ type Props<T> = {
12
12
  onSelect: (args: CallbackArgs<T>) => void;
13
13
  onFocus?: (args: CallbackArgs<T>) => void;
14
14
  disabled?: boolean;
15
+ disableSelect?: boolean;
15
16
  maxWidth?: number;
16
17
  };
17
18
 
@@ -118,11 +119,13 @@ export function MultiSelect<T>(props: Props<T>) {
118
119
 
119
120
  const space = input === " ";
120
121
 
121
- if (key.return || space) {
122
- selectRef.current = true;
123
- const item = props.items[index];
124
- if (!item.disabled) {
125
- return select(index);
122
+ if (!props.disableSelect) {
123
+ if (key.return || space) {
124
+ selectRef.current = true;
125
+ const item = props.items[index];
126
+ if (!item.disabled) {
127
+ return select(index);
128
+ }
126
129
  }
127
130
  }
128
131
 
@@ -35,15 +35,24 @@ function SelectCommitRangesInternal(props: Props) {
35
35
 
36
36
  const argv = Store.useState((state) => state.argv);
37
37
 
38
- const [selected_group_id, set_selected_group_id] = React.useState(
39
- props.commit_range.UNASSIGNED
40
- );
38
+ const [selected_group_id, set_selected_group_id] = React.useState(() => {
39
+ const first_group = props.commit_range.group_list.find(
40
+ (g) => g.id !== props.commit_range.UNASSIGNED
41
+ );
42
+
43
+ if (first_group) {
44
+ return first_group.id;
45
+ }
46
+
47
+ return props.commit_range.UNASSIGNED;
48
+ });
41
49
 
42
50
  const [group_input, set_group_input] = React.useState(false);
43
51
 
44
52
  const [new_group_list, create_group] = React.useReducer(
45
53
  (group_list: Array<SimpleGroup>, group: SimpleGroup) => {
46
- return group_list.concat(group);
54
+ const next_group_list = group_list.concat(group);
55
+ return next_group_list;
47
56
  },
48
57
  []
49
58
  );
@@ -79,12 +88,13 @@ function SelectCommitRangesInternal(props: Props) {
79
88
  }
80
89
  }
81
90
 
82
- group_list.push(...new_group_list);
83
-
84
91
  const total_group_count =
85
92
  new_group_list.length + props.commit_range.group_list.length;
86
93
 
87
- for (const group of props.commit_range.group_list) {
94
+ for (let i = 0; i < props.commit_range.group_list.length; i++) {
95
+ const index = props.commit_range.group_list.length - i - 1;
96
+ const group = props.commit_range.group_list[index];
97
+
88
98
  if (group.pr?.state === "MERGED") continue;
89
99
 
90
100
  if (group.id === props.commit_range.UNASSIGNED) {
@@ -105,6 +115,8 @@ function SelectCommitRangesInternal(props: Props) {
105
115
  });
106
116
  }
107
117
 
118
+ group_list.push(...new_group_list);
119
+
108
120
  let current_index = group_list.findIndex((g) => g.id === selected_group_id);
109
121
  if (current_index === -1) {
110
122
  current_index = 0;
@@ -159,6 +171,9 @@ function SelectCommitRangesInternal(props: Props) {
159
171
 
160
172
  const group = group_list[current_index];
161
173
 
174
+ const multiselect_disabled = group_input;
175
+ const multiselect_disableSelect = group.id === props.commit_range.UNASSIGNED;
176
+
162
177
  const items = props.commit_range.commit_list.map((commit) => {
163
178
  const commit_metadata_id = commit_map.get(commit.sha);
164
179
 
@@ -168,8 +183,6 @@ function SelectCommitRangesInternal(props: Props) {
168
183
 
169
184
  if (group_input) {
170
185
  disabled = true;
171
- } else if (group.id === props.commit_range.UNASSIGNED) {
172
- disabled = true;
173
186
  } else {
174
187
  disabled = Boolean(selected && commit_metadata_id !== group.id);
175
188
  }
@@ -206,10 +219,10 @@ function SelectCommitRangesInternal(props: Props) {
206
219
  <Ink.Box height={1} />
207
220
 
208
221
  <MultiSelect
209
- key={group.id}
210
222
  items={items}
211
223
  maxWidth={max_item_width}
212
- disabled={group_input}
224
+ disabled={multiselect_disabled}
225
+ disableSelect={multiselect_disableSelect}
213
226
  onFocus={(args) => {
214
227
  // console.debug("onFocus", args);
215
228