forstok-ui-lib 5.2.9 → 5.2.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forstok-ui-lib",
3
- "version": "5.2.9",
3
+ "version": "5.2.11",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -1,16 +1,12 @@
1
1
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
2
2
 
3
3
  <!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
4
- <svg width="auto" height="auto" viewBox="-2.4 -2.4 28.80 28.80" xmlns="http://www.w3.org/2000/svg" id="discount" class="icon glyph" fill="#215645" stroke="#215645">
4
+ <svg height="auto" width="auto" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 511.985 511.985" xml:space="preserve" fill="#000000">
5
5
 
6
6
  <g id="SVGRepo_bgCarrier" stroke-width="0"/>
7
7
 
8
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.096"/>
8
+ <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
9
9
 
10
- <g id="SVGRepo_iconCarrier">
11
-
12
- <path d="M21.59,9.83A4.21,4.21,0,0,1,21.17,9,4.73,4.73,0,0,1,21,8.07a4.19,4.19,0,0,0-.64-2.16,4.15,4.15,0,0,0-1.87-1.28,4.36,4.36,0,0,1-.84-.43A4.55,4.55,0,0,1,17,3.54a4.29,4.29,0,0,0-1.81-1.4A4.19,4.19,0,0,0,13,2.21a4.24,4.24,0,0,1-1.94,0A4.19,4.19,0,0,0,8.8,2.14,4.29,4.29,0,0,0,7,3.54a4.55,4.55,0,0,1-.66.66,4.36,4.36,0,0,1-.84.43A4.15,4.15,0,0,0,3.62,5.91,4.19,4.19,0,0,0,3,8.07,4.73,4.73,0,0,1,2.83,9a4.21,4.21,0,0,1-.42.81A4.3,4.3,0,0,0,1.64,12a4.3,4.3,0,0,0,.77,2.17,4.21,4.21,0,0,1,.42.81,4.73,4.73,0,0,1,.15.95,4.19,4.19,0,0,0,.64,2.16,4.15,4.15,0,0,0,1.87,1.28,4.36,4.36,0,0,1,.84.43,4.55,4.55,0,0,1,.66.66,4.29,4.29,0,0,0,1.81,1.4,2.91,2.91,0,0,0,.87.13,6,6,0,0,0,1.36-.2,4.24,4.24,0,0,1,1.94,0,4.19,4.19,0,0,0,2.23.07A4.29,4.29,0,0,0,17,20.46a4.55,4.55,0,0,1,.66-.66,4.36,4.36,0,0,1,.84-.43,4.15,4.15,0,0,0,1.87-1.28A4.19,4.19,0,0,0,21,15.93a4.73,4.73,0,0,1,.15-.95,4.21,4.21,0,0,1,.42-.81A4.3,4.3,0,0,0,22.36,12,4.3,4.3,0,0,0,21.59,9.83ZM9.5,8A1.5,1.5,0,1,1,8,9.5,1.5,1.5,0,0,1,9.5,8Zm5,8A1.5,1.5,0,1,1,16,14.5,1.5,1.5,0,0,1,14.5,16Zm1.21-6.29-6,6a1,1,0,0,1-1.42,0,1,1,0,0,1,0-1.42l6-6a1,1,0,0,1,1.42,1.42Z" style="fill:#215645"/>
13
-
14
- </g>
10
+ <g id="SVGRepo_iconCarrier"> <path style="fill:#21ba63;" d="M500.391,223.525l-4.469-5.203c-9.875-11.539-16.094-34.741-13.312-49.67l1.266-6.742 c2.125-11.289-0.078-23.336-6.188-33.913c-6.109-10.578-15.438-18.508-26.265-22.32l-6.484-2.281 c-14.327-5.038-31.312-22.03-36.358-36.357L406.3,60.57c-6.781-19.266-26.858-33.249-47.764-33.249 c-2.844,0-5.688,0.266-8.453,0.781l-6.75,1.266c-2.391,0.445-5.062,0.672-7.922,0.672c-14.734,0-32.295-5.883-41.748-13.984 l-5.203-4.461c-8.719-7.478-20.25-11.594-32.468-11.594c-12.219,0-23.749,4.116-32.468,11.593l-5.203,4.469 c-9.453,8.094-27.015,13.977-41.749,13.977c-2.875,0-5.531-0.227-7.922-0.672l-6.749-1.266c-2.75-0.516-5.609-0.773-8.469-0.773l0,0 c-20.89,0-40.968,13.976-47.749,33.241l-2.281,6.477c-5.046,14.319-22.03,31.312-36.373,36.35l-6.469,2.281 c-10.828,3.812-20.156,11.742-26.266,22.32c-6.108,10.577-8.296,22.624-6.202,33.913l1.281,6.742 c2.781,14.929-3.438,38.139-13.312,49.662l-4.469,5.211C4.124,232.252,0,243.782,0,255.993c0,12.219,4.124,23.749,11.593,32.468 l4.469,5.203c9.875,11.53,16.094,34.733,13.312,49.67l-1.281,6.75c-2.094,11.28,0.094,23.327,6.202,33.905 c6.109,10.578,15.438,18.5,26.266,22.312l6.469,2.281c14.343,5.046,31.327,22.029,36.373,36.357l2.281,6.484 c6.781,19.25,26.859,33.233,47.765,33.233c2.859,0,5.703-0.266,8.453-0.781l6.749-1.266c2.391-0.438,5.047-0.656,7.922-0.656 c14.734,0,32.296,5.875,41.733,13.968l5.219,4.469c8.719,7.469,20.249,11.594,32.468,11.594c12.218,0,23.749-4.125,32.468-11.594 l5.203-4.469c9.453-8.093,27.014-13.968,41.748-13.968c2.875,0,5.531,0.219,7.922,0.656l6.734,1.281 c2.766,0.5,5.609,0.766,8.469,0.766c20.905,0,40.982-13.983,47.764-33.233l2.281-6.484c5.047-14.328,22.031-31.312,36.358-36.357 l6.484-2.281c10.827-3.812,20.155-11.734,26.265-22.312s8.297-22.625,6.188-33.905l-1.266-6.75 c-2.781-14.937,3.438-38.14,13.312-49.654l4.469-5.219c7.468-8.719,11.593-20.249,11.593-32.468 C511.984,243.782,507.859,232.252,500.391,223.525z"/> <g> <path style="fill:#ffffff;" d="M191.994,245.329c29.452,0,53.326-23.882,53.326-53.334s-23.874-53.335-53.326-53.335 s-53.327,23.883-53.327,53.335S162.542,245.329,191.994,245.329z M191.994,159.996c17.64,0,31.999,14.358,31.999,31.999 c0,17.647-14.359,31.999-31.999,31.999c-17.641,0-31.999-14.352-31.999-31.999C159.995,174.354,174.353,159.996,191.994,159.996z"/> <path style="fill:#ffffff;" d="M319.99,266.657c-29.452,0-53.327,23.882-53.327,53.334s23.875,53.342,53.327,53.342 s53.326-23.89,53.326-53.342S349.442,266.657,319.99,266.657z M319.99,351.99c-17.64,0-31.999-14.343-31.999-31.999 s14.359-31.999,31.999-31.999s31.999,14.343,31.999,31.999S337.63,351.99,319.99,351.99z"/> <path style="fill:#ffffff;" d="M370.192,156.871c1.937-1.93,3.124-4.594,3.124-7.539c0-5.891-4.765-10.672-10.655-10.672 c-2.953,0-5.609,1.195-7.547,3.125l0,0l-213.322,213.33l0,0c-1.938,1.938-3.125,4.594-3.125,7.53 c0,5.906,4.766,10.688,10.656,10.688c2.953,0,5.609-1.203,7.547-3.125l0,0L370.192,156.871z"/> </g> </g>
15
11
 
16
12
  </svg>
@@ -2,50 +2,56 @@ import { ReactNode } from 'react';
2
2
  import { TMessage, TMessageQuestion } from '../../components/message/typed';
3
3
 
4
4
  export const getStorage = (name: string, type: string = 'string', defaultVal?: any, loadName: string = 'load') => {
5
- let result: any
5
+ let result: any;
6
6
  if (sessionStorage.getItem(loadName) !== null) {
7
- result = sessionStorage.getItem(name) !== null ? sessionStorage.getItem(name) : defaultVal
7
+ result = sessionStorage.getItem(name) !== null ? sessionStorage.getItem(name) : defaultVal;
8
8
  } else {
9
- result = localStorage.getItem(name) !== null ? localStorage.getItem(name) : defaultVal
10
- localStorage.getItem(name) !== null && sessionStorage.setItem(name, result)
9
+ result = localStorage.getItem(name) !== null ? localStorage.getItem(name) : defaultVal;
10
+ localStorage.getItem(name) !== null && sessionStorage.setItem(name, result);
11
11
  }
12
12
  switch (type) {
13
13
  case 'boolean':
14
- result = (result !== undefined && result !== 'undefined') ? (result === 'true') : false
15
- break
14
+ result = (result !== undefined && result !== 'undefined') ? (result === 'true') : false;
15
+ break;
16
16
  case 'number':
17
17
  case 'integer':
18
- result = (result !== undefined && result !== 'undefined') ? parseInt(result) : 0
19
- break
18
+ result = (result !== undefined && result !== 'undefined') ? parseInt(result) : 0;
19
+ break;
20
20
  case 'object':
21
21
  case 'array':
22
- result = (result !== undefined && result !== 'undefined') ? JSON.parse(result) : undefined
23
- break
22
+ result = (result !== undefined && result !== 'undefined') ? JSON.parse(result) : undefined;
23
+ break;
24
24
  default:
25
- result = (result === undefined || result === 'undefined') ? '' : result
26
- break
25
+ result = (result === undefined || result === 'undefined') ? '' : result;
26
+ break;
27
27
  }
28
- return result
28
+ return result;
29
29
  }
30
30
 
31
31
  export const setStorage = (name: string, value?: any, only?: string) => {
32
32
  if (value === undefined || value === null) {
33
- return false
33
+ return false;
34
34
  }
35
- const _value: string = (typeof value !== 'string') ? ((typeof value === 'object') ? JSON.stringify(value) : value.toString()) : value
35
+ const _value: string = (typeof value !== 'string') ? ((typeof value === 'object') ? JSON.stringify(value) : value.toString()) : value;
36
36
  switch (only) {
37
37
  case 'session':
38
- sessionStorage.setItem(name, _value)
38
+ sessionStorage.setItem(name, _value);
39
39
  break
40
40
  case 'local':
41
- localStorage.setItem(name, _value)
41
+ localStorage.setItem(name, _value);
42
42
  break
43
43
  default:
44
- sessionStorage.setItem(name, _value)
45
- localStorage.setItem(name, _value)
44
+ sessionStorage.setItem(name, _value);
45
+ localStorage.setItem(name, _value);
46
46
  }
47
47
  }
48
48
 
49
+ export const removeStorage = (name: string) => {
50
+ localStorage.removeItem(name);
51
+ sessionStorage.removeItem(name);
52
+ return true;
53
+ }
54
+
49
55
  export const debounce = (fn: Function, ms = 300) => {
50
56
  let timeoutId: ReturnType<typeof setTimeout>;
51
57
  return function (this: any, ...args: any[]) {
@@ -55,22 +61,22 @@ export const debounce = (fn: Function, ms = 300) => {
55
61
  }
56
62
 
57
63
  export const capitalize = (value?: string) => {
58
- return value ? (value[0].toUpperCase() + value.substring(1)) : ''
64
+ return value ? (value[0].toUpperCase() + value.substring(1)) : '';
59
65
  }
60
66
 
61
67
  export const formatNumber = (n?: string | number, flag?: boolean) => {
62
- const _flag = flag === undefined ? true : flag
63
- let result:string = ''
68
+ const _flag = flag === undefined ? true : flag;
69
+ let result:string = '';
64
70
  if (n !== '' && n !== null && n !== undefined) {
65
- result = n?.toString().replaceAll(".", "")
71
+ result = n?.toString().replaceAll(".", "");
66
72
  if (result.length === 2 && result.substring(0, 1) === "0") {
67
- result = parseInt(result).toString()
73
+ result = parseInt(result).toString();
68
74
  }
69
75
  if (_flag) {
70
- result = result.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ".")
76
+ result = result.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ".");
71
77
  }
72
78
  }
73
- return result
79
+ return result;
74
80
  }
75
81
 
76
82
  export const generateMessage = (type: string, value: string | ReactNode, callback?: () => void, timer?: number) => {
@@ -78,9 +84,9 @@ export const generateMessage = (type: string, value: string | ReactNode, callbac
78
84
  $type: type,
79
85
  message: value,
80
86
  timer: timer || (type === 'warning' ? 3000 : 2000)
81
- }
82
- callback && (result.callback = () => { callback() })
83
- return result
87
+ };
88
+ callback && (result.callback = () => { callback() });
89
+ return result;
84
90
  }
85
91
 
86
92
  export const generateMessageQuestion = (type: string, title: string, subtitle: string, callback?: () => void, buttonSubmit?: string, cancelCallback?: () => void) => {
@@ -91,12 +97,16 @@ export const generateMessageQuestion = (type: string, title: string, subtitle: s
91
97
  callback: callback,
92
98
  buttonSubmit: buttonSubmit,
93
99
  cancelCallback: cancelCallback
94
- }
95
- return result
100
+ };
101
+ return result;
96
102
  }
97
103
 
98
104
  export const currencyNumber = (value: number) => {
99
- if(value === null) return value
100
- else if(typeof value == 'number') return value.toLocaleString('id-ID', {style: 'currency', currency: 'IDR', minimumFractionDigits: 0})
101
- else return value
105
+ if (value === null) {
106
+ return value;
107
+ } else if (typeof value == 'number') {
108
+ return value.toLocaleString('id-ID', {style: 'currency', currency: 'IDR', minimumFractionDigits: 0});
109
+ } else {
110
+ return value;
111
+ }
102
112
  }