ar-design 0.2.35 → 0.2.37

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.
@@ -334,7 +334,9 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
334
334
  React.createElement("div", null, c.filters.map((filter, fIndex) => {
335
335
  const name = typeof c.key !== "object" ? String(c.key) : String(c.key.field);
336
336
  return (React.createElement("div", null,
337
- React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), label: filter.text, name: name, status: "primary", value: filter.value, checked: checkboxSelectedParams?.[name]?.includes(String(filter.value)), onChange: async (event) => await handleCheckboxChange(event) })));
337
+ React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), label: filter.text, name: name, status: "primary",
338
+ // value={filter.value}
339
+ checked: checkboxSelectedParams?.[name]?.includes(String(filter.value)), onChange: async (event) => await handleCheckboxChange(event) })));
338
340
  }))), windowBlur: true },
339
341
  React.createElement(Button, { variant: "borderless", icon: { element: React.createElement(ARIcon, { icon: "Filter", stroke: "var(--primary)", size: 16 }) } }))))));
340
342
  })))),
@@ -369,7 +369,9 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
369
369
  c.filters && (React.createElement(Popover, { content: React.createElement("div", null, c.filters.map((filter, fIndex) => {
370
370
  const name = typeof c.key !== "object" ? String(c.key) : String(c.key.field);
371
371
  return (React.createElement("div", null,
372
- React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), label: filter.text, name: name, status: "primary", value: filter.value, checked: checkboxSelectedParams?.[name]?.includes(String(filter.value)), onChange: async (event) => await handleCheckboxChange(event) })));
372
+ React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), label: filter.text, name: name, status: "primary",
373
+ // value={filter.value}
374
+ checked: checkboxSelectedParams?.[name]?.includes(String(filter.value)), onChange: async (event) => await handleCheckboxChange(event) })));
373
375
  })), windowBlur: true },
374
376
  React.createElement(Button, { variant: "borderless", icon: { element: React.createElement(ARIcon, { icon: "Filter", stroke: "var(--primary)", size: 16 }) } })))))));
375
377
  })))),
@@ -5,5 +5,6 @@ interface IProps extends IValidation {
5
5
  onChange: (value?: string) => void;
6
6
  placeholder?: string;
7
7
  height?: number;
8
+ multilang?: boolean;
8
9
  }
9
10
  export default IProps;
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import IProps from "./IProps";
3
1
  import "../../../assets/css/components/form/text-editor/styles.css";
2
+ import IProps from "./IProps";
3
+ import React from "react";
4
4
  declare const TextEditor: React.FC<IProps>;
5
5
  export default TextEditor;
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import Utils from "../../../libs/infrastructure/shared/Utils";
3
- import React, { useEffect, useRef, useState } from "react";
4
- import Button from "../button";
5
- import { ARIcon } from "../../icons";
6
2
  import "../../../assets/css/components/form/text-editor/styles.css";
7
- const TextEditor = ({ name, value, onChange, placeholder, height, validation }) => {
3
+ import { ARIcon } from "../../icons";
4
+ import Button from "../button";
5
+ import React, { useEffect, useRef, useState } from "react";
6
+ import Utils from "../../../libs/infrastructure/shared/Utils";
7
+ const TextEditor = ({ name, value, onChange, placeholder, height, multilang, validation }) => {
8
8
  // refs
9
9
  const _container = useRef(null);
10
10
  const _arIframe = useRef(null);
@@ -64,8 +64,10 @@ const TextEditor = ({ name, value, onChange, placeholder, height, validation })
64
64
  if (selection && selection.rangeCount > 0)
65
65
  range = selection.getRangeAt(0);
66
66
  // Eğer içeriği kendimiz değiştirmedikse ve gelen value farklıysa, içeriği güncelle
67
- if (iframeDocument.body.innerHTML !== value)
68
- iframeDocument.body.innerHTML = value || `<p>${placeholder ?? ""}</p>`;
67
+ if (iframeDocument.body.innerHTML !== value) {
68
+ // iframeDocument.body.innerHTML = value || `<p>${placeholder ?? ""}</p>`;
69
+ iframeDocument.body.innerHTML = value ?? "";
70
+ }
69
71
  // Cursor (caret) konumunu geri yükle
70
72
  if (range) {
71
73
  selection?.removeAllRanges();
@@ -76,25 +78,27 @@ const TextEditor = ({ name, value, onChange, placeholder, height, validation })
76
78
  // Iframe yüklendikten sonra çalışacaktır.
77
79
  if (!iframe)
78
80
  return;
79
- const iframeDocument = iframe.contentDocument || iframe.contentWindow?.document;
80
- if (!iframeDocument)
81
- return; // 👈 Güvenlik önlemi
81
+ const _iframeDocument = iframe.contentDocument || iframe.contentWindow?.document;
82
+ if (!_iframeDocument)
83
+ return;
84
+ setIframeDocument(_iframeDocument);
85
+ _iframeDocument.designMode = "on";
82
86
  // Herhangi bir değişikliği izlemek için MutationObserver kullan
83
87
  const observer = new MutationObserver((mutationsList) => {
84
88
  mutationsList.forEach(() => {
85
- iframeDocument?.body.innerHTML === "<br>" ? onChange(undefined) : onChange(iframeDocument.body.innerHTML);
89
+ _iframeDocument?.body.innerHTML === "<br>"
90
+ ? onChangeRef.current(undefined)
91
+ : onChangeRef.current(_iframeDocument.body.innerHTML);
86
92
  });
87
93
  });
88
- setIframeDocument(iframeDocument);
89
- iframeDocument.designMode = "on";
90
94
  // Observer'ı body üzerinde başlat
91
- observer.observe(iframeDocument.body, { childList: true, subtree: true, characterData: true, attributes: true });
92
- iframeDocument.body.addEventListener("focus", handleFocus);
93
- iframeDocument.body.addEventListener("blur", handleBlur);
95
+ observer.observe(_iframeDocument.body, { childList: true, subtree: true, characterData: true, attributes: true });
96
+ _iframeDocument.body.addEventListener("focus", handleFocus);
97
+ _iframeDocument.body.addEventListener("blur", handleBlur);
94
98
  return () => {
95
99
  observer.disconnect();
96
- iframeDocument?.body.removeEventListener("focus", handleFocus);
97
- iframeDocument?.body.removeEventListener("blur", handleBlur);
100
+ _iframeDocument?.body.removeEventListener("focus", handleFocus);
101
+ _iframeDocument?.body.removeEventListener("blur", handleBlur);
98
102
  };
99
103
  }, [iframe]);
100
104
  useEffect(() => {
@@ -108,6 +112,11 @@ const TextEditor = ({ name, value, onChange, placeholder, height, validation })
108
112
  }
109
113
  };
110
114
  }, []);
115
+ const onChangeRef = useRef(onChange);
116
+ // onChange değiştiğinde ref'i güncelle
117
+ useEffect(() => {
118
+ onChangeRef.current = onChange;
119
+ }, [onChange]);
111
120
  return (React.createElement("div", { ref: _container, className: "ar-text-editor" },
112
121
  React.createElement("div", { className: "toolbar" }, toolbarButtons.map(({ command, icon, tooltip }) => (React.createElement(Button, { key: command, type: "button", variant: "borderless", status: "secondary", icon: { element: React.createElement(ARIcon, { icon: icon, size: 18, fill: "var(--gray-700)" }) }, tooltip: {
113
122
  text: tooltip,
@@ -88,10 +88,8 @@ export const useValidation = function (data, params, step) {
88
88
  paramsShape(param, currentData);
89
89
  }
90
90
  else {
91
- if (!value)
92
- return;
93
91
  // Subkey sadece bir seviye ise, doğrudan kullanılır.
94
- paramsShape(param, value[param.subkey]);
92
+ paramsShape(param, value?.[param.subkey]);
95
93
  }
96
94
  }
97
95
  else {
@@ -12,7 +12,7 @@ export type Icon = {
12
12
  };
13
13
  export type Sizes = "large" | "normal" | "small";
14
14
  export type Option = {
15
- value: string | number;
15
+ value: string | number | null;
16
16
  text: string;
17
17
  };
18
18
  export type MenuProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",