|
|
|
|
@ -2,9 +2,9 @@ import { memo, useMemo, useState } from 'react'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
import { FixedSizeList as List, areEqual } from 'react-window'
|
|
|
|
|
import type { ListChildComponentProps } from 'react-window'
|
|
|
|
|
import { RiArrowDownSLine, RiArrowRightSLine } from '@remixicon/react'
|
|
|
|
|
import Checkbox from '../../checkbox'
|
|
|
|
|
import NotionIcon from '../../notion-icon'
|
|
|
|
|
import s from './index.module.css'
|
|
|
|
|
import cn from '@/utils/classnames'
|
|
|
|
|
import type { DataSourceNotionPage, DataSourceNotionPageMap } from '@/models/common'
|
|
|
|
|
|
|
|
|
|
@ -94,10 +94,16 @@ const ItemComponent = ({ index, style, data }: ListChildComponentProps<{
|
|
|
|
|
if (hasChild) {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={cn(s.arrow, current.expand && s['arrow-expand'], 'shrink-0 mr-1 w-5 h-5 hover:bg-gray-200 rounded-md')}
|
|
|
|
|
className='flex items-center justify-center shrink-0 mr-1 w-5 h-5 hover:bg-components-button-ghost-bg-hover rounded-md'
|
|
|
|
|
style={{ marginLeft: current.depth * 8 }}
|
|
|
|
|
onClick={() => handleToggle(index)}
|
|
|
|
|
/>
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
current.expand
|
|
|
|
|
? <RiArrowDownSLine className='w-4 h-4 text-text-tertiary' />
|
|
|
|
|
: <RiArrowRightSLine className='w-4 h-4 text-text-tertiary' />
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
if (current.parent_id === 'root' || !pagesMap[current.parent_id]) {
|
|
|
|
|
@ -112,14 +118,12 @@ const ItemComponent = ({ index, style, data }: ListChildComponentProps<{
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={cn('group flex items-center pl-2 pr-[2px] rounded-md border border-transparent hover:bg-gray-100 cursor-pointer', previewPageId === current.page_id && s['preview-item'])}
|
|
|
|
|
className={cn('group flex items-center pl-2 pr-[2px] rounded-md hover:bg-state-base-hover cursor-pointer',
|
|
|
|
|
previewPageId === current.page_id && 'bg-state-base-hover')}
|
|
|
|
|
style={{ ...style, top: style.top as number + 8, left: 8, right: 8, width: 'calc(100% - 16px)' }}
|
|
|
|
|
>
|
|
|
|
|
<Checkbox
|
|
|
|
|
className={cn(
|
|
|
|
|
'shrink-0 mr-2 group-hover:border-primary-600 group-hover:border-[2px]',
|
|
|
|
|
disabled && 'group-hover:border-transparent',
|
|
|
|
|
)}
|
|
|
|
|
className='shrink-0 mr-2'
|
|
|
|
|
checked={checkedIds.has(current.page_id)}
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
onCheck={() => {
|
|
|
|
|
@ -135,7 +139,7 @@ const ItemComponent = ({ index, style, data }: ListChildComponentProps<{
|
|
|
|
|
src={current.page_icon}
|
|
|
|
|
/>
|
|
|
|
|
<div
|
|
|
|
|
className='grow text-sm font-medium text-gray-700 truncate'
|
|
|
|
|
className='grow text-[13px] leading-4 font-medium text-text-secondary truncate'
|
|
|
|
|
title={current.page_name}
|
|
|
|
|
>
|
|
|
|
|
{current.page_name}
|
|
|
|
|
@ -143,7 +147,9 @@ const ItemComponent = ({ index, style, data }: ListChildComponentProps<{
|
|
|
|
|
{
|
|
|
|
|
canPreview && (
|
|
|
|
|
<div
|
|
|
|
|
className='shrink-0 hidden group-hover:flex items-center ml-1 px-2 h-6 rounded-md text-xs font-medium text-gray-500 cursor-pointer hover:bg-gray-50 hover:text-gray-700'
|
|
|
|
|
className='shrink-0 hidden group-hover:flex items-center ml-1 px-2 h-6 rounded-md text-xs leading-4 font-medium text-components-button-secondary-text
|
|
|
|
|
cursor-pointer bg-components-button-secondary-bg border-[0.5px] border-components-button-secondary-border shadow-xs shadow-shadow-shadow-3
|
|
|
|
|
backdrop-blur-[10px] hover:bg-components-button-secondary-bg-hover hover:border-components-button-secondary-border-hover'
|
|
|
|
|
onClick={() => handlePreview(index)}>
|
|
|
|
|
{t('common.dataSource.notion.selector.preview')}
|
|
|
|
|
</div>
|
|
|
|
|
@ -152,7 +158,7 @@ const ItemComponent = ({ index, style, data }: ListChildComponentProps<{
|
|
|
|
|
{
|
|
|
|
|
searchValue && (
|
|
|
|
|
<div
|
|
|
|
|
className='shrink-0 ml-1 max-w-[120px] text-xs text-gray-400 truncate'
|
|
|
|
|
className='shrink-0 ml-1 max-w-[120px] text-xs text-text-quaternary truncate'
|
|
|
|
|
title={breadCrumbs.join(' / ')}
|
|
|
|
|
>
|
|
|
|
|
{breadCrumbs.join(' / ')}
|
|
|
|
|
@ -278,7 +284,7 @@ const PageSelector = ({
|
|
|
|
|
|
|
|
|
|
if (!currentDataList.length) {
|
|
|
|
|
return (
|
|
|
|
|
<div className='flex items-center justify-center h-[296px] text-[13px] text-gray-500'>
|
|
|
|
|
<div className='flex items-center justify-center h-[296px] text-[13px] text-text-tertiary'>
|
|
|
|
|
{t('common.dataSource.notion.selector.noSearchResult')}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
|