PHP 8.2.31
Preview: multiselect.js Size: 2.11 KB
/proc/self/root/var/softaculous/sitepad/editor/site-data/plugins/pagelayer/js/react/src/components/multiselect.js

import { useState, useEffect } from '@wordpress/element';
import { LabelControl } from './label';

export const MultiSelectControl = (props) => {
	
	const { prop, label, value, setAttributes } = props;
	const { name } = prop['c'];
	
	var selection = pagelayer_empty(value) ? [] : value;
	
	if(pagelayer_is_string(selection)){
		selection = selection.split(',');
	}
	
	const [isSelectorOpen, setIsSelectorOpen] = useState(false);

	const option = (val, lang) => {
		const itemSelected = selection.includes(val) ? 'selected' : '';
		return (
			<li
				className="pagelayer-elp-multiselect-option"
				data-val={val}
				data-selected={itemSelected}
				onClick={ () => handleOptionClick(val)}
			>{ lang }</li>
		);
	};

	const showSelected = () => {
		return selection.map((value) => (
			<span className="pagelayer-elp-multiselect-selected" data-val={value}>
				{prop['list'][value]}{' '}
				<span className="pagelayer-elp-multiselect-remove" onClick={() => handleRemove(value)}>
					x
				</span>
			</span>
		));
	};

	const handleRemove = (value) => {
		const updatedSelection = selection.filter((val) => val !== value);
		setAttributes({[name]: updatedSelection.join(',') });
	};

	const handleOptionClick = (val) => {
		
		if (selection.includes(val)) {
			const updatedSelection = selection.filter((value) => value !== val);
			setAttributes({[name]: updatedSelection.join(',') });
		} else {
			const updatedSelection = [...selection, val];
			setAttributes({[name]: updatedSelection.join(',')});
		}
		
	};

	return (
		<div className="components-base-control pagelayer-base-control">
			<LabelControl {...props}/>
			<div className="pagelayer-elp-multiselect-div pagelayer-elp-pos-rel">
				<div 
					className="pagelayer-elp-multiselect" 
					onClick={ () => setIsSelectorOpen(!isSelectorOpen) }
				>{showSelected()}</div>
				{ isSelectorOpen && (
					<ul className={`pagelayer-elp-multiselect-ul ${isSelectorOpen ? 'open' : ''}`} name={name}>
						{Object.keys(prop['list']).map((key) => option(key, prop['list'][key]))}
					</ul>
				)}
			</div>
		</div>
	);
}

Directory Contents

Dirs: 0 × Files: 29

Name Size Perms Modified Actions
1.26 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
5.70 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
653 B lrw-r--r-- 2026-04-22 07:17:42
Edit Download
4.90 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
1000 B lrw-r--r-- 2026-04-22 07:17:42
Edit Download
1.82 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
2.29 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
1.53 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
4.01 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
237 B lrw-r--r-- 2026-04-22 07:17:42
Edit Download
5.16 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
2.26 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
1.32 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
7.39 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
1.91 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
1.81 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
2.96 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
2.11 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
2.13 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
771 B lrw-r--r-- 2026-04-22 07:17:42
Edit Download
4.20 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
1.08 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
2.18 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
1.95 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
1.47 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
846 B lrw-r--r-- 2026-04-22 07:17:42
Edit Download
7.21 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download
693 B lrw-r--r-- 2026-04-22 07:17:42
Edit Download
17.44 KB lrw-r--r-- 2026-04-22 07:17:42
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).