Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
package.lib.composables.display.mjs.map Maven / Gradle / Ivy
{"version":3,"file":"display.mjs","names":["computed","inject","reactive","shallowRef","toRefs","watchEffect","getCurrentInstanceName","mergeDeep","propsFactory","IN_BROWSER","SUPPORTS_TOUCH","breakpoints","DisplaySymbol","Symbol","for","defaultDisplayOptions","mobileBreakpoint","thresholds","xs","sm","md","lg","xl","xxl","parseDisplayOptions","options","arguments","length","undefined","getClientWidth","ssr","window","innerWidth","clientWidth","getClientHeight","innerHeight","clientHeight","getPlatform","userAgent","navigator","match","regexp","Boolean","android","ios","cordova","electron","chrome","edge","firefox","opera","win","mac","linux","touch","createDisplay","height","platform","state","width","updateSize","value","update","name","breakpointValue","mobile","smAndUp","mdAndUp","lgAndUp","xlAndUp","smAndDown","mdAndDown","lgAndDown","xlAndDown","addEventListener","passive","makeDisplayProps","type","default","Number","String","useDisplay","props","display","Error","displayClasses"],"sources":["../../src/composables/display.ts"],"sourcesContent":["// Utilities\nimport { computed, inject, reactive, shallowRef, toRefs, watchEffect } from 'vue'\nimport { getCurrentInstanceName, mergeDeep, propsFactory } from '@/util'\nimport { IN_BROWSER, SUPPORTS_TOUCH } from '@/util/globals'\n\n// Types\nimport type { InjectionKey, PropType, Ref } from 'vue'\n\nexport const breakpoints = ['sm', 'md', 'lg', 'xl', 'xxl'] as const // no xs\n\nexport type Breakpoint = typeof breakpoints[number]\n\nexport type DisplayBreakpoint = 'xs' | Breakpoint\n\nexport type DisplayThresholds = {\n [key in DisplayBreakpoint]: number\n}\n\nexport interface DisplayProps {\n mobile?: boolean | null\n mobileBreakpoint?: number | DisplayBreakpoint\n}\n\nexport interface DisplayOptions {\n mobileBreakpoint?: number | DisplayBreakpoint\n thresholds?: Partial\n}\n\nexport interface InternalDisplayOptions {\n mobileBreakpoint: number | DisplayBreakpoint\n thresholds: DisplayThresholds\n}\n\nexport type SSROptions = boolean | {\n clientWidth: number\n clientHeight?: number\n}\n\nexport interface DisplayPlatform {\n android: boolean\n ios: boolean\n cordova: boolean\n electron: boolean\n chrome: boolean\n edge: boolean\n firefox: boolean\n opera: boolean\n win: boolean\n mac: boolean\n linux: boolean\n touch: boolean\n ssr: boolean\n}\n\nexport interface DisplayInstance {\n xs: Ref\n sm: Ref\n md: Ref\n lg: Ref\n xl: Ref\n xxl: Ref\n smAndUp: Ref\n mdAndUp: Ref\n lgAndUp: Ref\n xlAndUp: Ref\n smAndDown: Ref\n mdAndDown: Ref\n lgAndDown: Ref\n xlAndDown: Ref\n name: Ref\n height: Ref\n width: Ref\n mobile: Ref\n mobileBreakpoint: Ref\n platform: Ref\n thresholds: Ref\n\n /** @internal */\n ssr: boolean\n\n update (): void\n}\n\nexport const DisplaySymbol: InjectionKey = Symbol.for('vuetify:display')\n\nconst defaultDisplayOptions: DisplayOptions = {\n mobileBreakpoint: 'lg',\n thresholds: {\n xs: 0,\n sm: 600,\n md: 960,\n lg: 1280,\n xl: 1920,\n xxl: 2560,\n },\n}\n\nconst parseDisplayOptions = (options: DisplayOptions = defaultDisplayOptions) => {\n return mergeDeep(defaultDisplayOptions, options) as InternalDisplayOptions\n}\n\nfunction getClientWidth (ssr?: SSROptions) {\n return IN_BROWSER && !ssr\n ? window.innerWidth\n : (typeof ssr === 'object' && ssr.clientWidth) || 0\n}\n\nfunction getClientHeight (ssr?: SSROptions) {\n return IN_BROWSER && !ssr\n ? window.innerHeight\n : (typeof ssr === 'object' && ssr.clientHeight) || 0\n}\n\nfunction getPlatform (ssr?: SSROptions): DisplayPlatform {\n const userAgent = IN_BROWSER && !ssr\n ? window.navigator.userAgent\n : 'ssr'\n\n function match (regexp: RegExp) {\n return Boolean(userAgent.match(regexp))\n }\n\n const android = match(/android/i)\n const ios = match(/iphone|ipad|ipod/i)\n const cordova = match(/cordova/i)\n const electron = match(/electron/i)\n const chrome = match(/chrome/i)\n const edge = match(/edge/i)\n const firefox = match(/firefox/i)\n const opera = match(/opera/i)\n const win = match(/win/i)\n const mac = match(/mac/i)\n const linux = match(/linux/i)\n\n return {\n android,\n ios,\n cordova,\n electron,\n chrome,\n edge,\n firefox,\n opera,\n win,\n mac,\n linux,\n touch: SUPPORTS_TOUCH,\n ssr: userAgent === 'ssr',\n }\n}\n\nexport function createDisplay (options?: DisplayOptions, ssr?: SSROptions): DisplayInstance {\n const { thresholds, mobileBreakpoint } = parseDisplayOptions(options)\n\n const height = shallowRef(getClientHeight(ssr))\n const platform = shallowRef(getPlatform(ssr))\n const state = reactive({} as DisplayInstance)\n const width = shallowRef(getClientWidth(ssr))\n\n function updateSize () {\n height.value = getClientHeight()\n width.value = getClientWidth()\n }\n function update () {\n updateSize()\n platform.value = getPlatform()\n }\n\n // eslint-disable-next-line max-statements\n watchEffect(() => {\n const xs = width.value < thresholds.sm\n const sm = width.value < thresholds.md && !xs\n const md = width.value < thresholds.lg && !(sm || xs)\n const lg = width.value < thresholds.xl && !(md || sm || xs)\n const xl = width.value < thresholds.xxl && !(lg || md || sm || xs)\n const xxl = width.value >= thresholds.xxl\n const name =\n xs ? 'xs'\n : sm ? 'sm'\n : md ? 'md'\n : lg ? 'lg'\n : xl ? 'xl'\n : 'xxl'\n const breakpointValue = typeof mobileBreakpoint === 'number' ? mobileBreakpoint : thresholds[mobileBreakpoint]\n const mobile = width.value < breakpointValue\n\n state.xs = xs\n state.sm = sm\n state.md = md\n state.lg = lg\n state.xl = xl\n state.xxl = xxl\n state.smAndUp = !xs\n state.mdAndUp = !(xs || sm)\n state.lgAndUp = !(xs || sm || md)\n state.xlAndUp = !(xs || sm || md || lg)\n state.smAndDown = !(md || lg || xl || xxl)\n state.mdAndDown = !(lg || xl || xxl)\n state.lgAndDown = !(xl || xxl)\n state.xlAndDown = !xxl\n state.name = name\n state.height = height.value\n state.width = width.value\n state.mobile = mobile\n state.mobileBreakpoint = mobileBreakpoint\n state.platform = platform.value\n state.thresholds = thresholds\n })\n\n if (IN_BROWSER) {\n window.addEventListener('resize', updateSize, { passive: true })\n }\n\n return { ...toRefs(state), update, ssr: !!ssr }\n}\n\nexport const makeDisplayProps = propsFactory({\n mobile: {\n type: Boolean as PropType,\n default: false,\n },\n mobileBreakpoint: [Number, String] as PropType,\n}, 'display')\n\nexport function useDisplay (\n props: DisplayProps = {},\n name = getCurrentInstanceName(),\n) {\n const display = inject(DisplaySymbol)\n\n if (!display) throw new Error('Could not find Vuetify display injection')\n\n const mobile = computed(() => {\n if (props.mobile != null) return props.mobile\n if (!props.mobileBreakpoint) return display.mobile.value\n\n const breakpointValue = typeof props.mobileBreakpoint === 'number'\n ? props.mobileBreakpoint\n : display.thresholds.value[props.mobileBreakpoint]\n\n return display.width.value < breakpointValue\n })\n\n const displayClasses = computed(() => {\n if (!name) return {}\n\n return { [`${name}--mobile`]: mobile.value }\n })\n\n return { ...display, displayClasses, mobile }\n}\n"],"mappings":"AAAA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,MAAM,EAAEC,WAAW,QAAQ,KAAK;AAAA,SACxEC,sBAAsB,EAAEC,SAAS,EAAEC,YAAY;AAAA,SAC/CC,UAAU,EAAEC,cAAc,+BAEnC;AAGA,OAAO,MAAMC,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,EAAC;;AA2EpE,OAAO,MAAMC,aAA4C,GAAGC,MAAM,CAACC,GAAG,CAAC,iBAAiB,CAAC;AAEzF,MAAMC,qBAAqC,GAAG;EAC5CC,gBAAgB,EAAE,IAAI;EACtBC,UAAU,EAAE;IACVC,EAAE,EAAE,CAAC;IACLC,EAAE,EAAE,GAAG;IACPC,EAAE,EAAE,GAAG;IACPC,EAAE,EAAE,IAAI;IACRC,EAAE,EAAE,IAAI;IACRC,GAAG,EAAE;EACP;AACF,CAAC;AAED,MAAMC,mBAAmB,GAAG,SAAAA,CAAA,EAAqD;EAAA,IAApDC,O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