@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,46 @@
1
+ import React, { ReactNode, memo } from 'react';
2
+
3
+ import styles from './Box.module.css';
4
+
5
+ interface Props {
6
+ children?: ReactNode;
7
+ className?: string;
8
+ title?: string | ReactNode;
9
+ icon?: ReactNode;
10
+ menu?: ReactNode;
11
+ mainStyle?: React.CSSProperties;
12
+ iconStyle?: React.CSSProperties;
13
+ titleStyle?: React.CSSProperties;
14
+ menuStyle?: React.CSSProperties;
15
+ component?: any;
16
+ marginBottom?: number;
17
+ }
18
+
19
+ export const BoxHeader = memo(function FunctionMemo({ children, className, title, icon, menu, mainStyle, iconStyle, titleStyle, menuStyle, marginBottom, component = 'div' }: Props) {
20
+ const Comp = component;
21
+ return (
22
+ <div
23
+ className={`sbox_header ${styles.header} ${className || ''}`}
24
+ style={{
25
+ marginBottom,
26
+ ...mainStyle
27
+ }}
28
+ >
29
+ {icon && (
30
+ <div className={styles.icon} style={iconStyle}>
31
+ {icon}
32
+ </div>
33
+ )}
34
+
35
+ <Comp className={`sbox_title ${styles.title}`} style={titleStyle}>
36
+ {children || title}
37
+ </Comp>
38
+
39
+ {menu && (
40
+ <div className={styles.menu} style={menuStyle}>
41
+ {menu}
42
+ </div>
43
+ )}
44
+ </div>
45
+ );
46
+ });
package/box/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) 2023
3
+ * @author: izzetseydaoglu
4
+ * @last-modified: 29.01.2024 02:41
5
+ */
6
+
7
+ export * from "./Box";
8
+ export * from './BoxContent';
9
+ export * from './BoxFooter';
10
+ export * from './BoxHeader';
@@ -0,0 +1,116 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+
3
+ import React from 'react';
4
+ import { useInterval } from '../_lib/useInterval';
5
+
6
+ type Props = {
7
+ targetTime: number | string; // 30 | "2022-01-20 22:35" | veya direkt microtime ;
8
+ timerType?: 'countdown' | 'datetime';
9
+ speed?: number;
10
+ countType?: 'seconds' | 'minutes:seconds' | 'hours:minutes:seconds' | 'days:hours:minutes:seconds';
11
+ hide?: boolean;
12
+ onComplete?: () => void;
13
+ getStatus?: ({ days, hours, minutes, seconds, timer }: any) => void;
14
+ autoStart?: boolean;
15
+ };
16
+
17
+ export const useCountDown = ({ autoStart = false, onComplete, getStatus, targetTime, timerType = 'countdown', countType = 'seconds', speed = 1000, hide }: Props) => {
18
+ const refCountDownRender = useRef<any>(null);
19
+ const [enabled, setEnabled] = useState(timerType === 'datetime' || autoStart);
20
+ const [timer, setTimer] = useState<any>(0);
21
+ const [timerSpeed, setTimerSpeed] = useState<number>(typeof speed === 'number' && speed > 0 ? speed : 1000);
22
+
23
+ useEffect(() => prepareTimer(targetTime), [targetTime]);
24
+
25
+ useEffect(() => {
26
+ if (!hide) render();
27
+ }, [timer]);
28
+
29
+ useInterval(
30
+ () => {
31
+ if (enabled) {
32
+ if (timer <= 1) {
33
+ stopCountDown();
34
+ } else {
35
+ setTimer(timer - 1);
36
+ }
37
+ }
38
+ },
39
+ enabled ? timerSpeed : null
40
+ );
41
+
42
+ const prepareTimer = (timeORstring: string | number) => {
43
+ if (timerType === 'datetime') {
44
+ setTimer(Math.floor((new Date(timeORstring).getTime() - new Date().getTime()) / 1000));
45
+ setEnabled(true);
46
+ } else {
47
+ setTimer(timeORstring);
48
+ }
49
+ };
50
+
51
+ const stopCountDown = () => {
52
+ setTimer(0);
53
+ setEnabled(false);
54
+ if ((enabled && onComplete) || (timerType === 'datetime' && onComplete)) {
55
+ onComplete();
56
+ }
57
+ };
58
+
59
+ const padNumber = (num: number, padLength = 2, padString = '0') => (typeof targetTime === 'number' && targetTime < 10 ? num : String(num).padStart(padLength, padString));
60
+
61
+ const render = () => {
62
+ let days = 0,
63
+ hours = 0,
64
+ minutes = 0,
65
+ seconds = timer;
66
+ if (countType === 'minutes:seconds') {
67
+ minutes = Math.floor(seconds / 60);
68
+ seconds -= minutes * 60;
69
+ } else if (countType === 'hours:minutes:seconds') {
70
+ hours = Math.floor(seconds / (60 * 60));
71
+ seconds -= hours * 60 * 60;
72
+ minutes = Math.floor(seconds / 60);
73
+ seconds -= minutes * 60;
74
+ } else if (countType === 'days:hours:minutes:seconds') {
75
+ days = Math.floor(seconds / (60 * 60 * 24));
76
+ seconds -= days * 60 * 60 * 24;
77
+ hours = Math.floor(seconds / (60 * 60));
78
+ seconds -= hours * 60 * 60;
79
+ minutes = Math.floor(seconds / 60);
80
+ seconds -= minutes * 60;
81
+ }
82
+
83
+ seconds = Math.floor(seconds);
84
+
85
+ if (getStatus && timer > 0) getStatus({ days, hours, minutes, seconds, timer });
86
+
87
+ if (refCountDownRender.current) {
88
+ const getPadValues = (div: any) => {
89
+ const length = div.dataset.padlength || 2;
90
+ const string = div.dataset.padstring || '0';
91
+ return { length, string };
92
+ };
93
+
94
+ const divGun = refCountDownRender.current.querySelector("[data-name='days']");
95
+ if (divGun) divGun.innerHTML = padNumber(days, getPadValues(divGun).length, getPadValues(divGun).string).toString();
96
+
97
+ const divSaat = refCountDownRender.current.querySelector("[data-name='hours']");
98
+ if (divSaat) divSaat.innerHTML = padNumber(hours, getPadValues(divSaat).length, getPadValues(divSaat).string).toString();
99
+
100
+ const divDakika = refCountDownRender.current.querySelector("[data-name='minutes']");
101
+ if (divDakika) divDakika.innerHTML = padNumber(minutes, getPadValues(divDakika).length, getPadValues(divDakika).string).toString();
102
+
103
+ const divSaniye = refCountDownRender.current.querySelector("[data-name='seconds']");
104
+ if (divSaniye) divSaniye.innerHTML = padNumber(seconds, getPadValues(divSaniye).length, getPadValues(divSaniye).string).toString();
105
+ }
106
+ };
107
+
108
+ return {
109
+ ComponentCountDown: (children: any) => (hide ? null : React.cloneElement(children, { ref: refCountDownRender })),
110
+ startCountDown: () => setEnabled(true),
111
+ stopCountDown: () => setEnabled(false),
112
+ setTargetTime: (targetTime: number | string) => prepareTimer(targetTime),
113
+ setTimerSpeed: (timerSpeed: number) => setTimerSpeed(timerSpeed),
114
+ getChildrenRef: () => refCountDownRender.current || null
115
+ };
116
+ };
@@ -0,0 +1,79 @@
1
+ export default class dateTime {
2
+ private datetime: Date | string;
3
+ private resut_format: string = "y-m-d h:i:s";
4
+
5
+ constructor(datetime: Date | string | null = null, format: string = "y-m-d h:i:s") {
6
+ this.format(format);
7
+ this.datetime = datetime !== "0000-00-00 00:00:00" && datetime !== "0000-00-00" && datetime ? datetime : new Date().toISOString(); // GMT ekli halde
8
+ return this;
9
+ }
10
+
11
+ public addDays(days: number) {
12
+ const datetime = new Date(this.datetime);
13
+ datetime.setDate(datetime.getDate() + days);
14
+ this.datetime = datetime.toISOString();
15
+ return this;
16
+ }
17
+
18
+ private parse() {
19
+ const datetime = new Date(this.datetime);
20
+ const monthNames = ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"];
21
+ const dayNames = ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"];
22
+ return {
23
+ y: datetime.getFullYear().toString(),
24
+ m: (datetime.getMonth() + 1).toString().padStart(2, "0"),
25
+ d: datetime.getDate().toString().padStart(2, "0"),
26
+ h: datetime.getHours().toString().padStart(2, "0"),
27
+ i: datetime.getMinutes().toString().padStart(2, "0"),
28
+ s: datetime.getSeconds().toString().padStart(2, "0"),
29
+ ms: (datetime.getMilliseconds() / 10).toFixed(0).toString().padStart(2, "0"),
30
+ z: (datetime.getTimezoneOffset() / 60).toString(),
31
+ // TAM STRING ICEREN IFADELER SONA EKLENMELI
32
+ TAMAY: monthNames[datetime.getMonth()],
33
+ TAMGUN: dayNames[datetime.getDay()]
34
+ };
35
+ }
36
+
37
+ public getResult() {
38
+ const parse: any = this.parse();
39
+ let result = this.resut_format;
40
+ result = result.replace(new RegExp("y", "g"), parse.y.toString());
41
+ result = result.replace(new RegExp("m", "g"), parse.m.toString());
42
+ result = result.replace(new RegExp("d", "g"), parse.d.toString());
43
+ result = result.replace(new RegExp("h", "g"), parse.h.toString());
44
+ result = result.replace(new RegExp("i", "g"), parse.i.toString());
45
+ result = result.replace(new RegExp("s", "g"), parse.s.toString());
46
+ result = result.replace(new RegExp("ms", "g"), parse.ms.toString());
47
+ result = result.replace(new RegExp("z", "g"), parse.z.toString());
48
+ result = result.replace(new RegExp("TAMAY", "g"), parse.TAMAY.toString());
49
+ result = result.replace(new RegExp("TAMGUN", "g"), parse.TAMGUN.toString());
50
+ return result;
51
+ }
52
+
53
+ public format(format: string = "y-m-d h:i:s") {
54
+ this.resut_format = format;
55
+ return this;
56
+ }
57
+
58
+ public today() {
59
+ this.datetime = new Date().toISOString();
60
+ this.format("y-m-d");
61
+ return this.getResult();
62
+ }
63
+
64
+ public getTime() {
65
+ const convertDateTime = new dateTime(this.datetime).format("y-m-d h:i:s").getResult();
66
+ const datetime = new Date(convertDateTime);
67
+ return datetime.getTime();
68
+ }
69
+
70
+ public nextMonthFirstDay(format = "y-m-d") {
71
+ // Verilen tarihin bir sonraki ayının ilk gününü bul
72
+ this.datetime = new Date(this.datetime);
73
+ this.datetime.setMonth(this.datetime.getMonth() + 1);
74
+ this.datetime.setDate(1);
75
+ this.datetime = this.datetime.toISOString();
76
+ this.format(format);
77
+ return this.getResult();
78
+ }
79
+ }
@@ -0,0 +1,143 @@
1
+ import { Dialog, propsDialog } from "./Dialog";
2
+ import React, { memo, useCallback, useEffect, useState } from "react";
3
+ import { Tooltip, typeTooltipPosition } from "../tooltip";
4
+
5
+ import Link from "next/link";
6
+ import styles from "./styles/Button.module.css";
7
+
8
+ interface Props {
9
+ children?: React.ReactNode;
10
+ onlyIcon?: React.ReactNode;
11
+ buttonClass?: "default" | "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "link";
12
+ buttonSize?: "small" | "medium" | "large";
13
+ autoFocus?: boolean;
14
+ hidden?: boolean;
15
+ component?: "button" | "a" | "div" | any;
16
+ className?: string;
17
+ type?: "submit" | "reset" | "button";
18
+ disabled?: boolean;
19
+ fullWidth?: boolean;
20
+ onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
21
+ href?: string | undefined;
22
+ target?: string | undefined;
23
+ style?: React.CSSProperties;
24
+ tabIndex?: number;
25
+
26
+ //Tooltip
27
+ title?: string;
28
+ titlePosition?: typeTooltipPosition;
29
+ titleArrow?: boolean;
30
+
31
+ //Dialog
32
+ dialog?: propsDialog;
33
+ }
34
+
35
+ export const Button = memo(function MemoFunction({
36
+ children,
37
+ component = "button",
38
+ className,
39
+ buttonClass = "default",
40
+ buttonSize = "medium",
41
+ style,
42
+ type = "button",
43
+ fullWidth = false,
44
+ onlyIcon,
45
+ onClick,
46
+ href,
47
+ target,
48
+ tabIndex,
49
+ title,
50
+ titlePosition,
51
+ titleArrow,
52
+ dialog,
53
+ autoFocus,
54
+ ...other
55
+ }: Props) {
56
+ const Comp = component;
57
+ const ripple = (e: any): void => {
58
+ const el = e.currentTarget;
59
+ const circle = document.createElement("span");
60
+ const diameter = Math.max(el.clientWidth, el.clientHeight);
61
+ circle.style.width = circle.style.height = `${diameter}px`;
62
+ circle.classList.add(styles.ripple);
63
+ const ripple = el.getElementsByClassName(styles.ripple)[0];
64
+ if (ripple) ripple.remove();
65
+ el.appendChild(circle);
66
+ };
67
+
68
+ const handleClick = (e: any) => {
69
+ ripple(e);
70
+ if (dialog) {
71
+ Dialog(dialog).then((result) => {
72
+ if (result && onClick) {
73
+ onClick(e);
74
+ }
75
+ });
76
+ } else {
77
+ if (onClick) onClick(e);
78
+ }
79
+ };
80
+
81
+ const createClassList = useCallback(() => {
82
+ const list = ["sbutton", styles.button];
83
+ if (buttonClass) list.push(styles[buttonClass]);
84
+ if (className) list.push(className);
85
+ if (onlyIcon) list.push(styles.iconbutton);
86
+ if (fullWidth) list.push(styles.fullwidth);
87
+ return list.join(" ");
88
+ }, [buttonClass, className, onlyIcon, fullWidth]);
89
+
90
+ const [classList, setClassList] = useState<string>(() => createClassList());
91
+
92
+ useEffect(() => {
93
+ const newClassList = createClassList().split(" ").filter(Boolean);
94
+ if (href && typeof window !== "undefined" && window.location.pathname === href) {
95
+ newClassList.push("active");
96
+ }
97
+ setClassList(newClassList.join(" "));
98
+ }, [href, createClassList]);
99
+
100
+ let ortakProps = {
101
+ className: classList,
102
+ style,
103
+ onClick: handleClick,
104
+ tabIndex,
105
+ autoFocus,
106
+ "data-button-size": (!onlyIcon)? buttonSize :null,
107
+ ...other
108
+ };
109
+
110
+
111
+
112
+
113
+
114
+ let renderComponent;
115
+ if (href !== undefined) {
116
+ if (other?.hidden) {
117
+ renderComponent = null;
118
+ } else {
119
+ let checkHref = other?.disabled ? "#" : href;
120
+ renderComponent = (
121
+ <Link href={checkHref} target={other?.disabled ? "_self" : target}>
122
+ <Comp {...ortakProps}>{onlyIcon ? onlyIcon : children}</Comp>
123
+ </Link>
124
+ );
125
+ }
126
+ } else {
127
+ renderComponent = (
128
+ <Comp type={type} {...ortakProps}>
129
+ {onlyIcon ? onlyIcon : children}
130
+ </Comp>
131
+ );
132
+ }
133
+
134
+ if (title && renderComponent) {
135
+ return (
136
+ <Tooltip title={title} position={titlePosition} arrow={titleArrow}>
137
+ {renderComponent}
138
+ </Tooltip>
139
+ );
140
+ } else {
141
+ return renderComponent;
142
+ }
143
+ });
@@ -0,0 +1,48 @@
1
+ import React, { useRef } from "react";
2
+
3
+ import styles from "./styles/Input.module.css";
4
+
5
+ interface Props {
6
+ checked: "0" | "1" | boolean;
7
+ ref?: React.Ref<any>;
8
+ name?: string;
9
+ label?: string;
10
+ className?: string;
11
+ disabled?: boolean;
12
+ onToogle?: (e: { target: { name?: string; value: "0" | "1" } }) => void;
13
+ style?: React.CSSProperties;
14
+ styleCheckbox?: React.CSSProperties;
15
+ styleLabel?: React.CSSProperties;
16
+ tabIndex?: number;
17
+ required?: boolean;
18
+ children?: React.ReactNode;
19
+ }
20
+
21
+ export const Checkbox: React.FC<Props> = ({ ref, children, name, label, checked, className, style, styleCheckbox, styleLabel, onToogle, disabled, tabIndex, required = false }) => {
22
+ const refMain = useRef<HTMLDivElement>(null);
23
+
24
+ // checked değerini boolean hâline getiriyoruz
25
+ const isChecked = checked === "1" || checked === true;
26
+
27
+ const handleChange = (newChecked: boolean) => {
28
+ if (disabled) return;
29
+ onToogle?.({
30
+ target: {
31
+ name,
32
+ value: newChecked ? "1" : "0"
33
+ }
34
+ });
35
+ };
36
+
37
+ const toggleCheck = () => {
38
+ handleChange(!isChecked);
39
+ };
40
+
41
+ return (
42
+ <div ref={refMain} className={`${styles.checkbox} ${className || ""}`} style={style} tabIndex={tabIndex} onClick={toggleCheck}>
43
+ <input ref={ref} type="checkbox" name={name} onChange={(e) => handleChange(e.target.checked)} checked={isChecked} required={required} style={styleCheckbox} disabled={disabled} />
44
+ {label && <label style={styleLabel}>{label}</label>}
45
+ {children && <div>{children}</div>}
46
+ </div>
47
+ );
48
+ };
@@ -0,0 +1,109 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { Box, BoxFooter } from '../box';
3
+
4
+ import { createRoot } from 'react-dom/client';
5
+ import { Modal } from '../modal';
6
+ import { Button } from './Button';
7
+
8
+ export type propsDialog = {
9
+ message: any;
10
+ acceptButtonShow?: boolean;
11
+ cancelButtonShow?: boolean;
12
+ acceptButtonText?: string | ReactNode;
13
+ cancelButtonText?: string | ReactNode;
14
+ acceptButtonClass?: 'default' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | 'link';
15
+ cancelButtonClass?: 'default' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | 'link';
16
+ vertialAlign?: 'flex-start' | 'center' | 'flex-end';
17
+ horizontalAlign?: 'flex-start' | 'center' | 'flex-end';
18
+ hideBackdrop?: boolean;
19
+ hideEsc?: boolean;
20
+ styleMessage?: React.CSSProperties;
21
+ styleBox?: React.CSSProperties;
22
+ styleBoxFooter?: React.CSSProperties;
23
+ autoFocus?: 'accept' | 'cancel';
24
+ backdropStyle?: React.CSSProperties;
25
+ };
26
+
27
+ export const Dialog = (config: propsDialog) =>
28
+ new Promise((resolve) => {
29
+ if (typeof window === 'undefined') return false;
30
+ let mainDiv: any = document.getElementById('sdialog');
31
+ if (!mainDiv) {
32
+ const createDiv = document.createElement('div');
33
+ createDiv.setAttribute('id', 'sdialog');
34
+ document.body.appendChild(createDiv);
35
+ mainDiv = createDiv;
36
+ }
37
+ const root = createRoot(mainDiv!);
38
+ const settings: propsDialog = {
39
+ acceptButtonShow: true,
40
+ cancelButtonShow: true,
41
+ acceptButtonText: 'EVET',
42
+ cancelButtonText: 'HAYIR',
43
+ acceptButtonClass: 'danger',
44
+ cancelButtonClass: 'secondary',
45
+ vertialAlign: 'center',
46
+ horizontalAlign: 'center',
47
+ hideBackdrop: true,
48
+ hideEsc: true,
49
+ styleMessage: {
50
+ fontSize: '1.1rem',
51
+ padding: '10px 20px'
52
+ },
53
+ styleBox: { padding: 0, margin: 0, minWidth: 250 },
54
+ styleBoxFooter: { padding: '8px 5px' },
55
+ autoFocus: 'accept',
56
+ ...config
57
+ };
58
+
59
+ const close = () => {
60
+ if (mainDiv) {
61
+ root.unmount();
62
+ mainDiv.remove();
63
+ }
64
+ };
65
+
66
+ const onCancel = () => {
67
+ resolve(false);
68
+ close();
69
+ };
70
+
71
+ const onAccept = () => {
72
+ resolve(true);
73
+ close();
74
+ };
75
+
76
+ const Component = (
77
+ <Modal
78
+ open={true}
79
+ keepMounted={false}
80
+ close={onCancel}
81
+ hideBackdrop={settings.hideBackdrop}
82
+ hideEsc={settings.hideEsc}
83
+ hideCloseButton={true}
84
+ vertialAlign={settings.vertialAlign}
85
+ horizontalAlign={settings.horizontalAlign}
86
+ backdropStyle={settings.backdropStyle}
87
+ >
88
+ <Box style={settings.styleBox}>
89
+ <div className="sbox_content" style={settings.styleMessage} dangerouslySetInnerHTML={{ __html: settings.message }} />
90
+
91
+ {(settings.acceptButtonShow || settings.cancelButtonShow) && (
92
+ <BoxFooter style={settings.styleBoxFooter}>
93
+ {settings.cancelButtonShow && (
94
+ <Button autoFocus={settings.autoFocus === 'cancel'} buttonClass={settings.cancelButtonClass} onClick={onCancel}>
95
+ {settings.cancelButtonText}
96
+ </Button>
97
+ )}
98
+ {settings.acceptButtonShow && (
99
+ <Button autoFocus={settings.autoFocus === 'accept'} buttonClass={settings.acceptButtonClass} onClick={onAccept}>
100
+ {settings.acceptButtonText}
101
+ </Button>
102
+ )}
103
+ </BoxFooter>
104
+ )}
105
+ </Box>
106
+ </Modal>
107
+ );
108
+ root.render(Component);
109
+ });
package/form/Form.tsx ADDED
@@ -0,0 +1,19 @@
1
+ import React, { FormEventHandler, memo } from "react";
2
+
3
+ interface Props {
4
+ children?: React.ReactNode;
5
+ encType?: React.FormHTMLAttributes<HTMLFormElement>["encType"];
6
+ onSubmit?: FormEventHandler<HTMLFormElement>;
7
+ style?: React.CSSProperties;
8
+ disableOnEnterSubmit?: boolean;
9
+ }
10
+
11
+ export const Form = memo(function FunctionMemo({ encType = "multipart/form-data", onSubmit, style, disableOnEnterSubmit = false, ...other }: Props) {
12
+ const onKeyDown = (e: React.KeyboardEvent<HTMLFormElement>) => {
13
+ if (e.key === "Enter" && disableOnEnterSubmit) {
14
+ e.preventDefault();
15
+ }
16
+ };
17
+
18
+ return <form style={style} encType={encType} onSubmit={onSubmit} onKeyDown={onKeyDown} {...other} />;
19
+ });
@@ -0,0 +1,105 @@
1
+ import React, { memo, useEffect, useMemo } from 'react';
2
+ import { Col, Row, typeJustifyContent, typeSpacingValues } from '../grid';
3
+
4
+ import { isDev } from '../_lib/baseFunctions';
5
+ import { Label } from './Label';
6
+
7
+ type gridValues = 'auto' | 'full' | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
8
+ type grid = {
9
+ xs?: gridValues;
10
+ sm?: gridValues;
11
+ md?: gridValues;
12
+ lg?: gridValues;
13
+ xl?: gridValues;
14
+ xxl?: gridValues;
15
+ };
16
+
17
+ export type PropsFormOgeler = {
18
+ label?: string | null;
19
+ noRender?: boolean;
20
+ fullComponent?: any;
21
+ component?: any;
22
+ propsComponent?: object;
23
+ propsRow?: object;
24
+ propsLabel?: object;
25
+ gridLabel?: grid;
26
+ gridInput?: grid;
27
+ };
28
+
29
+ interface Props {
30
+ // form: { [key: string | number]: any; }[],
31
+ // form: any[],
32
+ form: { [key: string | number]: any };
33
+ formOgeler: PropsFormOgeler[];
34
+ onChange: Function;
35
+ sabitGrid: {
36
+ label: grid;
37
+ input: grid;
38
+ };
39
+ formType: 'label' | 'noLabel';
40
+ justifyContent: typeJustifyContent;
41
+ rowSpacing?: typeSpacingValues;
42
+ colSpacing?: typeSpacingValues;
43
+ }
44
+
45
+ export const FormOlustur = memo(function FunctionMemo(props: Props) {
46
+ const { form, formOgeler, onChange, formType, sabitGrid, justifyContent, rowSpacing, colSpacing } = props;
47
+ useEffect(() => {
48
+ if (formOgeler && onChange && form) {
49
+ formOgeler.forEach((formOgeler: any) => {
50
+ const fieldName = formOgeler?.component?.props?.name;
51
+ if (formOgeler.noRender && fieldName && form[fieldName] && form[fieldName] != '') {
52
+ isDev && console.log('noRenderGuncelle');
53
+ if (formOgeler?.component && formOgeler?.component?.props?.name) {
54
+ onChange({
55
+ target: {
56
+ name: fieldName,
57
+ value: ''
58
+ }
59
+ });
60
+ }
61
+ }
62
+ });
63
+ }
64
+ }, [JSON.stringify(form), formOgeler]);
65
+
66
+ const result = useMemo(() => {
67
+ return formOgeler.map(({ noRender, fullComponent, component, propsComponent, propsRow, label, propsLabel, gridLabel, gridInput }: PropsFormOgeler, i: React.Key) => {
68
+ if (noRender) {
69
+ return null;
70
+ }
71
+
72
+ if (fullComponent) return React.cloneElement(fullComponent, { key: i });
73
+
74
+ let newProps = { ...propsComponent };
75
+
76
+ if (onChange && component && !component.props.onChange) {
77
+ newProps = { ...newProps, onChange };
78
+ }
79
+
80
+ if (onChange && form && component.props.name && !component.props.value) {
81
+ newProps = { ...newProps, value: form[component.props.name] && form[component.props.name].length > 0 ? String(form[component.props.name]) : '' };
82
+ }
83
+
84
+ if (formType === 'label') newProps = { ...newProps, label: '' };
85
+
86
+ const detectLabel = label || component.props.label;
87
+ gridLabel = { ...sabitGrid.label, ...gridLabel };
88
+ gridInput = { ...sabitGrid.input, ...gridInput };
89
+
90
+ return (
91
+ <Row key={i} justifyContent={justifyContent} rowSpacing={rowSpacing} colSpacing={colSpacing} {...propsRow}>
92
+ {formType === 'label' && detectLabel && (
93
+ <Col {...gridLabel}>
94
+ <Label required={component.props.required} {...propsLabel}>
95
+ {detectLabel}
96
+ </Label>
97
+ </Col>
98
+ )}
99
+ <Col {...gridInput}>{React.cloneElement(component, newProps)}</Col>
100
+ </Row>
101
+ );
102
+ });
103
+ }, [form, formOgeler, onChange, formType, sabitGrid, justifyContent, rowSpacing, colSpacing]);
104
+ return <React.Fragment>{result}</React.Fragment>;
105
+ });