@@ -3,22 +3,82 @@ export const TAG_SLOT_CONFIG = {
33 slots : [ 'tag1' , 'tag2' , 'tag3' , 'tag4' , 'tag5' , 'tag6' , 'tag7' ] as const ,
44 maxSlots : 7 ,
55 } ,
6+ number : {
7+ slots : [ 'number1' , 'number2' , 'number3' ] as const ,
8+ maxSlots : 3 ,
9+ } ,
10+ date : {
11+ slots : [ 'date1' , 'date2' ] as const ,
12+ maxSlots : 2 ,
13+ } ,
14+ boolean : {
15+ slots : [ 'boolean1' , 'boolean2' ] as const ,
16+ maxSlots : 2 ,
17+ } ,
618} as const
719
820export const SUPPORTED_FIELD_TYPES = Object . keys ( TAG_SLOT_CONFIG ) as Array <
921 keyof typeof TAG_SLOT_CONFIG
1022>
1123
24+ /** Text tag slots (for backwards compatibility) */
1225export const TAG_SLOTS = TAG_SLOT_CONFIG . text . slots
1326
27+ /** All tag slots across all field types */
28+ export const ALL_TAG_SLOTS = [
29+ ...TAG_SLOT_CONFIG . text . slots ,
30+ ...TAG_SLOT_CONFIG . number . slots ,
31+ ...TAG_SLOT_CONFIG . date . slots ,
32+ ...TAG_SLOT_CONFIG . boolean . slots ,
33+ ] as const
34+
1435export const MAX_TAG_SLOTS = TAG_SLOT_CONFIG . text . maxSlots
1536
37+ /** Type for text tag slots (for backwards compatibility) */
1638export type TagSlot = ( typeof TAG_SLOTS ) [ number ]
1739
40+ /** Type for all tag slots */
41+ export type AllTagSlot = ( typeof ALL_TAG_SLOTS ) [ number ]
42+
43+ /** Type for number tag slots */
44+ export type NumberTagSlot = ( typeof TAG_SLOT_CONFIG . number . slots ) [ number ]
45+
46+ /** Type for date tag slots */
47+ export type DateTagSlot = ( typeof TAG_SLOT_CONFIG . date . slots ) [ number ]
48+
49+ /** Type for boolean tag slots */
50+ export type BooleanTagSlot = ( typeof TAG_SLOT_CONFIG . boolean . slots ) [ number ]
51+
52+ /**
53+ * Get the available slots for a field type
54+ */
1855export function getSlotsForFieldType ( fieldType : string ) : readonly string [ ] {
1956 const config = TAG_SLOT_CONFIG [ fieldType as keyof typeof TAG_SLOT_CONFIG ]
2057 if ( ! config ) {
2158 return [ ]
2259 }
2360 return config . slots
2461}
62+
63+ /**
64+ * Get the field type for a tag slot
65+ */
66+ export function getFieldTypeForSlot ( tagSlot : string ) : keyof typeof TAG_SLOT_CONFIG | null {
67+ for ( const [ fieldType , config ] of Object . entries ( TAG_SLOT_CONFIG ) ) {
68+ if ( ( config . slots as readonly string [ ] ) . includes ( tagSlot ) ) {
69+ return fieldType as keyof typeof TAG_SLOT_CONFIG
70+ }
71+ }
72+ return null
73+ }
74+
75+ /**
76+ * Check if a slot is valid for a given field type
77+ */
78+ export function isValidSlotForFieldType ( tagSlot : string , fieldType : string ) : boolean {
79+ const config = TAG_SLOT_CONFIG [ fieldType as keyof typeof TAG_SLOT_CONFIG ]
80+ if ( ! config ) {
81+ return false
82+ }
83+ return ( config . slots as readonly string [ ] ) . includes ( tagSlot )
84+ }
0 commit comments