@ramathibodi/nuxt-commons 0.1.74 → 4.0.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/README.md +9 -2
- package/dist/module.json +4 -4
- package/dist/module.mjs +4 -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 -26
- 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 -81
- 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 -76
- 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 -50
- 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 -111
- 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 +69 -109
- 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 -35
- 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 -20
- 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 -45
- 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 -67
- 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 -165
- 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 -178
- 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 -59
- 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 -57
- 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 -40
- 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 -29
- 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 -62
- 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 -29
- 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 -48
- 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 -29
- 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 -82
- 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 -42
- 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 -194
- 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 -85
- 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 -76
- 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 -64
- 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 -36
- 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 -162
- 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 -143
- 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 -96
- 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 -85
- 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 -186
- 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 -34
- 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 -252
- 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 -55
- 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 -265
- 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 -126
- 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 -32
- 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 -182
- 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 -139
- 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 -99
- 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 -147
- 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 -81
- 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 -205
- 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 -40
- 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 -29
- 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 -75
- 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 -105
- 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 -40
- 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 -28
- 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 -38
- 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 -20
- 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 -34
- 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 -35
- 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 -59
- 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 -34
- 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 -42
- 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 -49
- 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 -49
- 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 -65
- 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 -44
- 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 -145
- 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 -183
- 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 -43
- 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 -50
- 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 -95
- package/dist/runtime/components/pdf/View.vue.d.ts +52 -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/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/lookupListMaster.js +3 -3
- package/dist/runtime/composables/menu.js +2 -2
- 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/datetime.js +1 -1
- package/dist/types.d.mts +2 -6
- package/package.json +71 -59
- package/scripts/ci-release.mjs +125 -0
- package/scripts/release-version.mjs +68 -0
- package/scripts/release.mjs +49 -0
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -8
- package/dist/types.d.ts +0 -7
|
@@ -1,355 +1,255 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
compile,
|
|
9
|
-
computed,
|
|
10
|
-
defineComponent,
|
|
11
|
-
defineOptions,
|
|
12
|
-
inject,
|
|
13
|
-
onMounted,
|
|
14
|
-
ref,
|
|
15
|
-
shallowRef,
|
|
16
|
-
watch,
|
|
17
|
-
withDefaults
|
|
18
|
-
} from 'vue'
|
|
19
|
-
import {watchDebounced} from '@vueuse/core'
|
|
20
|
-
import {useRules} from '../../composables/utils/validation'
|
|
21
|
-
import {useDocumentTemplate} from '../../composables/document/template'
|
|
22
|
-
import { isObject, isArray, isString, isPlainObject, isEqual, debounce } from 'lodash-es'
|
|
23
|
-
import FormPad from './Pad.vue'
|
|
24
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { compile, computed, defineComponent, inject, onMounted, ref, shallowRef, watch } from "vue";
|
|
3
|
+
import { watchDebounced } from "@vueuse/core";
|
|
4
|
+
import { useRules } from "../../composables/utils/validation";
|
|
5
|
+
import { useDocumentTemplate } from "../../composables/document/template";
|
|
6
|
+
import { isObject, isArray, isString, isPlainObject, isEqual, debounce } from "lodash-es";
|
|
7
|
+
import FormPad from "./Pad.vue";
|
|
25
8
|
defineOptions({
|
|
26
|
-
inheritAttrs: false
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
49
|
-
disabled: false,
|
|
50
|
-
readonly: false,
|
|
51
|
-
isolated: false,
|
|
52
|
-
decoration: () => { return {} },
|
|
53
|
-
parentTemplates: (): string[] => [],
|
|
54
|
-
dirtyClass: "form-data-dirty",
|
|
55
|
-
dirtyOnCreate: false,
|
|
56
|
-
sanitizeDelay: 2000,
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Custom events emitted by FormPad.
|
|
61
|
-
* Parents can listen to these events to react to user actions and internal state changes.
|
|
62
|
-
*/
|
|
63
|
-
const emit = defineEmits(['update:modelValue'])
|
|
64
|
-
|
|
65
|
-
const disabled = ref(props.disabled)
|
|
66
|
-
const readonly = ref(props.readonly)
|
|
67
|
-
const decoration = ref(props.decoration)
|
|
68
|
-
|
|
9
|
+
inheritAttrs: false
|
|
10
|
+
});
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
modelValue: { type: Object, required: false },
|
|
13
|
+
originalData: { type: Object, required: false },
|
|
14
|
+
template: { type: null, required: false },
|
|
15
|
+
templateScript: { type: String, required: false },
|
|
16
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
17
|
+
readonly: { type: Boolean, required: false, default: false },
|
|
18
|
+
isolated: { type: Boolean, required: false, default: false },
|
|
19
|
+
decoration: { type: Object, required: false, default: () => {
|
|
20
|
+
return {};
|
|
21
|
+
} },
|
|
22
|
+
parentTemplates: { type: [String, Array], required: false, default: () => [] },
|
|
23
|
+
dirtyClass: { type: String, required: false, default: "form-data-dirty" },
|
|
24
|
+
dirtyOnCreate: { type: Boolean, required: false, default: false },
|
|
25
|
+
sanitizeDelay: { type: Number, required: false, default: 2e3 }
|
|
26
|
+
});
|
|
27
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
28
|
+
const disabled = ref(props.disabled);
|
|
29
|
+
const readonly = ref(props.readonly);
|
|
30
|
+
const decoration = ref(props.decoration);
|
|
69
31
|
watch(() => props.disabled, (newValue) => {
|
|
70
|
-
disabled.value = newValue
|
|
71
|
-
})
|
|
72
|
-
|
|
32
|
+
disabled.value = newValue;
|
|
33
|
+
});
|
|
73
34
|
watch(() => props.readonly, (newValue) => {
|
|
74
|
-
readonly.value = newValue
|
|
75
|
-
})
|
|
76
|
-
|
|
35
|
+
readonly.value = newValue;
|
|
36
|
+
});
|
|
77
37
|
watch(() => props.decoration, (newValue) => {
|
|
78
|
-
decoration.value = newValue
|
|
79
|
-
}, { deep: true })
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const trimmedTemplate = ref<string>('')
|
|
84
|
-
|
|
85
|
-
const vueFunctions = { ref, shallowRef, computed, watch, onMounted }
|
|
86
|
-
|
|
38
|
+
decoration.value = newValue;
|
|
39
|
+
}, { deep: true });
|
|
40
|
+
const { rules } = useRules();
|
|
41
|
+
const trimmedTemplate = ref("");
|
|
42
|
+
const vueFunctions = { ref, shallowRef, computed, watch, onMounted };
|
|
87
43
|
const templateScriptFunction = computed(() => {
|
|
88
|
-
let templateScript = props.templateScript?.trim() ||
|
|
89
|
-
const pattern = /^\s*[{[].*[}\]]\s
|
|
90
|
-
if (pattern.test(templateScript)) templateScript =
|
|
91
|
-
return Function(
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
function isBlankString(v: unknown): v is string {
|
|
101
|
-
return isString(v) && v.trim().length === 0
|
|
44
|
+
let templateScript = props.templateScript?.trim() || "return {}";
|
|
45
|
+
const pattern = /^\s*[{[].*[}\]]\s*$/;
|
|
46
|
+
if (pattern.test(templateScript)) templateScript = "return {}";
|
|
47
|
+
return Function("props", "ctx", ...Object.keys(vueFunctions), templateScript);
|
|
48
|
+
});
|
|
49
|
+
const formPad = ref();
|
|
50
|
+
const formInjectKey = /* @__PURE__ */ Symbol.for("vuetify:form");
|
|
51
|
+
const formInjected = ref();
|
|
52
|
+
const formData = ref({});
|
|
53
|
+
function isBlankString(v) {
|
|
54
|
+
return isString(v) && v.trim().length === 0;
|
|
102
55
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
function sanitizeBlankStringsRaw(val: any, original?: any): void {
|
|
56
|
+
const sanitizeBlankStrings = debounce(sanitizeBlankStringsRaw, props.sanitizeDelay);
|
|
57
|
+
function sanitizeBlankStringsRaw(val, original) {
|
|
107
58
|
if (!original && props.originalData) {
|
|
108
|
-
sanitizeBlankStrings(val, props.originalData)
|
|
109
|
-
return
|
|
59
|
+
sanitizeBlankStrings(val, props.originalData);
|
|
60
|
+
return;
|
|
110
61
|
}
|
|
111
|
-
|
|
112
62
|
if (isArray(val)) {
|
|
113
63
|
for (let i = val.length - 1; i >= 0; i--) {
|
|
114
|
-
const item = val[i]
|
|
64
|
+
const item = val[i];
|
|
115
65
|
if (isBlankString(item)) {
|
|
116
|
-
val.splice(i, 1)
|
|
66
|
+
val.splice(i, 1);
|
|
117
67
|
} else if (isPlainObject(item) || isArray(item)) {
|
|
118
|
-
sanitizeBlankStrings(item,{})
|
|
68
|
+
sanitizeBlankStrings(item, {});
|
|
119
69
|
} else {
|
|
120
|
-
if (item && typeof item ===
|
|
70
|
+
if (item && typeof item === "string") val[i] = item.replace(/[ \t]+$/, "");
|
|
121
71
|
}
|
|
122
72
|
}
|
|
123
|
-
return
|
|
73
|
+
return;
|
|
124
74
|
}
|
|
125
|
-
|
|
126
75
|
if (isPlainObject(val)) {
|
|
127
76
|
for (const key of Object.keys(val)) {
|
|
128
|
-
const v = val[key]
|
|
77
|
+
const v = val[key];
|
|
129
78
|
if (isBlankString(v)) {
|
|
130
|
-
if (original && !Object.keys(original).includes(key)) delete val[key]
|
|
131
|
-
else val[key] = null
|
|
79
|
+
if (original && !Object.keys(original).includes(key)) delete val[key];
|
|
80
|
+
else val[key] = null;
|
|
132
81
|
} else if (isPlainObject(v) || isArray(v)) {
|
|
133
|
-
let originalChild =
|
|
134
|
-
sanitizeBlankStrings(v, originalChild)
|
|
82
|
+
let originalChild = original && (isPlainObject(original[key]) || isArray(original[key])) ? original[key] : {};
|
|
83
|
+
sanitizeBlankStrings(v, originalChild);
|
|
135
84
|
} else {
|
|
136
|
-
if (v && typeof v ===
|
|
85
|
+
if (v && typeof v === "string") val[key] = v.replace(/[ \t]+$/, "");
|
|
137
86
|
}
|
|
138
87
|
}
|
|
139
88
|
}
|
|
140
89
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
v === undefined ||
|
|
146
|
-
(typeof v === "string" && v.trim() === "") ||
|
|
147
|
-
(typeof v === "number" && Number.isNaN(v));
|
|
148
|
-
|
|
149
|
-
const toStr = (v: any): string | undefined => {
|
|
150
|
-
if (isEmptyScalar(v)) return undefined;
|
|
90
|
+
function autoSanitizedDisplay(item, separator = ",") {
|
|
91
|
+
const isEmptyScalar = (v) => v === null || v === void 0 || typeof v === "string" && v.trim() === "" || typeof v === "number" && Number.isNaN(v);
|
|
92
|
+
const toStr = (v) => {
|
|
93
|
+
if (isEmptyScalar(v)) return void 0;
|
|
151
94
|
if (typeof v === "string") return v.trim();
|
|
152
95
|
if (typeof v === "number" || typeof v === "boolean" || typeof v === "bigint") return String(v);
|
|
153
96
|
if (typeof v === "symbol") return v.description ?? String(v);
|
|
154
97
|
if (typeof v === "function") return v.name ? `[Function ${v.name}]` : "[Function]";
|
|
155
|
-
return
|
|
98
|
+
return void 0;
|
|
156
99
|
};
|
|
157
|
-
|
|
158
|
-
// 1) empty -> undefined
|
|
159
|
-
if (isEmptyScalar(item)) return undefined;
|
|
160
|
-
|
|
161
|
-
// 2) array -> recurse + join
|
|
100
|
+
if (isEmptyScalar(item)) return void 0;
|
|
162
101
|
if (Array.isArray(item)) {
|
|
163
|
-
const parts = item
|
|
164
|
-
|
|
165
|
-
.filter((s): s is string => typeof s === "string" && s.trim() !== "");
|
|
166
|
-
return parts.length ? parts.join(separator) : undefined;
|
|
102
|
+
const parts = item.map((x) => autoSanitizedDisplay(x, separator)).filter((s) => typeof s === "string" && s.trim() !== "");
|
|
103
|
+
return parts.length ? parts.join(separator) : void 0;
|
|
167
104
|
}
|
|
168
|
-
|
|
169
|
-
// simple scalars
|
|
170
105
|
const scalar = toStr(item);
|
|
171
|
-
if (scalar !==
|
|
172
|
-
|
|
173
|
-
// 3) object
|
|
106
|
+
if (scalar !== void 0) return scalar;
|
|
174
107
|
if (typeof item === "object") {
|
|
175
|
-
// 3.1 label
|
|
176
108
|
if ("label" in item) {
|
|
177
|
-
const v = autoSanitizedDisplay(
|
|
178
|
-
if (v !==
|
|
109
|
+
const v = autoSanitizedDisplay(item.label, separator) ?? toStr(item.label);
|
|
110
|
+
if (v !== void 0) return v;
|
|
179
111
|
}
|
|
180
|
-
// 3.2 value
|
|
181
112
|
if ("value" in item) {
|
|
182
|
-
const v = autoSanitizedDisplay(
|
|
183
|
-
if (v !==
|
|
113
|
+
const v = autoSanitizedDisplay(item.value, separator) ?? toStr(item.value);
|
|
114
|
+
if (v !== void 0) return v;
|
|
184
115
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return `${k}:${rendered}`;
|
|
192
|
-
})
|
|
193
|
-
.filter((x): x is string => typeof x === "string" && x.trim() !== "");
|
|
194
|
-
|
|
195
|
-
return entries.length ? entries.join(separator) : undefined;
|
|
116
|
+
const entries = Object.entries(item).map(([k, v]) => {
|
|
117
|
+
const rendered = autoSanitizedDisplay(v, separator) ?? toStr(v);
|
|
118
|
+
if (rendered === void 0 || rendered.trim() === "") return void 0;
|
|
119
|
+
return `${k}:${rendered}`;
|
|
120
|
+
}).filter((x) => typeof x === "string" && x.trim() !== "");
|
|
121
|
+
return entries.length ? entries.join(separator) : void 0;
|
|
196
122
|
}
|
|
197
|
-
|
|
198
|
-
// fallback
|
|
199
123
|
try {
|
|
200
124
|
const s = String(item);
|
|
201
|
-
return s.trim() ? s :
|
|
125
|
+
return s.trim() ? s : void 0;
|
|
202
126
|
} catch {
|
|
203
|
-
return
|
|
127
|
+
return void 0;
|
|
204
128
|
}
|
|
205
129
|
}
|
|
206
|
-
|
|
207
130
|
watch(formData, (newValue) => {
|
|
208
|
-
sanitizeBlankStrings(newValue)
|
|
209
|
-
emit(
|
|
210
|
-
}, { deep: true })
|
|
211
|
-
|
|
131
|
+
sanitizeBlankStrings(newValue);
|
|
132
|
+
emit("update:modelValue", newValue);
|
|
133
|
+
}, { deep: true });
|
|
212
134
|
watch(() => props.modelValue, (newValue) => {
|
|
213
|
-
formData.value = isObject(newValue) ? newValue : {}
|
|
214
|
-
}, { deep: true, immediate: true })
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
a: any,
|
|
218
|
-
b: any,
|
|
219
|
-
base: string[] = [],
|
|
220
|
-
out: string[] = []
|
|
221
|
-
): string[] {
|
|
222
|
-
const keys = new Set<string>([
|
|
135
|
+
formData.value = isObject(newValue) ? newValue : {};
|
|
136
|
+
}, { deep: true, immediate: true });
|
|
137
|
+
function diffPaths(a, b, base = [], out = []) {
|
|
138
|
+
const keys = /* @__PURE__ */ new Set([
|
|
223
139
|
...Object.keys(a ?? {}),
|
|
224
|
-
...Object.keys(b ?? {})
|
|
225
|
-
])
|
|
226
|
-
|
|
140
|
+
...Object.keys(b ?? {})
|
|
141
|
+
]);
|
|
227
142
|
for (const k of keys) {
|
|
228
|
-
const av = a?.[k]
|
|
229
|
-
const bv = b?.[k]
|
|
230
|
-
if (!av && !bv) continue
|
|
231
|
-
|
|
232
|
-
const path = [...base, k]
|
|
233
|
-
|
|
143
|
+
const av = a?.[k];
|
|
144
|
+
const bv = b?.[k];
|
|
145
|
+
if (!av && !bv) continue;
|
|
146
|
+
const path = [...base, k];
|
|
234
147
|
if (isPlainObject(av) && isPlainObject(bv)) {
|
|
235
|
-
diffPaths(av, bv, path, out)
|
|
236
|
-
continue
|
|
148
|
+
diffPaths(av, bv, path, out);
|
|
149
|
+
continue;
|
|
237
150
|
}
|
|
238
|
-
|
|
239
151
|
if (!isEqual(av, bv)) {
|
|
240
|
-
out.push(path.join(
|
|
152
|
+
out.push(path.join("."));
|
|
241
153
|
}
|
|
242
154
|
}
|
|
243
|
-
|
|
244
|
-
return out
|
|
155
|
+
return out;
|
|
245
156
|
}
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
for (const p of paths) result[p] = cls
|
|
258
|
-
|
|
259
|
-
return result
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
const formComponent = shallowRef()
|
|
263
|
-
|
|
157
|
+
const injectedClass = computed(() => {
|
|
158
|
+
const data = formData.value ?? {};
|
|
159
|
+
const result = {};
|
|
160
|
+
if (!props.dirtyOnCreate && !props.originalData) return result;
|
|
161
|
+
const original = props.originalData ?? {};
|
|
162
|
+
const cls = props.dirtyClass || "form-data-dirty";
|
|
163
|
+
const paths = diffPaths(data, original);
|
|
164
|
+
for (const p of paths) result[p] = cls;
|
|
165
|
+
return result;
|
|
166
|
+
});
|
|
167
|
+
const formComponent = shallowRef();
|
|
264
168
|
function buildFormComponent() {
|
|
265
|
-
if (!trimmedTemplate.value) return
|
|
266
|
-
const originalConsoleError = console.warn
|
|
267
|
-
console.warn = (error
|
|
169
|
+
if (!trimmedTemplate.value) return;
|
|
170
|
+
const originalConsoleError = console.warn;
|
|
171
|
+
console.warn = (error) => {
|
|
172
|
+
throw new Error(error);
|
|
173
|
+
};
|
|
268
174
|
try {
|
|
269
|
-
const componentTemplate = '<form-pad ref="formPadTemplate" v-model="formComponentData" :originalData="originalData" :disabled="disabled" :readonly="readonly" :decoration="decoration" :isolated="isolated"><template v-slot="{ data,isDisabled,isReadonly,rules,formProvided,decoration,injectedClass }">' + trimmedTemplate.value +
|
|
270
|
-
compile(componentTemplate)
|
|
175
|
+
const componentTemplate = '<form-pad ref="formPadTemplate" v-model="formComponentData" :originalData="originalData" :disabled="disabled" :readonly="readonly" :decoration="decoration" :isolated="isolated"><template v-slot="{ data,isDisabled,isReadonly,rules,formProvided,decoration,injectedClass }">' + trimmedTemplate.value + "</template></form-pad>";
|
|
176
|
+
compile(componentTemplate);
|
|
271
177
|
formComponent.value = defineComponent({
|
|
272
178
|
components: { FormPad },
|
|
273
179
|
props: {
|
|
274
|
-
modelValue: { type: Object, default:
|
|
275
|
-
originalData: { type: Object, default:
|
|
180
|
+
modelValue: { type: Object, default: void 0 },
|
|
181
|
+
originalData: { type: Object, default: void 0 },
|
|
276
182
|
disabled: { type: Boolean, default: false },
|
|
277
183
|
readonly: { type: Boolean, default: false },
|
|
278
|
-
decoration: { type: Object, default: () => {
|
|
279
|
-
|
|
184
|
+
decoration: { type: Object, default: () => {
|
|
185
|
+
return {};
|
|
186
|
+
} },
|
|
187
|
+
isolated: { type: Boolean, default: false }
|
|
280
188
|
},
|
|
281
|
-
emits: [
|
|
282
|
-
setup(
|
|
283
|
-
const formComponentData = ref
|
|
284
|
-
const formPadTemplate = ref
|
|
189
|
+
emits: ["update:modelValue"],
|
|
190
|
+
setup(props2, ctx) {
|
|
191
|
+
const formComponentData = ref({});
|
|
192
|
+
const formPadTemplate = ref({});
|
|
285
193
|
watch(formComponentData, (newValue) => {
|
|
286
|
-
sanitizeBlankStrings(newValue)
|
|
287
|
-
ctx.emit(
|
|
288
|
-
}, { deep: true })
|
|
289
|
-
watch(() =>
|
|
290
|
-
formComponentData.value = isObject(newValue) ? newValue : {}
|
|
291
|
-
}, { deep: true, immediate: true })
|
|
292
|
-
const
|
|
194
|
+
sanitizeBlankStrings(newValue);
|
|
195
|
+
ctx.emit("update:modelValue", newValue);
|
|
196
|
+
}, { deep: true });
|
|
197
|
+
watch(() => props2.modelValue, (newValue) => {
|
|
198
|
+
formComponentData.value = isObject(newValue) ? newValue : {};
|
|
199
|
+
}, { deep: true, immediate: true });
|
|
200
|
+
const isValid2 = computed(() => formPadTemplate.value.isValid);
|
|
293
201
|
return {
|
|
294
202
|
formComponentData,
|
|
295
203
|
formPadTemplate,
|
|
296
204
|
reset: () => formPadTemplate.value.reset(),
|
|
297
205
|
validate: () => formPadTemplate.value.validate(),
|
|
298
206
|
resetValidate: () => formPadTemplate.value.resetValidate(),
|
|
299
|
-
isValid,
|
|
300
|
-
...templateScriptFunction.value(
|
|
207
|
+
isValid: isValid2,
|
|
208
|
+
...templateScriptFunction.value(props2, ctx, ...Object.values(vueFunctions)),
|
|
301
209
|
autoSanitizedDisplay
|
|
302
|
-
}
|
|
210
|
+
};
|
|
303
211
|
},
|
|
304
|
-
template: componentTemplate
|
|
305
|
-
})
|
|
212
|
+
template: componentTemplate
|
|
213
|
+
});
|
|
214
|
+
} catch (e) {
|
|
215
|
+
formComponent.value = null;
|
|
216
|
+
console.error(e);
|
|
306
217
|
}
|
|
307
|
-
|
|
308
|
-
formComponent.value = null
|
|
309
|
-
console.error(e)
|
|
310
|
-
}
|
|
311
|
-
console.warn = originalConsoleError
|
|
218
|
+
console.warn = originalConsoleError;
|
|
312
219
|
}
|
|
313
|
-
|
|
314
220
|
function reset() {
|
|
315
|
-
if (!formInjected.value) formPad.value.reset()
|
|
316
|
-
else formInjected.value.items.forEach((item
|
|
221
|
+
if (!formInjected.value) formPad.value.reset();
|
|
222
|
+
else formInjected.value.items.forEach((item) => item.reset());
|
|
317
223
|
}
|
|
318
|
-
|
|
319
224
|
function validate() {
|
|
320
|
-
if (!formInjected.value) formPad.value.validate()
|
|
321
|
-
else formInjected.value.items.forEach((item
|
|
225
|
+
if (!formInjected.value) formPad.value.validate();
|
|
226
|
+
else formInjected.value.items.forEach((item) => item.validate());
|
|
322
227
|
}
|
|
323
|
-
|
|
324
228
|
function resetValidate() {
|
|
325
|
-
if (!formInjected.value) formPad.value.resetValidate()
|
|
326
|
-
else formInjected.value.items.forEach((item
|
|
229
|
+
if (!formInjected.value) formPad.value.resetValidate();
|
|
230
|
+
else formInjected.value.items.forEach((item) => item.resetValidate());
|
|
327
231
|
}
|
|
328
|
-
|
|
329
232
|
const isValid = computed(() => {
|
|
330
|
-
validate()
|
|
331
|
-
return formInjected.value ? formInjected.value.isValid || false : formPad.value.isValid || false
|
|
332
|
-
})
|
|
333
|
-
|
|
233
|
+
validate();
|
|
234
|
+
return formInjected.value ? formInjected.value.isValid || false : formPad.value.isValid || false;
|
|
235
|
+
});
|
|
334
236
|
onMounted(() => {
|
|
335
|
-
if (!props.isolated) formInjected.value = inject(formInjectKey, false)
|
|
336
|
-
buildFormComponent()
|
|
337
|
-
})
|
|
338
|
-
|
|
237
|
+
if (!props.isolated) formInjected.value = inject(formInjectKey, false);
|
|
238
|
+
buildFormComponent();
|
|
239
|
+
});
|
|
339
240
|
watchDebounced(() => props.template, (newValue) => {
|
|
340
|
-
trimmedTemplate.value = useDocumentTemplate(newValue,props.parentTemplates).trim() ||
|
|
341
|
-
buildFormComponent()
|
|
342
|
-
}, { debounce: 500, maxWait:
|
|
343
|
-
watchDebounced(() => props.templateScript, buildFormComponent, { debounce: 500, maxWait:
|
|
344
|
-
|
|
241
|
+
trimmedTemplate.value = useDocumentTemplate(newValue, props.parentTemplates).trim() || "";
|
|
242
|
+
buildFormComponent();
|
|
243
|
+
}, { debounce: 500, maxWait: 5e3, deep: true, immediate: true });
|
|
244
|
+
watchDebounced(() => props.templateScript, buildFormComponent, { debounce: 500, maxWait: 5e3 });
|
|
345
245
|
defineExpose({
|
|
346
246
|
isValid,
|
|
347
247
|
disabled,
|
|
348
248
|
readonly,
|
|
349
249
|
reset,
|
|
350
250
|
validate,
|
|
351
|
-
resetValidate
|
|
352
|
-
})
|
|
251
|
+
resetValidate
|
|
252
|
+
});
|
|
353
253
|
</script>
|
|
354
254
|
|
|
355
255
|
<template>
|
|
@@ -397,6 +297,7 @@ defineExpose({
|
|
|
397
297
|
:class="$attrs.class"
|
|
398
298
|
/>
|
|
399
299
|
</template>
|
|
300
|
+
|
|
400
301
|
<style>
|
|
401
302
|
.form-data-dirty:not(.v-input--error) :not(.v-chip):not(.v-chip *){color:color-mix(in srgb,currentColor 70%,rgb(var(--v-theme-primary)))!important;text-shadow:0 0 .02em currentColor}
|
|
402
|
-
</style>
|
|
303
|
+
</style>
|