@connectycube/react-ui-kit 0.0.17 → 0.0.19

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 (89) hide show
  1. package/configs/dependencies.json +27 -0
  2. package/configs/imports.json +9 -0
  3. package/dist/index.cjs +14 -5
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.js +14 -6
  6. package/dist/index.js.map +1 -1
  7. package/dist/types/components/attachment.d.ts +45 -0
  8. package/dist/types/components/attachment.d.ts.map +1 -0
  9. package/dist/types/components/avatar.d.ts +3 -3
  10. package/dist/types/components/avatar.d.ts.map +1 -1
  11. package/dist/types/components/badge.d.ts +3 -3
  12. package/dist/types/components/badge.d.ts.map +1 -1
  13. package/dist/types/components/button.d.ts +2 -2
  14. package/dist/types/components/dialog-item.d.ts +46 -0
  15. package/dist/types/components/dialog-item.d.ts.map +1 -0
  16. package/dist/types/components/file-picker.d.ts +22 -0
  17. package/dist/types/components/file-picker.d.ts.map +1 -0
  18. package/dist/types/components/formatted-date.d.ts +8 -0
  19. package/dist/types/components/formatted-date.d.ts.map +1 -0
  20. package/dist/types/components/input.d.ts.map +1 -1
  21. package/dist/types/components/label.d.ts +5 -0
  22. package/dist/types/components/label.d.ts.map +1 -0
  23. package/dist/types/components/link-preview.d.ts +21 -0
  24. package/dist/types/components/link-preview.d.ts.map +1 -0
  25. package/dist/types/components/linkify-text.d.ts +9 -0
  26. package/dist/types/components/linkify-text.d.ts.map +1 -0
  27. package/dist/types/components/spinner.d.ts +3 -1
  28. package/dist/types/components/spinner.d.ts.map +1 -1
  29. package/dist/types/components/status-sent.d.ts +7 -0
  30. package/dist/types/components/status-sent.d.ts.map +1 -0
  31. package/dist/types/components/switch.d.ts +6 -0
  32. package/dist/types/components/switch.d.ts.map +1 -0
  33. package/dist/types/components/utils.d.ts +0 -1
  34. package/dist/types/components/utils.d.ts.map +1 -1
  35. package/dist/types/index.d.ts +21 -4
  36. package/dist/types/index.d.ts.map +1 -1
  37. package/gen/components/attachment.jsx +214 -0
  38. package/gen/components/avatar.jsx +13 -3
  39. package/gen/components/badge.jsx +3 -3
  40. package/gen/components/button.jsx +2 -2
  41. package/gen/components/dialog-item.jsx +149 -0
  42. package/gen/components/dismiss-layer.jsx +1 -1
  43. package/gen/components/file-picker.jsx +200 -0
  44. package/gen/components/formatted-date.jsx +57 -0
  45. package/gen/components/label.jsx +22 -0
  46. package/gen/components/link-preview.jsx +131 -0
  47. package/gen/components/linkify-text.jsx +31 -0
  48. package/gen/components/spinner.jsx +29 -5
  49. package/gen/components/status-sent.jsx +21 -0
  50. package/gen/components/switch.jsx +25 -0
  51. package/gen/components/utils.js +0 -7
  52. package/gen/index.js +46 -0
  53. package/package.json +5 -1
  54. package/src/components/attachment.tsx +270 -0
  55. package/src/components/avatar.tsx +16 -6
  56. package/src/components/badge.tsx +6 -6
  57. package/src/components/button.tsx +2 -2
  58. package/src/components/connectycube-ui/avatar.jsx +54 -0
  59. package/src/components/connectycube-ui/avatar.tsx +77 -0
  60. package/src/components/connectycube-ui/badge.jsx +45 -0
  61. package/src/components/connectycube-ui/badge.tsx +42 -0
  62. package/src/components/connectycube-ui/dialog-item.jsx +149 -0
  63. package/src/components/connectycube-ui/dialog-item.tsx +188 -0
  64. package/src/components/connectycube-ui/file-picker.jsx +200 -0
  65. package/src/components/connectycube-ui/file-picker.tsx +231 -0
  66. package/src/components/connectycube-ui/formatted-date.jsx +57 -0
  67. package/src/components/connectycube-ui/formatted-date.tsx +57 -0
  68. package/src/components/connectycube-ui/label.jsx +22 -0
  69. package/src/components/connectycube-ui/label.tsx +23 -0
  70. package/src/components/connectycube-ui/linkify-text.tsx +40 -0
  71. package/src/components/connectycube-ui/presence.jsx +81 -0
  72. package/src/components/connectycube-ui/presence.tsx +96 -0
  73. package/src/components/connectycube-ui/status-sent.jsx +21 -0
  74. package/src/components/connectycube-ui/status-sent.tsx +25 -0
  75. package/src/components/connectycube-ui/utils.js +10 -0
  76. package/src/components/connectycube-ui/utils.ts +10 -0
  77. package/src/components/dialog-item.tsx +188 -0
  78. package/src/components/dismiss-layer.tsx +1 -1
  79. package/src/components/file-picker.tsx +231 -0
  80. package/src/components/formatted-date.tsx +57 -0
  81. package/src/components/input.tsx +1 -1
  82. package/src/components/label.tsx +23 -0
  83. package/src/components/link-preview.tsx +149 -0
  84. package/src/components/linkify-text.tsx +41 -0
  85. package/src/components/spinner.tsx +31 -5
  86. package/src/components/status-sent.tsx +25 -0
  87. package/src/components/switch.tsx +27 -0
  88. package/src/components/utils.ts +0 -7
  89. package/src/index.ts +72 -4
@@ -0,0 +1,41 @@
1
+ import type React from 'react';
2
+ import type { Opts } from 'linkifyjs';
3
+ import { forwardRef, memo, useMemo } from 'react';
4
+ import Linkify from 'linkify-react';
5
+ import { cn } from './utils';
6
+
7
+ const DEFAULT_LINKIFY_OPTIONS: Opts = {
8
+ target: '_blank',
9
+ rel: 'noopener noreferrer',
10
+ };
11
+
12
+ interface LinkifyTextProps extends React.ComponentProps<'p'> {
13
+ text: string;
14
+ linkifyProps?: Opts;
15
+ }
16
+
17
+ function LinkifyTextBase(
18
+ { text, linkifyProps, ...props }: LinkifyTextProps,
19
+ ref: React.ForwardedRef<HTMLParagraphElement>
20
+ ) {
21
+ const options = useMemo(
22
+ () => ({
23
+ ...DEFAULT_LINKIFY_OPTIONS,
24
+ ...linkifyProps,
25
+ className: cn('text-blue-500 hover:text-blue-600 hover:underline', linkifyProps?.className),
26
+ }),
27
+ [linkifyProps]
28
+ );
29
+
30
+ return (
31
+ <p ref={ref} {...props} className={cn('wrap-break-word text-base', props?.className)}>
32
+ <Linkify options={options}>{text}</Linkify>
33
+ </p>
34
+ );
35
+ }
36
+
37
+ const LinkifyText = memo(forwardRef<HTMLParagraphElement, LinkifyTextProps>(LinkifyTextBase));
38
+
39
+ LinkifyText.displayName = 'LinkifyText';
40
+
41
+ export { LinkifyText, type LinkifyTextProps };
@@ -1,14 +1,40 @@
1
- import { LoaderCircle, type LucideProps } from 'lucide-react';
1
+ import { Loader, LoaderCircle, type LucideProps } from 'lucide-react';
2
2
  import { cn } from './utils';
3
3
 
4
4
  interface SpinnerProps extends LucideProps {
5
5
  loading?: boolean;
6
+ type?: 'default' | 'circle';
7
+ layout?: 'absolute' | 'centered' | 'overlay' | 'flow';
6
8
  }
7
9
 
8
- function Spinner({ loading = true, ...props }: SpinnerProps) {
9
- return loading ? (
10
- <LoaderCircle strokeWidth={2.5} {...props} className={cn('animate-spin mx-auto text-ring', props?.className)} />
11
- ) : null;
10
+ function Spinner({ loading = false, layout = 'flow', type = 'default', ...props }: SpinnerProps) {
11
+ const LoaderIcon = type === 'circle' ? LoaderCircle : Loader;
12
+
13
+ if (!loading) {
14
+ return null;
15
+ }
16
+
17
+ const spinnerElement = (
18
+ <LoaderIcon
19
+ strokeWidth={2.5}
20
+ {...props}
21
+ className={cn('animate-spin text-ring', layout === 'flow' && 'mx-auto', props?.className)}
22
+ />
23
+ );
24
+
25
+ switch (layout) {
26
+ case 'absolute':
27
+ return (
28
+ <div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">{spinnerElement}</div>
29
+ );
30
+ case 'centered':
31
+ return <div className="flex items-center justify-center size-full">{spinnerElement}</div>;
32
+ case 'overlay':
33
+ return <div className="flex items-center justify-center size-full absolute bg-muted/50">{spinnerElement}</div>;
34
+ case 'flow':
35
+ default:
36
+ return spinnerElement;
37
+ }
12
38
  }
13
39
 
14
40
  Spinner.displayName = 'Spinner';
@@ -0,0 +1,25 @@
1
+ import { Ban, Check, CheckCheck, Clock, type LucideProps } from 'lucide-react';
2
+ import { cn } from './utils';
3
+
4
+ interface StatusSentProps extends LucideProps {
5
+ status?: 'wait' | 'sent' | 'read' | 'lost' | null | undefined;
6
+ }
7
+
8
+ const StatusSent: React.FC<StatusSentProps> = ({ status, ...props }) => {
9
+ switch (status) {
10
+ case 'wait':
11
+ return <Clock {...props} className={cn('text-gray-500 size-4', props?.className)} />;
12
+ case 'sent':
13
+ return <Check {...props} className={cn('text-gray-500 size-4', props?.className)} />;
14
+ case 'read':
15
+ return <CheckCheck {...props} className={cn('text-gray-500 size-4', props?.className)} />;
16
+ case 'lost':
17
+ return <Ban {...props} className={cn('text-red-500 size-4', props?.className)} />;
18
+ default:
19
+ return null;
20
+ }
21
+ };
22
+
23
+ StatusSent.displayName = 'StatusSent';
24
+
25
+ export { StatusSent, type StatusSentProps };
@@ -0,0 +1,27 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
5
+ import { cn } from './utils';
6
+
7
+ type SwitchProps = React.ComponentProps<typeof SwitchPrimitive.Root>;
8
+
9
+ function Switch(props: SwitchProps) {
10
+ return (
11
+ <SwitchPrimitive.Root
12
+ {...props}
13
+ className={cn(
14
+ 'peer data-[state=checked]:bg-ring data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15em] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring disabled:cursor-not-allowed disabled:opacity-50',
15
+ props?.className
16
+ )}
17
+ >
18
+ <SwitchPrimitive.Thumb
19
+ className={cn(
20
+ 'bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0'
21
+ )}
22
+ />
23
+ </SwitchPrimitive.Root>
24
+ );
25
+ }
26
+
27
+ export { Switch, type SwitchProps };
@@ -9,13 +9,6 @@ export function getRandomString(length = 8): string {
9
9
  return (Date.now() / Math.random()).toString(36).replace('.', '').slice(0, length);
10
10
  }
11
11
 
12
- export function getInitialsFromName(name?: string): string {
13
- const words = name?.trim().split(/\s+/).filter(Boolean) ?? [];
14
- const result = words.length > 1 ? `${words[0]?.[0]}${words[1]?.[0]}` : (words[0]?.slice(0, 2) ?? 'NA');
15
-
16
- return result.toUpperCase();
17
- }
18
-
19
12
  export function capitalize(str?: string): string {
20
13
  return typeof str === 'string' && str.length > 0 ? `${str[0]?.toUpperCase()}${str.slice(1)}` : '';
21
14
  }
package/src/index.ts CHANGED
@@ -1,7 +1,75 @@
1
- export { DismissLayer } from './components/dismiss-layer';
1
+ export {
2
+ Attachment,
3
+ AttachmentLink,
4
+ AttachmentImage,
5
+ AttachmentAudio,
6
+ AttachmentVideo,
7
+ AttachmentFile,
8
+ AttachmentFailed,
9
+ type AttachmentProps,
10
+ type AttachmentLinkProps,
11
+ type AttachmentImageProps,
12
+ type AttachmentAudioProps,
13
+ type AttachmentVideoProps,
14
+ type AttachmentFileProps,
15
+ type AttachmentFailedProps,
16
+ } from './components/attachment';
2
17
 
3
- export type { DismissLayerProps } from './components/dismiss-layer';
18
+ export { Avatar, type AvatarProps } from './components/avatar';
4
19
 
5
- export { StreamView, LocalStreamView, RemoteStreamView, FullscreenStreamView } from './components/stream-view';
20
+ export { Badge, type BadgeProps } from './components/badge';
6
21
 
7
- export type { StreamViewProps, FullscreenStreamViewProps, FullscreenStreamViewRef } from './components/stream-view';
22
+ export { Button, type ButtonProps } from './components/button';
23
+
24
+ export { DialogItem, type DialogItemProps } from './components/dialog-item';
25
+
26
+ export { DismissLayer, type DismissLayerProps } from './components/dismiss-layer';
27
+
28
+ export {
29
+ FilePickerInput,
30
+ FilePickerDropzone,
31
+ type FilePickerInputProps,
32
+ type FilePickerDropzoneProps,
33
+ } from './components/file-picker';
34
+
35
+ export { FormattedDate, type FormattedDateProps } from './components/formatted-date';
36
+
37
+ export { Input, type InputProps } from './components/input';
38
+
39
+ export { Label, type LabelProps } from './components/label';
40
+
41
+ export { LinkPreview, type LinkPreviewProps } from './components/link-preview';
42
+
43
+ export { LinkifyText, type LinkifyTextProps } from './components/linkify-text';
44
+
45
+ export { PlaceholderText, type PlaceholderTextProps } from './components/placeholder-text';
46
+
47
+ export {
48
+ Presence,
49
+ PresenceBadge,
50
+ type PresenceStatus,
51
+ type PresenceProps,
52
+ type PresenceBadgeProps,
53
+ } from './components/presence';
54
+
55
+ export { Search, type SearchProps } from './components/search';
56
+
57
+ export { Spinner, type SpinnerProps } from './components/spinner';
58
+
59
+ export { StatusIndicator, type StatusName, type StatusIndicatorProps } from './components/status-indicator';
60
+
61
+ export { StatusSent, type StatusSentProps } from './components/status-sent';
62
+
63
+ export {
64
+ StreamView,
65
+ LocalStreamView,
66
+ RemoteStreamView,
67
+ FullscreenStreamView,
68
+ type StreamViewProps,
69
+ type FullscreenStreamViewProps,
70
+ type FullscreenStreamViewRef,
71
+ } from './components/stream-view';
72
+
73
+ export { Switch, type SwitchProps } from './components/switch';
74
+
75
+ export * from './components/utils';