1515 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1616 */
1717
18+ import { computed } from 'vue'
1819import { aliases , mdi } from 'vuetify/iconsets/mdi-svg'
1920import { VAutocomplete } from 'vuetify/components/VAutocomplete'
2021import { VCombobox } from 'vuetify/components/VCombobox'
@@ -23,22 +24,28 @@ import { VTextarea } from 'vuetify/components/VTextarea'
2324import { VTextField } from 'vuetify/components/VTextField'
2425import colors from 'vuetify/util/colors'
2526import { mdiClose } from '@mdi/js'
27+ import { useReducedAnimation } from '@/composables/localStorage'
28+ import { merge } from 'lodash-es'
2629
27- const inputDefaults = Object . fromEntries ( [
30+ export const inputComponents = [
2831 VAutocomplete ,
2932 VCombobox ,
3033 VSelect ,
3134 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+ )
4249
4350/**
4451 * @type {import('vuetify').VuetifyOptions }
@@ -76,3 +83,25 @@ export const vuetifyOptions = {
7683 ...inputDefaults
7784 } ,
7885}
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