{"version":3,"file":"date.mjs","names":["useLocale","inject","watch","propsFactory","VuetifyDateAdapter","DateAdapterSymbol","Symbol","for","createDate","options","adapter","makeDateProps","displayDate","type","Object","default","Date","hideAdjacentMonths","Boolean","modelValue","useDate","props","date","locale","Error","instance","current","value","val"],"sources":["../../../src/labs/date/date.ts"],"sourcesContent":["// Composables\nimport { useLocale } from '@/composables/locale'\n\n// Utilities\nimport { inject, watch } from 'vue'\nimport { propsFactory } from '@/util'\n\n// Adapters\nimport { VuetifyDateAdapter } from './adapters/vuetify'\n\n// Types\nimport type { InjectionKey, PropType } from 'vue'\nimport type { DateAdapter } from './DateAdapter'\n\nexport interface DateInstance extends DateAdapter<Date> {\n  locale: string\n}\n\nexport type DateOptions = {\n  adapter: (new (locale: string) => DateInstance) | DateInstance\n}\n\nexport const DateAdapterSymbol: InjectionKey<DateOptions> = Symbol.for('vuetify:date-adapter')\n\nexport interface DateProps {\n  displayDate: Date\n  hideAdjacentMonths: boolean\n  modelValue: readonly any[]\n}\n\nexport function createDate (options?: DateOptions) {\n  return options ?? { adapter: VuetifyDateAdapter }\n}\n\n// TODO: revisit this after it starts being implemented\nexport const makeDateProps = propsFactory({\n  displayDate: {\n    type: Object as PropType<Date>,\n    default: new Date(),\n  },\n  hideAdjacentMonths: Boolean,\n  modelValue: {\n    type: null as unknown as PropType<readonly any[]>,\n    default: () => [],\n  },\n}, 'date')\n\nexport function useDate (props?: DateProps) {\n  const date = inject(DateAdapterSymbol)\n  const locale = useLocale()\n\n  if (!date) throw new Error('[Vuetify] Could not find injected date')\n\n  const instance = typeof date.adapter === 'function'\n    // eslint-disable-next-line new-cap\n    ? new date.adapter(locale.current.value)\n    : date.adapter\n\n  if (typeof date.adapter === 'function') {\n    watch(locale.current, val => {\n      instance.locale = val\n    })\n  }\n\n  return instance\n}\n"],"mappings":"AAAA;AAAA,SACSA,SAAS,wCAElB;AACA,SAASC,MAAM,EAAEC,KAAK,QAAQ,KAAK;AAAA,SAC1BC,YAAY,gCAEr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