PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.3.50
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.3.50
1.4.21 1.4.20 1.4.19 1.4.18 1.4.17 1.4.16 1.4.15 1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 All 184 releases
disco / backend / views / components / Main / components / SingleSelect.jsx

SingleSelect.jsx in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.3.50, at backend/views/components/Main/components/SingleSelect.jsx

79 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Listbox, Transition } from '@headlessui/react';
2 import { ChevronDownIcon } from '@heroicons/react/24/solid';
3 import { __ } from '@wordpress/i18n';
4 import { Fragment } from 'react';
5
6 const SingleSelect = ({
7 menu = false,
8 placeholder = __('Select', 'disco'),
9 items,
10 onchange = () => {},
11 selected,
12 disabled = false,
13 className = '',
14 buttonClass = '',
15 }) => {
16 return (
17 <Listbox
18 className={`${className} ${disabled ? 'disco-opacity-50' : ''}`}
19 disabled={disabled}
20 value={selected}
21 onChange={!disabled && onchange}
22 >
23 <div className="disco-relative">
24 <Listbox.Button
25 className={`disco-relative disco-cursor-pointer disco-w-full disco-rounded-md disco-border disco-text-base disco-border-primary disco-py-2 disco-pl-2.5 disco-pr-8 disco-text-left focus:disco-outline-none ${buttonClass}`}
26 >
27 <span className="disco-block disco-truncate">
28 {items[selected] || placeholder}
29 </span>
30 <span className="disco-pointer-events-none disco-absolute disco-inset-y-0 disco-right-0 disco-flex disco-items-center disco-pr-0.5">
31 <ChevronDownIcon
32 className="disco-h-5 disco-w-5 disco-text-primary"
33 aria-hidden="true"
34 />
35 </span>
36 </Listbox.Button>
37 <Transition
38 as={Fragment}
39 leave="disco-transition disco-ease-in disco-duration-100"
40 leaveFrom="disco-opacity-100"
41 leaveTo="disco-opacity-0"
42 >
43 <Listbox.Options className="disco-z-50 disco-absolute disco-cursor-pointer disco-mt-1.5 disco-max-h-60 disco-w-full disco-overflow-auto disco-rounded-md disco-bg-white disco-text-base disco-shadow-lg disco-ring-1 disco-ring-black disco-ring-opacity-5 focus:disco-outline-none sm:disco-text-sm">
44 {items &&
45 Object.keys(items).map((item) => (
46 <Listbox.Option
47 key={item}
48 className={({ active }) =>
49 `disco-relative disco-py-1 disco-pl-4 disco-mb-0 hover:disco-bg-[#dfffefe6] ${
50 active && !menu
51 ? 'disco-bg-primary-light'
52 : 'disco-text-gray-900'
53 }`
54 }
55 value={item}
56 >
57 {({ selected }) => (
58 <>
59 <span
60 className={`disco-block disco-truncate ${
61 selected && !menu
62 ? 'disco-font-medium'
63 : 'disco-font-normal'
64 }`}
65 >
66 {items[item]}
67 </span>
68 </>
69 )}
70 </Listbox.Option>
71 ))}
72 </Listbox.Options>
73 </Transition>
74 </div>
75 </Listbox>
76 );
77 };
78 export default SingleSelect;
79