@harjs/react-ui 1.0.2 → 1.1.3

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.
package/README.md CHANGED
@@ -9,7 +9,7 @@ A lightweight, premium, and fully type-safe UI component library built explicitl
9
9
 
10
10
  ---
11
11
 
12
- ## 🚀 Key Features
12
+ ## Features
13
13
 
14
14
  - **Rich Component Ecosystem**: Out-of-the-box support for advanced architectural layout systems including dynamic Data Tables, Kanban Boards, Navigation Menus, Wizards (Steps), and Data Visualization Charts.
15
15
  - **Strict Type-Safety**: Fully engineered with TypeScript generics and atomic prop-types, giving you predictive IntelliSense and rigid compile-time validations for complex structures like nested table filters and form models.
@@ -18,7 +18,7 @@ A lightweight, premium, and fully type-safe UI component library built explicitl
18
18
 
19
19
  ---
20
20
 
21
- ## 📦 Installation
21
+ ## Installation
22
22
 
23
23
  To inject this package into your user interface layer workspace, execute the command corresponding to your package manager:
24
24
 
@@ -2,7 +2,9 @@
2
2
  import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import "../../../assets/css/components/charts/gantt/styles.css";
4
4
  import Pagination from "../../navigation/pagination";
5
- import { useTranslation } from "../../../libs/core/application/hooks";
5
+ import { useTranslation } from "@harjs/translation";
6
+ import TableTR from "../../../libs/core/application/locales/table/tr";
7
+ import TableEN from "../../../libs/core/application/locales/table/en";
6
8
  const colors = ["#A881FA", "#75CFA4", "#EE6D63", "#FAD87A"];
7
9
  const Gantt = ({ title, description, data, pagination, config = { isSearchable: false } }) => {
8
10
  // refs
@@ -48,7 +50,10 @@ const Gantt = ({ title, description, data, pagination, config = { isSearchable:
48
50
  let PREVMATCHMONT = 0;
49
51
  let PREVMATCHDAY = 0;
50
52
  // hooks
51
- const { t } = useTranslation(String(config.locale ?? "tr"));
53
+ const { t } = useTranslation(String(config?.locale ?? "tr"), {
54
+ tr: { ...TableTR },
55
+ en: { ...TableEN },
56
+ });
52
57
  // methods
53
58
  const handleResize = useCallback(() => {
54
59
  return (_) => {
@@ -4,11 +4,16 @@ import { ARIcon } from "../../../icons";
4
4
  import Grid from "../../grid-system";
5
5
  import Button from "../../../form/button";
6
6
  import Divider from "../../divider";
7
- import { useTranslation } from "../../../../libs/core/application/hooks";
7
+ import { useTranslation } from "@harjs/translation";
8
+ import KanbanBoardTR from "../../../../libs/core/application/locales/kanban-board/tr";
9
+ import KanbanBoardEN from "../../../../libs/core/application/locales/kanban-board/en";
8
10
  const { Row, Column, Box } = Grid;
9
11
  function DateFilters({ states, methods, config }) {
10
12
  // hooks
11
- const { t } = useTranslation(String(config?.locale ?? "tr"));
13
+ const { t } = useTranslation(String(config?.locale ?? "tr"), {
14
+ tr: { ...KanbanBoardTR },
15
+ en: { ...KanbanBoardEN },
16
+ });
12
17
  return Object.entries(states.dateFilters.get).map(([name, range], index) => {
13
18
  const isEqualsName = states.openName.get === name;
14
19
  const className = [];
@@ -4,11 +4,16 @@ import Checkbox from "../../../form/checkbox";
4
4
  import Grid from "../../grid-system";
5
5
  import Button from "../../../form/button";
6
6
  import Divider from "../../divider";
7
- import { useTranslation } from "../../../../libs/core/application/hooks";
7
+ import { useTranslation } from "@harjs/translation";
8
+ import KanbanBoardTR from "../../../../libs/core/application/locales/kanban-board/tr";
9
+ import KanbanBoardEN from "../../../../libs/core/application/locales/kanban-board/en";
8
10
  const { Box } = Grid;
9
11
  function SelectFilters({ states, methods, config }) {
10
12
  // hooks
11
- const { t } = useTranslation(String(config?.locale ?? "tr"));
13
+ const { t } = useTranslation(String(config?.locale ?? "tr"), {
14
+ tr: { ...KanbanBoardTR },
15
+ en: { ...KanbanBoardEN },
16
+ });
12
17
  return Object.entries(states.selectFilters.get).map(([name, values], index) => {
13
18
  const isEqualsName = states.openName.get === name;
14
19
  const className = [];
@@ -4,14 +4,19 @@ import DateFilters from "./DateFilters";
4
4
  import SelectFilters from "./SelectFilters";
5
5
  import React from "react";
6
6
  import Input from "../../../form/input";
7
- import { useTranslation } from "../../../../libs/core/application/hooks";
7
+ import { useTranslation } from "@harjs/translation";
8
+ import KanbanBoardTR from "../../../../libs/core/application/locales/kanban-board/tr";
9
+ import KanbanBoardEN from "../../../../libs/core/application/locales/kanban-board/en";
8
10
  function Filter({ states, config }) {
9
11
  // refs
10
12
  const _searchTimeOut = useRef(null);
11
13
  // states
12
14
  const [openName, setOpenName] = useState(null);
13
15
  // hooks
14
- const { t } = useTranslation(String(config?.locale ?? "tr"));
16
+ const { t } = useTranslation(String(config?.locale ?? "tr"), {
17
+ tr: { ...KanbanBoardTR },
18
+ en: { ...KanbanBoardEN },
19
+ });
15
20
  // methods
16
21
  const handleOpen = (name) => setOpenName(openName === name ? null : name);
17
22
  return (React.createElement("div", { className: "filters" },
@@ -3,12 +3,14 @@ import React, { memo, useEffect, useMemo, useRef } from "react";
3
3
  import ReactDOM from "react-dom";
4
4
  import { ARIcon } from "../../icons";
5
5
  import { ExtractKey } from "./Helpers";
6
- import { useTranslation } from "../../../libs/core/application/hooks";
6
+ import TableTR from "../../../libs/core/application/locales/table/tr";
7
+ import TableEN from "../../../libs/core/application/locales/table/en";
8
+ import { useTranslation } from "@harjs/translation";
7
9
  function PropertiesPopup({ refs, states, methods, coordinate, config }) {
8
10
  // refs
9
11
  const _arTablePropertiesPopup = useRef(null);
10
12
  // hooks
11
- const { t } = useTranslation(String(config.locale ?? "tr"));
13
+ const { t } = useTranslation(String(config.locale ?? "tr"), { tr: { ...TableTR }, en: { ...TableEN } });
12
14
  // methods
13
15
  const handleClickOutSide = (event) => {
14
16
  const target = event.target;
@@ -3,7 +3,9 @@ import React, { Fragment, memo, useEffect, useRef, useState } from "react";
3
3
  import { ARIcon } from "../../../icons";
4
4
  import Checkbox from "../../../form/checkbox";
5
5
  import Editable from "./Editable";
6
- import { useTranslation } from "../../../../libs/core/application/hooks";
6
+ import TableTR from "../../../../libs/core/application/locales/table/tr";
7
+ import TableEN from "../../../../libs/core/application/locales/table/en";
8
+ import { useTranslation } from "@harjs/translation";
7
9
  const SubitemList = ({ items, columns, depth, level = 1, parentKey = "", config, methods, states, renderCell, }) => {
8
10
  const _subrowSelector = config.subrow?.selector ?? "subitems";
9
11
  const _subrowButton = config.subrow?.button ?? true;
@@ -48,7 +50,7 @@ function TBody({ data, columns, refs, methods, states, config }) {
48
50
  const [rowHeights, setRowHeights] = useState([]);
49
51
  const _subrowSelector = config.subrow?.selector ?? "subitems";
50
52
  const _subrowButton = config.subrow?.button ?? false;
51
- const { t } = useTranslation(String(config.locale ?? "tr"));
53
+ const { t } = useTranslation(String(config.locale ?? "tr"), { tr: { ...TableTR }, en: { ...TableEN } });
52
54
  const renderCell = ({ item, column, index, cIndex, depth, level, height = 0, isSubrows = false }) => {
53
55
  let render;
54
56
  const itemTrackId = methods.trackBy?.(item) ?? index.toString();
@@ -19,7 +19,9 @@ import { ExtractKey } from "./Helpers";
19
19
  import Header from "./header/Header";
20
20
  import TBody from "./body/TBody";
21
21
  import DatePicker from "../../form/date-picker";
22
- import { useTranslation } from "../../../libs/core/application/hooks";
22
+ import { useTranslation } from "@harjs/translation";
23
+ import TableTR from "../../../libs/core/application/locales/table/tr";
24
+ import TableEN from "../../../libs/core/application/locales/table/en";
23
25
  const { Row, Column } = Grid;
24
26
  const Table = forwardRef(({ children, trackBy, title, description, data, columns, actions, rowBackgroundColor, selections, selectionDisabled, previousSelections, sortedParams, searchedParams, onEditable, onDnD, pagination, config = { isSearchable: false }, }, ref) => {
25
27
  const _innerRef = useRef(null);
@@ -64,7 +66,10 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
64
66
  const [currentPage, setCurrentPage] = useState(1);
65
67
  const [selectedPerPage, setSelectedPerPage] = useState(pagination?.perPage ?? 10);
66
68
  const [isMobile, setIsMobile] = useState(false);
67
- const { t } = useTranslation(String(config.locale ?? "tr"));
69
+ const { t } = useTranslation(String(config.locale ?? "tr"), {
70
+ tr: { ...TableTR },
71
+ en: { ...TableEN },
72
+ });
68
73
  useImperativeHandle(ref, () => _innerRef.current);
69
74
  if (config && Object.keys(config.scroll || {}).length > 0) {
70
75
  if (_tableContent.current && config.scroll) {
@@ -1,5 +1,4 @@
1
1
  import { ConfigProvider } from "./Config";
2
2
  import { NotificationProvider } from "./Notification";
3
- import { LanguageProvider } from "./Language";
4
3
  import { LoadingProvider } from "./Loading";
5
- export { ConfigProvider, LanguageProvider, NotificationProvider, LoadingProvider };
4
+ export { ConfigProvider, NotificationProvider, LoadingProvider };
@@ -1,5 +1,4 @@
1
1
  import { ConfigProvider } from "./Config";
2
2
  import { NotificationProvider } from "./Notification";
3
- import { LanguageProvider } from "./Language";
4
3
  import { LoadingProvider } from "./Loading";
5
- export { ConfigProvider, LanguageProvider, NotificationProvider, LoadingProvider };
4
+ export { ConfigProvider, NotificationProvider, LoadingProvider };
@@ -1,6 +1,5 @@
1
1
  import useNotification from "./useNotification";
2
2
  import useValidation from "./useValidation";
3
- import useTranslation from "./useTranslation";
4
3
  declare const useLayout: () => {
5
4
  config: {
6
5
  layout: {
@@ -37,5 +36,4 @@ declare const useLoading: () => {
37
36
  isLoading: boolean;
38
37
  setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
39
38
  };
40
- declare const useLanguage: () => string | undefined;
41
- export { useLayout, useLoading, useLanguage, useTranslation, useNotification, useValidation };
39
+ export { useLayout, useLoading, useNotification, useValidation };
@@ -1,11 +1,9 @@
1
1
  "use client";
2
2
  import { useContext } from "react";
3
3
  import { ConfigContext } from "../contexts/Config";
4
- import { LanguageContext } from "../contexts/Language";
5
4
  import { LoadingContext } from "../contexts/Loading";
6
5
  import useNotification from "./useNotification";
7
6
  import useValidation from "./useValidation";
8
- import useTranslation from "./useTranslation";
9
7
  const useLayout = () => {
10
8
  const context = useContext(ConfigContext);
11
9
  if (!context)
@@ -13,5 +11,4 @@ const useLayout = () => {
13
11
  return context;
14
12
  };
15
13
  const useLoading = () => useContext(LoadingContext);
16
- const useLanguage = () => useContext(LanguageContext);
17
- export { useLayout, useLoading, useLanguage, useTranslation, useNotification, useValidation };
14
+ export { useLayout, useLoading, useNotification, useValidation };
@@ -0,0 +1,5 @@
1
+ import DATE from "./DATE";
2
+ import NUMBER from "./NUMBER";
3
+ import PHONE from "./PHONE";
4
+ import Utils from "./Utils";
5
+ export { DATE, NUMBER, PHONE, Utils };
@@ -0,0 +1,5 @@
1
+ import DATE from "./DATE";
2
+ import NUMBER from "./NUMBER";
3
+ import PHONE from "./PHONE";
4
+ import Utils from "./Utils";
5
+ export { DATE, NUMBER, PHONE, Utils };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harjs/react-ui",
3
- "version": "1.0.2",
3
+ "version": "1.1.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -66,5 +66,8 @@
66
66
  "ts-node": "^10.9.2",
67
67
  "tslib": "^2.8.1",
68
68
  "typescript": "^6.0.3"
69
+ },
70
+ "dependencies": {
71
+ "@harjs/translation": "^1.0.1"
69
72
  }
70
73
  }
@@ -1,7 +0,0 @@
1
- import React from "react";
2
- declare const LanguageContext: React.Context<string | undefined>;
3
- declare const LanguageProvider: ({ children, language }: {
4
- children: React.ReactNode;
5
- language: string | undefined;
6
- }) => React.JSX.Element;
7
- export { LanguageContext, LanguageProvider };
@@ -1,7 +0,0 @@
1
- "use client";
2
- import React, { createContext } from "react";
3
- const LanguageContext = createContext(undefined);
4
- const LanguageProvider = ({ children, language }) => {
5
- return React.createElement(LanguageContext.Provider, { value: language }, children);
6
- };
7
- export { LanguageContext, LanguageProvider };
@@ -1,9 +0,0 @@
1
- import { INotificationLocale } from "../locales";
2
- import IKanbanBoardLocale from "../locales/kanban-board/IKanbanBoardLocale";
3
- import ITableLocale from "../locales/table/ITableLocale";
4
- type LocaleMap = Record<string, Record<string, any>>;
5
- declare const useTranslation: <TBaseLocale>(currentLanguage: string | undefined, translations?: LocaleMap) => {
6
- t: (key: Extract<keyof TBaseLocale | keyof ITableLocale | keyof IKanbanBoardLocale | keyof INotificationLocale, string>, ...args: any[]) => string;
7
- currentLanguage: string | undefined;
8
- };
9
- export default useTranslation;
@@ -1,25 +0,0 @@
1
- import Utils from "../../../infrastructure/shared/Utils";
2
- import { NotificationEN, NotificationTR } from "../locales";
3
- import KanbanBoardEN from "../locales/kanban-board/en";
4
- import KanbanBoardTR from "../locales/kanban-board/tr";
5
- import TableEN from "../locales/table/en";
6
- import TableTR from "../locales/table/tr";
7
- const useTranslation = function (currentLanguage, translations = {}) {
8
- const merged = {};
9
- const ExtraLocales = {
10
- tr: { ...TableTR, ...KanbanBoardTR, ...NotificationTR },
11
- en: { ...TableEN, ...KanbanBoardEN, ...NotificationEN },
12
- };
13
- const allLanguages = new Set([...Object.keys(translations), ...Object.keys(ExtraLocales)]);
14
- allLanguages.forEach((lang) => {
15
- merged[lang] = {
16
- ...translations[lang],
17
- ...ExtraLocales[lang],
18
- };
19
- });
20
- const t = (key, ...args) => {
21
- return Utils.StringFormat(merged[currentLanguage ?? "tr"][key], ...args) ?? "";
22
- };
23
- return { t, currentLanguage };
24
- };
25
- export default useTranslation;