list.mjs 847 B

12345678910111213141516171819202122232425262728293031323334
  1. // Utilities
  2. import { computed, inject, provide, shallowRef } from 'vue';
  3. // Types
  4. // Depth
  5. export const DepthKey = Symbol.for('vuetify:depth');
  6. export function useDepth(hasPrepend) {
  7. const parent = inject(DepthKey, shallowRef(-1));
  8. const depth = computed(() => parent.value + 1 + (hasPrepend?.value ? 1 : 0));
  9. provide(DepthKey, depth);
  10. return depth;
  11. }
  12. // List
  13. export const ListKey = Symbol.for('vuetify:list');
  14. export function createList() {
  15. const parent = inject(ListKey, {
  16. hasPrepend: shallowRef(false),
  17. updateHasPrepend: () => null
  18. });
  19. const data = {
  20. hasPrepend: shallowRef(false),
  21. updateHasPrepend: value => {
  22. if (value) data.hasPrepend.value = value;
  23. }
  24. };
  25. provide(ListKey, data);
  26. return parent;
  27. }
  28. export function useList() {
  29. return inject(ListKey, null);
  30. }
  31. //# sourceMappingURL=list.mjs.map