ar-design 0.1.39 → 0.1.41

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.
@@ -4,7 +4,12 @@
4
4
  border-radius: var(--border-radius-lg);
5
5
  }
6
6
  .ar-card > .title {
7
- padding: 1rem;
7
+ display: flex;
8
+ flex-direction: row;
9
+ justify-content: space-between;
10
+ align-items: center;
11
+ padding: 0 1rem;
12
+ height: 3rem;
8
13
  border-bottom: solid 1px var(--gray-200);
9
14
  }
10
15
  .ar-card > .title > .ar-typography-title {
@@ -6,42 +6,36 @@
6
6
  display: flex;
7
7
  flex-direction: column;
8
8
  gap: 1rem 0;
9
- background-color: rgba(var(--white-rgb), 0.75);
10
- backdrop-filter: blur(10px);
9
+ background-color: var(--white);
11
10
  width: 250px;
12
11
  padding: 10px;
13
12
  border-radius: var(--border-radius-sm);
14
13
  box-shadow: 0 0 15px -2.5px rgba(var(--black-rgb), 0.1);
15
14
  z-index: 5;
16
15
  }
17
- .ar-confirm-wrapper > .ar-confirm::after {
18
- position: absolute;
19
- top: 50%;
20
- transform: translateY(-50%);
21
- left: 100%;
22
- content: "";
23
- border: solid 10px transparent;
24
- border-left-color: var(--white);
25
- }
26
16
 
27
17
  /* #region Open or Close */
28
18
  .ar-confirm-wrapper > .ar-confirm:is(.opened) {
29
19
  visibility: visible;
30
20
  opacity: 1;
31
- transform: scale(1);
32
21
  transition: visibility 250ms, opacity 250ms, transform 250ms ease-in-out;
33
22
  z-index: 100;
34
23
  }
35
24
  .ar-confirm-wrapper > .ar-confirm:is(.closed) {
36
25
  visibility: hidden;
37
26
  opacity: 0;
38
- transform: scale(0.8);
39
27
  transition: visibility 250ms, opacity 250ms, transform 250ms ease-in-out;
40
28
  z-index: 99;
41
29
  }
42
30
  /* #endregion */
43
31
  /* Open or Close */
44
32
 
33
+ .ar-confirm-wrapper > .ar-confirm > .content {
34
+ max-height: 200px;
35
+ overflow-y: auto;
36
+ overflow-x: hidden;
37
+ }
38
+
45
39
  .ar-confirm-wrapper > .ar-confirm > .message {
46
40
  font-size: 0.85rem;
47
41
  text-wrap: wrap;
@@ -1,6 +1,5 @@
1
1
  .ar-select-wrapper > .options {
2
- position: absolute;
3
- inset: auto 0 auto 0;
2
+ position: fixed;
4
3
  background-color: var(--white);
5
4
  border: solid 1px var(--gray-200);
6
5
  border-radius: var(--border-radius-lg);
@@ -9,11 +8,11 @@
9
8
  transition: visibility 250ms, opacity 250ms, transform 250ms ease-in-out;
10
9
  }
11
10
  .ar-select-wrapper > .options.top {
12
- inset: 100% 0 auto 0;
11
+ /* inset: 100% 0 auto 0; */
13
12
  box-shadow: 0 5px 15px -2.5px rgba(var(--black-rgb), 0.1);
14
13
  }
15
14
  .ar-select-wrapper > .options.bottom {
16
- inset: auto 0 100% 0;
15
+ /* inset: auto 0 100% 0; */
17
16
  box-shadow: 0 -5px 15px -2.5px rgba(var(--black-rgb), 0.1);
18
17
  }
19
18
 
@@ -1,5 +1,7 @@
1
+ import React from "react";
1
2
  import { IChildren, IGlobalProps } from "../../../libs/types/IGlobalProps";
2
3
  interface IProps extends IGlobalProps, IChildren {
3
4
  title?: string;
5
+ actions?: React.JSX.Element;
4
6
  }
5
7
  export default IProps;
@@ -2,10 +2,11 @@ import React from "react";
2
2
  import Typography from "../typography";
3
3
  import "../../../assets/css/components/data-display/card/card.css";
4
4
  const { Title } = Typography;
5
- const Card = ({ children, title = "" }) => {
5
+ const Card = ({ children, title = "", actions }) => {
6
6
  return (React.createElement("div", { className: "ar-card" },
7
- React.createElement("div", { className: "title" },
8
- React.createElement(Title, { Level: "h4" }, title)),
7
+ title && (React.createElement("div", { className: "title" },
8
+ React.createElement(Title, { Level: "h4" }, title),
9
+ React.createElement("div", null, actions))),
9
10
  React.createElement("div", { className: "content" }, children)));
10
11
  };
11
12
  export default Card;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ interface IProps<T> {
3
+ data: T[];
4
+ renderItem: (item: T, index: number) => React.JSX.Element;
5
+ onChange: (data: T[]) => void;
6
+ }
7
+ export default IProps;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import IProps from "./IProps";
3
+ declare const DnD: <T>({ data, renderItem, onChange }: IProps<T>) => React.JSX.Element;
4
+ export default DnD;
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import React, { useEffect, useRef } from "react";
3
+ const DnD = function ({ data, renderItem, onChange }) {
4
+ // refs
5
+ const _arDnD = useRef(null);
6
+ const _dragItem = useRef();
7
+ useEffect(() => {
8
+ if (!_arDnD.current)
9
+ return;
10
+ _arDnD.current.childNodes.forEach((item) => {
11
+ const targetItem = item;
12
+ targetItem.draggable = true;
13
+ targetItem.style.cursor = "move";
14
+ targetItem.ondragstart = (event) => {
15
+ const dragItem = event.currentTarget;
16
+ // Drag olan öğeyi yakalanıyor.
17
+ _dragItem.current = dragItem;
18
+ dragItem.style.opacity = "0.5";
19
+ };
20
+ targetItem.ondrop = (event) => {
21
+ event.preventDefault();
22
+ const dropItem = event.currentTarget;
23
+ if (_dragItem.current !== dropItem) {
24
+ if (_arDnD.current && _dragItem.current) {
25
+ const dragItemIndex = [..._arDnD.current.children].indexOf(_dragItem.current);
26
+ const dropItemIndex = [..._arDnD.current.children].indexOf(dropItem);
27
+ if (dragItemIndex < dropItemIndex) {
28
+ // Render Order
29
+ _arDnD.current.insertBefore(_dragItem.current, dropItem.nextSibling);
30
+ }
31
+ else {
32
+ // Render Order
33
+ _arDnD.current.insertBefore(_dragItem.current, dropItem);
34
+ }
35
+ // Data Order
36
+ data.splice(dropItemIndex, 0, data.splice(dragItemIndex, 1)[0]);
37
+ }
38
+ onChange(data);
39
+ }
40
+ };
41
+ targetItem.ondragend = (event) => {
42
+ const item = event.currentTarget;
43
+ item.style.opacity = "1";
44
+ };
45
+ });
46
+ _arDnD.current.ondragover = (event) => event.preventDefault();
47
+ }, []);
48
+ return (React.createElement("div", { ref: _arDnD, className: "ar-dnd" }, data.map((item, index) => renderItem(item, index))));
49
+ };
50
+ export default DnD;
@@ -1,8 +1,5 @@
1
1
  import React from "react";
2
- import IProps from "../../form/button/IProps";
3
2
  declare const Actions: React.FC<{
4
- children: React.ReactElement<{
5
- children: React.ReactElement<IProps> | React.ReactElement<IProps>[];
6
- }>;
3
+ children: React.ReactElement | React.ReactElement[];
7
4
  }>;
8
5
  export default Actions;
@@ -1,2 +1,3 @@
1
- const Actions = ({ children }) => children;
1
+ import React from "react";
2
+ const Actions = ({ children }) => React.createElement("div", { style: { display: "flex", flexDirection: "row", gap: "0 .5rem" } }, children);
2
3
  export default Actions;
@@ -4,9 +4,7 @@ import "../../../assets/css/components/data-display/table/table.css";
4
4
  declare const Table: {
5
5
  <T extends object>({ children, data, columns, selections, pagination, config }: IProps<T>): React.JSX.Element;
6
6
  Action: React.FC<{
7
- children: React.ReactElement<{
8
- children: React.ReactElement<import("../../form/button/IProps").default> | React.ReactElement<import("../../form/button/IProps").default>[];
9
- }>;
7
+ children: React.ReactElement | React.ReactElement[];
10
8
  }>;
11
9
  };
12
10
  export default Table;
@@ -0,0 +1,8 @@
1
+ import { IChildren } from "../../../libs/types/IGlobalProps";
2
+ interface IProps extends IChildren {
3
+ title?: string;
4
+ message?: string;
5
+ content?: React.JSX.Element;
6
+ onConfirm?: (confirm: boolean) => void;
7
+ }
8
+ export default IProps;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,5 @@
1
1
  import React from "react";
2
2
  import "../../../assets/css/components/feedback/confirm/confirm.css";
3
- import { IChildren } from "../../../libs/types/IGlobalProps";
4
- declare const Confirm: React.FC<{
5
- title: string;
6
- message?: string;
7
- content?: React.JSX.Element;
8
- onConfirm: (confirm: boolean) => void;
9
- } & IChildren>;
3
+ import IProps from "./IProps";
4
+ declare const Confirm: React.FC<IProps>;
10
5
  export default Confirm;
@@ -41,10 +41,10 @@ const Confirm = ({ children, title, message, content, onConfirm }) => {
41
41
  }, [open]);
42
42
  return (React.createElement("div", { ref: _arConfirmWrapper, className: "ar-confirm-wrapper", role: "dialog" },
43
43
  React.createElement("div", { ref: _arConfirm, className: `ar-confirm ${open ? "opened" : "closed"}`, style: { top: coordinateY, left: coordinateX } },
44
- React.createElement(Title, { Level: "h4" }, title),
44
+ title && React.createElement(Title, { Level: "h4" }, title),
45
45
  message && React.createElement("p", { className: "message" }, message),
46
46
  content && React.createElement("div", { className: "content" }, content),
47
- React.createElement("div", { className: "footer" },
47
+ onConfirm && (React.createElement("div", { className: "footer" },
48
48
  React.createElement(Button, { status: "success", size: "small", onClick: () => {
49
49
  onConfirm(true);
50
50
  setOpen(false);
@@ -52,14 +52,14 @@ const Confirm = ({ children, title, message, content, onConfirm }) => {
52
52
  React.createElement(Button, { status: "light", size: "small", onClick: () => {
53
53
  onConfirm(false);
54
54
  setOpen(false);
55
- } }, "Hay\u0131r"))),
55
+ } }, "Hay\u0131r")))),
56
56
  React.createElement("div", { onClick: () => {
57
57
  if (!_arConfirmWrapper.current || !_arConfirm.current)
58
58
  return;
59
59
  const wrapper = _arConfirmWrapper.current.getBoundingClientRect();
60
60
  const confirm = _arConfirm.current.getBoundingClientRect();
61
- setCoordinatX(wrapper.left - confirm.width - 60);
62
- setCoordinatY(wrapper.top - confirm.height / 2 + 2.5);
61
+ setCoordinatX(wrapper.left - confirm.width - 10);
62
+ setCoordinatY(wrapper.top);
63
63
  setOpen((prev) => !prev);
64
64
  } }, children)));
65
65
  };
@@ -132,6 +132,11 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
132
132
  _singleInput.current.placeholder = value?.text || placeholder || "";
133
133
  }
134
134
  }
135
+ if (_options.current) {
136
+ _options.current.style.top = `${rect?.bottom}px`;
137
+ _options.current.style.left = `${rect?.left}px`;
138
+ _options.current.style.width = `${rect?.width}px`;
139
+ }
135
140
  // Options açıldıktan 100ms sonra arama kutusuna otomatik olarak focus oluyor.
136
141
  _otoFocus = setTimeout(() => {
137
142
  if (_searchField.current)
@@ -7,7 +7,7 @@ interface IHeaderProps {
7
7
  image?: React.ReactElement<SVGElement | HTMLImageElement>;
8
8
  text?: string | React.JSX.Element;
9
9
  };
10
- actions?: React.ReactNode[];
10
+ actions?: React.ReactNode;
11
11
  }
12
12
  interface IMainProps extends Omit<IGlobalProps, "variant" | "status" | "icon" | "border" | "size" | "upperCase">, IChildren {
13
13
  }
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ import Radio from "./components/form/radio";
11
11
  import Card from "./components/data-display/card";
12
12
  import Chip from "./components/data-display/chip";
13
13
  import Divider from "./components/data-display/divider";
14
+ import DnD from "./components/data-display/dnd";
14
15
  import Paper from "./components/data-display/paper";
15
16
  import SyntaxHighlighter from "./components/data-display/syntax-highlighter";
16
17
  import Table from "./components/data-display/table";
@@ -23,4 +24,4 @@ import Menu from "./components/navigation/menu";
23
24
  import Steps from "./components/navigation/steps";
24
25
  import Grid from "./components/layout/grid-system";
25
26
  import Layout from "./components/layout";
26
- export { Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Checkbox, Radio, Card, Chip, Divider, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Confirm, Modal, Menu, Steps, Grid, Layout, };
27
+ export { Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Checkbox, Radio, Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Confirm, Modal, Menu, Steps, Grid, Layout, };
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ import Radio from "./components/form/radio";
13
13
  import Card from "./components/data-display/card";
14
14
  import Chip from "./components/data-display/chip";
15
15
  import Divider from "./components/data-display/divider";
16
+ import DnD from "./components/data-display/dnd";
16
17
  import Paper from "./components/data-display/paper";
17
18
  import SyntaxHighlighter from "./components/data-display/syntax-highlighter";
18
19
  import Table from "./components/data-display/table";
@@ -32,7 +33,7 @@ export {
32
33
  // Form Elements
33
34
  Button, ButtonAction, ButtonGroup, Input, DatePicker, Select, Switch, Checkbox, Radio,
34
35
  // Data Display
35
- Card, Chip, Divider, Paper, SyntaxHighlighter, Table, Tabs, Typography,
36
+ Card, Chip, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography,
36
37
  // Feedback
37
38
  Alert, Confirm, Modal,
38
39
  // Navigation
@@ -44,3 +44,9 @@ export declare const useValidation: <TData extends object>(data: TData, params:
44
44
  setSubmit: import("react").Dispatch<import("react").SetStateAction<boolean>>;
45
45
  errors: Partial<{ [key in keyof TData]: string; }>;
46
46
  };
47
+ export declare const useTranslation: <TBaseLocale>(translations: {
48
+ [key: string]: any;
49
+ }) => {
50
+ t: (key: keyof TBaseLocale, ...args: any[]) => string;
51
+ changeLanguage: (language: string) => void;
52
+ };
@@ -85,3 +85,16 @@ export const useValidation = function (data, params) {
85
85
  errors,
86
86
  };
87
87
  };
88
+ // Custom hook for easier usage of context
89
+ export const useTranslation = function (translations) {
90
+ const t = (key, ...args) => {
91
+ return Utils.StringFormat(translations[localStorage.getItem("ar-language-value")][key], args);
92
+ };
93
+ const changeLanguage = (language) => {
94
+ if (typeof window === undefined)
95
+ return;
96
+ localStorage.setItem("ar-language-value", language);
97
+ window.location.reload();
98
+ };
99
+ return { t, changeLanguage };
100
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",