@lvce-editor/settings-view 2.27.0 → 2.27.2
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 +64 -11
- package/package.json +1 -1
|
@@ -62,7 +62,7 @@ class AssertionError extends Error {
|
|
|
62
62
|
}
|
|
63
63
|
const Object$1 = 1;
|
|
64
64
|
const Number$2 = 2;
|
|
65
|
-
const Array$1 = 3;
|
|
65
|
+
const Array$1$1 = 3;
|
|
66
66
|
const String$2 = 4;
|
|
67
67
|
const Boolean$2 = 5;
|
|
68
68
|
const Function = 6;
|
|
@@ -81,7 +81,7 @@ const getType = value => {
|
|
|
81
81
|
return Null;
|
|
82
82
|
}
|
|
83
83
|
if (Array.isArray(value)) {
|
|
84
|
-
return Array$1;
|
|
84
|
+
return Array$1$1;
|
|
85
85
|
}
|
|
86
86
|
return Object$1;
|
|
87
87
|
case 'boolean':
|
|
@@ -1463,7 +1463,7 @@ const validateSettings = (items, modifiedSettings, preferences) => {
|
|
|
1463
1463
|
modified,
|
|
1464
1464
|
options: item.options,
|
|
1465
1465
|
type: item.type,
|
|
1466
|
-
value
|
|
1466
|
+
value
|
|
1467
1467
|
};
|
|
1468
1468
|
});
|
|
1469
1469
|
};
|
|
@@ -2482,6 +2482,7 @@ const i18nString = (key, placeholders = emptyObject) => {
|
|
|
2482
2482
|
};
|
|
2483
2483
|
|
|
2484
2484
|
const Advanced = 'Advanced';
|
|
2485
|
+
const ArrayValue = 'array value';
|
|
2485
2486
|
const Clear$1 = 'Clear';
|
|
2486
2487
|
const ColorValue = 'Color value';
|
|
2487
2488
|
const Experimental = 'Experimental';
|
|
@@ -2503,6 +2504,7 @@ const Tag = 'Tag';
|
|
|
2503
2504
|
const UnknownSettingType = 'Unknown setting type';
|
|
2504
2505
|
|
|
2505
2506
|
const advanced = () => i18nString(Advanced);
|
|
2507
|
+
const arrayValue = () => i18nString(ArrayValue);
|
|
2506
2508
|
const clear = () => i18nString(Clear$1);
|
|
2507
2509
|
const colorValue = () => i18nString(ColorValue);
|
|
2508
2510
|
const experimental = () => i18nString(Experimental);
|
|
@@ -2743,10 +2745,7 @@ const getUpdatedTabs = (tabs, selectedTabId) => {
|
|
|
2743
2745
|
}));
|
|
2744
2746
|
};
|
|
2745
2747
|
|
|
2746
|
-
const handleClickTab = (state, name) => {
|
|
2747
|
-
if (!name) {
|
|
2748
|
-
return state;
|
|
2749
|
-
}
|
|
2748
|
+
const handleClickTab = (state, name = '') => {
|
|
2750
2749
|
const {
|
|
2751
2750
|
height,
|
|
2752
2751
|
itemHeight,
|
|
@@ -2928,6 +2927,7 @@ const handleSettingChecked = (state, name, value, source = User) => {
|
|
|
2928
2927
|
const Enum = 1;
|
|
2929
2928
|
const String$1 = 2;
|
|
2930
2929
|
const Boolean$1 = 3;
|
|
2930
|
+
const Array$1 = 4;
|
|
2931
2931
|
const Number$1 = 5;
|
|
2932
2932
|
const Color = 6;
|
|
2933
2933
|
const Url = 7;
|
|
@@ -2939,6 +2939,17 @@ const handleSettingInput = (state, name, value, inputSource = User) => {
|
|
|
2939
2939
|
|
|
2940
2940
|
// TODO maybe have separate input functions for number and string inputs
|
|
2941
2941
|
const settingItem = items.find(item => item.id === name);
|
|
2942
|
+
if (settingItem && settingItem.type === Array$1) {
|
|
2943
|
+
try {
|
|
2944
|
+
const arrayValue = JSON.parse(value);
|
|
2945
|
+
if (!Array.isArray(arrayValue)) {
|
|
2946
|
+
return state;
|
|
2947
|
+
}
|
|
2948
|
+
return handleSettingUpdate(state, name, arrayValue, inputSource);
|
|
2949
|
+
} catch {
|
|
2950
|
+
return state;
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2942
2953
|
if (settingItem && settingItem.type === Number$1) {
|
|
2943
2954
|
const numberValue = value === '' ? '' : Number(value);
|
|
2944
2955
|
return handleSettingUpdate(state, name, numberValue, inputSource);
|
|
@@ -3466,6 +3477,37 @@ const getItemLabelDom = (domId, label) => {
|
|
|
3466
3477
|
}, text(label)];
|
|
3467
3478
|
};
|
|
3468
3479
|
|
|
3480
|
+
const getItemArrayVirtualDom = item => {
|
|
3481
|
+
const {
|
|
3482
|
+
description,
|
|
3483
|
+
errorMessage,
|
|
3484
|
+
hasError,
|
|
3485
|
+
heading,
|
|
3486
|
+
id,
|
|
3487
|
+
modified
|
|
3488
|
+
} = item;
|
|
3489
|
+
const domId = getInputId(id);
|
|
3490
|
+
const inputClassName = hasError ? mergeClassNames(InputBox, InputBoxError) : InputBox;
|
|
3491
|
+
const errorChildCount = hasError ? 1 : 0;
|
|
3492
|
+
return [{
|
|
3493
|
+
childCount: 3 + errorChildCount,
|
|
3494
|
+
className: SettingsItem,
|
|
3495
|
+
'data-modified': modified,
|
|
3496
|
+
name: id,
|
|
3497
|
+
role: Group,
|
|
3498
|
+
type: Div
|
|
3499
|
+
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
3500
|
+
childCount: 0,
|
|
3501
|
+
className: inputClassName,
|
|
3502
|
+
id: domId,
|
|
3503
|
+
inputType: 'text',
|
|
3504
|
+
name: id,
|
|
3505
|
+
onInput: HandleSettingInput,
|
|
3506
|
+
placeholder: arrayValue(),
|
|
3507
|
+
type: Input
|
|
3508
|
+
}, ...getErrorMessageDom(errorMessage)];
|
|
3509
|
+
};
|
|
3510
|
+
|
|
3469
3511
|
const checkBoxWrapperNode = {
|
|
3470
3512
|
childCount: 2,
|
|
3471
3513
|
className: SettingsItemCheckBox,
|
|
@@ -3478,11 +3520,13 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
3478
3520
|
hasError,
|
|
3479
3521
|
heading,
|
|
3480
3522
|
id,
|
|
3481
|
-
modified
|
|
3523
|
+
modified,
|
|
3524
|
+
value
|
|
3482
3525
|
} = item;
|
|
3483
3526
|
const domId = getInputId(id);
|
|
3484
3527
|
const checkBoxClassName = hasError ? mergeClassNames(CheckBox, InputBoxError) : CheckBox;
|
|
3485
3528
|
const errorChildCount = hasError ? 1 : 0;
|
|
3529
|
+
const isChecked = value === true || value === 'true';
|
|
3486
3530
|
return [{
|
|
3487
3531
|
childCount: 2 + errorChildCount,
|
|
3488
3532
|
className: SettingsItem,
|
|
@@ -3491,6 +3535,7 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
3491
3535
|
role: Group,
|
|
3492
3536
|
type: Div
|
|
3493
3537
|
}, ...getItemHeadingDom(heading), checkBoxWrapperNode, {
|
|
3538
|
+
checked: isChecked,
|
|
3494
3539
|
childCount: 0,
|
|
3495
3540
|
className: checkBoxClassName,
|
|
3496
3541
|
id: domId,
|
|
@@ -3704,6 +3749,8 @@ const getItemUrlVirtualDom = item => {
|
|
|
3704
3749
|
|
|
3705
3750
|
const getItemRender = type => {
|
|
3706
3751
|
switch (type) {
|
|
3752
|
+
case Array$1:
|
|
3753
|
+
return getItemArrayVirtualDom;
|
|
3707
3754
|
case Boolean$1:
|
|
3708
3755
|
return getItemCheckBoxVirtualDom;
|
|
3709
3756
|
case Color:
|
|
@@ -3791,7 +3838,6 @@ const getSettingsTabsDom = tabs => {
|
|
|
3791
3838
|
return [{
|
|
3792
3839
|
childCount: tabs.length,
|
|
3793
3840
|
className: SettingsTabs,
|
|
3794
|
-
onClick: HandleClickTab,
|
|
3795
3841
|
role: TabList,
|
|
3796
3842
|
type: Ul
|
|
3797
3843
|
}, ...tabs.flatMap(getTabVirtualDom)];
|
|
@@ -3800,6 +3846,7 @@ const getSettingsTabsDom = tabs => {
|
|
|
3800
3846
|
const settingsSideBarNode = {
|
|
3801
3847
|
childCount: 1,
|
|
3802
3848
|
className: SettingsSideBar,
|
|
3849
|
+
onClick: HandleClickTab,
|
|
3803
3850
|
type: Aside
|
|
3804
3851
|
};
|
|
3805
3852
|
const getSettingsSideBarDom = tabs => {
|
|
@@ -3841,7 +3888,13 @@ const renderItems = (oldState, newState) => {
|
|
|
3841
3888
|
return ['Viewlet.setDom2', newState.id, dom];
|
|
3842
3889
|
};
|
|
3843
3890
|
|
|
3844
|
-
const enabledTypes = [Number$1, String$1, Color];
|
|
3891
|
+
const enabledTypes = [Array$1, Number$1, String$1, Color];
|
|
3892
|
+
const getInputValue = (type, value) => {
|
|
3893
|
+
if (type === Array$1) {
|
|
3894
|
+
return JSON.stringify(value);
|
|
3895
|
+
}
|
|
3896
|
+
return value;
|
|
3897
|
+
};
|
|
3845
3898
|
const renderSettingValues = (oldState, newState) => {
|
|
3846
3899
|
const {
|
|
3847
3900
|
filteredItems,
|
|
@@ -3850,7 +3903,7 @@ const renderSettingValues = (oldState, newState) => {
|
|
|
3850
3903
|
} = newState;
|
|
3851
3904
|
const enabledSettings = filteredItems.filter(item => enabledTypes.includes(item.type));
|
|
3852
3905
|
const inputValues = enabledSettings.map(item => {
|
|
3853
|
-
const value = preferences[item.id] ?? item.value;
|
|
3906
|
+
const value = getInputValue(item.type, preferences[item.id] ?? item.value);
|
|
3854
3907
|
return {
|
|
3855
3908
|
name: item.id,
|
|
3856
3909
|
value
|