ar-design 0.2.69 → 0.2.71

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.
@@ -186,18 +186,68 @@
186
186
  cursor: no-drop;
187
187
  }
188
188
 
189
+ /* For Rows */
190
+ .ar-table > .content > table > tbody > tr > td > .table-cell > .before {
191
+ position: absolute;
192
+ top: 0px;
193
+ content: "";
194
+ background: linear-gradient(0deg, var(--gray-200) 0%, var(--primary) 50%, var(--gray-200) 100%);
195
+ width: 2px;
196
+ height: 100%;
197
+ margin-left: -17.5px;
198
+ }
199
+ .ar-table > .content > table > tbody > tr:not(:has(+ tr)) > td > .table-cell > .before,
200
+ .ar-table > .content > table > tbody > tr:last-child > td > .table-cell > .before {
201
+ height: 50%;
202
+ background: linear-gradient(0deg, var(--gray-600) 0%, var(--gray-200) 100%);
203
+ }
204
+ .ar-table > .content > table > tbody > tr > td > .table-cell > .after {
205
+ position: absolute;
206
+ top: 50%;
207
+ transform: translateY(-50%);
208
+ content: "";
209
+ background-color: var(--primary);
210
+ width: 15px;
211
+ height: 2px;
212
+ margin-left: -17.5px;
213
+ }
214
+ .ar-table > .content > table > tbody > tr > td > .table-cell > .after > .circle {
215
+ position: absolute;
216
+ top: 50%;
217
+ transform: translateY(-50%);
218
+ right: 0;
219
+ content: "";
220
+ background-color: var(--primary);
221
+ width: 5px;
222
+ height: 5px;
223
+ border-radius: var(--border-radius-pill);
224
+ }
225
+
226
+ /* For Subrows */
189
227
  .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .before {
190
228
  position: absolute;
191
229
  top: 0px;
192
230
  content: "";
193
- background-color: var(--gray-600);
231
+ background: linear-gradient(0deg, var(--gray-200) 0%, var(--gray-600) 50%, var(--gray-200) 100%) !important;
194
232
  width: 2px;
195
233
  height: 100%;
196
234
  margin-left: -17.5px;
197
235
  }
236
+ .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .last-before {
237
+ position: absolute;
238
+ top: 0px;
239
+ content: "";
240
+ background: linear-gradient(0deg, var(--gray-200) 0%, var(--gray-600) 50%, var(--gray-200) 100%) !important;
241
+ width: 2px;
242
+ height: 100%;
243
+ }
244
+ .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .last-before:first-child {
245
+ background: linear-gradient(0deg, var(--gray-200) 0%, var(--primary) 50%, var(--gray-200) 100%) !important;
246
+ }
198
247
  .ar-table > .content > table > tbody > tr.subrow-item:not(:has(+ tr.subrow-item)) > td > .table-cell > .before,
199
248
  .ar-table > .content > table > tbody > tr.subrow-item:last-child > td > .table-cell > .before {
200
249
  height: 50%;
250
+ background: linear-gradient(0deg, var(--gray-600) 0%, var(--gray-200) 100%) !important;
201
251
  }
202
252
  .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .after {
203
253
  position: absolute;
@@ -209,6 +259,17 @@
209
259
  height: 2px;
210
260
  margin-left: -17.5px;
211
261
  }
262
+ .ar-table > .content > table > tbody > tr.subrow-item > td > .table-cell > .after > .circle {
263
+ position: absolute;
264
+ top: 50%;
265
+ transform: translateY(-50%);
266
+ right: 0;
267
+ content: "";
268
+ background-color: var(--gray-600);
269
+ width: 5px;
270
+ height: 5px;
271
+ border-radius: var(--border-radius-pill);
272
+ }
212
273
 
213
274
  @import url("./scroll.css");
214
275
  @import url("./filter-popup.css");
@@ -29,6 +29,17 @@
29
29
  cursor: pointer;
30
30
  user-select: none;
31
31
  }
32
+ .ar-upload-button > .button:has(> img) {
33
+ padding: 0;
34
+ border: none;
35
+ overflow: hidden;
36
+ }
37
+ .ar-upload-button > .button > img {
38
+ width: 100%;
39
+ height: 200px;
40
+ object-fit: fill;
41
+ object-position: top;
42
+ }
32
43
  .ar-upload-button > .button > .information {
33
44
  display: flex;
34
45
  flex-direction: column;
@@ -54,53 +65,10 @@
54
65
  transition: top 250ms ease-in-out;
55
66
  }
56
67
  .ar-upload-button > .ar-upload-files > ul {
57
- display: flex;
58
- flex-direction: column;
59
- list-style-type: none;
60
- }
61
- .ar-upload-button > .ar-upload-files > ul > li {
62
- position: relative;
63
- border-bottom: solid 1px var(--gray-200);
64
- }
65
- .ar-upload-button > .ar-upload-files > ul > li:hover > .errors {
66
- display: flex;
67
- }
68
- .ar-upload-button > .ar-upload-files > ul > li.error {
69
- border-left: solid 2px var(--danger);
70
- }
71
- .ar-upload-button > .ar-upload-files > ul > li .content {
72
- display: flex;
73
- flex-direction: row;
74
- justify-content: space-between;
75
- align-items: center;
76
- width: 100%;
77
- height: 2rem;
78
- padding: 0 0.5rem;
79
- }
80
- .ar-upload-button > .ar-upload-files > ul > li .content > span:first-child {
81
- width: 90%;
82
- font-size: 0.75rem;
83
- text-overflow: ellipsis;
84
- overflow: hidden;
85
- white-space: nowrap;
86
- }
87
- .ar-upload-button > .ar-upload-files > ul > li .content > span:first-child.error {
88
- color: var(--danger);
89
- /* -webkit-text-stroke: 0.5px var(--danger); */
90
- }
91
- .ar-upload-button > .ar-upload-files > ul > li .content > span:last-child {
92
- background-color: rgba(var(--danger-rgb), 0.1);
93
- width: 1rem;
94
- height: 1rem;
95
- border-radius: var(--border-radius-pill);
96
- color: rgba(var(--danger-rgb), 0.5);
97
- font-size: 0.75rem;
98
- text-align: center;
99
- /* -webkit-text-stroke: 1px rgba(var(--danger-rgb), 0.5); */
100
- line-height: 0.85rem;
101
- cursor: pointer;
68
+ list-style: none;
102
69
  }
103
70
 
71
+ .ar-upload-button > .ar-upload-files > ul > li > .file,
104
72
  .ar-upload-button > .ar-upload-files > .file {
105
73
  display: flex;
106
74
  flex-direction: row;
@@ -111,14 +79,17 @@
111
79
  padding: 0.5rem;
112
80
  border-radius: var(--border-radius-sm);
113
81
  }
82
+ .ar-upload-button > .ar-upload-files > ul > li > .file > .information,
114
83
  .ar-upload-button > .ar-upload-files > .file > .information {
115
84
  display: flex;
116
85
  flex-direction: row;
117
86
  gap: 0.5rem;
118
87
  }
88
+ .ar-upload-button > .ar-upload-files > ul > li > .file > .information > span,
119
89
  .ar-upload-button > .ar-upload-files > .file > .information > span {
120
90
  display: inline-block;
121
91
  }
92
+ .ar-upload-button > .ar-upload-files > ul > li > .file > .information > span:last-child,
122
93
  .ar-upload-button > .ar-upload-files > .file > .information > span:last-child {
123
94
  background-color: var(--primary);
124
95
  padding: 0 0.25rem;
@@ -127,6 +98,7 @@
127
98
  font-size: 0.75rem;
128
99
  line-height: 2;
129
100
  }
101
+ .ar-upload-button > .ar-upload-files > ul > li > .file > .delete,
130
102
  .ar-upload-button > .ar-upload-files > .file > .delete {
131
103
  cursor: pointer;
132
104
  }
@@ -51,6 +51,7 @@ export type Config = {
51
51
  */
52
52
  button?: boolean;
53
53
  };
54
+ isTreeView?: boolean;
54
55
  };
55
56
  type ImportActionType = {
56
57
  /**
@@ -22,6 +22,6 @@ const MemoizedTHeadCell = function ({ columns }) {
22
22
  React.createElement("span", { style: { fontWeight: 500 } }, c.title)));
23
23
  })));
24
24
  };
25
- // 👇 React.memo kullanımı sırasında generic tipi koruyoruz
25
+ // React.memo kullanımı sırasında generic tipi koruyoruz.
26
26
  const THeadCell = React.memo(MemoizedTHeadCell);
27
27
  export default THeadCell;
@@ -341,7 +341,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
341
341
  setTimeout(() => handleScroll(), 0);
342
342
  return _data;
343
343
  }, [data, searchedText, currentPage]);
344
- const renderRow = (item, index) => {
344
+ const renderRow = (item, index, deph) => {
345
345
  const isHasSubitems = _subrowSelector in item;
346
346
  // TODO: Keylere bakılacak...
347
347
  return (React.createElement(Fragment, { key: `row-${index}` },
@@ -360,10 +360,10 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
360
360
  [`${index}`]: !prev[`${index}`],
361
361
  }));
362
362
  } }))))) : isHasSubitems && _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
363
- columns.map((c, cIndex) => renderCell(item, c, cIndex, index, 0))),
363
+ columns.map((c, cIndex) => renderCell(item, c, cIndex, index, deph * (config.isTreeView ? 1.75 : 0), 0))),
364
364
  showSubitems[index] && item[_subrowSelector] && (React.createElement(SubitemList, { items: item[_subrowSelector], columns: columns, index: index, depth: 1.5 }))));
365
365
  };
366
- const renderCell = (item, c, cIndex, index, depth) => {
366
+ const renderCell = (item, c, cIndex, index, depth, level, isSubrows = false) => {
367
367
  let render;
368
368
  // `c.key` bir string ise
369
369
  if (typeof c.key !== "object") {
@@ -387,20 +387,28 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
387
387
  _className.push(`align-content-${c.config.alignContent}`);
388
388
  if (c.config?.textWrap)
389
389
  _className.push(`text-${c.config.textWrap}`);
390
+ console.log(depth);
390
391
  return (React.createElement("td", { key: `cell-${index}-${cIndex}`, className: _className.join(" "), style: c.config?.width ? { minWidth: c.config.width, maxWidth: c.config.width } : {}, "data-sticky-position": c.config?.sticky },
391
392
  React.createElement("div", { style: { paddingLeft: `${depth == 0 ? 1 : depth}rem` }, className: "table-cell" },
392
- cIndex === 0 && React.createElement("div", { className: "before" }),
393
+ config.isTreeView && cIndex === 0 && (React.createElement(React.Fragment, null,
394
+ isSubrows &&
395
+ Array.from({ length: level }).map((_, i) => {
396
+ if (i > 0)
397
+ i *= 1.655;
398
+ return (React.createElement("div", { key: `last-before-${i}`, style: { left: `${i + 0.65}rem` }, className: "last-before" }));
399
+ }),
400
+ React.createElement("div", { className: "before" }))),
393
401
  React.isValidElement(render) ? render : String(render),
394
- cIndex === 0 && React.createElement("div", { className: "after" }))));
402
+ config.isTreeView && cIndex === 0 && (React.createElement("div", { className: "after" },
403
+ React.createElement("div", { className: "circle" }))))));
395
404
  };
396
- const SubitemList = ({ items, columns, index, depth }) => {
405
+ const SubitemList = ({ items, columns, index, depth, level = 1 }) => {
397
406
  return items.map((subitem, subindex) => {
398
407
  const _subitem = subitem[_subrowSelector];
399
408
  const isHasSubitems = _subrowSelector in subitem;
400
- console.log(isHasSubitems);
401
409
  // TODO: Keylere bakılacak...
402
410
  return (React.createElement(Fragment, { key: `subitem-${index}-${subindex}-${Math.random()}` },
403
- React.createElement("tr", { key: `subitem-${index}-${subindex}-${Math.random()}`, className: `subrow-item ${_subrowButton ? "type-b" : "type-a"}` },
411
+ React.createElement("tr", { key: `subitem-${index}-${subindex}-${Math.random()}`, className: `subrow-item ${_subrowButton ? "type-b" : "type-a"}`, "data-level": level },
404
412
  isHasSubitems && _subrowButton ? (React.createElement("td", null,
405
413
  React.createElement("div", { className: "subitem-open-button-wrapper" },
406
414
  React.createElement("span", { className: `${(showSubitems[`${index}.${subindex}`] && "opened") ?? ""} ${!_subitem && "passive"}`, onClick: () => {
@@ -411,8 +419,8 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
411
419
  [`${index}.${subindex}`]: !prev[`${index}.${subindex}`],
412
420
  }));
413
421
  } })))) : !isHasSubitems && _subrowButton ? (React.createElement("td", { style: { width: 0, minWidth: 0 } })) : null,
414
- columns.map((c, cIndex) => renderCell(subitem, c, cIndex, subindex, depth * 1.75))),
415
- showSubitems[`${index}.${subindex}`] && _subitem && (React.createElement(SubitemList, { key: `subitem-${index}-${subindex}-${Math.random()}`, items: _subitem, columns: columns, index: subindex, depth: depth * 1.5 }))));
422
+ columns.map((c, cIndex) => renderCell(subitem, c, cIndex, subindex, depth * (config.isTreeView ? 2.25 : 1.75), level, true))),
423
+ showSubitems[`${index}.${subindex}`] && _subitem && (React.createElement(SubitemList, { key: `subitem-${index}-${subindex}-${Math.random()}`, items: _subitem, columns: columns, index: subindex, depth: depth + 0.75, level: level + 1 }))));
416
424
  });
417
425
  };
418
426
  // useEffects
@@ -571,7 +579,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
571
579
  element: (React.createElement(ARIcon, { viewBox: "0 0 16 16", size: 24, icon: "Filter", fill: "var(--dark)", strokeWidth: 0 })),
572
580
  } }))))));
573
581
  })))),
574
- React.createElement("tbody", null, getData.map((item, index) => (React.createElement(React.Fragment, { key: index }, renderRow(item, index))))))),
582
+ React.createElement("tbody", null, getData.map((item, index) => (React.createElement(React.Fragment, { key: index }, renderRow(item, index, 1))))))),
575
583
  React.createElement(FilterPopup, { tableContent: _tableContent, coordinate: filterButtonCoordinate, buttons: _filterButton }, filterPopupContent),
576
584
  pagination && pagination.totalRecords > pagination.perPage && (React.createElement("div", { className: "footer" },
577
585
  React.createElement("span", null,
@@ -98,6 +98,7 @@ type Props = {
98
98
  * ```
99
99
  */
100
100
  allowedTypes?: AllowedTypes[];
101
+ uploadType?: "image" | "application-file";
101
102
  /**
102
103
  * Kabul edilen maksimum dosya boyutu (byte cinsinden).
103
104
  *
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
2
2
  import "../../../assets/css/components/form/upload/styles.css";
3
3
  import Tooltip from "../../feedback/tooltip";
4
4
  import { ARIcon } from "../../icons";
5
- const Upload = ({ text, file, onChange, allowedTypes, maxSize, multiple }) => {
5
+ const Upload = ({ text, file, onChange, allowedTypes, uploadType = "application-file", maxSize, multiple, }) => {
6
6
  // refs
7
7
  const _firstLoad = useRef(false);
8
8
  const _input = useRef(null);
@@ -10,8 +10,9 @@ const Upload = ({ text, file, onChange, allowedTypes, maxSize, multiple }) => {
10
10
  // refs -> File Data
11
11
  const _validationErrors = useRef([]);
12
12
  // states
13
- const [selectedFiles, setSelectedFiles] = useState([]);
14
13
  const [selectedFile, setSelectedFile] = useState(undefined);
14
+ const [selectedFileBase64, setSelectedFileBase64] = useState(undefined);
15
+ const [selectedFiles, setSelectedFiles] = useState([]);
15
16
  const [validationErrors, setValidationErrors] = useState([]);
16
17
  // methods
17
18
  const handleFileChange = (files) => {
@@ -40,6 +41,7 @@ const Upload = ({ text, file, onChange, allowedTypes, maxSize, multiple }) => {
40
41
  }
41
42
  else {
42
43
  setSelectedFile(undefined);
44
+ setSelectedFileBase64(undefined);
43
45
  }
44
46
  };
45
47
  const handleValidationFile = (file) => {
@@ -101,6 +103,7 @@ const Upload = ({ text, file, onChange, allowedTypes, maxSize, multiple }) => {
101
103
  handleValidationFile(selectedFile);
102
104
  fileFormData.append("file", selectedFile);
103
105
  onChange(fileFormData, selectedFile, await handleFileToBase64(selectedFile));
106
+ setSelectedFileBase64(await handleFileToBase64(selectedFile));
104
107
  // Input içerisine dosyalar aktarılıyor.
105
108
  dataTransfer.items.add(selectedFile);
106
109
  _input.current.files = dataTransfer.files;
@@ -122,15 +125,17 @@ const Upload = ({ text, file, onChange, allowedTypes, maxSize, multiple }) => {
122
125
  if (_input.current)
123
126
  _input.current.click();
124
127
  } },
125
- React.createElement("div", { className: "information" },
126
- React.createElement(ARIcon, { variant: "linear", icon: "Upload", stroke: "var(--gray-600)", fill: "transparent" }),
127
- React.createElement("div", { className: "properies" },
128
- allowedTypes && (React.createElement("div", { className: "allow-types" }, allowedTypes?.map((allowedType) => allowedType.split("/")[1].toLocaleUpperCase()).join(", "))),
129
- maxSize && React.createElement("div", { className: "max-size" },
130
- "up to ",
131
- maxSize,
132
- "MB"))),
133
- text && React.createElement("span", null, text)),
128
+ uploadType === "image" && selectedFileBase64 && React.createElement("img", { src: selectedFileBase64 }),
129
+ (uploadType === "application-file" || !selectedFileBase64) && (React.createElement(React.Fragment, null,
130
+ React.createElement("div", { className: "information" },
131
+ React.createElement(ARIcon, { variant: "linear", icon: "Upload", stroke: "var(--gray-600)", fill: "transparent" }),
132
+ React.createElement("div", { className: "properies" },
133
+ allowedTypes && (React.createElement("div", { className: "allow-types" }, allowedTypes?.map((allowedType) => allowedType.split("/")[1].toLocaleUpperCase()).join(", "))),
134
+ maxSize && React.createElement("div", { className: "max-size" },
135
+ "up to ",
136
+ maxSize,
137
+ "MB"))),
138
+ text && React.createElement("span", null, text)))),
134
139
  React.createElement("div", { className: "ar-upload-files" }, multiple ? (React.createElement("ul", null, selectedFiles.map((selectedFile, index) => {
135
140
  let _className = [];
136
141
  const errorMessages = validationErrors
@@ -138,12 +143,14 @@ const Upload = ({ text, file, onChange, allowedTypes, maxSize, multiple }) => {
138
143
  .map((error) => error[selectedFile.name]);
139
144
  if (errorMessages.length > 0)
140
145
  _className.push("error");
141
- const content = (React.createElement("div", { className: "content" },
142
- React.createElement("span", { className: _className.map((c) => c).join(" ") }, selectedFile.name),
143
- React.createElement("span", { onClick: (event) => {
144
- event.stopPropagation();
145
- handleFileRemove(selectedFile);
146
- } }, "x")));
146
+ const content = (React.createElement("div", { className: "file" },
147
+ React.createElement("div", { className: "information" },
148
+ React.createElement("span", null, selectedFile.name),
149
+ React.createElement("span", null,
150
+ (selectedFile.size / 1024).toFixed(3),
151
+ "KB")),
152
+ React.createElement("div", { className: "delete", onClick: () => handleFileRemove(selectedFile) },
153
+ React.createElement(ARIcon, { icon: "CloseCircle", fill: "transparent", size: 20 }))));
147
154
  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))));
148
155
  }))) : (selectedFile && (React.createElement("div", { className: "file" },
149
156
  React.createElement("div", { className: "information" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.69",
3
+ "version": "0.2.71",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",