@lvce-editor/settings-view 2.27.1 → 2.27.3

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.
@@ -1559,6 +1559,7 @@ const create$1 = (id, uri, x, y, width, height) => {
1559
1559
  minLineY: 0,
1560
1560
  modifiedSettings: {},
1561
1561
  preferences: {},
1562
+ schemaErrors: [],
1562
1563
  scrollBarMinHeight: 0,
1563
1564
  scrollBarThumbHeight: 0,
1564
1565
  scrollBarThumbTop: 0,
@@ -2745,10 +2746,7 @@ const getUpdatedTabs = (tabs, selectedTabId) => {
2745
2746
  }));
2746
2747
  };
2747
2748
 
2748
- const handleClickTab = (state, name) => {
2749
- if (!name) {
2750
- return state;
2751
- }
2749
+ const handleClickTab = (state, name = '') => {
2752
2750
  const {
2753
2751
  height,
2754
2752
  itemHeight,
@@ -3059,6 +3057,15 @@ const getPreferences = async () => {
3059
3057
  }
3060
3058
  };
3061
3059
 
3060
+ const getSchemaErrors = async () => {
3061
+ try {
3062
+ return await invoke$1('SettingsWorker.getSchemaErrors');
3063
+ } catch {
3064
+ // Older settings-worker versions do not expose schema diagnostics yet.
3065
+ return [];
3066
+ }
3067
+ };
3068
+
3062
3069
  const getSettingItems = async () => {
3063
3070
  return invoke$1('SettingsWorker.getSettingsItems2');
3064
3071
  };
@@ -3175,7 +3182,7 @@ const loadContent = async (state, savedState) => {
3175
3182
  } = restoreState(savedState);
3176
3183
  const tabs = await getTabs();
3177
3184
  const newTabs = getUpdatedTabs(tabs, tabId);
3178
- const [items, preferences] = await Promise.all([getSettingItems(), getPreferences()]);
3185
+ const [items, preferences, schemaErrors] = await Promise.all([getSettingItems(), getPreferences(), getSchemaErrors()]);
3179
3186
  const modifiedSettings = getModifiedSettings(preferences);
3180
3187
  const filteredItems = getFilteredItems(items, newTabs, searchValue, modifiedSettings, preferences);
3181
3188
  const {
@@ -3205,6 +3212,7 @@ const loadContent = async (state, savedState) => {
3205
3212
  minLineY,
3206
3213
  modifiedSettings,
3207
3214
  preferences,
3215
+ schemaErrors,
3208
3216
  scrollBarThumbHeight: thumbHeight,
3209
3217
  scrollBarThumbTop: thumbTop,
3210
3218
  scrollOffset,
@@ -3243,6 +3251,7 @@ const renderCss = (oldState, newState) => {
3243
3251
 
3244
3252
  const Clear = 'Clear';
3245
3253
  const Filter = 'Filter';
3254
+ const SchemaErrorsTab = 'schema-errors';
3246
3255
  const SettingsSearch = 'SettingsSearch';
3247
3256
 
3248
3257
  const renderFocus = (oldState, newState) => {
@@ -3291,11 +3300,21 @@ const SettingsScrollBar = 'ScrollBar';
3291
3300
  const SettingsScrollBarSmall = 'ScrollBarSmall';
3292
3301
  const SettingsScrollBarThumb = 'ScrollBarThumb';
3293
3302
  const SettingsSearchInput = 'SettingsSearchInput';
3303
+ const SettingsSchemaError = 'SettingsSchemaError';
3304
+ const SettingsSchemaErrors = 'SettingsSchemaErrors';
3294
3305
  const SettingsSideBar = 'SettingsSideBar';
3295
3306
  const SettingsTabs = 'SettingsTabs';
3296
3307
  const Tab = 'Tab';
3297
3308
  const TabSelected = 'TabSelected';
3298
3309
 
3310
+ const getFilteredSchemaErrors = (errors, searchValue) => {
3311
+ const search = searchValue.trim().toLowerCase();
3312
+ if (!search) {
3313
+ return errors;
3314
+ }
3315
+ return errors.filter(error => `${error.id} ${error.message} ${error.source}`.toLowerCase().includes(search));
3316
+ };
3317
+
3299
3318
  const inputBadgeNode = {
3300
3319
  childCount: 1,
3301
3320
  className: InputBadge,
@@ -3372,6 +3391,7 @@ const getSettingsInputButtonsDom = hasSearchValue => {
3372
3391
  return [...getClearButtonDom(hasSearchValue), ...getFilterButtonDom()];
3373
3392
  };
3374
3393
 
3394
+ const searchInputClassName = mergeClassNames(InputBox, SettingsSearchInput, 'MultilineInputBox');
3375
3395
  const getSettingsInputDom = () => {
3376
3396
  const placeholder = searchSettings();
3377
3397
  return [{
@@ -3379,7 +3399,7 @@ const getSettingsInputDom = () => {
3379
3399
  autocomplete: 'off',
3380
3400
  autocorrect: 'off',
3381
3401
  childCount: 0,
3382
- className: mergeClassNames(InputBox, SettingsSearchInput, 'MultilineInputBox'),
3402
+ className: searchInputClassName,
3383
3403
  name: SettingsSearch,
3384
3404
  onFocus: HandleInputFocus,
3385
3405
  onInput: HandleInput,
@@ -3389,6 +3409,7 @@ const getSettingsInputDom = () => {
3389
3409
  }];
3390
3410
  };
3391
3411
 
3412
+ const inputWrapperClassName = mergeClassNames(SettingsInputWrapper, 'SearchField');
3392
3413
  const settingsHeaderNode = {
3393
3414
  childCount: 1,
3394
3415
  className: SettingsHeader,
@@ -3401,7 +3422,7 @@ const getSettingsHeaderDom = (filteredSettingsCount, hasSearchValue) => {
3401
3422
  const childCount = getChildCount$1(hasSearchValue);
3402
3423
  return [settingsHeaderNode, {
3403
3424
  childCount,
3404
- className: mergeClassNames(SettingsInputWrapper, 'SearchField'),
3425
+ className: inputWrapperClassName,
3405
3426
  type: Div
3406
3427
  }, ...getSettingsInputDom(), ...getSettingsInputBadgeDom(filteredSettingsCount, hasSearchValue), ...getSettingsInputButtonsDom(hasSearchValue)];
3407
3428
  };
@@ -3429,6 +3450,21 @@ const getContentHeadingDom = headerText => {
3429
3450
  return [parentNode$2, text(headerText)];
3430
3451
  };
3431
3452
 
3453
+ const getSchemaErrorsDom = errors => {
3454
+ return [{
3455
+ childCount: errors.length,
3456
+ className: SettingsSchemaErrors,
3457
+ role: Group,
3458
+ type: Div
3459
+ }, ...errors.flatMap(error => [{
3460
+ childCount: 2,
3461
+ className: SettingsSchemaError,
3462
+ name: error.id,
3463
+ role: Group,
3464
+ type: Div
3465
+ }, text(`${error.id}: ${error.message}`), text(`Source: ${error.source}`)])];
3466
+ };
3467
+
3432
3468
  const parentNode$1 = {
3433
3469
  childCount: 1,
3434
3470
  className: mergeClassNames(SettingsScrollBar, SettingsScrollBarSmall),
@@ -3480,6 +3516,7 @@ const getItemLabelDom = (domId, label) => {
3480
3516
  }, text(label)];
3481
3517
  };
3482
3518
 
3519
+ const errorInputClassName$3 = mergeClassNames(InputBox, InputBoxError);
3483
3520
  const getItemArrayVirtualDom = item => {
3484
3521
  const {
3485
3522
  description,
@@ -3490,7 +3527,7 @@ const getItemArrayVirtualDom = item => {
3490
3527
  modified
3491
3528
  } = item;
3492
3529
  const domId = getInputId(id);
3493
- const inputClassName = hasError ? mergeClassNames(InputBox, InputBoxError) : InputBox;
3530
+ const inputClassName = hasError ? errorInputClassName$3 : InputBox;
3494
3531
  const errorChildCount = hasError ? 1 : 0;
3495
3532
  return [{
3496
3533
  childCount: 3 + errorChildCount,
@@ -3511,6 +3548,7 @@ const getItemArrayVirtualDom = item => {
3511
3548
  }, ...getErrorMessageDom(errorMessage)];
3512
3549
  };
3513
3550
 
3551
+ const errorCheckBoxClassName = mergeClassNames(CheckBox, InputBoxError);
3514
3552
  const checkBoxWrapperNode = {
3515
3553
  childCount: 2,
3516
3554
  className: SettingsItemCheckBox,
@@ -3527,7 +3565,7 @@ const getItemCheckBoxVirtualDom = item => {
3527
3565
  value
3528
3566
  } = item;
3529
3567
  const domId = getInputId(id);
3530
- const checkBoxClassName = hasError ? mergeClassNames(CheckBox, InputBoxError) : CheckBox;
3568
+ const checkBoxClassName = hasError ? errorCheckBoxClassName : CheckBox;
3531
3569
  const errorChildCount = hasError ? 1 : 0;
3532
3570
  const isChecked = value === true || value === 'true';
3533
3571
  return [{
@@ -3549,6 +3587,8 @@ const getItemCheckBoxVirtualDom = item => {
3549
3587
  }, ...getItemLabelDom(domId, description), ...getErrorMessageDom(errorMessage)];
3550
3588
  };
3551
3589
 
3590
+ const errorColorInputClassName = mergeClassNames('ColorInput', InputBoxError);
3591
+ const defaultColorInputClassName = mergeClassNames('ColorInput');
3552
3592
  const colorInputWrapperNode = {
3553
3593
  childCount: 2,
3554
3594
  className: SettingsItemCheckBox,
@@ -3564,7 +3604,7 @@ const getItemColorVirtualDom = item => {
3564
3604
  modified
3565
3605
  } = item;
3566
3606
  const domId = getInputId(id);
3567
- const colorInputClassName = hasError ? mergeClassNames('ColorInput', InputBoxError) : mergeClassNames('ColorInput');
3607
+ const colorInputClassName = hasError ? errorColorInputClassName : defaultColorInputClassName;
3568
3608
  const errorChildCount = hasError ? 1 : 0;
3569
3609
  return [{
3570
3610
  childCount: 3 + errorChildCount,
@@ -3597,6 +3637,7 @@ const getSettingsModifiedIndicatorDom = isModified => {
3597
3637
  return [modifiedIndicatorNode];
3598
3638
  };
3599
3639
 
3640
+ const errorInputClassName$2 = mergeClassNames(InputBox, InputBoxError);
3600
3641
  const getChildCount = (modified, hasError) => {
3601
3642
  const modifiedChildCount = modified ? 1 : 0;
3602
3643
  const errorChildCount = hasError ? 1 : 0;
@@ -3605,7 +3646,7 @@ const getChildCount = (modified, hasError) => {
3605
3646
  };
3606
3647
  const getInputClassName = hasError => {
3607
3648
  if (hasError) {
3608
- return mergeClassNames(InputBox, InputBoxError);
3649
+ return errorInputClassName$2;
3609
3650
  }
3610
3651
  return InputBox;
3611
3652
  };
@@ -3652,6 +3693,7 @@ const getOptionDom = option => {
3652
3693
  }, text(label)];
3653
3694
  };
3654
3695
 
3696
+ const errorSelectClassName = mergeClassNames(Select, InputBoxError);
3655
3697
  const getItemSelectVirtualDom = item => {
3656
3698
  const {
3657
3699
  description,
@@ -3662,7 +3704,7 @@ const getItemSelectVirtualDom = item => {
3662
3704
  options
3663
3705
  } = item;
3664
3706
  const domId = getInputId(id);
3665
- const selectClassName = hasError ? mergeClassNames(Select, InputBoxError) : Select;
3707
+ const selectClassName = hasError ? errorSelectClassName : Select;
3666
3708
  const errorChildCount = hasError ? 1 : 0;
3667
3709
  return [{
3668
3710
  childCount: 3 + errorChildCount,
@@ -3680,6 +3722,7 @@ const getItemSelectVirtualDom = item => {
3680
3722
  }, ...(options?.flatMap(getOptionDom) || []), ...getErrorMessageDom(errorMessage)];
3681
3723
  };
3682
3724
 
3725
+ const errorInputClassName$1 = mergeClassNames(InputBox, InputBoxError);
3683
3726
  const getItemStringVirtualDom = item => {
3684
3727
  const {
3685
3728
  description,
@@ -3689,7 +3732,7 @@ const getItemStringVirtualDom = item => {
3689
3732
  id
3690
3733
  } = item;
3691
3734
  const domId = getInputId(id);
3692
- const inputClassName = hasError ? mergeClassNames(InputBox, InputBoxError) : InputBox;
3735
+ const inputClassName = hasError ? errorInputClassName$1 : InputBox;
3693
3736
  const errorChildCount = hasError ? 1 : 0;
3694
3737
  return [{
3695
3738
  childCount: 3 + errorChildCount,
@@ -3719,6 +3762,7 @@ const getItemUnknownVirtualDom = item => {
3719
3762
  }, text(unknownSettingType())];
3720
3763
  };
3721
3764
 
3765
+ const errorInputClassName = mergeClassNames(InputBox, InputBoxError);
3722
3766
  const getItemUrlVirtualDom = item => {
3723
3767
  const {
3724
3768
  description,
@@ -3729,7 +3773,7 @@ const getItemUrlVirtualDom = item => {
3729
3773
  modified
3730
3774
  } = item;
3731
3775
  const domId = getInputId(id);
3732
- const inputClassName = hasError ? mergeClassNames(InputBox, InputBoxError) : InputBox;
3776
+ const inputClassName = hasError ? errorInputClassName : InputBox;
3733
3777
  const errorChildCount = hasError ? 1 : 0;
3734
3778
  return [{
3735
3779
  childCount: 3 + errorChildCount,
@@ -3814,14 +3858,15 @@ const settingsItemWrapperNode = {
3814
3858
  className: SettingsItemWrapper,
3815
3859
  type: Div
3816
3860
  };
3817
- const getSettingsContentDom = (visibleItems, tabs, searchValue, showScrollBar) => {
3861
+ const getSettingsContentDom = (visibleItems, tabs, searchValue, showScrollBar, schemaErrors = []) => {
3818
3862
  const selectedTab = tabs.find(tab => tab.selected);
3819
3863
  const headerText = selectedTab ? selectedTab.label : settingsContent();
3820
- return [settingsContentNode, ...getContentHeadingDom(headerText), settingsItemWrapperNode, ...getSettingsItemsDom(visibleItems, searchValue), ...getScrollBarDom(showScrollBar)];
3864
+ return [settingsContentNode, ...getContentHeadingDom(headerText), settingsItemWrapperNode, ...(selectedTab?.id === SchemaErrorsTab ? getSchemaErrorsDom(schemaErrors) : getSettingsItemsDom(visibleItems, searchValue)), ...getScrollBarDom(showScrollBar)];
3821
3865
  };
3822
3866
 
3867
+ const selectedTabClassName = mergeClassNames(Tab, TabSelected);
3823
3868
  const getTabClassName = tab => {
3824
- return tab.selected ? mergeClassNames(Tab, TabSelected) : Tab;
3869
+ return tab.selected ? selectedTabClassName : Tab;
3825
3870
  };
3826
3871
 
3827
3872
  const getTabVirtualDom = tab => {
@@ -3841,7 +3886,6 @@ const getSettingsTabsDom = tabs => {
3841
3886
  return [{
3842
3887
  childCount: tabs.length,
3843
3888
  className: SettingsTabs,
3844
- onClick: HandleClickTab,
3845
3889
  role: TabList,
3846
3890
  type: Ul
3847
3891
  }, ...tabs.flatMap(getTabVirtualDom)];
@@ -3850,6 +3894,7 @@ const getSettingsTabsDom = tabs => {
3850
3894
  const settingsSideBarNode = {
3851
3895
  childCount: 1,
3852
3896
  className: SettingsSideBar,
3897
+ onClick: HandleClickTab,
3853
3898
  type: Aside
3854
3899
  };
3855
3900
  const getSettingsSideBarDom = tabs => {
@@ -3861,10 +3906,10 @@ const settingsMainNode = {
3861
3906
  className: SettingsMain,
3862
3907
  type: Div
3863
3908
  };
3864
- const getSettingsMainDom = (tabs, visibleItems, totalItemCount, searchValue, height, itemHeight) => {
3909
+ const getSettingsMainDom = (tabs, visibleItems, totalItemCount, searchValue, height, itemHeight, schemaErrors = []) => {
3865
3910
  const totalHeight = totalItemCount * itemHeight;
3866
3911
  const showScrollBar = totalHeight > height;
3867
- return [settingsMainNode, ...getSettingsSideBarDom(tabs), ...getResizerVirtualDom(), ...getSettingsContentDom(visibleItems, tabs, searchValue, showScrollBar)];
3912
+ return [settingsMainNode, ...getSettingsSideBarDom(tabs), ...getResizerVirtualDom(), ...getSettingsContentDom(visibleItems, tabs, searchValue, showScrollBar, schemaErrors)];
3868
3913
  };
3869
3914
 
3870
3915
  const parentNode = {
@@ -3872,18 +3917,28 @@ const parentNode = {
3872
3917
  className: mergeClassNames(Viewlet, Settings),
3873
3918
  type: Div
3874
3919
  };
3920
+ const getFilteredItemsCount = (isSchemaErrorsTab, schemaErrorsLength, filteredItemsLength) => {
3921
+ if (isSchemaErrorsTab) {
3922
+ return schemaErrorsLength;
3923
+ }
3924
+ return filteredItemsLength;
3925
+ };
3875
3926
  const getSettingsDom = state => {
3876
3927
  const {
3877
3928
  filteredItems,
3878
3929
  height,
3879
3930
  itemHeight,
3931
+ schemaErrors = [],
3880
3932
  searchValue,
3881
3933
  tabs,
3882
3934
  visibleItems
3883
3935
  } = state;
3936
+ const isSchemaErrorsTab = tabs.some(tab => tab.selected && tab.id === SchemaErrorsTab);
3884
3937
  const hasSearchValue = searchValue.trim().length > 0;
3885
- const filteredItemsCount = filteredItems.length;
3886
- return [parentNode, ...getSettingsHeaderDom(filteredItemsCount, hasSearchValue), ...getSettingsMainDom(tabs, visibleItems, filteredItemsCount, searchValue, height, itemHeight)];
3938
+ const filteredSchemaErrors = getFilteredSchemaErrors(schemaErrors, searchValue);
3939
+ const filteredItemsCount = getFilteredItemsCount(isSchemaErrorsTab, filteredSchemaErrors.length, filteredItems.length);
3940
+ const mainDom = getSettingsMainDom(tabs, visibleItems, filteredItemsCount, searchValue, height, itemHeight, filteredSchemaErrors);
3941
+ return [parentNode, ...getSettingsHeaderDom(filteredItemsCount, hasSearchValue), ...mainDom];
3887
3942
  };
3888
3943
 
3889
3944
  const renderItems = (oldState, newState) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/settings-view",
3
- "version": "2.27.1",
3
+ "version": "2.27.3",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",