function HeaderCheckbox({ columnData, t }) {
	if (!columnData.onToggleAll) {
		return null;
	}

	const { id, onToggleAll, collection, isSelected } = columnData;
	const checked = useMemo(() => collection.length > 0 && collection.every(isSelected), [
		collection,
		isSelected,
	]);
	const partial = useMemo(
		() => {
			if (!collection.length) {
				return false;
			}
			const selected = collection.filter(isSelected);
			return selected.length && selected.length < collection.length;
		}, [collection, isSelected],
	);

	const title = t('LIST_SELECT_ALL', { defaultValue: 'Select All' });
	return (
		<form className={classnames('tc-list-checkbox', theme['tc-list-checkbox'])}>
			<div className="checkbox" title={title}>
				<label htmlFor={id && `${id}-header-check`}>
					<Checkbox
						id={id && `${id}-header-check`}
						type="checkbox"
						onChange={onToggleAll}
						checked={checked}
						intermediate={partial}
						disabled={!collection.length}
						data-feature="list.select_all"
					/>
					<span className="sr-only">{title}</span>
				</label>
			</div>
		</form>
	);
}
/**
 * Header renderer that displays a "Select All" checkbox on header
 */
Header renderer that displays a "Select All" checkbox on header
Header renderer that displays a " Select All " checkbox on header
function HeaderCheckbox({ columnData, t }) {
	if (!columnData.onToggleAll) {
		return null;
	}
	const { id, onToggleAll, collection, isSelected } = columnData;
	const checked = useMemo(() => collection.length > 0 && collection.every(isSelected), [
		collection,
		isSelected,
	]);
	const partial = useMemo(
		() => {
			if (!collection.length) {
				return false;
			}
			const selected = collection.filter(isSelected);
			return selected.length && selected.length < collection.length;
		}, [collection, isSelected],
	);
	const title = t('LIST_SELECT_ALL', { defaultValue: 'Select All' });
	return (
		<form className={classnames('tc-list-checkbox', theme['tc-list-checkbox'])}>
			<div className="checkbox" title={title}>
				<label htmlFor={id && `${id}-header-check`}>
					<Checkbox
						id={id && `${id}-header-check`}
						type="checkbox"
						onChange={onToggleAll}
						checked={checked}
						intermediate={partial}
						disabled={!collection.length}
						data-feature="list.select_all"
					/>
					<span className="sr-only">{title}</span>
				</label>
			</div>
		</form>
	);
}
function HeaderCheckbox ( { columnData , t } ) { if ( ! columnData . onToggleAll ) { return null ; } const { id , onToggleAll , collection , isSelected } = columnData ; const checked = useMemo ( ( ) => collection . length > 0 && collection . every ( isSelected ) , [ collection , isSelected , ] ) ; const partial = useMemo ( ( ) => { if ( ! collection . length ) { return false ; } const selected = collection . filter ( isSelected ) ; return selected . length && selected . length < collection . length ; } , [ collection , isSelected ] , ) ; const title = t ( 'LIST_SELECT_ALL' , { defaultValue : 'Select All' } ) ; return ( < form className = { classnames ( 'tc-list-checkbox' , theme [ 'tc-list-checkbox' ] ) } > < div className = "checkbox" title = { title } > < label htmlFor = { id && ` ${ id } ` } > < Checkbox id = { id && ` ${ id } ` } type = "checkbox" onChange = { onToggleAll } checked = { checked } intermediate = { partial } disabled = { ! collection . length } data-feature = "list.select_all" / > < span className = "sr-only" > { title } < / span > < / label > < / div > < / form > ) ; }
Header renderer that displays a "Select All" checkbox on header
Header renderer that displays a " Select All " checkbox on header