@lvce-editor/settings-view 2.27.3 → 2.29.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.
@@ -1780,6 +1780,10 @@ const filterSettingId = state => appendFilter(state, '@id:');
1780
1780
  const filterStable = state => toggleExclusiveFilter(state, '@stable', ['@tag:preview', '@tag:experimental']);
1781
1781
  const filterTag = state => appendFilter(state, '@tag:');
1782
1782
 
1783
+ const getComponentState = uid => {
1784
+ return get$1(uid).newState;
1785
+ };
1786
+
1783
1787
  const Group = 'group';
1784
1788
  const Tab$1 = 'tab';
1785
1789
  const TabList = 'tablist';
@@ -2427,6 +2431,7 @@ const VirtualDomElements = {
2427
2431
  const ClientX = 'event.clientX';
2428
2432
  const ClientY = 'event.clientY';
2429
2433
  const DeltaY = 'event.deltaY';
2434
+ const TargetChecked = 'event.target.checked';
2430
2435
  const TargetName = 'event.target.name';
2431
2436
  const TargetValue = 'event.target.value';
2432
2437
 
@@ -3306,6 +3311,7 @@ const SettingsSideBar = 'SettingsSideBar';
3306
3311
  const SettingsTabs = 'SettingsTabs';
3307
3312
  const Tab = 'Tab';
3308
3313
  const TabSelected = 'TabSelected';
3314
+ const Toggle = 'Toggle';
3309
3315
 
3310
3316
  const getFilteredSchemaErrors = (errors, searchValue) => {
3311
3317
  const search = searchValue.trim().toLowerCase();
@@ -3549,12 +3555,14 @@ const getItemArrayVirtualDom = item => {
3549
3555
  };
3550
3556
 
3551
3557
  const errorCheckBoxClassName = mergeClassNames(CheckBox, InputBoxError);
3558
+ const errorToggleClassName = mergeClassNames(Toggle, InputBoxError);
3559
+ const settingUseToggles = 'settings.useToggles';
3552
3560
  const checkBoxWrapperNode = {
3553
3561
  childCount: 2,
3554
3562
  className: SettingsItemCheckBox,
3555
3563
  type: Div
3556
3564
  };
3557
- const getItemCheckBoxVirtualDom = item => {
3565
+ const getItemCheckBoxVirtualDom = (item, preferences = {}) => {
3558
3566
  const {
3559
3567
  description,
3560
3568
  errorMessage,
@@ -3565,9 +3573,14 @@ const getItemCheckBoxVirtualDom = item => {
3565
3573
  value
3566
3574
  } = item;
3567
3575
  const domId = getInputId(id);
3568
- const checkBoxClassName = hasError ? errorCheckBoxClassName : CheckBox;
3576
+ const useToggles = preferences[settingUseToggles] !== false && preferences[settingUseToggles] !== 'false';
3577
+ let checkBoxClassName = useToggles ? Toggle : CheckBox;
3578
+ if (hasError) {
3579
+ checkBoxClassName = useToggles ? errorToggleClassName : errorCheckBoxClassName;
3580
+ }
3569
3581
  const errorChildCount = hasError ? 1 : 0;
3570
- const isChecked = value === true || value === 'true';
3582
+ const currentValue = preferences[id] ?? value;
3583
+ const isChecked = currentValue === true || currentValue === 'true';
3571
3584
  return [{
3572
3585
  childCount: 2 + errorChildCount,
3573
3586
  className: SettingsItem,
@@ -3815,9 +3828,9 @@ const getItemRender = type => {
3815
3828
  }
3816
3829
  };
3817
3830
 
3818
- const getItemVirtualDom = item => {
3831
+ const getItemVirtualDom = (item, preferences) => {
3819
3832
  const fn = getItemRender(item.type);
3820
- return fn(item);
3833
+ return fn(item, preferences);
3821
3834
  };
3822
3835
 
3823
3836
  const settingsItemsNode = {
@@ -3835,7 +3848,7 @@ const getSettingsNoResultsDom = searchValue => {
3835
3848
  return [settingsItemsNode, noResultsNode, text(noSettingsMatching(searchValue))];
3836
3849
  };
3837
3850
 
3838
- const getSettingsItemsDom = (items, searchValue) => {
3851
+ const getSettingsItemsDom = (items, searchValue, preferences = {}) => {
3839
3852
  if (items.length === 0 && searchValue && searchValue.trim()) {
3840
3853
  return getSettingsNoResultsDom(searchValue);
3841
3854
  }
@@ -3844,7 +3857,7 @@ const getSettingsItemsDom = (items, searchValue) => {
3844
3857
  className: SettingsItems,
3845
3858
  onContextMenu: HandleContextMenu,
3846
3859
  type: Div
3847
- }, ...items.flatMap(getItemVirtualDom)];
3860
+ }, ...items.flatMap(item => getItemVirtualDom(item, preferences))];
3848
3861
  };
3849
3862
 
3850
3863
  const settingsContentNode = {
@@ -3858,10 +3871,10 @@ const settingsItemWrapperNode = {
3858
3871
  className: SettingsItemWrapper,
3859
3872
  type: Div
3860
3873
  };
3861
- const getSettingsContentDom = (visibleItems, tabs, searchValue, showScrollBar, schemaErrors = []) => {
3874
+ const getSettingsContentDom = (visibleItems, tabs, searchValue, showScrollBar, schemaErrors = [], preferences = {}) => {
3862
3875
  const selectedTab = tabs.find(tab => tab.selected);
3863
3876
  const headerText = selectedTab ? selectedTab.label : settingsContent();
3864
- return [settingsContentNode, ...getContentHeadingDom(headerText), settingsItemWrapperNode, ...(selectedTab?.id === SchemaErrorsTab ? getSchemaErrorsDom(schemaErrors) : getSettingsItemsDom(visibleItems, searchValue)), ...getScrollBarDom(showScrollBar)];
3877
+ return [settingsContentNode, ...getContentHeadingDom(headerText), settingsItemWrapperNode, ...(selectedTab?.id === SchemaErrorsTab ? getSchemaErrorsDom(schemaErrors) : getSettingsItemsDom(visibleItems, searchValue, preferences)), ...getScrollBarDom(showScrollBar)];
3865
3878
  };
3866
3879
 
3867
3880
  const selectedTabClassName = mergeClassNames(Tab, TabSelected);
@@ -3906,10 +3919,10 @@ const settingsMainNode = {
3906
3919
  className: SettingsMain,
3907
3920
  type: Div
3908
3921
  };
3909
- const getSettingsMainDom = (tabs, visibleItems, totalItemCount, searchValue, height, itemHeight, schemaErrors = []) => {
3922
+ const getSettingsMainDom = (tabs, visibleItems, totalItemCount, searchValue, height, itemHeight, schemaErrors = [], preferences = {}) => {
3910
3923
  const totalHeight = totalItemCount * itemHeight;
3911
3924
  const showScrollBar = totalHeight > height;
3912
- return [settingsMainNode, ...getSettingsSideBarDom(tabs), ...getResizerVirtualDom(), ...getSettingsContentDom(visibleItems, tabs, searchValue, showScrollBar, schemaErrors)];
3925
+ return [settingsMainNode, ...getSettingsSideBarDom(tabs), ...getResizerVirtualDom(), ...getSettingsContentDom(visibleItems, tabs, searchValue, showScrollBar, schemaErrors, preferences)];
3913
3926
  };
3914
3927
 
3915
3928
  const parentNode = {
@@ -3928,6 +3941,7 @@ const getSettingsDom = state => {
3928
3941
  filteredItems,
3929
3942
  height,
3930
3943
  itemHeight,
3944
+ preferences,
3931
3945
  schemaErrors = [],
3932
3946
  searchValue,
3933
3947
  tabs,
@@ -3937,7 +3951,7 @@ const getSettingsDom = state => {
3937
3951
  const hasSearchValue = searchValue.trim().length > 0;
3938
3952
  const filteredSchemaErrors = getFilteredSchemaErrors(schemaErrors, searchValue);
3939
3953
  const filteredItemsCount = getFilteredItemsCount(isSchemaErrorsTab, filteredSchemaErrors.length, filteredItems.length);
3940
- const mainDom = getSettingsMainDom(tabs, visibleItems, filteredItemsCount, searchValue, height, itemHeight, filteredSchemaErrors);
3954
+ const mainDom = getSettingsMainDom(tabs, visibleItems, filteredItemsCount, searchValue, height, itemHeight, filteredSchemaErrors, preferences);
3941
3955
  return [parentNode, ...getSettingsHeaderDom(filteredItemsCount, hasSearchValue), ...mainDom];
3942
3956
  };
3943
3957
 
@@ -4049,7 +4063,7 @@ const renderEventListeners = () => {
4049
4063
  params: ['handleSettingInput', TargetName, TargetValue]
4050
4064
  }, {
4051
4065
  name: HandleSettingChecked,
4052
- params: ['handleSettingChecked', TargetName, TargetValue]
4066
+ params: ['handleSettingChecked', TargetName, TargetChecked]
4053
4067
  },
4054
4068
  // {
4055
4069
  // name: DomEventListenerFunctions.HandleScroll,
@@ -4128,6 +4142,23 @@ const saveState = state => {
4128
4142
  };
4129
4143
  };
4130
4144
 
4145
+ const applyComponentState = (currentState, state) => {
4146
+ if (!state || typeof state !== 'object' || Array.isArray(state)) {
4147
+ throw new TypeError('Settings state must be an object');
4148
+ }
4149
+ const {
4150
+ id
4151
+ } = state;
4152
+ const {
4153
+ id: currentId
4154
+ } = currentState;
4155
+ if (id !== currentId) {
4156
+ throw new Error(`Settings state id must remain ${currentId}`);
4157
+ }
4158
+ return state;
4159
+ };
4160
+ const setComponentState = wrapCommand(applyComponentState);
4161
+
4131
4162
  const useNextSearchValue = state => {
4132
4163
  const {
4133
4164
  history,
@@ -4194,6 +4225,7 @@ const commandMap = {
4194
4225
  'Settings.filterStable': wrapCommand(filterStable),
4195
4226
  'Settings.filterTag': wrapCommand(filterTag),
4196
4227
  'Settings.getCommandIds': getCommandIds,
4228
+ 'Settings.getComponentState': getComponentState,
4197
4229
  'Settings.getKeyBindings': getKeyBindings,
4198
4230
  'Settings.getMenuEntries': wrapGetter(getMenuEntries2),
4199
4231
  'Settings.getMenuIds': getMenuIds,
@@ -4220,6 +4252,7 @@ const commandMap = {
4220
4252
  'Settings.resetSetting': wrapCommand(resetSetting),
4221
4253
  'Settings.restoreState': restoreState,
4222
4254
  'Settings.saveState': wrapGetter(saveState),
4255
+ 'Settings.setComponentState': setComponentState,
4223
4256
  'Settings.terminate': terminate,
4224
4257
  'Settings.useNextSearchValue': wrapCommand(useNextSearchValue),
4225
4258
  'Settings.usePreviousSearchValue': wrapCommand(usePreviousSearchValue)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/settings-view",
3
- "version": "2.27.3",
3
+ "version": "2.29.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",