ar-design 0.1.80 → 0.1.81
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/dist/assets/css/components/data-display/table/styles.css +3 -0
- package/dist/assets/css/components/feedback/tooltip/styles.css +59 -0
- package/dist/assets/css/components/form/button/{button.css → styles.css} +0 -1
- package/dist/assets/css/components/form/upload/styles.css +14 -23
- package/dist/components/data-display/table/index.js +16 -15
- package/dist/components/feedback/tooltip/IProps.d.ts +6 -0
- package/dist/components/feedback/tooltip/IProps.js +1 -0
- package/dist/components/feedback/tooltip/index.d.ts +5 -0
- package/dist/components/feedback/tooltip/index.js +78 -0
- package/dist/components/form/button/IProps.d.ts +1 -1
- package/dist/components/form/button/index.d.ts +1 -1
- package/dist/components/form/button/index.js +22 -105
- package/dist/components/form/upload/Props.d.ts +4 -1
- package/dist/components/form/upload/index.js +21 -20
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/libs/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/assets/css/components/form/button/core/tooltip.css +0 -40
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
border-top-color: var(--gray-200);
|
|
70
70
|
border-bottom-color: var(--gray-200);
|
|
71
71
|
}
|
|
72
|
+
.ar-table:not(:has(> .header)) > .content > table > thead {
|
|
73
|
+
border-top-color: transparent;
|
|
74
|
+
}
|
|
72
75
|
.ar-table > .content > table > thead > tr:first-child {
|
|
73
76
|
border-bottom: solid 1px var(--gray-200);
|
|
74
77
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.ar-tooltip {
|
|
2
|
+
position: absolute;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: 0.25rem;
|
|
6
|
+
background-color: var(--white);
|
|
7
|
+
padding: 0.25rem 0.5rem;
|
|
8
|
+
border: solid 1px var(--gray-300);
|
|
9
|
+
border-radius: var(--border-radius-sm);
|
|
10
|
+
z-index: 1052;
|
|
11
|
+
}
|
|
12
|
+
.ar-tooltip > span {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: row;
|
|
15
|
+
gap: 0.25rem;
|
|
16
|
+
}
|
|
17
|
+
.ar-tooltip > .text {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: row;
|
|
20
|
+
gap: 0.5rem;
|
|
21
|
+
color: var(--gray-700);
|
|
22
|
+
font-size: 0.85rem;
|
|
23
|
+
text-wrap: nowrap;
|
|
24
|
+
-webkit-text-stroke: 0.75px var(--gray-700);
|
|
25
|
+
}
|
|
26
|
+
.ar-tooltip > .text > .bullet {
|
|
27
|
+
color: var(--gray-400);
|
|
28
|
+
-webkit-text-stroke: 0px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ar-tooltip::before {
|
|
32
|
+
position: absolute;
|
|
33
|
+
content: "";
|
|
34
|
+
border: solid 7.5px transparent;
|
|
35
|
+
}
|
|
36
|
+
.ar-tooltip.top::before {
|
|
37
|
+
top: 100%;
|
|
38
|
+
left: 50%;
|
|
39
|
+
transform: translateX(-50%);
|
|
40
|
+
border-top-color: var(--gray-300);
|
|
41
|
+
}
|
|
42
|
+
.ar-tooltip.right::before {
|
|
43
|
+
top: 50%;
|
|
44
|
+
transform: translateY(-50%);
|
|
45
|
+
right: 100%;
|
|
46
|
+
border-right-color: var(--gray-300);
|
|
47
|
+
}
|
|
48
|
+
.ar-tooltip.bottom::before {
|
|
49
|
+
left: 50%;
|
|
50
|
+
transform: translateX(-50%);
|
|
51
|
+
bottom: 100%;
|
|
52
|
+
border-bottom-color: var(--gray-300);
|
|
53
|
+
}
|
|
54
|
+
.ar-tooltip.left::before {
|
|
55
|
+
top: 50%;
|
|
56
|
+
transform: translateY(-50%);
|
|
57
|
+
left: 100%;
|
|
58
|
+
border-left-color: var(--gray-300);
|
|
59
|
+
}
|
|
@@ -27,30 +27,36 @@
|
|
|
27
27
|
list-style-type: none;
|
|
28
28
|
}
|
|
29
29
|
.ar-upload-button > .ar-upload-files > ul > li {
|
|
30
|
-
|
|
31
|
-
flex-direction: column;
|
|
32
|
-
justify-content: space-between;
|
|
33
|
-
gap: 1rem;
|
|
34
|
-
padding: 0.5rem;
|
|
30
|
+
position: relative;
|
|
35
31
|
border-bottom: solid 1px var(--gray-200);
|
|
36
32
|
}
|
|
33
|
+
.ar-upload-button > .ar-upload-files > ul > li:hover > .errors {
|
|
34
|
+
display: flex;
|
|
35
|
+
}
|
|
37
36
|
.ar-upload-button > .ar-upload-files > ul > li.error {
|
|
38
37
|
border-left: solid 2px var(--danger);
|
|
39
38
|
}
|
|
40
|
-
.ar-upload-button > .ar-upload-files > ul > li
|
|
39
|
+
.ar-upload-button > .ar-upload-files > ul > li .content {
|
|
41
40
|
display: flex;
|
|
42
41
|
flex-direction: row;
|
|
43
42
|
justify-content: space-between;
|
|
44
43
|
align-items: center;
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: 2rem;
|
|
46
|
+
padding: 0 0.5rem;
|
|
45
47
|
}
|
|
46
|
-
.ar-upload-button > .ar-upload-files > ul > li
|
|
48
|
+
.ar-upload-button > .ar-upload-files > ul > li .content > span:first-child {
|
|
47
49
|
width: 90%;
|
|
48
50
|
font-size: 0.75rem;
|
|
49
51
|
text-overflow: ellipsis;
|
|
50
52
|
overflow: hidden;
|
|
51
53
|
white-space: nowrap;
|
|
52
54
|
}
|
|
53
|
-
.ar-upload-button > .ar-upload-files > ul > li
|
|
55
|
+
.ar-upload-button > .ar-upload-files > ul > li .content > span:first-child.error {
|
|
56
|
+
color: var(--danger);
|
|
57
|
+
-webkit-text-stroke: 0.5px var(--danger);
|
|
58
|
+
}
|
|
59
|
+
.ar-upload-button > .ar-upload-files > ul > li .content > span:last-child {
|
|
54
60
|
background-color: rgba(var(--danger-rgb), 0.1);
|
|
55
61
|
width: 1rem;
|
|
56
62
|
height: 1rem;
|
|
@@ -63,19 +69,4 @@
|
|
|
63
69
|
cursor: pointer;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
.ar-upload-button > .ar-upload-files > ul > li > .errors {
|
|
67
|
-
display: flex;
|
|
68
|
-
flex-direction: column;
|
|
69
|
-
list-style: circle;
|
|
70
|
-
}
|
|
71
|
-
.ar-upload-button > .ar-upload-files > ul > li > .errors > .bullet {
|
|
72
|
-
color: var(--danger);
|
|
73
|
-
}
|
|
74
|
-
.ar-upload-button > .ar-upload-files > ul > li > .errors > span {
|
|
75
|
-
display: flex;
|
|
76
|
-
gap: 0.25rem;
|
|
77
|
-
font-size: 0.75rem;
|
|
78
|
-
color: var(--danger);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
72
|
@import url("./animations.css");
|
|
@@ -6,7 +6,7 @@ import Actions from "./Actions";
|
|
|
6
6
|
import Pagination from "../../navigation/pagination";
|
|
7
7
|
import Button from "../../form/button";
|
|
8
8
|
import { ARIcon } from "../../icons";
|
|
9
|
-
const Table = function ({ children, title, description, data, columns, actions, selections, searchedParams, pagination, config = { isSearchable:
|
|
9
|
+
const Table = function ({ children, title, description, data, columns, actions, selections, searchedParams, pagination, config = { isSearchable: false }, }) {
|
|
10
10
|
// refs
|
|
11
11
|
let _dataLength = useRef(0);
|
|
12
12
|
const _tableWrapper = useRef(null);
|
|
@@ -157,7 +157,7 @@ const Table = function ({ children, title, description, data, columns, actions,
|
|
|
157
157
|
setSelectAll(allChecked);
|
|
158
158
|
}, [currentPage]);
|
|
159
159
|
return (React.createElement("div", { ref: _tableWrapper, className: _tableClassName.map((c) => c).join(" ") },
|
|
160
|
-
React.createElement("div", { className: "header" },
|
|
160
|
+
(title || description || actions) && (React.createElement("div", { className: "header" },
|
|
161
161
|
React.createElement("div", { className: "title" },
|
|
162
162
|
React.createElement("h3", null, title),
|
|
163
163
|
React.createElement("h5", null, description)),
|
|
@@ -165,7 +165,7 @@ const Table = function ({ children, title, description, data, columns, actions,
|
|
|
165
165
|
React.Children.count(children) > 0 && React.createElement("div", null, React.Children.map(children, (child) => child)),
|
|
166
166
|
actions && (React.createElement(React.Fragment, null,
|
|
167
167
|
actions.create && (React.createElement(Button, { variant: "outlined", status: "dark", icon: { element: React.createElement(ARIcon, { icon: "Add", size: 16 }) }, tooltip: { text: actions.create.tooltip, direction: "top" }, onClick: actions.create.onClick })),
|
|
168
|
-
actions.import && (React.createElement(Button, { variant: "outlined", status: "dark", icon: { element: React.createElement(ARIcon, { icon: "Import", size: 16 }) }, tooltip: { text: actions.import.tooltip, direction: "top" }, onClick: actions.import.onClick })))))),
|
|
168
|
+
actions.import && (React.createElement(Button, { variant: "outlined", status: "dark", icon: { element: React.createElement(ARIcon, { icon: "Import", size: 16 }) }, tooltip: { text: actions.import.tooltip, direction: "top" }, onClick: actions.import.onClick }))))))),
|
|
169
169
|
React.createElement("div", { ref: _tableContent, className: "content", onScroll: handleOnScroll },
|
|
170
170
|
React.createElement("table", { ref: _table },
|
|
171
171
|
React.createElement("thead", null,
|
|
@@ -284,19 +284,20 @@ const Table = function ({ children, title, description, data, columns, actions,
|
|
|
284
284
|
}) }, React.isValidElement(render) ? render : String(render)));
|
|
285
285
|
}))))) : (React.createElement("tr", null,
|
|
286
286
|
React.createElement("td", { colSpan: columns.length + 1 }, "Herhangi bir kay\u0131t bulunamad\u0131!")))))),
|
|
287
|
-
React.createElement("div", { className: "footer" },
|
|
288
|
-
React.createElement(
|
|
289
|
-
React.createElement("strong", null,
|
|
290
|
-
"Showing ",
|
|
291
|
-
getData().length),
|
|
292
|
-
" ",
|
|
287
|
+
pagination && pagination.totalRecords > pagination.perPage && (React.createElement("div", { className: "footer" },
|
|
288
|
+
React.createElement(React.Fragment, null,
|
|
293
289
|
React.createElement("span", null,
|
|
294
|
-
"
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
290
|
+
React.createElement("strong", null,
|
|
291
|
+
"Showing ",
|
|
292
|
+
getData().length),
|
|
293
|
+
" ",
|
|
294
|
+
React.createElement("span", null,
|
|
295
|
+
"of ",
|
|
296
|
+
pagination?.perPage ?? getData().length,
|
|
297
|
+
" agreement")),
|
|
298
|
+
React.createElement(Pagination, { totalRecords: pagination.totalRecords, perPage: pagination.perPage, onChange: (currentPage) => {
|
|
299
|
+
!config.isServerSide ? setCurrentPage(currentPage) : pagination.onChange(currentPage);
|
|
300
|
+
} }))))));
|
|
300
301
|
};
|
|
301
302
|
Table.Action = Actions;
|
|
302
303
|
export default Table;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import "../../../assets/css/components/feedback/tooltip/styles.css";
|
|
5
|
+
const Tooltip = ({ children, text, direction = "top" }) => {
|
|
6
|
+
// refs
|
|
7
|
+
const _arTooltip = useRef(null);
|
|
8
|
+
const _children = useRef(null);
|
|
9
|
+
// states
|
|
10
|
+
const [mouseEnter, setMouseEnter] = useState(false);
|
|
11
|
+
// methods
|
|
12
|
+
const handlePosition = () => {
|
|
13
|
+
if (_children.current && _arTooltip.current) {
|
|
14
|
+
const buttonR = _children.current.getBoundingClientRect();
|
|
15
|
+
const tooltipR = _arTooltip.current.getBoundingClientRect();
|
|
16
|
+
if (buttonR) {
|
|
17
|
+
const sx = window.scrollX || document.documentElement.scrollLeft;
|
|
18
|
+
const sy = window.scrollY || document.documentElement.scrollTop;
|
|
19
|
+
// Tooltip konumunu ayarlama için ortak bir fonksiyon.
|
|
20
|
+
const setTooltipPosition = (top, left) => {
|
|
21
|
+
if (!_arTooltip.current)
|
|
22
|
+
return;
|
|
23
|
+
_arTooltip.current.style.top = `${top + sy}px`;
|
|
24
|
+
_arTooltip.current.style.left = `${left + sx}px`;
|
|
25
|
+
};
|
|
26
|
+
const positonT = buttonR.top;
|
|
27
|
+
const positonL = buttonR.left + (sx == 0 ? 5.5 : 0);
|
|
28
|
+
const centerBX = buttonR.width / 2;
|
|
29
|
+
const centerBY = buttonR.height / 2;
|
|
30
|
+
const centerV = positonL - tooltipR.width + tooltipR.width / 2 + centerBX;
|
|
31
|
+
const margin = 17.5;
|
|
32
|
+
switch (direction) {
|
|
33
|
+
case "top":
|
|
34
|
+
{
|
|
35
|
+
const top = positonT - tooltipR.height - margin;
|
|
36
|
+
const left = centerV;
|
|
37
|
+
setTooltipPosition(top, left);
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
case "right":
|
|
41
|
+
{
|
|
42
|
+
const top = positonT + centerBY - tooltipR.height / 2;
|
|
43
|
+
const left = positonL + buttonR.width + margin;
|
|
44
|
+
setTooltipPosition(top, left);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
case "bottom":
|
|
48
|
+
{
|
|
49
|
+
const top = positonT + buttonR.height + margin;
|
|
50
|
+
const left = centerV;
|
|
51
|
+
setTooltipPosition(top, left);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case "left":
|
|
55
|
+
{
|
|
56
|
+
const top = positonT + centerBY - tooltipR.height / 2;
|
|
57
|
+
const left = positonL - tooltipR.width - margin;
|
|
58
|
+
setTooltipPosition(top, left);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
//useEffects
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (mouseEnter)
|
|
68
|
+
setTimeout(() => handlePosition(), 0);
|
|
69
|
+
}, [mouseEnter]);
|
|
70
|
+
return (React.createElement("div", { ref: _arTooltip, className: "ar-tooltip-wrapper" },
|
|
71
|
+
React.createElement("div", { ref: _children, onMouseEnter: () => setMouseEnter(true), onMouseLeave: () => setMouseEnter(false) }, children),
|
|
72
|
+
mouseEnter &&
|
|
73
|
+
ReactDOM.createPortal(React.createElement("div", { ref: _arTooltip, className: `ar-tooltip ${direction}` }, Array.isArray(text) ? (text.map((t) => (React.createElement("span", { className: "text" },
|
|
74
|
+
React.createElement("span", { className: "bullet" }, "\u2022"),
|
|
75
|
+
React.createElement("span", null, t))))) : (React.createElement("span", { className: "text" }, text))), document.body)));
|
|
76
|
+
};
|
|
77
|
+
Tooltip.displayName = "Tooltip";
|
|
78
|
+
export default Tooltip;
|
|
@@ -18,7 +18,7 @@ interface IProps extends Omit<IGlobalProps, "children" | "disabled">, ISizes, Re
|
|
|
18
18
|
shape?: "circle" | "square";
|
|
19
19
|
tooltip?: {
|
|
20
20
|
text: string;
|
|
21
|
-
direction
|
|
21
|
+
direction?: "top" | "right" | "left" | "bottom";
|
|
22
22
|
};
|
|
23
23
|
position?: {
|
|
24
24
|
type: "fixed" | "absolute";
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import React, {
|
|
3
|
-
import "../../../assets/css/components/form/button/
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
|
+
import "../../../assets/css/components/form/button/styles.css";
|
|
4
4
|
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
5
|
-
import
|
|
5
|
+
import Tooltip from "../../feedback/tooltip";
|
|
6
6
|
const Button = ({ children, variant = "filled", shape, status = "primary", border, size = "normal", tooltip, position, icon, upperCase, ...attributes }) => {
|
|
7
7
|
// refs
|
|
8
8
|
const _button = useRef(null);
|
|
9
|
-
const _arButtonTooltip = useRef(null);
|
|
10
9
|
const _buttonClassName = ["ar-button"];
|
|
11
10
|
_buttonClassName.push(...Utils.GetClassName(variant, status, border, size, icon, attributes.className));
|
|
12
11
|
if (!children)
|
|
@@ -17,108 +16,26 @@ const Button = ({ children, variant = "filled", shape, status = "primary", borde
|
|
|
17
16
|
_buttonClassName.push(position.type);
|
|
18
17
|
_buttonClassName.push(position.inset.map((_inset) => _inset).join(" "));
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const setTooltipPosition = (top, left) => {
|
|
33
|
-
if (!_arButtonTooltip.current)
|
|
34
|
-
return;
|
|
35
|
-
_arButtonTooltip.current.style.top = `${top + sy}px`;
|
|
36
|
-
_arButtonTooltip.current.style.left = `${left + sx}px`;
|
|
37
|
-
};
|
|
38
|
-
const positonT = buttonR.top;
|
|
39
|
-
const positonL = buttonR.left + (sx == 0 ? 5.5 : 0);
|
|
40
|
-
const centerBX = buttonR.width / 2;
|
|
41
|
-
const centerBY = buttonR.height / 2;
|
|
42
|
-
const centerV = positonL - tooltipR.width + tooltipR.width / 2 + centerBX;
|
|
43
|
-
const margin = 17.5;
|
|
44
|
-
switch (tooltip.direction) {
|
|
45
|
-
case "top":
|
|
46
|
-
{
|
|
47
|
-
const top = positonT - tooltipR.height - margin;
|
|
48
|
-
const left = centerV;
|
|
49
|
-
setTooltipPosition(top, left);
|
|
50
|
-
}
|
|
51
|
-
break;
|
|
52
|
-
case "right":
|
|
53
|
-
{
|
|
54
|
-
const top = positonT + centerBY - tooltipR.height / 2;
|
|
55
|
-
const left = positonL + buttonR.width + margin;
|
|
56
|
-
setTooltipPosition(top, left);
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case "bottom":
|
|
60
|
-
{
|
|
61
|
-
const top = positonT + buttonR.height + margin;
|
|
62
|
-
const left = centerV;
|
|
63
|
-
setTooltipPosition(top, left);
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
case "left":
|
|
67
|
-
{
|
|
68
|
-
const top = positonT + centerBY - tooltipR.height / 2;
|
|
69
|
-
const left = positonL - tooltipR.width - margin;
|
|
70
|
-
setTooltipPosition(top, left);
|
|
71
|
-
}
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
19
|
+
const buttonElement = (React.createElement("button", { ref: _button, ...attributes, className: _buttonClassName.map((c) => c).join(" "), onClick: (event) => {
|
|
20
|
+
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
21
|
+
if (attributes.disabled)
|
|
22
|
+
return;
|
|
23
|
+
(() => {
|
|
24
|
+
const _current = _button.current;
|
|
25
|
+
const addClass = "active";
|
|
26
|
+
if (_current && !_current.classList.contains(addClass)) {
|
|
27
|
+
// Sınıf ekleniyor...
|
|
28
|
+
_current.classList.add(addClass);
|
|
29
|
+
// Sınıf 500 milisaniye sonra kaldırlacak.
|
|
30
|
+
setTimeout(() => _current.classList.remove(addClass), 750);
|
|
74
31
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
return (React.createElement(React.Fragment, null,
|
|
83
|
-
React.createElement("button", { ref: _button, ...attributes, onMouseEnter: (event) => {
|
|
84
|
-
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
85
|
-
if (attributes.disabled)
|
|
86
|
-
return;
|
|
87
|
-
(() => {
|
|
88
|
-
setMouseEnter(true);
|
|
89
|
-
})();
|
|
90
|
-
(() => attributes.onMouseEnter && attributes.onMouseEnter(event))();
|
|
91
|
-
}, onMouseLeave: (event) => {
|
|
92
|
-
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
93
|
-
if (attributes.disabled)
|
|
94
|
-
return;
|
|
95
|
-
(() => {
|
|
96
|
-
setMouseEnter(false);
|
|
97
|
-
})();
|
|
98
|
-
(() => attributes.onMouseLeave && attributes.onMouseLeave(event))();
|
|
99
|
-
}, className: _buttonClassName.map((c) => c).join(" "), onClick: (event) => {
|
|
100
|
-
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
101
|
-
if (attributes.disabled)
|
|
102
|
-
return;
|
|
103
|
-
(() => {
|
|
104
|
-
const _current = _button.current;
|
|
105
|
-
const addClass = "active";
|
|
106
|
-
if (_current && !_current.classList.contains(addClass)) {
|
|
107
|
-
// Sınıf ekleniyor...
|
|
108
|
-
_current.classList.add(addClass);
|
|
109
|
-
// Sınıf 500 milisaniye sonra kaldırlacak.
|
|
110
|
-
setTimeout(() => _current.classList.remove(addClass), 750);
|
|
111
|
-
}
|
|
112
|
-
})();
|
|
113
|
-
(() => attributes.onClick && attributes.onClick(event))();
|
|
114
|
-
} },
|
|
115
|
-
React.createElement("span", { className: "text" },
|
|
116
|
-
icon?.element,
|
|
117
|
-
React.createElement("span", null, !shape ? (typeof children === "string" && upperCase ? children.toLocaleUpperCase() : children) : ""))),
|
|
118
|
-
tooltip &&
|
|
119
|
-
mouseEnter &&
|
|
120
|
-
ReactDOM.createPortal(React.createElement("div", { ref: _arButtonTooltip, className: `ar-button-tooltip ${tooltip.direction}` },
|
|
121
|
-
React.createElement("span", null, tooltip.text)), document.body)));
|
|
32
|
+
})();
|
|
33
|
+
(() => attributes.onClick && attributes.onClick(event))();
|
|
34
|
+
} },
|
|
35
|
+
React.createElement("span", { className: "text" },
|
|
36
|
+
icon?.element,
|
|
37
|
+
React.createElement("span", null, !shape ? (typeof children === "string" && upperCase ? children.toLocaleUpperCase() : children) : ""))));
|
|
38
|
+
return !tooltip ? (buttonElement) : (React.createElement(Tooltip, { text: tooltip.text, direction: tooltip.direction }, buttonElement));
|
|
122
39
|
};
|
|
123
40
|
Button.displayName = "Button";
|
|
124
41
|
export default Button;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { AllowedTypes } from "../../../libs/types";
|
|
1
2
|
import { IValidation } from "../../../libs/types/IGlobalProps";
|
|
2
3
|
interface IMultiple {
|
|
3
4
|
file: File[];
|
|
4
|
-
onChange: (formData: FormData, files: File[]) => void;
|
|
5
|
+
onChange: (formData: FormData, files: File[], isInvalidFileExist: boolean) => void;
|
|
5
6
|
multiple: true;
|
|
6
7
|
}
|
|
7
8
|
interface ISingle {
|
|
@@ -11,6 +12,8 @@ interface ISingle {
|
|
|
11
12
|
}
|
|
12
13
|
type Props = {
|
|
13
14
|
text: string;
|
|
15
|
+
allowedTypes?: AllowedTypes[];
|
|
16
|
+
maxSize?: number;
|
|
14
17
|
disabled?: boolean;
|
|
15
18
|
} & (IMultiple | ISingle) & IValidation;
|
|
16
19
|
export default Props;
|
|
@@ -2,7 +2,8 @@ import React, { useEffect, useRef, useState } from "react";
|
|
|
2
2
|
import "../../../assets/css/components/form/upload/styles.css";
|
|
3
3
|
import { ARIcon } from "../../icons";
|
|
4
4
|
import Button from "../button";
|
|
5
|
-
|
|
5
|
+
import Tooltip from "../../feedback/tooltip";
|
|
6
|
+
const Upload = ({ text, file, onChange, allowedTypes, maxSize, multiple }) => {
|
|
6
7
|
// refs
|
|
7
8
|
const _firstLoad = useRef(false);
|
|
8
9
|
const _input = useRef(null);
|
|
@@ -41,15 +42,18 @@ const Upload = ({ text, file, onChange, multiple }) => {
|
|
|
41
42
|
};
|
|
42
43
|
const handleValidationFile = (file) => {
|
|
43
44
|
const newErrors = [];
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
if (allowedTypes) {
|
|
46
|
+
if (!allowedTypes.includes(file.type)) {
|
|
47
|
+
newErrors.push({ [file.name]: "Geçersiz dosya türü." });
|
|
48
|
+
_validationErrors.current.push(file.name);
|
|
49
|
+
}
|
|
49
50
|
}
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (maxSize) {
|
|
52
|
+
const _maxSize = maxSize * 1024 * 1024; // 5MB
|
|
53
|
+
if (file.size > _maxSize) {
|
|
54
|
+
newErrors.push({ [file.name]: "Dosya boyutu çok büyük." });
|
|
55
|
+
_validationErrors.current.push(file.name);
|
|
56
|
+
}
|
|
53
57
|
}
|
|
54
58
|
setValidationErrors((prev) => [...prev, ...newErrors]);
|
|
55
59
|
};
|
|
@@ -70,7 +74,7 @@ const Upload = ({ text, file, onChange, multiple }) => {
|
|
|
70
74
|
// Geçerli olan dosyalar alındı...
|
|
71
75
|
const validFiles = [...selectedFiles.filter((x) => !inValidFiles.includes(x.name))];
|
|
72
76
|
validFiles.forEach((f) => fileFormData.append("file", f));
|
|
73
|
-
onChange(fileFormData, validFiles);
|
|
77
|
+
onChange(fileFormData, validFiles, _validationErrors.current.length === 0);
|
|
74
78
|
}
|
|
75
79
|
else {
|
|
76
80
|
if (selectedFile) {
|
|
@@ -105,16 +109,13 @@ const Upload = ({ text, file, onChange, multiple }) => {
|
|
|
105
109
|
.map((error) => error[selectedFile.name]);
|
|
106
110
|
if (errorMessages.length > 0)
|
|
107
111
|
_className.push("error");
|
|
108
|
-
|
|
109
|
-
React.createElement("
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
errorMessages.length > 0 && (React.createElement("div", { className: "errors" }, errorMessages.map((message, i) => (React.createElement("span", { key: i },
|
|
116
|
-
React.createElement("span", { className: "bullet" }, "\u2022"),
|
|
117
|
-
React.createElement("span", null, message))))))));
|
|
112
|
+
const content = (React.createElement("div", { className: "content" },
|
|
113
|
+
React.createElement("span", { className: _className.map((c) => c).join(" ") }, selectedFile.name),
|
|
114
|
+
React.createElement("span", { onClick: (event) => {
|
|
115
|
+
event.stopPropagation();
|
|
116
|
+
handleFileRemove(selectedFile);
|
|
117
|
+
} }, "x")));
|
|
118
|
+
return (React.createElement("li", { key: index, className: _className.map((c) => c).join(" ") }, errorMessages.length === 0 ? (content) : (React.createElement(Tooltip, { text: errorMessages.map((message) => message ?? "") }, content))));
|
|
118
119
|
}))))));
|
|
119
120
|
};
|
|
120
121
|
export default Upload;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,9 +23,10 @@ import Alert from "./components/feedback/alert";
|
|
|
23
23
|
import Modal from "./components/feedback/modal";
|
|
24
24
|
import Popover from "./components/feedback/popover";
|
|
25
25
|
import Progress from "./components/feedback/progress";
|
|
26
|
+
import Tooltip from "./components/feedback/tooltip";
|
|
26
27
|
import Breadcrumb from "./components/navigation/breadcrumb";
|
|
27
28
|
import Menu from "./components/navigation/menu";
|
|
28
29
|
import Steps from "./components/navigation/steps";
|
|
29
30
|
import Grid from "./components/layout/grid-system";
|
|
30
31
|
import Layout from "./components/layout";
|
|
31
|
-
export { Button, ButtonAction, ButtonGroup, Input, InputTag, DatePicker, Select, Switch, Upload, Checkbox, Radio, Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Modal, Popover, Progress, Breadcrumb, Menu, Steps, Grid, Layout, };
|
|
32
|
+
export { Button, ButtonAction, ButtonGroup, Input, InputTag, DatePicker, Select, Switch, Upload, Checkbox, Radio, Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Modal, Popover, Progress, Tooltip, Breadcrumb, Menu, Steps, Grid, Layout, };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import Alert from "./components/feedback/alert";
|
|
|
26
26
|
import Modal from "./components/feedback/modal";
|
|
27
27
|
import Popover from "./components/feedback/popover";
|
|
28
28
|
import Progress from "./components/feedback/progress";
|
|
29
|
+
import Tooltip from "./components/feedback/tooltip";
|
|
29
30
|
// Navigation
|
|
30
31
|
import Breadcrumb from "./components/navigation/breadcrumb";
|
|
31
32
|
import Menu from "./components/navigation/menu";
|
|
@@ -39,7 +40,7 @@ Button, ButtonAction, ButtonGroup, Input, InputTag, DatePicker, Select, Switch,
|
|
|
39
40
|
// Data Display
|
|
40
41
|
Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography,
|
|
41
42
|
// Feedback
|
|
42
|
-
Alert, Modal, Popover, Progress,
|
|
43
|
+
Alert, Modal, Popover, Progress, Tooltip,
|
|
43
44
|
// Navigation
|
|
44
45
|
Breadcrumb, Menu, Steps,
|
|
45
46
|
// Layout
|
|
@@ -60,6 +60,7 @@ export type ValidationProperties<T> = {
|
|
|
60
60
|
export type Errors<TData> = Partial<{
|
|
61
61
|
[key in keyof TData]: string;
|
|
62
62
|
}>;
|
|
63
|
+
export type AllowedTypes = "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/svg+xml" | "image/bmp" | "image/tiff" | "application/pdf" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/zip" | "application/x-rar-compressed" | "application/x-7z-compressed" | "application/gzip" | "application/json" | "application/xml" | "text/plain" | "text/csv" | "text/html" | "video/mp4" | "video/quicktime" | "video/x-msvideo" | "video/x-matroska" | "video/webm" | "video/x-flv" | "audio/mpeg" | "audio/wav" | "audio/ogg" | "audio/aac" | "audio/flac" | "application/octet-stream";
|
|
63
64
|
export type PieChartDataType = {
|
|
64
65
|
value: number;
|
|
65
66
|
text: string;
|
package/package.json
CHANGED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.ar-button-tooltip {
|
|
2
|
-
position: absolute;
|
|
3
|
-
background-color: var(--black);
|
|
4
|
-
padding: 0.25rem 0.5rem;
|
|
5
|
-
border-radius: var(--border-radius-sm);
|
|
6
|
-
z-index: 15;
|
|
7
|
-
}
|
|
8
|
-
.ar-button-tooltip::before {
|
|
9
|
-
position: absolute;
|
|
10
|
-
content: "";
|
|
11
|
-
border: solid 7.5px transparent;
|
|
12
|
-
}
|
|
13
|
-
.ar-button-tooltip.top::before {
|
|
14
|
-
top: 100%;
|
|
15
|
-
left: 50%;
|
|
16
|
-
transform: translateX(-50%);
|
|
17
|
-
border-top-color: var(--black);
|
|
18
|
-
}
|
|
19
|
-
.ar-button-tooltip.right::before {
|
|
20
|
-
top: 50%;
|
|
21
|
-
transform: translateY(-50%);
|
|
22
|
-
right: 100%;
|
|
23
|
-
border-right-color: var(--black);
|
|
24
|
-
}
|
|
25
|
-
.ar-button-tooltip.bottom::before {
|
|
26
|
-
left: 50%;
|
|
27
|
-
transform: translateX(-50%);
|
|
28
|
-
bottom: 100%;
|
|
29
|
-
border-bottom-color: var(--black);
|
|
30
|
-
}
|
|
31
|
-
.ar-button-tooltip.left::before {
|
|
32
|
-
top: 50%;
|
|
33
|
-
transform: translateY(-50%);
|
|
34
|
-
left: 100%;
|
|
35
|
-
border-left-color: var(--black);
|
|
36
|
-
}
|
|
37
|
-
.ar-button-tooltip > span {
|
|
38
|
-
color: var(--white);
|
|
39
|
-
text-wrap: nowrap;
|
|
40
|
-
}
|