@saasbase-io/core-elements 1.20.0 → 1.21.1

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
@@ -6288,7 +6288,6 @@ body {
6288
6288
  type="text"
6289
6289
  name="${this.name}"
6290
6290
  placeholder="${this.placeholder??m}"
6291
- pattern="${this._pattern.source}"
6292
6291
  minlength="${t??m}"
6293
6292
  maxlength="${r??m}"
6294
6293
  ?disabled="${this.disabled}"
@@ -6411,7 +6410,6 @@ body {
6411
6410
  type="text"
6412
6411
  name="${this.name}"
6413
6412
  placeholder="${this.placeholder??m}"
6414
- pattern="${this._pattern.source}"
6415
6413
  minlength="${t??m}"
6416
6414
  maxlength="${r??m}"
6417
6415
  ?disabled="${this.disabled}"
@@ -6443,7 +6441,7 @@ body {
6443
6441
  ${this.label}
6444
6442
  ${this.spinnerAlign==="end"?this._renderSpinner():m}
6445
6443
  </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`
6444
+ `}};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
6445
  <form
6448
6446
  id="${this.rootId}"
6449
6447
  part="${exports.SbForm.parts.root}"