Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

style(properties): use panel components in call panel, restyle multiselect props, dropdown checkbox (#3639)

Seamusc09eea010fb8
diff --git a/js/app/packages/app/component/side-panel/SidePanel.tsx b/js/app/packages/app/component/side-panel/SidePanel.tsx
index cde56d385d..f8de08c878 100644
--- a/js/app/packages/app/component/side-panel/SidePanel.tsx
+++ b/js/app/packages/app/component/side-panel/SidePanel.tsx
@@ -4,8 +4,7 @@ import { isMobile } from '@core/mobile/isMobile';
import { Accordion } from '@kobalte/core/accordion';
import CaretRight from '@phosphor/caret-right.svg';
import CircleDashedEmpty from '@phosphor/circle-dashed.svg';
-import LoadingSpinner from '@phosphor/spinner.svg';
-import { Panel, Scroll } from '@ui';
+import { Layer, Panel, Scroll } from '@ui';
import { cn } from '@ui/utils/classname';
import {
type Accessor,
@@ -379,10 +378,8 @@ function EmptyPill() {
*/
function Loading() {
return (
- <div class="flex items-center justify-center py-8">
- <div class="size-5 animate-spin text-ink-muted">
- <LoadingSpinner />
- </div>
+ <div class="flex items-center justify-center p-2">
+ <div class="animate-pulse text-ink-muted rounded-full h-2 w-full bg-edge-muted/50"></div>
</div>
);
}
@@ -403,6 +400,16 @@ function CountTitle(props: { label: JSX.Element; count: number }) {
);
}
+function Card(props: ParentProps) {
+ return (
+ <Layer depth={1}>
+ <div class="rounded-lg border border-edge-muted bg-surface overflow-hidden">
+ <div class="divide-y divide-edge-muted">{props.children}</div>
+ </div>
+ </Layer>
+ );
+}
+
export const SidePanel = {
Layout,
Section,
@@ -414,5 +421,6 @@ export const SidePanel = {
Loading,
CountTitle,
NarrowTabs,
+ Card,
};
export { useSidePanel };
diff --git a/js/app/packages/block-call/component/sidepanel/CallSidePanelSections.tsx b/js/app/packages/block-call/component/sidepanel/CallSidePanelSections.tsx
index 2d30fd003c..37a7a73623 100644
--- a/js/app/packages/block-call/component/sidepanel/CallSidePanelSections.tsx
+++ b/js/app/packages/block-call/component/sidepanel/CallSidePanelSections.tsx
@@ -37,10 +37,6 @@ export function CallSidePanelSections(props: CallSidePanelSectionsProps) {
);
}
-// ─────────────────────────────────────────────────────────────────────────────
-// Details Section
-// ─────────────────────────────────────────────────────────────────────────────
-
function DetailsSectionContent(props: { record: Accessor<CallRecord> }) {
const record = props.record;
@@ -49,36 +45,36 @@ function DetailsSectionContent(props: { record: Accessor<CallRecord> }) {
const durationMs = () => record().durationMs ?? undefined;
return (
- <div class="grid grid-cols-[var(--sidepanel-label-width,auto)_1fr] gap-x-3 items-center text-xs auto-rows-[2rem]">
- <DetailsRow label="Owner">
+ <SidePanel.Grid>
+ <SidePanel.Row label="Owner">
<OwnerValue ownerId={record().createdBy} />
- </DetailsRow>
+ </SidePanel.Row>
<Show when={startedAt()}>
{(value) => (
- <DetailsRow label="Started">
+ <SidePanel.Row label="Started">
<DateValueDisplay value={value()} />
- </DetailsRow>
+ </SidePanel.Row>
)}
</Show>
<Show when={endedAt()}>
{(value) => (
- <DetailsRow label="Ended">
+ <SidePanel.Row label="Ended">
<DateValueDisplay value={value()} />
- </DetailsRow>
+ </SidePanel.Row>
)}
</Show>
<Show when={durationMs()}>
{(ms) => (
- <DetailsRow label="Duration">
- <span class={cn(PILL_CLASS, 'w-fit')}>
+ <SidePanel.Row label="Duration">
+ <SidePanel.Pill>
<ClockIcon class="size-3 shrink-0" />
<span class="truncate">{formatCallDuration(ms())}</span>
- </span>
- </DetailsRow>
+ </SidePanel.Pill>
+ </SidePanel.Row>
)}
</Show>
- <DetailsRow label="Status">
- <span class={cn(PILL_CLASS, 'w-fit')}>
+ <SidePanel.Row label="Status">
+ <SidePanel.Pill>
<Show
when={record().isActive}
fallback={<span class="truncate text-ink-muted">Ended</span>}
@@ -86,44 +82,30 @@ function DetailsSectionContent(props: { record: Accessor<CallRecord> }) {
<span class="size-2 rounded-full bg-success shrink-0" />
<span class="truncate text-success font-medium">In progress</span>
</Show>
- </span>
- </DetailsRow>
- </div>
- );
-}
-
-function DetailsRow(props: {
- label: string;
- children: import('solid-js').JSX.Element;
-}) {
- return (
- <>
- <span class="text-ink-muted truncate" title={props.label}>
- {props.label}
- </span>
- <div class="flex items-center gap-2 min-w-0">{props.children}</div>
- </>
+ </SidePanel.Pill>
+ </SidePanel.Row>
+ </SidePanel.Grid>
);
}
function OwnerValue(props: { ownerId: string }) {
const [displayName] = useDisplayName(tryMacroId(props.ownerId));
return (
- <div class={cn(PILL_CLASS, 'w-fit')}>
+ <SidePanel.Pill>
<UserIcon id={props.ownerId} size="sm" showTooltip suppressClick />
<span class="truncate">{displayName()}</span>
- </div>
+ </SidePanel.Pill>
);
}
function DateValueDisplay(props: { value: DateValue }) {
return (
- <div class={cn(PILL_CLASS, 'w-fit')}>
+ <SidePanel.Pill>
<ClockIcon class="size-3 shrink-0" />
<span class="truncate">
{formatDate(props.value, { showTime: true })}
</span>
- </div>
+ </SidePanel.Pill>
);
}
@@ -212,26 +194,14 @@ function ReferencesSectionConditional(props: { callId: string }) {
const count = () => references()?.length ?? 0;
- const title = () => (
- <>
- References
- <Show when={count() > 0}>
- {' '}
- <span class="text-ink-extra-muted">({count()})</span>
- </Show>
- </>
- );
-
return (
<Show when={count() > 0}>
- <SidePanel.Section id="references" title={title()} order={50}>
- <Suspense
- fallback={
- <div class="flex justify-center py-8">
- <div class="animate-spin rounded-full size-6 border-b-2 border-ink-muted" />
- </div>
- }
- >
+ <SidePanel.Section
+ id="references"
+ title={<SidePanel.CountTitle label="References" count={count()} />}
+ order={50}
+ >
+ <Suspense fallback={<SidePanel.Loading />}>
<div class="text-xs">
<References documentId={props.callId} entityType="call" />
</div>
@@ -240,8 +210,3 @@ function ReferencesSectionConditional(props: { callId: string }) {
</Show>
);
}
-
-const PILL_CLASS = cn(
- 'inline-flex items-center gap-1.5 min-w-0 max-w-full',
- 'px-2 py-1 leading-tight text-left rounded-full'
-);
diff --git a/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx b/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
index be9efd8b96..cb2f7ff044 100644
--- a/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
+++ b/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
@@ -20,7 +20,8 @@ import GithubIcon from '@icon/mcp-github.svg';
import { useNotificationsForEntity } from '@notifications';
import ClockIcon from '@phosphor/clock.svg';
import Plus from '@phosphor/plus.svg';
-import { Property as PropertyNS } from '@property';
+import DeleteIcon from '@phosphor/x.svg';
+import { Property as PropertyNS, useProperty } from '@property';
import { Modals } from '@property/component/modal';
import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';
import {
@@ -32,9 +33,9 @@ import {
type PropertySaveHandler,
usePropertiesContext,
} from '@property/context/PropertiesContext';
-import { useEntityProperties } from '@property/hooks';
+import { useEntityProperties, usePropertyEntityDisplay } from '@property/hooks';
import type { Property, PropertyApiValues } from '@property/types';
-import { hasValue } from '@property/utils';
+import { getEntityValues, hasValue } from '@property/utils';
import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';
import { useDocumentMetadataQuery } from '@queries/storage/document-metadata';
import { useDocumentGithubPullRequestsQuery } from '@queries/storage/github-pull-requests';
@@ -45,6 +46,7 @@ import {
} from '@service-storage/client';
import type { GithubPullRequest } from '@service-storage/generated/schemas';
import { createCallback } from '@solid-primitives/rootless';
+import { Button } from '@ui';
import { cn } from '@ui/utils/classname';
import {
createEffect,
@@ -269,6 +271,14 @@ function PropertiesSectionContent(props: {
return sortPinnedProperties(pinned);
});
+ const gridPinnedProperties = createMemo(() =>
+ filteredPinnedProperties().filter(
+ (property) => !isNonUserMultiEntityProperty(property)
+ )
+ );
+ const collectionPinnedProperties = createMemo(() =>
+ filteredPinnedProperties().filter(isNonUserMultiEntityProperty)
+ );
const [pendingPinDefIds, setPendingPinDefIds] = createSignal<Set<string>>(
new Set()
@@ -360,14 +370,22 @@ function PropertiesSectionContent(props: {
<SidePanel.Loading />
</Show>
- <Show when={filteredPinnedProperties().length > 0}>
+ <Show when={gridPinnedProperties().length > 0}>
<SidePanel.Grid class="py-2">
- <For each={filteredPinnedProperties()}>
+ <For each={gridPinnedProperties()}>
{(property) => <SidePanelPropertyRow property={property} />}
</For>
</SidePanel.Grid>
</Show>
+ <Show when={collectionPinnedProperties().length > 0}>
+ <div class="flex flex-col gap-2 pb-2">
+ <For each={collectionPinnedProperties()}>
+ {(property) => <EntityCollectionProperty property={property} />}
+ </For>
+ </div>
+ </Show>
+
<Show when={props.canEdit}>
<AddPinnedPropertyButton />
</Show>
@@ -414,6 +432,14 @@ function sortPinnedProperties<T extends Property>(properties: T[]): T[] {
);
}
+function isNonUserMultiEntityProperty(property: Property): boolean {
+ return (
+ property.valueType === 'ENTITY' &&
+ property.isMultiSelect &&
+ property.specificEntityType !== 'USER'
+ );
+}
+
// ─────────────────────────────────────────────────────────────────────────────
// Pinned property rows — sidepanel-specific. Rendered into a two-column grid:
// the displayName label sits in the left column, the value pill in the right.
@@ -468,6 +494,20 @@ function SinglePill(props: { property: Property }) {
const ctx = usePropertiesContext();
const isReadOnly = () => !ctx.canEdit || props.property.isMetadata;
const empty = () => !hasValue(props.property);
+ const isNonUserEntity = () =>
+ props.property.valueType === 'ENTITY' &&
+ props.property.specificEntityType !== 'USER';
+
+ const entity = () =>
+ isNonUserEntity() ? getEntityValues(props.property)[0] : undefined;
+
+ const entityDisplay = usePropertyEntityDisplay(
+ () => entity()?.entity_id ?? '',
+ () => entity()?.entity_type ?? 'DOCUMENT',
+ {
+ specificMessageId: () => entity()?.specific_message_id,
+ }
+ );
return (
<PropertyNS.Tooltip property={props.property}>
@@ -477,8 +517,23 @@ function SinglePill(props: { property: Property }) {
})}
>
<Show when={!empty()} fallback={<SidePanel.EmptyPill />}>
- <PropertyNS.Icon property={props.property} class="size-3 shrink-0" />
- <PropertyNS.Text property={props.property} />
+ <Show
+ when={isNonUserEntity() && entity()}
+ fallback={
+ <>
+ <PropertyNS.Icon
+ property={props.property}
+ class="size-3 shrink-0"
+ />
+ <PropertyNS.Text property={props.property} />
+ </>
+ }
+ >
+ <span class="shrink-0 flex items-center">
+ {entityDisplay.icon()}
+ </span>
+ <span class="truncate">{entityDisplay.name()}</span>
+ </Show>
</Show>
<PropertyNS.Caret />
</PropertyNS.EditTrigger>
@@ -521,7 +576,10 @@ function MultiValue(props: { property: Property }) {
fallback={<UserStackPill property={props.property} />}
>
<PropertyNS.Tooltip property={props.property}>
- <Show when={!isEntity()} fallback={<PropertyNS.Display />}>
+ <Show
+ when={!isEntity()}
+ fallback={<NonUserEntityValue property={props.property} />}
+ >
<div class="flex flex-wrap items-center gap-1.5">
<PropertyNS.Chips
property={props.property}
@@ -555,6 +613,212 @@ function MultiValue(props: { property: Property }) {
);
}
+function NonUserEntityValue(props: { property: Property }) {
+ const ctx = usePropertiesContext();
+ const propertyCtx = useProperty();
+ const entities = () => getEntityValues(props.property);
+ const isReadOnly = () => !ctx.canEdit || props.property.isMetadata;
+
+ const handleRemoveEntity = async (entityId: string) => {
+ const remaining = entities().filter((e) => e.entity_id !== entityId);
+ await ctx.saveHandler.saveProperty(props.property, {
+ valueType: 'ENTITY',
+ refs: remaining.length > 0 ? remaining : null,
+ });
+ ctx.onRefresh();
+ };
+
+ return (
+ <div class="flex flex-wrap gap-1 justify-start items-start w-full min-w-0">
+ <For each={entities()}>
+ {(entityRef) => (
+ <NonUserEntityChip
+ property={props.property}
+ entityId={entityRef.entity_id}
+ entityType={entityRef.entity_type}
+ specificMessageId={entityRef.specific_message_id}
+ canEdit={!isReadOnly()}
+ onRemove={() => handleRemoveEntity(entityRef.entity_id)}
+ onEdit={(anchor) => {
+ if (isReadOnly()) return;
+ propertyCtx.openEditor(anchor);
+ }}
+ />
+ )}
+ </For>
+ <Show
+ when={!isReadOnly()}
+ fallback={
+ <Show when={entities().length === 0}>
+ <SidePanel.EmptyPill />
+ </Show>
+ }
+ >
+ <Show when={entities().length === 0 || props.property.isMultiSelect}>
+ <Button
+ type="button"
+ variant="ghost"
+ depth={0}
+ size="icon-sm"
+ class="size-5 rounded-full bg-surface"
+ aria-label={`Add ${props.property.displayName}`}
+ onClick={(e) => {
+ e.stopPropagation();
+ propertyCtx.openEditor(e.currentTarget);
+ }}
+ >
+ <Plus class="size-3" />
+ </Button>
+ </Show>
+ </Show>
+ </div>
+ );
+}
+
+function EntityCollectionProperty(props: { property: Property }) {
+ const ctx = usePropertiesContext();
+ const blockId = useBlockId();
+
+ return (
+ <PropertyNS.Root
+ property={props.property}
+ canEdit={ctx.canEdit}
+ onSave={ctx.saveHandler.saveProperty}
+ onRefresh={ctx.onRefresh}
+ >
+ <EntityCollectionPropertyBody property={props.property} />
+ <PropertyNS.PopoverEditor
+ entitySelfFilter={{ entityType: ctx.entityType, blockId }}
+ />
+ </PropertyNS.Root>
+ );
+}
+
+function EntityCollectionPropertyBody(props: { property: Property }) {
+ const ctx = usePropertiesContext();
+ const propertyCtx = useProperty();
+ const entities = () => getEntityValues(props.property);
+ const isReadOnly = () => !ctx.canEdit || props.property.isMetadata;
+
+ const handleRemoveEntity = async (entityId: string) => {
+ const remaining = entities().filter((e) => e.entity_id !== entityId);
+ await ctx.saveHandler.saveProperty(props.property, {
+ valueType: 'ENTITY',
+ refs: remaining.length > 0 ? remaining : null,
+ });
+ ctx.onRefresh();
+ };
+
+ return (
+ <SidePanel.Card>
+ <div class="p-2">
+ <div class="flex items-center justify-between gap-2">
+ <span
+ class="min-w-0 truncate text-ink-muted"
+ title={props.property.displayName}
+ >
+ {props.property.displayName}
+ </span>
+ <Show when={!isReadOnly()}>
+ <Button
+ type="button"
+ variant="ghost"
+ depth={0}
+ size="icon-sm"
+ class="size-5 rounded-full"
+ aria-label={`Add ${props.property.displayName}`}
+ onClick={(e) => {
+ e.stopPropagation();
+ propertyCtx.openEditor(e.currentTarget);
+ }}
+ >
+ <Plus class="size-3" />
+ </Button>
+ </Show>
+ </div>
+ <div class="mt-2 flex flex-wrap gap-1.5">
+ <For
+ each={entities()}
+ fallback={<span class="text-ink-extra-muted">Empty</span>}
+ >
+ {(entityRef) => (
+ <NonUserEntityChip
+ property={props.property}
+ entityId={entityRef.entity_id}
+ entityType={entityRef.entity_type}
+ specificMessageId={entityRef.specific_message_id}
+ canEdit={!isReadOnly()}
+ onRemove={() => handleRemoveEntity(entityRef.entity_id)}
+ onEdit={(anchor) => {
+ if (isReadOnly()) return;
+ propertyCtx.openEditor(anchor);
+ }}
+ />
+ )}
+ </For>
+ </div>
+ </div>
+ </SidePanel.Card>
+ );
+}
+
+function NonUserEntityChip(props: {
+ property: Property;
+ entityId: string;
+ entityType: PropertiesEntityType;
+ specificMessageId?: string | null;
+ canEdit?: boolean;
+ onRemove?: () => void;
+ onEdit?: (anchor?: HTMLElement) => void;
+}) {
+ let containerRef: HTMLDivElement | undefined;
+ const { name, icon } = usePropertyEntityDisplay(
+ () => props.entityId,
+ () => props.entityType,
+ {
+ specificMessageId: () => props.specificMessageId,
+ }
+ );
+
+ const openEditor = (e: MouseEvent) => {
+ if (!props.canEdit || !props.onEdit) return;
+ e.stopPropagation();
+ props.onEdit(containerRef);
+ };
+
+ return (
+ <div
+ ref={containerRef}
+ class="inline-flex shrink-0 border h-7 items-stretch border-edge-muted rounded-md text-ink overflow-clip"
+ >
+ <button
+ type="button"
+ class="flex min-w-0 max-w-[20ch] items-center gap-1.5 px-2 text-left"
+ onClick={openEditor}
+ disabled={!props.canEdit}
+ >
+ <span class="shrink-0 flex items-center">{icon()}</span>
+ <span class="min-w-0 truncate">{name()}</span>
+ </button>
+ <Show when={props.canEdit && props.onRemove}>
+ <div class="border-l border-edge-muted" />
+ <Button
+ type="button"
+ size="icon-sm"
+ class="flex w-6 p-1 h-full shrink-0 rounded-none text-ink-muted not-disabled:hover:text-failure-ink"
+ onClick={(e) => {
+ e.stopPropagation();
+ props.onRemove?.();
+ }}
+ aria-label={`Remove ${name()}`}
+ >
+ <DeleteIcon />
+ </Button>
+ </Show>
+ </div>
+ );
+}
+
function InputValue() {
return (
<div class="min-w-0 w-full">
diff --git a/js/app/packages/core/component/Notifications.tsx b/js/app/packages/core/component/Notifications.tsx
index da5b3be888..801f1012a2 100644
--- a/js/app/packages/core/component/Notifications.tsx
+++ b/js/app/packages/core/component/Notifications.tsx
@@ -1,3 +1,4 @@
+import { SidePanel } from '@app/component/side-panel';
import type { Entity as EntityRef } from '@core/types';
import { compareDateDesc } from '@core/util/date';
import { NotificationRow } from '@entity';
@@ -29,13 +30,11 @@ export function Notifications(props: NotificationsProps) {
</div>
}
>
- <div class="rounded-lg border border-ink-muted/8 bg-ink-muted/[0.025] overflow-hidden">
- <div class="divide-y divide-ink-muted/8">
- <For each={notifications()}>
- {(notification) => <NotificationRow notification={notification} />}
- </For>
- </div>
- </div>
+ <SidePanel.Card>
+ <For each={notifications()}>
+ {(notification) => <NotificationRow notification={notification} />}
+ </For>
+ </SidePanel.Card>
</Show>
);
}
diff --git a/js/app/packages/core/component/References.tsx b/js/app/packages/core/component/References.tsx
index b065962496..bd1f48ee13 100644
--- a/js/app/packages/core/component/References.tsx
+++ b/js/app/packages/core/component/References.tsx
@@ -1,4 +1,5 @@
import { useGlobalBlockOrchestrator } from '@app/component/GlobalAppState';
+import { SidePanel } from '@app/component/side-panel';
import { useSplitLayout } from '@app/component/split-layout/layout';
import { getChannelParams } from '@block-channel/utils/link';
import type { BlockAlias, BlockName } from '@core/block';
@@ -6,7 +7,6 @@ import { toast } from '@core/component/Toast/Toast';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
import { tryMacroId, useDisplayNameParts } from '@core/user';
import { compareDateDesc, type DateValue } from '@core/util/date';
-
import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
import { formatRelativeTimestamp } from '@entity';
import {
@@ -122,14 +122,6 @@ function ReferenceRow(props: ReferenceRowProps) {
);
}
-function ReferencesCard(props: { children: JSX.Element }) {
- return (
- <div class="rounded-lg border border-ink-muted/8 bg-ink-muted/2.5 overflow-hidden">
- <div class="divide-y divide-ink-muted/8">{props.children}</div>
- </div>
- );
-}
-
// A message that is only mention tags adds no info — the row's source chip
// already links to the same target.
const MENTION_TAG_RE = /<m-\w+-mention>[\s\S]*?<\/m-\w+-mention>/g;
@@ -312,7 +304,7 @@ export function References(props: ReferenceProps) {
</div>
}
>
- <ReferencesCard>
+ <SidePanel.Card>
<For each={sortedReferences()}>
{(ref) => {
if (isChannelReference(ref)) {
@@ -345,7 +337,7 @@ export function References(props: ReferenceProps) {
);
}}
</For>
- </ReferencesCard>
+ </SidePanel.Card>
</Show>
);
}
diff --git a/js/app/packages/property/src/editors/popover/EntityEditor.tsx b/js/app/packages/property/src/editors/popover/EntityEditor.tsx
index e7a5043bf6..2e97afb140 100644
--- a/js/app/packages/property/src/editors/popover/EntityEditor.tsx
+++ b/js/app/packages/property/src/editors/popover/EntityEditor.tsx
@@ -4,7 +4,7 @@ import {
} from '@property/utils/entityConversion';
import type { EntityReference } from '@service-properties/generated/schemas/entityReference';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
-import { createSignal, Show } from 'solid-js';
+import { createSignal, Show, Suspense } from 'solid-js';
import { useProperty } from '../../core/context';
import type { EntityProperty, PropertyApiValues } from '../../types';
import { isEntityProperty } from '../../utils';
@@ -72,25 +72,31 @@ function EntityEditorBody(props: EntityEditorProps) {
return (
<EditorPopover onClose={closeAndSave}>
- <PropertyEntitySelector
- config={{
- isMultiSelect: property.isMultiSelect,
- placeholder: `${property.isMultiSelect ? 'Add' : 'Change'} ${property.displayName.toLowerCase()}...`,
- specificEntityType: property.specificEntityType,
- selfFilter: props.selfFilter,
- }}
- selectedOptions={() => entityReferencesToIdSet(selectedRefs())}
- setSelectedOptions={(newOptions, entityInfo) => {
- const updated = updateEntityReferences(
- selectedRefs(),
- newOptions,
- entityInfo
- );
- setSelectedRefs(updated);
- setDirty(true);
- }}
- onClose={closeAndSave}
- />
+ <Suspense
+ fallback={
+ <div class="px-3 py-4 text-sm text-ink-muted">Loading...</div>
+ }
+ >
+ <PropertyEntitySelector
+ config={{
+ isMultiSelect: property.isMultiSelect,
+ placeholder: `${property.isMultiSelect ? 'Add' : 'Change'} ${property.displayName.toLowerCase()}...`,
+ specificEntityType: property.specificEntityType,
+ selfFilter: props.selfFilter,
+ }}
+ selectedOptions={() => entityReferencesToIdSet(selectedRefs())}
+ setSelectedOptions={(newOptions, entityInfo) => {
+ const updated = updateEntityReferences(
+ selectedRefs(),
+ newOptions,
+ entityInfo
+ );
+ setSelectedRefs(updated);
+ setDirty(true);
+ }}
+ onClose={closeAndSave}
+ />
+ </Suspense>
</EditorPopover>
);
}
diff --git a/js/app/packages/property/src/editors/selectors/OptionCheckBox.tsx b/js/app/packages/property/src/editors/selectors/OptionCheckBox.tsx
index b5e1e34cc4..9c5baeb2ab 100644
--- a/js/app/packages/property/src/editors/selectors/OptionCheckBox.tsx
+++ b/js/app/packages/property/src/editors/selectors/OptionCheckBox.tsx
@@ -1,5 +1,5 @@
-import CheckIcon from '@phosphor/check.svg';
-import { type Component, Show } from 'solid-js';
+import { Checkbox } from '@ui';
+import type { Component } from 'solid-js';
/**
* CheckBox component for property option menus.
@@ -13,18 +13,16 @@ export const OptionCheckBox: Component<{
multiselect?: boolean;
}> = (props) => {
return (
- <div
- class="size-4 flex items-center justify-center"
- classList={{
- 'bg-accent border-accent border': props.checked,
- 'bg-transparent border-edge-muted border': !props.checked,
- 'rounded-full': props.multiselect === false,
- 'rounded-sm': props.multiselect !== false,
- }}
+ <Checkbox
+ checked={props.checked}
+ onChange={() => undefined}
+ class="shrink-0"
>
- <Show when={props.checked && props.multiselect !== false}>
- <CheckIcon class="size-3 text-surface" />
- </Show>
- </div>
+ <Checkbox.Control
+ class={`size-3.5 border-transparent bg-transparent hover:border-accent data-checked:bg-accent data-checked:border-accent ${
+ props.checked ? '' : 'group-hover:not-hover:border-edge-muted'
+ } ${props.multiselect === false ? 'rounded-full' : 'rounded-sm'}`}
+ />
+ </Checkbox>
);
};
diff --git a/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx b/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx
index af63f9f714..8428cd8c05 100644
--- a/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx
+++ b/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx
@@ -7,6 +7,7 @@ import { useSelectedFirst } from '@core/util/useSelectedFirst';
import type { EmailEntity } from '@entity';
import { Entity, type EntityData } from '@entity';
import { createEmailsInfiniteQuery } from '@macro-entity';
+import CheckIcon from '@phosphor/check.svg';
import SearchIcon from '@phosphor/magnifying-glass.svg';
import { useSearchInputFocus } from '@property/utils';
import { useSearchSoupQuery } from '@queries/soup/search';
@@ -285,6 +286,17 @@ export function PropertyEntitySelector(props: EntityInputProps) {
getId: (e: CombinedEntity) => e.id,
});
+ const openedSelectedIds = new Set(props.selectedOptions());
+ const selectedEntityCountAtOpen = createMemo(() => {
+ if (!props.config.isMultiSelect || searchTerm()) return 0;
+ return sortedEntities().filter((entity) => openedSelectedIds.has(entity.id))
+ .length;
+ });
+ const shouldShowSelectedDivider = (index: number) =>
+ selectedEntityCountAtOpen() > 0 &&
+ selectedEntityCountAtOpen() < sortedEntities().length &&
+ index === selectedEntityCountAtOpen();
+
const toggleEntity = (entity: CombinedEntity) => {
const newSelected = new Set(props.selectedOptions());
const isCurrentlySelected = newSelected.has(entity.id);
@@ -422,10 +434,9 @@ export function PropertyEntitySelector(props: EntityInputProps) {
return (
<div
- class="flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8 rounded-md"
+ class="group flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8 rounded-md"
classList={{
'bg-hover': isKeyboardSelected(),
- 'bg-accent/10': isSelected(),
}}
onClick={() => togglePinnedOption(option)}
onMouseEnter={() => {
@@ -434,16 +445,18 @@ export function PropertyEntitySelector(props: EntityInputProps) {
}
}}
>
+ <Show when={props.config.isMultiSelect}>
+ <div class="shrink-0">
+ <OptionCheckBox checked={isSelected()} multiselect />
+ </div>
+ </Show>
<div class="flex items-center gap-2 flex-1 min-w-0">
<div class="size-4 shrink-0">{option.icon}</div>
<span class="truncate min-w-0">{option.label}</span>
</div>
- <div class="shrink-0">
- <OptionCheckBox
- checked={isSelected()}
- multiselect={props.config.isMultiSelect}
- />
- </div>
+ <Show when={!props.config.isMultiSelect && isSelected()}>
+ <CheckIcon class="size-3.5 shrink-0 text-accent" />
+ </Show>
</div>
);
}}
@@ -465,55 +478,68 @@ export function PropertyEntitySelector(props: EntityInputProps) {
adjustedIndex() === selectedIndex();
return (
- <div
- data-entity-index={index()}
- class="flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8 rounded-md"
- classList={{
- 'bg-hover': isKeyboardSelected(),
- 'bg-accent/10': isSelected(),
- }}
- onClick={() => toggleEntity(entity)}
- onKeyDown={(e) =>
- e.key === 'Enter' && toggleEntity(entity)
- }
- onMouseEnter={() => {
- if (!keyboardMode()) {
- setSelectedIndex(adjustedIndex());
+ <>
+ <Show when={shouldShowSelectedDivider(index())}>
+ <div class="my-1 border-t border-edge-muted" />
+ </Show>
+ <div
+ data-entity-index={index()}
+ class="group flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8 rounded-md"
+ classList={{
+ 'bg-hover': isKeyboardSelected(),
+ }}
+ onClick={() => toggleEntity(entity)}
+ onKeyDown={(e) =>
+ e.key === 'Enter' && toggleEntity(entity)
}
- }}
- >
- <div class="flex items-center gap-2 flex-1 min-w-0">
- <div class="size-4 shrink-0 flex items-center">
- <Show
- when={entity.kind === 'entity'}
- fallback={
- <UserIcon
- id={entity.id}
- size="sm"
- isDeleted={false}
- suppressClick={true}
+ onMouseEnter={() => {
+ if (!keyboardMode()) {
+ setSelectedIndex(adjustedIndex());
+ }
+ }}
+ >
+ <Show when={props.config.isMultiSelect}>
+ <div class="shrink-0">
+ <OptionCheckBox
+ checked={isSelected()}
+ multiselect
+ />
+ </div>
+ </Show>
+ <div class="flex items-center gap-2 flex-1 min-w-0">
+ <div class="size-4 shrink-0 flex items-center">
+ <Show
+ when={entity.kind === 'entity'}
+ fallback={
+ <UserIcon
+ id={entity.id}
+ size="sm"
+ isDeleted={false}
+ suppressClick={true}
+ />
+ }
+ >
+ <Entity.Icon entity={entity.data as EntityData} />
+ </Show>
+ </div>
+ <span class="truncate min-w-0">
+ <Show
+ when={entity.kind === 'entity'}
+ fallback={getEntityName(entity)}
+ >
+ <Entity.Title
+ entity={entity.data as EntityData}
/>
- }
- >
- <Entity.Icon entity={entity.data as EntityData} />
- </Show>
+ </Show>
+ </span>
</div>
- <span class="truncate min-w-0">
- <Show
- when={entity.kind === 'entity'}
- fallback={getEntityName(entity)}
- >
- <Entity.Title entity={entity.data as EntityData} />
- </Show>
- </span>
- </div>
- <div class="shrink-0">
- <OptionCheckBox
- checked={isSelected()}
- multiselect={props.config.isMultiSelect}
- />
+ <Show
+ when={!props.config.isMultiSelect && isSelected()}
+ >
+ <CheckIcon class="size-3.5 shrink-0 text-accent" />
+ </Show>
</div>
- </div>
+ </>
);
}}
</For>
diff --git a/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx b/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx
index 0016708ade..2c2d19fb4a 100644
--- a/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx
+++ b/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx
@@ -128,7 +128,7 @@ const DropdownSelectableRow: ParentComponent<DropdownSelectableRowProps> = (
) => {
return (
<div
- class="flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 rounded-md"
+ class="group flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 rounded-md"
classList={{
'bg-hover': props.isSelected,
}}