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.

improve [properties-fe] - some component refactoring (#83)

Daniel Kweonafa340a590da
diff --git a/js/app/packages/core/component/Properties/EntityValueDisplay.tsx b/js/app/packages/core/component/Properties/EntityValueDisplay.tsx
index 3e8437e245..0deeccaee8 100644
--- a/js/app/packages/core/component/Properties/EntityValueDisplay.tsx
+++ b/js/app/packages/core/component/Properties/EntityValueDisplay.tsx
@@ -11,7 +11,7 @@ import ChannelIcon from '@icon/duotone/hash-duotone.svg';
import User from '@icon/duotone/user-duotone.svg';
import ThreeUsersIcon from '@icon/duotone/users-three-duotone.svg';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
-import { createMemo, type ParentProps, Show } from 'solid-js';
+import { type Component, createMemo, type ParentProps, Show } from 'solid-js';
import type { Property } from './types';
type EntityValueDisplayProps = ParentProps<{
@@ -23,7 +23,9 @@ type EntityValueDisplayProps = ParentProps<{
const ICON_CLASSES = 'size-4 text-ink-muted';
-export function EntityValueDisplay(props: EntityValueDisplayProps) {
+export const EntityValueDisplay: Component<EntityValueDisplayProps> = (
+ props
+) => {
// Get preview for items that need it (document, project, chat, channel for icon)
const previewTypes: EntityType[] = ['DOCUMENT', 'PROJECT', 'CHAT', 'CHANNEL'];
const needsPreview = previewTypes.includes(props.entityType);
@@ -168,4 +170,4 @@ export function EntityValueDisplay(props: EntityValueDisplayProps) {
)}
</Show>
);
-}
+};
diff --git a/js/app/packages/core/component/Properties/components/AddPropertyButton.tsx b/js/app/packages/core/component/Properties/components/AddPropertyButton.tsx
index 12d88ad95c..60a3ca7654 100644
--- a/js/app/packages/core/component/Properties/components/AddPropertyButton.tsx
+++ b/js/app/packages/core/component/Properties/components/AddPropertyButton.tsx
@@ -1,8 +1,10 @@
+import type { Component } from 'solid-js';
+
interface AddPropertyButtonProps {
onClick: () => void;
}
-export function AddPropertyButton(props: AddPropertyButtonProps) {
+export const AddPropertyButton: Component<AddPropertyButtonProps> = (props) => {
return (
<button
class="w-full flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium text-ink-muted hover:text-ink border-2 border-edge hover:border-ink-muted font-mono"
@@ -11,4 +13,4 @@ export function AddPropertyButton(props: AddPropertyButtonProps) {
<span class="text-md leading-none">+ ADD PROPERTY</span>
</button>
);
-}
+};
diff --git a/js/app/packages/core/component/Properties/components/CreatePropertyModal.tsx b/js/app/packages/core/component/Properties/components/CreatePropertyModal.tsx
index 58608e8a07..852ae47ab9 100644
--- a/js/app/packages/core/component/Properties/components/CreatePropertyModal.tsx
+++ b/js/app/packages/core/component/Properties/components/CreatePropertyModal.tsx
@@ -8,7 +8,13 @@ import { useUserId } from '@service-gql/client';
import { propertiesServiceClient } from '@service-properties/client';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
import type { PropertyDataType } from '@service-properties/generated/schemas/propertyDataType';
-import { createMemo, createSignal, Index, Show } from 'solid-js';
+import {
+ type Component,
+ createMemo,
+ createSignal,
+ Index,
+ Show,
+} from 'solid-js';
import { Portal } from 'solid-js/web';
import {
BUTTON_BASE_CLASSES,
@@ -33,7 +39,9 @@ interface CreatePropertyModalProps {
onPropertyCreated?: () => void;
}
-export function CreatePropertyModal(props: CreatePropertyModalProps) {
+export const CreatePropertyModal: Component<CreatePropertyModalProps> = (
+ props
+) => {
const [isCreatingProperty, setIsCreatingProperty] = createSignal(false);
const [newPropertyName, setNewPropertyName] = createSignal('');
const [selectedDataType, setSelectedDataType] =
@@ -594,4 +602,4 @@ export function CreatePropertyModal(props: CreatePropertyModalProps) {
</div>
</Portal>
);
-}
+};
diff --git a/js/app/packages/core/component/Properties/components/PropertiesContent.tsx b/js/app/packages/core/component/Properties/components/PropertiesContent.tsx
index 634d3c10ff..9197e32162 100644
--- a/js/app/packages/core/component/Properties/components/PropertiesContent.tsx
+++ b/js/app/packages/core/component/Properties/components/PropertiesContent.tsx
@@ -1,4 +1,4 @@
-import type { Accessor } from 'solid-js';
+import type { Accessor, Component } from 'solid-js';
import { createMemo, Show } from 'solid-js';
import type { Property } from '../types';
import { PropertiesList } from './PropertiesList';
@@ -10,7 +10,7 @@ interface PropertiesContentProps {
emptyMessage?: string;
}
-export function PropertiesContent(props: PropertiesContentProps) {
+export const PropertiesContent: Component<PropertiesContentProps> = (props) => {
const hasProperties = createMemo(() => props.properties().length > 0);
const showContent = createMemo(
() => hasProperties() || (!props.isLoading() && !props.error())
@@ -31,4 +31,4 @@ export function PropertiesContent(props: PropertiesContentProps) {
</Show>
</Show>
);
-}
+};
diff --git a/js/app/packages/core/component/Properties/components/PropertiesList.tsx b/js/app/packages/core/component/Properties/components/PropertiesList.tsx
index 1b53074d05..93dc9c5596 100644
--- a/js/app/packages/core/component/Properties/components/PropertiesList.tsx
+++ b/js/app/packages/core/component/Properties/components/PropertiesList.tsx
@@ -1,4 +1,4 @@
-import { createMemo, For, Show } from 'solid-js';
+import { type Component, createMemo, For, Show } from 'solid-js';
import { usePropertiesContext } from '../context/PropertiesContext';
import type { Property } from '../types';
import { PropertyRow } from './PropertyRow';
@@ -7,7 +7,7 @@ interface PropertiesListProps {
properties: Property[];
}
-export function PropertiesList(props: PropertiesListProps) {
+export const PropertiesList: Component<PropertiesListProps> = (props) => {
const { openModal } = usePropertiesContext();
const metadataProperties = createMemo(() =>
@@ -78,4 +78,4 @@ export function PropertiesList(props: PropertiesListProps) {
</div>
</Show>
);
-}
+};
diff --git a/js/app/packages/core/component/Properties/components/PropertiesModals.tsx b/js/app/packages/core/component/Properties/components/PropertiesModals.tsx
index d55bc5088d..5ea420b201 100644
--- a/js/app/packages/core/component/Properties/components/PropertiesModals.tsx
+++ b/js/app/packages/core/component/Properties/components/PropertiesModals.tsx
@@ -1,6 +1,6 @@
import { useBlockId } from '@core/block';
import { DatePicker } from '@core/component/DatePicker';
-import { createMemo } from 'solid-js';
+import { type Component, createMemo } from 'solid-js';
import { Portal, Show } from 'solid-js/web';
import { savePropertyValue } from '../apiUtils';
import { usePropertiesContext } from '../context/PropertiesContext';
@@ -9,7 +9,7 @@ import { PropertySelector } from '../PropertySelector';
import type { Property } from '../types';
import { CreatePropertyModal } from './CreatePropertyModal';
-export function PropertiesModals() {
+export const PropertiesModals: Component = () => {
const blockId = useBlockId();
const {
entityType,
@@ -111,4 +111,4 @@ export function PropertiesModals() {
</Show>
</>
);
-}
+};
diff --git a/js/app/packages/core/component/Properties/components/PropertyRow.tsx b/js/app/packages/core/component/Properties/components/PropertyRow.tsx
index f8231f44b6..a9bba97d79 100644
--- a/js/app/packages/core/component/Properties/components/PropertyRow.tsx
+++ b/js/app/packages/core/component/Properties/components/PropertyRow.tsx
@@ -1,3 +1,4 @@
+import type { Component } from 'solid-js';
import type { Property } from '../types';
import { PropertyLabel } from './PropertyLabel';
import { PropertyValue } from './property-display/PropertyValue';
@@ -7,7 +8,7 @@ interface PropertyRowProps {
onValueClick: (property: Property, anchor?: HTMLElement) => void;
}
-export function PropertyRow(props: PropertyRowProps) {
+export const PropertyRow: Component<PropertyRowProps> = (props) => {
return (
<>
<div class="flex items-start min-w-0">
@@ -18,4 +19,4 @@ export function PropertyRow(props: PropertyRowProps) {
</div>
</>
);
-}
+};
diff --git a/js/app/packages/core/component/Properties/components/property-display/DateValue.tsx b/js/app/packages/core/component/Properties/components/property-display/DateValue.tsx
index cdd9d0b300..fa7e0b154e 100644
--- a/js/app/packages/core/component/Properties/components/property-display/DateValue.tsx
+++ b/js/app/packages/core/component/Properties/components/property-display/DateValue.tsx
@@ -1,4 +1,5 @@
import type { Component } from 'solid-js';
+import { Show } from 'solid-js';
import type { Property } from '../../types';
import { formatDate } from '../../utils';
@@ -21,23 +22,9 @@ export const DateValue: Component<DateValueProps> = (props) => {
const isReadOnly = () => props.property.isMetadata || !props.canEdit;
- // Empty state
- if (!props.property.value) {
- return (
- <button
- onClick={handleClick}
- class={`text-left text-xs px-2 py-1 border border-edge ${
- isReadOnly()
- ? 'bg-transparent text-ink-muted cursor-default'
- : 'hover:bg-hover cursor-pointer bg-transparent text-ink'
- } inline-block max-w-full`}
- >
- —
- </button>
- );
- }
-
- const displayValue = formatDate(props.property.value as Date);
+ const displayValue = props.property.value
+ ? formatDate(props.property.value as Date)
+ : '';
return (
<button
@@ -47,9 +34,10 @@ export const DateValue: Component<DateValueProps> = (props) => {
? 'bg-transparent text-ink-muted cursor-default'
: 'hover:bg-hover cursor-pointer bg-transparent text-ink'
} inline-block max-w-full break-words`}
- title={displayValue}
>
- <span class="block truncate max-w-full">{displayValue}</span>
+ <Show when={displayValue} fallback={<>—</>}>
+ <span class="block truncate max-w-full">{displayValue}</span>
+ </Show>
</button>
);
};
diff --git a/js/app/packages/core/component/Properties/components/property-display/EntityValue.tsx b/js/app/packages/core/component/Properties/components/property-display/EntityValue.tsx
index 059aefab80..f779bb6bcf 100644
--- a/js/app/packages/core/component/Properties/components/property-display/EntityValue.tsx
+++ b/js/app/packages/core/component/Properties/components/property-display/EntityValue.tsx
@@ -24,7 +24,7 @@ export const EntityValue: Component<EntityValueProps> = (props) => {
};
const isReadOnly = () => props.property.isMetadata || !props.canEdit;
- const entities = props.property.value as EntityReference[];
+ const entities = (props.property.value as EntityReference[]) ?? [];
return (
<div class="flex flex-wrap gap-1 justify-start items-start w-full min-w-0">
<For each={entities}>
@@ -52,7 +52,19 @@ export const EntityValue: Component<EntityValueProps> = (props) => {
);
}}
</For>
- <Show when={!isReadOnly()}>
+ <Show
+ when={!isReadOnly()}
+ fallback={
+ <Show when={entities.length === 0}>
+ <div
+ onClick={handleEditClick}
+ class="text-ink-muted text-xs px-2 py-1 border border-edge bg-transparent inline-block shrink-0"
+ >
+ {<>—</>}
+ </div>
+ </Show>
+ }
+ >
<button
onClick={handleEditClick}
class="text-ink-muted hover:text-ink text-xs hover:bg-hover px-2 py-1 cursor-pointer border border-edge bg-transparent inline-block shrink-0"
diff --git a/js/app/packages/core/component/Properties/components/property-display/LinkValue.tsx b/js/app/packages/core/component/Properties/components/property-display/LinkValue.tsx
index cac45406ce..f3e61888ed 100644
--- a/js/app/packages/core/component/Properties/components/property-display/LinkValue.tsx
+++ b/js/app/packages/core/component/Properties/components/property-display/LinkValue.tsx
@@ -30,6 +30,8 @@ export const LinkValue: Component<LinkValueProps> = (props) => {
const isReadOnly = () => props.property.isMetadata || !props.canEdit;
const linkValues = (props.property.value || []) as string[];
+ const hasLinks = () => linkValues.length > 0;
+ const isMultiValue = () => props.property.isMultiSelect;
const startAdding = () => {
if (isReadOnly()) return;
@@ -134,120 +136,103 @@ export const LinkValue: Component<LinkValueProps> = (props) => {
}
};
- // Empty state - show input if adding, otherwise show — button
- if (linkValues.length === 0) {
- if (isAdding()) {
- return (
- <div>
- <input
- ref={(el) => {
- setTimeout(() => el.focus(), 0);
- }}
- type="text"
- value={inputValue()}
- onInput={(e) => setInputValue(e.currentTarget.value)}
- onKeyDown={handleKeyDown}
- onBlur={() => {
- setTimeout(() => {
- if (isAdding()) {
- handleAddLink();
- }
- }, 100);
- }}
- placeholder="Enter URL..."
- disabled={isSaving()}
- class="text-left text-xs px-2 py-1 border border-edge bg-transparent focus:outline-none focus:border-accent text-ink"
- />
- <Show when={error()}>
- <div class="text-failure-ink text-xs mt-1">{error()}</div>
- </Show>
- </div>
- );
- }
-
- return (
- <button
- onClick={startAdding}
- class={`text-left text-xs px-2 py-1 border border-edge ${
- isReadOnly()
- ? 'bg-transparent text-ink-muted cursor-default'
- : 'hover:bg-hover cursor-pointer bg-transparent text-ink'
- } inline-block max-w-full`}
- disabled={isReadOnly()}
- >
- —
- </button>
- );
- }
-
- // Single value
- if (!props.property.isMultiSelect || linkValues.length === 1) {
- return (
- <LinkDisplay
- url={linkValues[0]}
- onRemove={() => handleRemoveLink(linkValues[0])}
- canEdit={!isReadOnly()}
- isRemoving={isSaving()}
- hoveredLink={hoveredLink()}
- setHoveredLink={setHoveredLink}
+ const AddLinkInput = () => (
+ <div>
+ <input
+ ref={(el) => {
+ setTimeout(() => el.focus(), 0);
+ }}
+ type="text"
+ value={inputValue()}
+ onInput={(e) => setInputValue(e.currentTarget.value)}
+ onKeyDown={handleKeyDown}
+ onBlur={() => {
+ setTimeout(() => {
+ if (isAdding()) {
+ handleAddLink();
+ }
+ }, 100);
+ }}
+ placeholder="Enter URL..."
+ disabled={isSaving()}
+ class="text-left text-xs px-2 py-1 border border-edge bg-transparent focus:outline-none focus:border-accent text-ink"
/>
- );
- }
+ <Show when={error()}>
+ <div class="text-failure-ink text-xs mt-1">{error()}</div>
+ </Show>
+ </div>
+ );
- // Multiple values
return (
- <div class="flex flex-wrap gap-1 justify-start items-start w-full min-w-0">
- <For each={linkValues}>
- {(url) => (
+ <Show
+ when={isMultiValue()}
+ fallback={
+ <Show
+ when={hasLinks()}
+ fallback={
+ <Show
+ when={isAdding()}
+ fallback={
+ <button
+ onClick={startAdding}
+ class={`text-left text-xs px-2 py-1 border border-edge ${
+ isReadOnly()
+ ? 'bg-transparent text-ink-muted cursor-default'
+ : 'hover:bg-hover cursor-pointer bg-transparent text-ink'
+ } inline-block max-w-full`}
+ disabled={isReadOnly()}
+ >
+ —
+ </button>
+ }
+ >
+ <AddLinkInput />
+ </Show>
+ }
+ >
<LinkDisplay
- url={url}
- onRemove={() => handleRemoveLink(url)}
+ url={linkValues[0]}
+ onRemove={() => handleRemoveLink(linkValues[0])}
canEdit={!isReadOnly()}
isRemoving={isSaving()}
hoveredLink={hoveredLink()}
setHoveredLink={setHoveredLink}
/>
- )}
- </For>
- <Show when={!isReadOnly()}>
- <Show
- when={isAdding()}
- fallback={
- <button
- onClick={startAdding}
- class="text-ink-muted hover:text-ink text-xs hover:bg-hover px-2 py-1 cursor-pointer border border-edge bg-transparent inline-block shrink-0"
- >
- +
- </button>
- }
- >
- <div class="inline-block">
- <input
- ref={(el) => {
- setTimeout(() => el.focus(), 0);
- }}
- type="text"
- value={inputValue()}
- onInput={(e) => setInputValue(e.currentTarget.value)}
- onKeyDown={handleKeyDown}
- onBlur={() => {
- setTimeout(() => {
- if (isAdding()) {
- handleAddLink();
- }
- }, 100);
- }}
- placeholder="Enter URL..."
- disabled={isSaving()}
- class="text-left text-xs px-2 py-1 border border-edge bg-transparent focus:outline-none focus:border-accent text-ink"
+ </Show>
+ }
+ >
+ <div class="flex flex-wrap gap-1 justify-start items-start w-full min-w-0">
+ <For each={linkValues}>
+ {(url) => (
+ <LinkDisplay
+ url={url}
+ onRemove={() => handleRemoveLink(url)}
+ canEdit={!isReadOnly()}
+ isRemoving={isSaving()}
+ hoveredLink={hoveredLink()}
+ setHoveredLink={setHoveredLink}
/>
- <Show when={error()}>
- <div class="text-failure-ink text-xs mt-1">{error()}</div>
- </Show>
- </div>
+ )}
+ </For>
+ <Show when={!isReadOnly()}>
+ <Show
+ when={isAdding()}
+ fallback={
+ <button
+ onClick={startAdding}
+ class="text-ink-muted hover:text-ink text-xs hover:bg-hover px-2 py-1 cursor-pointer border border-edge bg-transparent inline-block shrink-0"
+ >
+ +
+ </button>
+ }
+ >
+ <div class="inline-block">
+ <AddLinkInput />
+ </div>
+ </Show>
</Show>
- </Show>
- </div>
+ </div>
+ </Show>
);
};
diff --git a/js/app/packages/core/component/Properties/components/property-display/NumberValue.tsx b/js/app/packages/core/component/Properties/components/property-display/NumberValue.tsx
index d4896d05b9..94b730b7fd 100644
--- a/js/app/packages/core/component/Properties/components/property-display/NumberValue.tsx
+++ b/js/app/packages/core/component/Properties/components/property-display/NumberValue.tsx
@@ -44,46 +44,11 @@ export const NumberValue: Component<NumberValueProps> = (props) => {
}
};
- // Empty state
- if (props.property.value === undefined || props.property.value === null) {
- return (
- <Show
- when={editor.isEditing()}
- fallback={
- <button
- onClick={handleClick}
- class={`text-left text-xs px-2 py-1 border border-edge ${
- supportsInline()
- ? 'hover:bg-hover cursor-pointer bg-transparent text-ink'
- : 'bg-transparent text-ink-muted cursor-default'
- } inline-block max-w-full`}
- >
- —
- </button>
- }
- >
- <input
- ref={(el) => {
- setTimeout(() => {
- el.focus();
- el.setSelectionRange(el.value.length, el.value.length);
- }, 0);
- }}
- type="number"
- step="0.0001"
- value={editor.inputValue()}
- onInput={(e) => editor.setInputValue(e.currentTarget.value)}
- onBlur={editor.save}
- onKeyDown={handleKeyDown}
- disabled={editor.isSaving()}
- placeholder="Enter number..."
- class="w-full text-left text-ink text-xs px-2 py-1 border border-edge bg-transparent focus:outline-none focus:border-accent"
- />
- </Show>
- );
- }
-
- const displayValue = formatNumber(props.property.value as number);
+ const hasValue = () =>
+ !(props.property.value === undefined || props.property.value === null);
+ const displayValue = hasValue()
+ ? formatNumber(props.property.value as number)
+ : '';
return (
<Show
@@ -95,10 +60,11 @@ export const NumberValue: Component<NumberValueProps> = (props) => {
supportsInline()
? 'hover:bg-hover cursor-pointer bg-transparent text-ink'
: 'bg-transparent text-ink-muted cursor-default'
- } inline-block max-w-full break-words`}
- title={displayValue}
+ } block max-w-full break-words`}
>
- <span class="block truncate max-w-full">{displayValue}</span>
+ <Show when={hasValue()} fallback={<>—</>}>
+ <span class="block truncate max-w-full">{displayValue}</span>
+ </Show>
</button>
}
>
@@ -115,6 +81,7 @@ export const NumberValue: Component<NumberValueProps> = (props) => {
onBlur={editor.save}
onKeyDown={handleKeyDown}
disabled={editor.isSaving()}
+ placeholder="Enter number..."
class="w-full text-left text-ink text-xs px-2 py-1 border border-edge bg-transparent focus:outline-none focus:border-accent"
/>
</Show>
diff --git a/js/app/packages/core/component/Properties/components/property-display/SelectValue.tsx b/js/app/packages/core/component/Properties/components/property-display/SelectValue.tsx
index 7793d22808..079362c4db 100644
--- a/js/app/packages/core/component/Properties/components/property-display/SelectValue.tsx
+++ b/js/app/packages/core/component/Properties/components/property-display/SelectValue.tsx
@@ -1,5 +1,5 @@
import type { Component } from 'solid-js';
-import { For } from 'solid-js';
+import { For, Show } from 'solid-js';
import { PROPERTY_STYLES } from '../../styles/propertyStyles';
import type { Property } from '../../types';
import { formatPropertyValue } from '../../utils';
@@ -22,88 +22,67 @@ export const SelectValue: Component<SelectValueProps> = (props) => {
};
const isReadOnly = () => props.property.isMetadata || !props.canEdit;
-
- // Type-safe value accessor for select types
const displayValues = (props.property.value || []) as string[];
+ const isMultiValue = () => props.property.isMultiSelect;
- // Empty state
- if (displayValues.length === 0) {
- return (
- <button
- onClick={handleClick}
- class={`text-left text-xs px-2 py-1 border border-edge ${
- isReadOnly()
- ? 'bg-transparent text-ink-muted cursor-default'
- : 'hover:bg-hover cursor-pointer bg-transparent text-ink'
- } inline-block max-w-full`}
- >
- —
- </button>
- );
- }
-
- // Single value
- if (!props.property.isMultiSelect || displayValues.length === 1) {
- const displayValue = formatPropertyValue(props.property, displayValues[0]);
-
- return (
- <button
- onClick={handleClick}
- class={`text-left text-xs px-2 py-1 border border-edge ${
- isReadOnly()
- ? 'bg-transparent text-ink-muted cursor-default'
- : 'hover:bg-hover cursor-pointer bg-transparent text-ink'
- } inline-block max-w-full break-words`}
- title={displayValue}
+ return (
+ <Show
+ when={isMultiValue()}
+ fallback={
+ <button
+ onClick={handleClick}
+ class={`text-left text-xs px-2 py-1 border border-edge ${
+ isReadOnly()
+ ? 'bg-transparent text-ink-muted cursor-default'
+ : 'hover:bg-hover cursor-pointer bg-transparent text-ink'
+ } inline-block max-w-full break-words`}
+ >
+ <Show when={displayValues.length > 0} fallback={<>—</>}>
+ <span class="block truncate max-w-full">
+ {formatPropertyValue(props.property, displayValues[0])}
+ </span>
+ </Show>
+ </button>
+ }
+ >
+ <div
+ class={`flex flex-wrap gap-1 justify-start items-start w-full min-w-0`}
>
- <span class="block truncate max-w-full">{displayValue}</span>
- </button>
- );
- }
-
- // Multiple values
- if (isReadOnly()) {
- return (
- <div class="flex flex-wrap gap-1 justify-end items-start w-full min-w-0">
<For each={displayValues}>
{(value) => {
const formatted = formatPropertyValue(props.property, value);
return (
- <div
- class={`${PROPERTY_STYLES.value.multi} text-ink-muted`}
- title={formatted}
+ <Show
+ when={isReadOnly()}
+ fallback={
+ <button
+ onClick={handleClick}
+ class={PROPERTY_STYLES.value.multiButton}
+ title={formatted}
+ >
+ <span class="block truncate">{formatted}</span>
+ </button>
+ }
>
- <span class="block truncate">{formatted}</span>
- </div>
+ <div
+ class={`${PROPERTY_STYLES.value.multi} text-ink-muted`}
+ title={formatted}
+ >
+ <span class="block truncate">{formatted}</span>
+ </div>
+ </Show>
);
}}
</For>
+ <Show when={!isReadOnly()}>
+ <button
+ onClick={handleClick}
+ class="text-ink-muted hover:text-ink text-xs hover:bg-hover px-2 py-1 cursor-pointer border border-edge bg-transparent inline-block shrink-0"
+ >
+ +
+ </button>
+ </Show>
</div>
- );
- }
-
- return (
- <div class="flex flex-wrap gap-1 justify-start items-start w-full min-w-0">
- <For each={displayValues}>
- {(value) => {
- const formatted = formatPropertyValue(props.property, value);
- return (
- <button
- onClick={handleClick}
- class={PROPERTY_STYLES.value.multiButton}
- title={formatted}
- >
- <span class="block truncate">{formatted}</span>
- </button>
- );
- }}
- </For>
- <button
- onClick={handleClick}
- class="text-ink-muted hover:text-ink text-xs hover:bg-hover px-2 py-1 cursor-pointer border border-edge bg-transparent inline-block shrink-0"
- >
- +
- </button>
- </div>
+ </Show>
);
};
diff --git a/js/app/packages/core/component/Properties/components/property-display/TextValue.tsx b/js/app/packages/core/component/Properties/components/property-display/TextValue.tsx
index 6f4ddd6268..125d92598b 100644
--- a/js/app/packages/core/component/Properties/components/property-display/TextValue.tsx
+++ b/js/app/packages/core/component/Properties/components/property-display/TextValue.tsx
@@ -43,11 +43,6 @@ export const TextValue: Component<TextValueProps> = (props) => {
}
};
- const displayValue = formatPropertyValue(
- props.property,
- props.property.value as string
- );
-
return (
<Show
when={editor.isEditing()}
@@ -62,15 +57,18 @@ export const TextValue: Component<TextValueProps> = (props) => {
>
<Show
when={
- !(
- !props.property.value ||
- (typeof props.property.value === 'string' &&
- props.property.value.length === 0)
- )
+ props.property.value &&
+ typeof props.property.value === 'string' &&
+ props.property.value.length > 0
}
- fallback={<>-</>}
+ fallback={<>—</>}
>
- <span class="block max-w-full">{displayValue}</span>
+ <span class="block max-w-full">
+ {formatPropertyValue(
+ props.property,
+ props.property.value as string
+ )}
+ </span>
</Show>
</button>
}
diff --git a/js/app/packages/core/component/Properties/utils.ts b/js/app/packages/core/component/Properties/utils.ts
index 1c8f37908f..1865feabbc 100644
--- a/js/app/packages/core/component/Properties/utils.ts
+++ b/js/app/packages/core/component/Properties/utils.ts
@@ -112,7 +112,7 @@ export const formatPropertyValue = (
): string => {
// Handle undefined/null values
if (value === undefined || value === null) {
- return '—';
+ return '';
}
// For select types, value is an option ID - look it up in property.options