drill-widgets 2.7.11 → 2.7.13
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/drill-widgets.es.js +11 -3
- package/dist/drill-widgets.umd.js +3 -3
- package/dist/lib.d.ts +5 -0
- package/package.json +1 -1
package/dist/drill-widgets.es.js
CHANGED
|
@@ -6048,7 +6048,7 @@ class k {
|
|
|
6048
6048
|
.value=${t}
|
|
6049
6049
|
?required=${e.required}
|
|
6050
6050
|
?disabled=${this._isInputDisabled(i)}
|
|
6051
|
-
placeholder
|
|
6051
|
+
placeholder=${e.placeholder ? e.placeholder : "Your response"}
|
|
6052
6052
|
@input=${(n) => i.handlers.handleInputChange(e.id, n)}
|
|
6053
6053
|
></textarea>`;
|
|
6054
6054
|
}
|
|
@@ -6335,7 +6335,7 @@ class k {
|
|
|
6335
6335
|
.value=${t}
|
|
6336
6336
|
?required=${e.required}
|
|
6337
6337
|
?disabled=${this._isInputDisabled(i)}
|
|
6338
|
-
placeholder
|
|
6338
|
+
placeholder=${e.placeholder ? e.placeholder : "Your response"} // custom placeholder when not blank
|
|
6339
6339
|
@input=${(r) => i.handlers.handleInputChange(e.id, r)}
|
|
6340
6340
|
/>`;
|
|
6341
6341
|
}
|
|
@@ -7393,13 +7393,21 @@ let f = class extends L {
|
|
|
7393
7393
|
const s = this._getAssignedSteps();
|
|
7394
7394
|
return s.length === 0 ? !1 : s.every((t) => t.status === "completed");
|
|
7395
7395
|
}
|
|
7396
|
+
/**
|
|
7397
|
+
* Check if the current step is marked as completed in the internal completed steps set
|
|
7398
|
+
* This is used to determine if we should show the completion view for the current step
|
|
7399
|
+
*/
|
|
7400
|
+
_isCurrentStepCompleted() {
|
|
7401
|
+
const s = this._currentStep;
|
|
7402
|
+
return !s || !this._isCurrentStepAssigned() ? !1 : this._internalCompletedSteps.has(s.id);
|
|
7403
|
+
}
|
|
7396
7404
|
/**
|
|
7397
7405
|
* Determine if we should show the completion view based on instance status
|
|
7398
7406
|
* This replaces the old internal state-based completion logic
|
|
7399
7407
|
*/
|
|
7400
7408
|
_shouldShowCompletionView() {
|
|
7401
7409
|
var s;
|
|
7402
|
-
return this.mode !== "default" ? !1 : !!(this._isInstanceCompleted() || ((s = this.instance) == null ? void 0 : s.status) === "active" && this._areUserStepsCompleted());
|
|
7410
|
+
return this.mode !== "default" ? !1 : !!(this._isCurrentStepCompleted() || this._isInstanceCompleted() || ((s = this.instance) == null ? void 0 : s.status) === "active" && this._areUserStepsCompleted());
|
|
7403
7411
|
}
|
|
7404
7412
|
/**
|
|
7405
7413
|
* Handles mode-based content routing and basic validation
|
|
@@ -3647,7 +3647,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
|
|
|
3647
3647
|
.value=${t}
|
|
3648
3648
|
?required=${e.required}
|
|
3649
3649
|
?disabled=${this._isInputDisabled(i)}
|
|
3650
|
-
placeholder
|
|
3650
|
+
placeholder=${e.placeholder?e.placeholder:"Your response"}
|
|
3651
3651
|
@input=${n=>i.handlers.handleInputChange(e.id,n)}
|
|
3652
3652
|
></textarea>`}static renderSelect(e,t,i){var n;return i.mode==="print"?d`<div class="print-response-value select-response">
|
|
3653
3653
|
${t||d`<span class="print-no-response">No selection made</span>`}
|
|
@@ -3848,7 +3848,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
|
|
|
3848
3848
|
.value=${t}
|
|
3849
3849
|
?required=${e.required}
|
|
3850
3850
|
?disabled=${this._isInputDisabled(i)}
|
|
3851
|
-
placeholder
|
|
3851
|
+
placeholder=${e.placeholder?e.placeholder:"Your response"} // custom placeholder when not blank
|
|
3852
3852
|
@input=${r=>i.handlers.handleInputChange(e.id,r)}
|
|
3853
3853
|
/>`}static render(e,t){const i=t.formData[e.id]??"",n=t.validationErrors[e.id],r=()=>{switch(e.type){case"textarea":return k.renderTextArea(e,i,t);case"select":return k.renderSelect(e,i,t);case"radio":return k.renderRadio(e,i,t);case"checkbox":return k.renderCheckbox(e,i,t);case"signature":return k.renderSignature(e,i,t);case"file_upload":return k.renderFileUpload(e,i,t);default:return k.renderDefaultInput(e,i,t)}},o=e.type==="checkbox"&&(!e.options||e.options.length===0);return t.mode==="print"?d`
|
|
3854
3854
|
<div class="question-print">
|
|
@@ -4100,7 +4100,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
|
|
|
4100
4100
|
|
|
4101
4101
|
${this.instance.steps.map(e=>this._renderStepWithElements(e))}
|
|
4102
4102
|
</div>
|
|
4103
|
-
`}_nextStep(){var t,i,n,r;if(!this._validateStep())return;const s=this._currentStep;s&&this._captureSignaturesFromStep(s);const e=this._findNextAssignedStep(this._currentStepIndex);if(e!==-1){const o=(t=this._currentStep)==null?void 0:t.id;if(this._currentStepIndex=e,o&&((i=this.instance)!=null&&i.steps)){const l=this.instance.steps.find(p=>p.id===o);l&&(l.status="completed")}const a=(r=(n=this.instance)==null?void 0:n.steps)==null?void 0:r[this._currentStepIndex];a&&(a.status="active"),this._updateInstanceData(o,"step_navigation",{direction:"next",fromStepIndex:this._currentStepIndex-1,toStepIndex:this._currentStepIndex,completedStepId:o}),this.mode!=="admin"&&this._saveFormDataToHistory(),this._scrollToTop()}}_findNextAssignedStep(s){return this.instance?this.navigationService.findNextAssignedStep(s,this.instance):-1}_isLastAssignedStep(){return this.navigationService.isLastAssignedStep(this._currentStepIndex,this.instance)}_isLastStepInWorkflow(){var e;const s=(e=this.instance)==null?void 0:e.steps;return s?this._currentStepIndex===s.length-1:!1}_goToStep(s){var i;console.log(`🎯 _goToStep called: stepIndex=${s}, mode=${this.mode}, currentStep=${this._currentStepIndex}`);const e=this.mode==="preview"?this.workflow:this.instance;if(console.log("📊 Data source:",e?`${((i=e.steps)==null?void 0:i.length)||0} steps`:"null"),!e){console.log("❌ No data source available");return}const t=this.navigationService.canNavigateToStep(s,this._currentStepIndex,e,this._internalCompletedSteps,this._isSubmitted,this._userStepsSubmitted);console.log("🚦 Navigation result:",t),t.canNavigate?(this._currentStepIndex=t.newStepIndex,console.log(`✅ Navigated to step ${t.newStepIndex}`),this._scrollToTop()):console.log("❌ Navigation blocked:",t.reason)}_submitUserSteps(){var t;if(!this._validateStep())return;const s=this._currentStep;if(s&&this._captureSignaturesFromStep(s),!this.instance){console.error("Cannot submit, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;e&&this._internalCompletedSteps.add(e),console.log("User completing their assigned steps:",this.instance.id),console.log("Form data:",this._formData),this._userStepsSubmitted=!0,this._clearSavedFormData("user steps submission"),this._updateInstanceData(e,"user_steps_submission"),this._scrollToTop()}_submit(){var t;if(!this._validateStep())return;const s=this._currentStep;if(s&&this._captureSignaturesFromStep(s),!this.instance){console.error("Cannot submit, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;e&&this._internalCompletedSteps.add(e),console.log("Submitting entire workflow:",this.instance.id),console.log("Final form data:",this._formData),this.instance&&(this.instance.status="completed",this.instance.currentStepId=void 0,this.instance.completedSteps=Array.from(this._internalCompletedSteps)),this._isSubmitted=!0,this._clearSavedFormData("full workflow submission"),this._scrollToTop(),this._updateInstanceData(e,"submission")}_saveStep(){var t;if(!this._validateStep())return;const s=this._currentStep;if(s&&this._captureSignaturesFromStep(s),!this.instance){console.error("Cannot save, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;if(e&&(this._internalCompletedSteps.add(e),this.instance.steps)){const i=this.instance.steps.find(n=>n.id===e);i&&(i.status="completed")}this._updateInstanceData(e,"admin_save",{stepId:e,adminMode:!0}),this._justSaved=!0,this.requestUpdate(),setTimeout(()=>{this._justSaved=!1,this.requestUpdate()},2e3)}_clearSavedFormData(s){var e;this.persistenceManager.clearFormData((e=this.instance)==null?void 0:e.id,s)}_scrollToTop(){requestAnimationFrame(()=>{var t,i;this.scrollIntoView({behavior:"smooth",block:"start"});const s=(t=this.shadowRoot)==null?void 0:t.querySelector(".runner-layout");s&&s.scrollTo({top:0,behavior:"smooth"});const e=(i=this.shadowRoot)==null?void 0:i.querySelector(".runner-main-content");e&&e.scrollTo({top:0,behavior:"smooth"})})}_updateInstanceData(s,e,t){var l,p,c,u,h,m,v;s&&this._internalCompletedSteps.add(s);let i=(p=(l=this.instance)==null?void 0:l.steps)==null?void 0:p.find(D=>D.id===s);if(!i&&this._internalCompletedSteps.size>0){const D=Array.from(this._internalCompletedSteps),se=D[D.length-1];i=(u=(c=this.instance)==null?void 0:c.steps)==null?void 0:u.find(ne=>ne.id===se)}const n=e==="submission",r=((h=this.instance)==null?void 0:h.steps)&&this._internalCompletedSteps.size>=this.instance.steps.length,o=n||r?null:this._currentStep?{id:this._currentStep.id,title:this._currentStep.title}:null,a={instanceId:(m=this.instance)==null?void 0:m.id,workflowId:(v=this.instance)==null?void 0:v.workflowId,completedStepId:s||(i?i.id:null),completedStepData:i?{id:i.id,title:i.title,responses:i.responses||[]}:null,completedSteps:Array.from(this._internalCompletedSteps),currentStep:o,mode:this.mode};this.dispatchEvent(new CustomEvent("instance-updated",{detail:a,bubbles:!0,composed:!0}))}_restoreFormData(){var e;if(!this.persistenceManager.shouldRestoreData(this.mode||"default")){console.log("Skipping form data restoration - showing official instance data");return}const s=this.persistenceManager.restoreFormData((e=this.instance)==null?void 0:e.id);s?(this.formStateManager.updateFormData(s.formData),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=s.stepIndex,this._savedSignatures=s.savedSignatures,this._internalCompletedSteps=s.completedSteps,this._savedInstance=s.savedInstance||void 0):this._updateCompletedStepsFromCurrentIndex()}_updateCompletedStepsFromCurrentIndex(){var s;if((s=this.instance)!=null&&s.steps){this._internalCompletedSteps=new Set(this.instance.completedSteps||[]);for(let e=0;e<this._currentStepIndex;e++)this.instance.steps[e]&&this._internalCompletedSteps.add(this.instance.steps[e].id)}}_restoreFormDataFromDOM(){this._restoreFormData(),this._restoreFormValuesToDOM()}_restoreFormValuesToDOM(){this.updateComplete.then(()=>{var e,t;(e=this.shadowRoot)!=null&&e.querySelector(".runner-step-form")&&(Object.entries(this._formData).forEach(([i,n])=>{var o;if(i.endsWith("_signatureData"))return;const r=(o=this.shadowRoot)==null?void 0:o.getElementById(i);if(r){if(r.type==="checkbox"){const a=r;typeof n=="boolean"?a.checked=n:Array.isArray(n)&&(a.checked=n.includes(a.value))}else if(r.type==="radio"){const a=r;a.checked=a.value===n}else if(r.type==="file"){const a=r;a.value=""}else r.value=String(n||"");console.log(`Restored value for ${i}:`,n)}}),this._restoreSignatures(),console.log("Form values restored to DOM elements"),this._updateInstanceWithFormData(!0),(t=this._savedInstance)!=null&&t.steps&&this._restoreInstanceResponses())})}_updateInstanceWithFormData(s=!1){this.instance&&this.instance.steps&&this.instance.steps.forEach(e=>{e.responses||(e.responses=[]),e.elements.forEach(t=>{if(t.type==="text_input"||t.type==="textarea"||t.type==="select"||t.type==="number"||t.type==="radio"||t.type==="checkbox"||t.type==="date"||t.type==="file_upload"||t.type==="signature"){const i=t,n=this._formData[i.id];if(n!==void 0&&e.responses){let r=e.responses.find(o=>o.elementId===i.id);r?(r.value=n,r.answeredAt=new Date):(r={elementId:i.id,value:n,answeredAt:new Date},e.responses.push(r))}}})})}_restoreSignatures(){Object.entries(this._formData).forEach(([s,e])=>{if(s.endsWith("_signatureData")&&e){const t=s.replace("_signatureData",""),i=this.signatureManager.getSignaturePad(t);if(i&&e)try{i.clear(),i.fromData(e)}catch{}}})}_saveFormDataToHistory(){var s;this.persistenceManager.saveFormData((s=this.instance)==null?void 0:s.id,this._formData,this._currentStepIndex,this._savedSignatures,this._internalCompletedSteps,this.instance||null)}_extractFormDataFromDOM(){var i;const s={},e=(i=this.shadowRoot)==null?void 0:i.querySelector(".runner-step-form");if(!e)return s;const t=e.elements;for(let n=0;n<t.length;n++){const r=t[n];if(r.name||r.id){const o=r.id||r.name;if(r.type==="checkbox"){const a=r;a.name&&a.name===o?(s[o]||(s[o]=[]),a.checked&&s[o].push(a.value)):s[o]=a.checked}else if(r.type==="radio"){const a=r;a.checked&&(s[o]=a.value)}else s[o]=r.value}}return s}_updateInstanceFromFormData(s=!1){const e=this._extractFormDataFromDOM();Object.keys(e).length>0?(this.formStateManager.mergeFormData(e),this._formData=this.formStateManager.getFormData(),this.instance&&this.instance.steps&&this.instance.steps.forEach(i=>{i.responses||(i.responses=[]),i.elements.forEach(n=>{if(n.type==="text_input"||n.type==="textarea"||n.type==="select"||n.type==="number"||n.type==="radio"||n.type==="checkbox"||n.type==="date"||n.type==="file_upload"||n.type==="signature"){const r=n,o=this._formData[r.id];if(o!==void 0&&i.responses){let a=i.responses.find(l=>l.elementId===r.id);a?(a.value=o,a.answeredAt=new Date):(a={elementId:r.id,value:o,answeredAt:new Date},i.responses.push(a))}}})}),console.log("Instance updated from form data:",this.instance),s&&this._updateInstanceData(void 0,"form_data_update",{updatedFormDataKeys:Object.keys(this._formData),updatedCompletedSteps:Array.from(this._internalCompletedSteps)})):console.log("No new form data to update instance with")}updateInstanceFromFormData(s=!1){this._updateInstanceFromFormData(s)}getFormData(){return this.formStateManager.getFormData()}restoreFormData(){this._restoreFormDataFromDOM()}clearSavedFormData(s){this._clearSavedFormData(s)}_renderUnifiedSubmissionView(){const s={instance:this.instance,assignedSteps:this._getAssignedSteps(),completedSteps:this._internalCompletedSteps,isStepAssignedToUser:this._isStepAssignedToUser.bind(this)};return Ne.renderUnifiedSubmissionView(s)}_isInstanceCompleted(){var s;return((s=this.instance)==null?void 0:s.status)==="completed"}_areUserStepsCompleted(){var e;if(!((e=this.instance)!=null&&e.steps))return!1;const s=this._getAssignedSteps();return s.length===0?!1:s.every(t=>t.status==="completed")}_shouldShowCompletionView(){var s;return this.mode!=="default"?!1:!!(this._isInstanceCompleted()||((s=this.instance)==null?void 0:s.status)==="active"&&this._areUserStepsCompleted())}_renderModeBasedContent(){var e,t;if(this._shouldShowCompletionView())return this._renderUnifiedSubmissionView();if(this.mode==="print")return this._renderAllStepsForPrint();const s=this.mode==="preview"?(e=this.workflow)==null?void 0:e.steps:(t=this.instance)==null?void 0:t.steps;return!s||s.length===0?d`<div class="runner-content">
|
|
4103
|
+
`}_nextStep(){var t,i,n,r;if(!this._validateStep())return;const s=this._currentStep;s&&this._captureSignaturesFromStep(s);const e=this._findNextAssignedStep(this._currentStepIndex);if(e!==-1){const o=(t=this._currentStep)==null?void 0:t.id;if(this._currentStepIndex=e,o&&((i=this.instance)!=null&&i.steps)){const l=this.instance.steps.find(p=>p.id===o);l&&(l.status="completed")}const a=(r=(n=this.instance)==null?void 0:n.steps)==null?void 0:r[this._currentStepIndex];a&&(a.status="active"),this._updateInstanceData(o,"step_navigation",{direction:"next",fromStepIndex:this._currentStepIndex-1,toStepIndex:this._currentStepIndex,completedStepId:o}),this.mode!=="admin"&&this._saveFormDataToHistory(),this._scrollToTop()}}_findNextAssignedStep(s){return this.instance?this.navigationService.findNextAssignedStep(s,this.instance):-1}_isLastAssignedStep(){return this.navigationService.isLastAssignedStep(this._currentStepIndex,this.instance)}_isLastStepInWorkflow(){var e;const s=(e=this.instance)==null?void 0:e.steps;return s?this._currentStepIndex===s.length-1:!1}_goToStep(s){var i;console.log(`🎯 _goToStep called: stepIndex=${s}, mode=${this.mode}, currentStep=${this._currentStepIndex}`);const e=this.mode==="preview"?this.workflow:this.instance;if(console.log("📊 Data source:",e?`${((i=e.steps)==null?void 0:i.length)||0} steps`:"null"),!e){console.log("❌ No data source available");return}const t=this.navigationService.canNavigateToStep(s,this._currentStepIndex,e,this._internalCompletedSteps,this._isSubmitted,this._userStepsSubmitted);console.log("🚦 Navigation result:",t),t.canNavigate?(this._currentStepIndex=t.newStepIndex,console.log(`✅ Navigated to step ${t.newStepIndex}`),this._scrollToTop()):console.log("❌ Navigation blocked:",t.reason)}_submitUserSteps(){var t;if(!this._validateStep())return;const s=this._currentStep;if(s&&this._captureSignaturesFromStep(s),!this.instance){console.error("Cannot submit, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;e&&this._internalCompletedSteps.add(e),console.log("User completing their assigned steps:",this.instance.id),console.log("Form data:",this._formData),this._userStepsSubmitted=!0,this._clearSavedFormData("user steps submission"),this._updateInstanceData(e,"user_steps_submission"),this._scrollToTop()}_submit(){var t;if(!this._validateStep())return;const s=this._currentStep;if(s&&this._captureSignaturesFromStep(s),!this.instance){console.error("Cannot submit, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;e&&this._internalCompletedSteps.add(e),console.log("Submitting entire workflow:",this.instance.id),console.log("Final form data:",this._formData),this.instance&&(this.instance.status="completed",this.instance.currentStepId=void 0,this.instance.completedSteps=Array.from(this._internalCompletedSteps)),this._isSubmitted=!0,this._clearSavedFormData("full workflow submission"),this._scrollToTop(),this._updateInstanceData(e,"submission")}_saveStep(){var t;if(!this._validateStep())return;const s=this._currentStep;if(s&&this._captureSignaturesFromStep(s),!this.instance){console.error("Cannot save, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;if(e&&(this._internalCompletedSteps.add(e),this.instance.steps)){const i=this.instance.steps.find(n=>n.id===e);i&&(i.status="completed")}this._updateInstanceData(e,"admin_save",{stepId:e,adminMode:!0}),this._justSaved=!0,this.requestUpdate(),setTimeout(()=>{this._justSaved=!1,this.requestUpdate()},2e3)}_clearSavedFormData(s){var e;this.persistenceManager.clearFormData((e=this.instance)==null?void 0:e.id,s)}_scrollToTop(){requestAnimationFrame(()=>{var t,i;this.scrollIntoView({behavior:"smooth",block:"start"});const s=(t=this.shadowRoot)==null?void 0:t.querySelector(".runner-layout");s&&s.scrollTo({top:0,behavior:"smooth"});const e=(i=this.shadowRoot)==null?void 0:i.querySelector(".runner-main-content");e&&e.scrollTo({top:0,behavior:"smooth"})})}_updateInstanceData(s,e,t){var l,p,c,u,h,m,v;s&&this._internalCompletedSteps.add(s);let i=(p=(l=this.instance)==null?void 0:l.steps)==null?void 0:p.find(D=>D.id===s);if(!i&&this._internalCompletedSteps.size>0){const D=Array.from(this._internalCompletedSteps),se=D[D.length-1];i=(u=(c=this.instance)==null?void 0:c.steps)==null?void 0:u.find(ne=>ne.id===se)}const n=e==="submission",r=((h=this.instance)==null?void 0:h.steps)&&this._internalCompletedSteps.size>=this.instance.steps.length,o=n||r?null:this._currentStep?{id:this._currentStep.id,title:this._currentStep.title}:null,a={instanceId:(m=this.instance)==null?void 0:m.id,workflowId:(v=this.instance)==null?void 0:v.workflowId,completedStepId:s||(i?i.id:null),completedStepData:i?{id:i.id,title:i.title,responses:i.responses||[]}:null,completedSteps:Array.from(this._internalCompletedSteps),currentStep:o,mode:this.mode};this.dispatchEvent(new CustomEvent("instance-updated",{detail:a,bubbles:!0,composed:!0}))}_restoreFormData(){var e;if(!this.persistenceManager.shouldRestoreData(this.mode||"default")){console.log("Skipping form data restoration - showing official instance data");return}const s=this.persistenceManager.restoreFormData((e=this.instance)==null?void 0:e.id);s?(this.formStateManager.updateFormData(s.formData),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=s.stepIndex,this._savedSignatures=s.savedSignatures,this._internalCompletedSteps=s.completedSteps,this._savedInstance=s.savedInstance||void 0):this._updateCompletedStepsFromCurrentIndex()}_updateCompletedStepsFromCurrentIndex(){var s;if((s=this.instance)!=null&&s.steps){this._internalCompletedSteps=new Set(this.instance.completedSteps||[]);for(let e=0;e<this._currentStepIndex;e++)this.instance.steps[e]&&this._internalCompletedSteps.add(this.instance.steps[e].id)}}_restoreFormDataFromDOM(){this._restoreFormData(),this._restoreFormValuesToDOM()}_restoreFormValuesToDOM(){this.updateComplete.then(()=>{var e,t;(e=this.shadowRoot)!=null&&e.querySelector(".runner-step-form")&&(Object.entries(this._formData).forEach(([i,n])=>{var o;if(i.endsWith("_signatureData"))return;const r=(o=this.shadowRoot)==null?void 0:o.getElementById(i);if(r){if(r.type==="checkbox"){const a=r;typeof n=="boolean"?a.checked=n:Array.isArray(n)&&(a.checked=n.includes(a.value))}else if(r.type==="radio"){const a=r;a.checked=a.value===n}else if(r.type==="file"){const a=r;a.value=""}else r.value=String(n||"");console.log(`Restored value for ${i}:`,n)}}),this._restoreSignatures(),console.log("Form values restored to DOM elements"),this._updateInstanceWithFormData(!0),(t=this._savedInstance)!=null&&t.steps&&this._restoreInstanceResponses())})}_updateInstanceWithFormData(s=!1){this.instance&&this.instance.steps&&this.instance.steps.forEach(e=>{e.responses||(e.responses=[]),e.elements.forEach(t=>{if(t.type==="text_input"||t.type==="textarea"||t.type==="select"||t.type==="number"||t.type==="radio"||t.type==="checkbox"||t.type==="date"||t.type==="file_upload"||t.type==="signature"){const i=t,n=this._formData[i.id];if(n!==void 0&&e.responses){let r=e.responses.find(o=>o.elementId===i.id);r?(r.value=n,r.answeredAt=new Date):(r={elementId:i.id,value:n,answeredAt:new Date},e.responses.push(r))}}})})}_restoreSignatures(){Object.entries(this._formData).forEach(([s,e])=>{if(s.endsWith("_signatureData")&&e){const t=s.replace("_signatureData",""),i=this.signatureManager.getSignaturePad(t);if(i&&e)try{i.clear(),i.fromData(e)}catch{}}})}_saveFormDataToHistory(){var s;this.persistenceManager.saveFormData((s=this.instance)==null?void 0:s.id,this._formData,this._currentStepIndex,this._savedSignatures,this._internalCompletedSteps,this.instance||null)}_extractFormDataFromDOM(){var i;const s={},e=(i=this.shadowRoot)==null?void 0:i.querySelector(".runner-step-form");if(!e)return s;const t=e.elements;for(let n=0;n<t.length;n++){const r=t[n];if(r.name||r.id){const o=r.id||r.name;if(r.type==="checkbox"){const a=r;a.name&&a.name===o?(s[o]||(s[o]=[]),a.checked&&s[o].push(a.value)):s[o]=a.checked}else if(r.type==="radio"){const a=r;a.checked&&(s[o]=a.value)}else s[o]=r.value}}return s}_updateInstanceFromFormData(s=!1){const e=this._extractFormDataFromDOM();Object.keys(e).length>0?(this.formStateManager.mergeFormData(e),this._formData=this.formStateManager.getFormData(),this.instance&&this.instance.steps&&this.instance.steps.forEach(i=>{i.responses||(i.responses=[]),i.elements.forEach(n=>{if(n.type==="text_input"||n.type==="textarea"||n.type==="select"||n.type==="number"||n.type==="radio"||n.type==="checkbox"||n.type==="date"||n.type==="file_upload"||n.type==="signature"){const r=n,o=this._formData[r.id];if(o!==void 0&&i.responses){let a=i.responses.find(l=>l.elementId===r.id);a?(a.value=o,a.answeredAt=new Date):(a={elementId:r.id,value:o,answeredAt:new Date},i.responses.push(a))}}})}),console.log("Instance updated from form data:",this.instance),s&&this._updateInstanceData(void 0,"form_data_update",{updatedFormDataKeys:Object.keys(this._formData),updatedCompletedSteps:Array.from(this._internalCompletedSteps)})):console.log("No new form data to update instance with")}updateInstanceFromFormData(s=!1){this._updateInstanceFromFormData(s)}getFormData(){return this.formStateManager.getFormData()}restoreFormData(){this._restoreFormDataFromDOM()}clearSavedFormData(s){this._clearSavedFormData(s)}_renderUnifiedSubmissionView(){const s={instance:this.instance,assignedSteps:this._getAssignedSteps(),completedSteps:this._internalCompletedSteps,isStepAssignedToUser:this._isStepAssignedToUser.bind(this)};return Ne.renderUnifiedSubmissionView(s)}_isInstanceCompleted(){var s;return((s=this.instance)==null?void 0:s.status)==="completed"}_areUserStepsCompleted(){var e;if(!((e=this.instance)!=null&&e.steps))return!1;const s=this._getAssignedSteps();return s.length===0?!1:s.every(t=>t.status==="completed")}_isCurrentStepCompleted(){const s=this._currentStep;return!s||!this._isCurrentStepAssigned()?!1:this._internalCompletedSteps.has(s.id)}_shouldShowCompletionView(){var s;return this.mode!=="default"?!1:!!(this._isCurrentStepCompleted()||this._isInstanceCompleted()||((s=this.instance)==null?void 0:s.status)==="active"&&this._areUserStepsCompleted())}_renderModeBasedContent(){var e,t;if(this._shouldShowCompletionView())return this._renderUnifiedSubmissionView();if(this.mode==="print")return this._renderAllStepsForPrint();const s=this.mode==="preview"?(e=this.workflow)==null?void 0:e.steps:(t=this.instance)==null?void 0:t.steps;return!s||s.length===0?d`<div class="runner-content">
|
|
4104
4104
|
${this.mode==="preview"?"No workflow loaded or workflow has no steps.":"No workflow instance loaded or instance has no steps."}
|
|
4105
4105
|
</div>`:this.mode==="default"&&this._getAssignedSteps().length===0?this._renderNotAssignedView():null}_validateCurrentStep(){return this._currentStep}_initializeStepAssets(s){this.updateComplete.then(()=>{s.elements.forEach(e=>{var t;e.type==="signature"&&((t=this.shadowRoot)!=null&&t.getElementById(`signature-${e.id}`))&&this._initializeSignaturePad(e.id)}),this._restoreSignatures(),setTimeout(()=>{this._formRestorationComplete||(this._restoreFormDataFromDOM(),this._formRestorationComplete=!0)},100)})}_renderCurrentStepLayout(s){var n,r;const e=this._isLastAssignedStep(),t=this._isLastStepInWorkflow(),i=this.mode==="preview"?(n=this.workflow)==null?void 0:n.steps:(r=this.instance)==null?void 0:r.steps;return d`
|
|
4106
4106
|
<!-- Mobile Steps Navigation (visible only on mobile) -->
|
package/dist/lib.d.ts
CHANGED
|
@@ -361,6 +361,11 @@ export declare class RunnerWidget extends LitElement {
|
|
|
361
361
|
* This is used when instance status is "active" but user has finished their part
|
|
362
362
|
*/
|
|
363
363
|
private _areUserStepsCompleted;
|
|
364
|
+
/**
|
|
365
|
+
* Check if the current step is marked as completed in the internal completed steps set
|
|
366
|
+
* This is used to determine if we should show the completion view for the current step
|
|
367
|
+
*/
|
|
368
|
+
private _isCurrentStepCompleted;
|
|
364
369
|
/**
|
|
365
370
|
* Determine if we should show the completion view based on instance status
|
|
366
371
|
* This replaces the old internal state-based completion logic
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drill-widgets",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.13",
|
|
4
4
|
"description": "Easily embed powerful workflow building and running capabilities into your web applications with Lit-based web components. Includes HTML export for server-side PDF generation.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|