d3583028595faac4e3727697a4a5adeaac33032f6db6617bba94a551430e6b25b84dd504f361fb4e6a53887ee3203c0d8974324ff3ed77cab8acf252c48fc6 924 B

12345678910111213141516171819202122232425262728293031
  1. import { defineComponent, inject, watch } from 'vue';
  2. import { selectKey } from '../../select/src/token.mjs';
  3. import { isClient } from '@vueuse/core';
  4. var CacheOptions = defineComponent({
  5. props: {
  6. data: {
  7. type: Array,
  8. default: () => []
  9. }
  10. },
  11. setup(props) {
  12. const select = inject(selectKey);
  13. watch(() => props.data, () => {
  14. var _a;
  15. props.data.forEach((item) => {
  16. if (!select.states.cachedOptions.has(item.value)) {
  17. select.states.cachedOptions.set(item.value, item);
  18. }
  19. });
  20. const inputs = ((_a = select.selectRef) == null ? void 0 : _a.querySelectorAll("input")) || [];
  21. if (isClient && !Array.from(inputs).includes(document.activeElement)) {
  22. select.setSelected();
  23. }
  24. }, { flush: "post", immediate: true });
  25. return () => void 0;
  26. }
  27. });
  28. export { CacheOptions as default };
  29. //# sourceMappingURL=cache-options.mjs.map