@lvce-editor/settings-view 1.3.0 → 1.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.
@@ -914,6 +914,13 @@ 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,
@@ -933,7 +940,9 @@ const create$1 = (id, uri, x, y, width, height) => {
933
940
  y,
934
941
  width,
935
942
  height,
936
- tabs: []
943
+ tabs: [],
944
+ items: [],
945
+ searchValue: ''
937
946
  };
938
947
  set$1(id, state, state);
939
948
  };
@@ -972,20 +981,106 @@ const diff2 = uid => {
972
981
  return diffResult;
973
982
  };
974
983
 
984
+ const getSelectedTabId = tabs => {
985
+ for (const tab of tabs) {
986
+ if (tab.selected) {
987
+ return tab.id;
988
+ }
989
+ }
990
+ return '';
991
+ };
992
+ const getUpdatedTabs = (tabs, selectedTabId) => {
993
+ // Check if the clicked tab is already selected
994
+ const clickedTabId = getSelectedTabId(tabs);
995
+ if (clickedTabId === selectedTabId) {
996
+ return tabs;
997
+ }
998
+ return tabs.map(tab => ({
999
+ ...tab,
1000
+ selected: tab.id === selectedTabId
1001
+ }));
1002
+ };
1003
+
1004
+ const handleClickTab = (state, name) => {
1005
+ if (!name) {
1006
+ return state;
1007
+ }
1008
+ return {
1009
+ ...state,
1010
+ tabs: getUpdatedTabs(state.tabs, name)
1011
+ };
1012
+ };
1013
+
1014
+ const handleInput = (state, value) => {
1015
+ return {
1016
+ ...state,
1017
+ searchValue: value
1018
+ };
1019
+ };
1020
+
975
1021
  const initialize = async () => {
976
1022
  // TODO
977
1023
  };
978
1024
 
1025
+ const String = 2;
1026
+ const Number$1 = 5;
1027
+
1028
+ const getSettingItems = async () => {
1029
+ return [{
1030
+ id: 'fontSize',
1031
+ heading: 'Font Size',
1032
+ description: 'The font size of the editor',
1033
+ type: Number$1,
1034
+ value: '15px'
1035
+ }, {
1036
+ id: 'fontFamily',
1037
+ heading: 'Font Family',
1038
+ description: 'The font family of the editor',
1039
+ type: String,
1040
+ value: 'Fira Code'
1041
+ }];
1042
+ };
1043
+
979
1044
  const getTabs = () => {
980
- const tabs = ['Text Editor', 'Workbench', 'Window', 'Features', 'Applications', 'Security', 'Extensions'];
1045
+ const tabs = [{
1046
+ id: 'text-editor',
1047
+ label: 'Text Editor',
1048
+ selected: true
1049
+ }, {
1050
+ id: 'workbench',
1051
+ label: 'Workbench',
1052
+ selected: false
1053
+ }, {
1054
+ id: 'window',
1055
+ label: 'Window',
1056
+ selected: false
1057
+ }, {
1058
+ id: 'features',
1059
+ label: 'Features',
1060
+ selected: false
1061
+ }, {
1062
+ id: 'applications',
1063
+ label: 'Applications',
1064
+ selected: false
1065
+ }, {
1066
+ id: 'security',
1067
+ label: 'Security',
1068
+ selected: false
1069
+ }, {
1070
+ id: 'extensions',
1071
+ label: 'Extensions',
1072
+ selected: false
1073
+ }];
981
1074
  return tabs;
982
1075
  };
983
1076
 
984
1077
  const loadContent = async (state, savedState) => {
985
1078
  const tabs = getTabs();
1079
+ const items = await getSettingItems();
986
1080
  return {
987
1081
  ...state,
988
- tabs
1082
+ tabs,
1083
+ items
989
1084
  };
990
1085
  };
991
1086
 
@@ -1002,18 +1097,28 @@ const ClassNames = {
1002
1097
  const mergeClassNames = (...classNames) => {
1003
1098
  return classNames.filter(Boolean).join(' ');
1004
1099
  };
1100
+ const Button = 1;
1005
1101
  const Div = 4;
1102
+ const H1 = 5;
1006
1103
  const Input = 6;
1007
1104
  const Text = 12;
1008
1105
  const H2 = 22;
1106
+ const H3 = 23;
1009
1107
  const Aside = 28;
1108
+ const Li = 48;
1109
+ const P = 50;
1010
1110
  const Ul = 60;
1011
1111
  const VirtualDomElements = {
1012
1112
  __proto__: null,
1013
1113
  Aside,
1114
+ Button,
1014
1115
  Div,
1116
+ H1,
1015
1117
  H2,
1118
+ H3,
1016
1119
  Input,
1120
+ Li,
1121
+ P,
1017
1122
  Ul};
1018
1123
  const text = data => {
1019
1124
  return {
@@ -1027,17 +1132,30 @@ const {
1027
1132
  Viewlet} = ClassNames;
1028
1133
  const Settings = 'Settings';
1029
1134
 
1135
+ const SettingsSearch = 'SettingsSearch';
1136
+ const Clear = 'Clear';
1137
+
1030
1138
  const getSettingsInputDom = () => {
1031
1139
  const placeholder = 'Search Settings';
1032
1140
  return [{
1033
1141
  type: VirtualDomElements.Div,
1034
1142
  className: 'SettingsInputWrapper',
1035
- childCount: 1
1143
+ childCount: 2
1036
1144
  }, {
1037
1145
  type: VirtualDomElements.Input,
1038
1146
  className: 'InputBox SettingsSearchInput',
1039
- placeholder
1040
- }];
1147
+ placeholder,
1148
+ childCount: 0,
1149
+ name: SettingsSearch // TODO add input event listener
1150
+ }, {
1151
+ type: VirtualDomElements.Button,
1152
+ className: 'Button InputButton',
1153
+ childCount: 1,
1154
+ ariaLabel: 'Clear',
1155
+ // TODO i18n string
1156
+ name: Clear // TODO add click event listener
1157
+ }, text('Clear') // TODO use icon
1158
+ ];
1041
1159
  };
1042
1160
 
1043
1161
  const getSettingsHeaderDom = () => {
@@ -1048,21 +1166,63 @@ const getSettingsHeaderDom = () => {
1048
1166
  }, ...getSettingsInputDom()];
1049
1167
  };
1050
1168
 
1051
- const getSettingsContentDom = () => {
1169
+ const getItemNumberVirtualDom = item => {
1170
+ const {
1171
+ heading,
1172
+ description
1173
+ } = item;
1174
+ return [{
1175
+ type: VirtualDomElements.Div,
1176
+ className: 'SettingsItem',
1177
+ childCount: 3
1178
+ }, {
1179
+ type: VirtualDomElements.H3,
1180
+ childCount: 1
1181
+ }, text(heading), {
1182
+ type: VirtualDomElements.P,
1183
+ childCount: 1
1184
+ }, text(description), {
1185
+ type: VirtualDomElements.Input,
1186
+ className: 'InputBox',
1187
+ inputType: 'number',
1188
+ placeholder: 'number value',
1189
+ childCount: 0
1190
+ }];
1191
+ };
1192
+
1193
+ const getSettingsItemsDom = items => {
1194
+ return [{
1195
+ type: VirtualDomElements.Div,
1196
+ className: 'SettingsItems',
1197
+ childCount: items.length
1198
+ }, ...items.flatMap(getItemNumberVirtualDom)];
1199
+ };
1200
+
1201
+ const getSettingsContentDom = items => {
1052
1202
  return [{
1053
1203
  type: VirtualDomElements.Div,
1054
1204
  className: 'SettingsContent',
1205
+ childCount: 2
1206
+ }, {
1207
+ type: VirtualDomElements.H1,
1055
1208
  childCount: 1
1056
- }, text('Settings Content')];
1209
+ }, text('Settings Content'), ...getSettingsItemsDom(items)];
1057
1210
  };
1058
1211
 
1212
+ const HandleClickTab = 'handleClickTab';
1213
+ const HandleInput = 'handleInput';
1214
+
1215
+ // TODo use numeric ids
1216
+
1059
1217
  const getTabVirtualDom = tab => {
1218
+ const className = tab.selected ? mergeClassNames('Tab', 'TabSelected') : 'Tab';
1060
1219
  return [{
1061
- type: VirtualDomElements.Div,
1062
- className: 'Tab',
1220
+ type: VirtualDomElements.Li,
1221
+ className,
1063
1222
  childCount: 1,
1064
- role: AriaRoles.Tab
1065
- }, text(tab)];
1223
+ role: AriaRoles.Tab,
1224
+ name: tab.id
1225
+ }, text(tab.label)];
1066
1226
  };
1067
1227
 
1068
1228
  const getSettingsTabsDom = tabs => {
@@ -1070,7 +1230,8 @@ const getSettingsTabsDom = tabs => {
1070
1230
  type: VirtualDomElements.Ul,
1071
1231
  className: 'SettingsTabs',
1072
1232
  role: AriaRoles.TabList,
1073
- childCount: tabs.length
1233
+ childCount: tabs.length,
1234
+ onClick: HandleClickTab
1074
1235
  }, ...tabs.flatMap(getTabVirtualDom)];
1075
1236
  };
1076
1237
 
@@ -1087,23 +1248,24 @@ const getSettingsSideBarDom = tabs => {
1087
1248
  }, text(sideBarHeading), ...getSettingsTabsDom(tabs)];
1088
1249
  };
1089
1250
 
1090
- const getSettingsMainDom = tabs => {
1251
+ const getSettingsMainDom = (tabs, items) => {
1091
1252
  return [{
1092
1253
  type: VirtualDomElements.Div,
1093
1254
  className: 'SettingsMain',
1094
1255
  childCount: 2
1095
- }, ...getSettingsSideBarDom(tabs), ...getSettingsContentDom()];
1256
+ }, ...getSettingsSideBarDom(tabs), ...getSettingsContentDom(items)];
1096
1257
  };
1097
1258
 
1098
1259
  const getSettingsDom = state => {
1099
1260
  const {
1100
- tabs
1261
+ tabs,
1262
+ items
1101
1263
  } = state;
1102
1264
  return [{
1103
1265
  type: VirtualDomElements.Div,
1104
1266
  childCount: 2,
1105
1267
  className: mergeClassNames(Viewlet, Settings)
1106
- }, ...getSettingsHeaderDom(), ...getSettingsMainDom(tabs)];
1268
+ }, ...getSettingsHeaderDom(), ...getSettingsMainDom(tabs, items)];
1107
1269
  };
1108
1270
 
1109
1271
  const renderItems = (oldState, newState) => {
@@ -1143,108 +1305,13 @@ const renderActions = () => {
1143
1305
  return [];
1144
1306
  };
1145
1307
 
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
1308
  const renderEventListeners = () => {
1172
1309
  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']
1205
- }, {
1206
- name: HandleDebugInput,
1207
- params: ['handleDebugInput', 'event.target.value']
1208
- }, {
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
1310
+ name: HandleClickTab,
1311
+ params: ['handleClickTab', 'event.target.name']
1244
1312
  }, {
1245
- name: HandleWatchExpressionContextMenu,
1246
- params: ['handleWatchExpressionContextMenu', 'event.clientX', 'event.clientY', 'event.target.dataset.index'],
1247
- preventDefault: true
1313
+ name: HandleInput,
1314
+ params: ['handleInput', 'event.target.value']
1248
1315
  }];
1249
1316
  };
1250
1317
 
@@ -1305,7 +1372,10 @@ const commandMap = {
1305
1372
  'Settings.renderEventListeners': renderEventListeners,
1306
1373
  'Settings.restoreState': restoreState,
1307
1374
  'Settings.saveState': saveState,
1308
- 'Settings.terminate': terminate
1375
+ 'Settings.terminate': terminate,
1376
+ 'Settings.handleClickTab': wrapCommand(handleClickTab),
1377
+ 'Settings.clear': wrapCommand(clear),
1378
+ 'Settings.handleInput': wrapCommand(handleInput)
1309
1379
  };
1310
1380
 
1311
1381
  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.4.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",