@bagelink/vue 0.0.1082 → 0.0.1084
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/dist/index.cjs +10 -9
- package/dist/index.mjs +10 -9
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/form/BglForm.vue +12 -12
- package/src/styles/layout.css +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10091,22 +10091,23 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
|
|
|
10091
10091
|
const emit2 = __emit;
|
|
10092
10092
|
const slots = vue.useSlots();
|
|
10093
10093
|
const { showModal } = useModal();
|
|
10094
|
-
const instAt = /* @__PURE__ */ new Date();
|
|
10095
|
-
const timeSinceInst = () => Date.now() - instAt.getTime();
|
|
10096
10094
|
const existingFormState = vue.inject(FORM_STATE_KEY);
|
|
10097
10095
|
const isNested = Boolean(existingFormState && props2.fieldID);
|
|
10098
10096
|
const { data: data2, isDirty } = isNested ? existingFormState : provideBagelFormState(props2.modelValue);
|
|
10097
|
+
let emitDirty = vue.ref(false);
|
|
10099
10098
|
if (!isNested) {
|
|
10100
10099
|
vue.watch(() => props2.modelValue, (newVal) => {
|
|
10101
|
-
if (
|
|
10102
|
-
|
|
10100
|
+
if (emitDirty.value) {
|
|
10101
|
+
emitDirty.value = false;
|
|
10102
|
+
return;
|
|
10103
10103
|
}
|
|
10104
|
+
data2.value = newVal;
|
|
10104
10105
|
}, { deep: true, immediate: true });
|
|
10105
|
-
vue.watch(data2, (newVal) => {
|
|
10106
|
-
if (
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10106
|
+
vue.watch(() => data2, (newVal) => {
|
|
10107
|
+
if (emitDirty.value) return;
|
|
10108
|
+
emitDirty.value = true;
|
|
10109
|
+
emit2("dirty");
|
|
10110
|
+
emit2("update:modelValue", newVal);
|
|
10110
10111
|
}, { deep: true });
|
|
10111
10112
|
}
|
|
10112
10113
|
const form = vue.ref();
|
package/dist/index.mjs
CHANGED
|
@@ -10089,22 +10089,23 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
|
10089
10089
|
const emit2 = __emit;
|
|
10090
10090
|
const slots = useSlots();
|
|
10091
10091
|
const { showModal } = useModal();
|
|
10092
|
-
const instAt = /* @__PURE__ */ new Date();
|
|
10093
|
-
const timeSinceInst = () => Date.now() - instAt.getTime();
|
|
10094
10092
|
const existingFormState = inject(FORM_STATE_KEY);
|
|
10095
10093
|
const isNested = Boolean(existingFormState && props2.fieldID);
|
|
10096
10094
|
const { data: data2, isDirty } = isNested ? existingFormState : provideBagelFormState(props2.modelValue);
|
|
10095
|
+
let emitDirty = ref(false);
|
|
10097
10096
|
if (!isNested) {
|
|
10098
10097
|
watch(() => props2.modelValue, (newVal) => {
|
|
10099
|
-
if (
|
|
10100
|
-
|
|
10098
|
+
if (emitDirty.value) {
|
|
10099
|
+
emitDirty.value = false;
|
|
10100
|
+
return;
|
|
10101
10101
|
}
|
|
10102
|
+
data2.value = newVal;
|
|
10102
10103
|
}, { deep: true, immediate: true });
|
|
10103
|
-
watch(data2, (newVal) => {
|
|
10104
|
-
if (
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10104
|
+
watch(() => data2, (newVal) => {
|
|
10105
|
+
if (emitDirty.value) return;
|
|
10106
|
+
emitDirty.value = true;
|
|
10107
|
+
emit2("dirty");
|
|
10108
|
+
emit2("update:modelValue", newVal);
|
|
10108
10109
|
}, { deep: true });
|
|
10109
10110
|
}
|
|
10110
10111
|
const form = ref();
|
package/dist/style.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { BglField, type BglFormSchemaFnT, Title, useBglSchema, useModal } from '@bagelink/vue'
|
|
3
|
-
import { inject, useSlots, watch } from 'vue'
|
|
3
|
+
import { inject, onMounted, useSlots, watch } from 'vue'
|
|
4
4
|
import { FORM_STATE_KEY, provideBagelFormState, type BagelFormState } from './useBagelFormState'
|
|
5
5
|
|
|
6
6
|
export type FormStatus = 'idle' | 'loading' | 'success' | 'error'
|
|
@@ -26,8 +26,6 @@ const emit = defineEmits(['update:modelValue', 'submit', 'dirty'])
|
|
|
26
26
|
|
|
27
27
|
const slots = useSlots() as any
|
|
28
28
|
const { showModal } = useModal()
|
|
29
|
-
const instAt = new Date()
|
|
30
|
-
const timeSinceInst = () => Date.now() - instAt.getTime()
|
|
31
29
|
|
|
32
30
|
// Check if we're a nested form
|
|
33
31
|
const existingFormState = inject<BagelFormState | undefined>(FORM_STATE_KEY)
|
|
@@ -38,20 +36,22 @@ const { data, isDirty } = isNested
|
|
|
38
36
|
? existingFormState!
|
|
39
37
|
: provideBagelFormState(props.modelValue)
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
let emitDirty = $ref(false)
|
|
40
|
+
|
|
42
41
|
if (!isNested) {
|
|
43
42
|
watch(() => props.modelValue, (newVal) => {
|
|
44
|
-
if (
|
|
45
|
-
|
|
43
|
+
if (emitDirty) {
|
|
44
|
+
emitDirty = false
|
|
45
|
+
return
|
|
46
46
|
}
|
|
47
|
+
data.value = newVal
|
|
47
48
|
}, { deep: true, immediate: true })
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
50
|
+
watch(() => data, (newVal) => {
|
|
51
|
+
if (emitDirty) return
|
|
52
|
+
emitDirty = true
|
|
53
|
+
emit('dirty')
|
|
54
|
+
emit('update:modelValue', newVal)
|
|
55
55
|
}, { deep: true })
|
|
56
56
|
}
|
|
57
57
|
|