@saasbase-io/core-elements 1.20.0 → 1.21.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.
@@ -1,5 +1,5 @@
1
1
  import { IconAlign, RtgButtonBasicSize, RtgButtonBasicVariant } from '../../../../types';
2
- import { SbConfirmField, SbEmailField, SbIdentifierField, SbPasswordField, SbPhoneField, SbUsernameField } from '../field';
2
+ import { SbConfirmField, SbEmailField, SbIdentifierField, SbNameField, SbPasswordField, SbPhoneField, SbUsernameField } from '../field';
3
3
  export type FormOnSubmit = (data: Record<string, string>, event?: string) => void;
4
4
  export type FormOnReset = (event: Event) => void;
5
5
  export type FormProps = {
@@ -8,7 +8,7 @@ export type FormProps = {
8
8
  onSubmit?: FormOnSubmit;
9
9
  onReset?: FormOnReset;
10
10
  };
11
- export type Field = SbEmailField | SbPhoneField | SbUsernameField | SbIdentifierField | SbPasswordField | SbConfirmField;
11
+ export type Field = SbEmailField | SbPhoneField | SbUsernameField | SbIdentifierField | SbNameField | SbPasswordField | SbConfirmField;
12
12
  export type FormSubmitVariant = RtgButtonBasicVariant;
13
13
  export type FormSubmitSize = RtgButtonBasicSize;
14
14
  export type FormSubmitSpinnerAlign = IconAlign;
package/dist/index.js CHANGED
@@ -6443,7 +6443,7 @@ body {
6443
6443
  ${this.label}
6444
6444
  ${this.spinnerAlign==="end"?this._renderSpinner():m}
6445
6445
  </rtg-button>
6446
- `}};exports.SbFormSubmit._ROOT="form-submit";exports.SbFormSubmit._SPINNER="spinner";exports.SbFormSubmit.TAG=`sb-${exports.SbFormSubmit._ROOT}`;ee([a({type:String})],exports.SbFormSubmit.prototype,"seed",2);ee([a({attribute:"child-id",type:String})],exports.SbFormSubmit.prototype,"childId",2);ee([a({type:String})],exports.SbFormSubmit.prototype,"variant",2);ee([a({type:String})],exports.SbFormSubmit.prototype,"size",2);ee([a({type:String})],exports.SbFormSubmit.prototype,"label",2);ee([a({attribute:"spinner-align",type:String})],exports.SbFormSubmit.prototype,"spinnerAlign",2);ee([a({type:Boolean})],exports.SbFormSubmit.prototype,"disabled",2);ee([a({type:Boolean})],exports.SbFormSubmit.prototype,"loading",2);ee([a({type:String})],exports.SbFormSubmit.prototype,"event",2);ee([x()],exports.SbFormSubmit.prototype,"_loading",2);exports.SbFormSubmit=ee([p("sb-form-submit")],exports.SbFormSubmit);const cc=[exports.SbEmailField,exports.SbPhoneField,exports.SbUsernameField,exports.SbIdentifierField,exports.SbPasswordField,exports.SbConfirmField],Pg=cc.map(e=>e.TAG).join(", "),ud=cc.map(e=>e.validateEventName);var Fg=Object.defineProperty,Tg=Object.getOwnPropertyDescriptor,ki=(e,t,r,i)=>{for(var s=i>1?void 0:i?Tg(t,r):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(s=(i?n(t,r,s):n(s))||s);return i&&s&&Fg(t,r,s),s};exports.SbForm=class extends v{constructor(){super(...arguments),this.seed=_t(),this._loading=!1,this._handleSubmitClick=t=>{var r;this._pendingEvent=(r=t.detail)==null?void 0:r.event},this._handleSubmit=async t=>{if(t.preventDefault(),this._loading)return;const r=this._fields,i={},s=g=>{const y=g.detail;(y==null?void 0:y.name)!==void 0&&y.value!==void 0&&(i[y.name]=y.value)};ud.forEach(g=>this.addEventListener(g,s));const o=r.map(g=>g.validate());if(ud.forEach(g=>this.removeEventListener(g,s)),!o.every(Boolean))return;const h=this._pendingEvent;if(this.onSubmit){this.onSubmit(i,h);return}if(!h)return;const u=r.map(g=>!!g.disabled);this._setLoading(!0,r,u);try{await ht.processLoginflowEvent({event:h,...Object.keys(i).length?{data:i}:{}}),this._dispatch(exports.SbForm.SUCCESS_EVENT,{id:this.rootId,data:i,event:h})}catch(g){const y=g instanceof Error?g.message:String(g);this._dispatch(exports.SbForm.ERROR_EVENT,{id:this.rootId,data:i,event:h,message:y})}finally{this._setLoading(!1,r,u),this._pendingEvent=void 0}},this._handleReset=t=>{this._pendingEvent=void 0,this.onReset&&this.onReset(t),this._dispatch(exports.SbForm.RESET_EVENT,{id:this.rootId})}}static get parts(){return{root:this._ROOT}}createRenderRoot(){return this}get rootId(){return this.childId??`sb-${exports.SbForm.parts.root}-${this.seed}`}get _form(){return this.querySelector(`form[part="${exports.SbForm.parts.root}"]`)}get _fields(){const t=this._form;return t?Array.from(t.querySelectorAll(Pg)):[]}get _submit(){const t=this._form;return t?t.querySelector(exports.SbFormSubmit.TAG):null}connectedCallback(){super.connectedCallback(),this.addEventListener(exports.SbFormSubmit.clickEventName,this._handleSubmitClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(exports.SbFormSubmit.clickEventName,this._handleSubmitClick)}firstUpdated(){const t=this._form;if(!t)return;Array.from(this.childNodes).filter(i=>i!==t).forEach(i=>t.appendChild(i))}_dispatch(t,r={}){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}_setLoading(t,r,i){r.forEach((o,n)=>{o.disabled=t?!0:i[n]});const s=this._submit;s&&(s.loading=t),this._loading=t}render(){return d`
6446
+ `}};exports.SbFormSubmit._ROOT="form-submit";exports.SbFormSubmit._SPINNER="spinner";exports.SbFormSubmit.TAG=`sb-${exports.SbFormSubmit._ROOT}`;ee([a({type:String})],exports.SbFormSubmit.prototype,"seed",2);ee([a({attribute:"child-id",type:String})],exports.SbFormSubmit.prototype,"childId",2);ee([a({type:String})],exports.SbFormSubmit.prototype,"variant",2);ee([a({type:String})],exports.SbFormSubmit.prototype,"size",2);ee([a({type:String})],exports.SbFormSubmit.prototype,"label",2);ee([a({attribute:"spinner-align",type:String})],exports.SbFormSubmit.prototype,"spinnerAlign",2);ee([a({type:Boolean})],exports.SbFormSubmit.prototype,"disabled",2);ee([a({type:Boolean})],exports.SbFormSubmit.prototype,"loading",2);ee([a({type:String})],exports.SbFormSubmit.prototype,"event",2);ee([x()],exports.SbFormSubmit.prototype,"_loading",2);exports.SbFormSubmit=ee([p("sb-form-submit")],exports.SbFormSubmit);const cc=[exports.SbEmailField,exports.SbPhoneField,exports.SbUsernameField,exports.SbIdentifierField,exports.SbNameField,exports.SbPasswordField,exports.SbConfirmField],Pg=cc.map(e=>e.TAG).join(", "),ud=cc.map(e=>e.validateEventName);var Fg=Object.defineProperty,Tg=Object.getOwnPropertyDescriptor,ki=(e,t,r,i)=>{for(var s=i>1?void 0:i?Tg(t,r):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(s=(i?n(t,r,s):n(s))||s);return i&&s&&Fg(t,r,s),s};exports.SbForm=class extends v{constructor(){super(...arguments),this.seed=_t(),this._loading=!1,this._handleSubmitClick=t=>{var r;this._pendingEvent=(r=t.detail)==null?void 0:r.event},this._handleSubmit=async t=>{if(t.preventDefault(),this._loading)return;const r=this._fields,i={},s=g=>{const y=g.detail;(y==null?void 0:y.name)!==void 0&&y.value!==void 0&&(i[y.name]=y.value)};ud.forEach(g=>this.addEventListener(g,s));const o=r.map(g=>g.validate());if(ud.forEach(g=>this.removeEventListener(g,s)),!o.every(Boolean))return;const h=this._pendingEvent;if(this.onSubmit){this.onSubmit(i,h);return}if(!h)return;const u=r.map(g=>!!g.disabled);this._setLoading(!0,r,u);try{await ht.processLoginflowEvent({event:h,...Object.keys(i).length?{data:i}:{}}),this._dispatch(exports.SbForm.SUCCESS_EVENT,{id:this.rootId,data:i,event:h})}catch(g){const y=g instanceof Error?g.message:String(g);this._dispatch(exports.SbForm.ERROR_EVENT,{id:this.rootId,data:i,event:h,message:y})}finally{this._setLoading(!1,r,u),this._pendingEvent=void 0}},this._handleReset=t=>{this._pendingEvent=void 0,this.onReset&&this.onReset(t),this._dispatch(exports.SbForm.RESET_EVENT,{id:this.rootId})}}static get parts(){return{root:this._ROOT}}createRenderRoot(){return this}get rootId(){return this.childId??`sb-${exports.SbForm.parts.root}-${this.seed}`}get _form(){return this.querySelector(`form[part="${exports.SbForm.parts.root}"]`)}get _fields(){const t=this._form;return t?Array.from(t.querySelectorAll(Pg)):[]}get _submit(){const t=this._form;return t?t.querySelector(exports.SbFormSubmit.TAG):null}connectedCallback(){super.connectedCallback(),this.addEventListener(exports.SbFormSubmit.clickEventName,this._handleSubmitClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(exports.SbFormSubmit.clickEventName,this._handleSubmitClick)}firstUpdated(){const t=this._form;if(!t)return;Array.from(this.childNodes).filter(i=>i!==t).forEach(i=>t.appendChild(i))}_dispatch(t,r={}){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}_setLoading(t,r,i){r.forEach((o,n)=>{o.disabled=t?!0:i[n]});const s=this._submit;s&&(s.loading=t),this._loading=t}render(){return d`
6447
6447
  <form
6448
6448
  id="${this.rootId}"
6449
6449
  part="${exports.SbForm.parts.root}"