@ayseaistudio/ui-components 3.1.2 → 3.2.0

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.
@@ -15,9 +15,14 @@ interface Props {
15
15
  withUnderline?: boolean;
16
16
  withStrikethrough?: boolean;
17
17
  withHash?: boolean;
18
+ value?: string;
19
+ onChange?: (e: React.ChangeEvent<HTMLDivElement>) => void;
20
+ onKeyDown?: (e: React.KeyboardEvent<HTMLDivElement>) => void;
21
+ onValueChange?: (value: string) => void;
22
+ onEnter?: () => void;
18
23
  }
19
24
  export declare const MessageInputField: {
20
- ({ text, enter, richTextFormattingTools, className, placeholder, withPicture, withEmoji, withBold, withItalic, withUnderline, withStrikethrough, withHash, }: Props): React.JSX.Element;
25
+ ({ text, enter, richTextFormattingTools, className, placeholder, withPicture, withEmoji, withBold, withItalic, withUnderline, withStrikethrough, withHash, value, onChange, onKeyDown, onValueChange, onEnter, }: Props): React.JSX.Element;
21
26
  propTypes: {
22
27
  text: PropTypes.Requireable<string>;
23
28
  enter: PropTypes.Requireable<boolean>;
@@ -31,6 +36,11 @@ export declare const MessageInputField: {
31
36
  withUnderline: PropTypes.Requireable<boolean>;
32
37
  withStrikethrough: PropTypes.Requireable<boolean>;
33
38
  withHash: PropTypes.Requireable<boolean>;
39
+ value: PropTypes.Requireable<string>;
40
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
41
+ onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
42
+ onValueChange: PropTypes.Requireable<(...args: any[]) => any>;
43
+ onEnter: PropTypes.Requireable<(...args: any[]) => any>;
34
44
  };
35
45
  };
36
46
  export {};
@@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from "react";
4
4
  import "./style.css";
5
5
  import { IconArrowDown, IconBold, IconHash, IconItalic, IconMoodSmile, IconPhoto, IconStrikethrough, IconUnderline, } from "@tabler/icons-react";
6
6
  import { PrimaryButton } from "../PrimaryButton/PrimaryButton";
7
- export const MessageInputField = ({ text = "", enter = true, richTextFormattingTools = true, className, placeholder = "Mesaj yazın...", withPicture = true, withEmoji = true, withBold = true, withItalic = true, withUnderline = true, withStrikethrough = true, withHash = true, }) => {
7
+ export const MessageInputField = ({ text = "", enter = true, richTextFormattingTools = true, className, placeholder = "Mesaj yazın...", withPicture = true, withEmoji = true, withBold = true, withItalic = true, withUnderline = true, withStrikethrough = true, withHash = true, value, onChange, onKeyDown, onValueChange, onEnter, }) => {
8
8
  const editorRef = useRef(null);
9
9
  const fileInputRef = useRef(null);
10
10
  const [showEmoji, setShowEmoji] = useState(false);
@@ -20,6 +20,15 @@ export const MessageInputField = ({ text = "", enter = true, richTextFormattingT
20
20
  setIsEmpty(!editorRef.current.textContent || editorRef.current.textContent.trim().length === 0);
21
21
  }
22
22
  }, [text]);
23
+ // Keep editor content in sync when a controlled value is provided
24
+ useEffect(() => {
25
+ if (editorRef.current && value !== undefined) {
26
+ if (editorRef.current.textContent !== value) {
27
+ editorRef.current.textContent = value;
28
+ }
29
+ setIsEmpty(!value || value.trim().length === 0);
30
+ }
31
+ }, [value]);
23
32
  useEffect(() => {
24
33
  if (!showEmoji)
25
34
  return;
@@ -56,11 +65,26 @@ export const MessageInputField = ({ text = "", enter = true, richTextFormattingT
56
65
  "😀", "😁", "😂", "🤣", "😊", "😍", "🤔", "😎", "😅", "🙃",
57
66
  "👍", "🙏", "🎉", "🔥", "💡", "✅", "❌", "⚠️", "🚀", "❤️"
58
67
  ];
59
- return (_jsxs("div", { className: `message-input-field ${className ?? ""}`, children: [_jsxs("div", { className: "frame", children: [_jsx("div", { ref: editorRef, className: `m-teri-sat-raporlar ${isEmpty ? "is-empty" : ""}`, contentEditable: true, suppressContentEditableWarning: true, tabIndex: 0, "data-placeholder": placeholder, onInput: () => {
68
+ return (_jsxs("div", { className: `message-input-field ${className ?? ""}`, children: [_jsxs("div", { className: "frame", children: [_jsx("div", { ref: editorRef, className: `m-teri-sat-raporlar ${isEmpty ? "is-empty" : ""}`, contentEditable: true, suppressContentEditableWarning: true, tabIndex: 0, "data-placeholder": placeholder, onKeyDown: (e) => {
69
+ onKeyDown?.(e);
70
+ if (enter && onEnter && e.key === "Enter" && !e.shiftKey) {
71
+ e.preventDefault();
72
+ onEnter?.();
73
+ }
74
+ }, onInput: (e) => {
60
75
  if (editorRef.current) {
61
76
  setIsEmpty(!editorRef.current.textContent || editorRef.current.textContent.trim().length === 0);
62
77
  }
63
- } }), enter && (_jsx("div", { className: "primary-button-wrapper", children: _jsx(PrimaryButton, { className: "primary-button-instance", color: "black", leftIcon: _jsx(IconArrowDown, { className: "icon-instance-node" }), size: "large", status: "default" }) }))] }), richTextFormattingTools && (_jsx("div", { className: "content", children: _jsxs("div", { className: "primary-feature", children: [_jsxs("div", { className: "text-feature", children: [withBold && _jsx(IconBold, { className: "icon-instance-node toolbar-icon", color: "#3D3D3D", size: 20, strokeWidth: 1.5, onMouseDown: onIconMouseDown, onClick: () => exec("bold") }), withItalic && _jsx(IconItalic, { className: "icon-instance-node toolbar-icon", size: 20, strokeWidth: 1.5, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => exec("italic") }), withUnderline && _jsx(IconUnderline, { className: "icon-instance-node toolbar-icon", size: 20, strokeWidth: 1.5, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => exec("underline") }), withStrikethrough && _jsx(IconStrikethrough, { className: "icon-instance-node toolbar-icon", size: 20, strokeWidth: 1.5, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => exec("strikeThrough") })] }), _jsx("div", { className: "divide-vertical" }), _jsxs("div", { className: "text-feature", children: [withHash && _jsx(IconHash, { className: "icon-instance-node toolbar-icon", strokeWidth: 1.5, size: 20, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => exec("insertText", "#") }), _jsxs("div", { className: "text-feature", children: [withPicture && _jsx(IconPhoto, { className: "icon-instance-node toolbar-icon", size: 20, strokeWidth: 1.5, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => fileInputRef.current?.click() }), _jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", className: "hidden-file-input", onChange: (e) => {
78
+ // Forward as a change-like event for consumers that use onChange
79
+ if (onChange) {
80
+ onChange(e);
81
+ }
82
+ // Convenience string callback
83
+ if (onValueChange) {
84
+ const currentText = e.currentTarget.textContent ?? "";
85
+ onValueChange(currentText);
86
+ }
87
+ } }), enter && (_jsx("div", { className: "primary-button-wrapper", children: _jsx(PrimaryButton, { className: "primary-button-instance", color: "black", leftIcon: _jsx(IconArrowDown, { className: "icon-instance-node" }), size: "large", status: "default", onClick: () => onEnter?.() }) }))] }), richTextFormattingTools && (_jsx("div", { className: "content", children: _jsxs("div", { className: "primary-feature", children: [_jsxs("div", { className: "text-feature", children: [withBold && _jsx(IconBold, { className: "icon-instance-node toolbar-icon", color: "#3D3D3D", size: 20, strokeWidth: 1.5, onMouseDown: onIconMouseDown, onClick: () => exec("bold") }), withItalic && _jsx(IconItalic, { className: "icon-instance-node toolbar-icon", size: 20, strokeWidth: 1.5, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => exec("italic") }), withUnderline && _jsx(IconUnderline, { className: "icon-instance-node toolbar-icon", size: 20, strokeWidth: 1.5, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => exec("underline") }), withStrikethrough && _jsx(IconStrikethrough, { className: "icon-instance-node toolbar-icon", size: 20, strokeWidth: 1.5, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => exec("strikeThrough") })] }), _jsx("div", { className: "divide-vertical" }), _jsxs("div", { className: "text-feature", children: [withHash && _jsx(IconHash, { className: "icon-instance-node toolbar-icon", strokeWidth: 1.5, size: 20, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => exec("insertText", "#") }), _jsxs("div", { className: "text-feature", children: [withPicture && _jsx(IconPhoto, { className: "icon-instance-node toolbar-icon", size: 20, strokeWidth: 1.5, color: "#3D3D3D", onMouseDown: onIconMouseDown, onClick: () => fileInputRef.current?.click() }), _jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", className: "hidden-file-input", onChange: (e) => {
64
88
  const file = e.target.files?.[0];
65
89
  if (file)
66
90
  handleInsertImage(file);
@@ -84,4 +108,9 @@ MessageInputField.propTypes = {
84
108
  withUnderline: PropTypes.bool,
85
109
  withStrikethrough: PropTypes.bool,
86
110
  withHash: PropTypes.bool,
111
+ value: PropTypes.string,
112
+ onChange: PropTypes.func,
113
+ onKeyDown: PropTypes.func,
114
+ onValueChange: PropTypes.func,
115
+ onEnter: PropTypes.func,
87
116
  };
@@ -73,6 +73,8 @@
73
73
  height: 40px !important;
74
74
  padding: 12px 6px !important;
75
75
  width: 40px !important;
76
+ box-shadow: none !important;
77
+
76
78
  }
77
79
 
78
80
  .message-input-field .content {
@@ -7,14 +7,14 @@ interface AvatarData {
7
7
  version?: "default" | "half";
8
8
  }
9
9
  interface Props {
10
- icon: boolean;
10
+ icon?: boolean;
11
11
  status?: "pressing" | "hover" | "default";
12
- size: "large" | "medium";
12
+ size?: "large" | "medium";
13
13
  version: "multiple" | "single";
14
14
  className?: any;
15
- text: string;
16
- subtext: string;
17
- avatarLetter: string;
15
+ text?: string;
16
+ subtext?: string;
17
+ avatarLetter?: string;
18
18
  avatars?: AvatarData[];
19
19
  multipleAvatarSize?: "large" | "medium" | "small";
20
20
  multipleAvatarClassName?: any;
@@ -0,0 +1,29 @@
1
+ import PropTypes from "prop-types";
2
+ import "./style.css";
3
+ interface Props {
4
+ text?: string;
5
+ withLeftIcon?: boolean;
6
+ withText?: boolean;
7
+ withRightIcon?: boolean;
8
+ size?: "medium";
9
+ status?: "selected" | "default";
10
+ align?: "left-align";
11
+ version?: "no-background";
12
+ className?: any;
13
+ icon?: React.JSX.Element;
14
+ divClassName?: any;
15
+ }
16
+ export declare const TabButtonForSidebar: {
17
+ ({ text, withLeftIcon, withText, withRightIcon, size, status, align, version, className, icon, divClassName, }: Props): React.JSX.Element;
18
+ propTypes: {
19
+ text: PropTypes.Requireable<string>;
20
+ withLeftIcon: PropTypes.Requireable<boolean>;
21
+ withText: PropTypes.Requireable<boolean>;
22
+ withRightIcon: PropTypes.Requireable<boolean>;
23
+ size: PropTypes.Requireable<string>;
24
+ status: PropTypes.Requireable<string>;
25
+ align: PropTypes.Requireable<string>;
26
+ version: PropTypes.Requireable<string>;
27
+ };
28
+ };
29
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import PropTypes from "prop-types";
3
+ import "./style.css";
4
+ import { IconLayoutDashboard } from "@tabler/icons-react";
5
+ export const TabButtonForSidebar = ({ text = "Button", withLeftIcon = true, withText = true, withRightIcon = true, size, status, align, version, className, icon = _jsx(IconLayoutDashboard, { className: "icons-18", color: "#6D6D6D" }), divClassName, }) => {
6
+ return (_jsxs("div", { className: `tab-button ${className}`, children: [withLeftIcon && _jsx(_Fragment, { children: icon }), withText && (_jsx("div", { className: `button ${status} ${divClassName}`, children: text })), withRightIcon && (_jsx(IconLayoutDashboard, { className: "icons-18", color: status === "selected" ? "#3D3D3D" : "#6D6D6D" }))] }));
7
+ };
8
+ TabButtonForSidebar.propTypes = {
9
+ text: PropTypes.string,
10
+ withLeftIcon: PropTypes.bool,
11
+ withText: PropTypes.bool,
12
+ withRightIcon: PropTypes.bool,
13
+ size: PropTypes.oneOf(["medium"]),
14
+ status: PropTypes.oneOf(["selected", "default"]),
15
+ align: PropTypes.oneOf(["left-align"]),
16
+ version: PropTypes.oneOf(["no-background"]),
17
+ };
@@ -0,0 +1 @@
1
+ export { TabButtonForSidebar } from "./TabButtonForSidebar";
@@ -0,0 +1 @@
1
+ export { TabButtonForSidebar } from "./TabButtonForSidebar";
@@ -0,0 +1,40 @@
1
+ .tab-button {
2
+ align-items: center;
3
+ display: flex;
4
+ gap: 4px;
5
+ justify-content: center;
6
+ padding: 8px;
7
+ position: relative;
8
+ cursor: pointer;
9
+ }
10
+
11
+ .tab-button .button {
12
+ flex: 1;
13
+ font-family: var(--b1-medium-font-family);
14
+ font-size: var(--b1-medium-font-size);
15
+ font-style: var(--b1-medium-font-style);
16
+ font-weight: var(--b1-medium-font-weight);
17
+ letter-spacing: var(--b1-medium-letter-spacing);
18
+ line-height: var(--b1-medium-line-height);
19
+ position: relative;
20
+ }
21
+
22
+ .tab-button .icons-18 {
23
+ height: 20px !important;
24
+ position: relative !important;
25
+ width: 20px !important;
26
+ }
27
+
28
+ .tab-button .default {
29
+ color: #6d6d6d;
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: flex-start;
33
+ }
34
+
35
+ .tab-button .selected {
36
+ color: #3d3d3d;
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: flex-start;
40
+ }
package/dist/index.d.ts CHANGED
@@ -35,3 +35,4 @@ export { MessageInput } from "./MessageInput/MessageInput";
35
35
  export { Flag } from "./Flag/Flag";
36
36
  export { MessageInputField } from "./MessageInputField/MessageInputField";
37
37
  export { TimeSelector } from "./TimeSelector/TimeSelector";
38
+ export { TabButtonForSidebar } from "./TabButtonForSidebar/TabButtonForSidebar";
package/dist/index.js CHANGED
@@ -35,3 +35,4 @@ export { MessageInput } from "./MessageInput/MessageInput";
35
35
  export { Flag } from "./Flag/Flag";
36
36
  export { MessageInputField } from "./MessageInputField/MessageInputField";
37
37
  export { TimeSelector } from "./TimeSelector/TimeSelector";
38
+ export { TabButtonForSidebar } from "./TabButtonForSidebar/TabButtonForSidebar";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ayseaistudio/ui-components",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",