@dovetail-v2/refine 0.4.2-alpha.1 → 0.4.2-alpha.2

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.
@@ -24,8 +24,6 @@ export interface YamlFormProps<Model extends ResourceModel = ResourceModel> {
24
24
  transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
25
25
  transformApplyValues?: (values: Unstructured) => Unstructured;
26
26
  beforeSubmit?: (values: Unstructured, setErrors: (errors: string[]) => void) => Promise<Unstructured>;
27
- /** 自定义提交函数,存在时替代 refine core 的 onFinish */
28
- onSubmit?: (values: Record<string, unknown>) => Promise<unknown>;
29
27
  onSaveButtonPropsChange?: (saveButtonProps: {
30
28
  disabled?: boolean;
31
29
  onClick: () => void;
@@ -34,7 +34,5 @@ export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError ex
34
34
  onBeforeSubmitError?: (errors: string[]) => void;
35
35
  onSubmitStart?: () => void;
36
36
  onSubmitAbort?: () => void;
37
- /** 自定义提交函数,存在时替代 refine core 的 onFinish */
38
- onSubmit?: (values: Record<string, unknown>) => Promise<unknown>;
39
37
  } & UseHookFormProps<TVariables, TContext>;
40
- export declare const useForm: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables extends FieldValues = FieldValues, TContext extends object = object, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ refineCoreProps, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, disableServerSideValidation: disableServerSideValidationProp, transformApplyValues, transformInitValues, beforeSubmit, onBeforeSubmitError, onSubmitStart, onSubmitAbort, onSubmit, ...rest }?: UseFormProps<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>;
38
+ export declare const useForm: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables extends FieldValues = FieldValues, TContext extends object = object, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ refineCoreProps, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, disableServerSideValidation: disableServerSideValidationProp, transformApplyValues, transformInitValues, beforeSubmit, onBeforeSubmitError, onSubmitStart, onSubmitAbort, ...rest }?: UseFormProps<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>;
@@ -31,8 +31,6 @@ export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError ex
31
31
  onBeforeSubmitError?: (errors: string[]) => void;
32
32
  onSubmitStart?: () => void;
33
33
  onSubmitAbort?: () => void;
34
- /** 自定义提交函数,存在时替代 refine core 的 onFinish */
35
- onSubmit?: (values: Record<string, unknown>) => Promise<unknown>;
36
34
  rules?: YamlFormRule[];
37
35
  };
38
36
  export type UseFormReturnType<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables extends object = object, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = UseFormReturnTypeCore<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError> & {
@@ -57,5 +55,5 @@ declare const useYamlForm: <TQueryFnData extends Unstructured = Unstructured & {
57
55
  [prop: string]: unknown;
58
56
  } = {
59
57
  [prop: string]: unknown;
60
- }, TData extends Unstructured = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ action: actionFromProps, resource, onMutationSuccess: onMutationSuccessProp, onMutationError, submitOnEnter, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, redirect, successNotification, errorNotification, meta, metaData, queryMeta, mutationMeta, liveMode, liveParams, mutationMode, dataProviderName, onLiveEvent, invalidates, undoableTimeout, queryOptions, createMutationOptions, updateMutationOptions, id: idFromProps, overtimeOptions, editorOptions, initialValuesForCreate, initialValuesForEdit, transformInitValues, transformApplyValues, beforeSubmit, onBeforeSubmitError, onSubmitStart, onSubmitAbort, onSubmit, rules, }?: UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>;
58
+ }, TData extends Unstructured = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ action: actionFromProps, resource, onMutationSuccess: onMutationSuccessProp, onMutationError, submitOnEnter, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, redirect, successNotification, errorNotification, meta, metaData, queryMeta, mutationMeta, liveMode, liveParams, mutationMode, dataProviderName, onLiveEvent, invalidates, undoableTimeout, queryOptions, createMutationOptions, updateMutationOptions, id: idFromProps, overtimeOptions, editorOptions, initialValuesForCreate, initialValuesForEdit, transformInitValues, transformApplyValues, beforeSubmit, onBeforeSubmitError, onSubmitStart, onSubmitAbort, rules, }?: UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>;
61
59
  export default useYamlForm;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  export interface FormatRulePopoverProps {
3
3
  buttonText: string;
4
- columns: any[];
5
- dataSource: any[];
4
+ columns: Record<string, unknown>[];
5
+ dataSource: Record<string, unknown>[];
6
6
  }
7
7
  export declare const FormatRulePopover: React.FC<FormatRulePopoverProps>;
package/dist/refine.cjs CHANGED
@@ -11248,7 +11248,6 @@ const useYamlForm = ({
11248
11248
  onBeforeSubmitError,
11249
11249
  onSubmitStart,
11250
11250
  onSubmitAbort,
11251
- onSubmit,
11252
11251
  rules
11253
11252
  } = {}) => {
11254
11253
  var _a;
@@ -11462,11 +11461,6 @@ const useYamlForm = ({
11462
11461
  setIsBeforeSubmitLoading(false);
11463
11462
  }
11464
11463
  }
11465
- if (onSubmit) {
11466
- const result = await onSubmit(finalValues);
11467
- onMutationSuccessProp == null ? void 0 : onMutationSuccessProp({ data: result }, {}, {});
11468
- return result;
11469
- }
11470
11464
  return onFinish(finalValues);
11471
11465
  } catch (error) {
11472
11466
  onSubmitAbort == null ? void 0 : onSubmitAbort();
@@ -11516,7 +11510,6 @@ function YamlForm(props) {
11516
11510
  transformInitValues,
11517
11511
  transformApplyValues,
11518
11512
  beforeSubmit,
11519
- onSubmit,
11520
11513
  onSaveButtonPropsChange,
11521
11514
  onErrorsChange,
11522
11515
  rules
@@ -11555,7 +11548,6 @@ function YamlForm(props) {
11555
11548
  initialValuesForEdit: props.initialValuesForEdit,
11556
11549
  rules,
11557
11550
  beforeSubmit,
11558
- onSubmit,
11559
11551
  successNotification(data2) {
11560
11552
  var _a;
11561
11553
  const displayName = resourceConfig.displayName || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
@@ -16934,7 +16926,6 @@ const useForm = ({
16934
16926
  onBeforeSubmitError,
16935
16927
  onSubmitStart,
16936
16928
  onSubmitAbort,
16937
- onSubmit,
16938
16929
  ...rest
16939
16930
  } = {}) => {
16940
16931
  const { options } = core.useRefineContext();
@@ -17058,7 +17049,6 @@ const useForm = ({
17058
17049
  onSubmitStart == null ? void 0 : onSubmitStart();
17059
17050
  handleSubmit(
17060
17051
  async (v) => {
17061
- var _a;
17062
17052
  let finalValues = transformApplyValues ? transformApplyValues(v) : v;
17063
17053
  if (beforeSubmit) {
17064
17054
  try {
@@ -17085,11 +17075,6 @@ const useForm = ({
17085
17075
  setIsBeforeSubmitLoading(false);
17086
17076
  }
17087
17077
  }
17088
- if (onSubmit) {
17089
- const result = await onSubmit(finalValues);
17090
- (_a = refineCoreProps == null ? void 0 : refineCoreProps.onMutationSuccess) == null ? void 0 : _a.call(refineCoreProps, { data: result }, {}, {});
17091
- return result;
17092
- }
17093
17078
  return onFinish(finalValues);
17094
17079
  },
17095
17080
  () => {
@@ -17104,8 +17089,6 @@ const useForm = ({
17104
17089
  isBeforeSubmitLoading,
17105
17090
  handleSubmit,
17106
17091
  onFinish,
17107
- onSubmit,
17108
- refineCoreProps,
17109
17092
  transformApplyValues,
17110
17093
  beforeSubmit,
17111
17094
  onBeforeSubmitError,
@@ -17168,7 +17151,6 @@ const useRefineForm = (props) => {
17168
17151
  onBeforeSubmitError: options == null ? void 0 : options.onBeforeSubmitError,
17169
17152
  onSubmitStart: options == null ? void 0 : options.onSubmitStart,
17170
17153
  onSubmitAbort: options == null ? void 0 : options.onSubmitAbort,
17171
- onSubmit: formConfig == null ? void 0 : formConfig.onSubmit,
17172
17154
  ...formConfig == null ? void 0 : formConfig.useFormProps
17173
17155
  });
17174
17156
  React.useEffect(() => {
@@ -17203,7 +17185,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17203
17185
  onError,
17204
17186
  onSaveButtonPropsChange
17205
17187
  }, ref) {
17206
- var _a;
17188
+ var _a, _b;
17207
17189
  const action = id ? "edit" : "create";
17208
17190
  const pushModal = eagle.usePushModal();
17209
17191
  const popModal = eagle.usePopModal();
@@ -17291,7 +17273,6 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17291
17273
  id,
17292
17274
  action,
17293
17275
  isShowLayout: false,
17294
- onSubmit: formConfig == null ? void 0 : formConfig.onSubmit,
17295
17276
  useFormProps: {
17296
17277
  redirect: false,
17297
17278
  mutationMeta: (_a2 = formConfig == null ? void 0 : formConfig.refineCoreProps) == null ? void 0 : _a2.mutationMeta,
@@ -17330,6 +17311,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17330
17311
  id,
17331
17312
  refineFormResult,
17332
17313
  formConfig == null ? void 0 : formConfig.beforeSubmit,
17314
+ (_a = formConfig == null ? void 0 : formConfig.refineCoreProps) == null ? void 0 : _a.mutationMeta,
17333
17315
  transformApplyValues,
17334
17316
  onSaveButtonPropsChange,
17335
17317
  onSuccess,
@@ -17350,7 +17332,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17350
17332
  [refineFormResult.formResult]
17351
17333
  );
17352
17334
  const currentFormValues = refineFormResult.formResult.getValues();
17353
- const isReady = (formConfig == null ? void 0 : formConfig.isDataReady) ? formConfig.isDataReady(currentFormValues) : !!((_a = currentFormValues == null ? void 0 : currentFormValues.metadata) == null ? void 0 : _a.name);
17335
+ const isReady = (formConfig == null ? void 0 : formConfig.isDataReady) ? formConfig.isDataReady(currentFormValues) : !!((_b = currentFormValues == null ? void 0 : currentFormValues.metadata) == null ? void 0 : _b.name);
17354
17336
  if (action === "edit" && !isReady) {
17355
17337
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Loading, {});
17356
17338
  }
package/dist/refine.js CHANGED
@@ -11229,7 +11229,6 @@ const useYamlForm = ({
11229
11229
  onBeforeSubmitError,
11230
11230
  onSubmitStart,
11231
11231
  onSubmitAbort,
11232
- onSubmit,
11233
11232
  rules
11234
11233
  } = {}) => {
11235
11234
  var _a;
@@ -11443,11 +11442,6 @@ const useYamlForm = ({
11443
11442
  setIsBeforeSubmitLoading(false);
11444
11443
  }
11445
11444
  }
11446
- if (onSubmit) {
11447
- const result = await onSubmit(finalValues);
11448
- onMutationSuccessProp == null ? void 0 : onMutationSuccessProp({ data: result }, {}, {});
11449
- return result;
11450
- }
11451
11445
  return onFinish(finalValues);
11452
11446
  } catch (error) {
11453
11447
  onSubmitAbort == null ? void 0 : onSubmitAbort();
@@ -11497,7 +11491,6 @@ function YamlForm(props) {
11497
11491
  transformInitValues,
11498
11492
  transformApplyValues,
11499
11493
  beforeSubmit,
11500
- onSubmit,
11501
11494
  onSaveButtonPropsChange,
11502
11495
  onErrorsChange,
11503
11496
  rules
@@ -11536,7 +11529,6 @@ function YamlForm(props) {
11536
11529
  initialValuesForEdit: props.initialValuesForEdit,
11537
11530
  rules,
11538
11531
  beforeSubmit,
11539
- onSubmit,
11540
11532
  successNotification(data2) {
11541
11533
  var _a;
11542
11534
  const displayName = resourceConfig.displayName || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
@@ -16915,7 +16907,6 @@ const useForm = ({
16915
16907
  onBeforeSubmitError,
16916
16908
  onSubmitStart,
16917
16909
  onSubmitAbort,
16918
- onSubmit,
16919
16910
  ...rest
16920
16911
  } = {}) => {
16921
16912
  const { options } = useRefineContext();
@@ -17039,7 +17030,6 @@ const useForm = ({
17039
17030
  onSubmitStart == null ? void 0 : onSubmitStart();
17040
17031
  handleSubmit(
17041
17032
  async (v) => {
17042
- var _a;
17043
17033
  let finalValues = transformApplyValues ? transformApplyValues(v) : v;
17044
17034
  if (beforeSubmit) {
17045
17035
  try {
@@ -17066,11 +17056,6 @@ const useForm = ({
17066
17056
  setIsBeforeSubmitLoading(false);
17067
17057
  }
17068
17058
  }
17069
- if (onSubmit) {
17070
- const result = await onSubmit(finalValues);
17071
- (_a = refineCoreProps == null ? void 0 : refineCoreProps.onMutationSuccess) == null ? void 0 : _a.call(refineCoreProps, { data: result }, {}, {});
17072
- return result;
17073
- }
17074
17059
  return onFinish(finalValues);
17075
17060
  },
17076
17061
  () => {
@@ -17085,8 +17070,6 @@ const useForm = ({
17085
17070
  isBeforeSubmitLoading,
17086
17071
  handleSubmit,
17087
17072
  onFinish,
17088
- onSubmit,
17089
- refineCoreProps,
17090
17073
  transformApplyValues,
17091
17074
  beforeSubmit,
17092
17075
  onBeforeSubmitError,
@@ -17149,7 +17132,6 @@ const useRefineForm = (props) => {
17149
17132
  onBeforeSubmitError: options == null ? void 0 : options.onBeforeSubmitError,
17150
17133
  onSubmitStart: options == null ? void 0 : options.onSubmitStart,
17151
17134
  onSubmitAbort: options == null ? void 0 : options.onSubmitAbort,
17152
- onSubmit: formConfig == null ? void 0 : formConfig.onSubmit,
17153
17135
  ...formConfig == null ? void 0 : formConfig.useFormProps
17154
17136
  });
17155
17137
  useEffect(() => {
@@ -17184,7 +17166,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17184
17166
  onError,
17185
17167
  onSaveButtonPropsChange
17186
17168
  }, ref) {
17187
- var _a;
17169
+ var _a, _b;
17188
17170
  const action = id ? "edit" : "create";
17189
17171
  const pushModal = usePushModal();
17190
17172
  const popModal = usePopModal();
@@ -17272,7 +17254,6 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17272
17254
  id,
17273
17255
  action,
17274
17256
  isShowLayout: false,
17275
- onSubmit: formConfig == null ? void 0 : formConfig.onSubmit,
17276
17257
  useFormProps: {
17277
17258
  redirect: false,
17278
17259
  mutationMeta: (_a2 = formConfig == null ? void 0 : formConfig.refineCoreProps) == null ? void 0 : _a2.mutationMeta,
@@ -17311,6 +17292,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17311
17292
  id,
17312
17293
  refineFormResult,
17313
17294
  formConfig == null ? void 0 : formConfig.beforeSubmit,
17295
+ (_a = formConfig == null ? void 0 : formConfig.refineCoreProps) == null ? void 0 : _a.mutationMeta,
17314
17296
  transformApplyValues,
17315
17297
  onSaveButtonPropsChange,
17316
17298
  onSuccess,
@@ -17331,7 +17313,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17331
17313
  [refineFormResult.formResult]
17332
17314
  );
17333
17315
  const currentFormValues = refineFormResult.formResult.getValues();
17334
- const isReady = (formConfig == null ? void 0 : formConfig.isDataReady) ? formConfig.isDataReady(currentFormValues) : !!((_a = currentFormValues == null ? void 0 : currentFormValues.metadata) == null ? void 0 : _a.name);
17316
+ const isReady = (formConfig == null ? void 0 : formConfig.isDataReady) ? formConfig.isDataReady(currentFormValues) : !!((_b = currentFormValues == null ? void 0 : currentFormValues.metadata) == null ? void 0 : _b.name);
17335
17317
  if (action === "edit" && !isReady) {
17336
17318
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Loading, {});
17337
17319
  }
@@ -154,11 +154,6 @@ export type CommonFormConfig<Model extends ResourceModel = ResourceModel> = {
154
154
  * 默认检查 metadata.name,非标准 K8s 资源可覆盖
155
155
  */
156
156
  isDataReady?: (formValues: Record<string, unknown>) => boolean;
157
- /**
158
- * 自定义提交函数,存在时替代 refine core 的 onFinish
159
- * 用于非标准 K8s 资源或需要自定义 API 调用的场景
160
- */
161
- onSubmit?: (values: Record<string, unknown>) => Promise<unknown>;
162
157
  /**
163
158
  * 自定义成功 toast 消息
164
159
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.4.2-alpha.1",
3
+ "version": "0.4.2-alpha.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",