best-unit 0.0.5 → 0.0.7
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/dist/best-unit.cjs +1 -1
- package/dist/best-unit.js +569 -28
- package/dist/types/index.d.ts +14 -0
- package/dist/types/preact-custom-element.d.ts +1 -0
- package/package.json +6 -4
- package/src/app.tsx +8 -9
- package/src/components/ModalForm/components/Button.tsx +26 -0
- package/src/components/ModalForm/components/ModalForm.tsx +80 -0
- package/src/components/ModalForm/index.tsx +32 -0
- package/src/main.ts +4 -2
- package/src/types/index.d.ts +14 -0
- package/src/types/preact-custom-element.d.ts +1 -0
- package/dist/best-unit.d.ts +0 -6
package/dist/best-unit.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function d(){console.log("npm package test!!!")}function s(){console.log("Current time:",new Date().toISOString())}var u;function a(r){return r.children}u={__e:function(r,t,l,f){for(var e,c,o;t=t.__;)if((e=t.__c)&&!e.__)try{if((c=e.constructor)&&c.getDerivedStateFromError!=null&&(e.setState(c.getDerivedStateFromError(r)),o=e.__d),e.componentDidCatch!=null&&(e.componentDidCatch(r,f||{}),o=e.__d),o)return e.__E=e}catch(n){r=n}throw r}},typeof Promise=="function"&&Promise.prototype.then.bind(Promise.resolve());var m=0;function i(r,t,l,f,e,c){t||(t={});var o,n,_=t;if("ref"in _)for(n in _={},t)n=="ref"?o=t[n]:_[n]=t[n];var p={type:r,props:_,key:l,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--m,__i:-1,__u:0,__source:e,__self:c};if(typeof r=="function"&&(o=r.defaultProps))for(n in o)_[n]===void 0&&(_[n]=o[n]);return u.vnode&&u.vnode(p),p}function v(){return i(a,{children:i("div",{children:i("h1",{children:"Hello World"})})})}exports.App=v;exports.npmTest=d;exports.printCurrentTime=s;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Me(){console.log("npm package test!!!")}function De(){console.log("Current time:",new Date().toISOString())}var D,d,ye,$,oe,ge,be,ke,Z,J,K,M={},we=[],Fe=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,B=Array.isArray;function C(e,t){for(var _ in t)e[_]=t[_];return e}function ee(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function E(e,t,_){var n,o,r,l={};for(r in t)r=="key"?n=t[r]:r=="ref"?o=t[r]:l[r]=t[r];if(arguments.length>2&&(l.children=arguments.length>3?D.call(arguments,2):_),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)l[r]===void 0&&(l[r]=e.defaultProps[r]);return L(e,l,n,o,null)}function L(e,t,_,n,o){var r={type:e,props:t,key:_,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++ye,__i:-1,__u:0};return o==null&&d.vnode!=null&&d.vnode(r),r}function q(e){return e.children}function I(e,t){this.props=e,this.context=t}function P(e,t){if(t==null)return e.__?P(e.__,e.__i+1):null;for(var _;t<e.__k.length;t++)if((_=e.__k[t])!=null&&_.__e!=null)return _.__e;return typeof e.type=="function"?P(e):null}function xe(e){var t,_;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((_=e.__k[t])!=null&&_.__e!=null){e.__e=e.__c.base=_.__e;break}return xe(e)}}function ie(e){(!e.__d&&(e.__d=!0)&&$.push(e)&&!R.__r++||oe!=d.debounceRendering)&&((oe=d.debounceRendering)||ge)(R)}function R(){for(var e,t,_,n,o,r,l,u=1;$.length;)$.length>u&&$.sort(be),e=$.shift(),u=$.length,e.__d&&(_=void 0,o=(n=(t=e).__v).__e,r=[],l=[],t.__P&&((_=C({},n)).__v=n.__v+1,d.vnode&&d.vnode(_),te(t.__P,_,n,t.__n,t.__P.namespaceURI,32&n.__u?[o]:null,r,o??P(n),!!(32&n.__u),l),_.__v=n.__v,_.__.__k[_.__i]=_,$e(r,_,l),_.__e!=o&&xe(_)));R.__r=0}function Ce(e,t,_,n,o,r,l,u,c,s,f){var i,p,a,g,w,b,h=n&&n.__k||we,m=t.length;for(c=Oe(_,t,h,c,m),i=0;i<m;i++)(a=_.__k[i])!=null&&(p=a.__i==-1?M:h[a.__i]||M,a.__i=i,b=te(e,a,p,o,r,l,u,c,s,f),g=a.__e,a.ref&&p.ref!=a.ref&&(p.ref&&_e(p.ref,null,a),f.push(a.ref,a.__c||g,a)),w==null&&g!=null&&(w=g),4&a.__u||p.__k===a.__k?c=Se(a,c,e):typeof a.type=="function"&&b!==void 0?c=b:g&&(c=g.nextSibling),a.__u&=-7);return _.__e=w,c}function Oe(e,t,_,n,o){var r,l,u,c,s,f=_.length,i=f,p=0;for(e.__k=new Array(o),r=0;r<o;r++)(l=t[r])!=null&&typeof l!="boolean"&&typeof l!="function"?(c=r+p,(l=e.__k[r]=typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?L(null,l,null,null,null):B(l)?L(q,{children:l},null,null,null):l.constructor==null&&l.__b>0?L(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):l).__=e,l.__b=e.__b+1,u=null,(s=l.__i=je(l,_,c,i))!=-1&&(i--,(u=_[s])&&(u.__u|=2)),u==null||u.__v==null?(s==-1&&(o>f?p--:o<f&&p++),typeof l.type!="function"&&(l.__u|=4)):s!=c&&(s==c-1?p--:s==c+1?p++:(s>c?p--:p++,l.__u|=4))):e.__k[r]=null;if(i)for(r=0;r<f;r++)(u=_[r])!=null&&(2&u.__u)==0&&(u.__e==n&&(n=P(u)),Pe(u,u));return n}function Se(e,t,_){var n,o;if(typeof e.type=="function"){for(n=e.__k,o=0;n&&o<n.length;o++)n[o]&&(n[o].__=e,t=Se(n[o],t,_));return t}e.__e!=t&&(t&&e.type&&!_.contains(t)&&(t=P(e)),_.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function je(e,t,_,n){var o,r,l=e.key,u=e.type,c=t[_];if(c===null&&e.key==null||c&&l==c.key&&u==c.type&&(2&c.__u)==0)return _;if(n>(c!=null&&(2&c.__u)==0?1:0))for(o=_-1,r=_+1;o>=0||r<t.length;){if(o>=0){if((c=t[o])&&(2&c.__u)==0&&l==c.key&&u==c.type)return o;o--}if(r<t.length){if((c=t[r])&&(2&c.__u)==0&&l==c.key&&u==c.type)return r;r++}}return-1}function le(e,t,_){t[0]=="-"?e.setProperty(t,_??""):e[t]=_==null?"":typeof _!="number"||Fe.test(t)?_:_+"px"}function j(e,t,_,n,o){var r,l;e:if(t=="style")if(typeof _=="string")e.style.cssText=_;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)_&&t in _||le(e.style,t,"");if(_)for(t in _)n&&_[t]==n[t]||le(e.style,t,_[t])}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(ke,"$1")),l=t.toLowerCase(),t=l in e||t=="onFocusOut"||t=="onFocusIn"?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=_,_?n?_.u=n.u:(_.u=Z,e.addEventListener(t,r?K:J,r)):e.removeEventListener(t,r?K:J,r);else{if(o=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=_??"";break e}catch{}typeof _=="function"||(_==null||_===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&_==1?"":_))}}function ue(e){return function(t){if(this.l){var _=this.l[t.type+e];if(t.t==null)t.t=Z++;else if(t.t<_.u)return;return _(d.event?d.event(t):t)}}}function te(e,t,_,n,o,r,l,u,c,s){var f,i,p,a,g,w,b,h,m,T,S,F,H,re,O,N,V,x=t.type;if(t.constructor!=null)return null;128&_.__u&&(c=!!(32&_.__u),r=[u=t.__e=_.__e]),(f=d.__b)&&f(t);e:if(typeof x=="function")try{if(h=t.props,m="prototype"in x&&x.prototype.render,T=(f=x.contextType)&&n[f.__c],S=f?T?T.props.value:f.__:n,_.__c?b=(i=t.__c=_.__c).__=i.__E:(m?t.__c=i=new x(h,S):(t.__c=i=new I(h,S),i.constructor=x,i.render=We),T&&T.sub(i),i.props=h,i.state||(i.state={}),i.context=S,i.__n=n,p=i.__d=!0,i.__h=[],i._sb=[]),m&&i.__s==null&&(i.__s=i.state),m&&x.getDerivedStateFromProps!=null&&(i.__s==i.state&&(i.__s=C({},i.__s)),C(i.__s,x.getDerivedStateFromProps(h,i.__s))),a=i.props,g=i.state,i.__v=t,p)m&&x.getDerivedStateFromProps==null&&i.componentWillMount!=null&&i.componentWillMount(),m&&i.componentDidMount!=null&&i.__h.push(i.componentDidMount);else{if(m&&x.getDerivedStateFromProps==null&&h!==a&&i.componentWillReceiveProps!=null&&i.componentWillReceiveProps(h,S),!i.__e&&i.shouldComponentUpdate!=null&&i.shouldComponentUpdate(h,i.__s,S)===!1||t.__v==_.__v){for(t.__v!=_.__v&&(i.props=h,i.state=i.__s,i.__d=!1),t.__e=_.__e,t.__k=_.__k,t.__k.some(function(U){U&&(U.__=t)}),F=0;F<i._sb.length;F++)i.__h.push(i._sb[F]);i._sb=[],i.__h.length&&l.push(i);break e}i.componentWillUpdate!=null&&i.componentWillUpdate(h,i.__s,S),m&&i.componentDidUpdate!=null&&i.__h.push(function(){i.componentDidUpdate(a,g,w)})}if(i.context=S,i.props=h,i.__P=e,i.__e=!1,H=d.__r,re=0,m){for(i.state=i.__s,i.__d=!1,H&&H(t),f=i.render(i.props,i.state,i.context),O=0;O<i._sb.length;O++)i.__h.push(i._sb[O]);i._sb=[]}else do i.__d=!1,H&&H(t),f=i.render(i.props,i.state,i.context),i.state=i.__s;while(i.__d&&++re<25);i.state=i.__s,i.getChildContext!=null&&(n=C(C({},n),i.getChildContext())),m&&!p&&i.getSnapshotBeforeUpdate!=null&&(w=i.getSnapshotBeforeUpdate(a,g)),N=f,f!=null&&f.type===q&&f.key==null&&(N=Ee(f.props.children)),u=Ce(e,B(N)?N:[N],t,_,n,o,r,l,u,c,s),i.base=t.__e,t.__u&=-161,i.__h.length&&l.push(i),b&&(i.__E=i.__=null)}catch(U){if(t.__v=null,c||r!=null)if(U.then){for(t.__u|=c?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;r[r.indexOf(u)]=null,t.__e=u}else for(V=r.length;V--;)ee(r[V]);else t.__e=_.__e,t.__k=_.__k;d.__e(U,t,_)}else r==null&&t.__v==_.__v?(t.__k=_.__k,t.__e=_.__e):u=t.__e=Ie(_.__e,t,_,n,o,r,l,c,s);return(f=d.diffed)&&f(t),128&t.__u?void 0:u}function $e(e,t,_){for(var n=0;n<_.length;n++)_e(_[n],_[++n],_[++n]);d.__c&&d.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(r){r.call(o)})}catch(r){d.__e(r,o.__v)}})}function Ee(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:B(e)?e.map(Ee):C({},e)}function Ie(e,t,_,n,o,r,l,u,c){var s,f,i,p,a,g,w,b=_.props,h=t.props,m=t.type;if(m=="svg"?o="http://www.w3.org/2000/svg":m=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),r!=null){for(s=0;s<r.length;s++)if((a=r[s])&&"setAttribute"in a==!!m&&(m?a.localName==m:a.nodeType==3)){e=a,r[s]=null;break}}if(e==null){if(m==null)return document.createTextNode(h);e=document.createElementNS(o,m,h.is&&h),u&&(d.__m&&d.__m(t,r),u=!1),r=null}if(m==null)b===h||u&&e.data==h||(e.data=h);else{if(r=r&&D.call(e.childNodes),b=_.props||M,!u&&r!=null)for(b={},s=0;s<e.attributes.length;s++)b[(a=e.attributes[s]).name]=a.value;for(s in b)if(a=b[s],s!="children"){if(s=="dangerouslySetInnerHTML")i=a;else if(!(s in h)){if(s=="value"&&"defaultValue"in h||s=="checked"&&"defaultChecked"in h)continue;j(e,s,null,a,o)}}for(s in h)a=h[s],s=="children"?p=a:s=="dangerouslySetInnerHTML"?f=a:s=="value"?g=a:s=="checked"?w=a:u&&typeof a!="function"||b[s]===a||j(e,s,a,b[s],o);if(f)u||i&&(f.__html==i.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(i&&(e.innerHTML=""),Ce(t.type=="template"?e.content:e,B(p)?p:[p],t,_,n,m=="foreignObject"?"http://www.w3.org/1999/xhtml":o,r,l,r?r[0]:_.__k&&P(_,0),u,c),r!=null)for(s=r.length;s--;)ee(r[s]);u||(s="value",m=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[s]||m=="progress"&&!g||m=="option"&&g!=b[s])&&j(e,s,g,b[s],o),s="checked",w!=null&&w!=e[s]&&j(e,s,w,b[s],o))}return e}function _e(e,t,_){try{if(typeof e=="function"){var n=typeof e.__u=="function";n&&e.__u(),n&&t==null||(e.__u=e(t))}else e.current=t}catch(o){d.__e(o,_)}}function Pe(e,t,_){var n,o;if(d.unmount&&d.unmount(e),(n=e.ref)&&(n.current&&n.current!=e.__e||_e(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(r){d.__e(r,t)}n.base=n.__P=null}if(n=e.__k)for(o=0;o<n.length;o++)n[o]&&Pe(n[o],t,_||typeof e.type!="function");_||ee(e.__e),e.__c=e.__=e.__e=void 0}function We(e,t,_){return this.constructor(e,_)}function z(e,t,_){var n,o,r,l;t==document&&(t=document.documentElement),d.__&&d.__(e,t),o=(n=typeof _=="function")?null:_&&_.__k||t.__k,r=[],l=[],te(t,e=(!n&&_||t).__k=E(q,null,[e]),o||M,M,t.namespaceURI,!n&&_?[_]:o?null:t.firstChild?D.call(t.childNodes):null,r,!n&&_?_:o?o.__e:t.firstChild,n,l),$e(r,e,l)}function Te(e,t){z(e,t,Te)}function He(e,t,_){var n,o,r,l,u=C({},e.props);for(r in e.type&&e.type.defaultProps&&(l=e.type.defaultProps),t)r=="key"?n=t[r]:r=="ref"?o=t[r]:u[r]=t[r]===void 0&&l!=null?l[r]:t[r];return arguments.length>2&&(u.children=arguments.length>3?D.call(arguments,2):_),L(e.type,u,n||e.key,o||e.ref,null)}D=we.slice,d={__e:function(e,t,_,n){for(var o,r,l;t=t.__;)if((o=t.__c)&&!o.__)try{if((r=o.constructor)&&r.getDerivedStateFromError!=null&&(o.setState(r.getDerivedStateFromError(e)),l=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,n||{}),l=o.__d),l)return o.__E=o}catch(u){e=u}throw e}},ye=0,I.prototype.setState=function(e,t){var _;_=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=C({},this.state),typeof e=="function"&&(e=e(C({},_),this.props)),e&&C(_,e),e!=null&&this.__v&&(t&&this._sb.push(t),ie(this))},I.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ie(this))},I.prototype.render=q,$=[],ge=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,be=function(e,t){return e.__v.__b-t.__v.__b},R.__r=0,ke=/(PointerCapture)$|Capture$/i,Z=0,J=ue(!1),K=ue(!0);var Re=0;function k(e,t,_,n,o,r){t||(t={});var l,u,c=t;if("ref"in c)for(u in c={},t)u=="ref"?l=t[u]:c[u]=t[u];var s={type:e,props:c,key:_,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Re,__i:-1,__u:0,__source:o,__self:r};if(typeof e=="function"&&(l=e.defaultProps))for(u in l)c[u]===void 0&&(c[u]=l[u]);return d.vnode&&d.vnode(s),s}function ne(){return(ne=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var _=arguments[t];for(var n in _)Object.prototype.hasOwnProperty.call(_,n)&&(e[n]=_[n])}return e}).apply(this,arguments)}var Be=["context","children"];function qe(e){this.getChildContext=function(){return e.context};var t=e.children,_=function(n,o){if(n==null)return{};var r,l,u={},c=Object.keys(n);for(l=0;l<c.length;l++)o.indexOf(r=c[l])>=0||(u[r]=n[r]);return u}(e,Be);return He(t,_)}function ze(){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=E(qe,ne({},this._props,{context:e.detail.context}),function t(_,n){if(_.nodeType===3)return _.data;if(_.nodeType!==1)return null;var o=[],r={},l=0,u=_.attributes,c=_.childNodes;for(l=u.length;l--;)u[l].name!=="slot"&&(r[u[l].name]=u[l].value,r[Ne(u[l].name)]=u[l].value);for(l=c.length;l--;){var s=t(c[l],null),f=c[l].slot;f?r[f]=E(se,{name:f},s):o[l]=s}var i=n?E(se,null,o):o;return E(n||_.nodeName.toLowerCase(),r,i)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?Te:z)(this._vdom,this._root)}function Ne(e){return e.replace(/-(\w)/g,function(t,_){return _?_.toUpperCase():""})}function Ve(e,t,_){if(this._vdom){var n={};n[e]=_=_??void 0,n[Ne(e)]=_,this._vdom=He(this._vdom,n),z(this._vdom,this._root)}}function Ge(){z(this._vdom=null,this._root)}function se(e,t){var _=this;return E("slot",ne({},e,{ref:function(n){n?(_.ref=n,_._listener||(_._listener=function(o){o.stopPropagation(),o.detail.context=t},n.addEventListener("_preact",_._listener))):_.ref.removeEventListener("_preact",_._listener)}}))}function Ue(e,t,_,n){function o(){var r=Reflect.construct(HTMLElement,[],o);return r._vdomComponent=e,r._root=n&&n.shadow?r.attachShadow({mode:n.mode||"open"}):r,r}return(o.prototype=Object.create(HTMLElement.prototype)).constructor=o,o.prototype.connectedCallback=ze,o.prototype.attributeChangedCallback=Ve,o.prototype.disconnectedCallback=Ge,_=_||e.observedAttributes||Object.keys(e.propTypes||{}),o.observedAttributes=_,_.forEach(function(r){Object.defineProperty(o.prototype,r,{get:function(){return this._vdom.props[r]},set:function(l){this._vdom?this.attributeChangedCallback(r,null,l):(this._props||(this._props={}),this._props[r]=l,this.connectedCallback());var u=typeof l;l!=null&&u!=="string"&&u!=="boolean"&&u!=="number"||this.setAttribute(r,l)}})}),customElements.define(t||e.tagName||e.displayName||e.name,o)}const Je=({name:e="World"})=>k("p",{children:["Hello, ",e,"!"]});Ue(Je,"x-greeting",["name"],{shadow:!1});var Q,v,G,ce,X=0,Ae=[],y=d,ae=y.__b,fe=y.__r,pe=y.diffed,de=y.__c,he=y.unmount,me=y.__;function Ke(e,t){y.__h&&y.__h(v,e,X||t),X=0;var _=v.__H||(v.__H={__:[],__h:[]});return e>=_.__.length&&_.__.push({}),_.__[e]}function A(e){return X=1,Qe(Le,e)}function Qe(e,t,_){var n=Ke(Q++,2);if(n.t=e,!n.__c&&(n.__=[Le(void 0,t),function(u){var c=n.__N?n.__N[0]:n.__[0],s=n.t(c,u);c!==s&&(n.__N=[s,n.__[1]],n.__c.setState({}))}],n.__c=v,!v.__f)){var o=function(u,c,s){if(!n.__c.__H)return!0;var f=n.__c.__H.__.filter(function(p){return!!p.__c});if(f.every(function(p){return!p.__N}))return!r||r.call(this,u,c,s);var i=n.__c.props!==u;return f.forEach(function(p){if(p.__N){var a=p.__[0];p.__=p.__N,p.__N=void 0,a!==p.__[0]&&(i=!0)}}),r&&r.call(this,u,c,s)||i};v.__f=!0;var r=v.shouldComponentUpdate,l=v.componentWillUpdate;v.componentWillUpdate=function(u,c,s){if(this.__e){var f=r;r=void 0,o(u,c,s),r=f}l&&l.call(this,u,c,s)},v.shouldComponentUpdate=o}return n.__N||n.__}function Xe(){for(var e;e=Ae.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(W),e.__H.__h.forEach(Y),e.__H.__h=[]}catch(t){e.__H.__h=[],y.__e(t,e.__v)}}y.__b=function(e){v=null,ae&&ae(e)},y.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),me&&me(e,t)},y.__r=function(e){fe&&fe(e),Q=0;var t=(v=e.__c).__H;t&&(G===v?(t.__h=[],v.__h=[],t.__.forEach(function(_){_.__N&&(_.__=_.__N),_.u=_.__N=void 0})):(t.__h.forEach(W),t.__h.forEach(Y),t.__h=[],Q=0)),G=v},y.diffed=function(e){pe&&pe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ae.push(t)!==1&&ce===y.requestAnimationFrame||((ce=y.requestAnimationFrame)||Ye)(Xe)),t.__H.__.forEach(function(_){_.u&&(_.__H=_.u),_.u=void 0})),G=v=null},y.__c=function(e,t){t.some(function(_){try{_.__h.forEach(W),_.__h=_.__h.filter(function(n){return!n.__||Y(n)})}catch(n){t.some(function(o){o.__h&&(o.__h=[])}),t=[],y.__e(n,_.__v)}}),de&&de(e,t)},y.unmount=function(e){he&&he(e);var t,_=e.__c;_&&_.__H&&(_.__H.__.forEach(function(n){try{W(n)}catch(o){t=o}}),_.__H=void 0,t&&y.__e(t,_.__v))};var ve=typeof requestAnimationFrame=="function";function Ye(e){var t,_=function(){clearTimeout(n),ve&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(_,35);ve&&(t=requestAnimationFrame(_))}function W(e){var t=v,_=e.__c;typeof _=="function"&&(e.__c=void 0,_()),v=t}function Y(e){var t=v;e.__c=e.__(),v=t}function Le(e,t){return typeof t=="function"?t(e):t}function Ze({onClick:e,color:t,children:_}){return k("button",{style:{background:t||"#1890ff",color:"#fff",border:"none",borderRadius:4,padding:"8px 16px",cursor:"pointer",fontSize:16},onClick:e,children:_})}function et({visible:e,onClose:t,onSubmit:_,color:n}){const[o,r]=A(""),[l,u]=A(""),[c,s]=A(!1),[f,i]=A("");return e?k("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.3)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:k("form",{onSubmit:async a=>{a.preventDefault(),s(!0),i("");try{await _({name:o,email:l}),t()}catch{i("提交失败,请重试")}finally{s(!1)}},style:{background:"#fff",padding:24,borderRadius:8,minWidth:320},children:[k("h2",{style:{color:n||"#1890ff"},children:"表单"}),k("div",{style:{marginBottom:12},children:[k("input",{type:"text",placeholder:"姓名",value:o,onInput:a=>r(a.target.value),required:!0,style:{width:"100%",padding:8,marginBottom:8}}),k("input",{type:"email",placeholder:"邮箱",value:l,onInput:a=>u(a.target.value),required:!0,style:{width:"100%",padding:8}})]}),f&&k("div",{style:{color:"red",marginBottom:8},children:f}),k("button",{type:"submit",disabled:c,style:{background:n||"#1890ff",color:"#fff",border:"none",borderRadius:4,padding:"8px 16px",cursor:"pointer",fontSize:16},children:c?"提交中...":"提交"}),k("button",{type:"button",onClick:t,style:{marginLeft:12,background:"#eee",color:"#333",border:"none",borderRadius:4,padding:"8px 16px",cursor:"pointer",fontSize:16},children:"取消"})]})}):null}function tt(e){const[t,_]=A(!1),n=e.theme?.primaryColor;return k("div",{children:[k(Ze,{color:n,onClick:()=>_(!0),children:"打开表单"}),k(et,{visible:t,onClose:()=>_(!1),onSubmit:async r=>{console.log("submit",r)},color:n})]})}Ue(tt,"x-best-modal-form",["theme"],{shadow:!1});const _t=["x-greeting","x-best-modal-form"];exports.components=_t;exports.npmTest=Me;exports.printCurrentTime=De;
|
package/dist/best-unit.js
CHANGED
|
@@ -1,35 +1,576 @@
|
|
|
1
|
-
function
|
|
1
|
+
function et() {
|
|
2
2
|
console.log("npm package test!!!");
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function tt() {
|
|
5
5
|
console.log("Current time:", (/* @__PURE__ */ new Date()).toISOString());
|
|
6
6
|
}
|
|
7
|
-
var i;
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
i = { __e: function(r, o, l, f) {
|
|
12
|
-
for (var e, c, t; o = o.__; ) if ((e = o.__c) && !e.__) try {
|
|
13
|
-
if ((c = e.constructor) && c.getDerivedStateFromError != null && (e.setState(c.getDerivedStateFromError(r)), t = e.__d), e.componentDidCatch != null && (e.componentDidCatch(r, f || {}), t = e.__d), t) return e.__E = e;
|
|
14
|
-
} catch (n) {
|
|
15
|
-
r = n;
|
|
16
|
-
}
|
|
17
|
-
throw r;
|
|
18
|
-
} }, typeof Promise == "function" && Promise.prototype.then.bind(Promise.resolve());
|
|
19
|
-
var s = 0;
|
|
20
|
-
function u(r, o, l, f, e, c) {
|
|
21
|
-
o || (o = {});
|
|
22
|
-
var t, n, _ = o;
|
|
23
|
-
if ("ref" in _) for (n in _ = {}, o) n == "ref" ? t = o[n] : _[n] = o[n];
|
|
24
|
-
var d = { type: r, props: _, key: l, ref: t, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --s, __i: -1, __u: 0, __source: e, __self: c };
|
|
25
|
-
if (typeof r == "function" && (t = r.defaultProps)) for (n in t) _[n] === void 0 && (_[n] = t[n]);
|
|
26
|
-
return i.vnode && i.vnode(d), d;
|
|
27
|
-
}
|
|
28
|
-
function m() {
|
|
29
|
-
return /* @__PURE__ */ u(p, { children: /* @__PURE__ */ u("div", { children: /* @__PURE__ */ u("h1", { children: "Hello World" }) }) });
|
|
7
|
+
var D, d, ye, S, oe, ge, be, ke, Z, J, K, M = {}, we = [], Me = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, B = Array.isArray;
|
|
8
|
+
function C(e, t) {
|
|
9
|
+
for (var _ in t) e[_] = t[_];
|
|
10
|
+
return e;
|
|
30
11
|
}
|
|
12
|
+
function ee(e) {
|
|
13
|
+
e && e.parentNode && e.parentNode.removeChild(e);
|
|
14
|
+
}
|
|
15
|
+
function E(e, t, _) {
|
|
16
|
+
var n, o, r, l = {};
|
|
17
|
+
for (r in t) r == "key" ? n = t[r] : r == "ref" ? o = t[r] : l[r] = t[r];
|
|
18
|
+
if (arguments.length > 2 && (l.children = arguments.length > 3 ? D.call(arguments, 2) : _), typeof e == "function" && e.defaultProps != null) for (r in e.defaultProps) l[r] === void 0 && (l[r] = e.defaultProps[r]);
|
|
19
|
+
return L(e, l, n, o, null);
|
|
20
|
+
}
|
|
21
|
+
function L(e, t, _, n, o) {
|
|
22
|
+
var r = { type: e, props: t, key: _, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: o ?? ++ye, __i: -1, __u: 0 };
|
|
23
|
+
return o == null && d.vnode != null && d.vnode(r), r;
|
|
24
|
+
}
|
|
25
|
+
function q(e) {
|
|
26
|
+
return e.children;
|
|
27
|
+
}
|
|
28
|
+
function I(e, t) {
|
|
29
|
+
this.props = e, this.context = t;
|
|
30
|
+
}
|
|
31
|
+
function P(e, t) {
|
|
32
|
+
if (t == null) return e.__ ? P(e.__, e.__i + 1) : null;
|
|
33
|
+
for (var _; t < e.__k.length; t++) if ((_ = e.__k[t]) != null && _.__e != null) return _.__e;
|
|
34
|
+
return typeof e.type == "function" ? P(e) : null;
|
|
35
|
+
}
|
|
36
|
+
function xe(e) {
|
|
37
|
+
var t, _;
|
|
38
|
+
if ((e = e.__) != null && e.__c != null) {
|
|
39
|
+
for (e.__e = e.__c.base = null, t = 0; t < e.__k.length; t++) if ((_ = e.__k[t]) != null && _.__e != null) {
|
|
40
|
+
e.__e = e.__c.base = _.__e;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return xe(e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function ie(e) {
|
|
47
|
+
(!e.__d && (e.__d = !0) && S.push(e) && !R.__r++ || oe != d.debounceRendering) && ((oe = d.debounceRendering) || ge)(R);
|
|
48
|
+
}
|
|
49
|
+
function R() {
|
|
50
|
+
for (var e, t, _, n, o, r, l, u = 1; S.length; ) S.length > u && S.sort(be), e = S.shift(), u = S.length, e.__d && (_ = void 0, o = (n = (t = e).__v).__e, r = [], l = [], t.__P && ((_ = C({}, n)).__v = n.__v + 1, d.vnode && d.vnode(_), te(t.__P, _, n, t.__n, t.__P.namespaceURI, 32 & n.__u ? [o] : null, r, o ?? P(n), !!(32 & n.__u), l), _.__v = n.__v, _.__.__k[_.__i] = _, Se(r, _, l), _.__e != o && xe(_)));
|
|
51
|
+
R.__r = 0;
|
|
52
|
+
}
|
|
53
|
+
function Ce(e, t, _, n, o, r, l, u, c, s, f) {
|
|
54
|
+
var i, p, a, g, w, b, h = n && n.__k || we, m = t.length;
|
|
55
|
+
for (c = De(_, t, h, c, m), i = 0; i < m; i++) (a = _.__k[i]) != null && (p = a.__i == -1 ? M : h[a.__i] || M, a.__i = i, b = te(e, a, p, o, r, l, u, c, s, f), g = a.__e, a.ref && p.ref != a.ref && (p.ref && _e(p.ref, null, a), f.push(a.ref, a.__c || g, a)), w == null && g != null && (w = g), 4 & a.__u || p.__k === a.__k ? c = $e(a, c, e) : typeof a.type == "function" && b !== void 0 ? c = b : g && (c = g.nextSibling), a.__u &= -7);
|
|
56
|
+
return _.__e = w, c;
|
|
57
|
+
}
|
|
58
|
+
function De(e, t, _, n, o) {
|
|
59
|
+
var r, l, u, c, s, f = _.length, i = f, p = 0;
|
|
60
|
+
for (e.__k = new Array(o), r = 0; r < o; r++) (l = t[r]) != null && typeof l != "boolean" && typeof l != "function" ? (c = r + p, (l = e.__k[r] = typeof l == "string" || typeof l == "number" || typeof l == "bigint" || l.constructor == String ? L(null, l, null, null, null) : B(l) ? L(q, { children: l }, null, null, null) : l.constructor == null && l.__b > 0 ? L(l.type, l.props, l.key, l.ref ? l.ref : null, l.__v) : l).__ = e, l.__b = e.__b + 1, u = null, (s = l.__i = Fe(l, _, c, i)) != -1 && (i--, (u = _[s]) && (u.__u |= 2)), u == null || u.__v == null ? (s == -1 && (o > f ? p-- : o < f && p++), typeof l.type != "function" && (l.__u |= 4)) : s != c && (s == c - 1 ? p-- : s == c + 1 ? p++ : (s > c ? p-- : p++, l.__u |= 4))) : e.__k[r] = null;
|
|
61
|
+
if (i) for (r = 0; r < f; r++) (u = _[r]) != null && (2 & u.__u) == 0 && (u.__e == n && (n = P(u)), Pe(u, u));
|
|
62
|
+
return n;
|
|
63
|
+
}
|
|
64
|
+
function $e(e, t, _) {
|
|
65
|
+
var n, o;
|
|
66
|
+
if (typeof e.type == "function") {
|
|
67
|
+
for (n = e.__k, o = 0; n && o < n.length; o++) n[o] && (n[o].__ = e, t = $e(n[o], t, _));
|
|
68
|
+
return t;
|
|
69
|
+
}
|
|
70
|
+
e.__e != t && (t && e.type && !_.contains(t) && (t = P(e)), _.insertBefore(e.__e, t || null), t = e.__e);
|
|
71
|
+
do
|
|
72
|
+
t = t && t.nextSibling;
|
|
73
|
+
while (t != null && t.nodeType == 8);
|
|
74
|
+
return t;
|
|
75
|
+
}
|
|
76
|
+
function Fe(e, t, _, n) {
|
|
77
|
+
var o, r, l = e.key, u = e.type, c = t[_];
|
|
78
|
+
if (c === null && e.key == null || c && l == c.key && u == c.type && (2 & c.__u) == 0) return _;
|
|
79
|
+
if (n > (c != null && (2 & c.__u) == 0 ? 1 : 0)) for (o = _ - 1, r = _ + 1; o >= 0 || r < t.length; ) {
|
|
80
|
+
if (o >= 0) {
|
|
81
|
+
if ((c = t[o]) && (2 & c.__u) == 0 && l == c.key && u == c.type) return o;
|
|
82
|
+
o--;
|
|
83
|
+
}
|
|
84
|
+
if (r < t.length) {
|
|
85
|
+
if ((c = t[r]) && (2 & c.__u) == 0 && l == c.key && u == c.type) return r;
|
|
86
|
+
r++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return -1;
|
|
90
|
+
}
|
|
91
|
+
function le(e, t, _) {
|
|
92
|
+
t[0] == "-" ? e.setProperty(t, _ ?? "") : e[t] = _ == null ? "" : typeof _ != "number" || Me.test(t) ? _ : _ + "px";
|
|
93
|
+
}
|
|
94
|
+
function j(e, t, _, n, o) {
|
|
95
|
+
var r, l;
|
|
96
|
+
e: if (t == "style") if (typeof _ == "string") e.style.cssText = _;
|
|
97
|
+
else {
|
|
98
|
+
if (typeof n == "string" && (e.style.cssText = n = ""), n) for (t in n) _ && t in _ || le(e.style, t, "");
|
|
99
|
+
if (_) for (t in _) n && _[t] == n[t] || le(e.style, t, _[t]);
|
|
100
|
+
}
|
|
101
|
+
else if (t[0] == "o" && t[1] == "n") r = t != (t = t.replace(ke, "$1")), l = t.toLowerCase(), t = l in e || t == "onFocusOut" || t == "onFocusIn" ? l.slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + r] = _, _ ? n ? _.u = n.u : (_.u = Z, e.addEventListener(t, r ? K : J, r)) : e.removeEventListener(t, r ? K : J, r);
|
|
102
|
+
else {
|
|
103
|
+
if (o == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
104
|
+
else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
|
|
105
|
+
e[t] = _ ?? "";
|
|
106
|
+
break e;
|
|
107
|
+
} catch {
|
|
108
|
+
}
|
|
109
|
+
typeof _ == "function" || (_ == null || _ === !1 && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && _ == 1 ? "" : _));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function ue(e) {
|
|
113
|
+
return function(t) {
|
|
114
|
+
if (this.l) {
|
|
115
|
+
var _ = this.l[t.type + e];
|
|
116
|
+
if (t.t == null) t.t = Z++;
|
|
117
|
+
else if (t.t < _.u) return;
|
|
118
|
+
return _(d.event ? d.event(t) : t);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function te(e, t, _, n, o, r, l, u, c, s) {
|
|
123
|
+
var f, i, p, a, g, w, b, h, m, H, $, F, T, re, O, N, V, x = t.type;
|
|
124
|
+
if (t.constructor != null) return null;
|
|
125
|
+
128 & _.__u && (c = !!(32 & _.__u), r = [u = t.__e = _.__e]), (f = d.__b) && f(t);
|
|
126
|
+
e: if (typeof x == "function") try {
|
|
127
|
+
if (h = t.props, m = "prototype" in x && x.prototype.render, H = (f = x.contextType) && n[f.__c], $ = f ? H ? H.props.value : f.__ : n, _.__c ? b = (i = t.__c = _.__c).__ = i.__E : (m ? t.__c = i = new x(h, $) : (t.__c = i = new I(h, $), i.constructor = x, i.render = je), H && H.sub(i), i.props = h, i.state || (i.state = {}), i.context = $, i.__n = n, p = i.__d = !0, i.__h = [], i._sb = []), m && i.__s == null && (i.__s = i.state), m && x.getDerivedStateFromProps != null && (i.__s == i.state && (i.__s = C({}, i.__s)), C(i.__s, x.getDerivedStateFromProps(h, i.__s))), a = i.props, g = i.state, i.__v = t, p) m && x.getDerivedStateFromProps == null && i.componentWillMount != null && i.componentWillMount(), m && i.componentDidMount != null && i.__h.push(i.componentDidMount);
|
|
128
|
+
else {
|
|
129
|
+
if (m && x.getDerivedStateFromProps == null && h !== a && i.componentWillReceiveProps != null && i.componentWillReceiveProps(h, $), !i.__e && i.shouldComponentUpdate != null && i.shouldComponentUpdate(h, i.__s, $) === !1 || t.__v == _.__v) {
|
|
130
|
+
for (t.__v != _.__v && (i.props = h, i.state = i.__s, i.__d = !1), t.__e = _.__e, t.__k = _.__k, t.__k.some(function(U) {
|
|
131
|
+
U && (U.__ = t);
|
|
132
|
+
}), F = 0; F < i._sb.length; F++) i.__h.push(i._sb[F]);
|
|
133
|
+
i._sb = [], i.__h.length && l.push(i);
|
|
134
|
+
break e;
|
|
135
|
+
}
|
|
136
|
+
i.componentWillUpdate != null && i.componentWillUpdate(h, i.__s, $), m && i.componentDidUpdate != null && i.__h.push(function() {
|
|
137
|
+
i.componentDidUpdate(a, g, w);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (i.context = $, i.props = h, i.__P = e, i.__e = !1, T = d.__r, re = 0, m) {
|
|
141
|
+
for (i.state = i.__s, i.__d = !1, T && T(t), f = i.render(i.props, i.state, i.context), O = 0; O < i._sb.length; O++) i.__h.push(i._sb[O]);
|
|
142
|
+
i._sb = [];
|
|
143
|
+
} else do
|
|
144
|
+
i.__d = !1, T && T(t), f = i.render(i.props, i.state, i.context), i.state = i.__s;
|
|
145
|
+
while (i.__d && ++re < 25);
|
|
146
|
+
i.state = i.__s, i.getChildContext != null && (n = C(C({}, n), i.getChildContext())), m && !p && i.getSnapshotBeforeUpdate != null && (w = i.getSnapshotBeforeUpdate(a, g)), N = f, f != null && f.type === q && f.key == null && (N = Ee(f.props.children)), u = Ce(e, B(N) ? N : [N], t, _, n, o, r, l, u, c, s), i.base = t.__e, t.__u &= -161, i.__h.length && l.push(i), b && (i.__E = i.__ = null);
|
|
147
|
+
} catch (U) {
|
|
148
|
+
if (t.__v = null, c || r != null) if (U.then) {
|
|
149
|
+
for (t.__u |= c ? 160 : 128; u && u.nodeType == 8 && u.nextSibling; ) u = u.nextSibling;
|
|
150
|
+
r[r.indexOf(u)] = null, t.__e = u;
|
|
151
|
+
} else for (V = r.length; V--; ) ee(r[V]);
|
|
152
|
+
else t.__e = _.__e, t.__k = _.__k;
|
|
153
|
+
d.__e(U, t, _);
|
|
154
|
+
}
|
|
155
|
+
else r == null && t.__v == _.__v ? (t.__k = _.__k, t.__e = _.__e) : u = t.__e = Oe(_.__e, t, _, n, o, r, l, c, s);
|
|
156
|
+
return (f = d.diffed) && f(t), 128 & t.__u ? void 0 : u;
|
|
157
|
+
}
|
|
158
|
+
function Se(e, t, _) {
|
|
159
|
+
for (var n = 0; n < _.length; n++) _e(_[n], _[++n], _[++n]);
|
|
160
|
+
d.__c && d.__c(t, e), e.some(function(o) {
|
|
161
|
+
try {
|
|
162
|
+
e = o.__h, o.__h = [], e.some(function(r) {
|
|
163
|
+
r.call(o);
|
|
164
|
+
});
|
|
165
|
+
} catch (r) {
|
|
166
|
+
d.__e(r, o.__v);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function Ee(e) {
|
|
171
|
+
return typeof e != "object" || e == null || e.__b && e.__b > 0 ? e : B(e) ? e.map(Ee) : C({}, e);
|
|
172
|
+
}
|
|
173
|
+
function Oe(e, t, _, n, o, r, l, u, c) {
|
|
174
|
+
var s, f, i, p, a, g, w, b = _.props, h = t.props, m = t.type;
|
|
175
|
+
if (m == "svg" ? o = "http://www.w3.org/2000/svg" : m == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o || (o = "http://www.w3.org/1999/xhtml"), r != null) {
|
|
176
|
+
for (s = 0; s < r.length; s++) if ((a = r[s]) && "setAttribute" in a == !!m && (m ? a.localName == m : a.nodeType == 3)) {
|
|
177
|
+
e = a, r[s] = null;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (e == null) {
|
|
182
|
+
if (m == null) return document.createTextNode(h);
|
|
183
|
+
e = document.createElementNS(o, m, h.is && h), u && (d.__m && d.__m(t, r), u = !1), r = null;
|
|
184
|
+
}
|
|
185
|
+
if (m == null) b === h || u && e.data == h || (e.data = h);
|
|
186
|
+
else {
|
|
187
|
+
if (r = r && D.call(e.childNodes), b = _.props || M, !u && r != null) for (b = {}, s = 0; s < e.attributes.length; s++) b[(a = e.attributes[s]).name] = a.value;
|
|
188
|
+
for (s in b) if (a = b[s], s != "children") {
|
|
189
|
+
if (s == "dangerouslySetInnerHTML") i = a;
|
|
190
|
+
else if (!(s in h)) {
|
|
191
|
+
if (s == "value" && "defaultValue" in h || s == "checked" && "defaultChecked" in h) continue;
|
|
192
|
+
j(e, s, null, a, o);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
for (s in h) a = h[s], s == "children" ? p = a : s == "dangerouslySetInnerHTML" ? f = a : s == "value" ? g = a : s == "checked" ? w = a : u && typeof a != "function" || b[s] === a || j(e, s, a, b[s], o);
|
|
196
|
+
if (f) u || i && (f.__html == i.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
|
|
197
|
+
else if (i && (e.innerHTML = ""), Ce(t.type == "template" ? e.content : e, B(p) ? p : [p], t, _, n, m == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, r, l, r ? r[0] : _.__k && P(_, 0), u, c), r != null) for (s = r.length; s--; ) ee(r[s]);
|
|
198
|
+
u || (s = "value", m == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[s] || m == "progress" && !g || m == "option" && g != b[s]) && j(e, s, g, b[s], o), s = "checked", w != null && w != e[s] && j(e, s, w, b[s], o));
|
|
199
|
+
}
|
|
200
|
+
return e;
|
|
201
|
+
}
|
|
202
|
+
function _e(e, t, _) {
|
|
203
|
+
try {
|
|
204
|
+
if (typeof e == "function") {
|
|
205
|
+
var n = typeof e.__u == "function";
|
|
206
|
+
n && e.__u(), n && t == null || (e.__u = e(t));
|
|
207
|
+
} else e.current = t;
|
|
208
|
+
} catch (o) {
|
|
209
|
+
d.__e(o, _);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function Pe(e, t, _) {
|
|
213
|
+
var n, o;
|
|
214
|
+
if (d.unmount && d.unmount(e), (n = e.ref) && (n.current && n.current != e.__e || _e(n, null, t)), (n = e.__c) != null) {
|
|
215
|
+
if (n.componentWillUnmount) try {
|
|
216
|
+
n.componentWillUnmount();
|
|
217
|
+
} catch (r) {
|
|
218
|
+
d.__e(r, t);
|
|
219
|
+
}
|
|
220
|
+
n.base = n.__P = null;
|
|
221
|
+
}
|
|
222
|
+
if (n = e.__k) for (o = 0; o < n.length; o++) n[o] && Pe(n[o], t, _ || typeof e.type != "function");
|
|
223
|
+
_ || ee(e.__e), e.__c = e.__ = e.__e = void 0;
|
|
224
|
+
}
|
|
225
|
+
function je(e, t, _) {
|
|
226
|
+
return this.constructor(e, _);
|
|
227
|
+
}
|
|
228
|
+
function z(e, t, _) {
|
|
229
|
+
var n, o, r, l;
|
|
230
|
+
t == document && (t = document.documentElement), d.__ && d.__(e, t), o = (n = typeof _ == "function") ? null : _ && _.__k || t.__k, r = [], l = [], te(t, e = (!n && _ || t).__k = E(q, null, [e]), o || M, M, t.namespaceURI, !n && _ ? [_] : o ? null : t.firstChild ? D.call(t.childNodes) : null, r, !n && _ ? _ : o ? o.__e : t.firstChild, n, l), Se(r, e, l);
|
|
231
|
+
}
|
|
232
|
+
function He(e, t) {
|
|
233
|
+
z(e, t, He);
|
|
234
|
+
}
|
|
235
|
+
function Te(e, t, _) {
|
|
236
|
+
var n, o, r, l, u = C({}, e.props);
|
|
237
|
+
for (r in e.type && e.type.defaultProps && (l = e.type.defaultProps), t) r == "key" ? n = t[r] : r == "ref" ? o = t[r] : u[r] = t[r] === void 0 && l != null ? l[r] : t[r];
|
|
238
|
+
return arguments.length > 2 && (u.children = arguments.length > 3 ? D.call(arguments, 2) : _), L(e.type, u, n || e.key, o || e.ref, null);
|
|
239
|
+
}
|
|
240
|
+
D = we.slice, d = { __e: function(e, t, _, n) {
|
|
241
|
+
for (var o, r, l; t = t.__; ) if ((o = t.__c) && !o.__) try {
|
|
242
|
+
if ((r = o.constructor) && r.getDerivedStateFromError != null && (o.setState(r.getDerivedStateFromError(e)), l = o.__d), o.componentDidCatch != null && (o.componentDidCatch(e, n || {}), l = o.__d), l) return o.__E = o;
|
|
243
|
+
} catch (u) {
|
|
244
|
+
e = u;
|
|
245
|
+
}
|
|
246
|
+
throw e;
|
|
247
|
+
} }, ye = 0, I.prototype.setState = function(e, t) {
|
|
248
|
+
var _;
|
|
249
|
+
_ = this.__s != null && this.__s != this.state ? this.__s : this.__s = C({}, this.state), typeof e == "function" && (e = e(C({}, _), this.props)), e && C(_, e), e != null && this.__v && (t && this._sb.push(t), ie(this));
|
|
250
|
+
}, I.prototype.forceUpdate = function(e) {
|
|
251
|
+
this.__v && (this.__e = !0, e && this.__h.push(e), ie(this));
|
|
252
|
+
}, I.prototype.render = q, S = [], ge = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, be = function(e, t) {
|
|
253
|
+
return e.__v.__b - t.__v.__b;
|
|
254
|
+
}, R.__r = 0, ke = /(PointerCapture)$|Capture$/i, Z = 0, J = ue(!1), K = ue(!0);
|
|
255
|
+
var Ie = 0;
|
|
256
|
+
function k(e, t, _, n, o, r) {
|
|
257
|
+
t || (t = {});
|
|
258
|
+
var l, u, c = t;
|
|
259
|
+
if ("ref" in c) for (u in c = {}, t) u == "ref" ? l = t[u] : c[u] = t[u];
|
|
260
|
+
var s = { type: e, props: c, key: _, ref: l, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --Ie, __i: -1, __u: 0, __source: o, __self: r };
|
|
261
|
+
if (typeof e == "function" && (l = e.defaultProps)) for (u in l) c[u] === void 0 && (c[u] = l[u]);
|
|
262
|
+
return d.vnode && d.vnode(s), s;
|
|
263
|
+
}
|
|
264
|
+
function ne() {
|
|
265
|
+
return (ne = Object.assign ? Object.assign.bind() : function(e) {
|
|
266
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
267
|
+
var _ = arguments[t];
|
|
268
|
+
for (var n in _) Object.prototype.hasOwnProperty.call(_, n) && (e[n] = _[n]);
|
|
269
|
+
}
|
|
270
|
+
return e;
|
|
271
|
+
}).apply(this, arguments);
|
|
272
|
+
}
|
|
273
|
+
var We = ["context", "children"];
|
|
274
|
+
function Re(e) {
|
|
275
|
+
this.getChildContext = function() {
|
|
276
|
+
return e.context;
|
|
277
|
+
};
|
|
278
|
+
var t = e.children, _ = function(n, o) {
|
|
279
|
+
if (n == null) return {};
|
|
280
|
+
var r, l, u = {}, c = Object.keys(n);
|
|
281
|
+
for (l = 0; l < c.length; l++) o.indexOf(r = c[l]) >= 0 || (u[r] = n[r]);
|
|
282
|
+
return u;
|
|
283
|
+
}(e, We);
|
|
284
|
+
return Te(t, _);
|
|
285
|
+
}
|
|
286
|
+
function Be() {
|
|
287
|
+
var e = new CustomEvent("_preact", { detail: {}, bubbles: !0, cancelable: !0 });
|
|
288
|
+
this.dispatchEvent(e), this._vdom = E(Re, ne({}, this._props, { context: e.detail.context }), function t(_, n) {
|
|
289
|
+
if (_.nodeType === 3) return _.data;
|
|
290
|
+
if (_.nodeType !== 1) return null;
|
|
291
|
+
var o = [], r = {}, l = 0, u = _.attributes, c = _.childNodes;
|
|
292
|
+
for (l = u.length; l--; ) u[l].name !== "slot" && (r[u[l].name] = u[l].value, r[Ne(u[l].name)] = u[l].value);
|
|
293
|
+
for (l = c.length; l--; ) {
|
|
294
|
+
var s = t(c[l], null), f = c[l].slot;
|
|
295
|
+
f ? r[f] = E(se, { name: f }, s) : o[l] = s;
|
|
296
|
+
}
|
|
297
|
+
var i = n ? E(se, null, o) : o;
|
|
298
|
+
return E(n || _.nodeName.toLowerCase(), r, i);
|
|
299
|
+
}(this, this._vdomComponent)), (this.hasAttribute("hydrate") ? He : z)(this._vdom, this._root);
|
|
300
|
+
}
|
|
301
|
+
function Ne(e) {
|
|
302
|
+
return e.replace(/-(\w)/g, function(t, _) {
|
|
303
|
+
return _ ? _.toUpperCase() : "";
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function qe(e, t, _) {
|
|
307
|
+
if (this._vdom) {
|
|
308
|
+
var n = {};
|
|
309
|
+
n[e] = _ = _ ?? void 0, n[Ne(e)] = _, this._vdom = Te(this._vdom, n), z(this._vdom, this._root);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function ze() {
|
|
313
|
+
z(this._vdom = null, this._root);
|
|
314
|
+
}
|
|
315
|
+
function se(e, t) {
|
|
316
|
+
var _ = this;
|
|
317
|
+
return E("slot", ne({}, e, { ref: function(n) {
|
|
318
|
+
n ? (_.ref = n, _._listener || (_._listener = function(o) {
|
|
319
|
+
o.stopPropagation(), o.detail.context = t;
|
|
320
|
+
}, n.addEventListener("_preact", _._listener))) : _.ref.removeEventListener("_preact", _._listener);
|
|
321
|
+
} }));
|
|
322
|
+
}
|
|
323
|
+
function Ue(e, t, _, n) {
|
|
324
|
+
function o() {
|
|
325
|
+
var r = Reflect.construct(HTMLElement, [], o);
|
|
326
|
+
return r._vdomComponent = e, r._root = n && n.shadow ? r.attachShadow({ mode: n.mode || "open" }) : r, r;
|
|
327
|
+
}
|
|
328
|
+
return (o.prototype = Object.create(HTMLElement.prototype)).constructor = o, o.prototype.connectedCallback = Be, o.prototype.attributeChangedCallback = qe, o.prototype.disconnectedCallback = ze, _ = _ || e.observedAttributes || Object.keys(e.propTypes || {}), o.observedAttributes = _, _.forEach(function(r) {
|
|
329
|
+
Object.defineProperty(o.prototype, r, { get: function() {
|
|
330
|
+
return this._vdom.props[r];
|
|
331
|
+
}, set: function(l) {
|
|
332
|
+
this._vdom ? this.attributeChangedCallback(r, null, l) : (this._props || (this._props = {}), this._props[r] = l, this.connectedCallback());
|
|
333
|
+
var u = typeof l;
|
|
334
|
+
l != null && u !== "string" && u !== "boolean" && u !== "number" || this.setAttribute(r, l);
|
|
335
|
+
} });
|
|
336
|
+
}), customElements.define(t || e.tagName || e.displayName || e.name, o);
|
|
337
|
+
}
|
|
338
|
+
const Ve = ({ name: e = "World" }) => /* @__PURE__ */ k("p", { children: [
|
|
339
|
+
"Hello, ",
|
|
340
|
+
e,
|
|
341
|
+
"!"
|
|
342
|
+
] });
|
|
343
|
+
Ue(Ve, "x-greeting", ["name"], { shadow: !1 });
|
|
344
|
+
var Q, v, G, ce, X = 0, Ae = [], y = d, ae = y.__b, fe = y.__r, pe = y.diffed, de = y.__c, he = y.unmount, me = y.__;
|
|
345
|
+
function Ge(e, t) {
|
|
346
|
+
y.__h && y.__h(v, e, X || t), X = 0;
|
|
347
|
+
var _ = v.__H || (v.__H = { __: [], __h: [] });
|
|
348
|
+
return e >= _.__.length && _.__.push({}), _.__[e];
|
|
349
|
+
}
|
|
350
|
+
function A(e) {
|
|
351
|
+
return X = 1, Je(Le, e);
|
|
352
|
+
}
|
|
353
|
+
function Je(e, t, _) {
|
|
354
|
+
var n = Ge(Q++, 2);
|
|
355
|
+
if (n.t = e, !n.__c && (n.__ = [Le(void 0, t), function(u) {
|
|
356
|
+
var c = n.__N ? n.__N[0] : n.__[0], s = n.t(c, u);
|
|
357
|
+
c !== s && (n.__N = [s, n.__[1]], n.__c.setState({}));
|
|
358
|
+
}], n.__c = v, !v.__f)) {
|
|
359
|
+
var o = function(u, c, s) {
|
|
360
|
+
if (!n.__c.__H) return !0;
|
|
361
|
+
var f = n.__c.__H.__.filter(function(p) {
|
|
362
|
+
return !!p.__c;
|
|
363
|
+
});
|
|
364
|
+
if (f.every(function(p) {
|
|
365
|
+
return !p.__N;
|
|
366
|
+
})) return !r || r.call(this, u, c, s);
|
|
367
|
+
var i = n.__c.props !== u;
|
|
368
|
+
return f.forEach(function(p) {
|
|
369
|
+
if (p.__N) {
|
|
370
|
+
var a = p.__[0];
|
|
371
|
+
p.__ = p.__N, p.__N = void 0, a !== p.__[0] && (i = !0);
|
|
372
|
+
}
|
|
373
|
+
}), r && r.call(this, u, c, s) || i;
|
|
374
|
+
};
|
|
375
|
+
v.__f = !0;
|
|
376
|
+
var r = v.shouldComponentUpdate, l = v.componentWillUpdate;
|
|
377
|
+
v.componentWillUpdate = function(u, c, s) {
|
|
378
|
+
if (this.__e) {
|
|
379
|
+
var f = r;
|
|
380
|
+
r = void 0, o(u, c, s), r = f;
|
|
381
|
+
}
|
|
382
|
+
l && l.call(this, u, c, s);
|
|
383
|
+
}, v.shouldComponentUpdate = o;
|
|
384
|
+
}
|
|
385
|
+
return n.__N || n.__;
|
|
386
|
+
}
|
|
387
|
+
function Ke() {
|
|
388
|
+
for (var e; e = Ae.shift(); ) if (e.__P && e.__H) try {
|
|
389
|
+
e.__H.__h.forEach(W), e.__H.__h.forEach(Y), e.__H.__h = [];
|
|
390
|
+
} catch (t) {
|
|
391
|
+
e.__H.__h = [], y.__e(t, e.__v);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
y.__b = function(e) {
|
|
395
|
+
v = null, ae && ae(e);
|
|
396
|
+
}, y.__ = function(e, t) {
|
|
397
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), me && me(e, t);
|
|
398
|
+
}, y.__r = function(e) {
|
|
399
|
+
fe && fe(e), Q = 0;
|
|
400
|
+
var t = (v = e.__c).__H;
|
|
401
|
+
t && (G === v ? (t.__h = [], v.__h = [], t.__.forEach(function(_) {
|
|
402
|
+
_.__N && (_.__ = _.__N), _.u = _.__N = void 0;
|
|
403
|
+
})) : (t.__h.forEach(W), t.__h.forEach(Y), t.__h = [], Q = 0)), G = v;
|
|
404
|
+
}, y.diffed = function(e) {
|
|
405
|
+
pe && pe(e);
|
|
406
|
+
var t = e.__c;
|
|
407
|
+
t && t.__H && (t.__H.__h.length && (Ae.push(t) !== 1 && ce === y.requestAnimationFrame || ((ce = y.requestAnimationFrame) || Qe)(Ke)), t.__H.__.forEach(function(_) {
|
|
408
|
+
_.u && (_.__H = _.u), _.u = void 0;
|
|
409
|
+
})), G = v = null;
|
|
410
|
+
}, y.__c = function(e, t) {
|
|
411
|
+
t.some(function(_) {
|
|
412
|
+
try {
|
|
413
|
+
_.__h.forEach(W), _.__h = _.__h.filter(function(n) {
|
|
414
|
+
return !n.__ || Y(n);
|
|
415
|
+
});
|
|
416
|
+
} catch (n) {
|
|
417
|
+
t.some(function(o) {
|
|
418
|
+
o.__h && (o.__h = []);
|
|
419
|
+
}), t = [], y.__e(n, _.__v);
|
|
420
|
+
}
|
|
421
|
+
}), de && de(e, t);
|
|
422
|
+
}, y.unmount = function(e) {
|
|
423
|
+
he && he(e);
|
|
424
|
+
var t, _ = e.__c;
|
|
425
|
+
_ && _.__H && (_.__H.__.forEach(function(n) {
|
|
426
|
+
try {
|
|
427
|
+
W(n);
|
|
428
|
+
} catch (o) {
|
|
429
|
+
t = o;
|
|
430
|
+
}
|
|
431
|
+
}), _.__H = void 0, t && y.__e(t, _.__v));
|
|
432
|
+
};
|
|
433
|
+
var ve = typeof requestAnimationFrame == "function";
|
|
434
|
+
function Qe(e) {
|
|
435
|
+
var t, _ = function() {
|
|
436
|
+
clearTimeout(n), ve && cancelAnimationFrame(t), setTimeout(e);
|
|
437
|
+
}, n = setTimeout(_, 35);
|
|
438
|
+
ve && (t = requestAnimationFrame(_));
|
|
439
|
+
}
|
|
440
|
+
function W(e) {
|
|
441
|
+
var t = v, _ = e.__c;
|
|
442
|
+
typeof _ == "function" && (e.__c = void 0, _()), v = t;
|
|
443
|
+
}
|
|
444
|
+
function Y(e) {
|
|
445
|
+
var t = v;
|
|
446
|
+
e.__c = e.__(), v = t;
|
|
447
|
+
}
|
|
448
|
+
function Le(e, t) {
|
|
449
|
+
return typeof t == "function" ? t(e) : t;
|
|
450
|
+
}
|
|
451
|
+
function Xe({ onClick: e, color: t, children: _ }) {
|
|
452
|
+
return /* @__PURE__ */ k(
|
|
453
|
+
"button",
|
|
454
|
+
{
|
|
455
|
+
style: {
|
|
456
|
+
background: t || "#1890ff",
|
|
457
|
+
color: "#fff",
|
|
458
|
+
border: "none",
|
|
459
|
+
borderRadius: 4,
|
|
460
|
+
padding: "8px 16px",
|
|
461
|
+
cursor: "pointer",
|
|
462
|
+
fontSize: 16
|
|
463
|
+
},
|
|
464
|
+
onClick: e,
|
|
465
|
+
children: _
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
function Ye({ visible: e, onClose: t, onSubmit: _, color: n }) {
|
|
470
|
+
const [o, r] = A(""), [l, u] = A(""), [c, s] = A(!1), [f, i] = A("");
|
|
471
|
+
return e ? /* @__PURE__ */ k("div", { style: {
|
|
472
|
+
position: "fixed",
|
|
473
|
+
top: 0,
|
|
474
|
+
left: 0,
|
|
475
|
+
right: 0,
|
|
476
|
+
bottom: 0,
|
|
477
|
+
background: "rgba(0,0,0,0.3)",
|
|
478
|
+
display: "flex",
|
|
479
|
+
alignItems: "center",
|
|
480
|
+
justifyContent: "center",
|
|
481
|
+
zIndex: 9999
|
|
482
|
+
}, children: /* @__PURE__ */ k(
|
|
483
|
+
"form",
|
|
484
|
+
{
|
|
485
|
+
onSubmit: async (a) => {
|
|
486
|
+
a.preventDefault(), s(!0), i("");
|
|
487
|
+
try {
|
|
488
|
+
await _({ name: o, email: l }), t();
|
|
489
|
+
} catch {
|
|
490
|
+
i("提交失败,请重试");
|
|
491
|
+
} finally {
|
|
492
|
+
s(!1);
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
style: { background: "#fff", padding: 24, borderRadius: 8, minWidth: 320 },
|
|
496
|
+
children: [
|
|
497
|
+
/* @__PURE__ */ k("h2", { style: { color: n || "#1890ff" }, children: "表单" }),
|
|
498
|
+
/* @__PURE__ */ k("div", { style: { marginBottom: 12 }, children: [
|
|
499
|
+
/* @__PURE__ */ k(
|
|
500
|
+
"input",
|
|
501
|
+
{
|
|
502
|
+
type: "text",
|
|
503
|
+
placeholder: "姓名",
|
|
504
|
+
value: o,
|
|
505
|
+
onInput: (a) => r(a.target.value),
|
|
506
|
+
required: !0,
|
|
507
|
+
style: { width: "100%", padding: 8, marginBottom: 8 }
|
|
508
|
+
}
|
|
509
|
+
),
|
|
510
|
+
/* @__PURE__ */ k(
|
|
511
|
+
"input",
|
|
512
|
+
{
|
|
513
|
+
type: "email",
|
|
514
|
+
placeholder: "邮箱",
|
|
515
|
+
value: l,
|
|
516
|
+
onInput: (a) => u(a.target.value),
|
|
517
|
+
required: !0,
|
|
518
|
+
style: { width: "100%", padding: 8 }
|
|
519
|
+
}
|
|
520
|
+
)
|
|
521
|
+
] }),
|
|
522
|
+
f && /* @__PURE__ */ k("div", { style: { color: "red", marginBottom: 8 }, children: f }),
|
|
523
|
+
/* @__PURE__ */ k(
|
|
524
|
+
"button",
|
|
525
|
+
{
|
|
526
|
+
type: "submit",
|
|
527
|
+
disabled: c,
|
|
528
|
+
style: {
|
|
529
|
+
background: n || "#1890ff",
|
|
530
|
+
color: "#fff",
|
|
531
|
+
border: "none",
|
|
532
|
+
borderRadius: 4,
|
|
533
|
+
padding: "8px 16px",
|
|
534
|
+
cursor: "pointer",
|
|
535
|
+
fontSize: 16
|
|
536
|
+
},
|
|
537
|
+
children: c ? "提交中..." : "提交"
|
|
538
|
+
}
|
|
539
|
+
),
|
|
540
|
+
/* @__PURE__ */ k(
|
|
541
|
+
"button",
|
|
542
|
+
{
|
|
543
|
+
type: "button",
|
|
544
|
+
onClick: t,
|
|
545
|
+
style: { marginLeft: 12, background: "#eee", color: "#333", border: "none", borderRadius: 4, padding: "8px 16px", cursor: "pointer", fontSize: 16 },
|
|
546
|
+
children: "取消"
|
|
547
|
+
}
|
|
548
|
+
)
|
|
549
|
+
]
|
|
550
|
+
}
|
|
551
|
+
) }) : null;
|
|
552
|
+
}
|
|
553
|
+
function Ze(e) {
|
|
554
|
+
const [t, _] = A(!1), n = e.theme?.primaryColor;
|
|
555
|
+
return /* @__PURE__ */ k("div", { children: [
|
|
556
|
+
/* @__PURE__ */ k(Xe, { color: n, onClick: () => _(!0), children: "打开表单" }),
|
|
557
|
+
/* @__PURE__ */ k(
|
|
558
|
+
Ye,
|
|
559
|
+
{
|
|
560
|
+
visible: t,
|
|
561
|
+
onClose: () => _(!1),
|
|
562
|
+
onSubmit: async (r) => {
|
|
563
|
+
console.log("submit", r);
|
|
564
|
+
},
|
|
565
|
+
color: n
|
|
566
|
+
}
|
|
567
|
+
)
|
|
568
|
+
] });
|
|
569
|
+
}
|
|
570
|
+
Ue(Ze, "x-best-modal-form", ["theme"], { shadow: !1 });
|
|
571
|
+
const _t = ["x-greeting", "x-best-modal-form"];
|
|
31
572
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
573
|
+
_t as components,
|
|
574
|
+
et as npmTest,
|
|
575
|
+
tt as printCurrentTime
|
|
35
576
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function npmTest(): void;
|
|
2
|
+
|
|
3
|
+
export declare function printCurrentTime(): void;
|
|
4
|
+
|
|
5
|
+
declare namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'x-greeting': {
|
|
8
|
+
name?: string; // 组件支持的属性
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/// <reference path="./preact-custom-element.d.ts" />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'preact-custom-element'
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "best-unit",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/best-unit.cjs",
|
|
7
7
|
"module": "dist/best-unit.js",
|
|
8
|
-
"types": "dist/
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "vite",
|
|
11
|
-
"build": "tsc -b && vite build",
|
|
11
|
+
"build": "tsc -b && vite build && cp -r src/types dist/types",
|
|
12
|
+
"prepublishOnly": "npm version patch --no-git-tag-version",
|
|
12
13
|
"preview": "vite preview"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
|
-
"preact": "^10.26.9"
|
|
16
|
+
"preact": "^10.26.9",
|
|
17
|
+
"preact-custom-element": "^4.3.0"
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
18
20
|
"@preact/preset-vite": "^2.10.2",
|
package/src/app.tsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import register from 'preact-custom-element';
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
)
|
|
10
|
-
}
|
|
3
|
+
const Greeting = ({ name = 'World' }) => (
|
|
4
|
+
<p>Hello, {name}!</p>
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
register(Greeting, 'x-greeting', ['name'], { shadow: false });
|
|
8
|
+
|
|
9
|
+
export default Greeting;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComponentChildren } from 'preact';
|
|
2
|
+
|
|
3
|
+
interface ButtonProps {
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
color?: string;
|
|
6
|
+
children: ComponentChildren;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function ThemedButton({ onClick, color, children }: ButtonProps) {
|
|
10
|
+
return (
|
|
11
|
+
<button
|
|
12
|
+
style={{
|
|
13
|
+
background: color || '#1890ff',
|
|
14
|
+
color: '#fff',
|
|
15
|
+
border: 'none',
|
|
16
|
+
borderRadius: 4,
|
|
17
|
+
padding: '8px 16px',
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
fontSize: 16,
|
|
20
|
+
}}
|
|
21
|
+
onClick={onClick}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</button>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useState } from 'preact/hooks';
|
|
2
|
+
|
|
3
|
+
interface ModalFormProps {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
onSubmit: (form: { name: string; email: string }) => Promise<void>;
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function ModalForm({ visible, onClose, onSubmit, color }: ModalFormProps) {
|
|
11
|
+
const [name, setName] = useState('');
|
|
12
|
+
const [email, setEmail] = useState('');
|
|
13
|
+
const [loading, setLoading] = useState(false);
|
|
14
|
+
const [error, setError] = useState('');
|
|
15
|
+
|
|
16
|
+
if (!visible) return null;
|
|
17
|
+
|
|
18
|
+
const handleSubmit = async (e: Event) => {
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
setLoading(true);
|
|
21
|
+
setError('');
|
|
22
|
+
try {
|
|
23
|
+
await onSubmit({ name, email });
|
|
24
|
+
onClose();
|
|
25
|
+
} catch {
|
|
26
|
+
setError('提交失败,请重试');
|
|
27
|
+
} finally {
|
|
28
|
+
setLoading(false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div style={{
|
|
34
|
+
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
|
|
35
|
+
background: 'rgba(0,0,0,0.3)', display: 'flex', alignItems: 'center', justifyContent: 'center', zIndex: 9999
|
|
36
|
+
}}>
|
|
37
|
+
<form
|
|
38
|
+
onSubmit={handleSubmit}
|
|
39
|
+
style={{ background: '#fff', padding: 24, borderRadius: 8, minWidth: 320 }}
|
|
40
|
+
>
|
|
41
|
+
<h2 style={{ color: color || '#1890ff' }}>表单</h2>
|
|
42
|
+
<div style={{ marginBottom: 12 }}>
|
|
43
|
+
<input
|
|
44
|
+
type="text"
|
|
45
|
+
placeholder="姓名"
|
|
46
|
+
value={name}
|
|
47
|
+
onInput={e => setName((e.target as HTMLInputElement).value)}
|
|
48
|
+
required
|
|
49
|
+
style={{ width: '100%', padding: 8, marginBottom: 8 }}
|
|
50
|
+
/>
|
|
51
|
+
<input
|
|
52
|
+
type="email"
|
|
53
|
+
placeholder="邮箱"
|
|
54
|
+
value={email}
|
|
55
|
+
onInput={e => setEmail((e.target as HTMLInputElement).value)}
|
|
56
|
+
required
|
|
57
|
+
style={{ width: '100%', padding: 8 }}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
{error && <div style={{ color: 'red', marginBottom: 8 }}>{error}</div>}
|
|
61
|
+
<button
|
|
62
|
+
type="submit"
|
|
63
|
+
disabled={loading}
|
|
64
|
+
style={{
|
|
65
|
+
background: color || '#1890ff', color: '#fff', border: 'none', borderRadius: 4, padding: '8px 16px', cursor: 'pointer', fontSize: 16
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{loading ? '提交中...' : '提交'}
|
|
69
|
+
</button>
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
onClick={onClose}
|
|
73
|
+
style={{ marginLeft: 12, background: '#eee', color: '#333', border: 'none', borderRadius: 4, padding: '8px 16px', cursor: 'pointer', fontSize: 16 }}
|
|
74
|
+
>
|
|
75
|
+
取消
|
|
76
|
+
</button>
|
|
77
|
+
</form>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useState } from 'preact/hooks';
|
|
2
|
+
import { ThemedButton } from './components/Button';
|
|
3
|
+
import { ModalForm } from './components/ModalForm';
|
|
4
|
+
import register from 'preact-custom-element';
|
|
5
|
+
|
|
6
|
+
export function BestUnit(props: any) {
|
|
7
|
+
const [visible, setVisible] = useState(false);
|
|
8
|
+
const color = props.theme?.primaryColor;
|
|
9
|
+
|
|
10
|
+
const handleSubmit = async (form: { name: string; email: string }) => {
|
|
11
|
+
console.log('submit', form);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div>
|
|
16
|
+
<ThemedButton color={color} onClick={() => setVisible(true)}>
|
|
17
|
+
打开表单
|
|
18
|
+
</ThemedButton>
|
|
19
|
+
<ModalForm
|
|
20
|
+
visible={visible}
|
|
21
|
+
onClose={() => setVisible(false)}
|
|
22
|
+
onSubmit={handleSubmit}
|
|
23
|
+
color={color}
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
register(BestUnit, 'x-best-modal-form', ['theme'], { shadow: false });
|
|
31
|
+
|
|
32
|
+
export default BestUnit;
|
package/src/main.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import { npmTest, printCurrentTime } from './index.ts'
|
|
3
|
-
import
|
|
3
|
+
import './app.tsx'
|
|
4
|
+
import './components/ModalForm'
|
|
4
5
|
|
|
6
|
+
// 可选:导出组件列表或版本信息
|
|
7
|
+
export const components = ['x-greeting', 'x-best-modal-form'];
|
|
5
8
|
export {
|
|
6
9
|
npmTest,
|
|
7
10
|
printCurrentTime,
|
|
8
|
-
App
|
|
9
11
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function npmTest(): void;
|
|
2
|
+
|
|
3
|
+
export declare function printCurrentTime(): void;
|
|
4
|
+
|
|
5
|
+
declare namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'x-greeting': {
|
|
8
|
+
name?: string; // 组件支持的属性
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/// <reference path="./preact-custom-element.d.ts" />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'preact-custom-element'
|