15
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
*/
17
17
18
+ import { computed } from 'vue'
18
19
import { aliases , mdi } from 'vuetify/iconsets/mdi-svg'
19
20
import { VAutocomplete } from 'vuetify/components/VAutocomplete'
20
21
import { VCombobox } from 'vuetify/components/VCombobox'
@@ -23,22 +24,28 @@ import { VTextarea } from 'vuetify/components/VTextarea'
23
24
import { VTextField } from 'vuetify/components/VTextField'
24
25
import colors from 'vuetify/util/colors'
25
26
import { mdiClose } from '@mdi/js'
27
+ import { useReducedAnimation } from '@/composables/localStorage'
28
+ import { merge } from 'lodash-es'
26
29
27
- const inputDefaults = Object . fromEntries ( [
30
+ export const inputComponents = [
28
31
VAutocomplete ,
29
32
VCombobox ,
30
33
VSelect ,
31
34
VTextarea ,
32
- VTextField
33
- ] . map ( ( { name } ) => [
34
- name ,
35
- {
36
- density : 'compact' ,
37
- variant : 'outlined' ,
38
- clearIcon : mdiClose ,
39
- hideDetails : true ,
40
- }
41
- ] ) )
35
+ VTextField ,
36
+ ] . map ( ( { name } ) => name )
37
+
38
+ const inputDefaults = Object . fromEntries (
39
+ inputComponents . map ( ( name ) => [
40
+ name ,
41
+ {
42
+ density : 'compact' ,
43
+ variant : 'outlined' ,
44
+ clearIcon : mdiClose ,
45
+ hideDetails : true ,
46
+ }
47
+ ] )
48
+ )
42
49
43
50
/**
44
51
* @type {import('vuetify').VuetifyOptions }
@@ -76,3 +83,25 @@ export const vuetifyOptions = {
76
83
...inputDefaults
77
84
} ,
78
85
}
86
+
87
+ /**
88
+ * Composable that provides Vuetify defaults that can change at runtime, as opposed to
89
+ * the static defaults provided in `createVuetify(vuetifyOptions)`.
90
+ *
91
+ * For use with a v-defaults-provider.
92
+ *
93
+ * @param {Object= } other - Additional defaults to provide.
94
+ */
95
+ export function useDynamicVuetifyDefaults ( other = { } ) {
96
+ const reducedAnimation = useReducedAnimation ( )
97
+
98
+ return computed ( ( ) => merge (
99
+ {
100
+ global : {
101
+ transition : reducedAnimation . value ? 'no' : undefined ,
102
+ ripple : reducedAnimation . value ? false : undefined ,
103
+ } ,
104
+ } ,
105
+ other
106
+ ) )
107
+ }
0 commit comments