@streamline-pulse/formkrafter-wc 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/fk-brick-actions.js +1 -1
- package/dist/components/fk-brick-list.js +1 -1
- package/dist/components/fk-brick-mold-item.js +1 -1
- package/dist/components/fk-brick-render.js +1 -1
- package/dist/components/fk-data-grid.js +1 -1
- package/dist/components/fk-drop-area.js +1 -1
- package/dist/components/fk-empty-form.js +1 -1
- package/dist/components/fk-file-input.js +1 -1
- package/dist/components/fk-form-builder.js +1 -1
- package/dist/components/fk-form-render.js +1 -1
- package/dist/components/fk-form-review.js +1 -1
- package/dist/components/fk-property-panel.js +1 -1
- package/dist/components/fk-rules-editor.js +1 -1
- package/dist/components/fk-select-input.js +1 -1
- package/dist/components/fk-signature-input.js +1 -1
- package/dist/components/fk-stepper.js +1 -1
- package/dist/components/fk-tabs.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-D3gCWPK-.js → p-0sDICgJ3.js} +1 -1
- package/dist/components/{p-CQwP9ywY.js → p-1_c29Rag.js} +1 -1
- package/dist/components/{p-LFS7Colb.js → p-BOZ5pg73.js} +1 -1
- package/dist/components/{p-D6d40bcg.js → p-BPwPAGJq.js} +1 -1
- package/dist/components/{p-DFqFSvCD.js → p-BmSNDWrx.js} +1 -1
- package/dist/components/{p-D9Bex5Kq.js → p-BpDsZSJX.js} +1 -1
- package/dist/components/{p-Biq3Q5cJ.js → p-CgWxWEuI.js} +1 -1
- package/dist/components/{p-S9JRhOzf.js → p-D0fTMJ2D.js} +1 -1
- package/dist/{formkrafter-wc/p-CQdBfoyu.js → components/p-D6WtQeaQ.js} +1 -1
- package/dist/components/{p-DyibkWjq.js → p-DCKXkdxG.js} +1 -1
- package/dist/components/{p-DHJ5oYz-.js → p-DLYnonbs.js} +1 -1
- package/dist/components/p-DitxNIT2.js +1 -0
- package/dist/components/{p-Chsmhqt6.js → p-DzPxItO6.js} +1 -1
- package/dist/components/{p-B-a-xyQa.js → p-KYwjk9Yt.js} +1 -1
- package/dist/components/{p-CcBrQb8q.js → p-XP4h_v8Q.js} +1 -1
- package/dist/formkrafter-wc/formkrafter-wc.css +1 -1
- package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
- package/dist/formkrafter-wc/index.esm.js +1 -1
- package/dist/formkrafter-wc/{p-e30767fc.entry.js → p-0521c981.entry.js} +1 -1
- package/dist/formkrafter-wc/{p-899de018.entry.js → p-7bf6a9d1.entry.js} +1 -1
- package/dist/{components/p-BmlOjFQ_.js → formkrafter-wc/p-7kO7VDbG.js} +1 -1
- package/dist/formkrafter-wc/p-987a6904.entry.js +1 -0
- package/dist/types/components/fk-brick-render/fk-brick-render.d.ts +1 -0
- package/dist/types/components/fk-form-render/fk-form-render.d.ts +2 -0
- package/dist/types/components/fk-form-review/fk-form-review.d.ts +2 -0
- package/dist/types/components.d.ts +18 -0
- package/package.json +2 -2
- package/dist/components/p-bvpqmJPL.js +0 -1
- package/dist/formkrafter-wc/p-9c234229.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,p as s,H as i,c as e,h as r}from"./p-B29HakDD.js";import{b as a,d as o,h as n,e as h,i as c,g as d,v as l}from"./p-
|
|
1
|
+
import{t,p as s,H as i,c as e,h as r}from"./p-B29HakDD.js";import{b as a,d as o,h as n,e as h,i as c,g as d,v as l}from"./p-D6WtQeaQ.js";import{registerDefaultBricks as f}from"./index.js";import{d as m}from"./p-DCKXkdxG.js";import{d as u}from"./p-BTxz9ZnS.js";import{d as p}from"./p-DitxNIT2.js";import{d as b}from"./p-CIGtlYQn.js";import{d as k}from"./p-BmSNDWrx.js";import{d as v}from"./p-KYwjk9Yt.js";import{d as j}from"./p-BPwPAGJq.js";import{d as y}from"./p-DzPxItO6.js";import{d as g}from"./p-BpDsZSJX.js";import{d as O}from"./p-XP4h_v8Q.js";import{d as S}from"./p-1_c29Rag.js";const E=s(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.formDataChange=e(this,"formDataChange"),this.formSubmit=e(this,"formSubmit"),this.validityChange=e(this,"validityChange"),this.editable=!1,this.readOnly=!1,this.disabled=!1,this.showSubmit=!1,this.reviewable=!1,this.currentData={},this.touched={},this.expanding=!1,this.utils={validateForm:()=>({isValid:this.runValidation().valid})}}componentWillLoad(){return f(),this.attachFormInternals(),this.currentData=this.seeded(this.data),this.runExpansion()}syncData(t){this.currentData=this.seeded(t)}onSpecChange(){this.currentData=this.seeded(this.data),this.runExpansion()}componentDidLoad(){this.emitValidity()}emitValidity(t){const{valid:s,errors:i}=null!=t?t:this.runValidation(),e=`${s}|${Object.keys(i).sort().join(",")}`;e!==this.lastValidity&&(this.lastValidity=e,this.validityChange.emit({valid:s,errors:i}),this.reportToForm(s,i))}attachFormInternals(){const t=this.host;if("function"==typeof t.attachInternals)try{this.internals=t.attachInternals()}catch(t){this.internals=void 0}}reportToForm(t,s){var i,e,r;if(null===(i=this.internals)||void 0===i?void 0:i.setValidity)try{this.internals.setFormValue(JSON.stringify(this.publicData())),t?this.internals.setValidity({}):this.internals.setValidity({customError:!0},null!==(e=Object.values(s)[0])&&void 0!==e?e:a("form.invalid"),null!==(r=this.host.querySelector("input, select, textarea"))&&void 0!==r?r:void 0)}catch(t){}}handleHostFormSubmit(t){var s;const i=null===(s=this.internals)||void 0===s?void 0:s.form;i&&t.target===i&&(t.preventDefault(),this.submit())}seeded(t){return Object.assign(Object.assign({},o(this.effectiveSpec())),t)}effectiveSpec(){var t;return null!==(t=this.expandedSpec)&&void 0!==t?t:this.spec}async runExpansion(){if(this.expandError=void 0,this.editable||!n(this.spec))return void(this.expandedSpec=void 0);const t=this.spec;this.expanding=!0;try{const s=await h(t);this.spec===t&&(this.expandedSpec=s,this.currentData=this.seeded(this.currentData))}catch(s){this.spec===t&&(this.expandedSpec=void 0,this.expandError=s instanceof Error?s.message:String(s))}finally{this.spec===t&&(this.expanding=!1)}}publicData(){return Object.fromEntries(Object.entries(this.currentData).filter((([t])=>!t.startsWith("_"))))}dataMap(t=this.currentData){return this.context?Object.assign(Object.assign({},t),this.context):t}handleBrickDataChange(t){t.stopPropagation(),this.currentData=this.applyValueEffects(Object.assign(Object.assign({},this.currentData),t.detail));const s=Object.assign({},this.touched);for(const i of Object.keys(t.detail))s[i]=!0;this.touched=s;const{valid:i,errors:e}=this.runValidation();this.formDataChange.emit({data:this.publicData(),isValid:i,errors:e}),this.emitValidity({valid:i,errors:e})}applyValueEffects(t){var s,i;let e=t;for(const{brick:t}of c(this.effectiveSpec())){const r=null===(s=t.configs)||void 0===s?void 0:s.key;if(!r||!(null===(i=t.rules)||void 0===i?void 0:i.length))continue;const a=d(t.rules,this.dataMap(e));void 0!==a.value&&e[r]!==a.value&&(e=Object.assign(Object.assign({},e),{[r]:a.value}))}return e}async validate(){var t;const s={};for(const{brick:i}of c(this.effectiveSpec())){const e=null===(t=i.configs)||void 0===t?void 0:t.key;e&&(s[e]=!0)}this.touched=s;const i=this.runValidation(),e=Object.assign({},i.errors);let r=i.valid;const a=Array.from(this.host.querySelectorAll("fk-data-grid"));for(const t of a){const s=await t.validateRows();r=r&&s.valid,Object.assign(e,s.errors)}const o={valid:r,errors:e};return this.emitValidity(o),this.formDataChange.emit({data:this.publicData(),isValid:o.valid,errors:o.errors}),o}async submit(){const t=await this.validate();return!t.valid||this.readOnly||this.disabled||this.formSubmit.emit({data:this.publicData(),isValid:!0,errors:{}}),t}handleStepTouch(t){t.stopPropagation();const s=Object.assign({},this.touched);for(const i of t.detail.keys)s[i]=!0;this.touched=s}async handleStepperSubmit(t){t.stopPropagation(),await this.submit()}runValidation(){const t=Object.fromEntries(Object.entries(this.currentData).filter((([,t])=>""!==t&&null!=t)));return l(this.effectiveSpec(),t,this.locale,this.context?this.dataMap(t):void 0)}visibleErrors(){if(this.editable)return{};const t={};for(const[s,i]of Object.entries(this.runValidation().errors))this.touched[s]&&(t[s]=i);return t}render(){var t;return this.spec?this.expanding?r("p",{class:"fk-form__expanding"},a("nestedForm.loading")):r("form",{class:"fk-form",onSubmit:t=>t.preventDefault()},this.expandError?r("span",{class:"fk-field__error",role:"alert"},this.expandError):null,r("fk-brick-render",{brickSpec:this.effectiveSpec(),rootSpec:this.effectiveSpec(),data:this.currentData,dataMap:this.dataMap(),errors:this.visibleErrors(),annotations:this.annotations,notes:this.notes,editableKeys:this.editableKeys,reviewable:this.reviewable,locale:this.locale,path:"0",editable:this.editable,readOnly:this.readOnly,disabled:this.disabled,selectedPath:this.selectedPath,utils:this.utils}),!this.showSubmit||this.editable||this.readOnly||this.disabled?null:r("button",{type:"submit",class:"fk-form__submit",onClick:t=>{t.preventDefault(),this.submit()}},null!==(t=this.submitLabel)&&void 0!==t?t:a("form.submit"))):null}static get formAssociated(){return!0}get host(){return this}static get watchers(){return{data:[{syncData:0}],spec:[{onSpecChange:0}]}}static get style(){return".fk-form.sc-fk-form-render{display:flex;flex-direction:column;gap:var(--fk-spacing);font-family:var(--fk-font);color:var(--fk-color-text)}"}},[66,"fk-form-render",{spec:[16],data:[16],context:[16],editable:[4],readOnly:[4,"read-only"],disabled:[4],showSubmit:[4,"show-submit"],submitLabel:[1,"submit-label"],selectedPath:[1,"selected-path"],locale:[1],annotations:[16],notes:[16],editableKeys:[16],reviewable:[4],currentData:[32],touched:[32],expandedSpec:[32],expanding:[32],expandError:[32],validate:[64],submit:[64]},[[8,"submit","handleHostFormSubmit"],[0,"brickDataChange","handleBrickDataChange"],[0,"stepTouch","handleStepTouch"],[0,"stepperSubmit","handleStepperSubmit"]],{data:[{syncData:0}],spec:[{onSpecChange:0}]}]);function x(){"undefined"!=typeof customElements&&["fk-form-render","fk-brick-actions","fk-brick-not-found","fk-brick-render","fk-code-editor","fk-data-grid","fk-drop-area","fk-file-input","fk-select-input","fk-signature-input","fk-stepper","fk-tabs"].forEach((s=>{switch(s){case"fk-form-render":customElements.get(t(s))||customElements.define(t(s),E);break;case"fk-brick-actions":customElements.get(t(s))||m();break;case"fk-brick-not-found":customElements.get(t(s))||u();break;case"fk-brick-render":customElements.get(t(s))||p();break;case"fk-code-editor":customElements.get(t(s))||b();break;case"fk-data-grid":customElements.get(t(s))||k();break;case"fk-drop-area":customElements.get(t(s))||v();break;case"fk-file-input":customElements.get(t(s))||j();break;case"fk-select-input":customElements.get(t(s))||y();break;case"fk-signature-input":customElements.get(t(s))||g();break;case"fk-stepper":customElements.get(t(s))||O();break;case"fk-tabs":customElements.get(t(s))||S()}}))}x();export{E as F,x as d}
|