@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
4 lines • 2.02 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
;const index=require("./index-94c17ce6.js"),componentNames=require("./component-names-82c4d68d.js"),searchFormElement=e=>{for(index.getExperimentalMode()&&(index.devHint("↓ Search form element start."),index.Log.debug(e));e instanceof HTMLElement&&"FORM"!==e.tagName&&e.tagName!==componentNames.KolFormTag.toUpperCase();){try{e=e.parentElement instanceof HTMLElement?e.parentElement:e.parentNode instanceof ShadowRoot?e.parentNode.host:null}catch(e){}index.getExperimentalMode()&&(index.Log.debug(e),index.devHint("↑ Search form element finished."))}return e},propagateResetEventToForm=(e={})=>{var t,o;const n=searchFormElement(e.form);if(n instanceof HTMLElement){const e=new Event("reset",{bubbles:!0,cancelable:!0});if("FORM"===n.tagName)index.setEventTarget(e,n),n.dispatchEvent(e);else if(n.tagName===componentNames.KolFormTag.toUpperCase()){index.setEventTarget(e,index.KoliBriDevHelper.querySelector("form",n));const r=n;"function"==typeof(null===(t=r._on)||void 0===t?void 0:t.onReset)&&(null===(o=r._on)||void 0===o||o.onReset(e))}}},propagateSubmitEventToForm=(e={})=>{const t=searchFormElement(e.form);if(t instanceof HTMLElement){const e=new SubmitEvent("submit",{bubbles:!0,cancelable:!0,submitter:t});if("FORM"===t.tagName)index.getExperimentalMode()&&!1===t.noValidate&&index.devHint("If you have not focusable or hidden form fields in your form, you should enable noValidate for your form.",{force:!0}),setTimeout((()=>{"function"==typeof t.requestSubmit?t.requestSubmit():(index.setEventTarget(e,t),t.dispatchEvent(e))}));else if(t.tagName===componentNames.KolFormTag.toUpperCase()){index.setEventTarget(e,index.KoliBriDevHelper.querySelector("form",t));const o=t;setTimeout((()=>{var t,n;"function"==typeof(null===(t=o._on)||void 0===t?void 0:t.onSubmit)&&(null===(n=o._on)||void 0===n||n.onSubmit(e))}))}}};exports.propagateResetEventToForm=propagateResetEventToForm,exports.propagateSubmitEventToForm=propagateSubmitEventToForm;