/** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { InspectorControls } from '@wordpress/block-editor'; import { PanelBody, TextControl, Button, ButtonGroup, BaseControl, ToggleControl, SelectControl, TabPanel, Notice, } from '@wordpress/components'; import { useEffect } from '@wordpress/element'; import { select, useSelect } from '@wordpress/data'; /** * Internal depencencies */ import objAttributes from "./attributes"; import Select from "react-select"; import FontIconPicker from "@fonticonpicker/react-fonticonpicker"; import faIcons from "../../../util/faIcons"; import { mimmikCssForResBtns, mimmikCssOnPreviewBtnClickWhileBlockSelected, } from "../../../util/helpers"; import { ORDER_BY, ORDER, FAQ_LAYOUT, getFaqTaxonomyOptions, FAQ_LIST_BACKGROUND, FAQ_CONTENT_BACKGROUND, FAQ_LIST_MARGIN, FAQ_LIST_PADDING, FAQ_BORDER, FAQ_CONTENT_BORDER, FAQ_CONTENT_MARGIN, FAQ_CONTENT_PADDING, POSTS_ORDER_BY, ICON_MARGIN, BTN_MARGIN, BTN_PADDING, BTN_BACKGROUND, BTN_BORDER, BUTTON_POSITION, WRAPPER_MARGIN, ICON_SIZE, SECTION_TITLE_MARGIN, SECTION_TITLE_PADDING, GROUP_TITLE_MARGIN, GROUP_TITLE_PADDING, CONTAINER_SECTION_PADDING, CONTAINER_SECTION_MARGIN, CONTAINER_SECTION_BACKGROUND, FAQ_LIST_BACKGROUND_LAYOUT_3, GROUP_TITLE_PADDING_LAYOUT_4, GROUP_TITLE_MARGIN_LAYOUT_4, FAQ_LIST_PADDING_LAYOUT_4, FAQ_LIST_MARGIN_LAYOUT_4, FAQ_LIST_BACKGROUND_LAYOUT_4, FAQ_BORDER_LAYOUT_4, FAQ_CONTENT_PADDING_LAYOUT_4, FAQ_CONTENT_MARGIN_LAYOUT_4, FAQ_CONTENT_BACKGROUND_LAYOUT_4, FAQ_CONTENT_BORDER_LAYOUT_4, HTML_TAGS } from "./constants"; import { typoPrefix_section_titele, typoPrefix_group_title, typoPrefix_faq_title, typoPrefix_faq_content, typoPrefix_section_title_layout_3, typoPrefix_group_title_layout_4, typoPrefix_faq_title_layout_4, typoPrefix_faq_content_layout_4 } from "./typographyPrefixConstants"; // util import ResponsiveRangeController from "../../../util/responsive-range-control"; import ResponsiveDimensionsControl from "../../../util/dimensions-control-v2"; import TypographyDropdown from "../../../util/typography-control-v2"; import BackgroundControl from "../../../util/background-control"; import BorderShadowControl from "../../../util/border-shadow-control"; import ColorControl from "../../../util/color-control"; import { htmlToElem } from '../../../helpers/helper'; const Inspector = ({ faqs, attributes, setAttributes, }) => { const { resOption, faqLayout, faqTaxonomy, faqOrder, faqSectionText, faqSectionTitleTag, faqGroupTitleTag, includeFaqGroup, excludeFaqGroup, faqSectionTitleColor, faqSectionTitleHoverColor, faqGroupTitleColor, faqGroupTitleLayout4Color, faqGroupTitleLayout4HoverColor, faqListLayout4Color, faqContentLayout4Color, faqGroupTitleHoverColor, faqListColor, faqContentColor, faqIconColor, faqGroupTitleTypography, postCategories, faqPerPage, orderBy, order, postsPerPage, postsOrderBy, postsOrder, enableNestedSubcategory, postPerSubcategory, layout, layoutMode, showHeader, showIcon, showTitle, showThumbnail, showDescription, titleTag, showCount, showList, listIcon, showButton, buttonText, titleColor, titleHoverColor, descriptionColor, descriptionHoverColor, countColor, countHoverColor, listColor, listHoverColor, iconColor, showButtonIcon, buttonIcon, buttonColor, buttonColorLayout4, buttonHoverColor, buttonPosition, } = attributes; const docFaqs = useSelect( ( sel ) => { return sel( 'core' ).getEntityRecords( 'taxonomy', faqTaxonomy || 'betterdocs_faq_category', { per_page: -1 } ); }, [ faqTaxonomy ] ); const editorStoreForGettingPreivew = betterdocs_style_handler.editor_type === "edit-site" ? "core/edit-site" : "core/edit-post"; // this useEffect is for setting the resOption attribute to desktop/tab/mobile depending on the added 'eb-res-option-' class only the first time once useEffect(() => { setAttributes({ resOption: select( editorStoreForGettingPreivew ).__experimentalGetPreviewDeviceType(), }); }, []); const resRequiredProps = { setAttributes, resOption, attributes, objAttributes, }; // handle include faqs const handleIncludeCategories = (faqs) => { setAttributes({ includeFaqGroup: faqs ? JSON.stringify(faqs) : null, }); }; // handle exclude faqs const handleExcludeCategories = (faqs) => { setAttributes({ excludeFaqGroup: faqs ? JSON.stringify(faqs) : null, }); }; // Define a function to generate options const faqOptions = (docFaqs) => { if (!docFaqs) return []; return docFaqs.map((faq) => ({ value: faq.id, label: faq.name, })); }; // control POSTS_ORDER_BY for pro plugin let posts_order_by = Boolean(betterDocsBlocksHelper.is_pro_active) === true ? [ ...POSTS_ORDER_BY, { label: __("BetterDocs Order", "betterdocs-pro"), value: "betterdocs_order", }, ] : [...POSTS_ORDER_BY]; return (
{(tab) => (
{tab.name === "general" && ( <> <> setAttributes({ faqTaxonomy, includeFaqGroup: null, excludeFaqGroup: null })} /> setAttributes({ faqLayout })} /> setAttributes({ faqOrder })} /> setAttributes({ faqSectionText })} /> setAttributes({ faqSectionTitleTag: faqSectionTitleTag, }) } /> setAttributes({ faqGroupTitleTag: faqGroupTitleTag, }) } /> { faqTaxonomy === 'product_assignments' ? ( { __( 'Groups are resolved automatically per product: a per-product assignment is shown if set, otherwise the groups assigned to the product’s categories. Manage assignments on each group in FAQ Builder → WooCommerce → Product FAQ Groups.', 'betterdocs' ) } ) : ( <> ) } )} {tab.name === "styles" && ( <> setAttributes({ faqSectionTitleColor })} /> { if( faqLayout == 'layout-4' ) { setAttributes({ faqGroupTitleLayout4Color: faqGroupTitleColor }); } else { setAttributes({ faqGroupTitleColor: faqGroupTitleColor }); } }} /> { if( faqLayout == 'layout-4' ) { setAttributes({ faqGroupTitleLayout4HoverColor: faqGroupTitleHoverColor }) } else { setAttributes({ faqGroupTitleHoverColor: faqGroupTitleHoverColor }) } }} />

{__("Background", "betterdocs-pro")}

{ if(faqLayout == 'layout-4'){ setAttributes({ faqListLayout4Color:faqListColor }) } else { setAttributes({ faqListColor:faqListColor }) } }} />

{__("Border", "betterdocs-pro")}


{__("Background", "betterdocs-pro")}

{ if( faqLayout == 'layout-4' ) { setAttributes({ faqContentLayout4Color:faqContentColor }); }else { setAttributes({ faqContentColor:faqContentColor }); } }} />

{__("Border", "betterdocs-pro")}

{ setAttributes({ showButtonIcon: !showButtonIcon, }); }} /> {showButtonIcon && ( <> )} { if( faqLayout == 'layout-4' ) { setAttributes({ buttonColorLayout4:buttonColor }); } else { setAttributes({ buttonColor:buttonColor }); } }} /> )} {/* {tab.name === "advance" && ( )} */}
)}
); }; export default Inspector;