VBottomNavigation.mjs 4.3 KB

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