@lvce-editor/settings-view 1.9.0 → 1.10.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.
@@ -989,29 +989,35 @@ const create$1 = (id, uri, x, y, width, height) => {
989
989
  preferences: {},
990
990
  inputSource: 0,
991
991
  scrollOffset: 0,
992
- filteredItemsCount: 0
992
+ filteredItemsCount: 0,
993
+ history: []
993
994
  };
994
995
  set$1(id, state, state);
995
996
  };
996
997
 
997
- const isEqual$2 = (oldState, newState) => {
998
+ const isEqual$3 = (oldState, newState) => {
998
999
  return oldState.focus === newState.focus;
999
1000
  };
1000
1001
 
1001
- const isEqual$1 = (oldState, newState) => {
1002
+ const isEqual$2 = (oldState, newState) => {
1002
1003
  return oldState === newState;
1003
1004
  };
1004
1005
 
1006
+ const isEqual$1 = (oldState, newState) => {
1007
+ return oldState.filteredItems === newState.filteredItems;
1008
+ };
1009
+
1005
1010
  const RenderItems = 1;
1006
1011
  const RenderFocus = 2;
1007
1012
  const RenderValue = 3;
1013
+ const RenderSettingValues = 10;
1008
1014
 
1009
1015
  const isEqual = (oldState, newState) => {
1010
1016
  return newState.inputSource === User || oldState.searchValue === newState.searchValue;
1011
1017
  };
1012
1018
 
1013
- const modules = [isEqual$2, isEqual$1, isEqual];
1014
- const numbers = [RenderFocus, RenderItems, RenderValue];
1019
+ const modules = [isEqual$3, isEqual$2, isEqual, isEqual$1];
1020
+ const numbers = [RenderFocus, RenderItems, RenderValue, RenderSettingValues];
1015
1021
 
1016
1022
  const diff = (oldState, newState) => {
1017
1023
  const diffResult = [];
@@ -1142,7 +1148,7 @@ const FormatOnSave = 'Format on Save';
1142
1148
  const FormatOnSaveDescription = 'Format code when saving';
1143
1149
  const NumberValue = 'number value';
1144
1150
  const SearchSettings = 'Search Settings';
1145
- const SettingsContent = 'Settings Content';
1151
+ const SettingsContent$1 = 'Settings Content';
1146
1152
  const SidebarPosition = 'Sidebar Position';
1147
1153
  const SidebarPositionDescription = 'The position of the sidebar';
1148
1154
  const Telemetry = 'Telemetry';
@@ -1156,6 +1162,7 @@ const WindowSizeDescription = 'The default window size';
1156
1162
  const WindowTitle = 'Window Title';
1157
1163
  const WindowTitleDescription = 'The title shown in the window';
1158
1164
  const NoSettingsMatching = 'No settings matching "{PH1}" found';
1165
+ const MatchingSettings = '{PH1} matching settings';
1159
1166
 
1160
1167
  // Text Editor Settings
1161
1168
  const WordWrap = 'Word Wrap';
@@ -1447,7 +1454,7 @@ const searchSettings = () => {
1447
1454
  return i18nString(SearchSettings);
1448
1455
  };
1449
1456
  const settingsContent = () => {
1450
- return i18nString(SettingsContent);
1457
+ return i18nString(SettingsContent$1);
1451
1458
  };
1452
1459
  const sidebarPosition = () => {
1453
1460
  return i18nString(SidebarPosition);
@@ -1490,6 +1497,11 @@ const noSettingsMatching = searchTerm => {
1490
1497
  PH1: searchTerm
1491
1498
  });
1492
1499
  };
1500
+ const matchingSettings = count => {
1501
+ return i18nString(MatchingSettings, {
1502
+ PH1: count.toString()
1503
+ });
1504
+ };
1493
1505
 
1494
1506
  // Text Editor Settings
1495
1507
  const wordWrap = () => {
@@ -2181,7 +2193,7 @@ const wrappingIndentDescription = () => {
2181
2193
 
2182
2194
  const getSettingItems = async () => {
2183
2195
  return [{
2184
- id: 'fontSize',
2196
+ id: 'Editor.fontSize',
2185
2197
  heading: fontSize(),
2186
2198
  description: fontSizeDescription(),
2187
2199
  type: Number$1,
@@ -3218,7 +3230,7 @@ const ClassNames = {
3218
3230
  const mergeClassNames = (...classNames) => {
3219
3231
  return classNames.filter(Boolean).join(' ');
3220
3232
  };
3221
- const Button = 1;
3233
+ const Button$1 = 1;
3222
3234
  const Div = 4;
3223
3235
  const H1 = 5;
3224
3236
  const Input = 6;
@@ -3227,13 +3239,13 @@ const H3 = 23;
3227
3239
  const Aside = 28;
3228
3240
  const P = 50;
3229
3241
  const Ul = 60;
3230
- const Select = 63;
3242
+ const Select$1 = 63;
3231
3243
  const Option = 64;
3232
3244
  const Label = 66;
3233
3245
  const VirtualDomElements = {
3234
3246
  __proto__: null,
3235
3247
  Aside,
3236
- Button,
3248
+ Button: Button$1,
3237
3249
  Div,
3238
3250
  H1,
3239
3251
  H3,
@@ -3241,7 +3253,7 @@ const VirtualDomElements = {
3241
3253
  Label,
3242
3254
  Option,
3243
3255
  P,
3244
- Select,
3256
+ Select: Select$1,
3245
3257
  Ul};
3246
3258
  const text = data => {
3247
3259
  return {
@@ -3255,28 +3267,51 @@ const {
3255
3267
  Viewlet
3256
3268
  } = ClassNames;
3257
3269
  const Settings = 'Settings';
3270
+ const SettingsInputWrapper = 'SettingsInputWrapper';
3271
+ const InputBox = 'InputBox';
3272
+ const SettingsSearchInput = 'SettingsSearchInput';
3273
+ const Button = 'Button';
3274
+ const InputButton = 'InputButton';
3275
+ const SearchFieldButton = 'SearchFieldButton';
3276
+ const MaskIcon = 'MaskIcon';
3277
+ const MaskIconClearAll = 'MaskIconClearAll';
3278
+ const SettingsItem = 'SettingsItem';
3279
+ const SettingsItemCheckBox = 'SettingsItemCheckBox';
3280
+ const CheckBox = 'CheckBox';
3281
+ const Select = 'Select';
3282
+ const SettingsItems = 'SettingsItems';
3283
+ const SettingsNoResults = 'SettingsNoResults';
3284
+ const SettingsMain = 'SettingsMain';
3285
+ const SettingsContent = 'SettingsContent';
3286
+ const SettingsContentHeading = 'SettingsContentHeading';
3287
+ const SettingsHeader = 'SettingsHeader';
3288
+ const SettingsSideBar = 'SettingsSideBar';
3289
+ const SettingsTabs = 'SettingsTabs';
3290
+ const Tab = 'Tab';
3291
+ const TabSelected = 'TabSelected';
3292
+ const Badge = 'Badge';
3293
+
3294
+ const getSettingsInputBadgeDom = (filteredSettingsCount, hasSearchValue) => {
3295
+ if (!hasSearchValue) {
3296
+ return [];
3297
+ }
3298
+ const badgeText = matchingSettings(filteredSettingsCount);
3299
+ return [{
3300
+ type: VirtualDomElements.Div,
3301
+ className: Badge,
3302
+ childCount: 1
3303
+ }, text(badgeText)];
3304
+ };
3258
3305
 
3259
3306
  // TODo use numeric ids
3260
3307
  const HandleClickClear = 'handleClickClear';
3261
3308
  const HandleClickTab = 'handleClickTab';
3262
3309
  const HandleInput = 'handleInput';
3263
3310
 
3264
- const getSettingsInputDom = () => {
3265
- const placeholder = searchSettings();
3311
+ const getSettingsInputButtonsDom = () => {
3266
3312
  return [{
3267
- type: VirtualDomElements.Div,
3268
- className: 'SettingsInputWrapper',
3269
- childCount: 2
3270
- }, {
3271
- type: VirtualDomElements.Input,
3272
- className: 'InputBox SettingsSearchInput',
3273
- placeholder,
3274
- childCount: 0,
3275
- name: SettingsSearch,
3276
- onInput: HandleInput
3277
- }, {
3278
3313
  type: VirtualDomElements.Button,
3279
- className: 'Button InputButton SearchFieldButton',
3314
+ className: mergeClassNames(Button, InputButton, SearchFieldButton),
3280
3315
  childCount: 1,
3281
3316
  ariaLabel: clear(),
3282
3317
  name: Clear$1,
@@ -3284,17 +3319,38 @@ const getSettingsInputDom = () => {
3284
3319
  onClick: HandleClickClear
3285
3320
  }, {
3286
3321
  type: VirtualDomElements.Div,
3287
- className: 'MaskIcon MaskIconClearAll',
3322
+ className: mergeClassNames(MaskIcon, MaskIconClearAll),
3288
3323
  childCount: 0
3289
3324
  }];
3290
3325
  };
3291
3326
 
3292
- const getSettingsHeaderDom = () => {
3327
+ const getSettingsInputDom = () => {
3328
+ const placeholder = searchSettings();
3329
+ return [{
3330
+ type: VirtualDomElements.Input,
3331
+ className: mergeClassNames(InputBox, SettingsSearchInput),
3332
+ placeholder,
3333
+ childCount: 0,
3334
+ name: SettingsSearch,
3335
+ onInput: HandleInput
3336
+ }];
3337
+ };
3338
+
3339
+ const getChildCount = hasSearchValue => {
3340
+ return hasSearchValue ? 3 : 2;
3341
+ };
3342
+ const getSettingsHeaderDom = (filteredSettingsCount, hasSearchValue) => {
3343
+ const badgeDom = getSettingsInputBadgeDom(filteredSettingsCount, hasSearchValue);
3344
+ const childCount = getChildCount(hasSearchValue);
3293
3345
  return [{
3294
3346
  type: VirtualDomElements.Div,
3295
- className: 'SettingsHeader',
3347
+ className: SettingsHeader,
3296
3348
  childCount: 1
3297
- }, ...getSettingsInputDom()];
3349
+ }, {
3350
+ type: VirtualDomElements.Div,
3351
+ className: SettingsInputWrapper,
3352
+ childCount
3353
+ }, ...getSettingsInputDom(), ...getSettingsInputButtonsDom(), ...badgeDom];
3298
3354
  };
3299
3355
 
3300
3356
  const getInputId = id => {
@@ -3310,21 +3366,22 @@ const getItemCheckBoxVirtualDom = item => {
3310
3366
  const domId = getInputId(id);
3311
3367
  return [{
3312
3368
  type: VirtualDomElements.Div,
3313
- className: 'SettingsItem',
3369
+ className: SettingsItem,
3314
3370
  childCount: 3
3315
3371
  }, {
3316
3372
  type: VirtualDomElements.H3,
3317
3373
  childCount: 1
3318
3374
  }, text(heading), {
3319
3375
  type: VirtualDomElements.Div,
3320
- className: 'SettingsItemCheckBox',
3376
+ className: SettingsItemCheckBox,
3321
3377
  childCount: 2
3322
3378
  }, {
3323
3379
  type: VirtualDomElements.Input,
3324
- className: 'CheckBox',
3380
+ className: CheckBox,
3325
3381
  inputType: 'checkbox',
3326
3382
  childCount: 0,
3327
- id: domId
3383
+ id: domId,
3384
+ name: id
3328
3385
  }, {
3329
3386
  type: VirtualDomElements.Label,
3330
3387
  childCount: 1,
@@ -3335,24 +3392,30 @@ const getItemCheckBoxVirtualDom = item => {
3335
3392
  const getItemNumberVirtualDom = item => {
3336
3393
  const {
3337
3394
  heading,
3338
- description
3395
+ description,
3396
+ id
3339
3397
  } = item;
3398
+ const domId = getInputId(id);
3340
3399
  return [{
3341
3400
  type: VirtualDomElements.Div,
3342
- className: 'SettingsItem',
3401
+ className: SettingsItem,
3343
3402
  childCount: 3
3344
3403
  }, {
3345
3404
  type: VirtualDomElements.H3,
3346
3405
  childCount: 1
3347
3406
  }, text(heading), {
3348
- type: VirtualDomElements.P,
3349
- childCount: 1
3407
+ type: VirtualDomElements.Label,
3408
+ htmlFor: domId,
3409
+ childCount: 1,
3410
+ className: 'Label'
3350
3411
  }, text(description), {
3351
3412
  type: VirtualDomElements.Input,
3352
- className: 'InputBox',
3413
+ className: InputBox,
3353
3414
  inputType: 'number',
3354
3415
  placeholder: numberValue(),
3355
- childCount: 0
3416
+ childCount: 0,
3417
+ id: domId,
3418
+ name: id
3356
3419
  }];
3357
3420
  };
3358
3421
 
@@ -3371,12 +3434,13 @@ const getOptionDom = option => {
3371
3434
  const getItemSelectVirtualDom = item => {
3372
3435
  const {
3373
3436
  heading,
3374
- description
3437
+ description,
3438
+ id
3375
3439
  } = item;
3376
3440
  const options = item.options || [];
3377
3441
  return [{
3378
3442
  type: VirtualDomElements.Div,
3379
- className: 'SettingsItem',
3443
+ className: SettingsItem,
3380
3444
  childCount: 3
3381
3445
  }, {
3382
3446
  type: VirtualDomElements.H3,
@@ -3386,19 +3450,21 @@ const getItemSelectVirtualDom = item => {
3386
3450
  childCount: 1
3387
3451
  }, text(description), {
3388
3452
  type: VirtualDomElements.Select,
3389
- className: 'Select',
3390
- childCount: options.length
3453
+ className: Select,
3454
+ childCount: options.length,
3455
+ name: id
3391
3456
  }, ...options.flatMap(getOptionDom)];
3392
3457
  };
3393
3458
 
3394
3459
  const getItemStringVirtualDom = item => {
3395
3460
  const {
3396
3461
  heading,
3397
- description
3462
+ description,
3463
+ id
3398
3464
  } = item;
3399
3465
  return [{
3400
3466
  type: VirtualDomElements.Div,
3401
- className: 'SettingsItem',
3467
+ className: SettingsItem,
3402
3468
  childCount: 3
3403
3469
  }, {
3404
3470
  type: VirtualDomElements.H3,
@@ -3408,10 +3474,11 @@ const getItemStringVirtualDom = item => {
3408
3474
  childCount: 1
3409
3475
  }, text(description), {
3410
3476
  type: VirtualDomElements.Input,
3411
- className: 'InputBox',
3477
+ className: InputBox,
3412
3478
  inputType: 'text',
3413
3479
  placeholder: numberValue(),
3414
- childCount: 0
3480
+ childCount: 0,
3481
+ name: id
3415
3482
  }];
3416
3483
  };
3417
3484
 
@@ -3435,11 +3502,11 @@ const getItemVirtualDom = item => {
3435
3502
  const getSettingsNoResultsDom = searchValue => {
3436
3503
  return [{
3437
3504
  type: VirtualDomElements.Div,
3438
- className: 'SettingsItems',
3505
+ className: SettingsItems,
3439
3506
  childCount: 1
3440
3507
  }, {
3441
- type: VirtualDomElements.Div,
3442
- className: 'SettingsNoResults',
3508
+ type: VirtualDomElements.P,
3509
+ className: SettingsNoResults,
3443
3510
  childCount: 1
3444
3511
  }, text(noSettingsMatching(searchValue))];
3445
3512
  };
@@ -3450,7 +3517,7 @@ const getSettingsItemsDom = (items, searchValue) => {
3450
3517
  }
3451
3518
  return [{
3452
3519
  type: VirtualDomElements.Div,
3453
- className: 'SettingsItems',
3520
+ className: SettingsItems,
3454
3521
  childCount: items.length
3455
3522
  }, ...items.flatMap(getItemVirtualDom)];
3456
3523
  };
@@ -3460,17 +3527,17 @@ const getSettingsContentDom = (items, tabs, searchValue) => {
3460
3527
  const headerText = selectedTab ? selectedTab.label : settingsContent();
3461
3528
  return [{
3462
3529
  type: VirtualDomElements.Div,
3463
- className: 'SettingsContent',
3530
+ className: SettingsContent,
3464
3531
  childCount: 2
3465
3532
  }, {
3466
3533
  type: VirtualDomElements.H1,
3467
- className: 'SettingsContentHeading',
3534
+ className: SettingsContentHeading,
3468
3535
  childCount: 1
3469
3536
  }, text(headerText), ...getSettingsItemsDom(items, searchValue)];
3470
3537
  };
3471
3538
 
3472
3539
  const getTabClassName = tab => {
3473
- return tab.selected ? mergeClassNames('Tab', 'TabSelected') : 'Tab';
3540
+ return tab.selected ? mergeClassNames(Tab, TabSelected) : Tab;
3474
3541
  };
3475
3542
 
3476
3543
  const getTabVirtualDom = tab => {
@@ -3489,7 +3556,7 @@ const getTabVirtualDom = tab => {
3489
3556
  const getSettingsTabsDom = tabs => {
3490
3557
  return [{
3491
3558
  type: VirtualDomElements.Ul,
3492
- className: 'SettingsTabs',
3559
+ className: SettingsTabs,
3493
3560
  role: AriaRoles.TabList,
3494
3561
  childCount: tabs.length,
3495
3562
  onClick: HandleClickTab
@@ -3499,7 +3566,7 @@ const getSettingsTabsDom = tabs => {
3499
3566
  const getSettingsSideBarDom = tabs => {
3500
3567
  return [{
3501
3568
  type: VirtualDomElements.Aside,
3502
- className: 'SettingsSideBar',
3569
+ className: SettingsSideBar,
3503
3570
  childCount: 1
3504
3571
  }, ...getSettingsTabsDom(tabs)];
3505
3572
  };
@@ -3507,7 +3574,7 @@ const getSettingsSideBarDom = tabs => {
3507
3574
  const getSettingsMainDom = (tabs, items, searchValue) => {
3508
3575
  return [{
3509
3576
  type: VirtualDomElements.Div,
3510
- className: 'SettingsMain',
3577
+ className: SettingsMain,
3511
3578
  childCount: 2
3512
3579
  }, ...getSettingsSideBarDom(tabs), ...getSettingsContentDom(items, tabs, searchValue)];
3513
3580
  };
@@ -3516,13 +3583,15 @@ const getSettingsDom = state => {
3516
3583
  const {
3517
3584
  tabs,
3518
3585
  filteredItems,
3519
- searchValue
3586
+ searchValue,
3587
+ filteredItemsCount
3520
3588
  } = state;
3589
+ const hasSearchValue = searchValue.trim().length > 0;
3521
3590
  return [{
3522
3591
  type: VirtualDomElements.Div,
3523
3592
  childCount: 2,
3524
3593
  className: mergeClassNames(Viewlet, Settings)
3525
- }, ...getSettingsHeaderDom(), ...getSettingsMainDom(tabs, filteredItems, searchValue)];
3594
+ }, ...getSettingsHeaderDom(filteredItemsCount, hasSearchValue), ...getSettingsMainDom(tabs, filteredItems, searchValue)];
3526
3595
  };
3527
3596
 
3528
3597
  const renderItems = (oldState, newState) => {
@@ -3530,6 +3599,19 @@ const renderItems = (oldState, newState) => {
3530
3599
  return ['Viewlet.setDom2', newState.id, dom];
3531
3600
  };
3532
3601
 
3602
+ const renderSettingValues = (oldState, newState) => {
3603
+ const {
3604
+ filteredItems,
3605
+ id
3606
+ } = newState;
3607
+ const numericSettings = filteredItems.filter(item => item.type === Number$1);
3608
+ const inputValues = numericSettings.map(item => ({
3609
+ name: item.id,
3610
+ value: item.value
3611
+ }));
3612
+ return ['Viewlet.setInputValues', id, inputValues];
3613
+ };
3614
+
3533
3615
  const renderValue = (oldState, newState) => {
3534
3616
  const {
3535
3617
  id,
@@ -3544,6 +3626,8 @@ const getRenderer = diffType => {
3544
3626
  return renderItems;
3545
3627
  case RenderValue:
3546
3628
  return renderValue;
3629
+ case RenderSettingValues:
3630
+ return renderSettingValues;
3547
3631
  default:
3548
3632
  throw new Error('unknown renderer');
3549
3633
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/settings-view",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",