| Server IP : 38.190.208.107 / Your IP : 216.73.217.19 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/themes/blocksy/static/js/options/options/ |
Upload File : |
import {
createElement,
Component,
Fragment,
createContext,
useRef,
useContext,
useState,
} from '@wordpress/element'
import SinglePicker from './color-picker/single-picker'
import { normalizeCondition, matchValuesWithCondition } from 'match-conditions'
import BodyPickerModal from './color-picker/body-picker-modal'
import { useSpringModal } from '../helpers/useSpringModal'
const ColorPicker = ({
option,
values,
value: internalValue,
onChange: onInternalChange,
device,
}) => {
const value = internalValue
const onChange = onInternalChange
const [currentPicker, setCurrentPicker] = useState({
picker: null,
el: {
current: null,
},
})
const { modalOpen, modalStyles, openModal, closeModal } = useSpringModal({
onClosed: () => {
setCurrentPicker({
picker: null,
el: {
current: null,
},
})
},
})
const containerRef = useRef()
const modalRef = useRef()
return (
<Fragment>
<div ref={containerRef} className="ct-color-picker-container">
{option.pickers
.filter(
(picker) =>
!picker.condition ||
matchValuesWithCondition(
normalizeCondition(picker.condition),
picker.condition_source === 'global'
? Object.keys(picker.condition).reduce(
(current, key) => ({
...current,
[key]: wp.customize(key)(),
}),
{}
)
: values
)
)
.map((picker) => (
<SinglePicker
containerRef={containerRef}
device={device}
picker={picker}
key={picker.id}
option={option}
modalRef={modalRef}
values={values}
modalOpen={modalOpen}
onOutsideClick={() => {
closeModal()
}}
onPickingChange={(el) => {
if (
currentPicker.picker &&
currentPicker.picker.id === picker.id
) {
closeModal()
return
}
setCurrentPicker({
picker,
el,
})
openModal()
}}
onChange={(newPicker) => {
onChange({
...value,
[picker.id]: newPicker,
})
}}
value={value[picker.id] || option.value[picker.id]}
/>
))}
</div>
{modalOpen && (
<BodyPickerModal
option={option}
currentPicker={currentPicker}
values={values}
value={
currentPicker.picker
? value[currentPicker.picker.id] ||
option.value[currentPicker.picker.id]
: null
}
device={device}
modalRef={modalRef}
onChange={(newPicker) => {
onChange({
...value,
[currentPicker.picker.id]: newPicker,
})
}}
modalSprings={modalStyles}
/>
)}
</Fragment>
)
}
export default ColorPicker