@ramathibodi/nuxt-commons 0.1.73 → 4.0.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.
- package/README.md +81 -55
- package/dist/module.json +4 -4
- package/dist/module.mjs +5 -4
- package/dist/runtime/bridges/authentication.d.ts +21 -0
- package/dist/runtime/bridges/authentication.js +20 -0
- package/dist/runtime/bridges/graphql.d.ts +17 -0
- package/dist/runtime/bridges/graphql.js +45 -0
- package/dist/runtime/components/Alert.d.vue.ts +3 -0
- package/dist/runtime/components/Alert.vue +17 -22
- package/dist/runtime/components/Alert.vue.d.ts +3 -0
- package/dist/runtime/components/BarcodeReader.d.vue.ts +9 -0
- package/dist/runtime/components/BarcodeReader.vue +56 -73
- package/dist/runtime/components/BarcodeReader.vue.d.ts +9 -0
- package/dist/runtime/components/ExportCSV.d.vue.ts +55 -0
- package/dist/runtime/components/ExportCSV.vue +39 -68
- package/dist/runtime/components/ExportCSV.vue.d.ts +55 -0
- package/dist/runtime/components/FileBtn.d.vue.ts +53 -0
- package/dist/runtime/components/FileBtn.vue +23 -38
- package/dist/runtime/components/FileBtn.vue.d.ts +53 -0
- package/dist/runtime/components/ImportCSV.d.vue.ts +52 -0
- package/dist/runtime/components/ImportCSV.vue +60 -99
- package/dist/runtime/components/ImportCSV.vue.d.ts +52 -0
- package/dist/runtime/components/MrzReader.d.vue.ts +19 -0
- package/dist/runtime/components/MrzReader.vue +128 -0
- package/dist/runtime/components/MrzReader.vue.d.ts +19 -0
- package/dist/runtime/components/SplitterPanel.d.vue.ts +15 -0
- package/dist/runtime/components/SplitterPanel.vue +18 -27
- package/dist/runtime/components/SplitterPanel.vue.d.ts +15 -0
- package/dist/runtime/components/TabsGroup.d.vue.ts +19 -0
- package/dist/runtime/components/TabsGroup.vue +8 -12
- package/dist/runtime/components/TabsGroup.vue.d.ts +19 -0
- package/dist/runtime/components/TextBarcode.d.vue.ts +12 -0
- package/dist/runtime/components/TextBarcode.vue +22 -33
- package/dist/runtime/components/TextBarcode.vue.d.ts +12 -0
- package/dist/runtime/components/device/IdCardButton.d.vue.ts +57 -0
- package/dist/runtime/components/device/IdCardButton.vue +30 -55
- package/dist/runtime/components/device/IdCardButton.vue.d.ts +57 -0
- package/dist/runtime/components/device/IdCardWebSocket.d.vue.ts +55 -0
- package/dist/runtime/components/device/IdCardWebSocket.vue +104 -153
- package/dist/runtime/components/device/IdCardWebSocket.vue.d.ts +55 -0
- package/dist/runtime/components/device/Scanner.d.vue.ts +66 -0
- package/dist/runtime/components/device/Scanner.vue +97 -166
- package/dist/runtime/components/device/Scanner.vue.d.ts +66 -0
- package/dist/runtime/components/dialog/Confirm.d.vue.ts +37 -0
- package/dist/runtime/components/dialog/Confirm.vue +30 -47
- package/dist/runtime/components/dialog/Confirm.vue.d.ts +37 -0
- package/dist/runtime/components/dialog/Host.d.vue.ts +9 -0
- package/dist/runtime/components/dialog/Host.vue +34 -53
- package/dist/runtime/components/dialog/Host.vue.d.ts +9 -0
- package/dist/runtime/components/dialog/Index.d.vue.ts +24 -0
- package/dist/runtime/components/dialog/Index.vue +20 -28
- package/dist/runtime/components/dialog/Index.vue.d.ts +24 -0
- package/dist/runtime/components/dialog/Loading.d.vue.ts +21 -0
- package/dist/runtime/components/dialog/Loading.vue +12 -17
- package/dist/runtime/components/dialog/Loading.vue.d.ts +21 -0
- package/dist/runtime/components/dialog/default/Confirm.d.vue.ts +40 -0
- package/dist/runtime/components/dialog/default/Confirm.vue +29 -50
- package/dist/runtime/components/dialog/default/Confirm.vue.d.ts +40 -0
- package/dist/runtime/components/dialog/default/Loading.d.vue.ts +23 -0
- package/dist/runtime/components/dialog/default/Loading.vue +12 -17
- package/dist/runtime/components/dialog/default/Loading.vue.d.ts +23 -0
- package/dist/runtime/components/dialog/default/Notify.d.vue.ts +23 -0
- package/dist/runtime/components/dialog/default/Notify.vue +19 -36
- package/dist/runtime/components/dialog/default/Notify.vue.d.ts +23 -0
- package/dist/runtime/components/dialog/default/Printing.d.vue.ts +21 -0
- package/dist/runtime/components/dialog/default/Printing.vue +13 -17
- package/dist/runtime/components/dialog/default/Printing.vue.d.ts +21 -0
- package/dist/runtime/components/dialog/default/VerifyUser.d.vue.ts +29 -0
- package/dist/runtime/components/dialog/default/VerifyUser.vue +44 -70
- package/dist/runtime/components/dialog/default/VerifyUser.vue.d.ts +29 -0
- package/dist/runtime/components/document/Form.d.vue.ts +9 -0
- package/dist/runtime/components/document/Form.vue +27 -34
- package/dist/runtime/components/document/Form.vue.d.ts +9 -0
- package/dist/runtime/components/document/TemplateBuilder.d.vue.ts +24 -0
- package/dist/runtime/components/document/TemplateBuilder.vue +154 -182
- package/dist/runtime/components/document/TemplateBuilder.vue.d.ts +24 -0
- package/dist/runtime/components/form/ActionPad.d.vue.ts +114 -0
- package/dist/runtime/components/form/ActionPad.vue +48 -73
- package/dist/runtime/components/form/ActionPad.vue.d.ts +114 -0
- package/dist/runtime/components/form/Birthdate.d.vue.ts +38 -0
- package/dist/runtime/components/form/Birthdate.vue +44 -64
- package/dist/runtime/components/form/Birthdate.vue.d.ts +38 -0
- package/dist/runtime/components/form/CheckboxGroup.d.vue.ts +41 -0
- package/dist/runtime/components/form/CheckboxGroup.vue +34 -52
- package/dist/runtime/components/form/CheckboxGroup.vue.d.ts +41 -0
- package/dist/runtime/components/form/CodeEditor.d.vue.ts +25 -0
- package/dist/runtime/components/form/CodeEditor.vue +18 -28
- package/dist/runtime/components/form/CodeEditor.vue.d.ts +25 -0
- package/dist/runtime/components/form/Date.d.vue.ts +86 -0
- package/dist/runtime/components/form/Date.vue +109 -150
- package/dist/runtime/components/form/Date.vue.d.ts +86 -0
- package/dist/runtime/components/form/DateTime.d.vue.ts +36 -0
- package/dist/runtime/components/form/DateTime.vue +94 -131
- package/dist/runtime/components/form/DateTime.vue.d.ts +36 -0
- package/dist/runtime/components/form/Dialog.d.vue.ts +69 -0
- package/dist/runtime/components/form/Dialog.vue +60 -84
- package/dist/runtime/components/form/Dialog.vue.d.ts +69 -0
- package/dist/runtime/components/form/EditPad.d.vue.ts +113 -0
- package/dist/runtime/components/form/EditPad.vue +49 -73
- package/dist/runtime/components/form/EditPad.vue.d.ts +113 -0
- package/dist/runtime/components/form/File.d.vue.ts +65 -0
- package/dist/runtime/components/form/File.vue +112 -174
- package/dist/runtime/components/form/File.vue.d.ts +65 -0
- package/dist/runtime/components/form/Hidden.d.vue.ts +12 -0
- package/dist/runtime/components/form/Hidden.vue +17 -22
- package/dist/runtime/components/form/Hidden.vue.d.ts +12 -0
- package/dist/runtime/components/form/Iterator.d.vue.ts +279 -0
- package/dist/runtime/components/form/Iterator.vue +162 -240
- package/dist/runtime/components/form/Iterator.vue.d.ts +279 -0
- package/dist/runtime/components/form/Login.d.vue.ts +32 -0
- package/dist/runtime/components/form/Login.vue +23 -43
- package/dist/runtime/components/form/Login.vue.d.ts +32 -0
- package/dist/runtime/components/form/Pad.d.vue.ts +674 -0
- package/dist/runtime/components/form/Pad.vue +166 -253
- package/dist/runtime/components/form/Pad.vue.d.ts +674 -0
- package/dist/runtime/components/form/SignPad.d.vue.ts +62 -0
- package/dist/runtime/components/form/SignPad.vue +80 -118
- package/dist/runtime/components/form/SignPad.vue.d.ts +62 -0
- package/dist/runtime/components/form/System.d.vue.ts +34 -0
- package/dist/runtime/components/form/System.vue +18 -24
- package/dist/runtime/components/form/System.vue.d.ts +34 -0
- package/dist/runtime/components/form/Table.d.vue.ts +221 -0
- package/dist/runtime/components/form/Table.vue +123 -170
- package/dist/runtime/components/form/Table.vue.d.ts +221 -0
- package/dist/runtime/components/form/TableData.d.vue.ts +102 -0
- package/dist/runtime/components/form/TableData.vue +109 -127
- package/dist/runtime/components/form/TableData.vue.d.ts +102 -0
- package/dist/runtime/components/form/Time.d.vue.ts +49 -0
- package/dist/runtime/components/form/Time.vue +64 -87
- package/dist/runtime/components/form/Time.vue.d.ts +49 -0
- package/dist/runtime/components/form/images/Capture.d.vue.ts +96 -0
- package/dist/runtime/components/form/images/Capture.vue +104 -139
- package/dist/runtime/components/form/images/Capture.vue.d.ts +96 -0
- package/dist/runtime/components/form/images/Edit.d.vue.ts +29 -0
- package/dist/runtime/components/form/images/Edit.vue +57 -69
- package/dist/runtime/components/form/images/Edit.vue.d.ts +29 -0
- package/dist/runtime/components/form/images/Field.d.vue.ts +27 -0
- package/dist/runtime/components/form/images/Field.vue +136 -194
- package/dist/runtime/components/form/images/Field.vue.d.ts +27 -0
- package/dist/runtime/components/form/images/Pad.d.vue.ts +13 -0
- package/dist/runtime/components/form/images/Pad.vue +23 -28
- package/dist/runtime/components/form/images/Pad.vue.d.ts +13 -0
- package/dist/runtime/components/label/Date.d.vue.ts +13 -0
- package/dist/runtime/components/label/Date.vue +13 -21
- package/dist/runtime/components/label/Date.vue.d.ts +13 -0
- package/dist/runtime/components/label/DateAgo.d.vue.ts +20 -0
- package/dist/runtime/components/label/DateAgo.vue +43 -67
- package/dist/runtime/components/label/DateAgo.vue.d.ts +20 -0
- package/dist/runtime/components/label/DateCount.d.vue.ts +22 -0
- package/dist/runtime/components/label/DateCount.vue +58 -97
- package/dist/runtime/components/label/DateCount.vue.d.ts +22 -0
- package/dist/runtime/components/label/Field.d.vue.ts +38 -0
- package/dist/runtime/components/label/Field.vue +18 -32
- package/dist/runtime/components/label/Field.vue.d.ts +38 -0
- package/dist/runtime/components/label/FormatMoney.d.vue.ts +12 -0
- package/dist/runtime/components/label/FormatMoney.vue +12 -20
- package/dist/runtime/components/label/FormatMoney.vue.d.ts +12 -0
- package/dist/runtime/components/label/Mask.d.vue.ts +10 -0
- package/dist/runtime/components/label/Mask.vue +21 -30
- package/dist/runtime/components/label/Mask.vue.d.ts +10 -0
- package/dist/runtime/components/label/Object.d.vue.ts +8 -0
- package/dist/runtime/components/label/Object.vue +10 -12
- package/dist/runtime/components/label/Object.vue.d.ts +8 -0
- package/dist/runtime/components/master/Autocomplete.d.vue.ts +70 -0
- package/dist/runtime/components/master/Autocomplete.vue +25 -26
- package/dist/runtime/components/master/Autocomplete.vue.d.ts +70 -0
- package/dist/runtime/components/master/Combobox.d.vue.ts +70 -0
- package/dist/runtime/components/master/Combobox.vue +26 -27
- package/dist/runtime/components/master/Combobox.vue.d.ts +70 -0
- package/dist/runtime/components/master/RadioGroup.d.vue.ts +51 -0
- package/dist/runtime/components/master/RadioGroup.vue +44 -47
- package/dist/runtime/components/master/RadioGroup.vue.d.ts +51 -0
- package/dist/runtime/components/master/Select.d.vue.ts +68 -0
- package/dist/runtime/components/master/Select.vue +25 -26
- package/dist/runtime/components/master/Select.vue.d.ts +68 -0
- package/dist/runtime/components/master/label.d.vue.ts +24 -0
- package/dist/runtime/components/master/label.vue +22 -34
- package/dist/runtime/components/master/label.vue.d.ts +24 -0
- package/dist/runtime/components/model/Autocomplete.d.vue.ts +82 -0
- package/dist/runtime/components/model/Autocomplete.vue +50 -37
- package/dist/runtime/components/model/Autocomplete.vue.d.ts +82 -0
- package/dist/runtime/components/model/Combobox.d.vue.ts +82 -0
- package/dist/runtime/components/model/Combobox.vue +51 -37
- package/dist/runtime/components/model/Combobox.vue.d.ts +82 -0
- package/dist/runtime/components/model/Pad.d.vue.ts +72 -0
- package/dist/runtime/components/model/Pad.vue +50 -53
- package/dist/runtime/components/model/Pad.vue.d.ts +72 -0
- package/dist/runtime/components/model/Select.d.vue.ts +72 -0
- package/dist/runtime/components/model/Select.vue +42 -32
- package/dist/runtime/components/model/Select.vue.d.ts +72 -0
- package/dist/runtime/components/model/Table.d.vue.ts +272 -0
- package/dist/runtime/components/model/Table.vue +121 -133
- package/dist/runtime/components/model/Table.vue.d.ts +272 -0
- package/dist/runtime/components/model/iterator.d.vue.ts +321 -0
- package/dist/runtime/components/model/iterator.vue +148 -175
- package/dist/runtime/components/model/iterator.vue.d.ts +321 -0
- package/dist/runtime/components/model/label.d.vue.ts +26 -0
- package/dist/runtime/components/model/label.vue +25 -35
- package/dist/runtime/components/model/label.vue.d.ts +26 -0
- package/dist/runtime/components/pdf/Print.d.vue.ts +17 -0
- package/dist/runtime/components/pdf/Print.vue +27 -38
- package/dist/runtime/components/pdf/Print.vue.d.ts +17 -0
- package/dist/runtime/components/pdf/View.d.vue.ts +52 -0
- package/dist/runtime/components/pdf/View.vue +58 -83
- package/dist/runtime/components/pdf/View.vue.d.ts +52 -0
- package/dist/runtime/composables/alert.d.ts +4 -0
- package/dist/runtime/composables/api.d.ts +4 -0
- package/dist/runtime/composables/api.js +4 -2
- package/dist/runtime/composables/assetFile.js +4 -2
- package/dist/runtime/composables/dialog.d.ts +1 -1
- package/dist/runtime/composables/document/template.js +3 -3
- package/dist/runtime/composables/document/templateFormHidden.d.ts +4 -0
- package/dist/runtime/composables/document/templateFormTable.js +1 -0
- package/dist/runtime/composables/graphql.d.ts +2 -2
- package/dist/runtime/composables/graphql.js +5 -5
- package/dist/runtime/composables/graphqlModel.d.ts +6 -6
- package/dist/runtime/composables/graphqlModelItem.d.ts +4 -4
- package/dist/runtime/composables/graphqlModelOperation.d.ts +6 -6
- package/dist/runtime/composables/graphqlModelOperation.js +2 -1
- package/dist/runtime/composables/graphqlOperation.js +5 -1
- package/dist/runtime/composables/hostAgentWs.d.ts +1 -1
- package/dist/runtime/composables/localStorageModel.d.ts +4 -0
- package/dist/runtime/composables/lookupList.d.ts +4 -0
- package/dist/runtime/composables/lookupListMaster.js +3 -3
- package/dist/runtime/composables/menu.d.ts +4 -0
- package/dist/runtime/composables/menu.js +2 -2
- package/dist/runtime/composables/useMrzReader.d.ts +48 -0
- package/dist/runtime/composables/useMrzReader.js +423 -0
- package/dist/runtime/composables/useTesseract.d.ts +16 -0
- package/dist/runtime/composables/useTesseract.js +45 -0
- package/dist/runtime/composables/userPermission.d.ts +1 -1
- package/dist/runtime/composables/utils/fuzzy.d.ts +2 -1
- package/dist/runtime/labs/Calendar.d.vue.ts +35 -0
- package/dist/runtime/labs/Calendar.vue +47 -75
- package/dist/runtime/labs/Calendar.vue.d.ts +35 -0
- package/dist/runtime/labs/form/EditMobile.d.vue.ts +12 -0
- package/dist/runtime/labs/form/EditMobile.vue +19 -36
- package/dist/runtime/labs/form/EditMobile.vue.d.ts +12 -0
- package/dist/runtime/labs/form/TextFieldMask.d.vue.ts +21 -0
- package/dist/runtime/labs/form/TextFieldMask.vue +19 -25
- package/dist/runtime/labs/form/TextFieldMask.vue.d.ts +21 -0
- package/dist/runtime/plugins/dialogManager.js +2 -2
- package/dist/runtime/plugins/permission.js +3 -3
- package/dist/runtime/types/bridge.d.ts +14 -0
- package/dist/runtime/utils/asset.d.ts +2 -0
- package/dist/runtime/utils/asset.js +49 -0
- package/dist/runtime/utils/datetime.js +1 -1
- package/dist/types.d.mts +2 -6
- package/package.json +79 -57
- package/scripts/ci-release.mjs +125 -0
- package/scripts/enrich-vue-docs-from-ai.mjs +197 -0
- package/scripts/generate-ai-summary.mjs +321 -0
- package/scripts/generate-composables-md.mjs +129 -0
- package/scripts/release-version.mjs +68 -0
- package/scripts/release.mjs +49 -0
- package/templates/public/tesseract/mrz.traineddata.gz +0 -0
- package/templates/public/tesseract/ocrb.traineddata.gz +0 -0
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -8
- package/dist/types.d.ts +0 -7
|
@@ -1,80 +1,51 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import { ref } from
|
|
3
|
-
import * as XLSX from
|
|
4
|
-
import { VBtn } from
|
|
5
|
-
import { useAlert } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const props = withDefaults(defineProps<ExportButtonProps>(), {
|
|
16
|
-
fileName: 'download',
|
|
17
|
-
sheetName: 'Sheet1',
|
|
18
|
-
stringFields: ()=>[],
|
|
19
|
-
tooltip: ()=>({text: 'Export', location: 'bottom'}),
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const alert = useAlert()
|
|
23
|
-
const loading = ref(false)
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Triggers file export
|
|
27
|
-
*/
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import * as XLSX from "xlsx";
|
|
4
|
+
import { VBtn } from "vuetify/components/VBtn";
|
|
5
|
+
import { useAlert } from "../composables/alert";
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
fileName: { type: String, required: false, default: "download" },
|
|
8
|
+
sheetName: { type: String, required: false, default: "Sheet1" },
|
|
9
|
+
modelValue: { type: Array, required: false },
|
|
10
|
+
stringFields: { type: Array, required: false, default: () => [] },
|
|
11
|
+
tooltip: { type: null, required: false, default: () => ({ text: "Export", location: "bottom" }) }
|
|
12
|
+
});
|
|
13
|
+
const alert = useAlert();
|
|
14
|
+
const loading = ref(false);
|
|
28
15
|
function exportFile() {
|
|
29
16
|
if (props.modelValue && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
|
|
30
|
-
loading.value = true
|
|
31
|
-
|
|
17
|
+
loading.value = true;
|
|
32
18
|
try {
|
|
33
|
-
const workbook = XLSX.utils.book_new()
|
|
34
|
-
const worksheet = XLSX.utils.json_to_sheet(flattenNestedFields(props.modelValue))
|
|
35
|
-
const fileName = `${props.fileName}.xlsx
|
|
36
|
-
|
|
37
|
-
XLSX.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
alert?.addAlert({ message: `Export failed: ${error.message}`, alertType: 'error' })
|
|
19
|
+
const workbook = XLSX.utils.book_new();
|
|
20
|
+
const worksheet = XLSX.utils.json_to_sheet(flattenNestedFields(props.modelValue));
|
|
21
|
+
const fileName = `${props.fileName}.xlsx`;
|
|
22
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, props.sheetName);
|
|
23
|
+
XLSX.writeFile(workbook, fileName);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
alert?.addAlert({ message: `Export failed: ${error.message}`, alertType: "error" });
|
|
41
26
|
} finally {
|
|
42
|
-
loading.value = false
|
|
27
|
+
loading.value = false;
|
|
43
28
|
}
|
|
44
29
|
} else {
|
|
45
|
-
alert?.addAlert({ message:
|
|
30
|
+
alert?.addAlert({ message: "Invalid or no data to export", alertType: "error" });
|
|
46
31
|
}
|
|
47
32
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*/
|
|
53
|
-
function flattenNestedFields(items: any[]) {
|
|
54
|
-
return items.map((item: any) => {
|
|
55
|
-
return flattenObject(item)
|
|
56
|
-
})
|
|
33
|
+
function flattenNestedFields(items) {
|
|
34
|
+
return items.map((item) => {
|
|
35
|
+
return flattenObject(item);
|
|
36
|
+
});
|
|
57
37
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
function flattenObject(obj: any, parentKey = '', separator = '.') {
|
|
66
|
-
return Object.keys(obj).reduce((acc: any, key: string) => {
|
|
67
|
-
const newKey = parentKey ? `${parentKey}${separator}${key}` : key
|
|
68
|
-
const value = obj[key]
|
|
69
|
-
|
|
70
|
-
if (value && typeof value === 'object' && !Array.isArray(value) && !props.stringFields.includes(newKey)) {
|
|
71
|
-
Object.assign(acc, flattenObject(value, newKey, separator))
|
|
38
|
+
function flattenObject(obj, parentKey = "", separator = ".") {
|
|
39
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
40
|
+
const newKey = parentKey ? `${parentKey}${separator}${key}` : key;
|
|
41
|
+
const value = obj[key];
|
|
42
|
+
if (value && typeof value === "object" && !Array.isArray(value) && !props.stringFields.includes(newKey)) {
|
|
43
|
+
Object.assign(acc, flattenObject(value, newKey, separator));
|
|
72
44
|
} else {
|
|
73
|
-
acc[newKey] = typeof value ===
|
|
45
|
+
acc[newKey] = typeof value === "object" ? JSON.stringify(value) : value;
|
|
74
46
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, {})
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
78
49
|
}
|
|
79
50
|
</script>
|
|
80
51
|
|
|
@@ -89,13 +60,13 @@ function flattenObject(obj: any, parentKey = '', separator = '.') {
|
|
|
89
60
|
v-tooltip="props.tooltip"
|
|
90
61
|
>
|
|
91
62
|
<template
|
|
92
|
-
v-for="(_, name, index) in
|
|
63
|
+
v-for="(_, name, index) in $slots"
|
|
93
64
|
:key="index"
|
|
94
65
|
#[name]="slotData"
|
|
95
66
|
>
|
|
96
67
|
<slot
|
|
97
68
|
:name="name"
|
|
98
|
-
v-bind="
|
|
69
|
+
v-bind="slotData || {}"
|
|
99
70
|
/>
|
|
100
71
|
</template>
|
|
101
72
|
</VBtn>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VBtn } from 'vuetify/components/VBtn';
|
|
2
|
+
interface ExportButtonProps extends /* @vue-ignore */ InstanceType<typeof VBtn['$props']> {
|
|
3
|
+
fileName?: string;
|
|
4
|
+
sheetName?: string;
|
|
5
|
+
modelValue?: object[];
|
|
6
|
+
stringFields?: Array<string>;
|
|
7
|
+
tooltip?: string | Record<string, any> | undefined;
|
|
8
|
+
}
|
|
9
|
+
declare var __VLS_12: never, __VLS_13: {};
|
|
10
|
+
type __VLS_Slots = {} & {
|
|
11
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ExportButtonProps>, {
|
|
14
|
+
fileName: string;
|
|
15
|
+
sheetName: string;
|
|
16
|
+
stringFields: () => never[];
|
|
17
|
+
tooltip: () => {
|
|
18
|
+
text: string;
|
|
19
|
+
location: string;
|
|
20
|
+
};
|
|
21
|
+
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ExportButtonProps>, {
|
|
22
|
+
fileName: string;
|
|
23
|
+
sheetName: string;
|
|
24
|
+
stringFields: () => never[];
|
|
25
|
+
tooltip: () => {
|
|
26
|
+
text: string;
|
|
27
|
+
location: string;
|
|
28
|
+
};
|
|
29
|
+
}>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
30
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
export default _default;
|
|
33
|
+
type __VLS_TypePropsToOption<T> = {
|
|
34
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
35
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
36
|
+
} : {
|
|
37
|
+
type: import('vue').PropType<T[K]>;
|
|
38
|
+
required: true;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type __VLS_WithDefaults<P, D> = {
|
|
42
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
43
|
+
default: D[K];
|
|
44
|
+
}> : P[K];
|
|
45
|
+
};
|
|
46
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
47
|
+
new (): {
|
|
48
|
+
$slots: S;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
52
|
+
[K in keyof T]: T[K];
|
|
53
|
+
} : {
|
|
54
|
+
[K in keyof T as K]: T[K];
|
|
55
|
+
}) & {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { VBtn } from 'vuetify/components/VBtn';
|
|
2
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof VBtn['$props']> {
|
|
3
|
+
accept?: string;
|
|
4
|
+
multiple?: boolean;
|
|
5
|
+
iconOnly?: boolean;
|
|
6
|
+
modelValue?: File | File[] | undefined;
|
|
7
|
+
tooltip?: string | Record<string, any> | undefined;
|
|
8
|
+
}
|
|
9
|
+
declare var __VLS_11: never, __VLS_12: {};
|
|
10
|
+
type __VLS_Slots = {} & {
|
|
11
|
+
[K in NonNullable<typeof __VLS_11>]?: (props: typeof __VLS_12) => any;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
14
|
+
multiple: boolean;
|
|
15
|
+
accept: string;
|
|
16
|
+
tooltip: string;
|
|
17
|
+
}>>, {
|
|
18
|
+
reset: () => void;
|
|
19
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
20
|
+
"update:modelValue": (value: File | File[] | undefined) => any;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
22
|
+
multiple: boolean;
|
|
23
|
+
accept: string;
|
|
24
|
+
tooltip: string;
|
|
25
|
+
}>>> & Readonly<{
|
|
26
|
+
"onUpdate:modelValue"?: ((value: File | File[] | undefined) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_TypePropsToOption<T> = {
|
|
32
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
33
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
34
|
+
} : {
|
|
35
|
+
type: import('vue').PropType<T[K]>;
|
|
36
|
+
required: true;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type __VLS_WithDefaults<P, D> = {
|
|
40
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
41
|
+
default: D[K];
|
|
42
|
+
}> : P[K];
|
|
43
|
+
};
|
|
44
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
45
|
+
new (): {
|
|
46
|
+
$slots: S;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
50
|
+
[K in keyof T]: T[K];
|
|
51
|
+
} : {
|
|
52
|
+
[K in keyof T as K]: T[K];
|
|
53
|
+
}) & {};
|
|
@@ -1,42 +1,27 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {ref} from
|
|
3
|
-
import {VBtn} from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
multiple: false,
|
|
15
|
-
accept: '*',
|
|
16
|
-
tooltip: 'Upload File',
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const emit = defineEmits<{
|
|
20
|
-
(event: 'update:modelValue', value: File | File[] | undefined): void
|
|
21
|
-
}>()
|
|
22
|
-
|
|
23
|
-
const fileInput = ref<HTMLInputElement>()
|
|
24
|
-
const files = ref<File | File[]>()
|
|
25
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import { VBtn } from "vuetify/components/VBtn";
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
accept: { type: String, required: false, default: "*" },
|
|
6
|
+
multiple: { type: Boolean, required: false, default: false },
|
|
7
|
+
iconOnly: { type: Boolean, required: false },
|
|
8
|
+
modelValue: { type: null, required: false },
|
|
9
|
+
tooltip: { type: null, required: false, default: "Upload File" }
|
|
10
|
+
});
|
|
11
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
12
|
+
const fileInput = ref();
|
|
13
|
+
const files = ref();
|
|
26
14
|
const openFileInput = () => {
|
|
27
|
-
fileInput.value?.click()
|
|
28
|
-
}
|
|
29
|
-
|
|
15
|
+
fileInput.value?.click();
|
|
16
|
+
};
|
|
30
17
|
const reset = () => {
|
|
31
|
-
files.value =
|
|
32
|
-
}
|
|
33
|
-
|
|
18
|
+
files.value = void 0;
|
|
19
|
+
};
|
|
34
20
|
const emitFiles = () => {
|
|
35
|
-
emit(
|
|
36
|
-
files.value = []
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
defineExpose({ reset })
|
|
21
|
+
emit("update:modelValue", files.value);
|
|
22
|
+
files.value = [];
|
|
23
|
+
};
|
|
24
|
+
defineExpose({ reset });
|
|
40
25
|
</script>
|
|
41
26
|
|
|
42
27
|
<template>
|
|
@@ -46,13 +31,13 @@ defineExpose({ reset })
|
|
|
46
31
|
v-tooltip="tooltip"
|
|
47
32
|
>
|
|
48
33
|
<template
|
|
49
|
-
v-for="(_, name, index) in
|
|
34
|
+
v-for="(_, name, index) in $slots"
|
|
50
35
|
:key="index"
|
|
51
36
|
#[name]="slotData"
|
|
52
37
|
>
|
|
53
38
|
<slot
|
|
54
39
|
:name="name"
|
|
55
|
-
v-bind="
|
|
40
|
+
v-bind="slotData || {}"
|
|
56
41
|
/>
|
|
57
42
|
</template>
|
|
58
43
|
</v-btn>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { VBtn } from 'vuetify/components/VBtn';
|
|
2
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof VBtn['$props']> {
|
|
3
|
+
accept?: string;
|
|
4
|
+
multiple?: boolean;
|
|
5
|
+
iconOnly?: boolean;
|
|
6
|
+
modelValue?: File | File[] | undefined;
|
|
7
|
+
tooltip?: string | Record<string, any> | undefined;
|
|
8
|
+
}
|
|
9
|
+
declare var __VLS_11: never, __VLS_12: {};
|
|
10
|
+
type __VLS_Slots = {} & {
|
|
11
|
+
[K in NonNullable<typeof __VLS_11>]?: (props: typeof __VLS_12) => any;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
14
|
+
multiple: boolean;
|
|
15
|
+
accept: string;
|
|
16
|
+
tooltip: string;
|
|
17
|
+
}>>, {
|
|
18
|
+
reset: () => void;
|
|
19
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
20
|
+
"update:modelValue": (value: File | File[] | undefined) => any;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
22
|
+
multiple: boolean;
|
|
23
|
+
accept: string;
|
|
24
|
+
tooltip: string;
|
|
25
|
+
}>>> & Readonly<{
|
|
26
|
+
"onUpdate:modelValue"?: ((value: File | File[] | undefined) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_TypePropsToOption<T> = {
|
|
32
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
33
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
34
|
+
} : {
|
|
35
|
+
type: import('vue').PropType<T[K]>;
|
|
36
|
+
required: true;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type __VLS_WithDefaults<P, D> = {
|
|
40
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
41
|
+
default: D[K];
|
|
42
|
+
}> : P[K];
|
|
43
|
+
};
|
|
44
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
45
|
+
new (): {
|
|
46
|
+
$slots: S;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
50
|
+
[K in keyof T]: T[K];
|
|
51
|
+
} : {
|
|
52
|
+
[K in keyof T as K]: T[K];
|
|
53
|
+
}) & {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { VBtn } from 'vuetify/components/VBtn';
|
|
2
|
+
interface ImportButtonProps extends /* @vue-ignore */ InstanceType<typeof VBtn['$props']> {
|
|
3
|
+
stringFields?: Array<string>;
|
|
4
|
+
tooltip?: string | Record<string, any> | undefined;
|
|
5
|
+
}
|
|
6
|
+
declare var __VLS_13: never, __VLS_14: {};
|
|
7
|
+
type __VLS_Slots = {} & {
|
|
8
|
+
[K in NonNullable<typeof __VLS_13>]?: (props: typeof __VLS_14) => any;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ImportButtonProps>, {
|
|
11
|
+
stringFields: () => never[];
|
|
12
|
+
tooltip: () => {
|
|
13
|
+
text: string;
|
|
14
|
+
location: string;
|
|
15
|
+
};
|
|
16
|
+
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
17
|
+
import: (value: object[]) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ImportButtonProps>, {
|
|
19
|
+
stringFields: () => never[];
|
|
20
|
+
tooltip: () => {
|
|
21
|
+
text: string;
|
|
22
|
+
location: string;
|
|
23
|
+
};
|
|
24
|
+
}>>> & Readonly<{
|
|
25
|
+
onImport?: ((value: object[]) => any) | undefined;
|
|
26
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
30
|
+
type __VLS_TypePropsToOption<T> = {
|
|
31
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
32
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
33
|
+
} : {
|
|
34
|
+
type: import('vue').PropType<T[K]>;
|
|
35
|
+
required: true;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
type __VLS_WithDefaults<P, D> = {
|
|
39
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
40
|
+
default: D[K];
|
|
41
|
+
}> : P[K];
|
|
42
|
+
};
|
|
43
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
44
|
+
new (): {
|
|
45
|
+
$slots: S;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
49
|
+
[K in keyof T]: T[K];
|
|
50
|
+
} : {
|
|
51
|
+
[K in keyof T as K]: T[K];
|
|
52
|
+
}) & {};
|
|
@@ -1,116 +1,77 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import * as XLSX from
|
|
3
|
-
import { ref } from
|
|
4
|
-
import { useAlert } from
|
|
5
|
-
import { VBtn } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const alert = useAlert()
|
|
18
|
-
const emit = defineEmits<{
|
|
19
|
-
(e: 'import', value: object[]): void
|
|
20
|
-
}>()
|
|
21
|
-
|
|
22
|
-
const loading = ref(false)
|
|
23
|
-
const fileBtnRef = ref()
|
|
24
|
-
|
|
25
|
-
function uploadedFile(files: File[] | File | undefined) {
|
|
26
|
-
if (!files) return
|
|
27
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import * as XLSX from "xlsx";
|
|
3
|
+
import { ref } from "vue";
|
|
4
|
+
import { useAlert } from "../composables/alert";
|
|
5
|
+
import { VBtn } from "vuetify/components/VBtn";
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
stringFields: { type: Array, required: false, default: () => [] },
|
|
8
|
+
tooltip: { type: null, required: false, default: () => ({ text: "Import", location: "bottom" }) }
|
|
9
|
+
});
|
|
10
|
+
const alert = useAlert();
|
|
11
|
+
const emit = defineEmits(["import"]);
|
|
12
|
+
const loading = ref(false);
|
|
13
|
+
const fileBtnRef = ref();
|
|
14
|
+
function uploadedFile(files) {
|
|
15
|
+
if (!files) return;
|
|
28
16
|
if (Array.isArray(files) && files.length != 1) {
|
|
29
|
-
alert?.addAlert({ message:
|
|
30
|
-
return
|
|
17
|
+
alert?.addAlert({ message: "Please select a single file for import", alertType: "error" });
|
|
18
|
+
return;
|
|
31
19
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
alert?.addAlert({ message: `Please upload a file with .csv or .xlsx extension only (${files.name})`, alertType: 'error' })
|
|
38
|
-
return
|
|
20
|
+
if (Array.isArray(files)) files = files[0];
|
|
21
|
+
const fileExtension = files.name.slice(files.name.lastIndexOf(".")).toLowerCase();
|
|
22
|
+
if (![".xlsx", ".csv"].includes(fileExtension)) {
|
|
23
|
+
alert?.addAlert({ message: `Please upload a file with .csv or .xlsx extension only (${files.name})`, alertType: "error" });
|
|
24
|
+
return;
|
|
39
25
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const workbook = XLSX.read(e.target?.result)
|
|
26
|
+
const reader = new FileReader();
|
|
27
|
+
reader.onload = (e) => {
|
|
28
|
+
const workbook = XLSX.read(e.target?.result);
|
|
44
29
|
const parsedData = parseAndAggregateColumns(
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
emit(
|
|
48
|
-
loading.value = false
|
|
49
|
-
fileBtnRef.value.reset()
|
|
50
|
-
}
|
|
51
|
-
loading.value = true
|
|
52
|
-
reader.readAsArrayBuffer(files)
|
|
30
|
+
XLSX.utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]])
|
|
31
|
+
);
|
|
32
|
+
emit("import", parsedData);
|
|
33
|
+
loading.value = false;
|
|
34
|
+
fileBtnRef.value.reset();
|
|
35
|
+
};
|
|
36
|
+
loading.value = true;
|
|
37
|
+
reader.readAsArrayBuffer(files);
|
|
53
38
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* @param items - Array of data from the Excel sheet
|
|
58
|
-
*/
|
|
59
|
-
const parseAndAggregateColumns = (items: any[]) => {
|
|
60
|
-
return items.map((item: any) => {
|
|
61
|
-
const aggregatedItem: any = {}
|
|
62
|
-
|
|
39
|
+
const parseAndAggregateColumns = (items) => {
|
|
40
|
+
return items.map((item) => {
|
|
41
|
+
const aggregatedItem = {};
|
|
63
42
|
for (const key in item) {
|
|
64
|
-
if (key.includes(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// Recursively aggregate subKeys
|
|
69
|
-
aggregatedItem[rootKey] = aggregatedItem[rootKey] || {}
|
|
70
|
-
assignNestedValue(aggregatedItem[rootKey], subKeys, parseIfJson(item[key]))
|
|
43
|
+
if (key.includes(".")) {
|
|
44
|
+
const [rootKey, ...subKeys] = key.split(".");
|
|
45
|
+
aggregatedItem[rootKey] = aggregatedItem[rootKey] || {};
|
|
46
|
+
assignNestedValue(aggregatedItem[rootKey], subKeys, parseIfJson(item[key]));
|
|
71
47
|
} else {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
else aggregatedItem[key] = parseIfJson(item[key])
|
|
48
|
+
if (props.stringFields.includes(key)) aggregatedItem[key] = item[key];
|
|
49
|
+
else aggregatedItem[key] = parseIfJson(item[key]);
|
|
75
50
|
}
|
|
76
51
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Recursively assigns a value to a nested key structure.
|
|
84
|
-
* @param obj - The object to assign to
|
|
85
|
-
* @param keys - Array of keys leading to the final property
|
|
86
|
-
* @param value - The value to assign
|
|
87
|
-
*/
|
|
88
|
-
const assignNestedValue = (obj: any, keys: string[], value: any) => {
|
|
89
|
-
const [currentKey, ...remainingKeys] = keys
|
|
52
|
+
return aggregatedItem;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const assignNestedValue = (obj, keys, value) => {
|
|
56
|
+
const [currentKey, ...remainingKeys] = keys;
|
|
90
57
|
if (remainingKeys.length === 0) {
|
|
91
|
-
obj[currentKey] = value
|
|
58
|
+
obj[currentKey] = value;
|
|
92
59
|
} else {
|
|
93
|
-
obj[currentKey] = obj[currentKey] || {}
|
|
94
|
-
assignNestedValue(obj[currentKey], remainingKeys, value)
|
|
60
|
+
obj[currentKey] = obj[currentKey] || {};
|
|
61
|
+
assignNestedValue(obj[currentKey], remainingKeys, value);
|
|
95
62
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
* Attempt to parse a value as JSON or array.
|
|
100
|
-
* @param value - The value to parse
|
|
101
|
-
*/
|
|
102
|
-
const parseIfJson = (value: any) => {
|
|
103
|
-
if (typeof value === 'string') {
|
|
63
|
+
};
|
|
64
|
+
const parseIfJson = (value) => {
|
|
65
|
+
if (typeof value === "string") {
|
|
104
66
|
try {
|
|
105
|
-
let parsedValue = JSON.parse(value)
|
|
106
|
-
return
|
|
67
|
+
let parsedValue = JSON.parse(value);
|
|
68
|
+
return parsedValue == value ? value : parsedValue;
|
|
107
69
|
} catch {
|
|
108
|
-
|
|
109
|
-
return value
|
|
70
|
+
return value;
|
|
110
71
|
}
|
|
111
72
|
}
|
|
112
|
-
return value
|
|
113
|
-
}
|
|
73
|
+
return value;
|
|
74
|
+
};
|
|
114
75
|
</script>
|
|
115
76
|
|
|
116
77
|
<template>
|
|
@@ -126,13 +87,13 @@ const parseIfJson = (value: any) => {
|
|
|
126
87
|
:tooltip="props.tooltip"
|
|
127
88
|
>
|
|
128
89
|
<template
|
|
129
|
-
v-for="(_, name, index) in
|
|
90
|
+
v-for="(_, name, index) in $slots"
|
|
130
91
|
:key="index"
|
|
131
92
|
#[name]="slotData"
|
|
132
93
|
>
|
|
133
94
|
<slot
|
|
134
95
|
:name="name"
|
|
135
|
-
v-bind="
|
|
96
|
+
v-bind="slotData || {}"
|
|
136
97
|
/>
|
|
137
98
|
</template>
|
|
138
99
|
</FileBtn>
|