@webinex/chatify 1.0.0-build2 → 1.0.0-rc2

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.
Files changed (56) hide show
  1. package/package.json +90 -90
  2. package/src/ChatifyContext.tsx +41 -41
  3. package/src/core/action.tsx +319 -319
  4. package/src/core/client.ts +137 -137
  5. package/src/core/index.ts +14 -14
  6. package/src/core/models.tsx +75 -75
  7. package/src/core/reducer.tsx +86 -86
  8. package/src/core/state.ts +38 -38
  9. package/src/core/useAccounts.tsx +11 -11
  10. package/src/core/useAddChat.tsx +12 -12
  11. package/src/core/useAddMember.tsx +12 -12
  12. package/src/core/useAddMessage.tsx +40 -40
  13. package/src/core/useChat.tsx +12 -12
  14. package/src/core/useChatList.tsx +10 -10
  15. package/src/core/useLoadMore.tsx +42 -42
  16. package/src/core/useMessages.tsx +23 -23
  17. package/src/core/useMutation.tsx +48 -48
  18. package/src/core/useQuery.tsx +45 -45
  19. package/src/core/useReadMonitor.tsx +31 -31
  20. package/src/core/useRemoveMember.tsx +12 -12
  21. package/src/core/useSignalRMonitor.tsx +52 -52
  22. package/src/index.ts +3 -3
  23. package/src/ui/AddChat.tsx +55 -55
  24. package/src/ui/AddChatButton.tsx +19 -19
  25. package/src/ui/Aside.tsx +41 -41
  26. package/src/ui/Avatar.tsx +18 -18
  27. package/src/ui/Chat.tsx +26 -26
  28. package/src/ui/ChatBody.tsx +43 -43
  29. package/src/ui/ChatHeader.tsx +33 -33
  30. package/src/ui/ChatHeaderMembers.tsx +30 -30
  31. package/src/ui/ChatHeaderSettingsButton.tsx +26 -26
  32. package/src/ui/ChatListItem.tsx +101 -101
  33. package/src/ui/ChatName.tsx +15 -15
  34. package/src/ui/ChatSettings.tsx +59 -59
  35. package/src/ui/Chatify.tsx +106 -106
  36. package/src/ui/Footer.tsx +7 -7
  37. package/src/ui/Header.tsx +14 -14
  38. package/src/ui/Icon.tsx +21 -21
  39. package/src/ui/InputForm.tsx +51 -51
  40. package/src/ui/LoadMore.tsx +40 -40
  41. package/src/ui/Main.tsx +16 -16
  42. package/src/ui/Message.tsx +118 -118
  43. package/src/ui/MessageSkeleton.tsx +19 -19
  44. package/src/ui/SendingMessage.tsx +50 -50
  45. package/src/ui/SystemMessage.tsx +32 -32
  46. package/src/ui/index.ts +11 -11
  47. package/src/ui/localizer.tsx +68 -68
  48. package/src/ui/styles/aside.scss +94 -94
  49. package/src/ui/styles/index.scss +248 -248
  50. package/src/ui/styles/keyframes.scss +14 -14
  51. package/src/ui/styles/mixins.scss +20 -20
  52. package/src/ui/styles/variables.scss +10 -10
  53. package/src/util/customize.tsx +45 -45
  54. package/src/util/index.ts +3 -3
  55. package/src/util/uniqBy.tsx +17 -17
  56. package/src/util/uniqId.tsx +3 -3
@@ -1,14 +1,14 @@
1
- @keyframes fadeInFromNone {
2
- 0% {
3
- display: none;
4
- opacity: 0;
5
- }
6
-
7
- 1% {
8
- opacity: 0;
9
- }
10
-
11
- 100% {
12
- opacity: 1;
13
- }
14
- }
1
+ @keyframes fadeInFromNone {
2
+ 0% {
3
+ display: none;
4
+ opacity: 0;
5
+ }
6
+
7
+ 1% {
8
+ opacity: 0;
9
+ }
10
+
11
+ 100% {
12
+ opacity: 1;
13
+ }
14
+ }
@@ -1,20 +1,20 @@
1
- @mixin scrollbar() {
2
- &::-webkit-scrollbar {
3
- width: 8px;
4
- height: 8px;
5
- }
6
-
7
- &::-webkit-scrollbar-track {
8
- background-color: #f1f1f1;
9
- }
10
-
11
- &::-webkit-scrollbar-thumb {
12
- background-color: #dfdfdf;
13
- }
14
- }
15
-
16
- @mixin avatarSize($size) {
17
- width: $size;
18
- height: $size;
19
- line-height: $size - 2px;
20
- }
1
+ @mixin scrollbar() {
2
+ &::-webkit-scrollbar {
3
+ width: 8px;
4
+ height: 8px;
5
+ }
6
+
7
+ &::-webkit-scrollbar-track {
8
+ background-color: #f1f1f1;
9
+ }
10
+
11
+ &::-webkit-scrollbar-thumb {
12
+ background-color: #dfdfdf;
13
+ }
14
+ }
15
+
16
+ @mixin avatarSize($size) {
17
+ width: $size;
18
+ height: $size;
19
+ line-height: $size - 2px;
20
+ }
@@ -1,10 +1,10 @@
1
- $borderColor: #ddd;
2
- $border: 1px solid #ddd;
3
- $background: white;
4
- $radius: 4px;
5
- $chatBodyBackground: #f5f5f5;
6
- $messageBackground: #e1f5fe;
7
- $myMessageBackground: #b9f6ca;
8
- $unreadCountBackground: #ffa726;
9
- $avatarSize: 40px;
10
- $messageBorderRadius: 10px;
1
+ $borderColor: #ddd;
2
+ $border: 1px solid #ddd;
3
+ $background: white;
4
+ $radius: 4px;
5
+ $chatBodyBackground: #f5f5f5;
6
+ $messageBackground: #e1f5fe;
7
+ $myMessageBackground: #b9f6ca;
8
+ $unreadCountBackground: #ffa726;
9
+ $avatarSize: 40px;
10
+ $messageBorderRadius: 10px;
@@ -1,45 +1,45 @@
1
- import React, { FC, PropsWithChildren, useContext } from 'react';
2
-
3
- export type Customizable<TComponent extends React.ComponentType<any>, TKey extends string> = TComponent & {
4
- Component: TComponent;
5
- key: TKey;
6
- };
7
-
8
- const CustomizeContext = React.createContext<CustomizeProviderValue>(null!);
9
-
10
- export interface CustomizeProviderValue {
11
- [key: string]: React.ComponentType<any> | null;
12
- }
13
-
14
- export function CustomizeProvider(props: PropsWithChildren<{ value: CustomizeProviderValue }>) {
15
- const { children, value } = props;
16
- return <CustomizeContext.Provider value={value}>{children}</CustomizeContext.Provider>;
17
- }
18
-
19
- function useCustom<TComponent extends React.ComponentType>(key: string): TComponent | undefined | null {
20
- const value = useContext(CustomizeContext);
21
- return value[key] as TComponent | null | undefined;
22
- }
23
-
24
- export function customize<TComponent extends React.ComponentType<any>, TKey extends string>(
25
- key: TKey,
26
- Component: TComponent,
27
- ): Customizable<TComponent, TKey> {
28
- const Result: FC<any> = React.forwardRef<TComponent, any>((props: any, forwardRef) => {
29
- const Custom = useCustom(key);
30
-
31
- if (Custom === null) {
32
- return null;
33
- }
34
-
35
- if (Custom) {
36
- return <Custom {...props} ref={forwardRef} />;
37
- }
38
-
39
- return <Component {...props} ref={forwardRef} />;
40
- });
41
-
42
- Result.displayName = 'Customizable.' + Component.displayName;
43
-
44
- return Object.assign(Result, { key, Component }) as any;
45
- }
1
+ import React, { FC, PropsWithChildren, useContext } from 'react';
2
+
3
+ export type Customizable<TComponent extends React.ComponentType<any>, TKey extends string> = TComponent & {
4
+ Component: TComponent;
5
+ key: TKey;
6
+ };
7
+
8
+ const CustomizeContext = React.createContext<CustomizeProviderValue>(null!);
9
+
10
+ export interface CustomizeProviderValue {
11
+ [key: string]: React.ComponentType<any> | null;
12
+ }
13
+
14
+ export function CustomizeProvider(props: PropsWithChildren<{ value: CustomizeProviderValue }>) {
15
+ const { children, value } = props;
16
+ return <CustomizeContext.Provider value={value}>{children}</CustomizeContext.Provider>;
17
+ }
18
+
19
+ function useCustom<TComponent extends React.ComponentType>(key: string): TComponent | undefined | null {
20
+ const value = useContext(CustomizeContext);
21
+ return value[key] as TComponent | null | undefined;
22
+ }
23
+
24
+ export function customize<TComponent extends React.ComponentType<any>, TKey extends string>(
25
+ key: TKey,
26
+ Component: TComponent,
27
+ ): Customizable<TComponent, TKey> {
28
+ const Result: FC<any> = React.forwardRef<TComponent, any>((props: any, forwardRef) => {
29
+ const Custom = useCustom(key);
30
+
31
+ if (Custom === null) {
32
+ return null;
33
+ }
34
+
35
+ if (Custom) {
36
+ return <Custom {...props} ref={forwardRef} />;
37
+ }
38
+
39
+ return <Component {...props} ref={forwardRef} />;
40
+ });
41
+
42
+ Result.displayName = 'Customizable.' + Component.displayName;
43
+
44
+ return Object.assign(Result, { key, Component }) as any;
45
+ }
package/src/util/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './uniqBy';
2
- export * from './uniqId';
3
- export * from './customize';
1
+ export * from './uniqBy';
2
+ export * from './uniqId';
3
+ export * from './customize';
@@ -1,17 +1,17 @@
1
- export function uniqBy<T, TKey extends string | number | symbol>(items: T[], selector: (x: T) => TKey) {
2
- const keys = {} as Record<TKey, null>;
3
- const result: T[] = [];
4
-
5
- items.forEach((x) => {
6
- const key = selector(x);
7
-
8
- if (keys.hasOwnProperty(key)) {
9
- return;
10
- }
11
-
12
- keys[key] = null;
13
- result.push(x);
14
- });
15
-
16
- return result;
17
- }
1
+ export function uniqBy<T, TKey extends string | number | symbol>(items: T[], selector: (x: T) => TKey) {
2
+ const keys = {} as Record<TKey, null>;
3
+ const result: T[] = [];
4
+
5
+ items.forEach((x) => {
6
+ const key = selector(x);
7
+
8
+ if (keys.hasOwnProperty(key)) {
9
+ return;
10
+ }
11
+
12
+ keys[key] = null;
13
+ result.push(x);
14
+ });
15
+
16
+ return result;
17
+ }
@@ -1,3 +1,3 @@
1
- export function uniqId() {
2
- return Date.now().toString(36) + Math.random().toString(36).substring(2);
3
- }
1
+ export function uniqId() {
2
+ return Date.now().toString(36) + Math.random().toString(36).substring(2);
3
+ }