@piedata/pieui 1.1.1 → 1.1.3

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 (76) hide show
  1. package/dist/cli.js +39 -39
  2. package/dist/components/Buttons/AjaxButtonCard/ui/AjaxButtonCard.d.ts.map +1 -1
  3. package/dist/components/Chats/ChatCard/ui/ChatCard.d.ts.map +1 -1
  4. package/dist/components/Chats/ChatCard/ui/components/AttachFileButton.d.ts.map +1 -1
  5. package/dist/components/Chats/ChatCard/ui/components/ChatCardInput.d.ts +0 -1
  6. package/dist/components/Chats/ChatCard/ui/components/ChatCardInput.d.ts.map +1 -1
  7. package/dist/components/PieRoot/index.d.ts.map +1 -1
  8. package/dist/components/index.esm.js +14 -24
  9. package/dist/components/index.js +21 -31
  10. package/dist/index.esm.js +18 -28
  11. package/dist/index.js +32 -42
  12. package/dist/util/ajaxCommonUtils.d.ts +7 -1
  13. package/dist/util/ajaxCommonUtils.d.ts.map +1 -1
  14. package/package.json +9 -9
  15. package/src/components/Buttons/AjaxButtonCard/index.ts +0 -1
  16. package/src/components/Buttons/AjaxButtonCard/types/index.ts +0 -17
  17. package/src/components/Buttons/AjaxButtonCard/ui/AjaxButtonCard.tsx +0 -38
  18. package/src/components/Chats/ChatCard/index.ts +0 -1
  19. package/src/components/Chats/ChatCard/types/annyang.d.ts +0 -11
  20. package/src/components/Chats/ChatCard/types/index.ts +0 -59
  21. package/src/components/Chats/ChatCard/ui/ChatCard.tsx +0 -130
  22. package/src/components/Chats/ChatCard/ui/components/AttachFileButton.tsx +0 -48
  23. package/src/components/Chats/ChatCard/ui/components/AttachedFileView.tsx +0 -29
  24. package/src/components/Chats/ChatCard/ui/components/ChatCardInput.tsx +0 -177
  25. package/src/components/Chats/ChatCard/ui/components/ChatOption.tsx +0 -25
  26. package/src/components/Chats/ChatCard/ui/components/Markdown.tsx +0 -21
  27. package/src/components/Chats/ChatCard/ui/components/MessageAvatar.tsx +0 -17
  28. package/src/components/Chats/ChatCard/ui/components/MessageCard.tsx +0 -80
  29. package/src/components/Chats/ChatCard/ui/components/MessageContent.tsx +0 -27
  30. package/src/components/Chats/ChatCard/ui/components/MessagesBoard.tsx +0 -61
  31. package/src/components/Chats/ChatCard/ui/components/Options.tsx +0 -20
  32. package/src/components/Chats/ChatCard/ui/components/ResizableTextarea.tsx +0 -59
  33. package/src/components/Chats/ChatCard/ui/components/SendButton.tsx +0 -37
  34. package/src/components/Chats/ChatCard/ui/components/VoiceListeningButton.tsx +0 -35
  35. package/src/components/Chats/ChatCard/ui/components/icons/AttachFileIcon.tsx +0 -18
  36. package/src/components/Chats/ChatCard/ui/components/icons/AttachedFileIcon.tsx +0 -18
  37. package/src/components/Chats/ChatCard/ui/components/icons/CancelFileIcon.tsx +0 -14
  38. package/src/components/Chats/ChatCard/ui/components/icons/DefaultAvatar.tsx +0 -10
  39. package/src/components/Chats/ChatCard/ui/components/icons/SendIcon.tsx +0 -18
  40. package/src/components/Chats/ChatCard/ui/components/icons/VoiceRecordIcon.tsx +0 -15
  41. package/src/components/Containers/AjaxGroupCard/index.ts +0 -1
  42. package/src/components/Containers/AjaxGroupCard/types/index.ts +0 -17
  43. package/src/components/Containers/AjaxGroupCard/ui/AjaxGroupCard.tsx +0 -96
  44. package/src/components/Containers/SequenceCard/index.ts +0 -1
  45. package/src/components/Containers/SequenceCard/types/index.ts +0 -10
  46. package/src/components/Containers/SequenceCard/ui/SequenceCard.tsx +0 -32
  47. package/src/components/Containers/UnionCard/index.ts +0 -1
  48. package/src/components/Containers/UnionCard/types/index.ts +0 -8
  49. package/src/components/Containers/UnionCard/ui/UnionCard.tsx +0 -27
  50. package/src/components/PieCard/index.tsx +0 -149
  51. package/src/components/PieCard/types/index.ts +0 -18
  52. package/src/components/PieRoot/index.tsx +0 -154
  53. package/src/components/PieRoot/types/index.ts +0 -14
  54. package/src/components/PieTelegramRoot/index.tsx +0 -161
  55. package/src/components/UI/index.tsx +0 -70
  56. package/src/components/index.ts +0 -6
  57. package/src/index.ts +0 -15
  58. package/src/providers/CentrifugeIOInitProvider.tsx +0 -42
  59. package/src/providers/SocketIOInitProvider.tsx +0 -52
  60. package/src/types/index.ts +0 -139
  61. package/src/util/ajaxCommonUtils.ts +0 -137
  62. package/src/util/centrifuge.ts +0 -33
  63. package/src/util/fallback.tsx +0 -6
  64. package/src/util/initializeComponents.ts +0 -84
  65. package/src/util/lazy.ts +0 -25
  66. package/src/util/mitt.ts +0 -11
  67. package/src/util/pieConfig.ts +0 -43
  68. package/src/util/registry.ts +0 -81
  69. package/src/util/socket.ts +0 -24
  70. package/src/util/sx2radium.ts +0 -15
  71. package/src/util/tailwindCommonUtils.ts +0 -6
  72. package/src/util/useIsSupported.ts +0 -17
  73. package/src/util/useOpenAIWebRTC.ts +0 -176
  74. package/src/util/useWebApp.ts +0 -32
  75. package/src/util/waitForSidAvailable.ts +0 -21
  76. package/src/util/webrtcClient.ts +0 -247
@@ -1,80 +0,0 @@
1
- import parse from 'html-react-parser'
2
- import { useState, useEffect } from 'react'
3
- import MarkdownRender from './Markdown'
4
- import UI from '../../../../UI'
5
- import MessageAvatar from './MessageAvatar'
6
- import ChatOption from './ChatOption'
7
- import { Message } from '../../types'
8
- import { SetUiAjaxConfigurationType } from '../../../../../types'
9
-
10
- const MessageCard = ({
11
- message,
12
- handleOptionClick,
13
- setUiAjaxConfiguration,
14
- }: {
15
- message: Message
16
- handleOptionClick: (option: string) => void
17
- setUiAjaxConfiguration?: SetUiAjaxConfigurationType
18
- }) => {
19
- const [copied, setCopied] = useState(false)
20
-
21
- useEffect(() => {
22
- const timeout = setTimeout(() => {
23
- if (copied) setCopied(false)
24
- }, 1000)
25
-
26
- return () => clearTimeout(timeout)
27
- }, [copied])
28
-
29
- return (
30
- <div className='group w-full border-b border-black/10' id={message.id}>
31
- <div
32
- className={`flex gap-4 p-4 text-base md:max-w-2xl md:gap-6 md:py-6 lg:max-w-3xl xl:max-w-5xl ${message.align === 'center' ? 'm-auto' : ''} ${message.align === 'right' ? 'ml-auto justify-end' : ''} ${message.align === 'left' ? 'mr-auto' : ''} `}
33
- >
34
- {(message.align === 'left' || message.align === 'center') && (
35
- <div className='relative flex shrink-0 flex-col items-end'>
36
- <MessageAvatar username={message.username} avatar={message.avatar} />
37
- </div>
38
- )}
39
- <div className='relative flex w-[calc(100%-50px)] flex-col gap-1 md:gap-3 lg:w-[calc(100%-115px)]'>
40
- <div
41
- className={`markdown light prose w-full break-words dark:prose-invert first:mt-0 ${message.align === 'right' ? 'flex justify-end self-end' : ''}`}
42
- >
43
- {typeof message.content === 'string' ? (
44
- message.parseMode.toLowerCase() === 'markdown' ? (
45
- <MarkdownRender key={Date.now() + Math.random()}>
46
- {message.content}
47
- </MarkdownRender>
48
- ) : message.parseMode.toLowerCase() === 'html' ? (
49
- parse(message.content)
50
- ) : (
51
- message.content
52
- )
53
- ) : (
54
- <UI
55
- uiConfig={message.content}
56
- setUiAjaxConfiguration={setUiAjaxConfiguration}
57
- />
58
- )}
59
- </div>
60
- <div className='flex flex-row flex-wrap justify-start gap-1'>
61
- {message.options.map((option, idx) => (
62
- <ChatOption
63
- key={idx}
64
- onClickOption={handleOptionClick}
65
- option={option}
66
- />
67
- ))}
68
- </div>
69
- </div>
70
- {message.align === 'right' && (
71
- <div className='relative flex shrink-0 flex-col items-end'>
72
- <MessageAvatar username={message.username} avatar={message.avatar} />
73
- </div>
74
- )}
75
- </div>
76
- </div>
77
- )
78
- }
79
-
80
- export default MessageCard
@@ -1,27 +0,0 @@
1
- import clsx from 'clsx'
2
-
3
- const MessageContent = ({
4
- name,
5
- content,
6
- isSent,
7
- }: {
8
- name: string
9
- content: string
10
- isSent: boolean
11
- }) => {
12
- return (
13
- <div className='px-6 py-4'>
14
- <div
15
- className={clsx(
16
- 'text-xl font-medium text-black',
17
- isSent ? 'text-right' : 'text-left',
18
- )}
19
- >
20
- {isSent ? 'You' : name}
21
- </div>
22
- <p className='text-gray-500'>{content}</p>
23
- </div>
24
- )
25
- }
26
-
27
- export default MessageContent
@@ -1,61 +0,0 @@
1
- import MessageCard from './MessageCard'
2
- import { CSSProperties, forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react'
3
- import { Message } from '../../types'
4
- import { SetUiAjaxConfigurationType } from '../../../../../types'
5
-
6
- export interface MessagesBoardHandle {
7
- addMessage: (message: Message) => void
8
- setMessages: (messages: Array<Message>) => void
9
- scrollToBottom: () => void
10
- }
11
-
12
- const MessagesBoard = forwardRef<
13
- MessagesBoardHandle,
14
- {
15
- name: string
16
- handleOptionClick: (option: string) => void
17
- defaultMessages: Message[]
18
- sx: CSSProperties
19
- setUiAjaxConfiguration?: SetUiAjaxConfigurationType
20
- }
21
- >(({ name, handleOptionClick, defaultMessages, sx, setUiAjaxConfiguration }, ref) => {
22
- const [messages, setMessages] = useState<Message[]>(defaultMessages)
23
- const containerRef = useRef<HTMLDivElement>(null)
24
-
25
- const scrollToBottom = () => {
26
- if (containerRef.current) {
27
- containerRef.current.scrollTop = containerRef.current.scrollHeight
28
- }
29
- }
30
-
31
- useEffect(() => {
32
- scrollToBottom()
33
- }, [messages])
34
-
35
- useImperativeHandle(ref, () => ({
36
- setMessages: (currentMessages: Array<Message>) => setMessages(currentMessages),
37
- addMessage: (message: Message) =>
38
- setMessages((currentMessages) => [...currentMessages, message]),
39
- scrollToBottom: scrollToBottom,
40
- }))
41
-
42
- return (
43
- <div
44
- id={name + '_messages'}
45
- className='flex flex-col items-center overflow-y-scroll'
46
- style={sx}
47
- ref={containerRef}
48
- >
49
- {messages.map((message) => (
50
- <MessageCard
51
- key={message.id}
52
- message={message}
53
- handleOptionClick={handleOptionClick}
54
- setUiAjaxConfiguration={setUiAjaxConfiguration}
55
- />
56
- ))}
57
- </div>
58
- )
59
- })
60
-
61
- export default MessagesBoard
@@ -1,20 +0,0 @@
1
- import { Option } from '../../types'
2
- import ChatOption from './ChatOption'
3
-
4
- const Options = ({
5
- options,
6
- handleOptionClick,
7
- }: {
8
- options: Option[]
9
- handleOptionClick: (option: string) => void
10
- }) => {
11
- return (
12
- <div className='flex w-full flex-row flex-wrap justify-start gap-[5px]'>
13
- {options.map((option: Option, idx: number) => {
14
- return <ChatOption key={idx} option={option} onClickOption={handleOptionClick} />
15
- })}
16
- </div>
17
- )
18
- }
19
-
20
- export default Options
@@ -1,59 +0,0 @@
1
- import {
2
- DetailedHTMLProps,
3
- FocusEventHandler,
4
- KeyboardEventHandler,
5
- TextareaHTMLAttributes,
6
- useRef,
7
- useState,
8
- } from 'react'
9
-
10
- export default function ResizableTextarea(
11
- props: DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>,
12
- ) {
13
- const [canResize, setCanResize] = useState<boolean>(false)
14
- const textareaRef = useRef<HTMLTextAreaElement | null>(null)
15
-
16
- const handleKeyDown: KeyboardEventHandler<HTMLTextAreaElement> = (e) => {
17
- if (e.key === 'Enter' && e.shiftKey) {
18
- setCanResize(true)
19
- if (textareaRef.current && typeof window !== 'undefined') {
20
- const style = window.getComputedStyle(textareaRef.current)
21
- const lineHeight = parseFloat(style.lineHeight)
22
- textareaRef.current.style.height =
23
- textareaRef.current.scrollHeight + lineHeight + 'px'
24
- }
25
- }
26
- if (e.key === 'Backspace') {
27
- setCanResize(true)
28
- if (textareaRef.current && typeof window !== 'undefined') {
29
- const style = window.getComputedStyle(textareaRef.current)
30
- const lineHeight = parseFloat(style.lineHeight)
31
- if (textareaRef.current.scrollHeight > lineHeight) {
32
- textareaRef.current.style.height =
33
- textareaRef.current.scrollHeight - lineHeight + 'px'
34
- }
35
- }
36
- }
37
- props.onKeyDown && props.onKeyDown(e)
38
- }
39
-
40
- const handleKeyUp: KeyboardEventHandler<HTMLTextAreaElement> = () => {
41
- setCanResize(false)
42
- }
43
-
44
- const handleBlur: FocusEventHandler<HTMLTextAreaElement> = (e) => {
45
- setCanResize(false)
46
- props.onBlur && props.onBlur(e)
47
- }
48
-
49
- return (
50
- <textarea
51
- ref={textareaRef}
52
- {...props}
53
- onKeyUp={handleKeyUp}
54
- onKeyDown={handleKeyDown}
55
- onBlur={handleBlur}
56
- style={{ resize: canResize ? 'vertical' : 'none', overflowY: 'auto', ...props.style }}
57
- />
58
- )
59
- }
@@ -1,37 +0,0 @@
1
- import { useRef, useCallback, MouseEventHandler } from 'react'
2
- import SendIcon from './icons/SendIcon'
3
- import { ChatButtonProps } from '../../types'
4
-
5
-
6
- const SendButton = ({ type = 'button', onClick, icons }: ChatButtonProps) => {
7
- const buttonRef = useRef<HTMLButtonElement | null>(null)
8
-
9
- const animateSendButton = useCallback(() => {
10
- const btn = buttonRef.current
11
- if (btn) {
12
- btn.style.transform = 'scale(0.8)'
13
- setTimeout(() => {
14
- btn.style.transform = 'scale(1)'
15
- }, 600)
16
- }
17
- }, [])
18
-
19
- const handleClick: MouseEventHandler<HTMLButtonElement> = (e) => {
20
- if (onClick) onClick(e)
21
- animateSendButton()
22
- }
23
-
24
- return (
25
- <button
26
- ref={buttonRef}
27
- type={type}
28
- onClick={handleClick}
29
- className='mr-1.5 rounded-md p-1 text-gray-500 ring-0 hover:bg-gray-100 disabled:opacity-40 disabled:hover:bg-transparent'
30
- style={{ transition: 'transform 300ms ease' }}
31
- >
32
- {icons.sendIcon ? <img src={icons.sendIcon} alt='' /> : <SendIcon />}
33
- </button>
34
- )
35
- }
36
-
37
- export default SendButton
@@ -1,35 +0,0 @@
1
- import CancelFileIcon from './icons/CancelFileIcon'
2
- import VoiceRecordIcon from './icons/VoiceRecordIcon'
3
- import { ChatIconsType } from '../../types'
4
-
5
- const VoiceListeningButton = ({
6
- isListening,
7
- toggleListening,
8
- icons,
9
- }: {
10
- toggleListening: () => void
11
- isListening: boolean
12
- icons: ChatIconsType
13
- }) => {
14
- return (
15
- <button
16
- className='rounded-md p-1 text-gray-500 ring-0 hover:bg-gray-100 disabled:opacity-40 disabled:hover:bg-transparent'
17
- type='button'
18
- onClick={toggleListening}
19
- >
20
- {isListening ? (
21
- icons.cancelIcon ? (
22
- <img src={icons.cancelIcon} alt='' />
23
- ) : (
24
- <CancelFileIcon />
25
- )
26
- ) : icons.voiceRecordingIcon ? (
27
- <img src={icons.voiceRecordingIcon} alt='' />
28
- ) : (
29
- <VoiceRecordIcon />
30
- )}
31
- </button>
32
- )
33
- }
34
-
35
- export default VoiceListeningButton
@@ -1,18 +0,0 @@
1
- const AttachFileIcon = () => (
2
- <svg
3
- xmlns='http://www.w3.org/2000/svg'
4
- fill='none'
5
- viewBox='0 0 24 24'
6
- strokeWidth='1.5'
7
- stroke='currentColor'
8
- className='size-5'
9
- >
10
- <path
11
- strokeLinecap='round'
12
- strokeLinejoin='round'
13
- d='M18.375 12.739l-7.693 7.693a4.5 4.5 0 01-6.364-6.364l10.94-10.94A3 3 0 1119.5 7.372L8.552 18.32m.009-.01l-.01.01m5.699-9.941l-7.81 7.81a1.5 1.5 0 002.112 2.13'
14
- />
15
- </svg>
16
- )
17
-
18
- export default AttachFileIcon
@@ -1,18 +0,0 @@
1
- const AttachedFileIcon = () => (
2
- <svg
3
- xmlns='http://www.w3.org/2000/svg'
4
- fill='none'
5
- viewBox='0 0 24 24'
6
- strokeWidth='1.5'
7
- stroke='currentColor'
8
- className='size-5 text-gray-500'
9
- >
10
- <path
11
- strokeLinecap='round'
12
- strokeLinejoin='round'
13
- d='M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z'
14
- />
15
- </svg>
16
- )
17
-
18
- export default AttachedFileIcon
@@ -1,14 +0,0 @@
1
- const CancelFileIcon = () => (
2
- <svg
3
- xmlns='http://www.w3.org/2000/svg'
4
- fill='none'
5
- viewBox='0 0 24 24'
6
- strokeWidth='1.5'
7
- stroke='currentColor'
8
- className='size-5'
9
- >
10
- <path strokeLinecap='round' strokeLinejoin='round' d='M6 18L18 6M6 6l12 12' />
11
- </svg>
12
- )
13
-
14
- export default CancelFileIcon
@@ -1,10 +0,0 @@
1
- const DefaultAvatarIcon = () => (
2
- <svg width='30' height='30' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'>
3
- <path
4
- d='m 8 1 c -1.65625 0 -3 1.34375 -3 3 s 1.34375 3 3 3 s 3 -1.34375 3 -3 s -1.34375 -3 -3 -3 z m -1.5 7 c -2.492188 0 -4.5 2.007812 -4.5 4.5 v 0.5 c 0 1.109375 0.890625 2 2 2 h 8 c 1.109375 0 2 -0.890625 2 -2 v -0.5 c 0 -2.492188 -2.007812 -4.5 -4.5 -4.5 z m 0 0'
5
- fill='#2e3436'
6
- />
7
- </svg>
8
- )
9
-
10
- export default DefaultAvatarIcon
@@ -1,18 +0,0 @@
1
- const SendIcon = () => (
2
- <svg
3
- xmlns='http://www.w3.org/2000/svg'
4
- fill='none'
5
- viewBox='0 0 24 24'
6
- strokeWidth='1.5'
7
- stroke='currentColor'
8
- className='size-5'
9
- >
10
- <path
11
- strokeLinecap='round'
12
- strokeLinejoin='round'
13
- d='M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5'
14
- />
15
- </svg>
16
- )
17
-
18
- export default SendIcon
@@ -1,15 +0,0 @@
1
- const VoiceRecordIcon = () => (
2
- <svg
3
- xmlns='http://www.w3.org/2000/svg'
4
- fill='none'
5
- viewBox='0 0 24 24'
6
- strokeWidth='1.5'
7
- stroke='currentColor'
8
- className='size-5'
9
- >
10
- <path d='M8 5C8 2.79086 9.79086 1 12 1C14.2091 1 16 2.79086 16 5V12C16 14.2091 14.2091 16 12 16C9.79086 16 8 14.2091 8 12V5Z' />
11
- <path d='M6.25 11.8438V12C6.25 13.525 6.8558 14.9875 7.93414 16.0659C9.01247 17.1442 10.475 17.75 12 17.75C13.525 17.75 14.9875 17.1442 16.0659 16.0659C17.1442 14.9875 17.75 13.525 17.75 12V11.8438C17.75 11.2915 18.1977 10.8438 18.75 10.8438H19.25C19.8023 10.8438 20.25 11.2915 20.25 11.8437V12C20.25 14.188 19.3808 16.2865 17.8336 17.8336C16.5842 19.0831 14.9753 19.8903 13.25 20.1548V22C13.25 22.5523 12.8023 23 12.25 23H11.75C11.1977 23 10.75 22.5523 10.75 22V20.1548C9.02471 19.8903 7.41579 19.0831 6.16637 17.8336C4.61919 16.2865 3.75 14.188 3.75 12V11.8438C3.75 11.2915 4.19772 10.8438 4.75 10.8438H5.25C5.80228 10.8438 6.25 11.2915 6.25 11.8438Z' />
12
- </svg>
13
- )
14
-
15
- export default VoiceRecordIcon
@@ -1 +0,0 @@
1
- export { default } from './ui/AjaxGroupCard'
@@ -1,17 +0,0 @@
1
- import {PieContainerComponentProps} from "../../../../types";
2
-
3
-
4
- export interface AjaxGroupCardData {
5
- name: string
6
- noReturn: boolean
7
- returnType: 'content' | 'events'
8
- useLoader: boolean
9
-
10
- useSocketioSupport?: boolean
11
- useCentrifugeSupport?: boolean
12
- useMittSupport?: boolean
13
- centrifugeChannel?: string
14
- }
15
-
16
-
17
- export interface AjaxGroupCardProps extends PieContainerComponentProps<AjaxGroupCardData> {}
@@ -1,96 +0,0 @@
1
- import {ReactNode, useContext, useEffect, useRef, useState} from 'react'
2
- import UI from '../../../UI'
3
- import { AjaxGroupCardProps } from '../types'
4
- import { UIConfigType, UIEventType } from '../../../../types'
5
- import PieCard from '../../../PieCard'
6
- import MittContext from '../../../../util/mitt'
7
- import FallbackContext from '../../../../util/fallback'
8
- import { registerPieComponent } from '../../../../util/registry'
9
- import Radium from "radium";
10
-
11
-
12
- const AjaxGroupCard = ({
13
- data,
14
- content,
15
- }: AjaxGroupCardProps) => {
16
- const {
17
- useLoader,
18
- noReturn,
19
- returnType,
20
- useSocketioSupport,
21
- useCentrifugeSupport,
22
- useMittSupport,
23
- centrifugeChannel,
24
- } = data
25
- const Fallback: ReactNode = useContext(FallbackContext)
26
- const [isLoading, setIsLoading] = useState<boolean>(false)
27
- const [uiAjaxConfiguration, setUiAjaxConfiguration] = useState<UIConfigType | null>(null)
28
- const lastValidUiConfigRef = useRef<UIConfigType>(content)
29
- const mitt = useContext(MittContext)
30
-
31
- const setUiAjaxConfigurationForContentWrapper = (content: UIConfigType | null) => {
32
- if (content === null) {
33
- setIsLoading(true)
34
- } else {
35
- setIsLoading(false)
36
- if (!noReturn) {
37
- lastValidUiConfigRef.current = content
38
- }
39
- }
40
- if (!noReturn) {
41
- setUiAjaxConfiguration(content)
42
- }
43
- }
44
-
45
- const onChangeContent = (event: any) => {
46
- lastValidUiConfigRef.current = event.content
47
- setUiAjaxConfiguration(event.content)
48
- }
49
-
50
- const setUiAjaxConfigurationForEventsWrapper = (events: Array<UIEventType> | null) => {
51
- if (events === null) {
52
- setIsLoading(true)
53
- } else {
54
- setIsLoading(false)
55
- if (!noReturn) {
56
- for (const ev of events) {
57
- mitt.emit(ev.name, ev.data)
58
- }
59
- }
60
- }
61
- }
62
-
63
- useEffect(() => {
64
- setUiAjaxConfiguration(content)
65
- setIsLoading(false)
66
- }, [content])
67
-
68
- if (!uiAjaxConfiguration && useLoader) {
69
- return Fallback
70
- }
71
-
72
- return (
73
- <PieCard
74
- card={'AjaxGroupCard'}
75
- data={data}
76
- methods={{
77
- changeContent: onChangeContent,
78
- }}
79
- useSocketioSupport={useSocketioSupport}
80
- useCentrifugeSupport={useCentrifugeSupport}
81
- useMittSupport={useMittSupport}
82
- centrifugeChannel={centrifugeChannel}
83
- >
84
- <UI
85
- uiConfig={uiAjaxConfiguration ?? lastValidUiConfigRef.current}
86
- setUiAjaxConfiguration={
87
- returnType === 'events'
88
- ? setUiAjaxConfigurationForEventsWrapper
89
- : setUiAjaxConfigurationForContentWrapper
90
- }
91
- />
92
- </PieCard>
93
- )
94
- }
95
-
96
- export default Radium(AjaxGroupCard)
@@ -1 +0,0 @@
1
- export { default } from './ui/SequenceCard'
@@ -1,10 +0,0 @@
1
- import { CSSProperties } from 'react'
2
- import {PieComplexContainerComponentProps} from "../../../../types";
3
-
4
- export interface SequenceCardData {
5
- name: string
6
- sx: CSSProperties
7
- }
8
-
9
-
10
- export interface SequenceCardProps extends PieComplexContainerComponentProps<SequenceCardData> {}
@@ -1,32 +0,0 @@
1
- import { UIConfigType } from '../../../../types'
2
- import {SequenceCardProps} from '../types'
3
- import PieCard from '../../../PieCard'
4
- import UI from '../../../UI'
5
- import Radium from "radium";
6
- import {sx2radium} from "../../../../util/sx2radium.ts";
7
-
8
- const SequenceCard = ({
9
- data,
10
- content,
11
- setUiAjaxConfiguration,
12
- }: SequenceCardProps) => {
13
- const { name, sx } = data
14
- return (
15
- <PieCard card={name} data={data}>
16
- <div style={sx2radium(sx)} id={name}>
17
- {content.map((obj: UIConfigType, i: number) => {
18
- return (
19
- <UI
20
- key={`children-${i}`}
21
- uiConfig={obj}
22
- setUiAjaxConfiguration={setUiAjaxConfiguration}
23
- />
24
- )
25
- })}
26
- </div>
27
- </PieCard>
28
- )
29
- }
30
-
31
-
32
- export default Radium(SequenceCard)
@@ -1 +0,0 @@
1
- export { default } from './ui/UnionCard'
@@ -1,8 +0,0 @@
1
- import {PieComplexContainerComponentProps} from "../../../../types";
2
-
3
-
4
- export interface UnionCardData {
5
- name: string
6
- }
7
-
8
- export interface UnionCardProps extends PieComplexContainerComponentProps<UnionCardData> {}
@@ -1,27 +0,0 @@
1
- import { UIConfigType } from '../../../../types'
2
- import {UnionCardProps} from '../types'
3
- import PieCard from '../../../PieCard'
4
- import UI from '../../../UI'
5
-
6
- const UnionCard = ({
7
- data,
8
- content,
9
- setUiAjaxConfiguration,
10
- }: UnionCardProps) => {
11
- const { name } = data
12
- return (
13
- <PieCard card={name} data={data}>
14
- {content.map((obj: UIConfigType, i: number) => {
15
- return (
16
- <UI
17
- key={`children-${i}`}
18
- uiConfig={obj}
19
- setUiAjaxConfiguration={setUiAjaxConfiguration}
20
- />
21
- )
22
- })}
23
- </PieCard>
24
- )
25
- }
26
-
27
- export default UnionCard