@ramathibodi/nuxt-commons 0.1.74 → 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 +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 -58
- 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,219 +1,166 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { ref, watch, watchEffect, nextTick, defineExpose, computed} from 'vue'
|
|
7
|
-
import { VTextField } from 'vuetify/components/VTextField'
|
|
8
|
-
import Datepicker from '@vuepic/vue-datepicker'
|
|
9
|
-
import '@vuepic/vue-datepicker/dist/main.css'
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, watch, watchEffect, nextTick, computed } from "vue";
|
|
3
|
+
import { VTextField } from "vuetify/components/VTextField";
|
|
4
|
+
import Datepicker from "@vuepic/vue-datepicker";
|
|
5
|
+
import "@vuepic/vue-datepicker/dist/main.css";
|
|
10
6
|
import { isArray, isString } from "lodash-es";
|
|
11
|
-
import {
|
|
7
|
+
import { Datetime } from "../../utils/datetime";
|
|
12
8
|
import { useRules } from "../../composables/utils/validation";
|
|
13
|
-
import { th } from
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Public props accepted by FormDate.
|
|
31
|
-
* Document each prop field with intent, defaults, and side effects for clear generated docs.
|
|
32
|
-
*/
|
|
33
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
34
|
-
locale: 'TH',
|
|
35
|
-
format: 'shortDate',
|
|
36
|
-
pickerOnly: false,
|
|
37
|
-
flow: () => [],
|
|
38
|
-
|
|
39
|
-
defaultDate: false,
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Custom events emitted by FormDate.
|
|
44
|
-
* Parents can listen to these events to react to user actions and internal state changes.
|
|
45
|
-
*/
|
|
46
|
-
const emit = defineEmits(['update:modelValue'])
|
|
47
|
-
|
|
9
|
+
import { th } from "date-fns/locale";
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
locale: { type: String, required: false, default: "TH" },
|
|
12
|
+
format: { type: String, required: false, default: "shortDate" },
|
|
13
|
+
modelValue: { type: [String, null], required: false },
|
|
14
|
+
holiday: { type: null, required: false },
|
|
15
|
+
minDate: { type: [Date, String], required: false },
|
|
16
|
+
maxDate: { type: [Date, String], required: false },
|
|
17
|
+
pickerOnly: { type: Boolean, required: false, default: false },
|
|
18
|
+
flow: { type: Array, required: false, default: () => [] },
|
|
19
|
+
rules: { type: null, required: false },
|
|
20
|
+
defaultDate: { type: [Boolean, String], required: false, default: false }
|
|
21
|
+
});
|
|
22
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
48
23
|
const computedRules = computed(() => {
|
|
49
24
|
if (props.rules && isArray(props.rules)) {
|
|
50
|
-
|
|
51
25
|
const ruleConfig = {
|
|
52
|
-
singleModifier: [
|
|
53
|
-
twoPartModifier: [
|
|
26
|
+
singleModifier: ["DateFuture", "DateHappen"],
|
|
27
|
+
twoPartModifier: ["DateAfter", "DateBefore", "DateEqual"]
|
|
54
28
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const ruleFunc = ruleMapping[ruleName](...Object.values(modifier))
|
|
67
|
-
return ruleFunc(selectedDate.value)
|
|
29
|
+
const ruleMapping = {
|
|
30
|
+
"DateFuture": useRules().DateFuture,
|
|
31
|
+
"DateHappen": useRules().DateHappen,
|
|
32
|
+
"DateAfter": useRules().DateAfter,
|
|
33
|
+
"DateBefore": useRules().DatetimeFuture,
|
|
34
|
+
"DateEqual": useRules().DateEqual
|
|
35
|
+
};
|
|
36
|
+
const applyRule = (ruleName, modifier) => {
|
|
37
|
+
if (props.readonly) return true;
|
|
38
|
+
const ruleFunc = ruleMapping[ruleName](...Object.values(modifier));
|
|
39
|
+
return ruleFunc(selectedDate.value);
|
|
68
40
|
};
|
|
69
|
-
|
|
70
41
|
return props.rules.map((rule) => {
|
|
71
42
|
if (isString(rule)) {
|
|
72
|
-
const ruleParts = rule.split(
|
|
73
|
-
const baseRule = ruleParts[0]
|
|
74
|
-
|
|
43
|
+
const ruleParts = rule.split("#");
|
|
44
|
+
const baseRule = ruleParts[0];
|
|
75
45
|
if (ruleConfig.singleModifier.includes(baseRule)) {
|
|
76
|
-
const modifiers = ruleParts.slice(1).join(
|
|
46
|
+
const modifiers = ruleParts.slice(1).join("#").trim() || void 0;
|
|
77
47
|
return applyRule(baseRule, { modifiers });
|
|
78
48
|
}
|
|
79
|
-
|
|
80
49
|
if (ruleConfig.twoPartModifier.includes(baseRule)) {
|
|
81
|
-
const [modifier1, ...modifierRest] = ruleParts.slice(1)
|
|
82
|
-
const combinedModifier = modifierRest.join(
|
|
83
|
-
return applyRule(baseRule, { modifier1, combinedModifier })
|
|
50
|
+
const [modifier1, ...modifierRest] = ruleParts.slice(1);
|
|
51
|
+
const combinedModifier = modifierRest.join("#") || void 0;
|
|
52
|
+
return applyRule(baseRule, { modifier1, combinedModifier });
|
|
84
53
|
}
|
|
85
54
|
}
|
|
86
|
-
return rule
|
|
87
|
-
})
|
|
55
|
+
return rule;
|
|
56
|
+
});
|
|
88
57
|
} else {
|
|
89
|
-
return props.rules
|
|
58
|
+
return props.rules;
|
|
90
59
|
}
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
function handleTextFieldFocus(event: Event) {
|
|
101
|
-
isTextFieldFocused.value = true
|
|
60
|
+
});
|
|
61
|
+
const selectedDate = ref(null);
|
|
62
|
+
const displayedDate = ref(null);
|
|
63
|
+
const isMenuOpen = ref(false);
|
|
64
|
+
const isTextFieldFocused = ref(false);
|
|
65
|
+
const hasTextFieldInput = ref(false);
|
|
66
|
+
function handleTextFieldFocus(event) {
|
|
67
|
+
isTextFieldFocused.value = true;
|
|
102
68
|
nextTick(() => {
|
|
103
|
-
|
|
104
|
-
})
|
|
69
|
+
event.target.select();
|
|
70
|
+
});
|
|
105
71
|
}
|
|
106
|
-
|
|
107
72
|
function handleTextFieldInput() {
|
|
108
73
|
if (!hasTextFieldInput.value) {
|
|
109
|
-
hasTextFieldInput.value = true
|
|
110
|
-
isMenuOpen.value = false
|
|
74
|
+
hasTextFieldInput.value = true;
|
|
75
|
+
isMenuOpen.value = false;
|
|
111
76
|
}
|
|
112
77
|
}
|
|
113
|
-
|
|
114
78
|
function handleTextFieldBlur() {
|
|
115
79
|
if (hasTextFieldInput.value) {
|
|
116
|
-
updateDate(displayedDate.value)
|
|
117
|
-
hasTextFieldInput.value = false
|
|
80
|
+
updateDate(displayedDate.value);
|
|
81
|
+
hasTextFieldInput.value = false;
|
|
118
82
|
}
|
|
119
|
-
isTextFieldFocused.value = false
|
|
83
|
+
isTextFieldFocused.value = false;
|
|
120
84
|
}
|
|
121
|
-
|
|
122
85
|
function handleTextFieldEnterKey() {
|
|
123
|
-
handleTextFieldBlur()
|
|
86
|
+
handleTextFieldBlur();
|
|
124
87
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
updateDate(dateString)
|
|
88
|
+
function updateDatePicker(dateString) {
|
|
89
|
+
isMenuOpen.value = false;
|
|
90
|
+
updateDate(dateString);
|
|
129
91
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const dateTime = Datetime().fromString(dateString, undefined, props.locale)
|
|
92
|
+
function updateDate(dateString) {
|
|
93
|
+
const dateTime = Datetime().fromString(dateString, void 0, props.locale);
|
|
133
94
|
if (!dateTime.luxonDateTime.isValid) {
|
|
134
|
-
displayedDate.value = null
|
|
135
|
-
selectedDate.value = null
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
displayedDate.value = selectedDate.value
|
|
95
|
+
displayedDate.value = null;
|
|
96
|
+
selectedDate.value = null;
|
|
97
|
+
} else {
|
|
98
|
+
selectedDate.value = dateTime.toFormat("yyyy-MM-dd", "EN");
|
|
99
|
+
displayedDate.value = selectedDate.value;
|
|
140
100
|
}
|
|
141
|
-
|
|
142
|
-
if (!isTextFieldFocused.value) displayedDate.value = formatDate(displayedDate.value)
|
|
101
|
+
if (!isTextFieldFocused.value) displayedDate.value = formatDate(displayedDate.value);
|
|
143
102
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const dateTime = Datetime().fromString(dateString, undefined, props.locale)
|
|
149
|
-
return dateTime.toFormat(props.format, props.locale)
|
|
103
|
+
function formatDate(dateString) {
|
|
104
|
+
if (!dateString) return null;
|
|
105
|
+
const dateTime = Datetime().fromString(dateString, void 0, props.locale);
|
|
106
|
+
return dateTime.toFormat(props.format, props.locale);
|
|
150
107
|
}
|
|
151
|
-
|
|
152
108
|
function handleTextFieldClear() {
|
|
153
|
-
resetDatePicker()
|
|
109
|
+
resetDatePicker();
|
|
154
110
|
}
|
|
155
|
-
|
|
156
111
|
function resetDatePicker() {
|
|
157
|
-
selectedDate.value = null
|
|
158
|
-
displayedDate.value = null
|
|
112
|
+
selectedDate.value = null;
|
|
113
|
+
displayedDate.value = null;
|
|
159
114
|
}
|
|
160
|
-
|
|
161
115
|
watchEffect(() => {
|
|
162
116
|
if (!isTextFieldFocused.value && selectedDate.value) {
|
|
163
|
-
const dateTime = Datetime().fromString(selectedDate.value,
|
|
164
|
-
displayedDate.value = dateTime.toFormat(props.format, props.locale)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
displayedDate.value = selectedDate.value
|
|
117
|
+
const dateTime = Datetime().fromString(selectedDate.value, void 0, props.locale);
|
|
118
|
+
displayedDate.value = dateTime.toFormat(props.format, props.locale);
|
|
119
|
+
} else {
|
|
120
|
+
displayedDate.value = selectedDate.value;
|
|
168
121
|
}
|
|
169
|
-
})
|
|
170
|
-
|
|
122
|
+
});
|
|
171
123
|
watch(selectedDate, (newValue) => {
|
|
172
|
-
emit(
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
watch(() => props.modelValue, (newValue,oldValue) => {
|
|
124
|
+
emit("update:modelValue", newValue);
|
|
125
|
+
});
|
|
126
|
+
watch(() => props.modelValue, (newValue, oldValue) => {
|
|
176
127
|
if (!oldValue && !newValue && props.defaultDate) {
|
|
177
128
|
if (!oldValue && !newValue && props.defaultDate) {
|
|
178
|
-
let defaultDate
|
|
179
|
-
|
|
129
|
+
let defaultDate = null;
|
|
180
130
|
if (props.defaultDate === true) {
|
|
181
|
-
defaultDate = Datetime().now().toFormat(
|
|
182
|
-
} else if (typeof props.defaultDate ===
|
|
183
|
-
defaultDate = Datetime().now().luxonDateTime
|
|
184
|
-
.plus({ days: Number(props.defaultDate) })
|
|
185
|
-
.toFormat('yyyy-MM-dd');
|
|
131
|
+
defaultDate = Datetime().now().toFormat("yyyy-MM-dd", "EN");
|
|
132
|
+
} else if (typeof props.defaultDate === "string" && /^[+-]?\d+$/.test(props.defaultDate.trim())) {
|
|
133
|
+
defaultDate = Datetime().now().luxonDateTime.plus({ days: Number(props.defaultDate) }).toFormat("yyyy-MM-dd");
|
|
186
134
|
} else {
|
|
187
|
-
const dateTime = Datetime().fromString(props.defaultDate)
|
|
188
|
-
if (dateTime.luxonDateTime.isValid) defaultDate = dateTime.toFormat(
|
|
135
|
+
const dateTime = Datetime().fromString(props.defaultDate);
|
|
136
|
+
if (dateTime.luxonDateTime.isValid) defaultDate = dateTime.toFormat("yyyy-MM-dd");
|
|
189
137
|
}
|
|
190
|
-
|
|
191
138
|
updateDate(defaultDate);
|
|
192
139
|
} else {
|
|
193
140
|
updateDate(newValue ?? null);
|
|
194
141
|
}
|
|
195
142
|
} else {
|
|
196
|
-
updateDate(props.modelValue || null)
|
|
143
|
+
updateDate(props.modelValue || null);
|
|
197
144
|
}
|
|
198
|
-
}, { immediate: true })
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (!props.readonly) isMenuOpen.value = true
|
|
145
|
+
}, { immediate: true });
|
|
146
|
+
function toggleMenuOpen(trigger) {
|
|
147
|
+
if (trigger === "textField" && props.pickerOnly || trigger === "icon" && !props.pickerOnly) {
|
|
148
|
+
if (!props.readonly) isMenuOpen.value = true;
|
|
203
149
|
}
|
|
204
150
|
}
|
|
205
|
-
|
|
206
|
-
const textFieldRef = ref<VTextField>()
|
|
151
|
+
const textFieldRef = ref();
|
|
207
152
|
function validate() {
|
|
208
|
-
textFieldRef.value?.validate()
|
|
153
|
+
textFieldRef.value?.validate();
|
|
209
154
|
}
|
|
210
155
|
function resetValidation() {
|
|
211
|
-
textFieldRef.value?.resetValidation()
|
|
156
|
+
textFieldRef.value?.resetValidation();
|
|
212
157
|
}
|
|
213
|
-
|
|
214
158
|
defineExpose({
|
|
215
|
-
reset
|
|
216
|
-
|
|
159
|
+
reset: resetDatePicker,
|
|
160
|
+
validate,
|
|
161
|
+
resetValidation,
|
|
162
|
+
isValid: textFieldRef.value?.isValid
|
|
163
|
+
});
|
|
217
164
|
</script>
|
|
218
165
|
|
|
219
166
|
<template>
|
|
@@ -257,15 +204,15 @@ defineExpose({
|
|
|
257
204
|
auto-apply
|
|
258
205
|
inline
|
|
259
206
|
:locale="locale"
|
|
260
|
-
:format-locale="
|
|
207
|
+
:format-locale="locale == 'TH' ? th : void 0"
|
|
261
208
|
@update:model-value="updateDatePicker"
|
|
262
209
|
>
|
|
263
|
-
<template #year="{value}" v-if="locale=='TH'">
|
|
264
|
-
{{value+543}}
|
|
210
|
+
<template #year="{ value }" v-if="locale == 'TH'">
|
|
211
|
+
{{value + 543}}
|
|
265
212
|
</template>
|
|
266
|
-
<template #year-overlay-value="{value}" v-if="locale=='TH'">
|
|
267
|
-
{{value+543}}
|
|
213
|
+
<template #year-overlay-value="{ value }" v-if="locale == 'TH'">
|
|
214
|
+
{{value + 543}}
|
|
268
215
|
</template>
|
|
269
216
|
</Datepicker>
|
|
270
217
|
</v-menu>
|
|
271
|
-
</template>
|
|
218
|
+
</template>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { VTextField } from 'vuetify/components/VTextField';
|
|
2
|
+
import '@vuepic/vue-datepicker/dist/main.css';
|
|
3
|
+
import { type dateFormat } from '../../utils/datetime.js';
|
|
4
|
+
interface Props extends /* @vue-ignore */ InstanceType<typeof VTextField['$props']> {
|
|
5
|
+
locale?: 'TH' | 'EN';
|
|
6
|
+
format?: dateFormat | string;
|
|
7
|
+
modelValue?: string | null;
|
|
8
|
+
holiday?: object[] | undefined;
|
|
9
|
+
minDate?: Date | string;
|
|
10
|
+
maxDate?: Date | string;
|
|
11
|
+
pickerOnly?: boolean;
|
|
12
|
+
flow?: ('month' | 'year' | 'calendar' | 'time' | 'minutes' | 'hours' | 'seconds')[];
|
|
13
|
+
rules?: typeof VTextField['rules'];
|
|
14
|
+
defaultDate?: boolean | string;
|
|
15
|
+
}
|
|
16
|
+
declare function resetDatePicker(): void;
|
|
17
|
+
declare function toggleMenuOpen(trigger: string): void;
|
|
18
|
+
declare function validate(): void;
|
|
19
|
+
declare function resetValidation(): void;
|
|
20
|
+
declare var __VLS_25: {
|
|
21
|
+
toggleMenuOpen: typeof toggleMenuOpen;
|
|
22
|
+
activatorProps: Record<string, any>;
|
|
23
|
+
id: import("vue").ComputedRef<string>;
|
|
24
|
+
messagesId: import("vue").ComputedRef<string | undefined>;
|
|
25
|
+
isDirty: import("vue").ComputedRef<boolean>;
|
|
26
|
+
isDisabled: import("vue").ComputedRef<boolean>;
|
|
27
|
+
isReadonly: import("vue").ComputedRef<boolean>;
|
|
28
|
+
isPristine: import("vue").Ref<boolean>;
|
|
29
|
+
isValid: import("vue").ComputedRef<boolean | null>;
|
|
30
|
+
isValidating: import("vue").Ref<boolean>;
|
|
31
|
+
hasDetails: import("vue").Ref<boolean>;
|
|
32
|
+
reset: () => void;
|
|
33
|
+
resetValidation: () => void;
|
|
34
|
+
validate: () => void;
|
|
35
|
+
};
|
|
36
|
+
type __VLS_Slots = {} & {
|
|
37
|
+
append?: (props: typeof __VLS_25) => any;
|
|
38
|
+
};
|
|
39
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
40
|
+
locale: string;
|
|
41
|
+
format: string;
|
|
42
|
+
pickerOnly: boolean;
|
|
43
|
+
flow: () => never[];
|
|
44
|
+
defaultDate: boolean;
|
|
45
|
+
}>>, {
|
|
46
|
+
reset: typeof resetDatePicker;
|
|
47
|
+
validate: typeof validate;
|
|
48
|
+
resetValidation: typeof resetValidation;
|
|
49
|
+
isValid: boolean | null | undefined;
|
|
50
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
51
|
+
"update:modelValue": (...args: any[]) => void;
|
|
52
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
53
|
+
locale: string;
|
|
54
|
+
format: string;
|
|
55
|
+
pickerOnly: boolean;
|
|
56
|
+
flow: () => never[];
|
|
57
|
+
defaultDate: boolean;
|
|
58
|
+
}>>> & Readonly<{
|
|
59
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
60
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
61
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
62
|
+
declare const _default: typeof __VLS_export;
|
|
63
|
+
export default _default;
|
|
64
|
+
type __VLS_TypePropsToOption<T> = {
|
|
65
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
66
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
67
|
+
} : {
|
|
68
|
+
type: import('vue').PropType<T[K]>;
|
|
69
|
+
required: true;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
type __VLS_WithDefaults<P, D> = {
|
|
73
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
74
|
+
default: D[K];
|
|
75
|
+
}> : P[K];
|
|
76
|
+
};
|
|
77
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
78
|
+
new (): {
|
|
79
|
+
$slots: S;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
83
|
+
[K in keyof T]: T[K];
|
|
84
|
+
} : {
|
|
85
|
+
[K in keyof T as K]: T[K];
|
|
86
|
+
}) & {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type dateFormat } from '../../utils/datetime.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
modelValue?: string | null;
|
|
4
|
+
format?: dateFormat | string;
|
|
5
|
+
label?: string;
|
|
6
|
+
enableSeconds?: boolean;
|
|
7
|
+
rules?: typeof import('vuetify/components')['VTextField']['rules'];
|
|
8
|
+
dateRules?: typeof import('vuetify/components')['VTextField']['rules'];
|
|
9
|
+
timeRules?: typeof import('vuetify/components')['VTextField']['rules'];
|
|
10
|
+
dense?: boolean;
|
|
11
|
+
pickerOnly?: boolean;
|
|
12
|
+
minDate?: Date | string;
|
|
13
|
+
maxDate?: Date | string;
|
|
14
|
+
readonly?: boolean;
|
|
15
|
+
locale?: 'TH' | 'EN';
|
|
16
|
+
defaultDate?: boolean | string;
|
|
17
|
+
defaultDateTime?: boolean | string;
|
|
18
|
+
fixedDate?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
+
"update:modelValue": (...args: any[]) => void;
|
|
22
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
23
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
readonly: boolean;
|
|
26
|
+
locale: "TH" | "EN";
|
|
27
|
+
format: dateFormat | string;
|
|
28
|
+
dense: boolean;
|
|
29
|
+
pickerOnly: boolean;
|
|
30
|
+
defaultDate: boolean | string;
|
|
31
|
+
enableSeconds: boolean;
|
|
32
|
+
defaultDateTime: boolean | string;
|
|
33
|
+
fixedDate: boolean;
|
|
34
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
|
+
declare const _default: typeof __VLS_export;
|
|
36
|
+
export default _default;
|