@weconstudio/nuxt 0.0.0-stage → 1.72.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/LICENSE +1 -0
- package/README.md +115 -2
- package/dist/module.d.mts +7 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +250 -0
- package/dist/runtime/components/We/Autocomplete.d.vue.ts +13 -0
- package/dist/runtime/components/We/Autocomplete.vue +91 -0
- package/dist/runtime/components/We/Autocomplete.vue.d.ts +13 -0
- package/dist/runtime/components/We/BoldText.d.vue.ts +17 -0
- package/dist/runtime/components/We/BoldText.vue +29 -0
- package/dist/runtime/components/We/BoldText.vue.d.ts +17 -0
- package/dist/runtime/components/We/ColorPicker.d.vue.ts +11 -0
- package/dist/runtime/components/We/ColorPicker.vue +199 -0
- package/dist/runtime/components/We/ColorPicker.vue.d.ts +11 -0
- package/dist/runtime/components/We/ConfirmDialog.d.vue.ts +104 -0
- package/dist/runtime/components/We/ConfirmDialog.vue +143 -0
- package/dist/runtime/components/We/ConfirmDialog.vue.d.ts +104 -0
- package/dist/runtime/components/We/Datatable.d.vue.ts +40 -0
- package/dist/runtime/components/We/Datatable.vue +87 -0
- package/dist/runtime/components/We/Datatable.vue.d.ts +40 -0
- package/dist/runtime/components/We/DatatableInternal.d.vue.ts +194 -0
- package/dist/runtime/components/We/DatatableInternal.vue +638 -0
- package/dist/runtime/components/We/DatatableInternal.vue.d.ts +194 -0
- package/dist/runtime/components/We/DatePicker.d.vue.ts +51 -0
- package/dist/runtime/components/We/DatePicker.vue +901 -0
- package/dist/runtime/components/We/DatePicker.vue.d.ts +51 -0
- package/dist/runtime/components/We/Dt/Actions.d.vue.ts +51 -0
- package/dist/runtime/components/We/Dt/Actions.vue +106 -0
- package/dist/runtime/components/We/Dt/Actions.vue.d.ts +51 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.d.vue.ts +8 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.vue +26 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.vue.d.ts +8 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.d.vue.ts +17 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.vue +60 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.vue.d.ts +17 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.d.vue.ts +16 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.vue +47 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.vue.d.ts +16 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.d.vue.ts +7 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.vue +35 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.vue.d.ts +7 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.d.vue.ts +18 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.vue +68 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.vue.d.ts +18 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.d.vue.ts +19 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.vue +65 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.vue.d.ts +19 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.d.vue.ts +28 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.vue +140 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.vue.d.ts +28 -0
- package/dist/runtime/components/We/Dt/Filter.d.vue.ts +7 -0
- package/dist/runtime/components/We/Dt/Filter.vue +234 -0
- package/dist/runtime/components/We/Dt/Filter.vue.d.ts +7 -0
- package/dist/runtime/components/We/Dt/Filters.d.vue.ts +6 -0
- package/dist/runtime/components/We/Dt/Filters.vue +24 -0
- package/dist/runtime/components/We/Dt/Filters.vue.d.ts +6 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.d.vue.ts +12 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.vue +23 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.vue.d.ts +12 -0
- package/dist/runtime/components/We/Dt/SelectFilter.d.vue.ts +60 -0
- package/dist/runtime/components/We/Dt/SelectFilter.vue +333 -0
- package/dist/runtime/components/We/Dt/SelectFilter.vue.d.ts +60 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.d.vue.ts +43 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.vue +127 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.vue.d.ts +43 -0
- package/dist/runtime/components/We/Dt/dt.types.d.ts +8 -0
- package/dist/runtime/components/We/EndpointSwitcher.d.vue.ts +12 -0
- package/dist/runtime/components/We/EndpointSwitcher.vue +256 -0
- package/dist/runtime/components/We/EndpointSwitcher.vue.d.ts +12 -0
- package/dist/runtime/components/We/Import.d.vue.ts +118 -0
- package/dist/runtime/components/We/Import.vue +730 -0
- package/dist/runtime/components/We/Import.vue.d.ts +118 -0
- package/dist/runtime/components/We/ImportDefaultValues.d.vue.ts +3666 -0
- package/dist/runtime/components/We/ImportDefaultValues.vue +115 -0
- package/dist/runtime/components/We/ImportDefaultValues.vue.d.ts +3666 -0
- package/dist/runtime/components/We/ImportMatchColumns.d.vue.ts +66 -0
- package/dist/runtime/components/We/ImportMatchColumns.vue +172 -0
- package/dist/runtime/components/We/ImportMatchColumns.vue.d.ts +66 -0
- package/dist/runtime/components/We/ImportPreviewResults.d.vue.ts +38 -0
- package/dist/runtime/components/We/ImportPreviewResults.vue +165 -0
- package/dist/runtime/components/We/ImportPreviewResults.vue.d.ts +38 -0
- package/dist/runtime/components/We/ImportSelectStart.d.vue.ts +47 -0
- package/dist/runtime/components/We/ImportSelectStart.vue +106 -0
- package/dist/runtime/components/We/ImportSelectStart.vue.d.ts +47 -0
- package/dist/runtime/components/We/Notification.d.vue.ts +7 -0
- package/dist/runtime/components/We/Notification.vue +49 -0
- package/dist/runtime/components/We/Notification.vue.d.ts +7 -0
- package/dist/runtime/components/We/S3Dropzone.d.vue.ts +17 -0
- package/dist/runtime/components/We/S3Dropzone.vue +527 -0
- package/dist/runtime/components/We/S3Dropzone.vue.d.ts +17 -0
- package/dist/runtime/components/We/Select.d.vue.ts +39 -0
- package/dist/runtime/components/We/Select.vue +354 -0
- package/dist/runtime/components/We/Select.vue.d.ts +39 -0
- package/dist/runtime/components/We/TipTap.d.vue.ts +26 -0
- package/dist/runtime/components/We/TipTap.vue +362 -0
- package/dist/runtime/components/We/TipTap.vue.d.ts +26 -0
- package/dist/runtime/components/We/datatable.props.d.ts +57 -0
- package/dist/runtime/components/We/datatable.props.js +60 -0
- package/dist/runtime/composables/datatable/useAutoFillHeight.d.ts +31 -0
- package/dist/runtime/composables/datatable/useAutoFillHeight.js +57 -0
- package/dist/runtime/composables/datatable/useDataTable.d.ts +33 -0
- package/dist/runtime/composables/datatable/useDataTable.js +161 -0
- package/dist/runtime/composables/datatable/useDatatableColumns.d.ts +12 -0
- package/dist/runtime/composables/datatable/useDatatableColumns.js +96 -0
- package/dist/runtime/composables/useApi.d.ts +56 -0
- package/dist/runtime/composables/useApi.js +230 -0
- package/dist/runtime/composables/useApiFetch.d.ts +2 -0
- package/dist/runtime/composables/useApiFetch.js +9 -0
- package/dist/runtime/composables/useApiUrl.d.ts +10 -0
- package/dist/runtime/composables/useApiUrl.js +37 -0
- package/dist/runtime/composables/useAuth.d.ts +9 -0
- package/dist/runtime/composables/useAuth.js +22 -0
- package/dist/runtime/composables/useBus.d.ts +8 -0
- package/dist/runtime/composables/useBus.js +18 -0
- package/dist/runtime/composables/useDateRangePresets.d.ts +21 -0
- package/dist/runtime/composables/useDateRangePresets.js +90 -0
- package/dist/runtime/composables/useForm.d.ts +29 -0
- package/dist/runtime/composables/useForm.js +74 -0
- package/dist/runtime/composables/useFormLock.d.ts +11 -0
- package/dist/runtime/composables/useFormLock.js +8 -0
- package/dist/runtime/composables/useFormWrapper.d.ts +16 -0
- package/dist/runtime/composables/useFormWrapper.js +36 -0
- package/dist/runtime/composables/useImportJob.d.ts +55 -0
- package/dist/runtime/composables/useImportJob.js +94 -0
- package/dist/runtime/composables/useLux.d.ts +1 -0
- package/dist/runtime/composables/useLux.js +8 -0
- package/dist/runtime/composables/useNotify.d.ts +12 -0
- package/dist/runtime/composables/useNotify.js +24 -0
- package/dist/runtime/composables/usePaginatedFetch.d.ts +24 -0
- package/dist/runtime/composables/usePaginatedFetch.js +154 -0
- package/dist/runtime/composables/useServerErrors.d.ts +16 -0
- package/dist/runtime/composables/useServerErrors.js +60 -0
- package/dist/runtime/composables/useValidators.d.ts +18 -0
- package/dist/runtime/composables/useValidators.js +56 -0
- package/dist/runtime/generator/code/dt.d.ts +8 -0
- package/dist/runtime/generator/code/dt.js +97 -0
- package/dist/runtime/generator/code/edit.d.ts +4 -0
- package/dist/runtime/generator/code/edit.js +41 -0
- package/dist/runtime/generator/code/form.d.ts +6 -0
- package/dist/runtime/generator/code/form.js +229 -0
- package/dist/runtime/generator/code/i18n.d.ts +5 -0
- package/dist/runtime/generator/code/i18n.js +43 -0
- package/dist/runtime/generator/code/index.d.ts +11 -0
- package/dist/runtime/generator/code/index.js +90 -0
- package/dist/runtime/generator/components/CodeSnippet.d.vue.ts +14 -0
- package/dist/runtime/generator/components/CodeSnippet.vue +49 -0
- package/dist/runtime/generator/components/CodeSnippet.vue.d.ts +14 -0
- package/dist/runtime/generator/components/Configuration.d.vue.ts +16 -0
- package/dist/runtime/generator/components/Configuration.vue +154 -0
- package/dist/runtime/generator/components/Configuration.vue.d.ts +16 -0
- package/dist/runtime/generator/components/GeneratorPage.d.vue.ts +50 -0
- package/dist/runtime/generator/components/GeneratorPage.vue +226 -0
- package/dist/runtime/generator/components/GeneratorPage.vue.d.ts +50 -0
- package/dist/runtime/generator/fs.d.ts +16 -0
- package/dist/runtime/generator/fs.js +79 -0
- package/dist/runtime/generator/index.d.vue.ts +52 -0
- package/dist/runtime/generator/index.vue +17 -0
- package/dist/runtime/generator/index.vue.d.ts +52 -0
- package/dist/runtime/internals/api.d.ts +3 -0
- package/dist/runtime/internals/api.js +16 -0
- package/dist/runtime/internals/bus.d.ts +1 -0
- package/dist/runtime/internals/bus.js +2 -0
- package/dist/runtime/internals/dt.d.ts +24 -0
- package/dist/runtime/internals/dt.js +57 -0
- package/dist/runtime/lang/en.json +211 -0
- package/dist/runtime/lang/it.json +211 -0
- package/dist/runtime/mixins/formValidator.d.ts +38 -0
- package/dist/runtime/mixins/formValidator.js +118 -0
- package/dist/runtime/plugins/api-legacy.d.ts +76 -0
- package/dist/runtime/plugins/api-legacy.js +11 -0
- package/dist/runtime/plugins/auth-legacy.d.ts +22 -0
- package/dist/runtime/plugins/auth-legacy.js +14 -0
- package/dist/runtime/plugins/bus-legacy.d.ts +6 -0
- package/dist/runtime/plugins/bus-legacy.js +9 -0
- package/dist/runtime/plugins/notify-legacy.d.ts +25 -0
- package/dist/runtime/plugins/notify-legacy.js +35 -0
- package/dist/runtime/plugins/portal.d.ts +2 -0
- package/dist/runtime/plugins/portal.js +5 -0
- package/dist/runtime/plugins/update-sanctum-app-config.d.ts +2 -0
- package/dist/runtime/plugins/update-sanctum-app-config.js +44 -0
- package/dist/runtime/plugins/vuetify-nuxt-icon.d.ts +4 -0
- package/dist/runtime/plugins/vuetify-nuxt-icon.js +30 -0
- package/dist/runtime/types/app-config.d.ts +24 -0
- package/dist/runtime/types/app-config.js +1 -0
- package/dist/runtime/types/icons.d.ts +82 -0
- package/dist/runtime/types/icons.js +84 -0
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/types/module-options.d.ts +29 -0
- package/dist/runtime/types/module-options.js +0 -0
- package/dist/runtime/types/runtime-hooks.d.ts +17 -0
- package/dist/runtime/types/runtime-hooks.js +1 -0
- package/dist/runtime/utils/color.d.ts +10 -0
- package/dist/runtime/utils/color.js +38 -0
- package/dist/runtime/utils/file.d.ts +17 -0
- package/dist/runtime/utils/file.js +108 -0
- package/dist/runtime/utils/format.d.ts +1 -0
- package/dist/runtime/utils/format.js +14 -0
- package/dist/runtime/utils/make-enum.d.ts +15 -0
- package/dist/runtime/utils/make-enum.js +27 -0
- package/dist/runtime/utils/mergeDefaults.d.ts +1 -0
- package/dist/runtime/utils/mergeDefaults.js +18 -0
- package/dist/runtime/utils/object-to-formdata.d.ts +10 -0
- package/dist/runtime/utils/object-to-formdata.js +82 -0
- package/dist/runtime/utils/uuid.d.ts +1 -0
- package/dist/runtime/utils/uuid.js +9 -0
- package/dist/types.d.mts +9 -0
- package/package.json +92 -4
|
@@ -0,0 +1,901 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useHead, useI18n, useLux } from "#imports";
|
|
3
|
+
import VueDatePicker from "@vuepic/vue-datepicker";
|
|
4
|
+
import { usePointerSwipe } from "@vueuse/core";
|
|
5
|
+
import { DateTime } from "luxon";
|
|
6
|
+
import { computed, nextTick, onScopeDispose, ref, toRaw, useAttrs, useId, useSlots, useTemplateRef, watch } from "vue";
|
|
7
|
+
import { useDefaults, useTheme } from "vuetify";
|
|
8
|
+
import { useFormLock } from "../../composables/useFormLock";
|
|
9
|
+
import { textColorOn } from "../../utils/color";
|
|
10
|
+
import "@vuepic/vue-datepicker/dist/main.css";
|
|
11
|
+
defineOptions({ inheritAttrs: false });
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
modelValue: {
|
|
14
|
+
type: [String, Array, null],
|
|
15
|
+
required: false,
|
|
16
|
+
default: void 0
|
|
17
|
+
},
|
|
18
|
+
type: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: false,
|
|
21
|
+
default: "date"
|
|
22
|
+
},
|
|
23
|
+
// Oggetto per la configurazione di @vuepic/vue-datepicker, che lo normalizza
|
|
24
|
+
// da sé: `{ maxRange: 6 }` limita l'ampiezza selezionabile a 7 giorni, perché
|
|
25
|
+
// il valore è la differenza fra gli estremi. Il booleano resta la forma breve.
|
|
26
|
+
range: {
|
|
27
|
+
type: [Boolean, Object],
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
multiCalendars: {
|
|
31
|
+
type: [Boolean, Number, String],
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
showSeconds: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
displayFormat: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: void 0
|
|
41
|
+
},
|
|
42
|
+
modelFormat: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: void 0
|
|
45
|
+
},
|
|
46
|
+
min: {
|
|
47
|
+
type: [String, Date],
|
|
48
|
+
default: null
|
|
49
|
+
},
|
|
50
|
+
max: {
|
|
51
|
+
type: [String, Date],
|
|
52
|
+
default: null
|
|
53
|
+
},
|
|
54
|
+
minDate: {
|
|
55
|
+
type: [String, Date],
|
|
56
|
+
default: null
|
|
57
|
+
},
|
|
58
|
+
maxDate: {
|
|
59
|
+
type: [String, Date],
|
|
60
|
+
default: null
|
|
61
|
+
},
|
|
62
|
+
minTime: {
|
|
63
|
+
type: [String, Date],
|
|
64
|
+
default: null
|
|
65
|
+
},
|
|
66
|
+
maxTime: {
|
|
67
|
+
type: [String, Date],
|
|
68
|
+
default: null
|
|
69
|
+
},
|
|
70
|
+
startDate: {
|
|
71
|
+
type: [String, Date],
|
|
72
|
+
default: null
|
|
73
|
+
},
|
|
74
|
+
locale: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: "it"
|
|
77
|
+
},
|
|
78
|
+
monthChangeOnArrows: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: true
|
|
81
|
+
},
|
|
82
|
+
position: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: "left"
|
|
85
|
+
},
|
|
86
|
+
clearable: Boolean,
|
|
87
|
+
rules: {
|
|
88
|
+
type: Array,
|
|
89
|
+
default: () => []
|
|
90
|
+
},
|
|
91
|
+
disableDate: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false
|
|
94
|
+
},
|
|
95
|
+
allowedDates: {
|
|
96
|
+
type: Array,
|
|
97
|
+
default: void 0
|
|
98
|
+
},
|
|
99
|
+
disabledDates: {
|
|
100
|
+
type: Array,
|
|
101
|
+
default: () => void 0
|
|
102
|
+
},
|
|
103
|
+
presetDates: {
|
|
104
|
+
type: Array,
|
|
105
|
+
default: () => void 0
|
|
106
|
+
},
|
|
107
|
+
color: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: "primary"
|
|
110
|
+
},
|
|
111
|
+
// Colore del testo sul giorno selezionato: vince su tutto. Se non passata lo calcoliamo,
|
|
112
|
+
// `on-<colore>` per i colori del tema e bianco o nero sugli altri secondo la luminanza.
|
|
113
|
+
textColor: {
|
|
114
|
+
type: String,
|
|
115
|
+
default: void 0
|
|
116
|
+
},
|
|
117
|
+
readonly: {
|
|
118
|
+
type: Boolean,
|
|
119
|
+
default: null
|
|
120
|
+
},
|
|
121
|
+
disabled: {
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: null
|
|
124
|
+
},
|
|
125
|
+
// Come si apre il calendario: `menu` (popover sotto il campo) o `bottom-sheet`.
|
|
126
|
+
mode: {
|
|
127
|
+
type: String,
|
|
128
|
+
default: "menu",
|
|
129
|
+
validator: (value) => ["menu", "bottom-sheet"].includes(value)
|
|
130
|
+
},
|
|
131
|
+
// Titolo del bottom sheet; senza, quello del campo (`label`).
|
|
132
|
+
title: {
|
|
133
|
+
type: String,
|
|
134
|
+
default: void 0
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
138
|
+
const { current: currentTheme } = useTheme();
|
|
139
|
+
const { t } = useI18n();
|
|
140
|
+
const isDark = computed(() => currentTheme.value.dark);
|
|
141
|
+
const { isReadonly, isDisabled } = useFormLock(props);
|
|
142
|
+
const isLocked = computed(() => isReadonly.value || isDisabled.value);
|
|
143
|
+
const slots = useSlots();
|
|
144
|
+
const hasActivatorSlot = computed(() => !!slots.activator);
|
|
145
|
+
const defaultedProps = useDefaults(props, "WeDatePicker");
|
|
146
|
+
const sheet = computed(() => defaultedProps.mode === "bottom-sheet");
|
|
147
|
+
const sheetOpen = ref(false);
|
|
148
|
+
const SHEET_CLOSE_DRAG = 80;
|
|
149
|
+
const sheetHandle = useTemplateRef("sheetHandle");
|
|
150
|
+
const { isSwiping: isDraggingHandle, distanceY } = usePointerSwipe(sheetHandle, {
|
|
151
|
+
threshold: 0,
|
|
152
|
+
onSwipeEnd: (_, direction) => {
|
|
153
|
+
if (direction === "down" && -distanceY.value > SHEET_CLOSE_DRAG) {
|
|
154
|
+
sheetOpen.value = false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const sheetDragStyle = computed(() => isDraggingHandle.value ? { transform: `translateY(${Math.max(0, -distanceY.value)}px)`, transition: "none" } : void 0);
|
|
159
|
+
const splitMenu = computed(() => sheet.value && !!props.presetDates?.length);
|
|
160
|
+
const menuMode = ref("calendar");
|
|
161
|
+
const sheetValue = ref(null);
|
|
162
|
+
const PRESET_LIST_MAX_HEIGHT = 7.5 * 69;
|
|
163
|
+
watch(sheetOpen, (open) => {
|
|
164
|
+
menuMode.value = "calendar";
|
|
165
|
+
if (open) {
|
|
166
|
+
sheetValue.value = props.modelValue;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
function applySheet() {
|
|
170
|
+
emit("update:modelValue", sheetValue.value);
|
|
171
|
+
sheetOpen.value = false;
|
|
172
|
+
}
|
|
173
|
+
const attrs = useAttrs();
|
|
174
|
+
const inlineAttrs = () => Object.fromEntries(Object.entries(attrs).filter(([key]) => !/^(?:class|style)$|^on[A-Z]/.test(key)));
|
|
175
|
+
const resolvedColor = computed(() => props.color || "primary");
|
|
176
|
+
const colorClass = computed(() => `we-dp-color--${resolvedColor.value.replace(/[^\w-]/g, "-")}`);
|
|
177
|
+
const menuClass = `we-dp-menu--${useId()}`;
|
|
178
|
+
const colorCss = computed(() => {
|
|
179
|
+
const color = resolvedColor.value;
|
|
180
|
+
const isThemeColor = color in (currentTheme.value?.colors ?? {});
|
|
181
|
+
const base = isThemeColor ? `rgb(var(--v-theme-${color}))` : color;
|
|
182
|
+
const text = isThemeColor ? `rgb(var(--v-theme-on-${color}))` : textColorOn(color);
|
|
183
|
+
const tint = (alpha) => isThemeColor ? `rgba(var(--v-theme-${color}), ${alpha})` : `color-mix(in srgb, ${color} ${alpha * 100}%, transparent)`;
|
|
184
|
+
const soft = tint(0.12);
|
|
185
|
+
const selector = `.${colorClass.value}`.repeat(3);
|
|
186
|
+
const selectedHover = [".dp__active_date", ".dp__range_start", ".dp__range_end"].map((cell) => `${selector} ${cell}:hover`).join(",");
|
|
187
|
+
return `${selector}{--dp-primary-color:var(--we-dp-color, ${base});--dp-primary-text-color:var(--we-dp-text-color, ${text});--dp-primary-disabled-color:${tint(0.5)};--dp-range-between-dates-background-color:var(--we-dp-tint, ${soft});--dp-hover-color:var(--we-dp-tint, ${soft});--dp-hover-text-color:var(--dp-text-color);}${selectedHover}{background:var(--we-dp-color-dark, color-mix(in srgb, var(--dp-primary-color) 85%, black));color:var(--dp-primary-text-color);}`;
|
|
188
|
+
});
|
|
189
|
+
useHead(() => ({
|
|
190
|
+
style: [
|
|
191
|
+
{ key: colorClass.value, innerHTML: colorCss.value },
|
|
192
|
+
...props.textColor ? [{ key: menuClass, innerHTML: `.${menuClass}{--we-dp-text-color:${props.textColor};}` }] : []
|
|
193
|
+
]
|
|
194
|
+
}));
|
|
195
|
+
const vueDatePickerClass = computed(() => {
|
|
196
|
+
return {
|
|
197
|
+
"vue-date-picker": true,
|
|
198
|
+
"dp_main--reverse": hasActivatorSlot.value,
|
|
199
|
+
[colorClass.value]: true
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
const datePickerUi = computed(() => {
|
|
203
|
+
const ui = attrs.ui ?? {};
|
|
204
|
+
const menu = [ui.menu ?? []].flat();
|
|
205
|
+
return { ...ui, menu: [...menu, colorClass.value, "we-dp-menu", menuClass] };
|
|
206
|
+
});
|
|
207
|
+
const format = computed(() => {
|
|
208
|
+
if (props.displayFormat) {
|
|
209
|
+
return props.displayFormat;
|
|
210
|
+
}
|
|
211
|
+
const { type, showSeconds } = props;
|
|
212
|
+
const timeFormat = showSeconds ? "HH:mm:ss" : "HH:mm";
|
|
213
|
+
switch (type) {
|
|
214
|
+
case "datetime":
|
|
215
|
+
return `dd/MM/yyyy ${timeFormat}`;
|
|
216
|
+
case "time":
|
|
217
|
+
return timeFormat;
|
|
218
|
+
case "month":
|
|
219
|
+
return "MM/yyyy";
|
|
220
|
+
case "year":
|
|
221
|
+
return "yyyy";
|
|
222
|
+
default:
|
|
223
|
+
return "dd/MM/yyyy";
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
const isTypeTime = computed(() => props.type === "time");
|
|
227
|
+
const isTypeDate = computed(() => props.type === "date");
|
|
228
|
+
const isTypeMonth = computed(() => props.type === "month");
|
|
229
|
+
const isTypeYear = computed(() => props.type === "year");
|
|
230
|
+
const icon = computed(() => ({
|
|
231
|
+
time: "$time",
|
|
232
|
+
datetime: "$datetime"
|
|
233
|
+
})[props.type] || "$calendar");
|
|
234
|
+
const rangeEnabled = computed(() => typeof props.range === "object" ? props.range.enabled !== false : !!props.range);
|
|
235
|
+
const multiCalendars = computed(() => {
|
|
236
|
+
if (rangeEnabled.value) {
|
|
237
|
+
return props.multiCalendars == false ? false : 2;
|
|
238
|
+
}
|
|
239
|
+
return props.multiCalendars;
|
|
240
|
+
});
|
|
241
|
+
const $rules = computed(() => {
|
|
242
|
+
return (props.rules ?? []).map((r) => {
|
|
243
|
+
return () => {
|
|
244
|
+
return r(props.modelValue);
|
|
245
|
+
};
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
const modelFormat = computed(() => {
|
|
249
|
+
if (props.modelFormat) {
|
|
250
|
+
return props.modelFormat;
|
|
251
|
+
}
|
|
252
|
+
const { type, showSeconds } = props;
|
|
253
|
+
const timeFormat = showSeconds ? ":ss" : "";
|
|
254
|
+
switch (type) {
|
|
255
|
+
case "datetime":
|
|
256
|
+
return "iso";
|
|
257
|
+
// `yyyy-MM-dd HH:mm${timeFormat}`
|
|
258
|
+
case "time":
|
|
259
|
+
return `HH:mm${timeFormat}`;
|
|
260
|
+
case "month":
|
|
261
|
+
return "yyyy-MM";
|
|
262
|
+
case "year":
|
|
263
|
+
return "yyyy";
|
|
264
|
+
default:
|
|
265
|
+
return "yyyy-MM-dd";
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
const { $lux, $lp } = useLux();
|
|
269
|
+
const displayValue = computed(() => {
|
|
270
|
+
if (!props.modelValue) {
|
|
271
|
+
return "";
|
|
272
|
+
}
|
|
273
|
+
return [props.modelValue].flat().map((value) => $lux(value, format.value, modelFormat.value)).join(" \u2192 ");
|
|
274
|
+
});
|
|
275
|
+
const dpRef = ref(null);
|
|
276
|
+
const arrowLeft = ref(void 0);
|
|
277
|
+
let arrowFrame = null;
|
|
278
|
+
const datePickerConfig = computed(() => ({ arrowLeft: arrowLeft.value, ...attrs.config ?? {} }));
|
|
279
|
+
function activatorEl() {
|
|
280
|
+
const wrapper = dpRef.value?.$el?.querySelector(":scope > div");
|
|
281
|
+
return wrapper?.firstElementChild ?? wrapper;
|
|
282
|
+
}
|
|
283
|
+
function syncArrowLeft() {
|
|
284
|
+
const menu = document.querySelector(`.${menuClass}`);
|
|
285
|
+
const activator = activatorEl();
|
|
286
|
+
if (!menu || !activator) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const menuRect = menu.getBoundingClientRect();
|
|
290
|
+
const activatorRect = activator.getBoundingClientRect();
|
|
291
|
+
if (!menuRect.width || !activatorRect.width) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
arrowLeft.value = `${activatorRect.left + activatorRect.width / 2 - menuRect.left}px`;
|
|
295
|
+
const field = activator.querySelector(".v-input__control");
|
|
296
|
+
const inset = field ? activatorRect.bottom - field.getBoundingClientRect().bottom : 0;
|
|
297
|
+
menu.style.setProperty("--we-dp-activator-inset", `${inset}px`);
|
|
298
|
+
}
|
|
299
|
+
function scheduleArrowSync() {
|
|
300
|
+
if (arrowFrame || typeof window === "undefined") {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
arrowFrame = window.requestAnimationFrame(() => {
|
|
304
|
+
arrowFrame = null;
|
|
305
|
+
syncArrowLeft();
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
onScopeDispose(() => {
|
|
309
|
+
if (arrowFrame) {
|
|
310
|
+
window.cancelAnimationFrame(arrowFrame);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
watch(isLocked, (locked) => {
|
|
314
|
+
if (locked) {
|
|
315
|
+
dpRef.value?.closeMenu();
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
function blockWhenLocked(e) {
|
|
319
|
+
if (!isLocked.value) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (e.type === "keydown" && e.key !== "Backspace") {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
e.preventDefault();
|
|
326
|
+
e.stopImmediatePropagation();
|
|
327
|
+
}
|
|
328
|
+
function closeMenuOnEscape(e, isMenuOpen, closeMenu) {
|
|
329
|
+
if (!isMenuOpen) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
e.stopPropagation();
|
|
333
|
+
closeMenu();
|
|
334
|
+
}
|
|
335
|
+
function fromDatePickerModel(datePickerVal) {
|
|
336
|
+
if (!datePickerVal) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
function convert(value) {
|
|
340
|
+
const outputFormat = modelFormat.value;
|
|
341
|
+
const inputFormat = void 0;
|
|
342
|
+
if (isTypeTime.value) {
|
|
343
|
+
const { hours, minutes, seconds } = value;
|
|
344
|
+
value = DateTime.fromObject({ hour: hours, minute: minutes, second: seconds }).setZone("UTC");
|
|
345
|
+
}
|
|
346
|
+
if (isTypeMonth.value) {
|
|
347
|
+
const { month, year } = value;
|
|
348
|
+
return DateTime.fromObject({ month: month + 1, year }).toFormat("yyyy-MM");
|
|
349
|
+
}
|
|
350
|
+
if (isTypeYear.value) {
|
|
351
|
+
return DateTime.fromObject({ year: value }).toFormat(outputFormat);
|
|
352
|
+
}
|
|
353
|
+
return $lux(value, outputFormat, inputFormat);
|
|
354
|
+
}
|
|
355
|
+
if (Array.isArray(datePickerVal)) {
|
|
356
|
+
return datePickerVal.map(convert);
|
|
357
|
+
}
|
|
358
|
+
return convert(datePickerVal);
|
|
359
|
+
}
|
|
360
|
+
function toDatePickerModel(modelVal) {
|
|
361
|
+
if (!modelVal) {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
function convert(value) {
|
|
365
|
+
if (isTypeTime.value) {
|
|
366
|
+
const luxDateTime = $lp(value, modelFormat.value);
|
|
367
|
+
return {
|
|
368
|
+
hours: luxDateTime.hour,
|
|
369
|
+
minutes: luxDateTime.minute,
|
|
370
|
+
seconds: luxDateTime.second
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
if (isTypeMonth.value) {
|
|
374
|
+
const luxDate = DateTime.fromFormat(value, "yyyy-MM");
|
|
375
|
+
return { month: luxDate.month - 1, year: luxDate.year };
|
|
376
|
+
}
|
|
377
|
+
if (isTypeYear.value) {
|
|
378
|
+
return DateTime.fromFormat(String(value), modelFormat.value).year;
|
|
379
|
+
}
|
|
380
|
+
return value;
|
|
381
|
+
}
|
|
382
|
+
if (Array.isArray(modelVal)) {
|
|
383
|
+
return modelVal.map(convert);
|
|
384
|
+
}
|
|
385
|
+
return convert(modelVal);
|
|
386
|
+
}
|
|
387
|
+
const datePickerModelValue = computed({
|
|
388
|
+
get() {
|
|
389
|
+
return toDatePickerModel(sheet.value ? sheetValue.value : props.modelValue);
|
|
390
|
+
},
|
|
391
|
+
set(value) {
|
|
392
|
+
if (sheet.value) {
|
|
393
|
+
sheetValue.value = fromDatePickerModel(value);
|
|
394
|
+
} else {
|
|
395
|
+
emit("update:modelValue", fromDatePickerModel(value));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
const timePickerAttrs = computed(() => {
|
|
400
|
+
return {
|
|
401
|
+
enableTimePicker: !isTypeDate.value && !isTypeMonth.value && !isTypeYear.value,
|
|
402
|
+
timePickerInline: !isTypeTime.value,
|
|
403
|
+
timePicker: isTypeTime.value,
|
|
404
|
+
monthPicker: isTypeMonth.value,
|
|
405
|
+
yearPicker: isTypeYear.value,
|
|
406
|
+
enableSeconds: props.showSeconds
|
|
407
|
+
};
|
|
408
|
+
});
|
|
409
|
+
const minMaxAttrs = computed(() => {
|
|
410
|
+
const startDate = props.startDate ?? props.min ?? props.minDate ?? props.modelValue;
|
|
411
|
+
return {
|
|
412
|
+
minDate: props.min ?? props.minDate,
|
|
413
|
+
maxDate: props.max ?? props.maxDate,
|
|
414
|
+
minTime: toDatePickerModel(props.minTime),
|
|
415
|
+
maxTime: toDatePickerModel(props.maxTime),
|
|
416
|
+
startDate: Array.isArray(startDate) ? startDate[0] : startDate
|
|
417
|
+
};
|
|
418
|
+
});
|
|
419
|
+
const allowedDisabledDates = computed(() => {
|
|
420
|
+
const allowedDates = props.allowedDates ?? (props.disableDate && typeof props.modelValue === "string") ? [props.modelValue] : void 0;
|
|
421
|
+
return {
|
|
422
|
+
allowedDates,
|
|
423
|
+
disabledDates: props.disabledDates
|
|
424
|
+
};
|
|
425
|
+
});
|
|
426
|
+
const pickerProps = computed(() => ({
|
|
427
|
+
format: format.value,
|
|
428
|
+
multiCalendars: multiCalendars.value,
|
|
429
|
+
locale: props.locale,
|
|
430
|
+
range: props.range,
|
|
431
|
+
monthChangeOnArrows: props.monthChangeOnArrows,
|
|
432
|
+
autoApply: true,
|
|
433
|
+
teleport: true,
|
|
434
|
+
dark: isDark.value,
|
|
435
|
+
...minMaxAttrs.value,
|
|
436
|
+
...timePickerAttrs.value,
|
|
437
|
+
...allowedDisabledDates.value
|
|
438
|
+
}));
|
|
439
|
+
function handleClear() {
|
|
440
|
+
emit("update:modelValue", null);
|
|
441
|
+
}
|
|
442
|
+
const sheetCard = useTemplateRef("sheetCard");
|
|
443
|
+
function closeOtherOverlay({ open, overlay }) {
|
|
444
|
+
if (!open) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
sheetCard.value?.$el.querySelectorAll(`.dp__month_year_select:has(+ .dp__overlay):not([data-dp-element="overlay-${overlay}"])`).forEach((button) => button.click());
|
|
448
|
+
}
|
|
449
|
+
const maskInput = computed(() => {
|
|
450
|
+
const mask = format.value.replaceAll(/[a-z]/gi, "#");
|
|
451
|
+
if (rangeEnabled.value) {
|
|
452
|
+
return `${mask} - ${mask}`;
|
|
453
|
+
}
|
|
454
|
+
return mask;
|
|
455
|
+
});
|
|
456
|
+
function checkValidMask(value, mask) {
|
|
457
|
+
if (!value || !mask) {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
const regexPattern = mask.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/#/g, "\\d");
|
|
461
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
462
|
+
return regex.test(value);
|
|
463
|
+
}
|
|
464
|
+
function handleOnInput(value, fn) {
|
|
465
|
+
const isValid = checkValidMask(value, maskInput.value);
|
|
466
|
+
if (isValid) {
|
|
467
|
+
fn(value);
|
|
468
|
+
if (isTypeTime.value || props.type === "datetime") {
|
|
469
|
+
nextTick(() => fn(value));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
const $presetDates = computed(() => {
|
|
474
|
+
if (!props.presetDates) {
|
|
475
|
+
return void 0;
|
|
476
|
+
}
|
|
477
|
+
return props.presetDates.map((pd) => {
|
|
478
|
+
return {
|
|
479
|
+
...pd,
|
|
480
|
+
slot: pd.slot || "preset-date-range-button"
|
|
481
|
+
};
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
function modeButtonProps(mode) {
|
|
485
|
+
return menuMode.value === mode ? { active: false, variant: "flat", color: resolvedColor.value } : { active: false, variant: "text" };
|
|
486
|
+
}
|
|
487
|
+
function presetSubtitle([start, end]) {
|
|
488
|
+
if ($lux(start, "yyyy-MM-dd") === $lux(end, "yyyy-MM-dd")) {
|
|
489
|
+
return `${$lp(start).setLocale(props.locale).toFormat("ccc")} ${$lux(start)}`;
|
|
490
|
+
}
|
|
491
|
+
return `${$lux(start)} \u2013 ${$lux(end)}`;
|
|
492
|
+
}
|
|
493
|
+
function isPresetDateSelected(presetDateValue) {
|
|
494
|
+
const modelVal = toRaw(sheet.value ? sheetValue.value : props.modelValue);
|
|
495
|
+
if (!modelVal || !presetDateValue) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
if (Array.isArray(modelVal) && Array.isArray(presetDateValue)) {
|
|
499
|
+
if (modelVal.length !== presetDateValue.length) {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
return modelVal.every((val, index) => val === presetDateValue[index]);
|
|
503
|
+
}
|
|
504
|
+
return modelVal === presetDateValue;
|
|
505
|
+
}
|
|
506
|
+
</script>
|
|
507
|
+
|
|
508
|
+
<template>
|
|
509
|
+
<v-bottom-sheet
|
|
510
|
+
v-if="sheet"
|
|
511
|
+
v-model="sheetOpen"
|
|
512
|
+
:disabled="isLocked"
|
|
513
|
+
max-width="680"
|
|
514
|
+
scrim
|
|
515
|
+
scrollable
|
|
516
|
+
class="we-dp-sheet-overlay"
|
|
517
|
+
:content-props="{ class: 'rounded-t-xl', style: sheetDragStyle }"
|
|
518
|
+
>
|
|
519
|
+
<template #activator="{ props: sheetActivator }">
|
|
520
|
+
<div
|
|
521
|
+
v-if="$slots.activator"
|
|
522
|
+
v-bind="sheetActivator"
|
|
523
|
+
:class="$attrs.class"
|
|
524
|
+
:style="$attrs.style"
|
|
525
|
+
>
|
|
526
|
+
<slot
|
|
527
|
+
name="activator"
|
|
528
|
+
:sheet="true"
|
|
529
|
+
:readonly="isReadonly"
|
|
530
|
+
:disabled="isDisabled"
|
|
531
|
+
/>
|
|
532
|
+
</div>
|
|
533
|
+
<v-text-field
|
|
534
|
+
v-else
|
|
535
|
+
:model-value="displayValue"
|
|
536
|
+
:append-inner-icon="rangeEnabled ? 'mdi-calendar-range' : icon"
|
|
537
|
+
:color="resolvedColor"
|
|
538
|
+
v-bind="{ ...$attrs, ...sheetActivator }"
|
|
539
|
+
:disabled="isDisabled"
|
|
540
|
+
:rules="$rules"
|
|
541
|
+
:clearable="clearable && !isLocked"
|
|
542
|
+
readonly
|
|
543
|
+
@click:clear="handleClear"
|
|
544
|
+
@keydown.enter.prevent="sheetOpen = !isLocked"
|
|
545
|
+
/>
|
|
546
|
+
</template>
|
|
547
|
+
<v-card
|
|
548
|
+
ref="sheetCard"
|
|
549
|
+
rounded="t-xl"
|
|
550
|
+
class="we-dp-sheet pa-4"
|
|
551
|
+
>
|
|
552
|
+
<!-- Barra di trascinamento: arriva fino al bordo del sheet (mt-n4) per un'area di presa ampia.
|
|
553
|
+
`touch-action` va messo qui: usePointerSwipe lo imposta al mount, quando il sheet non c'è.
|
|
554
|
+
`touchmove.prevent`: su Android, senza, il gesto lascia un fling "fantasma" e il tap
|
|
555
|
+
successivo (es. per riaprire il picker) viene usato per fermarlo e non genera il click. -->
|
|
556
|
+
<div
|
|
557
|
+
ref="sheetHandle"
|
|
558
|
+
:class="isDraggingHandle ? 'cursor-grabbing' : 'cursor-grab'"
|
|
559
|
+
class="mt-n4 pt-4 pb-3 flex-shrink-0"
|
|
560
|
+
style="touch-action: none"
|
|
561
|
+
@touchmove.prevent
|
|
562
|
+
>
|
|
563
|
+
<v-sheet
|
|
564
|
+
width="32"
|
|
565
|
+
height="4"
|
|
566
|
+
rounded="pill"
|
|
567
|
+
color="grey-lighten-1"
|
|
568
|
+
class="mx-auto"
|
|
569
|
+
/>
|
|
570
|
+
</div>
|
|
571
|
+
<v-card-item
|
|
572
|
+
:title="title ?? $attrs.label"
|
|
573
|
+
:subtitle="rangeEnabled ? t('weDatePicker.selectRange') : t('weDatePicker.selectDate')"
|
|
574
|
+
class="align-start pa-0 mb-3 flex-shrink-0"
|
|
575
|
+
>
|
|
576
|
+
<template
|
|
577
|
+
v-if="clearable && sheetValue?.length"
|
|
578
|
+
#append
|
|
579
|
+
>
|
|
580
|
+
<v-btn
|
|
581
|
+
variant="text"
|
|
582
|
+
color="error"
|
|
583
|
+
@click="sheetValue = null"
|
|
584
|
+
>
|
|
585
|
+
{{ t('reset') }}
|
|
586
|
+
</v-btn>
|
|
587
|
+
</template>
|
|
588
|
+
</v-card-item>
|
|
589
|
+
|
|
590
|
+
<v-btn-toggle
|
|
591
|
+
v-if="splitMenu"
|
|
592
|
+
v-model="menuMode"
|
|
593
|
+
rounded="lg"
|
|
594
|
+
:divided="false"
|
|
595
|
+
mandatory
|
|
596
|
+
class="d-flex flex-shrink-0 pa-1 mb-3 bg-grey-lighten-4"
|
|
597
|
+
>
|
|
598
|
+
<v-btn
|
|
599
|
+
value="calendar"
|
|
600
|
+
rounded="lg"
|
|
601
|
+
class="flex-grow-1 text-none"
|
|
602
|
+
v-bind="modeButtonProps('calendar')"
|
|
603
|
+
>
|
|
604
|
+
{{ t('weDatePicker.calendar') }}
|
|
605
|
+
</v-btn>
|
|
606
|
+
<v-btn
|
|
607
|
+
value="presets"
|
|
608
|
+
rounded="lg"
|
|
609
|
+
class="flex-grow-1 text-none"
|
|
610
|
+
v-bind="modeButtonProps('presets')"
|
|
611
|
+
>
|
|
612
|
+
{{ t('weDatePicker.presets') }}
|
|
613
|
+
</v-btn>
|
|
614
|
+
</v-btn-toggle>
|
|
615
|
+
|
|
616
|
+
<!-- Calendario e preset nella stessa cella: il sheet prende la misura del più alto e non cambia
|
|
617
|
+
altezza passando dall'uno all'altro (né cambiando mese, grazie a `six-weeks`). -->
|
|
618
|
+
<v-card-text class="we-dp-sheet__body pa-0">
|
|
619
|
+
<div :class="{ 'we-dp-sheet__hidden': menuMode === 'presets' }">
|
|
620
|
+
<vue-date-picker
|
|
621
|
+
v-model="datePickerModelValue"
|
|
622
|
+
inline
|
|
623
|
+
six-weeks
|
|
624
|
+
month-name-format="long"
|
|
625
|
+
:esc-close="false"
|
|
626
|
+
:class="vueDatePickerClass"
|
|
627
|
+
v-bind="{ ...pickerProps, ...inlineAttrs(), ui: datePickerUi, config: datePickerConfig }"
|
|
628
|
+
@overlay-toggle="closeOtherOverlay"
|
|
629
|
+
>
|
|
630
|
+
<!-- Nel sheet mese e anno hanno la freccia, che si gira quando la griglia è aperta (CSS) -->
|
|
631
|
+
<template
|
|
632
|
+
#month="{ text }"
|
|
633
|
+
>
|
|
634
|
+
{{ text }}
|
|
635
|
+
<v-icon size="small">
|
|
636
|
+
$expand
|
|
637
|
+
</v-icon>
|
|
638
|
+
</template>
|
|
639
|
+
<template
|
|
640
|
+
#year="{ text }"
|
|
641
|
+
>
|
|
642
|
+
{{ text }}
|
|
643
|
+
<v-icon size="small">
|
|
644
|
+
$expand
|
|
645
|
+
</v-icon>
|
|
646
|
+
</template>
|
|
647
|
+
</vue-date-picker>
|
|
648
|
+
</div>
|
|
649
|
+
<v-list
|
|
650
|
+
v-if="splitMenu"
|
|
651
|
+
:class="{ 'we-dp-sheet__hidden': menuMode === 'calendar' }"
|
|
652
|
+
:color="resolvedColor"
|
|
653
|
+
:max-height="PRESET_LIST_MAX_HEIGHT"
|
|
654
|
+
bg-color="transparent"
|
|
655
|
+
border
|
|
656
|
+
rounded="lg"
|
|
657
|
+
class="py-0"
|
|
658
|
+
>
|
|
659
|
+
<template
|
|
660
|
+
v-for="(preset, index) in presetDates"
|
|
661
|
+
:key="preset.label"
|
|
662
|
+
>
|
|
663
|
+
<v-divider v-if="index" />
|
|
664
|
+
<v-list-item
|
|
665
|
+
:active="isPresetDateSelected(preset.value)"
|
|
666
|
+
lines="two"
|
|
667
|
+
@click="sheetValue = preset.value"
|
|
668
|
+
>
|
|
669
|
+
<template #title>
|
|
670
|
+
<span class="font-weight-bold text-body-2">{{ preset.label }}</span>
|
|
671
|
+
</template>
|
|
672
|
+
<template #subtitle>
|
|
673
|
+
<span class="text-caption">{{ presetSubtitle(preset.value) }}</span>
|
|
674
|
+
</template>
|
|
675
|
+
<template
|
|
676
|
+
v-if="isPresetDateSelected(preset.value)"
|
|
677
|
+
#append
|
|
678
|
+
>
|
|
679
|
+
<v-icon>$complete</v-icon>
|
|
680
|
+
</template>
|
|
681
|
+
</v-list-item>
|
|
682
|
+
</template>
|
|
683
|
+
</v-list>
|
|
684
|
+
</v-card-text>
|
|
685
|
+
|
|
686
|
+
<v-btn
|
|
687
|
+
:color="resolvedColor"
|
|
688
|
+
size="large"
|
|
689
|
+
block
|
|
690
|
+
class="mt-4 flex-shrink-0"
|
|
691
|
+
@click="applySheet"
|
|
692
|
+
>
|
|
693
|
+
{{ t('weDatePicker.apply') }}
|
|
694
|
+
</v-btn>
|
|
695
|
+
</v-card>
|
|
696
|
+
</v-bottom-sheet>
|
|
697
|
+
<vue-date-picker
|
|
698
|
+
v-else
|
|
699
|
+
ref="dpRef"
|
|
700
|
+
v-model="datePickerModelValue"
|
|
701
|
+
text-input
|
|
702
|
+
:preset-dates="$presetDates"
|
|
703
|
+
:position="position"
|
|
704
|
+
:clearable="false"
|
|
705
|
+
:class="vueDatePickerClass"
|
|
706
|
+
v-bind="{ ...pickerProps, ...$attrs, ui: datePickerUi, config: datePickerConfig, readonly: isReadonly, disabled: isDisabled }"
|
|
707
|
+
@open="scheduleArrowSync"
|
|
708
|
+
@recalculate-position="scheduleArrowSync"
|
|
709
|
+
>
|
|
710
|
+
<template
|
|
711
|
+
v-if="$slots.activator"
|
|
712
|
+
#trigger
|
|
713
|
+
>
|
|
714
|
+
<slot
|
|
715
|
+
name="activator"
|
|
716
|
+
:sheet="false"
|
|
717
|
+
:readonly="isReadonly"
|
|
718
|
+
:disabled="isDisabled"
|
|
719
|
+
/>
|
|
720
|
+
</template>
|
|
721
|
+
|
|
722
|
+
<template
|
|
723
|
+
v-else
|
|
724
|
+
#dp-input="{ value, isMenuOpen, onInput, onEnter, onTab, onBlur, onKeypress, onPaste, openMenu, closeMenu }"
|
|
725
|
+
>
|
|
726
|
+
<v-mask-input
|
|
727
|
+
:model-value="value"
|
|
728
|
+
:append-inner-icon="icon"
|
|
729
|
+
:color="resolvedColor"
|
|
730
|
+
v-bind="$attrs"
|
|
731
|
+
:readonly="isReadonly"
|
|
732
|
+
:disabled="isDisabled"
|
|
733
|
+
:rules="$rules"
|
|
734
|
+
:mask="maskInput"
|
|
735
|
+
return-masked-value
|
|
736
|
+
@focus="openMenu"
|
|
737
|
+
@update:model-value="handleOnInput($event, onInput)"
|
|
738
|
+
@keydown.enter="onEnter"
|
|
739
|
+
@keydown.tab="onTab"
|
|
740
|
+
@keydown.esc="closeMenuOnEscape($event, isMenuOpen, closeMenu)"
|
|
741
|
+
@blur="onBlur"
|
|
742
|
+
@keypress="onKeypress"
|
|
743
|
+
@paste="onPaste"
|
|
744
|
+
@paste.capture="blockWhenLocked"
|
|
745
|
+
@cut.capture="blockWhenLocked"
|
|
746
|
+
@keydown.capture="blockWhenLocked"
|
|
747
|
+
>
|
|
748
|
+
<template
|
|
749
|
+
v-if="clearable && !isLocked"
|
|
750
|
+
#clear
|
|
751
|
+
>
|
|
752
|
+
<div class="v-field__clearable">
|
|
753
|
+
<v-icon
|
|
754
|
+
@click.stop.prevent="handleClear"
|
|
755
|
+
/>
|
|
756
|
+
</div>
|
|
757
|
+
</template>
|
|
758
|
+
</v-mask-input>
|
|
759
|
+
</template>
|
|
760
|
+
|
|
761
|
+
<template #preset-date-range-button="{ label, value, presetDate }">
|
|
762
|
+
<v-chip
|
|
763
|
+
rounded="lg"
|
|
764
|
+
v-bind="isPresetDateSelected(value) ? { variant: 'tonal', color: resolvedColor, class: 'font-weight-bold' } : { variant: 'text' }"
|
|
765
|
+
@click="presetDate(value)"
|
|
766
|
+
@keyup.enter.prevent="presetDate(value)"
|
|
767
|
+
@keyup.space.prevent="presetDate(value)"
|
|
768
|
+
>
|
|
769
|
+
{{ label }}
|
|
770
|
+
</v-chip>
|
|
771
|
+
</template>
|
|
772
|
+
</vue-date-picker>
|
|
773
|
+
</template>
|
|
774
|
+
|
|
775
|
+
<style>
|
|
776
|
+
.dp__theme_light.dp__theme_light,
|
|
777
|
+
.dp__theme_dark.dp__theme_dark {
|
|
778
|
+
--dp-primary-color: rgb(var(--v-theme-primary));
|
|
779
|
+
--dp-primary-text-color: rgb(var(--v-theme-on-primary));
|
|
780
|
+
--dp-primary-disabled-color: rgba(var(--v-theme-primary), 0.5);
|
|
781
|
+
--dp-range-between-dates-background-color: rgba(var(--v-theme-primary), 0.12);
|
|
782
|
+
--dp-range-between-dates-text-color: rgb(var(--v-theme-on-surface));
|
|
783
|
+
--dp-range-between-border-color: transparent;
|
|
784
|
+
--dp-border-radius: 10px;
|
|
785
|
+
--dp-cell-border-radius: 4px;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
.vue-date-picker .dp__input_wrap {
|
|
789
|
+
box-sizing: border-box;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
.we-dp-menu {
|
|
793
|
+
--we-dp-arrow-inset: 14px;
|
|
794
|
+
}
|
|
795
|
+
.we-dp-menu .dp__arrow_top,
|
|
796
|
+
.we-dp-menu .dp__arrow_bottom {
|
|
797
|
+
left: clamp(var(--we-dp-arrow-inset), var(--dp-arrow-left), 100% - var(--we-dp-arrow-inset));
|
|
798
|
+
}
|
|
799
|
+
.we-dp-menu:has(> .dp__arrow_top) {
|
|
800
|
+
translate: 0 calc(-1 * var(--we-dp-activator-inset, 0px));
|
|
801
|
+
}
|
|
802
|
+
.we-dp-menu .dp__overlay {
|
|
803
|
+
border-radius: var(--dp-border-radius);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
html.v-overlay-scroll-blocked > body > .dp__outer_menu_wrap {
|
|
807
|
+
translate: calc(-1 * var(--v-body-scroll-x, 0px)) calc(-1 * var(--v-body-scroll-y, 0px));
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
.we-dp-sheet-overlay > .v-overlay__scrim.fade-transition-leave-active {
|
|
811
|
+
pointer-events: none;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
.we-dp-sheet {
|
|
815
|
+
--dp-cell-size: 44px;
|
|
816
|
+
--dp-menu-padding: 0;
|
|
817
|
+
}
|
|
818
|
+
.we-dp-sheet .dp__outer_menu_wrap {
|
|
819
|
+
flex: 1;
|
|
820
|
+
}
|
|
821
|
+
.we-dp-sheet .dp__menu {
|
|
822
|
+
border: none;
|
|
823
|
+
}
|
|
824
|
+
.we-dp-sheet .dp--tp-wrap {
|
|
825
|
+
max-width: none;
|
|
826
|
+
}
|
|
827
|
+
.we-dp-sheet .dp__cell_inner {
|
|
828
|
+
width: 100%;
|
|
829
|
+
}
|
|
830
|
+
.we-dp-sheet {
|
|
831
|
+
--dp-month-year-row-button-size: 36px;
|
|
832
|
+
--dp-overlay-col-padding: 4px;
|
|
833
|
+
}
|
|
834
|
+
.we-dp-sheet .dp__inner_nav,
|
|
835
|
+
.we-dp-sheet .dp__overlay_cell {
|
|
836
|
+
background: color-mix(in srgb, var(--dp-primary-color) 8%, transparent);
|
|
837
|
+
}
|
|
838
|
+
.we-dp-sheet .dp__month_year_wrap {
|
|
839
|
+
justify-content: center;
|
|
840
|
+
gap: 8px;
|
|
841
|
+
}
|
|
842
|
+
.we-dp-sheet .dp__month_year_select {
|
|
843
|
+
width: auto;
|
|
844
|
+
padding-inline: 12px;
|
|
845
|
+
}
|
|
846
|
+
.we-dp-sheet .dp__month_year_select.dp--hidden-el {
|
|
847
|
+
visibility: visible;
|
|
848
|
+
}
|
|
849
|
+
.we-dp-sheet .dp__month_year_select:has(+ .dp__overlay) {
|
|
850
|
+
background: color-mix(in srgb, var(--dp-primary-color) 12%, transparent);
|
|
851
|
+
color: var(--dp-primary-color);
|
|
852
|
+
}
|
|
853
|
+
.we-dp-sheet .dp__month_year_select:has(+ .dp__overlay) .v-icon {
|
|
854
|
+
rotate: 180deg;
|
|
855
|
+
}
|
|
856
|
+
.we-dp-sheet .dp--overlay-absolute {
|
|
857
|
+
top: var(--dp-month-year-row-height);
|
|
858
|
+
height: calc(100% - var(--dp-month-year-row-height));
|
|
859
|
+
}
|
|
860
|
+
.we-dp-sheet .dp__overlay_action {
|
|
861
|
+
display: none;
|
|
862
|
+
}
|
|
863
|
+
.we-dp-sheet .dp__overlay_row {
|
|
864
|
+
flex: none;
|
|
865
|
+
}
|
|
866
|
+
.we-dp-sheet .dp__overlay_cell,
|
|
867
|
+
.we-dp-sheet .dp__overlay_cell_active {
|
|
868
|
+
border-radius: var(--dp-border-radius);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
.we-dp-sheet__body {
|
|
872
|
+
display: grid;
|
|
873
|
+
}
|
|
874
|
+
.we-dp-sheet__body > * {
|
|
875
|
+
grid-area: 1/1;
|
|
876
|
+
min-width: 0;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
.we-dp-sheet__hidden {
|
|
880
|
+
visibility: hidden;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
.dp--preset-dates {
|
|
884
|
+
display: flex;
|
|
885
|
+
flex-wrap: wrap;
|
|
886
|
+
align-content: flex-start;
|
|
887
|
+
gap: 4px;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
.dp_main--reverse {
|
|
891
|
+
font-family: unset;
|
|
892
|
+
-webkit-user-select: unset;
|
|
893
|
+
-moz-user-select: unset;
|
|
894
|
+
user-select: unset;
|
|
895
|
+
box-sizing: unset;
|
|
896
|
+
width: unset;
|
|
897
|
+
}
|
|
898
|
+
.dp_main--reverse > div {
|
|
899
|
+
height: 100%;
|
|
900
|
+
}
|
|
901
|
+
</style>
|