@randstad-uca/design-system 1.0.124 → 1.0.126
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 +1 @@
|
|
|
1
|
-
import e from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";import t from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";import{bodyM as n}from"../styles/fontStyles.js";import"./Button.js";import{focusStyles as r}from"../styles/focus.js";import"./Form.js";import"./FormGroup.js";import"./Notice.js";import"./Modal.js";import{LitElement as i,css as a,html as o}from"lit";import{customElement as s,property as c,state as l}from"lit/decorators.js";let u=class extends i{constructor(...e){super(...e),this.open=!1,this.title=`verificación de seguridad`,this.email=`[correo electrónico]`,this.loading=!1,this.inputMode=`numeric`,this.showError=!1,this.showSuccessNotice=!1,this.successMessage=``,this.helperMessage=``,this.resendCooldown=60,this._resendDisabled=!1,this._resendRemaining=0,this._pinValues=[,,,,,,].fill(``),this.modalWidth=`450px`,this.modalHeight=`auto`,this.maxHeight=`90dvh`}static{this.styles=[r,a`:host{font-family:'Graphik',sans-serif}.mfa-content{display:flex;flex-direction:column;gap:
|
|
1
|
+
import e from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";import t from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";import{bodyM as n}from"../styles/fontStyles.js";import"./Button.js";import{focusStyles as r}from"../styles/focus.js";import"./Form.js";import"./FormGroup.js";import"./Notice.js";import"./Modal.js";import{LitElement as i,css as a,html as o}from"lit";import{customElement as s,property as c,state as l}from"lit/decorators.js";let u=class extends i{constructor(...e){super(...e),this.open=!1,this.title=`verificación de seguridad`,this.email=`[correo electrónico]`,this.loading=!1,this.inputMode=`numeric`,this.showError=!1,this.showSuccessNotice=!1,this.successMessage=``,this.helperMessage=``,this.resendCooldown=60,this._resendDisabled=!1,this._resendRemaining=0,this._pinValues=[,,,,,,].fill(``),this.modalWidth=`450px`,this.modalHeight=`auto`,this.maxHeight=`90dvh`}static{this.styles=[r,a`:host{font-family:'Graphik',sans-serif}.mfa-content{display:flex;flex-direction:column;gap:24px}.content-wrapper{display:flex;flex-direction:column;gap:8px}.mfa-instruction{${n}color:var(--secondary-color);margin:0}.pin-group{display:flex;gap:8px}.pin-input{width:60.33px;height:62px;text-align:center;font-size:18px;line-height:30px;font-family:'Graphik',sans-serif;font-weight:400;border:1px solid var(--secondary-color-20);border-radius:4px;outline:none;transition:border-color 0.2s,box-shadow 0.2s;color:var(--secondary-color);box-sizing:border-box;caret-color:var(--primary-color)}.pin-input:focus{border-color:var(--primary-color);box-shadow:0px 0px 0px 4px var(--primary-color-20)}.pin-input.error{border-color:var(--ui-negative)}.pin-input.error:focus{box-shadow:0px 0px 0px 4px var(--ui-negative-pink-shadow)}.resend-line{display:flex;justify-content:center;align-items:center;font-family:'Graphik',sans-serif;font-weight:400;font-size:18px;line-height:30px;letter-spacing:0%;color:var(--secondary-color,#0F1941);text-align:center;width:100%;height:62px}.resend-link{color:var(--primary-color,#2175D9);cursor:pointer;text-decoration:none;background:none;border:none;font-family:'Graphik',sans-serif;font-size:inherit;padding:0;line-height:inherit}.resend-link:hover{text-decoration:underline}.content-buton{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px}.confirm-button{width:100%;height:62px}.resend-link:disabled,.resend-link.disabled{color:var(--secondary-color-60);cursor:default;pointer-events:none;opacity:0.6}@media (max-width:940px){.pin-group{gap:8px;width:100%}.pin-input{flex:1;min-width:0;height:62px;font-size:18px}}@media (prefers-reduced-motion:reduce){.pin-input{transition:none}}`]}disconnectedCallback(){super.disconnectedCallback(),this._clearResendTimer()}updated(e){e.has(`open`)&&this.open&&requestAnimationFrame(()=>this._focusInput(0)),(e.has(`loading`)||e.has(`open`))&&requestAnimationFrame(()=>this._syncCloseButtonDisabled())}reset(){this._pinValues=[,,,,,,].fill(``),this.showError=!1,this.showSuccessNotice=!1,this._resendDisabled=!1,this._clearResendTimer(),this.requestUpdate()}focusFirstInput(){this._focusInput(0)}_clearResendTimer(){this._resendTimer!==void 0&&(clearInterval(this._resendTimer),this._resendTimer=void 0)}get _resolvedInputMode(){return this.inputMode===`numeric`?`numeric`:`text`}_sanitizeValue(e){return this.inputMode===`numeric`?e.replace(/[^0-9]/g,``):e.replace(/[^a-zA-Z0-9]/g,``)}_getCloseButton(){return this.renderRoot.querySelector(`custom-modal`)?.shadowRoot?.querySelector(`.modal-close`)}_syncCloseButtonDisabled(){let e=this._getCloseButton();if(!e)return;let t=e.querySelector(`randstad-icon`);this.loading?(e.setAttribute(`disabled`,``),e.setAttribute(`aria-disabled`,`true`),e.style.cursor=`default`,e.style.pointerEvents=`none`,t&&(t.style.filter=`grayscale(1)`,t.style.opacity=`0.5`)):(e.removeAttribute(`disabled`),e.removeAttribute(`aria-disabled`),e.style.cursor=``,e.style.pointerEvents=``,t&&(t.style.filter=``,t.style.opacity=``))}_clearForwardFromIndex(e){for(let t=e+1;t<6;t++)if(this._pinValues[t]){this._pinValues[t]=``,this.requestUpdate(),this._focusInput(t);return}}_getPinInputs(){return this.renderRoot.querySelectorAll(`.pin-input`)}_focusInput(e){let t=this._getPinInputs()?.[e];t&&(t.focus(),t.select())}get _isComplete(){return this._pinValues.every(e=>e!==``)}_onPinInput(e,t){let n=e.target,r=this._sanitizeValue(n.value||``);if(!r)this._pinValues[t]=``;else if(r.length>1){let e=r.split(``);for(let n=t;n<6&&e.length>0;n++)this._pinValues[n]=e.shift();let n=Math.min(5,t+r.length);setTimeout(()=>this._focusInput(n)),this.requestUpdate()}else this._pinValues[t]=r,this.requestUpdate(),t<5&&this._focusInput(t+1)}_onPinKeyDown(e,t){e.key===`Enter`&&this._isComplete?this._onConfirm():e.key===`Backspace`?this._pinValues[t]?(this._pinValues[t]=``,this.requestUpdate(),e.preventDefault()):t>0?(this._pinValues[t-1]=``,this.requestUpdate(),this._focusInput(t-1),e.preventDefault()):(this._clearForwardFromIndex(0),e.preventDefault()):e.key===`Delete`?(this._pinValues[t]?(this._pinValues[t]=``,this.requestUpdate()):this._clearForwardFromIndex(t),e.preventDefault()):e.key.length===1&&!e.ctrlKey&&!e.metaKey&&e.key!==`v`&&(this.inputMode===`numeric`?/\D/.test(e.key):/[^a-zA-Z0-9]/.test(e.key))&&e.preventDefault()}_onPinPaste(e){let t=(e.clipboardData??window.clipboardData)?.getData(`text`)||``,n=this._sanitizeValue(t).slice(0,6).split(``);if(n.length===0)return;for(let e=0;e<6;e++)this._pinValues[e]=n[e]||``;e.preventDefault(),this.requestUpdate();let r=this._pinValues.findIndex(e=>!e);setTimeout(()=>this._focusInput(r>=0?r:5))}_onClose(){this.loading||this.dispatchEvent(new CustomEvent(`mfa-close`))}_onConfirm(){this._isComplete&&!this.loading&&this.dispatchEvent(new CustomEvent(`mfa-confirm`,{detail:{code:this._pinValues.join(``)}}))}_onResend(){this._resendDisabled||(this.dispatchEvent(new CustomEvent(`resend-code`)),this._startResendCountdown())}_startResendCountdown(){this._clearResendTimer(),this._resendDisabled=!0,this._resendRemaining=this.resendCooldown,this._resendTimer=window.setInterval(()=>{--this._resendRemaining,this._resendRemaining<=0&&(this._resendDisabled=!1,this._clearResendTimer()),this.requestUpdate()},1e3)}_renderPinInputs(){return Array.from({length:6},(e,t)=>o`<input class="pin-input ${this.showError?`error`:``}" type="text" inputmode=${this._resolvedInputMode} pattern=${this.inputMode===`numeric`?`\\d*`:`[a-zA-Z0-9]*`} maxlength="1" autocomplete="one-time-code" .value=${this._pinValues[t]} @input=${e=>this._onPinInput(e,t)} @keydown=${e=>this._onPinKeyDown(e,t)} aria-label="Dígito ${t+1} del código" aria-invalid=${this.showError?`true`:`false`} >`)}_renderResendSection(){return o`<div class="resend-line"> ¿no lo recibiste? ${this._resendDisabled?o`<span role="status" aria-live="polite">reenviar en (${this._resendRemaining}s)</span>`:o`<button class="resend-link" @click=${this._onResend} >reenviar ahora</button>`}</div>`}render(){return o`<custom-modal .open=${this.open} title=${this.title} .hideFooter=${!0} modalWidth= ${this.modalWidth}; modalHeight=${this.modalHeight}; maxHeight= ${this.maxHeight}; @modal-close=${this._onClose} ><div slot="content" class="mfa-content" role="status" aria-live="polite" aria-describedby="mfa-notice-message"><div class="content-wrapper"><randstad-notice id="mfa-notice-message" .open=${!0} .type=${this.showSuccessNotice?`success`:`informative`} .icon=${this.showSuccessNotice?`check`:`info`} .message=${this.showSuccessNotice?this.successMessage:this.helperMessage} ></randstad-notice><randstad-form-group label="ingresá el código que recibiste" .error=${this.showError} errorMessage="el código ingresado es incorrecto" ><div class="pin-group" @paste=${this._onPinPaste}>${this._renderPinInputs()}</div></randstad-form-group></div><div class="content-buton"><randstad-button class="confirm-button" variant="button-primary" size="lg" label="actualizar" .loader=${this.loading} .disabled=${!this._isComplete||this.loading} @click=${this._onConfirm} ></randstad-button>${this._renderResendSection()}</div></div></custom-modal>`}};t([c({type:Boolean,reflect:!0}),e(`design:type`,Object)],u.prototype,`open`,void 0),t([c({type:String}),e(`design:type`,Object)],u.prototype,`title`,void 0),t([c({type:String}),e(`design:type`,Object)],u.prototype,`email`,void 0),t([c({type:Boolean,reflect:!0}),e(`design:type`,Object)],u.prototype,`loading`,void 0),t([c({type:String}),e(`design:type`,Object)],u.prototype,`inputMode`,void 0),t([c({type:Boolean}),e(`design:type`,Object)],u.prototype,`showError`,void 0),t([c({type:Boolean}),e(`design:type`,Object)],u.prototype,`showSuccessNotice`,void 0),t([c({type:String}),e(`design:type`,Object)],u.prototype,`successMessage`,void 0),t([c({type:String}),e(`design:type`,Object)],u.prototype,`helperMessage`,void 0),t([c({type:Number}),e(`design:type`,Object)],u.prototype,`resendCooldown`,void 0),t([l(),e(`design:type`,Object)],u.prototype,`_resendDisabled`,void 0),t([l(),e(`design:type`,Object)],u.prototype,`_resendRemaining`,void 0),t([l(),e(`design:type`,Array)],u.prototype,`_pinValues`,void 0),t([c({type:String}),e(`design:type`,Object)],u.prototype,`modalWidth`,void 0),t([c({type:String}),e(`design:type`,Object)],u.prototype,`modalHeight`,void 0),t([c({type:String}),e(`design:type`,Object)],u.prototype,`maxHeight`,void 0),u=t([s(`randstad-mfa-modal`)],u);export{u as MfaModal};
|
package/dist/components/Modal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";import t from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";import"./Icon.js";import{bodyM as n,titleS as r}from"../styles/fontStyles.js";import"./Button.js";import{focusStyles as i}from"../styles/focus.js";import{scrollbarStyles as a}from"../styles/scrollbar.js";import"./Notice.js";import{LitElement as o,css as s,html as c,nothing as l}from"lit";import{customElement as u,property as d,state as f}from"lit/decorators.js";let p=class extends o{constructor(...e){super(...e),this.open=!1,this.title=`Título del modal`,this.showNotice=!1,this.noticeType=`informative`,this.noticeMessage=``,this.noticeIcon=`info`,this.showPrimaryButton=!1,this.primaryButtonLabel=`Aceptar`,this.showSecondaryButton=!1,this.secondaryButtonLabel=`Cancelar`,this.isFooterCustom=!1,this.isPrimaryLoader=!1,this.isPrimaryDisabled=!1,this.modalWidth=`500px`,this.modalHeight=`80dvh`,this.maxHeight=`90dvh`,this.hideFooter=!1,this.scrollable=!1,this.hasDropdownOpen=!1,this.hasCalendarOpen=!1,this.handleDropdownOpen=e=>{let t=e.detail;this.hasDropdownOpen=t&&typeof t.open==`boolean`?t.open:!0},this.handleCalendarOpen=e=>{let t=e.detail;this.hasCalendarOpen=t&&typeof t.open==`boolean`?t.open:!0},this.setScrollableMode=()=>{this.scrollable=window.innerWidth>940}}static{this.styles=[a,s`${i}:host{font-family:'Graphik',sans-serif;display:none
|
|
1
|
+
import e from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";import t from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";import"./Icon.js";import{bodyM as n,titleS as r}from"../styles/fontStyles.js";import"./Button.js";import{focusStyles as i}from"../styles/focus.js";import{scrollbarStyles as a}from"../styles/scrollbar.js";import"./Notice.js";import{LitElement as o,css as s,html as c,nothing as l}from"lit";import{customElement as u,property as d,state as f}from"lit/decorators.js";let p=class extends o{constructor(...e){super(...e),this.open=!1,this.title=`Título del modal`,this.showNotice=!1,this.noticeType=`informative`,this.noticeMessage=``,this.noticeIcon=`info`,this.showPrimaryButton=!1,this.primaryButtonLabel=`Aceptar`,this.showSecondaryButton=!1,this.secondaryButtonLabel=`Cancelar`,this.isFooterCustom=!1,this.isPrimaryLoader=!1,this.isPrimaryDisabled=!1,this.modalWidth=`500px`,this.modalHeight=`80dvh`,this.maxHeight=`90dvh`,this.hideFooter=!1,this.scrollable=!1,this.hasDropdownOpen=!1,this.hasCalendarOpen=!1,this.handleDropdownOpen=e=>{let t=e.detail;this.hasDropdownOpen=t&&typeof t.open==`boolean`?t.open:!0},this.handleCalendarOpen=e=>{let t=e.detail;this.hasCalendarOpen=t&&typeof t.open==`boolean`?t.open:!0},this.setScrollableMode=()=>{this.scrollable=window.innerWidth>940}}static{this.styles=[a,s`${i}:host{font-family:'Graphik',sans-serif;display:none}:host([open]){display:block;z-index:9999}.overlay{position:fixed;top:0;left:0;right:0;bottom:0;z-index:9999;display:flex;background:rgba(15,25,65,0.4);justify-content:center;align-items:center}.modal{width:100%;height:var(--modal-height);max-height:var(--modal-max-height);background:var(--brand-off-white);max-width:var(--modal-width);box-shadow:0 4px 12px rgba(0,0,0,0.15);display:flex;flex-direction:column;border-radius:8px;overflow:hidden}.modal-body{overflow-y:auto;flex:1}.modal-footer{justify-content:flex-end}.modal-footer.one-button randstad-button{width:100%}.modal-footer.two-buttons randstad-button{width:50%}@media (max-width:940px){.modal{width:100% !important;height:100% !important;max-width:none !important;max-height:none !important;margin:0 !important;border-radius:0 !important}.modal-header,.modal-body,.modal-footer{padding:0}}.modal-header{display:flex;flex-direction:column;gap:8px;justify-content:space-between;align-items:center;padding:16px;border-bottom:1px solid var(--secondary-color-20)}.modal-header-content{display:flex;gap:32px;width:100%;justify-content:space-between;align-items:center}.titles-container{display:flex;flex-direction:column;gap:8px;flex-grow:1}.modal-title{display:flex;justify-content:space-between;align-items:center;${r}font-style:regular;font-size:24px;line-height:32px;letter-spacing:-1px;margin:0;color:var(--secondary-color)}.modal-subtitle{${n}margin:0;color:var(--secondary-color-80,#404767)}.modal-header randstad-notice{width:100%}.modal-close{background:none;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;width:40px;height:40px;border-radius:50%;transition:background-color 0.2s ease}.modal-close:hover{background-color:var(--primary-color-10)}.modal-body{display:flex;flex-direction:column;padding:16px;gap:16px}slot[name="content"].has-dropdown-open{display:block;padding-bottom:40px}slot[name="content"].has-calendar-open{display:block;padding-bottom:160px}slot[name="content"].has-dropdown-open.has-calendar-open{padding-bottom:160px}.modal-footer{display:flex;padding:24px;gap:16px;border-top:1px solid var(--secondary-color-20)}@media (max-width:940px){.modal-close:hover{background-color:transparent}}@media (max-width:500px){.modal-body{padding:16px}}`]}closeModal(){this.dispatchEvent(new CustomEvent(`modal-close`))}connectedCallback(){super.connectedCallback(),this.setScrollableMode(),window.addEventListener(`resize`,this.setScrollableMode),this.addEventListener(`dropdown-toggle`,this.handleDropdownOpen),this.addEventListener(`calendar-toggle`,this.handleDropdownOpen),this.addEventListener(`dropdown-toggle-calendar`,this.handleCalendarOpen)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(`resize`,this.setScrollableMode),this.removeEventListener(`dropdown-toggle`,this.handleDropdownOpen),this.removeEventListener(`calendar-toggle`,this.handleDropdownOpen),this.removeEventListener(`dropdown-toggle-calendar`,this.handleCalendarOpen)}getFooterClass(){return this.isFooterCustom&&!this.showPrimaryButton&&!this.showSecondaryButton?`footer-custom`:this.showPrimaryButton&&this.showSecondaryButton?`two-buttons`:`one-button`}render(){return c`<div class="overlay" role="dialog" aria-modal="true"><div class="modal" style="--modal-width: ${this.modalWidth}; --modal-height: ${this.modalHeight}; --modal-max-height: ${this.maxHeight};"><div class="modal-header"><div class="modal-header-content"><div class="titles-container"><div class="modal-title">${this.title}<button class="modal-close" @click=${this.closeModal} aria-label="Cerrar modal"><randstad-icon name="close" size="24" .color=${`var( --primary-color )`} ></randstad-icon></button></div>${this.subtitle?c`<div class="modal-subtitle">${this.subtitle}</div>`:l}</div></div>${this.showNotice?c`<randstad-notice .open=${!0} .type=${this.noticeType} .icon=${this.noticeIcon} .message=${this.noticeMessage} ></randstad-notice>`:l}</div><div class="modal-body ${this.scrollable?`scrollable`:``}"><slot name="content" class="${this.hasDropdownOpen?`has-dropdown-open`:``} ${this.hasCalendarOpen?`has-calendar-open`:``}"></slot></div>${this.hideFooter?l:c`<div class="modal-footer ${this.getFooterClass()}">${this.isFooterCustom&&!this.showPrimaryButton&&!this.showSecondaryButton?c`<slot name="footer-custom"></slot> `:l} ${this.showSecondaryButton?c`<randstad-button variant="button-secondary" size="md" @click=${()=>this.dispatchEvent(new CustomEvent(`secondary-click`))} label=${this.secondaryButtonLabel} ></randstad-button>`:l} ${this.showPrimaryButton?c`<randstad-button variant="button-primary" size="md" @click=${()=>this.dispatchEvent(new CustomEvent(`primary-click`))} label=${this.primaryButtonLabel} .loader=${this.isPrimaryLoader} .disabled=${this.isPrimaryDisabled} ></randstad-button>`:l}</div>`}</div></div>`}};t([d({type:Boolean,reflect:!0}),e(`design:type`,Object)],p.prototype,`open`,void 0),t([d({type:String}),e(`design:type`,Object)],p.prototype,`title`,void 0),t([d({type:String}),e(`design:type`,String)],p.prototype,`subtitle`,void 0),t([d({type:Boolean}),e(`design:type`,Object)],p.prototype,`showNotice`,void 0),t([d({type:String}),e(`design:type`,String)],p.prototype,`noticeType`,void 0),t([d({type:String}),e(`design:type`,Object)],p.prototype,`noticeMessage`,void 0),t([d({type:String}),e(`design:type`,Object)],p.prototype,`noticeIcon`,void 0),t([d({type:Boolean}),e(`design:type`,Object)],p.prototype,`showPrimaryButton`,void 0),t([d({type:String}),e(`design:type`,Object)],p.prototype,`primaryButtonLabel`,void 0),t([d({type:Boolean}),e(`design:type`,Object)],p.prototype,`showSecondaryButton`,void 0),t([d({type:String}),e(`design:type`,Object)],p.prototype,`secondaryButtonLabel`,void 0),t([d({type:Boolean}),e(`design:type`,Object)],p.prototype,`isFooterCustom`,void 0),t([d({type:Boolean}),e(`design:type`,Object)],p.prototype,`isPrimaryLoader`,void 0),t([d({type:Boolean}),e(`design:type`,Object)],p.prototype,`isPrimaryDisabled`,void 0),t([d({type:String}),e(`design:type`,Object)],p.prototype,`modalWidth`,void 0),t([d({type:String}),e(`design:type`,Object)],p.prototype,`modalHeight`,void 0),t([d({type:String}),e(`design:type`,Object)],p.prototype,`maxHeight`,void 0),t([d({type:Boolean}),e(`design:type`,Object)],p.prototype,`hideFooter`,void 0),t([f(),e(`design:type`,Object)],p.prototype,`scrollable`,void 0),t([f(),e(`design:type`,Object)],p.prototype,`hasDropdownOpen`,void 0),t([f(),e(`design:type`,Object)],p.prototype,`hasCalendarOpen`,void 0),p=t([u(`custom-modal`)],p);export{p as CustomModal};
|
package/dist/components/Popup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";import t from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";import"./Icon.js";import{bodyM as n,titleXS as r,titleXXS as i}from"../styles/fontStyles.js";import"./Button.js";import{LitElement as a,css as o,html as s,nothing as c}from"lit";import{customElement as l,property as u}from"lit/decorators.js";let d=class extends a{constructor(...e){super(...e),this.open=!1,this.type=`default`,this.icon=`warning`,this.iconColor=`var(--primary-color)`,this.title=``,this.description=``,this.width=`400px`,this.height=``,this.buttonText=`Aceptar`,this.confirmText=`Sí`,this.cancelText=`No`,this.closeOnOutsideClick=!1,this.stackedActions=[],this._onBackgroundClick=e=>{if(!this.closeOnOutsideClick)return;let t=e.composedPath(),n=this.renderRoot.querySelector(`.popup`);n&&!t.includes(n)&&(this.dispatchEvent(new CustomEvent(`popup-close`,{detail:null})),this.open=!1)}}static{this.styles=o`:host{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);justify-content:center;align-items:center;font-family:"Graphik",sans-serif}:host([open]){display:flex}@media (max-width:500px){.popup{width:100%;margin:0px 25px}}@media (min-width:501px){.popup{width:var(--popup-width,358px);min-height:var(--popup-height,auto)}}.popup{background:var(--white);padding:24px;border-radius:16px;text-align:center;animation:fadeIn 0.2s ease-in-out;display:flex;flex-direction:column;gap:24px;align-items:center;box-sizing:border-box;width:var(--popup-width,358px);height:var(--popup-height,auto)}@keyframes fadeIn{from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:scale(1)}}.popup-content{display:flex;flex-direction:column;gap:
|
|
1
|
+
import e from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";import t from"../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";import"./Icon.js";import{bodyM as n,titleXS as r,titleXXS as i}from"../styles/fontStyles.js";import"./Button.js";import{LitElement as a,css as o,html as s,nothing as c}from"lit";import{customElement as l,property as u}from"lit/decorators.js";let d=class extends a{constructor(...e){super(...e),this.open=!1,this.type=`default`,this.icon=`warning`,this.iconColor=`var(--primary-color)`,this.title=``,this.description=``,this.width=`400px`,this.height=``,this.buttonText=`Aceptar`,this.confirmText=`Sí`,this.cancelText=`No`,this.closeOnOutsideClick=!1,this.stackedActions=[],this._onBackgroundClick=e=>{if(!this.closeOnOutsideClick)return;let t=e.composedPath(),n=this.renderRoot.querySelector(`.popup`);n&&!t.includes(n)&&(this.dispatchEvent(new CustomEvent(`popup-close`,{detail:null})),this.open=!1)}}static{this.styles=o`:host{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);justify-content:center;align-items:center;font-family:"Graphik",sans-serif}:host([open]){display:flex}@media (max-width:500px){.popup{width:100%;margin:0px 25px}}@media (min-width:501px){.popup{width:var(--popup-width,358px);min-height:var(--popup-height,auto)}}.popup{background:var(--white);padding:24px;border-radius:16px;text-align:center;animation:fadeIn 0.2s ease-in-out;display:flex;flex-direction:column;gap:24px;align-items:center;box-sizing:border-box;width:var(--popup-width,358px);height:var(--popup-height,auto)}@keyframes fadeIn{from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:scale(1)}}.popup-content{display:flex;flex-direction:column;gap:8px;width:100%}.titles-container{display:flex;flex-direction:column;gap:8px;align-items:center}.popup-title{${r}margin:0;color:var(--secondary-color-80)}.popup-description{${n}margin:0;color:var(--secondary-color-60)}.buttons-container{display:flex;gap:10px;width:100%}.buttons-container ::slotted(randstad-button),.buttons-container randstad-button{flex:1 1 50%}:host([type="stacked"]) .buttons-container{flex-direction:column;gap:12px}.popup-actions{display:flex;flex-direction:column;width:100%}.action-item{${i};display:flex;align-items:center;gap:16px;cursor:pointer;color:var(--secondary-color);padding:16px;border-radius:8px;transition:background 0.2s}.action-item:hover{background:var(--secondary-color-10,#f0f4ff)}.icon-circle{width:32px;height:32px;background:rgb(from var(--icon-color) r g b / 0.2);border-radius:50%;display:flex;align-items:center;justify-content:center}`}firstUpdated(){if(this.open){let e=this.renderRoot.querySelector(`randstad-button`);e&&e.focus()}this.addEventListener(`click`,this._onBackgroundClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`click`,this._onBackgroundClick)}closePopup(e){this.dispatchEvent(new CustomEvent(`popup-close`,{detail:e})),this.open=!1}render(){let e=this.width||this.height?`--popup-width: ${this.width||`400px`}; --popup-height: ${this.height||`auto`};`:``;return s`<div class="popup" role="dialog" aria-modal="true" style="${e}" ${this.type==="default"?c:s`aria-labelledby="popup-title"`} aria-describedby="popup-description" >${this.type!==`stacked`&&this.icon?s`<randstad-icon name=${this.icon} size="56px" color=${this.iconColor} />`:c}<div class="popup-content">${this.type==="default"?s` ${this.title?s`<h2 id="popup-title" class="popup-title">${this.title}</h2>`:c} ${this.description?s`<p id="popup-description" class="popup-description">${this.description}</p>`:c} `:this.type===`stacked`?s`<div class="popup-actions">${this.stackedActions.map(e=>s`<div class="action-item" @click=${()=>this.closePopup(e.value)} ><div class="icon-circle" style="--icon-color:${e.iconColor}"><randstad-icon name=${e.icon} size="24px" color=${e.iconColor} ></randstad-icon></div><span>${e.label}</span></div>`)}</div>`:s`<div class="titles-container"><h2 id="popup-title" class="popup-title">${this.title}</h2>${this.description?s`<p id="popup-description" class="popup-description">${this.description}</p>`:c}</div>`}</div>${this.type===`stacked`?c:s`<div class="buttons-container">${this.type==="default"?s`<randstad-button variant="button-primary" size="md" @click=${()=>this.closePopup(!0)} label=${this.buttonText} ></randstad-button>`:s`<randstad-button variant="button-secondary" size="md" @click=${()=>this.closePopup(!1)} label=${this.cancelText} ></randstad-button><randstad-button variant="button-primary" size="md" @click=${()=>this.closePopup(!0)} label=${this.confirmText} ></randstad-button>`}</div>`}</div>`}};t([u({type:Boolean,reflect:!0}),e(`design:type`,Object)],d.prototype,`open`,void 0),t([u({type:String}),e(`design:type`,String)],d.prototype,`type`,void 0),t([u({type:String}),e(`design:type`,Object)],d.prototype,`icon`,void 0),t([u({type:String}),e(`design:type`,Object)],d.prototype,`iconColor`,void 0),t([u({type:String}),e(`design:type`,Object)],d.prototype,`title`,void 0),t([u({type:String}),e(`design:type`,Object)],d.prototype,`description`,void 0),t([u({type:String}),e(`design:type`,Object)],d.prototype,`width`,void 0),t([u({type:String}),e(`design:type`,Object)],d.prototype,`height`,void 0),t([u({type:String}),e(`design:type`,Object)],d.prototype,`buttonText`,void 0),t([u({type:String}),e(`design:type`,Object)],d.prototype,`confirmText`,void 0),t([u({type:String}),e(`design:type`,Object)],d.prototype,`cancelText`,void 0),t([u({type:Boolean}),e(`design:type`,Object)],d.prototype,`closeOnOutsideClick`,void 0),t([u({type:Array}),e(`design:type`,Array)],d.prototype,`stackedActions`,void 0),d=t([l(`custom-popup`)],d);export{d as CustomPopup};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./Icon.js";import{bodyS as e}from"../styles/fontStyles.js";import t from"../styles/globalStyles.js";import{LitElement as n,css as r,html as i}from"lit";var a=class extends n{static{this.styles=[t,r`:host{display:flex;position:fixed;align-items:center;max-width:100dvw;height:auto;z-index:9997}:host([position="top-left"]){top:16px;left:16px;right:auto;transform:none;justify-content:flex-start}:host([position="top-center"]){top:16px;left:50%;transform:translateX(-50%);justify-content:center}:host([position="top-right"]){top:16px;right:16px;left:auto;transform:none;justify-content:flex-end}:host([position="bottom-left"]){bottom:16px;left:16px;right:auto;transform:none;justify-content:flex-start}:host([position="bottom-center"]){bottom:16px;left:50%;transform:translateX(-50%);justify-content:center}:host([position="bottom-right"]){bottom:16px;right:16px;left:auto;transform:none;justify-content:flex-end}:host(.mobile){bottom:16px !important;top:auto !important;left:50% !important;transform:translateX(-50%) !important;justify-content:center !important;width:100%}:host(.mobile) .container{width:90dvw !important}:host(.navbar-visible)[position="bottom-left"],:host(.navbar-visible)[position="bottom-center"],:host(.navbar-visible)[position="bottom-right"]{bottom:calc(100px)}:host(.navbar-visible.mobile){bottom:calc(100px) !important}.container{${e};display:flex;align-items:center;box-sizing:border-box;min-height:48px;width:401px;border-radius:4px;padding:8px;gap:8px;white-space:nowrap;color:var(--white)}.message{display
|
|
1
|
+
import"./Icon.js";import{bodyS as e}from"../styles/fontStyles.js";import t from"../styles/globalStyles.js";import{LitElement as n,css as r,html as i}from"lit";var a=class extends n{static{this.styles=[t,r`:host{display:flex;position:fixed;align-items:center;max-width:100dvw;height:auto;z-index:9997}:host([position="top-left"]){top:16px;left:16px;right:auto;transform:none;justify-content:flex-start}:host([position="top-center"]){top:16px;left:50%;transform:translateX(-50%);justify-content:center}:host([position="top-right"]){top:16px;right:16px;left:auto;transform:none;justify-content:flex-end}:host([position="bottom-left"]){bottom:16px;left:16px;right:auto;transform:none;justify-content:flex-start}:host([position="bottom-center"]){bottom:16px;left:50%;transform:translateX(-50%);justify-content:center}:host([position="bottom-right"]){bottom:16px;right:16px;left:auto;transform:none;justify-content:flex-end}:host(.mobile){bottom:16px !important;top:auto !important;left:50% !important;transform:translateX(-50%) !important;justify-content:center !important;width:100%}:host(.mobile) .container{width:90dvw !important}:host(.navbar-visible)[position="bottom-left"],:host(.navbar-visible)[position="bottom-center"],:host(.navbar-visible)[position="bottom-right"]{bottom:calc(100px)}:host(.navbar-visible.mobile){bottom:calc(100px) !important}.container{${e};display:flex;align-items:center;box-sizing:border-box;min-height:48px;width:401px;border-radius:4px;padding:8px;gap:8px;white-space:nowrap;color:var(--white)}.message{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;text-overflow:ellipsis;white-space:pre-wrap;max-height:calc(3 * 25px);line-height:25px;word-break:break-word;max-width:100%}.container{color:var(--white)}randstad-icon{color:var(--white)}randstad-icon svg{fill:var(--white)}.icon{font-size:18px}.hidden{display:none}.success{background-color:var(--ui-positive)}.error{background-color:var(--ui-negative)}.warning{background-color:var(--ui-warning)}.informative{background-color:var(--ui-informative)}`]}static get properties(){return{type:{type:String},icon:{type:String},message:{type:String},open:{type:Boolean},position:{type:String,reflect:!0}}}constructor(){super(),this.type=`informative`,this.icon=`info`,this.message=`Este es un mensaje.`,this.open=!1,this.position=`bottom-center`,this.isMobile=!1,this._navbarObserver=null,this.updateResponsiveStyles=this.updateResponsiveStyles.bind(this)}connectedCallback(){super.connectedCallback(),window.addEventListener(`resize`,this.updateResponsiveStyles),this.updateResponsiveStyles(),this.observeNavbar()}disconnectedCallback(){window.removeEventListener(`resize`,this.updateResponsiveStyles),this._navbarObserver&&=(this._navbarObserver.disconnect(),null),super.disconnectedCallback()}updateResponsiveStyles(){this.isMobile=window.innerWidth<=940,this.classList.toggle(`mobile`,this.isMobile),this.updateNavbarPosition()}updated(e){e.has(`position`)&&this.updateNavbarPosition()}isNavbarVisible(){let e=document.querySelector(`randstad-navbar`);return!(!e||e.hasAttribute(`hidden`)||window.innerWidth>940&&!e.hasAttribute(`desktop`))}updateNavbarPosition(){let e=this.isNavbarVisible(),t=this.position.startsWith(`bottom`),n=e&&(t||this.isMobile);this.classList.toggle(`navbar-visible`,n)}observeNavbar(){if(this._navbarObserver)return;let e=document.querySelector(`randstad-navbar`);e&&(this._navbarObserver=new MutationObserver(()=>this.updateNavbarPosition()),this._navbarObserver.observe(e,{attributes:!0,attributeFilter:[`hidden`,`desktop`]}))}render(){let e=this.type===`error`||this.type===`warning`?`alert`:`status`;return i`<div class="container ${this.open?``:`hidden`} ${this.type}" role="${e}" aria-live="polite" ><randstad-icon name=${this.icon} size="24px" color="white"></randstad-icon><span class="message">${this.message}</span></div>`}};customElements.define(`randstad-snackbar`,a);
|
package/dist/package.json
CHANGED