VStepperWindow.mjs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { createVNode as _createVNode, mergeProps as _mergeProps, resolveDirective as _resolveDirective } from "vue";
  2. // Components
  3. import { makeVWindowProps, VWindow } from "../../components/VWindow/VWindow.mjs"; // Composables
  4. import { useProxiedModel } from "../../composables/proxiedModel.mjs"; // Utilities
  5. import { computed, inject } from 'vue';
  6. import { genericComponent, propsFactory, useRender } from "../../util/index.mjs"; // Types
  7. export const VStepperSymbol = Symbol.for('vuetify:v-stepper');
  8. export const makeVStepperWindowProps = propsFactory({
  9. ...makeVWindowProps({
  10. mandatory: false
  11. })
  12. }, 'VStepperWindow');
  13. export const VStepperWindow = genericComponent()({
  14. name: 'VStepperWindow',
  15. props: makeVStepperWindowProps(),
  16. emits: {
  17. 'update:modelValue': v => true
  18. },
  19. setup(props, _ref) {
  20. let {
  21. slots
  22. } = _ref;
  23. const group = inject(VStepperSymbol, null);
  24. const _model = useProxiedModel(props, 'modelValue');
  25. const model = computed({
  26. get() {
  27. // Always return modelValue if defined
  28. // or if not within a VStepper group
  29. if (_model.value != null || !group) return _model.value;
  30. // If inside of a VStepper, find the currently selected
  31. // item by id. Item value may be assigned by its index
  32. return group.items.value.find(item => group.selected.value.includes(item.id))?.value;
  33. },
  34. set(val) {
  35. _model.value = val;
  36. }
  37. });
  38. useRender(() => {
  39. const [windowProps] = VWindow.filterProps(props);
  40. return _createVNode(VWindow, _mergeProps(windowProps, {
  41. "modelValue": model.value,
  42. "onUpdate:modelValue": $event => model.value = $event,
  43. "class": "v-stepper-window"
  44. }), slots);
  45. });
  46. return {};
  47. }
  48. });
  49. //# sourceMappingURL=VStepperWindow.mjs.map