@sydsoft/base 1.47.0 → 1.49.0

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.
Files changed (151) hide show
  1. package/README.md +8 -1
  2. package/{dist/esm → _dist}/_lib/baseFunctions.d.ts +0 -1
  3. package/{dist/esm → _dist}/_lib/baseFunctions.js +25 -38
  4. package/{dist/esm → _dist}/_lib/inputMask.js +66 -69
  5. package/{dist/esm → _dist}/_lib/listFunctions.js +12 -13
  6. package/_dist/_lib/storage/cookies.d.ts +4 -0
  7. package/_dist/_lib/storage/cookies.js +33 -0
  8. package/_dist/_lib/storage/encData.js +41 -0
  9. package/{dist/esm → _dist}/_lib/storage/localStorage.js +10 -10
  10. package/{dist/esm → _dist}/_lib/storage/sessionStorage.js +10 -10
  11. package/{dist/esm → _dist}/_lib/useInterval.js +5 -5
  12. package/{dist/esm → _dist}/alert/index.js +28 -30
  13. package/_dist/box/Box.js +14 -0
  14. package/_dist/box/BoxContent.js +5 -0
  15. package/_dist/box/BoxFooter.js +10 -0
  16. package/_dist/box/BoxHeader.js +10 -0
  17. package/_dist/countDown/index.js +92 -0
  18. package/{dist/esm → _dist}/dateTime/index.js +25 -31
  19. package/_dist/form/Button.js +82 -0
  20. package/_dist/form/Checkbox.js +22 -0
  21. package/_dist/form/Dialog.js +53 -0
  22. package/_dist/form/Form.js +10 -0
  23. package/_dist/form/FormOlustur.js +50 -0
  24. package/{dist/esm → _dist}/form/Input.js +57 -56
  25. package/_dist/form/Label.js +7 -0
  26. package/{dist/esm → _dist}/form/SearchableInput.d.ts +0 -1
  27. package/_dist/form/SearchableInput.js +260 -0
  28. package/_dist/form/UploadBase.js +84 -0
  29. package/_dist/grid/index.js +96 -0
  30. package/{dist/esm → _dist}/icon/icons.js +1 -1
  31. package/{dist/esm → _dist}/icon/index.d.ts +1 -1
  32. package/_dist/icon/index.js +34 -0
  33. package/_dist/menu/index.js +50 -0
  34. package/_dist/modal/index.js +64 -0
  35. package/{dist/esm → _dist}/popover/index.js +100 -100
  36. package/_dist/tooltip/index.js +202 -0
  37. package/_lib/baseFunctions.ts +94 -0
  38. package/_lib/inputMask.ts +257 -0
  39. package/_lib/listFunctions.ts +106 -0
  40. package/_lib/storage/cookies.ts +39 -0
  41. package/_lib/storage/encData.ts +41 -0
  42. package/_lib/storage/localStorage.ts +67 -0
  43. package/_lib/storage/sessionStorage.ts +67 -0
  44. package/_lib/useInterval.ts +30 -0
  45. package/alert/index.module.css +119 -0
  46. package/alert/index.tsx +131 -0
  47. package/box/Box.module.css +153 -0
  48. package/box/Box.tsx +33 -0
  49. package/box/BoxContent.tsx +18 -0
  50. package/box/BoxFooter.tsx +25 -0
  51. package/box/BoxHeader.tsx +46 -0
  52. package/box/index.ts +10 -0
  53. package/countDown/index.tsx +116 -0
  54. package/dateTime/index.ts +79 -0
  55. package/form/Button.tsx +143 -0
  56. package/form/Checkbox.tsx +48 -0
  57. package/form/Dialog.tsx +109 -0
  58. package/form/Form.tsx +19 -0
  59. package/form/FormOlustur.tsx +105 -0
  60. package/form/Input.tsx +364 -0
  61. package/form/Label.tsx +20 -0
  62. package/form/SearchableInput.tsx +406 -0
  63. package/form/UploadBase.tsx +133 -0
  64. package/form/index.ts +10 -0
  65. package/form/styles/Button.module.css +145 -0
  66. package/form/styles/Input.module.css +221 -0
  67. package/form/styles/Label.module.css +31 -0
  68. package/form/styles/SearchableInput.module.css +80 -0
  69. package/global.d.ts +9 -0
  70. package/grid/index.module.css +805 -0
  71. package/grid/index.tsx +171 -0
  72. package/icon/icons.tsx +33 -0
  73. package/icon/index.tsx +95 -0
  74. package/icon/mui.tsx +5932 -0
  75. package/index.ts +21 -0
  76. package/menu/index.module.css +92 -0
  77. package/menu/index.tsx +143 -0
  78. package/modal/index.module.css +77 -0
  79. package/modal/index.tsx +106 -0
  80. package/npm_recovery_codes.txt +5 -0
  81. package/package.json +18 -11
  82. package/popover/index.module.css +89 -0
  83. package/popover/index.tsx +392 -0
  84. package/tooltip/index.tsx +216 -0
  85. package/tsconfig.json +24 -0
  86. package/dist/esm/_lib/storage/cookies.d.ts +0 -4
  87. package/dist/esm/_lib/storage/cookies.js +0 -34
  88. package/dist/esm/_lib/storage/encData.js +0 -43
  89. package/dist/esm/box/Box.js +0 -15
  90. package/dist/esm/box/BoxContent.js +0 -7
  91. package/dist/esm/box/BoxFooter.js +0 -8
  92. package/dist/esm/box/BoxHeader.js +0 -9
  93. package/dist/esm/countDown/index.js +0 -97
  94. package/dist/esm/form/Button.js +0 -76
  95. package/dist/esm/form/Checkbox.js +0 -23
  96. package/dist/esm/form/Dialog.js +0 -40
  97. package/dist/esm/form/Form.js +0 -12
  98. package/dist/esm/form/FormOlustur.js +0 -52
  99. package/dist/esm/form/Label.js +0 -9
  100. package/dist/esm/form/SearchableInput.js +0 -272
  101. package/dist/esm/form/UploadBase.js +0 -86
  102. package/dist/esm/grid/index.js +0 -97
  103. package/dist/esm/icon/index.js +0 -26
  104. package/dist/esm/menu/index.js +0 -52
  105. package/dist/esm/modal/index.js +0 -66
  106. package/dist/esm/tooltip/index.js +0 -119
  107. /package/{dist/esm → _dist}/_lib/inputMask.d.ts +0 -0
  108. /package/{dist/esm → _dist}/_lib/listFunctions.d.ts +0 -0
  109. /package/{dist/esm → _dist}/_lib/storage/encData.d.ts +0 -0
  110. /package/{dist/esm → _dist}/_lib/storage/localStorage.d.ts +0 -0
  111. /package/{dist/esm → _dist}/_lib/storage/sessionStorage.d.ts +0 -0
  112. /package/{dist/esm → _dist}/_lib/useInterval.d.ts +0 -0
  113. /package/{dist/esm → _dist}/alert/index.d.ts +0 -0
  114. /package/{dist/esm → _dist}/alert/index.module.css +0 -0
  115. /package/{dist/esm → _dist}/box/Box.d.ts +0 -0
  116. /package/{dist/esm → _dist}/box/Box.module.css +0 -0
  117. /package/{dist/esm → _dist}/box/BoxContent.d.ts +0 -0
  118. /package/{dist/esm → _dist}/box/BoxFooter.d.ts +0 -0
  119. /package/{dist/esm → _dist}/box/BoxHeader.d.ts +0 -0
  120. /package/{dist/esm → _dist}/box/index.d.ts +0 -0
  121. /package/{dist/esm → _dist}/box/index.js +0 -0
  122. /package/{dist/esm → _dist}/countDown/index.d.ts +0 -0
  123. /package/{dist/esm → _dist}/dateTime/index.d.ts +0 -0
  124. /package/{dist/esm → _dist}/form/Button.d.ts +0 -0
  125. /package/{dist/esm → _dist}/form/Checkbox.d.ts +0 -0
  126. /package/{dist/esm → _dist}/form/Dialog.d.ts +0 -0
  127. /package/{dist/esm → _dist}/form/Form.d.ts +0 -0
  128. /package/{dist/esm → _dist}/form/FormOlustur.d.ts +0 -0
  129. /package/{dist/esm → _dist}/form/Input.d.ts +0 -0
  130. /package/{dist/esm → _dist}/form/Label.d.ts +0 -0
  131. /package/{dist/esm → _dist}/form/UploadBase.d.ts +0 -0
  132. /package/{dist/esm → _dist}/form/index.d.ts +0 -0
  133. /package/{dist/esm → _dist}/form/index.js +0 -0
  134. /package/{dist/esm → _dist}/form/styles/Button.module.css +0 -0
  135. /package/{dist/esm → _dist}/form/styles/Input.module.css +0 -0
  136. /package/{dist/esm → _dist}/form/styles/Label.module.css +0 -0
  137. /package/{dist/esm → _dist}/form/styles/SearchableInput.module.css +0 -0
  138. /package/{dist/esm → _dist}/grid/index.d.ts +0 -0
  139. /package/{dist/esm → _dist}/grid/index.module.css +0 -0
  140. /package/{dist/esm → _dist}/icon/icons.d.ts +0 -0
  141. /package/{dist/esm → _dist}/icon/mui.d.ts +0 -0
  142. /package/{dist/esm → _dist}/icon/mui.js +0 -0
  143. /package/{dist/esm → _dist}/index.d.ts +0 -0
  144. /package/{dist/esm → _dist}/index.js +0 -0
  145. /package/{dist/esm → _dist}/menu/index.d.ts +0 -0
  146. /package/{dist/esm → _dist}/menu/index.module.css +0 -0
  147. /package/{dist/esm → _dist}/modal/index.d.ts +0 -0
  148. /package/{dist/esm → _dist}/modal/index.module.css +0 -0
  149. /package/{dist/esm → _dist}/popover/index.d.ts +0 -0
  150. /package/{dist/esm → _dist}/popover/index.module.css +0 -0
  151. /package/{dist/esm → _dist}/tooltip/index.d.ts +0 -0
@@ -0,0 +1,41 @@
1
+ import { isDev } from "../baseFunctions";
2
+
3
+ const encDecDataKeys: number[] = [3, 5, 8, 11, 15, 22];
4
+
5
+ export const encData = (data: object | string | number, keys: number[] = encDecDataKeys) => {
6
+ try {
7
+ const newJSON = { data: data };
8
+ const utf8Data = unescape(encodeURIComponent(JSON.stringify(newJSON))); // Dizeyi UTF-8'e dönüştür
9
+ let newData = btoa(utf8Data);
10
+ keys.map((value) => {
11
+ const randomChar = String.fromCharCode(Math.floor(Math.random() * (122 - 97 + 1)) + 97);
12
+ newData = newData.slice(0, value) + randomChar + newData.slice(value);
13
+ });
14
+ return newData;
15
+ } catch (e) {
16
+ isDev && console.log("ERROR => encData =>", e);
17
+ return "";
18
+ }
19
+ };
20
+
21
+ export const decData = (data: string, keys: number[] = encDecDataKeys) => {
22
+ try {
23
+ let decode = data;
24
+ keys.map((value, index) => {
25
+ const prevValue = keys[index - 1];
26
+ if (!prevValue) {
27
+ decode = decode.slice(0, value) + decode.slice(value + 1);
28
+ } else {
29
+ decode = decode.slice(0, value - index) + decode.slice(value - index + 1);
30
+ }
31
+ });
32
+ const decodedString = atob(decode);
33
+ const utf8DecodedString = decodeURIComponent(escape(decodedString));
34
+
35
+ const parse = JSON.parse(utf8DecodedString);
36
+ return parse?.data ?? "";
37
+ } catch (e) {
38
+ isDev && console.log("ERROR => decData =>", e);
39
+ return "";
40
+ }
41
+ };
@@ -0,0 +1,67 @@
1
+ import { decData, encData } from './encData';
2
+
3
+ import { isDev } from '../baseFunctions';
4
+
5
+ const storageAvailable = typeof Storage === 'undefined' || !window.localStorage ? false : true;
6
+
7
+ export const setLocalStorage = (key: string, value: any) => {
8
+ if (!storageAvailable) return false;
9
+ try {
10
+ localStorage.setItem(key, encData(value));
11
+ return true;
12
+ } catch (e) {
13
+ isDev && console.log('ERROR => localStorage =>', e);
14
+ return false;
15
+ }
16
+ };
17
+
18
+ export const getLocalStorage = (key: string) => {
19
+ if (!storageAvailable) return false;
20
+ try {
21
+ const saved = localStorage.getItem(key);
22
+ return saved ? decData(saved) : null;
23
+ } catch (e) {
24
+ isDev && console.log('ERROR => localStorage =>', e);
25
+ return null;
26
+ }
27
+ };
28
+ export const removeLocalStorage = (key: string) => {
29
+ if (!storageAvailable) return false;
30
+ try {
31
+ localStorage.removeItem(key);
32
+ return true;
33
+ } catch (e) {
34
+ isDev && console.log('ERROR => localStorage =>', e);
35
+ return false;
36
+ }
37
+ };
38
+
39
+ export const clearLocalStorage = () => {
40
+ if (!storageAvailable) return false;
41
+ try {
42
+ localStorage.clear();
43
+ return true;
44
+ } catch (e) {
45
+ isDev && console.log('ERROR => localStorage =>', e);
46
+ return false;
47
+ }
48
+ };
49
+
50
+ // Tüm localStorage anahtarlarını getir
51
+ export const getLocalStorageAllKeys = (): string[] => {
52
+ if (!storageAvailable) return [];
53
+ return Object.keys(localStorage);
54
+ };
55
+
56
+ // Tüm localStorage boyutunu getir
57
+ export const getLocalStorageSize = (): number => {
58
+ if (!storageAvailable) return 0;
59
+
60
+ let total = 0;
61
+ for (const key in localStorage) {
62
+ if (localStorage.hasOwnProperty(key)) {
63
+ total += localStorage[key].length + key.length;
64
+ }
65
+ }
66
+ return total;
67
+ };
@@ -0,0 +1,67 @@
1
+ import { decData, encData } from "./encData";
2
+
3
+ import { isDev } from "../baseFunctions";
4
+
5
+ const storageAvailable = typeof Storage === "undefined" || !window.sessionStorage ? false : true;
6
+
7
+ export const setSessionStorage = (key: string, value: any) => {
8
+ if (!storageAvailable) return false;
9
+ try {
10
+ sessionStorage.setItem(key, encData(value));
11
+ return true;
12
+ } catch (e) {
13
+ isDev && console.log("ERROR => SessionStorage =>", e);
14
+ return false;
15
+ }
16
+ };
17
+
18
+ export const getSessionStorage = (key: string) => {
19
+ if (!storageAvailable) return false;
20
+ try {
21
+ const saved = sessionStorage.getItem(key);
22
+ return saved ? decData(saved) : null;
23
+ } catch (e) {
24
+ isDev && console.log("ERROR => SessionStorage =>", e);
25
+ return null;
26
+ }
27
+ };
28
+ export const removeSessionStorage = (key: string) => {
29
+ if (!storageAvailable) return false;
30
+ try {
31
+ sessionStorage.removeItem(key);
32
+ return true;
33
+ } catch (e) {
34
+ isDev && console.log("ERROR => SessionStorage =>", e);
35
+ return false;
36
+ }
37
+ };
38
+
39
+ export const clearSessionStorage = () => {
40
+ if (!storageAvailable) return false;
41
+ try {
42
+ sessionStorage.clear();
43
+ return true;
44
+ } catch (e) {
45
+ isDev && console.log("ERROR => SessionStorage =>", e);
46
+ return false;
47
+ }
48
+ };
49
+
50
+ // Tüm SessionStorage anahtarlarını getir
51
+ export const getSessionStorageAllKeys = (): string[] => {
52
+ if (!storageAvailable) return [];
53
+ return Object.keys(sessionStorage);
54
+ };
55
+
56
+ // Tüm SessionStorage boyutunu getir
57
+ export const getSessionStorageSize = (): number => {
58
+ if (!storageAvailable) return 0;
59
+
60
+ let total = 0;
61
+ for (const key in sessionStorage) {
62
+ if (sessionStorage.hasOwnProperty(key)) {
63
+ total += sessionStorage[key].length + key.length;
64
+ }
65
+ }
66
+ return total;
67
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) 2023
3
+ * @author: izzetseydaoglu
4
+ * @last-modified: 29.01.2024 04:09
5
+ */
6
+
7
+ // source: https://overreacted.io/making-setinterval-declarative-with-react-hooks/
8
+
9
+ import { useEffect, useRef } from "react";
10
+
11
+ export function useInterval(callback: any, delay: any) {
12
+ const savedCallback = useRef<any>(null);
13
+
14
+ // Remember the latest callback.
15
+ useEffect(() => {
16
+ savedCallback.current = callback;
17
+ }, [callback]);
18
+
19
+ // Set up the interval.
20
+ useEffect(() => {
21
+ function tick() {
22
+ savedCallback && savedCallback.current && savedCallback.current();
23
+ }
24
+
25
+ if (delay !== null) {
26
+ const id = setInterval(tick, delay);
27
+ return () => clearInterval(id);
28
+ }
29
+ }, [delay]);
30
+ }
@@ -0,0 +1,119 @@
1
+ .message {
2
+ flex: 1;
3
+ }
4
+
5
+ .close {
6
+ position: absolute;
7
+ top: 0;
8
+ left: 0;
9
+ width: 17px;
10
+ height: 17px;
11
+ border-radius: 50%;
12
+ padding: 3px;
13
+ display: flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ font-size: 9px;
17
+ letter-spacing: 0;
18
+ transform: translate(-50%, -50%) scale(0);
19
+ transition: ease-in-out 0.2s;
20
+ border: 1px #97979740 solid;
21
+ box-shadow: 1px 1px 4px 0 #000000a6;
22
+ cursor: pointer;
23
+ background: inherit;
24
+ }
25
+ .close:hover {
26
+ zoom: 1.1;
27
+ }
28
+ .salert:hover .close {
29
+ transform: translate(-50%, -50%) scale(1);
30
+ }
31
+ .salert {
32
+ position: relative;
33
+ min-width: 50px;
34
+ width: fit-content;
35
+ margin: 6px 0 6px auto;
36
+ padding: 10px 15px;
37
+ border-radius: 5px;
38
+ cursor: default;
39
+ background: #1f1f1f;
40
+ color: rgba(255, 255, 255, 0.93);
41
+ border: 1px #97979740 solid;
42
+ box-shadow: 1px 1px 4px 0 #000000a6;
43
+ display: flex;
44
+ flex-direction: row;
45
+ align-items: center;
46
+ transition: transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms;
47
+ animation: show 0.3s;
48
+ font-family: inherit;
49
+ font-size: 1rem;
50
+ line-height: 1.5;
51
+ }
52
+
53
+ .error {
54
+ background: rgb(211, 47, 47);
55
+ background: linear-gradient(
56
+ 135deg,
57
+ rgba(211, 47, 47, 1) 0%,
58
+ rgba(211, 47, 47, 0.8) 70%
59
+ );
60
+ color: rgba(255, 255, 255, 0.93);
61
+ }
62
+
63
+ .success {
64
+ background: rgb(67, 160, 71);
65
+ background: linear-gradient(
66
+ 135deg,
67
+ rgba(67, 160, 71, 1) 0%,
68
+ rgba(67, 160, 71, 0.8) 70%
69
+ );
70
+ color: rgba(255, 255, 255, 0.93);
71
+ }
72
+
73
+ .info {
74
+ background: rgb(13, 141, 189);
75
+ background: linear-gradient(
76
+ 135deg,
77
+ rgba(13, 141, 189, 1) 0%,
78
+ rgba(13, 141, 189, 0.8) 70%
79
+ );
80
+ color: rgba(255, 255, 255, 0.93);
81
+ }
82
+
83
+ .warning {
84
+ background: rgb(217, 142, 4);
85
+ background: linear-gradient(
86
+ 135deg,
87
+ rgba(217, 142, 4, 1) 0%,
88
+ rgba(217, 142, 4, 0.8) 70%
89
+ );
90
+ color: rgba(255, 255, 255, 0.93);
91
+ }
92
+
93
+ .loading {
94
+ background: linear-gradient(
95
+ 60deg,
96
+ rgb(15 33 34) 0%,
97
+ rgba(0, 172, 193, 1) 100%
98
+ );
99
+ color: rgba(255, 255, 255, 0.93);
100
+ animation: waves 50s infinite linear;
101
+ }
102
+
103
+ @keyframes show {
104
+ from {
105
+ transform: translateX(200%);
106
+ }
107
+ to {
108
+ transform: translateX(0);
109
+ }
110
+ }
111
+
112
+ @keyframes waves {
113
+ from {
114
+ background-position: 0;
115
+ }
116
+ to {
117
+ background-position: 100vw 0;
118
+ }
119
+ }
@@ -0,0 +1,131 @@
1
+ import React, { useEffect } from "react";
2
+
3
+ import { createRoot } from "react-dom/client";
4
+ import styles from "./index.module.css";
5
+
6
+ const sAlertTimeout: any[] = [];
7
+
8
+ export type typeAlert = {
9
+ defaultTimer?: string;
10
+ defaultErrorTimer?: string;
11
+ defaultSuccessTimer?: string;
12
+ };
13
+
14
+ export const Alert = ({ defaultTimer = "5000", defaultErrorTimer = "10000", defaultSuccessTimer = "5000" }: typeAlert) => {
15
+ useEffect(() => {
16
+ if (typeof window === "undefined") return;
17
+ const divCheck = document.getElementById("salert");
18
+ if (!divCheck) {
19
+ // let div = document.createElement('div') as HTMLDivElement
20
+ const div = document.createElement("div");
21
+ div.setAttribute("id", "salert");
22
+ div.setAttribute("defaultTimer", defaultTimer);
23
+ div.setAttribute("defaultErrorTimer", defaultErrorTimer);
24
+ div.setAttribute("defaultSuccessTimer", defaultSuccessTimer);
25
+ const alertStyle = [
26
+ "position: fixed",
27
+ "bottom: 0",
28
+ "right: 0",
29
+ "max-width: 300px",
30
+ "max-height: 600px",
31
+ "overflow-x: hidden",
32
+ "padding: 15px",
33
+ "display: flex",
34
+ "flex-direction: column",
35
+ "z-index: 9999999"
36
+ ];
37
+ div.setAttribute("style", alertStyle.join(";"));
38
+ document.body.appendChild(div);
39
+ }
40
+ }, []);
41
+
42
+ return null;
43
+ };
44
+
45
+ type typeAddAlert = {
46
+ type: "error" | "success" | "warning" | "info" | "loading";
47
+ message: string;
48
+ timer?: number | boolean;
49
+ style?: React.CSSProperties;
50
+ };
51
+
52
+ export const alert_add = ({ type, message, style, timer }: typeAddAlert) => {
53
+ if (typeof window === "undefined") return false;
54
+ const mainDiv = document.getElementById("salert");
55
+ if (mainDiv) {
56
+ const alert = document.createElement("div");
57
+ mainDiv.prepend(alert);
58
+
59
+ const onClose = () => {
60
+ if (mainDiv && alert && mainDiv.contains(alert)) mainDiv.removeChild(alert);
61
+ };
62
+ const root = createRoot(alert!);
63
+ const Component = (
64
+ <div className={`${styles.salert} ${styles[type]}`} style={style}>
65
+ <div className={styles.message} dangerouslySetInnerHTML={{ __html: message }} />
66
+ <div className={styles.close} onClick={onClose}>
67
+
68
+ </div>
69
+ </div>
70
+ );
71
+ root.render(Component);
72
+
73
+ const defaultTimer = mainDiv.getAttribute("defaulttimer") ?? "5000";
74
+ const defaultErrorTimer = mainDiv.getAttribute("defaulterrortimer") ?? "10000";
75
+ const defaultSuccessTimer = mainDiv.getAttribute("defaultsuccesstimer") ?? "5000";
76
+
77
+ const timerFilled = typeof timer === "number" && timer > 0;
78
+
79
+ let newTimer = timerFilled ? timer : defaultTimer;
80
+
81
+ switch (type) {
82
+ case "error":
83
+ newTimer = timerFilled ? timer : defaultErrorTimer;
84
+ break;
85
+ case "success":
86
+ newTimer = timerFilled ? timer : defaultSuccessTimer;
87
+ break;
88
+ default:
89
+ break;
90
+ }
91
+ newTimer = newTimer as number;
92
+
93
+ if (typeof timer !== "boolean") {
94
+ // False gelmişse sabit kalsın
95
+ if (newTimer > 0) {
96
+ const timeout = setTimeout(() => onClose(), newTimer);
97
+ sAlertTimeout.push(timeout);
98
+ }
99
+ }
100
+
101
+ return alert;
102
+ }
103
+ return null;
104
+ };
105
+
106
+ export const alert_remove = (alert: any): void => {
107
+ if (typeof window === "undefined" || !alert) return;
108
+ const mainDiv = document.getElementById("salert");
109
+ if (mainDiv && alert && mainDiv.contains(alert)) mainDiv.removeChild(alert);
110
+ return;
111
+ };
112
+
113
+ export const alert_clear = () => {
114
+ if (typeof window === "undefined") return false;
115
+ sAlertTimeout.map((id) => clearTimeout(id));
116
+ const mainDiv = document.getElementById("salert");
117
+ if (mainDiv) mainDiv.innerHTML = "";
118
+ return true;
119
+ };
120
+
121
+ export function alertCheck(response: any) {
122
+ if (response.data && response.data["alert"]) {
123
+ response.data["alert"].map(function (alert: any) {
124
+ alert_add({
125
+ type: alert.type,
126
+ message: alert.message,
127
+ timer: alert.timer
128
+ });
129
+ });
130
+ }
131
+ }
@@ -0,0 +1,153 @@
1
+ .sbox {
2
+ position: relative;
3
+ max-width: 100%;
4
+ background-color: #fff;
5
+ box-shadow: 0 2px 4px rgb(0 0 0 / 10%), 0 8px 16px rgb(0 0 0 / 10%);
6
+ border-radius: 8px;
7
+ overflow-y: auto;
8
+ }
9
+
10
+ .sbox h1,
11
+ .sbox h2,
12
+ .sbox h3,
13
+ .sbox h4,
14
+ .sbox h5,
15
+ .sbox h6 {
16
+ margin: 0;
17
+ padding: 0;
18
+ }
19
+
20
+ .content {
21
+ padding: 20px;
22
+ box-sizing: border-box;
23
+ overflow: auto;
24
+ }
25
+
26
+ .header,
27
+ .footer {
28
+ z-index: 1;
29
+ position: sticky;
30
+ padding: 12px 16px;
31
+ background: inherit;
32
+ }
33
+ .header {
34
+ top: 0;
35
+ border-bottom: 1px solid #00000020;
36
+ display: flex;
37
+ flex-direction: row;
38
+ justify-content: flex-start;
39
+ align-items: center;
40
+ gap: 10px;
41
+ /* margin: 10px 0 5px 0; */
42
+ }
43
+ .footer {
44
+ display: flex;
45
+ flex-direction: row;
46
+ flex-wrap: wrap;
47
+ align-items: center;
48
+ justify-content: flex-end;
49
+ gap: 10px;
50
+ bottom: 0;
51
+ border-top: 1px solid #00000020;
52
+ background-color: #f7f7f7;
53
+ }
54
+
55
+ .icon {
56
+ display: inline-flex;
57
+ align-items: center;
58
+ flex: 0 0 auto;
59
+ text-align: center;
60
+
61
+ }
62
+
63
+ .title {
64
+ flex: 1;
65
+ font-size: 1.1rem;
66
+ font-weight: 500;
67
+ line-height: 1.5;
68
+ }
69
+
70
+ .menu {
71
+ display: inline-flex;
72
+ flex: 0 0 auto;
73
+ align-items: center;
74
+ justify-content: center;
75
+ }
76
+ .menu > * {
77
+ margin: 0 3px;
78
+ }
79
+
80
+ .loading {
81
+ position: absolute;
82
+ top: 0;
83
+ left: 0;
84
+ width: 100%;
85
+ height: 100%;
86
+ background-color: #f4f7faa6;
87
+ overflow: hidden;
88
+ border-radius: inherit;
89
+ display: flex;
90
+ justify-content: center;
91
+ align-items: center;
92
+ z-index: 9999;
93
+ }
94
+
95
+ .loading::after {
96
+ position: absolute;
97
+ top: 0;
98
+ right: 0;
99
+ bottom: 0;
100
+ left: 0;
101
+ transform: translateX(-100%);
102
+ background: linear-gradient(90deg, rgb(183 190 199 / 2%) 0, rgb(182 190 198 / 19%) 20%, rgb(183 190 199 / 2%) 60%, rgb(184 192 200 / 1%));
103
+ animation: shimmer 2s infinite;
104
+ content: "";
105
+ }
106
+
107
+ .loading_spinner {
108
+ position: relative;
109
+ margin: 6px;
110
+ width: 24px;
111
+ height: 24px;
112
+ }
113
+ .loading_spinner:before {
114
+ position: absolute;
115
+ display: block;
116
+ content: "";
117
+ z-index: 12;
118
+ top: 3px;
119
+ left: 3px;
120
+ width: 30px;
121
+ height: 30px;
122
+ border-radius: 50%;
123
+ background-color: #fff;
124
+ }
125
+
126
+ .loading_spinner:after {
127
+ position: absolute;
128
+ display: block;
129
+ content: "";
130
+ z-index: 11;
131
+ width: 18px;
132
+ height: 18px;
133
+ border-radius: 200px 0 0;
134
+ background: linear-gradient(45deg, rgba(0, 0, 0, 0) 0, rgba(69, 154, 215, 1) 50%, rgba(69, 154, 215, 1) 100%);
135
+ animation: loading_spinner 0.5s linear infinite;
136
+ }
137
+
138
+ @keyframes shimmer {
139
+ 100% {
140
+ transform: translateX(100%);
141
+ }
142
+ }
143
+ @keyframes loading_spinner {
144
+ 0% {
145
+ transform-origin: 100% 100%;
146
+ transform: rotate(0deg);
147
+ }
148
+
149
+ 100% {
150
+ transform-origin: 100% 100%;
151
+ transform: rotate(360deg);
152
+ }
153
+ }
package/box/Box.tsx ADDED
@@ -0,0 +1,33 @@
1
+ import React, { memo, useEffect, useRef, useState } from "react";
2
+
3
+ import styles from "./Box.module.css";
4
+
5
+ type Props = {
6
+ children: React.ReactNode;
7
+ className?: string;
8
+ style?: React.CSSProperties;
9
+ loading?: boolean;
10
+ };
11
+
12
+ export const Box = memo(function MemoFunction({ children, className, style, loading = false }: Props) {
13
+ const boxRef = useRef<HTMLDivElement>(null);
14
+
15
+ const [hasContent, setHasContent] = useState(false);
16
+ useEffect(() => {
17
+ if (!boxRef.current) return;
18
+ const found = boxRef.current.querySelector(".sbox_content");
19
+ setHasContent(!!found);
20
+ }, [children]);
21
+
22
+ return (
23
+ <div ref={boxRef} className={`sbox ${styles.sbox} ${className || ""}`} style={style}>
24
+ {(hasContent && children) || <div className={styles.content}>{children}</div>}
25
+
26
+ {loading && (
27
+ <div className={styles.loading}>
28
+ <div className={styles.loading_spinner} />
29
+ </div>
30
+ )}
31
+ </div>
32
+ );
33
+ });
@@ -0,0 +1,18 @@
1
+ import React, { ReactNode } from "react";
2
+
3
+ import styles from "./Box.module.css";
4
+
5
+ interface Props {
6
+ className?: string;
7
+ style?: React.CSSProperties;
8
+ padding?: number;
9
+ children?: ReactNode;
10
+ }
11
+
12
+ export const BoxContent = ({ className, style, padding, children }: Props) => {
13
+ return (
14
+ <div className={`${styles.content} sbox_content ${className || ""}`} style={{ ...style, padding }}>
15
+ {children}
16
+ </div>
17
+ );
18
+ };
@@ -0,0 +1,25 @@
1
+ import React, { memo } from "react";
2
+
3
+ import styles from "./Box.module.css";
4
+
5
+ interface Props {
6
+ children: React.ReactNode;
7
+ className?: string;
8
+ style?: React.CSSProperties;
9
+ marginTop?: number;
10
+ align?: "flex-start" | "center" | "flex-end" | "stretch";
11
+ }
12
+
13
+ export const BoxFooter = memo(function FunctionMemo({ children, className, style, align, marginTop }: Props) {
14
+ return (
15
+ <div
16
+ className={`sbox_footer ${styles.footer} ${className || ""}`}
17
+ style={{
18
+ marginTop,
19
+ justifyContent: align,
20
+ ...style
21
+ }}>
22
+ {children}
23
+ </div>
24
+ );
25
+ });