ar-design 0.1.56 → 0.1.57

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.
@@ -0,0 +1,84 @@
1
+ .ar-pie-chart-wrapper {
2
+ display: flex;
3
+ flex-direction: column;
4
+ justify-content: center;
5
+ align-items: center;
6
+ gap: 1rem 0;
7
+ }
8
+ .ar-pie-chart-wrapper > div {
9
+ display: flex;
10
+ flex-direction: row;
11
+ align-items: center;
12
+ gap: 0 2rem;
13
+ }
14
+
15
+ .ar-pie-chart-wrapper > .title {
16
+ width: 100%;
17
+ color: var(--gray-700);
18
+ font-size: 1.2rem;
19
+ font-weight: bold;
20
+ text-align: left;
21
+ }
22
+
23
+ .ar-pie-chart-wrapper > div > .ar-pie-chart {
24
+ position: relative;
25
+ width: 200px;
26
+ height: 200px;
27
+ border-radius: var(--border-radius-pill);
28
+ user-select: none;
29
+ }
30
+ .ar-pie-chart-wrapper > div > .ar-pie-chart > article {
31
+ position: absolute;
32
+ inset: 0.5rem;
33
+ display: flex;
34
+ justify-content: center;
35
+ align-items: center;
36
+ background-color: var(--white);
37
+ border-radius: var(--border-radius-pill);
38
+ box-shadow: inset 0 0 0 5px rgba(var(--black-rgb), 0.1);
39
+ color: var(--gray-700);
40
+ }
41
+
42
+ .ar-pie-chart-wrapper > div > .information-field {
43
+ display: flex;
44
+ flex-direction: column;
45
+ flex-wrap: wrap;
46
+ flex: 1;
47
+ justify-content: flex-start;
48
+ align-items: flex-start;
49
+ gap: 0.5rem 0;
50
+ width: 100%;
51
+ }
52
+ .ar-pie-chart-wrapper > div > .information-field > article {
53
+ display: flex;
54
+ flex-direction: row;
55
+ flex: 2;
56
+ align-items: center;
57
+ gap: 0 0.5rem;
58
+ }
59
+ .ar-pie-chart-wrapper > div > .information-field > article > span:first-child {
60
+ position: relative;
61
+ min-width: 1.75rem;
62
+ min-height: 1rem;
63
+ padding-left: 0.85rem;
64
+ border-radius: var(--border-radius-sm);
65
+ color: var(--white);
66
+ font-size: 0.75rem;
67
+ font-weight: bold;
68
+ line-height: 1rem;
69
+ overflow: hidden;
70
+ }
71
+ .ar-pie-chart-wrapper > div > .information-field > article > span:first-child::before {
72
+ position: absolute;
73
+ left: 0;
74
+ top: 50%;
75
+ transform: translateY(-50%);
76
+ content: "%";
77
+ background-color: rgba(var(--black-rgb), 0.2);
78
+ width: 0.75rem;
79
+ font-size: 0.65rem;
80
+ text-align: center;
81
+ }
82
+ .ar-pie-chart-wrapper > div > .information-field > article > span:last-child {
83
+ font-size: 0.75rem;
84
+ }
@@ -1,4 +1,5 @@
1
1
  .ar-paper {
2
+ position: relative;
2
3
  background-color: var(--white);
3
4
  padding: 2rem;
4
5
  border-radius: var(--border-radius-lg);
@@ -1,4 +1,5 @@
1
1
  .notification {
2
+ background-color: var(--danger);
2
3
  position: fixed;
3
4
  display: flex;
4
5
  flex-direction: column-reverse;
@@ -24,120 +25,124 @@
24
25
  right: 1rem;
25
26
  }
26
27
 
27
- .notification > .item {
28
+ .ar-notification-item {
29
+ position: fixed;
30
+ left: 2rem;
28
31
  display: flex;
29
32
  flex-direction: row;
30
33
  gap: 0 0.5rem;
31
- width: 100%;
32
- height: 5rem;
34
+ background-color: rgba(var(--white-rgb), 0.5);
35
+ backdrop-filter: blur(5px);
36
+ width: 350px;
37
+ height: 7.5rem;
33
38
  border-radius: var(--border-radius-xl);
39
+ box-shadow: 0 5px 15px -5px rgba(var(--black-rgb), 0.25);
40
+ transition: all 250ms ease-in-out;
34
41
  overflow: hidden;
35
42
  /* Sırasıyla; Ad, Süre, Hız, Gecikme Süresi, Tekrar Sayısı, Yön, Bitiş Süreci */
36
43
  animation: openSnackbar ease-in-out 500ms 0s 1 normal both;
37
44
  }
38
45
 
39
- .notification > .item.success {
40
- background-color: var(--success);
41
- }
42
- .notification > .item.warning {
43
- background-color: var(--warning);
44
- }
45
- .notification > .item.information {
46
- background-color: var(--info);
47
- }
48
- .notification > .item.error {
49
- background-color: var(--danger);
50
- }
51
-
52
- .notification > .item > .icon {
46
+ .ar-notification-item > .icon {
53
47
  position: relative;
54
48
  min-width: 3rem;
55
49
  border-top-left-radius: var(--border-radius-xl);
56
50
  border-bottom-left-radius: var(--border-radius-xl);
57
51
  overflow: hidden;
58
52
  }
59
- .notification > .item > .icon > span {
53
+ .ar-notification-item > .icon > span {
60
54
  position: absolute;
61
55
  border-radius: var(--border-radius-pill);
62
56
  }
63
- /* .notification > .item > .icon > span:nth-child(1) {
57
+ .ar-notification-item > .icon > span:nth-child(1) {
64
58
  top: 0.5rem;
65
59
  left: 0.5rem;
66
60
  width: 0.25rem;
67
61
  height: 0.25rem;
68
62
  }
69
- .notification > .item > .icon > span:nth-child(2) {
63
+ .ar-notification-item > .icon > span:nth-child(2) {
70
64
  top: 1.5rem;
71
65
  left: 0.5rem;
72
66
  width: 0.5rem;
73
67
  height: 0.5rem;
74
68
  }
75
- .notification > .item > .icon > span:nth-child(3) {
69
+ .ar-notification-item > .icon > span:nth-child(3) {
76
70
  top: 2rem;
77
71
  left: 1.75rem;
78
72
  width: 1rem;
79
73
  height: 1rem;
80
74
  }
81
- .notification > .item > .icon > span:nth-child(4) {
75
+ .ar-notification-item > .icon > span:nth-child(4) {
82
76
  bottom: -1.5rem;
83
77
  left: -0.5rem;
84
78
  width: 3rem;
85
79
  height: 3rem;
86
80
  }
87
- .notification > .item > .icon > span:nth-child(5) {
81
+ .ar-notification-item > .icon > span:nth-child(5) {
88
82
  bottom: 1.15rem;
89
83
  left: 1rem;
90
84
  width: 0.55rem;
91
85
  height: 0.55rem;
92
- } */
93
- .notification > .item > .icon > span.success {
86
+ }
87
+ .ar-notification-item > .icon > span.success {
94
88
  background-color: var(--success);
95
89
  }
96
- .notification > .item > .icon > span.warning {
90
+ .ar-notification-item > .icon > span.warning {
97
91
  background-color: var(--warning);
98
92
  }
99
- .notification > .item > .icon > span.information {
93
+ .ar-notification-item > .icon > span.information {
100
94
  background-color: var(--info);
101
95
  }
102
- .notification > .item > .icon > span.error {
96
+ .ar-notification-item > .icon > span.error {
103
97
  background-color: var(--danger);
104
98
  }
105
99
 
106
- .notification > .item > .content {
100
+ .ar-notification-item > .content {
107
101
  display: flex;
108
102
  flex-direction: column;
109
103
  justify-content: center;
110
- gap: 0.25rem 0;
104
+ gap: 0.75rem 0;
111
105
  width: 100%;
112
106
  padding: 0 1rem;
113
- color: var(--white);
107
+ color: var(--gray-700);
114
108
  }
115
- .notification > .item > .content > .title {
116
- font-size: 1.3rem;
109
+ .ar-notification-item > .content > .title {
110
+ font-size: 1.2rem;
117
111
  }
118
- .notification > .item > .content > .message {
112
+ .ar-notification-item > .content > .message {
113
+ color: var(--gray-600);
119
114
  }
120
115
 
121
- .notification > .item > .close {
122
- display: flex;
123
- justify-content: center;
124
- align-items: center;
116
+ .ar-notification-item > .close {
125
117
  min-width: 2.5rem;
126
- background-color: rgba(var(--black-rgb), 0.1);
127
- color: rgba(var(--white-rgb), 0.75);
118
+ }
119
+ .ar-notification-item > .close::before,
120
+ .ar-notification-item > .close::after {
121
+ position: absolute;
122
+ top: 0.75rem;
123
+ right: 1.25rem;
124
+ content: "";
125
+ width: 2px;
126
+ height: 15px;
127
+ background-color: var(--gray-500);
128
+ transform-origin: center;
129
+ transform: rotate(45deg);
130
+ }
131
+ .ar-notification-item > .close::after {
132
+ transform: rotate(-45deg);
128
133
  }
129
134
 
130
135
  @media only screen and (max-width: 480px) {
131
- .notification.top-left {
136
+ .ar-notification.top-left {
132
137
  inset: 1rem 1rem auto 1rem;
133
138
  }
134
- .notification.top-right {
139
+ .ar-notification.top-right {
135
140
  inset: 1rem 1rem auto 1rem;
136
141
  }
137
- .notification.bottom-left {
142
+ .ar-notification.bottom-left {
138
143
  inset: auto 1rem 1rem 1rem;
139
144
  }
140
- .notification.bottom-right {
145
+ .ar-notification.bottom-right {
141
146
  inset: auto 1rem 1rem 1rem;
142
147
  }
143
148
  }
@@ -0,0 +1,2 @@
1
+ import Pie from "./pie";
2
+ export { Pie };
@@ -0,0 +1,2 @@
1
+ import Pie from "./pie";
2
+ export { Pie };
@@ -0,0 +1,7 @@
1
+ import { PieChartDataType } from "../../../libs/types";
2
+ interface IProps {
3
+ title: string;
4
+ data: PieChartDataType[];
5
+ size?: number;
6
+ }
7
+ export default IProps;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import IProps from "./IProps";
3
+ import "../../../assets/css/components/charts/pie/pie.css";
4
+ declare const Pie: React.FC<IProps>;
5
+ export default Pie;
@@ -0,0 +1,55 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import "../../../assets/css/components/charts/pie/pie.css";
3
+ const Pie = ({ title, data, size }) => {
4
+ // refs
5
+ const _arPieChart = useRef(null);
6
+ // const _randomIndex = useRef<number[]>([]);
7
+ // state
8
+ const [conic, setConic] = useState([]);
9
+ // variable/s
10
+ const conicColors = [
11
+ ["#fff35e", "#000"], // Sarı
12
+ ["#ffc752", "#000"], // Açık Sarı
13
+ ["#ff9151", "#fff"], // Turuncu
14
+ ["#ee544e", "#fff"], // Kırmızı
15
+ ["#e52b66", "#fff"], // Pembemsi Kırmızı
16
+ ["#3c1d43", "#fff"], // Koyu Mor
17
+ ["#582d62", "#fff"], // Mor
18
+ ["#0470a7", "#fff"], // Açık Mavi
19
+ ["#068aa8", "#fff"], // Mavi-Turkuaz
20
+ ["#72a9bb", "#fff"], // Açık Mavi-Gri
21
+ ];
22
+ useEffect(() => {
23
+ if (!_arPieChart.current || data.length === 0)
24
+ return;
25
+ const conicGradients = [];
26
+ let total = data.reduce((sum, value) => sum + value.value, 0);
27
+ let normalizedData = data.map((value) => (value.value / total) * 100);
28
+ let start = 0;
29
+ // Gelen data uzunluğunda rastgele bir sayı dizisi oluşturuyor.
30
+ // do {
31
+ // const r = Math.floor(Math.random() * conicColors.length);
32
+ // if (!_randomIndex.current.includes(r)) _randomIndex.current.push(r);
33
+ // } while (_randomIndex.current.length < data.length);
34
+ normalizedData.forEach((percent, index) => {
35
+ let end = start + percent;
36
+ if (index === 0)
37
+ conicGradients.push(`#fff ${start + 0.5}% ${start}%`);
38
+ conicGradients.push(`${conicColors[index][0]} ${start}% ${end}%`);
39
+ conicGradients.push(`#fff ${end}% ${end + 0.5}%`);
40
+ start = end;
41
+ });
42
+ setConic(conicGradients);
43
+ }, [data]);
44
+ return (React.createElement("div", { className: "ar-pie-chart-wrapper" },
45
+ React.createElement("div", { className: "title" },
46
+ React.createElement("span", null, title)),
47
+ React.createElement("div", null,
48
+ React.createElement("div", { ref: _arPieChart, className: "ar-pie-chart", style: { background: `conic-gradient(${conic.join(", ")})`, width: size, height: size } },
49
+ React.createElement("article", null)),
50
+ React.createElement("div", { className: "information-field" }, data.map((item, index) => (React.createElement("article", { key: index },
51
+ React.createElement("span", { style: { backgroundColor: conicColors[index][0] } },
52
+ React.createElement("span", { style: { color: conicColors[index][1] } }, item.value)),
53
+ React.createElement("span", null, item.text))))))));
54
+ };
55
+ export default Pie;
@@ -1,6 +1,6 @@
1
1
  import { ParagraphColors, Status } from "../../../../libs/types";
2
- import { IChildren, IGlobalProps } from "../../../../libs/types/IGlobalProps";
3
- interface IProps extends Omit<IGlobalProps, "status">, IChildren {
2
+ import { IChildren, IGlobalProps, ISizes } from "../../../../libs/types/IGlobalProps";
3
+ interface IProps extends Omit<IGlobalProps, "status">, IChildren, ISizes {
4
4
  color?: ParagraphColors | Status;
5
5
  align?: "left" | "center" | "right";
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import IProps from "./IProps";
3
3
  import "../../../assets/css/components/feedback/notification/notification.css";
4
- declare const Notification: ({ title, message, status, direction, trigger }: IProps) => React.JSX.Element;
4
+ declare const Notification: ({ title, message, status, direction, trigger }: IProps) => React.JSX.Element[];
5
5
  export default Notification;
@@ -5,7 +5,8 @@ import "../../../assets/css/components/feedback/notification/notification.css";
5
5
  const Notification = ({ title, message, status, direction = "bottom-left", trigger }) => {
6
6
  // useRefs
7
7
  const _firstLoad = useRef(false);
8
- const _index = useRef(0);
8
+ // const _index = useRef<number>(0);
9
+ const _notificationItems = useRef([]);
9
10
  const _interval = useRef();
10
11
  // useStates
11
12
  const [items, setItems] = useState([]);
@@ -15,26 +16,37 @@ const Notification = ({ title, message, status, direction = "bottom-left", trigg
15
16
  _firstLoad.current = true;
16
17
  return;
17
18
  }
18
- _index.current += 1;
19
- const createItem = (React.createElement("div", { className: `item ${status}` },
20
- React.createElement("div", { className: "content" },
21
- React.createElement("span", { className: `title ${status}` }, title),
22
- React.createElement("span", { className: "message" }, message)),
23
- React.createElement("div", { className: "close", "data-index": _index.current, onClick: (event) => {
24
- const target = event.currentTarget;
25
- setItems((item) => item.filter((x) => x.index !== Number(target.dataset.index)));
26
- } }, "x")));
27
- setItems((items) => [...items, { index: _index.current, element: createItem }]);
19
+ setItems((items) => [...items, { title, message, status, direction }]);
28
20
  }, [trigger]);
29
21
  useEffect(() => {
30
22
  if (items.length === 0)
31
23
  return;
32
24
  // Ekleme işlemi bittikten bir süre sonra tekrar kaldırma işlemi yapılmaktadır.
33
25
  _interval.current = setTimeout(() => {
34
- setItems((items) => items.slice(0, -1));
26
+ setItems((items) => items.slice(1));
35
27
  clearTimeout(_interval.current);
36
28
  }, 3000);
37
29
  }, [items]);
38
- return (React.createElement("div", { className: `notification ${direction}` }, items.map((item, index) => (React.createElement(React.Fragment, { key: index }, item.element)))));
30
+ return items.map((item, index) => {
31
+ let bottom = 0;
32
+ // Önceki öğenin yüksekliğini dikkate alarak `bottom` hesaplanıyor.
33
+ if (_notificationItems.current[index - 1] && index > 0) {
34
+ bottom = _notificationItems.current.slice(0, index).reduce((acc, el) => {
35
+ const rect = el.getBoundingClientRect();
36
+ return acc + rect.height + 20; // Önceki öğelerin yüksekliğini topluyoruz.
37
+ }, 0);
38
+ }
39
+ return (React.createElement("div", { key: index, ref: (element) => (_notificationItems.current[index] = element), className: "ar-notification-item", style: { bottom: `${items.length > 5 ? index * 10.5 : bottom}px` } },
40
+ React.createElement("div", { className: "icon" },
41
+ React.createElement("span", { className: item.status }),
42
+ React.createElement("span", { className: item.status }),
43
+ React.createElement("span", { className: item.status }),
44
+ React.createElement("span", { className: item.status }),
45
+ React.createElement("span", { className: item.status })),
46
+ React.createElement("div", { className: "content" },
47
+ React.createElement("span", { className: "title" }, item.title),
48
+ React.createElement("span", { className: "message" }, item.message)),
49
+ React.createElement("div", { className: "close", onClick: () => setItems((items) => items.filter((_, _index) => _index !== index)) })));
50
+ });
39
51
  };
40
52
  export default Notification;
@@ -1,5 +1,5 @@
1
- import { IGlobalProps } from "../../../libs/types/IGlobalProps";
2
- interface IProps extends Omit<IGlobalProps, "children" | "disabled">, React.ButtonHTMLAttributes<HTMLButtonElement> {
1
+ import { IGlobalProps, ISizes } from "../../../libs/types/IGlobalProps";
2
+ interface IProps extends Omit<IGlobalProps, "children" | "disabled">, ISizes, React.ButtonHTMLAttributes<HTMLButtonElement> {
3
3
  /**
4
4
  * Bileşenin şekil varyantını belirtir ve genellikle sadece ikon için kullanılmalıdır.
5
5
  * İki seçenekten biri olabilir: "circle" veya "square".
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { IGlobalProps } from "../../../libs/types/IGlobalProps";
3
- interface IProps extends Omit<IGlobalProps, "children" | "icon" | "disabled">, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "type" | "size"> {
2
+ import { IGlobalProps, ISizes } from "../../../libs/types/IGlobalProps";
3
+ interface IProps extends Omit<IGlobalProps, "children" | "icon" | "disabled">, ISizes, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "type" | "size"> {
4
4
  label?: string;
5
5
  }
6
6
  export default IProps;
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
2
  import IButtonProps from "../button/IProps";
3
3
  import { Variants } from "../../../libs/types";
4
- import { IGlobalProps, IValidation } from "../../../libs/types/IGlobalProps";
5
- interface IProps extends Omit<IGlobalProps, "children" | "disabled">, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "size">, IValidation {
4
+ import { IGlobalProps, ISizes, IValidation } from "../../../libs/types/IGlobalProps";
5
+ interface IProps extends Omit<IGlobalProps, "children" | "disabled">, ISizes, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "size">, IValidation {
6
6
  button?: IButtonProps;
7
7
  addon?: {
8
8
  variant?: Variants;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { IGlobalProps } from "../../../libs/types/IGlobalProps";
3
- interface IProps extends Omit<IGlobalProps, "children">, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "size"> {
2
+ import { IGlobalProps, ISizes } from "../../../libs/types/IGlobalProps";
3
+ interface IProps extends Omit<IGlobalProps, "children">, ISizes, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "size"> {
4
4
  label?: string;
5
5
  }
6
6
  export default IProps;
@@ -1,13 +1,11 @@
1
1
  "use client";
2
- import React, { forwardRef, useRef, useState } from "react";
2
+ import React, { forwardRef, useRef } from "react";
3
3
  import "../../../assets/css/components/form/radio/radio.css";
4
4
  import Utils from "../../../libs/infrastructure/shared/Utils";
5
5
  const Radio = forwardRef(({ label, size = "normal", status, border = { radius: "sm" }, upperCase, ...attributes }, ref) => {
6
6
  // refs
7
7
  const _checkbox = useRef(null);
8
8
  const _checkboxClassName = ["ar-radio"];
9
- // states
10
- const [checked, setChecked] = useState(false);
11
9
  _checkboxClassName.push(...Utils.GetClassName("filled", undefined, border, size, undefined, attributes.className));
12
10
  return (React.createElement("div", { className: "ar-radio-wrapper" },
13
11
  React.createElement("label", null,
@@ -16,11 +14,6 @@ const Radio = forwardRef(({ label, size = "normal", status, border = { radius: "
16
14
  const _current = _checkbox.current;
17
15
  if (!_current)
18
16
  return;
19
- // 'checked' durumunun false olup olmadığını kontrol et
20
- if (event.target.checked === false) {
21
- console.log("Radio button is unchecked");
22
- }
23
- setChecked(event.target.checked);
24
17
  })();
25
18
  (() => attributes.onChange && attributes.onChange(event))();
26
19
  } }),
@@ -75,7 +75,6 @@ export interface IGlobalProps {
75
75
  * ```
76
76
  */
77
77
  border?: Border;
78
- size?: Sizes;
79
78
  /**
80
79
  * Bileşendeki metni büyük harflere dönüştürüp dönüştürmeyeceğini belirtir.
81
80
  * Boolean (true/false) değeri alır.
@@ -52,3 +52,7 @@ export type ValidationProperties<T> = {
52
52
  }[];
53
53
  where?: (param: T) => boolean;
54
54
  };
55
+ export type PieChartDataType = {
56
+ value: number;
57
+ text: string;
58
+ };
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.1.56",
3
+ "version": "0.1.57",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": "./dist/index.js",
9
+ "./@charts": "./dist/components/charts/index.js",
9
10
  "./@service": "./dist/libs/core/service/index.js",
10
11
  "./@config": "./dist/libs/core/application/contexts/index.js",
11
12
  "./@hooks": "./dist/libs/core/application/hooks/index.js",