ar-design 0.2.91 → 0.2.93

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.
@@ -1,6 +1,8 @@
1
1
  .ar-checkbox-wrapper {
2
2
  display: flex;
3
+ justify-content: center;
3
4
  align-items: center;
5
+ width: max-content;
4
6
  height: var(--input-height);
5
7
  }
6
8
  .ar-checkbox-wrapper > label > :is(input[type="checkbox"]) {
@@ -183,3 +183,5 @@ input[type="date"]::-webkit-calendar-picker-indicator {
183
183
  }
184
184
  /* #endregion */
185
185
  /* Variants */
186
+
187
+ @import url("./utils.css");
@@ -0,0 +1,13 @@
1
+ .flex {
2
+ display: flex;
3
+ }
4
+
5
+ .justify-content-start {
6
+ justify-content: flex-start;
7
+ }
8
+ .justify-content-center {
9
+ justify-content: center;
10
+ }
11
+ .justify-content-end {
12
+ justify-content: flex-end;
13
+ }
@@ -14,6 +14,7 @@ import { FilterOperator } from "../../../libs/infrastructure/shared/Enums";
14
14
  import Select from "../../form/select";
15
15
  import Grid from "../grid-system";
16
16
  import THeadCell from "./THeadCell";
17
+ import Tooltip from "../../feedback/tooltip";
17
18
  const filterOption = [
18
19
  { value: FilterOperator.Contains, text: "İçerir" },
19
20
  { value: FilterOperator.DoesNotContains, text: "İçermez" },
@@ -220,7 +221,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
220
221
  ?.map((filter, fIndex) => {
221
222
  const name = typeof c.key !== "object" ? String(c.key) : String(c.key.field);
222
223
  return (React.createElement("div", null,
223
- React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), label: filter.text, name: name, color: "blue", value: filter.value, checked: Array.isArray(checkboxSelectedParams?.[name]) &&
224
+ React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), variant: "filled", color: "green", label: filter.text, name: name, value: filter.value, checked: Array.isArray(checkboxSelectedParams?.[name]) &&
224
225
  checkboxSelectedParams?.[name]?.some((f) => String(f.value) === String(filter.value)), onChange: async (event) => await handleCheckboxChange(event) })));
225
226
  }))));
226
227
  default:
@@ -346,8 +347,8 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
346
347
  // TODO: Keylere bakılacak...
347
348
  return (React.createElement(Fragment, { key: `row-${index}` },
348
349
  React.createElement("tr", { key: `row-${index}` },
349
- selections && (React.createElement("td", { className: "sticky-left", "data-sticky-position": "left" },
350
- React.createElement(Checkbox, { ref: (element) => (_checkboxItems.current[index] = element), color: "blue", checked: selectionItems.some((selectionItem) => JSON.stringify(selectionItem) === JSON.stringify(item)), onChange: (event) => {
350
+ selections && (React.createElement("td", { className: "flex justify-content-center sticky-left", "data-sticky-position": "left" },
351
+ React.createElement(Checkbox, { ref: (element) => (_checkboxItems.current[index] = element), variant: "filled", color: "green", checked: selectionItems.some((selectionItem) => JSON.stringify(selectionItem) === JSON.stringify(item)), onChange: (event) => {
351
352
  if (event.target.checked)
352
353
  setSelectionItems((prev) => [...prev, item]);
353
354
  else
@@ -510,15 +511,17 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
510
511
  if (actions.import && actions.import.onClick)
511
512
  actions.import.onClick(formData, files);
512
513
  }, config: { buttons: { okay: "Yükle", cancel: "İptal" } }, windowBlur: true },
513
- React.createElement(Button, { variant: "outlined", color: "purple", icon: { element: React.createElement(ARIcon, { icon: "Upload" }) }, tooltip: { text: actions.import.tooltip, direction: "top" } }))),
514
- actions.create && (React.createElement(Button, { variant: "outlined", color: "green", icon: { element: React.createElement(ARIcon, { icon: "Add", size: 24 }) }, tooltip: { text: actions.create.tooltip, direction: "top" }, onClick: actions.create.onClick }))))))),
514
+ React.createElement(Tooltip, { text: actions.import.tooltip },
515
+ React.createElement(Button, { variant: "outlined", color: "purple", icon: { element: React.createElement(ARIcon, { icon: "Upload" }) } })))),
516
+ actions.create && (React.createElement(Tooltip, { text: actions.create.tooltip },
517
+ React.createElement(Button, { variant: "outlined", color: "green", icon: { element: React.createElement(ARIcon, { icon: "Add", size: 24 }) }, onClick: actions.create.onClick })))))))),
515
518
  React.createElement("div", { ref: _tableContent, className: "content", onScroll: handleScroll },
516
519
  React.createElement("table", { ref: ref },
517
520
  React.createElement("thead", null,
518
521
  React.createElement("tr", { key: "selection" },
519
522
  data.some((item) => _subrowSelector in item) && _subrowButton && (React.createElement("td", { style: { width: 0, minWidth: 0 } })),
520
523
  selections && (React.createElement("th", { className: "selection-col sticky-left", "data-sticky-position": "left" },
521
- React.createElement(Checkbox, { variant: "filled", color: "blue", checked: selectAll, onChange: (event) => {
524
+ React.createElement(Checkbox, { variant: "filled", color: "green", checked: selectAll, onChange: (event) => {
522
525
  if (_checkboxItems.current.length > 0) {
523
526
  setSelectAll(event.target.checked);
524
527
  _checkboxItems.current.forEach((item) => {
@@ -1,5 +1,5 @@
1
1
  import { IChildren, ISize } from "../../../libs/types/IGlobalProps";
2
- interface IProps extends IChildren, ISize {
2
+ interface IProps extends IChildren, ISize, React.HTMLAttributes<HTMLDivElement> {
3
3
  /**
4
4
  * Modal'ın açık olup olmadığını kontrol eden ve değiştiren değerler.
5
5
  *
@@ -3,7 +3,7 @@ import React, { useEffect, useRef } from "react";
3
3
  import "../../../assets/css/components/feedback/modal/styles.css";
4
4
  import Typography from "../../data-display/typography";
5
5
  const { Title } = Typography;
6
- const Modal = ({ children, open, title, size = "normal", footer }) => {
6
+ const Modal = ({ children, open, title, size = "normal", footer, ...attributes }) => {
7
7
  // refs
8
8
  const _arModal = useRef(null);
9
9
  const _modalWrapperClassName = ["ar-modal-wrapper"];
@@ -64,6 +64,10 @@ const Modal = ({ children, open, title, size = "normal", footer }) => {
64
64
  window.removeEventListener("resize", handlePosition);
65
65
  };
66
66
  }, [open.get]);
67
+ useEffect(() => {
68
+ if (attributes.className)
69
+ _modalClassName.push(attributes.className);
70
+ }, [attributes.className]);
67
71
  return (React.createElement("div", { className: _modalWrapperClassName.map((c) => c).join(" ") },
68
72
  React.createElement("div", { className: "ar-modal-bg", onMouseDown: (event) => {
69
73
  event.stopPropagation();
@@ -71,7 +75,7 @@ const Modal = ({ children, open, title, size = "normal", footer }) => {
71
75
  if (_arModal.current && !_arModal.current.contains(target))
72
76
  open.set(false);
73
77
  } }),
74
- React.createElement("div", { ref: _arModal, className: _modalClassName.map((c) => c).join(" "), role: "dialog" },
78
+ React.createElement("div", { ref: _arModal, ...attributes, className: _modalClassName.map((c) => c).join(" "), role: "dialog" },
75
79
  title && (React.createElement("div", { className: "header" },
76
80
  React.createElement(Title, { Level: "h3" }, title),
77
81
  React.createElement("div", { className: "close", onClick: () => open.set((prev) => !prev) }))),
@@ -21,12 +21,12 @@ const Tooltip = ({ children, text, direction = "top" }) => {
21
21
  const childRect = child.getBoundingClientRect();
22
22
  const tooltipRect = tooltip.getBoundingClientRect();
23
23
  const isOnRight = childRect.left > screenCenterX;
24
- const coordinate = isOnRight ? childRect.right + tooltipRect.width / 2 : childRect.left + tooltipRect.width;
24
+ console.log(tooltipRect.left);
25
25
  if (direction === "top" || direction === "bottom") {
26
- if (isOnRight && coordinate > windowWidth) {
26
+ if (isOnRight && tooltipRect.right > windowWidth - 10) {
27
27
  direction = "left";
28
28
  }
29
- else if (!isOnRight && coordinate < windowWidth) {
29
+ else if (!isOnRight && tooltipRect.left < 10) {
30
30
  direction = "right";
31
31
  }
32
32
  }
@@ -55,6 +55,19 @@ const Tooltip = ({ children, text, direction = "top" }) => {
55
55
  setDirection(direction);
56
56
  }, []);
57
57
  //useEffects
58
+ useEffect(() => {
59
+ const observer = new MutationObserver(() => {
60
+ handlePosition();
61
+ });
62
+ observer.observe(document.body, {
63
+ attributes: true,
64
+ childList: true,
65
+ subtree: true,
66
+ });
67
+ return () => {
68
+ observer.disconnect();
69
+ };
70
+ }, []);
58
71
  useEffect(() => {
59
72
  if (mouseEnter)
60
73
  setTimeout(() => handlePosition(), 0);
@@ -16,31 +16,6 @@ interface IProps extends IVariant, IColors, IBorder, IIcon, ISize, IUpperCase, O
16
16
  * ```
17
17
  */
18
18
  shape?: "circle" | "square";
19
- /**
20
- * Bileşene açıklayıcı bir bilgi balonu (tooltip) eklemek için kullanılır.
21
- *
22
- * - `text`: Tooltip içerisinde gösterilecek açıklama metni.
23
- * - `direction`: Tooltip’in hangi yönde görüneceğini belirtir. Varsayılan yön kullanılabilir.
24
- * - `top`: Tooltip yukarıda görünür.
25
- * - `right`: Tooltip sağda görünür.
26
- * - `left`: Tooltip solda görünür.
27
- * - `bottom`: Tooltip aşağıda görünür.
28
- *
29
- * Örneğin;
30
- *
31
- * ```jsx
32
- * <Component
33
- * tooltip={{
34
- * text: "Bu bir açıklamadır.",
35
- * direction: "top"
36
- * }}
37
- * />
38
- * ```
39
- */
40
- tooltip?: {
41
- text: string;
42
- direction?: "top" | "right" | "left" | "bottom";
43
- };
44
19
  /**
45
20
  * Bileşenin konumlandırmasını belirlemek için kullanılır.
46
21
  *
@@ -2,8 +2,7 @@
2
2
  import React, { useRef } from "react";
3
3
  import "../../../assets/css/components/form/button/styles.css";
4
4
  import Utils from "../../../libs/infrastructure/shared/Utils";
5
- import Tooltip from "../../feedback/tooltip";
6
- const Button = ({ children, variant = "filled", shape, color = "light", border = { radius: "sm" }, size = "normal", tooltip, position, fullWidth, icon, upperCase, ...attributes }) => {
5
+ const Button = ({ children, variant = "filled", shape, color = "light", border = { radius: "sm" }, size = "normal", position, fullWidth, icon, upperCase, ...attributes }) => {
7
6
  // refs
8
7
  const _button = useRef(null);
9
8
  const _arButtonClassName = ["ar-button"];
@@ -18,7 +17,7 @@ const Button = ({ children, variant = "filled", shape, color = "light", border =
18
17
  _arButtonClassName.push(position.type);
19
18
  _arButtonClassName.push(position.inset.map((_inset) => _inset).join(" "));
20
19
  }
21
- const buttonElement = (React.createElement("button", { ref: _button, ...attributes, className: _arButtonClassName.map((c) => c).join(" "), onClick: (event) => {
20
+ return (React.createElement("button", { ref: _button, ...attributes, className: _arButtonClassName.map((c) => c).join(" "), onClick: (event) => {
22
21
  // Disabled gelmesi durumunda işlem yapmasına izin verme...
23
22
  if (attributes.disabled)
24
23
  return;
@@ -37,7 +36,6 @@ const Button = ({ children, variant = "filled", shape, color = "light", border =
37
36
  React.createElement("span", { className: "text" },
38
37
  icon?.element,
39
38
  React.createElement("span", null, !shape ? (typeof children === "string" && upperCase ? children.toLocaleUpperCase() : children) : ""))));
40
- return !tooltip ? (buttonElement) : (React.createElement(Tooltip, { text: tooltip.text, direction: tooltip.direction }, buttonElement));
41
39
  };
42
40
  Button.displayName = "Button";
43
41
  export default Button;
@@ -5,6 +5,7 @@ import Button from "../button";
5
5
  import React, { useEffect, useRef, useState } from "react";
6
6
  import Utils from "../../../libs/infrastructure/shared/Utils";
7
7
  import ReactDOM from "react-dom";
8
+ import Tooltip from "../../feedback/tooltip";
8
9
  const TextEditor = ({ color = "light", name, value, onChange, dynamicList,
9
10
  // placeholder,
10
11
  height,
@@ -212,9 +213,8 @@ validation, }) => {
212
213
  }, []);
213
214
  return (React.createElement("div", { ref: _container, className: "ar-text-editor" },
214
215
  React.createElement("iframe", { ref: _arIframe, name: name, className: _iframeClassName.map((c) => c).join(" "), height: height }),
215
- React.createElement("div", { className: "toolbar" }, toolbarButtons.map(({ command, icon, tooltip }) => (React.createElement(Button, { key: command, type: "button", variant: "borderless", color: "teal", border: { radius: "none" }, icon: { element: React.createElement(ARIcon, { icon: icon }) }, tooltip: {
216
- text: tooltip,
217
- }, onClick: () => execCommand(command) })))),
216
+ React.createElement("div", { className: "toolbar" }, toolbarButtons.map(({ command, icon, tooltip }) => (React.createElement(Tooltip, { text: tooltip },
217
+ React.createElement(Button, { key: command, type: "button", variant: "borderless", color: "light", border: { radius: "none" }, icon: { element: React.createElement(ARIcon, { icon: icon }) }, onClick: () => execCommand(command) }))))),
218
218
  React.createElement("div", { className: "resize", onMouseDown: handleMouseDown }),
219
219
  validation?.text && React.createElement("span", { className: "validation" }, validation.text),
220
220
  dynamicList &&
@@ -0,0 +1,28 @@
1
+ declare class DATE {
2
+ /**
3
+ * YYYY-MM-DD
4
+ *
5
+ * @param date
6
+ * @returns
7
+ */
8
+ YMD: (date: Date) => string;
9
+ /**
10
+ * DD-MM-YYYY
11
+ *
12
+ * @param date
13
+ * @returns
14
+ */
15
+ DMY: (date: Date) => string;
16
+ /**
17
+ * 30 Mayıs 2021
18
+ *
19
+ * @param date
20
+ * @param locale
21
+ * @returns
22
+ */
23
+ Verbose: (date: Date, locale?: string) => string;
24
+ WithTime: (date: Date, locale?: string) => string;
25
+ private GetLocaleFromLanguage;
26
+ }
27
+ declare const _default: DATE;
28
+ export default _default;
@@ -0,0 +1,66 @@
1
+ class DATE {
2
+ /**
3
+ * YYYY-MM-DD
4
+ *
5
+ * @param date
6
+ * @returns
7
+ */
8
+ YMD = (date) => {
9
+ const year = date.getFullYear();
10
+ const month = String(date.getMonth() + 1).padStart(2, "0");
11
+ const day = String(date.getDate()).padStart(2, "0");
12
+ return `${year}-${month}-${day}`;
13
+ };
14
+ /**
15
+ * DD-MM-YYYY
16
+ *
17
+ * @param date
18
+ * @returns
19
+ */
20
+ DMY = (date) => {
21
+ const day = String(date.getDate()).padStart(2, "0");
22
+ const month = String(date.getMonth() + 1).padStart(2, "0");
23
+ const year = date.getFullYear();
24
+ return `${day}-${month}-${year}`;
25
+ };
26
+ /**
27
+ * 30 Mayıs 2021
28
+ *
29
+ * @param date
30
+ * @param locale
31
+ * @returns
32
+ */
33
+ Verbose = (date, locale = "tr") => {
34
+ return date.toLocaleDateString(this.GetLocaleFromLanguage(locale), {
35
+ day: "numeric",
36
+ month: "long",
37
+ year: "numeric",
38
+ });
39
+ };
40
+ WithTime = (date, locale = "tr") => {
41
+ return date.toLocaleString(this.GetLocaleFromLanguage(locale), {
42
+ day: "numeric",
43
+ month: "long",
44
+ year: "numeric",
45
+ hour: "2-digit",
46
+ minute: "2-digit",
47
+ });
48
+ };
49
+ GetLocaleFromLanguage = (lang) => {
50
+ const languageToLocaleMap = {
51
+ tr: "tr-TR",
52
+ en: "en-US",
53
+ fr: "fr-FR",
54
+ de: "de-DE",
55
+ es: "es-ES",
56
+ ja: "ja-JP",
57
+ ru: "ru-RU",
58
+ zh: "zh-CN",
59
+ hi: "hi-IN",
60
+ fa: "fa-IR",
61
+ ko: "ko-KR",
62
+ };
63
+ return languageToLocaleMap[lang] || lang;
64
+ };
65
+ }
66
+ export default new DATE();
@@ -0,0 +1,2 @@
1
+ import DATE from "./DATE";
2
+ export { DATE };
@@ -0,0 +1,2 @@
1
+ import DATE from "./DATE";
2
+ export { DATE };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.91",
3
+ "version": "0.2.93",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -13,6 +13,7 @@
13
13
  "./@hooks": "./dist/libs/core/application/hooks/index.js",
14
14
  "./@locales": "./dist/libs/core/application/locales/index.js",
15
15
  "./@types": "./dist/libs/types/index.js",
16
+ "./@utils": "./dist/libs/infrastructure/shared/index.js",
16
17
  "./@styles": "./dist/assets/css/core/ar-core.css"
17
18
  },
18
19
  "files": [