@lvce-editor/settings-view 1.3.0 → 1.5.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.
@@ -914,12 +914,20 @@ const terminate = () => {
914
914
  globalThis.close();
915
915
  };
916
916
 
917
+ const clear = state => {
918
+ return {
919
+ ...state,
920
+ searchValue: ''
921
+ };
922
+ };
923
+
917
924
  const {
918
925
  get: get$1,
919
926
  set: set$1,
920
927
  wrapCommand,
921
928
  getCommandIds,
922
- registerCommands
929
+ registerCommands,
930
+ wrapGetter
923
931
  } = create$2();
924
932
 
925
933
  const create$1 = (id, uri, x, y, width, height) => {
@@ -933,7 +941,10 @@ const create$1 = (id, uri, x, y, width, height) => {
933
941
  y,
934
942
  width,
935
943
  height,
936
- tabs: []
944
+ tabs: [],
945
+ items: [],
946
+ searchValue: '',
947
+ filteredItems: []
937
948
  };
938
949
  set$1(id, state, state);
939
950
  };
@@ -972,20 +983,217 @@ const diff2 = uid => {
972
983
  return diffResult;
973
984
  };
974
985
 
986
+ const getFilteredItems = (items, tabs) => {
987
+ const selectedTab = tabs.find(tab => tab.selected);
988
+ if (!selectedTab) {
989
+ return items;
990
+ }
991
+ return items.filter(item => item.category === selectedTab.id);
992
+ };
993
+
994
+ const getSelectedTabId = tabs => {
995
+ for (const tab of tabs) {
996
+ if (tab.selected) {
997
+ return tab.id;
998
+ }
999
+ }
1000
+ return '';
1001
+ };
1002
+
1003
+ const getUpdatedTabs = (tabs, selectedTabId) => {
1004
+ // Check if the clicked tab is already selected
1005
+ const clickedTabId = getSelectedTabId(tabs);
1006
+ if (clickedTabId === selectedTabId) {
1007
+ return tabs;
1008
+ }
1009
+ return tabs.map(tab => ({
1010
+ ...tab,
1011
+ selected: tab.id === selectedTabId
1012
+ }));
1013
+ };
1014
+
1015
+ const handleClickTab = (state, name) => {
1016
+ if (!name) {
1017
+ return state;
1018
+ }
1019
+ const updatedTabs = getUpdatedTabs(state.tabs, name);
1020
+ const filteredItems = getFilteredItems(state.items, updatedTabs);
1021
+ return {
1022
+ ...state,
1023
+ tabs: updatedTabs,
1024
+ filteredItems
1025
+ };
1026
+ };
1027
+
1028
+ const handleInput = (state, value) => {
1029
+ return {
1030
+ ...state,
1031
+ searchValue: value
1032
+ };
1033
+ };
1034
+
975
1035
  const initialize = async () => {
976
1036
  // TODO
977
1037
  };
978
1038
 
1039
+ const ApplicationsTab = 'applications';
1040
+ const Clear = 'Clear';
1041
+ const ExtensionsTab = 'extensions';
1042
+ const FeaturesTab = 'features';
1043
+ const SecurityTab = 'security';
1044
+ const SettingsSearch = 'SettingsSearch';
1045
+ const TextEditorTab = 'text-editor';
1046
+ const WindowTab = 'window';
1047
+ const WorkbenchTab = 'workbench';
1048
+
1049
+ const String = 2;
1050
+ const Boolean$1 = 3;
1051
+ const Number$1 = 5;
1052
+
1053
+ const getSettingItems = async () => {
1054
+ return [{
1055
+ id: 'fontSize',
1056
+ heading: 'Font Size',
1057
+ description: 'The font size of the editor',
1058
+ type: Number$1,
1059
+ value: '15px',
1060
+ category: TextEditorTab
1061
+ }, {
1062
+ id: 'fontFamily',
1063
+ heading: 'Font Family',
1064
+ description: 'The font family of the editor',
1065
+ type: String,
1066
+ value: 'Fira Code',
1067
+ category: TextEditorTab
1068
+ }, {
1069
+ id: 'theme',
1070
+ heading: 'Theme',
1071
+ description: 'The color theme of the workbench',
1072
+ type: String,
1073
+ value: 'Dark',
1074
+ category: WorkbenchTab
1075
+ }, {
1076
+ id: 'sidebarPosition',
1077
+ heading: 'Sidebar Position',
1078
+ description: 'The position of the sidebar',
1079
+ type: String,
1080
+ value: 'Left',
1081
+ category: WorkbenchTab
1082
+ }, {
1083
+ id: 'windowTitle',
1084
+ heading: 'Window Title',
1085
+ description: 'The title shown in the window',
1086
+ type: String,
1087
+ value: 'Settings View',
1088
+ category: WindowTab
1089
+ }, {
1090
+ id: 'windowSize',
1091
+ heading: 'Window Size',
1092
+ description: 'The default window size',
1093
+ type: String,
1094
+ value: '1024x768',
1095
+ category: WindowTab
1096
+ }, {
1097
+ id: 'autoSave',
1098
+ heading: 'Auto Save',
1099
+ description: 'Automatically save files',
1100
+ type: Boolean$1,
1101
+ value: 'true',
1102
+ category: FeaturesTab
1103
+ }, {
1104
+ id: 'formatOnSave',
1105
+ heading: 'Format on Save',
1106
+ description: 'Format code when saving',
1107
+ type: Boolean$1,
1108
+ value: 'false',
1109
+ category: FeaturesTab
1110
+ }, {
1111
+ id: 'telemetry',
1112
+ heading: 'Telemetry',
1113
+ description: 'Enable telemetry collection',
1114
+ type: Boolean$1,
1115
+ value: 'true',
1116
+ category: ApplicationsTab
1117
+ }, {
1118
+ id: 'updates',
1119
+ heading: 'Auto Updates',
1120
+ description: 'Automatically check for updates',
1121
+ type: Boolean$1,
1122
+ value: 'true',
1123
+ category: ApplicationsTab
1124
+ }, {
1125
+ id: 'encryption',
1126
+ heading: 'File Encryption',
1127
+ description: 'Encrypt sensitive files',
1128
+ type: Boolean$1,
1129
+ value: 'false',
1130
+ category: SecurityTab
1131
+ }, {
1132
+ id: 'twoFactor',
1133
+ heading: 'Two Factor Auth',
1134
+ description: 'Enable two factor authentication',
1135
+ type: Boolean$1,
1136
+ value: 'false',
1137
+ category: SecurityTab
1138
+ }, {
1139
+ id: 'extensionsAutoUpdate',
1140
+ heading: 'Auto Update Extensions',
1141
+ description: 'Automatically update extensions',
1142
+ type: Boolean$1,
1143
+ value: 'true',
1144
+ category: ExtensionsTab
1145
+ }, {
1146
+ id: 'extensionRecommendations',
1147
+ heading: 'Extension Recommendations',
1148
+ description: 'Show extension recommendations',
1149
+ type: Boolean$1,
1150
+ value: 'true',
1151
+ category: ExtensionsTab
1152
+ }];
1153
+ };
1154
+
979
1155
  const getTabs = () => {
980
- const tabs = ['Text Editor', 'Workbench', 'Window', 'Features', 'Applications', 'Security', 'Extensions'];
1156
+ const tabs = [{
1157
+ id: TextEditorTab,
1158
+ label: 'Text Editor',
1159
+ selected: true
1160
+ }, {
1161
+ id: WorkbenchTab,
1162
+ label: 'Workbench',
1163
+ selected: false
1164
+ }, {
1165
+ id: WindowTab,
1166
+ label: 'Window',
1167
+ selected: false
1168
+ }, {
1169
+ id: FeaturesTab,
1170
+ label: 'Features',
1171
+ selected: false
1172
+ }, {
1173
+ id: ApplicationsTab,
1174
+ label: 'Applications',
1175
+ selected: false
1176
+ }, {
1177
+ id: SecurityTab,
1178
+ label: 'Security',
1179
+ selected: false
1180
+ }, {
1181
+ id: ExtensionsTab,
1182
+ label: 'Extensions',
1183
+ selected: false
1184
+ }];
981
1185
  return tabs;
982
1186
  };
983
1187
 
984
1188
  const loadContent = async (state, savedState) => {
985
1189
  const tabs = getTabs();
1190
+ const items = await getSettingItems();
1191
+ const filteredItems = getFilteredItems(items, tabs);
986
1192
  return {
987
1193
  ...state,
988
- tabs
1194
+ tabs,
1195
+ items,
1196
+ filteredItems
989
1197
  };
990
1198
  };
991
1199
 
@@ -1002,18 +1210,26 @@ const ClassNames = {
1002
1210
  const mergeClassNames = (...classNames) => {
1003
1211
  return classNames.filter(Boolean).join(' ');
1004
1212
  };
1213
+ const Button = 1;
1005
1214
  const Div = 4;
1215
+ const H1 = 5;
1006
1216
  const Input = 6;
1007
1217
  const Text = 12;
1008
1218
  const H2 = 22;
1219
+ const H3 = 23;
1009
1220
  const Aside = 28;
1221
+ const P = 50;
1010
1222
  const Ul = 60;
1011
1223
  const VirtualDomElements = {
1012
1224
  __proto__: null,
1013
1225
  Aside,
1226
+ Button,
1014
1227
  Div,
1228
+ H1,
1015
1229
  H2,
1230
+ H3,
1016
1231
  Input,
1232
+ P,
1017
1233
  Ul};
1018
1234
  const text = data => {
1019
1235
  return {
@@ -1032,12 +1248,22 @@ const getSettingsInputDom = () => {
1032
1248
  return [{
1033
1249
  type: VirtualDomElements.Div,
1034
1250
  className: 'SettingsInputWrapper',
1035
- childCount: 1
1251
+ childCount: 2
1036
1252
  }, {
1037
1253
  type: VirtualDomElements.Input,
1038
1254
  className: 'InputBox SettingsSearchInput',
1039
- placeholder
1040
- }];
1255
+ placeholder,
1256
+ childCount: 0,
1257
+ name: SettingsSearch // TODO add input event listener
1258
+ }, {
1259
+ type: VirtualDomElements.Button,
1260
+ className: 'Button InputButton',
1261
+ childCount: 1,
1262
+ ariaLabel: 'Clear',
1263
+ // TODO i18n string
1264
+ name: Clear // TODO add click event listener
1265
+ }, text('Clear') // TODO use icon
1266
+ ];
1041
1267
  };
1042
1268
 
1043
1269
  const getSettingsHeaderDom = () => {
@@ -1048,21 +1274,71 @@ const getSettingsHeaderDom = () => {
1048
1274
  }, ...getSettingsInputDom()];
1049
1275
  };
1050
1276
 
1051
- const getSettingsContentDom = () => {
1277
+ const getItemNumberVirtualDom = item => {
1278
+ const {
1279
+ heading,
1280
+ description
1281
+ } = item;
1282
+ return [{
1283
+ type: VirtualDomElements.Div,
1284
+ className: 'SettingsItem',
1285
+ childCount: 3
1286
+ }, {
1287
+ type: VirtualDomElements.H3,
1288
+ childCount: 1
1289
+ }, text(heading), {
1290
+ type: VirtualDomElements.P,
1291
+ childCount: 1
1292
+ }, text(description), {
1293
+ type: VirtualDomElements.Input,
1294
+ className: 'InputBox',
1295
+ inputType: 'number',
1296
+ placeholder: 'number value',
1297
+ childCount: 0
1298
+ }];
1299
+ };
1300
+
1301
+ const getSettingsItemsDom = items => {
1302
+ return [{
1303
+ type: VirtualDomElements.Div,
1304
+ className: 'SettingsItems',
1305
+ childCount: items.length
1306
+ }, ...items.flatMap(getItemNumberVirtualDom)];
1307
+ };
1308
+
1309
+ const getSettingsContentDom = (items, tabs) => {
1310
+ const selectedTab = tabs.find(tab => tab.selected);
1311
+ const headerText = selectedTab ? selectedTab.label : 'Settings Content';
1052
1312
  return [{
1053
1313
  type: VirtualDomElements.Div,
1054
1314
  className: 'SettingsContent',
1315
+ childCount: 2
1316
+ }, {
1317
+ type: VirtualDomElements.H1,
1055
1318
  childCount: 1
1056
- }, text('Settings Content')];
1319
+ }, text(headerText), ...getSettingsItemsDom(items)];
1320
+ };
1321
+
1322
+ // TODo use numeric ids
1323
+ const HandleClickClear = 'handleClickClear';
1324
+ const HandleClickTab = 'handleClickTab';
1325
+ const HandleInput = 'handleInput';
1326
+
1327
+ const getTabClassName = tab => {
1328
+ return tab.selected ? mergeClassNames('Tab', 'TabSelected') : 'Tab';
1057
1329
  };
1058
1330
 
1059
1331
  const getTabVirtualDom = tab => {
1332
+ const className = getTabClassName(tab);
1060
1333
  return [{
1061
- type: VirtualDomElements.Div,
1062
- className: 'Tab',
1334
+ type: VirtualDomElements.Button,
1335
+ className,
1063
1336
  childCount: 1,
1064
- role: AriaRoles.Tab
1065
- }, text(tab)];
1337
+ role: AriaRoles.Tab,
1338
+ name: tab.id,
1339
+ id: tab.id,
1340
+ ariaSelected: tab.selected
1341
+ }, text(tab.label)];
1066
1342
  };
1067
1343
 
1068
1344
  const getSettingsTabsDom = tabs => {
@@ -1070,7 +1346,8 @@ const getSettingsTabsDom = tabs => {
1070
1346
  type: VirtualDomElements.Ul,
1071
1347
  className: 'SettingsTabs',
1072
1348
  role: AriaRoles.TabList,
1073
- childCount: tabs.length
1349
+ childCount: tabs.length,
1350
+ onClick: HandleClickTab
1074
1351
  }, ...tabs.flatMap(getTabVirtualDom)];
1075
1352
  };
1076
1353
 
@@ -1087,23 +1364,24 @@ const getSettingsSideBarDom = tabs => {
1087
1364
  }, text(sideBarHeading), ...getSettingsTabsDom(tabs)];
1088
1365
  };
1089
1366
 
1090
- const getSettingsMainDom = tabs => {
1367
+ const getSettingsMainDom = (tabs, items) => {
1091
1368
  return [{
1092
1369
  type: VirtualDomElements.Div,
1093
1370
  className: 'SettingsMain',
1094
1371
  childCount: 2
1095
- }, ...getSettingsSideBarDom(tabs), ...getSettingsContentDom()];
1372
+ }, ...getSettingsSideBarDom(tabs), ...getSettingsContentDom(items, tabs)];
1096
1373
  };
1097
1374
 
1098
1375
  const getSettingsDom = state => {
1099
1376
  const {
1100
- tabs
1377
+ tabs,
1378
+ filteredItems
1101
1379
  } = state;
1102
1380
  return [{
1103
1381
  type: VirtualDomElements.Div,
1104
1382
  childCount: 2,
1105
1383
  className: mergeClassNames(Viewlet, Settings)
1106
- }, ...getSettingsHeaderDom(), ...getSettingsMainDom(tabs)];
1384
+ }, ...getSettingsHeaderDom(), ...getSettingsMainDom(tabs, filteredItems)];
1107
1385
  };
1108
1386
 
1109
1387
  const renderItems = (oldState, newState) => {
@@ -1143,108 +1421,16 @@ const renderActions = () => {
1143
1421
  return [];
1144
1422
  };
1145
1423
 
1146
- const HandleClickCallStackItem = 'handleClickCallStackItem';
1147
- const HandleClickWatchExpression = 'handleClickWatchExpression';
1148
- const HandleClickWatchExpressionDelete = 'handleClickWatchExpressionDelete';
1149
- const HandleClickCheckBox = 'handleClickCheckBox';
1150
- const HandleClickContinue = 'handleClickContinue';
1151
- const HandleClickDebugButton = 'handleClickDebugButton';
1152
- const HandleClickPause = 'handleClickPause';
1153
- const HandleClickScopeValue = 'handleClickScopeValue';
1154
- const HandleClickSectionBreakPoints = 'handleClickSectionBreakPoints';
1155
- const HandleClickSectionCallstack = 'handleClickSectionCallstack';
1156
- const HandleClickSectionHeading = 'handleClickSectionHeading';
1157
- const HandleClickSectionScope = 'handleClickSectionScope';
1158
- const HandleClickSectionWatch = 'handleClickSectionWatch';
1159
- const HandleClickStepInto = 'handleClickStepInto';
1160
- const HandleClickStepOut = 'handleClickStepOut';
1161
- const HandleClickStepOver = 'handleClickStepOver';
1162
- const HandleDebugInput = 'handleDebugInput';
1163
- const HandleClickSectionAction = 'handleClickSectionAction';
1164
- const HandleInputFieldChange = 'handleInputFieldChange';
1165
- const HandleInputBlur = 'handleInputBlur';
1166
- const HandleSectionHeaderContextMenu = 'handleSectionHeaderContextMenu';
1167
- const HandleWatchExpressionContextMenu = 'handleWatchExpressionContextMenu';
1168
-
1169
- // TODo use numeric ids
1170
-
1171
1424
  const renderEventListeners = () => {
1172
1425
  return [{
1173
- name: HandleClickContinue,
1174
- params: ['handleClickContinue']
1175
- }, {
1176
- name: HandleClickDebugButton,
1177
- params: ['handleClickDebugButton', 'event.target.name']
1178
- }, {
1179
- name: HandleClickPause,
1180
- params: ['handleClickPause']
1181
- }, {
1182
- name: HandleClickStepOver,
1183
- params: ['handleClickStepOver']
1184
- }, {
1185
- name: HandleClickStepInto,
1186
- params: ['handleClickStepInto']
1187
- }, {
1188
- name: HandleClickStepOut,
1189
- params: ['handleClickStepOut']
1190
- }, {
1191
- name: HandleClickSectionWatch,
1192
- params: ['HandleClickSectionWatch']
1193
- }, {
1194
- name: HandleClickSectionBreakPoints,
1195
- params: ['handleClickSectionBreakpoints']
1196
- }, {
1197
- name: HandleClickSectionScope,
1198
- params: ['handleClickSectionScope']
1199
- }, {
1200
- name: HandleClickSectionCallstack,
1201
- params: ['handleClickSectionCallstack']
1202
- }, {
1203
- name: HandleClickSectionBreakPoints,
1204
- params: ['handleClickSectionBreakPoints']
1426
+ name: HandleClickTab,
1427
+ params: ['handleClickTab', 'event.target.name']
1205
1428
  }, {
1206
- name: HandleDebugInput,
1207
- params: ['handleDebugInput', 'event.target.value']
1429
+ name: HandleInput,
1430
+ params: ['handleInput', 'event.target.value']
1208
1431
  }, {
1209
- name: HandleClickSectionHeading,
1210
- params: ['handleClickSectionHeading', 'event.target.dataset.name', 'event.button'],
1211
- preventDefault: true
1212
- }, {
1213
- name: HandleClickCheckBox,
1214
- params: ['handleClickCheckBox', 'event.target.name']
1215
- }, {
1216
- name: HandleClickDebugButton,
1217
- params: ['handleClickDebugButton', 'event.target.name']
1218
- }, {
1219
- name: HandleClickCallStackItem,
1220
- params: ['handleClickCallStackItem', 'event.target.dataset.index']
1221
- }, {
1222
- name: HandleClickWatchExpression,
1223
- params: ['handleClickWatchExpression', 'event.target.dataset.index', 'event.defaultPrevented']
1224
- }, {
1225
- name: HandleClickWatchExpressionDelete,
1226
- params: ['handleClickWatchExpressionDelete', 'event.target.dataset.index'],
1227
- preventDefault: true
1228
- }, {
1229
- name: HandleClickScopeValue,
1230
- params: ['handleClickScopeValue', 'event.target.dataset.index', 'event.button']
1231
- }, {
1232
- name: HandleInputFieldChange,
1233
- params: ['handleInputFieldChange', 'event.target.name', 'event.target.value']
1234
- }, {
1235
- name: HandleClickSectionAction,
1236
- params: ['handleClickSectionAction', 'event.target.name']
1237
- }, {
1238
- name: HandleInputBlur,
1239
- params: ['handleInputBlur']
1240
- }, {
1241
- name: HandleSectionHeaderContextMenu,
1242
- params: ['handleSectionHeaderContextMenu', 'event.clientX', 'event.clientY', 'event.target.dataset.name'],
1243
- preventDefault: true
1244
- }, {
1245
- name: HandleWatchExpressionContextMenu,
1246
- params: ['handleWatchExpressionContextMenu', 'event.clientX', 'event.clientY', 'event.target.dataset.index'],
1247
- preventDefault: true
1432
+ name: HandleClickClear,
1433
+ params: ['clear']
1248
1434
  }];
1249
1435
  };
1250
1436
 
@@ -1284,13 +1470,20 @@ const restoreState = savedState => {
1284
1470
  };
1285
1471
  };
1286
1472
 
1287
- const saveState = uid => {
1473
+ const saveState = state => {
1474
+ const {
1475
+ tabs,
1476
+ searchValue
1477
+ } = state;
1478
+ const selectedTab = getSelectedTabId(tabs);
1288
1479
  return {
1289
1480
  expandedPaths: [],
1290
1481
  root: '',
1291
1482
  minLineY: 0,
1292
1483
  maxLineY: 0,
1293
- deltaY: 0
1484
+ deltaY: 0,
1485
+ searchValue,
1486
+ selectedTab
1294
1487
  };
1295
1488
  };
1296
1489
 
@@ -1304,8 +1497,11 @@ const commandMap = {
1304
1497
  'Settings.renderActions': renderActions,
1305
1498
  'Settings.renderEventListeners': renderEventListeners,
1306
1499
  'Settings.restoreState': restoreState,
1307
- 'Settings.saveState': saveState,
1308
- 'Settings.terminate': terminate
1500
+ 'Settings.saveState': wrapGetter(saveState),
1501
+ 'Settings.terminate': terminate,
1502
+ 'Settings.handleClickTab': wrapCommand(handleClickTab),
1503
+ 'Settings.clear': wrapCommand(clear),
1504
+ 'Settings.handleInput': wrapCommand(handleInput)
1309
1505
  };
1310
1506
 
1311
1507
  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.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",