@svadmin/core 0.65.0 → 0.66.0

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": "@svadmin/core",
3
- "version": "0.65.0",
3
+ "version": "0.66.0",
4
4
  "author": "zuohuadong",
5
5
  "repository": {
6
6
  "type": "git",
@@ -143,6 +143,7 @@
143
143
  "files": [
144
144
  "src/**/*.ts",
145
145
  "!src/**/*.test.*",
146
+ "!src/**/*.test-*",
146
147
  "!src/**/*.spec.*",
147
148
  "!src/**/vitest.config.*",
148
149
  "!src/**/setupTest.*"
@@ -19,7 +19,7 @@ import { useTranslation } from './i18n.svelte';
19
19
  import { Type } from 'typebox';
20
20
  import { checkExact } from './schema-validation';
21
21
  import { auditWithProvider } from './audit';
22
- import { fireSuccessNotification, fireErrorNotification } from './hook-utils.svelte';
22
+ import { fireSuccessNotification, fireErrorNotification, type NotificationConfig } from './hook-utils.svelte';
23
23
  import { captureAuthLiveScope, clearAuthQueries, handleAuthError } from './auth-hooks.svelte';
24
24
  import { getAdminOptions } from './options.svelte';
25
25
 
@@ -39,6 +39,8 @@ interface FormOptions<S extends ContractSchemas, A extends ContractFormAction> {
39
39
  validate?: (values: NoInfer<Draft<S, A>>) => Record<string, string> | null;
40
40
  onMutationSuccess?: (result: { data: NoInfer<ContractRecord<S>> }) => void | Promise<void>;
41
41
  onMutationError?: (error: HttpError) => void | Promise<void>;
42
+ /** 为 false 时不弹默认失败 toast。调用方已有表单内提示时使用。 */
43
+ errorNotification?: NotificationConfig;
42
44
  warnWhenUnsavedChanges?: boolean;
43
45
  }
44
46
  export type ContractFormOptions<S extends ContractSchemas, A extends ContractFormAction> =
@@ -477,7 +479,7 @@ export function useContractForm<S extends ContractSchemas, A extends ContractFor
477
479
  () => targetCurrent(target) && latest === token,
478
480
  () => clearAuthQueries(client, target.authProvider), target.authScope,
479
481
  () => mounted && latest !== token); }, undefined);
480
- if (current()) notify(() => fireErrorNotification({ config: undefined, defaultMessage: i18n.t('common.operationFailed'), error: copyFailure(failed.error),
482
+ if (current()) notify(() => fireErrorNotification({ config: options.errorNotification, defaultMessage: i18n.t('common.operationFailed'), error: copyFailure(failed.error),
481
483
  resource: target.contract.name, ...definedOptions({ provider: target.notificationProvider }) }), undefined);
482
484
  if (current()) notify(onError, copyFailure(failed.error));
483
485
  throw failed.error;