Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/static/js/customizer/controls/options.js

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + import { createElement, useRef, useState } from '@wordpress/element'
2 + import classnames from 'classnames'
3 +
4 + import OptionsPanel from '../../options/OptionsPanel'
5 + import { getValueFromInput } from '../../options/helpers/get-value-from-input'
6 + import PanelLevel from '../../options/components/PanelLevel'
7 + import { DeviceManagerProvider } from '../components/useDeviceManager'
8 +
9 + import { CustomizerValues } from './customizer-values-context'
10 +
11 + const Options = ({ option, renderOptions = null }) => {
12 + const [values, setValues] = useState(null)
13 +
14 + const containerRef = useRef()
15 +
16 + const onChangeFor = (key, val) => {
17 + setValues((values) => {
18 + return {
19 + ...(values ||
20 + getValueFromInput(option['inner-options'], {}, (id) => ({
21 + [id]: wp.customize(id) && wp.customize(id)(),
22 + }))),
23 + [key]: val,
24 + }
25 + })
26 +
27 + wp.customize(key) && wp.customize(key).set(val)
28 + }
29 +
30 + const computedValues =
31 + values ||
32 + getValueFromInput(option['inner-options'], {}, (id) => ({
33 + [id]: wp.customize(id) && wp.customize(id)(),
34 + }))
35 +
36 + return (
37 + <CustomizerValues.Provider
38 + value={{
39 + values: computedValues,
40 + onChange: onChangeFor,
41 + }}>
42 + <DeviceManagerProvider>
43 + <div className="ct-options-container" ref={containerRef}>
44 + <PanelLevel containerRef={containerRef}>
45 + <OptionsPanel
46 + renderOptions={renderOptions}
47 + purpose="customizer"
48 + onChange={(key, val) => {
49 + onChangeFor(key, val)
50 + }}
51 + options={option['inner-options']}
52 + value={computedValues}
53 + />
54 + </PanelLevel>
55 + </div>
56 + </DeviceManagerProvider>
57 + </CustomizerValues.Provider>
58 + )
59 + }
60 +
61 + export default Options
62 +