VBottomNavigation.mjs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import { createVNode as _createVNode } from "vue";
  2. // Styles
  3. import "./VBottomNavigation.css";
  4. // Components
  5. import { VBtnToggleSymbol } from "../VBtnToggle/VBtnToggle.mjs"; // Composables
  6. import { makeBorderProps, useBorder } from "../../composables/border.mjs";
  7. import { useBackgroundColor } from "../../composables/color.mjs";
  8. import { makeComponentProps } from "../../composables/component.mjs";
  9. import { provideDefaults } from "../../composables/defaults.mjs";
  10. import { makeDensityProps, useDensity } from "../../composables/density.mjs";
  11. import { makeElevationProps, useElevation } from "../../composables/elevation.mjs";
  12. import { makeGroupProps, useGroup } from "../../composables/group.mjs";
  13. import { makeLayoutItemProps, useLayoutItem } from "../../composables/layout.mjs";
  14. import { makeRoundedProps, useRounded } from "../../composables/rounded.mjs";
  15. import { useSsrBoot } from "../../composables/ssrBoot.mjs";
  16. import { makeTagProps } from "../../composables/tag.mjs";
  17. import { makeThemeProps, useTheme } from "../../composables/theme.mjs"; // Utilities
  18. import { computed, toRef } from 'vue';
  19. import { convertToUnit, genericComponent, propsFactory, useRender } from "../../util/index.mjs";
  20. export const makeVBottomNavigationProps = propsFactory({
  21. bgColor: String,
  22. color: String,
  23. grow: Boolean,
  24. mode: {
  25. type: String,
  26. validator: v => !v || ['horizontal', 'shift'].includes(v)
  27. },
  28. height: {
  29. type: [Number, String],
  30. default: 56
  31. },
  32. active: {
  33. type: Boolean,
  34. default: true
  35. },
  36. ...makeBorderProps(),
  37. ...makeComponentProps(),
  38. ...makeDensityProps(),
  39. ...makeElevationProps(),
  40. ...makeRoundedProps(),
  41. ...makeLayoutItemProps({
  42. name: 'bottom-navigation'
  43. }),
  44. ...makeTagProps({
  45. tag: 'header'
  46. }),
  47. ...makeGroupProps({
  48. modelValue: true,
  49. selectedClass: 'v-btn--selected'
  50. }),
  51. ...makeThemeProps()
  52. }, 'VBottomNavigation');
  53. export const VBottomNavigation = genericComponent()({
  54. name: 'VBottomNavigation',
  55. props: makeVBottomNavigationProps(),
  56. emits: {
  57. 'update:modelValue': value => true
  58. },
  59. setup(props, _ref) {
  60. let {
  61. slots
  62. } = _ref;
  63. const {
  64. themeClasses
  65. } = useTheme();
  66. const {
  67. borderClasses
  68. } = useBorder(props);
  69. const {
  70. backgroundColorClasses,
  71. backgroundColorStyles
  72. } = useBackgroundColor(toRef(props, 'bgColor'));
  73. const {
  74. densityClasses
  75. } = useDensity(props);
  76. const {
  77. elevationClasses
  78. } = useElevation(props);
  79. const {
  80. roundedClasses
  81. } = useRounded(props);
  82. const {
  83. ssrBootStyles
  84. } = useSsrBoot();
  85. const height = computed(() => Number(props.height) - (props.density === 'comfortable' ? 8 : 0) - (props.density === 'compact' ? 16 : 0));
  86. const isActive = toRef(props, 'active');
  87. const {
  88. layoutItemStyles
  89. } = useLayoutItem({
  90. id: props.name,
  91. order: computed(() => parseInt(props.order, 10)),
  92. position: computed(() => 'bottom'),
  93. layoutSize: computed(() => isActive.value ? height.value : 0),
  94. elementSize: height,
  95. active: isActive,
  96. absolute: toRef(props, 'absolute')
  97. });
  98. useGroup(props, VBtnToggleSymbol);
  99. provideDefaults({
  100. VBtn: {
  101. color: toRef(props, 'color'),
  102. density: toRef(props, 'density'),
  103. stacked: computed(() => props.mode !== 'horizontal'),
  104. variant: 'text'
  105. }
  106. }, {
  107. scoped: true
  108. });
  109. useRender(() => {
  110. return _createVNode(props.tag, {
  111. "class": ['v-bottom-navigation', {
  112. 'v-bottom-navigation--active': isActive.value,
  113. 'v-bottom-navigation--grow': props.grow,
  114. 'v-bottom-navigation--shift': props.mode === 'shift'
  115. }, themeClasses.value, backgroundColorClasses.value, borderClasses.value, densityClasses.value, elevationClasses.value, roundedClasses.value, props.class],
  116. "style": [backgroundColorStyles.value, layoutItemStyles.value, {
  117. height: convertToUnit(height.value),
  118. transform: `translateY(${convertToUnit(!isActive.value ? 100 : 0, '%')})`
  119. }, ssrBootStyles.value, props.style]
  120. }, {
  121. default: () => [slots.default && _createVNode("div", {
  122. "class": "v-bottom-navigation__content"
  123. }, [slots.default()])]
  124. });
  125. });
  126. return {};
  127. }
  128. });
  129. //# sourceMappingURL=VBottomNavigation.mjs.map