-
Notifications
You must be signed in to change notification settings - Fork 0
/
p-2cc1ddee.entry.js
5 lines (5 loc) · 16.9 KB
/
p-2cc1ddee.entry.js
1
2
3
4
5
/*!
* Built by BASIS
* Copyright BASIS International Ltd.
*/
import{r,c as o,h as t,H as i,g as c}from"./p-00e3df8e.js";import{D as e}from"./p-5440a118.js";import{h as a}from"./p-3e9fe89f.js";import{D as s,a as d,b as n}from"./p-b9ac3f72.js";import{S as h}from"./p-7ccdab1d.js";let l=0;const w=class{constructor(t){r(this,t),this.changedEvent=o(this,"dwc-changed",7),this.focusedEvent=o(this,"dwc-focused",7),this.blurredEvent=o(this,"dwc-blurred",7),this.validatedEvent=o(this,"dwc-validated",7),this.inputId="radio-"+ ++l,this.validationExpressionEngine=new e("BBjRadioButton<dwc-radio> Validation",["x","value","text","component","control","group"]),this.autoValidate=!0,this.autoValidateOnLoad=!1,this.autoWasValidated=!1,this.activation="manual",this.checked=!1,this.disabled=!1,this.expanse="m",this.hasFocus=!1,this.helperText=void 0,this.invalid=!1,this.invalidMessage=void 0,this.label=void 0,this.name="",this.readonly=!1,this.switch=!1,this.tabTraversable=0,this.required=!1,this.validator=void 0,this.validationIcon="dwc:info",this.validationPopoverDistance=6,this.validationPopoverSkidding=0,this.validationPopoverPlacement="bottom",this.validationStyle="popover",this.valid=!1,this.value=""}onCheckedChanged(r){this.check(r),this.autoValidate&&this.validate()}connectedCallback(){var r;this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleClick=this.handleClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),null===(r=this.slotsObserver)||void 0===r||r.connect()}disconnectedCallback(){var r;null===(r=this.slotsObserver)||void 0===r||r.disconnect()}componentWillLoad(){if(this.slotsObserver=new h(this.el,"helper-text"),this.checked){const r=this.getRadiosList().filter((r=>r.checked));this.checked&&r.length>0&&r.indexOf(this.el)<r.length-1&&(this.checked=!1)}}componentDidLoad(){null!=window.applyFocusVisiblePolyfill&&window.applyFocusVisiblePolyfill(this.el.shadowRoot),this.autoValidateOnLoad&&requestAnimationFrame((()=>this.validate()))}handleHostClick(r){r.isTrusted||this.handleClick(r)}handleClick(r){if(this.disableChangingCheckedTemporally)return void(this.disableChangingCheckedTemporally=!1);if(this.disabled||this.readonly)return r.preventDefault(),void r.stopPropagation();const o=this.checked;this.checked=!!this.getRadiosSiblingList().length||!this.checked,this.check(this.checked,!0),o!==this.checked&&this.fireChangedEvent()}async setFocus(){this.el.shadowRoot.activeElement!==this.$input&&(this.$input.disabled=this.disabled,this.$input.focus())}async removeFocus(){this.$input.blur()}async validate(){let r=!0,o=this.getRadiosList();if(0===o.length&&(o=[this.el]),this.validator){const t=!!this.checked,i=this.el;r=this.validationExpressionEngine.evaluate(this.validator,{x:t,value:t,text:t?"1":"0",component:i,control:i,group:{anyChecked:!!o.find((r=>r.checked)),radios:o}})}else o.find((r=>r.required))&&(r=!!o.find((r=>r.checked)));return o.forEach((o=>{o.invalid=!r,o.dispatchEvent(new CustomEvent("dwc-validated",{detail:r}))})),r||o.forEach((r=>r.valid=!1)),o.forEach((o=>{!r&&o.autoWasValidated&&(o.valid=!0)})),r}async getPart(r){return new Promise((o=>{o(this.el.shadowRoot.querySelector(`[part="${r}"]`))}))}getRadiosList(){if(!this.name)return[];const r=this.el.closest("form")||document.body;return Array.from(r.querySelectorAll("dwc-radio")).filter((r=>r.name===this.name))}getRadiosSiblingList(){return this.getRadiosList().filter((r=>r!==this.el))}check(r,o=!1){this.disabled||this.readonly||(r&&o&&this.getRadiosSiblingList().forEach((r=>{const o=r.checked;r.checked=!1,o&&r.dispatchEvent(new CustomEvent("dwc-changed",{bubbles:!0,cancelable:!0}))})),this.$input&&(this.$input.checked=r))}handleFocus(){this.hasFocus=!0,this.disabled||this.readonly||this.checked||"auto"!==this.activation||(this.checked=!0,this.fireChangedEvent(),this.disableChangingCheckedTemporally=!0),this.focusedEvent.emit()}handleBlur(){this.hasFocus=!1,this.blurredEvent.emit()}handleKeyDown(r){if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(r.key)){const o=this.getRadiosList().filter((r=>!r.disabled)),t=["ArrowUp","ArrowLeft"].includes(r.key)?-1:1;let i=o.indexOf(this.el)+t;i<0&&(i=o.length-1),i>o.length-1&&(i=0),o.length&&o[i]&&(o[i].setFocus(),"auto"===o[i].activation&&(this.getRadiosList().forEach((r=>{const o=r.checked;r.checked=!1,o&&r.dispatchEvent(new CustomEvent("dwc-changed"))})),o[i].checked=!0,o[i].dispatchEvent(new CustomEvent("dwc-changed")))),r.preventDefault()}}fireChangedEvent(){this.changedEvent.emit()}render(){var r;const o=this.invalid&&!!(this.invalidMessage&&this.invalidMessage.trim().length>0),c=(null===(r=this.helperText)||void 0===r?void 0:r.trim().length)>0||this.slotsObserver.hasContent("helper-text"),e=()=>t("input",{ref:r=>this.$input=r,id:this.inputId,type:"radio",part:"input",name:this.name,value:this.value,checked:this.checked,disabled:this.disabled,readonly:this.readonly,"aria-checked":this.checked?"true":"false",tabIndex:this.disabled?-1:this.tabTraversable,onClick:this.handleClick,onFocus:this.handleFocus,onBlur:this.handleBlur});return t(i,{class:a({BBjControl:!0,BBjRadioButton:!0,"bbj-disabled":this.disabled,"bbj-focused":this.hasFocus,"bbj-readonly":this.readonly,"bbj-checked":this.checked,"bbj-unchecked":!this.checked,"bbj-invalid":this.invalid,"bbj-valid":this.valid})},t("div",{part:"control",onKeyDown:this.handleKeyDown},this.switch?t(e,null):t("div",{part:"input-wrapper"},t("span",{part:"checked-icon"},t("svg",{part:"checked-icon-svg",viewBox:"0 0 16 16"},t("g",{stroke:"none","stroke-width":"1",fill:"red","fill-rule":"evenodd"},t("g",{fill:"currentColor"},t("circle",{cx:"8",cy:"8",r:"3.42857143"}))))),t(e,null)),t("label",{part:"label",htmlFor:this.inputId,innerHTML:this.label},t("slot",null)),o&&"popover"===this.validationStyle&&t(n,{invalidMessage:this.invalidMessage,icon:this.validationIcon,hasFocus:this.hasFocus,popoverDistance:this.validationPopoverDistance,popoverPlacement:this.validationPopoverPlacement,popoverSkidding:this.validationPopoverSkidding})),t(d,{helperText:this.helperText,visible:c}),o&&"inline"===this.validationStyle&&t(s,{invalidMessage:this.invalidMessage,icon:this.validationIcon}))}get el(){return c(this)}static get watchers(){return{checked:["onCheckedChanged"]}}};w.style='@media (prefers-reduced-motion: reduce){*,::before,::after{animation-delay:-1ms !important;animation-duration:1ms !important;animation-iteration-count:1 !important;background-attachment:initial !important;scroll-behavior:auto !important;transition-delay:0s !important;transition-duration:0s !important}}:host{box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:relative;-webkit-tap-highlight-color:transparent;text-size-adjust:100%}:host *,:host *::before,:host *::after{box-sizing:inherit}:host{--_dwc-radio-size:var(--dwc-radio-size, var(--dwc-size-3xs));--_dwc-switch-size:var(--dwc-switch-size, var(--dwc-size-3xs));--_dwc-switch-thumb-size:var(--dwc-switch-thumb-size, calc(var(--_dwc-switch-size) / 2));display:inline-block}:host(.focus-visible) [part=input-wrapper]{box-shadow:var(--dwc-radio-focus-ring, var(--dwc-focus-ring-default))}[part=control]{align-items:stretch;color:var(--dwc-radio-label-color, inherit);cursor:var(--dwc-cursor-click);display:inline-flex;height:auto;padding:var(--dwc-radio-padding, auto);position:relative;vertical-align:middle;width:auto}[part=control] *{cursor:var(--dwc-cursor-click)}:host(.bbj-reverse-order) [part=control]{flex-direction:row-reverse}:host([disabled]) [part=control]{cursor:var(--dwc-disabled-cursor);opacity:var(--dwc-disabled-opacity);user-select:none;pointer-events:none}:host([disabled]) [part=control] *{cursor:var(--dwc-disabled-cursor);user-select:none;pointer-events:none}[part=label]{align-items:center;align-self:flex-start;display:flex;gap:0.3rem;line-height:var(--dwc-font-line-height);margin-top:0;padding-left:var(--dwc-space-s);user-select:none}:host(.bbj-reverse-order) [part=label]{padding-left:0;padding-right:var(--dwc-space-s)}:host(.bbj-whitespace-nowrap) [part=label]{white-space:nowrap}:host(:not([switch])) [part=input-wrapper]{align-items:center;align-self:flex-start;background-color:transparent;block-size:var(--_dwc-radio-size);border:var(--dwc-border-width) var(--dwc-border-style) transparent;border-radius:50%;box-sizing:content-box;color:transparent;display:flex;flex-shrink:0;height:var(--_dwc-radio-size);inline-size:var(--_dwc-radio-size);justify-content:center;position:relative;transition:var(--dwc-transition) border-color, var(--dwc-transition) background-color;width:var(--_dwc-radio-size)}:host(:not([switch])) [part=input],:host(:not([switch])) [part=checked-icon]{margin:0;padding:0;position:absolute}:host(:not([switch])) [part=input]{opacity:0}:host(:not([switch])) [part=checked-icon]{display:inline-flex;height:100%;height:var(--_dwc-radio-size);opacity:0;transform:scale(0) translate3d(0, 0, 0);transition:transform var(--dwc-transition-medium) var(--dwc-ease-inQutCubic);width:100%;width:var(--_dwc-radio-size);will-change:transform;}:host(:not([switch])) [part=checked-icon] svg{height:100%;width:100%}:host([checked]:not([switch])) [part=checked-icon]{opacity:1;transform:scale(1) translate3d(0, 0, 0)}:host(:not([switch])) [part=input-wrapper]{background-color:var(--dwc-radio-background, var(--dwc-color-default));border-color:var(--dwc-radio-border-color, var(--dwc-color-default-dark))}:host([has-focus]:not([switch])) [part=input-wrapper],:host(:hover:not([switch])) [part=input-wrapper]{background-color:var(--dwc-radio-hover-background, var(--dwc-color-default-light));border-color:var(--dwc-radio-hover-border-color, var(--dwc-color-primary))}:host([checked]:not([switch])) [part=input-wrapper]{background-color:var(--dwc-radio-checked-background, var(--dwc-color-primary));border-color:var(--dwc-radio-checked-border-color, var(--dwc-color-primary));color:var(--dwc-radio-checked-color, var(--dwc-color-on-primary-text))}:host([checked]:not([switch]):not([disabled]):hover) [part=input-wrapper],:host([checked]:not([switch]):not([disabled])) [part=input-wrapper]:hover,:host([checked][has-focus]:not([switch])) [part=input-wrapper],:host([checked]:not([switch]):not([disabled])) [part=input-wrapper]:focus{background-color:var(--dwc-radio-hover-checked-background, var(--dwc-color-primary-light));border-color:var(--dwc-radio-hover-checked-border-color, var(--dwc-color-primary));color:var(--dwc-radio-hover-checked-color, var(--dwc-color-on-primary-text-light))}:host([switch]) [part=label]{align-self:normal}:host([switch]) [part=input]{align-items:center;align-self:flex-start;appearance:none;background-color:var(--dwc-switch-background, var(--dwc-color-default));block-size:var(--_dwc-switch-thumb-size);border:var(--dwc-border-width) var(--dwc-border-style) var(--dwc-switch-border-color, var(--dwc-color-default-dark));border-radius:var(--dwc-switch-border-radius, var(--_dwc-switch-size));box-sizing:content-box;cursor:var(--dwc-cursor-click);display:flex;flex-shrink:0;inline-size:var(--_dwc-switch-size);margin:0;outline:none;padding:var(--dwc-switch-padding, 2px);position:relative;transition:var(--dwc-transition) background-color, var(--dwc-transition) border-color}:host([switch]) [part=input]::before{align-items:center;background-color:var(--dwc-switch-thumb-background, var(--dwc-color-white));block-size:var(--_dwc-switch-thumb-size);border-radius:var(--dwc-border-radius-round);box-shadow:var(--dwc-switch-thumb-shadow, var(--dwc-shadow-m));content:"";display:flex;grid-area:track;inline-size:var(--_dwc-switch-thumb-size);justify-content:center;transform:translateX(0);transition:var(--dwc-transition) background-color, var(--dwc-transition) transform, var(--dwc-transition) box-shadow, var(--dwc-transition) border;z-index:1}:host([switch]) [part=input]:checked{background-color:var(--dwc-switch-checked-background, var(--dwc-color-primary));border-color:var(--dwc-switch-checked-border-color, var(--dwc-switch-checked-background, var(--dwc-color-primary)));}:host([switch]) [part=input]:checked::before{transform:translateX(100%)}:host([switch]) [part=input].focus-visible{box-shadow:var(--dwc-switch-focus-ring, var(--dwc-focus-ring-default));}:host([switch]) [part=input].focus-visible:not(:checked){border-color:var(--dwc-switch-focus-border-color, var(--dwc-color-primary))}:host([has-focus][switch]) [part=input],:host(:hover[switch]) [part=input]{background-color:var(--dwc-switch-hover-background, var(--dwc-color-default-light));border-color:var(--dwc-switch-hover-border-color, var(--dwc-color-primary))}:host([checked][switch]) [part=input]{background-color:var(--dwc-switch-checked-background, var(--dwc-color-primary));color:var(--dwc-switch-checked-color, var(--dwc-color-on-primary-text))}:host([checked][switch]:not([disabled]):hover) [part=input],:host([checked][switch]:not([disabled])) [part=input]:hover,:host([checked][has-focus][switch]) [part=input],:host([checked][switch]:not([disabled])) [part=input]:focus{background-color:var(--dwc-switch-hover-checked-background, var(--dwc-color-primary-light));border-color:var(--dwc-switch-hover-checked-border-color, var(--dwc-color-primary));color:var(--dwc-switch-hover-checked-color, var(--dwc-color-on-primary-text-light))}:host(.focus-visible[switch]) [part=input]{box-shadow:var(--dwc-switch-focus-ring, var(--dwc-focus-ring-default))}dwc-alert{--dwc-alert-padding:var(--dwc-space-s) 0;margin-left:calc(var(--dwc-border-radius) / 4 + var(--dwc-border-width) * 2);text-align:left}:host([valid]),:host([invalid]){--dwc-icon-button-color:var(--dwc-input-color);--dwc-icon-button-hover-color:var(--dwc-icon-button-color);--dwc-icon-button-active-color:var(--dwc-icon-button-color)}:host([valid]:not([valid=false])){--dwc-input-label-color:var(--dwc-color-success-text);--dwc-input-label-hover-color:var(--dwc-color-success-text-light);--dwc-input-border-color:var(--dwc-color-success);--dwc-input-hover-border-color:var(--dwc-input-border-color);--dwc-input-focus-ring:var(--dwc-focus-ring-success);--dwc-input-placeholder-color:var(--dwc-color-gray-30);--dwc-input-selection-background:var(--dwc-color-success-light);--dwc-input-selection-color:var(--dwc-color-on-success-text-light);--dwc-input-required-field-indicator-color:var(--dwc-input-label-color)}:host([invalid]:not([invalid=false])){--dwc-input-label-color:var(--dwc-color-danger-text);--dwc-input-label-hover-color:var(--dwc-color-danger-text-light);--dwc-input-border-color:var(--dwc-color-danger);--dwc-input-hover-border-color:var(--dwc-input-border-color);--dwc-input-focus-ring:var(--dwc-focus-ring-danger);--dwc-input-placeholder-color:var(--dwc-color-gray-30);--dwc-input-selection-background:var(--dwc-color-danger-light);--dwc-input-selection-color:var(--dwc-color-on-danger-text-light);--dwc-alert-color:var(--dwc-input-label-color);--dwc-alert-icon-color:var(--dwc-alert-color);--dwc-input-required-field-indicator-color:var(--dwc-input-label-color)}[part=helper-text-wrapper],[part=helper-text-wrapper] ::slotted([slot=helper-text]){color:var(--dwc-color-gray-text-light);cursor:var(--dwc-cursor-text);font-size:var(--dwc-font-size-s);font-weight:var(--dwc-font-weight-normal);line-height:var(--dwc-font-line-height-s);text-align:left;transition:color 0.2s}[part=helper-text-wrapper][data-visible]{margin-left:calc(var(--dwc-border-radius) / 4 + var(--dwc-border-width) * 2);padding-top:var(--dwc-space-s)}[part=helper-text-wrapper][data-visible]{margin-left:calc(var(--dwc-border-radius) / 4 + var(--dwc-border-width) * 2)}:host([invalid]){--dwc-radio-label-color:var(--dwc-color-danger-text);--dwc-radio-border-color:var(--dwc-color-danger);--dwc-radio-checked-border-color:var(--dwc-radio-border-color);--dwc-radio-hover-border-color:var(--dwc-radio-border-color);--dwc-radio-hover-checked-border-color:var(--dwc-radio-border-color);--dwc-radio-focus-ring:var(--dwc-focus-ring-danger);--dwc-alert-color:var(--dwc-radio-label-color);--dwc-alert-icon-color:var(--dwc-alert-color);--dwc-switch-border-color:var(--dwc-radio-border-color);--dwc-switch-hover-border-color:var(--dwc-radio-border-color);--dwc-switch-checked-border-color:var(--dwc-switch-border-color);--dwc-switch-hover-checked-border-color:var(--dwc-radio-border-color);--dwc-switch-focus-border-color:var(--dwc-switch-border-color);--dwc-switch-focus-ring:var(--dwc-focus-ring-danger)}:host([expanse=xl]){--_dwc-radio-size:var(--dwc-radio-size, calc(var(--dwc-size-xl) / 2));--_dwc-switch-size:var(--dwc-switch-size, calc(var(--dwc-size-xl)));font-size:var(--dwc-font-size-xl)}:host([expanse=l]){--_dwc-radio-size:var(--dwc-radio-size, calc(var(--dwc-size-l) / 2));--_dwc-switch-size:var(--dwc-switch-size, calc(var(--dwc-size-l)));font-size:var(--dwc-font-size-l)}:host([expanse=m]){--_dwc-radio-size:var(--dwc-radio-size, calc(var(--dwc-size-m) / 2));--_dwc-switch-size:var(--dwc-switch-size, calc(var(--dwc-size-m)));font-size:var(--dwc-font-size-m)}:host([expanse=s]){--_dwc-radio-size:var(--dwc-radio-size, calc(var(--dwc-size-s) / 2));--_dwc-switch-size:var(--dwc-switch-size, calc(var(--dwc-size-s)));font-size:var(--dwc-font-size-s)}:host([expanse=xs]){--_dwc-radio-size:var(--dwc-radio-size, calc(var(--dwc-size-xs) / 2));--_dwc-switch-size:var(--dwc-switch-size, calc(var(--dwc-size-xs)));font-size:var(--dwc-font-size-xs)}';export{w as dwc_radio}