import { AppState } from '@/ui_models/app_state'; import VisuallyHidden from '@reach/visually-hidden'; import { toDirective, useCloseOnBlur } from './utils'; import { Disclosure, DisclosureButton, DisclosurePanel, } from '@reach/disclosure'; import MoreIcon from '../../icons/ic-more.svg'; import PencilOffIcon from '../../icons/ic-pencil-off.svg'; import RichTextIcon from '../../icons/ic-text-rich.svg'; import TrashIcon from '../../icons/ic-trash.svg'; import PinIcon from '../../icons/ic-pin.svg'; import UnpinIcon from '../../icons/ic-pin-off.svg'; import ArchiveIcon from '../../icons/ic-archive.svg'; import UnarchiveIcon from '../../icons/ic-unarchive.svg'; import NotesIcon from '../../icons/il-notes.svg'; import { useRef, useState } from 'preact/hooks'; import { Switch } from './Switch'; import { observer } from 'mobx-react-lite'; import { SNApplication } from '@standardnotes/snjs'; type Props = { application: SNApplication; appState: AppState; }; const MultipleSelectedNotes = observer(({ appState }: Props) => { const count = appState.notes.selectedNotesCount; const [open, setOpen] = useState(false); const [optionsPanelPosition, setOptionsPanelPosition] = useState({ top: 0, right: 0, }); const buttonRef = useRef(); const panelRef = useRef(); const [closeOnBlur, setLockCloseOnBlur] = useCloseOnBlur(panelRef, setOpen); const notes = Object.values(appState.notes.selectedNotes); const hidePreviews = !notes.some((note) => !note.hidePreview); const locked = !notes.some((note) => !note.locked); const archived = !notes.some((note) => !note.archived); const trashed = !notes.some((note) => !note.trashed); const pinned = !notes.some((note) => !note.pinned); const iconClass = 'fill-current color-neutral mr-2.5'; const buttonClass = 'flex items-center border-0 capitalize focus:inner-ring-info ' + 'cursor-pointer hover:bg-contrast color-text bg-transparent h-10 px-3 ' + 'text-left'; return (

{count} selected notes

{ const rect = buttonRef.current.getBoundingClientRect(); setOptionsPanelPosition({ top: rect.bottom, right: document.body.clientWidth - rect.right, }); setOpen((prevOpen) => !prevOpen); }} > { if (event.key === 'Escape') { setOpen(false); } }} onBlur={closeOnBlur} ref={buttonRef} className={ 'bg-transparent border-solid border-1 border-gray-300 ' + 'cursor-pointer w-32px h-32px rounded-full p-0 ' + 'flex justify-center items-center' } > Actions { if (event.key === 'Escape') { setOpen(false); buttonRef.current.focus(); } }} ref={panelRef} style={{ ...optionsPanelPosition, }} className="sn-dropdown sn-dropdown-anchor-right flex flex-col py-2 select-none" > { appState.notes.setLockSelectedNotes(!locked); }} > Prevent editing { appState.notes.setHideSelectedNotePreviews(!hidePreviews); }} > Show Preview

{count} selected notes

Actions will be performed on all selected notes.

); }); export const MultipleSelectedNotesDirective = toDirective( MultipleSelectedNotes );