feat: plugin auto upgrade strategy (#19758)
Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Novice <novice12185727@gmail.com>
This commit is contained in:

committed by
GitHub

parent
e6913744ae
commit
eaae79a581
@@ -1,13 +1,18 @@
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
const Header = () => {
|
||||
type Props = {
|
||||
title?: string
|
||||
}
|
||||
const Header = ({
|
||||
title,
|
||||
}: Props) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className='flex flex-col border-b-[0.5px] border-divider-regular'>
|
||||
<div className='system-md-semibold flex items-center px-2 py-1.5 text-text-primary'>
|
||||
{t('time.title.pickTime')}
|
||||
{title || t('time.title.pickTime')}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
@@ -20,6 +20,9 @@ const TimePicker = ({
|
||||
onChange,
|
||||
onClear,
|
||||
renderTrigger,
|
||||
title,
|
||||
minuteFilter,
|
||||
popupClassName,
|
||||
}: TimePickerProps) => {
|
||||
const { t } = useTranslation()
|
||||
const [isOpen, setIsOpen] = useState(false)
|
||||
@@ -108,6 +111,15 @@ const TimePicker = ({
|
||||
const displayValue = value?.format(timeFormat) || ''
|
||||
const placeholderDate = isOpen && selectedTime ? selectedTime.format(timeFormat) : (placeholder || t('time.defaultPlaceholder'))
|
||||
|
||||
const inputElem = (
|
||||
<input
|
||||
className='system-xs-regular flex-1 cursor-pointer appearance-none truncate bg-transparent p-1
|
||||
text-components-input-text-filled outline-none placeholder:text-components-input-text-placeholder'
|
||||
readOnly
|
||||
value={isOpen ? '' : displayValue}
|
||||
placeholder={placeholderDate}
|
||||
/>
|
||||
)
|
||||
return (
|
||||
<PortalToFollowElem
|
||||
open={isOpen}
|
||||
@@ -115,18 +127,16 @@ const TimePicker = ({
|
||||
placement='bottom-end'
|
||||
>
|
||||
<PortalToFollowElemTrigger>
|
||||
{renderTrigger ? (renderTrigger()) : (
|
||||
{renderTrigger ? (renderTrigger({
|
||||
inputElem,
|
||||
onClick: handleClickTrigger,
|
||||
isOpen,
|
||||
})) : (
|
||||
<div
|
||||
className='group flex w-[252px] cursor-pointer items-center gap-x-0.5 rounded-lg bg-components-input-bg-normal px-2 py-1 hover:bg-state-base-hover-alt'
|
||||
onClick={handleClickTrigger}
|
||||
>
|
||||
<input
|
||||
className='system-xs-regular flex-1 cursor-pointer appearance-none truncate bg-transparent p-1
|
||||
text-components-input-text-filled outline-none placeholder:text-components-input-text-placeholder'
|
||||
readOnly
|
||||
value={isOpen ? '' : displayValue}
|
||||
placeholder={placeholderDate}
|
||||
/>
|
||||
{inputElem}
|
||||
<RiTimeLine className={cn(
|
||||
'h-4 w-4 shrink-0 text-text-quaternary',
|
||||
isOpen ? 'text-text-secondary' : 'group-hover:text-text-secondary',
|
||||
@@ -142,14 +152,15 @@ const TimePicker = ({
|
||||
</div>
|
||||
)}
|
||||
</PortalToFollowElemTrigger>
|
||||
<PortalToFollowElemContent className='z-50'>
|
||||
<PortalToFollowElemContent className={cn('z-50', popupClassName)}>
|
||||
<div className='mt-1 w-[252px] rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-lg shadow-shadow-shadow-5'>
|
||||
{/* Header */}
|
||||
<Header />
|
||||
<Header title={title} />
|
||||
|
||||
{/* Time Options */}
|
||||
<Options
|
||||
selectedTime={selectedTime}
|
||||
minuteFilter={minuteFilter}
|
||||
handleSelectHour={handleSelectHour}
|
||||
handleSelectMinute={handleSelectMinute}
|
||||
handleSelectPeriod={handleSelectPeriod}
|
||||
|
@@ -5,6 +5,7 @@ import OptionListItem from '../common/option-list-item'
|
||||
|
||||
const Options: FC<TimeOptionsProps> = ({
|
||||
selectedTime,
|
||||
minuteFilter,
|
||||
handleSelectHour,
|
||||
handleSelectMinute,
|
||||
handleSelectPeriod,
|
||||
@@ -33,7 +34,7 @@ const Options: FC<TimeOptionsProps> = ({
|
||||
{/* Minute */}
|
||||
<ul className='no-scrollbar flex h-[208px] flex-col gap-y-0.5 overflow-y-auto pb-[184px]'>
|
||||
{
|
||||
minuteOptions.map((minute) => {
|
||||
(minuteFilter ? minuteFilter(minuteOptions) : minuteOptions).map((minute) => {
|
||||
const isSelected = selectedTime?.format('mm') === minute
|
||||
return (
|
||||
<OptionListItem
|
||||
@@ -57,6 +58,7 @@ const Options: FC<TimeOptionsProps> = ({
|
||||
key={period}
|
||||
isSelected={isSelected}
|
||||
onClick={handleSelectPeriod.bind(null, period)}
|
||||
noAutoScroll // if choose PM which would hide(scrolled) AM that may make user confused that there's no am.
|
||||
>
|
||||
{period}
|
||||
</OptionListItem>
|
||||
|
Reference in New Issue
Block a user