forstok-ui-lib 5.2.4 → 5.2.6
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/dist/index.d.ts +9 -1
- package/dist/index.js +107 -107
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -106
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -4
- package/src/assets/index.ts +3 -1
- package/src/assets/javascripts/function.ts +57 -0
- package/src/components/input/styles.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forstok-ui-lib",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.6",
|
|
4
4
|
"description": "Forstok UI Components Library",
|
|
5
5
|
"path": "dist",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
-
"build": "rollup -c --bundleConfigAsCjs"
|
|
12
|
-
"patch": "npm run build && npm version patch && npm publish",
|
|
13
|
-
"master": "git add . && git commit -m 'patch' && git push origin master"
|
|
11
|
+
"build": "rollup -c --bundleConfigAsCjs"
|
|
14
12
|
},
|
|
15
13
|
"repository": {
|
|
16
14
|
"type": "git",
|
package/src/assets/index.ts
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { TMessage, TMessageQuestion } from '../../components/message/typed';
|
|
3
3
|
|
|
4
|
+
export const getStorage = (name: string, type: string = 'string', defaultVal?: any, loadName: string = 'load') => {
|
|
5
|
+
let result: any
|
|
6
|
+
if (sessionStorage.getItem(loadName) !== null) {
|
|
7
|
+
result = sessionStorage.getItem(name) !== null ? sessionStorage.getItem(name) : defaultVal
|
|
8
|
+
} else {
|
|
9
|
+
result = localStorage.getItem(name) !== null ? localStorage.getItem(name) : defaultVal
|
|
10
|
+
localStorage.getItem(name) !== null && sessionStorage.setItem(name, result)
|
|
11
|
+
}
|
|
12
|
+
switch (type) {
|
|
13
|
+
case 'boolean':
|
|
14
|
+
result = (result !== undefined && result !== 'undefined') ? (result === 'true') : false
|
|
15
|
+
break
|
|
16
|
+
case 'number':
|
|
17
|
+
case 'integer':
|
|
18
|
+
result = (result !== undefined && result !== 'undefined') ? parseInt(result) : 0
|
|
19
|
+
break
|
|
20
|
+
case 'object':
|
|
21
|
+
case 'array':
|
|
22
|
+
result = (result !== undefined && result !== 'undefined') ? JSON.parse(result) : undefined
|
|
23
|
+
break
|
|
24
|
+
default:
|
|
25
|
+
result = (result === undefined || result === 'undefined') ? '' : result
|
|
26
|
+
break
|
|
27
|
+
}
|
|
28
|
+
return result
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const setStorage = (name: string, value?: any, only?: string) => {
|
|
32
|
+
if (value === undefined || value === null) {
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
const _value: string = (typeof value !== 'string') ? ((typeof value === 'object') ? JSON.stringify(value) : value.toString()) : value
|
|
36
|
+
switch (only) {
|
|
37
|
+
case 'session':
|
|
38
|
+
sessionStorage.setItem(name, _value)
|
|
39
|
+
break
|
|
40
|
+
case 'local':
|
|
41
|
+
localStorage.setItem(name, _value)
|
|
42
|
+
break
|
|
43
|
+
default:
|
|
44
|
+
sessionStorage.setItem(name, _value)
|
|
45
|
+
localStorage.setItem(name, _value)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const debounce = (fn: Function, ms = 300) => {
|
|
50
|
+
let timeoutId: ReturnType<typeof setTimeout>;
|
|
51
|
+
return function (this: any, ...args: any[]) {
|
|
52
|
+
clearTimeout(timeoutId);
|
|
53
|
+
timeoutId = setTimeout(() => fn.apply(this, args), ms);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const capitalize = (value?: string) => {
|
|
58
|
+
return value ? (value[0].toUpperCase() + value.substring(1)) : ''
|
|
59
|
+
}
|
|
60
|
+
|
|
4
61
|
export const formatNumber = (n?: string | number, flag?: boolean) => {
|
|
5
62
|
const _flag = flag === undefined ? true : flag
|
|
6
63
|
let result:string = ''
|
|
@@ -27,8 +27,8 @@ const getInputModifiedStyled = ({ width, height, $iconLeft, $iconRight, $isError
|
|
|
27
27
|
}
|
|
28
28
|
if (height) {
|
|
29
29
|
style += `
|
|
30
|
-
height: ${height}px
|
|
31
|
-
max-height: ${height}px
|
|
30
|
+
height: ${height}px;
|
|
31
|
+
max-height: ${height}px;
|
|
32
32
|
`
|
|
33
33
|
}
|
|
34
34
|
if ($mode === 'search') {
|
|
@@ -58,11 +58,11 @@ const getInputModifiedStyled = ({ width, height, $iconLeft, $iconRight, $isError
|
|
|
58
58
|
}
|
|
59
59
|
if (width) {
|
|
60
60
|
style += `
|
|
61
|
-
width: ${width}px
|
|
61
|
+
width: ${width}px;
|
|
62
62
|
`
|
|
63
63
|
}
|
|
64
64
|
if (type === 'submit') {
|
|
65
|
-
style += SubmitStyles
|
|
65
|
+
style += SubmitStyles;
|
|
66
66
|
}
|
|
67
67
|
return style;
|
|
68
68
|
}
|