ar-design 0.4.39 → 0.4.40

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.
@@ -6,7 +6,7 @@ let _fromColumn = undefined;
6
6
  const DnD = function ({ data, renderItem, columnKey, onChange, confing = { isMoveIcon: true } }) {
7
7
  // refs
8
8
  const _arDnD = useRef(null);
9
- const _dragItem = useRef();
9
+ const _dragItem = useRef(null);
10
10
  // useEffects
11
11
  useEffect(() => {
12
12
  if (!_arDnD.current || data.length === 0)
@@ -1,7 +1,7 @@
1
1
  import "../../../assets/css/components/data-display/grid-system/styles.css";
2
2
  declare const Grid: {
3
3
  Box: import("react").FC<{
4
- children: import("react").ReactNode;
4
+ children: React.ReactNode;
5
5
  direction?: "flex-start" | "center" | "flex-end";
6
6
  }>;
7
7
  Row: import("react").FC<import("./row/IProps").default>;
@@ -11,12 +11,13 @@ class Parser {
11
11
  JsxToString = (child, subChilde = false, indentLevel = 0) => {
12
12
  if (!React.isValidElement(child))
13
13
  return;
14
+ const element = child;
14
15
  let componentName = "";
15
- let componentContent = child.props.children;
16
- if (typeof child.type === "string")
17
- componentName = child.type;
16
+ let componentContent = element.props.children;
17
+ if (typeof element.type === "string")
18
+ componentName = element.type;
18
19
  else {
19
- const componentType = child.type;
20
+ const componentType = element.type;
20
21
  componentName = componentType.displayName || componentType.name || "Unknown";
21
22
  }
22
23
  // Indent seviyesi için boşlukları ekle.
@@ -24,11 +25,9 @@ class Parser {
24
25
  // Eğer `br` elementi ise işlemi sonlandır
25
26
  if (componentName === "br")
26
27
  return;
27
- const attributes = Object.keys(child.props).filter((key) => key !== "children");
28
+ const attributes = Object.keys(element.props).filter((key) => key !== "children");
28
29
  const attributesLength = attributes.length;
29
- const attributesList = attributes
30
- .map((key) => this.FormatAttributeValue(key, child.props[key]))
31
- .join(" ");
30
+ const attributesList = attributes.map((key) => this.FormatAttributeValue(key, element.props[key])).join(" ");
32
31
  const formattedTag = componentName[0]
33
32
  ? componentName[0].toUpperCase() === componentName[0]
34
33
  ? `[react-tag]${componentName}[/react-tag]`
@@ -53,7 +52,7 @@ class Parser {
53
52
  // componentContent =
54
53
  // attributesLength >= this._lineBreakSpaces ? `\n ${componentContent}\n` : componentContent;
55
54
  const renderElement = componentContent != undefined
56
- ? `${indent}[open]&lt;[/open][tag]${formattedTag}[/tag]${formattedAttributes}[close]&gt;[/close]${componentContent}${typeof child.props["children"] === "object" ? indent : ""}[open]&lt;&#47;[/open][tag]${formattedTag}[/tag][close]&gt;[/close]`
55
+ ? `${indent}[open]&lt;[/open][tag]${formattedTag}[/tag]${formattedAttributes}[close]&gt;[/close]${componentContent}${typeof element.props["children"] === "object" ? indent : ""}[open]&lt;&#47;[/open][tag]${formattedTag}[/tag][close]&gt;[/close]`
57
56
  : `${indent}[open]&lt;[/open][tag]${formattedTag}[/tag]${formattedAttributes} [close]&#47;&gt;[/close]`;
58
57
  !subChilde && this._setElements((prevElements) => [...prevElements, renderElement]);
59
58
  return renderElement;
@@ -68,9 +67,7 @@ class Parser {
68
67
  .map(([key, value]) => `[attribute-key]${key}[/attribute-key][colon]&#58;[/colon] ${this.HandleEntries(value)}`)
69
68
  .join(", ")} [/curly-bracket]`;
70
69
  }
71
- return typeof propValue === "number"
72
- ? `[number]${propValue}[/number]`
73
- : `[string]${propValue}[/string]`;
70
+ return typeof propValue === "number" ? `[number]${propValue}[/number]` : `[string]${propValue}[/string]`;
74
71
  };
75
72
  FormatAttributeValue = (key, value) => {
76
73
  let result = "";
@@ -82,7 +82,7 @@ interface IProps<T> extends IChildren {
82
82
  previousSelections?: T[];
83
83
  sortedParams?: (params: Sort<T>[], query: string) => void;
84
84
  searchedParams?: (params: SearchedParam | null, query: string, operator: FilterOperator) => void;
85
- onEditable?: (item: T, trackByValue: string) => void;
85
+ onEditable?: (item: T, trackByValue: string, currentKey?: keyof T | null) => void;
86
86
  onDnD?: (item: T[]) => void;
87
87
  pagination?: {
88
88
  totalRecords: number;
@@ -30,7 +30,11 @@ const MemoizedTHeadCell = function ({ refs, states, methods, columns, config, })
30
30
  _direction === "asc" && React.createElement(ARIcon, { icon: "ArrowUp" }),
31
31
  _direction === "desc" && React.createElement(ARIcon, { icon: "ArrowDown" }))),
32
32
  c.title),
33
- config.isProperties && isProperties && (React.createElement("span", { ref: (element) => (refs.propertiesButton.current[cIndex] = element), className: "properties-field", "data-properties-button": "true", onClick: (event) => {
33
+ config.isProperties && isProperties && (React.createElement("span", { ref: (element) => {
34
+ if (!element)
35
+ return;
36
+ refs.propertiesButton.current[cIndex] = element;
37
+ }, className: "properties-field", "data-properties-button": "true", onClick: (event) => {
34
38
  event.preventDefault();
35
39
  event.stopPropagation();
36
40
  const rect = event.currentTarget.getBoundingClientRect();
@@ -5,7 +5,7 @@ interface IProps<T> {
5
5
  c: TableColumnType<T>;
6
6
  item: T;
7
7
  trackByValue: string;
8
- onEditable: (item: T, trackByValue: string) => void;
8
+ onEditable: (item: T, trackByValue: string, currentKey?: keyof T | null) => void;
9
9
  validation?: Errors<T>;
10
10
  config: Config<T>;
11
11
  }
@@ -3,6 +3,7 @@ import React, { useEffect, useState } from "react";
3
3
  import Input from "../../../form/input";
4
4
  import DatePicker from "../../../form/date-picker";
5
5
  import Select from "../../../form/select";
6
+ import { ExtractKey } from "../Helpers";
6
7
  const Editable = function ({ c, item, trackByValue, onEditable, validation, config }) {
7
8
  // variables
8
9
  const key = c.key;
@@ -22,32 +23,32 @@ const Editable = function ({ c, item, trackByValue, onEditable, validation, conf
22
23
  return (React.createElement(Input, { variant: "borderless", value: _value, onChange: (event) => {
23
24
  const { value } = event.target;
24
25
  setValue(value);
25
- onEditable({ ...item, [key]: c.editable?.type === "number" ? Number(value) : value }, trackByValue);
26
+ onEditable({ ...item, [key]: c.editable?.type === "number" ? Number(value) : value }, trackByValue, ExtractKey(c.key));
26
27
  }, validation: { text: _vText }, ...(c.editable.where ? { disabled: c.editable.where(item) } : {}) }));
27
28
  case "decimal":
28
29
  return (React.createElement(Input.Decimal, { variant: "borderless", name: c.key, value: _value, onChange: (event) => {
29
30
  const { value } = event.target;
30
31
  setValue(value);
31
- onEditable({ ...item, [key]: value }, trackByValue);
32
+ onEditable({ ...item, [key]: value }, trackByValue, ExtractKey(c.key));
32
33
  }, validation: { text: _vText }, locale: config.locale, ...(c.editable.where ? { disabled: c.editable.where(item) } : {}) }));
33
34
  case "input-formatted-decimal":
34
35
  return (React.createElement(Input.FormattedDecimal, { variant: "borderless", name: c.key, value: _value, onChange: (event) => {
35
36
  const { value } = event.target;
36
37
  setValue(value);
37
- onEditable({ ...item, [key]: value }, trackByValue);
38
+ onEditable({ ...item, [key]: value }, trackByValue, ExtractKey(c.key));
38
39
  }, validation: { text: _vText }, locale: config.locale, ...(c.editable.where ? { disabled: c.editable.where(item) } : {}) }));
39
40
  case "date-picker":
40
41
  return (React.createElement(DatePicker, { variant: "borderless", value: _value, onChange: (value) => {
41
42
  setValue(value);
42
- onEditable({ ...item, [key]: value }, trackByValue);
43
+ onEditable({ ...item, [key]: value }, trackByValue, ExtractKey(c.key));
43
44
  }, validation: { text: _vText }, ...(c.editable.where ? { disabled: c.editable.where(item) } : {}) }));
44
45
  case "single-select":
45
46
  return (React.createElement(Select, { variant: "borderless", value: selectItem, options: c.editable.options, onClick: async () => await c.editable?.method?.(), onChange: (option) => {
46
- onEditable({ ...item, [key]: option?.value }, trackByValue);
47
+ onEditable({ ...item, [key]: option?.value }, trackByValue, ExtractKey(c.key));
47
48
  }, validation: { text: _vText }, ...(c.editable.where ? { disabled: c.editable.where(item) } : {}) }));
48
49
  case "multiple-select":
49
50
  return (React.createElement(Select, { variant: "borderless", value: selectItems, options: c.editable.options, onClick: async () => await c.editable?.method?.(), onChange: (options) => {
50
- onEditable({ ...item, [key]: options.map((option) => option.value) }, trackByValue);
51
+ onEditable({ ...item, [key]: options.map((option) => option.value) }, trackByValue, ExtractKey(c.key));
51
52
  }, validation: { text: _vText }, multiple: true, ...(c.editable.where ? { disabled: c.editable.where(item) } : {}) }));
52
53
  default:
53
54
  return null;
@@ -26,7 +26,7 @@ interface IProps<T> {
26
26
  trackBy?: (item: T) => string;
27
27
  selections?: (selectionItems: T[]) => void;
28
28
  onDnD?: (item: T[]) => void;
29
- onEditable?: (item: T, trackByValue: string) => void;
29
+ onEditable?: (item: T, trackByValue: string, currentKey?: keyof T | null) => void;
30
30
  rowBackgroundColor?: (item: T) => string;
31
31
  };
32
32
  config: Config<T>;
@@ -26,7 +26,11 @@ function TBody({ data, columns, refs, methods, states, config }) {
26
26
  methods.selections && (React.createElement("td", { ref: (element) => {
27
27
  _tHeadTH.current[index] = element;
28
28
  }, className: "flex justify-content-center sticky-left", style: { display: "flex", alignItems: "center", height: rowHeights[index] ?? 0 }, "data-sticky-position": "left" },
29
- React.createElement(Checkbox, { key: Date.now(), ref: (element) => (refs._checkboxItems.current[index] = element), variant: "filled", color: "green", checked: refs._selectionItems.current.some((selectionItem) => methods.trackBy?.(selectionItem) === methods.trackBy?.(item)), onChange: (event) => {
29
+ React.createElement(Checkbox, { key: Date.now(), ref: (element) => {
30
+ if (!element)
31
+ return;
32
+ refs._checkboxItems.current[index] = element;
33
+ }, variant: "filled", color: "green", checked: refs._selectionItems.current.some((selectionItem) => methods.trackBy?.(selectionItem) === methods.trackBy?.(item)), onChange: (event) => {
30
34
  const key = methods.trackBy?.(item);
31
35
  if (event.target.checked) {
32
36
  if (!refs._selectionItems.current.some((_item) => methods.trackBy?.(_item) === key)) {
@@ -3,5 +3,5 @@ import IProps from "./IProps";
3
3
  import React from "react";
4
4
  declare const _default: <T extends object>(props: IProps<T> & {
5
5
  ref?: React.Ref<HTMLTableElement>;
6
- }) => JSX.Element;
6
+ }) => React.JSX.Element;
7
7
  export default _default;
@@ -27,7 +27,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
27
27
  const _tableWrapper = useRef(null);
28
28
  const _tableContent = useRef(null);
29
29
  const _tBody = useRef(null);
30
- const _dragItem = useRef();
30
+ const _dragItem = useRef(null);
31
31
  const _checkboxItems = useRef([]);
32
32
  const _filterCheckboxItems = useRef([]);
33
33
  // refs -> Search
@@ -241,7 +241,11 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
241
241
  ?.map((filter, fIndex) => {
242
242
  const name = typeof c.key !== "object" ? String(c.key) : String(c.key.field);
243
243
  return (React.createElement("div", null,
244
- 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]) &&
244
+ React.createElement(Checkbox, { ref: (element) => {
245
+ if (!element)
246
+ return;
247
+ _filterCheckboxItems.current[fIndex] = element;
248
+ }, variant: "filled", color: "green", label: filter.text, name: name, value: filter.value, checked: Array.isArray(checkboxSelectedParams?.[name]) &&
245
249
  checkboxSelectedParams?.[name]?.some((f) => String(f.value) === String(filter.value)), onChange: async (event) => await handleCheckboxChange(event) })));
246
250
  }))));
247
251
  default:
@@ -629,10 +633,18 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
629
633
  }) }, c.key && (React.createElement("div", { className: "filter-field" }, c.filterDataType === "date" ? (React.createElement(DatePicker, { value: (config.isServerSide ? ssrValue : csrValue) ?? "", name: key, onClick: () => {
630
634
  handleScroll();
631
635
  }, onChange: (value) => handleSearch(key, value, c.filterDataType), style: { height: "2rem" }, config: { isClock: true, isFooterButton: true, locale: config.locale }, disabled: !c.key || !!c.filters })) : (React.createElement(React.Fragment, null,
632
- React.createElement(Input, { ref: (element) => (_searchTextInputs.current[cIndex] = element), variant: c.key && !c.filters ? "outlined" : "filled", style: { height: "2rem" }, value: (config.isServerSide ? ssrValue : csrValue) ?? "", name: key, onClick: () => {
636
+ React.createElement(Input, { ref: (element) => {
637
+ if (!element)
638
+ return;
639
+ _searchTextInputs.current[cIndex] = element;
640
+ }, variant: c.key && !c.filters ? "outlined" : "filled", style: { height: "2rem" }, value: (config.isServerSide ? ssrValue : csrValue) ?? "", name: key, onClick: () => {
633
641
  handleScroll();
634
642
  }, onInput: (event) => handleSearch(event.currentTarget.name, event.currentTarget.value), disabled: !c.key || !!c.filters }),
635
- React.createElement("span", { ref: (element) => (_filterButton.current[cIndex] = element), onClick: (event) => {
643
+ React.createElement("span", { ref: (element) => {
644
+ if (!element)
645
+ return;
646
+ _filterButton.current[cIndex] = element;
647
+ }, onClick: (event) => {
636
648
  event.preventDefault();
637
649
  event.stopPropagation();
638
650
  // Temizlik...
@@ -66,7 +66,11 @@ const Notification = ({ title, message, status, direction = "bottom-left", trigg
66
66
  };
67
67
  return items.map((item, index) => {
68
68
  const bottom = getBottomPosition(index);
69
- return (React.createElement("div", { key: item.id, ref: (element) => (_notificationItems.current[index] = element), className: "ar-notification-item", style: items.length > 5
69
+ return (React.createElement("div", { key: item.id, ref: (element) => {
70
+ if (!element)
71
+ return;
72
+ _notificationItems.current[index] = element;
73
+ }, className: "ar-notification-item", style: items.length > 5
70
74
  ? {
71
75
  backgroundColor: `rgba(var(--white-rgb), ${index === items.length - 1 ? 1 : 0.1})`,
72
76
  backdropFilter: "blur(10px)",
@@ -193,7 +193,11 @@ const DatePicker = ({ variant, color, onChange, config, validation, ...attribute
193
193
  }, [dateChanged, calendarIsOpen]);
194
194
  useEffect(() => {
195
195
  const generateList = (count, current, setFunc) => {
196
- const items = Array.from({ length: count }, (_, i) => (React.createElement("li", { ref: (element) => count === 24 ? (_hoursLiElements.current[i] = element) : (_minutesLiElements.current[i] = element), key: i, ...(current === i ? { className: "selection-time" } : {}), onClick: () => {
196
+ const items = Array.from({ length: count }, (_, i) => (React.createElement("li", { ref: (element) => {
197
+ if (!element)
198
+ return;
199
+ count === 24 ? (_hoursLiElements.current[i] = element) : (_minutesLiElements.current[i] = element);
200
+ }, key: i, ...(current === i ? { className: "selection-time" } : {}), onClick: () => {
197
201
  if (count === 24) {
198
202
  setTimeChanged((prev) => !prev);
199
203
  _hours.current = i;
@@ -17,7 +17,7 @@ const Select = ({ variant = "outlined", status, color, border = { radius: "sm" }
17
17
  const _optionItems = useRef([]);
18
18
  const _searchField = useRef(null);
19
19
  // const _searchTimeOut = useRef<NodeJS.Timeout | null>(null);
20
- let _otoFocus = useRef().current;
20
+ let _otoFocus = useRef(null).current;
21
21
  let _navigationIndex = useRef(0);
22
22
  // states
23
23
  const [optionsOpen, setOptionsOpen] = useState(false);
@@ -203,7 +203,7 @@ const Select = ({ variant = "outlined", status, color, border = { radius: "sm" }
203
203
  }
204
204
  }
205
205
  return () => {
206
- clearTimeout(_otoFocus);
206
+ _otoFocus && clearTimeout(_otoFocus);
207
207
  window.removeEventListener("blur", () => setOptionsOpen(false));
208
208
  document.removeEventListener("click", handleClickOutSide);
209
209
  document.removeEventListener("keydown", handleKeys);
@@ -323,7 +323,11 @@ const Select = ({ variant = "outlined", status, color, border = { radius: "sm" }
323
323
  onCreate && !isSearchTextEqual && searchText.length > 0 && React.createElement("li", null, createField()),
324
324
  filteredOptions.map((option, index) => {
325
325
  const isItem = multiple && value.some((_value) => _value.value === option.value);
326
- return (React.createElement("li", { key: index, ref: (element) => (_optionItems.current[index] = element), className: option === value ? "selectedItem" : "", onClick: (event) => {
326
+ return (React.createElement("li", { key: index, ref: (element) => {
327
+ if (!element)
328
+ return;
329
+ _optionItems.current[index] = element;
330
+ }, className: option === value ? "selectedItem" : "", onClick: (event) => {
327
331
  event.stopPropagation();
328
332
  handleItemSelected(option);
329
333
  } },
@@ -6,26 +6,26 @@ declare const useLayout: () => {
6
6
  layout: {
7
7
  sider: {
8
8
  left: {
9
- element: import("react").ReactNode | null;
9
+ element: React.ReactNode | null;
10
10
  active: boolean;
11
11
  };
12
12
  right: {
13
- element: import("react").ReactNode | null;
13
+ element: React.ReactNode | null;
14
14
  active: boolean;
15
15
  };
16
16
  };
17
17
  };
18
18
  perPage: number;
19
19
  };
20
- setConfig: import("react").Dispatch<import("react").SetStateAction<{
20
+ setConfig: React.Dispatch<React.SetStateAction<{
21
21
  layout: {
22
22
  sider: {
23
23
  left: {
24
- element: import("react").ReactNode | null;
24
+ element: React.ReactNode | null;
25
25
  active: boolean;
26
26
  };
27
27
  right: {
28
- element: import("react").ReactNode | null;
28
+ element: React.ReactNode | null;
29
29
  active: boolean;
30
30
  };
31
31
  };
@@ -35,7 +35,7 @@ declare const useLayout: () => {
35
35
  };
36
36
  declare const useLoading: () => {
37
37
  isLoading: boolean;
38
- setIsLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
38
+ setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
39
39
  };
40
40
  declare const useLanguage: () => string | undefined;
41
41
  export { useLayout, useLoading, useLanguage, useTranslation, useNotification, useValidation };
@@ -27,7 +27,7 @@ export type MenuItemVariants = "vertical" | "horizontal";
27
27
  export type MenuItemType = "group" | "divider";
28
28
  export type FilterDataType = "string" | "number" | "date" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
29
29
  export type TableColumnType<T> = {
30
- title: string;
30
+ title?: string;
31
31
  key?: keyof T | {
32
32
  field: keyof T;
33
33
  nestedKey: string;
@@ -42,7 +42,7 @@ export type TableColumnType<T> = {
42
42
  where?: (item: T) => boolean;
43
43
  };
44
44
  config?: {
45
- width?: number;
45
+ width?: number | "auto" | "fit-content" | "max-content" | "min-content";
46
46
  alignContent?: "left" | "center" | "right";
47
47
  sticky?: "left" | "right";
48
48
  textWrap?: "wrap" | "nowrap";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.4.39",
3
+ "version": "0.4.40",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -42,11 +42,11 @@
42
42
  "react-dom": ">=18.0.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@types/node": "^22.2.0",
46
- "@types/react": "^18.3.3",
47
- "@types/react-dom": "^18.3.0",
45
+ "@types/node": "^25.5.2",
46
+ "@types/react": "^19.2.14",
47
+ "@types/react-dom": "^19.2.3",
48
48
  "ts-node": "^10.9.2",
49
- "tslib": "^2.6.3",
50
- "typescript": "^5.5.4"
49
+ "tslib": "^2.8.1",
50
+ "typescript": "^6.0.2"
51
51
  }
52
52
  }