@lvce-editor/settings-view 1.19.0 → 1.20.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/dist/settingsViewWorkerMain.js +183 -80
- package/package.json +1 -1
|
@@ -914,15 +914,14 @@ const terminate = () => {
|
|
|
914
914
|
globalThis.close();
|
|
915
915
|
};
|
|
916
916
|
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
modified: isItemModified(item, preferences)
|
|
924
|
-
}));
|
|
917
|
+
const filterBySearch = (items, searchValue) => {
|
|
918
|
+
if (!searchValue || !searchValue.trim()) {
|
|
919
|
+
return items;
|
|
920
|
+
}
|
|
921
|
+
const normalizedSearchValue = searchValue.toLowerCase().trim();
|
|
922
|
+
return items.filter(item => item.heading.toLowerCase().includes(normalizedSearchValue));
|
|
925
923
|
};
|
|
924
|
+
|
|
926
925
|
const filterByTab = (items, tabs) => {
|
|
927
926
|
const selectedTab = tabs.find(tab => tab.selected);
|
|
928
927
|
if (!selectedTab) {
|
|
@@ -930,17 +929,36 @@ const filterByTab = (items, tabs) => {
|
|
|
930
929
|
}
|
|
931
930
|
return items.filter(item => item.category === selectedTab.id);
|
|
932
931
|
};
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
}
|
|
937
|
-
const normalizedSearchValue = searchValue.toLowerCase().trim();
|
|
938
|
-
return items.filter(item => item.heading.toLowerCase().includes(normalizedSearchValue));
|
|
932
|
+
|
|
933
|
+
const isItemModified = (item, preferences) => {
|
|
934
|
+
return item.id in preferences;
|
|
939
935
|
};
|
|
940
|
-
const
|
|
936
|
+
const validateSettings = (items, modifiedSettings, preferences) => {
|
|
937
|
+
return items.map(item => {
|
|
938
|
+
const value = preferences[item.id] ?? item.value;
|
|
939
|
+
const errorMessage = item.validate ? item.validate(value) : '';
|
|
940
|
+
const hasError = errorMessage.length > 0;
|
|
941
|
+
const modified = isItemModified(item, modifiedSettings);
|
|
942
|
+
return {
|
|
943
|
+
id: item.id,
|
|
944
|
+
heading: item.heading,
|
|
945
|
+
description: item.description,
|
|
946
|
+
type: item.type,
|
|
947
|
+
value: item.value,
|
|
948
|
+
category: item.category,
|
|
949
|
+
options: item.options,
|
|
950
|
+
modified,
|
|
951
|
+
errorMessage,
|
|
952
|
+
hasError
|
|
953
|
+
};
|
|
954
|
+
});
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
const getFilteredItems = (items, tabs, searchValue, modifiedSettings, preferences) => {
|
|
941
958
|
const tabFilteredItems = filterByTab(items, tabs);
|
|
942
|
-
const
|
|
943
|
-
|
|
959
|
+
const searchFilteredItems = filterBySearch(tabFilteredItems, searchValue);
|
|
960
|
+
const validated = validateSettings(searchFilteredItems, modifiedSettings, preferences);
|
|
961
|
+
return validated;
|
|
944
962
|
};
|
|
945
963
|
|
|
946
964
|
const User = 1;
|
|
@@ -952,10 +970,11 @@ const clear$1 = state => {
|
|
|
952
970
|
const {
|
|
953
971
|
items,
|
|
954
972
|
tabs,
|
|
955
|
-
modifiedSettings
|
|
973
|
+
modifiedSettings,
|
|
974
|
+
preferences
|
|
956
975
|
} = state;
|
|
957
976
|
const newSearchValue = '';
|
|
958
|
-
const filteredItems = getFilteredItems(items, tabs, newSearchValue, modifiedSettings);
|
|
977
|
+
const filteredItems = getFilteredItems(items, tabs, newSearchValue, modifiedSettings, preferences);
|
|
959
978
|
return {
|
|
960
979
|
...state,
|
|
961
980
|
filteredItems,
|
|
@@ -1065,10 +1084,12 @@ const diff2 = uid => {
|
|
|
1065
1084
|
return diffResult;
|
|
1066
1085
|
};
|
|
1067
1086
|
|
|
1087
|
+
const Group = 'group';
|
|
1068
1088
|
const Tab$1 = 'tab';
|
|
1069
1089
|
const TabList = 'tablist';
|
|
1070
1090
|
const AriaRoles = {
|
|
1071
1091
|
__proto__: null,
|
|
1092
|
+
Group,
|
|
1072
1093
|
Tab: Tab$1,
|
|
1073
1094
|
TabList};
|
|
1074
1095
|
const Viewlet$1 = 'Viewlet';
|
|
@@ -1164,10 +1185,11 @@ const handleClickTab = (state, name) => {
|
|
|
1164
1185
|
items,
|
|
1165
1186
|
tabs,
|
|
1166
1187
|
searchValue,
|
|
1167
|
-
modifiedSettings
|
|
1188
|
+
modifiedSettings,
|
|
1189
|
+
preferences
|
|
1168
1190
|
} = state;
|
|
1169
1191
|
const updatedTabs = getUpdatedTabs(tabs, name);
|
|
1170
|
-
const filteredItems = getFilteredItems(items, updatedTabs, searchValue, modifiedSettings);
|
|
1192
|
+
const filteredItems = getFilteredItems(items, updatedTabs, searchValue, modifiedSettings, preferences);
|
|
1171
1193
|
return {
|
|
1172
1194
|
...state,
|
|
1173
1195
|
tabs: updatedTabs,
|
|
@@ -1241,9 +1263,10 @@ const handleInput = (state, value, inputSource = User) => {
|
|
|
1241
1263
|
items,
|
|
1242
1264
|
tabs,
|
|
1243
1265
|
history,
|
|
1244
|
-
modifiedSettings
|
|
1266
|
+
modifiedSettings,
|
|
1267
|
+
preferences
|
|
1245
1268
|
} = state;
|
|
1246
|
-
const filteredItems = getFilteredItems(items, tabs, value, modifiedSettings);
|
|
1269
|
+
const filteredItems = getFilteredItems(items, tabs, value, modifiedSettings, preferences);
|
|
1247
1270
|
const {
|
|
1248
1271
|
newHistory,
|
|
1249
1272
|
newHistoryIndex
|
|
@@ -1283,11 +1306,11 @@ const handleScroll = (state, scrollTop, inputSource = User) => {
|
|
|
1283
1306
|
};
|
|
1284
1307
|
};
|
|
1285
1308
|
|
|
1286
|
-
const getNewFilteredItems = (oldModifiedSetings, newModifiedSettings, items, tabs, searchValue, oldFilteredItems) => {
|
|
1287
|
-
if (oldModifiedSetings === newModifiedSettings) {
|
|
1309
|
+
const getNewFilteredItems = (oldModifiedSetings, newModifiedSettings, items, tabs, searchValue, oldFilteredItems, oldPreferences, newPreferences) => {
|
|
1310
|
+
if (oldModifiedSetings === newModifiedSettings && oldPreferences === newPreferences) {
|
|
1288
1311
|
return oldFilteredItems;
|
|
1289
1312
|
}
|
|
1290
|
-
return getFilteredItems(items, tabs, searchValue, newModifiedSettings);
|
|
1313
|
+
return getFilteredItems(items, tabs, searchValue, newModifiedSettings, newPreferences);
|
|
1291
1314
|
};
|
|
1292
1315
|
|
|
1293
1316
|
const getNewModifiedSettings = (modifiedSettings, name) => {
|
|
@@ -1314,7 +1337,7 @@ const handleSettingUpdate = (state, name, value, inputSource) => {
|
|
|
1314
1337
|
...preferences,
|
|
1315
1338
|
[name]: value
|
|
1316
1339
|
};
|
|
1317
|
-
const newFilteredItems = getNewFilteredItems(modifiedSettings, newModifiedSettings, items, tabs, searchValue, filteredItems);
|
|
1340
|
+
const newFilteredItems = getNewFilteredItems(modifiedSettings, newModifiedSettings, items, tabs, searchValue, filteredItems, preferences, newPreferences);
|
|
1318
1341
|
return {
|
|
1319
1342
|
...state,
|
|
1320
1343
|
inputSource,
|
|
@@ -1451,6 +1474,11 @@ const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
|
1451
1474
|
// @ts-ignore
|
|
1452
1475
|
await invokeAndTransfer$3('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
1453
1476
|
};
|
|
1477
|
+
const sendMessagePortToErrorWorker = async (port, rpcId) => {
|
|
1478
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1479
|
+
// @ts-ignore
|
|
1480
|
+
await invokeAndTransfer$3('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1481
|
+
};
|
|
1454
1482
|
const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
|
|
1455
1483
|
const command = 'Markdown.handleMessagePort';
|
|
1456
1484
|
// @ts-ignore
|
|
@@ -1700,6 +1728,7 @@ const RendererWorker = {
|
|
|
1700
1728
|
searchFileHtml,
|
|
1701
1729
|
searchFileMemory,
|
|
1702
1730
|
sendMessagePortToEditorWorker,
|
|
1731
|
+
sendMessagePortToErrorWorker,
|
|
1703
1732
|
sendMessagePortToExtensionHostWorker,
|
|
1704
1733
|
sendMessagePortToFileSystemWorker,
|
|
1705
1734
|
sendMessagePortToMarkdownWorker,
|
|
@@ -2851,7 +2880,21 @@ const getSettingItemsEditor = () => {
|
|
|
2851
2880
|
description: fontSizeDescription(),
|
|
2852
2881
|
type: Number$1,
|
|
2853
2882
|
value: 15,
|
|
2854
|
-
category: TextEditorTab
|
|
2883
|
+
category: TextEditorTab,
|
|
2884
|
+
validate(value) {
|
|
2885
|
+
if (typeof value !== 'number') {
|
|
2886
|
+
return 'font size must be of type number';
|
|
2887
|
+
}
|
|
2888
|
+
const minFontSize = 10;
|
|
2889
|
+
const maxFontSize = 100;
|
|
2890
|
+
if (value < minFontSize) {
|
|
2891
|
+
return 'font size must be at least 10';
|
|
2892
|
+
}
|
|
2893
|
+
if (value > maxFontSize) {
|
|
2894
|
+
return 'font size must not be greater than 100';
|
|
2895
|
+
}
|
|
2896
|
+
return '';
|
|
2897
|
+
}
|
|
2855
2898
|
}, {
|
|
2856
2899
|
id: 'editor.fontFamily',
|
|
2857
2900
|
heading: fontFamily(),
|
|
@@ -2935,7 +2978,21 @@ const getSettingItemsEditor = () => {
|
|
|
2935
2978
|
description: tabSizeDescription(),
|
|
2936
2979
|
type: Number$1,
|
|
2937
2980
|
value: '4',
|
|
2938
|
-
category: TextEditorTab
|
|
2981
|
+
category: TextEditorTab,
|
|
2982
|
+
validate(value) {
|
|
2983
|
+
if (typeof value !== 'number') {
|
|
2984
|
+
return 'font size must be of type number';
|
|
2985
|
+
}
|
|
2986
|
+
const minTabSize = 1;
|
|
2987
|
+
const maxTabSize = 8;
|
|
2988
|
+
if (value < minTabSize) {
|
|
2989
|
+
return `tab size must be at least ${minTabSize}`;
|
|
2990
|
+
}
|
|
2991
|
+
if (value > maxTabSize) {
|
|
2992
|
+
return `tab size must not be greater than ${maxTabSize}`;
|
|
2993
|
+
}
|
|
2994
|
+
return '';
|
|
2995
|
+
}
|
|
2939
2996
|
}, {
|
|
2940
2997
|
id: 'editor.insertSpaces',
|
|
2941
2998
|
heading: insertSpaces(),
|
|
@@ -3908,7 +3965,7 @@ const loadContent = async (state, savedState) => {
|
|
|
3908
3965
|
const items = await getSettingItems();
|
|
3909
3966
|
const preferences = await getPreferences();
|
|
3910
3967
|
const modifiedSettings = getModifiedSettings(preferences);
|
|
3911
|
-
const filteredItems = getFilteredItems(items, newTabs, searchValue, modifiedSettings);
|
|
3968
|
+
const filteredItems = getFilteredItems(items, newTabs, searchValue, modifiedSettings, preferences);
|
|
3912
3969
|
return {
|
|
3913
3970
|
...state,
|
|
3914
3971
|
filteredItems,
|
|
@@ -3942,7 +3999,9 @@ const {
|
|
|
3942
3999
|
} = ClassNames;
|
|
3943
4000
|
const Badge = 'Badge';
|
|
3944
4001
|
const CheckBox = 'CheckBox';
|
|
4002
|
+
const ErrorMessage = 'ErrorMessage';
|
|
3945
4003
|
const InputBox = 'InputBox';
|
|
4004
|
+
const InputBoxError = 'InputBoxError';
|
|
3946
4005
|
const MaskIcon = 'MaskIcon';
|
|
3947
4006
|
const MaskIconClearAll = 'MaskIconClearAll';
|
|
3948
4007
|
const ModifiedIndicator = 'ModifiedIndicator';
|
|
@@ -4025,11 +4084,11 @@ const getSettingsInputDom = () => {
|
|
|
4025
4084
|
}];
|
|
4026
4085
|
};
|
|
4027
4086
|
|
|
4028
|
-
const getChildCount = hasSearchValue => {
|
|
4087
|
+
const getChildCount$1 = hasSearchValue => {
|
|
4029
4088
|
return hasSearchValue ? 3 : 2;
|
|
4030
4089
|
};
|
|
4031
4090
|
const getSettingsHeaderDom = (filteredSettingsCount, hasSearchValue) => {
|
|
4032
|
-
const childCount = getChildCount(hasSearchValue);
|
|
4091
|
+
const childCount = getChildCount$1(hasSearchValue);
|
|
4033
4092
|
return [{
|
|
4034
4093
|
type: VirtualDomElements.Div,
|
|
4035
4094
|
className: SettingsHeader,
|
|
@@ -4041,6 +4100,17 @@ const getSettingsHeaderDom = (filteredSettingsCount, hasSearchValue) => {
|
|
|
4041
4100
|
}, ...getSettingsInputDom(), ...getSettingsInputBadgeDom(filteredSettingsCount, hasSearchValue), ...getSettingsInputButtonsDom(hasSearchValue)];
|
|
4042
4101
|
};
|
|
4043
4102
|
|
|
4103
|
+
const getErrorMessageDom = errorMessage => {
|
|
4104
|
+
if (!errorMessage) {
|
|
4105
|
+
return [];
|
|
4106
|
+
}
|
|
4107
|
+
return [{
|
|
4108
|
+
type: VirtualDomElements.Div,
|
|
4109
|
+
className: ErrorMessage,
|
|
4110
|
+
childCount: 1
|
|
4111
|
+
}, text(errorMessage)];
|
|
4112
|
+
};
|
|
4113
|
+
|
|
4044
4114
|
const getInputId = id => {
|
|
4045
4115
|
return id.replaceAll('.', '\\.');
|
|
4046
4116
|
};
|
|
@@ -4050,16 +4120,19 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
4050
4120
|
heading,
|
|
4051
4121
|
description,
|
|
4052
4122
|
id,
|
|
4053
|
-
modified
|
|
4123
|
+
modified,
|
|
4124
|
+
hasError,
|
|
4125
|
+
errorMessage
|
|
4054
4126
|
} = item;
|
|
4055
|
-
const isModified = modified || false;
|
|
4056
4127
|
const domId = getInputId(id);
|
|
4128
|
+
const checkBoxClassName = hasError ? `${CheckBox} ${InputBoxError}` : CheckBox;
|
|
4129
|
+
const errorChildCount = hasError ? 1 : 0;
|
|
4057
4130
|
return [{
|
|
4058
4131
|
type: VirtualDomElements.Div,
|
|
4059
4132
|
className: SettingsItem,
|
|
4060
|
-
childCount: 3,
|
|
4061
|
-
role:
|
|
4062
|
-
'data-modified':
|
|
4133
|
+
childCount: 3 + errorChildCount,
|
|
4134
|
+
role: AriaRoles.Group,
|
|
4135
|
+
'data-modified': modified
|
|
4063
4136
|
}, {
|
|
4064
4137
|
type: VirtualDomElements.H3,
|
|
4065
4138
|
childCount: 1
|
|
@@ -4069,7 +4142,7 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
4069
4142
|
childCount: 2
|
|
4070
4143
|
}, {
|
|
4071
4144
|
type: VirtualDomElements.Input,
|
|
4072
|
-
className:
|
|
4145
|
+
className: checkBoxClassName,
|
|
4073
4146
|
childCount: 0,
|
|
4074
4147
|
id: domId,
|
|
4075
4148
|
inputType: 'checkbox',
|
|
@@ -4079,7 +4152,7 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
4079
4152
|
type: VirtualDomElements.Label,
|
|
4080
4153
|
childCount: 1,
|
|
4081
4154
|
htmlFor: domId
|
|
4082
|
-
}, text(description)];
|
|
4155
|
+
}, text(description), ...getErrorMessageDom(errorMessage)];
|
|
4083
4156
|
};
|
|
4084
4157
|
|
|
4085
4158
|
const parent = {
|
|
@@ -4104,30 +4177,33 @@ const getItemColorVirtualDom = item => {
|
|
|
4104
4177
|
heading,
|
|
4105
4178
|
description,
|
|
4106
4179
|
id,
|
|
4107
|
-
modified
|
|
4180
|
+
modified,
|
|
4181
|
+
hasError,
|
|
4182
|
+
errorMessage
|
|
4108
4183
|
} = item;
|
|
4109
4184
|
const domId = getInputId(id);
|
|
4110
|
-
const
|
|
4185
|
+
const colorInputClassName = hasError ? mergeClassNames('ColorInput', InputBoxError) : mergeClassNames('ColorInput');
|
|
4186
|
+
const errorChildCount = hasError ? 1 : 0;
|
|
4111
4187
|
return [{
|
|
4112
4188
|
type: VirtualDomElements.Div,
|
|
4113
4189
|
className: SettingsItem,
|
|
4114
|
-
childCount: 3,
|
|
4115
|
-
role:
|
|
4116
|
-
'data-modified':
|
|
4190
|
+
childCount: 3 + errorChildCount,
|
|
4191
|
+
role: AriaRoles.Group,
|
|
4192
|
+
'data-modified': modified
|
|
4117
4193
|
}, ...getItemHeadingDom(heading), {
|
|
4118
4194
|
type: VirtualDomElements.Div,
|
|
4119
4195
|
className: SettingsItemCheckBox,
|
|
4120
4196
|
childCount: 2
|
|
4121
4197
|
}, {
|
|
4122
4198
|
type: VirtualDomElements.Input,
|
|
4123
|
-
className:
|
|
4199
|
+
className: colorInputClassName,
|
|
4124
4200
|
inputType: 'color',
|
|
4125
4201
|
placeholder: colorValue(),
|
|
4126
4202
|
childCount: 0,
|
|
4127
4203
|
id: domId,
|
|
4128
4204
|
name: id,
|
|
4129
4205
|
onInput: HandleSettingInput
|
|
4130
|
-
}, ...getItemLabelDom(domId, description)];
|
|
4206
|
+
}, ...getItemLabelDom(domId, description), ...getErrorMessageDom(errorMessage)];
|
|
4131
4207
|
};
|
|
4132
4208
|
|
|
4133
4209
|
const getSettingsModifiedIndicatorDom = isModified => {
|
|
@@ -4141,32 +4217,46 @@ const getSettingsModifiedIndicatorDom = isModified => {
|
|
|
4141
4217
|
}];
|
|
4142
4218
|
};
|
|
4143
4219
|
|
|
4220
|
+
const getChildCount = (modified, hasError) => {
|
|
4221
|
+
const modifiedChildCount = modified ? 1 : 0;
|
|
4222
|
+
const errorChildCount = hasError ? 1 : 0;
|
|
4223
|
+
const childCount = 3 + modifiedChildCount + errorChildCount;
|
|
4224
|
+
return childCount;
|
|
4225
|
+
};
|
|
4226
|
+
const getInputClassName = hasError => {
|
|
4227
|
+
if (hasError) {
|
|
4228
|
+
return `${InputBox} ${InputBoxError}`;
|
|
4229
|
+
}
|
|
4230
|
+
return InputBox;
|
|
4231
|
+
};
|
|
4144
4232
|
const getItemNumberVirtualDom = item => {
|
|
4145
4233
|
const {
|
|
4146
4234
|
heading,
|
|
4147
4235
|
description,
|
|
4148
4236
|
id,
|
|
4149
|
-
modified
|
|
4237
|
+
modified,
|
|
4238
|
+
hasError,
|
|
4239
|
+
errorMessage
|
|
4150
4240
|
} = item;
|
|
4151
4241
|
const domId = getInputId(id);
|
|
4152
|
-
const
|
|
4153
|
-
const
|
|
4242
|
+
const inputClassName = getInputClassName(hasError);
|
|
4243
|
+
const childCount = getChildCount(modified, hasError);
|
|
4154
4244
|
return [{
|
|
4155
4245
|
type: VirtualDomElements.Div,
|
|
4156
4246
|
className: SettingsItem,
|
|
4157
|
-
childCount
|
|
4158
|
-
role:
|
|
4159
|
-
'data-modified':
|
|
4160
|
-
}, ...getSettingsModifiedIndicatorDom(
|
|
4247
|
+
childCount,
|
|
4248
|
+
role: AriaRoles.Group,
|
|
4249
|
+
'data-modified': modified
|
|
4250
|
+
}, ...getSettingsModifiedIndicatorDom(modified), ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
4161
4251
|
type: VirtualDomElements.Input,
|
|
4162
|
-
className:
|
|
4252
|
+
className: inputClassName,
|
|
4163
4253
|
inputType: 'number',
|
|
4164
4254
|
placeholder: numberValue(),
|
|
4165
4255
|
childCount: 0,
|
|
4166
4256
|
id: domId,
|
|
4167
4257
|
name: id,
|
|
4168
4258
|
onInput: HandleSettingInput
|
|
4169
|
-
}];
|
|
4259
|
+
}, ...getErrorMessageDom(errorMessage)];
|
|
4170
4260
|
};
|
|
4171
4261
|
|
|
4172
4262
|
const getOptionDom = option => {
|
|
@@ -4185,36 +4275,44 @@ const getItemSelectVirtualDom = item => {
|
|
|
4185
4275
|
const {
|
|
4186
4276
|
heading,
|
|
4187
4277
|
description,
|
|
4188
|
-
id
|
|
4278
|
+
id,
|
|
4279
|
+
options,
|
|
4280
|
+
hasError,
|
|
4281
|
+
errorMessage
|
|
4189
4282
|
} = item;
|
|
4190
|
-
const options = item.options || [];
|
|
4191
4283
|
const domId = getInputId(id);
|
|
4284
|
+
const selectClassName = hasError ? `${Select} ${InputBoxError}` : Select;
|
|
4285
|
+
const errorChildCount = hasError ? 1 : 0;
|
|
4192
4286
|
return [{
|
|
4193
4287
|
type: VirtualDomElements.Div,
|
|
4194
4288
|
className: SettingsItem,
|
|
4195
|
-
childCount: 3,
|
|
4196
|
-
role:
|
|
4289
|
+
childCount: 3 + errorChildCount,
|
|
4290
|
+
role: AriaRoles.Group
|
|
4197
4291
|
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
4198
4292
|
type: VirtualDomElements.Select,
|
|
4199
|
-
className:
|
|
4200
|
-
childCount: options
|
|
4293
|
+
className: selectClassName,
|
|
4294
|
+
childCount: options?.length || 0,
|
|
4201
4295
|
id: domId,
|
|
4202
4296
|
name: id,
|
|
4203
4297
|
onChange: HandleSettingSelect
|
|
4204
|
-
}, ...options
|
|
4298
|
+
}, ...(options?.flatMap(getOptionDom) || []), ...getErrorMessageDom(errorMessage)];
|
|
4205
4299
|
};
|
|
4206
4300
|
|
|
4207
4301
|
const getItemStringVirtualDom = item => {
|
|
4208
4302
|
const {
|
|
4209
4303
|
heading,
|
|
4210
4304
|
description,
|
|
4211
|
-
id
|
|
4305
|
+
id,
|
|
4306
|
+
hasError,
|
|
4307
|
+
errorMessage
|
|
4212
4308
|
} = item;
|
|
4309
|
+
const inputClassName = hasError ? `${InputBox} ${InputBoxError}` : InputBox;
|
|
4310
|
+
const errorChildCount = hasError ? 1 : 0;
|
|
4213
4311
|
return [{
|
|
4214
4312
|
type: VirtualDomElements.Div,
|
|
4215
4313
|
className: SettingsItem,
|
|
4216
|
-
childCount: 3,
|
|
4217
|
-
role:
|
|
4314
|
+
childCount: 3 + errorChildCount,
|
|
4315
|
+
role: AriaRoles.Group
|
|
4218
4316
|
}, {
|
|
4219
4317
|
type: VirtualDomElements.H3,
|
|
4220
4318
|
childCount: 1
|
|
@@ -4223,13 +4321,13 @@ const getItemStringVirtualDom = item => {
|
|
|
4223
4321
|
childCount: 1
|
|
4224
4322
|
}, text(description), {
|
|
4225
4323
|
type: VirtualDomElements.Input,
|
|
4226
|
-
className:
|
|
4324
|
+
className: inputClassName,
|
|
4227
4325
|
inputType: 'text',
|
|
4228
4326
|
placeholder: stringValue(),
|
|
4229
4327
|
childCount: 0,
|
|
4230
4328
|
name: id,
|
|
4231
4329
|
onInput: HandleSettingInput
|
|
4232
|
-
}];
|
|
4330
|
+
}, ...getErrorMessageDom(errorMessage)];
|
|
4233
4331
|
};
|
|
4234
4332
|
|
|
4235
4333
|
const getItemUnknownVirtualDom = () => {
|
|
@@ -4237,7 +4335,7 @@ const getItemUnknownVirtualDom = () => {
|
|
|
4237
4335
|
type: VirtualDomElements.Div,
|
|
4238
4336
|
className: SettingsItem,
|
|
4239
4337
|
childCount: 1,
|
|
4240
|
-
role:
|
|
4338
|
+
role: AriaRoles.Group
|
|
4241
4339
|
}, text(unknownSettingType())];
|
|
4242
4340
|
};
|
|
4243
4341
|
|
|
@@ -4246,26 +4344,29 @@ const getItemUrlVirtualDom = item => {
|
|
|
4246
4344
|
heading,
|
|
4247
4345
|
description,
|
|
4248
4346
|
id,
|
|
4249
|
-
modified
|
|
4347
|
+
modified,
|
|
4348
|
+
hasError,
|
|
4349
|
+
errorMessage
|
|
4250
4350
|
} = item;
|
|
4251
4351
|
const domId = getInputId(id);
|
|
4252
|
-
const
|
|
4352
|
+
const inputClassName = hasError ? `${InputBox} ${InputBoxError}` : InputBox;
|
|
4353
|
+
const errorChildCount = hasError ? 1 : 0;
|
|
4253
4354
|
return [{
|
|
4254
4355
|
type: VirtualDomElements.Div,
|
|
4255
4356
|
className: SettingsItem,
|
|
4256
|
-
childCount: 3,
|
|
4257
|
-
role:
|
|
4258
|
-
'data-modified':
|
|
4357
|
+
childCount: 3 + errorChildCount,
|
|
4358
|
+
role: AriaRoles.Group,
|
|
4359
|
+
'data-modified': modified
|
|
4259
4360
|
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
4260
4361
|
type: VirtualDomElements.Input,
|
|
4261
|
-
className:
|
|
4362
|
+
className: inputClassName,
|
|
4262
4363
|
inputType: 'url',
|
|
4263
4364
|
placeholder: numberValue(),
|
|
4264
4365
|
childCount: 0,
|
|
4265
4366
|
id: domId,
|
|
4266
4367
|
name: id,
|
|
4267
4368
|
onInput: HandleSettingInput
|
|
4268
|
-
}];
|
|
4369
|
+
}, ...getErrorMessageDom(errorMessage)];
|
|
4269
4370
|
};
|
|
4270
4371
|
|
|
4271
4372
|
const getItemVirtualDom = item => {
|
|
@@ -4303,7 +4404,7 @@ const getSettingsNoResultsDom = searchValue => {
|
|
|
4303
4404
|
};
|
|
4304
4405
|
|
|
4305
4406
|
const getSettingsItemsDom = (items, searchValue) => {
|
|
4306
|
-
if (items.length === 0 && searchValue.trim()) {
|
|
4407
|
+
if (items.length === 0 && searchValue && searchValue.trim()) {
|
|
4307
4408
|
return getSettingsNoResultsDom(searchValue);
|
|
4308
4409
|
}
|
|
4309
4410
|
return [{
|
|
@@ -4527,14 +4628,15 @@ const useNextSearchValue = state => {
|
|
|
4527
4628
|
historyIndex,
|
|
4528
4629
|
items,
|
|
4529
4630
|
tabs,
|
|
4530
|
-
modifiedSettings
|
|
4631
|
+
modifiedSettings,
|
|
4632
|
+
preferences
|
|
4531
4633
|
} = state;
|
|
4532
4634
|
if (history.length === 0 || historyIndex >= history.length - 1) {
|
|
4533
4635
|
return state;
|
|
4534
4636
|
}
|
|
4535
4637
|
const newHistoryIndex = historyIndex + 1;
|
|
4536
4638
|
const newSearchValue = history[newHistoryIndex];
|
|
4537
|
-
const filteredItems = getFilteredItems(items, tabs, newSearchValue, modifiedSettings);
|
|
4639
|
+
const filteredItems = getFilteredItems(items, tabs, newSearchValue, modifiedSettings, preferences);
|
|
4538
4640
|
return {
|
|
4539
4641
|
...state,
|
|
4540
4642
|
searchValue: newSearchValue,
|
|
@@ -4550,14 +4652,15 @@ const usePreviousSearchValue = state => {
|
|
|
4550
4652
|
historyIndex,
|
|
4551
4653
|
items,
|
|
4552
4654
|
tabs,
|
|
4553
|
-
modifiedSettings
|
|
4655
|
+
modifiedSettings,
|
|
4656
|
+
preferences
|
|
4554
4657
|
} = state;
|
|
4555
4658
|
if (history.length === 0 || historyIndex <= 0) {
|
|
4556
4659
|
return state;
|
|
4557
4660
|
}
|
|
4558
4661
|
const newHistoryIndex = historyIndex - 1;
|
|
4559
4662
|
const newSearchValue = history[newHistoryIndex];
|
|
4560
|
-
const filteredItems = getFilteredItems(items, tabs, newSearchValue, modifiedSettings);
|
|
4663
|
+
const filteredItems = getFilteredItems(items, tabs, newSearchValue, modifiedSettings, preferences);
|
|
4561
4664
|
return {
|
|
4562
4665
|
...state,
|
|
4563
4666
|
searchValue: newSearchValue,
|