@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 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 (JSON.stringify(newVal) !== JSON.stringify(data2.value)) {
10102
- data2.value = newVal;
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 (timeSinceInst() > 100 && JSON.stringify(newVal) !== JSON.stringify(props2.modelValue)) {
10107
- emit2("dirty");
10108
- emit2("update:modelValue", newVal);
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 (JSON.stringify(newVal) !== JSON.stringify(data2.value)) {
10100
- data2.value = newVal;
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 (timeSinceInst() > 100 && JSON.stringify(newVal) !== JSON.stringify(props2.modelValue)) {
10105
- emit2("dirty");
10106
- emit2("update:modelValue", newVal);
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
@@ -3832,7 +3832,7 @@ to {
3832
3832
  border-radius: calc(var(--btn-border-radius) * 4) !important;
3833
3833
  }
3834
3834
  .round-none {
3835
- border-radius: 0;
3835
+ border-radius: 0 !important;
3836
3836
  }
3837
3837
  .oval {
3838
3838
  border-radius: 100%;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "0.0.1082",
4
+ "version": "0.0.1084",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -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
- // Only watch for external updates if we're not nested
39
+ let emitDirty = $ref(false)
40
+
42
41
  if (!isNested) {
43
42
  watch(() => props.modelValue, (newVal) => {
44
- if (JSON.stringify(newVal) !== JSON.stringify(data.value)) {
45
- data.value = newVal
43
+ if (emitDirty) {
44
+ emitDirty = false
45
+ return
46
46
  }
47
+ data.value = newVal
47
48
  }, { deep: true, immediate: true })
48
49
 
49
- // Emit updates when internal state changes
50
- watch(data, (newVal) => {
51
- if (timeSinceInst() > 100 && JSON.stringify(newVal) !== JSON.stringify(props.modelValue)) {
52
- emit('dirty')
53
- emit('update:modelValue', newVal)
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
 
@@ -44,7 +44,7 @@
44
44
 
45
45
 
46
46
  .round-none {
47
- border-radius: 0;
47
+ border-radius: 0 !important;
48
48
  }
49
49
 
50
50
  .oval {