@lvce-editor/settings-view 1.11.0 → 1.13.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.
@@ -1096,17 +1096,45 @@ const handleInput = (state, value, inputSource = User) => {
1096
1096
  };
1097
1097
 
1098
1098
  const handleSettingChecked = (state, name, value) => {
1099
+ const {
1100
+ modifiedSettings,
1101
+ items,
1102
+ tabs,
1103
+ searchValue
1104
+ } = state;
1105
+ const newModifiedSettings = {
1106
+ ...modifiedSettings,
1107
+ [name]: true
1108
+ };
1109
+ const filteredItems = getFilteredItems(items, tabs, searchValue, newModifiedSettings);
1110
+
1099
1111
  // TODO update value
1100
1112
  return {
1101
- ...state
1113
+ ...state,
1114
+ modifiedSettings: newModifiedSettings,
1115
+ filteredItems
1102
1116
  };
1103
1117
  };
1104
1118
 
1105
1119
  const handleSettingInput = (state, name, value, inputSource = User) => {
1106
1120
  // TODO update value
1121
+ const {
1122
+ modifiedSettings,
1123
+ items,
1124
+ tabs,
1125
+ searchValue
1126
+ } = state;
1127
+ const newModifiedSettings = {
1128
+ ...modifiedSettings,
1129
+ [name]: true
1130
+ };
1131
+
1132
+ // TODO don't need to update items if it was already modified
1133
+ const filteredItems = getFilteredItems(items, tabs, searchValue, newModifiedSettings);
1107
1134
  return {
1108
1135
  ...state,
1109
- inputSource
1136
+ inputSource,
1137
+ filteredItems
1110
1138
  };
1111
1139
  };
1112
1140
 
@@ -1419,6 +1447,7 @@ const WordSeparators = 'Word Separators';
1419
1447
  const WordSeparatorsDescription = 'Characters that will be used as word separators when doing word related navigations or operations';
1420
1448
  const WrappingIndent = 'Wrapping Indent';
1421
1449
  const WrappingIndentDescription = 'Controls the indentation of wrapped lines';
1450
+ const UnknownSettingType = 'Unknown setting type';
1422
1451
 
1423
1452
  const autoSave = () => {
1424
1453
  return i18nString(AutoSave);
@@ -2217,6 +2246,9 @@ const wrappingIndent = () => {
2217
2246
  const wrappingIndentDescription = () => {
2218
2247
  return i18nString(WrappingIndentDescription);
2219
2248
  };
2249
+ const unknownSettingType = () => {
2250
+ return i18nString(UnknownSettingType);
2251
+ };
2220
2252
 
2221
2253
  const getSettingItems = async () => {
2222
2254
  return [{
@@ -3302,30 +3334,31 @@ const text = data => {
3302
3334
  const {
3303
3335
  Viewlet
3304
3336
  } = ClassNames;
3305
- const Settings = 'Settings';
3306
- const SettingsInputWrapper = 'SettingsInputWrapper';
3307
- const InputBox = 'InputBox';
3308
- const SettingsSearchInput = 'SettingsSearchInput';
3337
+ const Badge = 'Badge';
3309
3338
  const Button = 'Button';
3339
+ const CheckBox = 'CheckBox';
3340
+ const Disabled = 'Disabled';
3341
+ const InputBox = 'InputBox';
3310
3342
  const InputButton = 'InputButton';
3311
- const SearchFieldButton = 'SearchFieldButton';
3312
3343
  const MaskIcon = 'MaskIcon';
3313
3344
  const MaskIconClearAll = 'MaskIconClearAll';
3314
- const SettingsItem = 'SettingsItem';
3315
- const SettingsItemCheckBox = 'SettingsItemCheckBox';
3316
- const CheckBox = 'CheckBox';
3345
+ const SearchFieldButton = 'SearchFieldButton';
3317
3346
  const Select = 'Select';
3318
- const SettingsItems = 'SettingsItems';
3319
- const SettingsNoResults = 'SettingsNoResults';
3320
- const SettingsMain = 'SettingsMain';
3347
+ const Settings = 'Settings';
3321
3348
  const SettingsContent = 'SettingsContent';
3322
3349
  const SettingsContentHeading = 'SettingsContentHeading';
3323
3350
  const SettingsHeader = 'SettingsHeader';
3351
+ const SettingsInputWrapper = 'SettingsInputWrapper';
3352
+ const SettingsItem = 'SettingsItem';
3353
+ const SettingsItemCheckBox = 'SettingsItemCheckBox';
3354
+ const SettingsItems = 'SettingsItems';
3355
+ const SettingsMain = 'SettingsMain';
3356
+ const SettingsNoResults = 'SettingsNoResults';
3357
+ const SettingsSearchInput = 'SettingsSearchInput';
3324
3358
  const SettingsSideBar = 'SettingsSideBar';
3325
3359
  const SettingsTabs = 'SettingsTabs';
3326
3360
  const Tab = 'Tab';
3327
3361
  const TabSelected = 'TabSelected';
3328
- const Badge = 'Badge';
3329
3362
 
3330
3363
  const getSettingsInputBadgeDom = (filteredSettingsCount, hasSearchValue) => {
3331
3364
  if (!hasSearchValue) {
@@ -3347,14 +3380,20 @@ const HandleSettingInput = 'handleSettingInput';
3347
3380
  const HandleSettingChecked = 'handleSettingChecked';
3348
3381
  const HandleSettingSelect = 'handleSettingSelect';
3349
3382
 
3350
- const getSettingsInputButtonsDom = () => {
3383
+ const getButtonClassName = hasSearchValue => {
3384
+ if (hasSearchValue) {
3385
+ return mergeClassNames(Button, InputButton, SearchFieldButton);
3386
+ }
3387
+ return mergeClassNames(Button, InputButton, SearchFieldButton, Disabled);
3388
+ };
3389
+ const getSettingsInputButtonsDom = hasSearchValue => {
3351
3390
  return [{
3352
3391
  type: VirtualDomElements.Button,
3353
- className: mergeClassNames(Button, InputButton, SearchFieldButton),
3392
+ className: getButtonClassName(hasSearchValue),
3354
3393
  childCount: 1,
3355
3394
  ariaLabel: clear(),
3356
3395
  name: Clear$1,
3357
- // TODO add click event listener
3396
+ disabled: !hasSearchValue,
3358
3397
  onClick: HandleClickClear
3359
3398
  }, {
3360
3399
  type: VirtualDomElements.Div,
@@ -3389,7 +3428,7 @@ const getSettingsHeaderDom = (filteredSettingsCount, hasSearchValue) => {
3389
3428
  type: VirtualDomElements.Div,
3390
3429
  className: SettingsInputWrapper,
3391
3430
  childCount
3392
- }, ...getSettingsInputDom(), ...getSettingsInputButtonsDom(), ...badgeDom];
3431
+ }, ...getSettingsInputDom(), ...getSettingsInputButtonsDom(hasSearchValue), ...badgeDom];
3393
3432
  };
3394
3433
 
3395
3434
  const getInputId = id => {
@@ -3400,13 +3439,17 @@ const getItemCheckBoxVirtualDom = item => {
3400
3439
  const {
3401
3440
  heading,
3402
3441
  description,
3403
- id
3442
+ id,
3443
+ modified
3404
3444
  } = item;
3445
+ const isModified = modified || false;
3405
3446
  const domId = getInputId(id);
3406
3447
  return [{
3407
3448
  type: VirtualDomElements.Div,
3408
3449
  className: SettingsItem,
3409
- childCount: 3
3450
+ childCount: 3,
3451
+ role: 'group',
3452
+ dataModified: isModified
3410
3453
  }, {
3411
3454
  type: VirtualDomElements.H3,
3412
3455
  childCount: 1
@@ -3417,10 +3460,11 @@ const getItemCheckBoxVirtualDom = item => {
3417
3460
  }, {
3418
3461
  type: VirtualDomElements.Input,
3419
3462
  className: CheckBox,
3420
- inputType: 'checkbox',
3421
3463
  childCount: 0,
3422
3464
  id: domId,
3423
- name: id
3465
+ inputType: 'checkbox',
3466
+ name: id,
3467
+ onChange: HandleSettingChecked
3424
3468
  }, {
3425
3469
  type: VirtualDomElements.Label,
3426
3470
  childCount: 1,
@@ -3428,6 +3472,22 @@ const getItemCheckBoxVirtualDom = item => {
3428
3472
  }, text(description)];
3429
3473
  };
3430
3474
 
3475
+ const getItemHeadingDom = heading => {
3476
+ return [{
3477
+ type: VirtualDomElements.H3,
3478
+ childCount: 1
3479
+ }, text(heading)];
3480
+ };
3481
+
3482
+ const getItemLabelDom = (domId, label) => {
3483
+ return [{
3484
+ type: VirtualDomElements.Label,
3485
+ htmlFor: domId,
3486
+ childCount: 1,
3487
+ className: 'Label'
3488
+ }, text(label)];
3489
+ };
3490
+
3431
3491
  const getItemNumberVirtualDom = item => {
3432
3492
  const {
3433
3493
  heading,
@@ -3438,16 +3498,9 @@ const getItemNumberVirtualDom = item => {
3438
3498
  return [{
3439
3499
  type: VirtualDomElements.Div,
3440
3500
  className: SettingsItem,
3441
- childCount: 3
3442
- }, {
3443
- type: VirtualDomElements.H3,
3444
- childCount: 1
3445
- }, text(heading), {
3446
- type: VirtualDomElements.Label,
3447
- htmlFor: domId,
3448
- childCount: 1,
3449
- className: 'Label'
3450
- }, text(description), {
3501
+ childCount: 3,
3502
+ role: 'group'
3503
+ }, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
3451
3504
  type: VirtualDomElements.Input,
3452
3505
  className: InputBox,
3453
3506
  inputType: 'number',
@@ -3478,21 +3531,18 @@ const getItemSelectVirtualDom = item => {
3478
3531
  id
3479
3532
  } = item;
3480
3533
  const options = item.options || [];
3534
+ const domId = getInputId(id);
3481
3535
  return [{
3482
3536
  type: VirtualDomElements.Div,
3483
3537
  className: SettingsItem,
3484
- childCount: 3
3485
- }, {
3486
- type: VirtualDomElements.H3,
3487
- childCount: 1
3488
- }, text(heading), {
3489
- type: VirtualDomElements.P,
3490
- childCount: 1
3491
- }, text(description), {
3538
+ childCount: 3,
3539
+ role: 'group'
3540
+ }, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
3492
3541
  type: VirtualDomElements.Select,
3493
3542
  className: Select,
3494
3543
  childCount: options.length,
3495
- name: id
3544
+ name: id,
3545
+ onChange: HandleSettingSelect
3496
3546
  }, ...options.flatMap(getOptionDom)];
3497
3547
  };
3498
3548
 
@@ -3505,7 +3555,8 @@ const getItemStringVirtualDom = item => {
3505
3555
  return [{
3506
3556
  type: VirtualDomElements.Div,
3507
3557
  className: SettingsItem,
3508
- childCount: 3
3558
+ childCount: 3,
3559
+ role: 'group'
3509
3560
  }, {
3510
3561
  type: VirtualDomElements.H3,
3511
3562
  childCount: 1
@@ -3527,8 +3578,9 @@ const getItemUnknownVirtualDom = () => {
3527
3578
  return [{
3528
3579
  type: VirtualDomElements.Div,
3529
3580
  className: SettingsItem,
3530
- childCount: 1
3531
- }, text('unknown setting type')];
3581
+ childCount: 1,
3582
+ role: 'group'
3583
+ }, text(unknownSettingType())];
3532
3584
  };
3533
3585
 
3534
3586
  const getItemVirtualDom = item => {
@@ -3720,10 +3772,10 @@ const renderEventListeners = () => {
3720
3772
  params: ['handleSettingInput', 'event.target.name', 'event.target.value']
3721
3773
  }, {
3722
3774
  name: HandleSettingChecked,
3723
- params: ['handleSettingInput', 'event.target.name', 'event.target.value']
3775
+ params: ['handleSettingChecked', 'event.target.name', 'event.target.value']
3724
3776
  }, {
3725
3777
  name: HandleSettingSelect,
3726
- params: ['handleSettingInput', 'event.target.name', 'event.target.value']
3778
+ params: ['handleSettingSelect', 'event.target.name', 'event.target.value']
3727
3779
  }];
3728
3780
  };
3729
3781
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/settings-view",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",