@sydsoft/base 1.1.0 → 1.3.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.
@@ -2,20 +2,21 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect } from "react";
3
3
  import { createRoot } from "react-dom/client";
4
4
  import styles from "./index.module.css";
5
- const sAlertTimeout = [];
6
- export const Alert = ({ defaultTimer = "5000", defaultErrorTimer = "10000", defaultSuccessTimer = "5000" }) => {
7
- useEffect(() => {
5
+ var sAlertTimeout = [];
6
+ export var Alert = function (_a) {
7
+ var _b = _a.defaultTimer, defaultTimer = _b === void 0 ? "5000" : _b, _c = _a.defaultErrorTimer, defaultErrorTimer = _c === void 0 ? "10000" : _c, _d = _a.defaultSuccessTimer, defaultSuccessTimer = _d === void 0 ? "5000" : _d;
8
+ useEffect(function () {
8
9
  if (typeof window === "undefined")
9
10
  return;
10
- const divCheck = document.getElementById("salert");
11
+ var divCheck = document.getElementById("salert");
11
12
  if (!divCheck) {
12
13
  // let div = document.createElement('div') as HTMLDivElement
13
- const div = document.createElement("div");
14
+ var div = document.createElement("div");
14
15
  div.setAttribute("id", "salert");
15
16
  div.setAttribute("defaultTimer", defaultTimer);
16
17
  div.setAttribute("defaultErrorTimer", defaultErrorTimer);
17
18
  div.setAttribute("defaultSuccessTimer", defaultSuccessTimer);
18
- const alertStyle = [
19
+ var alertStyle = [
19
20
  "position: fixed",
20
21
  "bottom: 0",
21
22
  "right: 0",
@@ -33,25 +34,27 @@ export const Alert = ({ defaultTimer = "5000", defaultErrorTimer = "10000", defa
33
34
  }, []);
34
35
  return null;
35
36
  };
36
- export const alert_add = ({ type, message, style, timer }) => {
37
+ export var alert_add = function (_a) {
38
+ var _b, _c, _d;
39
+ var type = _a.type, message = _a.message, style = _a.style, timer = _a.timer;
37
40
  if (typeof window === "undefined")
38
41
  return false;
39
- const mainDiv = document.getElementById("salert");
42
+ var mainDiv = document.getElementById("salert");
40
43
  if (mainDiv) {
41
- const alert = document.createElement("div");
42
- mainDiv.prepend(alert);
43
- const onClose = () => {
44
- if (mainDiv && alert && mainDiv.contains(alert))
45
- mainDiv.removeChild(alert);
44
+ var alert_1 = document.createElement("div");
45
+ mainDiv.prepend(alert_1);
46
+ var onClose_1 = function () {
47
+ if (mainDiv && alert_1 && mainDiv.contains(alert_1))
48
+ mainDiv.removeChild(alert_1);
46
49
  };
47
- const root = createRoot(alert);
48
- const Component = (_jsxs("div", { className: `${styles.salert} ${styles[type]}`, style: style, children: [_jsx("div", { className: styles.message, dangerouslySetInnerHTML: { __html: message } }), _jsx("div", { className: styles.close, onClick: onClose, children: "\u2715" })] }));
50
+ var root = createRoot(alert_1);
51
+ var Component = (_jsxs("div", { className: "".concat(styles.salert, " ").concat(styles[type]), style: style, children: [_jsx("div", { className: styles.message, dangerouslySetInnerHTML: { __html: message } }), _jsx("div", { className: styles.close, onClick: onClose_1, children: "\u2715" })] }));
49
52
  root.render(Component);
50
- const defaultTimer = mainDiv.getAttribute("defaulttimer") ?? "5000";
51
- const defaultErrorTimer = mainDiv.getAttribute("defaulterrortimer") ?? "10000";
52
- const defaultSuccessTimer = mainDiv.getAttribute("defaultsuccesstimer") ?? "5000";
53
- const timerFilled = typeof timer === "number" && timer > 0;
54
- let newTimer = timerFilled ? timer : defaultTimer;
53
+ var defaultTimer = (_b = mainDiv.getAttribute("defaulttimer")) !== null && _b !== void 0 ? _b : "5000";
54
+ var defaultErrorTimer = (_c = mainDiv.getAttribute("defaulterrortimer")) !== null && _c !== void 0 ? _c : "10000";
55
+ var defaultSuccessTimer = (_d = mainDiv.getAttribute("defaultsuccesstimer")) !== null && _d !== void 0 ? _d : "5000";
56
+ var timerFilled = typeof timer === "number" && timer > 0;
57
+ var newTimer = timerFilled ? timer : defaultTimer;
55
58
  switch (type) {
56
59
  case "error":
57
60
  newTimer = timerFilled ? timer : defaultErrorTimer;
@@ -66,27 +69,27 @@ export const alert_add = ({ type, message, style, timer }) => {
66
69
  if (typeof timer !== "boolean") {
67
70
  // False gelmişse sabit kalsın
68
71
  if (newTimer > 0) {
69
- const timeout = setTimeout(() => onClose(), newTimer);
72
+ var timeout = setTimeout(function () { return onClose_1(); }, newTimer);
70
73
  sAlertTimeout.push(timeout);
71
74
  }
72
75
  }
73
- return alert;
76
+ return alert_1;
74
77
  }
75
78
  return null;
76
79
  };
77
- export const alert_remove = (alert) => {
80
+ export var alert_remove = function (alert) {
78
81
  if (typeof window === "undefined" || !alert)
79
82
  return;
80
- const mainDiv = document.getElementById("salert");
83
+ var mainDiv = document.getElementById("salert");
81
84
  if (mainDiv && alert && mainDiv.contains(alert))
82
85
  mainDiv.removeChild(alert);
83
86
  return;
84
87
  };
85
- export const alert_clear = () => {
88
+ export var alert_clear = function () {
86
89
  if (typeof window === "undefined")
87
90
  return false;
88
- sAlertTimeout.map((id) => clearTimeout(id));
89
- const mainDiv = document.getElementById("salert");
91
+ sAlertTimeout.map(function (id) { return clearTimeout(id); });
92
+ var mainDiv = document.getElementById("salert");
90
93
  if (mainDiv)
91
94
  mainDiv.innerHTML = "";
92
95
  return true;
@@ -1,20 +1,22 @@
1
- export default class dateTime {
2
- constructor(datetime = null, format = "y-m-d h:i:s") {
1
+ var dateTime = /** @class */ (function () {
2
+ function dateTime(datetime, format) {
3
+ if (datetime === void 0) { datetime = null; }
4
+ if (format === void 0) { format = "y-m-d h:i:s"; }
3
5
  this.resut_format = "y-m-d h:i:s";
4
6
  this.format(format);
5
7
  this.datetime = datetime !== "0000-00-00 00:00:00" && datetime !== "0000-00-00" && datetime ? datetime : new Date().toISOString(); // GMT ekli halde
6
8
  return this;
7
9
  }
8
- addDays(days) {
9
- const datetime = new Date(this.datetime);
10
+ dateTime.prototype.addDays = function (days) {
11
+ var datetime = new Date(this.datetime);
10
12
  datetime.setDate(datetime.getDate() + days);
11
13
  this.datetime = datetime.toISOString();
12
14
  return this;
13
- }
14
- parse() {
15
- const datetime = new Date(this.datetime);
16
- const monthNames = ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"];
17
- const dayNames = ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"];
15
+ };
16
+ dateTime.prototype.parse = function () {
17
+ var datetime = new Date(this.datetime);
18
+ var monthNames = ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"];
19
+ var dayNames = ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"];
18
20
  return {
19
21
  y: datetime.getFullYear().toString(),
20
22
  m: (datetime.getMonth() + 1).toString().padStart(2, "0"),
@@ -28,10 +30,10 @@ export default class dateTime {
28
30
  TAMAY: monthNames[datetime.getMonth()],
29
31
  TAMGUN: dayNames[datetime.getDay()]
30
32
  };
31
- }
32
- getResult() {
33
- const parse = this.parse();
34
- let result = this.resut_format;
33
+ };
34
+ dateTime.prototype.getResult = function () {
35
+ var parse = this.parse();
36
+ var result = this.resut_format;
35
37
  result = result.replace(new RegExp("y", "g"), parse.y.toString());
36
38
  result = result.replace(new RegExp("m", "g"), parse.m.toString());
37
39
  result = result.replace(new RegExp("d", "g"), parse.d.toString());
@@ -43,22 +45,24 @@ export default class dateTime {
43
45
  result = result.replace(new RegExp("TAMAY", "g"), parse.TAMAY.toString());
44
46
  result = result.replace(new RegExp("TAMGUN", "g"), parse.TAMGUN.toString());
45
47
  return result;
46
- }
47
- format(format = "y-m-d h:i:s") {
48
+ };
49
+ dateTime.prototype.format = function (format) {
50
+ if (format === void 0) { format = "y-m-d h:i:s"; }
48
51
  this.resut_format = format;
49
52
  return this;
50
- }
51
- today() {
53
+ };
54
+ dateTime.prototype.today = function () {
52
55
  this.datetime = new Date().toISOString();
53
56
  this.format("y-m-d");
54
57
  return this.getResult();
55
- }
56
- getTime() {
57
- const convertDateTime = new dateTime(this.datetime).format("y-m-d h:i:s").getResult();
58
- const datetime = new Date(convertDateTime);
58
+ };
59
+ dateTime.prototype.getTime = function () {
60
+ var convertDateTime = new dateTime(this.datetime).format("y-m-d h:i:s").getResult();
61
+ var datetime = new Date(convertDateTime);
59
62
  return datetime.getTime();
60
- }
61
- nextMonthFirstDay(format = "y-m-d") {
63
+ };
64
+ dateTime.prototype.nextMonthFirstDay = function (format) {
65
+ if (format === void 0) { format = "y-m-d"; }
62
66
  // Verilen tarihin bir sonraki ayının ilk gününü bul
63
67
  this.datetime = new Date(this.datetime);
64
68
  this.datetime.setMonth(this.datetime.getMonth() + 1);
@@ -66,5 +70,7 @@ export default class dateTime {
66
70
  this.datetime = this.datetime.toISOString();
67
71
  this.format(format);
68
72
  return this.getResult();
69
- }
70
- }
73
+ };
74
+ return dateTime;
75
+ }());
76
+ export default dateTime;
@@ -1,44 +1,26 @@
1
+ import { __assign, __rest } from "tslib";
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
2
- export const Icon = ({ className, style, iconOzel, iconMui, ...other }) => {
3
- const ortakStyle = {
4
- userSelect: "none",
5
- width: "1em",
6
- height: "1em",
7
- display: "inline-block",
8
- fontSize: "1.5rem",
9
- flexShrink: 0,
10
- ...style
11
- };
3
+ export var Icon = function (_a) {
4
+ var className = _a.className, style = _a.style, iconOzel = _a.iconOzel, iconMui = _a.iconMui, other = __rest(_a, ["className", "style", "iconOzel", "iconMui"]);
5
+ var ortakStyle = __assign({ userSelect: "none", width: "1em", height: "1em", display: "inline-block", fontSize: "1.5rem", flexShrink: 0 }, style);
12
6
  if (iconMui) {
13
- return (_jsx("span", { style: {
14
- color: "inherit",
15
- ...ortakStyle,
16
- ...style
17
- }, className: className ? className + " material-icons" : "material-icons", "aria-hidden": "true", ...other, children: iconMui }));
7
+ return (_jsx("span", __assign({ style: __assign(__assign({ color: "inherit" }, ortakStyle), style), className: className ? className + " material-icons" : "material-icons", "aria-hidden": "true" }, other, { children: iconMui })));
18
8
  }
19
9
  if (iconOzel) {
20
- const findIcon = ozelIkonlar.filter((key) => key["name"] === iconOzel);
10
+ var findIcon = ozelIkonlar.filter(function (key) { return key["name"] === iconOzel; });
21
11
  if (findIcon.length > 0) {
22
- const icon = findIcon[0];
12
+ var icon = findIcon[0];
23
13
  if (icon.full) {
24
- return (_jsx("svg", { style: {
25
- fill: "currentcolor",
26
- ...ortakStyle,
27
- ...style
28
- }, className: className, ...icon.attr, ...other, dangerouslySetInnerHTML: { __html: icon.full } }));
14
+ return (_jsx("svg", __assign({ style: __assign(__assign({ fill: "currentcolor" }, ortakStyle), style), className: className }, icon.attr, other, { dangerouslySetInnerHTML: { __html: icon.full } })));
29
15
  }
30
16
  else {
31
- return (_jsx("svg", { style: {
32
- fill: "currentcolor",
33
- ...ortakStyle,
34
- ...style
35
- }, className: className, viewBox: icon.viewBox, children: _jsx("path", { fill: icon.fill || "currentColor", d: icon.path }) }));
17
+ return (_jsx("svg", { style: __assign(__assign({ fill: "currentcolor" }, ortakStyle), style), className: className, viewBox: icon.viewBox, children: _jsx("path", { fill: icon.fill || "currentColor", d: icon.path }) }));
36
18
  }
37
19
  }
38
20
  }
39
21
  return null;
40
22
  };
41
- const ozelIkonlar = [
23
+ var ozelIkonlar = [
42
24
  {
43
25
  name: "word",
44
26
  path: "M31.999 4.977v22.063c0 0.188-0.067 0.34-0.199 0.461-0.135 0.125-0.295 0.184-0.48 0.184h-11.412v-3.060h9.309v-1.393h-9.317v-1.705h9.309v-1.392h-9.303v-1.72h9.307v-1.376h-9.307v-1.724h9.307v-1.392h-9.307v-1.705h9.307v-1.391h-9.307v-1.74h9.307v-1.325h-9.307v-3.457h11.416c0.199 0 0.36 0.064 0.477 0.199 0.14 0.132 0.2 0.293 0.199 0.475zM18.2 0.855v30.296l-18.2-3.149v-23.912l18.2-3.24zM15.453 9.799l-2.279 0.14-1.461 9.047h-0.033c-0.072-0.428-0.34-1.927-0.82-4.489l-0.852-4.351-2.139 0.107-0.856 4.244c-0.5 2.472-0.779 3.911-0.852 4.315h-0.020l-1.3-8.333-1.96 0.104 2.1 10.511 2.179 0.14 0.82-4.091c0.48-2.4 0.76-3.795 0.82-4.176h0.060c0.081 0.407 0.341 1.832 0.82 4.28l0.82 4.211 2.36 0.14 2.64-11.8z",
package/dist/index.d.ts CHANGED
@@ -3,6 +3,6 @@
3
3
  * @author: izzetseydaoglu
4
4
  * @last-modified: 16.02.2024 03:33
5
5
  */
6
- export * from './alert';
6
+ export { Alert } from "./alert";
7
7
  export * from './datetime';
8
8
  export * from './icon';
package/dist/index.js CHANGED
@@ -3,6 +3,6 @@
3
3
  * @author: izzetseydaoglu
4
4
  * @last-modified: 16.02.2024 03:33
5
5
  */
6
- export * from './alert';
6
+ export { Alert } from "./alert";
7
7
  export * from './datetime';
8
8
  export * from './icon';
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@sydsoft/base",
3
3
  "private": false,
4
- "version": "1.1.0",
4
+ "version": "1.3.0",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "scripts": {
10
10
  "build": "rm -rf ./dist && tsc && npm run copyCSS",
11
+ "pack": "npm pack",
11
12
  "copyCSS": "copyfiles -u 2 \"../@base/**/*.css\" dist/",
12
13
  "publishNPM": "npm run build && npm version patch && npm version minor && npm publish --dry-run && npm publish --access public"
13
14
  },
package/tsconfig.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "include": ["../@base", "global.d.ts"],
3
3
  "exclude": ["./dist", "node_modules"],
4
4
  "compilerOptions": {
5
- "target": "ES2020",
6
- "module": "ESNext",
5
+ "module": "esnext",
6
+ "lib": ["dom", "esnext"],
7
7
  "importHelpers": true,
8
8
  "declaration": true,
9
9
  "sourceMap": false,