PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / V3.0.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder vV3.0.2
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
bit-form / includes / Frontend / Form / View / Conversational / Fields / CurrencyField.php

CurrencyField.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder V3.0.2, at includes/Frontend/Form/View/Conversational/Fields/CurrencyField.php

238 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Frontend\Form\View\Conversational\Fields;
4
5 class CurrencyField
6 {
7 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = '')
8 {
9 $inputWrapper = new ConversationalInputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
10 $input = self::field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
11 return $inputWrapper->wrapper($input);
12 }
13
14 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = '')
15 {
16 $fh = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map);
17 $img_url = BITFORMS_ASSET_URI . '/../static/currencies/';
18
19 $req = $fh->required();
20 $disabled = $fh->disabled();
21 $readonly = $fh->readonly();
22 $name = $fh->name();
23 $ph = $fh->placeholder();
24 $ariaDescribedBy = $fh->ariaDescribedBy();
25 $ariaRequired = $fh->ariaRequired();
26 // Get dynamic label ID to properly link the combobox to its label for screen readers
27 $labelId = $fh->getLabelId();
28 $selectedFlagImage = '';
29 $tabIndx = isset($field->disabled) ? -1 : 0;
30 $selectedCurrencyClearable = '';
31 $searchPlaceholder = '';
32 $searchClearable = '';
33 $options = '';
34 $readonlyCls = isset($field->readonly) ? 'readonly' : '';
35 $disabledCls = isset($field->disabled) ? 'disabled' : '';
36 $value = is_string($value) ? $value : '';
37 $numValue = preg_replace('/[^0-9.-]/', '', $value);
38
39 $img = esc_url(includes_url('images/blank.gif'));
40
41 if ($fh->property_exists_nested($field, 'config->selectedFlagImage', true)) {
42 $selectedFlagImage = sprintf(
43 ' <div class="%1$s">
44 <img
45 %2$s
46 class="%3$s %4$s"
47 aria-hidden="true"
48 alt="selected country flag"
49 src="%5$s"
50 />
51 </div>
52 ',
53 $fh->getConversationalMultiCls('selected-currency-wrp'),
54 $fh->getCustomAttributes('selected-currency-img'),
55 $fh->getConversationalMultiCls('selected-currency-img'),
56 $fh->getCustomClasses('selected-currency-img'),
57 $img
58 );
59 }
60
61 if ($fh->property_exists_nested($field, 'config->selectedCurrencyClearable', true)) {
62 $selectedCurrencyClearable = sprintf(
63 ' <button
64 %1$s
65 type="button"
66 title="Clear selected currency value"
67 class="%2$s %3$s"
68 >
69 <svg
70 width="12"
71 height="12"
72 role="img"
73 title="Cross icon"
74 viewBox="0 0 24 24"
75 fill="none"
76 stroke="currentColor"
77 stroke-width="2"
78 stroke-linecap="round"
79 stroke-linejoin="round"
80 >
81 <line x1="18" y1="6" x2="6" y2="18" />
82 <line x1="6" y1="6" x2="18" y2="18" />
83 </svg>
84 </button>
85 ',
86 $fh->getCustomAttributes('input-clear-btn'),
87 $fh->getConversationalMultiCls('input-clear-btn'),
88 $fh->getCustomClasses('input-clear-btn')
89 );
90 }
91
92 if ($fh->property_exists_nested($field, 'config->searchPlaceholder', '', 1)) {
93 $searchPlaceholder = "placeholder='{$fh->esc_attr($field->config->searchPlaceholder)}'";
94 }
95
96 if ($fh->property_exists_nested($field, 'config->searchClearable', true)) {
97 $searchClearable = sprintf(
98 ' <button
99 %1$s
100 type="button"
101 title="Clear search"
102 class="%2$s %3$s %4$s"
103 tabIndex="-1"
104 >
105 <svg
106 width="12"
107 height="12"
108 role="img"
109 title="Cross icon"
110 viewBox="0 0 24 24"
111 fill="none"
112 stroke="currentColor"
113 stroke-width="2"
114 stroke-linecap="round"
115 stroke-linejoin="round"
116 >
117 <line x1="18" y1="6" x2="6" y2="18" />
118 <line x1="6" y1="6" x2="18" y2="18" />
119 </svg>
120 </button>
121 ',
122 $fh->getCustomAttributes('search-clear-btn'),
123 $fh->getConversationalMultiCls('icn'),
124 $fh->getConversationalMultiCls('search-clear-btn'),
125 $fh->getCustomClasses('search-clear-btn')
126 );
127 }
128
129 return ' <div class="' . $fh->getConversationalMultiCls('currency-fld-container') . '">
130 <div
131 ' . $fh->getCustomAttributes('currency-fld-wrp') . '
132 class="' . $fh->getConversationalMultiCls('currency-fld-wrp') . ' ' . $fh->getCustomClasses('currency-fld-wrp') . ' ' . $disabled . ' ' . $readonly . '"
133 >
134 <input
135 ' . $fh->getCustomAttributes('currency-hidden-input') . '
136 ' . $name . '
137 ' . $req . '
138 ' . $ariaRequired . '
139 ' . $ariaDescribedBy . '
140 type="text"
141 title="Currency Hidden Input"
142 class="' . $fh->getConversationalMultiCls('currency-hidden-input') . ' d-none"
143 ' . $disabled . '
144 ' . $readonly . '
145 value="' . $fh->esc_attr($value) . '"
146 />
147 <div class="' . $fh->getConversationalMultiCls('currency-inner-wrp') . '">
148 <div
149 ' . $fh->getCustomAttributes('dpd-wrp') . '
150 class="' . $fh->getConversationalMultiCls('dpd-wrp') . ' ' . $fh->getCustomClasses('dpd-wrp') . '"
151 role="combobox"
152 aria-controls="currency-dropdown"
153 aria-haspopup="listbox"
154 aria-live="assertive"
155 aria-labelledby="{$labelId}"
156 aria-expanded="false"
157 tabIndex="' . $tabIndx . '"
158 >
159 ' . $selectedFlagImage . '
160 <div class="' . $fh->getConversationalMultiCls('dpd-down-btn') . '">
161 <svg
162 width="15"
163 height="15"
164 role="img"
165 title="Downarrow icon"
166 viewBox="0 0 24 24"
167 fill="none"
168 stroke="currentColor"
169 stroke-width="2"
170 stroke-linecap="round"
171 stroke-linejoin="round"
172 >
173 <polyline points="6 9 12 15 18 9" />
174 </svg>
175 </div>
176 </div>
177 <input
178 ' . $fh->getCustomAttributes('currency-amount-input') . '
179 aria-label="Currency Input"
180 type="text"
181 class="' . $fh->getConversationalMultiCls('currency-amount-input') . ' ' . $fh->getCustomClasses('currency-amount-input') . '"
182 ' . $ph . '
183 tabIndex="' . $tabIndx . '"
184 data-num-value="' . $numValue . '"
185 />
186 ' . $selectedCurrencyClearable . '
187 </div>
188 <div
189 ' . $fh->getCustomAttributes('option-wrp') . '
190 class="' . $fh->getConversationalMultiCls('option-wrp') . ' ' . $fh->getCustomClasses('option-wrp') . '"
191 >
192 <div class="' . $fh->getConversationalMultiCls('option-inner-wrp') . '">
193 <div
194 ' . $fh->getCustomAttributes('option-search-wrp') . '
195 class="' . $fh->getConversationalMultiCls('option-search-wrp') . ' ' . $fh->getCustomClasses('option-search-wrp') . '"
196 >
197 <input
198 ' . $fh->getCustomAttributes('opt-search-input') . '
199 type="search"
200 class="' . $fh->getConversationalMultiCls('opt-search-input') . ' ' . $fh->getCustomClasses('opt-search-input') . '"
201 ' . $searchPlaceholder . '
202 autoComplete="off"
203 tabIndex="-1"
204 />
205 <svg
206 ' . $fh->getCustomAttributes('opt-search-icn') . '
207 class="' . $fh->getConversationalMultiCls('icn') . ' ' . $fh->getConversationalMultiCls('opt-search-icn') . ' ' . $fh->getCustomClasses('opt-search-icn') . '"
208 aria-hidden="true"
209 width="22"
210 height="22"
211 viewBox="0 0 24 24"
212 fill="none"
213 stroke="currentColor"
214 stroke-width="2"
215 stroke-linecap="round"
216 stroke-linejoin="round"
217 >
218 <circle cx="11" cy="11" r="8" />
219 <line x1="21" y1="21" x2="16.65" y2="16.65" />
220 </svg>
221 ' . $searchClearable . '
222 </div>
223 <ul
224 ' . $fh->getCustomAttributes('option-list') . '
225 class="' . $fh->getConversationalMultiCls('option-list') . ' ' . $fh->getCustomClasses('option-list') . '"
226 tabIndex="-1"
227 role="listbox"
228 aria-label="currency list"
229 >
230 ' . $options . '
231 </ul>
232 </div>
233 </div>
234 </div>
235 </div>';
236 }
237 }
238