aloha-vue 2.74.0 → 2.75.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.
- package/CHANGELOG.md +12 -0
- package/LICENSE +22 -21
- package/dist/aloha-vue.css +105 -105
- package/dist/aloha-vue.css.map +1 -1
- package/dist/aloha-vue.es.js +59267 -64918
- package/dist/aloha-vue.umd.js +338 -211
- package/package.json +27 -34
- package/scss/components/ATable.scss +2 -2
- package/scss/utils/button.scss +362 -362
- package/scss/utils/funktions.scss +162 -162
- package/src/AAccordion/AAccordionItem/AAccordionItem.js +235 -230
- package/src/ACarousel/ACarousel.js +7 -2
- package/src/ADropdown/ADropdown.js +4 -1
- package/src/AFilters/AFilterCenter/AFilterCenter.js +5 -1
- package/src/AFilters/AFilterCenter/AFilterCenterItem/AFilterCenterItem.js +7 -2
- package/src/AFilters/AFiltersHorizontal/AFiltersHorizontal.js +412 -396
- package/src/AFilters/AFiltersHorizontal/AFiltersHorizontalFilter/AFiltersHorizontalFilter.js +102 -99
- package/src/AFilters/AFiltersHorizontal/compositionAPI/FiltersSavedDeleteAPI.js +108 -108
- package/src/AFilters/AFiltersMain/AFiltersMain.js +114 -111
- package/src/AFilters/AFiltersSaveModal/compositionAPI/SaveAPI.js +65 -65
- package/src/ALinkCopy/ALinkCopy.js +98 -95
- package/src/ALinkCopy/compositionAPI/CopyAPI.js +48 -48
- package/src/AList/__tests__/AList.test.js +33 -33
- package/src/AList/compositionAPI/__tests__/TagAPI.test.js +43 -43
- package/src/AMenu/AMenu.js +4 -1
- package/src/AMenu/AMenuBreadcrumbs/AMenuBreadcrumbs.js +240 -237
- package/src/AMenu/AMenuPanelLink/AMenuPanelLink.js +4 -1
- package/src/AMenu/AMenuSearchPanelBreadcrumbs/AMenuSearchPanelBreadcrumbs.js +122 -119
- package/src/AModalWizard/AModalWizard.js +58 -53
- package/src/AModalWizard/compositionAPI/__tests__/ScrollAPI.test.js +46 -46
- package/src/APagination/APaginationPages/APaginationPages.js +15 -4
- package/src/ARate/ARate.js +254 -249
- package/src/ARate/ARateIcon/ADecimalIcon/ADecimalIcon.js +53 -50
- package/src/ARate/ARateIcon/ARateIcon.js +109 -104
- package/src/AResizer/AResizer.js +167 -162
- package/src/ATable/ATableHeaderTh/compositionAPI/SortAPI.js +172 -167
- package/src/ATable/ATableHeaderThAction/ATableHeaderThAction.js +14 -4
- package/src/ATable/ATableHeaderThAction/ATableHeaderThActionItem/ATableHeaderThActionItem.js +191 -184
- package/src/ATable/ATablePreviewDown/ATablePreviewDown.js +72 -69
- package/src/ATable/ATablePreviewRight/ATablePreviewRight.js +265 -258
- package/src/ATable/ATableSortingAdditional/ATableSortingAdditional.js +224 -219
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.AttributesAPI.test.js +39 -39
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.ColumnsAPI.test.js +68 -68
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.DropdownAPI.test.js +45 -45
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.FormAPI.test.js +95 -95
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.ModelAPI.test.js +1 -1
- package/src/ATable/ATableTd/ATableTd.js +4 -1
- package/src/ATable/ATableTdAction/ATableTdAction.js +19 -12
- package/src/ATable/ATableTopPanel/ATableTopPanel.js +11 -3
- package/src/ATable/ATableTr/ATableTr.js +408 -405
- package/src/ATable/__tests__/ATable.HeaderSlot.test.js +102 -97
- package/src/ATable/__tests__/ATable.RowIdsAPI.test.js +66 -66
- package/src/ATableForm/ATableForm.js +88 -85
- package/src/ATableForm/ATableFormCellAction/ATableFormCellAction.js +14 -4
- package/src/ATableForm/ATableFormCellDnd/ATableFormCellDnd.js +196 -187
- package/src/ATableForm/ATableFormRow/compositionAPI/EditAPI.js +104 -104
- package/src/ATableForm/__tests__/ATableForm.DragAndDropAPI.test.js +200 -212
- package/src/ATableForm/__tests__/ATableForm.ListView.test.js +134 -174
- package/src/ATableForm/compositionAPI/IconsAPI.js +24 -21
- package/src/AVerticalScroll/AVerticalScroll.js +182 -177
- package/src/AWizard/AWizard.js +26 -21
- package/src/AWizard/AWizardStep/AWizardStep.js +275 -270
- package/src/AWizard/compositionAPI/__tests__/ChangeStepAPI.test.js +32 -32
- package/src/AWizard/compositionAPI/__tests__/LocalAPI.test.js +55 -55
- package/src/PuxDatepicker/PuxDatepickerCalendarPanel/PuxDatepickerCalendarPanel.js +646 -648
- package/src/PuxDatepicker/panel/PanelDate/PanelDate.js +300 -301
- package/src/PuxDatepicker/panel/PanelMonth/PanelMonth.js +148 -149
- package/src/PuxDatepicker/panel/PanelTime/PanelTime.js +256 -257
- package/src/PuxDatepicker/panel/PanelYear/PanelYear.js +136 -137
- package/src/PuxDatepicker/utils/index.js +100 -100
- package/src/compositionAPI/AHttpAPI.js +593 -593
- package/src/compositionAPI/__tests__/AHttpAPI.test.js +42 -42
- package/src/filters/__tests__/filterBoolean.test.js +38 -38
- package/src/filters/__tests__/filterCapitalize.test.js +38 -38
- package/src/filters/__tests__/filterCurrency.test.js +21 -21
- package/src/filters/__tests__/filterDate.test.js +42 -42
- package/src/filters/__tests__/filterDefaultForEmpty.test.js +24 -24
- package/src/filters/__tests__/filterEmail.test.js +42 -42
- package/src/filters/__tests__/filterEscapeHtml.test.js +45 -45
- package/src/filters/__tests__/filterFileSize.test.js +45 -45
- package/src/filters/__tests__/filterFloat.test.js +74 -74
- package/src/filters/__tests__/filterJson.test.js +74 -74
- package/src/filters/__tests__/filterKeyValue.test.js +50 -50
- package/src/filters/__tests__/filterLimitTo.test.js +39 -39
- package/src/filters/__tests__/filterLink.test.js +41 -41
- package/src/filters/__tests__/filterList.test.js +149 -149
- package/src/filters/__tests__/filterLowerCase.test.js +38 -38
- package/src/filters/__tests__/filterMask.test.js +80 -80
- package/src/filters/__tests__/filterPropertyByValue.test.js +27 -27
- package/src/filters/__tests__/filterSearchHighlight.test.js +129 -129
- package/src/filters/__tests__/filterUpperCase.test.js +38 -38
- package/src/filters/__tests__/filterValueByCondition.test.js +3 -3
- package/src/filters/filterJson.js +39 -39
- package/src/filters/filterValueByCondition.js +2 -2
- package/src/plugins/AAlertPlugin.js +16 -5
- package/src/plugins/AMultiselectOrderedPlugin.js +88 -81
- package/src/plugins/ASelectPlugin.js +12 -10
- package/src/ui/ACheckbox/ACheckbox.js +82 -79
- package/src/ui/ADatepicker/ADatepicker.js +6 -5
- package/src/ui/ADatepicker/compositionAPI/EventsAPI.js +297 -297
- package/src/ui/ADatepicker/utils/index.js +76 -76
- package/src/ui/ADatepickerAlt/ADatepicker.js +912 -912
- package/src/ui/ADatepickerAlt/utils/index.js +98 -98
- package/src/ui/AFieldset/__tests__/AFieldset.ClassColumn.test.js +113 -114
- package/src/ui/AFormElementBtnClear/AFormElementBtnClear.js +4 -1
- package/src/ui/AInputCurrency/AInputCurrency.js +20 -15
- package/src/ui/AInputCurrency/__tests__/AInputCurrency.ModelAPI.test.js +73 -73
- package/src/ui/AInputNumber/AInputNumber.js +17 -12
- package/src/ui/AJson/AJson.js +12 -3
- package/src/ui/AJson/compositionAPI/JsonAPI.js +116 -116
- package/src/ui/ALabel/__tests__/ALabel.IdAPI.test.js +42 -42
- package/src/ui/ALabel/__tests__/ALabel.LabelAPI.test.js +33 -33
- package/src/ui/ARadio/ARadio.js +80 -77
- package/src/ui/ASelect/ASelect.js +390 -383
- package/src/ui/ASelect/ASelectElement/ASelectElement.js +179 -176
- package/src/ui/ASelect/ASelectValueCloseable/ASelectValueCloseable.js +143 -141
- package/src/ui/ASelect/__tests__/SelectedFirstAPI.test.js +101 -101
- package/src/ui/ASelect/__tests__/SelectedVisibleAPI.test.js +98 -98
- package/src/ui/ASlider/compositionAPI/SliderAPI.js +23 -23
- package/src/ui/AValidatedJson/AValidatedJson.js +4 -1
- package/src/ui/AValidatedJson/AValidatedJsonItem/AValidatedJsonItem.js +308 -298
- package/src/ui/compositionApi/UiCollapseAPI.js +68 -63
- package/src/ui/compositionApi/UiInputAutofillAPI.js +41 -41
- package/src/ui/compositionApi/__tests__/UIDataGroupAPI.test.js +106 -106
- package/src/ui/compositionApi/__tests__/UIExcludeRenderAttributesAPI.test.js +39 -39
- package/src/ui/compositionApi/__tests__/UiDataWithKeyIdAndLabelAPI.test.js +128 -128
- package/src/ui/compositionApi/__tests__/UiSearchAPI.test.js +71 -71
- package/src/utils/EventBus.js +51 -8
- package/src/utils/__tests__/EventBus.test.js +138 -0
- package/src/utils/__tests__/utils.aOrderBy.test.js +1 -1
- package/src/utils/__tests__/utils.aSortBy.test.js +1 -1
- package/src/utils/__tests__/utils.getTotalNestedCount.test.js +56 -56
- package/src/utils/__tests__/utils.isArrayOfArrays.test.js +44 -44
- package/src/utils/__tests__/utils.isArrayOfStrings.test.js +36 -36
- package/src/utils/__tests__/utilsArray.aFirst.test.js +1 -1
- package/src/utils/__tests__/utilsArray.aLast.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isArguments.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isArray.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isArrayBuffer.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isBoolean.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isBuffer.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isDate.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isElement.test.js +5 -3
- package/src/utils/__tests__/utilsLang.isError.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isFinite.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isFunction.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isInteger.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isMap.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isNaN.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isNil.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isNull.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isNumber.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isObject.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isObjectLike.test.js +5 -3
- package/src/utils/__tests__/utilsLang.isPlainObject.test.js +3 -2
- package/src/utils/__tests__/utilsLang.isPromise.test.js +5 -2
- package/src/utils/__tests__/utilsLang.isRegExp.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isSet.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isString.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isSymbol.test.js +5 -3
- package/src/utils/__tests__/utilsLang.isUndefined.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isWeakMap.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isWeakSet.test.js +1 -1
- package/src/utils/__tests__/utilsMath.isEven.test.js +43 -43
- package/src/utils/__tests__/utilsMath.isOdd.test.js +43 -43
- package/src/utils/__tests__/utilsUi.isModelForFilterNotEmpty.test.js +65 -65
- package/src/utils/autosize.js +1 -1
|
@@ -31,13 +31,18 @@ import PlaceholderAPI from "../../ATranslation/compositionAPI/PlaceholderAPI";
|
|
|
31
31
|
import VerifyAPI from "./compositionAPI/VerifyAPI";
|
|
32
32
|
import WidthAPI from "./compositionAPI/WidthAPI";
|
|
33
33
|
|
|
34
|
-
import Dash from "aloha-svg/dist/js/bootstrap/Dash";
|
|
35
|
-
import Plus from "aloha-svg/dist/js/bootstrap/Plus";
|
|
36
34
|
import UiMixinProps from "../mixins/UiMixinProps";
|
|
37
35
|
import {
|
|
38
36
|
isNumber,
|
|
39
37
|
} from "lodash-es";
|
|
40
38
|
|
|
39
|
+
const Dash = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-dash" viewBox="0 0 16 16">
|
|
40
|
+
<path d="M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8"/>
|
|
41
|
+
</svg>`;
|
|
42
|
+
const Plus = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16">
|
|
43
|
+
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>
|
|
44
|
+
</svg>`;
|
|
45
|
+
|
|
41
46
|
export default {
|
|
42
47
|
name: "AInputNumber",
|
|
43
48
|
inheritAttrs: false,
|
|
@@ -360,11 +365,11 @@ export default {
|
|
|
360
365
|
a_form_element__parent_invalid: this.isErrors,
|
|
361
366
|
}],
|
|
362
367
|
}, [
|
|
363
|
-
this.label && !this.isLabelFloat && h(ALabel, {
|
|
364
|
-
id: this.htmlIdLocal,
|
|
365
|
-
alwaysTranslate: this.alwaysTranslate,
|
|
366
|
-
extra: this.extra,
|
|
367
|
-
label: this.label,
|
|
368
|
+
this.label && !this.isLabelFloat && h(ALabel, {
|
|
369
|
+
id: this.htmlIdLocal,
|
|
370
|
+
alwaysTranslate: this.alwaysTranslate,
|
|
371
|
+
extra: this.extra,
|
|
372
|
+
label: this.label,
|
|
368
373
|
labelClass: this.labelClass,
|
|
369
374
|
labelScreenReader: this.labelScreenReader,
|
|
370
375
|
required: this.required,
|
|
@@ -393,11 +398,11 @@ export default {
|
|
|
393
398
|
...this.inputWidthStyleValue,
|
|
394
399
|
},
|
|
395
400
|
}, [
|
|
396
|
-
this.label && this.isLabelFloat && h(ALabel, {
|
|
397
|
-
id: this.htmlIdLocal,
|
|
398
|
-
alwaysTranslate: this.alwaysTranslate,
|
|
399
|
-
extra: this.extra,
|
|
400
|
-
label: this.label,
|
|
401
|
+
this.label && this.isLabelFloat && h(ALabel, {
|
|
402
|
+
id: this.htmlIdLocal,
|
|
403
|
+
alwaysTranslate: this.alwaysTranslate,
|
|
404
|
+
extra: this.extra,
|
|
405
|
+
label: this.label,
|
|
401
406
|
labelClass: this.labelClass,
|
|
402
407
|
labelScreenReader: this.labelScreenReader,
|
|
403
408
|
required: this.required,
|
package/src/ui/AJson/AJson.js
CHANGED
|
@@ -21,13 +21,22 @@ import HeightAPI from "./compositionAPI/HeightAPI";
|
|
|
21
21
|
import JsonAPI from "./compositionAPI/JsonAPI";
|
|
22
22
|
import ReadonlyAPI from "./compositionAPI/ReadonlyAPI";
|
|
23
23
|
|
|
24
|
-
import ArrowRepeat from "aloha-svg/dist/js/bootstrap/ArrowRepeat";
|
|
25
|
-
import Braces from "aloha-svg/dist/js/bootstrap/Braces";
|
|
26
|
-
import Trash from "aloha-svg/dist/js/bootstrap/Trash";
|
|
27
24
|
import {
|
|
28
25
|
uniqueId,
|
|
29
26
|
} from "lodash-es";
|
|
30
27
|
|
|
28
|
+
const ArrowRepeat = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-repeat" viewBox="0 0 16 16">
|
|
29
|
+
<path d="M11.534 7h3.932a.25.25 0 0 1 .192.41l-1.966 2.36a.25.25 0 0 1-.384 0l-1.966-2.36a.25.25 0 0 1 .192-.41m-11 2h3.932a.25.25 0 0 0 .192-.41L2.692 6.23a.25.25 0 0 0-.384 0L.342 8.59A.25.25 0 0 0 .534 9"/>
|
|
30
|
+
<path fill-rule="evenodd" d="M8 3c-1.552 0-2.94.707-3.857 1.818a.5.5 0 1 1-.771-.636A6.002 6.002 0 0 1 13.917 7H12.9A5 5 0 0 0 8 3M3.1 9a5.002 5.002 0 0 0 8.757 2.182.5.5 0 1 1 .771.636A6.002 6.002 0 0 1 2.083 9z"/>
|
|
31
|
+
</svg>`;
|
|
32
|
+
const Braces = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-braces" viewBox="0 0 16 16">
|
|
33
|
+
<path d="M2.114 8.063V7.9c1.005-.102 1.497-.615 1.497-1.6V4.503c0-1.094.39-1.538 1.354-1.538h.273V2h-.376C3.25 2 2.49 2.759 2.49 4.352v1.524c0 1.094-.376 1.456-1.49 1.456v1.299c1.114 0 1.49.362 1.49 1.456v1.524c0 1.593.759 2.352 2.372 2.352h.376v-.964h-.273c-.964 0-1.354-.444-1.354-1.538V9.663c0-.984-.492-1.497-1.497-1.6M13.886 7.9v.163c-1.005.103-1.497.616-1.497 1.6v1.798c0 1.094-.39 1.538-1.354 1.538h-.273v.964h.376c1.613 0 2.372-.759 2.372-2.352v-1.524c0-1.094.376-1.456 1.49-1.456V7.332c-1.114 0-1.49-.362-1.49-1.456V4.352C13.51 2.759 12.75 2 11.138 2h-.376v.964h.273c.964 0 1.354.444 1.354 1.538V6.3c0 .984.492 1.497 1.497 1.6"/>
|
|
34
|
+
</svg>`;
|
|
35
|
+
const Trash = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
|
|
36
|
+
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/>
|
|
37
|
+
<path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/>
|
|
38
|
+
</svg>`;
|
|
39
|
+
|
|
31
40
|
export default {
|
|
32
41
|
name: "AJson",
|
|
33
42
|
inheritAttrs: false,
|
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ref,
|
|
3
|
-
toRef,
|
|
4
|
-
} from "vue";
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
cloneDeep,
|
|
8
|
-
} from "lodash-es";
|
|
9
|
-
|
|
10
|
-
export default function JsonAPI(props, {
|
|
11
|
-
changeModel = () => {},
|
|
12
|
-
}) {
|
|
13
|
-
const disabled = toRef(props, "disabled");
|
|
14
|
-
const modelUndefined = toRef(props, "modelUndefined");
|
|
15
|
-
const modelValue = toRef(props, "modelValue");
|
|
16
|
-
|
|
17
|
-
const initialValue = ref(undefined);
|
|
18
|
-
const jsonString = ref("");
|
|
19
|
-
const jsonStringInput = ref("");
|
|
20
|
-
const parseError = ref(undefined);
|
|
21
|
-
|
|
22
|
-
const initInitialValue = () => {
|
|
23
|
-
initialValue.value = cloneDeep(modelValue.value) || "";
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const clearModel = () => {
|
|
27
|
-
if (disabled.value) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
changeModel({
|
|
31
|
-
model: modelUndefined.value,
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const JSONtoString = () => {
|
|
36
|
-
try {
|
|
37
|
-
if (modelValue.value) {
|
|
38
|
-
jsonString.value = JSON.stringify(modelValue.value, undefined, 2);
|
|
39
|
-
} else {
|
|
40
|
-
jsonString.value = "";
|
|
41
|
-
}
|
|
42
|
-
jsonStringInput.value = jsonString.value;
|
|
43
|
-
parseError.value = undefined;
|
|
44
|
-
} catch
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const stringToJSON = $event => {
|
|
49
|
-
if (disabled.value) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!jsonStringInput.value || jsonStringInput.value.length === 0) {
|
|
54
|
-
changeModel({
|
|
55
|
-
$event,
|
|
56
|
-
model: modelUndefined.value,
|
|
57
|
-
});
|
|
58
|
-
} else {
|
|
59
|
-
try {
|
|
60
|
-
const MODEL = JSON.parse(jsonStringInput.value);
|
|
61
|
-
changeModel({
|
|
62
|
-
$event,
|
|
63
|
-
model: MODEL,
|
|
64
|
-
});
|
|
65
|
-
jsonString.value = JSON.stringify(MODEL, undefined, 2);
|
|
66
|
-
parseError.value = null;
|
|
67
|
-
} catch
|
|
68
|
-
parseError.value = e.toString();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const onInput = $event => {
|
|
74
|
-
if (disabled.value) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
jsonStringInput.value = $event.target.value;
|
|
79
|
-
stringToJSON();
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const formatJson = () => {
|
|
83
|
-
try {
|
|
84
|
-
jsonStringInput.value = JSON.stringify(JSON.parse(jsonStringInput.value), undefined, 2);
|
|
85
|
-
} catch
|
|
86
|
-
parseError.value = e.toString();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const resetModel = () => {
|
|
91
|
-
if (disabled.value) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
changeModel({
|
|
96
|
-
model: initialValue.value,
|
|
97
|
-
});
|
|
98
|
-
setTimeout(() => {
|
|
99
|
-
JSONtoString();
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
clearModel,
|
|
105
|
-
formatJson,
|
|
106
|
-
initialValue,
|
|
107
|
-
initInitialValue,
|
|
108
|
-
jsonString,
|
|
109
|
-
jsonStringInput,
|
|
110
|
-
JSONtoString,
|
|
111
|
-
onInput,
|
|
112
|
-
parseError,
|
|
113
|
-
resetModel,
|
|
114
|
-
stringToJSON,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
toRef,
|
|
4
|
+
} from "vue";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
cloneDeep,
|
|
8
|
+
} from "lodash-es";
|
|
9
|
+
|
|
10
|
+
export default function JsonAPI(props, {
|
|
11
|
+
changeModel = () => {},
|
|
12
|
+
}) {
|
|
13
|
+
const disabled = toRef(props, "disabled");
|
|
14
|
+
const modelUndefined = toRef(props, "modelUndefined");
|
|
15
|
+
const modelValue = toRef(props, "modelValue");
|
|
16
|
+
|
|
17
|
+
const initialValue = ref(undefined);
|
|
18
|
+
const jsonString = ref("");
|
|
19
|
+
const jsonStringInput = ref("");
|
|
20
|
+
const parseError = ref(undefined);
|
|
21
|
+
|
|
22
|
+
const initInitialValue = () => {
|
|
23
|
+
initialValue.value = cloneDeep(modelValue.value) || "";
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const clearModel = () => {
|
|
27
|
+
if (disabled.value) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
changeModel({
|
|
31
|
+
model: modelUndefined.value,
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const JSONtoString = () => {
|
|
36
|
+
try {
|
|
37
|
+
if (modelValue.value) {
|
|
38
|
+
jsonString.value = JSON.stringify(modelValue.value, undefined, 2);
|
|
39
|
+
} else {
|
|
40
|
+
jsonString.value = "";
|
|
41
|
+
}
|
|
42
|
+
jsonStringInput.value = jsonString.value;
|
|
43
|
+
parseError.value = undefined;
|
|
44
|
+
} catch(e) {
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const stringToJSON = $event => {
|
|
49
|
+
if (disabled.value) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!jsonStringInput.value || jsonStringInput.value.length === 0) {
|
|
54
|
+
changeModel({
|
|
55
|
+
$event,
|
|
56
|
+
model: modelUndefined.value,
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
try {
|
|
60
|
+
const MODEL = JSON.parse(jsonStringInput.value);
|
|
61
|
+
changeModel({
|
|
62
|
+
$event,
|
|
63
|
+
model: MODEL,
|
|
64
|
+
});
|
|
65
|
+
jsonString.value = JSON.stringify(MODEL, undefined, 2);
|
|
66
|
+
parseError.value = null;
|
|
67
|
+
} catch(e) {
|
|
68
|
+
parseError.value = e.toString();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const onInput = $event => {
|
|
74
|
+
if (disabled.value) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
jsonStringInput.value = $event.target.value;
|
|
79
|
+
stringToJSON();
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const formatJson = () => {
|
|
83
|
+
try {
|
|
84
|
+
jsonStringInput.value = JSON.stringify(JSON.parse(jsonStringInput.value), undefined, 2);
|
|
85
|
+
} catch(e) {
|
|
86
|
+
parseError.value = e.toString();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const resetModel = () => {
|
|
91
|
+
if (disabled.value) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
changeModel({
|
|
96
|
+
model: initialValue.value,
|
|
97
|
+
});
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
JSONtoString();
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
clearModel,
|
|
105
|
+
formatJson,
|
|
106
|
+
initialValue,
|
|
107
|
+
initInitialValue,
|
|
108
|
+
jsonString,
|
|
109
|
+
jsonStringInput,
|
|
110
|
+
JSONtoString,
|
|
111
|
+
onInput,
|
|
112
|
+
parseError,
|
|
113
|
+
resetModel,
|
|
114
|
+
stringToJSON,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computed,
|
|
3
|
-
} from "vue";
|
|
4
|
-
import {
|
|
5
|
-
describe,
|
|
6
|
-
expect,
|
|
7
|
-
it,
|
|
8
|
-
} from "
|
|
9
|
-
|
|
10
|
-
import IdAPI from "../compositionAPI/IdAPI";
|
|
11
|
-
|
|
12
|
-
describe("ALabel IdAPI", () => {
|
|
13
|
-
it("'forLabelLocal' and 'idLabelLocal' should return correct values when 'hideForLocal' and 'hideIdLocal' are false", () => {
|
|
14
|
-
const props = { id: "user", idSuffix: "_123" };
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
forLabelLocal,
|
|
18
|
-
idLabelLocal,
|
|
19
|
-
} = IdAPI(props, {
|
|
20
|
-
hideForLocal: computed(() => false),
|
|
21
|
-
hideIdLocal: computed(() => false),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
expect(idLabelLocal.value).toBe("user_123");
|
|
25
|
-
expect(forLabelLocal.value).toBe("user");
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("'forLabelLocal' and 'idLabelLocal' should be undefined when 'hideForLocal' and 'hideIdLocal' are true", () => {
|
|
29
|
-
const props = { id: "user", idSuffix: "_123" };
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
forLabelLocal,
|
|
33
|
-
idLabelLocal,
|
|
34
|
-
} = IdAPI(props, {
|
|
35
|
-
hideForLocal: computed(() => true),
|
|
36
|
-
hideIdLocal: computed(() => true),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
expect(idLabelLocal.value).toBeUndefined();
|
|
40
|
-
expect(forLabelLocal.value).toBeUndefined();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
} from "vue";
|
|
4
|
+
import {
|
|
5
|
+
describe,
|
|
6
|
+
expect,
|
|
7
|
+
it,
|
|
8
|
+
} from "vitest";
|
|
9
|
+
|
|
10
|
+
import IdAPI from "../compositionAPI/IdAPI";
|
|
11
|
+
|
|
12
|
+
describe("ALabel IdAPI", () => {
|
|
13
|
+
it("'forLabelLocal' and 'idLabelLocal' should return correct values when 'hideForLocal' and 'hideIdLocal' are false", () => {
|
|
14
|
+
const props = { id: "user", idSuffix: "_123" };
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
forLabelLocal,
|
|
18
|
+
idLabelLocal,
|
|
19
|
+
} = IdAPI(props, {
|
|
20
|
+
hideForLocal: computed(() => false),
|
|
21
|
+
hideIdLocal: computed(() => false),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
expect(idLabelLocal.value).toBe("user_123");
|
|
25
|
+
expect(forLabelLocal.value).toBe("user");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("'forLabelLocal' and 'idLabelLocal' should be undefined when 'hideForLocal' and 'hideIdLocal' are true", () => {
|
|
29
|
+
const props = { id: "user", idSuffix: "_123" };
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
forLabelLocal,
|
|
33
|
+
idLabelLocal,
|
|
34
|
+
} = IdAPI(props, {
|
|
35
|
+
hideForLocal: computed(() => true),
|
|
36
|
+
hideIdLocal: computed(() => true),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
expect(idLabelLocal.value).toBeUndefined();
|
|
40
|
+
expect(forLabelLocal.value).toBeUndefined();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
} from "
|
|
6
|
-
|
|
7
|
-
import LabelAPI from "../compositionAPI/LabelAPI";
|
|
8
|
-
|
|
9
|
-
describe("ALabel LabelAPI", () => {
|
|
10
|
-
it("textAfterLabel should be empty when 'required' is false", () => {
|
|
11
|
-
const {
|
|
12
|
-
textAfterLabel,
|
|
13
|
-
} = LabelAPI({ required: false, label: "Aloha" });
|
|
14
|
-
|
|
15
|
-
expect(textAfterLabel.value).toBe("");
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("textAfterLabel should be empty when 'label' is empty", () => {
|
|
19
|
-
const {
|
|
20
|
-
textAfterLabel,
|
|
21
|
-
} = LabelAPI({ required: false, label: "" });
|
|
22
|
-
|
|
23
|
-
expect(textAfterLabel.value).toBe("");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("textAfterLabel should be asterisk when 'required' is true", () => {
|
|
27
|
-
const {
|
|
28
|
-
textAfterLabel,
|
|
29
|
-
} = LabelAPI({ required: true, label: "Aloha" });
|
|
30
|
-
|
|
31
|
-
expect(textAfterLabel.value).toBe("*");
|
|
32
|
-
});
|
|
33
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
expect,
|
|
4
|
+
it,
|
|
5
|
+
} from "vitest";
|
|
6
|
+
|
|
7
|
+
import LabelAPI from "../compositionAPI/LabelAPI";
|
|
8
|
+
|
|
9
|
+
describe("ALabel LabelAPI", () => {
|
|
10
|
+
it("textAfterLabel should be empty when 'required' is false", () => {
|
|
11
|
+
const {
|
|
12
|
+
textAfterLabel,
|
|
13
|
+
} = LabelAPI({ required: false, label: "Aloha" });
|
|
14
|
+
|
|
15
|
+
expect(textAfterLabel.value).toBe("");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("textAfterLabel should be empty when 'label' is empty", () => {
|
|
19
|
+
const {
|
|
20
|
+
textAfterLabel,
|
|
21
|
+
} = LabelAPI({ required: false, label: "" });
|
|
22
|
+
|
|
23
|
+
expect(textAfterLabel.value).toBe("");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("textAfterLabel should be asterisk when 'required' is true", () => {
|
|
27
|
+
const {
|
|
28
|
+
textAfterLabel,
|
|
29
|
+
} = LabelAPI({ required: true, label: "Aloha" });
|
|
30
|
+
|
|
31
|
+
expect(textAfterLabel.value).toBe("*");
|
|
32
|
+
});
|
|
33
|
+
});
|