formkit-addon-inertia
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
@@ -13,54 +13,48 @@ 'use strict'; | ||
const injectNode = (node, options) => { | ||
const addonOptions = {}; | ||
const mergedOptions = { ...options }; | ||
addonOptions.onCancelToken = ({ cancel }) => { | ||
if (options?.onCancelToken) return options.onCancelToken(cancel, node); | ||
}; | ||
if (mergedOptions?.onCancelToken) { | ||
mergedOptions.onCancelToken = ({ cancel }) => options?.onCancelToken?.(cancel, node); | ||
} | ||
addonOptions.onBefore = (visit) => { | ||
if (options?.onBefore) return options.onBefore(visit, node); | ||
}; | ||
if (mergedOptions?.onCancel) { | ||
mergedOptions.onCancel = () => options?.onCancel?.(node); | ||
} | ||
addonOptions.onStart = (visit) => { | ||
if (mergedOptions?.onSuccess) { | ||
mergedOptions.onSuccess = (page) => options?.onSuccess?.(page, node); | ||
} | ||
if (mergedOptions?.onBefore) { | ||
mergedOptions.onBefore = (visit) => options?.onBefore?.(visit, node); | ||
} | ||
mergedOptions.onStart = (visit) => { | ||
if (!options?.disableLoading) node.store.set(loadingMessage); | ||
if (!options?.disableDisabled) node.props.disabled = true; | ||
if (options?.onStart) options.onStart(visit, node); | ||
if (options?.onStart) return options.onStart(visit, node); | ||
}; | ||
addonOptions.onProgress = (progress) => { | ||
if (!options?.disableProgress && node.context) | ||
node.context.attrs = { "data-progress": progress?.total }; | ||
mergedOptions.onProgress = (progress) => { | ||
if (!options?.disableProgress && node.context) node.context.attrs = { 'data-progress': progress?.total }; | ||
if (options?.onProgress) options.onProgress(progress, node); | ||
if (options?.onProgress) return options.onProgress(progress, node); | ||
}; | ||
addonOptions.onFinish = (visit) => { | ||
if (!options?.disableLoading) node.store.remove("loading"); | ||
mergedOptions.onFinish = (visit) => { | ||
if (!options?.disableLoading) node.store.remove('loading'); | ||
if (!options?.disableDisabled) node.props.disabled = false; | ||
if ( | ||
!options?.disableProgress && | ||
node.context && | ||
node.context.attrs["data-progress"] | ||
) | ||
delete node.context.attrs["data-progress"]; | ||
if (!options?.disableProgress && node.context && node.context.attrs['data-progress']) delete node.context.attrs['data-progress']; | ||
if (options?.onFinish) options.onFinish(visit, node); | ||
if (options?.onFinish) return options.onFinish(visit, node); | ||
}; | ||
addonOptions.onCancel = () => { | ||
if (options?.onCancel) options.onCancel(node); | ||
}; | ||
mergedOptions.onError = (errors) => { | ||
if (!options?.disableErrors) node.setErrors([], errors); | ||
addonOptions.onSuccess = (page) => { | ||
if (options?.onSuccess) options.onSuccess(page, node); | ||
}; | ||
addonOptions.onError = (errors) => { | ||
if (options?.onError) return options.onError(errors, node); | ||
if (!options?.disableErrors) node.setErrors([], errors); | ||
}; | ||
return addonOptions; | ||
return mergedOptions; | ||
}; | ||
@@ -67,0 +61,0 @@ |
@@ -11,54 +11,48 @@ import { router } from '@inertiajs/vue3'; | ||
const injectNode = (node, options) => { | ||
const addonOptions = {}; | ||
const mergedOptions = { ...options }; | ||
addonOptions.onCancelToken = ({ cancel }) => { | ||
if (options?.onCancelToken) return options.onCancelToken(cancel, node); | ||
}; | ||
if (mergedOptions?.onCancelToken) { | ||
mergedOptions.onCancelToken = ({ cancel }) => options?.onCancelToken?.(cancel, node); | ||
} | ||
addonOptions.onBefore = (visit) => { | ||
if (options?.onBefore) return options.onBefore(visit, node); | ||
}; | ||
if (mergedOptions?.onCancel) { | ||
mergedOptions.onCancel = () => options?.onCancel?.(node); | ||
} | ||
addonOptions.onStart = (visit) => { | ||
if (mergedOptions?.onSuccess) { | ||
mergedOptions.onSuccess = (page) => options?.onSuccess?.(page, node); | ||
} | ||
if (mergedOptions?.onBefore) { | ||
mergedOptions.onBefore = (visit) => options?.onBefore?.(visit, node); | ||
} | ||
mergedOptions.onStart = (visit) => { | ||
if (!options?.disableLoading) node.store.set(loadingMessage); | ||
if (!options?.disableDisabled) node.props.disabled = true; | ||
if (options?.onStart) options.onStart(visit, node); | ||
if (options?.onStart) return options.onStart(visit, node); | ||
}; | ||
addonOptions.onProgress = (progress) => { | ||
if (!options?.disableProgress && node.context) | ||
node.context.attrs = { "data-progress": progress?.total }; | ||
mergedOptions.onProgress = (progress) => { | ||
if (!options?.disableProgress && node.context) node.context.attrs = { 'data-progress': progress?.total }; | ||
if (options?.onProgress) options.onProgress(progress, node); | ||
if (options?.onProgress) return options.onProgress(progress, node); | ||
}; | ||
addonOptions.onFinish = (visit) => { | ||
if (!options?.disableLoading) node.store.remove("loading"); | ||
mergedOptions.onFinish = (visit) => { | ||
if (!options?.disableLoading) node.store.remove('loading'); | ||
if (!options?.disableDisabled) node.props.disabled = false; | ||
if ( | ||
!options?.disableProgress && | ||
node.context && | ||
node.context.attrs["data-progress"] | ||
) | ||
delete node.context.attrs["data-progress"]; | ||
if (!options?.disableProgress && node.context && node.context.attrs['data-progress']) delete node.context.attrs['data-progress']; | ||
if (options?.onFinish) options.onFinish(visit, node); | ||
if (options?.onFinish) return options.onFinish(visit, node); | ||
}; | ||
addonOptions.onCancel = () => { | ||
if (options?.onCancel) options.onCancel(node); | ||
}; | ||
mergedOptions.onError = (errors) => { | ||
if (!options?.disableErrors) node.setErrors([], errors); | ||
addonOptions.onSuccess = (page) => { | ||
if (options?.onSuccess) options.onSuccess(page, node); | ||
}; | ||
addonOptions.onError = (errors) => { | ||
if (options?.onError) return options.onError(errors, node); | ||
if (!options?.disableErrors) node.setErrors([], errors); | ||
}; | ||
return addonOptions; | ||
return mergedOptions; | ||
}; | ||
@@ -65,0 +59,0 @@ |
{ | ||
"name": "formkit-addon-inertia", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"description": "A plugin for integrating InertiaJS with FormKit.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30971
362