xn-fe-tools 1.3.0 → 1.3.1

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,23 @@
1
+ export interface UseInputNumberOptions {
2
+ defaultValue?: string | number;
3
+ precision?: number;
4
+ autoFixed?: boolean;
5
+ max?: number;
6
+ min?: number;
7
+ allowNegative?: boolean;
8
+ showThousands?: boolean;
9
+ }
10
+ /**
11
+ * useInputNumber Hook
12
+ * A hook for managing number inputs with precision and formatting
13
+ */
14
+ export declare function useInputNumber(options?: UseInputNumberOptions): {
15
+ value: import("vue").Ref<string, string>;
16
+ displayValue: import("vue").ComputedRef<string>;
17
+ handleInput: (val: string | number | undefined) => void;
18
+ handleBlur: () => void;
19
+ formatter: (val: string) => string;
20
+ parser: (val: string) => string;
21
+ clean: (val: string | number | undefined) => string;
22
+ };
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useInputNumber/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,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;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B;;;uBAwEtC,MAAM,GAAG,MAAM,GAAG,SAAS;;qBAmC7B,MAAM;kBALT,MAAM;iBAtEP,MAAM,GAAG,MAAM,GAAG,SAAS,KAAG,MAAM;EA+FzD"}
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={}){const l=()=>t.precision??0,r=()=>t.showThousands??!1,a=e.ref(t.defaultValue?.toString()??""),n=e.computed(()=>{let e=a.value;if(r()){const[t,l]=e.split(".");let r=t.replace(/\B(?=(\d{3})+(?!\d))/g,",");return l?r+=`.${l}`:e.includes(".")&&(r+="."),r}return e}),u=e=>{let r=null==e?"":e.toString().trim();const a=t.allowNegative?/[^\d.-]/g:/[^\d.]/g;r=r.replace(a,""),r=r.replace(/^-/,"$#$").replace(/-/g,"").replace("$#$","-"),r.length>1&&r.startsWith("0")&&"."!==r[1]&&(r=r.replace(/^0+/,""),""===r&&(r="0")),r.startsWith("-0")&&r.length>2&&"."!==r[2]&&(r="-"+r.slice(2).replace(/^0+/,""),"-"===r&&(r="-0"));const n=l();if(n>0){r=r.replace(/^\./g,"").replace(/\./g,"$#$").replace(/\./g,"").replace("$#$",".");const e=r.indexOf(".");-1!==e&&(r=r.slice(0,e+n+1))}else r=r.replace(/\./g,"");return r};return e.watch(()=>t.defaultValue,e=>{void 0!==e&&e.toString()!==a.value&&(a.value=e.toString())}),{value:a,displayValue:n,handleInput:e=>{const t=u(e);a.value=t},handleBlur:()=>{if(!a.value)return;let e=Number(a.value);void 0!==t.max&&e>t.max&&(e=t.max,a.value=t.max.toString()),void 0!==t.min&&e<t.min&&(e=t.min,a.value=t.min.toString()),t.autoFixed??1?a.value=e.toFixed(l()):a.value=e.toString()},formatter:e=>n.value,parser:e=>r()?e.replace(/,/g,""):e,clean:u}};
@@ -0,0 +1 @@
1
+ import{ref as e,computed as l,watch as t}from"vue";function a(a={}){const r=()=>a.precision??0,n=()=>a.showThousands??!1,i=e(a.defaultValue?.toString()??""),u=l(()=>{let e=i.value;if(n()){const[l,t]=e.split(".");let a=l.replace(/\B(?=(\d{3})+(?!\d))/g,",");return t?a+=`.${t}`:e.includes(".")&&(a+="."),a}return e}),o=e=>{let l=null==e?"":e.toString().trim();const t=a.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 n=r();if(n>0){l=l.replace(/^\./g,"").replace(/\./g,"$#$").replace(/\./g,"").replace("$#$",".");const e=l.indexOf(".");-1!==e&&(l=l.slice(0,e+n+1))}else l=l.replace(/\./g,"");return l};return t(()=>a.defaultValue,e=>{void 0!==e&&e.toString()!==i.value&&(i.value=e.toString())}),{value:i,displayValue:u,handleInput:e=>{const l=o(e);i.value=l},handleBlur:()=>{if(!i.value)return;let e=Number(i.value);void 0!==a.max&&e>a.max&&(e=a.max,i.value=a.max.toString()),void 0!==a.min&&e<a.min&&(e=a.min,i.value=a.min.toString()),a.autoFixed??1?i.value=e.toFixed(r()):i.value=e.toString()},formatter:e=>u.value,parser:e=>n()?e.replace(/,/g,""):e,clean:o}}export{a 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.1";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.1";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.1",
4
4
  "description": "A powerful fetch wrapper with chaining & tuple API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",