shineout 3.5.4-beta.2 → 3.5.4-beta.3

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.
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import IForm from './form';
3
- import { useFormRef as useForm, useFromInstance } from '@sheinx/hooks';
3
+ import { useFormRef as useForm, useFormInstance } from '@sheinx/hooks';
4
4
  type RefForm = typeof IForm;
5
5
  declare const Button: ((props: import("./interface").SubmitProps) => JSX.Element) & {
6
6
  displayName: string;
@@ -32,7 +32,7 @@ export interface FormComponent extends RefForm {
32
32
  Reset: typeof Reset;
33
33
  Flow: typeof FormFlow;
34
34
  useForm: typeof useForm;
35
- useFromInstance: typeof useFromInstance;
35
+ useFormInstance: typeof useFormInstance;
36
36
  }
37
37
  declare const FormComp: FormComponent;
38
38
  export default FormComp;
package/cjs/form/index.js CHANGED
@@ -36,5 +36,5 @@ FormComp.Submit = Submit;
36
36
  FormComp.Reset = Reset;
37
37
  FormComp.Flow = FormFlow;
38
38
  FormComp.useForm = _hooks.useFormRef;
39
- FormComp.useFromInstance = _hooks.useFromInstance;
39
+ FormComp.useFormInstance = _hooks.useFormInstance;
40
40
  var _default = exports.default = FormComp;
package/cjs/index.js CHANGED
@@ -500,5 +500,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
500
500
  // 此文件由脚本自动生成,请勿直接修改。
501
501
  // This file was generated automatically by a script. Please do not modify it directly.
502
502
  var _default = exports.default = {
503
- version: '3.5.4-beta.2'
503
+ version: '3.5.4-beta.3'
504
504
  };
package/dist/shineout.js CHANGED
@@ -12030,7 +12030,7 @@ var handleStyle = function handleStyle(style) {
12030
12030
  };
12031
12031
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12032
12032
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12033
- /* harmony default export */ var version = ('3.5.4-beta.2');
12033
+ /* harmony default export */ var version = ('3.5.4-beta.3');
12034
12034
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12035
12035
 
12036
12036
 
@@ -48036,7 +48036,7 @@ function useFormRef() {
48036
48036
  };
48037
48037
  return [ref.current, setFormRef];
48038
48038
  }
48039
- function useFromInstance() {
48039
+ function useFormInstance() {
48040
48040
  var formCtx = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useContext(FormContext);
48041
48041
  return formCtx;
48042
48042
  }
@@ -48132,10 +48132,25 @@ var Form = function Form(props) {
48132
48132
  handleFormModalInfo();
48133
48133
  }, [props.disabled, props.pending]);
48134
48134
  var rootClass = classnames_default()([formClasses === null || formClasses === void 0 ? void 0 : formClasses.rootClass, formClasses === null || formClasses === void 0 ? void 0 : formClasses.wrapper, className, props.inline && (formClasses === null || formClasses === void 0 ? void 0 : formClasses.wrapperInline)]);
48135
- return /*#__PURE__*/(0,jsx_runtime.jsx)("form", objectSpread2_default()(objectSpread2_default()({}, getFormProps({
48135
+ var formProps = getFormProps({
48136
48136
  className: rootClass,
48137
48137
  style: style
48138
+ });
48139
+ var formElRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
48140
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
48141
+ if (formElRef.current instanceof HTMLFormElement) {
48142
+ formElRef.current.addEventListener('submit', formProps.onSubmit);
48143
+ }
48144
+ return function () {
48145
+ if (formElRef.current instanceof HTMLFormElement) {
48146
+ formElRef.current.removeEventListener('submit', formProps.onSubmit);
48147
+ }
48148
+ };
48149
+ }, [formProps.onSubmit]);
48150
+ return /*#__PURE__*/(0,jsx_runtime.jsx)("form", objectSpread2_default()(objectSpread2_default()({}, removeProps(formProps, {
48151
+ onSubmit: true
48138
48152
  })), {}, {
48153
+ ref: formElRef,
48139
48154
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(Provider, objectSpread2_default()(objectSpread2_default()({}, ProviderProps), {}, {
48140
48155
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(FormContext.Provider, {
48141
48156
  value: formRefObj,
@@ -48691,6 +48706,11 @@ var FormButton = function FormButton(props) {
48691
48706
  if (formFunc && props.htmlType === 'button') {
48692
48707
  formFunc.submit();
48693
48708
  }
48709
+ if (formFunc && props.htmlType === 'reset') {
48710
+ // 阻止默认的form reset,改用formFunc.reset。处理嵌套form的reset问题。
48711
+ e.preventDefault();
48712
+ formFunc.reset();
48713
+ }
48694
48714
  if (props.onClick) {
48695
48715
  props.onClick(e);
48696
48716
  }
@@ -48763,7 +48783,7 @@ FormComp.Submit = form_Submit;
48763
48783
  FormComp.Reset = form_Reset;
48764
48784
  FormComp.Flow = form_FormFlow;
48765
48785
  FormComp.useForm = useFormRef;
48766
- FormComp.useFromInstance = useFromInstance;
48786
+ FormComp.useFormInstance = useFormInstance;
48767
48787
  /* harmony default export */ var src_form_0 = (FormComp);
48768
48788
  ;// CONCATENATED MODULE: ../base/src/gap/support.ts
48769
48789
  function support_flexGapSupport() {
@@ -66970,7 +66990,7 @@ var upload_interface = __webpack_require__(8821);
66970
66990
 
66971
66991
 
66972
66992
  /* harmony default export */ var src_0 = ({
66973
- version: '3.5.4-beta.2'
66993
+ version: '3.5.4-beta.3'
66974
66994
  });
66975
66995
  }();
66976
66996
  /******/ return __webpack_exports__;