dphelper 0.2.88 → 0.2.89
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/.editorconfig +13 -0
- package/.env +3 -0
- package/.eslintignore +13 -0
- package/.eslintrc.json +87 -0
- package/.eslintrc.legacy.json +91 -0
- package/.gitattributes +2 -0
- package/.hintrc +11 -0
- package/.jsbeautifyrc +25 -0
- package/.jshintrc +16 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +8 -0
- package/.stylelintignore +0 -0
- package/.stylelintrc.json +468 -0
- package/.vscode/launch.json +34 -0
- package/.vscode/settings.json +58 -0
- package/3party/shortcut.js +224 -0
- package/__mocks__/fileMock.js +3 -0
- package/__mocks__/styleMock.js +3 -0
- package/babel.config.js +30 -0
- package/backup.bat +43 -0
- package/coverage/coverage-final.json +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +101 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +0 -0
- package/data/list.json +19 -0
- package/dist/LICENSE.txt +209 -0
- package/dist/README.md +79 -0
- package/elements/button/component.js +0 -0
- package/elements/code/component.js +0 -0
- package/elements/costants.tsx +13 -0
- package/elements/fieldset/component.js +0 -0
- package/elements/input/checkbox/component.js +0 -0
- package/elements/input/date/component.js +27 -0
- package/elements/input/number/component.js +0 -0
- package/elements/input/radio/component.js +0 -0
- package/elements/input/search/component.js +0 -0
- package/elements/input/select/component.js +0 -0
- package/elements/input/slider/component.js +0 -0
- package/elements/input/switch/component.js +0 -0
- package/elements/tab/component.js +0 -0
- package/elements/table/component.js +0 -0
- package/elements/tags.less +0 -0
- package/elements/textarea/component.js +0 -0
- package/elements/x-foo/define.js +33 -0
- package/elements/x-foo/namespace.d.ts +7 -0
- package/index.js +12 -2
- package/init.js +87 -0
- package/jest.config.js +81 -0
- package/node/createTag.js +7 -0
- package/node/gitDeploy.js +7 -0
- package/node/goLive.js +7 -0
- package/package.json +7 -7
- package/{assets → public/assets}/images/banner.png +0 -0
- package/{assets → public/assets}/logos/logo.svg +0 -0
- package/{documents → public/documents}/iDB/list.html +0 -0
- package/{documents → public/documents}/iDB/toState.html +0 -0
- package/scripts/.OLD/import.js +48 -0
- package/scripts/.OLD/onBeforeUnLoad.js +120 -0
- package/scripts/.OLD/purge.js +53 -0
- package/scripts/.OLD/string.js +27 -0
- package/scripts/anchor.js +73 -0
- package/scripts/array.js +203 -0
- package/scripts/avoid.js +48 -0
- package/scripts/browser.js +100 -0
- package/scripts/color.js +121 -0
- package/scripts/console.js +97 -0
- package/scripts/console.mapped.js +160 -0
- package/scripts/coods.js +57 -0
- package/scripts/cookie.js +105 -0
- package/scripts/date.js +179 -0
- package/scripts/disable.js +91 -0
- package/scripts/errors.js +3 -0
- package/scripts/event.js +57 -0
- package/scripts/font.js +60 -0
- package/scripts/form.js +211 -0
- package/scripts/format.js +71 -0
- package/scripts/function.js +55 -0
- package/scripts/iDB.js +688 -0
- package/scripts/json.js +84 -0
- package/scripts/load.js +112 -0
- package/scripts/math.js +100 -0
- package/scripts/obj.js +118 -0
- package/scripts/path.js +101 -0
- package/scripts/promise.js +56 -0
- package/scripts/screen.js +82 -0
- package/scripts/scrollbar.js +293 -0
- package/scripts/shortcut.js +83 -0
- package/scripts/socket.js +184 -0
- package/scripts/state.js +87 -0
- package/scripts/storage.js +93 -0
- package/scripts/store.js +115 -0
- package/scripts/svg.js +380 -0
- package/scripts/text.js +116 -0
- package/scripts/time.js +43 -0
- package/scripts/timer.js +54 -0
- package/scripts/tool.js +73 -0
- package/scripts/trigger.js +57 -0
- package/scripts/type.js +76 -0
- package/scripts/ui.js +41 -0
- package/scripts/window.js +244 -0
- package/styles/console.less +95 -0
- package/tests/setupJest.tsx +4 -0
- package/typings/.OLD/cordova.d.ts +12 -0
- package/typings/.OLD/layerpro.d.ts +20 -0
- package/typings/.OLD/menupro.d.ts +20 -0
- package/typings/dphelper.d.ts +26 -0
- package/typings/image.d.ts +5 -0
- package/typings/styles.d.ts +23 -0
- package/webpack.config.js +249 -0
- package/index.js.LICENSE.txt +0 -31
package/scripts/font.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Font",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "font",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"fitContainer",
|
|
18
|
+
"description":""
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"example" : "",
|
|
22
|
+
"author" : "Dario Passariello",
|
|
23
|
+
"active" : true
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
dphelper._list.scripts.push( description );
|
|
27
|
+
|
|
28
|
+
/***********************************************************************/
|
|
29
|
+
|
|
30
|
+
dphelper.font = {
|
|
31
|
+
|
|
32
|
+
fitContainer: ( name ) => {
|
|
33
|
+
if( !name ) return;
|
|
34
|
+
|
|
35
|
+
function fitStart(){
|
|
36
|
+
var divs = document.querySelectorAll( name );
|
|
37
|
+
if( divs.length <= 0 ) return;
|
|
38
|
+
for(var i = 0; i < divs.length; i++) {
|
|
39
|
+
var fontSize = divs[i].offsetWidth * 0.05;
|
|
40
|
+
divs[i].style.fontSize = fontSize+'px';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
dphelper.addListenerMulti( window , 'load resize', () => {
|
|
45
|
+
fitStart( name );
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
Object.defineProperty( dphelper, 'font', {
|
|
53
|
+
writable: false,
|
|
54
|
+
configurable: false
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
package/scripts/form.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Form",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "form",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"serialize",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"confirmType",
|
|
21
|
+
"description":"test"
|
|
22
|
+
},{
|
|
23
|
+
"name":"required",
|
|
24
|
+
"description":"test"
|
|
25
|
+
},{
|
|
26
|
+
"name":"minLength",
|
|
27
|
+
"description":"test"
|
|
28
|
+
},{
|
|
29
|
+
"name":"maxLength",
|
|
30
|
+
"description":"test"
|
|
31
|
+
},{
|
|
32
|
+
"name":"maxPhoneNumber",
|
|
33
|
+
"description":"test"
|
|
34
|
+
},{
|
|
35
|
+
"name":"isNumeric",
|
|
36
|
+
"description":"test"
|
|
37
|
+
},{
|
|
38
|
+
"name":"isEmail",
|
|
39
|
+
"description":"test"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"example" : "",
|
|
43
|
+
"author" : "Dario Passariello",
|
|
44
|
+
"active" : true
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
dphelper._list.scripts.push( description );
|
|
48
|
+
|
|
49
|
+
/***********************************************************************/
|
|
50
|
+
|
|
51
|
+
dphelper.form = {
|
|
52
|
+
|
|
53
|
+
serialize: ( form ) => {
|
|
54
|
+
|
|
55
|
+
const $ = require("jquery");
|
|
56
|
+
const el = this;
|
|
57
|
+
//const el = $( form );
|
|
58
|
+
|
|
59
|
+
var self = el,
|
|
60
|
+
|
|
61
|
+
json = {},
|
|
62
|
+
push_counters = {},
|
|
63
|
+
|
|
64
|
+
patterns = {
|
|
65
|
+
//"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
|
|
66
|
+
"validate": /[a-zA-Z][a-zA-Z0-9-_.]/, //{1,200}
|
|
67
|
+
"key": /[a-zA-Z0-9_]+|(?=\[\])/g,
|
|
68
|
+
"push": /^$/,
|
|
69
|
+
"fixed": /^\d+$/,
|
|
70
|
+
"named": /^[a-zA-Z0-9_]+$/
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
el.build = function(base, key, value) {
|
|
74
|
+
base[key] = isNaN(value) || Array.isArray(value) ? value : Number(value);
|
|
75
|
+
return base;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
el.push_counter = function(key) {
|
|
79
|
+
if (push_counters[key] === undefined) {
|
|
80
|
+
push_counters[key] = 0;
|
|
81
|
+
}
|
|
82
|
+
return push_counters[key]++;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
$.each( $(el).serializeArray(), function() {
|
|
86
|
+
|
|
87
|
+
// skip invalid keys
|
|
88
|
+
if (!patterns.validate.test(el.name)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
var k,
|
|
93
|
+
keys = el.name.match(patterns.key),
|
|
94
|
+
merge = el.value,
|
|
95
|
+
reverse_key = el.name;
|
|
96
|
+
|
|
97
|
+
if( merge === 'false' ) merge = Boolean(false);
|
|
98
|
+
if( merge === 'true' ) merge = Boolean(true);
|
|
99
|
+
if( merge === 'off' ) merge = Boolean(false);
|
|
100
|
+
if( merge === 'on' ) merge = Boolean(true);
|
|
101
|
+
if( merge === '[]' ) merge = [];
|
|
102
|
+
if( merge === '{}' ) merge = {};
|
|
103
|
+
if( merge === 'undefined' ) merge = undefined;
|
|
104
|
+
if( merge === 'null' ) merge = null;
|
|
105
|
+
if( merge === '' ) merge = '';
|
|
106
|
+
|
|
107
|
+
while ((k = keys.pop()) !== undefined) {
|
|
108
|
+
|
|
109
|
+
// adjust reverse_key
|
|
110
|
+
reverse_key = reverse_key.replace(new RegExp("\\[" + k + "\\]$"), '');
|
|
111
|
+
|
|
112
|
+
// push
|
|
113
|
+
if (k.match(patterns.push)) {
|
|
114
|
+
merge = self.build([], self.push_counter(reverse_key), merge);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// fixed
|
|
118
|
+
else if (k.match(patterns.fixed)) {
|
|
119
|
+
merge = self.build([], k, merge);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// named
|
|
123
|
+
else if (k.match(patterns.named)) {
|
|
124
|
+
merge = self.build({}, k, merge);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
json = $.extend(true, json, merge);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return json;
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
confirmType: ( type, value ) => {
|
|
136
|
+
|
|
137
|
+
// FIX NUMBERS
|
|
138
|
+
if ( type === 'number' ) {
|
|
139
|
+
const containsNum = new RegExp(/^\d+$/);
|
|
140
|
+
// console.log(type, value, containsNum.test(value.toString()));
|
|
141
|
+
return containsNum.test(value.toString());
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// FIX EMAIL FORMAT
|
|
145
|
+
if ( type === 'email' ) {
|
|
146
|
+
const isEmail = new RegExp(
|
|
147
|
+
/^(([^<>()[\]\\.,;:\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,}))$/,
|
|
148
|
+
)
|
|
149
|
+
// console.log( type, value, isEmail.test(value.toString()) );
|
|
150
|
+
return isEmail.test(value.toString().toLowerCase());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return true;
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
required: (value) => {
|
|
157
|
+
if (value === null || value === undefined) {
|
|
158
|
+
return "Required";
|
|
159
|
+
} else {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
minLength: ( value , num = 1 ) => {
|
|
165
|
+
if (!value || value?.length < num ) {
|
|
166
|
+
return "Must Enter a Value";
|
|
167
|
+
} else {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
maxLength: ( value , num = 10 ) => {
|
|
173
|
+
if (value?.length > num ) {
|
|
174
|
+
return "Exceeds Max Length";
|
|
175
|
+
} else {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
maxPhoneNumber: ( value , num = 10 ) => {
|
|
181
|
+
if (value?.toString()?.length > num ) {
|
|
182
|
+
return "Exceeds Max Length";
|
|
183
|
+
} else {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
isNumeric: ( value ) => {
|
|
189
|
+
if ( isNaN(value) ) {
|
|
190
|
+
return false;
|
|
191
|
+
} else {
|
|
192
|
+
return value;
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
isEmail: ( value ) => {
|
|
197
|
+
const isEmail = new RegExp(
|
|
198
|
+
/^(([^<>()[\]\\.,;:\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,}))$/,
|
|
199
|
+
)
|
|
200
|
+
return isEmail.test( value.toString().toLowerCase() );
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
Object.defineProperty( dphelper, 'form', {
|
|
207
|
+
writable: false,
|
|
208
|
+
configurable: false
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Format",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "cormat",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"currency",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"phoneNumber",
|
|
21
|
+
"description":"test"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"example" : "",
|
|
25
|
+
"author" : "Dario Passariello",
|
|
26
|
+
"active" : true
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
dphelper._list.scripts.push( description );
|
|
30
|
+
|
|
31
|
+
/***********************************************************************/
|
|
32
|
+
|
|
33
|
+
dphelper.format = {
|
|
34
|
+
|
|
35
|
+
currency: ( val, int = 'en-US', cur = 'USD' ) => {
|
|
36
|
+
if( !val || isNaN( val ) ) val = 0;
|
|
37
|
+
var formatter = new Intl.NumberFormat( int , {
|
|
38
|
+
style: 'currency',
|
|
39
|
+
currency: cur,
|
|
40
|
+
});
|
|
41
|
+
// return ( val ).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')
|
|
42
|
+
return formatter.format( val );
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
////////////////////////////////////////////////////////////////////////////
|
|
46
|
+
|
|
47
|
+
phoneNumber: (str) => {
|
|
48
|
+
//Filter only numbers from the input
|
|
49
|
+
let cleaned = ('' + str).replace(/\D/g, '');
|
|
50
|
+
|
|
51
|
+
//Check if the input is of correct
|
|
52
|
+
let match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/);
|
|
53
|
+
|
|
54
|
+
if (match) {
|
|
55
|
+
//Remove the matched extension code
|
|
56
|
+
//Change this to format for any country code.
|
|
57
|
+
let intlCode = (match[1] ? '+1 ' : '')
|
|
58
|
+
return [intlCode, '(', match[2], ') ', match[3], '-', match[4]].join('')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Object.defineProperty( dphelper, 'format', {
|
|
67
|
+
writable: false,
|
|
68
|
+
configurable: false
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Func",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "func",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"new",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"toObj.set",
|
|
21
|
+
"description":"test"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"example" : "",
|
|
25
|
+
"author" : "Dario Passariello",
|
|
26
|
+
"active" : true
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
dphelper._list.scripts.push( description );
|
|
30
|
+
|
|
31
|
+
/***********************************************************************/
|
|
32
|
+
|
|
33
|
+
dphelper.func = {
|
|
34
|
+
|
|
35
|
+
new: ( name , text ) => {
|
|
36
|
+
args = [ name , "return" + text ];
|
|
37
|
+
myFunc = Function.apply( null, args );
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
toObj: {
|
|
41
|
+
set: ( value , key ) => {
|
|
42
|
+
return [value , key];
|
|
43
|
+
}
|
|
44
|
+
// var dog = new dphelper.func.oop( "Dog", "Bobby" );
|
|
45
|
+
// console.log( dog.getDetails());
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
Object.defineProperty( dphelper, 'func', {
|
|
51
|
+
writable: false,
|
|
52
|
+
configurable: false
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|