wrapper($input); } private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) { $fh = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map); $ph = isset($field->ph) ? $field->ph : ''; $val = !empty($value) ? $value : $fh->value(); $val = 'array' === gettype($val) ? ("value='" . implode(',', $val) . "'") : $val; $name = $fh->name(); $req = $fh->required(); $readonlyCls = isset($field->valid->readonly) ? 'readonly' : ''; $disabledCls = isset($field->valid->disabled) ? 'disabled' : ''; $selectedOptImage = ''; $optionsList = ''; $activeList = isset($field->config->activeList) ? $field->config->activeList : null; $optionIcon = ''; $allowCustomOption = isset($field->config->allowCustomOption) ? $field->config->allowCustomOption : false; $img = htmlentities("data:image/svg+xml,"); if ($fh->property_exists_nested($field, 'config->optionIcon', true)) { $optionIcon = <<getCustomAttributes('opt-icn')} class="opt-icn {$fh->getCustomClasses('opt-icn')}" src="{$img}" alt="BD" loading="lazy" /> OPTIONICON; } if ($fh->property_exists_nested($field, 'config->selectedOptImage', true)) { $selectedOptImage = <<getCustomAttributes('selected-opt-img')} class="{$fh->getConversationalMultiCls('selected-opt-img')} placeholder-img {$fh->getCustomClasses('selected-opt-img')}" aria-hidden="true" alt="selected option icon" src="{$img}" > SELECTEDoPTIMAGE; } if (property_exists($field, 'optionsList')) { foreach ($field->optionsList as $key => $value) { $dataIndex = 0; $valueArr = (array) $value; $listName = array_keys($valueArr)[0]; $options = array_values($valueArr)[0]; $optionsList .= <<getCustomAttributes('option-list')} class="{$fh->getClassWithFieldKey('option-list')} {$fh->getConversationalCls('dpd-option-list')} {$fh->getCustomClasses('option-list')}" aria-hidden="true" aria-label="Option List" data-list="{$fh->esc_attr($listName)}" data-list-index="{$key}" tabIndex="-1" role="listbox" > OPTIONSLIST; if ($allowCustomOption) { $optionsList .= <<getCustomAttributes('option')} data-index={$dataIndex} data-value="create-opt" class="option create-opt {$fh->getCustomClasses('option')}" role="option" aria-selected="false" tabIndex="-1" style="display: none !important;" > getCustomAttributes('opt-lbl-wrp')} class="opt-lbl-wrp {$fh->getCustomClasses('opt-lbl-wrp')}" > getCustomAttributes('opt-lbl')} class="opt-lbl {$fh->getCustomClasses('opt-lbl')}" > Create: CREATEOPT; } foreach ($options as $opt) { if (isset($opt->type)) { $disableOpt = isset($opt->disabled) ? 'disabled-opt' : ''; $optionsList .= <<getCustomAttributes('option')} class="option opt-group-title {$fh->getCustomClasses('option')} {$disableOpt}" > getCustomAttributes('opt-lbl')} class="opt-lbl {$fh->getCustomClasses('opt-lbl')}" > {$fh->kses_post($opt->title)} OPTIOINS; foreach ($opt->childs as $child) { $optVal = isset($child->val) ? $child->val : $child->lbl; $disableOpt = (isset($opt->disabled) || isset($child->disabled)) ? 'disabled-opt' : ''; $optImage = ''; if (isset($child->img)) { $optImage = <<getCustomAttributes('opt-icn')} class="opt-icn {$fh->getCustomClasses('opt-icn')}" aria-hidden="true" alt="{$fh->esc_attr($child->lbl)}" src="{$fh->esc_url($child->img)}" > OPTIMAGE; } $optionsList .= <<getCustomAttributes('option')} data-index="{$dataIndex}" data-value="{$fh->esc_attr($optVal)}" class="option opt-group-child {$fh->getCustomClasses('option')} {$disableOpt}" role="option" aria-selected="false" tabIndex="-1" > getCustomAttributes('opt-lbl-wrp')} class="opt-lbl-wrp {$fh->getCustomClasses('opt-lbl-wrp')}" > {$optImage} getCustomAttributes('opt-lbl')} class="opt-lbl {$fh->getCustomClasses('opt-lbl')}" > {$fh->kses_post($child->lbl)} OPTIONS_CHILDREN; } } else { $optVal = isset($opt->val) ? $opt->val : $opt->lbl; $disableOpt = isset($opt->disabled) ? 'disabled-opt' : ''; $optImage = ''; if (isset($opt->img)) { $optImage = <<getCustomAttributes('opt-icn')} class="opt-icn {$fh->getCustomClasses('opt-icn')}" aria-hidden="true" alt="{$fh->esc_attr($opt->lbl)}" src="{$fh->esc_url($opt->img)}" > OPTIMAGE; } $optionsList .= <<getCustomAttributes('option')} data-index="{$dataIndex}" data-value="{$fh->esc_attr($optVal)}" class="option {$fh->getCustomClasses('option')} {$disableOpt}" role="option" aria-selected="false" tabIndex="-1" > getCustomAttributes('opt-lbl-wrp')} class="opt-lbl-wrp {$fh->getCustomClasses('opt-lbl-wrp')}" > {$optImage} getCustomAttributes('opt-lbl')} class="opt-lbl {$fh->getCustomClasses('opt-lbl')}" > {$fh->kses_post($opt->lbl)} OPTIONS; } } $optionsList .= ''; $dataIndex++; } $optionsList .= <<getCustomAttributes('option-list')} class="{$fh->getClassWithFieldKey('option-list')} {$fh->getConversationalCls('dpd-option-list')} {$fh->getCustomClasses('option-list')} active-list" aria-hidden="true" aria-label="Option List" tabIndex="-1" role="listbox" > OPTIONSLIST; $multiChipClass = ($fh->property_exists_nested($field, 'config->multipleSelect', true) && $fh->property_exists_nested($field, 'config->showChip', true)) ? 'multi-chip' : ''; return <<
getCustomAttributes('dpd-fld-wrp')} class="{$fh->getClassWithFieldKey('dpd-fld-wrp')} {$fh->getConversationalCls('dpd-slct-fld-wrp')} {$fh->getCustomClasses('dpd-fld-wrp')} {$readonlyCls} {$disabledCls}" > disabled()} {$fh->readonly()} {$val} />
getCustomAttributes('dpd-wrp')} class="{$fh->getClassWithFieldKey('dpd-wrp')} {$fh->getConversationalCls('dpd-slct-wrp')} {$fh->getCustomClasses('dpd-wrp')}" role="combobox" aria-controls="" aria-live="assertive" aria-expanded="false" tabIndex="0" aria-label="Dropdown" >
getCustomAttributes('selected-opt-wrp')} class="{$fh->getConversationalMultiCls('selected-opt-wrp')} {$fh->getCustomClasses('selected-opt-wrp')}" > {$selectedOptImage} getCustomAttributes('selected-opt-lbl')} aria-label="Selected Option Label" class="{$fh->getConversationalMultiCls('selected-opt-lbl')} {$multiChipClass} {$fh->getCustomClasses('selected-opt-lbl')}" > {$fh->esc_html($ph)}
getCustomAttributes('dpd-btn-wrp')} class="{$fh->getConversationalMultiCls('dpd-btn-wrp')} {$fh->getCustomClasses('dpd-btn-wrp')}" >
getCustomAttributes('dpd-down-btn')} class="{$fh->getConversationalMultiCls('dpd-down-btn')} {$fh->getCustomClasses('dpd-down-btn')}" >
getCustomAttributes('option-wrp')} class="{$fh->getConversationalMultiCls('option-wrp')} {$fh->getCustomClasses('option-wrp')}" >
getCustomAttributes('option-inner-wrp')} class="{$fh->getConversationalMultiCls('option-inner-wrp')} {$fh->getCustomClasses('option-inner-wrp')}" >
getCustomAttributes('option-search-wrp')} class="{$fh->getConversationalMultiCls('option-search-wrp')} {$fh->getCustomClasses('option-search-wrp')}" > getCustomAttributes('opt-search-input')} type="search" class="{$fh->getConversationalMultiCls('opt-search-input')} {$fh->getCustomClasses('opt-search-input')}" placeholder="Search Country" aria-label="Search Options" aria-hidden="true" tabIndex="-1" /> getCustomAttributes('opt-search-icn')} class="{$fh->getConversationalMultiCls('icn')} {$fh->getConversationalMultiCls('opt-search-icn')} {$fh->getCustomClasses('opt-search-icn')}" aria-hidden="true" width="22" height="22" role="img" title="Search icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" >
{$optionsList}
DROPDOWNFIELD; } } }