@@ -13,6 +13,7 @@ import {
13
13
import { v4 } from 'uuid' ;
14
14
15
15
import { FieldMetadataItemOption } from '@/object-metadata/types/FieldMetadataItem' ;
16
+ import { EXPANDED_WIDTH_ANIMATION_VARIANTS } from '@/settings/constants/ExpandedWidthAnimationVariants' ;
16
17
import { OPTION_VALUE_MAXIMUM_LENGTH } from '@/settings/data-model/constants/OptionValueMaximumLength' ;
17
18
import { getOptionValueFromLabel } from '@/settings/data-model/fields/forms/select/utils/getOptionValueFromLabel' ;
18
19
import { LightIconButton } from '@/ui/input/button/components/LightIconButton' ;
@@ -23,6 +24,9 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop
23
24
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown' ;
24
25
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem' ;
25
26
import { MenuItemSelectColor } from '@/ui/navigation/menu-item/components/MenuItemSelectColor' ;
27
+ import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState' ;
28
+ import { AnimatePresence , motion } from 'framer-motion' ;
29
+ import { useRecoilValue } from 'recoil' ;
26
30
27
31
type SettingsDataModelFieldSelectFormOptionRowProps = {
28
32
className ?: string ;
@@ -45,19 +49,29 @@ const StyledRow = styled.div`
45
49
46
50
const StyledColorSample = styled ( ColorSample ) `
47
51
cursor: pointer;
48
- margin-left: 9px;
49
- margin-right: 14px;
52
+ margin-top: ${ ( { theme } ) => theme . spacing ( 1 ) } ;
53
+ margin-bottom: ${ ( { theme } ) => theme . spacing ( 1 ) } ;
54
+
55
+ margin-right: ${ ( { theme } ) => theme . spacing ( 3.5 ) } ;
56
+ margin-left: ${ ( { theme } ) => theme . spacing ( 3.5 ) } ;
50
57
` ;
51
58
52
59
const StyledOptionInput = styled ( TextInput ) `
53
- flex: 1 0 auto;
54
- margin-right: ${ ( { theme } ) => theme . spacing ( 2 ) } ;
55
-
60
+ flex-grow: 1;
61
+ width: 100%;
56
62
& input {
57
63
height: ${ ( { theme } ) => theme . spacing ( 6 ) } ;
58
64
}
59
65
` ;
60
66
67
+ const StyledIconGripVertical = styled ( IconGripVertical ) `
68
+ margin-right: ${ ( { theme } ) => theme . spacing ( 0.75 ) } ;
69
+ ` ;
70
+
71
+ const StyledLightIconButton = styled ( LightIconButton ) `
72
+ margin-left: ${ ( { theme } ) => theme . spacing ( 2 ) } ;
73
+ ` ;
74
+
61
75
export const SettingsDataModelFieldSelectFormOptionRow = ( {
62
76
className,
63
77
isDefault,
@@ -69,6 +83,7 @@ export const SettingsDataModelFieldSelectFormOptionRow = ({
69
83
option,
70
84
isNewRow,
71
85
} : SettingsDataModelFieldSelectFormOptionRowProps ) => {
86
+ const isAdvancedModeEnabled = useRecoilValue ( isAdvancedModeEnabledState ) ;
72
87
const theme = useTheme ( ) ;
73
88
74
89
const dropdownIds = useMemo ( ( ) => {
@@ -90,11 +105,34 @@ export const SettingsDataModelFieldSelectFormOptionRow = ({
90
105
91
106
return (
92
107
< StyledRow className = { className } >
93
- < IconGripVertical
108
+ < StyledIconGripVertical
109
+ style = { { minWidth : theme . icon . size . md } }
94
110
size = { theme . icon . size . md }
95
111
stroke = { theme . icon . stroke . sm }
96
112
color = { theme . font . color . extraLight }
97
113
/>
114
+ < AnimatePresence >
115
+ { isAdvancedModeEnabled && (
116
+ < motion . div
117
+ initial = "initial"
118
+ animate = "animate"
119
+ exit = "exit"
120
+ variants = { EXPANDED_WIDTH_ANIMATION_VARIANTS }
121
+ >
122
+ < StyledOptionInput
123
+ value = { option . value }
124
+ onChange = { ( input ) =>
125
+ onChange ( {
126
+ ...option ,
127
+ value : getOptionValueFromLabel ( input ) ,
128
+ } )
129
+ }
130
+ RightIcon = { isDefault ? IconCheck : undefined }
131
+ maxLength = { OPTION_VALUE_MAXIMUM_LENGTH }
132
+ />
133
+ </ motion . div >
134
+ ) }
135
+ </ AnimatePresence >
98
136
< Dropdown
99
137
dropdownId = { dropdownIds . color }
100
138
dropdownPlacement = "bottom-start"
@@ -122,13 +160,18 @@ export const SettingsDataModelFieldSelectFormOptionRow = ({
122
160
/>
123
161
< StyledOptionInput
124
162
value = { option . label }
125
- onChange = { ( label ) =>
163
+ onChange = { ( label ) => {
164
+ const optionNameHasBeenEdited = ! (
165
+ option . value === getOptionValueFromLabel ( option . label )
166
+ ) ;
126
167
onChange ( {
127
168
...option ,
128
169
label,
129
- value : getOptionValueFromLabel ( label ) ,
130
- } )
131
- }
170
+ value : optionNameHasBeenEdited
171
+ ? option . value
172
+ : getOptionValueFromLabel ( label ) ,
173
+ } ) ;
174
+ } }
132
175
RightIcon = { isDefault ? IconCheck : undefined }
133
176
maxLength = { OPTION_VALUE_MAXIMUM_LENGTH }
134
177
onInputEnter = { handleInputEnter }
@@ -141,7 +184,9 @@ export const SettingsDataModelFieldSelectFormOptionRow = ({
141
184
dropdownHotkeyScope = { {
142
185
scope : dropdownIds . actions ,
143
186
} }
144
- clickableComponent = { < LightIconButton Icon = { IconDotsVertical } /> }
187
+ clickableComponent = {
188
+ < StyledLightIconButton accent = "tertiary" Icon = { IconDotsVertical } />
189
+ }
145
190
dropdownComponents = {
146
191
< DropdownMenu >
147
192
< DropdownMenuItemsContainer >
0 commit comments