sprintify-ui 0.0.58 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.0.58",
3
+ "version": "0.0.59",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -29,7 +29,7 @@
29
29
  <script lang="ts" setup>
30
30
  import { PropType, Ref } from 'vue';
31
31
  import { get, isEqual } from 'lodash';
32
- import { useMounted } from '@vueuse/core';
32
+ import { useMutationObserver } from '@vueuse/core';
33
33
  import { useField } from '@/composables/field';
34
34
 
35
35
  type Option = string | number | null;
@@ -76,6 +76,8 @@ const { nameInternal, requiredInternal, hasErrorInternal, emitUpdate } =
76
76
  emit: emit,
77
77
  });
78
78
 
79
+ const options = ref([] as HTMLOptionElement[]);
80
+
79
81
  function isEmptyExternal(value: string | number | null | undefined) {
80
82
  if (value === undefined || value === EMPTY_VALUE_EXTERNAL) {
81
83
  return true;
@@ -101,7 +103,7 @@ const modelValueInternal = computed(() => {
101
103
  return EMPTY_VALUE_INTERNAL;
102
104
  }
103
105
 
104
- if (!validModelValue()) {
106
+ if (!checkIfModelValueIsValid()) {
105
107
  return EMPTY_VALUE_INTERNAL;
106
108
  }
107
109
 
@@ -111,13 +113,26 @@ const modelValueInternal = computed(() => {
111
113
  /**
112
114
  * Checks if the current modelValue is valid
113
115
  */
114
- function validModelValue(): boolean {
116
+ useMutationObserver(select.value, () => {
117
+ options.value = getOptions();
118
+ });
119
+
120
+ onMounted(() => {
121
+ options.value = getOptions();
122
+ });
123
+
124
+ function getOptions(): HTMLOptionElement[] {
125
+ return [...(select.value?.options ?? [])];
126
+ }
127
+
128
+ function checkIfModelValueIsValid(): boolean {
115
129
  if (props.modelValue === EMPTY_VALUE_EXTERNAL) {
116
130
  return true;
117
131
  }
118
132
 
119
- const options = [...(select.value?.options ?? [])];
120
- return options.findIndex((o) => isEqual(o.value, props.modelValue)) != -1;
133
+ return (
134
+ options.value.findIndex((o) => isEqual(o.value, props.modelValue)) != -1
135
+ );
121
136
  }
122
137
 
123
138
  /**