xn-fe-tools 1.3.0 → 1.3.2

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,25 @@
1
+ import { type Ref, type MaybeRefOrGetter, type ComputedRef } from 'vue';
2
+ export interface UseInputNumberOptions {
3
+ precision?: number;
4
+ autoFixed?: boolean;
5
+ max?: number;
6
+ min?: number;
7
+ allowNegative?: boolean;
8
+ showThousands?: boolean;
9
+ }
10
+ export interface UseInputNumberReturn {
11
+ value: Ref<string>;
12
+ displayValue: ComputedRef<string>;
13
+ handleInput: (val: string | number | undefined) => void;
14
+ handleBlur: () => void;
15
+ formatter: (val: string) => string;
16
+ parser: (val: string) => string;
17
+ clean: (val: string | number | undefined) => string;
18
+ }
19
+ /**
20
+ * useInputNumber Hook
21
+ * A hook for managing number inputs with precision and formatting
22
+ */
23
+ export declare function useInputNumber(options?: UseInputNumberOptions): UseInputNumberReturn;
24
+ export declare function useInputNumber(value: MaybeRefOrGetter<string | number | undefined>, options?: UseInputNumberOptions): UseInputNumberReturn;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useInputNumber/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,GAAG,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAE9G,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IACxD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAChC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,KAAK,MAAM,CAAC;CACrD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CAAC;AACtF,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./toAwaitFetch/toAwaitFetch.cjs.js"),t=require("./useTableRequest/index.cjs.js"),s=require("./version.cjs.js");exports.cancel=e.cancel,exports.createInstance=e.createInstance,exports.sendGet=e.sendGet,exports.sendGetBlob=e.sendGetBlob,exports.sendPost=e.sendPost,exports.sendPostBlob=e.sendPostBlob,exports.sendPostForm=e.sendPostForm,exports.setGlobalConfig=e.setGlobalConfig,exports.toAwaitFetch=e.default,exports.getTableRequestGlobalConfig=t.getTableRequestGlobalConfig,exports.setTableRequestGlobalConfig=t.setTableRequestGlobalConfig,exports.useTableRequest=t.useTableRequest,exports.VERSION=s.VERSION,exports.getVersion=s.getVersion;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./toAwaitFetch/toAwaitFetch.cjs.js"),s=require("./useTableRequest/index.cjs.js"),t=require("./useInputNumber/index.cjs.js"),o=require("./version.cjs.js");exports.cancel=e.cancel,exports.createInstance=e.createInstance,exports.sendGet=e.sendGet,exports.sendGetBlob=e.sendGetBlob,exports.sendPost=e.sendPost,exports.sendPostBlob=e.sendPostBlob,exports.sendPostForm=e.sendPostForm,exports.setGlobalConfig=e.setGlobalConfig,exports.toAwaitFetch=e.default,exports.getTableRequestGlobalConfig=s.getTableRequestGlobalConfig,exports.setTableRequestGlobalConfig=s.setTableRequestGlobalConfig,exports.useTableRequest=s.useTableRequest,exports.useInputNumber=t.useInputNumber,exports.VERSION=o.VERSION,exports.getVersion=o.getVersion;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './hooks/toAwaitFetch/toAwaitFetch.api';
2
2
  export { default as toAwaitFetch, sendGet, sendPost, sendPostForm, sendPostBlob, sendGetBlob, setGlobalConfig, cancel, createInstance, } from './hooks/toAwaitFetch/toAwaitFetch';
3
3
  export * from './hooks/useTableRequest';
4
+ export * from './hooks/useInputNumber';
4
5
  export { VERSION, getVersion } from './version';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,uCAAuC,CAAA;AACrD,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,MAAM,EACN,cAAc,GACf,MAAM,mCAAmC,CAAA;AAE1C,cAAc,yBAAyB,CAAA;AAEvC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,uCAAuC,CAAA;AACrD,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,MAAM,EACN,cAAc,GACf,MAAM,mCAAmC,CAAA;AAE1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AAEtC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
package/dist/index.es.js CHANGED
@@ -1 +1 @@
1
- import{cancel as t,createInstance as e,sendGet as o,sendGetBlob as s,sendPost as i,sendPostBlob as r,sendPostForm as a,setGlobalConfig as m,default as f}from"./toAwaitFetch/toAwaitFetch.es.js";import{getTableRequestGlobalConfig as p,setTableRequestGlobalConfig as c,useTableRequest as h}from"./useTableRequest/index.es.js";import{VERSION as j,getVersion as u}from"./version.es.js";export{j as VERSION,t as cancel,e as createInstance,p as getTableRequestGlobalConfig,u as getVersion,o as sendGet,s as sendGetBlob,i as sendPost,r as sendPostBlob,a as sendPostForm,m as setGlobalConfig,c as setTableRequestGlobalConfig,f as toAwaitFetch,h as useTableRequest};
1
+ import{cancel as e,createInstance as t,sendGet as s,sendGetBlob as o,sendPost as r,sendPostBlob as i,sendPostForm as m,setGlobalConfig as a,default as p}from"./toAwaitFetch/toAwaitFetch.es.js";import{getTableRequestGlobalConfig as u,setTableRequestGlobalConfig as f,useTableRequest as j}from"./useTableRequest/index.es.js";import{useInputNumber as n}from"./useInputNumber/index.es.js";import{VERSION as c,getVersion as d}from"./version.es.js";export{c as VERSION,e as cancel,t as createInstance,u as getTableRequestGlobalConfig,d as getVersion,s as sendGet,o as sendGetBlob,r as sendPost,i as sendPostBlob,m as sendPostForm,a as setGlobalConfig,f as setTableRequestGlobalConfig,p as toAwaitFetch,n as useInputNumber,j as useTableRequest};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");exports.useInputNumber=function(t,l){let r,a;null===t||"object"!=typeof t||e.isRef(t)?(r=t,a=l||{}):(a=t,r="");const n=()=>a.precision??0,u=()=>a.showThousands??!1,o=e.ref(e.toValue(r)?.toString()??""),c=e.computed(()=>{let e=o.value;if(u()){const[t,l]=e.split(".");let r=t.replace(/\B(?=(\d{3})+(?!\d))/g,",");return l?r+=`.${l}`:e.includes(".")&&(r+="."),r}return e}),i=e=>{let t=null==e?"":e.toString().trim();const l=a.allowNegative?/[^\d.-]/g:/[^\d.]/g;t=t.replace(l,""),t=t.replace(/^-/,"$#$").replace(/-/g,"").replace("$#$","-"),t.length>1&&t.startsWith("0")&&"."!==t[1]&&(t=t.replace(/^0+/,""),""===t&&(t="0")),t.startsWith("-0")&&t.length>2&&"."!==t[2]&&(t="-"+t.slice(2).replace(/^0+/,""),"-"===t&&(t="-0"));const r=n();if(r>0){t=t.replace(/^\./g,"").replace(/\./g,"$#$").replace(/\./g,"").replace("$#$",".");const e=t.indexOf(".");-1!==e&&(t=t.slice(0,e+r+1))}else t=t.replace(/\./g,"");return t};return e.watch(()=>e.toValue(r),e=>{const t=null==e?"":e.toString();t!==o.value&&(o.value=t)}),{value:o,displayValue:c,handleInput:e=>{const t=i(e);o.value=t},handleBlur:()=>{if(!o.value)return;let e=Number(o.value);const t=a.max??1/0,l=a.min??-1/0;e>t&&(e=t,o.value=t.toString()),e<l&&(e=l,o.value=l.toString()),a.autoFixed??1?o.value=e.toFixed(n()):o.value=e.toString()},formatter:e=>c.value,parser:e=>u()?e.replace(/,/g,""):e,clean:i}};
@@ -0,0 +1 @@
1
+ import{isRef as e,ref as l,toValue as t,computed as r,watch as a}from"vue";function n(n,u){let c,o;null===n||"object"!=typeof n||e(n)?(c=n,o=u||{}):(o=n,c="");const i=()=>o.precision??0,s=()=>o.showThousands??!1,p=l(t(c)?.toString()??""),g=r(()=>{let e=p.value;if(s()){const[l,t]=e.split(".");let r=l.replace(/\B(?=(\d{3})+(?!\d))/g,",");return t?r+=`.${t}`:e.includes(".")&&(r+="."),r}return e}),v=e=>{let l=null==e?"":e.toString().trim();const t=o.allowNegative?/[^\d.-]/g:/[^\d.]/g;l=l.replace(t,""),l=l.replace(/^-/,"$#$").replace(/-/g,"").replace("$#$","-"),l.length>1&&l.startsWith("0")&&"."!==l[1]&&(l=l.replace(/^0+/,""),""===l&&(l="0")),l.startsWith("-0")&&l.length>2&&"."!==l[2]&&(l="-"+l.slice(2).replace(/^0+/,""),"-"===l&&(l="-0"));const r=i();if(r>0){l=l.replace(/^\./g,"").replace(/\./g,"$#$").replace(/\./g,"").replace("$#$",".");const e=l.indexOf(".");-1!==e&&(l=l.slice(0,e+r+1))}else l=l.replace(/\./g,"");return l};return a(()=>t(c),e=>{const l=null==e?"":e.toString();l!==p.value&&(p.value=l)}),{value:p,displayValue:g,handleInput:e=>{const l=v(e);p.value=l},handleBlur:()=>{if(!p.value)return;let e=Number(p.value);const l=o.max??1/0,t=o.min??-1/0;e>l&&(e=l,p.value=l.toString()),e<t&&(e=t,p.value=t.toString()),o.autoFixed??1?p.value=e.toFixed(i()):p.value=e.toString()},formatter:e=>g.value,parser:e=>s()?e.replace(/,/g,""):e,clean:v}}export{n as useInputNumber};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="1.2.2";exports.VERSION=e,exports.getVersion=function(){return e};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="1.3.2";exports.VERSION=e,exports.getVersion=function(){return e};
@@ -1 +1 @@
1
- const n="1.2.2";function t(){return n}export{n as VERSION,t as getVersion};
1
+ const n="1.3.2";function t(){return n}export{n as VERSION,t as getVersion};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xn-fe-tools",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "A powerful fetch wrapper with chaining & tuple API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",
@@ -72,6 +72,7 @@
72
72
  "@types/node": "^22.9.4",
73
73
  "@vitejs/plugin-vue": "^5.2.1",
74
74
  "@vue/test-utils": "^2.4.6",
75
+ "ant-design-vue": "^4.2.6",
75
76
  "axios": "^1.13.2",
76
77
  "element-plus": "^2.13.1",
77
78
  "eslint": "^9.39.1",