@dovetail-v2/refine 0.3.14 → 0.3.16-alpha.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.
@@ -23,6 +23,7 @@ export interface YamlFormProps<Model extends ResourceModel = ResourceModel> {
23
23
  rules?: YamlFormRule[];
24
24
  transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
25
25
  transformApplyValues?: (values: Unstructured) => Unstructured;
26
+ beforeSubmit?: (values: Unstructured, setErrors: (errors: string[]) => void) => Promise<Unstructured>;
26
27
  onSaveButtonPropsChange?: (saveButtonProps: {
27
28
  disabled?: boolean;
28
29
  onClick: () => void;
@@ -9,6 +9,7 @@ export type UseFormReturnType<TQueryFnData extends BaseRecord = BaseRecord, TErr
9
9
  disabled: boolean;
10
10
  onClick: (e: React.BaseSyntheticEvent) => void;
11
11
  };
12
+ beforeSubmitErrors: string[];
12
13
  };
13
14
  export type UseFormProps<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> = {
14
15
  /**
@@ -29,5 +30,7 @@ export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError ex
29
30
  disableServerSideValidation?: boolean;
30
31
  transformApplyValues?: (values: TVariables) => TVariables;
31
32
  transformInitValues?: (values: Record<string, unknown>) => DefaultValues<TVariables>;
33
+ beforeSubmit?: (values: TVariables, setErrors: (errors: string[]) => void) => Promise<TVariables>;
34
+ onBeforeSubmitError?: (errors: string[]) => void;
32
35
  } & UseHookFormProps<TVariables, TContext>;
33
- 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, ...rest }?: UseFormProps<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>;
36
+ 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, ...rest }?: UseFormProps<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>;
@@ -2,6 +2,7 @@ import { CommonFormConfig, RefineFormConfig, ResourceConfig } from '../../types'
2
2
  import { UseFormProps } from './useReactHookForm';
3
3
  interface UseRefineFormOptions {
4
4
  initialValues?: Record<string, unknown>;
5
+ onBeforeSubmitError?: (errors: string[]) => void;
5
6
  }
6
7
  export declare const useRefineForm: (props: {
7
8
  formConfig?: RefineFormConfig & CommonFormConfig;
@@ -14,5 +15,6 @@ export declare const useRefineForm: (props: {
14
15
  [x: string]: any;
15
16
  }, {}, import("@refinedev/core").BaseRecord, import("@refinedev/core").BaseRecord, import("@refinedev/core").HttpError>;
16
17
  responseErrorMsgs: string[];
18
+ beforeSubmitErrors: string[];
17
19
  };
18
20
  export {};
@@ -27,6 +27,8 @@ export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError ex
27
27
  initialValuesForEdit?: Record<string, unknown>;
28
28
  transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
29
29
  transformApplyValues?: (values: Unstructured) => Unstructured;
30
+ beforeSubmit?: (values: Unstructured, setErrors: (errors: string[]) => void) => Promise<Unstructured>;
31
+ onBeforeSubmitError?: (errors: string[]) => void;
30
32
  rules?: YamlFormRule[];
31
33
  };
32
34
  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> & {
@@ -43,6 +45,7 @@ export type UseFormReturnType<TQueryFnData extends BaseRecord = BaseRecord, TErr
43
45
  loadSchemaError: Error | null;
44
46
  fetchSchema: () => void;
45
47
  errorResponseBody?: Record<string, unknown> | null;
48
+ beforeSubmitErrors: string[];
46
49
  };
47
50
  declare const useYamlForm: <TQueryFnData extends Unstructured = Unstructured & {
48
51
  id: string;
@@ -50,5 +53,5 @@ declare const useYamlForm: <TQueryFnData extends Unstructured = Unstructured & {
50
53
  [prop: string]: unknown;
51
54
  } = {
52
55
  [prop: string]: unknown;
53
- }, 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, rules, }?: UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>;
56
+ }, 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, rules, }?: UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>;
54
57
  export default useYamlForm;
package/dist/refine.cjs CHANGED
@@ -10729,7 +10729,12 @@ function validateLabelValue(value2, i18n2, isOptional) {
10729
10729
  if (isOptional && value2 === "") {
10730
10730
  return { isValid: true };
10731
10731
  } else if (value2 === "") {
10732
- return { isValid: false, errorMessage: i18n2.t("dovetail.required_field", { label: i18n2.t("dovetail.value") }) };
10732
+ return {
10733
+ isValid: false,
10734
+ errorMessage: i18n2.t("dovetail.required_field", {
10735
+ label: i18n2.t("dovetail.value")
10736
+ })
10737
+ };
10733
10738
  }
10734
10739
  if (value2.length > 63) {
10735
10740
  return { isValid: false };
@@ -10766,7 +10771,7 @@ function validatePort(port2, options) {
10766
10771
  return { isValid: true };
10767
10772
  }
10768
10773
  function validateNodePort(nodePort, allNodePorts, i18n2) {
10769
- if (!nodePort) {
10774
+ if (nodePort === "") {
10770
10775
  return {
10771
10776
  isValid: false,
10772
10777
  errorMessage: i18n2.t("dovetail.required_field", {
@@ -11846,7 +11851,7 @@ function _KeyValueTableForm(props, ref) {
11846
11851
  },
11847
11852
  disableBatchFilling: true,
11848
11853
  hideEmptyTable: true
11849
- }), isHideLabelFormatPopover ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(LabelFormatPopover, {
11854
+ }), isHideLabelFormatPopover || _value.length === 0 ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(LabelFormatPopover, {
11850
11855
  noValueValidation
11851
11856
  })]
11852
11857
  });
@@ -15490,6 +15495,8 @@ const useForm = ({
15490
15495
  disableServerSideValidation: disableServerSideValidationProp = false,
15491
15496
  transformApplyValues,
15492
15497
  transformInitValues,
15498
+ beforeSubmit,
15499
+ onBeforeSubmitError,
15493
15500
  ...rest
15494
15501
  } = {}) => {
15495
15502
  const { options } = core.useRefineContext();
@@ -15502,6 +15509,8 @@ const useForm = ({
15502
15509
  defaultValues: transformInitValues && typeof rest.defaultValues === "object" ? transformInitValues(rest.defaultValues) : rest.defaultValues
15503
15510
  });
15504
15511
  const [transformedInitValues, setTransformedInitValues] = React.useState(useHookFormResult.getValues());
15512
+ const [beforeSubmitErrors, setBeforeSubmitErrors] = React.useState([]);
15513
+ const [isBeforeSubmitLoading, setIsBeforeSubmitLoading] = React.useState(false);
15505
15514
  const {
15506
15515
  watch,
15507
15516
  setValue,
@@ -15605,20 +15614,55 @@ const useForm = ({
15605
15614
  const saveButtonProps = React.useMemo(() => {
15606
15615
  return {
15607
15616
  disabled: formLoading,
15608
- onClick: (e2) => {
15617
+ loading: formLoading || isBeforeSubmitLoading,
15618
+ onClick: async (e2) => {
15619
+ setBeforeSubmitErrors([]);
15609
15620
  handleSubmit(
15610
- (v) => onFinish(transformApplyValues ? transformApplyValues(v) : v),
15621
+ async (v) => {
15622
+ let finalValues = transformApplyValues ? transformApplyValues(v) : v;
15623
+ if (beforeSubmit) {
15624
+ try {
15625
+ setIsBeforeSubmitLoading(true);
15626
+ let hasErrors = false;
15627
+ const result = await beforeSubmit(finalValues, (errors) => {
15628
+ if (errors && errors.length > 0) {
15629
+ setBeforeSubmitErrors(errors);
15630
+ onBeforeSubmitError == null ? void 0 : onBeforeSubmitError(errors);
15631
+ hasErrors = true;
15632
+ }
15633
+ });
15634
+ if (hasErrors) {
15635
+ return;
15636
+ }
15637
+ if (result !== void 0) {
15638
+ finalValues = result;
15639
+ }
15640
+ } finally {
15641
+ setIsBeforeSubmitLoading(false);
15642
+ }
15643
+ }
15644
+ return onFinish(finalValues);
15645
+ },
15611
15646
  () => false
15612
15647
  )(e2);
15613
15648
  }
15614
15649
  };
15615
- }, [formLoading, handleSubmit, onFinish, transformApplyValues]);
15650
+ }, [
15651
+ formLoading,
15652
+ isBeforeSubmitLoading,
15653
+ handleSubmit,
15654
+ onFinish,
15655
+ transformApplyValues,
15656
+ beforeSubmit,
15657
+ onBeforeSubmitError
15658
+ ]);
15616
15659
  return {
15617
15660
  ...useHookFormResult,
15618
15661
  transformedInitValues,
15619
15662
  handleSubmit,
15620
15663
  refineCore: useFormCoreResult,
15621
- saveButtonProps
15664
+ saveButtonProps,
15665
+ beforeSubmitErrors
15622
15666
  };
15623
15667
  };
15624
15668
  const useRefineForm = (props) => {
@@ -15660,6 +15704,8 @@ const useRefineForm = (props) => {
15660
15704
  defaultValues: (options == null ? void 0 : options.initialValues) || (config == null ? void 0 : config.initValue),
15661
15705
  transformApplyValues,
15662
15706
  transformInitValues,
15707
+ beforeSubmit: formConfig == null ? void 0 : formConfig.beforeSubmit,
15708
+ onBeforeSubmitError: options == null ? void 0 : options.onBeforeSubmitError,
15663
15709
  ...formConfig == null ? void 0 : formConfig.useFormProps
15664
15710
  });
15665
15711
  React.useEffect(() => {
@@ -15672,7 +15718,7 @@ const useRefineForm = (props) => {
15672
15718
  });
15673
15719
  }
15674
15720
  }, [formConfig, result, i18n2]);
15675
- return { formResult: result, responseErrorMsgs };
15721
+ return { formResult: result, responseErrorMsgs, beforeSubmitErrors: result.beforeSubmitErrors };
15676
15722
  };
15677
15723
  const index_2ivb33 = "";
15678
15724
  const Style = "s1bsn3us";
@@ -16091,6 +16137,8 @@ const useYamlForm = ({
16091
16137
  initialValuesForEdit,
16092
16138
  transformInitValues,
16093
16139
  transformApplyValues,
16140
+ beforeSubmit,
16141
+ onBeforeSubmitError,
16094
16142
  rules
16095
16143
  } = {}) => {
16096
16144
  var _a;
@@ -16100,6 +16148,8 @@ const useYamlForm = ({
16100
16148
  const [isSchemaValid, setIsSchemaValid] = React.useState(true);
16101
16149
  const [editorErrors, setEditorErrors] = React.useState([]);
16102
16150
  const [rulesErrors, setRulesErrors] = React.useState([]);
16151
+ const [isBeforeSubmitLoading, setIsBeforeSubmitLoading] = React.useState(false);
16152
+ const [beforeSubmitErrors, setBeforeSubmitErrors] = React.useState([]);
16103
16153
  const [errorResponseBody, setErrorResponseBody] = React.useState(null);
16104
16154
  const useResourceResult = core.useResource();
16105
16155
  const globalStore = useGlobalStore();
@@ -16175,12 +16225,12 @@ const useYamlForm = ({
16175
16225
  }, [schema]);
16176
16226
  const saveButtonProps = React.useMemo(
16177
16227
  () => ({
16178
- loading: formLoading,
16228
+ loading: formLoading || isBeforeSubmitLoading,
16179
16229
  onClick: () => {
16180
16230
  form2.submit();
16181
16231
  }
16182
16232
  }),
16183
- [formLoading, form2]
16233
+ [formLoading, form2, isBeforeSubmitLoading]
16184
16234
  );
16185
16235
  const emptySchemas = React.useMemo(() => {
16186
16236
  return [];
@@ -16257,6 +16307,7 @@ const useYamlForm = ({
16257
16307
  ...formSF.formProps,
16258
16308
  onFinish: async (values) => {
16259
16309
  var _a2, _b;
16310
+ setBeforeSubmitErrors([]);
16260
16311
  const errors = [
16261
16312
  !isYamlValid ? t2("dovetail.yaml_format_wrong") : "",
16262
16313
  !isSchemaValid ? t2("dovetail.yaml_value_wrong") : ""
@@ -16273,7 +16324,28 @@ const useYamlForm = ({
16273
16324
  }
16274
16325
  try {
16275
16326
  const objectValues = editor.current ? yaml$2.load(((_b = editor.current) == null ? void 0 : _b.getEditorValue()) || "") : values;
16276
- const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
16327
+ let finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
16328
+ if (beforeSubmit) {
16329
+ try {
16330
+ let hasErrors = false;
16331
+ setIsBeforeSubmitLoading(true);
16332
+ const result = await beforeSubmit(finalValues, (errors2) => {
16333
+ if (errors2 && errors2.length > 0) {
16334
+ setBeforeSubmitErrors(errors2);
16335
+ onBeforeSubmitError == null ? void 0 : onBeforeSubmitError(errors2);
16336
+ hasErrors = true;
16337
+ }
16338
+ });
16339
+ if (hasErrors) {
16340
+ return;
16341
+ }
16342
+ if (result !== void 0) {
16343
+ finalValues = result;
16344
+ }
16345
+ } finally {
16346
+ setIsBeforeSubmitLoading(false);
16347
+ }
16348
+ }
16277
16349
  return onFinish(finalValues);
16278
16350
  } catch (error) {
16279
16351
  if (error instanceof Error) {
@@ -16293,6 +16365,7 @@ const useYamlForm = ({
16293
16365
  saveButtonProps,
16294
16366
  ...useFormCoreResult,
16295
16367
  errorResponseBody,
16368
+ beforeSubmitErrors,
16296
16369
  editorProps,
16297
16370
  schemas: schema ? [schema] : [],
16298
16371
  isLoadingSchema,
@@ -16320,6 +16393,7 @@ function YamlForm(props) {
16320
16393
  config,
16321
16394
  transformInitValues,
16322
16395
  transformApplyValues,
16396
+ beforeSubmit,
16323
16397
  onSaveButtonPropsChange,
16324
16398
  onErrorsChange,
16325
16399
  rules
@@ -16340,6 +16414,7 @@ function YamlForm(props) {
16340
16414
  saveButtonProps,
16341
16415
  editorProps,
16342
16416
  errorResponseBody,
16417
+ beforeSubmitErrors,
16343
16418
  mutationResult,
16344
16419
  isLoadingSchema,
16345
16420
  queryResult,
@@ -16356,6 +16431,7 @@ function YamlForm(props) {
16356
16431
  initialValuesForCreate: props.initialValuesForCreate ?? BASE_INIT_VALUE,
16357
16432
  initialValuesForEdit: props.initialValuesForEdit,
16358
16433
  rules,
16434
+ beforeSubmit,
16359
16435
  successNotification(data2) {
16360
16436
  var _a;
16361
16437
  const displayName = config.displayName || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
@@ -16383,6 +16459,18 @@ function YamlForm(props) {
16383
16459
  saveButtonProps
16384
16460
  } : {};
16385
16461
  const responseErrors = React.useMemo(() => errorResponseBody ? getCommonErrors(errorResponseBody, i18n2) : [], [errorResponseBody, i18n2]);
16462
+ const finalErrors = React.useMemo(() => {
16463
+ if (beforeSubmitErrors.length) {
16464
+ return beforeSubmitErrors;
16465
+ }
16466
+ if (mutationResult.error) {
16467
+ if (responseErrors.length) {
16468
+ return responseErrors;
16469
+ }
16470
+ return [mutationResult.error.message];
16471
+ }
16472
+ return [];
16473
+ }, [responseErrors, beforeSubmitErrors, mutationResult.error]);
16386
16474
  const onFinish = React.useCallback(async (store) => {
16387
16475
  var _a, _b;
16388
16476
  try {
@@ -16402,8 +16490,8 @@ function YamlForm(props) {
16402
16490
  onSaveButtonPropsChange == null ? void 0 : onSaveButtonPropsChange(saveButtonProps);
16403
16491
  }, [saveButtonProps, onSaveButtonPropsChange]);
16404
16492
  React.useEffect(() => {
16405
- onErrorsChange == null ? void 0 : onErrorsChange(responseErrors);
16406
- }, [responseErrors, onErrorsChange]);
16493
+ onErrorsChange == null ? void 0 : onErrorsChange(finalErrors);
16494
+ }, [finalErrors, onErrorsChange]);
16407
16495
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(FormWrapper, {
16408
16496
  ...formWrapperProps,
16409
16497
  children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Form, {
@@ -16427,8 +16515,8 @@ function YamlForm(props) {
16427
16515
  collapsable: false
16428
16516
  })
16429
16517
  }), /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Form.Item, {
16430
- children: mutationResult.error && /* @__PURE__ */ common.jsxRuntimeExports.jsx(FormErrorAlert, {
16431
- errorMsgs: errorResponseBody ? responseErrors : [mutationResult.error.message],
16518
+ children: finalErrors.length > 0 && /* @__PURE__ */ common.jsxRuntimeExports.jsx(FormErrorAlert, {
16519
+ errorMsgs: finalErrors,
16432
16520
  style: {
16433
16521
  marginBottom: 16
16434
16522
  },
@@ -16474,7 +16562,14 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
16474
16562
  ...formConfig == null ? void 0 : formConfig.refineCoreProps
16475
16563
  },
16476
16564
  formConfig,
16477
- options
16565
+ options: {
16566
+ ...options,
16567
+ onBeforeSubmitError: (errors) => {
16568
+ if (errors.length) {
16569
+ onError == null ? void 0 : onError();
16570
+ }
16571
+ }
16572
+ }
16478
16573
  });
16479
16574
  const fieldsConfig = useFieldsConfig(
16480
16575
  config,
@@ -16516,6 +16611,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
16516
16611
  validators: "validators" in config2 ? config2.validators : void 0
16517
16612
  })),
16518
16613
  onSaveButtonPropsChange,
16614
+ beforeSubmit: formConfig == null ? void 0 : formConfig.beforeSubmit,
16519
16615
  onErrorsChange(errors) {
16520
16616
  if (errors.length) {
16521
16617
  onError == null ? void 0 : onError();
@@ -16535,6 +16631,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
16535
16631
  config,
16536
16632
  id,
16537
16633
  refineFormResult,
16634
+ formConfig == null ? void 0 : formConfig.beforeSubmit,
16538
16635
  transformApplyValues,
16539
16636
  onSaveButtonPropsChange,
16540
16637
  onSuccess,
@@ -16576,7 +16673,10 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
16576
16673
  config,
16577
16674
  step,
16578
16675
  formConfig,
16579
- errorMsgs: refineFormResult.responseErrorMsgs,
16676
+ errorMsgs: [
16677
+ ...refineFormResult.responseErrorMsgs,
16678
+ ...refineFormResult.beforeSubmitErrors
16679
+ ],
16580
16680
  resourceId: id,
16581
16681
  transformedInitValues: refineFormResult.formResult.transformedInitValues,
16582
16682
  customOptions: options == null ? void 0 : options.customOptions
@@ -16606,6 +16706,7 @@ function YamlFormContainer({
16606
16706
  config,
16607
16707
  transformInitValues,
16608
16708
  transformApplyValues,
16709
+ beforeSubmit: formConfig == null ? void 0 : formConfig.beforeSubmit,
16609
16710
  initialValuesForCreate: (customYamlFormProps == null ? void 0 : customYamlFormProps.initialValuesForCreate) || getInitialValues(config),
16610
16711
  initialValuesForEdit: void 0,
16611
16712
  id,
@@ -16628,6 +16729,7 @@ function YamlFormContainer({
16628
16729
  action,
16629
16730
  customYamlFormProps,
16630
16731
  config,
16732
+ formConfig == null ? void 0 : formConfig.beforeSubmit,
16631
16733
  transformInitValues,
16632
16734
  transformApplyValues,
16633
16735
  onSuccess,
@@ -17846,7 +17948,7 @@ const MatchLabelSelector = React.forwardRef(function MatchLabelSelector2(props,
17846
17948
  }
17847
17949
  ),
17848
17950
  onChange,
17849
- isValueOptional: false,
17951
+ isValueOptional: true,
17850
17952
  minSize: 1,
17851
17953
  disabledChagneDefaultValues
17852
17954
  }
@@ -18685,7 +18787,7 @@ const PortsConfigForm = React.forwardRef(function PortsConfigForm2({ value: valu
18685
18787
  },
18686
18788
  {
18687
18789
  key: "name",
18688
- title: i18n2.t("dovetail.port_name"),
18790
+ title: `${i18n2.t("dovetail.name")} ${i18n2.t("dovetail.optional_with_bracket")}`,
18689
18791
  type: "input",
18690
18792
  validator: ({ value: portName, rowIndex }) => {
18691
18793
  const { errorMessage } = validateRfc1123Name({
@@ -18713,7 +18815,7 @@ const PortsConfigForm = React.forwardRef(function PortsConfigForm2({ value: valu
18713
18815
  );
18714
18816
  },
18715
18817
  validator: ({ value: value22 }) => {
18716
- const { isValid, errorMessage } = validatePort(value22 || "", {
18818
+ const { isValid, errorMessage } = validatePort(value22 ?? "", {
18717
18819
  isOptional: false,
18718
18820
  i18n: i18n2,
18719
18821
  emptyText: i18n2.t("dovetail.required_field", {
@@ -18739,7 +18841,7 @@ const PortsConfigForm = React.forwardRef(function PortsConfigForm2({ value: valu
18739
18841
  );
18740
18842
  },
18741
18843
  validator: ({ value: value22 }) => {
18742
- const { isValid, errorMessage } = validatePort(value22 || "", {
18844
+ const { isValid, errorMessage } = validatePort(value22 ?? "", {
18743
18845
  isOptional: false,
18744
18846
  i18n: i18n2,
18745
18847
  emptyText: i18n2.t("dovetail.required_field", {
@@ -18776,7 +18878,7 @@ const PortsConfigForm = React.forwardRef(function PortsConfigForm2({ value: valu
18776
18878
  }
18777
18879
  ).map((row) => row.nodePort.value)
18778
18880
  ];
18779
- const { isValid, errorMessage } = value22.mode === "auto" ? { isValid: true, errorMessage: void 0 } : validateNodePort(value22.value, allNodePorts, i18n2);
18881
+ const { isValid, errorMessage } = value22.mode === "auto" ? { isValid: true, errorMessage: void 0 } : validateNodePort(value22.value ?? "", allNodePorts, i18n2);
18780
18882
  if (!isValid)
18781
18883
  return errorMessage;
18782
18884
  }
@@ -19377,13 +19479,7 @@ const DataKeysColumnRenderer = (i18n2) => {
19377
19479
  const PortMappingColumnRenderer = (i18n2) => {
19378
19480
  return {
19379
19481
  key: "displayPortMapping",
19380
- title: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Tooltip, {
19381
- title: i18n2.t("dovetail.port_mapping_title_tooltip"),
19382
- children: /* @__PURE__ */ common.jsxRuntimeExports.jsx("span", {
19383
- className: DashedTitleStyle,
19384
- children: i18n2.t("dovetail.port_mapping")
19385
- })
19386
- }),
19482
+ title: i18n2.t("dovetail.port_mapping"),
19387
19483
  display: true,
19388
19484
  dataIndex: ["displayPortMapping"],
19389
19485
  width: 300,
@@ -19951,6 +20047,7 @@ exports.DataTab = DataTab;
19951
20047
  exports.DeleteButton = DeleteButton;
19952
20048
  exports.DeleteManyButton = DeleteManyButton;
19953
20049
  exports.DeploymentModel = DeploymentModel;
20050
+ exports.DnsSubdomainRegExp = DnsSubdomainRegExp;
19954
20051
  exports.Dovetail = Dovetail;
19955
20052
  exports.DrawerShow = DrawerShow;
19956
20053
  exports.DurationColumnRenderer = DurationColumnRenderer;
@@ -20112,6 +20209,8 @@ exports.ResourceTableField = ResourceTableField;
20112
20209
  exports.ResourceTableGroup = ResourceTableGroup;
20113
20210
  exports.ResourceUsageBar = ResourceUsageBar;
20114
20211
  exports.RestartsColumnRenderer = RestartsColumnRenderer;
20212
+ exports.Rfc1035NameRegExp = Rfc1035NameRegExp;
20213
+ exports.Rfc1123NameRegExp = Rfc1123NameRegExp;
20115
20214
  exports.SCAllowExpandColumnRenderer = SCAllowExpandColumnRenderer;
20116
20215
  exports.SCReclaimPolicyColumnRenderer = SCReclaimPolicyColumnRenderer;
20117
20216
  exports.SCReclaimPolicyField = SCReclaimPolicyField;
package/dist/refine.js CHANGED
@@ -10710,7 +10710,12 @@ function validateLabelValue(value2, i18n2, isOptional) {
10710
10710
  if (isOptional && value2 === "") {
10711
10711
  return { isValid: true };
10712
10712
  } else if (value2 === "") {
10713
- return { isValid: false, errorMessage: i18n2.t("dovetail.required_field", { label: i18n2.t("dovetail.value") }) };
10713
+ return {
10714
+ isValid: false,
10715
+ errorMessage: i18n2.t("dovetail.required_field", {
10716
+ label: i18n2.t("dovetail.value")
10717
+ })
10718
+ };
10714
10719
  }
10715
10720
  if (value2.length > 63) {
10716
10721
  return { isValid: false };
@@ -10747,7 +10752,7 @@ function validatePort(port2, options) {
10747
10752
  return { isValid: true };
10748
10753
  }
10749
10754
  function validateNodePort(nodePort, allNodePorts, i18n2) {
10750
- if (!nodePort) {
10755
+ if (nodePort === "") {
10751
10756
  return {
10752
10757
  isValid: false,
10753
10758
  errorMessage: i18n2.t("dovetail.required_field", {
@@ -11827,7 +11832,7 @@ function _KeyValueTableForm(props, ref) {
11827
11832
  },
11828
11833
  disableBatchFilling: true,
11829
11834
  hideEmptyTable: true
11830
- }), isHideLabelFormatPopover ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(LabelFormatPopover, {
11835
+ }), isHideLabelFormatPopover || _value.length === 0 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(LabelFormatPopover, {
11831
11836
  noValueValidation
11832
11837
  })]
11833
11838
  });
@@ -15471,6 +15476,8 @@ const useForm = ({
15471
15476
  disableServerSideValidation: disableServerSideValidationProp = false,
15472
15477
  transformApplyValues,
15473
15478
  transformInitValues,
15479
+ beforeSubmit,
15480
+ onBeforeSubmitError,
15474
15481
  ...rest
15475
15482
  } = {}) => {
15476
15483
  const { options } = useRefineContext();
@@ -15483,6 +15490,8 @@ const useForm = ({
15483
15490
  defaultValues: transformInitValues && typeof rest.defaultValues === "object" ? transformInitValues(rest.defaultValues) : rest.defaultValues
15484
15491
  });
15485
15492
  const [transformedInitValues, setTransformedInitValues] = useState(useHookFormResult.getValues());
15493
+ const [beforeSubmitErrors, setBeforeSubmitErrors] = useState([]);
15494
+ const [isBeforeSubmitLoading, setIsBeforeSubmitLoading] = useState(false);
15486
15495
  const {
15487
15496
  watch,
15488
15497
  setValue,
@@ -15586,20 +15595,55 @@ const useForm = ({
15586
15595
  const saveButtonProps = useMemo(() => {
15587
15596
  return {
15588
15597
  disabled: formLoading,
15589
- onClick: (e2) => {
15598
+ loading: formLoading || isBeforeSubmitLoading,
15599
+ onClick: async (e2) => {
15600
+ setBeforeSubmitErrors([]);
15590
15601
  handleSubmit(
15591
- (v) => onFinish(transformApplyValues ? transformApplyValues(v) : v),
15602
+ async (v) => {
15603
+ let finalValues = transformApplyValues ? transformApplyValues(v) : v;
15604
+ if (beforeSubmit) {
15605
+ try {
15606
+ setIsBeforeSubmitLoading(true);
15607
+ let hasErrors = false;
15608
+ const result = await beforeSubmit(finalValues, (errors) => {
15609
+ if (errors && errors.length > 0) {
15610
+ setBeforeSubmitErrors(errors);
15611
+ onBeforeSubmitError == null ? void 0 : onBeforeSubmitError(errors);
15612
+ hasErrors = true;
15613
+ }
15614
+ });
15615
+ if (hasErrors) {
15616
+ return;
15617
+ }
15618
+ if (result !== void 0) {
15619
+ finalValues = result;
15620
+ }
15621
+ } finally {
15622
+ setIsBeforeSubmitLoading(false);
15623
+ }
15624
+ }
15625
+ return onFinish(finalValues);
15626
+ },
15592
15627
  () => false
15593
15628
  )(e2);
15594
15629
  }
15595
15630
  };
15596
- }, [formLoading, handleSubmit, onFinish, transformApplyValues]);
15631
+ }, [
15632
+ formLoading,
15633
+ isBeforeSubmitLoading,
15634
+ handleSubmit,
15635
+ onFinish,
15636
+ transformApplyValues,
15637
+ beforeSubmit,
15638
+ onBeforeSubmitError
15639
+ ]);
15597
15640
  return {
15598
15641
  ...useHookFormResult,
15599
15642
  transformedInitValues,
15600
15643
  handleSubmit,
15601
15644
  refineCore: useFormCoreResult,
15602
- saveButtonProps
15645
+ saveButtonProps,
15646
+ beforeSubmitErrors
15603
15647
  };
15604
15648
  };
15605
15649
  const useRefineForm = (props) => {
@@ -15641,6 +15685,8 @@ const useRefineForm = (props) => {
15641
15685
  defaultValues: (options == null ? void 0 : options.initialValues) || (config == null ? void 0 : config.initValue),
15642
15686
  transformApplyValues,
15643
15687
  transformInitValues,
15688
+ beforeSubmit: formConfig == null ? void 0 : formConfig.beforeSubmit,
15689
+ onBeforeSubmitError: options == null ? void 0 : options.onBeforeSubmitError,
15644
15690
  ...formConfig == null ? void 0 : formConfig.useFormProps
15645
15691
  });
15646
15692
  useEffect(() => {
@@ -15653,7 +15699,7 @@ const useRefineForm = (props) => {
15653
15699
  });
15654
15700
  }
15655
15701
  }, [formConfig, result, i18n2]);
15656
- return { formResult: result, responseErrorMsgs };
15702
+ return { formResult: result, responseErrorMsgs, beforeSubmitErrors: result.beforeSubmitErrors };
15657
15703
  };
15658
15704
  const index_2ivb33 = "";
15659
15705
  const Style = "s1bsn3us";
@@ -16072,6 +16118,8 @@ const useYamlForm = ({
16072
16118
  initialValuesForEdit,
16073
16119
  transformInitValues,
16074
16120
  transformApplyValues,
16121
+ beforeSubmit,
16122
+ onBeforeSubmitError,
16075
16123
  rules
16076
16124
  } = {}) => {
16077
16125
  var _a;
@@ -16081,6 +16129,8 @@ const useYamlForm = ({
16081
16129
  const [isSchemaValid, setIsSchemaValid] = useState(true);
16082
16130
  const [editorErrors, setEditorErrors] = useState([]);
16083
16131
  const [rulesErrors, setRulesErrors] = useState([]);
16132
+ const [isBeforeSubmitLoading, setIsBeforeSubmitLoading] = useState(false);
16133
+ const [beforeSubmitErrors, setBeforeSubmitErrors] = useState([]);
16084
16134
  const [errorResponseBody, setErrorResponseBody] = useState(null);
16085
16135
  const useResourceResult = useResource();
16086
16136
  const globalStore = useGlobalStore();
@@ -16156,12 +16206,12 @@ const useYamlForm = ({
16156
16206
  }, [schema]);
16157
16207
  const saveButtonProps = useMemo(
16158
16208
  () => ({
16159
- loading: formLoading,
16209
+ loading: formLoading || isBeforeSubmitLoading,
16160
16210
  onClick: () => {
16161
16211
  form2.submit();
16162
16212
  }
16163
16213
  }),
16164
- [formLoading, form2]
16214
+ [formLoading, form2, isBeforeSubmitLoading]
16165
16215
  );
16166
16216
  const emptySchemas = useMemo(() => {
16167
16217
  return [];
@@ -16238,6 +16288,7 @@ const useYamlForm = ({
16238
16288
  ...formSF.formProps,
16239
16289
  onFinish: async (values) => {
16240
16290
  var _a2, _b;
16291
+ setBeforeSubmitErrors([]);
16241
16292
  const errors = [
16242
16293
  !isYamlValid ? t2("dovetail.yaml_format_wrong") : "",
16243
16294
  !isSchemaValid ? t2("dovetail.yaml_value_wrong") : ""
@@ -16254,7 +16305,28 @@ const useYamlForm = ({
16254
16305
  }
16255
16306
  try {
16256
16307
  const objectValues = editor.current ? yaml$2.load(((_b = editor.current) == null ? void 0 : _b.getEditorValue()) || "") : values;
16257
- const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
16308
+ let finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
16309
+ if (beforeSubmit) {
16310
+ try {
16311
+ let hasErrors = false;
16312
+ setIsBeforeSubmitLoading(true);
16313
+ const result = await beforeSubmit(finalValues, (errors2) => {
16314
+ if (errors2 && errors2.length > 0) {
16315
+ setBeforeSubmitErrors(errors2);
16316
+ onBeforeSubmitError == null ? void 0 : onBeforeSubmitError(errors2);
16317
+ hasErrors = true;
16318
+ }
16319
+ });
16320
+ if (hasErrors) {
16321
+ return;
16322
+ }
16323
+ if (result !== void 0) {
16324
+ finalValues = result;
16325
+ }
16326
+ } finally {
16327
+ setIsBeforeSubmitLoading(false);
16328
+ }
16329
+ }
16258
16330
  return onFinish(finalValues);
16259
16331
  } catch (error) {
16260
16332
  if (error instanceof Error) {
@@ -16274,6 +16346,7 @@ const useYamlForm = ({
16274
16346
  saveButtonProps,
16275
16347
  ...useFormCoreResult,
16276
16348
  errorResponseBody,
16349
+ beforeSubmitErrors,
16277
16350
  editorProps,
16278
16351
  schemas: schema ? [schema] : [],
16279
16352
  isLoadingSchema,
@@ -16301,6 +16374,7 @@ function YamlForm(props) {
16301
16374
  config,
16302
16375
  transformInitValues,
16303
16376
  transformApplyValues,
16377
+ beforeSubmit,
16304
16378
  onSaveButtonPropsChange,
16305
16379
  onErrorsChange,
16306
16380
  rules
@@ -16321,6 +16395,7 @@ function YamlForm(props) {
16321
16395
  saveButtonProps,
16322
16396
  editorProps,
16323
16397
  errorResponseBody,
16398
+ beforeSubmitErrors,
16324
16399
  mutationResult,
16325
16400
  isLoadingSchema,
16326
16401
  queryResult,
@@ -16337,6 +16412,7 @@ function YamlForm(props) {
16337
16412
  initialValuesForCreate: props.initialValuesForCreate ?? BASE_INIT_VALUE,
16338
16413
  initialValuesForEdit: props.initialValuesForEdit,
16339
16414
  rules,
16415
+ beforeSubmit,
16340
16416
  successNotification(data2) {
16341
16417
  var _a;
16342
16418
  const displayName = config.displayName || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
@@ -16364,6 +16440,18 @@ function YamlForm(props) {
16364
16440
  saveButtonProps
16365
16441
  } : {};
16366
16442
  const responseErrors = useMemo(() => errorResponseBody ? getCommonErrors(errorResponseBody, i18n2) : [], [errorResponseBody, i18n2]);
16443
+ const finalErrors = useMemo(() => {
16444
+ if (beforeSubmitErrors.length) {
16445
+ return beforeSubmitErrors;
16446
+ }
16447
+ if (mutationResult.error) {
16448
+ if (responseErrors.length) {
16449
+ return responseErrors;
16450
+ }
16451
+ return [mutationResult.error.message];
16452
+ }
16453
+ return [];
16454
+ }, [responseErrors, beforeSubmitErrors, mutationResult.error]);
16367
16455
  const onFinish = useCallback(async (store) => {
16368
16456
  var _a, _b;
16369
16457
  try {
@@ -16383,8 +16471,8 @@ function YamlForm(props) {
16383
16471
  onSaveButtonPropsChange == null ? void 0 : onSaveButtonPropsChange(saveButtonProps);
16384
16472
  }, [saveButtonProps, onSaveButtonPropsChange]);
16385
16473
  useEffect(() => {
16386
- onErrorsChange == null ? void 0 : onErrorsChange(responseErrors);
16387
- }, [responseErrors, onErrorsChange]);
16474
+ onErrorsChange == null ? void 0 : onErrorsChange(finalErrors);
16475
+ }, [finalErrors, onErrorsChange]);
16388
16476
  return /* @__PURE__ */ jsxRuntimeExports.jsx(FormWrapper, {
16389
16477
  ...formWrapperProps,
16390
16478
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(Form, {
@@ -16408,8 +16496,8 @@ function YamlForm(props) {
16408
16496
  collapsable: false
16409
16497
  })
16410
16498
  }), /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Item, {
16411
- children: mutationResult.error && /* @__PURE__ */ jsxRuntimeExports.jsx(FormErrorAlert, {
16412
- errorMsgs: errorResponseBody ? responseErrors : [mutationResult.error.message],
16499
+ children: finalErrors.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(FormErrorAlert, {
16500
+ errorMsgs: finalErrors,
16413
16501
  style: {
16414
16502
  marginBottom: 16
16415
16503
  },
@@ -16455,7 +16543,14 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
16455
16543
  ...formConfig == null ? void 0 : formConfig.refineCoreProps
16456
16544
  },
16457
16545
  formConfig,
16458
- options
16546
+ options: {
16547
+ ...options,
16548
+ onBeforeSubmitError: (errors) => {
16549
+ if (errors.length) {
16550
+ onError == null ? void 0 : onError();
16551
+ }
16552
+ }
16553
+ }
16459
16554
  });
16460
16555
  const fieldsConfig = useFieldsConfig(
16461
16556
  config,
@@ -16497,6 +16592,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
16497
16592
  validators: "validators" in config2 ? config2.validators : void 0
16498
16593
  })),
16499
16594
  onSaveButtonPropsChange,
16595
+ beforeSubmit: formConfig == null ? void 0 : formConfig.beforeSubmit,
16500
16596
  onErrorsChange(errors) {
16501
16597
  if (errors.length) {
16502
16598
  onError == null ? void 0 : onError();
@@ -16516,6 +16612,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
16516
16612
  config,
16517
16613
  id,
16518
16614
  refineFormResult,
16615
+ formConfig == null ? void 0 : formConfig.beforeSubmit,
16519
16616
  transformApplyValues,
16520
16617
  onSaveButtonPropsChange,
16521
16618
  onSuccess,
@@ -16557,7 +16654,10 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
16557
16654
  config,
16558
16655
  step,
16559
16656
  formConfig,
16560
- errorMsgs: refineFormResult.responseErrorMsgs,
16657
+ errorMsgs: [
16658
+ ...refineFormResult.responseErrorMsgs,
16659
+ ...refineFormResult.beforeSubmitErrors
16660
+ ],
16561
16661
  resourceId: id,
16562
16662
  transformedInitValues: refineFormResult.formResult.transformedInitValues,
16563
16663
  customOptions: options == null ? void 0 : options.customOptions
@@ -16587,6 +16687,7 @@ function YamlFormContainer({
16587
16687
  config,
16588
16688
  transformInitValues,
16589
16689
  transformApplyValues,
16690
+ beforeSubmit: formConfig == null ? void 0 : formConfig.beforeSubmit,
16590
16691
  initialValuesForCreate: (customYamlFormProps == null ? void 0 : customYamlFormProps.initialValuesForCreate) || getInitialValues(config),
16591
16692
  initialValuesForEdit: void 0,
16592
16693
  id,
@@ -16609,6 +16710,7 @@ function YamlFormContainer({
16609
16710
  action,
16610
16711
  customYamlFormProps,
16611
16712
  config,
16713
+ formConfig == null ? void 0 : formConfig.beforeSubmit,
16612
16714
  transformInitValues,
16613
16715
  transformApplyValues,
16614
16716
  onSuccess,
@@ -17827,7 +17929,7 @@ const MatchLabelSelector = React.forwardRef(function MatchLabelSelector2(props,
17827
17929
  }
17828
17930
  ),
17829
17931
  onChange,
17830
- isValueOptional: false,
17932
+ isValueOptional: true,
17831
17933
  minSize: 1,
17832
17934
  disabledChagneDefaultValues
17833
17935
  }
@@ -18666,7 +18768,7 @@ const PortsConfigForm = React.forwardRef(function PortsConfigForm2({ value: valu
18666
18768
  },
18667
18769
  {
18668
18770
  key: "name",
18669
- title: i18n2.t("dovetail.port_name"),
18771
+ title: `${i18n2.t("dovetail.name")} ${i18n2.t("dovetail.optional_with_bracket")}`,
18670
18772
  type: "input",
18671
18773
  validator: ({ value: portName, rowIndex }) => {
18672
18774
  const { errorMessage } = validateRfc1123Name({
@@ -18694,7 +18796,7 @@ const PortsConfigForm = React.forwardRef(function PortsConfigForm2({ value: valu
18694
18796
  );
18695
18797
  },
18696
18798
  validator: ({ value: value22 }) => {
18697
- const { isValid, errorMessage } = validatePort(value22 || "", {
18799
+ const { isValid, errorMessage } = validatePort(value22 ?? "", {
18698
18800
  isOptional: false,
18699
18801
  i18n: i18n2,
18700
18802
  emptyText: i18n2.t("dovetail.required_field", {
@@ -18720,7 +18822,7 @@ const PortsConfigForm = React.forwardRef(function PortsConfigForm2({ value: valu
18720
18822
  );
18721
18823
  },
18722
18824
  validator: ({ value: value22 }) => {
18723
- const { isValid, errorMessage } = validatePort(value22 || "", {
18825
+ const { isValid, errorMessage } = validatePort(value22 ?? "", {
18724
18826
  isOptional: false,
18725
18827
  i18n: i18n2,
18726
18828
  emptyText: i18n2.t("dovetail.required_field", {
@@ -18757,7 +18859,7 @@ const PortsConfigForm = React.forwardRef(function PortsConfigForm2({ value: valu
18757
18859
  }
18758
18860
  ).map((row) => row.nodePort.value)
18759
18861
  ];
18760
- const { isValid, errorMessage } = value22.mode === "auto" ? { isValid: true, errorMessage: void 0 } : validateNodePort(value22.value, allNodePorts, i18n2);
18862
+ const { isValid, errorMessage } = value22.mode === "auto" ? { isValid: true, errorMessage: void 0 } : validateNodePort(value22.value ?? "", allNodePorts, i18n2);
18761
18863
  if (!isValid)
18762
18864
  return errorMessage;
18763
18865
  }
@@ -19358,13 +19460,7 @@ const DataKeysColumnRenderer = (i18n2) => {
19358
19460
  const PortMappingColumnRenderer = (i18n2) => {
19359
19461
  return {
19360
19462
  key: "displayPortMapping",
19361
- title: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, {
19362
- title: i18n2.t("dovetail.port_mapping_title_tooltip"),
19363
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
19364
- className: DashedTitleStyle,
19365
- children: i18n2.t("dovetail.port_mapping")
19366
- })
19367
- }),
19463
+ title: i18n2.t("dovetail.port_mapping"),
19368
19464
  display: true,
19369
19465
  dataIndex: ["displayPortMapping"],
19370
19466
  width: 300,
@@ -19933,6 +20029,7 @@ export {
19933
20029
  DeleteButton,
19934
20030
  DeleteManyButton,
19935
20031
  DeploymentModel,
20032
+ DnsSubdomainRegExp,
19936
20033
  Dovetail,
19937
20034
  DrawerShow,
19938
20035
  DurationColumnRenderer,
@@ -20094,6 +20191,8 @@ export {
20094
20191
  ResourceTableGroup,
20095
20192
  ResourceUsageBar,
20096
20193
  RestartsColumnRenderer,
20194
+ Rfc1035NameRegExp,
20195
+ Rfc1123NameRegExp,
20097
20196
  SCAllowExpandColumnRenderer,
20098
20197
  SCReclaimPolicyColumnRenderer,
20099
20198
  SCReclaimPolicyField,
@@ -111,6 +111,13 @@ export type CommonFormConfig<Model extends ResourceModel = ResourceModel> = {
111
111
  * @returns YAML格式的数据
112
112
  */
113
113
  transformApplyValues?: (values: Record<string, unknown>) => Model['_rawYaml'];
114
+ /**
115
+ * 提交前回调函数
116
+ * @param values 表单值
117
+ * @param setErrors 设置错误信息的函数,如果调用此函数并传入错误信息,将阻止提交
118
+ * @returns 可选的处理后的值,如果返回值存在,将使用返回值替代原始值进行提交
119
+ */
120
+ beforeSubmit?: (values: Record<string, unknown>, setErrors: (errors: string[]) => void) => Promise<Model['_rawYaml']>;
114
121
  /** 表单容器类型:页面形式或模态框形式
115
122
  * PAGE 或者 MODAL
116
123
  */
@@ -1,4 +1,7 @@
1
1
  import { i18n as I18n } from 'i18next';
2
+ export declare const Rfc1123NameRegExp: RegExp;
3
+ export declare const Rfc1035NameRegExp: RegExp;
4
+ export declare const DnsSubdomainRegExp: RegExp;
2
5
  interface ValidateResourceNameOptions {
3
6
  v: string;
4
7
  allNames: string[];
@@ -58,7 +61,7 @@ export declare function validatePort(port: string | number, options: {
58
61
  isValid: boolean;
59
62
  errorMessage?: string;
60
63
  };
61
- export declare function validateNodePort(nodePort: number | null, allNodePorts: number[], i18n: I18n): {
64
+ export declare function validateNodePort(nodePort: number | string | null, allNodePorts: number[], i18n: I18n): {
62
65
  isValid: boolean;
63
66
  errorMessage?: string;
64
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.3.14",
3
+ "version": "0.3.16-alpha.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",