{
  "version": 3,
  "sources": ["../../../src/components/dataviews-selection-checkbox/index.tsx"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { CheckboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from '../../types/private';\nimport type { NormalizedField } from '../../types';\n\ninterface DataViewsSelectionCheckboxProps< Item > {\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\titem: Item;\n\tgetItemId: ( item: Item ) => string;\n\ttitleField?: NormalizedField< Item >;\n\tdisabled: boolean;\n\ttabIndex?: number;\n}\n\nexport default function DataViewsSelectionCheckbox< Item >( {\n\tselection,\n\tonChangeSelection,\n\titem,\n\tgetItemId,\n\ttitleField,\n\tdisabled,\n\t...extraProps\n}: DataViewsSelectionCheckboxProps< Item > ) {\n\tconst id = getItemId( item );\n\tconst isInSelectionArray = selection.includes( id );\n\tconst checked = ! disabled && isInSelectionArray;\n\n\t// Fallback label to ensure accessibility\n\tconst selectionLabel =\n\t\ttitleField?.getValue?.( { item } ) || __( '(no title)' );\n\n\treturn (\n\t\t<CheckboxControl\n\t\t\tclassName=\"dataviews-selection-checkbox\"\n\t\t\taria-label={ selectionLabel }\n\t\t\taria-disabled={ disabled }\n\t\t\tchecked={ checked }\n\t\t\tonChange={ () => {\n\t\t\t\tif ( disabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Toggle in/out of selection array\n\t\t\t\tonChangeSelection(\n\t\t\t\t\tisInSelectionArray\n\t\t\t\t\t\t? selection.filter( ( itemId ) => id !== itemId )\n\t\t\t\t\t\t: [ ...selection, id ]\n\t\t\t\t);\n\t\t\t} }\n\t\t\t{ ...extraProps }\n\t\t/>\n\t);\n}\n"],
  "mappings": ";AAGA,SAAS,uBAAuB;AAChC,SAAS,UAAU;AAoCjB;AAlBa,SAAR,2BAAqD;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAA6C;AAC5C,QAAM,KAAK,UAAW,IAAK;AAC3B,QAAM,qBAAqB,UAAU,SAAU,EAAG;AAClD,QAAM,UAAU,CAAE,YAAY;AAG9B,QAAM,iBACL,YAAY,WAAY,EAAE,KAAK,CAAE,KAAK,GAAI,YAAa;AAExD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,cAAa;AAAA,MACb,iBAAgB;AAAA,MAChB;AAAA,MACA,UAAW,MAAM;AAChB,YAAK,UAAW;AACf;AAAA,QACD;AAGA;AAAA,UACC,qBACG,UAAU,OAAQ,CAAE,WAAY,OAAO,MAAO,IAC9C,CAAE,GAAG,WAAW,EAAG;AAAA,QACvB;AAAA,MACD;AAAA,MACE,GAAG;AAAA;AAAA,EACN;AAEF;",
  "names": []
}
