react-optimistic-chat 2.2.0 → 2.2.2

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
@@ -58,17 +58,6 @@ yarn add react-optimistic-chat
58
58
 
59
59
  <br>
60
60
 
61
- ## styles
62
- <code>react-optimistic-chat</code>의 **채팅 UI 컴포넌트**를 사용하려면
63
- 아래 스타일 파일을 반드시 import 해야 합니다.
64
- ```ts
65
- import "react-optimistic-chat/style.css";
66
- ```
67
- > React 프로젝트에서는 `App.tsx`에,
68
- > Next.js(App Router)에서는 루트 `Layout.tsx`에서 import 하는 것을 권장합니다.
69
-
70
- <br>
71
-
72
61
  <h1 id="quick-start">🚀 Quick Start</h1>
73
62
 
74
63
  아래 예제는 서버로부터 전달되는 Raw 채팅 데이터를
@@ -905,3 +894,4 @@ See the [LICENSE](./LICENSE) file for details.
905
894
 
906
895
 
907
896
 
897
+
package/dist/index.js CHANGED
@@ -59,6 +59,46 @@ __export(index_exports, {
59
59
  });
60
60
  module.exports = __toCommonJS(index_exports);
61
61
 
62
+ // #style-inject:#style-inject
63
+ function styleInject(css, { insertAt } = {}) {
64
+ if (!css || typeof document === "undefined") return;
65
+ const head = document.head || document.getElementsByTagName("head")[0];
66
+ const style = document.createElement("style");
67
+ style.type = "text/css";
68
+ if (insertAt === "top") {
69
+ if (head.firstChild) {
70
+ head.insertBefore(style, head.firstChild);
71
+ } else {
72
+ head.appendChild(style);
73
+ }
74
+ } else {
75
+ head.appendChild(style);
76
+ }
77
+ if (style.styleSheet) {
78
+ style.styleSheet.cssText = css;
79
+ } else {
80
+ style.appendChild(document.createTextNode(css));
81
+ }
82
+ }
83
+
84
+ // src/styles/chatMessage.css
85
+ styleInject(".roc-chat-message {\n display: flex;\n align-items: flex-start;\n margin-bottom: 1rem;\n width: 100%;\n box-sizing: border-box;\n}\n.roc-chat-message--left {\n justify-content: flex-start;\n}\n.roc-chat-message--right {\n justify-content: flex-end;\n}\n.roc-chat-message__icon {\n width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: #f3f4f6;\n border-radius: 9999px;\n border: 2px solid #000;\n flex-shrink: 0;\n margin-right: 0.5rem;\n}\n.roc-chat-message__icon svg {\n display: block;\n}\n.roc-chat-message__bubble {\n padding: 0.75rem;\n max-width: calc(100% - 3rem);\n max-height: 24rem;\n overflow-y: auto;\n white-space: pre-wrap;\n word-break: break-word;\n font-size: 0.875rem;\n line-height: 1.4;\n box-sizing: border-box;\n}\n.roc-chat-message__bubble--ai {\n background-color: #f3f4f6;\n border-radius: 0.75rem;\n}\n.roc-chat-message__bubble--user {\n background-color: #ffffff;\n border: 1px solid #e5e7eb;\n border-radius: 0.75rem 0.75rem 0 0.75rem;\n}\n");
86
+
87
+ // src/styles/chatList.css
88
+ styleInject(".roc-chat-list {\n display: flex;\n flex-direction: column;\n}\n");
89
+
90
+ // src/styles/chatInput.css
91
+ styleInject('.roc-chat-input {\n display: flex;\n border: 1px solid #d1d5db;\n padding: 8px 8px;\n border-radius: 24px;\n}\n.roc-chat-input__textarea {\n width: 100%;\n resize: none;\n border: none;\n font-size: 16px;\n line-height: 2.2;\n outline: none;\n overflow: hidden;\n padding: 0;\n padding-left: 8px;\n}\n.roc-chat-input__textarea::-moz-placeholder {\n color: #9ca3af;\n font-family:\n -apple-system,\n BlinkMacSystemFont,\n "Segoe UI",\n "Apple SD Gothic Neo",\n "Noto Sans KR",\n "Noto Sans",\n system-ui,\n sans-serif;\n}\n.roc-chat-input__textarea::placeholder {\n color: #9ca3af;\n font-family:\n -apple-system,\n BlinkMacSystemFont,\n "Segoe UI",\n "Apple SD Gothic Neo",\n "Noto Sans KR",\n "Noto Sans",\n system-ui,\n sans-serif;\n}\n.roc-chat-input__button {\n position: relative;\n width: 36px;\n height: 36px;\n margin-top: auto;\n flex-shrink: 0;\n background: none;\n border: none;\n margin-left: 8px;\n cursor: pointer;\n}\n.roc-chat-input__layer {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 24px;\n opacity: 0;\n transition: opacity 150ms ease;\n}\n.roc-chat-input__layer.is-active {\n opacity: 1;\n}\n.roc-chat-input__layer--mic {\n background: #f3f4f6;\n color: #374151;\n}\n.roc-chat-input__layer--recording {\n background: #dc2626;\n color: #ffffff;\n}\n.roc-chat-input__layer--send {\n background: #000000;\n color: #ffffff;\n}\n.roc-chat-input__layer--sending {\n background: #9ca3af;\n color: #ffffff;\n}\n');
92
+
93
+ // src/styles/chatContainer.css
94
+ styleInject(".roc-chat-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n.roc-chat-container__list {\n flex: 1;\n overflow-y: auto;\n padding: 8px;\n}\n.roc-chat-container__loading {\n display: flex;\n justify-content: center;\n padding: 8px 0;\n}\n.roc-chat-container__input {\n position: relative;\n flex-shrink: 0;\n}\n.roc-chat-container__scroll-button {\n position: absolute;\n bottom: 80px;\n left: 50%;\n transform: translateX(-50%);\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: #ffffff;\n border: 1px solid #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n}\n");
95
+
96
+ // src/styles/loadingSpinner.css
97
+ styleInject(".roc-spinner-wrapper {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.roc-spinner {\n border: 4px solid #e5e7eb;\n border-right-color: transparent;\n border-radius: 50%;\n animation: roc-spin 1s linear infinite;\n}\n@keyframes roc-spin {\n to {\n transform: rotate(1turn);\n }\n}\n");
98
+
99
+ // src/styles/sendingDots.css
100
+ styleInject(".roc-sending-dots {\n display: inline-flex;\n justify-content: space-between;\n align-items: center;\n}\n.roc-sending-dot {\n font-weight: 800;\n line-height: 1;\n animation: roc-sending-bounce 1.4s ease-in-out infinite;\n}\n@keyframes roc-sending-bounce {\n 0%, to {\n opacity: .2;\n transform: translateY(0);\n }\n 50% {\n opacity: 1;\n transform: translateY(-2px);\n }\n}\n");
101
+
62
102
  // src/components/indicators/LoadingSpinner.tsx
63
103
  var import_jsx_runtime = require("react/jsx-runtime");
64
104
  function LoadingSpinner({ size = "md" }) {
package/dist/index.mjs CHANGED
@@ -18,6 +18,46 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
 
21
+ // #style-inject:#style-inject
22
+ function styleInject(css, { insertAt } = {}) {
23
+ if (!css || typeof document === "undefined") return;
24
+ const head = document.head || document.getElementsByTagName("head")[0];
25
+ const style = document.createElement("style");
26
+ style.type = "text/css";
27
+ if (insertAt === "top") {
28
+ if (head.firstChild) {
29
+ head.insertBefore(style, head.firstChild);
30
+ } else {
31
+ head.appendChild(style);
32
+ }
33
+ } else {
34
+ head.appendChild(style);
35
+ }
36
+ if (style.styleSheet) {
37
+ style.styleSheet.cssText = css;
38
+ } else {
39
+ style.appendChild(document.createTextNode(css));
40
+ }
41
+ }
42
+
43
+ // src/styles/chatMessage.css
44
+ styleInject(".roc-chat-message {\n display: flex;\n align-items: flex-start;\n margin-bottom: 1rem;\n width: 100%;\n box-sizing: border-box;\n}\n.roc-chat-message--left {\n justify-content: flex-start;\n}\n.roc-chat-message--right {\n justify-content: flex-end;\n}\n.roc-chat-message__icon {\n width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: #f3f4f6;\n border-radius: 9999px;\n border: 2px solid #000;\n flex-shrink: 0;\n margin-right: 0.5rem;\n}\n.roc-chat-message__icon svg {\n display: block;\n}\n.roc-chat-message__bubble {\n padding: 0.75rem;\n max-width: calc(100% - 3rem);\n max-height: 24rem;\n overflow-y: auto;\n white-space: pre-wrap;\n word-break: break-word;\n font-size: 0.875rem;\n line-height: 1.4;\n box-sizing: border-box;\n}\n.roc-chat-message__bubble--ai {\n background-color: #f3f4f6;\n border-radius: 0.75rem;\n}\n.roc-chat-message__bubble--user {\n background-color: #ffffff;\n border: 1px solid #e5e7eb;\n border-radius: 0.75rem 0.75rem 0 0.75rem;\n}\n");
45
+
46
+ // src/styles/chatList.css
47
+ styleInject(".roc-chat-list {\n display: flex;\n flex-direction: column;\n}\n");
48
+
49
+ // src/styles/chatInput.css
50
+ styleInject('.roc-chat-input {\n display: flex;\n border: 1px solid #d1d5db;\n padding: 8px 8px;\n border-radius: 24px;\n}\n.roc-chat-input__textarea {\n width: 100%;\n resize: none;\n border: none;\n font-size: 16px;\n line-height: 2.2;\n outline: none;\n overflow: hidden;\n padding: 0;\n padding-left: 8px;\n}\n.roc-chat-input__textarea::-moz-placeholder {\n color: #9ca3af;\n font-family:\n -apple-system,\n BlinkMacSystemFont,\n "Segoe UI",\n "Apple SD Gothic Neo",\n "Noto Sans KR",\n "Noto Sans",\n system-ui,\n sans-serif;\n}\n.roc-chat-input__textarea::placeholder {\n color: #9ca3af;\n font-family:\n -apple-system,\n BlinkMacSystemFont,\n "Segoe UI",\n "Apple SD Gothic Neo",\n "Noto Sans KR",\n "Noto Sans",\n system-ui,\n sans-serif;\n}\n.roc-chat-input__button {\n position: relative;\n width: 36px;\n height: 36px;\n margin-top: auto;\n flex-shrink: 0;\n background: none;\n border: none;\n margin-left: 8px;\n cursor: pointer;\n}\n.roc-chat-input__layer {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 24px;\n opacity: 0;\n transition: opacity 150ms ease;\n}\n.roc-chat-input__layer.is-active {\n opacity: 1;\n}\n.roc-chat-input__layer--mic {\n background: #f3f4f6;\n color: #374151;\n}\n.roc-chat-input__layer--recording {\n background: #dc2626;\n color: #ffffff;\n}\n.roc-chat-input__layer--send {\n background: #000000;\n color: #ffffff;\n}\n.roc-chat-input__layer--sending {\n background: #9ca3af;\n color: #ffffff;\n}\n');
51
+
52
+ // src/styles/chatContainer.css
53
+ styleInject(".roc-chat-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n.roc-chat-container__list {\n flex: 1;\n overflow-y: auto;\n padding: 8px;\n}\n.roc-chat-container__loading {\n display: flex;\n justify-content: center;\n padding: 8px 0;\n}\n.roc-chat-container__input {\n position: relative;\n flex-shrink: 0;\n}\n.roc-chat-container__scroll-button {\n position: absolute;\n bottom: 80px;\n left: 50%;\n transform: translateX(-50%);\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: #ffffff;\n border: 1px solid #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n}\n");
54
+
55
+ // src/styles/loadingSpinner.css
56
+ styleInject(".roc-spinner-wrapper {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.roc-spinner {\n border: 4px solid #e5e7eb;\n border-right-color: transparent;\n border-radius: 50%;\n animation: roc-spin 1s linear infinite;\n}\n@keyframes roc-spin {\n to {\n transform: rotate(1turn);\n }\n}\n");
57
+
58
+ // src/styles/sendingDots.css
59
+ styleInject(".roc-sending-dots {\n display: inline-flex;\n justify-content: space-between;\n align-items: center;\n}\n.roc-sending-dot {\n font-weight: 800;\n line-height: 1;\n animation: roc-sending-bounce 1.4s ease-in-out infinite;\n}\n@keyframes roc-sending-bounce {\n 0%, to {\n opacity: .2;\n transform: translateY(0);\n }\n 50% {\n opacity: 1;\n transform: translateY(-2px);\n }\n}\n");
60
+
21
61
  // src/components/indicators/LoadingSpinner.tsx
22
62
  import { jsx } from "react/jsx-runtime";
23
63
  function LoadingSpinner({ size = "md" }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-optimistic-chat",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
package/dist/index.css DELETED
@@ -1,214 +0,0 @@
1
- /* src/styles/chatMessage.css */
2
- .roc-chat-message {
3
- display: flex;
4
- align-items: flex-start;
5
- margin-bottom: 1rem;
6
- width: 100%;
7
- box-sizing: border-box;
8
- }
9
- .roc-chat-message--left {
10
- justify-content: flex-start;
11
- }
12
- .roc-chat-message--right {
13
- justify-content: flex-end;
14
- }
15
- .roc-chat-message__icon {
16
- width: 40px;
17
- height: 40px;
18
- display: flex;
19
- align-items: center;
20
- justify-content: center;
21
- background-color: #f3f4f6;
22
- border-radius: 9999px;
23
- border: 2px solid #000;
24
- flex-shrink: 0;
25
- margin-right: 0.5rem;
26
- }
27
- .roc-chat-message__icon svg {
28
- display: block;
29
- }
30
- .roc-chat-message__bubble {
31
- padding: 0.75rem;
32
- max-width: calc(100% - 3rem);
33
- max-height: 24rem;
34
- overflow-y: auto;
35
- white-space: pre-wrap;
36
- word-break: break-word;
37
- font-size: 0.875rem;
38
- line-height: 1.4;
39
- box-sizing: border-box;
40
- }
41
- .roc-chat-message__bubble--ai {
42
- background-color: #f3f4f6;
43
- border-radius: 0.75rem;
44
- }
45
- .roc-chat-message__bubble--user {
46
- background-color: #ffffff;
47
- border: 1px solid #e5e7eb;
48
- border-radius: 0.75rem 0.75rem 0 0.75rem;
49
- }
50
-
51
- /* src/styles/chatList.css */
52
- .roc-chat-list {
53
- display: flex;
54
- flex-direction: column;
55
- }
56
-
57
- /* src/styles/chatInput.css */
58
- .roc-chat-input {
59
- display: flex;
60
- border: 1px solid #d1d5db;
61
- padding: 8px 8px;
62
- border-radius: 24px;
63
- }
64
- .roc-chat-input__textarea {
65
- width: 100%;
66
- resize: none;
67
- border: none;
68
- font-size: 16px;
69
- line-height: 2.2;
70
- outline: none;
71
- overflow: hidden;
72
- padding: 0;
73
- padding-left: 8px;
74
- }
75
- .roc-chat-input__textarea::-moz-placeholder {
76
- color: #9ca3af;
77
- font-family:
78
- -apple-system,
79
- BlinkMacSystemFont,
80
- "Segoe UI",
81
- "Apple SD Gothic Neo",
82
- "Noto Sans KR",
83
- "Noto Sans",
84
- system-ui,
85
- sans-serif;
86
- }
87
- .roc-chat-input__textarea::placeholder {
88
- color: #9ca3af;
89
- font-family:
90
- -apple-system,
91
- BlinkMacSystemFont,
92
- "Segoe UI",
93
- "Apple SD Gothic Neo",
94
- "Noto Sans KR",
95
- "Noto Sans",
96
- system-ui,
97
- sans-serif;
98
- }
99
- .roc-chat-input__button {
100
- position: relative;
101
- width: 36px;
102
- height: 36px;
103
- margin-top: auto;
104
- flex-shrink: 0;
105
- background: none;
106
- border: none;
107
- margin-left: 8px;
108
- cursor: pointer;
109
- }
110
- .roc-chat-input__layer {
111
- position: absolute;
112
- inset: 0;
113
- display: flex;
114
- align-items: center;
115
- justify-content: center;
116
- border-radius: 24px;
117
- opacity: 0;
118
- transition: opacity 150ms ease;
119
- }
120
- .roc-chat-input__layer.is-active {
121
- opacity: 1;
122
- }
123
- .roc-chat-input__layer--mic {
124
- background: #f3f4f6;
125
- color: #374151;
126
- }
127
- .roc-chat-input__layer--recording {
128
- background: #dc2626;
129
- color: #ffffff;
130
- }
131
- .roc-chat-input__layer--send {
132
- background: #000000;
133
- color: #ffffff;
134
- }
135
- .roc-chat-input__layer--sending {
136
- background: #9ca3af;
137
- color: #ffffff;
138
- }
139
-
140
- /* src/styles/chatContainer.css */
141
- .roc-chat-container {
142
- display: flex;
143
- flex-direction: column;
144
- height: 100%;
145
- }
146
- .roc-chat-container__list {
147
- flex: 1;
148
- overflow-y: auto;
149
- padding: 8px;
150
- }
151
- .roc-chat-container__loading {
152
- display: flex;
153
- justify-content: center;
154
- padding: 8px 0;
155
- }
156
- .roc-chat-container__input {
157
- position: relative;
158
- flex-shrink: 0;
159
- }
160
- .roc-chat-container__scroll-button {
161
- position: absolute;
162
- bottom: 80px;
163
- left: 50%;
164
- transform: translateX(-50%);
165
- width: 40px;
166
- height: 40px;
167
- border-radius: 50%;
168
- background: #ffffff;
169
- border: 1px solid #e5e7eb;
170
- display: flex;
171
- align-items: center;
172
- justify-content: center;
173
- cursor: pointer;
174
- }
175
-
176
- /* src/styles/loadingSpinner.css */
177
- .roc-spinner-wrapper {
178
- display: flex;
179
- align-items: center;
180
- justify-content: center;
181
- }
182
- .roc-spinner {
183
- border: 4px solid #e5e7eb;
184
- border-right-color: transparent;
185
- border-radius: 50%;
186
- animation: roc-spin 1s linear infinite;
187
- }
188
- @keyframes roc-spin {
189
- to {
190
- transform: rotate(1turn);
191
- }
192
- }
193
-
194
- /* src/styles/sendingDots.css */
195
- .roc-sending-dots {
196
- display: inline-flex;
197
- justify-content: space-between;
198
- align-items: center;
199
- }
200
- .roc-sending-dot {
201
- font-weight: 800;
202
- line-height: 1;
203
- animation: roc-sending-bounce 1.4s ease-in-out infinite;
204
- }
205
- @keyframes roc-sending-bounce {
206
- 0%, to {
207
- opacity: .2;
208
- transform: translateY(0);
209
- }
210
- 50% {
211
- opacity: 1;
212
- transform: translateY(-2px);
213
- }
214
- }