@mi-avalon/libs 0.0.14 → 0.0.15

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.
@@ -0,0 +1,32 @@
1
+ (function(d,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("antd")):typeof define=="function"&&define.amd?define(["exports","react","antd"],m):(d=typeof globalThis<"u"?globalThis:d||self,m(d.MiAvalonLibs={},d.React,d.antd))})(this,function(d,m,O){"use strict";var Rr=Object.defineProperty;var yr=(d,m,O)=>m in d?Rr(d,m,{enumerable:!0,configurable:!0,writable:!0,value:O}):d[m]=O;var c=(d,m,O)=>(yr(d,typeof m!="symbol"?m+"":m,O),O);var J={exports:{}},$={};/**
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 ae;function xe(){if(ae)return $;ae=1;var S=m,R=Symbol.for("react.element"),w=Symbol.for("react.fragment"),C=Object.prototype.hasOwnProperty,z=S.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,L={key:!0,ref:!0,__self:!0,__source:!0};function F(T,p,A){var b,y={},D=null,H=null;A!==void 0&&(D=""+A),p.key!==void 0&&(D=""+p.key),p.ref!==void 0&&(H=p.ref);for(b in p)C.call(p,b)&&!L.hasOwnProperty(b)&&(y[b]=p[b]);if(T&&T.defaultProps)for(b in p=T.defaultProps,p)y[b]===void 0&&(y[b]=p[b]);return{$$typeof:R,type:T,key:D,ref:H,props:y,_owner:z.current}}return $.Fragment=w,$.jsx=F,$.jsxs=F,$}var M={};/**
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 ie;function ke(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&function(){var S=m,R=Symbol.for("react.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),z=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),T=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),H=Symbol.for("react.offscreen"),ue=Symbol.iterator,Ie="@@iterator";function We(e){if(e===null||typeof e!="object")return null;var r=ue&&e[ue]||e[Ie];return typeof r=="function"?r:null}var x=S.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];Ne("error",e,t)}}function Ne(e,r,t){{var n=x.ReactDebugCurrentFrame,o=n.getStackAddendum();o!==""&&(r+="%s",t=t.concat([o]));var u=t.map(function(i){return String(i)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var ze=!1,Le=!1,He=!1,Ue=!1,Ve=!1,se;se=Symbol.for("react.module.reference");function Ze(e){return!!(typeof e=="string"||typeof e=="function"||e===C||e===L||Ve||e===z||e===A||e===b||Ue||e===H||ze||Le||He||typeof e=="object"&&e!==null&&(e.$$typeof===D||e.$$typeof===y||e.$$typeof===F||e.$$typeof===T||e.$$typeof===p||e.$$typeof===se||e.getModuleId!==void 0))}function Be(e,r,t){var n=e.displayName;if(n)return n;var o=r.displayName||r.name||"";return o!==""?t+"("+o+")":t}function ce(e){return e.displayName||"Context"}function E(e){if(e==null)return null;if(typeof e.tag=="number"&&v("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 C:return"Fragment";case w:return"Portal";case L:return"Profiler";case z:return"StrictMode";case A:return"Suspense";case b:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case T:var r=e;return ce(r)+".Consumer";case F:var t=e;return ce(t._context)+".Provider";case p:return Be(e,e.render,"ForwardRef");case y:var n=e.displayName||null;return n!==null?n:E(e.type)||"Memo";case D:{var o=e,u=o._payload,i=o._init;try{return E(i(u))}catch{return null}}}return null}var j=Object.assign,I=0,fe,le,de,ve,pe,ge,me;function he(){}he.__reactDisabledLog=!0;function Je(){{if(I===0){fe=console.log,le=console.info,de=console.warn,ve=console.error,pe=console.group,ge=console.groupCollapsed,me=console.groupEnd;var e={configurable:!0,enumerable:!0,value:he,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}I++}}function qe(){{if(I--,I===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},e,{value:fe}),info:j({},e,{value:le}),warn:j({},e,{value:de}),error:j({},e,{value:ve}),group:j({},e,{value:pe}),groupCollapsed:j({},e,{value:ge}),groupEnd:j({},e,{value:me})})}I<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var q=x.ReactCurrentDispatcher,G;function U(e,r,t){{if(G===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);G=n&&n[1]||""}return`
18
+ `+G+e}}var K=!1,V;{var Ge=typeof WeakMap=="function"?WeakMap:Map;V=new Ge}function be(e,r){if(!e||K)return"";{var t=V.get(e);if(t!==void 0)return t}var n;K=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=q.current,q.current=null,Je();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
+ `),g=n.stack.split(`
20
+ `),f=a.length-1,l=g.length-1;f>=1&&l>=0&&a[f]!==g[l];)l--;for(;f>=1&&l>=0;f--,l--)if(a[f]!==g[l]){if(f!==1||l!==1)do if(f--,l--,l<0||a[f]!==g[l]){var _=`
21
+ `+a[f].replace(" at new "," at ");return e.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",e.displayName)),typeof e=="function"&&V.set(e,_),_}while(f>=1&&l>=0);break}}}finally{K=!1,q.current=u,qe(),Error.prepareStackTrace=o}var P=e?e.displayName||e.name:"",Y=P?U(P):"";return typeof e=="function"&&V.set(e,Y),Y}function Ke(e,r,t){return be(e,!1)}function Xe(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function Z(e,r,t){if(e==null)return"";if(typeof e=="function")return be(e,Xe(e));if(typeof e=="string")return U(e);switch(e){case A:return U("Suspense");case b:return U("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case p:return Ke(e.render);case y:return Z(e.type,r,t);case D:{var n=e,o=n._payload,u=n._init;try{return Z(u(o),r,t)}catch{}}}return""}var W=Object.prototype.hasOwnProperty,_e={},Ee=x.ReactDebugCurrentFrame;function B(e){if(e){var r=e._owner,t=Z(e.type,e._source,r?r.type:null);Ee.setExtraStackFrame(t)}else Ee.setExtraStackFrame(null)}function Qe(e,r,t,n,o){{var u=Function.call.bind(W);for(var i in e)if(u(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var g=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 g.name="Invariant Violation",g}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)&&(B(o),v("%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),B(null)),a instanceof Error&&!(a.message in _e)&&(_e[a.message]=!0,B(o),v("Failed %s type: %s",t,a.message),B(null))}}}var er=Array.isArray;function X(e){return er(e)}function rr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function tr(e){try{return Re(e),!1}catch{return!0}}function Re(e){return""+e}function ye(e){if(tr(e))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",rr(e)),Re(e)}var N=x.ReactCurrentOwner,nr={key:!0,ref:!0,__self:!0,__source:!0},Oe,Se,Q;Q={};function ar(e){if(W.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function ir(e){if(W.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function or(e,r){if(typeof e.ref=="string"&&N.current&&r&&N.current.stateNode!==r){var t=E(N.current.type);Q[t]||(v('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',E(N.current.type),e.ref),Q[t]=!0)}}function ur(e,r){{var t=function(){Oe||(Oe=!0,v("%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 sr(e,r){{var t=function(){Se||(Se=!0,v("%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 cr=function(e,r,t,n,o,u,i){var a={$$typeof:R,type:e,key:r,ref:t,props:i,_owner:u};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:o}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function fr(e,r,t,n,o){{var u,i={},a=null,g=null;t!==void 0&&(ye(t),a=""+t),ir(r)&&(ye(r.key),a=""+r.key),ar(r)&&(g=r.ref,or(r,o));for(u in r)W.call(r,u)&&!nr.hasOwnProperty(u)&&(i[u]=r[u]);if(e&&e.defaultProps){var f=e.defaultProps;for(u in f)i[u]===void 0&&(i[u]=f[u])}if(a||g){var l=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&ur(i,l),g&&sr(i,l)}return cr(e,a,g,o,n,N.current,i)}}var ee=x.ReactCurrentOwner,Ce=x.ReactDebugCurrentFrame;function k(e){if(e){var r=e._owner,t=Z(e.type,e._source,r?r.type:null);Ce.setExtraStackFrame(t)}else Ce.setExtraStackFrame(null)}var re;re=!1;function te(e){return typeof e=="object"&&e!==null&&e.$$typeof===R}function we(){{if(ee.current){var e=E(ee.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function lr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
24
+
25
+ Check your code at `+r+":"+t+"."}return""}}var Te={};function dr(e){{var r=we();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
26
+
27
+ Check the top-level render call using <`+t+">.")}return r}}function De(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=dr(r);if(Te[t])return;Te[t]=!0;var n="";e&&e._owner&&e._owner!==ee.current&&(n=" It was passed a child from "+E(e._owner.type)+"."),k(e),v('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),k(null)}}function je(e,r){{if(typeof e!="object")return;if(X(e))for(var t=0;t<e.length;t++){var n=e[t];te(n)&&De(n,r)}else if(te(e))e._store&&(e._store.validated=!0);else if(e){var o=We(e);if(typeof o=="function"&&o!==e.entries)for(var u=o.call(e),i;!(i=u.next()).done;)te(i.value)&&De(i.value,r)}}}function vr(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===y))t=r.propTypes;else return;if(t){var n=E(r);Qe(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!re){re=!0;var o=E(r);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",o||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function pr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){k(e),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),k(null);break}}e.ref!==null&&(k(e),v("Invalid attribute `ref` supplied to `React.Fragment`."),k(null))}}var Ye={};function Ae(e,r,t,n,o,u){{var i=Ze(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 g=lr(o);g?a+=g:a+=we();var f;e===null?f="null":X(e)?f="array":e!==void 0&&e.$$typeof===R?(f="<"+(E(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):f=typeof e,v("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 l=fr(e,r,t,o,u);if(l==null)return l;if(i){var _=r.children;if(_!==void 0)if(n)if(X(_)){for(var P=0;P<_.length;P++)je(_[P],e);Object.freeze&&Object.freeze(_)}else v("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 je(_,e)}if(W.call(r,"key")){var Y=E(e),h=Object.keys(r).filter(function(Er){return Er!=="key"}),ne=h.length>0?"{key: someKey, "+h.join(": ..., ")+": ...}":"{key: someKey}";if(!Ye[Y+ne]){var _r=h.length>0?"{"+h.join(": ..., ")+": ...}":"{}";v(`A props object containing a "key" prop is being spread into JSX:
28
+ let props = %s;
29
+ <%s {...props} />
30
+ React keys must be passed directly to JSX without using spread:
31
+ let props = %s;
32
+ <%s key={someKey} {...props} />`,ne,Y,_r,Y),Ye[Y+ne]=!0}}return e===C?pr(l):vr(l),l}}function gr(e,r,t){return Ae(e,r,t,!0)}function mr(e,r,t){return Ae(e,r,t,!1)}var hr=mr,br=gr;M.Fragment=C,M.jsx=hr,M.jsxs=br}()),M}process.env.NODE_ENV==="production"?J.exports=xe():J.exports=ke();var oe=J.exports;const Or="",Pe=({type:S="primary",children:R,onClick:w,custom:C})=>oe.jsx(O.Button,{type:S,onClick:w,className:"my-button",children:C||R}),Sr="",$e=({value:S,placeholder:R,onChange:w})=>oe.jsx(O.Input,{value:S,placeholder:R,onChange:w,className:"my-input"}),Me={YMD_Hms:"YYYY-MM-DD HH:mm:ss",YMD:"YYYY-MM-DD",YMD2:"YYYYMMDD",YMD_POINT:"YYYY.M.DD",Hms:"HH:mm:ss",Hm:"HH:mm",YMD_000:"YYYY-MM-DD 00:00:00",YMD_end:"YYYY-MM-DD 23:59:59",YMD_Hm:"YYYYMMDD HHmm"},Fe=10;class s{}c(s,"integerRegex",/^-?\d+$/),c(s,"positiveIntegerRegex",/^[1-9]\d*$/),c(s,"negativeIntegerRegex",/^-[1-9]\d*$/),c(s,"floatRegex",/^-?\d+(\.\d+)?$/),c(s,"letter",/^[a-zA-Z]+$/),c(s,"chinese",/^[\u4e00-\u9fa5]+$/),c(s,"number",/^[0-9]*$/),c(s,"username",/^[a-zA-Z]\w{3,15}$/),c(s,"strongUsername",/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,20}$/),c(s,"password",/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/),c(s,"strongPassword",/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/),c(s,"phone",/^1[3-9]\d{9}$/),c(s,"phoneWithAreaCode",/^\+?\d{2,3}-?\d{8,11}$/),c(s,"email",/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/),c(s,"idCard",/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/),c(s,"bankCard",/^[1-9]\d{3,30}$/),c(s,"zipCode",/^[1-9]\d{5}$/),c(s,"ip",/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/),c(s,"url",/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/),c(s,"carNumber",/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/),c(s,"time",/^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/),c(s,"date",/^(\d{4})-(\d{2})-(\d{2})$/),d.DATE_FORMAT=Me,d.MyButton=Pe,d.MyInput=$e,d.PAGE_SIZE=Fe,d.PatternType=s,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,74 +1,35 @@
1
1
  {
2
- "name": "@mi-avalon/libs",
3
- "author": "顾冬杰",
4
- "module": "dist/lib.esm.js",
5
- "version": "0.0.14",
6
- "license": "MIT",
7
- "main": "dist/index.js",
8
- "typings": "dist/index.d.ts",
9
- "files": [
10
- "dist"
11
- ],
12
- "exports": {
13
- ".": {
14
- "import": "./dist/lib.esm.js",
15
- "require": "./dist/index.js",
16
- "types": "./dist/index.d.ts"
17
- },
18
- "./*": "./dist/*"
19
- },
20
- "engines": {
21
- "node": ">=18"
22
- },
23
- "scripts": {
24
- "start": "tsdx watch",
25
- "build": "tsdx build",
26
- "test": "tsdx test --passWithNoTests",
27
- "lint": "tsdx lint",
28
- "prepare": "tsdx build",
29
- "size": "size-limit",
30
- "analyze": "size-limit --why"
31
- },
32
- "peerDependencies": {
33
- "antd": ">=5",
34
- "react": ">=18.0.0 || ^19.0.0",
35
- "react-dom": ">=18.0.0 || ^19.0.0"
36
- },
37
- "husky": {
38
- "hooks": {
39
- "pre-commit": "tsdx lint"
40
- }
41
- },
42
- "prettier": {
43
- "printWidth": 80,
44
- "semi": true,
45
- "singleQuote": true,
46
- "trailingComma": "es5"
47
- },
48
- "size-limit": [
49
- {
50
- "path": "dist/lib.cjs.production.min.js",
51
- "limit": "10 KB"
52
- },
53
- {
54
- "path": "dist/lib.esm.js",
55
- "limit": "10 KB"
56
- }
57
- ],
58
- "devDependencies": {
59
- "@size-limit/preset-small-lib": "^11.2.0",
60
- "@types/react": "^19.1.8",
61
- "@types/react-dom": "^19.1.6",
62
- "antd": "^5.26.6",
63
- "husky": "^9.1.7",
64
- "postcss": "^8.5.6",
65
- "react": "^19.1.0",
66
- "react-dom": "^19.1.0",
67
- "rollup-plugin-postcss": "^4.0.2",
68
- "sass": "^1.89.2",
69
- "size-limit": "^11.2.0",
70
- "tsdx": "^0.14.1",
71
- "tslib": "^2.8.1",
72
- "typescript": "^5.8.3"
73
- }
2
+ "name": "@mi-avalon/libs",
3
+ "private": false,
4
+ "version": "0.0.15",
5
+ "type": "module",
6
+ "main": "./dist/index.umd.js",
7
+ "module": "./dist/index.es.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "dev": "vite",
14
+ "build": "vite build && tsc --declaration --emitDeclarationOnly --outDir dist",
15
+ "preview": "vite preview"
16
+ },
17
+ "dependencies": {
18
+ "antd": "^4.0.0 || ^5.0.0",
19
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
20
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^20.0.0",
24
+ "@types/react": "^18.0.0",
25
+ "@types/react-dom": "^18.0.0",
26
+ "@vitejs/plugin-react": "^4.7.0",
27
+ "typescript": "^5.0.0",
28
+ "vite": "^4.5.14"
29
+ },
30
+ "peerDependencies": {
31
+ "antd": "^4.0.0 || ^5.0.0",
32
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
33
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
34
+ }
74
35
  }
package/README.md DELETED
@@ -1,160 +0,0 @@
1
- # TSDX React User Guide
2
-
3
- Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.
4
-
5
- > This TSDX setup is meant for developing React component libraries (not apps!) that can be published to NPM. If you’re looking to build a React-based app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.
6
-
7
- > If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
8
-
9
- ## Commands
10
-
11
- TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.
12
-
13
- The recommended workflow is to run TSDX in one terminal:
14
-
15
- ```bash
16
- npm start # or yarn start
17
- ```
18
-
19
- This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
20
-
21
- Then run the example inside another:
22
-
23
- ```bash
24
- cd example
25
- npm i # or yarn to install dependencies
26
- npm start # or yarn start
27
- ```
28
-
29
- The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases).
30
-
31
- To do a one-off build, use `npm run build` or `yarn build`.
32
-
33
- To run tests, use `npm test` or `yarn test`.
34
-
35
- ## Configuration
36
-
37
- Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
38
-
39
- ### Jest
40
-
41
- Jest tests are set up to run with `npm test` or `yarn test`.
42
-
43
- ### Bundle analysis
44
-
45
- Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `npm run size` and visulize it with `npm run analyze`.
46
-
47
- #### Setup Files
48
-
49
- This is the folder structure we set up for you:
50
-
51
- ```txt
52
- /example
53
- index.html
54
- index.tsx # test your component here in a demo app
55
- package.json
56
- tsconfig.json
57
- /src
58
- index.tsx # EDIT THIS
59
- /test
60
- blah.test.tsx # EDIT THIS
61
- .gitignore
62
- package.json
63
- README.md # EDIT THIS
64
- tsconfig.json
65
- ```
66
-
67
- #### React Testing Library
68
-
69
- We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
70
-
71
- ### Rollup
72
-
73
- TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
74
-
75
- ### TypeScript
76
-
77
- `tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
78
-
79
- ## Continuous Integration
80
-
81
- ### GitHub Actions
82
-
83
- Two actions are added by default:
84
-
85
- - `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
86
- - `size` which comments cost comparison of your library on every pull request using [`size-limit`](https://github.com/ai/size-limit)
87
-
88
- ## Optimizations
89
-
90
- Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
91
-
92
- ```js
93
- // ./types/index.d.ts
94
- declare var __DEV__: boolean;
95
-
96
- // inside your code...
97
- if (__DEV__) {
98
- console.log('foo');
99
- }
100
- ```
101
-
102
- You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
103
-
104
- ## Module Formats
105
-
106
- CJS, ESModules, and UMD module formats are supported.
107
-
108
- The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
109
-
110
- ## Deploying the Example Playground
111
-
112
- The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
113
-
114
- ```bash
115
- cd example # if not already in the example folder
116
- npm run build # builds to dist
117
- netlify deploy # deploy the dist folder
118
- ```
119
-
120
- Alternatively, if you already have a git repo connected, you can set up continuous deployment with Netlify:
121
-
122
- ```bash
123
- netlify init
124
- # build command: yarn build && cd example && yarn && yarn build
125
- # directory to deploy: example/dist
126
- # pick yes for netlify.toml
127
- ```
128
-
129
- ## Named Exports
130
-
131
- Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
132
-
133
- ## Including Styles
134
-
135
- There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
136
-
137
- For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
138
-
139
- ## Publishing to NPM
140
-
141
- We recommend using [np](https://github.com/sindresorhus/np).
142
-
143
- ## Usage with Lerna
144
-
145
- When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
146
-
147
- The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
148
-
149
- Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
150
-
151
- ```diff
152
- "alias": {
153
- - "react": "../node_modules/react",
154
- - "react-dom": "../node_modules/react-dom"
155
- + "react": "../../../node_modules/react",
156
- + "react-dom": "../../../node_modules/react-dom"
157
- },
158
- ```
159
-
160
- An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)
@@ -1 +0,0 @@
1
- export * from './MyButton';
@@ -1,7 +0,0 @@
1
- export * from './useFuncRequest';
2
- export * from './useInterval';
3
- export * from './usePagination';
4
- export * from './useQuery';
5
- export * from './useReactive';
6
- export * from './useTimeout';
7
- export * from './useVirtualList';
@@ -1,16 +0,0 @@
1
- declare type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
2
- export declare type UseFuncRequestOptions<T extends (...args: any[]) => Promise<any>> = {
3
- autoRunArgs?: Parameters<T>;
4
- onBefore?: (...args: Parameters<T>) => boolean | Promise<boolean>;
5
- onSuccess?: (data: UnwrapPromise<ReturnType<T>>) => void | Promise<void>;
6
- onError?: (error: Error) => void | Promise<void>;
7
- onFinally?: () => void | Promise<void>;
8
- };
9
- export declare function useFuncRequest<T extends (...args: any[]) => Promise<any>>(asyncFunc: T, options?: UseFuncRequestOptions<T>): {
10
- run: (...args: Parameters<T>) => Promise<any>;
11
- cancel: () => void;
12
- loading: boolean;
13
- error: Error | null;
14
- data: UnwrapPromise<ReturnType<T>> | null;
15
- };
16
- export {};
@@ -1,8 +0,0 @@
1
- declare type Callback = () => void;
2
- interface UseTimeoutReturn {
3
- start: Callback;
4
- isRunning: boolean;
5
- clear: Callback;
6
- }
7
- declare function useInterval(callback: Callback, delay: number | null, immediate?: boolean): UseTimeoutReturn;
8
- export { useInterval };
@@ -1,42 +0,0 @@
1
- /// <reference types="react" />
2
- interface IPaginationProps {
3
- current: number;
4
- pageSize: number;
5
- total: number;
6
- onChange: (page: number, pageSize: number) => Promise<void>;
7
- onShowSizeChange: (size: number, current: number) => Promise<void>;
8
- showTotal?: (t: number) => React.ReactNode;
9
- showQuickJumper?: boolean;
10
- showSizeChanger?: boolean;
11
- }
12
- interface PaginationResult<T> {
13
- tableProps: {
14
- loading?: boolean;
15
- dataSource: T[];
16
- };
17
- loading?: boolean;
18
- dataSource: T[];
19
- paginationProps: IPaginationProps;
20
- isFirstComplete: boolean;
21
- refresh: (resetPage?: boolean) => Promise<void>;
22
- debounceRefresh: (resetPage?: boolean) => void;
23
- setDataSource: (data: T[]) => void;
24
- }
25
- interface IServerParams {
26
- offset: number;
27
- limit: number;
28
- current: number;
29
- }
30
- declare type IInfoBack<T> = {
31
- dataSource: T[];
32
- total: number;
33
- };
34
- declare type IInfoServer<T> = (params: IServerParams) => IInfoBack<T> | Promise<IInfoBack<T>>;
35
- interface IInfoOption<T> {
36
- isReady?: boolean;
37
- dataSource?: T[];
38
- current?: number;
39
- pageSize?: number;
40
- }
41
- export declare const usePagination: <T>(server: IInfoServer<T>, deps?: any[] | undefined, option?: IInfoOption<T> | undefined) => PaginationResult<T>;
42
- export {};
@@ -1,3 +0,0 @@
1
- export declare function useQuery(): {
2
- [k: string]: string;
3
- };
@@ -1,2 +0,0 @@
1
- declare const useReactive: <T extends object>(initialState: T) => readonly [T, (newState: Partial<T> | ((prev: T) => Partial<T>)) => void, () => T, () => void];
2
- export { useReactive };
@@ -1,8 +0,0 @@
1
- declare type Callback = () => void;
2
- interface UseTimeoutReturn {
3
- start: Callback;
4
- isRunning: boolean;
5
- clear: Callback;
6
- }
7
- declare function useTimeout(callback: Callback, delay: number | null, immediate?: boolean): UseTimeoutReturn;
8
- export { useTimeout };
@@ -1,74 +0,0 @@
1
- import { DependencyList } from 'react';
2
- export interface IPaginationResult<T> {
3
- /**
4
- * 数据
5
- *
6
- * @memberof IPaginationResult
7
- */
8
- dataSource: T[];
9
- /**
10
- * 加载状态
11
- *
12
- * @memberof IPaginationResult
13
- */
14
- loading?: boolean;
15
- /**
16
- * 是否完成了一次请求
17
- *
18
- * @memberof IPaginationResult
19
- */
20
- isFirstComplete: boolean;
21
- /**
22
- * 分页信息
23
- *
24
- * @memberof IPaginationResult
25
- */
26
- paginationProps: {
27
- current: number;
28
- pageSize: number;
29
- total: number;
30
- };
31
- /**
32
- * reset 是否重置查询
33
- *
34
- * @memberof IPaginationResult
35
- */
36
- refresh: (reset?: boolean) => Promise<void>;
37
- debounceRefresh: (reset?: boolean) => void;
38
- setDataSource: (data: T[]) => void;
39
- setTotal: (total: number) => void;
40
- }
41
- interface IServerParams {
42
- offset: number;
43
- limit: number;
44
- current: number;
45
- }
46
- declare type IInfoBack<T> = {
47
- dataSource: T[];
48
- total: number;
49
- };
50
- declare type IInfoServer<T> = (params: IServerParams) => IInfoBack<T> | Promise<IInfoBack<T>>;
51
- interface IInfoOption<T> {
52
- /**
53
- * 第一次是否执行server
54
- *
55
- */
56
- isReady?: boolean;
57
- /**
58
- * 默认的数据
59
- *
60
- */
61
- dataSource?: T[];
62
- /**
63
- * 默认当前第几页
64
- *
65
- */
66
- current?: number;
67
- /**
68
- * 默认一页几条数据
69
- *
70
- */
71
- pageSize?: number;
72
- }
73
- export declare const useVirtualList: <T>(server: IInfoServer<T>, deps?: DependencyList | undefined, option?: IInfoOption<T> | undefined) => IPaginationResult<T>;
74
- export {};
package/dist/index.js DELETED
@@ -1,8 +0,0 @@
1
-
2
- 'use strict'
3
-
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./libs.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./libs.cjs.development.js')
8
- }