react-mario-core 1.0.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/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # mario-core
2
+ 用于react-mario基础组件构建及渲染
@@ -0,0 +1,3 @@
1
+ import { ComponentRegistryConfig } from '../types';
2
+
3
+ export declare const defaultComponents: ComponentRegistryConfig[];
@@ -0,0 +1,4 @@
1
+ declare const App: (() => import("react/jsx-runtime").JSX.Element) & {
2
+ displayName: string;
3
+ };
4
+ export default App;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+ import { FormRendererProps } from '../types';
3
+
4
+ declare const FormRenderer: React.FC<FormRendererProps>;
5
+ export default FormRenderer;
@@ -0,0 +1,30 @@
1
+ "use strict";var gr=Object.defineProperty;var hr=(v,o,l)=>o in v?gr(v,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):v[o]=l;var Ve=(v,o,l)=>hr(v,typeof o!="symbol"?o+"":o,l);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react"),yr=require("mobx-react-lite"),Q=require("react-antd-xform"),br=require("antd");var ve={exports:{}},M={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Ye;function Rr(){if(Ye)return M;Ye=1;var v=$,o=Symbol.for("react.element"),l=Symbol.for("react.fragment"),b=Object.prototype.hasOwnProperty,k=v.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,F={key:!0,ref:!0,__self:!0,__source:!0};function x(_,p,T){var g,R={},C=null,D=null;T!==void 0&&(C=""+T),p.key!==void 0&&(C=""+p.key),p.ref!==void 0&&(D=p.ref);for(g in p)b.call(p,g)&&!F.hasOwnProperty(g)&&(R[g]=p[g]);if(_&&_.defaultProps)for(g in p=_.defaultProps,p)R[g]===void 0&&(R[g]=p[g]);return{$$typeof:o,type:_,key:C,ref:D,props:R,_owner:k.current}}return M.Fragment=l,M.jsx=x,M.jsxs=x,M}var q={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Me;function Er(){return Me||(Me=1,process.env.NODE_ENV!=="production"&&function(){var v=$,o=Symbol.for("react.element"),l=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),F=Symbol.for("react.profiler"),x=Symbol.for("react.provider"),_=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),N=Symbol.iterator,B="@@iterator";function U(e){if(e===null||typeof e!="object")return null;var r=N&&e[N]||e[B];return typeof r=="function"?r:null}var w=v.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function u(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];ee("error",e,t)}}function ee(e,r,t){{var n=w.ReactDebugCurrentFrame,s=n.getStackAddendum();s!==""&&(r+="%s",t=t.concat([s]));var c=t.map(function(i){return String(i)});c.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,c)}}var W=!1,J=!1,re=!1,te=!1,ne=!1,X;X=Symbol.for("react.module.reference");function ae(e){return!!(typeof e=="string"||typeof e=="function"||e===b||e===F||ne||e===k||e===T||e===g||te||e===D||W||J||re||typeof e=="object"&&e!==null&&(e.$$typeof===C||e.$$typeof===R||e.$$typeof===x||e.$$typeof===_||e.$$typeof===p||e.$$typeof===X||e.getModuleId!==void 0))}function V(e,r,t){var n=e.displayName;if(n)return n;var s=r.displayName||r.name||"";return s!==""?t+"("+s+")":t}function K(e){return e.displayName||"Context"}function E(e){if(e==null)return null;if(typeof e.tag=="number"&&u("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case b:return"Fragment";case l:return"Portal";case F:return"Profiler";case k:return"StrictMode";case T:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _:var r=e;return K(r)+".Consumer";case x:var t=e;return K(t._context)+".Provider";case p:return V(e,e.render,"ForwardRef");case R:var n=e.displayName||null;return n!==null?n:E(e.type)||"Memo";case C:{var s=e,c=s._payload,i=s._init;try{return E(i(c))}catch{return null}}}return null}var O=Object.assign,P=0,me,ge,he,ye,be,Re,Ee;function _e(){}_e.__reactDisabledLog=!0;function Ne(){{if(P===0){me=console.log,ge=console.info,he=console.warn,ye=console.error,be=console.group,Re=console.groupCollapsed,Ee=console.groupEnd;var e={configurable:!0,enumerable:!0,value:_e,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}P++}}function Be(){{if(P--,P===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},e,{value:me}),info:O({},e,{value:ge}),warn:O({},e,{value:he}),error:O({},e,{value:ye}),group:O({},e,{value:be}),groupCollapsed:O({},e,{value:Re}),groupEnd:O({},e,{value:Ee})})}P<0&&u("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var oe=w.ReactCurrentDispatcher,ie;function z(e,r,t){{if(ie===void 0)try{throw Error()}catch(s){var n=s.stack.trim().match(/\n( *(at )?)/);ie=n&&n[1]||""}return`
18
+ `+ie+e}}var se=!1,G;{var Ue=typeof WeakMap=="function"?WeakMap:Map;G=new Ue}function Ce(e,r){if(!e||se)return"";{var t=G.get(e);if(t!==void 0)return t}var n;se=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var c;c=oe.current,oe.current=null,Ne();try{if(r){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(h){n=h}Reflect.construct(e,[],i)}else{try{i.call()}catch(h){n=h}e.call(i.prototype)}}else{try{throw Error()}catch(h){n=h}e()}}catch(h){if(h&&n&&typeof h.stack=="string"){for(var a=h.stack.split(`
19
+ `),m=n.stack.split(`
20
+ `),f=a.length-1,d=m.length-1;f>=1&&d>=0&&a[f]!==m[d];)d--;for(;f>=1&&d>=0;f--,d--)if(a[f]!==m[d]){if(f!==1||d!==1)do if(f--,d--,d<0||a[f]!==m[d]){var y=`
21
+ `+a[f].replace(" at new "," at ");return e.displayName&&y.includes("<anonymous>")&&(y=y.replace("<anonymous>",e.displayName)),typeof e=="function"&&G.set(e,y),y}while(f>=1&&d>=0);break}}}finally{se=!1,oe.current=c,Be(),Error.prepareStackTrace=s}var I=e?e.displayName||e.name:"",S=I?z(I):"";return typeof e=="function"&&G.set(e,S),S}function Je(e,r,t){return Ce(e,!1)}function Xe(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function H(e,r,t){if(e==null)return"";if(typeof e=="function")return Ce(e,Xe(e));if(typeof e=="string")return z(e);switch(e){case T:return z("Suspense");case g:return z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case p:return Je(e.render);case R:return H(e.type,r,t);case C:{var n=e,s=n._payload,c=n._init;try{return H(c(s),r,t)}catch{}}}return""}var Y=Object.prototype.hasOwnProperty,Pe={},Te=w.ReactDebugCurrentFrame;function Z(e){if(e){var r=e._owner,t=H(e.type,e._source,r?r.type:null);Te.setExtraStackFrame(t)}else Te.setExtraStackFrame(null)}function Ke(e,r,t,n,s){{var c=Function.call.bind(Y);for(var i in e)if(c(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var m=Error((n||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw m.name="Invariant Violation",m}a=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(f){a=f}a&&!(a instanceof Error)&&(Z(s),u("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,i,typeof a),Z(null)),a instanceof Error&&!(a.message in Pe)&&(Pe[a.message]=!0,Z(s),u("Failed %s type: %s",t,a.message),Z(null))}}}var ze=Array.isArray;function ue(e){return ze(e)}function Ge(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function He(e){try{return we(e),!1}catch{return!0}}function we(e){return""+e}function Oe(e){if(He(e))return u("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ge(e)),we(e)}var xe=w.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},Se,je;function Qe(e){if(Y.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function er(e){if(Y.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function rr(e,r){typeof e.ref=="string"&&xe.current}function tr(e,r){{var t=function(){Se||(Se=!0,u("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function nr(e,r){{var t=function(){je||(je=!0,u("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var ar=function(e,r,t,n,s,c,i){var a={$$typeof:o,type:e,key:r,ref:t,props:i,_owner:c};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function or(e,r,t,n,s){{var c,i={},a=null,m=null;t!==void 0&&(Oe(t),a=""+t),er(r)&&(Oe(r.key),a=""+r.key),Qe(r)&&(m=r.ref,rr(r,s));for(c in r)Y.call(r,c)&&!Ze.hasOwnProperty(c)&&(i[c]=r[c]);if(e&&e.defaultProps){var f=e.defaultProps;for(c in f)i[c]===void 0&&(i[c]=f[c])}if(a||m){var d=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&tr(i,d),m&&nr(i,d)}return ar(e,a,m,s,n,xe.current,i)}}var le=w.ReactCurrentOwner,ke=w.ReactDebugCurrentFrame;function A(e){if(e){var r=e._owner,t=H(e.type,e._source,r?r.type:null);ke.setExtraStackFrame(t)}else ke.setExtraStackFrame(null)}var ce;ce=!1;function fe(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function Fe(){{if(le.current){var e=E(le.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function ir(e){return""}var De={};function sr(e){{var r=Fe();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
24
+
25
+ Check the top-level render call using <`+t+">.")}return r}}function Ae(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=sr(r);if(De[t])return;De[t]=!0;var n="";e&&e._owner&&e._owner!==le.current&&(n=" It was passed a child from "+E(e._owner.type)+"."),A(e),u('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),A(null)}}function Ie(e,r){{if(typeof e!="object")return;if(ue(e))for(var t=0;t<e.length;t++){var n=e[t];fe(n)&&Ae(n,r)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var s=U(e);if(typeof s=="function"&&s!==e.entries)for(var c=s.call(e),i;!(i=c.next()).done;)fe(i.value)&&Ae(i.value,r)}}}function ur(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===p||r.$$typeof===R))t=r.propTypes;else return;if(t){var n=E(r);Ke(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ce){ce=!0;var s=E(r);u("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",s||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&u("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){A(e),u("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),A(null);break}}e.ref!==null&&(A(e),u("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}var $e={};function We(e,r,t,n,s,c){{var i=ae(e);if(!i){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var m=ir();m?a+=m:a+=Fe();var f;e===null?f="null":ue(e)?f="array":e!==void 0&&e.$$typeof===o?(f="<"+(E(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):f=typeof e,u("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",f,a)}var d=or(e,r,t,s,c);if(d==null)return d;if(i){var y=r.children;if(y!==void 0)if(n)if(ue(y)){for(var I=0;I<y.length;I++)Ie(y[I],e);Object.freeze&&Object.freeze(y)}else u("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ie(y,e)}if(Y.call(r,"key")){var S=E(e),h=Object.keys(r).filter(function(mr){return mr!=="key"}),de=h.length>0?"{key: someKey, "+h.join(": ..., ")+": ...}":"{key: someKey}";if(!$e[S+de]){var pr=h.length>0?"{"+h.join(": ..., ")+": ...}":"{}";u(`A props object containing a "key" prop is being spread into JSX:
26
+ let props = %s;
27
+ <%s {...props} />
28
+ React keys must be passed directly to JSX without using spread:
29
+ let props = %s;
30
+ <%s key={someKey} {...props} />`,de,S,pr,S),$e[S+de]=!0}}return e===b?lr(d):ur(d),d}}function cr(e,r,t){return We(e,r,t,!0)}function fr(e,r,t){return We(e,r,t,!1)}var dr=fr,vr=cr;q.Fragment=b,q.jsx=dr,q.jsxs=vr}()),q}process.env.NODE_ENV==="production"?ve.exports=Rr():ve.exports=Er();var j=ve.exports;class qe{constructor(){Ve(this,"components");this.components=new Map}register(o,l){this.components.has(o)&&console.warn(`[XForm Registry] 组件 ${o} 已存在,将被覆盖`),this.components.set(o,{name:o,label:l.label,component:l.component,defaultValue:l.defaultValue,defaultProps:l.defaultProps||{},hasIntrinsicWidth:l.hasIntrinsicWidth||!1})}registerBatch(o){o.forEach(l=>{this.register(l.name,l)})}getComponent(o){return this.components.get(o)}getAllComponentNames(){return Array.from(this.components.keys())}getAllComponents(){return this.components}hasComponent(o){return this.components.has(o)}unregister(o){this.components.delete(o)}clear(){this.components.clear()}}const L=new qe,Le=$.createContext(L),_r=({children:v,registry:o=L,components:l=[]})=>{const b=$.useRef(!1);return!b.current&&l.length>0&&(o.registerBatch(l),b.current=!0),j.jsx(Le.Provider,{value:o,children:v})},pe=()=>$.useContext(Le),Cr=v=>{const l=pe().getComponent(v);return l||(console.warn(`组件 "${v}" 未注册`),null)},Pr=[{name:"input",label:"输入框",component:"input",defaultValue:"",defaultProps:{placeholder:"请输入",allowClear:!0,style:{width:"320px"}}},{name:"select",label:"select单选",component:"select",defaultValue:"",defaultProps:{placeholder:"请输入",allowClear:!0,style:{width:"320px"}}}],Tr=()=>{L.getAllComponentNames().length===0&&(L.registerBatch(Pr),console.log("[XForm] 默认组件已初始化"))},wr=yr.observer(({config:v=[],model:o,onSubmit:l,onError:b,onReset:k,layout:F={inlineError:!0},showButtons:x=!0,submitText:_="提交",resetText:p="重置",submitButtonProps:T={},resetButtonProps:g={},wrapperClassName:R,wrapperStyle:C,...D})=>{const N=u=>{console.log("[XForm Renderer] 表单提交:",u),l==null||l(u)},B=pe(),U=o==null?void 0:o.values,w=$.useMemo(()=>v.filter(u=>u.visible===!1?!1:typeof u.visible=="function"?u.visible(U||{}):!0).map((u,ee)=>{const{name:W,component:J,componentProps:re={},disabled:te,style:ne,className:X,...ae}=u,V=B.getComponent(J);if(!V)return console.error(`组件 "${J}" 未注册,无法渲染表单项 "${W}"`),null;const K=V.component,E={...V.defaultProps,...re};te&&(E.disabled=!0);const P={...ae,name:W,component:K,componentProps:E,style:ne,className:X};return u.required&&u.requiredMessage&&(P.required=u.required,P.requiredMessage=u.requiredMessage),j.jsx(Q.FormItem,{...P},`${W}-${ee}`)}).filter(Boolean),[v,U,B]);return j.jsx("div",{className:R,style:C,children:j.jsxs(Q.Form,{model:o,layout:F,onSubmit:N,onError:b,onReset:k,...D,children:[w,x&&j.jsx(Q.Form.ItemView,{children:j.jsx("div",{style:{marginTop:24},children:j.jsx(Q.Form.Submit,{ButtonComponent:br.Button,type:"primary",...T,children:_})})})]})})}),Or=Tr;exports.ComponentProvider=_r;exports.ComponentRegistry=qe;exports.FormRenderer=wr;exports.globalRegistry=L;exports.registerDefaultComponents=Or;exports.useComponent=Cr;exports.useComponentRegistry=pe;
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export { ComponentRegistry, globalRegistry, ComponentProvider, useComponentRegistry, useComponent, } from './registry';
3
+ export { default as FormRenderer } from './formRenderer';
4
+ export declare const registerDefaultComponents: () => void;
@@ -0,0 +1,783 @@
1
+ var mr = Object.defineProperty;
2
+ var gr = (v, o, l) => o in v ? mr(v, o, { enumerable: !0, configurable: !0, writable: !0, value: l }) : v[o] = l;
3
+ var $e = (v, o, l) => gr(v, typeof o != "symbol" ? o + "" : o, l);
4
+ import Ye, { createContext as hr, useContext as yr, useRef as br, useMemo as Rr } from "react";
5
+ import { observer as Er } from "mobx-react-lite";
6
+ import { FormItem as _r, Form as fe } from "react-antd-xform";
7
+ import { Button as Cr } from "antd";
8
+ var de = { exports: {} }, Y = {};
9
+ /**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+ var We;
19
+ function Pr() {
20
+ if (We) return Y;
21
+ We = 1;
22
+ var v = Ye, o = Symbol.for("react.element"), l = Symbol.for("react.fragment"), b = Object.prototype.hasOwnProperty, k = v.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, F = { key: !0, ref: !0, __self: !0, __source: !0 };
23
+ function x(_, p, T) {
24
+ var g, R = {}, C = null, D = null;
25
+ T !== void 0 && (C = "" + T), p.key !== void 0 && (C = "" + p.key), p.ref !== void 0 && (D = p.ref);
26
+ for (g in p) b.call(p, g) && !F.hasOwnProperty(g) && (R[g] = p[g]);
27
+ if (_ && _.defaultProps) for (g in p = _.defaultProps, p) R[g] === void 0 && (R[g] = p[g]);
28
+ return { $$typeof: o, type: _, key: C, ref: D, props: R, _owner: k.current };
29
+ }
30
+ return Y.Fragment = l, Y.jsx = x, Y.jsxs = x, Y;
31
+ }
32
+ var M = {};
33
+ /**
34
+ * @license React
35
+ * react-jsx-runtime.development.js
36
+ *
37
+ * Copyright (c) Facebook, Inc. and its affiliates.
38
+ *
39
+ * This source code is licensed under the MIT license found in the
40
+ * LICENSE file in the root directory of this source tree.
41
+ */
42
+ var Ve;
43
+ function Tr() {
44
+ return Ve || (Ve = 1, process.env.NODE_ENV !== "production" && function() {
45
+ var v = Ye, o = Symbol.for("react.element"), l = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), F = Symbol.for("react.profiler"), x = Symbol.for("react.provider"), _ = Symbol.for("react.context"), p = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), g = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), D = Symbol.for("react.offscreen"), N = Symbol.iterator, L = "@@iterator";
46
+ function B(e) {
47
+ if (e === null || typeof e != "object")
48
+ return null;
49
+ var r = N && e[N] || e[L];
50
+ return typeof r == "function" ? r : null;
51
+ }
52
+ var w = v.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
53
+ function u(e) {
54
+ {
55
+ for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
56
+ t[n - 1] = arguments[n];
57
+ Z("error", e, t);
58
+ }
59
+ }
60
+ function Z(e, r, t) {
61
+ {
62
+ var n = w.ReactDebugCurrentFrame, s = n.getStackAddendum();
63
+ s !== "" && (r += "%s", t = t.concat([s]));
64
+ var c = t.map(function(i) {
65
+ return String(i);
66
+ });
67
+ c.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, c);
68
+ }
69
+ }
70
+ var $ = !1, U = !1, Q = !1, ee = !1, re = !1, q;
71
+ q = Symbol.for("react.module.reference");
72
+ function te(e) {
73
+ return !!(typeof e == "string" || typeof e == "function" || e === b || e === F || re || e === k || e === T || e === g || ee || e === D || $ || U || Q || typeof e == "object" && e !== null && (e.$$typeof === C || e.$$typeof === R || e.$$typeof === x || e.$$typeof === _ || e.$$typeof === p || // This needs to include all possible module reference object
74
+ // types supported by any Flight configuration anywhere since
75
+ // we don't know which Flight build this will end up being used
76
+ // with.
77
+ e.$$typeof === q || e.getModuleId !== void 0));
78
+ }
79
+ function W(e, r, t) {
80
+ var n = e.displayName;
81
+ if (n)
82
+ return n;
83
+ var s = r.displayName || r.name || "";
84
+ return s !== "" ? t + "(" + s + ")" : t;
85
+ }
86
+ function J(e) {
87
+ return e.displayName || "Context";
88
+ }
89
+ function E(e) {
90
+ if (e == null)
91
+ return null;
92
+ if (typeof e.tag == "number" && u("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
93
+ return e.displayName || e.name || null;
94
+ if (typeof e == "string")
95
+ return e;
96
+ switch (e) {
97
+ case b:
98
+ return "Fragment";
99
+ case l:
100
+ return "Portal";
101
+ case F:
102
+ return "Profiler";
103
+ case k:
104
+ return "StrictMode";
105
+ case T:
106
+ return "Suspense";
107
+ case g:
108
+ return "SuspenseList";
109
+ }
110
+ if (typeof e == "object")
111
+ switch (e.$$typeof) {
112
+ case _:
113
+ var r = e;
114
+ return J(r) + ".Consumer";
115
+ case x:
116
+ var t = e;
117
+ return J(t._context) + ".Provider";
118
+ case p:
119
+ return W(e, e.render, "ForwardRef");
120
+ case R:
121
+ var n = e.displayName || null;
122
+ return n !== null ? n : E(e.type) || "Memo";
123
+ case C: {
124
+ var s = e, c = s._payload, i = s._init;
125
+ try {
126
+ return E(i(c));
127
+ } catch {
128
+ return null;
129
+ }
130
+ }
131
+ }
132
+ return null;
133
+ }
134
+ var O = Object.assign, P = 0, ve, pe, me, ge, he, ye, be;
135
+ function Re() {
136
+ }
137
+ Re.__reactDisabledLog = !0;
138
+ function Le() {
139
+ {
140
+ if (P === 0) {
141
+ ve = console.log, pe = console.info, me = console.warn, ge = console.error, he = console.group, ye = console.groupCollapsed, be = console.groupEnd;
142
+ var e = {
143
+ configurable: !0,
144
+ enumerable: !0,
145
+ value: Re,
146
+ writable: !0
147
+ };
148
+ Object.defineProperties(console, {
149
+ info: e,
150
+ log: e,
151
+ warn: e,
152
+ error: e,
153
+ group: e,
154
+ groupCollapsed: e,
155
+ groupEnd: e
156
+ });
157
+ }
158
+ P++;
159
+ }
160
+ }
161
+ function Be() {
162
+ {
163
+ if (P--, P === 0) {
164
+ var e = {
165
+ configurable: !0,
166
+ enumerable: !0,
167
+ writable: !0
168
+ };
169
+ Object.defineProperties(console, {
170
+ log: O({}, e, {
171
+ value: ve
172
+ }),
173
+ info: O({}, e, {
174
+ value: pe
175
+ }),
176
+ warn: O({}, e, {
177
+ value: me
178
+ }),
179
+ error: O({}, e, {
180
+ value: ge
181
+ }),
182
+ group: O({}, e, {
183
+ value: he
184
+ }),
185
+ groupCollapsed: O({}, e, {
186
+ value: ye
187
+ }),
188
+ groupEnd: O({}, e, {
189
+ value: be
190
+ })
191
+ });
192
+ }
193
+ P < 0 && u("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
194
+ }
195
+ }
196
+ var ne = w.ReactCurrentDispatcher, ae;
197
+ function K(e, r, t) {
198
+ {
199
+ if (ae === void 0)
200
+ try {
201
+ throw Error();
202
+ } catch (s) {
203
+ var n = s.stack.trim().match(/\n( *(at )?)/);
204
+ ae = n && n[1] || "";
205
+ }
206
+ return `
207
+ ` + ae + e;
208
+ }
209
+ }
210
+ var oe = !1, X;
211
+ {
212
+ var Ue = typeof WeakMap == "function" ? WeakMap : Map;
213
+ X = new Ue();
214
+ }
215
+ function Ee(e, r) {
216
+ if (!e || oe)
217
+ return "";
218
+ {
219
+ var t = X.get(e);
220
+ if (t !== void 0)
221
+ return t;
222
+ }
223
+ var n;
224
+ oe = !0;
225
+ var s = Error.prepareStackTrace;
226
+ Error.prepareStackTrace = void 0;
227
+ var c;
228
+ c = ne.current, ne.current = null, Le();
229
+ try {
230
+ if (r) {
231
+ var i = function() {
232
+ throw Error();
233
+ };
234
+ if (Object.defineProperty(i.prototype, "props", {
235
+ set: function() {
236
+ throw Error();
237
+ }
238
+ }), typeof Reflect == "object" && Reflect.construct) {
239
+ try {
240
+ Reflect.construct(i, []);
241
+ } catch (h) {
242
+ n = h;
243
+ }
244
+ Reflect.construct(e, [], i);
245
+ } else {
246
+ try {
247
+ i.call();
248
+ } catch (h) {
249
+ n = h;
250
+ }
251
+ e.call(i.prototype);
252
+ }
253
+ } else {
254
+ try {
255
+ throw Error();
256
+ } catch (h) {
257
+ n = h;
258
+ }
259
+ e();
260
+ }
261
+ } catch (h) {
262
+ if (h && n && typeof h.stack == "string") {
263
+ for (var a = h.stack.split(`
264
+ `), m = n.stack.split(`
265
+ `), f = a.length - 1, d = m.length - 1; f >= 1 && d >= 0 && a[f] !== m[d]; )
266
+ d--;
267
+ for (; f >= 1 && d >= 0; f--, d--)
268
+ if (a[f] !== m[d]) {
269
+ if (f !== 1 || d !== 1)
270
+ do
271
+ if (f--, d--, d < 0 || a[f] !== m[d]) {
272
+ var y = `
273
+ ` + a[f].replace(" at new ", " at ");
274
+ return e.displayName && y.includes("<anonymous>") && (y = y.replace("<anonymous>", e.displayName)), typeof e == "function" && X.set(e, y), y;
275
+ }
276
+ while (f >= 1 && d >= 0);
277
+ break;
278
+ }
279
+ }
280
+ } finally {
281
+ oe = !1, ne.current = c, Be(), Error.prepareStackTrace = s;
282
+ }
283
+ var I = e ? e.displayName || e.name : "", S = I ? K(I) : "";
284
+ return typeof e == "function" && X.set(e, S), S;
285
+ }
286
+ function qe(e, r, t) {
287
+ return Ee(e, !1);
288
+ }
289
+ function Je(e) {
290
+ var r = e.prototype;
291
+ return !!(r && r.isReactComponent);
292
+ }
293
+ function z(e, r, t) {
294
+ if (e == null)
295
+ return "";
296
+ if (typeof e == "function")
297
+ return Ee(e, Je(e));
298
+ if (typeof e == "string")
299
+ return K(e);
300
+ switch (e) {
301
+ case T:
302
+ return K("Suspense");
303
+ case g:
304
+ return K("SuspenseList");
305
+ }
306
+ if (typeof e == "object")
307
+ switch (e.$$typeof) {
308
+ case p:
309
+ return qe(e.render);
310
+ case R:
311
+ return z(e.type, r, t);
312
+ case C: {
313
+ var n = e, s = n._payload, c = n._init;
314
+ try {
315
+ return z(c(s), r, t);
316
+ } catch {
317
+ }
318
+ }
319
+ }
320
+ return "";
321
+ }
322
+ var V = Object.prototype.hasOwnProperty, _e = {}, Ce = w.ReactDebugCurrentFrame;
323
+ function G(e) {
324
+ if (e) {
325
+ var r = e._owner, t = z(e.type, e._source, r ? r.type : null);
326
+ Ce.setExtraStackFrame(t);
327
+ } else
328
+ Ce.setExtraStackFrame(null);
329
+ }
330
+ function Ke(e, r, t, n, s) {
331
+ {
332
+ var c = Function.call.bind(V);
333
+ for (var i in e)
334
+ if (c(e, i)) {
335
+ var a = void 0;
336
+ try {
337
+ if (typeof e[i] != "function") {
338
+ var m = Error((n || "React class") + ": " + t + " type `" + i + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[i] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
339
+ throw m.name = "Invariant Violation", m;
340
+ }
341
+ a = e[i](r, i, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
342
+ } catch (f) {
343
+ a = f;
344
+ }
345
+ a && !(a instanceof Error) && (G(s), u("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, i, typeof a), G(null)), a instanceof Error && !(a.message in _e) && (_e[a.message] = !0, G(s), u("Failed %s type: %s", t, a.message), G(null));
346
+ }
347
+ }
348
+ }
349
+ var Xe = Array.isArray;
350
+ function ie(e) {
351
+ return Xe(e);
352
+ }
353
+ function ze(e) {
354
+ {
355
+ var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
356
+ return t;
357
+ }
358
+ }
359
+ function Ge(e) {
360
+ try {
361
+ return Pe(e), !1;
362
+ } catch {
363
+ return !0;
364
+ }
365
+ }
366
+ function Pe(e) {
367
+ return "" + e;
368
+ }
369
+ function Te(e) {
370
+ if (Ge(e))
371
+ return u("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ze(e)), Pe(e);
372
+ }
373
+ var we = w.ReactCurrentOwner, He = {
374
+ key: !0,
375
+ ref: !0,
376
+ __self: !0,
377
+ __source: !0
378
+ }, Oe, xe;
379
+ function Ze(e) {
380
+ if (V.call(e, "ref")) {
381
+ var r = Object.getOwnPropertyDescriptor(e, "ref").get;
382
+ if (r && r.isReactWarning)
383
+ return !1;
384
+ }
385
+ return e.ref !== void 0;
386
+ }
387
+ function Qe(e) {
388
+ if (V.call(e, "key")) {
389
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
390
+ if (r && r.isReactWarning)
391
+ return !1;
392
+ }
393
+ return e.key !== void 0;
394
+ }
395
+ function er(e, r) {
396
+ typeof e.ref == "string" && we.current;
397
+ }
398
+ function rr(e, r) {
399
+ {
400
+ var t = function() {
401
+ Oe || (Oe = !0, u("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
402
+ };
403
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
404
+ get: t,
405
+ configurable: !0
406
+ });
407
+ }
408
+ }
409
+ function tr(e, r) {
410
+ {
411
+ var t = function() {
412
+ xe || (xe = !0, u("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
413
+ };
414
+ t.isReactWarning = !0, Object.defineProperty(e, "ref", {
415
+ get: t,
416
+ configurable: !0
417
+ });
418
+ }
419
+ }
420
+ var nr = function(e, r, t, n, s, c, i) {
421
+ var a = {
422
+ // This tag allows us to uniquely identify this as a React Element
423
+ $$typeof: o,
424
+ // Built-in properties that belong on the element
425
+ type: e,
426
+ key: r,
427
+ ref: t,
428
+ props: i,
429
+ // Record the component responsible for creating this element.
430
+ _owner: c
431
+ };
432
+ return a._store = {}, Object.defineProperty(a._store, "validated", {
433
+ configurable: !1,
434
+ enumerable: !1,
435
+ writable: !0,
436
+ value: !1
437
+ }), Object.defineProperty(a, "_self", {
438
+ configurable: !1,
439
+ enumerable: !1,
440
+ writable: !1,
441
+ value: n
442
+ }), Object.defineProperty(a, "_source", {
443
+ configurable: !1,
444
+ enumerable: !1,
445
+ writable: !1,
446
+ value: s
447
+ }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
448
+ };
449
+ function ar(e, r, t, n, s) {
450
+ {
451
+ var c, i = {}, a = null, m = null;
452
+ t !== void 0 && (Te(t), a = "" + t), Qe(r) && (Te(r.key), a = "" + r.key), Ze(r) && (m = r.ref, er(r, s));
453
+ for (c in r)
454
+ V.call(r, c) && !He.hasOwnProperty(c) && (i[c] = r[c]);
455
+ if (e && e.defaultProps) {
456
+ var f = e.defaultProps;
457
+ for (c in f)
458
+ i[c] === void 0 && (i[c] = f[c]);
459
+ }
460
+ if (a || m) {
461
+ var d = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
462
+ a && rr(i, d), m && tr(i, d);
463
+ }
464
+ return nr(e, a, m, s, n, we.current, i);
465
+ }
466
+ }
467
+ var se = w.ReactCurrentOwner, Se = w.ReactDebugCurrentFrame;
468
+ function A(e) {
469
+ if (e) {
470
+ var r = e._owner, t = z(e.type, e._source, r ? r.type : null);
471
+ Se.setExtraStackFrame(t);
472
+ } else
473
+ Se.setExtraStackFrame(null);
474
+ }
475
+ var ue;
476
+ ue = !1;
477
+ function le(e) {
478
+ return typeof e == "object" && e !== null && e.$$typeof === o;
479
+ }
480
+ function je() {
481
+ {
482
+ if (se.current) {
483
+ var e = E(se.current.type);
484
+ if (e)
485
+ return `
486
+
487
+ Check the render method of \`` + e + "`.";
488
+ }
489
+ return "";
490
+ }
491
+ }
492
+ function or(e) {
493
+ return "";
494
+ }
495
+ var ke = {};
496
+ function ir(e) {
497
+ {
498
+ var r = je();
499
+ if (!r) {
500
+ var t = typeof e == "string" ? e : e.displayName || e.name;
501
+ t && (r = `
502
+
503
+ Check the top-level render call using <` + t + ">.");
504
+ }
505
+ return r;
506
+ }
507
+ }
508
+ function Fe(e, r) {
509
+ {
510
+ if (!e._store || e._store.validated || e.key != null)
511
+ return;
512
+ e._store.validated = !0;
513
+ var t = ir(r);
514
+ if (ke[t])
515
+ return;
516
+ ke[t] = !0;
517
+ var n = "";
518
+ e && e._owner && e._owner !== se.current && (n = " It was passed a child from " + E(e._owner.type) + "."), A(e), u('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), A(null);
519
+ }
520
+ }
521
+ function De(e, r) {
522
+ {
523
+ if (typeof e != "object")
524
+ return;
525
+ if (ie(e))
526
+ for (var t = 0; t < e.length; t++) {
527
+ var n = e[t];
528
+ le(n) && Fe(n, r);
529
+ }
530
+ else if (le(e))
531
+ e._store && (e._store.validated = !0);
532
+ else if (e) {
533
+ var s = B(e);
534
+ if (typeof s == "function" && s !== e.entries)
535
+ for (var c = s.call(e), i; !(i = c.next()).done; )
536
+ le(i.value) && Fe(i.value, r);
537
+ }
538
+ }
539
+ }
540
+ function sr(e) {
541
+ {
542
+ var r = e.type;
543
+ if (r == null || typeof r == "string")
544
+ return;
545
+ var t;
546
+ if (typeof r == "function")
547
+ t = r.propTypes;
548
+ else if (typeof r == "object" && (r.$$typeof === p || // Note: Memo only checks outer props here.
549
+ // Inner props are checked in the reconciler.
550
+ r.$$typeof === R))
551
+ t = r.propTypes;
552
+ else
553
+ return;
554
+ if (t) {
555
+ var n = E(r);
556
+ Ke(t, e.props, "prop", n, e);
557
+ } else if (r.PropTypes !== void 0 && !ue) {
558
+ ue = !0;
559
+ var s = E(r);
560
+ u("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", s || "Unknown");
561
+ }
562
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && u("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
563
+ }
564
+ }
565
+ function ur(e) {
566
+ {
567
+ for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
568
+ var n = r[t];
569
+ if (n !== "children" && n !== "key") {
570
+ A(e), u("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), A(null);
571
+ break;
572
+ }
573
+ }
574
+ e.ref !== null && (A(e), u("Invalid attribute `ref` supplied to `React.Fragment`."), A(null));
575
+ }
576
+ }
577
+ var Ae = {};
578
+ function Ie(e, r, t, n, s, c) {
579
+ {
580
+ var i = te(e);
581
+ if (!i) {
582
+ var a = "";
583
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
584
+ var m = or();
585
+ m ? a += m : a += je();
586
+ var f;
587
+ e === null ? f = "null" : ie(e) ? f = "array" : e !== void 0 && e.$$typeof === o ? (f = "<" + (E(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : f = typeof e, u("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", f, a);
588
+ }
589
+ var d = ar(e, r, t, s, c);
590
+ if (d == null)
591
+ return d;
592
+ if (i) {
593
+ var y = r.children;
594
+ if (y !== void 0)
595
+ if (n)
596
+ if (ie(y)) {
597
+ for (var I = 0; I < y.length; I++)
598
+ De(y[I], e);
599
+ Object.freeze && Object.freeze(y);
600
+ } else
601
+ u("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
602
+ else
603
+ De(y, e);
604
+ }
605
+ if (V.call(r, "key")) {
606
+ var S = E(e), h = Object.keys(r).filter(function(pr) {
607
+ return pr !== "key";
608
+ }), ce = h.length > 0 ? "{key: someKey, " + h.join(": ..., ") + ": ...}" : "{key: someKey}";
609
+ if (!Ae[S + ce]) {
610
+ var vr = h.length > 0 ? "{" + h.join(": ..., ") + ": ...}" : "{}";
611
+ u(`A props object containing a "key" prop is being spread into JSX:
612
+ let props = %s;
613
+ <%s {...props} />
614
+ React keys must be passed directly to JSX without using spread:
615
+ let props = %s;
616
+ <%s key={someKey} {...props} />`, ce, S, vr, S), Ae[S + ce] = !0;
617
+ }
618
+ }
619
+ return e === b ? ur(d) : sr(d), d;
620
+ }
621
+ }
622
+ function lr(e, r, t) {
623
+ return Ie(e, r, t, !0);
624
+ }
625
+ function cr(e, r, t) {
626
+ return Ie(e, r, t, !1);
627
+ }
628
+ var fr = cr, dr = lr;
629
+ M.Fragment = b, M.jsx = fr, M.jsxs = dr;
630
+ }()), M;
631
+ }
632
+ process.env.NODE_ENV === "production" ? de.exports = Pr() : de.exports = Tr();
633
+ var j = de.exports;
634
+ class wr {
635
+ constructor() {
636
+ $e(this, "components");
637
+ this.components = /* @__PURE__ */ new Map();
638
+ }
639
+ register(o, l) {
640
+ this.components.has(o) && console.warn(`[XForm Registry] 组件 ${o} 已存在,将被覆盖`), this.components.set(o, {
641
+ name: o,
642
+ label: l.label,
643
+ component: l.component,
644
+ defaultValue: l.defaultValue,
645
+ defaultProps: l.defaultProps || {},
646
+ hasIntrinsicWidth: l.hasIntrinsicWidth || !1
647
+ });
648
+ }
649
+ registerBatch(o) {
650
+ o.forEach((l) => {
651
+ this.register(l.name, l);
652
+ });
653
+ }
654
+ getComponent(o) {
655
+ return this.components.get(o);
656
+ }
657
+ getAllComponentNames() {
658
+ return Array.from(this.components.keys());
659
+ }
660
+ getAllComponents() {
661
+ return this.components;
662
+ }
663
+ hasComponent(o) {
664
+ return this.components.has(o);
665
+ }
666
+ unregister(o) {
667
+ this.components.delete(o);
668
+ }
669
+ clear() {
670
+ this.components.clear();
671
+ }
672
+ }
673
+ const H = new wr(), Me = hr(H), Ar = ({
674
+ children: v,
675
+ registry: o = H,
676
+ components: l = []
677
+ }) => {
678
+ const b = br(!1);
679
+ return !b.current && l.length > 0 && (o.registerBatch(l), b.current = !0), /* @__PURE__ */ j.jsx(Me.Provider, { value: o, children: v });
680
+ }, Ne = () => yr(Me), Ir = (v) => {
681
+ const l = Ne().getComponent(v);
682
+ return l || (console.warn(`组件 "${v}" 未注册`), null);
683
+ }, Or = [
684
+ {
685
+ name: "input",
686
+ label: "输入框",
687
+ component: "input",
688
+ defaultValue: "",
689
+ defaultProps: {
690
+ placeholder: "请输入",
691
+ allowClear: !0,
692
+ style: {
693
+ width: "320px"
694
+ }
695
+ }
696
+ },
697
+ {
698
+ name: "select",
699
+ label: "select单选",
700
+ component: "select",
701
+ defaultValue: "",
702
+ defaultProps: {
703
+ placeholder: "请输入",
704
+ allowClear: !0,
705
+ style: {
706
+ width: "320px"
707
+ }
708
+ }
709
+ }
710
+ ], xr = () => {
711
+ H.getAllComponentNames().length === 0 && (H.registerBatch(Or), console.log("[XForm] 默认组件已初始化"));
712
+ }, $r = Er(
713
+ ({
714
+ config: v = [],
715
+ model: o,
716
+ onSubmit: l,
717
+ onError: b,
718
+ onReset: k,
719
+ layout: F = { inlineError: !0 },
720
+ showButtons: x = !0,
721
+ submitText: _ = "提交",
722
+ resetText: p = "重置",
723
+ submitButtonProps: T = {},
724
+ resetButtonProps: g = {},
725
+ wrapperClassName: R,
726
+ wrapperStyle: C,
727
+ ...D
728
+ }) => {
729
+ const N = (u) => {
730
+ console.log("[XForm Renderer] 表单提交:", u), l == null || l(u);
731
+ }, L = Ne(), B = o == null ? void 0 : o.values, w = Rr(() => v.filter((u) => u.visible === !1 ? !1 : typeof u.visible == "function" ? u.visible(B || {}) : !0).map((u, Z) => {
732
+ const {
733
+ name: $,
734
+ component: U,
735
+ componentProps: Q = {},
736
+ disabled: ee,
737
+ style: re,
738
+ className: q,
739
+ ...te
740
+ } = u, W = L.getComponent(U);
741
+ if (!W)
742
+ return console.error(`组件 "${U}" 未注册,无法渲染表单项 "${$}"`), null;
743
+ const J = W.component, E = {
744
+ ...W.defaultProps,
745
+ ...Q
746
+ };
747
+ ee && (E.disabled = !0);
748
+ const P = {
749
+ ...te,
750
+ name: $,
751
+ component: J,
752
+ componentProps: E,
753
+ style: re,
754
+ className: q
755
+ };
756
+ return u.required && u.requiredMessage && (P.required = u.required, P.requiredMessage = u.requiredMessage), /* @__PURE__ */ j.jsx(_r, { ...P }, `${$}-${Z}`);
757
+ }).filter(Boolean), [v, B, L]);
758
+ return /* @__PURE__ */ j.jsx("div", { className: R, style: C, children: /* @__PURE__ */ j.jsxs(
759
+ fe,
760
+ {
761
+ model: o,
762
+ layout: F,
763
+ onSubmit: N,
764
+ onError: b,
765
+ onReset: k,
766
+ ...D,
767
+ children: [
768
+ w,
769
+ x && /* @__PURE__ */ j.jsx(fe.ItemView, { children: /* @__PURE__ */ j.jsx("div", { style: { marginTop: 24 }, children: /* @__PURE__ */ j.jsx(fe.Submit, { ButtonComponent: Cr, type: "primary", ...T, children: _ }) }) })
770
+ ]
771
+ }
772
+ ) });
773
+ }
774
+ ), Wr = xr;
775
+ export {
776
+ Ar as ComponentProvider,
777
+ wr as ComponentRegistry,
778
+ $r as FormRenderer,
779
+ H as globalRegistry,
780
+ Wr as registerDefaultComponents,
781
+ Ir as useComponent,
782
+ Ne as useComponentRegistry
783
+ };
@@ -0,0 +1 @@
1
+ export declare const initializeDefaultComponents: () => void;
@@ -0,0 +1,27 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { ComponentConfig, ComponentRegistryConfig } from '../types';
3
+
4
+ declare class ComponentRegistry {
5
+ private components;
6
+ constructor();
7
+ register(name: string, config: ComponentRegistryConfig): void;
8
+ registerBatch(configs: ComponentRegistryConfig[]): void;
9
+ getComponent(name: string): ComponentConfig | undefined;
10
+ getAllComponentNames(): string[];
11
+ getAllComponents(): Map<string, ComponentConfig>;
12
+ hasComponent(name: string): boolean;
13
+ unregister(name: string): void;
14
+ clear(): void;
15
+ }
16
+ export declare const globalRegistry: ComponentRegistry;
17
+ export declare const ComponentRegistryContext: React.Context<ComponentRegistry>;
18
+ export interface ComponentProviderProps {
19
+ children: ReactNode;
20
+ registry?: ComponentRegistry;
21
+ components?: ComponentRegistryConfig[];
22
+ }
23
+ export declare const ComponentProvider: React.FC<ComponentProviderProps>;
24
+ export declare const useComponentRegistry: () => ComponentRegistry;
25
+ export declare const useComponent: (name: string) => ComponentConfig | null;
26
+ export { ComponentRegistry };
27
+ export default ComponentRegistry;
@@ -0,0 +1,60 @@
1
+ import { default as React } from 'react';
2
+ import { FormModel, FormItemProps, DefaultOptionType, FormProps, FormLayoutParams } from 'react-antd-xform';
3
+
4
+ export interface FormItemConfig extends Partial<Omit<FormItemProps, 'component'>> {
5
+ name: string;
6
+ component: string;
7
+ label?: React.ReactNode;
8
+ help?: React.ReactNode;
9
+ componentProps?: Record<string, any>;
10
+ required?: boolean;
11
+ requiredMessage?: string;
12
+ defaultValue?: any;
13
+ writeDefaultValueToModel?: boolean | 'force';
14
+ options?: DefaultOptionType[];
15
+ rules?: Array<{
16
+ required?: boolean;
17
+ message?: string;
18
+ validator?: (rule: any, value: any) => Promise<void>;
19
+ pattern?: RegExp;
20
+ min?: number;
21
+ max?: number;
22
+ len?: number;
23
+ }>;
24
+ visible?: boolean | ((values: Record<string, any>) => boolean);
25
+ disabled?: boolean;
26
+ style?: React.CSSProperties;
27
+ className?: string;
28
+ valuePropName?: string;
29
+ getValueFromEvent?: (...args: any[]) => any;
30
+ getValueProps?: (value: any) => any;
31
+ validator?: (value: any) => boolean | string;
32
+ [key: string]: any;
33
+ }
34
+ export interface FormRendererProps extends Partial<FormProps> {
35
+ config: FormItemConfig[];
36
+ model?: FormModel;
37
+ onSubmit?: (values: any) => void;
38
+ onError?: (errors: any, model: FormModel<any>) => void;
39
+ onReset?: (model: FormModel<any>) => void;
40
+ layout?: FormLayoutParams;
41
+ showButtons?: boolean;
42
+ submitText?: string;
43
+ resetText?: string;
44
+ submitButtonProps?: Record<string, any>;
45
+ resetButtonProps?: Record<string, any>;
46
+ wrapperClassName?: string;
47
+ wrapperStyle?: React.CSSProperties;
48
+ }
49
+ export interface ComponentConfig {
50
+ label?: React.ReactNode | string;
51
+ component: string;
52
+ defaultValue?: any;
53
+ defaultProps?: Record<string, any>;
54
+ hasIntrinsicWidth?: boolean;
55
+ validator?: (value: any) => boolean | string;
56
+ transformer?: (value: any) => any;
57
+ id?: string;
58
+ name: string;
59
+ }
60
+ export type ComponentRegistryConfig = FormItemConfig;
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "react-mario-core",
3
+ "version": "1.0.0",
4
+ "description": "基于react-antd-xform的低代码组件注册器",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "dev": "vite",
13
+ "build": "vite build",
14
+ "preview": "vite preview"
15
+ },
16
+ "keywords": [
17
+ "react",
18
+ "antd",
19
+ "xform",
20
+ "lowcode",
21
+ "form-builder"
22
+ ],
23
+ "author": "",
24
+ "license": "MIT",
25
+ "peerDependencies": {
26
+ "antd": ">=5.0.0",
27
+ "mobx": ">=6.0.0",
28
+ "mobx-react-lite": ">=3.0.0",
29
+ "react": ">=16.8.0",
30
+ "react-dom": ">=16.8.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^20.10.6",
34
+ "@types/react": "^18.2.45",
35
+ "@types/react-dom": "^18.2.18",
36
+ "@vitejs/plugin-react": "^4.2.1",
37
+ "antd": "^5.12.0",
38
+ "mobx": "^6.12.0",
39
+ "mobx-react-lite": "^4.0.5",
40
+ "react": "^18.2.0",
41
+ "react-antd-xform": "1.0.12-beta.2",
42
+ "react-dom": "^18.2.0",
43
+ "typescript": "^5.3.3",
44
+ "vite": "^5.0.8",
45
+ "vite-plugin-dts": "^3.7.0"
46
+ }
47
+ }