From d67809965f6a9b14d9043597a52a0f8c7bff5683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Garc=C3=ADa?= <lucas@codeccoop.org> Date: Sat, 4 May 2024 03:37:48 +0200 Subject: [PATCH] feat: remove custom fields --- abstract/class-integration.php | 10 +- assets/css/wpct7-theme.css | 20 - assets/js/fieldset-control-js.php | 49 - assets/js/wpcf7-swv-validators.js | 32 - includes/fields/gf/iban/class-addon.php | 57 - .../fields/gf/iban/class-field-adapter.php | 28 - includes/fields/gf/iban/class-field.php | 278 ---- includes/fields/gf/vat-id/class-addon.php | 58 - .../fields/gf/vat-id/class-field-adapter.php | 28 - includes/fields/gf/vat-id/class-field.php | 237 ---- .../fields/wpcf7/conditional/class-field.php | 308 ----- .../fields/wpcf7/conditional/class-rule.php | 18 - .../wpcf7/conditionalfile/class-field.php | 128 -- .../wpcf7/conditionalfile/class-rule.php | 18 - includes/fields/wpcf7/files/class-field.php | 131 -- includes/fields/wpcf7/files/class-rule.php | 55 - includes/fields/wpcf7/iban/class-field.php | 128 -- includes/fields/wpcf7/iban/class-rule.php | 158 --- .../integrations/gf/class-integration.php | 11 - package-lock.json | 1182 ----------------- package.json | 12 +- src/js/ConditionalCheckbox.js | 32 - src/js/ConditionalControl.js | 114 -- src/js/ConditionalHidden.js | 20 - src/js/ConditionalRadio.js | 35 - src/js/Form.js | 126 -- src/js/gf.js | 3 - src/js/wpcf7.js | 7 - wpct-erp-forms.php | 1 - 29 files changed, 3 insertions(+), 3281 deletions(-) delete mode 100644 assets/css/wpct7-theme.css delete mode 100644 assets/js/fieldset-control-js.php delete mode 100644 assets/js/wpcf7-swv-validators.js delete mode 100644 includes/fields/gf/iban/class-addon.php delete mode 100644 includes/fields/gf/iban/class-field-adapter.php delete mode 100644 includes/fields/gf/iban/class-field.php delete mode 100644 includes/fields/gf/vat-id/class-addon.php delete mode 100644 includes/fields/gf/vat-id/class-field-adapter.php delete mode 100644 includes/fields/gf/vat-id/class-field.php delete mode 100644 includes/fields/wpcf7/conditional/class-field.php delete mode 100644 includes/fields/wpcf7/conditional/class-rule.php delete mode 100644 includes/fields/wpcf7/conditionalfile/class-field.php delete mode 100644 includes/fields/wpcf7/conditionalfile/class-rule.php delete mode 100644 includes/fields/wpcf7/files/class-field.php delete mode 100644 includes/fields/wpcf7/files/class-rule.php delete mode 100644 includes/fields/wpcf7/iban/class-field.php delete mode 100644 includes/fields/wpcf7/iban/class-rule.php delete mode 100644 src/js/ConditionalCheckbox.js delete mode 100644 src/js/ConditionalControl.js delete mode 100644 src/js/ConditionalHidden.js delete mode 100644 src/js/ConditionalRadio.js delete mode 100644 src/js/Form.js delete mode 100644 src/js/gf.js delete mode 100644 src/js/wpcf7.js diff --git a/abstract/class-integration.php b/abstract/class-integration.php index c57c1ac..79f8ce6 100644 --- a/abstract/class-integration.php +++ b/abstract/class-integration.php @@ -7,20 +7,11 @@ use Exception; abstract class Integration extends Singleton { - public static $fields = []; - abstract public function serialize_submission($submission, $form); abstract public function serialize_form($form); protected function __construct() { - foreach (static::$fields as $Field) { - $field = $Field::get_instance(); - add_action('init', function () use ($field) { - $field->init(); - }); - } - add_action('init', [$this, 'init']); } @@ -32,6 +23,7 @@ abstract class Integration extends Singleton { $success = true; foreach ($endpoints as $endpoint) { + if (empty($files)) { $response = Wpct_Http_Client::post($endpoint, $payload); } else { diff --git a/assets/css/wpct7-theme.css b/assets/css/wpct7-theme.css deleted file mode 100644 index 0e72466..0000000 --- a/assets/css/wpct7-theme.css +++ /dev/null @@ -1,20 +0,0 @@ -.wpcf7-form.submitting { - cursor: wait; -} - -.wpcf7-form.submitting .wpcf7-form-control input, -.wpcf7-form.submitting .wpcf7-form-control select, -.wpcf7-form.submitting .wpcf7-form-control textarea { - cursor: wait; - pointer-events: none; -} - -.wpcf7-form-control.wpcf7-not-valid { - color: var(--wp--preset--color--vivid-red); - font-style: italic; -} - -.wpcf7-form-control.wpcf7-radio.vertical .wpcf7-list-item, -.wpcf7-form-control.wpcf7-checkbox.vertical .wpcf7-list-item { - display: block; -} diff --git a/assets/js/fieldset-control-js.php b/assets/js/fieldset-control-js.php deleted file mode 100644 index 04a4a70..0000000 --- a/assets/js/fieldset-control-js.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -// Script to be buffered from settings class -$default_value = $defaults[$field][0]; -$is_array = is_array($default_value); -$table_id = $setting . '__' . str_replace('][', '_', $field); -?> - -<script> - (function() { - function renderRowContent(index) { - <?php if ($is_array) : ?> - return `<table id="<?= $table_id ?>_${index}"> - <?php foreach (array_keys($default_value) as $key) : ?> - <tr> - <th><?= $field ?></th> - <td><?= $this->input_render($setting, $field . '][${index}][' . $key, $default_value[$key]); ?></td> - </tr> - <?php endforeach; ?> - </table>`; - <?php else : ?> - return `<?= $this->input_render($setting, $field . '][${index}', $default_value); ?>`; - <?php endif; ?> - } - - function addItem(ev) { - ev.preventDefault(); - const table = document.getElementById("<?= $table_id ?>") - .children[0]; - const tr = document.createElement("tr"); - tr.innerHTML = - "<td>" + renderRowContent(table.children.length) + "</td>"; - table.appendChild(tr); - } - - function removeItem(ev) { - ev.preventDefault(); - const table = document.getElementById("<?= $table_id ?>") - .children[0]; - const rows = table.children; - table.removeChild(rows[rows.length - 1]); - } - - const buttons = document.currentScript.previousElementSibling.querySelectorAll("button"); - buttons.forEach((btn) => { - const callback = btn.dataset.action === "add" ? addItem : removeItem; - btn.addEventListener("click", callback); - }); - })(); -</script> diff --git a/assets/js/wpcf7-swv-validators.js b/assets/js/wpcf7-swv-validators.js deleted file mode 100644 index 25498de..0000000 --- a/assets/js/wpcf7-swv-validators.js +++ /dev/null @@ -1,32 +0,0 @@ -for (const form of document.querySelectorAll(".wpcf7 > form")) { - let _wpcft = form.wpcf7, - _schema = form.wpcf7?.schema; - Object.defineProperty(form, "wpcf7", { - get: () => _wpcft, - set: (val) => { - _wpcft = val; - Object.defineProperty(_wpcft, "schema", { - get: () => _schema, - set: (val) => { - _schema = val; - }, - }); - }, - }); - - form.querySelectorAll(".wpcf7-files").forEach((control) => { - control.name = control.name + "[]"; - }); -} - -document.addEventListener("DOMContentLoaded", () => { - function conditionalValidator(a) { - const validator = window.swv.validators[this.condition]; - if (validator) { - validator.call(this, a); - } - } - - window.swv.validators.conditional = conditionalValidator; - window.swv.validators.conditionalfile = conditionalValidator; -}); diff --git a/includes/fields/gf/iban/class-addon.php b/includes/fields/gf/iban/class-addon.php deleted file mode 100644 index 1123270..0000000 --- a/includes/fields/gf/iban/class-addon.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\GF\Fields\Iban; - -use GFForms; -use GFAddOn; -use GF_Fields; - -GFForms::include_addon_framework(); - -class Addon extends GFAddOn -{ - protected $_version = '1.0'; - protected $_slug = 'wpct-erp-forms-iban-field'; - protected $_title = 'Gravity Forms IBAN validated text field'; - protected $_short_title = 'IBAN field'; - - /** - * @var object $_instance If available, contains an instance of this class. - */ - private static $_instance = null; - - /** - * Returns an instance of this class, and stores it in the $_instance property. - * - * @return object $_instance An instance of this class. - */ - public static function get_instance() - { - if (self::$_instance == null) { - self::$_instance = new self(); - } - - return self::$_instance; - } - - function __construct() - { - $this->_full_path = __FILE__; - parent::__construct(); - } - - /** - * Include the field early so it is available when entry exports are being performed. - */ - public function pre_init() - { - parent::pre_init(); - if ( - $this->is_gravityforms_supported() && - class_exists('GF_Field') && - class_exists('GF_Fields') - ) { - GF_Fields::register(new GFField()); - } - } -} diff --git a/includes/fields/gf/iban/class-field-adapter.php b/includes/fields/gf/iban/class-field-adapter.php deleted file mode 100644 index d86d409..0000000 --- a/includes/fields/gf/iban/class-field-adapter.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\GF\Fields\Iban; - -use WPCT_ERP_FORMS\Abstract\Field as BaseField; - -use GFAddOn; - -require_once 'class-addon.php'; -require_once 'class-field.php'; - -class FieldAdapter extends BaseField -{ - public function __construct() - { - add_action('gform_loaded', [$this, 'register']); - } - - public function register() - { - if (!method_exists('GFForms', 'include_addon_framework')) return; - GFAddOn::register(Addon::class); - } - - public function init() - { - } -} diff --git a/includes/fields/gf/iban/class-field.php b/includes/fields/gf/iban/class-field.php deleted file mode 100644 index 25fdedc..0000000 --- a/includes/fields/gf/iban/class-field.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\GF\Fields\Iban; - -use GF_Field; -use Exception; - -class GFField extends GF_Field -{ - /** - * @var array @type Country codes - */ - private $_countries = [ - 'al' => 28, - 'ad' => 24, - 'at' => 20, - 'az' => 28, - 'bh' => 22, - 'be' => 16, - 'ba' => 20, - 'br' => 29, - 'bg' => 22, - 'cr' => 21, - 'hr' => 21, - 'cy' => 28, - 'cz' => 24, - 'dk' => 18, - 'do' => 28, - 'ee' => 20, - 'fo' => 18, - 'fi' => 18, - 'fr' => 27, - 'ge' => 22, - 'de' => 22, - 'gi' => 23, - 'gr' => 27, - 'gl' => 18, - 'gt' => 28, - 'hu' => 28, - 'is' => 26, - 'ie' => 22, - 'il' => 23, - 'it' => 27, - 'jo' => 30, - 'kz' => 20, - 'kw' => 30, - 'lv' => 21, - 'lb' => 28, - 'li' => 21, - 'lt' => 20, - 'lu' => 20, - 'mk' => 19, - 'mt' => 31, - 'mr' => 27, - 'mu' => 30, - 'mc' => 27, - 'md' => 24, - 'me' => 22, - 'nl' => 18, - 'no' => 15, - 'pk' => 24, - 'ps' => 29, - 'pl' => 28, - 'pt' => 25, - 'qa' => 29, - 'ro' => 24, - 'sm' => 27, - 'sa' => 24, - 'rs' => 22, - 'sk' => 24, - 'si' => 19, - 'es' => 24, - 'se' => 24, - 'ch' => 21, - 'tn' => 24, - 'tr' => 26, - 'ae' => 23, - 'gb' => 22, - 'vg' => 24, - ]; - - /** - * @var array $type Char codes - */ - private $_chars = [ - 'a' => 10, - 'b' => 11, - 'c' => 12, - 'd' => 13, - 'e' => 14, - 'f' => 15, - 'g' => 16, - 'h' => 17, - 'i' => 18, - 'j' => 19, - 'k' => 20, - 'l' => 21, - 'm' => 22, - 'n' => 23, - 'o' => 24, - 'p' => 25, - 'q' => 26, - 'r' => 27, - 's' => 28, - 't' => 29, - 'u' => 30, - 'v' => 31, - 'w' => 32, - 'x' => 33, - 'y' => 34, - 'z' => 35 - ]; - /** - * @var string $type The field type. - */ - public $type = 'iban-field'; - - /** - * Return the field title, for use in the form editor. - * - * @return string - */ - public function get_form_editor_field_title() - { - return esc_attr__('IBAN'); - } - - /** - * Assign the field button to the Advanced Fields group. - * - * @return array - */ - public function get_form_editor_button() - { - return [ - 'group' => 'advanced_fields', - 'text' => $this->get_form_editor_field_title(), - ]; - } - - /** - * The settings which should be available on the field in the form editor. - * - * @return array - */ - public function get_form_editor_field_settings() - { - return [ - 'conditional_logic_field_setting', - 'error_message_setting', - 'label_setting', - 'label_placement_setting', - 'admin_label_setting', - 'size_setting', - 'password_field_setting', - 'rules_setting', - 'visibility_setting', - 'duplicate_setting', - 'default_value_setting', - 'placeholder_setting', - 'description_setting', - 'css_class_setting', - 'prepopulate_field_setting', - ]; - } - - /** - * Enable this field for use with conditional logic. - * - * @return bool - */ - public function is_conditional_logic_supported() - { - return true; - } - - /** - * Define the fields inner markup. - * - * @param array $form The Form Object currently being processed. - * @param string|array $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission. - * @param null|array $entry Null or the Entry Object currently being edited. - * - * @return string - */ - public function get_field_input($form, $value = '', $entry = null) - { - $form_id = absint($form['id']); - $is_entry_detail = $this->is_entry_detail(); - $is_form_editor = $this->is_form_editor(); - - $html_input_type = 'text'; - - if ($this->enablePasswordInput && !$is_entry_detail) { - $html_input_type = 'password'; - } - - $logic_event = ''; // !$is_form_editor && !$is_entry_detail ? $this->get_conditional_logic_event('keyup') : ''; - $id = (int) $this->id; - $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_$id" : 'input_' . $form_id . "_$id"; - - $value = esc_attr($value); - $size = $this->size; - $class_suffix = $is_entry_detail ? '_admin' : ''; - $class = $size . $class_suffix; - - $tabindex = $this->get_tabindex(); - $disabled_text = $is_form_editor ? 'disabled="disabled"' : ''; - $placeholder_attribute = $this->get_field_placeholder_attribute(); - $required_attribute = $this->isRequired ? 'aria-required="true"' : ''; - $invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"'; - - $input = "<input name='input_{$id}' id='{$field_id}' type='{$html_input_type}' value='{$value}' class='{$class}' {$tabindex} {$logic_event} {$placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>"; - - return sprintf("<div class='ginput_container ginput_container_text'>%s</div>", $input); - } - - /** - * Validate Field - */ - public function validate($value, $form) - { - try { - if (strlen($value) < 5) { - throw new Exception(); - } - $value = strtolower(str_replace(' ', '', $value)); - - $country_exists = array_key_exists(substr($value, 0, 2), $this->_countries); - $country_conform = strlen($value) == $this->_countries[substr($value, 0, 2)]; - - if (!($country_exists && $country_conform)) { - throw new Exception(); - } - - $moved_char = substr($value, 4) . substr($value, 0, 4); - $move_char_array = str_split($moved_char); - $new_string = ''; - - foreach ($move_char_array as $key => $val) { - if (!is_numeric($move_char_array[$key])) { - if (!isset($this->_chars[$val])) { - throw new Exception(); - } - $move_char_array[$key] = $this->_chars[$val]; - } - - $new_string .= $move_char_array[$key]; - } - - if (bcmod($new_string, '97') != 1) { - throw new Exception(); - } - } catch (Exception $e) { - $this->failed_validation = true; - $this->validation_message = empty($this->errorMessage) ? __('The IBAN you\'ve inserted is not valid.', 'wpct-erp-forms') : $this->errorMessage; - } - } - - public function get_form_inline_script_on_page_render($form) - { - ob_start(); - ?> - const input = document.querySelector('#input_<?= $form['id'] ?>_<?= $this->id ?>'); - input.addEventListener("input", ({ target }) => { - const value = String(target.value); - const chars = value.split("").filter((c) => c !== " "); - target.value = chars.reduce((repr, char, i) => { - if (i % 4 === 0) { - char = " " + char; - } - return repr + char; - }); - }); - <?php - return ob_get_clean(); - } -} diff --git a/includes/fields/gf/vat-id/class-addon.php b/includes/fields/gf/vat-id/class-addon.php deleted file mode 100644 index fb297e7..0000000 --- a/includes/fields/gf/vat-id/class-addon.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\GF\Fields\VatID; - -use GFForms; -use GFAddOn; -use GF_Fields; - -GFForms::include_addon_framework(); - -class Addon extends GFAddOn -{ - protected $_version = '1.0'; - protected $_slug = 'wpct-erp-forms-vat-id-field'; - protected $_title = 'Gravity Forms VatID validated text field'; - protected $_short_title = 'VatID field'; - protected $_full_path; - - /** - * @var object $_instance If available, contains an instance of this class. - */ - private static $_instance = null; - - /** - * Returns an instance of this class, and stores it in the $_instance property. - * - * @return object $_instance An instance of this class. - */ - public static function get_instance() - { - if (self::$_instance == null) { - self::$_instance = new self(); - } - - return self::$_instance; - } - - public function __construct() - { - $this->_full_path = __FILE__; - parent::__construct(); - } - - /** - * Include the field early so it is available when entry exports are being performed. - */ - public function pre_init() - { - parent::pre_init(); - if ( - $this->is_gravityforms_supported() && - class_exists('GF_Field') && - class_exists('GF_Fields') - ) { - GF_Fields::register(new GFField()); - } - } -} diff --git a/includes/fields/gf/vat-id/class-field-adapter.php b/includes/fields/gf/vat-id/class-field-adapter.php deleted file mode 100644 index 2a23769..0000000 --- a/includes/fields/gf/vat-id/class-field-adapter.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\GF\Fields\VatID; - -use WPCT_ERP_FORMS\Abstract\Field as BaseField; - -use GFAddOn; - -require_once 'class-addon.php'; -require_once 'class-field.php'; - -class FieldAdapter extends BaseField -{ - public function __construct() - { - add_action('gform_loaded', [$this, 'register']); - } - - public function register() - { - if (!method_exists('GFForms', 'include_addon_framework')) return; - GFAddOn::register(Addon::class); - } - - public function init() - { - } -} diff --git a/includes/fields/gf/vat-id/class-field.php b/includes/fields/gf/vat-id/class-field.php deleted file mode 100644 index b6adb4f..0000000 --- a/includes/fields/gf/vat-id/class-field.php +++ /dev/null @@ -1,237 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\GF\Fields\VatID; - -use Exception; -use GF_Field; - -class GFField extends GF_Field -{ - // https://gist.github.com/afgomez/5691823#file-validate_spanish_id-js-L88 - private static $_dni_regex = '/^(\d{8})([A-Z])$/'; - private static $_cif_regex = '/^([ABCDEFGHJKLMNPQRSUVW])(\d{7})([0-9A-J])$/'; - private static $_nie_regex = '/^[XYZ]\d{7,8}[A-Z]$/'; - - /** - * @var string $type The field type. - */ - public $type = 'vat-id-field'; - - /** - * Return the field title, for use in the form editor. - * - * @return string - */ - public function get_form_editor_field_title() - { - return esc_attr__('VAT ID'); - } - - /** - * Assign the field button to the Advanced Fields group. - * - * @return array - */ - public function get_form_editor_button() - { - return [ - 'group' => 'advanced_fields', - 'text' => $this->get_form_editor_field_title(), - ]; - } - - /** - * The settings which should be available on the field in the form editor. - * - * @return array - */ - public function get_form_editor_field_settings() - { - return [ - 'conditional_logic_field_setting', - 'error_message_setting', - 'label_setting', - 'label_placement_setting', - 'admin_label_setting', - 'size_setting', - 'password_field_setting', - 'rules_setting', - 'visibility_setting', - 'duplicate_setting', - 'default_value_setting', - 'placeholder_setting', - 'description_setting', - 'css_class_setting', - 'prepopulate_field_setting', - ]; - } - - /** - * Enable this field for use with conditional logic. - * - * @return bool - */ - public function is_conditional_logic_supported() - { - return true; - } - - /** - * Define the fields inner markup. - * - * @param array $form The Form Object currently being processed. - * @param string|array $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission. - * @param null|array $entry Null or the Entry Object currently being edited. - * - * @return string - */ - public function get_field_input($form, $value = '', $entry = null) - { - $form_id = absint($form['id']); - $is_entry_detail = $this->is_entry_detail(); - $is_form_editor = $this->is_form_editor(); - - $html_input_type = 'text'; - - if ($this->enablePasswordInput && !$is_entry_detail) { - $html_input_type = 'password'; - } - - $logic_event = ''; // !$is_form_editor && !$is_entry_detail ? $this->get_conditional_logic_event('keyup') : ''; - $id = (int) $this->id; - $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_$id" : 'input_' . $form_id . "_$id"; - - $value = esc_attr($value); - $size = $this->size; - $class_suffix = $is_entry_detail ? '_admin' : ''; - $class = $size . $class_suffix; - - $tabindex = $this->get_tabindex(); - $disabled_text = $is_form_editor ? 'disabled="disabled"' : ''; - $placeholder_attribute = $this->get_field_placeholder_attribute(); - $required_attribute = $this->isRequired ? 'aria-required="true"' : ''; - $invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"'; - - $input = "<input name='input_{$id}' id='{$field_id}' type='{$html_input_type}' value='{$value}' class='{$class}' {$tabindex} {$logic_event} {$placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>"; - - return sprintf("<div class='ginput_container ginput_container_text'>%s</div>", $input); - } - - /** - * Validate Field - */ - public function validate($value, $form) - { - try { - if (strlen($value) < 5) { - throw new Exception(); - } - - $value = strtolower(str_replace(' ', '', $value)); - $value = preg_replace('/\s/', '', strtoupper($value)); - - $valid = false; - $type = $this->id_type($value); - switch ($type) { - case 'dni': - $valid = $this->validate_dni($value); - break; - case 'nie': - $valid = $this->validate_nie($value); - break; - case 'cif': - $valid = $this->validate_cif($value); - break; - } - - if (!$valid) { - throw new Exception(); - } - } catch (Exception $e) { - $this->failed_validation = true; - $this->validation_message = empty($this->errorMessage) ? __('The VAT number you\'ve inserted is not valid.', 'wpct-erp-forms') : $this->errorMessage; - } - } - - private function id_type($value) - { - if (preg_match(GFField::$_dni_regex, $value)) { - return 'dni'; - } elseif (preg_match(GFField::$_nie_regex, $value)) { - return 'nie'; - } elseif (preg_match(GFField::$_cif_regex, $value)) { - return 'cif'; - } - } - - private function validate_dni($value) - { - $dni_letters = 'TRWAGMYFPDXBNJZSQVHLCKE'; - $number = (int) substr($value, 0, 8); - $index = $number % 23; - $letter = substr($dni_letters, $index, 1); - - return $letter == substr($value, 8, 9); - } - - private function validate_nie($value) - { - $nie_prefix = substr($value, 0, 1); - - switch ($nie_prefix) { - case 'X': - $nie_prefix = 0; - break; - case 'Y': - $nie_prefix = 1; - break; - case 'Z': - $nie_prefix = 2; - break; - } - - return $this->validate_dni($nie_prefix . substr($value, 1, 9)); - } - - private function validate_cif($value) - { - preg_match(GFField::$_cif_regex, $value, $matches); - $letter = $matches[1]; - $number = $matches[2]; - $control = $matches[3]; - - $even_sum = 0; - $odd_sum = 0; - $n = null; - - for ($i = 0; $i < strlen($number); $i++) { - $n = (int) $number[$i]; - - if ($i % 2 === 0) { - // Odd positions are multiplied first. - $n *= 2; - // If the multiplication is bigger than 10 we need to adjust - $odd_sum += $n < 10 ? $n : $n - 9; - - // Even positions - // Just sum them - } else { - $even_sum += $n; - } - } - - $control_digit = 10 - (int) substr(strval($even_sum + $odd_sum), -1); - $control_letter = substr('JABCDEFGHI', $control_digit, 1); - - if (preg_match('/[ABEH]/', $letter)) { - // Control must be a digit - return (int) $control === $control_digit; - } elseif (preg_match('/[KPQS]/', $letter)) { - // Control must be a letter - return (string) $control === $control_letter; - } else { - // Can be either - return (int) $control === $control_digit || (string) $control === $control_letter; - } - } -} diff --git a/includes/fields/wpcf7/conditional/class-field.php b/includes/fields/wpcf7/conditional/class-field.php deleted file mode 100644 index 9172f41..0000000 --- a/includes/fields/wpcf7/conditional/class-field.php +++ /dev/null @@ -1,308 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\WPCF7\Fields\Conditional; - -use WPCT_ERP_FORMS\Abstract\Field as BaseField; -use WPCF7_FormTag; - -require 'class-rule.php'; - -class Field extends BaseField -{ - static private $tag_callbacks = [ - [ - 'tags' => [ - 'text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*', - ], - 'function' => 'wpcf7_text_form_tag_handler' - ], - [ - 'tags' => [ - 'textarea', 'textarea*' - ], - 'function' => 'wpcf7_textarea_form_tag_handler' - ], - [ - 'tags' => [ - 'checkbox', 'checkbox*', 'radio' - ], - 'function' => 'wpcf7_checkbox_form_tag_handler' - ], - [ - 'tags' => [ - 'select', 'select*' - ], - 'function' => 'wpcf7_select_form_tag_handler' - ], - [ - 'tags' => [ - 'date', 'date*' - ], - 'function' => 'wpcf7_date_form_tag_handler' - ], - [ - 'tags' => [ - 'number', 'number*', 'range', 'range*' - ], - 'function' => 'wpcf7_number_form_tag_handler' - ], - [ - 'tags' => [ - 'hidden' - ], - 'function' => 'wpcf7_hidden_form_tag_handler' - ], - [ - 'tags' => [ - 'count' - ], - 'function' => 'wpcf7_count_form_tag_handler' - ], - [ - 'tags' => [ - 'iban', 'iban*' - ], - 'function' => 'wpct7_iban_form_tag_handler' - ] - ]; - - protected function __construct() - { - add_action('wpcf7_swv_create_schema', [$this, 'add_rules'], 20, 2); - - add_filter('wpcf7_swv_available_rules', function ($rules) { - $rules['conditional'] = 'WCPT_WPCF7_Conditional_Rule'; - return $rules; - }); - } - - public function init() - { - if (!function_exists('wpcf7_add_form_tag')) return; - - wpcf7_add_form_tag( - ['conditional', 'conditional*'], - [$this, 'handler'], - ['name-attr' => true] - ); - } - - public function handler($tag) - { - $data = array_merge([], (array) $tag); - - $tag_type = $this->get_tag_type($tag); - $tag_basetype = $this->get_tag_basetype($tag); - $standard_options = []; - foreach ($tag->options as $option) { - if (strstr($option, 'type:') || strstr($option, 'conditions:')) { - continue; - } else { - array_push($standard_options, $option); - } - } - - $data['options'] = $standard_options; - $data['type'] = $tag_type; - $data['basetype'] = $tag_basetype; - - $base_tag = new WPCF7_FormTag($data); - $callback = array_values(array_map(function ($tag_callback) { - return $tag_callback['function']; - }, array_filter(static::$tag_callbacks, function ($tag_callback) use ($base_tag) { - return in_array($base_tag->type, $tag_callback['tags'], true); - }))); - if (count($callback) > 0) $callback = $callback[0]; - else return ''; - - $html_atts = [ - 'class' => 'wpcf7-form-control wpcf7-form-control-conditional', - 'data-conditions' => $tag->get_option('conditions')[0], - 'type' => $tag_type, - 'name' => $tag->name - ]; - - $input = call_user_func($callback, $base_tag); - $meta = sprintf('<span hidden aria-hidden="true" class="wpcf7-form-control-conditional" data-name="%s" %s ></span>', $tag->name, wpcf7_format_atts($html_atts)); - return $input . $meta; - } - - private function get_tag_basetype($tag) - { - $type = $this->get_tag_type($tag); - return preg_replace('/\*$/', '', $type); - } - - private function get_tag_type($tag) - { - $tag = (object) $tag; - - $type = null; - foreach ($tag->options as $option) { - if (strstr($option, 'type:')) { - $type = substr($option, 5); - break; - } - } - - return $type; - } - - public function add_rules($schema, $form) - { - $tags = $form->scan_form_tags([ - 'basetype' => [ - 'conditional' - ] - ]); - - $available_rules = wpcf7_swv_available_rules(); - foreach ($tags as $tag) { - $base_type = $this->get_tag_basetype($tag); - - if ($tag->is_required()) { - $schema->add_rule( - wpcf7_swv_create_rule('conditional', [ - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_required'), - 'type' => $base_type, - 'rule' => $available_rules['required'], - 'condition' => 'required', - ]) - ); - } - - if ($base_type === 'email') { - $schema->add_rule( - wpcf7_swv_create_rule('email', [ - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_email'), - 'type' => $base_type, - ]) - ); - } - - if ('url' === $base_type) { - $schema->add_rule( - wpcf7_swv_create_rule('url', [ - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_url'), - 'type' => $base_type, - ]) - ); - } - - if ('tel' === $base_type) { - $schema->add_rule( - wpcf7_swv_create_rule('tel', [ - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_tel'), - 'type' => $base_type, - ]) - ); - } - - if ($minlength = $tag->get_minlength_option()) { - $schema->add_rule( - wpcf7_swv_create_rule('minlength', [ - 'field' => $tag->name, - 'threshold' => absint($minlength), - 'error' => wpcf7_get_message('invalid_too_short'), - 'type' => $base_type, - ]) - ); - } - - if ($maxlength = $tag->get_maxlength_option()) { - $schema->add_rule( - wpcf7_swv_create_rule('maxlength', [ - 'field' => $tag->name, - 'threshold' => absint($maxlength), - 'error' => wpcf7_get_message('invalid_too_long'), - 'type' => $base_type, - ]) - ); - } - - if ('date' === $base_type) { - $schema->add_rule( - wpcf7_swv_create_rule('date', [ - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_date'), - 'type' => $base_type, - ]) - ); - - $min = $tag->get_date_option('min'); - $max = $tag->get_date_option('max'); - - if (false !== $min) { - $schema->add_rule( - wpcf7_swv_create_rule('mindate', [ - 'field' => $tag->name, - 'threshold' => $min, - 'error' => wpcf7_get_message('date_too_early'), - 'type' => $base_type, - ]) - ); - } - - if (false !== $max) { - $schema->add_rule( - wpcf7_swv_create_rule('maxdate', [ - 'field' => $tag->name, - 'threshold' => $max, - 'error' => wpcf7_get_message('date_too_late'), - 'type' => $base_type, - ]) - ); - } - } - - if ('number' === $base_type) { - $schema->add_rule( - wpcf7_swv_create_rule('number', [ - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_number'), - 'type' => $base_type, - ]) - ); - - $min = $tag->get_option('min', 'signed_num', true); - $max = $tag->get_option('max', 'signed_num', true); - - if ('range' === $tag->basetype) { - if (!wpcf7_is_number($min)) { - $min = '0'; - } - - if (!wpcf7_is_number($max)) { - $max = '100'; - } - } - - if (wpcf7_is_number($min)) { - $schema->add_rule( - wpcf7_swv_create_rule('minnumber', [ - 'field' => $tag->name, - 'threshold' => $min, - 'error' => wpcf7_get_message('number_too_small'), - 'type' => $base_type, - ]) - ); - } - - if (wpcf7_is_number($max)) { - $schema->add_rule( - wpcf7_swv_create_rule('maxnumber', [ - 'field' => $tag->name, - 'threshold' => $max, - 'error' => wpcf7_get_message('number_too_large'), - 'type' => $base_type, - ]) - ); - } - } - } - } -} diff --git a/includes/fields/wpcf7/conditional/class-rule.php b/includes/fields/wpcf7/conditional/class-rule.php deleted file mode 100644 index cb65c34..0000000 --- a/includes/fields/wpcf7/conditional/class-rule.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -class WCPT_WPCF7_Conditional_Rule extends Contactable\SWV\Rule -{ - const rule_name = 'conditional'; - - public function validate($context) - { - $field = $this->get_property('field'); - if (!isset($_POST[$field])) return true; - - $rule_class = $this->get_property('rule'); - $props = $this->to_array(); - $rule = new $rule_class($props); - - return $rule->validate($context); - } -} diff --git a/includes/fields/wpcf7/conditionalfile/class-field.php b/includes/fields/wpcf7/conditionalfile/class-field.php deleted file mode 100644 index 423f401..0000000 --- a/includes/fields/wpcf7/conditionalfile/class-field.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\WPCF7\Fields\ConditionalFile; - -use WPCT_ERP_FORMS\Abstract\Field as BaseField; -use WPCF7_FormTag; - -require 'class-rule.php'; - -class Field extends BaseField -{ - static private $tag_callbacks = [ - [ - 'tags' => [ - 'file', 'file*' - ], - 'function' => 'wpcf7_file_form_tag_handler' - ], - ]; - - protected function __construct() - { - add_action('wpcf7_swv_create_schema', [$this, 'add_rules'], 20, 2); - - add_filter('wpcf7_swv_available_rules', function ($rules) { - $rules['conditionalfile'] = 'WCPT_WPCF7_ConditionalFile_Rule'; - return $rules; - }); - } - - public function init() - { - if (!function_exists('wpcf7_add_form_tag')) return; - - wpcf7_add_form_tag( - ['conditionalfile', 'conditionalfile*'], - [$this, 'handler'], - [ - 'name-attr' => true, - 'file-uploading' => true, - ] - ); - } - - public function handler($tag) - { - $data = array_merge([], (array) $tag); - - $tag_type = $tag->is_required() ? 'file*' : 'file'; - $tag_basetype = 'file'; - $standard_options = []; - foreach ($tag->options as $option) { - if (strstr($option, 'conditions:')) { - continue; - } else { - array_push($standard_options, $option); - } - } - - $data['options'] = $standard_options; - $data['type'] = $tag_type; - $data['basetype'] = $tag_basetype; - - $base_tag = new WPCF7_FormTag($data); - - $callback = array_values(array_map(function ($tag_callback) { - return $tag_callback['function']; - }, array_filter(static::$tag_callbacks, function ($tag_callback) use ($base_tag) { - return in_array($base_tag->type, $tag_callback['tags'], true); - }))); - - if (count($callback) > 0) $callback = $callback[0]; - else return ''; - - $html_atts = [ - 'class' => 'wpcf7-form-control wpcf7-form-control-conditional', - 'data-conditions' => $tag->get_option('conditions')[0], - 'type' => $tag_type, - 'name' => $tag->name - ]; - - $input = call_user_func($callback, $base_tag); - $meta = sprintf('<span hidden aria-hidden="true" class="wpcf7-form-control-conditional" data-name="%s" %s ></span>', $tag->name, wpcf7_format_atts($html_atts)); - return $input . $meta; - } - - public function add_rules($schema, $form) - { - $tags = $form->scan_form_tags([ - 'basetype' => [ - 'conditionalfile' - ] - ]); - - $available_rules = wpcf7_swv_available_rules(); - foreach ($tags as $tag) { - if ($tag->is_required()) { - $schema->add_rule( - wpcf7_swv_create_rule('conditionalfile', array( - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_required'), - 'rule' => $available_rules['requiredfile'], - 'condition' => 'requiredfile' - )) - ); - } - - $schema->add_rule( - wpcf7_swv_create_rule('file', [ - 'field' => $tag->name, - 'accept' => explode(',', wpcf7_acceptable_filetypes( - $tag->get_option('filetypes'), - 'attr' - )), - 'error' => wpcf7_get_message('upload_file_type_invalid'), - ]) - ); - - $schema->add_rule( - wpcf7_swv_create_rule('maxfilesize', [ - 'field' => $tag->name, - 'threshold' => $tag->get_limit_option(), - 'error' => wpcf7_get_message('upload_file_too_large'), - ]) - ); - } - } -} diff --git a/includes/fields/wpcf7/conditionalfile/class-rule.php b/includes/fields/wpcf7/conditionalfile/class-rule.php deleted file mode 100644 index 3d41a67..0000000 --- a/includes/fields/wpcf7/conditionalfile/class-rule.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -class WCPT_WPCF7_ConditionalFile_Rule extends Contactable\SWV\Rule -{ - const rule_name = 'conditionalfile'; - - public function validate($context) - { - $field = $this->get_property('field'); - if (!isset($_FILES[$field])) return true; - - $rule_class = $this->get_property('rule'); - $props = $this->to_array(); - $rule = new $rule_class($props); - - return $rule->validate($context); - } -} diff --git a/includes/fields/wpcf7/files/class-field.php b/includes/fields/wpcf7/files/class-field.php deleted file mode 100644 index 513ebfe..0000000 --- a/includes/fields/wpcf7/files/class-field.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\WPCF7\Fields\Files; - -use WPCT_ERP_FORMS\Abstract\Field as BaseField; - -require_once 'class-rule.php'; - -class Field extends BaseField -{ - protected function __construct() - { - add_action('wpcf7_swv_create_schema', [$this, 'add_rules'], 20, 2); - - add_filter('wpcf7_swv_available_rules', function ($rules) { - $rules['files'] = 'WPCT_WPCF7_Files_Rule'; - return $rules; - }); - - add_filter('wpcf7_display_message', function ($msg, $status) { - if ($msg) { - return $msg; - } - - if ($status === 'upload_files_max' || $status === 'upload_files_min') { - return __($status, 'wpct-erp-forms'); - } - }, 40, 2); - } - - public function init() - { - wpcf7_add_form_tag( - ['files', 'files*'], - [$this, 'handler'], - [ - 'name-attr' => true, - 'file-uploading' => true, - ] - ); - } - - public function handler($tag) - { - if (!$tag->name) { - return ''; - } - - $validation_error = wpcf7_get_validation_error($tag->name); - - $class = wpcf7_form_controls_class($tag->type); - if ($validation_error) { - $class .= ' wpcf7-not-valid'; - } - - $atts = [ - 'class' => $tag->get_class_option($class), - 'id' => $tag->get_id_option(), - 'accept' => wpcf7_acceptable_filetypes( - $tag->get_option('filetypes'), - 'attr' - ), - 'capture' => $tag->get_option('capture', '(user|environment)', true), - 'tabindex' => $tag->get_option('tabindex', 'signed_int', true), - 'name' => $tag->name, - 'multiple' => 'multiple', - 'type' => 'file', - ]; - - if ($tag->is_required()) { - $atts['aria-required'] = 'true'; - } - - if ($validation_error) { - $atts['aria-invalid'] = 'true'; - $atts['aria-describedby'] = wpcf7_get_validation_error_reference( - $tag->name - ); - } else { - $atts['aria-invalid'] = 'false'; - } - - $html = sprintf( - '<span class="wpcf7-form-control-wrap" data-name="%1$s"><input %2$s />%3$s</span>', - esc_attr($tag->name), - wpcf7_format_atts($atts), - $validation_error - ); - - return $html; - } - - public function add_rules($schema, $form) - { - $tags = $form->scan_form_tags([ - 'basetype' => ['files'], - ]); - - foreach ($tags as $tag) { - if ($tag->is_required()) { - $schema->add_rule( - wpcf7_swv_create_rule('requiredfile', [ - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_required'), - ]) - ); - } - - $schema->add_rule( - wpcf7_swv_create_rule('files', [ - 'field' => $tag->name, - 'accept' => explode(',', wpcf7_acceptable_filetypes( - $tag->get_option('filetypes'), - 'attr' - )), - 'error' => wpcf7_get_message('upload_file_type_invalid'), - 'minfiles' => (int) $tag->get_option('minfiles', 'int', true), - 'maxfiles' => (int) $tag->get_option('maxfiles', 'int', true), - ]) - ); - - $schema->add_rule( - wpcf7_swv_create_rule('maxfilesize', [ - 'field' => $tag->name, - 'threshold' => $tag->get_limit_option(), - 'error' => wpcf7_get_message('upload_file_too_large'), - ]) - ); - } - } -} diff --git a/includes/fields/wpcf7/files/class-rule.php b/includes/fields/wpcf7/files/class-rule.php deleted file mode 100644 index e58d97f..0000000 --- a/includes/fields/wpcf7/files/class-rule.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -class WPCT_WPCF7_Files_Rule extends Contactable\SWV\Rule -{ - public const rule_name = 'files'; - - public function validate($context) - { - $field = $this->get_property('field'); - $input = $_FILES[$field]['name'] ?? ''; - $input = wpcf7_array_flatten($input); - $input = wpcf7_exclude_blank($input); - - $acceptable_filetypes = []; - foreach ((array) $this->get_property('accept') as $accept) { - if (preg_match('/^\.[a-z0-9]+$/i', $accept)) { - $acceptable_filetypes[] = strtolower($accept); - } else { - foreach (wpcf7_convert_mime_to_ext($accept) as $ext) { - $acceptable_filetypes[] = sprintf( - '.%s', - strtolower(trim($ext, ' .')) - ); - } - } - } - - $acceptable_filetypes = array_unique($acceptable_filetypes); - foreach ($input as $i) { - $last_period_pos = strrpos($i, '.'); - - if (false === $last_period_pos) { // no period - return $this->create_error(); - } - - $suffix = strtolower(substr($i, $last_period_pos)); - if (! in_array($suffix, $acceptable_filetypes, true)) { - return $this->create_error(); - } - } - - $max = $this->get_property('maxfiles'); - $min = $this->get_property('minfiles'); - - if (sizeof($input) > $max) { - $this->properties['error'] = 'upload_files_max'; - return $this->create_error(); - } elseif (sizeof($input) < $min) { - $this->properties['error'] = 'upload_files_min'; - return $this->create_error(); - } - - return true; - } -} diff --git a/includes/fields/wpcf7/iban/class-field.php b/includes/fields/wpcf7/iban/class-field.php deleted file mode 100644 index 6be9c5c..0000000 --- a/includes/fields/wpcf7/iban/class-field.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php - -namespace WPCT_ERP_FORMS\WPCF7\Fields\Iban; - -use WPCT_ERP_FORMS\Abstract\Field as BaseField; - -require_once 'class-rule.php'; - -class Field extends BaseField -{ - protected function __construct() - { - add_action('wpcf7_swv_create_schema', [$this, 'add_rules'], 20, 2); - - add_filter('wpcf7_swv_available_rules', function ($rules) { - $rules['iban'] = 'WPCT_WPCF7_Iban_Rule'; - return $rules; - }); - - add_filter('wpcf7_display_message', function ($msg, $status) { - if ($msg) { - return $msg; - } - - if ($status === 'invalid_iban') { - return __($status, 'wpct-erp-forms'); - } - }, 40, 2); - } - - public function init() - { - wpcf7_add_form_tag( - ['iban', 'iban*'], - [$this, 'handler'], - ['name-attr' => true] - ); - } - - public function handler($tag) - { - if (!$tag->name) { - return ''; - } - - $validation_error = wpcf7_get_validation_error($tag->name); - - $class = wpcf7_form_controls_class($tag->type); - if ($validation_error) { - $class .= ' wpcf7-not-valid'; - } - - $atts = [ - 'class' => $tag->get_class_option($class), - 'id' => $tag->get_id_option(), - 'tabindex' => $tag->get_option('tabindex', 'signed_int', true), - 'name' => $tag->name, - 'type' => 'text', - ]; - - if ($tag->is_required()) { - $atts['aria-required'] = 'true'; - } - - if ($validation_error) { - $atts['aria-invalid'] = 'true'; - $atts['aria-describedby'] = wpcf7_get_validation_error_reference( - $tag->name - ); - } - - $html = sprintf( - '<span class="wpcf7-form-control-wrap" data-name="%1$s"><input %2$s />%3$s</span>', - esc_attr($tag->name), - wpcf7_format_atts($atts), - $validation_error, - ); - - return $html . $this->add_script($tag); - } - - public function add_rules($schema, $form) - { - $tags = $form->scan_form_tags([ - 'basetype' => 'iban' - ]); - - foreach ($tags as $tag) { - $schema->add_rule( - wpcf7_swv_create_rule('iban', [ - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_iban') - ]) - ); - - if ($tag->is_required()) { - $schema->add_rule( - wpcf7_swv_create_rule('required', [ - 'field' => $tag->name, - 'error' => wpcf7_get_message('invalid_required') - ]) - ); - } - } - } - - private function add_script($tag) - { - ob_start(); - ?> - <script> - const input = document.currentScript.parentElement.querySelector('input[name="<?= $tag->name ?>"]'); - input.addEventListener("input", ({ target }) => { - const value = String(target.value); - const chars = value.split("").filter((c) => c !== " "); - target.value = chars.reduce((repr, char, i) => { - if (i % 4 === 0) { - char = " " + char; - } - return repr + char; - }); - }); - </script> - <?php - return ob_get_clean(); - - } -} diff --git a/includes/fields/wpcf7/iban/class-rule.php b/includes/fields/wpcf7/iban/class-rule.php deleted file mode 100644 index 5d8eafa..0000000 --- a/includes/fields/wpcf7/iban/class-rule.php +++ /dev/null @@ -1,158 +0,0 @@ -<?php - -class WPCT_WPCF7_Iban_Rule extends Contactable\SWV\Rule -{ - public const rule_name = 'iban'; - - /** - * @var array @type Country codes - */ - private $_countries = [ - 'al' => 28, - 'ad' => 24, - 'at' => 20, - 'az' => 28, - 'bh' => 22, - 'be' => 16, - 'ba' => 20, - 'br' => 29, - 'bg' => 22, - 'cr' => 21, - 'hr' => 21, - 'cy' => 28, - 'cz' => 24, - 'dk' => 18, - 'do' => 28, - 'ee' => 20, - 'fo' => 18, - 'fi' => 18, - 'fr' => 27, - 'ge' => 22, - 'de' => 22, - 'gi' => 23, - 'gr' => 27, - 'gl' => 18, - 'gt' => 28, - 'hu' => 28, - 'is' => 26, - 'ie' => 22, - 'il' => 23, - 'it' => 27, - 'jo' => 30, - 'kz' => 20, - 'kw' => 30, - 'lv' => 21, - 'lb' => 28, - 'li' => 21, - 'lt' => 20, - 'lu' => 20, - 'mk' => 19, - 'mt' => 31, - 'mr' => 27, - 'mu' => 30, - 'mc' => 27, - 'md' => 24, - 'me' => 22, - 'nl' => 18, - 'no' => 15, - 'pk' => 24, - 'ps' => 29, - 'pl' => 28, - 'pt' => 25, - 'qa' => 29, - 'ro' => 24, - 'sm' => 27, - 'sa' => 24, - 'rs' => 22, - 'sk' => 24, - 'si' => 19, - 'es' => 24, - 'se' => 24, - 'ch' => 21, - 'tn' => 24, - 'tr' => 26, - 'ae' => 23, - 'gb' => 22, - 'vg' => 24, - ]; - - /** - * @var array $type Char codes - */ - private $_chars = [ - 'a' => 10, - 'b' => 11, - 'c' => 12, - 'd' => 13, - 'e' => 14, - 'f' => 15, - 'g' => 16, - 'h' => 17, - 'i' => 18, - 'j' => 19, - 'k' => 20, - 'l' => 21, - 'm' => 22, - 'n' => 23, - 'o' => 24, - 'p' => 25, - 'q' => 26, - 'r' => 27, - 's' => 28, - 't' => 29, - 'u' => 30, - 'v' => 31, - 'w' => 32, - 'x' => 33, - 'y' => 34, - 'z' => 35 - ]; - - - public function validate($context) - { - $input = $this->get_default_input(); - $input = wpcf7_array_flatten($input); - $input = wpcf7_exclude_blank($input); - - foreach ($input as $value) { - if (strlen($value) === 0) { - return $this->create_error(); - } - - if (strlen($value) < 5) { - return $this->create_error(); - } - - $value = strtolower(str_replace(' ', '', $value)); - - $country_exists = array_key_exists(substr($value, 0, 2), $this->_countries); - $country_conform = strlen($value) == $this->_countries[substr($value, 0, 2)]; - - if (!($country_exists && $country_conform)) { - return $this->create_error(); - } - - $moved_char = substr($value, 4) . substr($value, 0, 4); - $move_char_array = str_split($moved_char); - $new_string = ''; - - foreach ($move_char_array as $key => $val) { - if (!is_numeric($move_char_array[$key])) { - if (!isset($this->_chars[$val])) { - return $this->create_error(); - } - $move_char_array[$key] = $this->_chars[$val]; - } - - $new_string .= $move_char_array[$key]; - } - - if (bcmod($new_string, '97') != 1) { - return $this->create_error(); - } - } - - return true; - } -} diff --git a/includes/integrations/gf/class-integration.php b/includes/integrations/gf/class-integration.php index 1abdfb8..a0c3ae4 100644 --- a/includes/integrations/gf/class-integration.php +++ b/includes/integrations/gf/class-integration.php @@ -5,23 +5,12 @@ namespace WPCT_ERP_FORMS\GF; use Exception; use TypeError; use WPCT_ERP_FORMS\Abstract\Integration as BaseIntegration; -use WPCT_ERP_FORMS\GF\Fields\Iban\FieldAdapter as IbanField; -use WPCT_ERP_FORMS\GF\Fields\VatID\FieldAdapter as VatIDField; require_once 'attachments.php'; require_once 'fields-population.php'; -// Fields -require_once dirname(__FILE__, 3) . '/fields/gf/iban/class-field-adapter.php'; -require_once dirname(__FILE__, 3) . '/fields/gf/vat-id/class-field-adapter.php'; - class Integration extends BaseIntegration { - public static $fields = [ - IbanField::class, - VatIDField::class, - ]; - protected function __construct() { add_action('gform_after_submission', function ($entry, $form) { diff --git a/package-lock.json b/package-lock.json index ded9c07..3225d08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,423 +8,17 @@ "name": "wpct-crm-forms", "version": "1.0.0", "devDependencies": { - "concurrently": "^8.2.2", - "esbuild": "^0.20.0", "grunt": "~0.4.5", "grunt-wp-i18n": "~0.5.0", "grunt-wp-readme-to-markdown": "~1.0.0" } }, - "node_modules/@babel/runtime": { - "version": "7.23.9", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.9.tgz", - "integrity": "sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw==", - "dev": true, - "dependencies": { - "regenerator-runtime": "^0.14.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.0.tgz", - "integrity": "sha512-fGFDEctNh0CcSwsiRPxiaqX0P5rq+AqE0SRhYGZ4PX46Lg1FNR6oCxJghf8YgY0WQEgQuh3lErUFE4KxLeRmmw==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.0.tgz", - "integrity": "sha512-3bMAfInvByLHfJwYPJRlpTeaQA75n8C/QKpEaiS4HrFWFiJlNI0vzq/zCjBrhAYcPyVPG7Eo9dMrcQXuqmNk5g==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.0.tgz", - "integrity": "sha512-aVpnM4lURNkp0D3qPoAzSG92VXStYmoVPOgXveAUoQBWRSuQzt51yvSju29J6AHPmwY1BjH49uR29oyfH1ra8Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.0.tgz", - "integrity": "sha512-uK7wAnlRvjkCPzh8jJ+QejFyrP8ObKuR5cBIsQZ+qbMunwR8sbd8krmMbxTLSrDhiPZaJYKQAU5Y3iMDcZPhyQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.0.tgz", - "integrity": "sha512-AjEcivGAlPs3UAcJedMa9qYg9eSfU6FnGHJjT8s346HSKkrcWlYezGE8VaO2xKfvvlZkgAhyvl06OJOxiMgOYQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.0.tgz", - "integrity": "sha512-bsgTPoyYDnPv8ER0HqnJggXK6RyFy4PH4rtsId0V7Efa90u2+EifxytE9pZnsDgExgkARy24WUQGv9irVbTvIw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.0.tgz", - "integrity": "sha512-kQ7jYdlKS335mpGbMW5tEe3IrQFIok9r84EM3PXB8qBFJPSc6dpWfrtsC/y1pyrz82xfUIn5ZrnSHQQsd6jebQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.0.tgz", - "integrity": "sha512-uG8B0WSepMRsBNVXAQcHf9+Ko/Tr+XqmK7Ptel9HVmnykupXdS4J7ovSQUIi0tQGIndhbqWLaIL/qO/cWhXKyQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.0.tgz", - "integrity": "sha512-2ezuhdiZw8vuHf1HKSf4TIk80naTbP9At7sOqZmdVwvvMyuoDiZB49YZKLsLOfKIr77+I40dWpHVeY5JHpIEIg==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.0.tgz", - "integrity": "sha512-uTtyYAP5veqi2z9b6Gr0NUoNv9F/rOzI8tOD5jKcCvRUn7T60Bb+42NDBCWNhMjkQzI0qqwXkQGo1SY41G52nw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.0.tgz", - "integrity": "sha512-c88wwtfs8tTffPaoJ+SQn3y+lKtgTzyjkD8NgsyCtCmtoIC8RDL7PrJU05an/e9VuAke6eJqGkoMhJK1RY6z4w==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.0.tgz", - "integrity": "sha512-lR2rr/128/6svngnVta6JN4gxSXle/yZEZL3o4XZ6esOqhyR4wsKyfu6qXAL04S4S5CgGfG+GYZnjFd4YiG3Aw==", - "cpu": [ - "loong64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.0.tgz", - "integrity": "sha512-9Sycc+1uUsDnJCelDf6ZNqgZQoK1mJvFtqf2MUz4ujTxGhvCWw+4chYfDLPepMEvVL9PDwn6HrXad5yOrNzIsQ==", - "cpu": [ - "mips64el" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.0.tgz", - "integrity": "sha512-CoWSaaAXOZd+CjbUTdXIJE/t7Oz+4g90A3VBCHLbfuc5yUQU/nFDLOzQsN0cdxgXd97lYW/psIIBdjzQIwTBGw==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.0.tgz", - "integrity": "sha512-mlb1hg/eYRJUpv8h/x+4ShgoNLL8wgZ64SUr26KwglTYnwAWjkhR2GpoKftDbPOCnodA9t4Y/b68H4J9XmmPzA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.0.tgz", - "integrity": "sha512-fgf9ubb53xSnOBqyvWEY6ukBNRl1mVX1srPNu06B6mNsNK20JfH6xV6jECzrQ69/VMiTLvHMicQR/PgTOgqJUQ==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.0.tgz", - "integrity": "sha512-H9Eu6MGse++204XZcYsse1yFHmRXEWgadk2N58O/xd50P9EvFMLJTQLg+lB4E1cF2xhLZU5luSWtGTb0l9UeSg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.0.tgz", - "integrity": "sha512-lCT675rTN1v8Fo+RGrE5KjSnfY0x9Og4RN7t7lVrN3vMSjy34/+3na0q7RIfWDAj0e0rCh0OL+P88lu3Rt21MQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.0.tgz", - "integrity": "sha512-HKoUGXz/TOVXKQ+67NhxyHv+aDSZf44QpWLa3I1lLvAwGq8x1k0T+e2HHSRvxWhfJrFxaaqre1+YyzQ99KixoA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.0.tgz", - "integrity": "sha512-GDwAqgHQm1mVoPppGsoq4WJwT3vhnz/2N62CzhvApFD1eJyTroob30FPpOZabN+FgCjhG+AgcZyOPIkR8dfD7g==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.0.tgz", - "integrity": "sha512-0vYsP8aC4TvMlOQYozoksiaxjlvUcQrac+muDqj1Fxy6jh9l9CZJzj7zmh8JGfiV49cYLTorFLxg7593pGldwQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.0.tgz", - "integrity": "sha512-p98u4rIgfh4gdpV00IqknBD5pC84LCub+4a3MO+zjqvU5MVXOc3hqR2UgT2jI2nh3h8s9EQxmOsVI3tyzv1iFg==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.0.tgz", - "integrity": "sha512-NgJnesu1RtWihtTtXGFMU5YSE6JyyHPMxCwBZK7a6/8d31GuSo9l0Ss7w1Jw5QnKUawG6UEehs883kcXf5fYwg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/argparse": { "version": "0.1.16", "resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz", @@ -459,48 +53,6 @@ "node": "*" } }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chalk/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/coffee-script": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.3.tgz", @@ -515,24 +67,6 @@ "node": ">=0.4.0" } }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, "node_modules/colors": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", @@ -542,55 +76,6 @@ "node": ">=0.1.90" } }, - "node_modules/concurrently": { - "version": "8.2.2", - "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.2.2.tgz", - "integrity": "sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==", - "dev": true, - "dependencies": { - "chalk": "^4.1.2", - "date-fns": "^2.30.0", - "lodash": "^4.17.21", - "rxjs": "^7.8.1", - "shell-quote": "^1.8.1", - "spawn-command": "0.0.2", - "supports-color": "^8.1.1", - "tree-kill": "^1.2.2", - "yargs": "^17.7.2" - }, - "bin": { - "conc": "dist/bin/concurrently.js", - "concurrently": "dist/bin/concurrently.js" - }, - "engines": { - "node": "^14.13.0 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" - } - }, - "node_modules/concurrently/node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "node_modules/date-fns": { - "version": "2.30.0", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", - "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", - "dev": true, - "dependencies": { - "@babel/runtime": "^7.21.0" - }, - "engines": { - "node": ">=0.11" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/date-fns" - } - }, "node_modules/dateformat": { "version": "1.0.2-1.2.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz", @@ -600,12 +85,6 @@ "node": "*" } }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, "node_modules/encoding": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", @@ -627,53 +106,6 @@ "node": ">=0.10.0" } }, - "node_modules/esbuild": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.0.tgz", - "integrity": "sha512-6iwE3Y2RVYCME1jLpBqq7LQWK3MW6vjV2bZy6gt/WrqkY+WE74Spyc0ThAOYpMtITvnjX09CrC6ym7A/m9mebA==", - "dev": true, - "hasInstallScript": true, - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=12" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.20.0", - "@esbuild/android-arm": "0.20.0", - "@esbuild/android-arm64": "0.20.0", - "@esbuild/android-x64": "0.20.0", - "@esbuild/darwin-arm64": "0.20.0", - "@esbuild/darwin-x64": "0.20.0", - "@esbuild/freebsd-arm64": "0.20.0", - "@esbuild/freebsd-x64": "0.20.0", - "@esbuild/linux-arm": "0.20.0", - "@esbuild/linux-arm64": "0.20.0", - "@esbuild/linux-ia32": "0.20.0", - "@esbuild/linux-loong64": "0.20.0", - "@esbuild/linux-mips64el": "0.20.0", - "@esbuild/linux-ppc64": "0.20.0", - "@esbuild/linux-riscv64": "0.20.0", - "@esbuild/linux-s390x": "0.20.0", - "@esbuild/linux-x64": "0.20.0", - "@esbuild/netbsd-x64": "0.20.0", - "@esbuild/openbsd-x64": "0.20.0", - "@esbuild/sunos-x64": "0.20.0", - "@esbuild/win32-arm64": "0.20.0", - "@esbuild/win32-ia32": "0.20.0", - "@esbuild/win32-x64": "0.20.0" - } - }, - "node_modules/escalade": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", - "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/esprima": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", @@ -758,15 +190,6 @@ "node": "*" } }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, "node_modules/getobject": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz", @@ -972,15 +395,6 @@ "grunt": "~0.4.1" } }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/hooker": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", @@ -1005,15 +419,6 @@ "integrity": "sha512-Al67oatbRSo3RV5hRqIoln6Y5yMVbJSIn4jEJNL7VCImzq/kLr7vvb6sFRJXqr8rpHc/2kJOM+y0sPKN47VdzA==", "dev": true }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/js-yaml": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-2.0.5.tgz", @@ -1075,21 +480,6 @@ "node": "*" } }, - "node_modules/regenerator-runtime": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", - "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", - "dev": true - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/rimraf": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", @@ -1099,98 +489,18 @@ "rimraf": "bin.js" } }, - "node_modules/rxjs": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", - "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", - "dev": true, - "dependencies": { - "tslib": "^2.1.0" - } - }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "node_modules/shell-quote": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", - "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/sigmund": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", "integrity": "sha512-fCvEXfh6NWpm+YSuY2bpXb/VIihqWA6hLsgboC+0nl71Q7N7o2eaCW8mJa/NLvQhs6jpd3VZV4UiUQlV6+lc8g==", "dev": true }, - "node_modules/spawn-command": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", - "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==", - "dev": true - }, - "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, - "node_modules/tree-kill": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", - "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", - "dev": true, - "bin": { - "tree-kill": "cli.js" - } - }, - "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", - "dev": true - }, "node_modules/underscore": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", @@ -1214,253 +524,15 @@ "bin": { "which": "bin/which" } - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dev": true, - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "dev": true, - "engines": { - "node": ">=12" - } } }, "dependencies": { - "@babel/runtime": { - "version": "7.23.9", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.9.tgz", - "integrity": "sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw==", - "dev": true, - "requires": { - "regenerator-runtime": "^0.14.0" - } - }, - "@esbuild/aix-ppc64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.0.tgz", - "integrity": "sha512-fGFDEctNh0CcSwsiRPxiaqX0P5rq+AqE0SRhYGZ4PX46Lg1FNR6oCxJghf8YgY0WQEgQuh3lErUFE4KxLeRmmw==", - "dev": true, - "optional": true - }, - "@esbuild/android-arm": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.0.tgz", - "integrity": "sha512-3bMAfInvByLHfJwYPJRlpTeaQA75n8C/QKpEaiS4HrFWFiJlNI0vzq/zCjBrhAYcPyVPG7Eo9dMrcQXuqmNk5g==", - "dev": true, - "optional": true - }, - "@esbuild/android-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.0.tgz", - "integrity": "sha512-aVpnM4lURNkp0D3qPoAzSG92VXStYmoVPOgXveAUoQBWRSuQzt51yvSju29J6AHPmwY1BjH49uR29oyfH1ra8Q==", - "dev": true, - "optional": true - }, - "@esbuild/android-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.0.tgz", - "integrity": "sha512-uK7wAnlRvjkCPzh8jJ+QejFyrP8ObKuR5cBIsQZ+qbMunwR8sbd8krmMbxTLSrDhiPZaJYKQAU5Y3iMDcZPhyQ==", - "dev": true, - "optional": true - }, - "@esbuild/darwin-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.0.tgz", - "integrity": "sha512-AjEcivGAlPs3UAcJedMa9qYg9eSfU6FnGHJjT8s346HSKkrcWlYezGE8VaO2xKfvvlZkgAhyvl06OJOxiMgOYQ==", - "dev": true, - "optional": true - }, - "@esbuild/darwin-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.0.tgz", - "integrity": "sha512-bsgTPoyYDnPv8ER0HqnJggXK6RyFy4PH4rtsId0V7Efa90u2+EifxytE9pZnsDgExgkARy24WUQGv9irVbTvIw==", - "dev": true, - "optional": true - }, - "@esbuild/freebsd-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.0.tgz", - "integrity": "sha512-kQ7jYdlKS335mpGbMW5tEe3IrQFIok9r84EM3PXB8qBFJPSc6dpWfrtsC/y1pyrz82xfUIn5ZrnSHQQsd6jebQ==", - "dev": true, - "optional": true - }, - "@esbuild/freebsd-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.0.tgz", - "integrity": "sha512-uG8B0WSepMRsBNVXAQcHf9+Ko/Tr+XqmK7Ptel9HVmnykupXdS4J7ovSQUIi0tQGIndhbqWLaIL/qO/cWhXKyQ==", - "dev": true, - "optional": true - }, - "@esbuild/linux-arm": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.0.tgz", - "integrity": "sha512-2ezuhdiZw8vuHf1HKSf4TIk80naTbP9At7sOqZmdVwvvMyuoDiZB49YZKLsLOfKIr77+I40dWpHVeY5JHpIEIg==", - "dev": true, - "optional": true - }, - "@esbuild/linux-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.0.tgz", - "integrity": "sha512-uTtyYAP5veqi2z9b6Gr0NUoNv9F/rOzI8tOD5jKcCvRUn7T60Bb+42NDBCWNhMjkQzI0qqwXkQGo1SY41G52nw==", - "dev": true, - "optional": true - }, - "@esbuild/linux-ia32": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.0.tgz", - "integrity": "sha512-c88wwtfs8tTffPaoJ+SQn3y+lKtgTzyjkD8NgsyCtCmtoIC8RDL7PrJU05an/e9VuAke6eJqGkoMhJK1RY6z4w==", - "dev": true, - "optional": true - }, - "@esbuild/linux-loong64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.0.tgz", - "integrity": "sha512-lR2rr/128/6svngnVta6JN4gxSXle/yZEZL3o4XZ6esOqhyR4wsKyfu6qXAL04S4S5CgGfG+GYZnjFd4YiG3Aw==", - "dev": true, - "optional": true - }, - "@esbuild/linux-mips64el": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.0.tgz", - "integrity": "sha512-9Sycc+1uUsDnJCelDf6ZNqgZQoK1mJvFtqf2MUz4ujTxGhvCWw+4chYfDLPepMEvVL9PDwn6HrXad5yOrNzIsQ==", - "dev": true, - "optional": true - }, - "@esbuild/linux-ppc64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.0.tgz", - "integrity": "sha512-CoWSaaAXOZd+CjbUTdXIJE/t7Oz+4g90A3VBCHLbfuc5yUQU/nFDLOzQsN0cdxgXd97lYW/psIIBdjzQIwTBGw==", - "dev": true, - "optional": true - }, - "@esbuild/linux-riscv64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.0.tgz", - "integrity": "sha512-mlb1hg/eYRJUpv8h/x+4ShgoNLL8wgZ64SUr26KwglTYnwAWjkhR2GpoKftDbPOCnodA9t4Y/b68H4J9XmmPzA==", - "dev": true, - "optional": true - }, - "@esbuild/linux-s390x": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.0.tgz", - "integrity": "sha512-fgf9ubb53xSnOBqyvWEY6ukBNRl1mVX1srPNu06B6mNsNK20JfH6xV6jECzrQ69/VMiTLvHMicQR/PgTOgqJUQ==", - "dev": true, - "optional": true - }, - "@esbuild/linux-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.0.tgz", - "integrity": "sha512-H9Eu6MGse++204XZcYsse1yFHmRXEWgadk2N58O/xd50P9EvFMLJTQLg+lB4E1cF2xhLZU5luSWtGTb0l9UeSg==", - "dev": true, - "optional": true - }, - "@esbuild/netbsd-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.0.tgz", - "integrity": "sha512-lCT675rTN1v8Fo+RGrE5KjSnfY0x9Og4RN7t7lVrN3vMSjy34/+3na0q7RIfWDAj0e0rCh0OL+P88lu3Rt21MQ==", - "dev": true, - "optional": true - }, - "@esbuild/openbsd-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.0.tgz", - "integrity": "sha512-HKoUGXz/TOVXKQ+67NhxyHv+aDSZf44QpWLa3I1lLvAwGq8x1k0T+e2HHSRvxWhfJrFxaaqre1+YyzQ99KixoA==", - "dev": true, - "optional": true - }, - "@esbuild/sunos-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.0.tgz", - "integrity": "sha512-GDwAqgHQm1mVoPppGsoq4WJwT3vhnz/2N62CzhvApFD1eJyTroob30FPpOZabN+FgCjhG+AgcZyOPIkR8dfD7g==", - "dev": true, - "optional": true - }, - "@esbuild/win32-arm64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.0.tgz", - "integrity": "sha512-0vYsP8aC4TvMlOQYozoksiaxjlvUcQrac+muDqj1Fxy6jh9l9CZJzj7zmh8JGfiV49cYLTorFLxg7593pGldwQ==", - "dev": true, - "optional": true - }, - "@esbuild/win32-ia32": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.0.tgz", - "integrity": "sha512-p98u4rIgfh4gdpV00IqknBD5pC84LCub+4a3MO+zjqvU5MVXOc3hqR2UgT2jI2nh3h8s9EQxmOsVI3tyzv1iFg==", - "dev": true, - "optional": true - }, - "@esbuild/win32-x64": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.0.tgz", - "integrity": "sha512-NgJnesu1RtWihtTtXGFMU5YSE6JyyHPMxCwBZK7a6/8d31GuSo9l0Ss7w1Jw5QnKUawG6UEehs883kcXf5fYwg==", - "dev": true, - "optional": true - }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, "argparse": { "version": "0.1.16", "resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz", @@ -1491,111 +563,24 @@ "integrity": "sha512-2tEzliJmf5fHNafNwQLJXUasGzQCVctvsNkXmnlELHwypU0p08/rHohYvkqKIjyXpx+0rkrYv6QbhJ+UF4QkBg==", "dev": true }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "dependencies": { - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - } - }, "coffee-script": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.3.tgz", "integrity": "sha512-QjQ1T4BqyHv19k6XSfdhy/QLlIOhywz0ekBUCa9h71zYMJlfDTGan/Z1JXzYkZ6v8R+GhvL/p4FZPbPW8WNXlg==", "dev": true }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, "colors": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", "integrity": "sha512-OsSVtHK8Ir8r3+Fxw/b4jS1ZLPXkV6ZxDRJQzeD7qo0SqMXWrHDM71DgYzPMHY8SFJ0Ao+nNU2p1MmwdzKqPrw==", "dev": true }, - "concurrently": { - "version": "8.2.2", - "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.2.2.tgz", - "integrity": "sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==", - "dev": true, - "requires": { - "chalk": "^4.1.2", - "date-fns": "^2.30.0", - "lodash": "^4.17.21", - "rxjs": "^7.8.1", - "shell-quote": "^1.8.1", - "spawn-command": "0.0.2", - "supports-color": "^8.1.1", - "tree-kill": "^1.2.2", - "yargs": "^17.7.2" - }, - "dependencies": { - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - } - } - }, - "date-fns": { - "version": "2.30.0", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", - "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", - "dev": true, - "requires": { - "@babel/runtime": "^7.21.0" - } - }, "dateformat": { "version": "1.0.2-1.2.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz", "integrity": "sha512-AXvW8g7tO4ilk5HgOWeDmPi/ZPaCnMJ+9Cg1I3p19w6mcvAAXBuuGEXAxybC+Djj1PSZUiHUcyoYu7WneCX8gQ==", "dev": true }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, "encoding": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", @@ -1616,43 +601,6 @@ } } }, - "esbuild": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.0.tgz", - "integrity": "sha512-6iwE3Y2RVYCME1jLpBqq7LQWK3MW6vjV2bZy6gt/WrqkY+WE74Spyc0ThAOYpMtITvnjX09CrC6ym7A/m9mebA==", - "dev": true, - "requires": { - "@esbuild/aix-ppc64": "0.20.0", - "@esbuild/android-arm": "0.20.0", - "@esbuild/android-arm64": "0.20.0", - "@esbuild/android-x64": "0.20.0", - "@esbuild/darwin-arm64": "0.20.0", - "@esbuild/darwin-x64": "0.20.0", - "@esbuild/freebsd-arm64": "0.20.0", - "@esbuild/freebsd-x64": "0.20.0", - "@esbuild/linux-arm": "0.20.0", - "@esbuild/linux-arm64": "0.20.0", - "@esbuild/linux-ia32": "0.20.0", - "@esbuild/linux-loong64": "0.20.0", - "@esbuild/linux-mips64el": "0.20.0", - "@esbuild/linux-ppc64": "0.20.0", - "@esbuild/linux-riscv64": "0.20.0", - "@esbuild/linux-s390x": "0.20.0", - "@esbuild/linux-x64": "0.20.0", - "@esbuild/netbsd-x64": "0.20.0", - "@esbuild/openbsd-x64": "0.20.0", - "@esbuild/sunos-x64": "0.20.0", - "@esbuild/win32-arm64": "0.20.0", - "@esbuild/win32-ia32": "0.20.0", - "@esbuild/win32-x64": "0.20.0" - } - }, - "escalade": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", - "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", - "dev": true - }, "esprima": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", @@ -1715,12 +663,6 @@ } } }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, "getobject": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz", @@ -1882,12 +824,6 @@ "dev": true, "requires": {} }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, "hooker": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", @@ -1906,12 +842,6 @@ "integrity": "sha512-Al67oatbRSo3RV5hRqIoln6Y5yMVbJSIn4jEJNL7VCImzq/kLr7vvb6sFRJXqr8rpHc/2kJOM+y0sPKN47VdzA==", "dev": true }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, "js-yaml": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-2.0.5.tgz", @@ -1953,98 +883,24 @@ "abbrev": "1" } }, - "regenerator-runtime": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", - "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", - "dev": true - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true - }, "rimraf": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", "integrity": "sha512-R5KMKHnPAQaZMqLOsyuyUmcIjSeDm+73eoqQpaXA7AZ22BL+6C+1mcUscgOsNd8WVlJuvlgAPsegcx7pjlV0Dg==", "dev": true }, - "rxjs": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", - "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", - "dev": true, - "requires": { - "tslib": "^2.1.0" - } - }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "shell-quote": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", - "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", - "dev": true - }, "sigmund": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", "integrity": "sha512-fCvEXfh6NWpm+YSuY2bpXb/VIihqWA6hLsgboC+0nl71Q7N7o2eaCW8mJa/NLvQhs6jpd3VZV4UiUQlV6+lc8g==", "dev": true }, - "spawn-command": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", - "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "tree-kill": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", - "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", - "dev": true - }, - "tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", - "dev": true - }, "underscore": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", @@ -2062,44 +918,6 @@ "resolved": "https://registry.npmjs.org/which/-/which-1.0.9.tgz", "integrity": "sha512-E87fdQ/eRJr9W1X4wTPejNy9zTW3FI2vpCZSJ/HAY+TkjKVC0TUm1jk6vn2Z7qay0DQy0+RBGdXxj+RmmiGZKQ==", "dev": true - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - }, - "yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dev": true, - "requires": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - } - }, - "yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "dev": true } } } diff --git a/package.json b/package.json index 8e558a9..e357483 100755 --- a/package.json +++ b/package.json @@ -2,21 +2,13 @@ "name": "wpct-crm-forms", "version": "1.0.0", "main": "Gruntfile.js", - "author": "codeccoop", + "author": "Còdec", "scripts": { - "start": "npm run dev", - "dev:wpcf7": "NODE_ENV=development npx esbuild src/js/wpcf7.js --bundle --outfile=assets/js/wpcf7.js --watch", - "dev:gf": "NODE_ENV=development npx esbuild src/js/gf.js --bundle --outfile=assets/js/gf.js --watch", - "dev": "NODE_ENV=development npx concurrently \"npm run dev:wpcf7\" \"npm run dev:gf\"", - "build:wpcf7": "NODE_ENV=production npx esbuild src/js/wpcf7.js --bundle --minify --outfile=assets/js/wpcf7.js", - "build:gf": "NODE_ENV=production npx esbuild src/js/gf.js --bundle --minify --outfile=assets/js/gf.js", - "build": "NODE_ENV=production npx concurrently \"npm run build:wpcf7\" \"npm run build:gf\"", + "start": "grunt default", "readme": "grunt readme", "i18n": "grunt i18n" }, "devDependencies": { - "concurrently": "^8.2.2", - "esbuild": "^0.20.0", "grunt": "~0.4.5", "grunt-wp-i18n": "~0.5.0", "grunt-wp-readme-to-markdown": "~1.0.0" diff --git a/src/js/ConditionalCheckbox.js b/src/js/ConditionalCheckbox.js deleted file mode 100644 index 15ed4d9..0000000 --- a/src/js/ConditionalCheckbox.js +++ /dev/null @@ -1,32 +0,0 @@ -import ConditionalControl from "./ConditionalControl.js"; - -function ConditionalCheckbox(el, meta) { - ConditionalControl.call(this, el, meta); - this.options = Array.from(el.querySelectorAll("input[type='checkbox']")); - for (const option of this.options) { - option.addEventListener("change", (ev) => { - setTimeout(() => { - el.value = this.getValue(); - el.dispatchEvent(new Event("change")); - }, 0); - }); - } - - this.fieldName = this.controlWrap.dataset.name; - this.type = "checkbox"; - this.el.value = this.getValue(); - Object.defineProperty(this, "defaultValue", { - writable: false, - configurable: false, - enumerable: false, - value: this.el.value, - }); -} - -ConditionalCheckbox.prototype = Object.create(ConditionalControl.prototype); - -ConditionalCheckbox.prototype.getValue = function () { - return this.options.filter((opt) => opt.checked).map((opt) => opt.value); -}; - -export default ConditionalCheckbox; diff --git a/src/js/ConditionalControl.js b/src/js/ConditionalControl.js deleted file mode 100644 index 1290d02..0000000 --- a/src/js/ConditionalControl.js +++ /dev/null @@ -1,114 +0,0 @@ -function ConditionalControl(el, meta) { - this.el = el; - this.type = el.getAttribute("type"); - this.fieldName = - el.getAttribute("name") && el.getAttribute("name").replace(/\[\]/, ""); - this.conditional = - meta && meta.classList.contains("wpcf7-form-control-conditional"); - this.conditions = {}; - - if (this.conditional) { - this.conditions = meta.dataset.conditions - .split("&") - .reduce((acum, chunk) => { - const [field, val] = chunk.split("="); - acum[field] = val; - return acum; - }, {}); - } - - Object.defineProperty(this, "value", { - get() { - return this.el.value; - }, - set(value) { - this.el.value = value; - }, - }); - - if (this.el.value !== void 0) { - Object.defineProperty(this, "defaultValue", { - writable: false, - configurable: false, - enumerable: false, - value: this.el.value, - }); - } - - Object.defineProperty(this, "visible", { - get() { - return this.conditionalWrap.classList.contains("visible"); - }, - }); - - this.prepareDom(meta); -} - -ConditionalControl.prototype.prepareDom = function (meta) { - this.controlWrap = this.el.parentElement; - this.conditionalWrap = this.controlWrap.parentElement.parentElement; - - if (this.conditional) { - this.conditionalWrap.classList.add( - "wpcf7-form-control-conditional-wrap" - ); - } - - if (meta) meta.parentElement.removeChild(meta); -}; - -ConditionalControl.prototype.validateConditions = function (state) { - if (!this.conditional) return true; - return Object.keys(this.conditions).reduce((acum, field) => { - const value = Array.isArray(state[field]) - ? state[field].join(",") - : state[field]; - return acum && value == this.conditions[field]; - }, true); -}; - -ConditionalControl.prototype.updateVisibility = function ( - state, - initial = false -) { - // Check visibility based on state - const isVisible = this.validateConditions(state); - const hasChanged = this.visible !== isVisible; - - // Update visibility state - if (isVisible) { - this.conditionalWrap.classList.add("visible"); - if (!this.controlWrap.contains(this.el)) { - this.controlWrap.appendChild(this.el); - this.controlWrap.setAttribute("data-name", this.fieldName); - } - } else { - this.conditionalWrap.classList.remove("visible"); - if (this.controlWrap.contains(this.el)) { - this.controlWrap.removeChild(this.el); - this.controlWrap.removeAttribute("data-name"); - } - } - - if (!hasChanged) return; - - // Emit visibility change - this.el.dispatchEvent( - new CustomEvent("show", { - detail: { - value: this.visible, - state: state, - }, - }) - ); -}; - -ConditionalControl.prototype.on = function (event, callback) { - this.el.addEventListener(event, callback); -}; - -ConditionalControl.prototype.off = function (event, callback) { - this.el.removeEventListener(event, callback); -}; - -export default ConditionalControl; diff --git a/src/js/ConditionalHidden.js b/src/js/ConditionalHidden.js deleted file mode 100644 index 87cb510..0000000 --- a/src/js/ConditionalHidden.js +++ /dev/null @@ -1,20 +0,0 @@ -import ConditionalControl from "./ConditionalControl.js"; - -function ConditionalHidden(el, meta) { - ConditionalControl.call(this, el, meta); -} - -ConditionalHidden.prototype = Object.create(ConditionalControl.prototype); - -ConditionalHidden.prototype.prepareDom = function (meta) { - if (this.conditional) { - this.conditionalWrap = this.controlWrap = this.el.parentElement; - this.conditionalWrap.classList.add( - "wpcf7-form-control-conditional-wrap", - "visible" - ); - meta.parentElement.removeChild(meta); - } -}; - -export default ConditionalHidden; diff --git a/src/js/ConditionalRadio.js b/src/js/ConditionalRadio.js deleted file mode 100644 index 03db3c7..0000000 --- a/src/js/ConditionalRadio.js +++ /dev/null @@ -1,35 +0,0 @@ -import ConditionalControl from "./ConditionalControl.js"; - -function ConditionalRadio(el, meta) { - ConditionalControl.call(this, el, meta); - this.options = Array.from(el.querySelectorAll("input[type='radio']")); - for (const option of this.options) { - option.addEventListener("change", (ev) => { - setTimeout(() => { - el.value = this.getValue(); - el.dispatchEvent(new Event("change")); - }, 0); - }); - } - - this.fieldName = this.controlWrap.dataset.name; - this.type = "radio"; - this.el.value = this.getValue(); - Object.defineProperty(this, "defaultValue", { - writable: false, - configurable: false, - enumerable: false, - value: this.el.value, - }); -} - -ConditionalRadio.prototype = Object.create(ConditionalControl.prototype); - -ConditionalRadio.prototype.getValue = function () { - return this.options - .filter((opt) => opt.checked) - .map((opt) => opt.value) - .pop(); -}; - -export default ConditionalRadio; diff --git a/src/js/Form.js b/src/js/Form.js deleted file mode 100644 index 2491f29..0000000 --- a/src/js/Form.js +++ /dev/null @@ -1,126 +0,0 @@ -import ConditionalControl from "./ConditionalControl.js"; -import ConditionalCheckbox from "./ConditionalCheckbox.js"; -import ConditionalRadio from "./ConditionalRadio.js"; -import ConditionalHidden from "./ConditionalHidden.js"; - -function Form(el) { - this.el = el; - this.state = {}; - this.conditions = {}; - - // Instantiante controls - this.controls = Array.from(this.el.querySelectorAll(".wpcf7-form-control")) - .map((el) => Form.getControl(el)) - .filter((control) => control); - - for (const control of this.controls) { - // Store control conditions to the global conditions registry - Object.keys(control.conditions).forEach( - (field) => (this.conditions[field] = true) - ); - - control.on("show", ({ detail }) => { - if (detail.value) { - // Subscrive visible values - this.setStateField(control); - } else { - // Unsubscrive hidden values - delete detail.state[control.fieldName]; - } - }); - - // Bind control to state - this.setStateField(control); - - // Propagate visibility updates on control change acros form - control.on("change", () => this.updateVisibility(control)); - } - - this.el.addEventListener("wpcf7reset", (ev) => this.reset(ev)); - - // Initial visibility update - this.updateVisibility(); -} - -Form.getControl = function (el) { - let type = el.getAttribute("type"); - if (!type) { - if (el.classList.contains("wpcf7-checkbox")) { - type = "checkbox"; - } else if (el.classList.contains("wpcf7-radio")) { - type = "radio"; - } else if (el.classList.contains("wpcf7-acceptance")) { - type = "acceptance"; - } - } - - let meta = el.parentElement.nextElementSibling; - switch (type) { - case "submit": - case "acceptance": - return null; - case "hidden": - meta = el.nextElementSibling; - return new ConditionalHidden(el, meta); - case "checkbox": - return new ConditionalCheckbox(el, meta); - case "radio": - return new ConditionalRadio(el, meta); - default: - return new ConditionalControl(el, meta); - } -}; - -Form.prototype.setStateField = function (control) { - Object.defineProperty(this.state, control.fieldName, { - enumerable: true, - configurable: true, - get() { - return control.value; - }, - set(value) { - if (control.value != value) { - control.value = value; - } - }, - }); -}; - -Form.prototype.updateVisibility = function (control) { - if (control && !this.conditions[control.fieldName]) return; - - for (const control of this.controls) { - if (!control.conditional) continue; - control.updateVisibility(this.state); - } -}; - -Form.prototype.getState = function () { - return this.controls.reduce((acum, control) => { - const exists = Object.prototype.hasOwnProperty.call( - this.state, - control.fieldName - ); - - if (control.visible && exists) { - acum[control.fieldName] = control.value; - } - - return acum; - }, {}); -}; - -Form.prototype.reset = function ({ detail }) { - this.controls.forEach( - (control) => (control.value = control.defaultValue || "") - ); - setTimeout(() => { - this.updateVisibility(); - window.scrollTo({ - top: Math.max(0, this.el.offsetTop - 20), - behavior: "smooth", - }); - }, 500); -}; - -export default Form; diff --git a/src/js/gf.js b/src/js/gf.js deleted file mode 100644 index 498d0c9..0000000 --- a/src/js/gf.js +++ /dev/null @@ -1,3 +0,0 @@ -document.addEventListener("DOMContentLoaded", () => { - console.log("Hello GF"); -}); diff --git a/src/js/wpcf7.js b/src/js/wpcf7.js deleted file mode 100644 index a64897c..0000000 --- a/src/js/wpcf7.js +++ /dev/null @@ -1,7 +0,0 @@ -import Form from "./Form.js"; - -document.addEventListener("DOMContentLoaded", function () { - for (const form of document.querySelectorAll(".wpcf7-form")) { - new Form(form); - } -}); diff --git a/wpct-erp-forms.php b/wpct-erp-forms.php index 22387d4..a66f01a 100755 --- a/wpct-erp-forms.php +++ b/wpct-erp-forms.php @@ -27,7 +27,6 @@ define('WPCT_ERP_FORMS_VERSION', '1.0.1'); require_once 'abstract/class-singleton.php'; require_once 'abstract/class-plugin.php'; require_once 'abstract/class-settings.php'; -require_once 'abstract/class-field.php'; require_once 'abstract/class-integration.php'; require_once 'includes/class-menu.php'; -- GitLab