@@ -4,8 +4,8 @@ import a from "prop-types";
44import j from "classnames" ;
55import { isEmpty as y , get as z , throttle as Re , isNil as G } from "lodash" ;
66import se from "../NewChipInput/NewChipInput.mjs" ;
7- import be from "../../../elements/OptionsMenu/OptionsMenu.mjs" ;
8- import ke from "../../../elements/ValidationTemplate/ValidationTemplate.mjs" ;
7+ import ke from "../../../elements/OptionsMenu/OptionsMenu.mjs" ;
8+ import be from "../../../elements/ValidationTemplate/ValidationTemplate.mjs" ;
99import { CHIP_OPTIONS as We } from "../../../types.mjs" ;
1010import { CLICK as Ie , TAB as J , TAB_SHIFT as Ke } from "../../../constants.mjs" ;
1111import { getTextWidth as D } from "../formChipCell.util.mjs" ;
@@ -15,21 +15,21 @@ import _e from "../../../images/close.svg.mjs";
1515const Ne = {
1616 rules : { }
1717} ;
18- let P = ( {
18+ let E = ( {
1919 chip : d ,
2020 chipIndex : i ,
2121 chipOptions : ne ,
2222 className : ie = "" ,
2323 editConfig : r ,
24- handleRemoveChip : le ,
24+ handleRemoveChip : ue ,
2525 isDeletable : Q ,
2626 isEditable : u ,
2727 keyName : N ,
2828 meta : m ,
2929 onChange : q ,
3030 setChipSizeIsRecalculated : U ,
3131 setEditConfig : O ,
32- validationRules : ue = Ne . rules ,
32+ validationRules : le = Ne . rules ,
3333 valueName : oe
3434} , w ) => {
3535 const [ l , A ] = $ ( {
@@ -38,7 +38,7 @@ let P = ({
3838 value : d . value ,
3939 keyFieldWidth : 0 ,
4040 valueFieldWidth : 0
41- } ) , [ v , ce ] = $ ( "key" ) , [ X , ae ] = $ ( ue ) , [ p , B ] = $ ( ! 1 ) , { background : Y , borderColor : Z , borderRadius : C , density : g , font : ee } = ne , F = H ( ( ) => u ? 25 : 20 , [ u ] ) , f = H ( ( ) => u ? 35 : 20 , [ u ] ) , M = H ( ( ) => Ve ( ) , [ ] ) , o = T . useRef ( { } ) , c = T . useRef ( { } ) , S = T . useRef ( ) , x = T . useRef ( ) , de = j (
41+ } ) , [ v , ce ] = $ ( "key" ) , [ X , ae ] = $ ( le ) , [ p , B ] = $ ( ! 1 ) , { background : Y , borderColor : Z , borderRadius : C , density : g , font : ee } = ne , F = H ( ( ) => u ? 25 : 20 , [ u ] ) , f = H ( ( ) => u ? 35 : 20 , [ u ] ) , M = H ( ( ) => Ve ( ) , [ ] ) , o = T . useRef ( { } ) , c = T . useRef ( { } ) , S = T . useRef ( ) , x = T . useRef ( ) , de = j (
4242 ie ,
4343 ! r . isKeyFocused && "item_edited" ,
4444 ! y ( z ( m , [ "error" , i , "key" ] , [ ] ) ) && ! y ( l . key ) && ! d . disabled && u && "item_edited_invalid"
@@ -57,29 +57,29 @@ let P = ({
5757 ! y ( z ( m , [ "error" , i , "value" ] , [ ] ) ) && ! y ( l . value ) && u && "item_edited_invalid"
5858 ) , he = j (
5959 "item-icon-close" ,
60- ! d . disabled && ( r . chipIndex === i && u || ! Q ) && "item-icon-close invisible" ,
60+ ! d . disabled && ( r . chipIndex === i && u || ! Q && ! u ) && "item-icon-close invisible" ,
6161 ! u && ! Q && "item-icon-close hidden"
6262 ) , K = I ( ( ) => {
6363 var e ;
6464 if ( o . current ) {
65- const t = D ( o . current ) + 1 , s = D ( c . current ) + 1 , n = ( ( e = w . current ) == null ? void 0 : e . clientWidth ) - 50 , _ = t >= n / 2 , L = s >= n / 2 ;
66- let R = null , b = null ;
67- if ( _ && L )
68- R = b = n / 2 ;
65+ const t = D ( o . current ) + 1 , s = D ( c . current ) + 1 , n = ( ( e = w . current ) == null ? void 0 : e . clientWidth ) - 50 , _ = t >= n / 2 , P = s >= n / 2 ;
66+ let R = null , k = null ;
67+ if ( _ && P )
68+ R = k = n / 2 ;
6969 else if ( _ ) {
70- b = l . value ? s : f ;
71- const k = n - b ;
72- R = k > t ? t : k ;
73- } else if ( L ) {
70+ k = l . value ? s : f ;
71+ const b = n - k ;
72+ R = b > t ? t : b ;
73+ } else if ( P ) {
7474 R = l . key ? t : F ;
75- const k = n - R ;
76- b = k > s ? s : k ;
75+ const b = n - R ;
76+ k = b > s ? s : b ;
7777 } else
78- R = ! l . key || t <= F ? F : t , b = ! l . value || s <= f ? f : s ;
79- o . current . style . width = `${ R } px` , y ( c . current ) || ( c . current . style . width = `${ b } px` ) , A ( ( k ) => ( {
80- ...k ,
78+ R = ! l . key || t <= F ? F : t , k = ! l . value || s <= f ? f : s ;
79+ o . current . style . width = `${ R } px` , y ( c . current ) || ( c . current . style . width = `${ k } px` ) , A ( ( b ) => ( {
80+ ...b ,
8181 keyFieldWidth : R ,
82- valueFieldWidth : b
82+ valueFieldWidth : k
8383 } ) ) , U ( ! 0 ) ;
8484 }
8585 } , [
@@ -103,17 +103,17 @@ let P = ({
103103 } , [ u , K , M ] ) , h ( ( ) => {
104104 ! l . keyFieldWidth && ! l . valueFieldWidth && K ( ) ;
105105 } , [ l . keyFieldWidth , l . valueFieldWidth , K ] ) ;
106- const E = I (
106+ const L = I (
107107 ( e , t ) => {
108108 var s ;
109109 r . chipIndex === i && ( ! ( e . path ?? ( ( s = e . composedPath ) == null ? void 0 : s . call ( e ) ) ) . includes ( S . current ) || t ? ( q ( e , Ie , ! 0 ) , window . getSelection ( ) . removeAllRanges ( ) , document . activeElement . blur ( ) ) : e . stopPropagation ( ) ) ;
110110 } ,
111111 [ q , S , i , r . chipIndex ]
112112 ) , V = I (
113113 ( e ) => {
114- x != null && x . current && ! x . current . contains ( e . target ) && ( B ( ! 1 ) , E ( e , ! 0 ) ) ;
114+ x != null && x . current && ! x . current . contains ( e . target ) && ( B ( ! 1 ) , L ( e , ! 0 ) ) ;
115115 } ,
116- [ E ]
116+ [ L ]
117117 ) ;
118118 h ( ( ) => ( p && window . addEventListener ( "scroll" , V , ! 0 ) , ( ) => {
119119 window . removeEventListener ( "scroll" , V , ! 0 ) ;
@@ -130,10 +130,10 @@ let P = ({
130130 window . removeEventListener ( "scroll" , V , ! 0 ) ;
131131 } ) , [ V , p ] ) , h ( ( ) => {
132132 if ( r . isEdit )
133- return document . addEventListener ( "click" , E , ! 0 ) , ( ) => {
134- document . removeEventListener ( "click" , E , ! 0 ) ;
133+ return document . addEventListener ( "click" , L , ! 0 ) , ( ) => {
134+ document . removeEventListener ( "click" , L , ! 0 ) ;
135135 } ;
136- } , [ E , r . isEdit ] ) ;
136+ } , [ L , r . isEdit ] ) ;
137137 const ye = I (
138138 ( e ) => {
139139 if ( r . chipIndex === i && u ) {
@@ -178,11 +178,11 @@ let P = ({
178178 } else {
179179 const n = D ( c . current ) ;
180180 A ( ( _ ) => {
181- var L ;
181+ var P ;
182182 return {
183183 ..._ ,
184184 value : c . current . value ,
185- valueFieldWidth : ( ( L = c . current . value ) == null ? void 0 : L . length ) <= 1 ? f : n >= t ? t : n > f ? n + 2 : f
185+ valueFieldWidth : ( ( P = c . current . value ) == null ? void 0 : P . length ) <= 1 ? f : n >= t ? t : n > f ? n + 2 : f
186186 } ;
187187 } ) ;
188188 }
@@ -209,7 +209,7 @@ let P = ({
209209 } , [ m , p , v , r . chipIndex ] ) ;
210210 const ve = I ( ( ) => {
211211 var e ;
212- return ( e = X [ v ] ) == null ? void 0 : e . map ( ( { isValid : t = ! 1 , label : s , name : n } ) => /* @__PURE__ */ W ( ke , { valid : t , validationMessage : s } , n ) ) ;
212+ return ( e = X [ v ] ) == null ? void 0 : e . map ( ( { isValid : t = ! 1 , label : s , name : n } ) => /* @__PURE__ */ W ( be , { valid : t , validationMessage : s } , n ) ) ;
213213 } , [ v , X ] ) ;
214214 return /* @__PURE__ */ Fe (
215215 "div" ,
@@ -250,18 +250,18 @@ let P = ({
250250 {
251251 disabled : d . disabled ,
252252 className : he ,
253- onClick : ( e ) => ! d . disabled && le ( e , i ) ,
253+ onClick : ( e ) => ! d . disabled && ue ( e , i ) ,
254254 children : /* @__PURE__ */ W ( _e , { } )
255255 }
256256 ) ,
257- ! d . disabled && ( r . isKeyFocused ? ! y ( l . key ) : ! y ( l . value ) ) && r . chipIndex === i && ! y ( z ( m , [ "error" , r . chipIndex , v ] , [ ] ) ) && /* @__PURE__ */ W ( be , { show : p , ref : { refInputContainer : S , validationRulesRef : x } , children : ve ( ) } )
257+ ! d . disabled && ( r . isKeyFocused ? ! y ( l . key ) : ! y ( l . value ) ) && r . chipIndex === i && ! y ( z ( m , [ "error" , r . chipIndex , v ] , [ ] ) ) && /* @__PURE__ */ W ( ke , { show : p , ref : { refInputContainer : S , validationRulesRef : x } , children : ve ( ) } )
258258 ]
259259 }
260260 ) ;
261261} ;
262- P = we ( P ) ;
263- P . displayName = "NewChipForm" ;
264- P . propTypes = {
262+ E = we ( E ) ;
263+ E . displayName = "NewChipForm" ;
264+ E . propTypes = {
265265 chip : a . object . isRequired ,
266266 chipIndex : a . number . isRequired ,
267267 chipOptions : We . isRequired ,
@@ -278,7 +278,7 @@ P.propTypes = {
278278 validationRules : a . object ,
279279 valueName : a . string . isRequired
280280} ;
281- const Me = P ;
281+ const Me = E ;
282282export {
283283 Me as default
284284} ;
0 commit comments