ar-design 0.2.26 → 0.2.28

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,5 +1,5 @@
1
1
  .ar-chip {
2
- display: flex;
2
+ display: inline-flex;
3
3
  justify-content: center;
4
4
  align-items: center;
5
5
  gap: 0 0.5rem;
@@ -7,6 +7,7 @@ import Pagination from "../../navigation/pagination";
7
7
  import React, { forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
8
8
  import Input from "../../form/input";
9
9
  import Popover from "../../feedback/popover";
10
+ import Utils from "../../../libs/infrastructure/shared/Utils";
10
11
  const Table = forwardRef(({ children, title, description, data, columns, actions, selections, previousSelections, searchedParams, pagination, config = { isSearchable: false }, }, ref) => {
11
12
  // refs
12
13
  const _tableWrapper = useRef(null);
@@ -169,7 +170,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
169
170
  };
170
171
  const getData = useMemo(() => {
171
172
  let _data = [...data];
172
- if (searchedText) {
173
+ if (searchedText && Object.keys(searchedText).length > 0) {
173
174
  _data = _data.filter((item) => deepSearch(item, searchedText));
174
175
  setTotalRecords(_data.length);
175
176
  }
@@ -354,7 +355,9 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
354
355
  } })))));
355
356
  });
356
357
  export default memo(Table, (prevProps, nextProps) => {
357
- return (JSON.stringify(prevProps.data) === JSON.stringify(nextProps.data) &&
358
- JSON.stringify(prevProps.columns) === JSON.stringify(nextProps.columns) &&
359
- JSON.stringify(prevProps.actions) === JSON.stringify(nextProps.actions));
358
+ const data = Utils.DeepEqual(prevProps.data, nextProps.data);
359
+ const columns = Utils.DeepEqual(prevProps.columns, nextProps.columns);
360
+ const actions = Utils.DeepEqual(prevProps.actions, nextProps.actions);
361
+ const previousSelections = Utils.DeepEqual(prevProps.previousSelections, nextProps.previousSelections);
362
+ return data && columns && actions && previousSelections;
360
363
  });
@@ -40,7 +40,9 @@ const Pagination = ({ defaultCurrent = 1, currentPage, totalRecords, perPage, on
40
40
  setPages(liItems);
41
41
  onChange(_currentPage);
42
42
  }, [totalRecords, _currentPage]);
43
- useEffect(() => setCurrentPage(currentPage), [currentPage]);
43
+ useEffect(() => {
44
+ setCurrentPage(currentPage);
45
+ }, [currentPage]);
44
46
  return (React.createElement("div", { className: "ar-pagination" },
45
47
  React.createElement("ul", null,
46
48
  React.createElement("li", { className: _currentPage === 1 ? "passive" : "", onClick: () => {
@@ -1,5 +1,6 @@
1
1
  import { Status } from "../contexts/Notification";
2
2
  import { ValidationProperties } from "../../../types";
3
+ import { INotificationLocale } from "../locales";
3
4
  export declare const useLayout: () => {
4
5
  config: {
5
6
  layout: {
@@ -37,10 +38,10 @@ export declare const useLoading: () => {
37
38
  setIsLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
38
39
  };
39
40
  export declare const useLanguage: () => string | undefined;
40
- export declare const useTranslation: <TBaseLocale>(currentLanguage: string | undefined, translations: {
41
+ export declare const useTranslation: <TBaseLocale>(currentLanguage: string | undefined, translations?: {
41
42
  [key: string]: any;
42
43
  }) => {
43
- t: (key: keyof TBaseLocale, ...args: any[]) => string;
44
+ t: (key: keyof TBaseLocale & keyof INotificationLocale, ...args: any[]) => string;
44
45
  currentLanguage: string | undefined;
45
46
  };
46
47
  export declare const useNotification: () => {
@@ -4,6 +4,7 @@ import { NotificationContext } from "../contexts/Notification";
4
4
  import Utils from "../../../infrastructure/shared/Utils";
5
5
  import { LanguageContext } from "../contexts/Language";
6
6
  import { LoadingContext } from "../contexts/Loading";
7
+ import { NotificationTR, NotificationEN } from "../locales";
7
8
  export const useLayout = () => {
8
9
  const context = useContext(ConfigContext);
9
10
  if (!context)
@@ -13,8 +14,12 @@ export const useLayout = () => {
13
14
  export const useLoading = () => useContext(LoadingContext);
14
15
  export const useLanguage = () => useContext(LanguageContext);
15
16
  export const useTranslation = function (currentLanguage, translations) {
17
+ const merged = {
18
+ tr: { ...translations?.tr, ...NotificationTR },
19
+ en: { ...translations?.en, ...NotificationEN },
20
+ };
16
21
  const t = (key, ...args) => {
17
- return Utils.StringFormat(translations[currentLanguage ?? "tr"][key], args) ?? "";
22
+ return Utils.StringFormat(merged[currentLanguage ?? "tr"][key], args) ?? "";
18
23
  };
19
24
  return { t, currentLanguage };
20
25
  };
@@ -6,6 +6,7 @@ declare class Utils {
6
6
  GetOSShortCutIcons: () => "⌘" | "ctrl" | "";
7
7
  StringFormat: (value: string, ...args: any[]) => string;
8
8
  IsNullOrEmpty: (value: unknown) => boolean;
9
+ DeepEqual: (obj1: any, obj2: any) => boolean;
9
10
  }
10
11
  declare const _default: Utils;
11
12
  export default _default;
@@ -66,5 +66,17 @@ class Utils {
66
66
  return true;
67
67
  return false;
68
68
  };
69
+ DeepEqual = (obj1, obj2) => {
70
+ if (Object.is(obj1, obj2))
71
+ return true; // Aynı referanssa true döndür
72
+ if (typeof obj1 !== "object" || typeof obj2 !== "object" || obj1 === null || obj2 === null) {
73
+ return false; // Eğer biri obje değilse ve eşit değilse false
74
+ }
75
+ const keys1 = Object.keys(obj1);
76
+ const keys2 = Object.keys(obj2);
77
+ if (keys1.length !== keys2.length)
78
+ return false; // Farklı uzunlukta anahtar varsa false
79
+ return keys1.every((key) => this.DeepEqual(obj1[key], obj2[key])); // Rekürsif karşılaştırma
80
+ };
69
81
  }
70
82
  export default new Utils();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",