VTimePickerControls.mjs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
  2. // Styles
  3. import "./VTimePickerControls.css";
  4. // Components
  5. import { pad } from "./util.mjs";
  6. import { VBtn } from "../../components/VBtn/index.mjs"; // Composables
  7. import { useLocale } from "../../composables/locale.mjs"; // Utilities
  8. import { genericComponent, propsFactory, useRender } from "../../util/index.mjs"; // Types
  9. import { SelectingTimes } from "./SelectingTimes.mjs";
  10. export const makeVTimePickerControlsProps = propsFactory({
  11. ampm: Boolean,
  12. ampmInTitle: Boolean,
  13. ampmReadonly: Boolean,
  14. color: String,
  15. disabled: Boolean,
  16. hour: Number,
  17. minute: Number,
  18. second: Number,
  19. period: String,
  20. readonly: Boolean,
  21. useSeconds: Boolean,
  22. selecting: Number,
  23. value: Number
  24. }, 'VTimePickerControls');
  25. export const VTimePickerControls = genericComponent()({
  26. name: 'VTimePickerControls',
  27. props: makeVTimePickerControlsProps(),
  28. emits: {
  29. 'update:period': data => true,
  30. 'update:selecting': data => true
  31. },
  32. setup(props, _ref) {
  33. let {
  34. emit,
  35. slots
  36. } = _ref;
  37. const {
  38. t
  39. } = useLocale();
  40. useRender(() => {
  41. let hour = props.hour;
  42. if (props.ampm) {
  43. hour = hour ? (hour - 1) % 12 + 1 : 12;
  44. }
  45. return _createVNode("div", {
  46. "class": "v-time-picker-controls"
  47. }, [_createVNode("div", {
  48. "class": {
  49. 'v-time-picker-controls__time': true,
  50. 'v-time-picker-controls__time--with-seconds': props.useSeconds
  51. }
  52. }, [_createVNode(VBtn, {
  53. "active": props.selecting === 1,
  54. "color": props.selecting === 1 ? props.color : undefined,
  55. "disabled": props.disabled,
  56. "variant": "tonal",
  57. "class": {
  58. 'v-time-picker-controls__time__btn': true,
  59. 'v-time-picker-controls__time--with-ampm__btn': props.ampm,
  60. 'v-time-picker-controls__time--with-seconds__btn': props.useSeconds
  61. },
  62. "text": props.hour == null ? '--' : pad(`${hour}`),
  63. "onClick": () => emit('update:selecting', SelectingTimes.Hour)
  64. }, null), _createVNode("span", {
  65. "class": ['v-time-picker-controls__time__separator', {
  66. 'v-time-picker-controls--with-seconds__time__separator': props.useSeconds
  67. }]
  68. }, [_createTextVNode(":")]), _createVNode(VBtn, {
  69. "active": props.selecting === 2,
  70. "color": props.selecting === 2 ? props.color : undefined,
  71. "class": {
  72. 'v-time-picker-controls__time__btn': true,
  73. 'v-time-picker-controls__time__btn__active': props.selecting === 2,
  74. 'v-time-picker-controls__time--with-ampm__btn': props.ampm,
  75. 'v-time-picker-controls__time--with-seconds__btn': props.useSeconds
  76. },
  77. "disabled": props.disabled,
  78. "variant": "tonal",
  79. "text": props.minute == null ? '--' : pad(props.minute),
  80. "onClick": () => emit('update:selecting', SelectingTimes.Minute)
  81. }, null), props.useSeconds && _createVNode("span", {
  82. "class": ['v-time-picker-controls__time__separator', {
  83. 'v-time-picker-controls--with-seconds__time__separator': props.useSeconds
  84. }],
  85. "key": "secondsDivider"
  86. }, [_createTextVNode(":")]), props.useSeconds && _createVNode(VBtn, {
  87. "key": "secondsVal",
  88. "variant": "tonal",
  89. "onClick": () => emit('update:selecting', SelectingTimes.Second),
  90. "class": {
  91. 'v-time-picker-controls__time__btn': true,
  92. 'v-time-picker-controls__time__btn__active': props.selecting === 3,
  93. 'v-time-picker-controls__time--with-seconds__btn': props.useSeconds
  94. },
  95. "disabled": props.disabled,
  96. "text": props.second == null ? '--' : pad(props.second)
  97. }, null), props.ampm && props.ampmInTitle && _createVNode("div", {
  98. "class": ['v-time-picker-controls__ampm', {
  99. 'v-time-picker-controls__ampm--readonly': props.ampmReadonly
  100. }]
  101. }, [_createVNode(VBtn, {
  102. "active": props.period === 'am',
  103. "color": props.period === 'am' ? props.color : undefined,
  104. "class": {
  105. 'v-time-picker-controls__ampm__am': true,
  106. 'v-time-picker-controls__ampm__btn': true,
  107. 'v-time-picker-controls__ampm__btn__active': props.period === 'am'
  108. },
  109. "disabled": props.disabled,
  110. "text": t('$vuetify.timePicker.am'),
  111. "variant": props.disabled && props.period === 'am' ? 'elevated' : 'tonal',
  112. "onClick": () => props.period !== 'am' ? emit('update:period', 'am') : null
  113. }, null), _createVNode(VBtn, {
  114. "active": props.period === 'pm',
  115. "color": props.period === 'pm' ? props.color : undefined,
  116. "class": {
  117. 'v-time-picker-controls__ampm__pm': true,
  118. 'v-time-picker-controls__ampm__btn': true,
  119. 'v-time-picker-controls__ampm__btn__active': props.period === 'pm'
  120. },
  121. "disabled": props.disabled,
  122. "text": t('$vuetify.timePicker.pm'),
  123. "variant": props.disabled && props.period === 'pm' ? 'elevated' : 'tonal',
  124. "onClick": () => props.period !== 'pm' ? emit('update:period', 'pm') : null
  125. }, null)])])]);
  126. });
  127. return {};
  128. }
  129. });
  130. //# sourceMappingURL=VTimePickerControls.mjs.map