Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
add [properties-fe] - display properties as chips on row (#376)
Daniel Kweon03222b163091
diff --git a/js/app/packages/app/component/PropertyDisplayControl.tsx b/js/app/packages/app/component/PropertyDisplayControl.tsxindex 27e26ad229..f3d6780991 100644--- a/js/app/packages/app/component/PropertyDisplayControl.tsx+++ b/js/app/packages/app/component/PropertyDisplayControl.tsx@@ -17,6 +17,8 @@ import {} from 'solid-js';import type { DisplayOptions } from './ViewConfig';+const MAX_DISPLAY_PROPERTIES = 4;+type PropertyDisplayControlProps = {selectedPropertyIds: Accessor<DisplayOptions['displayProperties']>;setSelectedPropertyIds: (@@ -199,7 +201,7 @@ export const PropertyDisplayControl: Component<PropertyDisplayControlProps> = (if (!currentIds.includes(property.id)) {const currentIds = props.selectedPropertyIds();// Enforce max 6 properties- if (currentIds.length >= 6) {+ if (currentIds.length >= MAX_DISPLAY_PROPERTIES) {toast.failure('You can only select up to 6 properties to display.');return;}diff --git a/js/app/packages/core/component/Properties/utils/PropertyDataTypeIcon.tsx b/js/app/packages/core/component/Properties/utils/PropertyDataTypeIcon.tsxindex 0d8cb41e81..a4e29fb602 100644--- a/js/app/packages/core/component/Properties/utils/PropertyDataTypeIcon.tsx+++ b/js/app/packages/core/component/Properties/utils/PropertyDataTypeIcon.tsx@@ -4,11 +4,11 @@ import ChatIcon from '@icon/regular/chat.svg';import CheckSquareIcon from '@icon/regular/check-square.svg';import FileIcon from '@icon/regular/file.svg';import FolderIcon from '@icon/regular/folder.svg';-import GlobeIcon from '@icon/regular/globe.svg';import HashIcon from '@icon/regular/hash.svg';import LinkIcon from '@icon/regular/link.svg';import ListBulletIcon from '@icon/regular/list-bullets.svg';import PencilIcon from '@icon/regular/pencil.svg';+import SimpleTagIcon from '@icon/regular/tag-simple.svg';import UserCircleIcon from '@icon/regular/user-circle.svg';import type { Component } from 'solid-js';import type { PropertyDefinitionFlat } from '../types';@@ -39,7 +39,7 @@ export const PropertyDataTypeIcon: Component<PropertyDataTypeIconProps> = (case 'CHANNEL':return <HashIcon class={ICON_CLASSES} />;default:- return <GlobeIcon class={ICON_CLASSES} />;+ return <SimpleTagIcon class={ICON_CLASSES} />;}}diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsxindex e1e165e981..88876e3e80 100644--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx@@ -1,4 +1,5 @@import { EntityIcon } from '@core/component/EntityIcon';+import type { Property } from '@core/component/Properties/types';import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';import { TOKENS } from '@core/hotkey/tokens';import { matches } from '@core/util/match';@@ -41,6 +42,7 @@ import type {WithSearch,} from '../types/search';import type { EntityClickEvent, EntityClickHandler } from './Entity';+import { PropertyPills } from './PropertyPills';function UnreadIndicator(props: { active?: boolean }) {return (@@ -134,7 +136,7 @@ interface EntityProps<T extends WithNotification<EntityData>>onMouseLeave?: () => void;onFocusIn?: () => void;onContextMenu?: () => void;- properties?: Record<string, string>;+ properties?: Property[];contentPlacement?: 'middle' | 'bottom-row';unreadIndicatorActive?: boolean;fadeIfRead?: boolean;@@ -406,6 +408,15 @@ export function EntityWithEverything(};};+ /**+ * Properties for this entity+ * TODO - @danielkweon: Once endpoint includes properties, remove temp data and use: props.displayProperties ?? []+ */+ const properties = (): Property[] => {+ // Use real properties if provided, otherwise use temp data for testing+ return props.properties ?? [];+ };+return (<divuse:draggable@@ -522,6 +533,11 @@ export function EntityWithEverything(}}><div class="flex flex-row items-center justify-end gap-2 min-w-0">+ <div class="flex flex-row items-center justify-end w-fit h-full pr-3">+ <Show when={properties().length > 0}>+ <PropertyPills properties={properties()} />+ </Show>+ </div><Show when={sharedData()}>{(shared) => (<Tooltipdiff --git a/js/app/packages/macro-entity/src/components/PropertyPills/BooleanPropertyPill.tsx b/js/app/packages/macro-entity/src/components/PropertyPills/BooleanPropertyPill.tsxnew file mode 100644index 0000000000..914184a200--- /dev/null+++ b/js/app/packages/macro-entity/src/components/PropertyPills/BooleanPropertyPill.tsx@@ -0,0 +1,70 @@+import type { Property } from '@core/component/Properties/types';+import { PropertyDataTypeIcon } from '@core/component/Properties/utils';+import { Tooltip } from '@core/component/Tooltip';+import { cornerClip } from '@core/util/clipPath';+import { PropertyPillTooltip } from './PropertyPillTooltip';++type BooleanPropertyPillProps = {+ property: Property & { valueType: 'BOOLEAN' };+};++/**+ * Pill for boolean properties+ * Only shows when value is true (false = no pill displayed)+ */+export const BooleanPropertyPill = (props: BooleanPropertyPillProps) => {+ // Don't show pill for false or null values+ if (!props.property.value) return null;++ return (+ <Tooltip+ tooltip={<BooleanTooltipContent property={props.property} />}+ floatingOptions={{+ offset: 4,+ flip: true,+ shift: { padding: 8 },+ }}+ >+ <div+ class="p-px bg-edge box-border h-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ >+ <PropertyDataTypeIcon+ property={{+ data_type: 'BOOLEAN',+ }}+ />+ <span class="truncate max-w-[120px]">+ {props.property.displayName}+ </span>+ </div>+ </div>+ </Tooltip>+ );+};++const BooleanTooltipContent = (props: {+ property: Property & { valueType: 'BOOLEAN' };+}) => {+ return (+ <PropertyPillTooltip property={props.property}>+ <div class="flex items-center gap-1.5 flex-wrap">+ <div+ class="p-px bg-edge box-border h-fit w-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="inline-flex items-center px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ >+ <span>True</span>+ </div>+ </div>+ </div>+ </PropertyPillTooltip>+ );+};diff --git a/js/app/packages/macro-entity/src/components/PropertyPills/EntityPropertyPill.tsx b/js/app/packages/macro-entity/src/components/PropertyPills/EntityPropertyPill.tsxnew file mode 100644index 0000000000..f5168d946b--- /dev/null+++ b/js/app/packages/macro-entity/src/components/PropertyPills/EntityPropertyPill.tsx@@ -0,0 +1,395 @@+import { useChannelName } from '@core/component/ChannelsProvider';+import { EntityIcon as CoreEntityIcon } from '@core/component/EntityIcon';+import type { Property } from '@core/component/Properties/types';+import { PropertyDataTypeIcon } from '@core/component/Properties/utils';+import { Tooltip } from '@core/component/Tooltip';+import { UserIcon } from '@core/component/UserIcon';+import { fileTypeToBlockName } from '@core/constant/allBlocks';+import { isAccessiblePreviewItem, useItemPreview } from '@core/signal/preview';+import { idToDisplayName } from '@core/user';+import { cornerClip } from '@core/util/clipPath';+import ChannelBuildingIcon from '@icon/duotone/building-office-duotone.svg';+import GlobeIcon from '@icon/duotone/globe-duotone.svg';+import ChannelIcon from '@icon/duotone/hash-duotone.svg';+import UserDuotoneIcon from '@icon/duotone/user-duotone.svg';+import ThreeUsersIcon from '@icon/duotone/users-three-duotone.svg';+import type { EntityReference } from '@service-properties/generated/schemas/entityReference';+import { EntityType } from '@service-properties/generated/schemas/entityType';+import { For, Show } from 'solid-js';+import { PropertyPillTooltip } from './PropertyPillTooltip';++/** Entity types that require preview lookup for name/icon resolution */+const PREVIEWABLE_ENTITY_TYPES: EntityType[] = [+ EntityType.DOCUMENT,+ EntityType.PROJECT,+ EntityType.CHAT,+ EntityType.CHANNEL,+];++type EntityPropertyPillProps = {+ property: Property & { valueType: 'ENTITY' };+};++/**+ * Pill for entity properties+ * Single value: shows entity name directly with tooltip+ * Multi value: shows "Property Name (N)" with tooltip+ */+export const EntityPropertyPill = (props: EntityPropertyPillProps) => {+ const entities = () => props.property.value ?? [];+ const count = () => entities().length;++ if (count() === 0) return null;++ // Single entity - show name directly in pill+ if (count() === 1) {+ return (+ <SingleEntityPill property={props.property} entity={entities()[0]} />+ );+ }++ // Multiple entities - show count with tooltip+ return <MultiEntityPill property={props.property} entities={entities()} />;+};++type SingleEntityPillProps = {+ property: Property & { valueType: 'ENTITY' };+ entity: EntityReference;+};++const ICON_CLASSES = 'size-4 text-ink-muted';++const SingleEntityPill = (props: SingleEntityPillProps) => {+ const entityType = () => props.entity.entity_type;+ const entityId = () => props.entity.entity_id;++ const needsPreview = () =>+ PREVIEWABLE_ENTITY_TYPES.includes(entityType() as EntityType);++ const [preview] = useItemPreview({+ id: needsPreview() ? entityId() : '',+ type: needsPreview()+ ? (entityType().toLowerCase() as+ | 'document'+ | 'project'+ | 'chat'+ | 'channel')+ : undefined,+ });++ const channelName = useChannelName(+ entityType() === 'CHANNEL' ? entityId() : '',+ 'Unknown Channel'+ );++ const entityName = () => {+ switch (entityType()) {+ case 'USER':+ return idToDisplayName(entityId()).replace('macro|', '');+ case 'CHANNEL':+ return channelName();+ case 'DOCUMENT':+ case 'PROJECT':+ case 'CHAT': {+ const previewItem = preview();+ if (!previewItem || previewItem.loading) return 'Loading...';+ if (!isAccessiblePreviewItem(previewItem)) return 'Unavailable';+ return previewItem.name || `Unknown ${entityType().toLowerCase()}`;+ }+ default:+ return entityId();+ }+ };++ const entityIcon = () => {+ switch (entityType()) {+ case 'USER':+ return <UserIcon id={entityId()} size="xs" />;++ case 'CHANNEL': {+ const previewItem = preview();+ if (+ !previewItem ||+ previewItem.loading ||+ !isAccessiblePreviewItem(previewItem)+ ) {+ return <ChannelIcon class={ICON_CLASSES} />;+ }++ const channelType = previewItem.channelType;+ switch (channelType) {+ case 'direct_message':+ return <UserDuotoneIcon class={ICON_CLASSES} />;+ case 'private':+ return <ThreeUsersIcon class={ICON_CLASSES} />;+ case 'organization':+ return <ChannelBuildingIcon class={ICON_CLASSES} />;+ case 'public':+ return <GlobeIcon class={ICON_CLASSES} />;+ default:+ return <ChannelIcon class={ICON_CLASSES} />;+ }+ }++ case 'DOCUMENT': {+ const previewItem = preview();+ if (+ !previewItem ||+ previewItem.loading ||+ !isAccessiblePreviewItem(previewItem)+ ) {+ return <CoreEntityIcon targetType="unknown" size="xs" />;+ }++ const fileType = previewItem.fileType;+ const blockName = fileType+ ? fileTypeToBlockName(fileType, true)+ : 'unknown';+ return <CoreEntityIcon targetType={blockName} size="xs" />;+ }++ case 'PROJECT':+ return <CoreEntityIcon targetType="project" size="xs" />;++ case 'CHAT':+ return <CoreEntityIcon targetType="chat" size="xs" />;++ default:+ return (+ <PropertyDataTypeIcon+ property={{+ data_type: 'ENTITY',+ specific_entity_type: props.property.specificEntityType,+ }}+ />+ );+ }+ };++ return (+ <Tooltip+ tooltip={+ <SingleEntityTooltipContent+ property={props.property}+ entity={props.entity}+ />+ }+ floatingOptions={{+ offset: 4,+ flip: true,+ shift: { padding: 8 },+ }}+ >+ <div+ class="p-px bg-edge box-border h-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ >+ <Show when={entityIcon()}>{entityIcon()}</Show>+ <span class="truncate max-w-[120px]">{entityName()}</span>+ </div>+ </div>+ </Tooltip>+ );+};++type SingleEntityTooltipContentProps = {+ property: Property & { valueType: 'ENTITY' };+ entity: EntityReference;+};++const SingleEntityTooltipContent = (props: SingleEntityTooltipContentProps) => {+ return (+ <PropertyPillTooltip property={props.property}>+ <div class="flex items-center gap-1.5 flex-wrap">+ <EntityValuePill entity={props.entity} property={props.property} />+ </div>+ </PropertyPillTooltip>+ );+};++type MultiEntityPillProps = {+ property: Property & { valueType: 'ENTITY' };+ entities: EntityReference[];+};++const MultiEntityPill = (props: MultiEntityPillProps) => {+ return (+ <Tooltip+ tooltip={+ <EntityTooltipContent+ property={props.property}+ entities={props.entities}+ />+ }+ floatingOptions={{+ offset: 4,+ flip: true,+ shift: { padding: 8 },+ }}+ >+ <div+ class="p-px bg-edge box-border h-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ >+ <PropertyDataTypeIcon+ property={{+ data_type: 'ENTITY',+ specific_entity_type: props.property.specificEntityType,+ }}+ />+ <span class="truncate max-w-[120px]">+ {props.property.displayName} ({props.entities.length})+ </span>+ </div>+ </div>+ </Tooltip>+ );+};++type EntityTooltipContentProps = {+ property: Property & { valueType: 'ENTITY' };+ entities: EntityReference[];+};++const EntityTooltipContent = (props: EntityTooltipContentProps) => {+ return (+ <PropertyPillTooltip property={props.property}>+ <div class="flex items-center gap-1.5 flex-wrap">+ <For each={props.entities}>+ {(entity) => (+ <EntityValuePill entity={entity} property={props.property} />+ )}+ </For>+ </div>+ </PropertyPillTooltip>+ );+};++type EntityValuePillProps = {+ entity: EntityReference;+ property: Property & { valueType: 'ENTITY' };+};++const EntityValuePill = (props: EntityValuePillProps) => {+ const entityType = () => props.entity.entity_type;+ const entityId = () => props.entity.entity_id;++ const needsPreview = () =>+ PREVIEWABLE_ENTITY_TYPES.includes(entityType() as EntityType);++ const [preview] = useItemPreview({+ id: needsPreview() ? entityId() : '',+ type: needsPreview()+ ? (entityType().toLowerCase() as+ | 'document'+ | 'project'+ | 'chat'+ | 'channel')+ : undefined,+ });++ const channelName = useChannelName(+ entityType() === 'CHANNEL' ? entityId() : '',+ 'Unknown Channel'+ );++ const entityName = () => {+ switch (entityType()) {+ case 'USER':+ return idToDisplayName(entityId()).replace('macro|', '');+ case 'CHANNEL':+ return channelName();+ case 'DOCUMENT':+ case 'PROJECT':+ case 'CHAT': {+ const previewItem = preview();+ if (!previewItem || previewItem.loading) return 'Loading...';+ if (!isAccessiblePreviewItem(previewItem)) return 'Unavailable';+ return previewItem.name || `Unknown ${entityType().toLowerCase()}`;+ }+ default:+ return entityId();+ }+ };++ const entityIcon = () => {+ switch (entityType()) {+ case 'USER':+ return <UserIcon id={entityId()} size="xs" />;++ case 'CHANNEL': {+ const previewItem = preview();+ if (+ !previewItem ||+ previewItem.loading ||+ !isAccessiblePreviewItem(previewItem)+ ) {+ return <ChannelIcon class={ICON_CLASSES} />;+ }++ const channelType = previewItem.channelType;+ switch (channelType) {+ case 'direct_message':+ return <UserDuotoneIcon class={ICON_CLASSES} />;+ case 'private':+ return <ThreeUsersIcon class={ICON_CLASSES} />;+ case 'organization':+ return <ChannelBuildingIcon class={ICON_CLASSES} />;+ case 'public':+ return <GlobeIcon class={ICON_CLASSES} />;+ default:+ return <ChannelIcon class={ICON_CLASSES} />;+ }+ }++ case 'DOCUMENT': {+ const previewItem = preview();+ if (+ !previewItem ||+ previewItem.loading ||+ !isAccessiblePreviewItem(previewItem)+ ) {+ return <CoreEntityIcon targetType="unknown" size="xs" />;+ }++ const fileType = previewItem.fileType;+ const blockName = fileType+ ? fileTypeToBlockName(fileType, true)+ : 'unknown';+ return <CoreEntityIcon targetType={blockName} size="xs" />;+ }++ case 'PROJECT':+ return <CoreEntityIcon targetType="project" size="xs" />;++ case 'CHAT':+ return <CoreEntityIcon targetType="chat" size="xs" />;++ default:+ return null;+ }+ };++ return (+ <div+ class="p-px bg-edge box-border h-fit w-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ >+ <Show when={entityIcon()}>{entityIcon()}</Show>+ <span class="truncate max-w-[150px]">{entityName()}</span>+ </div>+ </div>+ );+};diff --git a/js/app/packages/macro-entity/src/components/PropertyPills/LinkPropertyPill.tsx b/js/app/packages/macro-entity/src/components/PropertyPills/LinkPropertyPill.tsxnew file mode 100644index 0000000000..f32256d221--- /dev/null+++ b/js/app/packages/macro-entity/src/components/PropertyPills/LinkPropertyPill.tsx@@ -0,0 +1,258 @@+import type { Property } from '@core/component/Properties/types';+import {+ extractDomain,+ PropertyDataTypeIcon,+} from '@core/component/Properties/utils';+import { Tooltip } from '@core/component/Tooltip';+import { useUnfurl } from '@core/signal/unfurl';+import { cornerClip } from '@core/util/clipPath';+import LinkIcon from '@icon/regular/link.svg';+import { proxyResource } from '@service-unfurl/client';+import { createSignal, For, Show } from 'solid-js';+import { PropertyPillTooltip } from './PropertyPillTooltip';++type LinkPropertyPillProps = {+ property: Property & { valueType: 'LINK' };+};++/**+ * Pill for link properties+ * Single value: shows unfurled title or domain with tooltip+ * Multi value: shows "Links (N)" with tooltip+ */+export const LinkPropertyPill = (props: LinkPropertyPillProps) => {+ const links = () => props.property.value ?? [];+ const count = () => links().length;++ if (count() === 0) return null;++ // Single link - show title/domain directly in pill+ if (count() === 1) {+ return <SingleLinkPill property={props.property} url={links()[0]} />;+ }++ // Multiple links - show count with tooltip+ return <MultiLinkPill property={props.property} urls={links()} />;+};++type SingleLinkPillProps = {+ property: Property & { valueType: 'LINK' };+ url: string;+};++const SingleLinkPill = (props: SingleLinkPillProps) => {+ const [unfurlData] = useUnfurl(props.url);+ const [imageError, setImageError] = createSignal(false);++ const title = () => {+ const data = unfurlData();+ if (data?.type === 'success' && data.data.title) {+ return data.data.title;+ }+ return extractDomain(props.url);+ };++ const faviconUrl = () => {+ const data = unfurlData();+ if (data?.type === 'success' && data.data.favicon_url) {+ return proxyResource(data.data.favicon_url);+ }+ return null;+ };++ return (+ <Tooltip+ tooltip={+ <SingleLinkTooltipContent+ property={props.property}+ url={props.url}+ title={title()}+ faviconUrl={faviconUrl()}+ />+ }+ floatingOptions={{+ offset: 4,+ flip: true,+ shift: { padding: 8 },+ }}+ >+ <div+ class="p-px bg-edge box-border h-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ >+ <Show+ when={faviconUrl() && !imageError()}+ fallback={<LinkIcon class="size-4 text-ink-muted" />}+ >+ <img+ src={faviconUrl()!}+ class="size-4 object-cover rounded"+ crossorigin="anonymous"+ alt=""+ onError={() => setImageError(true)}+ />+ </Show>+ <span class="truncate max-w-[100px]">{title()}</span>+ </div>+ </div>+ </Tooltip>+ );+};++type SingleLinkTooltipContentProps = {+ property: Property & { valueType: 'LINK' };+ url: string;+ title: string;+ faviconUrl: string | null;+};++const SingleLinkTooltipContent = (props: SingleLinkTooltipContentProps) => {+ const [imageError, setImageError] = createSignal(false);++ return (+ <PropertyPillTooltip property={props.property}>+ <div class="flex items-center gap-1.5 flex-wrap">+ <div+ class="p-px bg-edge box-border h-fit w-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <a+ href={props.url}+ target="_blank"+ rel="noopener noreferrer"+ class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ title={props.url}+ >+ <Show+ when={props.faviconUrl && !imageError()}+ fallback={<LinkIcon class="size-4 text-ink-muted" />}+ >+ <img+ src={props.faviconUrl!}+ class="size-4 object-cover rounded"+ crossorigin="anonymous"+ alt=""+ onError={() => setImageError(true)}+ />+ </Show>+ <span class="truncate max-w-[150px]">{props.title}</span>+ </a>+ </div>+ </div>+ </PropertyPillTooltip>+ );+};++type MultiLinkPillProps = {+ property: Property & { valueType: 'LINK' };+ urls: string[];+};++const MultiLinkPill = (props: MultiLinkPillProps) => {+ return (+ <Tooltip+ tooltip={+ <LinkTooltipContent property={props.property} urls={props.urls} />+ }+ floatingOptions={{+ offset: 4,+ flip: true,+ shift: { padding: 8 },+ }}+ >+ <div+ class="p-px bg-edge box-border h-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ >+ <PropertyDataTypeIcon+ property={{+ data_type: 'LINK',+ }}+ />+ <span class="truncate max-w-[120px]">+ {props.property.displayName} ({props.urls.length})+ </span>+ </div>+ </div>+ </Tooltip>+ );+};++type LinkTooltipContentProps = {+ property: Property & { valueType: 'LINK' };+ urls: string[];+};++const LinkTooltipContent = (props: LinkTooltipContentProps) => {+ return (+ <PropertyPillTooltip property={props.property}>+ <div class="flex items-center gap-1.5 flex-wrap">+ <For each={props.urls}>{(url) => <LinkValuePill url={url} />}</For>+ </div>+ </PropertyPillTooltip>+ );+};++type LinkValuePillProps = {+ url: string;+};++const LinkValuePill = (props: LinkValuePillProps) => {+ const [unfurlData] = useUnfurl(props.url);+ const [imageError, setImageError] = createSignal(false);++ const title = () => {+ const data = unfurlData();+ if (data?.type === 'success' && data.data.title) {+ return data.data.title;+ }+ return extractDomain(props.url);+ };++ const faviconUrl = () => {+ const data = unfurlData();+ if (data?.type === 'success' && data.data.favicon_url) {+ return proxyResource(data.data.favicon_url);+ }+ return null;+ };++ return (+ <div+ class="p-px bg-edge box-border h-fit w-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <a+ href={props.url}+ target="_blank"+ rel="noopener noreferrer"+ class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ title={props.url}+ >+ <Show+ when={faviconUrl() && !imageError()}+ fallback={<LinkIcon class="size-4 text-ink-muted" />}+ >+ <img+ src={faviconUrl()!}+ class="size-4 object-cover rounded"+ crossorigin="anonymous"+ alt=""+ onError={() => setImageError(true)}+ />+ </Show>+ <span class="truncate max-w-[150px]">{title()}</span>+ </a>+ </div>+ );+};diff --git a/js/app/packages/macro-entity/src/components/PropertyPills/PropertyPillTooltip.tsx b/js/app/packages/macro-entity/src/components/PropertyPills/PropertyPillTooltip.tsxnew file mode 100644index 0000000000..7a13022f2c--- /dev/null+++ b/js/app/packages/macro-entity/src/components/PropertyPills/PropertyPillTooltip.tsx@@ -0,0 +1,42 @@+import type { Property } from '@core/component/Properties/types';+import { PropertyDataTypeIcon } from '@core/component/Properties/utils';+import { cornerClip } from '@core/util/clipPath';+import type { ParentProps } from 'solid-js';++type PropertyPillTooltipProps = ParentProps<{+ property: Property;+}>;++/**+ * Shared tooltip content wrapper for property pills+ * Provides consistent header with icon and display name+ * Children are rendered as the values body+ */+export const PropertyPillTooltip = (props: PropertyPillTooltipProps) => {+ return (+ <div+ class="-m-1.5 p-[0.5px] bg-edge box-border"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="flex flex-col gap-2 p-2 bg-menu min-w-[240px] max-w-[280px] box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ >+ <div class="flex items-center gap-2 text-ink-muted pb-1.5 border-b border-edge/50">+ <PropertyDataTypeIcon+ property={{+ data_type: props.property.valueType,+ specific_entity_type:+ props.property.specificEntityType ?? undefined,+ }}+ class="size-3.5 text-ink-muted"+ />+ <span class="text-sm font-semibold">+ {props.property.displayName}+ </span>+ </div>+ {props.children}+ </div>+ </div>+ );+};diff --git a/js/app/packages/macro-entity/src/components/PropertyPills/PropertyPills.tsx b/js/app/packages/macro-entity/src/components/PropertyPills/PropertyPills.tsxnew file mode 100644index 0000000000..d223a328ea--- /dev/null+++ b/js/app/packages/macro-entity/src/components/PropertyPills/PropertyPills.tsx@@ -0,0 +1,197 @@+import type { Property } from '@core/component/Properties/types';+import {+ formatPropertyValue,+ PropertyDataTypeIcon,+} from '@core/component/Properties/utils';+import { Tooltip } from '@core/component/Tooltip';+import { cornerClip } from '@core/util/clipPath';+import { For, Match, Show, Switch } from 'solid-js';+import { BooleanPropertyPill } from './BooleanPropertyPill';+import { EntityPropertyPill } from './EntityPropertyPill';+import { LinkPropertyPill } from './LinkPropertyPill';+import { PropertyPillTooltip } from './PropertyPillTooltip';++type PropertyPillsProps = {+ properties: Property[];+};++/**+ * Component to display multiple property pills+ * Properties are displayed in the order provided (which should match displayProperties order)+ */+const MAX_DISPLAY_PILLS = 4;++export const PropertyPills = (props: PropertyPillsProps) => {+ const displayProperties = () => props.properties.slice(0, MAX_DISPLAY_PILLS);++ return (+ <Show when={props.properties.length > 0}>+ <div class="flex items-center gap-1 flex-wrap justify-end">+ <For each={displayProperties()}>+ {(property) => <PropertyPill property={property} />}+ </For>+ </div>+ </Show>+ );+};++type PropertyPillProps = {+ property: Property;+};++/**+ * Routes to specialized pill components based on property type+ */+const PropertyPill = (props: PropertyPillProps) => {+ return (+ <Switch fallback={<TextPropertyPill property={props.property} />}>+ <Match when={props.property.valueType === 'BOOLEAN'}>+ <BooleanPropertyPill+ property={props.property as Property & { valueType: 'BOOLEAN' }}+ />+ </Match>+ <Match when={props.property.valueType === 'ENTITY'}>+ <EntityPropertyPill+ property={props.property as Property & { valueType: 'ENTITY' }}+ />+ </Match>+ <Match when={props.property.valueType === 'LINK'}>+ <LinkPropertyPill+ property={props.property as Property & { valueType: 'LINK' }}+ />+ </Match>+ </Switch>+ );+};++/**+ * Pill for String, Number, Date, Select types+ */+const TextPropertyPill = (props: PropertyPillProps) => {+ const displayValue = () => formatPillValue(props.property);++ const value = displayValue();+ if (!value) return null;++ return (+ <Tooltip+ tooltip={<TextTooltipContent property={props.property} />}+ floatingOptions={{+ offset: 4,+ flip: true,+ shift: { padding: 8 },+ }}+ >+ <div+ class="p-px bg-edge box-border h-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0) }}+ >+ <PropertyDataTypeIcon+ property={{+ data_type: props.property.valueType,+ specific_entity_type: props.property.specificEntityType,+ }}+ />+ <span class="truncate max-w-[120px]" title={value}>+ {value}+ </span>+ </div>+ </div>+ </Tooltip>+ );+};++const getValues = (property: Property): string[] => {+ if (property.value === null || property.value === undefined) return [];++ if (+ (property.valueType === 'SELECT_STRING' ||+ property.valueType === 'SELECT_NUMBER') &&+ Array.isArray(property.value)+ ) {+ return property.value.map((v) => formatPropertyValue(property, v));+ }++ if (property.valueType === 'DATE' && property.value instanceof Date) {+ return [formatPropertyValue(property, property.value)];+ }++ if (property.valueType === 'NUMBER' && typeof property.value === 'number') {+ return [formatPropertyValue(property, property.value)];+ }++ if (property.valueType === 'STRING' && typeof property.value === 'string') {+ return property.value ? [property.value] : [];+ }++ return [];+};++const TextTooltipContent = (props: { property: Property }) => {+ return (+ <PropertyPillTooltip property={props.property}>+ <div class="flex items-center gap-1.5 flex-wrap">+ <For each={getValues(props.property)}>+ {(value) => (+ <div+ class="p-px bg-edge box-border h-fit w-fit flex items-center"+ style={{ 'clip-path': cornerClip('0.2rem', 0, 0, 0) }}+ >+ <div+ class="inline-flex items-center px-2 py-1 text-xs leading-none text-ink-muted bg-panel box-border"+ style={{+ 'clip-path': cornerClip('calc(0.2rem - 0.5px)', 0, 0, 0),+ }}+ >+ <span class="truncate max-w-[150px]">{value}</span>+ </div>+ </div>+ )}+ </For>+ </div>+ </PropertyPillTooltip>+ );+};++/**+ * Format property value for display in pill (default types only)+ */+const formatPillValue = (property: Property): string | null => {+ if (property.value === null || property.value === undefined) {+ return null;+ }++ if (+ (property.valueType === 'DATE' && property.value instanceof Date) ||+ (property.valueType === 'NUMBER' && typeof property.value === 'number')+ ) {+ return formatPropertyValue(property, property.value);+ }++ if (property.valueType === 'STRING' && typeof property.value === 'string') {+ return property.value || null;+ }++ // Handle SELECT_STRING and SELECT_NUMBER+ if (+ (property.valueType === 'SELECT_STRING' ||+ property.valueType === 'SELECT_NUMBER') &&+ Array.isArray(property.value)+ ) {+ if (property.value.length === 0) {+ return null;+ }+ // Multi-select with multiple values: show "Property Name (N)"+ if (property.isMultiSelect && property.value.length > 1) {+ return `${property.displayName} (${property.value.length})`;+ }+ // Single value (or multi-select with 1 value): show the value+ return formatPropertyValue(property, property.value[0]);+ }++ return null;+};diff --git a/js/app/packages/macro-entity/src/components/PropertyPills/index.tsx b/js/app/packages/macro-entity/src/components/PropertyPills/index.tsxnew file mode 100644index 0000000000..4437a916e0--- /dev/null+++ b/js/app/packages/macro-entity/src/components/PropertyPills/index.tsx@@ -0,0 +1 @@+export { PropertyPills } from './PropertyPills';