@@ -14,9 +14,13 @@ import DtcControlString from '@/src/components/controls/control_string.vue';
1414import DtcControlNullish from '@/src/components/controls/control_nullish.vue' ;
1515import DtcControlBase from '@/src/components/controls/control_base.vue' ;
1616import DtcControlIconSlot from '@/src/components/controls/control_icon_slot.vue' ;
17+ import DtcControlSegmented from '@/src/components/controls/control_segmented.vue' ;
1718
1819import { typeOfMemberValue } from '@/src/lib/utils' ;
1920
21+ const MAX_SEGMENTED_COUNT = 6 ;
22+ const MAX_SEGMENTED_LABEL_LENGTH = 4 ;
23+
2024/**
2125 * Symbol representing a value that is "not set".
2226 * The main usage is to indicate that a prop value should be 'undefined' instead of using its default value.
@@ -58,6 +62,10 @@ export const controlMap = Object.freeze({
5862 component : DtcControlSelection ,
5963 default ( { values } = { } ) { return values ?. [ 0 ] ; } ,
6064 } ,
65+ segmented : {
66+ component : DtcControlSegmented ,
67+ default ( { values } = { } ) { return values ?. [ 0 ] ; } ,
68+ } ,
6169 string : {
6270 component : DtcControlString ,
6371 default ( ) { return getControlDataDefault ( this ) ; } ,
@@ -102,6 +110,7 @@ export function getControlByValue (value) {
102110export function getControlByMemberType ( type , args ) {
103111 if ( type === 'boolean' ) return 'boolean' ;
104112 if ( args ?. values ?. length > 0 ) {
113+ if ( shouldUseSegmented ( args . values ) ) return 'segmented' ;
105114 return 'selection' ;
106115 }
107116 switch ( type ) {
@@ -110,6 +119,11 @@ export function getControlByMemberType (type, args) {
110119 }
111120}
112121
122+ function shouldUseSegmented ( values ) {
123+ return values . length <= MAX_SEGMENTED_COUNT &&
124+ values . every ( v => String ( v ) . length <= MAX_SEGMENTED_LABEL_LENGTH ) ;
125+ }
126+
113127/**
114128 * Serializes a value before giving it to a control that requires a serialized value.
115129 * Currently, this only converts between 'UNSET' and 'undefined'.
0 commit comments