@lvce-editor/settings-view 1.14.0 → 1.16.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;
@@ -1030,6 +1044,11 @@ const diff = (oldState, newState) => {
1030
1044
  const diffResult = [];
1031
1045
  for (let i = 0; i < modules.length; i++) {
1032
1046
  const fn = modules[i];
1047
+
1048
+ // TODO enable this
1049
+ if (numbers[i] === RenderScrollOffset) {
1050
+ continue;
1051
+ }
1033
1052
  if (!fn(oldState, newState)) {
1034
1053
  diffResult.push(numbers[i]);
1035
1054
  }
@@ -1046,6 +1065,15 @@ const diff2 = uid => {
1046
1065
  return diffResult;
1047
1066
  };
1048
1067
 
1068
+ const getKeyBindings = () => {
1069
+ return [];
1070
+ };
1071
+
1072
+ const getName = () => {
1073
+ // TODO i18n string
1074
+ return 'Settings';
1075
+ };
1076
+
1049
1077
  const getSelectedTabId = tabs => {
1050
1078
  for (const tab of tabs) {
1051
1079
  if (tab.selected) {
@@ -1124,6 +1152,15 @@ const handleInput = (state, value, inputSource = User) => {
1124
1152
  };
1125
1153
  };
1126
1154
 
1155
+ const SearchInput = 1;
1156
+
1157
+ const handleInputFocus = state => {
1158
+ return {
1159
+ ...state,
1160
+ focus: SearchInput
1161
+ };
1162
+ };
1163
+
1127
1164
  const handleScroll = (state, scrollTop, inputSource = User) => {
1128
1165
  return {
1129
1166
  ...state,
@@ -1206,6 +1243,8 @@ const Enum = 1;
1206
1243
  const String = 2;
1207
1244
  const Boolean$1 = 3;
1208
1245
  const Number$1 = 5;
1246
+ const Color = 6;
1247
+ const Url = 7;
1209
1248
 
1210
1249
  const emptyObject = {};
1211
1250
  const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
@@ -1270,6 +1309,7 @@ const CursorBlinking = 'Cursor Blinking';
1270
1309
  const CursorBlinkingDescription = 'Controls how the cursor should blink';
1271
1310
  const CursorStyle = 'Cursor Style';
1272
1311
  const CursorStyleDescription = 'Controls the cursor style';
1312
+ const ColorValue = 'Color value';
1273
1313
  const CursorWidth = 'Cursor Width';
1274
1314
  const CursorWidthDescription = 'Controls the width of the cursor';
1275
1315
  const TabSize = 'Tab Size';
@@ -1542,6 +1582,9 @@ const formatOnSaveDescription = () => {
1542
1582
  const numberValue = () => {
1543
1583
  return i18nString(NumberValue);
1544
1584
  };
1585
+ const colorValue = () => {
1586
+ return i18nString(ColorValue);
1587
+ };
1545
1588
  const stringValue = () => {
1546
1589
  return i18nString(StringValue);
1547
1590
  };
@@ -3057,6 +3100,13 @@ const getSettingItems = async () => {
3057
3100
  type: Boolean$1,
3058
3101
  value: 'true',
3059
3102
  category: TextEditorTab
3103
+ }, {
3104
+ id: 'Editor.background',
3105
+ heading: 'Editor background',
3106
+ description: 'Editor background color',
3107
+ type: Color,
3108
+ value: '#567567',
3109
+ category: TextEditorTab
3060
3110
  }, {
3061
3111
  id: 'showUnused',
3062
3112
  heading: showUnused(),
@@ -3335,6 +3385,19 @@ const loadContent = async (state, savedState) => {
3335
3385
  };
3336
3386
  };
3337
3387
 
3388
+ const renderFocus = (oldState, newState) => {
3389
+ const {
3390
+ id
3391
+ } = newState;
3392
+ const selector = `[name="${SettingsSearch}"]`;
3393
+ return ['Viewlet.focusSelector', id, selector];
3394
+ };
3395
+
3396
+ const renderFocusContext = (oldState, newState) => {
3397
+ const focusKey = FocusSettingsInput;
3398
+ return ['Viewlet.setFocusContext', focusKey];
3399
+ };
3400
+
3338
3401
  const Tab$1 = 'tab';
3339
3402
  const TabList = 'tablist';
3340
3403
  const AriaRoles = {
@@ -3430,6 +3493,7 @@ const HandleSettingInput = 'handleSettingInput';
3430
3493
  const HandleSettingChecked = 'handleSettingChecked';
3431
3494
  const HandleScroll = 'handleScroll';
3432
3495
  const HandleSettingSelect = 'handleSettingSelect';
3496
+ const HandleInputFocus = 'handleInputFocus';
3433
3497
 
3434
3498
  const getButtonClassName = hasSearchValue => {
3435
3499
  if (hasSearchValue) {
@@ -3461,7 +3525,8 @@ const getSettingsInputDom = () => {
3461
3525
  placeholder,
3462
3526
  childCount: 0,
3463
3527
  name: SettingsSearch,
3464
- onInput: HandleInput
3528
+ onInput: HandleInput,
3529
+ onFocus: HandleInputFocus
3465
3530
  }];
3466
3531
  };
3467
3532
 
@@ -3539,6 +3604,37 @@ const getItemLabelDom = (domId, label) => {
3539
3604
  }, text(label)];
3540
3605
  };
3541
3606
 
3607
+ const getItemColorVirtualDom = item => {
3608
+ const {
3609
+ heading,
3610
+ description,
3611
+ id,
3612
+ modified
3613
+ } = item;
3614
+ const domId = getInputId(id);
3615
+ const isModified = modified || false;
3616
+ return [{
3617
+ type: VirtualDomElements.Div,
3618
+ className: SettingsItem,
3619
+ childCount: 3,
3620
+ role: 'group',
3621
+ 'data-modified': isModified
3622
+ }, ...getItemHeadingDom(heading), {
3623
+ type: VirtualDomElements.Div,
3624
+ className: SettingsItemCheckBox,
3625
+ childCount: 2
3626
+ }, {
3627
+ type: VirtualDomElements.Input,
3628
+ className: mergeClassNames('ColorInput'),
3629
+ inputType: 'color',
3630
+ placeholder: colorValue(),
3631
+ childCount: 0,
3632
+ id: domId,
3633
+ name: id,
3634
+ onInput: HandleSettingInput
3635
+ }, ...getItemLabelDom(domId, description)];
3636
+ };
3637
+
3542
3638
  const getItemNumberVirtualDom = item => {
3543
3639
  const {
3544
3640
  heading,
@@ -3595,6 +3691,7 @@ const getItemSelectVirtualDom = item => {
3595
3691
  type: VirtualDomElements.Select,
3596
3692
  className: Select,
3597
3693
  childCount: options.length,
3694
+ id: domId,
3598
3695
  name: id,
3599
3696
  onChange: HandleSettingSelect
3600
3697
  }, ...options.flatMap(getOptionDom)];
@@ -3637,6 +3734,33 @@ const getItemUnknownVirtualDom = () => {
3637
3734
  }, text(unknownSettingType())];
3638
3735
  };
3639
3736
 
3737
+ const getItemUrlVirtualDom = item => {
3738
+ const {
3739
+ heading,
3740
+ description,
3741
+ id,
3742
+ modified
3743
+ } = item;
3744
+ const domId = getInputId(id);
3745
+ const isModified = modified || false;
3746
+ return [{
3747
+ type: VirtualDomElements.Div,
3748
+ className: SettingsItem,
3749
+ childCount: 3,
3750
+ role: 'group',
3751
+ 'data-modified': isModified
3752
+ }, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
3753
+ type: VirtualDomElements.Input,
3754
+ className: InputBox,
3755
+ inputType: 'url',
3756
+ placeholder: numberValue(),
3757
+ childCount: 0,
3758
+ id: domId,
3759
+ name: id,
3760
+ onInput: HandleSettingInput
3761
+ }];
3762
+ };
3763
+
3640
3764
  const getItemVirtualDom = item => {
3641
3765
  if (item.type === Number$1) {
3642
3766
  return getItemNumberVirtualDom(item);
@@ -3650,6 +3774,12 @@ const getItemVirtualDom = item => {
3650
3774
  if (item.type === Enum) {
3651
3775
  return getItemSelectVirtualDom(item);
3652
3776
  }
3777
+ if (item.type === Color) {
3778
+ return getItemColorVirtualDom(item);
3779
+ }
3780
+ if (item.type === Url) {
3781
+ return getItemUrlVirtualDom(item);
3782
+ }
3653
3783
  return getItemUnknownVirtualDom();
3654
3784
  };
3655
3785
 
@@ -3764,12 +3894,12 @@ const renderScrollOffset = (oldState, newState) => {
3764
3894
  return ['Viewlet.setProperty', id, selector, property, scrollOffset];
3765
3895
  };
3766
3896
 
3897
+ const enabledTypes = [Number$1, String, Color];
3767
3898
  const renderSettingValues = (oldState, newState) => {
3768
3899
  const {
3769
3900
  filteredItems,
3770
3901
  id
3771
3902
  } = newState;
3772
- const enabledTypes = [Number$1, String];
3773
3903
  const numericSettings = filteredItems.filter(item => enabledTypes.includes(item.type));
3774
3904
  const inputValues = numericSettings.map(item => ({
3775
3905
  name: item.id,
@@ -3796,6 +3926,10 @@ const getRenderer = diffType => {
3796
3926
  return renderSettingValues;
3797
3927
  case RenderScrollOffset:
3798
3928
  return renderScrollOffset;
3929
+ case RenderFocusContext:
3930
+ return renderFocusContext;
3931
+ case RenderFocus:
3932
+ return renderFocus;
3799
3933
  default:
3800
3934
  throw new Error('unknown renderer');
3801
3935
  }
@@ -3847,6 +3981,9 @@ const renderEventListeners = () => {
3847
3981
  }, {
3848
3982
  name: HandleSettingSelect,
3849
3983
  params: ['handleSettingSelect', 'event.target.name', 'event.target.value']
3984
+ }, {
3985
+ name: HandleInputFocus,
3986
+ params: ['handleInputFocus']
3850
3987
  }];
3851
3988
  };
3852
3989
 
@@ -3854,7 +3991,8 @@ const saveState = state => {
3854
3991
  const {
3855
3992
  tabs,
3856
3993
  searchValue,
3857
- scrollOffset
3994
+ scrollOffset,
3995
+ focus
3858
3996
  } = state;
3859
3997
  const selectedTab = getSelectedTabId(tabs);
3860
3998
  return {
@@ -3865,7 +4003,8 @@ const saveState = state => {
3865
4003
  deltaY: 0,
3866
4004
  searchValue,
3867
4005
  selectedTab,
3868
- scrollOffset
4006
+ scrollOffset,
4007
+ focus
3869
4008
  };
3870
4009
  };
3871
4010
 
@@ -3918,14 +4057,17 @@ const usePreviousSearchValue = state => {
3918
4057
  const commandMap = {
3919
4058
  'Initialize.initialize': initialize,
3920
4059
  'Settings.clear': wrapCommand(clear$1),
4060
+ 'Settings.clearHistory': wrapCommand(clearHistory),
3921
4061
  'Settings.create': create$1,
3922
4062
  'Settings.diff2': diff2,
4063
+ 'Settings.getName': getName,
3923
4064
  'Settings.getCommandIds': getCommandIds,
3924
4065
  'Settings.handleClickTab': wrapCommand(handleClickTab),
3925
4066
  'Settings.handleInput': wrapCommand(handleInput),
3926
4067
  'Settings.handleScroll': wrapCommand(handleScroll),
3927
4068
  'Settings.handleSettingChecked': wrapCommand(handleSettingChecked),
3928
4069
  'Settings.handleSettingInput': wrapCommand(handleSettingInput),
4070
+ 'Settings.handleInputFocus': wrapCommand(handleInputFocus),
3929
4071
  'Settings.handleSettingSelect': wrapCommand(handleSettingSelect),
3930
4072
  'Settings.loadContent': wrapCommand(loadContent),
3931
4073
  'Settings.render2': render2,
@@ -3935,7 +4077,8 @@ const commandMap = {
3935
4077
  'Settings.saveState': wrapGetter(saveState),
3936
4078
  'Settings.terminate': terminate,
3937
4079
  'Settings.useNextSearchValue': wrapCommand(useNextSearchValue),
3938
- 'Settings.usePreviousSearchValue': wrapCommand(usePreviousSearchValue)
4080
+ 'Settings.usePreviousSearchValue': wrapCommand(usePreviousSearchValue),
4081
+ 'Settings.getKeyBindings': getKeyBindings
3939
4082
  };
3940
4083
 
3941
4084
  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.16.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",