757383f7c1e7640cd95913bb19e0aabf9b5b8697a94ad72ed3802bc04bd8e9dbdbad3699ef6664ca91e1d0f55e68347d26f9b9e2324935cfd71a87a88681f0 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { ref, watch } from 'vue';
  2. import { makeList } from '../utils.mjs';
  3. const makeAvailableArr = (disabledList) => {
  4. const trueOrNumber = (isDisabled, index) => isDisabled || index;
  5. const getNumber = (predicate) => predicate !== true;
  6. return disabledList.map(trueOrNumber).filter(getNumber);
  7. };
  8. const getTimeLists = (disabledHours, disabledMinutes, disabledSeconds) => {
  9. const getHoursList = (role, compare) => {
  10. return makeList(24, disabledHours && (() => disabledHours == null ? void 0 : disabledHours(role, compare)));
  11. };
  12. const getMinutesList = (hour, role, compare) => {
  13. return makeList(60, disabledMinutes && (() => disabledMinutes == null ? void 0 : disabledMinutes(hour, role, compare)));
  14. };
  15. const getSecondsList = (hour, minute, role, compare) => {
  16. return makeList(60, disabledSeconds && (() => disabledSeconds == null ? void 0 : disabledSeconds(hour, minute, role, compare)));
  17. };
  18. return {
  19. getHoursList,
  20. getMinutesList,
  21. getSecondsList
  22. };
  23. };
  24. const buildAvailableTimeSlotGetter = (disabledHours, disabledMinutes, disabledSeconds) => {
  25. const { getHoursList, getMinutesList, getSecondsList } = getTimeLists(disabledHours, disabledMinutes, disabledSeconds);
  26. const getAvailableHours = (role, compare) => {
  27. return makeAvailableArr(getHoursList(role, compare));
  28. };
  29. const getAvailableMinutes = (hour, role, compare) => {
  30. return makeAvailableArr(getMinutesList(hour, role, compare));
  31. };
  32. const getAvailableSeconds = (hour, minute, role, compare) => {
  33. return makeAvailableArr(getSecondsList(hour, minute, role, compare));
  34. };
  35. return {
  36. getAvailableHours,
  37. getAvailableMinutes,
  38. getAvailableSeconds
  39. };
  40. };
  41. const useOldValue = (props) => {
  42. const oldValue = ref(props.parsedValue);
  43. watch(() => props.visible, (val) => {
  44. if (!val) {
  45. oldValue.value = props.parsedValue;
  46. }
  47. });
  48. return oldValue;
  49. };
  50. export { buildAvailableTimeSlotGetter, getTimeLists, useOldValue };
  51. //# sourceMappingURL=use-time-picker.mjs.map