{"version":3,"file":"fields.mjs","sources":["../../../../src/lib/shared/fields.mts"],"sourcesContent":["/**\n * A form element that can be an input, select or text area\n */\nexport type FormElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\n/**\n * Type guard to check if an element is a form element\n */\nfunction isFormElement(el: Element): el is FormElement {\n  return 'checkValidity' in el && typeof (el as HTMLInputElement).checkValidity === 'function';\n}\n\n/**\n * Extract all fields from the form that are valid inputs with `name` property that are not part of a form group\n */\nexport function getFormFields(rootEl: HTMLElement): FormElement[] {\n  const nodeList = rootEl.querySelectorAll('*[name]:not([data-in-group])');\n  return Array.from(nodeList).filter(isFormElement);\n}\n\n/**\n * Extract all fields from a group that are valid inputs with `name` property\n */\nexport function getGroupFields(rootEl: HTMLElement): FormElement[] {\n  const nodeList = rootEl.querySelectorAll('*[name]');\n  return Array.from(nodeList).filter(isFormElement);\n}\n"],"names":["isFormElement","el","getFormFields","rootEl","nodeList","getGroupFields"],"mappings":"AAQA,SAASA,EAAcC,GAAgC;AACrD,SAAO,mBAAmBA,KAAM,OAAQA,EAAwB,iBAAkB;AACpF;AAKO,SAASC,EAAcC,GAAoC;AAChE,QAAMC,IAAWD,EAAO,iBAAiB,8BAA8B;AACvE,SAAO,MAAM,KAAKC,CAAQ,EAAE,OAAOJ,CAAa;AAClD;AAKO,SAASK,EAAeF,GAAoC;AACjE,QAAMC,IAAWD,EAAO,iBAAiB,SAAS;AAClD,SAAO,MAAM,KAAKC,CAAQ,EAAE,OAAOJ,CAAa;AAClD;"}