diff --git a/packages/ui-vue/components/message-box/index.ts b/packages/ui-vue/components/message-box/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/packages/ui-vue/components/message-box/src/composition/types.ts b/packages/ui-vue/components/message-box/src/composition/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/packages/ui-vue/components/message-box/src/message-box.component.tsx b/packages/ui-vue/components/message-box/src/message-box.component.tsx new file mode 100644 index 0000000000000000000000000000000000000000..3ab0fe7a6548dd4d47599716bce7e2d0a81b9a1e --- /dev/null +++ b/packages/ui-vue/components/message-box/src/message-box.component.tsx @@ -0,0 +1,349 @@ +import { computed, defineComponent, ref, SetupContext } from "vue"; +import { MessageBoxProps, messageBoxProps } from "./message-box.props"; +import { type WebkitLineClampProperty, type BoxOrientProperty, type TextAlignProperty } from 'csstype'; +import { ModalButton } from "../../modal"; + +export interface ExceptionInfo { + date: string; + message: string; + copyButton: ModalButton; +} + +export default defineComponent({ + name: 'FMessageBox', + props: messageBoxProps, + emits: [], + setup(props: MessageBoxProps, context: SetupContext) { + const messageType = ref(''); + const messageIcon = ref(''); + const messageTitle = ref(''); + const messageDetail = ref(''); + const exception = ref({} as ExceptionInfo); + const happend = ref(''); + const promptInputType = ref(''); + const promptFontSize = ref(14); + const promptMaxLength = ref(140); + const promptInputPlaceholder = ref(''); + const messageText = ref(''); + const enableWordCount = ref(true); + const wordsTotalTips = ref(''); + const wordsTotal = ref(0); + const buttons = ref([]); + const okButtonText = ref(''); + const cancelButtonText = ref(''); + const showFontSize = ref(true); + const showCancelButton = ref(true); + const showOkButton = ref(true); + + const showLines = ref(''); + const exceptionMessageMaxHeight = ref(0); + + const messageBoxContainerClass = computed(() => { + const classObject = { + 'modal-tips': true, + 'd-flex': true, + 'flex-row': true + } as Record; + const messageBoxTypeClass = `messager-type-${messageType.value}`; + classObject[messageBoxTypeClass] = true; + return classObject; + }); + + const messageBoxIconClass = computed(() => { + const classObject = { 'f-icon': true } as Record; + const iconClass = messageIcon.value; + classObject[iconClass] = true; + return classObject; + }); + + const safeMessageTitle = computed(() => { + return messageTitle.value; + }); + + const safeMessageDetail = computed(() => { + return messageDetail.value; + }); + + const shouldShowMessageDetail = computed(() => { + return messageDetail.value && !exception.value; + }); + + const isExceptionMessage = computed(() => { + return !!exception.value; + }); + + const shouldShowExceptionDate = computed(() => { + return !!exception.value && !!exception.value.date; + }); + + const exceptionDateMessage = computed(() => { + const exceptionDate = exception.value && exception.value.date || ''; + return `${happend.value} : ${exceptionDate}`; + }); + + const shouldShowExceptionMessage = computed(() => { + return !!exception.value && !!exception.value.message; + }); + + const exceptionMessageStyle = computed(() => { + const maxHeight = `${exceptionMessageMaxHeight.value}px`; + const styleObject = { + 'overflow': 'hidden', + 'text-overflow': 'ellipsis', + 'display': '-webkit-box', + '-webkit-box-orient': 'vertical' as BoxOrientProperty, + '-webkit-line-clamp': showLines.value as WebkitLineClampProperty, + 'max-height': maxHeight + }; + return styleObject; + }); + + const exceptionMessageDetail = computed(() => { + return ''; + }); + + const safeExceptionMessage = computed(() => { + const safeMessage = exception.value && exception.value.message || ''; + return safeMessage; + }); + + const shouldShowExpandHandle = computed(() => { + return true; + }); + + const expandHandleStyle = computed(() => { + const styleObject = { + 'display': 'block', + 'text-align': 'right' as TextAlignProperty, + 'color': '#2A87FF' + }; + return styleObject; + }); + + const expandExceptionMessage = ref(false); + const expandText = ref(''); + const collapseText = ref(''); + + function toggalExceptionMessage(expand: boolean, $event: Event) { + + } + + function onClickExpand(payload: MouseEvent) { + return toggalExceptionMessage(true, payload); + } + + function onClickCollapse(payload: MouseEvent) { + return toggalExceptionMessage(true, payload); + } + + const promptTextAreaStyle = computed(() => { + const fontSize = `${promptFontSize.value}px`; + const styleObject = { + 'font-size': fontSize, + 'height': '100%' + }; + return styleObject; + }); + + function onTextChange($event: Event) { + + } + + const shouldShowWordCount = computed(() => { + return enableWordCount.value && promptMaxLength.value; + }); + + const shouldShowOkCancelButtons = computed(() => { + return !(buttons.value && buttons.value.length) && (okButtonText.value || cancelButtonText.value); + }); + + const shouldShowFontSize = computed(() => { + return messageType.value === 'prompt' && showFontSize.value; + }); + + function onFontSizeChange($event: Event) { } + + const shouldShowCancelButton = computed(() => { + return showCancelButton.value && cancelButtonText.value; + }); + + const shouldShowOkButton = computed(() => { + return showOkButton.value && okButtonText.value; + }); + + function onClickCancelButton($event: MouseEvent) { + + } + + function onClickOkButton($event: MouseEvent) { + + } + + const fontSizeName = ref(''); + const fontSmall = ''; + const fontMiddle = ''; + const fontBig = ''; + const fontLarge = ''; + const fontHuge = ''; + + const shouldShowButtons = computed(() => { + return buttons.value && buttons.value.length; + }); + + const shouldShowCopyButton = computed(() => { + return exception.value && exception.value.copyButton && exception.value.copyButton.text; + }); + + function onClickCopyButton($event: MouseEvent) { + + } + + return () => { + return ( + <> + { + messageType.value !== 'prompt' && +
+ + +
+ } + { + messageType.value === 'prompt' && +
+ { + promptInputType.value === 'textarea' && +
+ +
+ } + { + promptInputType.value !== 'textarea' && +
+ +
+ } +
+ } + { + shouldShowWordCount.value && + + {wordsTotal.value + ' / ' + promptMaxLength.value} + + } + { + shouldShowOkCancelButtons.value && + + } + { + shouldShowButtons.value && + } + { + exception.value && +
+ {messageDetail.value}: {exception.value?.message} +
+ } +
+
+ + ); + }; + } +}); diff --git a/packages/ui-vue/components/message-box/src/message-box.props.ts b/packages/ui-vue/components/message-box/src/message-box.props.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e79a38ec7a725ecfb003742352f179009c2f4af --- /dev/null +++ b/packages/ui-vue/components/message-box/src/message-box.props.ts @@ -0,0 +1,4 @@ +import { ExtractPropTypes } from 'vue'; + +export const messageBoxProps = {}; +export type MessageBoxProps = ExtractPropTypes;