@lvce-editor/explorer-view 7.2.0 → 7.4.0

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.
@@ -1276,6 +1276,7 @@ const DeltaMode = 'event.deltaMode';
1276
1276
  const DeltaY = 'event.deltaY';
1277
1277
  const EventTargetClassName = 'event.target.className';
1278
1278
  const IsTrusted = 'event.isTrusted';
1279
+ const Key = 'event.key';
1279
1280
  const ShiftKey = 'event.shiftKey';
1280
1281
  const TargetName = 'event.target.name';
1281
1282
  const TargetValue = 'event.target.value';
@@ -3695,6 +3696,18 @@ const getMouseActions = () => {
3695
3696
  }];
3696
3697
  };
3697
3698
 
3699
+ const getTitle$1 = state => {
3700
+ const {
3701
+ pathSeparator,
3702
+ root
3703
+ } = state;
3704
+ if (!root) {
3705
+ return 'Explorer';
3706
+ }
3707
+ const normalizedRoot = root.endsWith(pathSeparator) && root !== pathSeparator ? root.slice(0, -pathSeparator.length) : root;
3708
+ return getBaseName(pathSeparator, normalizedRoot) || normalizedRoot;
3709
+ };
3710
+
3698
3711
  const getParentStartIndex = (dirents, index) => {
3699
3712
  const dirent = dirents[index];
3700
3713
  let startIndex = index - 1;
@@ -3953,6 +3966,9 @@ const getNewDirentsForNewDirent = async (items, focusedIndex, type, root) => {
3953
3966
  setSize: 1,
3954
3967
  type
3955
3968
  };
3969
+ if (type === EditingFolder) {
3970
+ return [newDirent, ...items];
3971
+ }
3956
3972
  return [...items, newDirent];
3957
3973
  }
3958
3974
  const focusedItem = items[focusedIndex];
@@ -3993,7 +4009,7 @@ const getNewDirentType = editingType => {
3993
4009
  }
3994
4010
  };
3995
4011
 
3996
- const newDirent = async (state, editingType) => {
4012
+ const newDirent = async (state, editingType, editingIcon = '') => {
3997
4013
  // TODO do it like vscode, select position between folders and files
3998
4014
  const {
3999
4015
  editingIndex,
@@ -4010,6 +4026,7 @@ const newDirent = async (state, editingType) => {
4010
4026
  const newEditingIndex = newDirents.findIndex(item => item.type === EditingFile || item.type === EditingFolder);
4011
4027
  return {
4012
4028
  ...state,
4029
+ editingIcon,
4013
4030
  editingIndex: newEditingIndex,
4014
4031
  editingType,
4015
4032
  editingValue: '',
@@ -4024,8 +4041,38 @@ const newFile = state => {
4024
4041
  return newDirent(state, CreateFile);
4025
4042
  };
4026
4043
 
4027
- const newFolder = state => {
4028
- return newDirent(state, CreateFolder);
4044
+ const getEditingIcon = async (editingType, value, direntType) => {
4045
+ if (editingType === CreateFile) {
4046
+ return invoke$2('IconTheme.getFileIcon', {
4047
+ name: value
4048
+ });
4049
+ }
4050
+ if (editingType === Rename$1) {
4051
+ if (direntType === File || direntType === EditingFile) {
4052
+ return invoke$2('IconTheme.getFileIcon', {
4053
+ name: value
4054
+ });
4055
+ }
4056
+ if (direntType !== undefined && [Directory, EditingFolder, EditingDirectoryExpanded].includes(direntType)) {
4057
+ return invoke$2('IconTheme.getFolderIcon', {
4058
+ name: value
4059
+ });
4060
+ }
4061
+ }
4062
+ if (editingType === CreateFolder) {
4063
+ return invoke$2('IconTheme.getFolderIcon', {
4064
+ name: value
4065
+ });
4066
+ }
4067
+ return '';
4068
+ };
4069
+
4070
+ const newFolder = async state => {
4071
+ if (state.editingIndex !== -1) {
4072
+ return state;
4073
+ }
4074
+ const editingIcon = await getEditingIcon(CreateFolder, '');
4075
+ return newDirent(state, CreateFolder, editingIcon);
4029
4076
  };
4030
4077
 
4031
4078
  const isExpanded = item => {
@@ -5301,7 +5348,7 @@ const filterByFocusWord = (items, focusedIndex, focusWord) => {
5301
5348
  }
5302
5349
  const matches = [];
5303
5350
  for (let i = 0; i < items.length; i++) {
5304
- if (items[i].toLowerCase().includes(focusWord)) {
5351
+ if (items[i].toLowerCase().startsWith(focusWord)) {
5305
5352
  matches.push(i);
5306
5353
  }
5307
5354
  }
@@ -5318,19 +5365,22 @@ const filterByFocusWord = (items, focusedIndex, focusWord) => {
5318
5365
  return matches[nextIndex];
5319
5366
  };
5320
5367
 
5321
- const RE_ASCII = /^[a-z]$/;
5368
+ const RE_ASCII = /^[a-z]$/i;
5322
5369
  const isAscii = key => {
5323
5370
  return RE_ASCII.test(key);
5324
5371
  };
5325
5372
 
5326
5373
  const typeAheadTimeout = {};
5327
- const handleKeyDown = (state, key) => {
5374
+ const handleKeyDown = (state, defaultPrevented, key) => {
5328
5375
  const {
5329
5376
  focusedIndex,
5330
5377
  focusWord,
5331
5378
  focusWordTimeout,
5332
5379
  items
5333
5380
  } = state;
5381
+ if (defaultPrevented) {
5382
+ return state;
5383
+ }
5334
5384
  if (focusWord && key === '') {
5335
5385
  return cancelTypeAhead(state);
5336
5386
  }
@@ -6068,6 +6118,7 @@ const HandleDrop = 6;
6068
6118
  const HandleEditingInput = 7;
6069
6119
  const HandleInputBlur = 8;
6070
6120
  const HandleInputClick = 9;
6121
+ const HandleKeyDown = 21;
6071
6122
  const HandleListBlur = 11;
6072
6123
  const HandleListFocus = 12;
6073
6124
  const HandlePointerDown = 14;
@@ -6549,6 +6600,9 @@ const renderEventListeners = () => {
6549
6600
  }, {
6550
6601
  name: HandleListBlur,
6551
6602
  params: ['handleBlur']
6603
+ }, {
6604
+ name: HandleKeyDown,
6605
+ params: ['handleKeyDown', DefaultPrevented, Key]
6552
6606
  }, {
6553
6607
  name: HandleClick,
6554
6608
  params: ['handleClickAt', DefaultPrevented, Button$3, CtrlKey, ShiftKey, ClientX, ClientY],
@@ -6876,32 +6930,6 @@ const selectUp = state => {
6876
6930
  };
6877
6931
  };
6878
6932
 
6879
- const getEditingIcon = async (editingType, value, direntType) => {
6880
- if (editingType === CreateFile) {
6881
- return invoke$2('IconTheme.getFileIcon', {
6882
- name: value
6883
- });
6884
- }
6885
- if (editingType === Rename$1) {
6886
- if (direntType === File || direntType === EditingFile) {
6887
- return invoke$2('IconTheme.getFileIcon', {
6888
- name: value
6889
- });
6890
- }
6891
- if (direntType !== undefined && [Directory, EditingFolder, EditingDirectoryExpanded].includes(direntType)) {
6892
- return invoke$2('IconTheme.getFolderIcon', {
6893
- name: value
6894
- });
6895
- }
6896
- }
6897
- if (editingType === CreateFolder) {
6898
- return invoke$2('IconTheme.getFolderIcon', {
6899
- name: value
6900
- });
6901
- }
6902
- return '';
6903
- };
6904
-
6905
6933
  const updateEditingValue = async (state, value, inputSource = User) => {
6906
6934
  const {
6907
6935
  editingIndex,
@@ -6950,6 +6978,7 @@ const commandMap = {
6950
6978
  'Explorer.getMenuEntries': getMenuEntries,
6951
6979
  'Explorer.getMenuEntries2': wrapGetter(getMenuEntries2),
6952
6980
  'Explorer.getMouseActions': getMouseActions,
6981
+ 'Explorer.getTitle': wrapGetter(getTitle$1),
6953
6982
  'Explorer.handleArrowLeft': wrapListItemCommand(handleArrowLeft),
6954
6983
  'Explorer.handleArrowRight': wrapListItemCommand(handleArrowRight),
6955
6984
  'Explorer.handleBlur': wrapListItemCommand(handleBlur),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.2.0",
3
+ "version": "7.4.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",