@@ -22,6 +22,7 @@ import { Spinner } from './Spinner';
2222import { useControlledValue , useEventCallback , useMergeRefs } from './hooks' ;
2323import { createFC } from './common' ;
2424import { Bivariant } from './typeUtils' ;
25+ import { registerStyle } from './util' ;
2526
2627/**
2728 *
@@ -195,10 +196,9 @@ const LookupScopeSelectorContainer: FC<LookupScopeSelectorContainerProps> = ({
195196 return (
196197 < div
197198 id = { scopeListboxId }
198- className = 'slds-dropdown slds-dropdown_length-with-icon-7 slds-dropdown_fluid'
199+ className = 'react-slds-lookup-dropdown slds-dropdown slds-dropdown_length-with-icon-7 slds-dropdown_fluid'
199200 role = 'listbox'
200201 aria-label = 'Scope Options'
201- style = { { left : 0 , transform : 'translateX(0)' } }
202202 ref = { useMergeRefs ( [ autoAlignContentRef ] ) }
203203 >
204204 { children }
@@ -373,7 +373,7 @@ const LookupScopeSelector: FC<LookupScopeSelectorProps> = ({
373373 Filter Search by:
374374 </ label >
375375 < div className = 'slds-form-element__control' >
376- < div className = 'slds-combobox_container slds-has-icon-only' >
376+ < div className = 'react-slds-lookup-scope-combobox-container slds-combobox_container slds-has-icon-only' >
377377 < div
378378 className = { classnames (
379379 'slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click' ,
@@ -386,30 +386,16 @@ const LookupScopeSelector: FC<LookupScopeSelectorProps> = ({
386386 className = 'slds-combobox__form-element slds-input-has-icon slds-input-has-icon_left-right'
387387 role = 'none'
388388 >
389- < div
390- className = 'slds-is-absolute'
391- style = { {
392- top : '50%' ,
393- transform : 'translateY(-50%)' ,
394- left : '0.5rem' ,
395- pointerEvents : 'none' ,
396- zIndex : SCOPE_INPUT_ZINDEX + 1 ,
397- } }
398- >
399- < Icon
400- category = { currentScope . category }
401- icon = { currentScope . icon }
402- size = 'small'
403- />
404- </ div >
389+ < Icon
390+ containerClassName = 'react-slds-lookup-current-scope-icon-container slds-is-absolute'
391+ className = 'react-slds-lookup-current-scope-icon'
392+ category = { currentScope . category }
393+ icon = { currentScope . icon }
394+ size = 'small'
395+ />
405396 < input
406397 type = 'text'
407- className = 'slds-input slds-combobox__input slds-combobox__input-value'
408- style = { {
409- paddingLeft : '1.5rem' ,
410- cursor : ! disabled ? 'pointer' : undefined ,
411- zIndex : SCOPE_INPUT_ZINDEX ,
412- } }
398+ className = 'react-slds-lookup-scope-input slds-input slds-combobox__input slds-combobox__input-value'
413399 aria-controls = 'objectswitcher-listbox-id'
414400 aria-expanded = { scopeOpened }
415401 aria-haspopup = 'listbox'
@@ -423,21 +409,12 @@ const LookupScopeSelector: FC<LookupScopeSelectorProps> = ({
423409 onKeyDown = { onScopeKeyDown }
424410 readOnly
425411 />
426- < div
427- className = 'slds-is-absolute'
428- style = { {
429- bottom : '0.2rem' ,
430- right : '0.55rem' ,
431- pointerEvents : 'none' ,
432- zIndex : SCOPE_INPUT_ZINDEX + 1 ,
433- } }
434- >
435- < Icon
436- icon = 'down'
437- size = 'x-small'
438- style = { { width : '0.8rem' , height : '0.8rem' } }
439- />
440- </ div >
412+ < Icon
413+ containerClassName = 'react-slds-lookup-scope-down-icon-container slds-is-absolute'
414+ className = 'react-slds-lookup-scope-down-icon'
415+ icon = 'down'
416+ size = 'x-small'
417+ />
441418 </ div >
442419 { scopeOpened && (
443420 < AutoAlign
@@ -706,8 +683,7 @@ const LookupDropdownContainer: FC<LookupDropdownContainerProps> = ({
706683 return (
707684 < div
708685 id = { listboxId }
709- className = 'slds-dropdown slds-dropdown_length-with-icon-7 slds-dropdown_fluid slds-scrollable_none'
710- style = { { maxHeight : LIST_PARENT_MAX_HEIGHT } }
686+ className = 'react-slds-lookup-dropdown react-slds-lookup-dropdown-main slds-dropdown slds-dropdown_length-with-icon-7 slds-dropdown_fluid slds-scrollable_none'
711687 role = 'listbox'
712688 aria-label = 'Search Results'
713689 tabIndex = { 0 }
@@ -797,8 +773,7 @@ const LookupDropdown: FC<LookupDropdownProps> = ({
797773 </ ul >
798774 ) : null }
799775 < ul
800- className = 'slds-listbox slds-listbox_vertical slds-scrollable_y'
801- style = { { maxHeight : LIST_CONTENT_MAX_HEIGHT } }
776+ className = 'react-slds-lookup-list slds-listbox slds-listbox_vertical slds-scrollable_y'
802777 role = 'presentation'
803778 onKeyDown = { onKeyDown }
804779 onBlur = { onBlur }
@@ -851,6 +826,46 @@ const LookupDropdown: FC<LookupDropdownProps> = ({
851826const LIST_PARENT_MAX_HEIGHT = 'unset' ;
852827const LIST_CONTENT_MAX_HEIGHT = 'calc((1.5rem + 1rem) * 7)' ; // copied from `.slds-dropdown_length-with-icon-7`
853828
829+ /**
830+ *
831+ */
832+ function useInitComponentStyle ( ) {
833+ useEffect ( ( ) => {
834+ registerStyle ( 'lookup-search' , [
835+ [
836+ '.react-slds-lookup-current-scope-icon-container' ,
837+ `{ top: 50%; transform: translateY(-50%); left: 14.2%; pointer-events: none; z-index: ${
838+ SCOPE_INPUT_ZINDEX + 1
839+ } ; }`,
840+ ] ,
841+ [ '.react-slds-lookup-scope-input:not(:disabled)' , '{ cursor: pointer; }' ] ,
842+ [
843+ '.react-slds-lookup-scope-input.react-slds-lookup-scope-input.react-slds-lookup-scope-input' ,
844+ `{ padding-left: 1.5rem; z-index: ${ SCOPE_INPUT_ZINDEX } ; }` ,
845+ ] ,
846+ [
847+ '.react-slds-lookup-scope-down-icon-container' ,
848+ `{ line-height: 0; bottom: 17%; right: 15.7%; pointer-events: none; z-index: ${
849+ SCOPE_INPUT_ZINDEX + 1
850+ } ; }`,
851+ ] ,
852+ [
853+ '.react-slds-lookup-scope-down-icon-container .react-slds-lookup-scope-down-icon' ,
854+ '{ width: 0.8rem; height: 0.8rem; }' ,
855+ ] ,
856+ [ '.react-slds-lookup-dropdown' , '{ left: 0; transform: translateX(0); }' ] ,
857+ [
858+ '.react-slds-lookup-dropdown-main' ,
859+ `{ max-height: ${ LIST_PARENT_MAX_HEIGHT } ; min-width: 15rem; }` ,
860+ ] ,
861+ [
862+ '.react-slds-lookup-list' ,
863+ `{ max-height: ${ LIST_CONTENT_MAX_HEIGHT } ; }` ,
864+ ] ,
865+ ] ) ;
866+ } , [ ] ) ;
867+ }
868+
854869/**
855870 *
856871 */
@@ -956,6 +971,8 @@ export const Lookup = createFC<LookupProps, { isFormElement: boolean }>(
956971 ...rprops
957972 } = props ;
958973
974+ useInitComponentStyle ( ) ;
975+
959976 const fallbackId = useId ( ) ;
960977 const comboboxId = id_ ?? `${ fallbackId } -combobox` ;
961978 const listboxId = `${ fallbackId } -listbox` ;
@@ -1252,6 +1269,7 @@ export const Lookup = createFC<LookupProps, { isFormElement: boolean }>(
12521269 const containerRef = useRef < HTMLDivElement | null > ( null ) ;
12531270 const containerClassNames = classnames (
12541271 'react-slds-lookup' ,
1272+ `react-slds-lookup-scope-${ scopes ? 'multi' : 'single' } ` ,
12551273 'slds-combobox_container' ,
12561274 {
12571275 'slds-has-selection' : hasSelection ,
@@ -1305,7 +1323,7 @@ export const Lookup = createFC<LookupProps, { isFormElement: boolean }>(
13051323 return (
13061324 < FormElement { ...formElemProps } >
13071325 < div ref = { containerRef } className = { containerClassNames } >
1308- < div className = 'slds-combobox-group' >
1326+ < div className = 'react-slds-combobox-group slds-combobox-group' >
13091327 < LookupScopeSelector
13101328 scopes = { scopes }
13111329 targetScope = { targetScope }
0 commit comments