@@ -5,8 +5,9 @@ import { Plus } from 'lucide-react'
55import { Trash } from '@/components/emcn/icons/trash'
66import { Button } from '@/components/ui/button'
77import { Input } from '@/components/ui/input'
8+ import { Switch } from '@/components/ui/switch'
89import { cn } from '@/lib/core/utils/cn'
9- import { MAX_TAG_SLOTS } from '@/lib/knowledge/constants'
10+ import { SUPPORTED_FIELD_TYPES , TAG_SLOT_CONFIG } from '@/lib/knowledge/constants'
1011import { formatDisplayText } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/formatted-text'
1112import { TagDropdown } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown'
1213import { useSubBlockInput } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-input'
@@ -113,15 +114,26 @@ export function DocumentTagEntry({
113114 ( def ) => ! usedTagNames . has ( def . displayName . toLowerCase ( ) )
114115 )
115116
116- // Check if we can add more tags based on MAX_TAG_SLOTS
117+ // Calculate total available slots across all field types
118+ const totalSlots = Object . values ( TAG_SLOT_CONFIG ) . reduce ( ( sum , config ) => sum + config . maxSlots , 0 )
119+
120+ // Check if we can add more tags
117121 const newTagsBeingCreated = rows . filter (
118122 ( row ) =>
119123 row . cells . tagName ?. trim ( ) &&
120124 ! tagDefinitions . some (
121125 ( def ) => def . displayName . toLowerCase ( ) === row . cells . tagName . toLowerCase ( )
122126 )
123127 ) . length
124- const canAddMoreTags = tagDefinitions . length + newTagsBeingCreated < MAX_TAG_SLOTS
128+ const canAddMoreTags = tagDefinitions . length + newTagsBeingCreated < totalSlots
129+
130+ // Field type labels for display
131+ const FIELD_TYPE_LABELS : Record < string , string > = {
132+ text : 'Text' ,
133+ number : 'Number' ,
134+ date : 'Date' ,
135+ boolean : 'Boolean' ,
136+ }
125137
126138 // Function to pre-fill existing tags
127139 const handlePreFillTags = ( ) => {
@@ -386,7 +398,10 @@ export function DocumentTagEntry({
386398 setTimeout ( ( ) => setShowTypeDropdown ( false ) , 150 )
387399 }
388400
389- const typeOptions = [ { value : 'text' , label : 'Text' } ]
401+ const typeOptions = SUPPORTED_FIELD_TYPES . map ( ( type ) => ( {
402+ value : type ,
403+ label : FIELD_TYPE_LABELS [ type ] || type ,
404+ } ) )
390405
391406 return (
392407 < td className = 'border-r p-1' >
@@ -440,6 +455,7 @@ export function DocumentTagEntry({
440455
441456 const renderValueCell = ( row : DocumentTagRow , rowIndex : number ) => {
442457 const cellValue = row . cells . value || ''
458+ const fieldType = row . cells . type || 'text'
443459 const cellKey = `value-${ rowIndex } `
444460
445461 const fieldState = inputController . fieldHelpers . getFieldState ( cellKey )
@@ -454,6 +470,91 @@ export function DocumentTagEntry({
454470 ( newValue ) => handleTagDropdownSelection ( rowIndex , 'value' , newValue )
455471 )
456472
473+ // Render boolean as a switch
474+ if ( fieldType === 'boolean' ) {
475+ const boolValue = cellValue === 'true'
476+ return (
477+ < td className = 'p-1' >
478+ < div className = 'flex h-9 items-center justify-center' >
479+ < Switch
480+ checked = { boolValue }
481+ onCheckedChange = { ( checked ) => handleCellChange ( rowIndex , 'value' , String ( checked ) ) }
482+ disabled = { disabled }
483+ />
484+ </ div >
485+ </ td >
486+ )
487+ }
488+
489+ // Render date as date input
490+ if ( fieldType === 'date' ) {
491+ return (
492+ < td className = 'p-1' >
493+ < div className = 'relative w-full' >
494+ < Input
495+ ref = { ( el ) => {
496+ if ( el ) valueInputRefs . current [ rowIndex ] = el
497+ } }
498+ type = 'datetime-local'
499+ value = { cellValue }
500+ onChange = { ( e ) => handleCellChange ( rowIndex , 'value' , e . target . value ) }
501+ disabled = { disabled }
502+ className = 'w-full border-0 focus-visible:ring-0 focus-visible:ring-offset-0'
503+ />
504+ </ div >
505+ </ td >
506+ )
507+ }
508+
509+ // Render number as number input
510+ if ( fieldType === 'number' ) {
511+ return (
512+ < td className = 'p-1' >
513+ < div className = 'relative w-full' >
514+ < Input
515+ ref = { ( el ) => {
516+ if ( el ) valueInputRefs . current [ rowIndex ] = el
517+ } }
518+ type = 'number'
519+ value = { cellValue }
520+ onChange = { handlers . onChange }
521+ onKeyDown = { handlers . onKeyDown }
522+ onDrop = { handlers . onDrop }
523+ onDragOver = { handlers . onDragOver }
524+ disabled = { disabled }
525+ autoComplete = 'off'
526+ className = 'w-full border-0 text-transparent caret-foreground placeholder:text-muted-foreground/50 focus-visible:ring-0 focus-visible:ring-offset-0'
527+ />
528+ < div className = 'pointer-events-none absolute inset-0 flex items-center overflow-hidden bg-transparent px-3 text-sm' >
529+ < div className = 'whitespace-pre' >
530+ { formatDisplayText ( cellValue , {
531+ accessiblePrefixes,
532+ highlightAll : ! accessiblePrefixes ,
533+ } ) }
534+ </ div >
535+ </ div >
536+ { fieldState . showTags && (
537+ < TagDropdown
538+ visible = { fieldState . showTags }
539+ onSelect = { tagSelectHandler }
540+ blockId = { blockId }
541+ activeSourceBlockId = { fieldState . activeSourceBlockId }
542+ inputValue = { cellValue }
543+ cursorPosition = { fieldState . cursorPosition }
544+ onClose = { ( ) => inputController . fieldHelpers . hideFieldDropdowns ( cellKey ) }
545+ inputRef = {
546+ {
547+ current : valueInputRefs . current [ rowIndex ] || null ,
548+ } as React . RefObject < HTMLInputElement >
549+ }
550+ />
551+ ) }
552+ </ div >
553+ </ td >
554+ )
555+ }
556+
557+ // Default: text input with tag dropdown support
457558 return (
458559 < td className = 'p-1' >
459560 < div className = 'relative w-full' >
@@ -567,7 +668,7 @@ export function DocumentTagEntry({
567668
568669 { /* Tag slots usage indicator */ }
569670 < div className = 'text-muted-foreground text-xs' >
570- { tagDefinitions . length + newTagsBeingCreated } of { MAX_TAG_SLOTS } tag slots used
671+ { tagDefinitions . length + newTagsBeingCreated } of { totalSlots } tag slots used
571672 </ div >
572673 </ div >
573674 ) }
0 commit comments