33// found in the LICENSE file.
44
55import '../../ui/components/adorners/adorners.js' ;
6- import '../../ui/components/data_grid/data_grid.js' ;
6+ import '../../ui/legacy/ components/data_grid/data_grid.js' ;
77
88import * as Common from '../../core/common/common.js' ;
99import * as i18n from '../../core/i18n/i18n.js' ;
1010import type * as Platform from '../../core/platform/platform.js' ;
1111import * as SDK from '../../core/sdk/sdk.js' ;
1212import * as Protocol from '../../generated/protocol.js' ;
1313import * as AutofillManager from '../../models/autofill_manager/autofill_manager.js' ;
14- import type * as DataGrid from '../../ui/components/data_grid/data_grid.js' ;
1514import * as ComponentHelpers from '../../ui/components/helpers/helpers.js' ;
1615import * as Input from '../../ui/components/input/input.js' ;
1716import * as LegacyWrapper from '../../ui/components/legacy_wrapper/legacy_wrapper.js' ;
@@ -20,7 +19,8 @@ import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
2019
2120import autofillViewStyles from './autofillView.css.js' ;
2221
23- const { html} = Lit ;
22+ const { html, render, Directives : { styleMap} } = Lit ;
23+ const { FillingStrategy} = Protocol . Autofill ;
2424
2525const UIStrings = {
2626 /**
@@ -166,7 +166,7 @@ export class AutofillView extends LegacyWrapper.LegacyWrapper.WrappableComponent
166166 if ( ! this . #address && ! this . #filledFields. length ) {
167167 // Disabled until https://crbug.com/1079231 is fixed.
168168 // clang-format off
169- Lit . render ( html `
169+ render ( html `
170170 < main >
171171 < div class ="top-left-corner ">
172172 < label class ="checkbox-label " title =${ i18nString ( UIStrings . showTestAddressesInAutofillMenu ) } >
@@ -201,7 +201,7 @@ export class AutofillView extends LegacyWrapper.LegacyWrapper.WrappableComponent
201201
202202 // Disabled until https://crbug.com/1079231 is fixed.
203203 // clang-format off
204- Lit . render ( html `
204+ render ( html `
205205 < main >
206206 < div class ="content-container " jslog =${ VisualLogging . pane ( 'autofill' ) } >
207207 < div class ="right-to-left " role ="region " aria-label =${ i18nString ( UIStrings . addressPreview ) } >
@@ -320,64 +320,54 @@ export class AutofillView extends LegacyWrapper.LegacyWrapper.WrappableComponent
320320 return Lit . nothing ;
321321 }
322322
323- const gridData : DataGrid . DataGridController . DataGridControllerData = {
324- columns : [
325- {
326- id : 'name' ,
327- title : i18nString ( UIStrings . formField ) ,
328- widthWeighting : 50 ,
329- hideable : false ,
330- visible : true ,
331- sortable : true ,
332- } ,
333- {
334- id : 'autofill-type' ,
335- title : i18nString ( UIStrings . predictedAutofillValue ) ,
336- widthWeighting : 50 ,
337- hideable : false ,
338- visible : true ,
339- sortable : true ,
340- } ,
341- {
342- id : 'value' ,
343- title : i18nString ( UIStrings . value ) ,
344- widthWeighting : 50 ,
345- hideable : false ,
346- visible : true ,
347- sortable : true ,
348- } ,
349- {
350- id : 'filled-field-index' ,
351- title : 'filledFieldIndex' ,
352- widthWeighting : 50 ,
353- hideable : true ,
354- visible : false ,
355- } ,
356- ] ,
357- rows : this . #buildReportRows( ) ,
358- striped : true ,
359- } ;
360-
323+ const highlightedGridRows = new Set ( this . #highlightedMatches. map ( match => match . filledFieldIndex ) ) ;
361324 // Disabled until https://crbug.com/1079231 is fixed.
362325 // clang-format off
363326 return html `
364327 < div class ="grid-wrapper " role ="region " aria-label =${ i18nString ( UIStrings . formInspector ) } >
365- < devtools-data-grid-controller
366- @rowmouseenter =${ this . #onGridRowMouseEnter}
367- @rowmouseleave =${ this . #onGridRowMouseLeave}
328+ < devtools-new-data-grid
329+ striped
368330 class ="filled-fields-grid "
369- .data=${ gridData } >
370- </ devtools-data-grid-controller >
331+ >
332+ < table >
333+ < tr >
334+ < th id ="name " weight ="50 " sortable > ${ i18nString ( UIStrings . formField ) } </ th >
335+ < th id ="autofill-type " weight ="50 " sortable > ${ i18nString ( UIStrings . predictedAutofillValue ) } </ th >
336+ < th id ="value " weight ="50 " sortable > ${ i18nString ( UIStrings . value ) } </ th >
337+ </ tr >
338+ ${ this . #filledFields. map ( ( field , index ) => html `
339+ < tr style =${ styleMap ( {
340+ 'font-family' : 'var(--monospace-font-family)' ,
341+ 'font-size' : 'var(--monospace-font-size)' ,
342+ 'background-color' : highlightedGridRows . has ( index ) ? 'var(--sys-color-state-hover-on-subtle)' : null ,
343+ } ) }
344+ @mouseenter =${ ( ) => this . #onGridRowMouseEnter( index ) }
345+ @mouseleave=${ this . #onGridRowMouseLeave. bind ( this ) }
346+ >
347+ < td > ${ field . name || `#${ field . id } ` } (${ field . htmlType } )</ td >
348+ < td >
349+ ${ field . autofillType }
350+ ${ field . fillingStrategy === FillingStrategy . AutocompleteAttribute ?
351+ html `< devtools-adorner title =${ i18nString ( UIStrings . autocompleteAttribute ) } .data =${ { name : field . fillingStrategy } } >
352+ < span slot ="content "> ${ i18nString ( UIStrings . attr ) } </ span >
353+ </ devtools-adorner > ` :
354+ field . fillingStrategy === FillingStrategy . AutofillInferred ?
355+ html `< devtools-adorner title =${ i18nString ( UIStrings . inferredByHeuristics ) } .data =${ { name : field . fillingStrategy } } >
356+ < span slot ="content "> ${ i18nString ( UIStrings . heur ) } </ span >
357+ </ devtools-adorner > ` :
358+ Lit . nothing }
359+ </ td >
360+ < td > "${ field . value } "</ td >
361+ </ tr > `
362+ ) }
363+ </ table >
364+ </ devtools-new-data-grid >
371365 </ div >
372366 ` ;
373367 // clang-format on
374368 }
375369
376- #onGridRowMouseEnter( event : DataGrid . DataGridEvents . RowMouseEnterEvent ) : void {
377- const rowIndex = event . data . row . cells [ 3 ] . value ;
378- if ( typeof rowIndex !== 'number' ) {
379- return ;
380- }
370+ #onGridRowMouseEnter( rowIndex : number ) : void {
381371 this . #highlightedMatches = this . #matches. filter ( match => match . filledFieldIndex === rowIndex ) ;
382372 void ComponentHelpers . ScheduledRender . scheduleRender ( this , this . #renderBound) ;
383373
@@ -400,57 +390,6 @@ export class AutofillView extends LegacyWrapper.LegacyWrapper.WrappableComponent
400390 void ComponentHelpers . ScheduledRender . scheduleRender ( this , this . #renderBound) ;
401391 SDK . OverlayModel . OverlayModel . hideDOMNodeHighlight ( ) ;
402392 }
403-
404- #buildReportRows( ) : DataGrid . DataGridUtils . Row [ ] {
405- const highlightedGridRows = new Set ( this . #highlightedMatches. map ( match => match . filledFieldIndex ) ) ;
406-
407- return this . #filledFields. map (
408- ( field , index ) => {
409- const fieldName = field . name || `#${ field . id } ` ;
410- return {
411- cells : [
412- { columnId : 'name' , value : `${ fieldName } (${ field . htmlType } )` } ,
413- {
414- columnId : 'autofill-type' ,
415- value : field . autofillType ,
416- renderer : ( ) => this . #autofillTypeRenderer( field . autofillType , field . fillingStrategy ) ,
417- } ,
418- { columnId : 'value' , value : `"${ field . value } "` } ,
419- { columnId : 'filled-field-index' , value : index } ,
420- ] ,
421- styles : {
422- 'font-family' : 'var(--monospace-font-family)' ,
423- 'font-size' : 'var(--monospace-font-size)' ,
424- ...( highlightedGridRows . has ( index ) && { 'background-color' : 'var(--sys-color-state-hover-on-subtle)' } ) ,
425- } ,
426- } ;
427- } ,
428- ) ;
429- }
430-
431- #autofillTypeRenderer( autofillType : string , fillingStrategy : Protocol . Autofill . FillingStrategy ) : Lit . TemplateResult {
432- const adornerContent = document . createElement ( 'span' ) ;
433- let adornerTitle = '' ;
434- switch ( fillingStrategy ) {
435- case Protocol . Autofill . FillingStrategy . AutocompleteAttribute :
436- adornerContent . textContent = i18nString ( UIStrings . attr ) ;
437- adornerTitle = i18nString ( UIStrings . autocompleteAttribute ) ;
438- break ;
439- case Protocol . Autofill . FillingStrategy . AutofillInferred :
440- adornerContent . textContent = i18nString ( UIStrings . heur ) ;
441- adornerTitle = i18nString ( UIStrings . inferredByHeuristics ) ;
442- }
443-
444- // Disabled until https://crbug.com/1079231 is fixed.
445- // clang-format off
446- return html `
447- ${ autofillType }
448- ${ adornerContent . textContent ? html `
449- < devtools-adorner title =${ adornerTitle } .data =${ { name : fillingStrategy , content : adornerContent } } > </ devtools-adorner >
450- ` : Lit . nothing }
451- ` ;
452- // clang-format on
453- }
454393}
455394
456395customElements . define ( 'devtools-autofill-view' , AutofillView ) ;
0 commit comments