dphelper 4.6.0 → 4.6.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.
- package/COPYRIGHT.md +6 -6
- package/FUNDING.yml +12 -12
- package/LICENSE.md +21 -21
- package/README.md +637 -397
- package/SECURITY.md +26 -26
- package/SUMMARY.md +83 -83
- package/index.cjs +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/llms.txt +515 -73
- package/modules/ai.cjs +1 -1
- package/modules/ai.d.ts +11 -11
- package/modules/ai.js +1 -1
- package/modules/anchor.cjs +1 -1
- package/modules/anchor.d.ts +6 -6
- package/modules/anchor.js +1 -1
- package/modules/array.cjs +1 -1
- package/modules/array.d.ts +21 -21
- package/modules/array.js +1 -1
- package/modules/audio.cjs +1 -1
- package/modules/audio.d.ts +10 -10
- package/modules/audio.js +1 -1
- package/modules/avoid.cjs +1 -1
- package/modules/avoid.d.ts +2 -2
- package/modules/avoid.js +1 -1
- package/modules/biometric.cjs +1 -1
- package/modules/biometric.d.ts +14 -14
- package/modules/biometric.js +1 -1
- package/modules/browser.cjs +1 -1
- package/modules/browser.d.ts +10 -10
- package/modules/browser.js +1 -1
- package/modules/check.cjs +1 -1
- package/modules/check.d.ts +4 -4
- package/modules/check.js +1 -1
- package/modules/color.cjs +1 -1
- package/modules/color.d.ts +6 -6
- package/modules/color.js +1 -1
- package/modules/compress.cjs +1 -1
- package/modules/compress.d.ts +13 -13
- package/modules/compress.js +1 -1
- package/modules/cookie.cjs +1 -1
- package/modules/cookie.d.ts +12 -12
- package/modules/cookie.js +1 -1
- package/modules/coords.cjs +1 -1
- package/modules/coords.d.ts +8 -8
- package/modules/coords.js +1 -1
- package/modules/credits.cjs +1 -1
- package/modules/credits.d.ts +11 -11
- package/modules/credits.js +1 -1
- package/modules/date.cjs +1 -1
- package/modules/date.d.ts +25 -25
- package/modules/date.js +1 -1
- package/modules/disable.cjs +1 -1
- package/modules/disable.d.ts +8 -8
- package/modules/disable.js +1 -1
- package/modules/dispatch.cjs +1 -1
- package/modules/dispatch.d.ts +4 -4
- package/modules/dispatch.js +1 -1
- package/modules/elements.cjs +1 -1
- package/modules/elements.d.ts +3 -3
- package/modules/elements.js +1 -1
- package/modules/events.cjs +1 -1
- package/modules/events.d.ts +6 -6
- package/modules/events.js +1 -1
- package/modules/fetch.cjs +1 -1
- package/modules/fetch.d.ts +15 -15
- package/modules/fetch.js +1 -1
- package/modules/form.cjs +1 -1
- package/modules/form.d.ts +13 -13
- package/modules/form.js +1 -1
- package/modules/format.cjs +1 -1
- package/modules/format.d.ts +3 -3
- package/modules/format.js +1 -1
- package/modules/i18n.cjs +1 -1
- package/modules/i18n.d.ts +11 -11
- package/modules/i18n.js +1 -1
- package/modules/image.cjs +1 -1
- package/modules/image.d.ts +13 -13
- package/modules/image.js +1 -1
- package/modules/json.cjs +1 -1
- package/modules/json.d.ts +8 -8
- package/modules/json.js +1 -1
- package/modules/load.cjs +1 -1
- package/modules/load.d.ts +8 -8
- package/modules/load.js +1 -1
- package/modules/logging.cjs +1 -1
- package/modules/logging.d.ts +8 -8
- package/modules/logging.js +1 -1
- package/modules/math.cjs +1 -1
- package/modules/math.d.ts +13 -13
- package/modules/math.js +1 -1
- package/modules/memory.cjs +1 -1
- package/modules/memory.d.ts +3 -3
- package/modules/memory.js +1 -1
- package/modules/navigation.cjs +1 -1
- package/modules/navigation.d.ts +4 -4
- package/modules/navigation.js +1 -1
- package/modules/net.cjs +1 -1
- package/modules/net.d.ts +10 -10
- package/modules/net.js +1 -1
- package/modules/objects.cjs +1 -1
- package/modules/objects.d.ts +15 -15
- package/modules/objects.js +1 -1
- package/modules/path.cjs +1 -1
- package/modules/path.d.ts +4 -4
- package/modules/path.js +1 -1
- package/modules/promise.cjs +1 -1
- package/modules/promise.d.ts +3 -3
- package/modules/promise.js +1 -1
- package/modules/sanitize.cjs +1 -1
- package/modules/sanitize.d.ts +2 -2
- package/modules/sanitize.js +1 -1
- package/modules/screen.cjs +1 -1
- package/modules/screen.d.ts +11 -11
- package/modules/screen.js +1 -1
- package/modules/scrollbar.cjs +1 -1
- package/modules/scrollbar.d.ts +9 -9
- package/modules/scrollbar.js +1 -1
- package/modules/security.cjs +1 -1
- package/modules/security.d.ts +15 -15
- package/modules/security.js +1 -1
- package/modules/shortcut.cjs +1 -1
- package/modules/shortcut.d.ts +2 -2
- package/modules/shortcut.js +1 -1
- package/modules/socket.cjs +1 -1
- package/modules/socket.d.ts +13 -13
- package/modules/socket.js +1 -1
- package/modules/sse.cjs +1 -1
- package/modules/sse.d.ts +8 -8
- package/modules/sse.js +1 -1
- package/modules/svg.cjs +1 -1
- package/modules/svg.d.ts +12 -12
- package/modules/svg.js +1 -1
- package/modules/sync.cjs +1 -1
- package/modules/sync.d.ts +13 -13
- package/modules/sync.js +1 -1
- package/modules/system.cjs +1 -1
- package/modules/system.d.ts +2 -2
- package/modules/system.js +1 -1
- package/modules/text.cjs +1 -1
- package/modules/text.d.ts +13 -13
- package/modules/text.js +1 -1
- package/modules/timer.cjs +1 -1
- package/modules/timer.d.ts +3 -3
- package/modules/timer.js +1 -1
- package/modules/tools.cjs +1 -1
- package/modules/tools.d.ts +5 -5
- package/modules/tools.js +1 -1
- package/modules/translators.cjs +1 -1
- package/modules/translators.d.ts +2 -2
- package/modules/translators.js +1 -1
- package/modules/triggers.cjs +1 -1
- package/modules/triggers.d.ts +43 -43
- package/modules/triggers.js +1 -1
- package/modules/types.cjs +1 -1
- package/modules/types.d.ts +5 -5
- package/modules/types.js +1 -1
- package/modules/ui.cjs +1 -1
- package/modules/ui.d.ts +3 -3
- package/modules/ui.js +1 -1
- package/modules/window.cjs +1 -1
- package/modules/window.d.ts +9 -9
- package/modules/window.js +1 -1
- package/modules/worker.cjs +1 -1
- package/modules/worker.d.ts +16 -16
- package/modules/worker.js +1 -1
- package/package.json +2 -2
- package/sbom.json +10 -15
- package/types/dphelper.d.ts +546 -546
- package/types/global.d.ts +8 -8
package/modules/date.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
-
export interface DateTool {
|
|
3
|
-
days: (lang?: string) => string[]
|
|
4
|
-
months: (lang?: string) => string[]
|
|
5
|
-
year: () => number
|
|
6
|
-
toIso: (value: any, int?: string) => string | null
|
|
7
|
-
toMMDDYYYY: (value: any) => string
|
|
8
|
-
toYYYYMMDD: (value: any) => string | undefined
|
|
9
|
-
toHuman: (value: any) => string
|
|
10
|
-
convert: (value: any, format: string[]) => string | null
|
|
11
|
-
iso2Epoch: (value: any) => number
|
|
12
|
-
localIsoTime: (value: any) => string
|
|
13
|
-
utc: () => string
|
|
14
|
-
parse: (value: any, separator?: string) => string | null
|
|
15
|
-
addDays: (date: any, days: number) => Date
|
|
16
|
-
dateTimeToString: (dateObject: any) => string
|
|
17
|
-
isoToHuman: (value: any, symbol?: string) => string | null
|
|
18
|
-
fullDate: () => string
|
|
19
|
-
epoch: () => number
|
|
20
|
-
diffInDays: (d1: any, d2: any) => number
|
|
21
|
-
diffInWeeks: (d1: any, d2: any) => number
|
|
22
|
-
diffInMonths: (d1: any, d2: any) => number
|
|
23
|
-
diffInYears: (d1: any, d2: any) => number
|
|
24
|
-
dateToYMD: (date: any) => string
|
|
25
|
-
collection: (params: { date?: Date; type: string; locale?: string }) => string | undefined
|
|
26
|
-
timeZones: () => string[]
|
|
2
|
+
export interface DateTool {
|
|
3
|
+
days: (lang?: string) => string[]
|
|
4
|
+
months: (lang?: string) => string[]
|
|
5
|
+
year: () => number
|
|
6
|
+
toIso: (value: any, int?: string) => string | null
|
|
7
|
+
toMMDDYYYY: (value: any) => string
|
|
8
|
+
toYYYYMMDD: (value: any) => string | undefined
|
|
9
|
+
toHuman: (value: any) => string
|
|
10
|
+
convert: (value: any, format: string[]) => string | null
|
|
11
|
+
iso2Epoch: (value: any) => number
|
|
12
|
+
localIsoTime: (value: any) => string
|
|
13
|
+
utc: () => string
|
|
14
|
+
parse: (value: any, separator?: string) => string | null
|
|
15
|
+
addDays: (date: any, days: number) => Date
|
|
16
|
+
dateTimeToString: (dateObject: any) => string
|
|
17
|
+
isoToHuman: (value: any, symbol?: string) => string | null
|
|
18
|
+
fullDate: () => string
|
|
19
|
+
epoch: () => number
|
|
20
|
+
diffInDays: (d1: any, d2: any) => number
|
|
21
|
+
diffInWeeks: (d1: any, d2: any) => number
|
|
22
|
+
diffInMonths: (d1: any, d2: any) => number
|
|
23
|
+
diffInYears: (d1: any, d2: any) => number
|
|
24
|
+
dateToYMD: (date: any) => string
|
|
25
|
+
collection: (params: { date?: Date; type: string; locale?: string }) => string | undefined
|
|
26
|
+
timeZones: () => string[]
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export const date: DateTool
|
package/modules/date.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var c={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var m={version:"4.6.
|
|
1
|
+
var c={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var m={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...c},configurable:true,writable:true},version:{value:m.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var i=dphelper;Object.defineProperty(i,"setProps",{value:(e,t,a)=>{Object.defineProperty(e,t.name,a||{writable:false,configurable:false,enumerable:false}),a?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(i,"setDescription",{value:(e,t)=>{Object.defineProperties(i,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(a=>(Object.defineProperties(i[e.name],{[a]:{writable:false,configurable:false,enumerable:false}}),null)),i.setProps(i,e,{writable:false,configurable:false,enumerable:false}),i._list.scripts.push(e);}});var p={en:["January","February","March","April","May","June","July","August","September","October","November","December"],it:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]};var g={name:"date",active:true,subCommand:[{name:"toIso",version:"0.0.2",example:"dphelper.date.toIso(value, 'en')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a date value to ISO format.",env:"both",subCommand:[]},{name:"toMMDDYYYY",version:"0.0.2",example:"dphelper.date.toMMDDYYYY(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a date value to MMDDYYYY format.",env:"both",subCommand:[]},{name:"toYYYYMMDD",version:"0.0.2",example:"dphelper.date.toYYYYMMDD(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:true,description:"Converts a date value to YYYYMMDD format.",env:"both",subCommand:[]},{name:"toHuman",version:"0.0.2",example:"dphelper.date.toHuman(value)",author:"Dario Passariello",creationDate:"20230101",lastMod:"20260220",type:"function",active:true,description:"Converts a date value to a human-readable format.",env:"both",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.date.convert(value, format)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a date value to a specified format.",env:"both",subCommand:[]},{name:"iso2Epoch",version:"0.0.2",example:"dphelper.date.iso2Epoch(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts an ISO date value to epoch time.",env:"both",subCommand:[]},{name:"localIsoTime",version:"0.0.2",example:"dphelper.date.localIsoTime(value)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Gets the local ISO time for a given date value.",env:"both",subCommand:[]},{name:"utc",version:"0.0.2",example:"dphelper.date.utc()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Gets the current UTC time.",env:"both",subCommand:[]},{name:"parse",version:"0.0.2",example:"dphelper.date.parse(value, '/')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Parses a date value with a specified separator.",env:"both",subCommand:[]},{name:"year",version:"0.0.2",example:"dphelper.date.year()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Gets the current year.",env:"both",subCommand:[]},{name:"addDays",version:"0.0.2",example:"dphelper.date.addDays(date, days)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Adds a specified number of days to a date.",env:"both",subCommand:[]},{name:"dateTimeToString",version:"0.0.2",example:"dphelper.date.dateTimeToString(dateObject)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a date object to a string.",env:"both",subCommand:[]},{name:"isoToHuman",version:"0.0.2",example:"dphelper.date.isoToHuman(value, '@')",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts an ISO date value to a human-readable format with a specified symbol.",env:"both",subCommand:[]},{name:"fullDate",version:"0.0.2",example:"dphelper.date.fullDate()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Gets the full date and time in the format DD-MM-YYYY HH:MM:SS.",env:"both",subCommand:[]},{name:"epoch",version:"0.0.2",example:"dphelper.date.epoch()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Gets the current epoch time.",env:"both",subCommand:[]},{name:"diffInDays",version:"0.0.2",example:"dphelper.date.diffInDays(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the difference in days between two dates.",env:"both",subCommand:[]},{name:"diffInWeeks",version:"0.0.2",example:"dphelper.date.diffInWeeks(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the difference in weeks between two dates.",env:"both",subCommand:[]},{name:"diffInMonths",version:"0.0.2",example:"dphelper.date.diffInMonths(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the difference in months between two dates.",env:"both",subCommand:[]},{name:"diffInYears",version:"0.0.2",example:"dphelper.date.diffInYears(d1, d2)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the difference in years between two dates.",env:"both",subCommand:[]},{name:"dateToYMD",version:"0.0.2",example:"dphelper.date.dateToYMD(date)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a date to the format YYYY-MM-DD.",env:"both",subCommand:[]},{name:"collection",version:"0.0.2",example:"dphelper.date.collection()",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Gets various date representations based on the type and locale.",env:"both",subCommand:[]},{name:"timeZones",version:"0.0.2",example:"dphelper.date.timeZones()",author:"Dario Passariello",creationDate:"20240901",lastMod:"20260220",type:"function",active:true,description:"Returns an array of all supported timezones.",env:"both",subCommand:[]}]},D={days:(e="en")=>({en:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],it:["luned\xEC","marted\xEC","mercoled\xEC","gioved\xEC","venerd\xEC","sabato","domenica"]})[e],months:(e="en")=>p[e],year:()=>new Date().getFullYear(),toIso:(e,t="en")=>{e||(e="");let a=new Date(e);return String(a)==="Invalid Date"?null:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"numeric"}).format(a)},toMMDDYYYY:e=>{try{let t=new Date(e);return isNaN(t.getTime())?"":`0${t.getMonth()+1}`.slice(-2)+""+`0${t.getDate()}`.slice(-2)+t.getFullYear()}catch{return ""}},toYYYYMMDD:e=>{if(e)return e.toISOString().split("T")[0].replaceAll("-","")},toHuman:e=>{let t={weekday:"long",year:"numeric",month:"long",day:"numeric"};return e.toLocaleDateString(void 0,t)},convert:(e,t)=>{if(!e)return null;t||(t=dphelper.date.months("en"));let a=e.substring(0,2).replace("0",""),o=e.substring(2,4),n=e.substring(e.length-4);return `${o} ${t[Number(a)-1]} ${n}`},iso2Epoch:e=>(e||(e=""),new Date(e).getTime()),localIsoTime:e=>{e||(e=new Date);let t=new Date(e);if(isNaN(t.getTime()))return "";let a=t.getTimezoneOffset()*6e4;return new Date(Date.now()-a).toISOString().slice(0,-1)},utc:()=>new Date().toUTCString(),parse:(e,t="/")=>{if(!e)return null;let a=e.substring(0,2),o=e.substring(2,4),n=e.substring(4,8);return a+t+o+t+n},addDays:(e,t)=>{let a=new Date(Number(e));return a.setDate(e.getDate()+t),a},dateTimeToString:e=>{try{return `${e.getFullYear()}${e.getMonth().toString().length>1?e.getMonth()+1:`0${e.getMonth()+1}`}
|
|
2
2
|
${e.getDate().toString().length>1?e.getDate():`0${e.getDate()}`}_${e.getHours()}${e.getMinutes()}${e.getSeconds()}`}catch(t){return console.error(t),e}},isoToHuman:(e,t="@")=>{if(!e)return null;let a=dphelper.date.months("en"),o=new Date(e),n=o.getFullYear(),s=e.split("T")[1].split(":").slice(0,2).join(":"),r=(o.getMonth()+1).toString(),l=o.getDate().toString();return l.length<2&&(l=`0${l}`),r.length<2&&(r=`0${r}`),`${l} ${a[Number(r)-1]} ${n} ${t} ${s}`},fullDate:()=>{let e=new Date,t=Number(e.getDate()),a=Number(e.getMonth()+1),o=Number(e.getFullYear()),n=Number(e.getHours()),s=Number(e.getMinutes()),r=Number(e.getSeconds());return (t<10?`0${t}`:t)+"-"+(a<10?`0${a}`:a)+"-"+o+" "+(n<10?`0${n}`:n)+":"+(s<10?`0${s}`:s)+":"+(r<10?`0${r}`:r)},epoch:()=>Date.now(),diffInDays:(e,t)=>{let a=t.getTime(),o=e.getTime();return Math.floor((a-o)/(24*3600*1e3))},diffInWeeks:(e,t)=>{let a=t.getTime(),o=e.getTime();return Number(Number.parseInt(String((a-o)/(24*3600*1e3*7)),10))},diffInMonths:(e,t)=>{let a=e.getFullYear(),o=t.getFullYear(),n=e.getMonth();return t.getMonth()+12*o-(n+12*a)},diffInYears:(e,t)=>t.getFullYear()-e.getFullYear(),dateToYMD:e=>{let t=e.getDate(),a=e.getMonth()+1;return `${e.getFullYear()}-${a<=9?`0${a}`:a}-${t<=9?`0${t}`:t}`},collection:({date:e=new Date,type:t="",locale:a="en-US"})=>{!e&&t&&a&&console.debug(`
|
|
3
3
|
"toDateString" -> Tue Jan 02 2024
|
|
4
4
|
"toISOString" -> 2024-01-02T18:44:43.590Z
|
package/modules/disable.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var s={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var c={version:"4.6.
|
|
1
|
+
'use strict';var s={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var c={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...s},configurable:true,writable:true},version:{value:c.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var o=dphelper;Object.defineProperty(o,"setProps",{value:(t,e,n)=>{Object.defineProperty(t,e.name,n||{writable:false,configurable:false,enumerable:false}),n?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(o,"setDescription",{value:(t,e)=>{Object.defineProperties(o,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(n=>(Object.defineProperties(o[t.name],{[n]:{writable:false,configurable:false,enumerable:false}}),null)),o.setProps(o,t,{writable:false,configurable:false,enumerable:false}),o._list.scripts.push(t);}});var b={name:"disable",active:true,subCommand:[{name:"select",version:"0.0.2",example:"dphelper.disable.select([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable text selection on the specified element.",env:"client",subCommand:[]},{name:"spellCheck",version:"0.0.2",example:"dphelper.disable.spellCheck([tmr = 5000])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable spell check on the specified element after a delay.",env:"client",subCommand:[]},{name:"rightClick",version:"0.0.2",example:"dphelper.disable.rightClick([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable right-click context menu on the specified element.",env:"client",subCommand:[]},{name:"copy",version:"0.0.2",example:"dphelper.disable.copy([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable copy functionality on the specified element.",env:"client",subCommand:[]},{name:"paste",version:"0.0.2",example:"dphelper.disable.paste([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable paste functionality on the specified element.",env:"client",subCommand:[]},{name:"cut",version:"0.0.2",example:"dphelper.disable.cut([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable cut functionality on the specified element.",env:"client",subCommand:[]},{name:"drag",version:"0.0.2",example:"dphelper.disable.drag([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable drag functionality on the specified element.",env:"client",subCommand:[]}]},m={select:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;if(!e||typeof e.addEventListener!="function")return;let n=r=>{let i=r.target,d=i.tagName.toLowerCase();if(!["input","button","select","textarea"].includes(d)&&!i.classList.contains("selectable"))return document.querySelectorAll("*").forEach(a=>a.blur()),r.preventDefault(),!1;document.querySelectorAll("img, a, input, button").forEach(a=>{a.addEventListener("dragstart",p=>(p.preventDefault(),!1));});};e.addEventListener("mousedown",n),console.debug("%cSelection Disabled: %ctrue","color:orange","");}catch(e){console.debug("dphelper.disable.select:",e);}},spellCheck:(t=5e3)=>{setInterval(()=>{let n=document.querySelectorAll("input[type=text], textarea, code");for(let r of n)r.getAttribute("spellcheck")||r.setAttribute("spellcheck","false");},t);},rightClick:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("contextmenu",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.rightClick:",e);}},copy:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("copy",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.copy:",e);}},paste:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("paste",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.paste:",e);}},cut:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("cut",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.cut:",e);}},drag:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("dragstart",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.drag:",e);}}};dphelper?.setDescription?.(b,m);var P=dphelper.disable;exports.disable=P;
|
package/modules/disable.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
-
export interface DisableTool {
|
|
3
|
-
select: (el?: string) => void
|
|
4
|
-
spellCheck: (tmr?: number) => void
|
|
5
|
-
rightClick: (el?: string) => void
|
|
6
|
-
copy: (el?: string) => void
|
|
7
|
-
paste: (el?: string) => void
|
|
8
|
-
cut: (el?: string) => void
|
|
9
|
-
drag: (el?: string) => void
|
|
2
|
+
export interface DisableTool {
|
|
3
|
+
select: (el?: string) => void
|
|
4
|
+
spellCheck: (tmr?: number) => void
|
|
5
|
+
rightClick: (el?: string) => void
|
|
6
|
+
copy: (el?: string) => void
|
|
7
|
+
paste: (el?: string) => void
|
|
8
|
+
cut: (el?: string) => void
|
|
9
|
+
drag: (el?: string) => void
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const disable: DisableTool
|
package/modules/disable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var d={version:"4.6.
|
|
1
|
+
var c={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var d={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...c},configurable:true,writable:true},version:{value:d.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var o=dphelper;Object.defineProperty(o,"setProps",{value:(t,e,n)=>{Object.defineProperty(t,e.name,n||{writable:false,configurable:false,enumerable:false}),n?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(o,"setDescription",{value:(t,e)=>{Object.defineProperties(o,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(n=>(Object.defineProperties(o[t.name],{[n]:{writable:false,configurable:false,enumerable:false}}),null)),o.setProps(o,t,{writable:false,configurable:false,enumerable:false}),o._list.scripts.push(t);}});var m={name:"disable",active:true,subCommand:[{name:"select",version:"0.0.2",example:"dphelper.disable.select([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable text selection on the specified element.",env:"client",subCommand:[]},{name:"spellCheck",version:"0.0.2",example:"dphelper.disable.spellCheck([tmr = 5000])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable spell check on the specified element after a delay.",env:"client",subCommand:[]},{name:"rightClick",version:"0.0.2",example:"dphelper.disable.rightClick([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable right-click context menu on the specified element.",env:"client",subCommand:[]},{name:"copy",version:"0.0.2",example:"dphelper.disable.copy([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable copy functionality on the specified element.",env:"client",subCommand:[]},{name:"paste",version:"0.0.2",example:"dphelper.disable.paste([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable paste functionality on the specified element.",env:"client",subCommand:[]},{name:"cut",version:"0.0.2",example:"dphelper.disable.cut([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable cut functionality on the specified element.",env:"client",subCommand:[]},{name:"drag",version:"0.0.2",example:"dphelper.disable.drag([el = 'body'])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Disable drag functionality on the specified element.",env:"client",subCommand:[]}]},h={select:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;if(!e||typeof e.addEventListener!="function")return;let n=r=>{let s=r.target,p=s.tagName.toLowerCase();if(!["input","button","select","textarea"].includes(p)&&!s.classList.contains("selectable"))return document.querySelectorAll("*").forEach(a=>a.blur()),r.preventDefault(),!1;document.querySelectorAll("img, a, input, button").forEach(a=>{a.addEventListener("dragstart",u=>(u.preventDefault(),!1));});};e.addEventListener("mousedown",n),console.debug("%cSelection Disabled: %ctrue","color:orange","");}catch(e){console.debug("dphelper.disable.select:",e);}},spellCheck:(t=5e3)=>{setInterval(()=>{let n=document.querySelectorAll("input[type=text], textarea, code");for(let r of n)r.getAttribute("spellcheck")||r.setAttribute("spellcheck","false");},t);},rightClick:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("contextmenu",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.rightClick:",e);}},copy:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("copy",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.copy:",e);}},paste:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("paste",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.paste:",e);}},cut:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("cut",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.cut:",e);}},drag:(t="body")=>{try{if(typeof document>"u")return;let e=typeof t=="string"?document.querySelector(t):t;e&&typeof e.addEventListener=="function"&&e.addEventListener("dragstart",n=>n.preventDefault());}catch(e){console.debug("dphelper.disable.drag:",e);}}};dphelper?.setDescription?.(m,h);var x=dphelper.disable;export{x as disable};
|
package/modules/dispatch.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var l={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var o={version:"4.6.
|
|
1
|
+
'use strict';var l={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var o={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...l},configurable:true,writable:true},version:{value:o.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var i=dphelper;Object.defineProperty(i,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(i,"setDescription",{value:(e,t)=>{Object.defineProperties(i,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(i[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),i.setProps(i,e,{writable:false,configurable:false,enumerable:false}),i._list.scripts.push(e);}});var s={},u={name:"dispatch",active:true,subCommand:[{name:"set",version:"0.0.2",example:"dphelper.dispatch.set([name, value])",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:true,description:"Dispatches a custom event with the specified name and value.",env:"client",subCommand:[]},{name:"listen",version:"0.0.2",example:"dphelper.dispatch.listen([eventNames, callback=null], flag = true)",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:true,description:"Listens for the specified event names and executes the callback when the event is triggered.",env:"client",subCommand:[]},{name:"remove",version:"0.0.2",example:"dphelper.dispatch.remove([eventNames, callback=null], flag = true)",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:true,description:"Removes the event listener for the specified event names.",env:"client",subCommand:[]}]},d={set:(e,t={})=>dispatchEvent(new CustomEvent(String(e),t)),listen:(e,t)=>{s[e]&&s[e].length>0&&dphelper.dispatch.remove(e);let r=n=>t?setTimeout(()=>t(n),0):null;window.addEventListener(e,r),s[e]||(s[e]=[]),s[e].push(r);},remove:e=>{let t=s[e];t&&(t.forEach(r=>window.removeEventListener(e,r)),delete s[e]);}};dphelper?.setDescription(u,d);var D=dphelper.dispatch;exports.dispatch=D;
|
package/modules/dispatch.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
-
export interface DispatchTool {
|
|
3
|
-
set: (name: string, value?: any) => void
|
|
4
|
-
listen: (name: string, cb?: (e: Event) => void, flag?: boolean) => void
|
|
5
|
-
remove: (name: string) => void
|
|
2
|
+
export interface DispatchTool {
|
|
3
|
+
set: (name: string, value?: any) => void
|
|
4
|
+
listen: (name: string, cb?: (e: Event) => void, flag?: boolean) => void
|
|
5
|
+
remove: (name: string) => void
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export const dispatch: DispatchTool
|
package/modules/dispatch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var o={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var n={version:"4.6.
|
|
1
|
+
var o={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var n={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...o},configurable:true,writable:true},version:{value:n.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var i=dphelper;Object.defineProperty(i,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(i,"setDescription",{value:(e,t)=>{Object.defineProperties(i,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(i[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),i.setProps(i,e,{writable:false,configurable:false,enumerable:false}),i._list.scripts.push(e);}});var s={},d={name:"dispatch",active:true,subCommand:[{name:"set",version:"0.0.2",example:"dphelper.dispatch.set([name, value])",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:true,description:"Dispatches a custom event with the specified name and value.",env:"client",subCommand:[]},{name:"listen",version:"0.0.2",example:"dphelper.dispatch.listen([eventNames, callback=null], flag = true)",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:true,description:"Listens for the specified event names and executes the callback when the event is triggered.",env:"client",subCommand:[]},{name:"remove",version:"0.0.2",example:"dphelper.dispatch.remove([eventNames, callback=null], flag = true)",author:"Dario Passariello",creationDate:"20231231",lastMod:"20240612",type:"function",active:true,description:"Removes the event listener for the specified event names.",env:"client",subCommand:[]}]},h={set:(e,t={})=>dispatchEvent(new CustomEvent(String(e),t)),listen:(e,t)=>{s[e]&&s[e].length>0&&dphelper.dispatch.remove(e);let r=c=>t?setTimeout(()=>t(c),0):null;window.addEventListener(e,r),s[e]||(s[e]=[]),s[e].push(r);},remove:e=>{let t=s[e];t&&(t.forEach(r=>window.removeEventListener(e,r)),delete s[e]);}};dphelper?.setDescription(d,h);var k=dphelper.dispatch;export{k as dispatch};
|
package/modules/elements.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var s={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var p={version:"4.6.
|
|
1
|
+
'use strict';var s={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var p={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...s},configurable:true,writable:true},version:{value:p.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var l=dphelper;Object.defineProperty(l,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(l,"setDescription",{value:(e,t)=>{Object.defineProperties(l,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(l[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),l.setProps(l,e,{writable:false,configurable:false,enumerable:false}),l._list.scripts.push(e);}});var b={name:"element",active:true,subCommand:[{name:"fitScale",version:"0.0.2",example:"dphelper.element.fitScale([el = 'root', scale = 1, fit = false])",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:true,description:"Scales an element based on the window size.",env:"client",subCommand:[]}]},h={fitScale:(e,t=1,r=false)=>addEventListener("resize",a=>dphelper.element.scaleBasedOnWindow(e,t,r)),scaleBasedOnWindow:(e,t,r)=>{if(!e)return;let a=typeof e=="string"?document.querySelector(e):e;if(!a)return;let n=a.offsetWidth||1,i=a.offsetHeight||1,c=r?t/Math.max(n/window.innerWidth,i/window.innerHeight):t/Math.min(n/window.innerWidth,i/window.innerHeight);a.style.transform=`scale(${c})`;}};dphelper?.setDescription(b,h);var x=dphelper.element;exports.element=x;
|
package/modules/elements.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
-
export interface ElementsTool {
|
|
3
|
-
fitScale: (el: any, scale?: number, fit?: boolean) => void
|
|
4
|
-
scaleBasedOnWindow: (elm: any, scale: number, fit: boolean) => void
|
|
2
|
+
export interface ElementsTool {
|
|
3
|
+
fitScale: (el: any, scale?: number, fit?: boolean) => void
|
|
4
|
+
scaleBasedOnWindow: (elm: any, scale: number, fit: boolean) => void
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export const element: ElementsTool
|
package/modules/elements.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var p={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var c={version:"4.6.
|
|
1
|
+
var p={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var c={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...p},configurable:true,writable:true},version:{value:c.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var l=dphelper;Object.defineProperty(l,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(l,"setDescription",{value:(e,t)=>{Object.defineProperties(l,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(l[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),l.setProps(l,e,{writable:false,configurable:false,enumerable:false}),l._list.scripts.push(e);}});var h={name:"element",active:true,subCommand:[{name:"fitScale",version:"0.0.2",example:"dphelper.element.fitScale([el = 'root', scale = 1, fit = false])",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:true,description:"Scales an element based on the window size.",env:"client",subCommand:[]}]},d={fitScale:(e,t=1,r=false)=>addEventListener("resize",a=>dphelper.element.scaleBasedOnWindow(e,t,r)),scaleBasedOnWindow:(e,t,r)=>{if(!e)return;let a=typeof e=="string"?document.querySelector(e):e;if(!a)return;let i=a.offsetWidth||1,s=a.offsetHeight||1,u=r?t/Math.max(i/window.innerWidth,s/window.innerHeight):t/Math.min(i/window.innerWidth,s/window.innerHeight);a.style.transform=`scale(${u})`;}};dphelper?.setDescription(h,d);var D=dphelper.element;export{D as element};
|
package/modules/events.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var s={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var c={version:"4.6.
|
|
1
|
+
'use strict';var s={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var c={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...s},configurable:true,writable:true},version:{value:c.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var o=dphelper;Object.defineProperty(o,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(o,"setDescription",{value:(e,t)=>{Object.defineProperties(o,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(o[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),o.setProps(o,e,{writable:false,configurable:false,enumerable:false}),o._list.scripts.push(e);}});var b={name:"event",active:true,subCommand:[{name:"list",version:"0.0.2",example:"dphelper.event.list([element])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Show attached events.",env:"client",subCommand:[]},{name:"multi",version:"0.0.2",example:"dphelper.event.multi([element, eventNames, listener])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Attach multiple event listeners to an element.",env:"client",subCommand:[]},{name:"copy",version:"0.0.2",example:"dphelper.event.copy([element])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Copy text content of an element to the clipboard.",env:"client",subCommand:[]},{name:"onDrag",version:"0.0.2",example:"dphelper.event.onDrag([element])",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:true,description:"Handle dragging functionality for elements.",env:"client",subCommand:[]},{name:"keys",version:"0.0.2",example:"dphelper.event.keys(e)",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:true,description:"Return key event properties.",env:"client",subCommand:[]}]},h={list:e=>window.getEventListeners(e),multi:(e,t,r)=>{let n=t.split(" ");for(let a of n)e.addEventListener(a,r,false);},copy:e=>{let t=document.querySelector(e);t&&t.addEventListener("click",async r=>{if(navigator.clipboard)try{let n=r.target;n&&(await navigator.clipboard.writeText(n.textContent||""),alert("Copied"));}catch(n){console.error("Can't copy the value",n);}});},onDrag:e=>{let t=`.popup_overflow_${e}`,r=document.querySelector(t);if(!r)return;let n=a=>{let i=document.querySelector(t),p=i?.offsetHeight||0,u=i?.offsetWidth||0,m=Math.max(a.pageY,0)-p/2,d=Math.max(a.pageX,0)-u/2;localStorage.setItem(e,JSON.stringify([m,d]));};r.addEventListener("mousedown",()=>{window.addEventListener("mousemove",n);}),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",n);});},keys:e=>({key:e.key,ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey})};dphelper?.setDescription(b,h);var L=dphelper.events;exports.events=L;
|
package/modules/events.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
-
export interface EventsTool {
|
|
3
|
-
list: (el: Element) => any
|
|
4
|
-
multi: (element: Element, eventNames: string, listener: EventListener) => void
|
|
5
|
-
copy: (el: string) => void
|
|
6
|
-
onDrag: (elem: string) => void
|
|
7
|
-
keys: (e: KeyboardEvent) => { key: string; ctrl: boolean; alt: boolean; shift: boolean }
|
|
2
|
+
export interface EventsTool {
|
|
3
|
+
list: (el: Element) => any
|
|
4
|
+
multi: (element: Element, eventNames: string, listener: EventListener) => void
|
|
5
|
+
copy: (el: string) => void
|
|
6
|
+
onDrag: (elem: string) => void
|
|
7
|
+
keys: (e: KeyboardEvent) => { key: string; ctrl: boolean; alt: boolean; shift: boolean }
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const events: EventsTool
|
package/modules/events.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var p={version:"4.6.
|
|
1
|
+
var c={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var p={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...c},configurable:true,writable:true},version:{value:p.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var o=dphelper;Object.defineProperty(o,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(o,"setDescription",{value:(e,t)=>{Object.defineProperties(o,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(o[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),o.setProps(o,e,{writable:false,configurable:false,enumerable:false}),o._list.scripts.push(e);}});var h={name:"event",active:true,subCommand:[{name:"list",version:"0.0.2",example:"dphelper.event.list([element])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Show attached events.",env:"client",subCommand:[]},{name:"multi",version:"0.0.2",example:"dphelper.event.multi([element, eventNames, listener])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Attach multiple event listeners to an element.",env:"client",subCommand:[]},{name:"copy",version:"0.0.2",example:"dphelper.event.copy([element])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Copy text content of an element to the clipboard.",env:"client",subCommand:[]},{name:"onDrag",version:"0.0.2",example:"dphelper.event.onDrag([element])",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:true,description:"Handle dragging functionality for elements.",env:"client",subCommand:[]},{name:"keys",version:"0.0.2",example:"dphelper.event.keys(e)",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:true,description:"Return key event properties.",env:"client",subCommand:[]}]},g={list:e=>window.getEventListeners(e),multi:(e,t,r)=>{let n=t.split(" ");for(let a of n)e.addEventListener(a,r,false);},copy:e=>{let t=document.querySelector(e);t&&t.addEventListener("click",async r=>{if(navigator.clipboard)try{let n=r.target;n&&(await navigator.clipboard.writeText(n.textContent||""),alert("Copied"));}catch(n){console.error("Can't copy the value",n);}});},onDrag:e=>{let t=`.popup_overflow_${e}`,r=document.querySelector(t);if(!r)return;let n=a=>{let s=document.querySelector(t),u=s?.offsetHeight||0,m=s?.offsetWidth||0,d=Math.max(a.pageY,0)-u/2,f=Math.max(a.pageX,0)-m/2;localStorage.setItem(e,JSON.stringify([d,f]));};r.addEventListener("mousedown",()=>{window.addEventListener("mousemove",n);}),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",n);});},keys:e=>({key:e.key,ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey})};dphelper?.setDescription(h,g);var M=dphelper.events;export{M as events};
|
package/modules/fetch.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var f={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var h={version:"4.6.
|
|
1
|
+
'use strict';var f={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var h={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...f},configurable:true,writable:true},version:{value:h.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var a=dphelper;Object.defineProperty(a,"setProps",{value:(t,e,r)=>{Object.defineProperty(t,e.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(a,"setDescription",{value:(t,e)=>{Object.defineProperties(a,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(r=>(Object.defineProperties(a[t.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),a.setProps(a,t,{writable:false,configurable:false,enumerable:false}),a._list.scripts.push(t);}});var w={name:"fetch",active:true,subCommand:[{name:"get",version:"0.0.2",example:"dphelper.fetch.get('https://api.example.com')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260513",type:"function",active:true,description:"Perform a GET request with automatic retries and exponential backoff. HTTPS required for Zero Trust. Supports timeout and CSRF.",env:"both",subCommand:[]},{name:"post",version:"0.0.2",example:"dphelper.fetch.post('/api', { data: 123 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260513",type:"function",active:true,description:"Perform a POST request with JSON support. HTTPS required for Zero Trust. Supports timeout and CSRF.",env:"both",subCommand:[]}]},g=1e4,T=t=>{try{let e=new URL(t);return e.protocol!=="https:"&&e.protocol!=="http:"?(console.error("[dphelper] Only HTTP/HTTPS protocols allowed"),!1):!0}catch{return true}},i=async(t,e={},r=3,n=1e3,s=g)=>{if(!T(t))throw new Error("Invalid protocol - HTTPS required");let l=new AbortController,u=setTimeout(()=>l.abort(),s);try{let o=await fetch(t,{...e,signal:l.signal});if(clearTimeout(u),!o.ok&&r>0)throw new Error(o.statusText);return o}catch(o){if(clearTimeout(u),o.name==="AbortError")throw new Error(`[dphelper] Request timeout after ${s}ms`,{cause:o});if(r===0)throw o;return console.warn(`[dphelper] Fetch failed, retrying in ${n}ms... (${r} retries left)`),await new Promise(m=>setTimeout(m,n)),i(t,e,r-1,n*2,s)}},c=(t,e)=>i(t,e);c.get=(t,e)=>i(t,{...e,method:"GET"});c.post=(t,e,r={})=>{let n=typeof e=="object"&&e!==null,l=(typeof document<"u"?document.querySelector("meta[name='csrf-token']"):null)?.getAttribute("content")||"";return i(t,{...r,method:"POST",headers:{...n?{"Content-Type":"application/json"}:{},...l?{"X-CSRF-Token":l}:{},...r.headers||{}},body:n?JSON.stringify(e):e})};var y=c;typeof dphelper?.setDescription=="function"&&dphelper.setDescription(w,y);var R=dphelper.fetch;
|
|
2
2
|
exports.fetch=R;
|
package/modules/fetch.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
-
export interface FetchTool {
|
|
3
|
-
/**
|
|
4
|
-
* Perform a resilient fetch with automatic retries and exponential backoff.
|
|
5
|
-
*/
|
|
6
|
-
(url: string, options?: any, retries?: number, backoff?: number): Promise<Response>
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Perform a GET request.
|
|
10
|
-
*/
|
|
11
|
-
get: (url: string, options?: any) => Promise<Response>
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Perform a POST request with optional JSON body auto-serialization.
|
|
15
|
-
*/
|
|
16
|
-
post: (url: string, body: any, options?: any) => Promise<Response>
|
|
2
|
+
export interface FetchTool {
|
|
3
|
+
/**
|
|
4
|
+
* Perform a resilient fetch with automatic retries and exponential backoff.
|
|
5
|
+
*/
|
|
6
|
+
(url: string, options?: any, retries?: number, backoff?: number): Promise<Response>
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Perform a GET request.
|
|
10
|
+
*/
|
|
11
|
+
get: (url: string, options?: any) => Promise<Response>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Perform a POST request with optional JSON body auto-serialization.
|
|
15
|
+
*/
|
|
16
|
+
post: (url: string, body: any, options?: any) => Promise<Response>
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const fetch: FetchTool
|
package/modules/fetch.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var h={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var m={version:"4.6.
|
|
1
|
+
var h={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var m={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...h},configurable:true,writable:true},version:{value:m.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var a=dphelper;Object.defineProperty(a,"setProps",{value:(t,e,r)=>{Object.defineProperty(t,e.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(t[e.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(a,"setDescription",{value:(t,e)=>{Object.defineProperties(a,{[t.name]:{value:e,writable:false,configurable:false,enumerable:false}}),Object.keys(e).map(r=>(Object.defineProperties(a[t.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),a.setProps(a,t,{writable:false,configurable:false,enumerable:false}),a._list.scripts.push(t);}});var g={name:"fetch",active:true,subCommand:[{name:"get",version:"0.0.2",example:"dphelper.fetch.get('https://api.example.com')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260513",type:"function",active:true,description:"Perform a GET request with automatic retries and exponential backoff. HTTPS required for Zero Trust. Supports timeout and CSRF.",env:"both",subCommand:[]},{name:"post",version:"0.0.2",example:"dphelper.fetch.post('/api', { data: 123 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260513",type:"function",active:true,description:"Perform a POST request with JSON support. HTTPS required for Zero Trust. Supports timeout and CSRF.",env:"both",subCommand:[]}]},T=1e4,y=t=>{try{let e=new URL(t);return e.protocol!=="https:"&&e.protocol!=="http:"?(console.error("[dphelper] Only HTTP/HTTPS protocols allowed"),!1):!0}catch{return true}},i=async(t,e={},r=3,n=1e3,s=T)=>{if(!y(t))throw new Error("Invalid protocol - HTTPS required");let l=new AbortController,f=setTimeout(()=>l.abort(),s);try{let o=await fetch(t,{...e,signal:l.signal});if(clearTimeout(f),!o.ok&&r>0)throw new Error(o.statusText);return o}catch(o){if(clearTimeout(f),o.name==="AbortError")throw new Error(`[dphelper] Request timeout after ${s}ms`,{cause:o});if(r===0)throw o;return console.warn(`[dphelper] Fetch failed, retrying in ${n}ms... (${r} retries left)`),await new Promise(b=>setTimeout(b,n)),i(t,e,r-1,n*2,s)}},u=(t,e)=>i(t,e);u.get=(t,e)=>i(t,{...e,method:"GET"});u.post=(t,e,r={})=>{let n=typeof e=="object"&&e!==null,l=(typeof document<"u"?document.querySelector("meta[name='csrf-token']"):null)?.getAttribute("content")||"";return i(t,{...r,method:"POST",headers:{...n?{"Content-Type":"application/json"}:{},...l?{"X-CSRF-Token":l}:{},...r.headers||{}},body:n?JSON.stringify(e):e})};var v=u;typeof dphelper?.setDescription=="function"&&dphelper.setDescription(g,v);var H=dphelper.fetch;
|
|
2
2
|
export{H as fetch};
|
package/modules/form.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var d={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var h={version:"4.6.
|
|
1
|
+
'use strict';var d={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var h={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...d},configurable:true,writable:true},version:{value:h.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var s=dphelper;Object.defineProperty(s,"setProps",{value:(t,a,r)=>{Object.defineProperty(t,a.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(t[a.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(s,"setDescription",{value:(t,a)=>{Object.defineProperties(s,{[t.name]:{value:a,writable:false,configurable:false,enumerable:false}}),Object.keys(a).map(r=>(Object.defineProperties(s[t.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),s.setProps(s,t,{writable:false,configurable:false,enumerable:false}),s._list.scripts.push(t);}});var v={email:/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/},y={name:"form",active:true,subCommand:[{name:"serialize",version:"0.0.2",example:"dphelper.form.serialize([form])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Serialize form data into an object.",env:"client",subCommand:[]},{name:"confirmType",version:"0.0.2",example:"dphelper.form.confirmType([type, value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Confirm the type of a value.",env:"client",subCommand:[]},{name:"required",version:"0.0.2",example:"dphelper.form.required([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a value is required.",env:"client",subCommand:[]},{name:"minLength",version:"0.0.2",example:"dphelper.form.minLength([value, num = 1])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a value meets the minimum length.",env:"client",subCommand:[]},{name:"maxLength",version:"0.0.2",example:"dphelper.form.maxLength([value, num = 10])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a value exceeds the maximum length.",env:"client",subCommand:[]},{name:"maxPhoneNumber",version:"0.0.2",example:"dphelper.form.maxPhoneNumber([value, num = 10])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a phone number exceeds the maximum length.",env:"client",subCommand:[]},{name:"isNumeric",version:"0.0.2",example:"dphelper.form.isNumeric([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a value is numeric.",env:"client",subCommand:[]},{name:"isEmail",version:"0.0.2",example:"dphelper.form.isEmail([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Validate an email format.",env:"client",subCommand:[]},{name:"pattern",version:"0.0.2",example:"dphelper.form.pattern(event)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Pattern validation using onChange on inputs when you provide a pattern.",env:"client",subCommand:[]},{name:"noSpecialChars",version:"0.0.2",example:"dphelper.form.noSpecialChars(event)",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:true,description:"Avoid special characters in an input.",env:"client",subCommand:[]},{name:"table",version:"0.0.2",example:"dphelper.form.table(size = [7, 24], id, elem)",author:"Dario Passariello",creationDate:"20240101",lastMod:"20240101",type:"function",active:true,description:"Generate a table (default 7x24).",env:"client",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.form.sanitize(input)",author:"Dario Passariello",creationDate:"20240318",lastMod:"20240318",type:"function",active:true,description:"Sanitize input value to avoid injection.",env:"client",subCommand:[]}]},x={serialize:t=>{let a=typeof t=="string"?document.querySelector(t):t;if(!a)return {};let r={};if(!{validate:/^[a-zA-Z][a-zA-Z0-9-_.]{0,199}$/}.validate.test(a.name))return;let m=e=>(e===""&&(e=null),e==="null"&&(e=null),e==="undefined"&&(e=void 0),e==="false"&&(e=false),e==="true"&&(e=true),e==="off"&&(e=false),e==="on"&&(e=true),e==="[]"&&(e=Array),e==="{}"&&(e=Object),["null","undefined","false","true","on","off"].filter(o=>o.includes(e)).length===0&&!Number.isNaN(e)&&(e=Number(e)),e),c=(e,n)=>{let i=[...e],o=i[0];o.slice(-1)==="]"&&(o=o.slice(0,-1));let p={};return i.length===1?p[o]=m(n):(i.shift(),p[o]=c(i,n)),p},l;a instanceof HTMLFormElement?l=Array.from(new FormData(a)).map(([e,n])=>({name:String(e),value:typeof n=="object"&&n!==null?n:JSON.stringify(n)})):typeof a.serializeArray=="function"?l=a.serializeArray():(l=[],a.querySelectorAll("input, select, textarea").forEach(n=>{n.name&&l.push({name:n.name,value:n.value||""});}));for(let e of l){let n=e.value,i=e.name.split("["),o=c(i,n);Object.assign(r,o);}return r},confirmType:(t,a)=>t==="number"?/^\d+$/.test(a.toString()):t==="email"?/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(a.toString().toLowerCase()):true,required:t=>t==null?"Required":void 0,minLength:(t,a=1)=>!t||t.length<a?"Must Enter a Value":void 0,maxLength:(t,a=10)=>t.length>a?"Exceeds Max Length":void 0,maxPhoneNumber:(t,a=10)=>t.toString().length>a?"Exceeds Max Length":void 0,isNumeric:t=>!Number.isNaN(t),isEmail:t=>v.email.test(t.toString().toLowerCase()),pattern:t=>{let a=t.target;if(!(a.type&&a.value))return;let r;switch(a.type){case "text":case "password":r=/^[a-zA-Z0-9.\- !$@]+$/;break;case "email":r=/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/;break;case "number":r=/^[0-9\-+]*$/;break;case "tel":r=/^[0-9\s()\-+]*$/;break;default:return}a.value.match(r)||(a.value=a.value.slice(0,-1),t.preventDefault());},noSpecialChars:t=>{let a=t.target,r=a.value.trim(),u=/[^\w\s]/gi;r.length>2&&(a.value=r.replace(u,""));},table:(t,a,r)=>{let u=t[0]||7,m=t[1]||24,c=n=>String(n).replace(/[&<>"']/g,i=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[i]||i),e=`<form id='${c(a||`table_${Date.now()}`)}'>`;e+="<div class='table'>",e+="<div class='title'>";for(let n=1;n<=u;n++)e+=`<span>${n}</span>`;e+="</div>";for(let n=1;n<=m;n++){e+=`<div class='row'><span>${n}</span>`;for(let i=1;i<=u;i++){let o=c(`${i} to ${n}`);e+=`<input name='data[${i}][${n}]' tabindex='${i.toString().padStart(2,"0")}${n.toString().padStart(2,"0")}' type='number' onclick="this.select()" value='${Math.floor(Math.random()*100)}' title='${o}' />`;}e+="</div>";}e+="</div>",e+="</form>",r&&(r.innerHTML=e);},sanitize:t=>{if(t)return t.replace(/[^\w ]/g,"").replace(/[&/\\#, +()$~%.'":*?<>{}]/g,"")}};dphelper?.setDescription(y,x);var S=dphelper.form;exports.form=S;
|
package/modules/form.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
-
export interface FormTool {
|
|
3
|
-
serialize: (form: HTMLFormElement) => { [key: string]: any }
|
|
4
|
-
confirmType: (type: string, value: any) => boolean
|
|
5
|
-
required: (value: any) => string | undefined
|
|
6
|
-
minLength: (value: any, num?: number) => string | undefined
|
|
7
|
-
maxLength: (value: any, num?: number) => string | undefined
|
|
8
|
-
maxPhoneNumber: (value: any, num?: number) => string | undefined
|
|
9
|
-
isNumeric: (value: any) => boolean
|
|
10
|
-
isEmail: (value: any) => boolean
|
|
11
|
-
pattern: (e: Event) => void
|
|
12
|
-
noSpecialChars: (e: Event) => void
|
|
13
|
-
table: (size: [number, number], id: string, elem: HTMLElement) => void
|
|
14
|
-
sanitize: (str: string) => string | undefined
|
|
2
|
+
export interface FormTool {
|
|
3
|
+
serialize: (form: HTMLFormElement) => { [key: string]: any }
|
|
4
|
+
confirmType: (type: string, value: any) => boolean
|
|
5
|
+
required: (value: any) => string | undefined
|
|
6
|
+
minLength: (value: any, num?: number) => string | undefined
|
|
7
|
+
maxLength: (value: any, num?: number) => string | undefined
|
|
8
|
+
maxPhoneNumber: (value: any, num?: number) => string | undefined
|
|
9
|
+
isNumeric: (value: any) => boolean
|
|
10
|
+
isEmail: (value: any) => boolean
|
|
11
|
+
pattern: (e: Event) => void
|
|
12
|
+
noSpecialChars: (e: Event) => void
|
|
13
|
+
table: (size: [number, number], id: string, elem: HTMLElement) => void
|
|
14
|
+
sanitize: (str: string) => string | undefined
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const form: FormTool
|
package/modules/form.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var h={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var b={version:"4.6.
|
|
1
|
+
var h={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var b={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...h},configurable:true,writable:true},version:{value:b.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var s=dphelper;Object.defineProperty(s,"setProps",{value:(t,a,r)=>{Object.defineProperty(t,a.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(t[a.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(s,"setDescription",{value:(t,a)=>{Object.defineProperties(s,{[t.name]:{value:a,writable:false,configurable:false,enumerable:false}}),Object.keys(a).map(r=>(Object.defineProperties(s[t.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),s.setProps(s,t,{writable:false,configurable:false,enumerable:false}),s._list.scripts.push(t);}});var y={email:/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/},x={name:"form",active:true,subCommand:[{name:"serialize",version:"0.0.2",example:"dphelper.form.serialize([form])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Serialize form data into an object.",env:"client",subCommand:[]},{name:"confirmType",version:"0.0.2",example:"dphelper.form.confirmType([type, value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Confirm the type of a value.",env:"client",subCommand:[]},{name:"required",version:"0.0.2",example:"dphelper.form.required([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a value is required.",env:"client",subCommand:[]},{name:"minLength",version:"0.0.2",example:"dphelper.form.minLength([value, num = 1])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a value meets the minimum length.",env:"client",subCommand:[]},{name:"maxLength",version:"0.0.2",example:"dphelper.form.maxLength([value, num = 10])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a value exceeds the maximum length.",env:"client",subCommand:[]},{name:"maxPhoneNumber",version:"0.0.2",example:"dphelper.form.maxPhoneNumber([value, num = 10])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a phone number exceeds the maximum length.",env:"client",subCommand:[]},{name:"isNumeric",version:"0.0.2",example:"dphelper.form.isNumeric([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Check if a value is numeric.",env:"client",subCommand:[]},{name:"isEmail",version:"0.0.2",example:"dphelper.form.isEmail([value])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Validate an email format.",env:"client",subCommand:[]},{name:"pattern",version:"0.0.2",example:"dphelper.form.pattern(event)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Pattern validation using onChange on inputs when you provide a pattern.",env:"client",subCommand:[]},{name:"noSpecialChars",version:"0.0.2",example:"dphelper.form.noSpecialChars(event)",author:"Dario Passariello",creationDate:"20230527",lastMod:"20230527",type:"function",active:true,description:"Avoid special characters in an input.",env:"client",subCommand:[]},{name:"table",version:"0.0.2",example:"dphelper.form.table(size = [7, 24], id, elem)",author:"Dario Passariello",creationDate:"20240101",lastMod:"20240101",type:"function",active:true,description:"Generate a table (default 7x24).",env:"client",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.form.sanitize(input)",author:"Dario Passariello",creationDate:"20240318",lastMod:"20240318",type:"function",active:true,description:"Sanitize input value to avoid injection.",env:"client",subCommand:[]}]},w={serialize:t=>{let a=typeof t=="string"?document.querySelector(t):t;if(!a)return {};let r={};if(!{validate:/^[a-zA-Z][a-zA-Z0-9-_.]{0,199}$/}.validate.test(a.name))return;let m=e=>(e===""&&(e=null),e==="null"&&(e=null),e==="undefined"&&(e=void 0),e==="false"&&(e=false),e==="true"&&(e=true),e==="off"&&(e=false),e==="on"&&(e=true),e==="[]"&&(e=Array),e==="{}"&&(e=Object),["null","undefined","false","true","on","off"].filter(o=>o.includes(e)).length===0&&!Number.isNaN(e)&&(e=Number(e)),e),c=(e,n)=>{let i=[...e],o=i[0];o.slice(-1)==="]"&&(o=o.slice(0,-1));let p={};return i.length===1?p[o]=m(n):(i.shift(),p[o]=c(i,n)),p},l;a instanceof HTMLFormElement?l=Array.from(new FormData(a)).map(([e,n])=>({name:String(e),value:typeof n=="object"&&n!==null?n:JSON.stringify(n)})):typeof a.serializeArray=="function"?l=a.serializeArray():(l=[],a.querySelectorAll("input, select, textarea").forEach(n=>{n.name&&l.push({name:n.name,value:n.value||""});}));for(let e of l){let n=e.value,i=e.name.split("["),o=c(i,n);Object.assign(r,o);}return r},confirmType:(t,a)=>t==="number"?/^\d+$/.test(a.toString()):t==="email"?/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(a.toString().toLowerCase()):true,required:t=>t==null?"Required":void 0,minLength:(t,a=1)=>!t||t.length<a?"Must Enter a Value":void 0,maxLength:(t,a=10)=>t.length>a?"Exceeds Max Length":void 0,maxPhoneNumber:(t,a=10)=>t.toString().length>a?"Exceeds Max Length":void 0,isNumeric:t=>!Number.isNaN(t),isEmail:t=>y.email.test(t.toString().toLowerCase()),pattern:t=>{let a=t.target;if(!(a.type&&a.value))return;let r;switch(a.type){case "text":case "password":r=/^[a-zA-Z0-9.\- !$@]+$/;break;case "email":r=/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/;break;case "number":r=/^[0-9\-+]*$/;break;case "tel":r=/^[0-9\s()\-+]*$/;break;default:return}a.value.match(r)||(a.value=a.value.slice(0,-1),t.preventDefault());},noSpecialChars:t=>{let a=t.target,r=a.value.trim(),u=/[^\w\s]/gi;r.length>2&&(a.value=r.replace(u,""));},table:(t,a,r)=>{let u=t[0]||7,m=t[1]||24,c=n=>String(n).replace(/[&<>"']/g,i=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[i]||i),e=`<form id='${c(a||`table_${Date.now()}`)}'>`;e+="<div class='table'>",e+="<div class='title'>";for(let n=1;n<=u;n++)e+=`<span>${n}</span>`;e+="</div>";for(let n=1;n<=m;n++){e+=`<div class='row'><span>${n}</span>`;for(let i=1;i<=u;i++){let o=c(`${i} to ${n}`);e+=`<input name='data[${i}][${n}]' tabindex='${i.toString().padStart(2,"0")}${n.toString().padStart(2,"0")}' type='number' onclick="this.select()" value='${Math.floor(Math.random()*100)}' title='${o}' />`;}e+="</div>";}e+="</div>",e+="</form>",r&&(r.innerHTML=e);},sanitize:t=>{if(t)return t.replace(/[^\w ]/g,"").replace(/[&/\\#, +()$~%.'":*?<>{}]/g,"")}};dphelper?.setDescription(x,w);var E=dphelper.form;export{E as form};
|
package/modules/format.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var n={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var s={version:"4.6.
|
|
1
|
+
'use strict';var n={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var s={version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...n},configurable:true,writable:true},version:{value:s.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var a=dphelper;Object.defineProperty(a,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(a,"setDescription",{value:(e,t)=>{Object.defineProperties(a,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(a[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),a.setProps(a,e,{writable:false,configurable:false,enumerable:false}),a._list.scripts.push(e);}});var p={name:"format",active:true,subCommand:[{name:"currency",version:"0.0.2",example:"dphelper.format.currency(value, locale, currency)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Format a number as currency.",env:"both",subCommand:[]},{name:"phoneNumber",version:"0.0.2",example:"dphelper.format.phoneNumber(value, countryCode)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Format a string as a phone number.",env:"both",subCommand:[]}]},u={currency:(e,t="en-US",r="USD")=>new Intl.NumberFormat(t,{style:"currency",currency:r}).format(e),phoneNumber:(e,t="US")=>{let r=`${e}`.replace(/\D/g,""),o;return t==="US"&&(o=r.match(/^(\d{3})(\d{3})(\d{4})$/),o)?`(${o[1]}) ${o[2]}-${o[3]}`:e}};typeof dphelper?.setDescription=="function"&&dphelper.setDescription(p,u);var D=dphelper.format;exports.format=D;
|
package/modules/format.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="../types/dphelper.d.ts" />
|
|
2
|
-
export interface FormatTool {
|
|
3
|
-
currency: (value: number, locale?: string, currency?: string) => string
|
|
4
|
-
phoneNumber: (value: string, countryCode?: string) => string
|
|
2
|
+
export interface FormatTool {
|
|
3
|
+
currency: (value: number, locale?: string, currency?: string) => string
|
|
4
|
+
phoneNumber: (value: string, countryCode?: string) => string
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export const format: FormatTool
|