UNPKG

@synergy-design-system/components

Version:

This package provides the base of the Synergy Design System as native web components. It uses [lit](https://www.lit.dev) and parts of [shoelace](https://shoelace.style/). Synergy officially supports the latest two versions of all major browsers (as define

41 lines (38 loc) 1.07 kB
import { formCollections } from "./chunk.HP2LEQRU.js"; // src/utilities/form.ts function serialize(form) { const formData = new FormData(form); const object = {}; formData.forEach((value, key) => { if (Reflect.has(object, key)) { const entry = object[key]; if (Array.isArray(entry)) { entry.push(value); } else { object[key] = [object[key], value]; } } else { object[key] = value; } }); return object; } function getFormControls(form) { const rootNode = form.getRootNode(); const allNodes = [...rootNode.querySelectorAll("*")]; const formControls = [...form.elements]; const collection = formCollections.get(form); const synergyFormControls = collection ? Array.from(collection) : []; return [...formControls, ...synergyFormControls].sort((a, b) => { if (allNodes.indexOf(a) < allNodes.indexOf(b)) return -1; if (allNodes.indexOf(a) > allNodes.indexOf(b)) return 1; return 0; }); } export { serialize, getFormControls }; //# sourceMappingURL=chunk.MTN5NM4A.js.map