Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
style(properties): restyle ceate property and select property modal (#2656)
Seamusd6cc11dbd7e3
diff --git a/js/app/packages/app/component/property-edit-modal/PropertyEditorModal.tsx b/js/app/packages/app/component/property-edit-modal/PropertyEditorModal.tsxindex 499d2d7f22..c3bb50f6b4 100644--- a/js/app/packages/app/component/property-edit-modal/PropertyEditorModal.tsx+++ b/js/app/packages/app/component/property-edit-modal/PropertyEditorModal.tsx@@ -50,7 +50,7 @@ import { useEntitiesForProperty } from './hooks/useEntitiesForProperty';import {useListKeyBindings,type ListNavActions,-} from './hooks/useListKeyBindings';+} from '@core/util/useListKeyBindings';import {getEntityName,getEntityType,diff --git a/js/app/packages/core/component/Properties/component/modal/CreatePropertyModal.tsx b/js/app/packages/core/component/Properties/component/modal/CreatePropertyModal.tsxindex 8f96c60e67..6331903871 100644--- a/js/app/packages/core/component/Properties/component/modal/CreatePropertyModal.tsx+++ b/js/app/packages/core/component/Properties/component/modal/CreatePropertyModal.tsx@@ -1,7 +1,11 @@-import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';-import { MODAL_VIEWPORT_CLASSES } from '@core/util/modalUtils';+import { useBlockId } from '@core/block';+import { Button } from '@ui/components/Button';+import { SegmentedControl } from '@ui/components/SegmentedControl';+import { DialogWrapper } from '@core/component/DialogWrapper';import LoadingSpinner from '@icon/regular/spinner.svg';import XIcon from '@icon/regular/x.svg';+import { Dialog } from '@kobalte/core/dialog';+import { useAddEntityPropertyMutation } from '@queries/properties/entity';import { useCreatePropertyDefinitionMutation } from '@queries/properties/definitions';import { useUserId } from '@core/context/user';import type { EntityType } from '@service-properties/generated/schemas/entityType';@@ -13,8 +17,8 @@ import {Index,Show,} from 'solid-js';-import { Portal } from 'solid-js/web';-import { PROPERTY_STYLES } from '../../styles';++import { usePropertiesContext } from '../../context/PropertiesContext';import {getPropertyDataTypeDropdownOptions,usePropertyNameFocus,@@ -88,7 +92,7 @@ const OptionInput: Component<OptionInputProps<string | number>> = (props) => {}}onKeyDown={(e) => handleKeyDown(e, option().id, option().value)}placeholder={props.placeholder}- class="flex-1 px-2 py-1 border border-edge text-sm"+ class="flex-1 p-1.5 border border-edge-muted/50 text-sm rounded-sm bg-input placeholder:text-ink-placeholder"data-option-id={option().id}/><button@@ -113,12 +117,16 @@ const OptionInput: Component<OptionInputProps<string | number>> = (props) => {interface CreatePropertyModalProps {isOpen: boolean;onClose: () => void;- onPropertyCreated?: () => void;+ onPropertyCreated?: (propertyDefinitionId?: string) => void;+ autoPinOnCreate?: boolean;}export const CreatePropertyModal: Component<CreatePropertyModalProps> = (props) => {+ const blockId = useBlockId();+ const { entityType } = usePropertiesContext();+const [newPropertyName, setNewPropertyName] = createSignal('');const [selectedDataType, setSelectedDataType] =createSignal<DataTypeValue>('string');@@ -131,11 +139,32 @@ export const CreatePropertyModal: Component<CreatePropertyModalProps> = (>([]);const [error, setError] = createSignal<string | null>(null);+ const addMutation = useAddEntityPropertyMutation();+const createPropertyMutation = useCreatePropertyDefinitionMutation({- onSuccess: () => {- resetCreateForm();- props.onPropertyCreated?.();- props.onClose();+ onSuccess: async (propertyDefinition) => {+ // Add the property to the current entity if autoPinOnCreate is true+ if (props.autoPinOnCreate && blockId) {+ try {+ await addMutation.mutateAsync({+ entityId: blockId,+ entityType,+ propertyDefinitionId: propertyDefinition.id,+ });++ resetCreateForm();+ // Pass the property definition ID so parent can pin it after refresh+ props.onPropertyCreated?.(propertyDefinition.id);+ props.onClose();+ } catch (error) {+ console.error('Failed to add property to entity', error);+ setError(ERROR_MESSAGES.PROPERTY_CREATE);+ }+ } else {+ resetCreateForm();+ props.onPropertyCreated?.();+ props.onClose();+ }},onError: () => {setError(ERROR_MESSAGES.PROPERTY_CREATE);@@ -378,184 +407,178 @@ export const CreatePropertyModal: Component<CreatePropertyModalProps> = ();return (- <Portal>- <div- class="fixed inset-0 bg-overlay z-modal-overlay"- onClick={() => props.onClose()}- onKeyDown={(e) => e.key === 'Escape' && props.onClose()}- role="dialog"- aria-modal="true"- >- <div- class={`absolute bg-dialog border-3 border-edge shadow-xl w-full overflow-hidden font-mono max-w-lg max-h-[90vh] ${MODAL_VIEWPORT_CLASSES}`}- style={{- top: '50%',- left: '50%',- transform: 'translate(-50%, -50%)',- }}- onClick={(e) => e.stopPropagation()}- onKeyDown={(e) => e.stopPropagation()}- role="document"- >- <div class="flex items-center justify-between p-4">- <h3 class="text-base font-semibold text-ink">- Create New Property- </h3>- <DeprecatedIconButton- icon={XIcon}- theme="clear"- size="sm"- onClick={() => props.onClose()}- />- </div>-- <div class="px-4 pb-2 overflow-y-auto max-h-[70vh]">- <div class="space-y-3">- <Show when={error()}>- <div class="text-failure-ink text-sm p-2 bg-failure-bg">- {error()}- </div>- </Show>+ <Dialog+ open={props.isOpen}+ onOpenChange={(open) => {+ if (!open) props.onClose();+ }}+ modal={true}+ >+ <Dialog.Portal>+ <DialogWrapper>+ <div class="flex flex-col overflow-hidden bracket-never text-sm">+ <div class="flex items-center justify-between gap-2 bg-panel px-2 h-[40px] border-b border-edge-muted shrink-0">+ <Dialog.Title class="pl-2 text-sm font-medium">+ Create New Property+ </Dialog.Title>+ <Button+ variant="ghost"+ size="icon-sm"+ onClick={() => props.onClose()}+ >+ <XIcon />+ </Button>+ </div>- <div>- <label- for="property-name"- class="block text-xs font-medium text-ink mb-1"- >- Property Name- </label>- <input- id="property-name"- ref={propertyNameInputRef}- type="text"- value={newPropertyName()}- onInput={(e) => setNewPropertyName(e.currentTarget.value)}- placeholder="Enter property name"- class="w-full px-3 py-1.5 border border-edge text-sm focus:outline-none focus:ring-2 focus:ring-accent/50 focus:border-accent"- />- </div>+ <div class="min-h-0 overflow-y-auto scrollbar-hidden p-4">+ <div class="space-y-3">+ <Show when={error()}>+ <div class="text-failure-ink text-sm p-2 bg-failure-bg">+ {error()}+ </div>+ </Show>- <div>- <label class="block text-xs font-medium text-ink mb-1">- Data Type- </label>- <Dropdown- value={selectedDataType()}- options={dataTypeDropdownOptions}- onChange={(value) => {- setSelectedDataType(value);- // Reset options when changing type- setNewStringOptions([]);- setNewNumberOptions([]);- setIsMultiSelect(false);- }}- placeholder="Select type"- />- </div>+ <div>+ <label+ for="property-name"+ class="block text-xs font-medium text-ink mb-1"+ >+ Property Name+ </label>+ <input+ id="property-name"+ ref={propertyNameInputRef}+ type="text"+ value={newPropertyName()}+ onInput={(e) => setNewPropertyName(e.currentTarget.value)}+ placeholder="Enter property name"+ class="w-full p-1.5 border border-edge-muted/50 text-sm rounded-sm bg-input placeholder:text-ink-placeholder"+ />+ </div>- <Show when={shouldShowMultiSelect()}><div><label class="block text-xs font-medium text-ink mb-1">- Selection Type+ Data Type</label>- <div class="flex gap-2">- <button- type="button"- onClick={() => setIsMultiSelect(false)}- class={`flex-1 px-3 py-1.5 text-sm border ${!isMultiSelect() ? 'border-accent bg-active text-accent-ink' : 'bg-button border-edge text-ink hover:bg-hover'}`}- >- Single Select- </button>- <button- type="button"- onClick={() => setIsMultiSelect(true)}- class={`flex-1 px-3 py-1.5 text-sm border ${isMultiSelect() ? 'border-accent bg-active text-accent-ink' : 'bg-button border-edge text-ink hover:bg-hover'}`}- >- Multi Select- </button>- </div>+ <Dropdown+ value={selectedDataType()}+ options={dataTypeDropdownOptions}+ onChange={(value) => {+ setSelectedDataType(value);+ setNewStringOptions([]);+ setNewNumberOptions([]);+ setIsMultiSelect(false);+ }}+ placeholder="Select type"+ /></div>- </Show>- <Show when={shouldShowOptions()}>- <div>- <div class="flex items-center justify-between mb-2">- <label class="block text-xs font-medium text-ink">- Options+ <Show when={shouldShowMultiSelect()}>+ <div>+ <label class="block text-xs font-medium text-ink mb-1">+ Selection Type</label>- <button- type="button"- onClick={() => {- const { type } = parseDataTypeValue(selectedDataType());- if (type === 'select_string') {- addOption(newStringOptions, setNewStringOptions, '');- } else {- addOption(newNumberOptions, setNewNumberOptions, 0);- }- }}- class="px-2 py-1 text-xs bg-accent text-ink hover:bg-accent/90"- >- + Add Option- </button>+ <SegmentedControl+ value={isMultiSelect()}+ onChange={setIsMultiSelect}+ options={[+ { value: false, label: 'Single Select' },+ { value: true, label: 'Multi Select' },+ ]}+ aria-label="Selection type"+ /></div>- <Show- when={selectedDataType() === 'select_string'}- fallback={+ </Show>++ <Show when={shouldShowOptions()}>+ <div>+ <div class="flex items-center justify-between mb-2">+ <label class="block text-xs font-medium text-ink">+ Options+ </label>+ <Button+ variant="secondary"+ size="sm"+ class="rounded-xs"+ onClick={() => {+ const { type } = parseDataTypeValue(+ selectedDataType()+ );+ if (type === 'select_string') {+ addOption(+ newStringOptions,+ setNewStringOptions,+ ''+ );+ } else {+ addOption(newNumberOptions, setNewNumberOptions, 0);+ }+ }}+ >+ + Add Option+ </Button>+ </div>+ <Show+ when={selectedDataType() === 'select_string'}+ fallback={+ <OptionInput+ options={newNumberOptions}+ type="number"+ onAdd={() =>+ addOption(newNumberOptions, setNewNumberOptions, 0)+ }+ onRemove={(id) =>+ removeOption(+ newNumberOptions,+ setNewNumberOptions,+ id+ )+ }+ onUpdate={(id, value) =>+ updateOption(+ newNumberOptions,+ setNewNumberOptions,+ id,+ value as number+ )+ }+ placeholder="Enter number"+ />+ }+ ><OptionInput- options={newNumberOptions}- type="number"+ options={newStringOptions}+ type="string"onAdd={() =>- addOption(newNumberOptions, setNewNumberOptions, 0)+ addOption(newStringOptions, setNewStringOptions, '')}onRemove={(id) =>removeOption(- newNumberOptions,- setNewNumberOptions,+ newStringOptions,+ setNewStringOptions,id)}onUpdate={(id, value) =>updateOption(- newNumberOptions,- setNewNumberOptions,+ newStringOptions,+ setNewStringOptions,id,- value as number+ value as string)}- placeholder="Enter number"+ placeholder="Enter option value"/>- }- >- <OptionInput- options={newStringOptions}- type="string"- onAdd={() =>- addOption(newStringOptions, setNewStringOptions, '')- }- onRemove={(id) =>- removeOption(newStringOptions, setNewStringOptions, id)- }- onUpdate={(id, value) =>- updateOption(- newStringOptions,- setNewStringOptions,- id,- value as string- )- }- placeholder="Enter option value"- />- </Show>- </div>- </Show>+ </Show>+ </div>+ </Show>+ </div></div>- </div>- <div class="flex items-center justify-between p-4 pt-2">- <div class="flex gap-2">- <button- type="button"- class={`${PROPERTY_STYLES.button.base} ${PROPERTY_STYLES.button.secondary}`}+ <div class="flex items-center justify-end gap-2 px-2 py-1.5 border-t border-edge-muted shrink-0">+ <Button+ variant="ghost"+ class="rounded-xs"onClick={() => {resetCreateForm();props.onClose();@@ -563,33 +586,33 @@ export const CreatePropertyModal: Component<CreatePropertyModalProps> = (disabled={createPropertyMutation.isPending}>Cancel- </button>- </div>- <button- type="button"- class={`${PROPERTY_STYLES.button.base} ${PROPERTY_STYLES.button.accent} ${newPropertyName().trim() && !createPropertyMutation.isPending ? '' : 'cursor-not-allowed'}`}- onClick={handleCreateProperty}- disabled={- !newPropertyName().trim() || createPropertyMutation.isPending- }- >- <Show- when={!createPropertyMutation.isPending}- fallback={- <div class="flex items-center gap-1.5">- <div class="w-3 h-3 animate-spin">- <LoadingSpinner />- </div>- Creating...- </div>+ </Button>+ <Button+ variant="secondary"+ class="rounded-xs"+ onClick={handleCreateProperty}+ disabled={+ !newPropertyName().trim() || createPropertyMutation.isPending}>- Create Property- </Show>- </button>+ <Show+ when={!createPropertyMutation.isPending}+ fallback={+ <div class="flex items-center gap-1.5">+ <div class="w-3 h-3 animate-spin">+ <LoadingSpinner />+ </div>+ Creating...+ </div>+ }+ >+ Create Property+ </Show>+ </Button>+ </div></div>- </div>- </div>- </Portal>+ </DialogWrapper>+ </Dialog.Portal>+ </Dialog>);};diff --git a/js/app/packages/core/component/Properties/component/modal/Modals.tsx b/js/app/packages/core/component/Properties/component/modal/Modals.tsxindex 3297d49b85..1074c28515 100644--- a/js/app/packages/core/component/Properties/component/modal/Modals.tsx+++ b/js/app/packages/core/component/Properties/component/modal/Modals.tsx@@ -1,4 +1,9 @@-import { type Component, createMemo } from 'solid-js';+import {+ type Component,+ createEffect,+ createMemo,+ createSignal,+} from 'solid-js';import { Show } from 'solid-js/web';import { usePropertiesContext } from '../../context/PropertiesContext';import { CreatePropertyModal } from './CreatePropertyModal';@@ -17,8 +22,28 @@ export const Modals: Component = () => {closePropertySelector,closePropertyEditor,closeCreateProperty,+ onPropertyPinned,} = usePropertiesContext();+ const [pendingPinDefinitionId, setPendingPinDefinitionId] = createSignal<+ string | null+ >(null);++ // Effect to pin property after it's been added and appears in the list+ createEffect(() => {+ const definitionId = pendingPinDefinitionId();+ if (!definitionId || !onPropertyPinned) return;++ const addedProperty = properties().find(+ (p) => p.propertyDefinitionId === definitionId+ );++ if (addedProperty) {+ onPropertyPinned(addedProperty.propertyId);+ setPendingPinDefinitionId(null);+ }+ });+const existingPropertyIds = createMemo(() => {return properties().map((prop) => prop.propertyDefinitionId);});@@ -28,8 +53,13 @@ export const Modals: Component = () => {closePropertyEditor();};- const handlePropertyCreated = () => {- onPropertyAdded();+ const handlePropertyCreated = (propertyDefinitionId?: string) => {+ if (propertyDefinitionId) {+ onPropertyAdded([propertyDefinitionId]);+ setPendingPinDefinitionId(propertyDefinitionId);+ } else {+ onPropertyAdded();+ }closeCreateProperty();};@@ -56,11 +86,14 @@ export const Modals: Component = () => {</Show><Show when={createPropertyModal()}>- <CreatePropertyModal- isOpen={true}- onClose={closeCreateProperty}- onPropertyCreated={handlePropertyCreated}- />+ {(state) => (+ <CreatePropertyModal+ isOpen={true}+ onClose={closeCreateProperty}+ onPropertyCreated={handlePropertyCreated}+ autoPinOnCreate={state().autoPinOnCreate}+ />+ )}</Show></>);diff --git a/js/app/packages/core/component/Properties/component/modal/SelectPropertyModal.tsx b/js/app/packages/core/component/Properties/component/modal/SelectPropertyModal.tsxindex f98430f3a7..84fa2d7f7f 100644--- a/js/app/packages/core/component/Properties/component/modal/SelectPropertyModal.tsx+++ b/js/app/packages/core/component/Properties/component/modal/SelectPropertyModal.tsx@@ -1,41 +1,42 @@import { useBlockId } from '@core/block';-import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';-import { MODAL_VIEWPORT_CLASSES } from '@core/util/modalUtils';-import CheckIcon from '@icon/bold/check-bold.svg';-import SearchIcon from '@icon/regular/magnifying-glass.svg';+import { DialogWrapper } from '@core/component/DialogWrapper';+import { useListKeyBindings } from '@core/util/useListKeyBindings';import LoadingSpinner from '@icon/regular/spinner.svg';-import XIcon from '@icon/regular/x.svg';+import PlusIcon from '@icon/regular/plus.svg';+import { Dialog } from '@kobalte/core/dialog';import { useAddEntityPropertyMutation } from '@queries/properties/entity';+import { useListPropertiesQuery } from '@queries/properties/definitions';+import { cn } from '@ui/utils/classname';import {createEffect,createMemo,+ createSelector,createSignal,For,- onCleanup,Show,} from 'solid-js';-import { Portal } from 'solid-js/web';-import { MODAL_DIMENSIONS } from '../../constants';import { usePropertiesContext } from '../../context/PropertiesContext';import { usePropertySelection } from '../../hooks/usePropertySelection';-import { PROPERTY_STYLES } from '../../styles';import type {PropertyDefinitionDomain,PropertySelectorProps,} from '../../types';import {getPropertyDefinitionTypeDisplay,+ PropertyDataTypeIcon,toPropertyDefinitionDomain,useSearchInputFocus,} from '../../utils';-import { useListPropertiesQuery } from '@queries/properties/definitions';export function SelectPropertyModal(props: PropertySelectorProps) {const blockId = useBlockId();const { entityType, onPropertyAdded, openCreateProperty } =usePropertiesContext();- const [isAdding, setIsAdding] = createSignal(false);+const [searchQuery, setSearchQuery] = createSignal('');+ const [focusedIndex, setFocusedIndex] = createSignal(0);++ const [dialogRef, setDialogRef] = createSignal<HTMLDivElement | undefined>();const addMutation = useAddEntityPropertyMutation();@@ -69,69 +70,38 @@ export function SelectPropertyModal(props: PropertySelectorProps) {});let searchInputRef!: HTMLInputElement;- let modalRef!: HTMLDivElement;- const { selectedPropertyIds, filteredProperties, togglePropertySelection } =- usePropertySelection(props.existingPropertyIds, availableProperties, () =>- searchQuery()- );+ const { filteredProperties } = usePropertySelection(+ props.existingPropertyIds,+ availableProperties,+ () => searchQuery()+ );- const handleAddProperties = async () => {- const selected = Array.from(selectedPropertyIds());- if (selected.length === 0) return;+ const createLabel = createMemo(() => {+ const query = searchQuery().trim();+ return query ? `Create Property "${query}"` : 'Create New Property';+ });- setIsAdding(true);+ const createIndex = createMemo(() => filteredProperties().length);+ const addProperty = async (propertyDefinitionId: string) => {try {- const addPromises = selected.map(async (propertyDefinitionId) => {- try {- await addMutation.mutateAsync({- entityId: blockId,- entityType,- propertyDefinitionId,- });- return propertyDefinitionId;- } catch {- // Error toast is shown by mutation's onError callback- return undefined;- }+ await addMutation.mutateAsync({+ entityId: blockId,+ entityType,+ propertyDefinitionId,});-- const results = await Promise.all(addPromises);- const succeeded = results.filter((id): id is string => !!id);-- props.onClose();-- if (succeeded.length > 0) {- onPropertyAdded(succeeded);- }+ onPropertyAdded([propertyDefinitionId]);+ } catch {+ // Error toast is shown by mutation's onError callback} finally {- setIsAdding(false);+ props.onClose();}};- // Always center horizontally but anchor to top for stable positioning- const modalPosition = () => {- const viewportHeight = window.innerHeight;- const topPercentage = MODAL_DIMENSIONS.SELECTOR_TOP_PERCENTAGE;- const minTopMargin = MODAL_DIMENSIONS.SELECTOR_MIN_TOP_MARGIN;-- const topPosition = Math.max(minTopMargin, viewportHeight * topPercentage);-- const finalTopPosition =- viewportHeight < MODAL_DIMENSIONS.SELECTOR_SMALL_SCREEN_THRESHOLD- ? Math.max(- minTopMargin,- viewportHeight *- MODAL_DIMENSIONS.SELECTOR_SMALL_SCREEN_TOP_PERCENTAGE- )- : topPosition;-- return {- top: `${finalTopPosition}px`,- left: '50%',- transform: 'translateX(-50%)',- };+ const handleCreate = () => {+ props.onClose();+ openCreateProperty(true);};useSearchInputFocus(@@ -146,202 +116,129 @@ export function SelectPropertyModal(props: PropertySelectorProps) {});createEffect(() => {- if (!props.isOpen) return;+ searchQuery();+ setFocusedIndex(0);+ });- const handleResize = () => {- if (modalRef) {- const newPosition = modalPosition();- modalRef.style.top = newPosition.top;- modalRef.style.left = newPosition.left;- modalRef.style.transform = newPosition.transform;- }- };+ createEffect(() => {+ const index = focusedIndex();+ const elem = document.getElementById(`select-property-option-${index}`);+ if (elem) {+ elem.scrollIntoView({ block: 'nearest' });+ }+ });++ const setKeybindings = useListKeyBindings(dialogRef);- window.addEventListener('resize', handleResize);- onCleanup(() => window.removeEventListener('resize', handleResize));+ createEffect(() => {+ const items = filteredProperties();+ const totalLen = items.length + 1; // +1 for Create row+ setKeybindings({+ next: () => setFocusedIndex((prev) => (prev + 1) % totalLen),+ previous: () =>+ setFocusedIndex((prev) => (prev - 1 + totalLen) % totalLen),+ select: () => {+ const idx = focusedIndex();+ if (idx >= items.length) {+ handleCreate();+ } else {+ addProperty(items[idx].id);+ }+ },+ });});- return (- <Portal>- <div- class="fixed inset-0 z-modal-overlay"- onClick={() => props.onClose()}- onKeyDown={(e) => e.key === 'Escape' && props.onClose()}- role="dialog"- aria-modal="true"- >- <div- ref={modalRef}- class={`absolute bg-dialog border-3 border-edge shadow-xl w-full overflow-hidden font-mono z-modal-content max-w-md max-h-[80vh] ${MODAL_VIEWPORT_CLASSES}`}- style={{- ...modalPosition(),- 'max-width': '28rem',- 'max-height': '80vh',- }}- onClick={(e) => e.stopPropagation()}- onKeyDown={(e) => e.stopPropagation()}- role="document"- >- <div class="flex items-center justify-between p-4">- <h3 class="text-base font-semibold text-ink">Add Properties</h3>- <DeprecatedIconButton- icon={XIcon}- theme="clear"- size="sm"- onClick={() => props.onClose()}- />- </div>+ const isFocused = createSelector(focusedIndex);- <Show when={availableProperties().length > 0}>- <div class="px-4 pb-2">- <div class="relative">- <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none z-10">- <SearchIcon class="h-4 w-4 text-ink-muted" />- </div>- <input- ref={searchInputRef}- type="text"- value={searchQuery()}- onInput={(e) => setSearchQuery(e.currentTarget.value)}- placeholder="Search properties..."- class={`${PROPERTY_STYLES.input.search} relative z-0`}- />- </div>+ return (+ <Dialog+ open={props.isOpen}+ onOpenChange={(open) => {+ if (!open) props.onClose();+ }}+ modal={true}+ >+ <Dialog.Portal>+ <DialogWrapper contentRef={setDialogRef}>+ <div class="flex flex-col overflow-hidden bracket-never text-sm">+ <div class="flex items-center gap-2 bg-panel px-2 h-[40px] border-b border-edge-muted shrink-0">+ <span class="pl-2 pointer-events-none">❯</span>+ <input+ ref={searchInputRef}+ type="text"+ value={searchQuery()}+ onInput={(e) => setSearchQuery(e.currentTarget.value)}+ placeholder="Add a property..."+ class="flex-1 text-base border-0 outline-none! focus:outline-none ring-0! focus:ring-0 bg-transparent"+ autofocus+ /></div>- </Show>- <div class="px-4 pb-2 overflow-y-auto max-h-[60vh]">- <Show- when={!listPropertiesQuery.isLoading}- fallback={- <div class="flex items-center justify-center py-8">- <div class="w-5 h-5 animate-spin">- <LoadingSpinner />- </div>- <span class="ml-2 text-ink-muted">Loading properties...</span>- </div>- }- >- <Show when={!listPropertiesQuery.error}>- <Show- when={availableProperties().length > 0}- fallback={- <div class="text-center py-6">- <div class="text-ink-muted text-sm">- No additional properties available- </div>+ <div class="min-h-0 overflow-y-auto scrollbar-hidden">+ <Show+ when={!listPropertiesQuery.isLoading}+ fallback={+ <div class="flex items-center justify-center py-8">+ <div class="w-5 h-5 animate-spin">+ <LoadingSpinner /></div>- }- >- <div class="space-y-2 max-h-80 overflow-y-auto">- <Show- when={filteredProperties().length > 0}- fallback={- <div class="text-center py-4 text-ink-muted text-sm">- No properties match your search- </div>- }- >- <For each={filteredProperties()}>- {(property) => {- const isSelected = () =>- selectedPropertyIds().has(property.id);-- return (- <button- type="button"- class={`w-full px-2.5 py-1.5 text-left border ${isSelected() ? 'bg-active border-accent text-accent-ink' : 'hover:bg-hover border-edge text-ink'}`}- onClick={() =>- togglePropertySelection(property.id)- }- >- <div class="flex items-center justify-between">- <div class="flex-1">- <div class="flex items-center gap-2">- <h4 class="font-medium text-xs">- {property.displayName}- </h4>- </div>- <div class="text-xs text-ink-muted mt-0.5">- {getPropertyDefinitionTypeDisplay({- dataType: property.valueType,- specificEntityType:- property.specificEntityType,- isMultiSelect: property.isMultiSelect,- })}- </div>- </div>- <div- class={`${PROPERTY_STYLES.checkbox.base} border-edge bg-transparent`}- >- <Show when={isSelected()}>- <CheckIcon class="w-3 h-3 text-accent" />- </Show>- </div>- </div>- </button>- );- }}- </For>- </Show>+ <span class="ml-2 text-ink-muted">+ Loading properties...+ </span></div>- </Show>- </Show>- </Show>- </div>-- <div class="flex items-center justify-between p-4 pt-2">- <button- type="button"- class={`${PROPERTY_STYLES.button.base} ${PROPERTY_STYLES.button.secondary}`}- onClick={() => props.onClose()}- disabled={isAdding()}- >- Cancel- </button>- <Show when={selectedPropertyIds().size > 0}>- <button- type="button"- class={`${PROPERTY_STYLES.button.base} ${selectedPropertyIds().size > 0 && !isAdding() ? PROPERTY_STYLES.button.accent : 'bg-ink-muted text-ink cursor-not-allowed'}`}- onClick={handleAddProperties}- disabled={selectedPropertyIds().size === 0 || isAdding()}+ }>- <Show- when={!isAdding()}- fallback={- <div class="flex items-center gap-1.5">- <div class="w-3 h-3 animate-spin">- <LoadingSpinner />- </div>- Adding...- </div>- }- >- Add{' '}- {selectedPropertyIds().size > 0- ? `(${selectedPropertyIds().size})`- : ''}- </Show>- </button>- </Show>- <Show when={selectedPropertyIds().size === 0}>- <div class="flex gap-2">- <button- type="button"- onClick={() => {- props.onClose();- openCreateProperty();- }}- class={`${PROPERTY_STYLES.button.base} ${PROPERTY_STYLES.button.accent}`}- disabled={false}- >- Create New Property- </button>- </div>- </Show>+ <div class="p-1">+ <For each={filteredProperties()}>+ {(property, index) => (+ <button+ type="button"+ id={`select-property-option-${index()}`}+ class={cn(+ 'flex flex-row w-full items-center gap-2 py-1.5 px-2 scroll-my-1',+ isFocused(index()) && 'bg-hover'+ )}+ onClick={() => addProperty(property.id)}+ onMouseEnter={() => setFocusedIndex(index())}+ >+ <PropertyDataTypeIcon+ property={property}+ class="opacity-50 shrink-0"+ />+ <p class="text-sm font-medium truncate text-left grow-1">+ {property.displayName}+ </p>+ <p class="text-sm text-ink-extra-muted/50 shrink-0">+ {getPropertyDefinitionTypeDisplay({+ dataType: property.valueType,+ specificEntityType: property.specificEntityType,+ isMultiSelect: property.isMultiSelect,+ })}+ </p>+ </button>+ )}+ </For>+ <button+ type="button"+ id={`select-property-option-${createIndex()}`}+ class={cn(+ 'flex flex-row w-full items-center gap-2 py-1.5 px-2 scroll-my-1',+ isFocused(createIndex()) && 'bg-hover'+ )}+ onClick={handleCreate}+ onMouseEnter={() => setFocusedIndex(createIndex())}+ >+ <PlusIcon class="size-4 shrink-0" />+ <p class="text-sm font-medium truncate flex-1 text-left">+ {createLabel()}+ </p>+ </button>+ </div>+ </Show>+ </div></div>- </div>- </div>- </Portal>+ </DialogWrapper>+ </Dialog.Portal>+ </Dialog>);}diff --git a/js/app/packages/core/component/Properties/component/modal/shared/Dropdown.tsx b/js/app/packages/core/component/Properties/component/modal/shared/Dropdown.tsxindex a510e8c814..bdddc13a0d 100644--- a/js/app/packages/core/component/Properties/component/modal/shared/Dropdown.tsx+++ b/js/app/packages/core/component/Properties/component/modal/shared/Dropdown.tsx@@ -1,3 +1,5 @@+import { ScopedPortal } from '@core/component/ScopedPortal';+import { cn } from '@ui/utils/classname';import ChevronDownIcon from '@icon/bold/caret-down-bold.svg';import CheckIcon from '@icon/bold/check-bold.svg';import {@@ -9,7 +11,6 @@ import {onCleanup,Show,} from 'solid-js';-import { Portal } from 'solid-js/web';export type DropdownOption<T> = {value: T;@@ -116,17 +117,17 @@ export const Dropdown = <T extends string | number>(ref={buttonRef}type="button"onClick={() => setIsOpen(!isOpen())}- class="w-full px-3 py-1.5 border border-edge-muted bg-menu text-sm text-ink text-left flex items-center gap-2 hover:bg-hover font-mono"+ class="w-full p-1.5 border border-edge-muted/50 bg-input text-sm text-ink text-left flex items-center gap-2 hover:bg-hover rounded-sm">{props.renderValue?.(selectedOption()) ??defaultRenderValue(selectedOption())}<ChevronDownIcon class="w-3 h-3 text-ink-muted flex-shrink-0" /></button><Show when={isOpen()}>- <Portal>+ <ScopedPortal scope="local"><divref={menuRef}- class="z-toast-region border border-edge bg-menu shadow-lg max-h-64 overflow-y-auto font-mono"+ class="z-toast-region border border-edge-muted/50 bg-menu shadow-lg max-h-64 overflow-y-auto p-1"style={getMenuStyle()}><For each={props.options}>@@ -144,13 +145,14 @@ export const Dropdown = <T extends string | number>(}}}disabled={isDisabled()}- class={`w-full px-3 py-2 text-sm text-left flex items-center justify-between ${+ class={cn(+ 'w-full p-1.5 text-sm text-left flex items-center justify-between',isDisabled()? 'opacity-50 cursor-not-allowed': isSelected()- ? 'bg-active text-accent-ink'- : 'hover:bg-hover text-ink'- }`}+ ? 'bg-active text-ink'+ : 'hover:bg-hover/50 text-ink'+ )}>{props.renderOption?.(option, isSelected()) ??defaultRenderOption(option, isSelected())}@@ -159,7 +161,7 @@ export const Dropdown = <T extends string | number>(}}</For></div>- </Portal>+ </ScopedPortal></Show></div>);diff --git a/js/app/packages/core/component/Properties/component/panel/AddPropertyButton.tsx b/js/app/packages/core/component/Properties/component/panel/AddPropertyButton.tsxindex 60a3ca7654..776538f7eb 100644--- a/js/app/packages/core/component/Properties/component/panel/AddPropertyButton.tsx+++ b/js/app/packages/core/component/Properties/component/panel/AddPropertyButton.tsx@@ -1,3 +1,4 @@+import { Button } from '@ui/components/Button';import type { Component } from 'solid-js';interface AddPropertyButtonProps {@@ -6,11 +7,8 @@ interface 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"- onClick={props.onClick}- >- <span class="text-md leading-none">+ ADD PROPERTY</span>- </button>+ <Button variant="secondary" class="w-full" onClick={props.onClick}>+ + Add Property+ </Button>);};diff --git a/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx b/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsxindex c875398445..0ac2bee7f3 100644--- a/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx+++ b/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx@@ -1,5 +1,6 @@import { useMaybeBlockAliasedName, useMaybeBlockId } from '@core/block';-import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';+import { Button } from '@ui/components/Button';+import { DialogWrapper } from '@core/component/DialogWrapper';import DeleteIcon from '@icon/bold/x-bold.svg';import PinIcon from '@icon/regular/push-pin.svg';import UnpinIcon from '@icon/regular/push-pin-slash.svg';@@ -115,15 +116,18 @@ export const PropertyLabel: Component<PropertyLabelProps> = (props) => {isHovered() ? 'opacity-100' : 'opacity-0'}`}>- <DeprecatedIconButton- icon={isPinned() ? UnpinIcon : PinIcon}- theme="clear"- size="xs"- tooltip={{- label: isPinned() ? 'Unpin property' : 'Pin property',- }}+ <Button+ variant="ghost"+ class="p-1"+ tooltip={isPinned() ? 'Unpin property' : 'Pin property'}onClick={handlePinClick}- />+ >+ {isPinned() ? (+ <UnpinIcon class="size-3" />+ ) : (+ <PinIcon class="size-3" />+ )}+ </Button></div></Show>@@ -133,14 +137,14 @@ export const PropertyLabel: Component<PropertyLabelProps> = (props) => {isHovered() ? 'opacity-100' : 'opacity-0'}`}>- <DeprecatedIconButton- icon={DeleteIcon}- theme="clear"- size="xs"- class="!text-failure hover:!bg-failure/15"- tooltip={{ label: 'Remove property' }}+ <Button+ variant="ghost"+ class="p-1 !text-failure hover:!bg-failure/15"+ tooltip="Remove property"onClick={handleDeleteClick}- />+ >+ <DeleteIcon class="size-3" />+ </Button></div></Show></Show>@@ -151,46 +155,46 @@ export const PropertyLabel: Component<PropertyLabelProps> = (props) => {onOpenChange={setDeleteConfirmVisible}><Dialog.Portal>- <Dialog.Overlay class="fixed inset-0 z-modal-overlay bg-overlay" />- <div class="fixed inset-0 z-modal-content flex items-center justify-center p-4">- <Dialog.Content class="bg-dialog border-3 border-edge shadow-xl max-w-md w-full">- <div class="flex items-center justify-between p-4">- <Dialog.Title class="text-lg font-semibold text-ink">+ <DialogWrapper>+ <div class="flex flex-col overflow-hidden bracket-never text-sm">+ <div class="flex items-center justify-between gap-2 bg-panel px-2 h-[40px] border-b border-edge-muted shrink-0">+ <Dialog.Title class="pl-2 text-sm font-medium">Delete Property</Dialog.Title>- <DeprecatedIconButton- icon={XIcon}- theme="clear"- size="sm"+ <Button+ variant="ghost"+ size="icon-sm"onClick={handleDeleteCancel}disabled={deleteMutation.isPending}- />+ >+ <XIcon />+ </Button></div>- <div class="px-4 pb-4">- <Dialog.Description class="text-sm text-ink-muted mb-4">+ <div class="p-4">+ <Dialog.Description class="text-sm text-ink-muted">Are you sure you want to remove property "{props.property.displayName}"{documentName ? ` from "${documentName}"` : ''}?</Dialog.Description>- <div class="flex justify-end gap-2">- <button- onClick={handleDeleteCancel}- disabled={deleteMutation.isPending}- class="px-3 py-1.5 text-sm border text-ink-muted hover:text-ink border-edge hover:bg-hover"- >- Cancel- </button>- <button- onClick={handleDeleteConfirm}- disabled={deleteMutation.isPending}- class="px-3 py-1.5 text-sm border bg-failure/90 hover:bg-failure/80 text-ink disabled:opacity-50"- >- {deleteMutation.isPending ? 'Deleting...' : 'Delete'}- </button>- </div></div>- </Dialog.Content>- </div>+ <div class="flex items-center justify-end gap-2 px-2 py-1.5 border-t border-edge-muted shrink-0">+ <Button+ variant="ghost"+ onClick={handleDeleteCancel}+ disabled={deleteMutation.isPending}+ >+ Cancel+ </Button>+ <Button+ variant="destructive"+ onClick={handleDeleteConfirm}+ disabled={deleteMutation.isPending}+ >+ {deleteMutation.isPending ? 'Deleting...' : 'Delete'}+ </Button>+ </div>+ </div>+ </DialogWrapper></Dialog.Portal></Dialog></>diff --git a/js/app/packages/core/component/Properties/constants.ts b/js/app/packages/core/component/Properties/constants.tsindex 46026ea4f4..c156d8c015 100644--- a/js/app/packages/core/component/Properties/constants.ts+++ b/js/app/packages/core/component/Properties/constants.ts@@ -95,10 +95,6 @@ export const MODAL_DIMENSIONS = {DEFAULT_WIDTH: 448, // 28remDEFAULT_HEIGHT: 384, // 24remPROPERTY_EDITOR_HEIGHT: 384,- SELECTOR_TOP_PERCENTAGE: 0.2, // 20% from top- SELECTOR_MIN_TOP_MARGIN: 16, // 1rem- SELECTOR_SMALL_SCREEN_THRESHOLD: 600, // Mobile breakpoint- SELECTOR_SMALL_SCREEN_TOP_PERCENTAGE: 0.1, // 10% from top} as const;// Common option ids for mapping to custom icons.diff --git a/js/app/packages/core/component/Properties/context/PropertiesContext.tsx b/js/app/packages/core/component/Properties/context/PropertiesContext.tsxindex 0616056402..c5a77678c1 100644--- a/js/app/packages/core/component/Properties/context/PropertiesContext.tsx+++ b/js/app/packages/core/component/Properties/context/PropertiesContext.tsx@@ -27,6 +27,7 @@ export interface DatePickerModalState {export interface CreatePropertyModalState {isOpen: boolean;+ autoPinOnCreate?: boolean;}export interface PropertySaveHandler {@@ -66,7 +67,7 @@ export interface PropertiesContextValue {) => void;closeDatePicker: () => void;- openCreateProperty: () => void;+ openCreateProperty: (autoPinOnCreate?: boolean) => void;closeCreateProperty: () => void;// Convenience function to close all modals@@ -131,8 +132,8 @@ export function PropertiesProvider(props: PropertiesProviderProps) {};// Create Property actions- const openCreateProperty = () => {- setCreatePropertyModal({ isOpen: true });+ const openCreateProperty = (autoPinOnCreate?: boolean) => {+ setCreatePropertyModal({ isOpen: true, autoPinOnCreate });};const closeCreateProperty = () => {diff --git a/js/app/packages/app/component/property-edit-modal/hooks/useListKeyBindings.ts b/js/app/packages/core/util/useListKeyBindings.tssimilarity index 100%rename from js/app/packages/app/component/property-edit-modal/hooks/useListKeyBindings.tsrename to js/app/packages/core/util/useListKeyBindings.tsdiff --git a/js/app/packages/ui/components/SegmentedControl.tsx b/js/app/packages/ui/components/SegmentedControl.tsxnew file mode 100644index 0000000000..1494240c91--- /dev/null+++ b/js/app/packages/ui/components/SegmentedControl.tsx@@ -0,0 +1,66 @@+import { SegmentedControl as KSegmentedControl } from '@kobalte/core/segmented-control';+import { cn } from '@ui/utils/classname';+import { For, type JSX } from 'solid-js';++export type SegmentedControlOption<T extends string | number | boolean> = {+ value: T;+ label: string;+ disabled?: boolean;+};++type SegmentedControlProps<T extends string | number | boolean> = {+ value: T;+ options: Array<SegmentedControlOption<T>>;+ onChange: (value: T) => void;+ class?: string;+ size?: 'sm' | 'md';+ 'aria-label'?: string;+};++const serialize = (v: string | number | boolean): string => String(v);++export const SegmentedControl = <T extends string | number | boolean>(+ props: SegmentedControlProps<T>+): JSX.Element => {+ const size = () => props.size ?? 'md';++ const handleChange = (serialized: string) => {+ const match = props.options.find((o) => serialize(o.value) === serialized);+ if (match && !match.disabled) {+ props.onChange(match.value);+ }+ };++ return (+ <KSegmentedControl+ value={serialize(props.value)}+ onChange={handleChange}+ aria-label={props['aria-label']}+ class={cn(+ 'border border-edge-muted rounded-xs inline-flex overflow-hidden',+ props.class+ )}+ >+ <For each={props.options}>+ {(option) => (+ <KSegmentedControl.Item+ value={serialize(option.value)}+ disabled={option.disabled}+ class={cn(+ 'relative flex items-center justify-center border-r border-edge-muted last:border-r-0 font-medium',+ size() === 'sm' ? 'px-2 py-1 text-xs' : 'px-3 py-1.5 text-sm',+ option.disabled+ ? 'opacity-50'+ : 'text-ink-muted hover:text-ink hover:bg-ink/15 data-[checked]:text-ink data-[checked]:bg-ink/10 data-[checked]:hover:bg-ink/20'+ )}+ >+ <KSegmentedControl.ItemInput class="absolute inset-0 pointer-events-none" />+ <KSegmentedControl.ItemLabel>+ {option.label}+ </KSegmentedControl.ItemLabel>+ </KSegmentedControl.Item>+ )}+ </For>+ </KSegmentedControl>+ );+};