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.

refactor(properties): begin refactor properties to use composable extractor pattern (#3332)

Seamus33fd229084fc
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.css b/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.css
index ea256d3130..0fe7e147ee 100644
--- a/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.css
+++ b/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.css
@@ -1,7 +1,7 @@
.task-grid-row {
--task-col-status: 7rem;
--task-col-priority: 7rem;
- --task-col-assignees: 7rem;
+ --task-col-assignees: 9rem;
--task-col-created-by: 7rem;
--task-col-timestamp: 5rem;
}
@@ -18,7 +18,7 @@
.task-grid-row {
--task-col-status: 2rem;
--task-col-priority: 2rem;
- --task-col-assignees: 2rem;
+ --task-col-assignees: 3rem;
--task-col-created-by: 0rem;
--task-col-timestamp: 5rem;
}
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx b/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx
index 28907a4dbb..47f0bc0f11 100644
--- a/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx
@@ -1,240 +1,89 @@
-import { CondensedPropertyValue } from '@core/component/Properties/component/propertyValue/CondensedPropertyValue';
-import { PropertyTooltip } from '@core/component/Properties/component/propertyValue/PropertyTooltip';
-import { PropertyValueIcon } from '@core/component/Properties/component/propertyValue/PropertyValueIcon';
import { usePropertiesContext } from '@core/component/Properties/context/PropertiesContext';
-import type { Property } from '@core/component/Properties/types';
-import {
- formatPropertyValue,
- getEntityValues,
- getSelectValues,
-} from '@core/component/Properties/utils';
-import { UserGroup } from '@core/component/UserGroup';
-import { UserIcon } from '@core/component/UserIcon';
-import { tryMacroId, useDisplayNameParts } from '@core/user';
-import CaretDownIcon from '@icon/caret-down.svg';
+import type { Property as PropertyT } from '@core/component/Properties/types';
import CircleDashedEmpty from '@icon/circle-dashed.svg';
-import { HoverCard } from '@ui';
-import { cn } from '@ui/utils/classname';
-import { type Component, Show } from 'solid-js';
+import { Property } from '@property';
+import { getEntityValues, hasValue } from '@property/utils';
+import { type Component, Match, Show, Switch } from 'solid-js';
import './list-property-value.css';
+import { Layer } from '@ui';
type ListPropertyValueProps = {
- property: Property;
+ property: PropertyT;
};
/**
- * Borderless property value for list views. Routes by valueType:
- *
- * - SELECT_*: icon + label + caret-down. Empty: dashed-circle + "Set <name>".
- * - ENTITY (USER): avatar group + caret-down. Empty: dashed-circle +
- * "Add <name>".
- * - everything else: falls back to CondensedPropertyValue.
- *
- * All branches intercept clicks (stopPropagation) and open the property editor
- * anchored to the cell.
+ * Property pill for list views. Built from @property primitives,
+ * with `@max-[840px]/u-list:hidden` collapsing the label and caret on narrow
+ * containers so cells reduce to icon-only.
*/
export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
- const isSelect = () =>
- props.property.valueType === 'SELECT_STRING' ||
- props.property.valueType === 'SELECT_NUMBER';
+ const ctx = usePropertiesContext();
- const isEntity = () => props.property.valueType === 'ENTITY';
+ const isUserEntity = () =>
+ props.property.valueType === 'ENTITY' &&
+ props.property.specificEntityType === 'USER';
- const context = usePropertiesContext();
+ const userCount = () =>
+ isUserEntity() ? getEntityValues(props.property).length : 0;
- return (
- <Show
- when={isSelect()}
- fallback={
- <Show
- when={isEntity()}
- fallback={
- <CondensedPropertyValue
- property={props.property}
- canEdit={context.canEdit}
- onEdit={context.openPropertyEditor}
- />
- }
- >
- <ListEntityValue property={props.property} />
- </Show>
- }
- >
- <ListSelectValue property={props.property} />
- </Show>
- );
-};
-
-const buttonClass = (isReadOnly: boolean) =>
- cn(
- 'inline-flex items-center gap-1 min-w-0',
- 'px-1.5 py-1 leading-tight text-left rounded-sm',
- 'cursor-default',
- {
- 'hover:bg-hover': !isReadOnly,
- }
- );
-
-const ListSelectValue: Component<{ property: Property }> = (props) => {
- const context = usePropertiesContext();
-
- const isReadOnly = () => props.property.isMetadata || !context.canEdit;
-
- const handleClick = (e: MouseEvent) => {
- e.stopPropagation();
- if (isReadOnly()) return;
- context.openPropertyEditor(props.property, e.currentTarget as HTMLElement);
- };
-
- const firstValue = () => getSelectValues(props.property)[0];
-
- const displayText = () => {
- const value = firstValue();
- if (value !== undefined) {
- return formatPropertyValue(props.property, value);
- }
- return `None`;
- };
+ const isEmpty = () => !hasValue(props.property);
return (
- <HoverCard content={<PropertyTooltip property={props.property} />}>
- <button
- type="button"
- onClick={handleClick}
- class={cn('list-property-cell min-w-0', buttonClass(isReadOnly()), {
- 'text-ink-extra-muted/50': !firstValue(),
- })}
- >
- <Show
- when={firstValue()}
- fallback={<CircleDashedEmpty class="size-3 shrink-0" />}
- >
- {(value) => <PropertyValueIcon optionId={value()} />}
- </Show>
- {/* Label hidden when container is narrow via CSS */}
- <span
- class={cn(
- 'list-property-label truncate flex-1 @max-[840px]/u-list:hidden',
- {
- 'text-ink-extra-muted opacity-50': firstValue() === undefined,
- }
- )}
- >
- {displayText()}
- </span>
- {/* Caret hidden when container is narrow */}
- <Show when={!isReadOnly()}>
- <CaretDownIcon class="size-3 shrink-0 @max-[840px]/u-list:hidden" />
- </Show>
- </button>
- </HoverCard>
- );
-};
-
-/** Single user display with icon + truncated first name */
-const SingleUserValue: Component<{ userId: string }> = (props) => {
- const nameParts = () => useDisplayNameParts(tryMacroId(props.userId));
- const firstName = () => nameParts().firstName() || 'Unknown';
-
- return (
- <div class="flex items-center gap-1.5 min-w-0">
- <UserIcon id={props.userId} size="sm" suppressClick showTooltip />
- {/* First name hidden on narrow containers */}
- <span class="truncate @max-[840px]/u-list:hidden">{firstName()}</span>
- </div>
- );
-};
-
-/** Multi-user display with avatar stack */
-const MultiUserValue: Component<{ userIds: string[] }> = (props) => {
- return (
- <>
- {/* Wide mode: show up to 2 users */}
- <div class="flex @max-[840px]/u-list:hidden">
- <UserGroup
- userIds={props.userIds}
- size="sm"
- suppressClick
- showTooltip
- maxUsers={2}
- />
- </div>
- {/* Narrow mode: show 1 user */}
- <div class="hidden @max-[840px]/u-list:flex">
- <UserGroup
- userIds={props.userIds}
- size="sm"
- suppressClick
- showTooltip
- maxUsers={1}
- />
- </div>
- </>
- );
-};
-
-const ListEntityValue: Component<{ property: Property }> = (props) => {
- const context = usePropertiesContext();
-
- const isReadOnly = () => props.property.isMetadata || !context.canEdit;
-
- const handleClick = (e: MouseEvent) => {
- e.stopPropagation();
- if (isReadOnly()) return;
- context.openPropertyEditor(props.property, e.currentTarget as HTMLElement);
- };
-
- const entities = () => getEntityValues(props.property);
- const isUser = () => props.property.specificEntityType === 'USER';
- const hasValues = () => entities().length > 0;
- const isSingleUser = () => isUser() && entities().length === 1;
-
- return (
- <HoverCard content={<PropertyTooltip property={props.property} />}>
- <button
- type="button"
- onClick={handleClick}
- class={cn('list-property-cell min-w-0', buttonClass(isReadOnly()), {
- 'text-ink-extra-muted/50': !hasValues(),
- })}
- >
- <Show
- when={hasValues()}
- fallback={
- <>
- <CircleDashedEmpty class="size-3 shrink-0" />
- <span class="truncate flex-1 @max-[840px]/u-list:hidden">
- None
- </span>
- </>
- }
- >
- <Show
- when={isUser()}
- fallback={
- <span class="truncate flex-1 @max-[840px]/u-list:hidden">
- {entities().length === 1
- ? '1 item'
- : `${entities().length} items`}
- </span>
- }
- >
- {/* Single user: show icon + first name */}
+ <Property.Root
+ property={props.property}
+ canEdit={ctx.canEdit}
+ onEdit={ctx.openPropertyEditor}
+ >
+ <Property.Tooltip property={props.property}>
+ <Layer depth={2}>
+ <Property.EditTrigger class="list-property-cell min-w-0 rounded-full hover:bg-surface/50 inline-flex items-center gap-1 px-2 py-1.5 leading-tight text-left hover:ring ring-edge ring-inset">
<Show
- when={isSingleUser()}
+ when={!isEmpty()}
fallback={
- <MultiUserValue userIds={entities().map((e) => e.entity_id)} />
+ <>
+ <CircleDashedEmpty class="size-3 shrink-0 opacity-50" />
+ <span class="truncate flex-1 opacity-50 @max-[840px]/u-list:hidden">
+ None
+ </span>
+ </>
}
>
- <SingleUserValue userId={entities()[0].entity_id} />
+ <Switch
+ fallback={
+ <Property.Icon
+ property={props.property}
+ class="size-3 shrink-0"
+ />
+ }
+ >
+ <Match when={userCount() > 1}>
+ {/* Wide: 2 avatars; narrow: collapse to 1 to fit the cell. */}
+ <div class="@max-[840px]/u-list:hidden">
+ <Property.UserStack
+ property={props.property}
+ maxUsers={2}
+ />
+ </div>
+ <div class="hidden @max-[840px]/u-list:flex">
+ <Property.UserStack
+ property={props.property}
+ maxUsers={1}
+ />
+ </div>
+ </Match>
+ <Match when={isUserEntity()}>
+ <Property.Icon property={props.property} />
+ </Match>
+ </Switch>
+ <Property.Text
+ property={props.property}
+ class="flex-1 @max-[840px]/u-list:hidden"
+ />
</Show>
- </Show>
- </Show>
- {/* Caret hidden when container is narrow */}
- <Show when={!isReadOnly()}>
- <CaretDownIcon class="size-3 shrink-0 @max-[840px]/u-list:hidden" />
- </Show>
- </button>
- </HoverCard>
+ <Property.Caret class="@max-[840px]/u-list:hidden" />
+ </Property.EditTrigger>
+ </Layer>
+ </Property.Tooltip>
+ </Property.Root>
);
};
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index ecef39bfe8..926f4f94ff 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -361,6 +361,11 @@ if (LOCAL_ONLY) {
lazy(() => import('@core/component/Properties/debug/PropertiesDebug'))
);
+ registerComponent(
+ 'props-debug',
+ lazy(() => import('@property/debug/PropertyDebug'))
+ );
+
registerComponent(
'entity-debug',
lazy(() => import('@entity/debug/DebugEntityView'))
diff --git a/js/app/packages/block-md/component/InlinePropertyValue.tsx b/js/app/packages/block-md/component/InlinePropertyValue.tsx
index 1e64d49ed7..6fe036348e 100644
--- a/js/app/packages/block-md/component/InlinePropertyValue.tsx
+++ b/js/app/packages/block-md/component/InlinePropertyValue.tsx
@@ -1,210 +1,78 @@
-import { PropertyTooltip } from '@core/component/Properties/component/propertyValue/PropertyTooltip';
-import { PropertyValueIcon } from '@core/component/Properties/component/propertyValue/PropertyValueIcon';
import { usePropertiesContext } from '@core/component/Properties/context/PropertiesContext';
-import type { Property } from '@core/component/Properties/types';
-import {
- formatPropertyValue,
- getEntityValues,
- getSelectValues,
-} from '@core/component/Properties/utils';
-import { UserGroup } from '@core/component/UserGroup';
-import { UserIcon } from '@core/component/UserIcon';
-import { tryMacroId, useDisplayNameParts } from '@core/user';
-import CaretDownIcon from '@icon/caret-down.svg';
-import CircleDashedEmpty from '@icon/circle-dashed.svg';
-import { HoverCard, Layer } from '@ui';
+import type { Property as PropertyT } from '@core/component/Properties/types';
+import { Property } from '@property';
+import { getEntityValues, hasValue } from '@property/utils';
+import { Layer } from '@ui';
import { cn } from '@ui/utils/classname';
-import { type Component, Show } from 'solid-js';
+import { type Component, Match, Switch } from 'solid-js';
type InlinePropertyValueProps = {
- property: Property;
+ property: PropertyT;
};
/**
- * Inline property value for task view when sidebar is closed.
- * Similar to ListPropertyValue but always shows labels (no container query hiding).
+ * Inline property pill shown beneath a task title when the side panel is
+ * closed. Built from @property primitives — same visual surface as before,
+ * but routes through Property.Root / Tooltip / EditTrigger so any property
+ * type renders correctly without bespoke per-type components.
*/
export const InlinePropertyValue: Component<InlinePropertyValueProps> = (
props
) => {
- const isSelect = () =>
- props.property.valueType === 'SELECT_STRING' ||
- props.property.valueType === 'SELECT_NUMBER';
+ const ctx = usePropertiesContext();
- const isEntity = () => props.property.valueType === 'ENTITY';
+ const isReadOnly = () => !ctx.canEdit || props.property.isMetadata;
+ const isEmpty = () => !hasValue(props.property);
- return (
- <Show
- when={isSelect()}
- fallback={
- <Show when={isEntity()}>
- <InlineEntityValue property={props.property} />
- </Show>
- }
- >
- <InlineSelectValue property={props.property} />
- </Show>
- );
-};
-
-const buttonClass = (isReadOnly: boolean) =>
- cn(
- 'inline-flex items-center gap-1.5 min-w-0',
- 'px-2 py-1 leading-tight text-left rounded-sm',
- 'cursor-default bg-surface',
- {
- 'hover:bg-hover': !isReadOnly,
- }
- );
-
-const InlineSelectValue: Component<{ property: Property }> = (props) => {
- const context = usePropertiesContext();
-
- const isReadOnly = () => props.property.isMetadata || !context.canEdit;
+ const isUserEntity = () =>
+ props.property.valueType === 'ENTITY' &&
+ props.property.specificEntityType === 'USER';
- const handleClick = (e: MouseEvent) => {
- e.stopPropagation();
- if (isReadOnly()) return;
- context.openPropertyEditor(props.property, e.currentTarget as HTMLElement);
- };
-
- const firstValue = () => getSelectValues(props.property)[0];
-
- const displayText = () => {
- const value = firstValue();
- if (value !== undefined) {
- return formatPropertyValue(props.property, value);
- }
- return 'None';
- };
+ const isMultiUserEntity = () =>
+ isUserEntity() && getEntityValues(props.property).length > 1;
return (
- <HoverCard content={<PropertyTooltip property={props.property} />}>
- <Layer depth={2}>
- <button
- type="button"
- onClick={handleClick}
- class={cn(buttonClass(isReadOnly()), {
- 'text-ink-extra-muted/50': !firstValue(),
- })}
- >
- <Show
- when={firstValue()}
- fallback={<CircleDashedEmpty class="size-3 shrink-0" />}
- >
- {(value) => <PropertyValueIcon optionId={value()} />}
- </Show>
- <span
- class={cn('truncate', {
- 'text-ink-extra-muted opacity-50': firstValue() === undefined,
- })}
- >
- {displayText()}
- </span>
- <Show when={!isReadOnly()}>
- <CaretDownIcon class="size-3 shrink-0" />
- </Show>
- </button>
- </Layer>
- </HoverCard>
- );
-};
-
-/** Single user display with icon + truncated first name */
-const SingleUserValue: Component<{ userId: string }> = (props) => {
- const nameParts = () => useDisplayNameParts(tryMacroId(props.userId));
- const firstName = () => nameParts().firstName() || 'Unknown';
-
- return (
- <div class="flex items-center gap-1.5 min-w-0">
- <UserIcon id={props.userId} size="sm" suppressClick showTooltip />
- <span class="truncate">{firstName()}</span>
- </div>
- );
-};
-
-/** Multi-user display with avatar stack + count */
-const MultiUserValue: Component<{ userIds: string[] }> = (props) => {
- const count = () => props.userIds.length;
- return (
- <div class="flex items-center gap-1.5 min-w-0">
- <UserGroup
- userIds={props.userIds}
- size="sm"
- suppressClick
- showTooltip
- maxUsers={2}
- />
- <span class="truncate">
- {count() === 2 ? '2 people' : `${count()} people`}
- </span>
- </div>
- );
-};
-
-const InlineEntityValue: Component<{ property: Property }> = (props) => {
- const context = usePropertiesContext();
-
- const isReadOnly = () => props.property.isMetadata || !context.canEdit;
-
- const handleClick = (e: MouseEvent) => {
- e.stopPropagation();
- if (isReadOnly()) return;
- context.openPropertyEditor(props.property, e.currentTarget as HTMLElement);
- };
-
- const entities = () => getEntityValues(props.property);
- const isUser = () => props.property.specificEntityType === 'USER';
- const hasValues = () => entities().length > 0;
- const isSingleUser = () => isUser() && entities().length === 1;
-
- return (
- <Layer depth={2}>
- <HoverCard content={<PropertyTooltip property={props.property} />}>
- <button
- type="button"
- onClick={handleClick}
- class={cn(buttonClass(isReadOnly()), {
- 'text-ink-extra-muted/50': !hasValues(),
- })}
- >
- <Show
- when={hasValues()}
- fallback={
- <>
- <CircleDashedEmpty class="size-3 shrink-0" />
- <span class="truncate">None</span>
- </>
- }
+ <Property.Root
+ property={props.property}
+ canEdit={ctx.canEdit}
+ onEdit={ctx.openPropertyEditor}
+ >
+ <Property.Tooltip property={props.property}>
+ <Layer depth={2}>
+ <Property.EditTrigger
+ class={cn(
+ 'inline-flex items-center gap-1.5 min-w-0 ring ring-edge-muted',
+ 'px-2 py-1 leading-tight text-left rounded-full',
+ 'bg-surface',
+ {
+ 'hover:bg-hover': !isReadOnly(),
+ 'text-ink-extra-muted/50': isEmpty(),
+ }
+ )}
>
- <Show
- when={isUser()}
+ <Switch
fallback={
- <span class="truncate">
- {entities().length === 1
- ? '1 item'
- : `${entities().length} items`}
- </span>
+ <Property.Icon
+ property={props.property}
+ class="size-3 shrink-0"
+ />
}
>
- {/* Single user: show icon + first name */}
- <Show
- when={isSingleUser()}
- fallback={
- <MultiUserValue
- userIds={entities().map((e) => e.entity_id)}
- />
- }
- >
- <SingleUserValue userId={entities()[0].entity_id} />
- </Show>
- </Show>
- </Show>
- <Show when={!isReadOnly()}>
- <CaretDownIcon class="size-3 shrink-0" />
- </Show>
- </button>
- </HoverCard>
- </Layer>
+ <Match when={isMultiUserEntity()}>
+ <Property.UserStack property={props.property} maxUsers={2} />
+ </Match>
+ <Match when={isUserEntity()}>
+ <Property.Icon property={props.property} />
+ </Match>
+ </Switch>
+ <Property.Text
+ property={props.property}
+ fallback={<Property.Empty label="None" />}
+ />
+ <Property.Caret />
+ </Property.EditTrigger>
+ </Layer>
+ </Property.Tooltip>
+ </Property.Root>
);
};
diff --git a/js/app/packages/block-md/component/InlineTaskProperties.tsx b/js/app/packages/block-md/component/InlineTaskProperties.tsx
index de0ad8175f..c2b68db647 100644
--- a/js/app/packages/block-md/component/InlineTaskProperties.tsx
+++ b/js/app/packages/block-md/component/InlineTaskProperties.tsx
@@ -1,5 +1,9 @@
-import { useSidePanel } from '@app/component/side-panel';
-import { useBlockAliasedName, useBlockId } from '@core/block';
+import {
+ type BlockAlias,
+ type BlockName,
+ useBlockAliasedName,
+ useBlockId,
+} from '@core/block';
import { Modals } from '@core/component/Properties/component/modal';
import { SYSTEM_PROPERTY_IDS } from '@core/component/Properties/constants';
import {
@@ -14,7 +18,9 @@ import type {
import { useCanEdit } from '@core/signal/permissions';
import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';
+import type { EntityType } from '@service-properties/generated/schemas/entityType';
import { createMemo, For, Show, Suspense } from 'solid-js';
+import { match } from 'ts-pattern';
import { InlinePropertyValue } from './InlinePropertyValue';
/**
@@ -24,26 +30,18 @@ import { InlinePropertyValue } from './InlinePropertyValue';
export function InlineTaskProperties() {
const blockId = useBlockId();
const blockName = useBlockAliasedName();
- const sidePanel = useSidePanel();
const canEdit = useCanEdit();
const documentName = useBlockDocumentName();
+ const entityType = match<BlockName | BlockAlias, EntityType>(blockName)
+ .with('task', () => 'TASK')
+ .otherwise(() => 'DOCUMENT');
- const isTask = () => blockName === 'task';
-
- // Only show when side panel is closed or doesn't exist
- const shouldShow = () => {
- if (!isTask()) return false;
- // If no side panel context, show properties inline
- if (!sidePanel) return true;
- // In narrow mode, always show (side panel is an overlay)
- if (sidePanel.isNarrow()) return true;
- // In wide mode, show when panel is closed
- return !sidePanel.isOpen();
- };
-
- const { properties, refetch } = useEntityProperties(blockId, 'TASK', false);
+ const { properties, refetch } = useEntityProperties(
+ blockId,
+ entityType,
+ false
+ );
- // Get the three main properties we want to display
const inlineProperties = createMemo(() => {
const props = properties();
const ids = [
@@ -60,9 +58,7 @@ export function InlineTaskProperties() {
const saveOne = (property: Property, apiValues: PropertyApiValues) =>
saveMutation.mutateAsync({
- properties: [
- { entityId: blockId, entityType: 'TASK', property, apiValues },
- ],
+ properties: [{ entityId: blockId, entityType, property, apiValues }],
});
const saveHandler: PropertySaveHandler = {
@@ -72,28 +68,26 @@ export function InlineTaskProperties() {
};
return (
- <Show when={shouldShow()}>
- <Suspense>
- <Show when={inlineProperties().length > 0}>
- <PropertiesProvider
- entityType="TASK"
- canEdit={canEdit()}
- documentName={documentName()}
- properties={inlineProperties}
- onRefresh={refetch}
- onPropertyAdded={refetch}
- onPropertyDeleted={refetch}
- saveHandler={saveHandler}
- >
- <div class="flex flex-row flex-wrap items-center gap-1 text-base mb-6">
- <For each={inlineProperties()}>
- {(property) => <InlinePropertyValue property={property} />}
- </For>
- </div>
- <Modals />
- </PropertiesProvider>
- </Show>
- </Suspense>
- </Show>
+ <Suspense>
+ <Show when={inlineProperties().length > 0}>
+ <PropertiesProvider
+ entityType={entityType}
+ canEdit={canEdit()}
+ documentName={documentName()}
+ properties={inlineProperties}
+ onRefresh={refetch}
+ onPropertyAdded={refetch}
+ onPropertyDeleted={refetch}
+ saveHandler={saveHandler}
+ >
+ <div class="flex flex-row flex-wrap items-center gap-1 text-base mb-6">
+ <For each={inlineProperties()}>
+ {(property) => <InlinePropertyValue property={property} />}
+ </For>
+ </div>
+ <Modals />
+ </PropertiesProvider>
+ </Show>
+ </Suspense>
);
}
diff --git a/js/app/packages/core/component/DocumentPreview.tsx b/js/app/packages/core/component/DocumentPreview.tsx
index 48d6efddb4..daff0f44bb 100644
--- a/js/app/packages/core/component/DocumentPreview.tsx
+++ b/js/app/packages/core/component/DocumentPreview.tsx
@@ -13,7 +13,6 @@ import { EntityIcon } from '@core/component/EntityIcon';
import { isBlockNameWithLocation } from '@core/component/LexicalMarkdown/component/core/BlockLink';
import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { channelTheme } from '@core/component/LexicalMarkdown/theme';
-import { PropertyValue } from '@core/component/Properties/component/propertyValue/PropertyValue';
import { SYSTEM_PROPERTY_IDS } from '@core/component/Properties/constants';
import { useEntityProperties } from '@core/component/Properties/hooks';
import { toast } from '@core/component/Toast/Toast';
@@ -38,6 +37,8 @@ import SparkleIcon from '@icon/sparkle.svg';
import LoadingSpinner from '@icon/spinner.svg';
import TrashSimple from '@icon/trash-simple.svg';
import MacroEmbed from '@macro-icons/macro-embed.svg';
+import { Property } from '@property';
+import { getEntityValues, hasValue } from '@property/utils';
import {
isAccessiblePreviewItem,
isChannelPreviewItem,
@@ -389,7 +390,7 @@ export function TaskPropertiesPreview(props: { taskId: string }) {
const previewProperties = createMemo(() =>
TASK_PREVIEW_PROPERTIES.flatMap((id) => {
const p = properties().find((p) => p.propertyDefinitionId === id);
- return p ? [p] : [];
+ return p && hasValue(p) ? [p] : [];
})
);
@@ -397,19 +398,50 @@ export function TaskPropertiesPreview(props: { taskId: string }) {
<Show when={!isLoading() && previewProperties().length > 0}>
<div class="px-2 pb-2 flex flex-row flex-wrap gap-1 text-xs justify-start">
<For each={previewProperties()}>
- {(property) => (
- <Show when={property.value !== null}>
- <div class="w-fit max-w-full">
- <PropertyValue property={property} />
- </div>
- </Show>
- )}
+ {(property) => <PreviewPropertyPill property={property} />}
</For>
</div>
</Show>
);
}
+/**
+ * Compact read-only pill for the document preview popup. The popup itself is
+ * already a tooltip-like surface, so there's no edit trigger or hover-card.
+ */
+function PreviewPropertyPill(props: {
+ property: import('@core/component/Properties/types').Property;
+}) {
+ const isMultiUser = () =>
+ props.property.valueType === 'ENTITY' &&
+ props.property.specificEntityType === 'USER' &&
+ getEntityValues(props.property).length > 1;
+
+ const isUserEntity = () =>
+ props.property.valueType === 'ENTITY' &&
+ props.property.specificEntityType === 'USER';
+
+ return (
+ <Property.Root property={props.property}>
+ <div class="inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm bg-hover">
+ <Switch
+ fallback={
+ <Property.Icon property={props.property} class="size-3 shrink-0" />
+ }
+ >
+ <Match when={isMultiUser()}>
+ <Property.UserStack property={props.property} maxUsers={2} />
+ </Match>
+ <Match when={isUserEntity()}>
+ <Property.Icon property={props.property} />
+ </Match>
+ </Switch>
+ <Property.Text property={props.property} class="truncate" />
+ </div>
+ </Property.Root>
+ );
+}
+
export function PopupPreview(props: {
mouseEnter: () => void;
mouseLeave: () => void;
diff --git a/js/app/packages/property/README.md b/js/app/packages/property/README.md
new file mode 100644
index 0000000000..99fd3b71a9
--- /dev/null
+++ b/js/app/packages/property/README.md
@@ -0,0 +1,10 @@
+# Property
+
+Composable property component library for Macro.
+
+Mirrors `@app/packages/entity`: small extractors (`Property.Icon`, `Property.Text`,
+`Property.Chips`, ...) compose under a `Property.Root` to render property values
+in any layout, replacing the duplicated `PropertyValue` / `CondensedPropertyValue`
+/ `InlinePropertyValue` / `ListPropertyValue` trees.
+
+Debug page: `/props-debug` (LOCAL_ONLY).
diff --git a/js/app/packages/property/mocks/mockProperties.ts b/js/app/packages/property/mocks/mockProperties.ts
new file mode 100644
index 0000000000..5f545d4cab
--- /dev/null
+++ b/js/app/packages/property/mocks/mockProperties.ts
@@ -0,0 +1,273 @@
+import {
+ PROPERTY_OPTION_IDS,
+ SYSTEM_PROPERTY_IDS,
+} from '@core/component/Properties/constants';
+import type {
+ Property,
+ PropertyOption,
+} from '@core/component/Properties/types';
+
+const EPOCH = new Date(0).toISOString();
+const now = new Date();
+
+const systemOwner = { scope: 'system' } as const;
+const userOwner = {
+ scope: 'user',
+ user_id: 'macro|[email protected]',
+} as const;
+
+const statusOptions: PropertyOption[] = [
+ {
+ id: PROPERTY_OPTION_IDS.STATUS.NOT_STARTED,
+ property_definition_id: SYSTEM_PROPERTY_IDS.STATUS,
+ value: { type: 'string', value: 'Not started' },
+ display_order: 0,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+ {
+ id: PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS,
+ property_definition_id: SYSTEM_PROPERTY_IDS.STATUS,
+ value: { type: 'string', value: 'In progress' },
+ display_order: 1,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+ {
+ id: PROPERTY_OPTION_IDS.STATUS.IN_REVIEW,
+ property_definition_id: SYSTEM_PROPERTY_IDS.STATUS,
+ value: { type: 'string', value: 'In review' },
+ display_order: 2,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+ {
+ id: PROPERTY_OPTION_IDS.STATUS.COMPLETED,
+ property_definition_id: SYSTEM_PROPERTY_IDS.STATUS,
+ value: { type: 'string', value: 'Completed' },
+ display_order: 3,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+];
+
+const priorityOptions: PropertyOption[] = [
+ {
+ id: PROPERTY_OPTION_IDS.PRIORITY.LOW,
+ property_definition_id: SYSTEM_PROPERTY_IDS.PRIORITY,
+ value: { type: 'string', value: 'Low' },
+ display_order: 0,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+ {
+ id: PROPERTY_OPTION_IDS.PRIORITY.MEDIUM,
+ property_definition_id: SYSTEM_PROPERTY_IDS.PRIORITY,
+ value: { type: 'string', value: 'Medium' },
+ display_order: 1,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+ {
+ id: PROPERTY_OPTION_IDS.PRIORITY.HIGH,
+ property_definition_id: SYSTEM_PROPERTY_IDS.PRIORITY,
+ value: { type: 'string', value: 'High' },
+ display_order: 2,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+ {
+ id: PROPERTY_OPTION_IDS.PRIORITY.URGENT,
+ property_definition_id: SYSTEM_PROPERTY_IDS.PRIORITY,
+ value: { type: 'string', value: 'Urgent' },
+ display_order: 3,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+];
+
+const MOCK_USER_IDS = [
+] as const;
+
+const base = {
+ isMultiSelect: false,
+ owner: userOwner,
+ createdAt: now,
+ updatedAt: now,
+} as const;
+
+/**
+ * One property per valueType, each populated with a representative value.
+ */
+export const PROPERTIES_FILLED: Property[] = [
+ {
+ ...base,
+ propertyId: 'mock-status',
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.STATUS,
+ displayName: 'Status',
+ owner: systemOwner,
+ isSystemProperty: true,
+ isRequired: true,
+ options: statusOptions,
+ valueType: 'SELECT_STRING',
+ value: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],
+ },
+ {
+ ...base,
+ propertyId: 'mock-priority',
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PRIORITY,
+ displayName: 'Priority',
+ owner: systemOwner,
+ isSystemProperty: true,
+ options: priorityOptions,
+ valueType: 'SELECT_STRING',
+ value: [PROPERTY_OPTION_IDS.PRIORITY.HIGH],
+ },
+ {
+ ...base,
+ propertyId: 'mock-assignees',
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.ASSIGNEES,
+ displayName: 'Assignees',
+ owner: systemOwner,
+ isSystemProperty: true,
+ isMultiSelect: true,
+ specificEntityType: 'USER',
+ valueType: 'ENTITY',
+ value: [
+ { entity_id: MOCK_USER_IDS[0], entity_type: 'USER' },
+ { entity_id: MOCK_USER_IDS[1], entity_type: 'USER' },
+ ],
+ },
+ {
+ ...base,
+ propertyId: 'mock-single-user',
+ propertyDefinitionId: 'mock-def-single-user',
+ displayName: 'Lead',
+ specificEntityType: 'USER',
+ valueType: 'ENTITY',
+ value: [{ entity_id: MOCK_USER_IDS[0], entity_type: 'USER' }],
+ },
+ {
+ ...base,
+ propertyId: 'mock-string',
+ propertyDefinitionId: 'mock-def-string',
+ displayName: 'Codename',
+ valueType: 'STRING',
+ value: 'project-helios',
+ },
+ {
+ ...base,
+ propertyId: 'mock-number',
+ propertyDefinitionId: 'mock-def-number',
+ displayName: 'Story points',
+ valueType: 'NUMBER',
+ value: 8,
+ },
+ {
+ ...base,
+ propertyId: 'mock-boolean',
+ propertyDefinitionId: 'mock-def-boolean',
+ displayName: 'Blocked',
+ valueType: 'BOOLEAN',
+ value: true,
+ },
+ {
+ ...base,
+ propertyId: 'mock-date',
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.DUE_DATE,
+ displayName: 'Due date',
+ valueType: 'DATE',
+ value: new Date(now.getTime() + 1000 * 60 * 60 * 24 * 3),
+ },
+ {
+ ...base,
+ propertyId: 'mock-select-multi',
+ propertyDefinitionId: 'mock-def-select-multi',
+ displayName: 'Tags',
+ isMultiSelect: true,
+ options: priorityOptions,
+ valueType: 'SELECT_STRING',
+ value: [
+ PROPERTY_OPTION_IDS.PRIORITY.LOW,
+ PROPERTY_OPTION_IDS.PRIORITY.HIGH,
+ ],
+ },
+ {
+ ...base,
+ propertyId: 'mock-select-number',
+ propertyDefinitionId: 'mock-def-select-number',
+ displayName: 'Tier',
+ options: [
+ {
+ id: 'tier-1',
+ property_definition_id: 'mock-def-select-number',
+ value: { type: 'number', value: 1 },
+ display_order: 0,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+ {
+ id: 'tier-2',
+ property_definition_id: 'mock-def-select-number',
+ value: { type: 'number', value: 2 },
+ display_order: 1,
+ created_at: EPOCH,
+ updated_at: EPOCH,
+ },
+ ],
+ valueType: 'SELECT_NUMBER',
+ value: ['tier-2'],
+ },
+ {
+ ...base,
+ propertyId: 'mock-entity-docs',
+ propertyDefinitionId: 'mock-def-entity-docs',
+ displayName: 'Related docs',
+ isMultiSelect: true,
+ specificEntityType: 'DOCUMENT',
+ valueType: 'ENTITY',
+ value: [
+ { entity_id: 'doc-1', entity_type: 'DOCUMENT' },
+ { entity_id: 'doc-2', entity_type: 'DOCUMENT' },
+ { entity_id: 'doc-3', entity_type: 'DOCUMENT' },
+ ],
+ },
+ {
+ ...base,
+ propertyId: 'mock-link',
+ propertyDefinitionId: 'mock-def-link',
+ displayName: 'Links',
+ isMultiSelect: true,
+ valueType: 'LINK',
+ value: ['https://macro.com', 'https://github.com'],
+ },
+];
+
+/**
+ * Empty-state variants — same definitions, value=null.
+ */
+export const PROPERTIES_EMPTY: Property[] = PROPERTIES_FILLED.map((p) =>
+ withClearedValue(p, `${p.propertyId}-empty`)
+);
+
+/**
+ * Read-only variants — canEdit=false should hide affordances; this just
+ * marks them as metadata so the readOnly path is exercised too.
+ */
+export const PROPERTIES_METADATA: Property[] = PROPERTIES_FILLED.map((p) => ({
+ ...p,
+ propertyId: `${p.propertyId}-metadata`,
+ isMetadata: true,
+}));
+
+function withClearedValue(p: Property, id: string): Property {
+ const next = { ...p, propertyId: id };
+ if (next.valueType === 'STRING') return { ...next, value: null };
+ if (next.valueType === 'NUMBER') return { ...next, value: null };
+ if (next.valueType === 'BOOLEAN') return { ...next, value: null };
+ if (next.valueType === 'DATE') return { ...next, value: null };
+ return { ...next, value: null };
+}
diff --git a/js/app/packages/property/src/constants.ts b/js/app/packages/property/src/constants.ts
new file mode 100644
index 0000000000..a85aadc94a
--- /dev/null
+++ b/js/app/packages/property/src/constants.ts
@@ -0,0 +1,13 @@
+// Re-export business-logic constants from @core/component/Properties.
+
+export {
+ BUILTIN_PROPERTIES_BY_BLOCK,
+ DEFAULT_PINNED_PROPERTIES_BY_BLOCK,
+ FOCUS_CONFIG,
+ getBuiltinPropertyIds,
+ getDefaultPinnedProperties,
+ MODAL_DIMENSIONS,
+ NUMBER_DECIMAL_PLACES,
+ PROPERTY_OPTION_IDS,
+ SYSTEM_PROPERTY_IDS,
+} from '@core/component/Properties/constants';
diff --git a/js/app/packages/property/src/core/Layout.tsx b/js/app/packages/property/src/core/Layout.tsx
new file mode 100644
index 0000000000..76f6617f69
--- /dev/null
+++ b/js/app/packages/property/src/core/Layout.tsx
@@ -0,0 +1,12 @@
+import { cn } from '@ui';
+import { type JSX, splitProps } from 'solid-js';
+
+export function Layout(props: JSX.HTMLAttributes<HTMLDivElement>) {
+ const [local, rest] = splitProps(props, ['class', 'children']);
+
+ return (
+ <div class={cn(local.class)} {...rest}>
+ {local.children}
+ </div>
+ );
+}
diff --git a/js/app/packages/property/src/core/Root.tsx b/js/app/packages/property/src/core/Root.tsx
new file mode 100644
index 0000000000..cf5c441c62
--- /dev/null
+++ b/js/app/packages/property/src/core/Root.tsx
@@ -0,0 +1,58 @@
+import { cn } from '@ui';
+import { type JSX, splitProps } from 'solid-js';
+import type { Property } from '../types';
+import {
+ type PropertyEditFn,
+ PropertyRootContext,
+ type PropertyRootContextValue,
+ type PropertySaveFn,
+} from './context';
+
+export interface PropertyRootProps
+ extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'onSave' | 'property'> {
+ property: Property;
+ canEdit?: boolean;
+ onSave?: PropertySaveFn;
+ onEdit?: PropertyEditFn;
+ onRefresh?: () => void;
+}
+
+export function Root(props: PropertyRootProps) {
+ const [local, rest] = splitProps(props, [
+ 'property',
+ 'canEdit',
+ 'onSave',
+ 'onEdit',
+ 'onRefresh',
+ 'class',
+ 'children',
+ ]);
+
+ const value: PropertyRootContextValue = {
+ property: () => local.property,
+ canEdit: () => local.canEdit ?? false,
+ get onSave() {
+ return local.onSave;
+ },
+ get onEdit() {
+ return local.onEdit;
+ },
+ get onRefresh() {
+ return local.onRefresh;
+ },
+ };
+
+ return (
+ <PropertyRootContext.Provider value={value}>
+ <div
+ class={cn('property-root', local.class)}
+ data-property
+ data-property-id={local.property.propertyId}
+ data-property-type={local.property.valueType}
+ {...rest}
+ >
+ {local.children}
+ </div>
+ </PropertyRootContext.Provider>
+ );
+}
diff --git a/js/app/packages/property/src/core/Slot.tsx b/js/app/packages/property/src/core/Slot.tsx
new file mode 100644
index 0000000000..6dff873b6c
--- /dev/null
+++ b/js/app/packages/property/src/core/Slot.tsx
@@ -0,0 +1,59 @@
+import { cn } from '@ui';
+import {
+ type ComponentProps,
+ type JSX,
+ splitProps,
+ type ValidComponent,
+} from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+
+type SlotElement = 'div' | 'span' | 'button';
+
+const placeGrid = (
+ area: string | [string, string] | undefined
+): Partial<JSX.CSSProperties> => {
+ if (area === undefined) return {};
+ if (typeof area === 'string') {
+ return { 'grid-area': area };
+ }
+ return {
+ 'grid-column-start': area[0],
+ 'grid-column-end': area[1],
+ };
+};
+
+type CommonProps = {
+ children?: JSX.Element;
+ placement?: string | [string, string];
+ class?: string;
+ style?: JSX.CSSProperties | string;
+};
+
+type SlotProps<T extends ValidComponent = 'div'> = { as?: T } & CommonProps &
+ Omit<ComponentProps<T>, keyof CommonProps | 'component'>;
+
+export function Slot<T extends SlotElement = 'div'>(props: SlotProps<T>) {
+ const [local, rest] = splitProps(props, [
+ 'as',
+ 'class',
+ 'children',
+ 'placement',
+ 'style',
+ ]);
+
+ const gridArea = () => placeGrid(local.placement);
+
+ return (
+ <Dynamic
+ class={cn('property-slot', local.class)}
+ component={local.as ?? ('div' as SlotElement)}
+ style={{
+ ...gridArea(),
+ ...(typeof local.style === 'object' ? local.style : {}),
+ }}
+ {...rest}
+ >
+ {local.children}
+ </Dynamic>
+ );
+}
diff --git a/js/app/packages/property/src/core/context.ts b/js/app/packages/property/src/core/context.ts
new file mode 100644
index 0000000000..36dddac858
--- /dev/null
+++ b/js/app/packages/property/src/core/context.ts
@@ -0,0 +1,31 @@
+import { createContext, useContext } from 'solid-js';
+import type { Property, PropertyApiValues } from '../types';
+
+export type PropertySaveFn = (
+ property: Property,
+ value: PropertyApiValues
+) => Promise<void>;
+
+export type PropertyEditFn = (property: Property, anchor?: HTMLElement) => void;
+
+export interface PropertyRootContextValue {
+ property: () => Property;
+ canEdit: () => boolean;
+ onSave?: PropertySaveFn;
+ onEdit?: PropertyEditFn;
+ onRefresh?: () => void;
+}
+
+export const PropertyRootContext = createContext<PropertyRootContextValue>();
+
+export function useProperty(): PropertyRootContextValue {
+ const ctx = useContext(PropertyRootContext);
+ if (!ctx) {
+ throw new Error('useProperty must be used within <Property.Root>');
+ }
+ return ctx;
+}
+
+export function useMaybeProperty(): PropertyRootContextValue | undefined {
+ return useContext(PropertyRootContext);
+}
diff --git a/js/app/packages/property/src/debug/PropertyDebug.tsx b/js/app/packages/property/src/debug/PropertyDebug.tsx
new file mode 100644
index 0000000000..685bd0583f
--- /dev/null
+++ b/js/app/packages/property/src/debug/PropertyDebug.tsx
@@ -0,0 +1,285 @@
+import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
+import { StaticSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+import { seedMockDisplayNames } from '@core/user';
+import { cn } from '@ui';
+import { type Component, For, type JSX, Show } from 'solid-js';
+import {
+ PROPERTIES_EMPTY,
+ PROPERTIES_FILLED,
+ PROPERTIES_METADATA,
+} from '../../mocks/mockProperties';
+import { Property } from '../property';
+import type { Property as PropertyT } from '../types';
+
+// Seed mock display names so user properties render real first names.
+seedMockDisplayNames([
+ { id: 'macro|[email protected]', firstName: 'Alex', lastName: 'Owner' },
+ { id: 'macro|[email protected]', firstName: 'Sam', lastName: 'Shared' },
+ { id: 'macro|[email protected]', firstName: 'Jordan', lastName: 'Team' },
+ { id: 'macro|[email protected]', firstName: 'Current', lastName: 'User' },
+]);
+
+const Section: Component<{ title: string; children: JSX.Element }> = (
+ props
+) => (
+ <section class="border border-edge-muted rounded p-4 flex flex-col gap-3">
+ <h2 class="text-sm font-mono text-ink-muted">{props.title}</h2>
+ {props.children}
+ </section>
+);
+
+const Cell: Component<{ label: string; children: JSX.Element }> = (props) => (
+ <div class="flex flex-col gap-1 min-w-0">
+ <div class="text-xxs text-ink-extra-muted uppercase tracking-wide">
+ {props.label}
+ </div>
+ <div class="min-w-0">{props.children}</div>
+ </div>
+);
+
+const Grid: Component<{
+ title: string;
+ properties: PropertyT[];
+ children: (p: PropertyT) => JSX.Element;
+}> = (props) => (
+ <div>
+ <div class="text-xs text-ink-muted mb-2">{props.title}</div>
+ <div
+ class="grid gap-3"
+ style={{ 'grid-template-columns': 'repeat(4, minmax(0, 1fr))' }}
+ >
+ <For each={props.properties}>
+ {(p) => (
+ <div class="border border-edge-muted/30 rounded p-2 flex flex-col gap-1 min-w-0">
+ <div class="text-xxs text-ink-extra-muted truncate">
+ {p.displayName} · {p.valueType}
+ </div>
+ <div class="min-w-0">{props.children(p)}</div>
+ </div>
+ )}
+ </For>
+ </div>
+ </div>
+);
+
+const buttonClass = cn(
+ 'inline-flex items-center gap-1 min-w-0',
+ 'px-2 py-1 leading-tight text-left rounded-sm hover:bg-hover'
+);
+
+/**
+ * Debug surface for the @property primitives. Mirrors the entity debug view:
+ * exhaustively renders each extractor and composed assembly against mock
+ * properties with no network. Save handler logs to console and updates local
+ * state so editing affordances are testable.
+ *
+ * Mounted at /props-debug via componentRegistry (LOCAL_ONLY).
+ */
+const PropertyDebug: Component = () => {
+ // For now the demo renders straight from the fixtures. A future enhancement
+ // could make edits round-trip through a local store so save/clear visibly
+ // mutate state.
+ const get = (p: PropertyT) => p;
+
+ const onSave = async (p: PropertyT, value: unknown) => {
+ console.log('[props-debug] save', {
+ property: p.displayName,
+ valueType: p.valueType,
+ value,
+ });
+ // No-op locally: in a real consumer the property accessor would refetch.
+ // For the debug page we just keep the original value so the demo stays
+ // visually stable across clicks.
+ };
+
+ const onEdit = (p: PropertyT) => {
+ console.log('[props-debug] open editor', {
+ property: p.displayName,
+ valueType: p.valueType,
+ });
+ };
+
+ return (
+ <>
+ <SplitHeaderLeft>
+ <StaticSplitLabel label="Property Component Demo" />
+ </SplitHeaderLeft>
+ <div class="size-full overflow-auto p-4 flex flex-col gap-4">
+ <Section title="Primitives — filled (canEdit=true)">
+ <Grid title="Property.Text + fallback" properties={PROPERTIES_FILLED}>
+ {(p) => (
+ <Property.Root
+ property={get(p)}
+ canEdit
+ onSave={onSave}
+ onEdit={onEdit}
+ >
+ <Property.Text
+ property={get(p)}
+ fallback={<Property.Empty label="None" />}
+ />
+ </Property.Root>
+ )}
+ </Grid>
+ <Grid
+ title="Property.Icon + Property.Text"
+ properties={PROPERTIES_FILLED}
+ >
+ {(p) => (
+ <Property.Root
+ property={get(p)}
+ canEdit
+ onSave={onSave}
+ onEdit={onEdit}
+ >
+ <div class="inline-flex items-center gap-1.5 min-w-0">
+ <Property.Icon property={get(p)} class="size-3 shrink-0" />
+ <Property.Text
+ property={get(p)}
+ fallback={<Property.Empty label="None" />}
+ />
+ </div>
+ </Property.Root>
+ )}
+ </Grid>
+ </Section>
+
+ <Section title="Primitives — empty">
+ <Grid
+ title="Property.Text with fallback"
+ properties={PROPERTIES_EMPTY}
+ >
+ {(p) => (
+ <Property.Root
+ property={get(p)}
+ canEdit
+ onSave={onSave}
+ onEdit={onEdit}
+ >
+ <Property.Text
+ property={get(p)}
+ fallback={
+ <Property.Empty
+ label={`Set ${p.displayName.toLowerCase()}`}
+ />
+ }
+ />
+ </Property.Root>
+ )}
+ </Grid>
+ </Section>
+
+ <Section title="Primitives — read-only (isMetadata)">
+ <Grid
+ title="No edit affordances should render"
+ properties={PROPERTIES_METADATA}
+ >
+ {(p) => (
+ <Property.Root
+ property={get(p)}
+ canEdit
+ onSave={onSave}
+ onEdit={onEdit}
+ >
+ <div class="inline-flex items-center gap-1.5">
+ <Property.Icon property={get(p)} class="size-3 shrink-0" />
+ <Property.Text property={get(p)} />
+ <Property.Caret />
+ </div>
+ </Property.Root>
+ )}
+ </Grid>
+ </Section>
+
+ <Section title="Compositions — inline pill (like InlinePropertyValue)">
+ <Grid
+ title="Tooltip + EditTrigger + Icon + Text + Caret"
+ properties={PROPERTIES_FILLED}
+ >
+ {(p) => (
+ <Property.Root
+ property={get(p)}
+ canEdit
+ onSave={onSave}
+ onEdit={onEdit}
+ >
+ <Property.Tooltip property={get(p)}>
+ <Property.EditTrigger class={buttonClass}>
+ <Property.Icon property={get(p)} class="size-3 shrink-0" />
+ <Property.Text
+ property={get(p)}
+ fallback={<Property.Empty label="None" />}
+ />
+ <Property.Caret />
+ </Property.EditTrigger>
+ </Property.Tooltip>
+ </Property.Root>
+ )}
+ </Grid>
+ </Section>
+
+ <Section title="Compositions — user stack (ENTITY+USER)">
+ <Cell label="Single & multi users">
+ <div class="flex gap-4">
+ <For
+ each={PROPERTIES_FILLED.filter(
+ (p) =>
+ p.valueType === 'ENTITY' && p.specificEntityType === 'USER'
+ )}
+ >
+ {(p) => (
+ <Property.Root
+ property={get(p)}
+ canEdit
+ onSave={onSave}
+ onEdit={onEdit}
+ >
+ <div class="inline-flex items-center gap-2">
+ <Property.UserStack property={get(p)} maxUsers={2} />
+ <Property.Text property={get(p)} />
+ </div>
+ </Property.Root>
+ )}
+ </For>
+ </div>
+ </Cell>
+ </Section>
+
+ <Section title="Compositions — chips (multi-select / non-user entity / link)">
+ <For
+ each={PROPERTIES_FILLED.filter(
+ (p) =>
+ (p.valueType === 'SELECT_STRING' && p.isMultiSelect) ||
+ p.valueType === 'LINK' ||
+ (p.valueType === 'ENTITY' && p.specificEntityType !== 'USER')
+ )}
+ >
+ {(p) => (
+ <Cell label={`${p.displayName} · ${p.valueType}`}>
+ <Property.Root
+ property={get(p)}
+ canEdit
+ onSave={onSave}
+ onEdit={onEdit}
+ >
+ <Property.Chips property={get(p)} />
+ </Property.Root>
+ </Cell>
+ )}
+ </For>
+ </Section>
+
+ <Section title="Composed (stubs — coming in PR 3-6)">
+ <Show when={true} fallback={null}>
+ <div class="text-xs text-ink-muted">
+ CondensedProperty / InlineProperty / ListProperty / PanelRow will
+ land here as their corresponding migration PRs go in.
+ </div>
+ </Show>
+ </Section>
+ </div>
+ </>
+ );
+};
+
+export default PropertyDebug;
diff --git a/js/app/packages/property/src/extractors/PropertyAddButton.tsx b/js/app/packages/property/src/extractors/PropertyAddButton.tsx
new file mode 100644
index 0000000000..21615d8834
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyAddButton.tsx
@@ -0,0 +1,39 @@
+import { cn } from '@ui';
+import { useProperty } from '../core/context';
+
+type Props = {
+ class?: string;
+};
+
+/**
+ * `+` button for adding values to multi-value properties. Opens the editor
+ * anchored to itself.
+ *
+ * Must be inside <Property.Root>.
+ */
+export function PropertyAddButton(props: Props) {
+ const ctx = useProperty();
+ const isReadOnly = () => !ctx.canEdit() || ctx.property().isMetadata;
+
+ const handleClick = (
+ e: MouseEvent & { currentTarget: HTMLButtonElement }
+ ) => {
+ e.stopPropagation();
+ if (isReadOnly()) return;
+ ctx.onEdit?.(ctx.property(), e.currentTarget);
+ };
+
+ return (
+ <button
+ type="button"
+ onClick={handleClick}
+ disabled={isReadOnly()}
+ class={cn(
+ 'text-ink-muted hover:text-ink hover:bg-hover px-2 py-0.5 inline-block shrink-0 rounded-sm cursor-default',
+ props.class
+ )}
+ >
+ +
+ </button>
+ );
+}
diff --git a/js/app/packages/property/src/extractors/PropertyCaret.tsx b/js/app/packages/property/src/extractors/PropertyCaret.tsx
new file mode 100644
index 0000000000..d13422f601
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyCaret.tsx
@@ -0,0 +1,23 @@
+import CaretDownIcon from '@icon/caret-down.svg';
+import { cn } from '@ui';
+import { Show } from 'solid-js';
+import { useProperty } from '../core/context';
+
+type Props = {
+ class?: string;
+};
+
+/**
+ * Caret-down affordance — hidden when the property is read-only.
+ * Must be inside <Property.Root>.
+ */
+export function PropertyCaret(props: Props) {
+ const ctx = useProperty();
+ const isReadOnly = () => !ctx.canEdit() || ctx.property().isMetadata;
+
+ return (
+ <Show when={!isReadOnly()}>
+ <CaretDownIcon class={cn('size-3 shrink-0', props.class)} />
+ </Show>
+ );
+}
diff --git a/js/app/packages/property/src/extractors/PropertyChips.tsx b/js/app/packages/property/src/extractors/PropertyChips.tsx
new file mode 100644
index 0000000000..8356fb44d5
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyChips.tsx
@@ -0,0 +1,74 @@
+import { cn } from '@ui';
+import { type Component, For, type JSX, Show } from 'solid-js';
+import type { Property } from '../types';
+import {
+ formatPropertyValue,
+ getEntityValues,
+ getLinkValues,
+ getSelectValues,
+ isEntityProperty,
+ isLinkProperty,
+ isSelectProperty,
+} from '../utils';
+import { PropertyIcon } from './PropertyIcon';
+
+type Props = {
+ property: Property;
+ class?: string;
+ /** Render-prop for each chip. Defaults to a simple label-only chip. */
+ renderChip?: (chip: ChipInfo) => JSX.Element;
+};
+
+export type ChipInfo = {
+ /** Stable identifier for the chip (option ID, entity ID, URL, etc.). */
+ key: string;
+ /** Human-readable label. */
+ label: string;
+};
+
+/**
+ * Renders a property's values as a chip list — for SELECT_* multi, ENTITY
+ * (non-user), LINK. Caller controls the chip appearance via `renderChip`.
+ *
+ * For single-value properties returns null (use <PropertyText /> instead).
+ */
+export const PropertyChips: Component<Props> = (props) => {
+ const chips = (): ChipInfo[] => {
+ if (isSelectProperty(props.property)) {
+ return getSelectValues(props.property).map((id) => ({
+ key: id,
+ label: formatPropertyValue(props.property, id),
+ }));
+ }
+ if (isEntityProperty(props.property)) {
+ return getEntityValues(props.property).map((ref) => ({
+ key: `${ref.entity_type}:${ref.entity_id}`,
+ label: ref.entity_id,
+ }));
+ }
+ if (isLinkProperty(props.property)) {
+ return getLinkValues(props.property).map((url) => ({
+ key: url,
+ label: url,
+ }));
+ }
+ return [];
+ };
+
+ const renderChip =
+ props.renderChip ??
+ ((chip: ChipInfo) => (
+ <span class="inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-sm bg-hover">
+ <Show when={isSelectProperty(props.property)}>
+ <PropertyIcon property={props.property} class="size-3 shrink-0" />
+ </Show>
+ <span class="truncate">{chip.label}</span>
+ </span>
+ ));
+
+ return (
+ <div class={cn('flex flex-wrap gap-1', props.class)}>
+ <For each={chips()}>{(chip) => renderChip(chip)}</For>
+ </div>
+ );
+};
diff --git a/js/app/packages/property/src/extractors/PropertyEditTrigger.tsx b/js/app/packages/property/src/extractors/PropertyEditTrigger.tsx
new file mode 100644
index 0000000000..cbbc57ae72
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyEditTrigger.tsx
@@ -0,0 +1,51 @@
+import { cn } from '@ui';
+import { type JSX, splitProps } from 'solid-js';
+import { useProperty } from '../core/context';
+
+type ButtonClickHandler = JSX.EventHandler<HTMLButtonElement, MouseEvent>;
+
+type Props = Omit<
+ JSX.ButtonHTMLAttributes<HTMLButtonElement>,
+ 'type' | 'disabled' | 'onClick'
+> & {
+ onClick?: ButtonClickHandler;
+ stopPropagation?: boolean;
+};
+
+/**
+ * Wraps children in a button that opens the property editor on click.
+ * - Disabled when canEdit=false or property.isMetadata.
+ * - Stops propagation by default (pills usually nest inside clickable rows).
+ * - Anchors the editor to itself via onEdit(property, anchor).
+ *
+ * Must be inside <Property.Root>.
+ */
+export function PropertyEditTrigger(props: Props) {
+ const ctx = useProperty();
+ const [local, rest] = splitProps(props, [
+ 'class',
+ 'children',
+ 'onClick',
+ 'stopPropagation',
+ ]);
+
+ const isReadOnly = () => !ctx.canEdit() || ctx.property().isMetadata;
+
+ const handleClick: ButtonClickHandler = (e) => {
+ if (local.stopPropagation !== false) e.stopPropagation();
+ if (isReadOnly()) return;
+ ctx.onEdit?.(ctx.property(), e.currentTarget);
+ if (typeof local.onClick === 'function') local.onClick(e);
+ };
+
+ return (
+ <button
+ type="button"
+ onClick={handleClick}
+ class={cn('cursor-default', local.class)}
+ {...rest}
+ >
+ {local.children}
+ </button>
+ );
+}
diff --git a/js/app/packages/property/src/extractors/PropertyEmpty.tsx b/js/app/packages/property/src/extractors/PropertyEmpty.tsx
new file mode 100644
index 0000000000..17aaf7c6c6
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyEmpty.tsx
@@ -0,0 +1,30 @@
+import CircleDashedEmpty from '@icon/circle-dashed.svg';
+import { cn } from '@ui';
+import type { JSX } from 'solid-js';
+import { Show } from 'solid-js';
+
+type Props = {
+ /** Text to render after the empty icon (e.g. "None", "Set status"). */
+ label?: JSX.Element;
+ /** Hide the dashed-circle icon (text-only empty state). */
+ hideIcon?: boolean;
+ class?: string;
+};
+
+/**
+ * Standard empty-value affordance — dashed circle + optional label.
+ */
+export function PropertyEmpty(props: Props) {
+ return (
+ <span
+ class={cn('inline-flex items-center gap-1.5 opacity-50', props.class)}
+ >
+ <Show when={!props.hideIcon}>
+ <CircleDashedEmpty class="size-3 shrink-0" />
+ </Show>
+ <Show when={props.label}>
+ <span class="truncate">{props.label}</span>
+ </Show>
+ </span>
+ );
+}
diff --git a/js/app/packages/property/src/extractors/PropertyIcon.tsx b/js/app/packages/property/src/extractors/PropertyIcon.tsx
new file mode 100644
index 0000000000..6f913d576c
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyIcon.tsx
@@ -0,0 +1,49 @@
+import { PropertyValueIcon } from '@core/component/Properties/component/propertyValue/PropertyValueIcon';
+import { UserIcon } from '@core/component/UserIcon';
+import { cn } from '@ui';
+import { type JSX, Show } from 'solid-js';
+import type { Property } from '../types';
+import { getEntityValues, getSelectValues } from '../utils';
+
+type Props = {
+ property: Property;
+ class?: string;
+};
+
+/**
+ * Renders the icon associated with a property's value:
+ * - SELECT_*: option icon for the first value (status/priority icons).
+ * - ENTITY+USER: avatar for the first user.
+ * - everything else: null (extractor stays uninvolved).
+ *
+ * Layout-free — caller controls sizing/spacing.
+ */
+export function PropertyIcon(props: Props): JSX.Element {
+ if (
+ props.property.valueType === 'SELECT_STRING' ||
+ props.property.valueType === 'SELECT_NUMBER'
+ ) {
+ const optionId = () => getSelectValues(props.property)[0];
+ return (
+ <Show when={optionId()}>
+ {(id) => <PropertyValueIcon optionId={id()} class={props.class} />}
+ </Show>
+ );
+ }
+
+ if (
+ props.property.valueType === 'ENTITY' &&
+ props.property.specificEntityType === 'USER'
+ ) {
+ const userId = () => getEntityValues(props.property)[0]?.entity_id;
+ return (
+ <Show when={userId()}>
+ {(id) => (
+ <UserIcon id={id()} size="sm" suppressClick class={cn(props.class)} />
+ )}
+ </Show>
+ );
+ }
+
+ return null;
+}
diff --git a/js/app/packages/property/src/extractors/PropertyLabel.tsx b/js/app/packages/property/src/extractors/PropertyLabel.tsx
new file mode 100644
index 0000000000..a83ea9b018
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyLabel.tsx
@@ -0,0 +1,18 @@
+import { cn } from '@ui';
+import type { Property } from '../types';
+
+type Props = {
+ property: Property;
+ class?: string;
+};
+
+/**
+ * Renders the property's display name — no styling beyond truncate.
+ */
+export function PropertyLabel(props: Props) {
+ return (
+ <span class={cn('truncate', props.class)}>
+ {props.property.displayName}
+ </span>
+ );
+}
diff --git a/js/app/packages/property/src/extractors/PropertyRemoveButton.tsx b/js/app/packages/property/src/extractors/PropertyRemoveButton.tsx
new file mode 100644
index 0000000000..7a5785bf78
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyRemoveButton.tsx
@@ -0,0 +1,85 @@
+import DeleteIcon from '@icon/x.svg';
+import { cn } from '@ui';
+import { createSignal } from 'solid-js';
+import { useProperty } from '../core/context';
+import type { Property } from '../types';
+import { hasValue, toPropertyApiValue } from '../utils';
+
+type Props = {
+ /**
+ * Optional specific value to remove (multi-value properties). If omitted,
+ * clears the entire property.
+ */
+ valueToRemove?: string;
+ class?: string;
+ disabled?: boolean;
+};
+
+/**
+ * Small X button that clears a property value (or removes one item from a
+ * multi-value property). Disabled when read-only or already saving.
+ *
+ * Must be inside <Property.Root>.
+ */
+export function PropertyRemoveButton(props: Props) {
+ const ctx = useProperty();
+ const [isSaving, setIsSaving] = createSignal(false);
+
+ const isReadOnly = () =>
+ !ctx.canEdit() || ctx.property().isMetadata || !hasValue(ctx.property());
+
+ const handleClick = async (e: MouseEvent) => {
+ e.stopPropagation();
+ if (isReadOnly() || isSaving() || props.disabled) return;
+ const property = ctx.property();
+ const save = ctx.onSave;
+ if (!save) return;
+ setIsSaving(true);
+ try {
+ const next = nextValue(property, props.valueToRemove);
+ if (next) await save(property, next);
+ ctx.onRefresh?.();
+ } finally {
+ setIsSaving(false);
+ }
+ };
+
+ return (
+ <button
+ type="button"
+ onClick={handleClick}
+ disabled={isSaving() || props.disabled || isReadOnly()}
+ class={cn(
+ 'size-4 p-0.5 flex items-center justify-center text-ink-muted hover:text-failure-ink rounded-sm',
+ props.class
+ )}
+ >
+ <DeleteIcon class="size-3" />
+ </button>
+ );
+}
+
+function nextValue(property: Property, removeValue?: string) {
+ if (
+ removeValue !== undefined &&
+ (property.valueType === 'SELECT_STRING' ||
+ property.valueType === 'SELECT_NUMBER' ||
+ property.valueType === 'LINK')
+ ) {
+ const remaining = (property.value ?? []).filter((v) => v !== removeValue);
+ return {
+ valueType: property.valueType,
+ values: remaining.length > 0 ? remaining : null,
+ } as ReturnType<typeof toPropertyApiValue>;
+ }
+ if (removeValue !== undefined && property.valueType === 'ENTITY') {
+ const remaining = (property.value ?? []).filter(
+ (ref) => ref.entity_id !== removeValue
+ );
+ return {
+ valueType: 'ENTITY' as const,
+ refs: remaining.length > 0 ? remaining : null,
+ };
+ }
+ return toPropertyApiValue(property, null);
+}
diff --git a/js/app/packages/property/src/extractors/PropertyText.tsx b/js/app/packages/property/src/extractors/PropertyText.tsx
new file mode 100644
index 0000000000..8118c11f12
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyText.tsx
@@ -0,0 +1,93 @@
+import { tryMacroId, useDisplayNameParts } from '@core/user';
+import { cn } from '@ui';
+import { type JSX, Show } from 'solid-js';
+import type { Property } from '../types';
+import {
+ formatBoolean,
+ formatDate,
+ formatNumber,
+ formatPropertyValue,
+ getEntityValues,
+ getLinkValues,
+ getSelectValues,
+ hasValue,
+ isBooleanProperty,
+ isDateProperty,
+ isEntityProperty,
+ isLinkProperty,
+ isNumberProperty,
+ isSelectProperty,
+ isStringProperty,
+} from '../utils';
+
+type Props = {
+ property: Property;
+ /** Rendered when the property has no value. */
+ fallback?: JSX.Element;
+ class?: string;
+ /** Override the rendered text (overrides default extraction). */
+ text?: string;
+};
+
+/**
+ * Renders a property's value as text (single-line, truncate-friendly).
+ *
+ * Routes by valueType to produce the right representation:
+ * - STRING: raw value
+ * - NUMBER: formatted number
+ * - BOOLEAN: "True"/"False"
+ * - DATE: formatted date
+ * - SELECT_*: first option's display label
+ * - ENTITY+USER (single): user's first name
+ * - ENTITY+USER (multi): "N people"
+ * - ENTITY (non-user): "1 item" / "N items"
+ * - LINK: first URL
+ *
+ * Caller is responsible for any container/border/padding.
+ */
+export function PropertyText(props: Props) {
+ const text = () => props.text ?? extractText(props.property);
+ const empty = () => !text();
+
+ return (
+ <Show when={!empty()} fallback={props.fallback ?? null}>
+ <span class={cn('truncate', props.class)}>{text()}</span>
+ </Show>
+ );
+}
+
+function extractText(property: Property): string {
+ if (!hasValue(property)) return '';
+
+ if (isStringProperty(property)) return property.value ?? '';
+ if (isNumberProperty(property))
+ return property.value === null ? '' : formatNumber(property.value);
+ if (isBooleanProperty(property))
+ return property.value === null ? '' : formatBoolean(property.value);
+ if (isDateProperty(property))
+ return property.value === null ? '' : formatDate(property.value);
+
+ if (isSelectProperty(property)) {
+ const first = getSelectValues(property)[0];
+ return first ? formatPropertyValue(property, first) : '';
+ }
+
+ if (isEntityProperty(property)) {
+ const entities = getEntityValues(property);
+ if (entities.length === 0) return '';
+ if (property.specificEntityType === 'USER') {
+ if (entities.length === 1) {
+ const parts = useDisplayNameParts(tryMacroId(entities[0].entity_id));
+ return parts.firstName() || 'Unknown';
+ }
+ return entities.length === 2 ? '2 people' : `${entities.length} people`;
+ }
+ return entities.length === 1 ? '1 item' : `${entities.length} items`;
+ }
+
+ if (isLinkProperty(property)) {
+ return getLinkValues(property)[0] ?? '';
+ }
+
+ return '';
+}
diff --git a/js/app/packages/property/src/extractors/PropertyTooltip.tsx b/js/app/packages/property/src/extractors/PropertyTooltip.tsx
new file mode 100644
index 0000000000..57c56df308
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyTooltip.tsx
@@ -0,0 +1,22 @@
+import { PropertyTooltip as CorePropertyTooltip } from '@core/component/Properties/component/propertyValue/PropertyTooltip';
+import { HoverCard } from '@ui';
+import type { JSX } from 'solid-js';
+import type { Property } from '../types';
+
+type Props = {
+ property: Property;
+ children: JSX.Element;
+};
+
+/**
+ * Wraps children in a HoverCard showing the property's tooltip content.
+ * The tooltip body is delegated to the existing CorePropertyTooltip so
+ * consumers see the same content across migrations.
+ */
+export function PropertyTooltip(props: Props) {
+ return (
+ <HoverCard content={<CorePropertyTooltip property={props.property} />}>
+ {props.children}
+ </HoverCard>
+ );
+}
diff --git a/js/app/packages/property/src/extractors/PropertyUserStack.tsx b/js/app/packages/property/src/extractors/PropertyUserStack.tsx
new file mode 100644
index 0000000000..26492492ef
--- /dev/null
+++ b/js/app/packages/property/src/extractors/PropertyUserStack.tsx
@@ -0,0 +1,45 @@
+import { UserIcon } from '@core/component/UserIcon';
+import { AvatarGroup } from '@ui';
+import { For, Show } from 'solid-js';
+import type { Property } from '../types';
+import { getEntityValues, isEntityProperty } from '../utils';
+
+type Props = {
+ property: Property;
+ maxUsers?: number;
+};
+
+/**
+ * Avatar stack for ENTITY+USER properties. Renders nothing for other types.
+ */
+export function PropertyUserStack(props: Props) {
+ const isUser = () =>
+ isEntityProperty(props.property) &&
+ props.property.specificEntityType === 'USER';
+
+ const max = () => props.maxUsers ?? 3;
+
+ const entities = () => getEntityValues(props.property);
+ const display = () => entities().slice(0, max());
+ const remaining = () => Math.max(0, entities().length - max());
+
+ return (
+ <Show when={isUser()}>
+ <AvatarGroup size="sm">
+ <For each={display()}>
+ {(entity) => (
+ <UserIcon
+ id={entity.entity_id}
+ size="sm"
+ suppressClick
+ showTooltip={false}
+ />
+ )}
+ </For>
+ <Show when={remaining() > 0}>
+ <AvatarGroup.Count size="sm">+{remaining()}</AvatarGroup.Count>
+ </Show>
+ </AvatarGroup>
+ </Show>
+ );
+}
diff --git a/js/app/packages/property/src/extractors/index.ts b/js/app/packages/property/src/extractors/index.ts
new file mode 100644
index 0000000000..919cda36d7
--- /dev/null
+++ b/js/app/packages/property/src/extractors/index.ts
@@ -0,0 +1,11 @@
+export { PropertyAddButton } from './PropertyAddButton';
+export { PropertyCaret } from './PropertyCaret';
+export { type ChipInfo, PropertyChips } from './PropertyChips';
+export { PropertyEditTrigger } from './PropertyEditTrigger';
+export { PropertyEmpty } from './PropertyEmpty';
+export { PropertyIcon } from './PropertyIcon';
+export { PropertyLabel } from './PropertyLabel';
+export { PropertyRemoveButton } from './PropertyRemoveButton';
+export { PropertyText } from './PropertyText';
+export { PropertyTooltip } from './PropertyTooltip';
+export { PropertyUserStack } from './PropertyUserStack';
diff --git a/js/app/packages/property/src/hooks/index.ts b/js/app/packages/property/src/hooks/index.ts
new file mode 100644
index 0000000000..026f97387b
--- /dev/null
+++ b/js/app/packages/property/src/hooks/index.ts
@@ -0,0 +1,3 @@
+export { usePropertyClear } from './usePropertyClear';
+export { type PropertyDisplay, usePropertyDisplay } from './usePropertyDisplay';
+export { usePropertyEdit } from './usePropertyEdit';
diff --git a/js/app/packages/property/src/hooks/usePropertyClear.ts b/js/app/packages/property/src/hooks/usePropertyClear.ts
new file mode 100644
index 0000000000..66be2bb949
--- /dev/null
+++ b/js/app/packages/property/src/hooks/usePropertyClear.ts
@@ -0,0 +1,30 @@
+import { createSignal } from 'solid-js';
+import { useProperty } from '../core/context';
+import { toPropertyApiValue } from '../utils';
+
+/**
+ * Clears a property's value (sets to null). Tracks an `isSaving` signal so
+ * UI can disable affordances during the call.
+ */
+export function usePropertyClear() {
+ const ctx = useProperty();
+ const [isSaving, setIsSaving] = createSignal(false);
+
+ const clear = async () => {
+ if (isSaving()) return;
+ const save = ctx.onSave;
+ if (!save) return;
+ const property = ctx.property();
+ if (!ctx.canEdit() || property.isMetadata) return;
+ setIsSaving(true);
+ try {
+ const next = toPropertyApiValue(property, null);
+ if (next) await save(property, next);
+ ctx.onRefresh?.();
+ } finally {
+ setIsSaving(false);
+ }
+ };
+
+ return { clear, isSaving };
+}
diff --git a/js/app/packages/property/src/hooks/usePropertyDisplay.ts b/js/app/packages/property/src/hooks/usePropertyDisplay.ts
new file mode 100644
index 0000000000..010bd21777
--- /dev/null
+++ b/js/app/packages/property/src/hooks/usePropertyDisplay.ts
@@ -0,0 +1,89 @@
+import { tryMacroId, useDisplayNameParts } from '@core/user';
+import { createMemo } from 'solid-js';
+import type { Property } from '../types';
+import {
+ formatBoolean,
+ formatDate,
+ formatNumber,
+ formatPropertyValue,
+ getEntityValues,
+ getLinkValues,
+ getSelectValues,
+ hasValue,
+ isBooleanProperty,
+ isDateProperty,
+ isEntityProperty,
+ isLinkProperty,
+ isNumberProperty,
+ isSelectProperty,
+ isStringProperty,
+} from '../utils';
+
+export interface PropertyDisplay {
+ isEmpty: boolean;
+ isUser: boolean;
+ /** Best single-value representation as text. */
+ text: string;
+ /** For SELECT properties: the first option's id. */
+ firstOptionId: string | undefined;
+ /** For ENTITY+USER: the first user id. */
+ firstUserId: string | undefined;
+ /** Count of values for multi-value properties (0 for single). */
+ count: number;
+}
+
+/**
+ * Centralizes the "extract a displayable representation from a property"
+ * logic that today is duplicated across InlinePropertyValue / ListProperty /
+ * Condensed.
+ */
+export function usePropertyDisplay(
+ property: () => Property
+): () => PropertyDisplay {
+ return createMemo(() => {
+ const p = property();
+ const empty = !hasValue(p);
+ const isUser = isEntityProperty(p) && p.specificEntityType === 'USER';
+
+ let text = '';
+ let firstOptionId: string | undefined;
+ let firstUserId: string | undefined;
+ let count = 0;
+
+ if (isStringProperty(p)) {
+ text = p.value ?? '';
+ } else if (isNumberProperty(p)) {
+ text = p.value === null ? '' : formatNumber(p.value);
+ } else if (isBooleanProperty(p)) {
+ text = p.value === null ? '' : formatBoolean(p.value);
+ } else if (isDateProperty(p)) {
+ text = p.value === null ? '' : formatDate(p.value);
+ } else if (isSelectProperty(p)) {
+ const values = getSelectValues(p);
+ count = values.length;
+ firstOptionId = values[0];
+ text = firstOptionId ? formatPropertyValue(p, firstOptionId) : '';
+ } else if (isEntityProperty(p)) {
+ const entities = getEntityValues(p);
+ count = entities.length;
+ if (isUser) {
+ firstUserId = entities[0]?.entity_id;
+ if (entities.length === 1 && firstUserId) {
+ const parts = useDisplayNameParts(tryMacroId(firstUserId));
+ text = parts.firstName() || 'Unknown';
+ } else if (entities.length > 1) {
+ text =
+ entities.length === 2 ? '2 people' : `${entities.length} people`;
+ }
+ } else if (entities.length > 0) {
+ text = entities.length === 1 ? '1 item' : `${entities.length} items`;
+ }
+ } else if (isLinkProperty(p)) {
+ const links = getLinkValues(p);
+ count = links.length;
+ text = links[0] ?? '';
+ }
+
+ return { isEmpty: empty, isUser, text, firstOptionId, firstUserId, count };
+ });
+}
diff --git a/js/app/packages/property/src/hooks/usePropertyEdit.ts b/js/app/packages/property/src/hooks/usePropertyEdit.ts
new file mode 100644
index 0000000000..37f43b9ac3
--- /dev/null
+++ b/js/app/packages/property/src/hooks/usePropertyEdit.ts
@@ -0,0 +1,18 @@
+import { useProperty } from '../core/context';
+
+/**
+ * Convenience hook around <Property.Root>'s edit affordance.
+ * - `open(anchor?)`: invokes the root's onEdit handler.
+ * - `isReadOnly()`: combines canEdit + isMetadata.
+ */
+export function usePropertyEdit() {
+ const ctx = useProperty();
+ return {
+ open(anchor?: HTMLElement) {
+ const p = ctx.property();
+ if (!ctx.canEdit() || p.isMetadata) return;
+ ctx.onEdit?.(p, anchor);
+ },
+ isReadOnly: () => !ctx.canEdit() || ctx.property().isMetadata,
+ };
+}
diff --git a/js/app/packages/property/src/index.ts b/js/app/packages/property/src/index.ts
new file mode 100644
index 0000000000..f159357360
--- /dev/null
+++ b/js/app/packages/property/src/index.ts
@@ -0,0 +1,14 @@
+// Public surface for @property. Built up incrementally as primitives land.
+
+export * from './constants';
+export {
+ type PropertyEditFn,
+ type PropertyRootContextValue,
+ type PropertySaveFn,
+ useMaybeProperty,
+ useProperty,
+} from './core/context';
+export * from './hooks';
+export { Property } from './property';
+export * from './types';
+export * as PropertyUtils from './utils';
diff --git a/js/app/packages/property/src/property.ts b/js/app/packages/property/src/property.ts
new file mode 100644
index 0000000000..2a4989dd4c
--- /dev/null
+++ b/js/app/packages/property/src/property.ts
@@ -0,0 +1,43 @@
+// Composable property component namespace.
+//
+// Mirrors @entity: small extractors compose under <Property.Root> to render
+// property values in any layout, replacing the duplicated PropertyValue /
+// CondensedPropertyValue / InlinePropertyValue / ListPropertyValue trees.
+
+import { Layout } from './core/Layout';
+import { Root } from './core/Root';
+import { Slot } from './core/Slot';
+import {
+ PropertyAddButton,
+ PropertyCaret,
+ PropertyChips,
+ PropertyEditTrigger,
+ PropertyEmpty,
+ PropertyIcon,
+ PropertyLabel,
+ PropertyRemoveButton,
+ PropertyText,
+ PropertyTooltip,
+ PropertyUserStack,
+} from './extractors';
+
+export const Property = {
+ Root,
+ Layout,
+ Slot,
+
+ // Display extractors — take property as a prop, render no behavior.
+ Icon: PropertyIcon,
+ Label: PropertyLabel,
+ Text: PropertyText,
+ Chips: PropertyChips,
+ UserStack: PropertyUserStack,
+ Empty: PropertyEmpty,
+ Tooltip: PropertyTooltip,
+
+ // Behavior extractors — read from <Property.Root> context.
+ Caret: PropertyCaret,
+ EditTrigger: PropertyEditTrigger,
+ RemoveButton: PropertyRemoveButton,
+ AddButton: PropertyAddButton,
+};
diff --git a/js/app/packages/property/src/types.ts b/js/app/packages/property/src/types.ts
new file mode 100644
index 0000000000..8f05cc5f84
--- /dev/null
+++ b/js/app/packages/property/src/types.ts
@@ -0,0 +1,34 @@
+// Re-export domain types from the existing @core/component/Properties package.
+// Source of truth lives there for now; a future PR will flip ownership to @property.
+
+export type {
+ ApiError,
+ BooleanProperty,
+ DataType,
+ DateProperty,
+ EntityPropertiesResponse,
+ EntityProperty,
+ EntityPropertyWithDefinition,
+ EntityReference,
+ LinkProperty,
+ MultiValueProperty,
+ NumberProperty,
+ PropertiesPanelProps,
+ Property,
+ PropertyApiValues,
+ PropertyDefinitionDomain,
+ PropertyDefinitionResponse,
+ PropertyEditorProps,
+ PropertyOption,
+ PropertyOptionValue,
+ PropertySelectorProps,
+ PropertyValue,
+ Result,
+ SelectNumberProperty,
+ SelectProperty,
+ SelectStringProperty,
+ SetPropertyValue,
+ SingleValueProperty,
+ StringProperty,
+ ValueType,
+} from '@core/component/Properties/types';
diff --git a/js/app/packages/property/src/utils/index.ts b/js/app/packages/property/src/utils/index.ts
new file mode 100644
index 0000000000..ea7542d2a2
--- /dev/null
+++ b/js/app/packages/property/src/utils/index.ts
@@ -0,0 +1,35 @@
+// Re-export the utilities the @property primitives consume.
+// Source of truth still lives under @core/component/Properties/utils;
+// a future consolidation PR will move ownership here.
+
+export {
+ extractDomain,
+ formatBoolean,
+ formatDate,
+ formatNumber,
+ formatOptionValue,
+ formatOptionValueById,
+ formatPropertyValue,
+ getOptionValue,
+} from '@core/component/Properties/utils/formatting';
+
+export {
+ getEntityValues,
+ getLinkValues,
+ getSelectValues,
+ hasMultiValue,
+ hasSingleValue,
+ hasValue,
+ isBooleanProperty,
+ isDateProperty,
+ isEntityProperty,
+ isLinkProperty,
+ isMultiValueProperty,
+ isNumberProperty,
+ isSelectNumberProperty,
+ isSelectProperty,
+ isSelectStringProperty,
+ isSingleValueProperty,
+ isStringProperty,
+ toPropertyApiValue,
+} from '@core/component/Properties/utils/typeGuards';
diff --git a/js/app/packages/property/tsconfig.json b/js/app/packages/property/tsconfig.json
new file mode 100644
index 0000000000..db1fa1ca9b
--- /dev/null
+++ b/js/app/packages/property/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "allowSyntheticDefaultImports": true,
+ "esModuleInterop": true,
+ "jsx": "preserve",
+ "jsxImportSource": "solid-js",
+ "composite": true,
+ "isolatedModules": true,
+ "skipLibCheck": true,
+ "moduleResolution": "bundler"
+ }
+}
diff --git a/js/app/packages/property/vitest.config.ts b/js/app/packages/property/vitest.config.ts
new file mode 100644
index 0000000000..70485d572f
--- /dev/null
+++ b/js/app/packages/property/vitest.config.ts
@@ -0,0 +1,13 @@
+import tsconfigPaths from 'vite-tsconfig-paths';
+import { defineConfig } from 'vitest/config';
+
+export default defineConfig({
+ plugins: [
+ tsconfigPaths({
+ root: '../../',
+ }),
+ ],
+ test: {
+ globals: true,
+ },
+} as any);
diff --git a/js/app/packages/queries/properties/entity.ts b/js/app/packages/queries/properties/entity.ts
index 2f63b5d76b..0815a9114c 100644
--- a/js/app/packages/queries/properties/entity.ts
+++ b/js/app/packages/queries/properties/entity.ts
@@ -17,6 +17,7 @@ import {
propertiesServiceClient,
} from '../../service-clients/service-properties/client';
import type { EntityType } from '../../service-clients/service-properties/generated/schemas/entityType';
+import type { SoupProperty } from '../../service-clients/service-storage/generated/schemas/soupProperty';
import type { SoupPropertyValue } from '../../service-clients/service-storage/generated/schemas/soupPropertyValue';
import { queryClient } from '../client';
import {
@@ -80,7 +81,7 @@ function getPropertyDefinitionId(
function optimisticUpdateSoupEntityProperty(
entityId: string,
- propertyDefinitionId: string,
+ property: Property | PropertyDefinitionDomain,
value: SoupPropertyValue
): SoupTransaction | undefined {
const current = getSoupEntityById(entityId);
@@ -93,18 +94,59 @@ function optimisticUpdateSoupEntityProperty(
return undefined;
}
+ const propertyDefinitionId = getPropertyDefinitionId(property);
+ const existing = current.data.properties;
+ const isAlreadyAttached = existing.some(
+ (prop) => prop.definition.id === propertyDefinitionId
+ );
+
+ // If the property is already attached, swap its value. Otherwise append a
+ // fabricated SoupProperty so the row updates without waiting for the
+ // settled-refetch — necessary when editing a previously-unset property
+ // that the entity didn't ship with (e.g. via `buildStubProperty`).
+ const nextProperties: SoupProperty[] = isAlreadyAttached
+ ? existing.map((prop) =>
+ prop.definition.id === propertyDefinitionId ? { ...prop, value } : prop
+ )
+ : [...existing, fabricateSoupProperty(property, value)];
+
return optimisticUpdateSoupEntity({
tag: current.tag,
data: {
...current.data,
- properties: current.data.properties.map((prop) =>
- prop.definition.id === propertyDefinitionId ? { ...prop, value } : prop
- ),
+ properties: nextProperties,
},
frecency_score: current.frecency_score,
});
}
+function fabricateSoupProperty(
+ property: Property | PropertyDefinitionDomain,
+ value: SoupPropertyValue
+): SoupProperty {
+ const now = new Date().toISOString();
+ const instantiated = isInstantiatedProperty(property);
+ return {
+ definition: {
+ id: getPropertyDefinitionId(property),
+ display_name: property.displayName,
+ data_type: property.valueType,
+ is_metadata: instantiated
+ ? (property.isMetadata ?? false)
+ : property.isMetadata,
+ is_multi_select: property.isMultiSelect,
+ is_system: instantiated
+ ? (property.isSystemProperty ?? false)
+ : property.isSystem,
+ owner: property.owner,
+ specific_entity_type: property.specificEntityType ?? undefined,
+ created_at: now,
+ updated_at: now,
+ },
+ value,
+ };
+}
+
/**
* Converts PropertyApiValues to the SoupProperty value format for optimistic updates.
*/
@@ -289,7 +331,7 @@ export function useBulkSaveEntityPropertiesMutation(
for (const item of vars.properties) {
const txn = optimisticUpdateSoupEntityProperty(
item.entityId,
- getPropertyDefinitionId(item.property),
+ item.property,
apiValuesToSoupPropertyValue(item.apiValues)
);
if (txn) txns.push(txn);
diff --git a/js/app/tsconfig.json b/js/app/tsconfig.json
index d63c1d3caa..807c3669c9 100644
--- a/js/app/tsconfig.json
+++ b/js/app/tsconfig.json
@@ -227,6 +227,12 @@
"@entity/*": [
"./packages/entity/src/*"
],
+ "@property": [
+ "./packages/property/src/index.ts"
+ ],
+ "@property/*": [
+ "./packages/property/src/*"
+ ],
},
"rootDir": "..",
"outDir": "./dist"
@@ -261,6 +267,9 @@
},
{
"path": "./packages/entity"
+ },
+ {
+ "path": "./packages/property"
}
]
}