@lvce-editor/settings-view 1.14.0 → 1.15.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.
package/README.md CHANGED
@@ -1,3 +1,16 @@
1
1
  # Settings View
2
2
 
3
3
  WebWorker for the Settings View functionality in Lvce Editor.
4
+
5
+ ## Contributing
6
+
7
+ ```sh
8
+ git clone git@github.com:lvce-editor/settings-view.git &&
9
+ cd settings-view &&
10
+ npm ci &&
11
+ npm test
12
+ ```
13
+
14
+ ## Gitpod
15
+
16
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lvce-editor/settings-view)
@@ -946,6 +946,8 @@ const getFilteredItems = (items, tabs, searchValue = '', preferences = {}) => {
946
946
  const User = 1;
947
947
  const Script = 2;
948
948
 
949
+ const FocusSettingsInput = 2199;
950
+
949
951
  const clear$1 = state => {
950
952
  const {
951
953
  items,
@@ -956,9 +958,19 @@ const clear$1 = state => {
956
958
  const filteredItems = getFilteredItems(items, tabs, newSearchValue, preferences);
957
959
  return {
958
960
  ...state,
959
- searchValue: newSearchValue,
961
+ filteredItems,
962
+ focus: FocusSettingsInput,
963
+ focusSource: Script,
960
964
  inputSource: Script,
961
- filteredItems
965
+ searchValue: newSearchValue
966
+ };
967
+ };
968
+
969
+ const clearHistory = state => {
970
+ return {
971
+ ...state,
972
+ history: [],
973
+ historyIndex: -1
962
974
  };
963
975
  };
964
976
 
@@ -992,7 +1004,8 @@ const create$1 = (id, uri, x, y, width, height) => {
992
1004
  filteredItemsCount: 0,
993
1005
  history: [],
994
1006
  historyIndex: -1,
995
- modifiedSettings: {}
1007
+ modifiedSettings: {},
1008
+ focusSource: 0
996
1009
  };
997
1010
  set$1(id, state, state);
998
1011
  };
@@ -1018,6 +1031,7 @@ const RenderFocus = 2;
1018
1031
  const RenderValue = 3;
1019
1032
  const RenderSettingValues = 10;
1020
1033
  const RenderScrollOffset = 11;
1034
+ const RenderFocusContext = 12;
1021
1035
 
1022
1036
  const isEqual = (oldState, newState) => {
1023
1037
  return newState.inputSource === User || oldState.searchValue === newState.searchValue;
@@ -1046,6 +1060,15 @@ const diff2 = uid => {
1046
1060
  return diffResult;
1047
1061
  };
1048
1062
 
1063
+ const getKeyBindings = () => {
1064
+ return [];
1065
+ };
1066
+
1067
+ const getName = () => {
1068
+ // TODO i18n string
1069
+ return 'Settings';
1070
+ };
1071
+
1049
1072
  const getSelectedTabId = tabs => {
1050
1073
  for (const tab of tabs) {
1051
1074
  if (tab.selected) {
@@ -1124,6 +1147,15 @@ const handleInput = (state, value, inputSource = User) => {
1124
1147
  };
1125
1148
  };
1126
1149
 
1150
+ const SearchInput = 1;
1151
+
1152
+ const handleInputFocus = state => {
1153
+ return {
1154
+ ...state,
1155
+ focus: SearchInput
1156
+ };
1157
+ };
1158
+
1127
1159
  const handleScroll = (state, scrollTop, inputSource = User) => {
1128
1160
  return {
1129
1161
  ...state,
@@ -1206,6 +1238,7 @@ const Enum = 1;
1206
1238
  const String = 2;
1207
1239
  const Boolean$1 = 3;
1208
1240
  const Number$1 = 5;
1241
+ const Color = 6;
1209
1242
 
1210
1243
  const emptyObject = {};
1211
1244
  const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
@@ -1270,6 +1303,7 @@ const CursorBlinking = 'Cursor Blinking';
1270
1303
  const CursorBlinkingDescription = 'Controls how the cursor should blink';
1271
1304
  const CursorStyle = 'Cursor Style';
1272
1305
  const CursorStyleDescription = 'Controls the cursor style';
1306
+ const ColorValue = 'Color value';
1273
1307
  const CursorWidth = 'Cursor Width';
1274
1308
  const CursorWidthDescription = 'Controls the width of the cursor';
1275
1309
  const TabSize = 'Tab Size';
@@ -1542,6 +1576,9 @@ const formatOnSaveDescription = () => {
1542
1576
  const numberValue = () => {
1543
1577
  return i18nString(NumberValue);
1544
1578
  };
1579
+ const colorValue = () => {
1580
+ return i18nString(ColorValue);
1581
+ };
1545
1582
  const stringValue = () => {
1546
1583
  return i18nString(StringValue);
1547
1584
  };
@@ -3057,6 +3094,13 @@ const getSettingItems = async () => {
3057
3094
  type: Boolean$1,
3058
3095
  value: 'true',
3059
3096
  category: TextEditorTab
3097
+ }, {
3098
+ id: 'Editor.background',
3099
+ heading: 'Editor background',
3100
+ description: 'Editor background color',
3101
+ type: Color,
3102
+ value: '#567567',
3103
+ category: TextEditorTab
3060
3104
  }, {
3061
3105
  id: 'showUnused',
3062
3106
  heading: showUnused(),
@@ -3335,6 +3379,19 @@ const loadContent = async (state, savedState) => {
3335
3379
  };
3336
3380
  };
3337
3381
 
3382
+ const renderFocus = (oldState, newState) => {
3383
+ const {
3384
+ id
3385
+ } = newState;
3386
+ const selector = `[name="${SettingsSearch}"]`;
3387
+ return ['Viewlet.focusSelector', id, selector];
3388
+ };
3389
+
3390
+ const renderFocusContext = (oldState, newState) => {
3391
+ const focusKey = FocusSettingsInput;
3392
+ return ['Viewlet.setFocusContext', focusKey];
3393
+ };
3394
+
3338
3395
  const Tab$1 = 'tab';
3339
3396
  const TabList = 'tablist';
3340
3397
  const AriaRoles = {
@@ -3430,6 +3487,7 @@ const HandleSettingInput = 'handleSettingInput';
3430
3487
  const HandleSettingChecked = 'handleSettingChecked';
3431
3488
  const HandleScroll = 'handleScroll';
3432
3489
  const HandleSettingSelect = 'handleSettingSelect';
3490
+ const HandleInputFocus = 'handleInputFocus';
3433
3491
 
3434
3492
  const getButtonClassName = hasSearchValue => {
3435
3493
  if (hasSearchValue) {
@@ -3461,7 +3519,8 @@ const getSettingsInputDom = () => {
3461
3519
  placeholder,
3462
3520
  childCount: 0,
3463
3521
  name: SettingsSearch,
3464
- onInput: HandleInput
3522
+ onInput: HandleInput,
3523
+ onFocus: HandleInputFocus
3465
3524
  }];
3466
3525
  };
3467
3526
 
@@ -3539,6 +3598,37 @@ const getItemLabelDom = (domId, label) => {
3539
3598
  }, text(label)];
3540
3599
  };
3541
3600
 
3601
+ const getItemColorVirtualDom = item => {
3602
+ const {
3603
+ heading,
3604
+ description,
3605
+ id,
3606
+ modified
3607
+ } = item;
3608
+ const domId = getInputId(id);
3609
+ const isModified = modified || false;
3610
+ return [{
3611
+ type: VirtualDomElements.Div,
3612
+ className: SettingsItem,
3613
+ childCount: 3,
3614
+ role: 'group',
3615
+ 'data-modified': isModified
3616
+ }, ...getItemHeadingDom(heading), {
3617
+ type: VirtualDomElements.Div,
3618
+ className: SettingsItemCheckBox,
3619
+ childCount: 2
3620
+ }, {
3621
+ type: VirtualDomElements.Input,
3622
+ className: mergeClassNames('ColorInput'),
3623
+ inputType: 'color',
3624
+ placeholder: colorValue(),
3625
+ childCount: 0,
3626
+ id: domId,
3627
+ name: id,
3628
+ onInput: HandleSettingInput
3629
+ }, ...getItemLabelDom(domId, description)];
3630
+ };
3631
+
3542
3632
  const getItemNumberVirtualDom = item => {
3543
3633
  const {
3544
3634
  heading,
@@ -3595,6 +3685,7 @@ const getItemSelectVirtualDom = item => {
3595
3685
  type: VirtualDomElements.Select,
3596
3686
  className: Select,
3597
3687
  childCount: options.length,
3688
+ id: domId,
3598
3689
  name: id,
3599
3690
  onChange: HandleSettingSelect
3600
3691
  }, ...options.flatMap(getOptionDom)];
@@ -3650,6 +3741,9 @@ const getItemVirtualDom = item => {
3650
3741
  if (item.type === Enum) {
3651
3742
  return getItemSelectVirtualDom(item);
3652
3743
  }
3744
+ if (item.type === Color) {
3745
+ return getItemColorVirtualDom(item);
3746
+ }
3653
3747
  return getItemUnknownVirtualDom();
3654
3748
  };
3655
3749
 
@@ -3764,12 +3858,12 @@ const renderScrollOffset = (oldState, newState) => {
3764
3858
  return ['Viewlet.setProperty', id, selector, property, scrollOffset];
3765
3859
  };
3766
3860
 
3861
+ const enabledTypes = [Number$1, String, Color];
3767
3862
  const renderSettingValues = (oldState, newState) => {
3768
3863
  const {
3769
3864
  filteredItems,
3770
3865
  id
3771
3866
  } = newState;
3772
- const enabledTypes = [Number$1, String];
3773
3867
  const numericSettings = filteredItems.filter(item => enabledTypes.includes(item.type));
3774
3868
  const inputValues = numericSettings.map(item => ({
3775
3869
  name: item.id,
@@ -3796,6 +3890,10 @@ const getRenderer = diffType => {
3796
3890
  return renderSettingValues;
3797
3891
  case RenderScrollOffset:
3798
3892
  return renderScrollOffset;
3893
+ case RenderFocusContext:
3894
+ return renderFocusContext;
3895
+ case RenderFocus:
3896
+ return renderFocus;
3799
3897
  default:
3800
3898
  throw new Error('unknown renderer');
3801
3899
  }
@@ -3847,6 +3945,9 @@ const renderEventListeners = () => {
3847
3945
  }, {
3848
3946
  name: HandleSettingSelect,
3849
3947
  params: ['handleSettingSelect', 'event.target.name', 'event.target.value']
3948
+ }, {
3949
+ name: HandleInputFocus,
3950
+ params: ['handleInputFocus']
3850
3951
  }];
3851
3952
  };
3852
3953
 
@@ -3854,7 +3955,8 @@ const saveState = state => {
3854
3955
  const {
3855
3956
  tabs,
3856
3957
  searchValue,
3857
- scrollOffset
3958
+ scrollOffset,
3959
+ focus
3858
3960
  } = state;
3859
3961
  const selectedTab = getSelectedTabId(tabs);
3860
3962
  return {
@@ -3865,7 +3967,8 @@ const saveState = state => {
3865
3967
  deltaY: 0,
3866
3968
  searchValue,
3867
3969
  selectedTab,
3868
- scrollOffset
3970
+ scrollOffset,
3971
+ focus
3869
3972
  };
3870
3973
  };
3871
3974
 
@@ -3918,14 +4021,17 @@ const usePreviousSearchValue = state => {
3918
4021
  const commandMap = {
3919
4022
  'Initialize.initialize': initialize,
3920
4023
  'Settings.clear': wrapCommand(clear$1),
4024
+ 'Settings.clearHistory': wrapCommand(clearHistory),
3921
4025
  'Settings.create': create$1,
3922
4026
  'Settings.diff2': diff2,
4027
+ 'Settings.getName': getName,
3923
4028
  'Settings.getCommandIds': getCommandIds,
3924
4029
  'Settings.handleClickTab': wrapCommand(handleClickTab),
3925
4030
  'Settings.handleInput': wrapCommand(handleInput),
3926
4031
  'Settings.handleScroll': wrapCommand(handleScroll),
3927
4032
  'Settings.handleSettingChecked': wrapCommand(handleSettingChecked),
3928
4033
  'Settings.handleSettingInput': wrapCommand(handleSettingInput),
4034
+ 'Settings.handleInputFocus': wrapCommand(handleInputFocus),
3929
4035
  'Settings.handleSettingSelect': wrapCommand(handleSettingSelect),
3930
4036
  'Settings.loadContent': wrapCommand(loadContent),
3931
4037
  'Settings.render2': render2,
@@ -3935,7 +4041,8 @@ const commandMap = {
3935
4041
  'Settings.saveState': wrapGetter(saveState),
3936
4042
  'Settings.terminate': terminate,
3937
4043
  'Settings.useNextSearchValue': wrapCommand(useNextSearchValue),
3938
- 'Settings.usePreviousSearchValue': wrapCommand(usePreviousSearchValue)
4044
+ 'Settings.usePreviousSearchValue': wrapCommand(usePreviousSearchValue),
4045
+ 'Settings.getKeyBindings': getKeyBindings
3939
4046
  };
3940
4047
 
3941
4048
  const rpcs = Object.create(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/settings-view",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",