vuetify
Version:
Vue Material Component Framework
1 lines • 7.98 kB
Source Map (JSON)
{"version":3,"file":"VWindowItem.mjs","names":["Touch","makeGroupItemProps","useGroupItem","makeLazyProps","useLazy","MaybeTransition","useSsrBoot","computed","inject","nextTick","ref","convertToUnit","genericComponent","useRender","VWindowGroupSymbol","VWindowSymbol","VWindowItem","name","directives","props","reverseTransition","type","Boolean","String","default","undefined","transition","emits","val","setup","slots","window","groupItem","isBooted","Error","isTransitioning","hasTransition","isReversed","value","onAfterTransition","transitionCount","transitionHeight","onBeforeTransition","rootRef","clientHeight","onTransitionCancelled","onEnterTransition","el","onBeforeEnter","onAfterEnter","onEnterCancelled","onBeforeLeave","onAfterLeave","onLeaveCancelled","onEnter","hasContent","isSelected","selectedClass"],"sources":["../../../src/components/VWindow/VWindowItem.tsx"],"sourcesContent":["// Directives\nimport Touch from '@/directives/touch'\n\n// Composables\nimport { makeGroupItemProps, useGroupItem } from '@/composables/group'\nimport { makeLazyProps, useLazy } from '@/composables/lazy'\nimport { MaybeTransition } from '@/composables/transition'\nimport { useSsrBoot } from '@/composables/ssrBoot'\n\n// Utilities\nimport { computed, inject, nextTick, ref } from 'vue'\nimport { convertToUnit, genericComponent, useRender } from '@/util'\n\n// Types\nimport { VWindowGroupSymbol, VWindowSymbol } from './VWindow'\n\nexport const VWindowItem = genericComponent()({\n name: 'VWindowItem',\n\n directives: {\n Touch,\n },\n\n props: {\n reverseTransition: {\n type: [Boolean, String],\n default: undefined,\n },\n transition: {\n type: [Boolean, String],\n default: undefined,\n },\n\n ...makeGroupItemProps(),\n ...makeLazyProps(),\n },\n\n emits: {\n 'group:selected': (val: { value: boolean }) => true,\n },\n\n setup (props, { slots }) {\n const window = inject(VWindowSymbol)\n const groupItem = useGroupItem(props, VWindowGroupSymbol)\n const { isBooted } = useSsrBoot()\n\n if (!window || !groupItem) throw new Error('[Vuetify] VWindowItem must be used inside VWindow')\n\n const isTransitioning = ref(false)\n const hasTransition = computed(() => window.isReversed.value ? props.reverseTransition !== false : props.transition !== false)\n\n function onAfterTransition () {\n if (!isTransitioning.value || !window) {\n return\n }\n\n // Finalize transition state.\n isTransitioning.value = false\n if (window.transitionCount.value > 0) {\n window.transitionCount.value -= 1\n\n // Remove container height if we are out of transition.\n if (window.transitionCount.value === 0) {\n window.transitionHeight.value = undefined\n }\n }\n }\n\n function onBeforeTransition () {\n if (isTransitioning.value || !window) {\n return\n }\n\n // Initialize transition state here.\n isTransitioning.value = true\n\n if (window.transitionCount.value === 0) {\n // Set initial height for height transition.\n window.transitionHeight.value = convertToUnit(window.rootRef.value?.clientHeight)\n }\n\n window.transitionCount.value += 1\n }\n\n function onTransitionCancelled () {\n onAfterTransition() // This should have the same path as normal transition end.\n }\n\n function onEnterTransition (el: Element) {\n if (!isTransitioning.value) {\n return\n }\n\n nextTick(() => {\n // Do not set height if no transition or cancelled.\n if (!hasTransition.value || !isTransitioning.value || !window) {\n return\n }\n\n // Set transition target height.\n window.transitionHeight.value = convertToUnit(el.clientHeight)\n })\n }\n\n const transition = computed(() => {\n const name = window.isReversed.value\n ? props.reverseTransition\n : props.transition\n\n return !hasTransition.value ? false : {\n name: typeof name !== 'string' ? window.transition.value : name,\n onBeforeEnter: onBeforeTransition,\n onAfterEnter: onAfterTransition,\n onEnterCancelled: onTransitionCancelled,\n onBeforeLeave: onBeforeTransition,\n onAfterLeave: onAfterTransition,\n onLeaveCancelled: onTransitionCancelled,\n onEnter: onEnterTransition,\n }\n })\n\n const { hasContent } = useLazy(props, groupItem.isSelected)\n\n useRender(() => (\n <MaybeTransition transition={ isBooted.value && transition.value } >\n <div\n class={[\n 'v-window-item',\n groupItem.selectedClass.value,\n ]}\n v-show={ groupItem.isSelected.value }\n >\n { hasContent.value && slots.default?.() }\n </div>\n </MaybeTransition>\n ))\n\n return {}\n },\n})\n\nexport type VWindowItem = InstanceType<typeof VWindowItem>\n"],"mappings":";AAAA;AAAA,OACOA,KAAK,0CAEZ;AAAA,SACSC,kBAAkB,EAAEC,YAAY;A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