@hybridly/vue 0.10.0-beta.22 → 0.10.0-beta.23

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.
Files changed (2) hide show
  1. package/dist/index.mjs +10 -10
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -111,7 +111,7 @@ const formStore = {
111
111
  };
112
112
  //#endregion
113
113
  //#region src/composables/form.ts
114
- function safeClone(obj) {
114
+ function deepCloneRaw(obj) {
115
115
  return cloneDeep(toRaw(obj));
116
116
  }
117
117
  function useForm(options) {
@@ -123,11 +123,11 @@ function useForm(options) {
123
123
  recentlySuccessful: void 0
124
124
  };
125
125
  /** Fields that were initially set up. */
126
- const defaults = safeClone(options.fields);
126
+ const defaults = ref(deepCloneRaw(options.fields));
127
127
  /** Fields as they were when loaded. */
128
- const loaded = safeClone(historyData?.fields ?? options.fields);
128
+ const loaded = deepCloneRaw(historyData?.fields ?? options.fields);
129
129
  /** Current fields. */
130
- const fields = reactive(safeClone(loaded));
130
+ const fields = reactive(deepCloneRaw(loaded));
131
131
  /** Validation errors for each field. */
132
132
  const errors = ref(historyData?.errors ?? {});
133
133
  /** Whether the form is dirty. */
@@ -153,7 +153,7 @@ function useForm(options) {
153
153
  */
154
154
  function setDefault(newDefault) {
155
155
  Object.entries(newDefault).forEach(([key, value]) => {
156
- set(defaults, key, safeClone(value));
156
+ set(defaults.value, key, deepCloneRaw(value));
157
157
  });
158
158
  }
159
159
  function resolveFieldBehaviorKeys(option, fallback) {
@@ -166,7 +166,7 @@ function useForm(options) {
166
166
  const keys = resolveFieldBehaviorKeys(option, false);
167
167
  if (!keys) return;
168
168
  keys.forEach((key) => {
169
- set(defaults, key, safeClone(get(fields, key)));
169
+ set(defaults.value, key, deepCloneRaw(get(fields, key)));
170
170
  });
171
171
  }
172
172
  function resetFieldsFromBehavior(option, fallback) {
@@ -200,7 +200,7 @@ function useForm(options) {
200
200
  function resetFields(...keys) {
201
201
  if (keys.length === 0) keys = Object.keys(fields);
202
202
  keys.forEach((key) => {
203
- Reflect.set(fields, key, safeClone(Reflect.get(defaults, key)));
203
+ set(fields, key, deepCloneRaw(get(defaults.value, key)));
204
204
  });
205
205
  }
206
206
  /**
@@ -229,7 +229,7 @@ function useForm(options) {
229
229
  abortController,
230
230
  url: url ?? state.context.value?.url,
231
231
  method: requestOptions.method ?? "POST",
232
- data: safeClone(data),
232
+ data: deepCloneRaw(data),
233
233
  preserveState,
234
234
  hooks: {
235
235
  before: (_request, context) => {
@@ -288,7 +288,7 @@ function useForm(options) {
288
288
  */
289
289
  function hasDirty(...keys) {
290
290
  if (keys.length === 0) return isDirty.value;
291
- return keys.some((key) => !isEqual(toRaw(get(fields, key)), toRaw(get(defaults, key))));
291
+ return keys.some((key) => !isEqual(toRaw(get(fields, key)), toRaw(get(defaults.value, key))));
292
292
  }
293
293
  /**
294
294
  * Clears the given field's error.
@@ -316,7 +316,7 @@ function useForm(options) {
316
316
  processing,
317
317
  errors
318
318
  ], () => {
319
- isDirty.value = !isEqual(toRaw(defaults), toRaw(fields));
319
+ isDirty.value = !isEqual(toRaw(defaults.value), toRaw(fields));
320
320
  if (shouldRemember) router$1.history.remember(historyKey, {
321
321
  fields: toRaw(fields),
322
322
  errors: toRaw(errors.value)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hybridly/vue",
3
3
  "type": "module",
4
- "version": "0.10.0-beta.22",
4
+ "version": "0.10.0-beta.23",
5
5
  "description": "Vue adapter for Hybridly",
6
6
  "author": "Enzo Innocenzi <enzo@innocenzi.dev>",
7
7
  "license": "MIT",
@@ -47,8 +47,8 @@
47
47
  "dependencies": {
48
48
  "@clickbar/dot-diver": "^1.0.7",
49
49
  "es-toolkit": "^1.45.1",
50
- "@hybridly/core": "0.10.0-beta.22",
51
- "@hybridly/utils": "0.10.0-beta.22",
50
+ "@hybridly/core": "0.10.0-beta.23",
51
+ "@hybridly/utils": "0.10.0-beta.23",
52
52
  "@vue/devtools-api": "^8.1.0",
53
53
  "defu": "^6.1.4",
54
54
  "nprogress": "^0.2.0"