Skip to main content
Glama
ContentSelectorWrapper.tsx1.7 kB
import { isSameKeyPath, type NodeProps } from '@intlayer/core'; import { NodeType } from '@intlayer/types'; import { type Component, createMemo, type JSX } from 'solid-js'; import { useIntlayerContext } from '../client'; import { ContentSelector } from '../UI/ContentSelector'; import { useEditorEnabled, useFocusDictionary } from './contexts'; export type ContentSelectorWrapperProps = NodeProps & Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children'> & { children?: JSX.Element; }; const ContentSelectorWrapperContent: Component<ContentSelectorWrapperProps> = ( props ) => { const { focusedContent, setFocusedContent } = useFocusDictionary(); const filteredKeyPath = createMemo(() => props.keyPath.filter((key) => key.type !== NodeType.Translation) ); const handleSelect = () => setFocusedContent({ dictionaryKey: props.dictionaryKey, keyPath: filteredKeyPath(), }); const isSelected = createMemo( () => (focusedContent?.dictionaryKey === props.dictionaryKey && (focusedContent?.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath())) ?? false ); return ( <ContentSelector onPress={handleSelect} isSelecting={isSelected()}> {props.children} </ContentSelector> ); }; export const ContentSelectorRenderer: Component<ContentSelectorWrapperProps> = ( props ) => { const { enabled } = useEditorEnabled(); const { disableEditor } = useIntlayerContext(); if (enabled() && !disableEditor) { return ( <ContentSelectorWrapperContent {...props}> {props.children} </ContentSelectorWrapperContent> ); } return props.children; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server