@lvce-editor/settings-view 2.27.0 → 2.27.1
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.
|
@@ -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);
|
|
@@ -2928,6 +2930,7 @@ const handleSettingChecked = (state, name, value, source = User) => {
|
|
|
2928
2930
|
const Enum = 1;
|
|
2929
2931
|
const String$1 = 2;
|
|
2930
2932
|
const Boolean$1 = 3;
|
|
2933
|
+
const Array$1 = 4;
|
|
2931
2934
|
const Number$1 = 5;
|
|
2932
2935
|
const Color = 6;
|
|
2933
2936
|
const Url = 7;
|
|
@@ -2939,6 +2942,17 @@ const handleSettingInput = (state, name, value, inputSource = User) => {
|
|
|
2939
2942
|
|
|
2940
2943
|
// TODO maybe have separate input functions for number and string inputs
|
|
2941
2944
|
const settingItem = items.find(item => item.id === name);
|
|
2945
|
+
if (settingItem && settingItem.type === Array$1) {
|
|
2946
|
+
try {
|
|
2947
|
+
const arrayValue = JSON.parse(value);
|
|
2948
|
+
if (!Array.isArray(arrayValue)) {
|
|
2949
|
+
return state;
|
|
2950
|
+
}
|
|
2951
|
+
return handleSettingUpdate(state, name, arrayValue, inputSource);
|
|
2952
|
+
} catch {
|
|
2953
|
+
return state;
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2942
2956
|
if (settingItem && settingItem.type === Number$1) {
|
|
2943
2957
|
const numberValue = value === '' ? '' : Number(value);
|
|
2944
2958
|
return handleSettingUpdate(state, name, numberValue, inputSource);
|
|
@@ -3466,6 +3480,37 @@ const getItemLabelDom = (domId, label) => {
|
|
|
3466
3480
|
}, text(label)];
|
|
3467
3481
|
};
|
|
3468
3482
|
|
|
3483
|
+
const getItemArrayVirtualDom = item => {
|
|
3484
|
+
const {
|
|
3485
|
+
description,
|
|
3486
|
+
errorMessage,
|
|
3487
|
+
hasError,
|
|
3488
|
+
heading,
|
|
3489
|
+
id,
|
|
3490
|
+
modified
|
|
3491
|
+
} = item;
|
|
3492
|
+
const domId = getInputId(id);
|
|
3493
|
+
const inputClassName = hasError ? mergeClassNames(InputBox, InputBoxError) : InputBox;
|
|
3494
|
+
const errorChildCount = hasError ? 1 : 0;
|
|
3495
|
+
return [{
|
|
3496
|
+
childCount: 3 + errorChildCount,
|
|
3497
|
+
className: SettingsItem,
|
|
3498
|
+
'data-modified': modified,
|
|
3499
|
+
name: id,
|
|
3500
|
+
role: Group,
|
|
3501
|
+
type: Div
|
|
3502
|
+
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
3503
|
+
childCount: 0,
|
|
3504
|
+
className: inputClassName,
|
|
3505
|
+
id: domId,
|
|
3506
|
+
inputType: 'text',
|
|
3507
|
+
name: id,
|
|
3508
|
+
onInput: HandleSettingInput,
|
|
3509
|
+
placeholder: arrayValue(),
|
|
3510
|
+
type: Input
|
|
3511
|
+
}, ...getErrorMessageDom(errorMessage)];
|
|
3512
|
+
};
|
|
3513
|
+
|
|
3469
3514
|
const checkBoxWrapperNode = {
|
|
3470
3515
|
childCount: 2,
|
|
3471
3516
|
className: SettingsItemCheckBox,
|
|
@@ -3478,11 +3523,13 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
3478
3523
|
hasError,
|
|
3479
3524
|
heading,
|
|
3480
3525
|
id,
|
|
3481
|
-
modified
|
|
3526
|
+
modified,
|
|
3527
|
+
value
|
|
3482
3528
|
} = item;
|
|
3483
3529
|
const domId = getInputId(id);
|
|
3484
3530
|
const checkBoxClassName = hasError ? mergeClassNames(CheckBox, InputBoxError) : CheckBox;
|
|
3485
3531
|
const errorChildCount = hasError ? 1 : 0;
|
|
3532
|
+
const isChecked = value === true || value === 'true';
|
|
3486
3533
|
return [{
|
|
3487
3534
|
childCount: 2 + errorChildCount,
|
|
3488
3535
|
className: SettingsItem,
|
|
@@ -3491,6 +3538,7 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
3491
3538
|
role: Group,
|
|
3492
3539
|
type: Div
|
|
3493
3540
|
}, ...getItemHeadingDom(heading), checkBoxWrapperNode, {
|
|
3541
|
+
checked: isChecked,
|
|
3494
3542
|
childCount: 0,
|
|
3495
3543
|
className: checkBoxClassName,
|
|
3496
3544
|
id: domId,
|
|
@@ -3704,6 +3752,8 @@ const getItemUrlVirtualDom = item => {
|
|
|
3704
3752
|
|
|
3705
3753
|
const getItemRender = type => {
|
|
3706
3754
|
switch (type) {
|
|
3755
|
+
case Array$1:
|
|
3756
|
+
return getItemArrayVirtualDom;
|
|
3707
3757
|
case Boolean$1:
|
|
3708
3758
|
return getItemCheckBoxVirtualDom;
|
|
3709
3759
|
case Color:
|
|
@@ -3841,7 +3891,13 @@ const renderItems = (oldState, newState) => {
|
|
|
3841
3891
|
return ['Viewlet.setDom2', newState.id, dom];
|
|
3842
3892
|
};
|
|
3843
3893
|
|
|
3844
|
-
const enabledTypes = [Number$1, String$1, Color];
|
|
3894
|
+
const enabledTypes = [Array$1, Number$1, String$1, Color];
|
|
3895
|
+
const getInputValue = (type, value) => {
|
|
3896
|
+
if (type === Array$1) {
|
|
3897
|
+
return JSON.stringify(value);
|
|
3898
|
+
}
|
|
3899
|
+
return value;
|
|
3900
|
+
};
|
|
3845
3901
|
const renderSettingValues = (oldState, newState) => {
|
|
3846
3902
|
const {
|
|
3847
3903
|
filteredItems,
|
|
@@ -3850,7 +3906,7 @@ const renderSettingValues = (oldState, newState) => {
|
|
|
3850
3906
|
} = newState;
|
|
3851
3907
|
const enabledSettings = filteredItems.filter(item => enabledTypes.includes(item.type));
|
|
3852
3908
|
const inputValues = enabledSettings.map(item => {
|
|
3853
|
-
const value = preferences[item.id] ?? item.value;
|
|
3909
|
+
const value = getInputValue(item.type, preferences[item.id] ?? item.value);
|
|
3854
3910
|
return {
|
|
3855
3911
|
name: item.id,
|
|
3856
3912
|
value
|