ar-design 0.1.61 → 0.1.63

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.
@@ -12,7 +12,7 @@
12
12
  padding: 10px;
13
13
  border-radius: var(--border-radius-sm);
14
14
  box-shadow: 0 0 15px -2.5px rgba(var(--black-rgb), 0.1);
15
- z-index: 5;
15
+ z-index: 1051;
16
16
  }
17
17
 
18
18
  .ar-confirm > .content {
@@ -5,6 +5,6 @@
5
5
  border: solid 1px var(--gray-200);
6
6
  border-radius: var(--border-radius-lg);
7
7
  box-shadow: 0 0 10px -5px rgba(var(--black-rgb), 0.25);
8
- z-index: 15;
8
+ z-index: 1051;
9
9
  transition: visibility 250ms, opacity 250ms ease-in-out;
10
10
  }
@@ -10,7 +10,7 @@
10
10
  border: solid 1px var(--gray-200);
11
11
  border-radius: var(--border-radius-lg);
12
12
  box-shadow: 0 0 10px -5px rgba(var(--black-rgb), 0.25);
13
- z-index: 5;
13
+ z-index: 1051;
14
14
  user-select: none;
15
15
  }
16
16
  .ar-date-calendar > .clock.active {
@@ -0,0 +1,14 @@
1
+ @keyframes count {
2
+ 0% {
3
+ transform: scale(1);
4
+ }
5
+ 50% {
6
+ box-shadow: 0 0 0 2.5px rgba(var(--warning-rgb), 0.25);
7
+ color: var(--warning);
8
+ -webkit-text-stroke: 1px var(--warning);
9
+ transform: scale(1.25);
10
+ }
11
+ 100% {
12
+ transform: scale(1);
13
+ }
14
+ }
@@ -0,0 +1,102 @@
1
+ .ar-upload {
2
+ position: relative;
3
+ width: 8.5rem;
4
+ }
5
+ .ar-upload > input {
6
+ display: none;
7
+ }
8
+
9
+ .ar-upload > .ar-upload-button > .count {
10
+ position: absolute;
11
+ top: 8px;
12
+ left: 42.5px;
13
+ display: flex;
14
+ flex-direction: row;
15
+ justify-content: center;
16
+ align-items: center;
17
+ background-color: var(--white);
18
+ width: 1.25rem;
19
+ height: 1.25rem;
20
+ border-radius: var(--border-radius-pill);
21
+ box-shadow: 0 0 0 2.5px rgba(var(--black-rgb), 0.1);
22
+ color: var(--success);
23
+ font-size: 0.75rem;
24
+ -webkit-text-stroke: 1px var(--success);
25
+ user-select: none;
26
+ }
27
+ .ar-upload > .ar-upload-button > .count.changed {
28
+ animation: count cubic-bezier(0.23, 1, 0.32, 1) 250ms 0s 1 normal both;
29
+ }
30
+ .ar-upload > .ar-upload-button > button {
31
+ display: flex;
32
+ flex-direction: column;
33
+ justify-content: center;
34
+ align-items: center;
35
+ gap: 0.5rem 0;
36
+ background-color: rgba(var(--success-rgb), 0.1);
37
+ width: 100%;
38
+ padding: 0.75rem 1rem;
39
+ border: dashed 2px rgba(var(--success-rgb), 0.5);
40
+ border-radius: var(--border-radius-sm);
41
+ cursor: pointer;
42
+ color: var(--success);
43
+ box-shadow: 0 0 0 2.5px rgba(var(--success-rgb), 0.1);
44
+ }
45
+
46
+ .ar-upload > .ar-upload-button .selected-files {
47
+ list-style: none;
48
+ }
49
+ .ar-upload > .ar-upload-button .selected-files > li {
50
+ display: flex;
51
+ flex-direction: row;
52
+ gap: 0 0.5rem;
53
+ }
54
+ .ar-upload > .ar-upload-button .selected-files > li > span:first-child {
55
+ font-size: 0.15rem;
56
+ }
57
+
58
+ .ar-upload-files {
59
+ position: absolute;
60
+ background-color: var(--white);
61
+ width: 250px;
62
+ border-radius: var(--border-radius-sm);
63
+ box-shadow: 0 0 15px -2.5px rgba(var(--black-rgb), 0.1);
64
+ z-index: 5;
65
+ transition: top 250ms ease-in-out;
66
+ }
67
+ .ar-upload-files::after {
68
+ position: absolute;
69
+ top: 10px;
70
+ left: 100%;
71
+ content: "";
72
+ border: solid 5px transparent;
73
+ border-left-color: var(--white);
74
+ }
75
+ .ar-upload-files > ul {
76
+ display: flex;
77
+ flex-direction: column;
78
+ list-style-type: none;
79
+ }
80
+ .ar-upload-files > ul > li {
81
+ display: flex;
82
+ flex-direction: row;
83
+ justify-content: space-between;
84
+ align-items: center;
85
+ padding: 0.5rem;
86
+ border-bottom: solid 1px var(--gray-200);
87
+ }
88
+ .ar-upload-files > ul > li:last-child {
89
+ border-bottom: none;
90
+ }
91
+ .ar-upload-files > ul > li > span:first-child {
92
+ width: 90%;
93
+ font-size: 0.75rem;
94
+ text-overflow: ellipsis;
95
+ overflow: hidden;
96
+ white-space: nowrap;
97
+ }
98
+ .ar-upload-files > ul > li > span:last-child {
99
+ cursor: pointer;
100
+ }
101
+
102
+ @import url("./animations.css");
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none"><path d="m9.17 14.83 5.66-5.66M14.83 14.83 9.17 9.17M9 22h6c5 0 7-2 7-7V9c0-5-2-7-7-7H9C4 2 2 4 2 9v6c0 5 2 7 7 7Z" stroke="#FF8A65" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>
@@ -31,7 +31,6 @@ const Confirm = ({ children, title, message, content, onConfirm }) => {
31
31
  const screenCenter = window.innerHeight / 2;
32
32
  const sx = window.scrollX || document.documentElement.scrollLeft;
33
33
  const sy = window.scrollY || document.documentElement.scrollTop;
34
- console.log(screenCenter, elementRect.top);
35
34
  _arConfirm.current.style.top = `${(elementRect.top > screenCenter
36
35
  ? elementRect.top - confirmRect.height + elementRect.height
37
36
  : elementRect.top) + sy}px`;
@@ -0,0 +1,15 @@
1
+ import { IValidation } from "../../../libs/types/IGlobalProps";
2
+ interface IMultiple {
3
+ file: FormData[];
4
+ onChange: (files: FormData) => void;
5
+ multiple: true;
6
+ }
7
+ interface ISingle {
8
+ file: FormData | undefined;
9
+ onChange: (file: FormData | undefined) => void;
10
+ multiple?: false;
11
+ }
12
+ type Props = {
13
+ disabled?: boolean;
14
+ } & (IMultiple | ISingle) & IValidation;
15
+ export default Props;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import Props from "./Props";
3
+ import "../../../assets/css/components/form/upload/styles.css";
4
+ declare const Upload: React.FC<Props>;
5
+ export default Upload;
@@ -0,0 +1,119 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import "../../../assets/css/components/form/upload/styles.css";
3
+ import Icons from "../../../libs/infrastructure/shared/Icons";
4
+ import ReactDOM from "react-dom";
5
+ const Upload = ({ file, onChange, multiple }) => {
6
+ // refs
7
+ const _input = useRef(null);
8
+ const _arUplaod = useRef(null);
9
+ const _arUplaodFiles = useRef(null);
10
+ const _count = useRef(null);
11
+ const _countInterval = useRef();
12
+ // states
13
+ const [open, setOpen] = useState(false);
14
+ const [selectedFiles, setSelectedFiles] = useState([]);
15
+ // methods
16
+ const handleClickOutSide = (event) => {
17
+ const target = event.target;
18
+ if (_arUplaodFiles.current && !_arUplaodFiles.current.contains(target))
19
+ setOpen(false);
20
+ };
21
+ const handleKeys = (event) => {
22
+ const key = event.key;
23
+ if (key === "Escape")
24
+ setOpen(false);
25
+ };
26
+ const handlePosition = () => {
27
+ if (_arUplaod.current && _arUplaodFiles.current) {
28
+ const wRect = _arUplaod.current.getBoundingClientRect(); // Wrapper
29
+ const ufRect = _arUplaodFiles.current.getBoundingClientRect(); // Popup
30
+ const screenCenter = window.innerHeight / 2;
31
+ const sx = window.scrollX || document.documentElement.scrollLeft;
32
+ const sy = window.scrollY || document.documentElement.scrollTop;
33
+ if (multiple) {
34
+ _arUplaodFiles.current.style.top = `${(wRect.top > screenCenter ? wRect.top - ufRect.height + wRect.height : wRect.top) + sy}px`;
35
+ }
36
+ else {
37
+ _arUplaodFiles.current.style.top = `${wRect.top + sy}px`;
38
+ }
39
+ _arUplaodFiles.current.style.left = `${wRect.left - ufRect.width + sx - 10}px`;
40
+ }
41
+ };
42
+ const handleFileChange = (event) => {
43
+ const filesArray = Array.from(event.target.files ?? []);
44
+ setSelectedFiles(filesArray);
45
+ if (filesArray.length > 0) {
46
+ const formData = new FormData();
47
+ if (multiple) {
48
+ filesArray.forEach((file) => formData.append("file", file));
49
+ onChange(formData);
50
+ }
51
+ else {
52
+ formData.append("file", filesArray[0]);
53
+ onChange(formData);
54
+ }
55
+ }
56
+ };
57
+ const handleFileRemove = (fileToRemove) => {
58
+ setSelectedFiles((prev) => prev.filter((x) => x.name !== fileToRemove.name));
59
+ // Dosyayı input'tan kaldırmak için input'un value'sunu sıfırla
60
+ if (_input.current) {
61
+ const inputFiles = Array.from(_input.current.files ?? []);
62
+ const updatedFiles = inputFiles.filter((file) => file.name !== fileToRemove.name);
63
+ const dataTransfer = new DataTransfer();
64
+ updatedFiles.forEach((file) => dataTransfer.items.add(file));
65
+ // input'un files özelliğini güncelle
66
+ _input.current.files = dataTransfer.files;
67
+ }
68
+ };
69
+ // useEffects
70
+ useEffect(() => {
71
+ handlePosition();
72
+ if (_count.current) {
73
+ _count.current.classList.add("changed");
74
+ _countInterval.current = setTimeout(() => {
75
+ _count.current?.classList.remove("changed");
76
+ clearTimeout(_countInterval.current);
77
+ }, 250);
78
+ }
79
+ }, [selectedFiles]);
80
+ useEffect(() => {
81
+ if (_input.current) {
82
+ const dataTransfer = new DataTransfer();
83
+ _input.current.files = dataTransfer.files;
84
+ }
85
+ }, [file]);
86
+ useEffect(() => {
87
+ if (open) {
88
+ handlePosition();
89
+ // window.addEventListener("blur", () => setOpen(false));
90
+ document.addEventListener("click", handleClickOutSide);
91
+ document.addEventListener("keydown", handleKeys);
92
+ }
93
+ return () => {
94
+ window.removeEventListener("blur", () => setOpen(false));
95
+ document.removeEventListener("click", handleClickOutSide);
96
+ document.removeEventListener("keydown", handleKeys);
97
+ };
98
+ }, [open]);
99
+ return (React.createElement("div", { ref: _arUplaod, className: "ar-upload" },
100
+ React.createElement("input", { ref: _input, type: "file", onChange: handleFileChange, multiple: multiple }),
101
+ React.createElement("div", { className: "ar-upload-button" },
102
+ React.createElement("span", { ref: _count, className: "count", onClick: () => setOpen((prev) => !prev) }, selectedFiles.length),
103
+ React.createElement("button", { onClick: () => {
104
+ if (_input.current)
105
+ _input.current.click();
106
+ } },
107
+ Icons.Upload,
108
+ React.createElement("span", null, "Dosya Y\u00FCkle"))),
109
+ open &&
110
+ selectedFiles.length > 0 &&
111
+ ReactDOM.createPortal(React.createElement("div", { ref: _arUplaodFiles, className: "ar-upload-files" },
112
+ React.createElement("ul", null, selectedFiles.map((selectedFile, index) => (React.createElement("li", { key: index },
113
+ React.createElement("span", null, selectedFile.name),
114
+ React.createElement("span", { onClick: (event) => {
115
+ event.stopPropagation();
116
+ handleFileRemove(selectedFile);
117
+ } }, Icons.CrudProcesses.Trash)))))), document.body)));
118
+ };
119
+ export default Upload;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const CloseSquare: React.FC;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ export const CloseSquare = () => {
3
+ return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "32", height: "32", viewBox: "0 0 24 24", fill: "none" },
4
+ React.createElement("path", { d: "m9.17 14.83 5.66-5.66M14.83 14.83 9.17 9.17M9 22h6c5 0 7-2 7-7V9c0-5-2-7-7-7H9C4 2 2 4 2 9v6c0 5 2 7 7 7Z", stroke: "#FF8A65", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" })));
5
+ };
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import DatePicker from "./components/form/date-picker";
7
7
  import Select from "./components/form/select";
8
8
  import Checkbox from "./components/form/checkbox";
9
9
  import Switch from "./components/form/switch";
10
+ import Upload from "./components/form/upload";
10
11
  import Radio from "./components/form/radio";
11
12
  import Card from "./components/data-display/card";
12
13
  import Chip from "./components/data-display/chip";
@@ -25,4 +26,4 @@ import Menu from "./components/navigation/menu";
25
26
  import Steps from "./components/navigation/steps";
26
27
  import Grid from "./components/layout/grid-system";
27
28
  import Layout from "./components/layout";
28
- export { Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Checkbox, Radio, Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Confirm, Modal, Progress, Menu, Steps, Grid, Layout, };
29
+ export { Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Upload, Checkbox, Radio, Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Confirm, Modal, Progress, Menu, Steps, Grid, Layout, };
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ import DatePicker from "./components/form/date-picker";
8
8
  import Select from "./components/form/select";
9
9
  import Checkbox from "./components/form/checkbox";
10
10
  import Switch from "./components/form/switch";
11
+ import Upload from "./components/form/upload";
11
12
  import Radio from "./components/form/radio";
12
13
  // Data Display
13
14
  import Card from "./components/data-display/card";
@@ -32,7 +33,7 @@ import Grid from "./components/layout/grid-system";
32
33
  import Layout from "./components/layout";
33
34
  export {
34
35
  // Form Elements
35
- Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Checkbox, Radio,
36
+ Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Upload, Checkbox, Radio,
36
37
  // Data Display
37
38
  Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography,
38
39
  // Feedback
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ declare const Icons: {
3
+ CrudProcesses: {
4
+ Trash: React.JSX.Element;
5
+ };
6
+ Close: React.JSX.Element;
7
+ Upload: React.JSX.Element;
8
+ };
9
+ export default Icons;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ const Icons = {
3
+ CrudProcesses: {
4
+ Trash: (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none" },
5
+ React.createElement("path", { d: "M21.07 5.23c-1.61-.16-3.22-.28-4.84-.37v-.01l-.22-1.3c-.15-.92-.37-2.3-2.71-2.3h-2.62c-2.33 0-2.55 1.32-2.71 2.29l-.21 1.28c-.93.06-1.86.12-2.79.21l-2.04.2c-.42.04-.72.41-.68.82.04.41.4.71.82.67l2.04-.2c5.24-.52 10.52-.32 15.82.21h.08c.38 0 .71-.29.75-.68a.766.766 0 0 0-.69-.82Z", fill: "var(--gray-500)" }),
6
+ React.createElement("path", { opacity: ".399", d: "M19.23 8.14c-.24-.25-.57-.39-.91-.39H5.68c-.34 0-.68.14-.91.39-.23.25-.36.59-.34.94l.62 10.26c.11 1.52.25 3.42 3.74 3.42h6.42c3.49 0 3.63-1.89 3.74-3.42l.62-10.25c.02-.36-.11-.7-.34-.95Z", fill: "var(--gray-500)" }),
7
+ React.createElement("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M9.58 17a.75.75 0 0 1 .75-.75h3.33a.75.75 0 0 1 0 1.5h-3.33a.75.75 0 0 1-.75-.75ZM8.75 13a.75.75 0 0 1 .75-.75h5a.75.75 0 0 1 0 1.5h-5a.75.75 0 0 1-.75-.75Z", fill: "var(--gray-500)" }))),
8
+ },
9
+ Close: (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "32", height: "32", viewBox: "0 0 24 24", fill: "none" },
10
+ React.createElement("path", { opacity: ".4", d: "M16.19 2H7.81C4.17 2 2 4.17 2 7.81v8.37C2 19.83 4.17 22 7.81 22h8.37c3.64 0 5.81-2.17 5.81-5.81V7.81C22 4.17 19.83 2 16.19 2Z", fill: "#FF8A65" }),
11
+ React.createElement("path", { d: "m13.06 12 2.3-2.3c.29-.29.29-.77 0-1.06a.754.754 0 0 0-1.06 0l-2.3 2.3-2.3-2.3a.754.754 0 0 0-1.06 0c-.29.29-.29.77 0 1.06l2.3 2.3-2.3 2.3c-.29.29-.29.77 0 1.06.15.15.34.22.53.22s.38-.07.53-.22l2.3-2.3 2.3 2.3c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06l-2.3-2.3Z", fill: "#FF8A65" }))),
12
+ Upload: (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "32", height: "32", viewBox: "0 0 24 24", fill: "none" },
13
+ React.createElement("path", { opacity: ".4", d: "M20.5 10.19h-2.89c-2.37 0-4.3-1.93-4.3-4.3V3c0-.55-.45-1-1-1H8.07C4.99 2 2.5 4 2.5 7.57v8.86C2.5 20 4.99 22 8.07 22h7.86c3.08 0 5.57-2 5.57-5.57v-5.24c0-.55-.45-1-1-1Z", fill: "var(--success)" }),
14
+ React.createElement("path", { d: "M15.8 2.21c-.41-.41-1.12-.13-1.12.44v3.49c0 1.46 1.24 2.67 2.75 2.67.95.01 2.27.01 3.4.01.57 0 .87-.67.47-1.07-1.44-1.45-4.02-4.06-5.5-5.54ZM11.53 12.47l-2-2c-.01-.01-.02-.01-.02-.02a.855.855 0 0 0-.22-.15h-.02c-.08-.03-.16-.04-.24-.05h-.08c-.06 0-.13.02-.19.04-.03.01-.05.02-.07.03-.08.04-.16.08-.22.15l-2 2c-.29.29-.29.77 0 1.06.29.29.77.29 1.06 0l.72-.72V17c0 .41.34.75.75.75s.75-.34.75-.75v-4.19l.72.72c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06Z", fill: "var(--success)" }))),
15
+ };
16
+ export default Icons;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
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
9
  "./@charts": "./dist/components/charts/index.js",
10
+ "./@icons": "./dist/components/icons/index.js",
10
11
  "./@service": "./dist/libs/core/service/index.js",
11
12
  "./@config": "./dist/libs/core/application/contexts/index.js",
12
13
  "./@hooks": "./dist/libs/core/application/hooks/index.js",