aw-wizard-forms 4.2.0 → 4.4.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/README.md +23 -0
- package/dist/wizard-form.esm.js +44 -28
- package/dist/wizard-form.esm.js.map +1 -1
- package/dist/wizard-form.min.js +44 -29
- package/dist/wizard-form.min.js.map +1 -1
- package/package.json +1 -1
package/dist/wizard-form.min.js
CHANGED
|
@@ -537,7 +537,7 @@
|
|
|
537
537
|
display: flex;
|
|
538
538
|
align-items: center;
|
|
539
539
|
gap: var(--wf-spacing-3);
|
|
540
|
-
|
|
540
|
+
height: var(--wf-input-min-height);
|
|
541
541
|
background: var(--wf-glass-bg);
|
|
542
542
|
backdrop-filter: blur(var(--wf-glass-blur));
|
|
543
543
|
-webkit-backdrop-filter: blur(var(--wf-glass-blur));
|
|
@@ -545,6 +545,7 @@
|
|
|
545
545
|
border-radius: var(--wf-radius-md);
|
|
546
546
|
box-shadow: var(--wf-glass-shadow);
|
|
547
547
|
padding-left: var(--wf-spacing-3);
|
|
548
|
+
padding-right: var(--wf-spacing-2);
|
|
548
549
|
transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
|
|
549
550
|
}
|
|
550
551
|
|
|
@@ -575,38 +576,46 @@
|
|
|
575
576
|
.wf-other-actions {
|
|
576
577
|
display: flex;
|
|
577
578
|
align-items: center;
|
|
578
|
-
justify-content:
|
|
579
|
+
justify-content: flex-end;
|
|
580
|
+
flex-shrink: 0;
|
|
581
|
+
opacity: 0;
|
|
582
|
+
visibility: hidden;
|
|
583
|
+
transition: opacity 200ms ease, visibility 200ms ease;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/* Show button when input has value */
|
|
587
|
+
.wf-other-input-wrapper.has-value .wf-other-actions {
|
|
588
|
+
opacity: 1;
|
|
589
|
+
visibility: visible;
|
|
579
590
|
}
|
|
580
591
|
|
|
581
|
-
/*
|
|
592
|
+
/* Button inside input box should not stretch */
|
|
582
593
|
.wf-other-actions ::slotted(*) {
|
|
583
|
-
width:
|
|
594
|
+
width: auto;
|
|
584
595
|
}
|
|
585
|
-
`;var Ht=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Ut=(t,e,s,r)=>{for(var i,o=r>1?void 0:r?Vt(e,s):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,s,o):i(o))||o);return r&&o&&Ht(e,s,o),o};t.WfOther=class extends ct{constructor(){super(...arguments),this.label="Others, please specify:",this.placeholder="",this.parentValue="Others",this.required=!1,this.disabled=!1,this.shortcut="",this._value="",this._handleInput=t=>{const e=t.target;this._value=e.value,this._notifyChange()}}get value(){return this._value}set value(t){this._value=t}clear(){this._value="",this._notifyChange()}focusInput(){const t=this.shadowRoot?.querySelector(".wf-other-input");t?.focus()}_notifyChange(){this.dispatchEvent(new CustomEvent("wf-other-change",{detail:{value:this._value,name:this.name},bubbles:!0,composed:!0}))}render(){return K`
|
|
596
|
+
`;var Ht=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Ut=(t,e,s,r)=>{for(var i,o=r>1?void 0:r?Vt(e,s):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,s,o):i(o))||o);return r&&o&&Ht(e,s,o),o};t.WfOther=class extends ct{constructor(){super(...arguments),this.label="Others, please specify:",this.placeholder="",this.parentValue="Others",this.required=!1,this.disabled=!1,this.shortcut="",this._value="",this._handleInput=t=>{const e=t.target;this._value=e.value,this._notifyChange()}}get value(){return this._value}set value(t){this._value=t}clear(){this._value="",this._notifyChange()}focusInput(){const t=this.shadowRoot?.querySelector(".wf-other-input");t?.focus()}_notifyChange(){this.dispatchEvent(new CustomEvent("wf-other-change",{detail:{value:this._value,name:this.name},bubbles:!0,composed:!0}))}render(){const t=this._value.trim().length>0;return K`
|
|
586
597
|
<div class="wf-other-container" data-testid="wf-other">
|
|
587
598
|
<label class="wf-other-label">
|
|
588
599
|
${this.label}
|
|
589
600
|
${this.labelHint?K`<span>${this.labelHint}</span>`:J}
|
|
590
601
|
</label>
|
|
591
|
-
<wf-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
</div>
|
|
605
|
-
<!-- Slot for action buttons (like wf-next-btn) -->
|
|
602
|
+
<div class="wf-other-input-wrapper ${t?"has-value":""}">
|
|
603
|
+
${this.shortcut?K`<wf-badge shortcut="${this.shortcut}"></wf-badge>`:J}
|
|
604
|
+
<input
|
|
605
|
+
type="text"
|
|
606
|
+
class="wf-other-input"
|
|
607
|
+
placeholder="${this.placeholder}"
|
|
608
|
+
.value="${this._value}"
|
|
609
|
+
?disabled="${this.disabled}"
|
|
610
|
+
?required="${this.required}"
|
|
611
|
+
@input="${this._handleInput}"
|
|
612
|
+
data-testid="wf-other-input"
|
|
613
|
+
/>
|
|
614
|
+
<!-- Slot for action buttons (like wf-next-btn) inside input -->
|
|
606
615
|
<div class="wf-other-actions">
|
|
607
616
|
<slot></slot>
|
|
608
617
|
</div>
|
|
609
|
-
</
|
|
618
|
+
</div>
|
|
610
619
|
</div>
|
|
611
620
|
`}},t.WfOther.styles=qt,Ut([mt({type:String})],t.WfOther.prototype,"label",2),Ut([mt({type:String,attribute:"label-hint"})],t.WfOther.prototype,"labelHint",2),Ut([mt({type:String})],t.WfOther.prototype,"placeholder",2),Ut([mt({type:String})],t.WfOther.prototype,"name",2),Ut([mt({type:String,attribute:"parent-value"})],t.WfOther.prototype,"parentValue",2),Ut([mt({type:Boolean})],t.WfOther.prototype,"required",2),Ut([mt({type:Boolean})],t.WfOther.prototype,"disabled",2),Ut([mt({type:String})],t.WfOther.prototype,"shortcut",2),Ut([wt()],t.WfOther.prototype,"_value",2),t.WfOther=Ut([ut("wf-other")],t.WfOther);var Rt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Kt=(t,e,s,r)=>{for(var i,o=r>1?void 0:r?Yt(e,s):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,s,o):i(o))||o);return r&&o&&Rt(e,s,o),o};t.WfOptions=class extends t.WfLayout{constructor(){super(...arguments),this.mode="grid",this.gap="md",this.name="",this.multi=!1,this.required=!1,this.min=0,this.max=0,this.columns="2",this._selected=new Set,this._otherValue="",this._errorMessage="",this._validationActivated=!1,this._options=[],this._shortcutMap=new Map,this._composableOther=null,this._handleComposableOtherChange=t=>{t.stopPropagation(),this._otherValue=t.detail.value,this._otherValue.trim()&&this._selected.size>0&&(this._selected.clear(),this._updateOptionStates()),this._dispatchChange()},this._handleOptionSelect=t=>{if(t.detail.forwarded)return;t.stopPropagation();const{value:e}=t.detail;this._selectValue(e),this.multi||this.dispatchEvent(new CustomEvent("wf-option-select",{detail:{...t.detail,forwarded:!0},bubbles:!0,composed:!0}))},this._handleKeydown=t=>{const e=this.closest("wf-step");if(!e||!e.hasAttribute("active"))return;const s=t.composedPath()[0];if("INPUT"===s?.tagName||"TEXTAREA"===s?.tagName)return;const r=t.key.toUpperCase();if(1===r.length&&r>="A"&&r<="Z"){if(this._composableOther&&r===this._composableOther.shortcut)return t.preventDefault(),void this._composableOther.focusInput();const e=this._shortcutMap.get(r);e&&!e.disabled&&(t.preventDefault(),e.triggerSelect())}}}connectedCallback(){super.connectedCallback(),this._errorMessage="",this._validationActivated=!1,this.addEventListener("wf-option-select",this._handleOptionSelect),this.addEventListener("wf-other-change",this._handleComposableOtherChange),document.addEventListener("keydown",this._handleKeydown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("wf-option-select",this._handleOptionSelect),this.removeEventListener("wf-other-change",this._handleComposableOtherChange),document.removeEventListener("keydown",this._handleKeydown)}firstUpdated(t){super.firstUpdated(t);const e=(this._defaultSlot?.assignedElements({flatten:!0})||[]).find(t=>"wf-other"===t.tagName.toLowerCase());this._composableOther=e||null,this._discoverOptions(),this.requestUpdate()}_hasComposableOther(){return null!==this._composableOther}updated(t){super.updated(t),(t.has("multi")||t.has("max"))&&this._updateOptionStates()}render(){return super.updated(new Map),this.setAttribute("role","listbox"),this.setAttribute("aria-multiselectable",this.multi+""),this.setAttribute("aria-required",this.required+""),K`
|
|
612
621
|
<slot @slotchange="${this._handleSlotChange}"></slot>
|
|
@@ -1000,20 +1009,23 @@
|
|
|
1000
1009
|
|
|
1001
1010
|
.wf-progress {
|
|
1002
1011
|
display: flex;
|
|
1003
|
-
gap:
|
|
1012
|
+
gap: 16px;
|
|
1013
|
+
align-items: center;
|
|
1014
|
+
justify-content: center;
|
|
1004
1015
|
}
|
|
1005
1016
|
|
|
1006
1017
|
.wf-progress-segment {
|
|
1007
|
-
width:
|
|
1008
|
-
height:
|
|
1009
|
-
background-color:
|
|
1010
|
-
|
|
1018
|
+
width: 32px;
|
|
1019
|
+
height: 8px;
|
|
1020
|
+
background-color: rgba(255, 255, 255, 0.6);
|
|
1021
|
+
|
|
1022
|
+
border-radius: 100vw;
|
|
1011
1023
|
transition: background-color 300ms ease;
|
|
1012
1024
|
}
|
|
1013
1025
|
|
|
1014
1026
|
.wf-progress-segment.completed,
|
|
1015
1027
|
.wf-progress-segment.active {
|
|
1016
|
-
background-color:
|
|
1028
|
+
background-color: rgba(136, 66, 240, 0.6);
|
|
1017
1029
|
}
|
|
1018
1030
|
`];var ye=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,xe=(t,e,s,r)=>{for(var i,o=r>1?void 0:r?Se(e,s):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,s,o):i(o))||o);return r&&o&&ye(e,s,o),o};t.WfProgress=class extends ct{constructor(){super(...arguments),this.for="",this._currentStep=1,this._totalSteps=1,this._isComplete=!1,this._wizard=null,this._boundHandleStepChange=this._handleStepChange.bind(this),this._boundHandleSuccess=this._handleSuccess.bind(this),this._boundHandleStepsDiscovered=this._handleStepsDiscovered.bind(this)}connectedCallback(){super.connectedCallback(),document.addEventListener("wf:steps-discovered",this._boundHandleStepsDiscovered),requestAnimationFrame(()=>{this._connectToWizard()})}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("wf:steps-discovered",this._boundHandleStepsDiscovered),this._disconnectFromWizard()}_connectToWizard(){this.for?this._wizard=document.getElementById(this.for):this._wizard=this.closest("wizard-form"),this._wizard&&(this._currentStep=this._wizard.currentStep||1,this._totalSteps=this._wizard.totalSteps||1,this._isComplete=this._wizard.isSubmitted||!1,this._wizard.addEventListener("wf:step-change",this._boundHandleStepChange),this._wizard.addEventListener("wf:success",this._boundHandleSuccess))}_disconnectFromWizard(){this._wizard&&(this._wizard.removeEventListener("wf:step-change",this._boundHandleStepChange),this._wizard.removeEventListener("wf:success",this._boundHandleSuccess),this._wizard=null)}_handleStepChange(t){this._currentStep=t.detail.to,this._wizard&&(this._totalSteps=this._wizard.totalSteps)}_handleStepsDiscovered(t){const{wizard:e,wizardId:s,totalSteps:r,currentStep:i}=t.detail;if(this.for){if(s!==this.for)return}else{const t=this.closest("wizard-form");if(!t||t!==e)return}!this._wizard&&e&&(this._wizard=e,e.addEventListener("wf:step-change",this._boundHandleStepChange),e.addEventListener("wf:success",this._boundHandleSuccess)),this._totalSteps=r,this._currentStep=i}_handleSuccess(){this._isComplete=!0}render(){if(this._isComplete)return null;const t=[];for(let e=1;e<=this._totalSteps;e++){const s=e<this._currentStep,r=e===this._currentStep;t.push(K`
|
|
1019
1031
|
<div
|
|
@@ -1073,9 +1085,12 @@
|
|
|
1073
1085
|
}
|
|
1074
1086
|
|
|
1075
1087
|
:host([inline]) .wf-btn {
|
|
1076
|
-
min-height:
|
|
1088
|
+
min-height: 16px;
|
|
1077
1089
|
width: auto;
|
|
1078
|
-
padding:
|
|
1090
|
+
padding-top: 8px;
|
|
1091
|
+
padding-bottom: 8px;
|
|
1092
|
+
padding-left: 12px;
|
|
1093
|
+
padding-right: 8px;
|
|
1079
1094
|
}
|
|
1080
1095
|
`];var Ce=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,We=(t,e,s,r)=>{for(var i,o=r>1?void 0:r?Oe(e,s):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,s,o):i(o))||o);return r&&o&&Ce(e,s,o),o};t.WfNextBtn=class extends ke{constructor(){super(...arguments),this.showShortcut=!0,this.inline=!1,this.disabled=!1,this._handleClick=()=>{this.disabled||this._isSubmitting||this._dispatchNavEvent()}}_getEventName(){return"wf:nav-next"}_getButtonLabel(){return this.label?this.label:!this.inline&&("submit"===this.action||"next"!==this.action&&this._isLastStep)?"Submit":"Continue"}_isSubmitAction(){return!this.inline&&("submit"===this.action||"next"!==this.action&&this._isLastStep)}render(){const t=this._getButtonLabel(),e=this.disabled||this._isSubmitting;return K`
|
|
1081
1096
|
<button
|