svelte-craftcms-headless-formie
Version:
Svelte Package for using Craft CMS with the Formie Plugin in headless configuration
73 lines (72 loc) • 2.72 kB
TypeScript
import type { FormField, FormieFetchDataProps, FormiePagesProps } from '../types/FormTypes.js';
import type { ReCaptchaInstance } from 'recaptcha-v3';
/**
* Überprüft die Bedingungen für ein Formularfeld und gibt `true` oder `false` zurück,
* je nachdem, ob die Bedingungen erfüllt sind.
*
* @param {string} conditionsStr - JSON-String der Bedingungen des Feldes
* @param {Array} formFields - Array der aktuellen Feldwerte
* @returns {boolean} - `true`, wenn die Bedingungen erfüllt sind, sonst `false`
*/
export declare const checkFieldConditions: (conditionsStr: string | null, formFields: FormField[]) => boolean;
/**
* Inserts or updates an object in an array based on its `handle` property.
*
* Searches the provided array for an object whose `handle` matches the
* `handle` of the given element. If found, replaces that object in-place;
* otherwise, appends the element to the end of the array.
*
* @param {Object[]} array - The array of objects to upsert into.
* @param {{ [key: string]: string }} element - The object to insert or update.
* Must have a `handle` property of type string.
* @returns {void}
*
* @example
* const items = [
* { handle: 'foo', value: 'old' },
* { handle: 'bar', value: 'baz' }
* ];
*
* upsert(items, { handle: 'foo', value: 'new' });
* // items is now [ { handle: 'foo', value: 'new' }, { handle: 'bar', value: 'baz' } ]
*
* upsert(items, { handle: 'qux', value: 'added' });
* // items is now [
* // { handle: 'foo', value: 'new' },
* // { handle: 'bar', value: 'baz' },
* // { handle: 'qux', value: 'added' }
* // ]
*/
export declare const upsert: (array: any[], element: {
[key: string]: string;
}) => void;
/**
* @async addRecaptcha
* @description
* Adds recaptcha validation to the formData if a key is provided
* @returns void
*/
export declare const addRecaptcha: (recaptcha: ReCaptchaInstance | undefined, formData: FormieFetchDataProps, recaptchaKey: string | undefined) => Promise<void>;
/**
* @function areInputFieldsValid
* @description checks the validity of all form fields of the current form page
* @returns boolean
*/
export declare const areInputFieldsValid: (pages: FormiePagesProps[], pageIndex: number) => boolean;
/**
* @function checkValidity
* @description
* Checks the validity form a passed in from HTML ELements Array
* @param elems
* @returns boolean
*/
export declare const checkValidity: (elems: (HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement)[]) => boolean;
/**
* @function isValidJSON
* @description
* checks if a string is valid json format
*
* @param input
* @returns boolean
*/
export declare const isValidJSON: (input: string | undefined | null) => boolean;