@cas-smartdesign/radio-button-group 5.0.0 → 5.0.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.
package/dist/docs/doc.mjs
CHANGED
|
@@ -255,7 +255,7 @@ function onValueChange(value: string | undefined, selectedIndex: number) {
|
|
|
255
255
|
`,R=s({default:()=>z}),z={mainContent:F,description:I,css:P,initializer:{content:L,type:`typescript`,initialize:()=>j(()=>import(`./5_segmented_button.js`),[],import.meta.url)}},B=globalThis,ee=B.ShadowRoot&&(B.ShadyCSS===void 0||B.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,te=Symbol(),ne=new WeakMap,re=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==te)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(ee&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=ne.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&ne.set(t,e))}return e}toString(){return this.cssText}},ie=e=>new re(typeof e==`string`?e:e+``,void 0,te),ae=(e,...t)=>new re(e.length===1?e[0]:t.reduce((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if(typeof e==`number`)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: `+e+`. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)})(n)+e[r+1],e[0]),e,te),oe=(e,t)=>{if(ee)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=B.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},se=ee?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return ie(t)})(e):e,{is:ce,defineProperty:le,getOwnPropertyDescriptor:ue,getOwnPropertyNames:de,getOwnPropertySymbols:fe,getPrototypeOf:pe}=Object,me=globalThis,he=me.trustedTypes,ge=he?he.emptyScript:``,_e=me.reactiveElementPolyfillSupport,ve=(e,t)=>e,ye={toAttribute(e,t){switch(t){case Boolean:e=e?ge:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},V=(e,t)=>!ce(e,t),be={attribute:!0,type:String,converter:ye,reflect:!1,useDefault:!1,hasChanged:V};Symbol.metadata??=Symbol(`metadata`),me.litPropertyMetadata??=new WeakMap;var H=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=be){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&le(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=ue(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??be}static _$Ei(){if(this.hasOwnProperty(ve(`elementProperties`)))return;let e=pe(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(ve(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ve(`properties`))){let e=this.properties,t=[...de(e),...fe(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(se(e))}else e!==void 0&&t.push(se(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return oe(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?ye:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?ye:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??V)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};H.elementStyles=[],H.shadowRootOptions={mode:`open`},H[ve(`elementProperties`)]=new Map,H[ve(`finalized`)]=new Map,_e?.({ReactiveElement:H}),(me.reactiveElementVersions??=[]).push(`2.1.2`);var xe=globalThis,Se=e=>e,Ce=xe.trustedTypes,we=Ce?Ce.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,Te=`$lit$`,U=`lit$${Math.random().toFixed(9).slice(2)}$`,Ee=`?`+U,De=`<${Ee}>`,W=document,Oe=()=>W.createComment(``),ke=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Ae=Array.isArray,je=e=>Ae(e)||typeof e?.[Symbol.iterator]==`function`,Me=`[
|
|
256
256
|
\f\r]`,Ne=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Pe=/-->/g,G=/>/g,K=RegExp(`>|${Me}(?:([^\\s"'>=/]+)(${Me}*=${Me}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),Fe=/'/g,Ie=/"/g,Le=/^(?:script|style|textarea|title)$/i,Re=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),ze=Symbol.for(`lit-noChange`),q=Symbol.for(`lit-nothing`),Be=new WeakMap,Ve=W.createTreeWalker(W,129);function He(e,t){if(!Ae(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return we===void 0?t:we.createHTML(t)}var Ue=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=Ne;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===Ne?c[1]===`!--`?o=Pe:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=K):(Le.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=K):o=G:o===K?c[0]===`>`?(o=i??Ne,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?K:c[3]===`"`?Ie:Fe):o===Ie||o===Fe?o=K:o===Pe||o===G?o=Ne:(o=K,i=void 0);let d=o===K&&e[t+1].startsWith(`/>`)?` `:``;a+=o===Ne?n+De:l>=0?(r.push(s),n.slice(0,l)+Te+n.slice(l)+U+d):n+U+(l===-2?t:d)}return[He(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},We=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=Ue(t,n);if(this.el=e.createElement(l,r),Ve.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=Ve.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(Te)){let t=u[o++],n=i.getAttribute(e).split(U),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?Ye:r[1]===`?`?Xe:r[1]===`@`?Ze:Je}),i.removeAttribute(e)}else e.startsWith(U)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(Le.test(i.tagName)){let e=i.textContent.split(U),t=e.length-1;if(t>0){i.textContent=Ce?Ce.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],Oe()),Ve.nextNode(),c.push({type:2,index:++a});i.append(e[t],Oe())}}}else if(i.nodeType===8)if(i.data===Ee)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(U,e+1))!==-1;)c.push({type:7,index:a}),e+=U.length-1}a++}}static createElement(e,t){let n=W.createElement(`template`);return n.innerHTML=e,n}};function Ge(e,t,n=e,r){if(t===ze)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=ke(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=Ge(e,i._$AS(e,t.values),i,r)),t}var Ke=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??W).importNode(t,!0);Ve.currentNode=r;let i=Ve.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new qe(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new Qe(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=Ve.nextNode(),a++)}return Ve.currentNode=W,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},qe=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=q,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Ge(this,e,t),ke(e)?e===q||e==null||e===``?(this._$AH!==q&&this._$AR(),this._$AH=q):e!==this._$AH&&e!==ze&&this._(e):e._$litType$===void 0?e.nodeType===void 0?je(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==q&&ke(this._$AH)?this._$AA.nextSibling.data=e:this.T(W.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=We.createElement(He(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new Ke(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=Be.get(e.strings);return t===void 0&&Be.set(e.strings,t=new We(e)),t}k(t){Ae(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(Oe()),this.O(Oe()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=Se(e).nextSibling;Se(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},Je=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=q,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=q}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=Ge(this,e,t,0),a=!ke(e)||e!==this._$AH&&e!==ze,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=Ge(this,r[n+o],t,o),s===ze&&(s=this._$AH[o]),a||=!ke(s)||s!==this._$AH[o],s===q?e=q:e!==q&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===q?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},Ye=class extends Je{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===q?void 0:e}},Xe=class extends Je{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==q)}},Ze=class extends Je{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=Ge(this,e,t,0)??q)===ze)return;let n=this._$AH,r=e===q&&n!==q||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==q&&(n===q||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},Qe=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Ge(this,e)}},$e=xe.litHtmlPolyfillSupport;$e?.(We,qe),(xe.litHtmlVersions??=[]).push(`3.3.2`);var et=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new qe(t.insertBefore(Oe(),e),e,void 0,n??{})}return i._$AI(e),i},tt=globalThis,nt=class extends H{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=et(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ze}};nt._$litElement$=!0,nt.finalized=!0,tt.litElementHydrateSupport?.({LitElement:nt});var rt=tt.litElementPolyfillSupport;rt?.({LitElement:nt}),(tt.litElementVersions??=[]).push(`4.2.2`);var it={attribute:!0,type:String,converter:ye,reflect:!1,hasChanged:V},at=(e=it,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function J(e){return(t,n)=>typeof n==`object`?at(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}var ot=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2012%2012'%3e%3cstyle%20id='style3'%3e%20.st0{fill:%23fff}.st1{fill:%23c00}%20%3c/style%3e%3cg%20id='g5'%3e%3cpath%20class='st1'%20d='M6%20.9c2.8%200%205.1%202.3%205.1%205.1S8.8%2011.1%206%2011.1.9%208.8.9%206%203.2.9%206%20.9m0-1C2.7-.1-.1%202.7-.1%206s2.7%206.1%206.1%206.1%206.1-2.7%206.1-6.1S9.3-.1%206-.1z'%20id='path9'/%3e%3c/g%3e%3cg%20id='g11'%3e%3cpath%20class='st0'%20id='rect13'%20d='M5.5%202.5h1v4h-1z'/%3e%3cpath%20class='st1'%20d='M6%203v3-3m1-1H5v5h2V2z'%20id='path15'/%3e%3c/g%3e%3cg%20id='g17'%3e%3cpath%20class='st0'%20id='rect19'%20d='M5.5%208.5h1v1h-1z'/%3e%3cpath%20class='st1'%20id='polygon21'%20d='M7%208H5v2h2V8z'/%3e%3c/g%3e%3c/svg%3e`,st=`:host{font-size:var(--sd-field-validation-message-font-size,13px);line-height:var(--sd-field-validation-message-line-height,20px);font-family:var(--sd-field-validation-message-font-family,"Segoe UI", "Lucida Sans", Arial, sans-serif);color:var(--sd-field-validation-message-color,#111);contain:content;display:inline-block}:host([hidden]){display:none!important}:host([level=warn i]){color:var(--sd-field-validation-message-warn-color,#555)}:host([level=suggest i]){color:var(--sd-field-validation-message-suggest-color,#bf8800)}:host([level=error i]){color:var(--sd-field-validation-message-error-color,#cc0017)}.icon{width:12px;height:12px;margin-bottom:-1px;padding-right:4px}`,ct=`data:image/svg+xml,%3csvg%20id='Ebene_1'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cstyle%3e%20.st0{fill:%23bf8800}%20%3c/style%3e%3cpath%20class='st0'%20d='M12%20.8l11%2019.8v1.3H1v-1.3L12%20.8zm.8-.6h-1.6L0%2020v3h24v-3L12.8.2z'/%3e%3cpath%20class='st0'%20d='M11%208h2v8h-2zm0%2010h2v2h-2z'/%3e%3c/svg%3e`,lt=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2012%2012'%3e%3cpath%20class='st1'%20d='M6%20.9c2.8%200%205.1%202.3%205.1%205.1S8.8%2011.1%206%2011.1.9%208.8.9%206%203.2.9%206%20.9m0-1C2.7-.1-.1%202.7-.1%206s2.7%206.1%206.1%206.1%206.1-2.7%206.1-6.1S9.3-.1%206-.1z'%20fill='%23555'/%3e%3cpath%20d='M6%209V6v3m-1%201h2V5H5v5zm2-8H5v2h2z'%20class='st1'%20fill='%23555'/%3e%3c/svg%3e`;function ut(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function dt(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var ft={Warn:`warn`,Suggest:`suggest`,Error:`error`},pt=class e extends nt{static{this.ID=`sd-field-validation-message`}static{this.ensureDefined=()=>{customElements.get(e.ID)||customElements.define(e.ID,e)}}static parseLevel(e){if(e==null)return;let t=e.toLowerCase();return Object.values(ft).find(e=>e===t)}static{this.levelConverter={fromAttribute(t){return e.parseLevel(t)},toAttribute(e){return e?.toLowerCase()}}}static get styles(){return[ae`
|
|
257
257
|
${ie(st)}
|
|
258
|
-
`]}render(){return Re`${this.iconToUse&&Re`<img class="icon" src="${this.iconToUse}" />`}${this.message}`}get iconToUse(){return this.icon||this._defaultIconPath}shouldUpdate(e){return e.has(`level`)&&(this._defaultIconPath=this.iconForLevel,!this.icon)?!0:super.shouldUpdate(e)}get iconForLevel(){switch(e.parseLevel(this.level)){case ft.Warn:return lt;case ft.Suggest:return ct;case ft.Error:return ot;default:return}}};dt([J({type:String,attribute:!0}),ut(`design:type`,Object)],pt.prototype,`message`,void 0),dt([J({type:String,attribute:!0}),ut(`design:type`,Object)],pt.prototype,`icon`,void 0),dt([J({converter:pt.levelConverter,reflect:!0}),ut(`design:type`,Object)],pt.prototype,`level`,void 0),pt.ensureDefined();var mt=e=>e??q,ht=`:host{display:block}:host,.label,.checkbox{outline:none}:host([disabled]){pointer-events:none}:host([disabled]) .root{opacity:.6;cursor:default;filter:grayscale()}:host(:not([disabled])[focused]) .highlight,:host([checked]) circle.inner{display:block!important}:host([checked]) circle.outer{stroke:var(--sd-radio-button-checked-color,#1467ba)!important}:host([oneline]) .label{white-space:
|
|
258
|
+
`]}render(){return Re`${this.iconToUse&&Re`<img class="icon" src="${this.iconToUse}" />`}${this.message}`}get iconToUse(){return this.icon||this._defaultIconPath}shouldUpdate(e){return e.has(`level`)&&(this._defaultIconPath=this.iconForLevel,!this.icon)?!0:super.shouldUpdate(e)}get iconForLevel(){switch(e.parseLevel(this.level)){case ft.Warn:return lt;case ft.Suggest:return ct;case ft.Error:return ot;default:return}}};dt([J({type:String,attribute:!0}),ut(`design:type`,Object)],pt.prototype,`message`,void 0),dt([J({type:String,attribute:!0}),ut(`design:type`,Object)],pt.prototype,`icon`,void 0),dt([J({converter:pt.levelConverter,reflect:!0}),ut(`design:type`,Object)],pt.prototype,`level`,void 0),pt.ensureDefined();var mt=e=>e??q,ht=`:host{display:block}:host,.label,.checkbox{outline:none}:host([disabled]){pointer-events:none}:host([disabled]) .root{opacity:.6;cursor:default;filter:grayscale()}:host(:not([disabled])[focused]) .highlight,:host([checked]) circle.inner{display:block!important}:host([checked]) circle.outer{stroke:var(--sd-radio-button-checked-color,#1467ba)!important}:host([oneline]) .label{white-space:pre;text-overflow:ellipsis;overflow:hidden}.root{vertical-align:middle;width:100%;padding:var(--sd-radio-button-padding,6px 0px);align-items:center;display:inline-flex}.root .radio-button-container{box-sizing:border-box;cursor:pointer;flex-shrink:0;width:28px;height:28px;margin-right:5px;display:inline-block;position:relative}.root .radio-button-container input{opacity:0;position:absolute;top:0;left:0}.root .radio-button-container circle.highlight{stroke:var(--sd-radio-button-highlight-color,#1467ba4d)}.root .radio-button-container circle.inner{fill:var(--sd-radio-button-checked-color,#1467ba)}.root .radio-button-container circle.outer{stroke:var(--sd-radio-button-unchecked-color,#767676)}.root .label{font-family:var(--sd-radio-button-font-family,"Segoe UI", "Lucida Sans", Arial, sans-serif);text-overflow:ellipsis;-webkit-user-select:none;user-select:none;cursor:pointer;padding-top:2px;padding-bottom:2px;overflow-x:hidden}`;function Y(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function X(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var gt=0,_t=class e extends nt{static{this.ID=`sd-radio-button`}static{this.ensureDefined=()=>{customElements.get(e.ID)||customElements.define(e.ID,e)}}constructor(){super(),this.checked=!1,this.value=``,this.disabled=!1,this.label=``,this.handleClick=e=>{e.preventDefault()},this.a11yID=e.ID+`_`+ gt++}static get styles(){return[ae`
|
|
259
259
|
${ie(ht)}
|
|
260
260
|
`]}render(){return Re`
|
|
261
261
|
<div class="root">
|
|
@@ -3,7 +3,7 @@ import { LitElement as t, css as n, html as r, unsafeCSS as i } from "lit";
|
|
|
3
3
|
import { property as a } from "lit/decorators/property.js";
|
|
4
4
|
import { ifDefined as o } from "lit/directives/if-defined.js";
|
|
5
5
|
//#region scss/button.scss?inline
|
|
6
|
-
var s = ":host{display:block}:host,.label,.checkbox{outline:none}:host([disabled]){pointer-events:none}:host([disabled]) .root{opacity:.6;cursor:default;filter:grayscale()}:host(:not([disabled])[focused]) .highlight,:host([checked]) circle.inner{display:block!important}:host([checked]) circle.outer{stroke:var(--sd-radio-button-checked-color,#1467ba)!important}:host([oneline]) .label{white-space:
|
|
6
|
+
var s = ":host{display:block}:host,.label,.checkbox{outline:none}:host([disabled]){pointer-events:none}:host([disabled]) .root{opacity:.6;cursor:default;filter:grayscale()}:host(:not([disabled])[focused]) .highlight,:host([checked]) circle.inner{display:block!important}:host([checked]) circle.outer{stroke:var(--sd-radio-button-checked-color,#1467ba)!important}:host([oneline]) .label{white-space:pre;text-overflow:ellipsis;overflow:hidden}.root{vertical-align:middle;width:100%;padding:var(--sd-radio-button-padding,6px 0px);align-items:center;display:inline-flex}.root .radio-button-container{box-sizing:border-box;cursor:pointer;flex-shrink:0;width:28px;height:28px;margin-right:5px;display:inline-block;position:relative}.root .radio-button-container input{opacity:0;position:absolute;top:0;left:0}.root .radio-button-container circle.highlight{stroke:var(--sd-radio-button-highlight-color,#1467ba4d)}.root .radio-button-container circle.inner{fill:var(--sd-radio-button-checked-color,#1467ba)}.root .radio-button-container circle.outer{stroke:var(--sd-radio-button-unchecked-color,#767676)}.root .label{font-family:var(--sd-radio-button-font-family,\"Segoe UI\", \"Lucida Sans\", Arial, sans-serif);text-overflow:ellipsis;-webkit-user-select:none;user-select:none;cursor:pointer;padding-top:2px;padding-bottom:2px;overflow-x:hidden}";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region \0@oxc-project+runtime@0.122.0/helpers/decorateMetadata.js
|
|
9
9
|
function c(e, t) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-button-group.mjs","names":[],"sources":["../scss/button.scss?inline","../radio-button.ts","../scss/group.scss?inline","../radio-button-group.ts"],"sourcesContent":["@use \"@cas-smartdesign/styles/scss/variables/colors\";\n@use \"@cas-smartdesign/styles/scss/variables/typography\";\n\n:host {\n\tdisplay: block;\n}\n\n:host,\n.label,\n.checkbox {\n\toutline: none;\n}\n\n:host([disabled]) {\n\tpointer-events: none;\n\n\t.root {\n\t\topacity: 0.6;\n\t\tcursor: default;\n\t\tfilter: grayscale(100%);\n\t}\n}\n\n:host(:not([disabled])[focused]) .highlight {\n\tdisplay: block !important;\n}\n\n:host([checked]) {\n\tcircle.inner {\n\t\tdisplay: block !important;\n\t}\n\tcircle.outer {\n\t\tstroke: var(--sd-radio-button-checked-color, colors.$sd-blue) !important;\n\t}\n}\n\n:host([oneline]) .label {\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n}\n\n.root {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tvertical-align: middle;\n\twidth: 100%;\n\tpadding: var(--sd-radio-button-padding, 6px 0px);\n\n\t.radio-button-container {\n\t\tposition: relative;\n\t\tdisplay: inline-block;\n\t\twidth: 28px;\n\t\theight: 28px;\n\t\tbox-sizing: border-box;\n\t\tcursor: pointer;\n\t\tmargin-right: 5px;\n\t\tflex-shrink: 0;\n\n\t\tinput {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\topacity: 0;\n\t\t}\n\n\t\tcircle.highlight {\n\t\t\tstroke: var(--sd-radio-button-highlight-color, rgba(colors.$sd-blue, 0.3));\n\t\t}\n\t\tcircle.inner {\n\t\t\tfill: var(--sd-radio-button-checked-color, colors.$sd-blue);\n\t\t}\n\t\tcircle.outer {\n\t\t\tstroke: var(--sd-radio-button-unchecked-color, colors.$sd-grey);\n\t\t}\n\t}\n\n\t.label {\n\t\tfont-family: var(--sd-radio-button-font-family, typography.$sd-font-family);\n\t\ttext-overflow: ellipsis;\n\t\toverflow-x: hidden;\n\t\tuser-select: none;\n\t\tcursor: pointer;\n\t\tpadding-top: 2px;\n\t\tpadding-bottom: 2px;\n\t}\n}\n","import { LitElement, type TemplateResult, html, unsafeCSS, css } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButton.ID]: RadioButton;\n }\n}\n\nimport style from \"./scss/button.scss?inline\";\nlet idCounter = 0;\n\nexport class RadioButton extends LitElement {\n public static readonly ID = \"sd-radio-button\";\n public static ensureDefined = (): void => {\n if (!customElements.get(RadioButton.ID)) {\n customElements.define(RadioButton.ID, RadioButton);\n }\n };\n @property({ type: Boolean, reflect: true, attribute: true })\n public checked = false;\n @property({ type: String, reflect: true, attribute: true })\n public value = \"\";\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String, reflect: true, attribute: true })\n public label = \"\";\n\n private a11yID;\n\n constructor() {\n super();\n this.a11yID = RadioButton.ID + \"_\" + idCounter++;\n }\n\n static override get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n public override render(): TemplateResult {\n return html`\n <div class=\"root\">\n <div class=\"radio-button-container\">\n <input\n type=\"radio\"\n id=\"${this.a11yID}\"\n .checked=\"${this.checked}\"\n ?disabled=\"${this.disabled}\"\n @click=\"${this.handleClick}\"\n class=\"radio-button\"\n />\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-14 -14 28 28\">\n <circle\n class=\"highlight\"\n style=\"display:none\"\n r=\"11px\"\n fill=\"transparent\"\n stroke-width=\"6px\"\n ></circle>\n <circle class=\"inner\" r=\"6px\" style=\"display:none\" stroke=\"none\"></circle>\n <circle class=\"outer\" r=\"9px\" fill=\"transparent\" stroke-width=\"2px\"></circle>\n </svg>\n </div>\n <label class=\"label\" for=\"${this.a11yID}\" @click=\"${this.handleClick}\">${this.label}</label>\n </div>\n `;\n }\n\n private handleClick = (event: MouseEvent): void => {\n event.preventDefault();\n };\n}\n",":host(:focus) {\n\toutline: none;\n}\n\n.buttons-container {\n\tdisplay: flex;\n\tgap: var(--sd-radio-button-group-gap, 0);\n}\n\n.buttons-container.vertical {\n\tflex-direction: column;\n}\n\n.validation-message {\n\tmargin-left: 5px;\n}\n","import SDFieldValidationMessage, { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\nimport {\n LitElement,\n type TemplateResult,\n html,\n type PropertyValues,\n type ComplexAttributeConverter,\n unsafeCSS,\n css,\n} from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\n\nimport type { LayoutType, IValueChangeEvent } from \"./types\";\n\nimport { RadioButton } from \"./radio-button\";\n\nexport { RadioButton } from \"./radio-button\";\nexport type * from \"./types\";\n\nimport style from \"./scss/group.scss?inline\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButtonGroup.ID]: RadioButtonGroup;\n }\n interface HTMLElementEventMap {\n \"sd-radio-button-group-value-change\": CustomEvent<IValueChangeEvent>;\n }\n}\n\nexport class RadioButtonGroup extends LitElement {\n public static readonly ID = \"sd-radio-button-group\";\n public static ensureDefined = (): void => {\n RadioButton.ensureDefined();\n if (!customElements.get(RadioButtonGroup.ID)) {\n customElements.define(RadioButtonGroup.ID, RadioButtonGroup);\n }\n };\n @property({ type: String, reflect: true, attribute: true })\n public layout: LayoutType = \"horizontal\";\n @property({ type: String })\n public value: string | undefined = \"\";\n @property({ type: Boolean, reflect: true, attribute: \"uncheck-allowed\" })\n public uncheckAllowed = false;\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String })\n public validationMessage: string | undefined;\n @property({ type: String })\n public validationIconSrc: string | undefined;\n @property({\n type: {\n fromAttribute(value: string): ValidationLevel | undefined {\n return SDFieldValidationMessage.parseLevel(value);\n },\n toAttribute(value: ValidationLevel | undefined): string | undefined {\n return value != null ? value.toLowerCase() : undefined;\n },\n } as ComplexAttributeConverter,\n reflect: true,\n })\n public validationLevel: ValidationLevel | undefined;\n\n private _buttonsSlot: HTMLSlotElement | undefined;\n private _buttons: HTMLElement[] = [];\n private _focusIndex = -1;\n private _checkedButton: HTMLElement | undefined = undefined;\n\n public get focusIndex(): number {\n return this._focusIndex;\n }\n\n public set focusIndex(index: number) {\n if (index >= -1 && index < this.childElementCount) {\n const oldValue = this._focusIndex;\n this._focusIndex = index;\n if (oldValue !== index) {\n const previousButton = this._buttons[oldValue];\n const currentButton = this._buttons[this.focusIndex];\n this.updateFocused(previousButton, currentButton);\n }\n }\n }\n\n protected override firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.buttonsSlot!.addEventListener(\"slotchange\", this.handleSlotChange);\n this.addEventListener(\"focusin\", this.handleFocusIn);\n this.addEventListener(\"focusout\", this.handleFocusOut);\n this.addEventListener(\"keydown\", this.handleKeyDown);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has(\"disabled\")) {\n if (this.disabled) {\n this.disableButtons();\n } else {\n this.enableButtons();\n }\n }\n }\n\n static override get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n public override render(): TemplateResult {\n return html`\n <div\n class=\"buttons-container ${this.layout === \"vertical\" ? \"vertical\" : \"horizontal\"}\"\n @click=\"${ifDefined(this.disabled ? undefined : this.handleButtonClick)}\"\n >\n <slot></slot>\n </div>\n ${this.validationMessage &&\n html`\n <sd-field-validation-message\n class=\"validation-message\"\n .message=${this.validationMessage}\n .icon=${this.validationIconSrc}\n .level=${this.validationLevel}\n >\n </sd-field-validation-message>\n `}\n `;\n }\n\n private handleSlotChange = (): void => {\n this._buttons = this.buttonsSlot!.assignedElements() as HTMLElement[];\n this._buttons.forEach((button) => {\n if (!button.hasAttribute(\"disabled\") && this.disabled) {\n button.setAttribute(\"disabled\", \"\");\n }\n // prevent radio buttons to be able to get focus by tabbing\n // as focus is handled by this element\n button.setAttribute(\"tabIndex\", \"-1\");\n this.updateCheckedButton(button);\n });\n };\n\n private updateCheckedButton(button: HTMLElement): void {\n if (this._checkedButton && this._checkedButton !== button) {\n this.uncheckButton(button);\n } else if (button.hasAttribute(\"checked\")) {\n this._checkedButton = button;\n const value = button.getAttribute(\"value\");\n this.updateValue(value);\n }\n }\n\n private handleFocusIn = (event: FocusEvent): void => {\n const target = event.target as HTMLElement;\n const ind = this._buttons.findIndex((button) => button == target);\n this.focusIndex = this.focusIndex >= 0 ? this.focusIndex : this.getNextFocusIndex(ind !== -1 ? ind : 0);\n this.updateFocused(undefined, this._buttons[this.focusIndex]);\n };\n\n private handleFocusOut = (): void => {\n this.updateFocused(this._buttons[this.focusIndex]);\n };\n\n private disableButtons(): void {\n this._buttons?.forEach((button) => {\n button.setAttribute(\"disabled\", \"\");\n });\n }\n\n private enableButtons(): void {\n this._buttons?.forEach((button) => {\n button.removeAttribute(\"disabled\");\n });\n }\n\n private handleButtonClick = (event: MouseEvent): void => {\n // the individual buttons are not focusable\n this.focus();\n const target = this._buttons.find((button) => button.contains(event.target as Node));\n const targetIndex = this._buttons.findIndex((button) => button == target);\n if (targetIndex >= 0) {\n this.focusIndex = targetIndex;\n this.updateChecked();\n }\n };\n\n private fireValueChangeEvent(): void {\n this.dispatchEvent(\n new CustomEvent<IValueChangeEvent>(\"sd-radio-button-group-value-change\", {\n detail: {\n value: this.value,\n selectedIndex: this.selectedIndex,\n },\n }),\n );\n }\n\n private handleKeyDown = (event: KeyboardEvent): void => {\n let shouldPrevent = true;\n switch (event.key) {\n case \"Down\":\n case \"ArrowDown\":\n case \"Right\":\n case \"ArrowRight\": {\n this.focusNext();\n break;\n }\n case \"Up\":\n case \"ArrowUp\":\n case \"Left\":\n case \"ArrowLeft\": {\n this.focusPrevious();\n break;\n }\n case \"Enter\": {\n this.updateChecked();\n break;\n }\n default: {\n shouldPrevent = false;\n }\n }\n if (shouldPrevent) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n private focusNext() {\n const newIndex = this.getNextFocusIndex(this.focusIndex + 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getNextFocusIndex(0);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n }\n\n private focusPrevious() {\n const newIndex = this.getPreviousFocusIndex(this.focusIndex - 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getPreviousFocusIndex(this.childElementCount - 1);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n }\n\n private getNextFocusIndex(index: number): number {\n for (let i = index; i < this.childElementCount; i++) {\n const button = this._buttons[i];\n if (button != null && this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private getPreviousFocusIndex(index: number): number {\n for (let i = index; i >= 0; i--) {\n const button = this._buttons[i];\n if (button != null && this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private isFocusable(button: HTMLElement): boolean {\n return !button.hasAttribute(\"disabled\");\n }\n\n private updateChecked(): void {\n const previousChecked = this._checkedButton;\n const currentChecked = this._buttons[this.focusIndex];\n this._checkedButton = currentChecked;\n if (previousChecked && previousChecked !== currentChecked) {\n this.uncheckButton(previousChecked);\n }\n if (currentChecked) {\n this.toggleButton(currentChecked);\n }\n }\n\n private toggleButton(button: HTMLElement): void {\n const checked = button.hasAttribute(\"checked\");\n if (checked) {\n if (this.uncheckAllowed) {\n this.uncheckButton(button);\n this._checkedButton = undefined;\n this.updateValue(\"\");\n }\n } else {\n this.checkButton(button);\n this.updateValue(button.getAttribute(\"value\"));\n }\n }\n\n private updateValue(newValue: string | null | undefined): void {\n this.value = newValue ?? undefined;\n this.fireValueChangeEvent();\n }\n\n private updateFocused(previousFocused?: HTMLElement, currentFocused?: HTMLElement): void {\n previousFocused?.removeAttribute?.(\"focused\");\n currentFocused?.setAttribute?.(\"focused\", \"\");\n }\n\n private checkButton(button: HTMLElement): void {\n button.setAttribute(\"checked\", \"\");\n }\n\n private uncheckButton(button: HTMLElement): void {\n button.removeAttribute(\"checked\");\n }\n\n private get buttonsSlot(): HTMLSlotElement | undefined {\n if (this.shadowRoot && !this._buttonsSlot) {\n this._buttonsSlot = this.shadowRoot.querySelector(\"slot\") ?? undefined;\n }\n return this._buttonsSlot;\n }\n\n private get selectedIndex(): number {\n if (this._buttons == undefined || this._checkedButton == undefined) {\n return -1;\n }\n return this._buttons.indexOf(this._checkedButton);\n }\n}\n\nRadioButtonGroup.ensureDefined();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;ACUA,IAAI,IAAY,GAEH,IAAb,MAAa,UAAoB,EAAW;;YACZ;;;6BACc;AACtC,GAAK,eAAe,IAAI,EAAY,GAAG,IACnC,eAAe,OAAO,EAAY,IAAI,EAAY;;;CAc1D,cAAc;AAEV,EADA,OAAO,iBAXM,iBAEF,oBAEG,iBAEH,wBA8CQ,MAA4B;AAC/C,KAAM,gBAAgB;KAzCtB,KAAK,SAAS,EAAY,KAAK,MAAM;;CAGzC,WAAoB,SAAS;AACzB,SAAO,CACH,CAAG;kBACG,EAAU,EAAM,CAAC;cAE1B;;CAGL,SAAyC;AACrC,SAAO,CAAI;;;;;8BAKW,KAAK,OAAO;oCACN,KAAK,QAAQ;qCACZ,KAAK,SAAS;kCACjB,KAAK,YAAY;;;;;;;;;;;;;;;4CAeP,KAAK,OAAO,YAAY,KAAK,YAAY,IAAI,KAAK,MAAM;;;;;GAhD/F,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;CAAM,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,WAAA,KAAA,EAAA,KAE3D,EAAS;CAAE,MAAM;CAAQ,SAAS;CAAM,WAAW;CAAM,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,SAAA,KAAA,EAAA,KAE1D,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;CAAM,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,YAAA,KAAA,EAAA,KAE3D,EAAS;CAAE,MAAM;CAAQ,SAAS;CAAM,WAAW;CAAM,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,SA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AA,WAAA,qBAAA,KAAA,EAAA,KAE1B,EAAS,EAAE,MAAM,QAAQ,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,qBAAA,KAAA,EAAA,KAE1B,EAAS;CACN,MAAM;EACF,cAAc,GAA4C;AACtD,UAAO,EAAyB,WAAW,EAAM;;EAErD,YAAY,GAAwD;AAChE,UAAO,GAAsB,aAAa;;EAEjD;CACD,SAAS;CACZ,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,mBAAA,KAAA,EAAA,EA+QN,EAAiB,eAAe"}
|
|
1
|
+
{"version":3,"file":"radio-button-group.mjs","names":[],"sources":["../scss/button.scss?inline","../radio-button.ts","../scss/group.scss?inline","../radio-button-group.ts"],"sourcesContent":["@use \"@cas-smartdesign/styles/scss/variables/colors\";\n@use \"@cas-smartdesign/styles/scss/variables/typography\";\n\n:host {\n\tdisplay: block;\n}\n\n:host,\n.label,\n.checkbox {\n\toutline: none;\n}\n\n:host([disabled]) {\n\tpointer-events: none;\n\n\t.root {\n\t\topacity: 0.6;\n\t\tcursor: default;\n\t\tfilter: grayscale(100%);\n\t}\n}\n\n:host(:not([disabled])[focused]) .highlight {\n\tdisplay: block !important;\n}\n\n:host([checked]) {\n\tcircle.inner {\n\t\tdisplay: block !important;\n\t}\n\tcircle.outer {\n\t\tstroke: var(--sd-radio-button-checked-color, colors.$sd-blue) !important;\n\t}\n}\n\n:host([oneline]) .label {\n\twhite-space: pre;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n}\n\n.root {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tvertical-align: middle;\n\twidth: 100%;\n\tpadding: var(--sd-radio-button-padding, 6px 0px);\n\n\t.radio-button-container {\n\t\tposition: relative;\n\t\tdisplay: inline-block;\n\t\twidth: 28px;\n\t\theight: 28px;\n\t\tbox-sizing: border-box;\n\t\tcursor: pointer;\n\t\tmargin-right: 5px;\n\t\tflex-shrink: 0;\n\n\t\tinput {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\topacity: 0;\n\t\t}\n\n\t\tcircle.highlight {\n\t\t\tstroke: var(--sd-radio-button-highlight-color, rgba(colors.$sd-blue, 0.3));\n\t\t}\n\t\tcircle.inner {\n\t\t\tfill: var(--sd-radio-button-checked-color, colors.$sd-blue);\n\t\t}\n\t\tcircle.outer {\n\t\t\tstroke: var(--sd-radio-button-unchecked-color, colors.$sd-grey);\n\t\t}\n\t}\n\n\t.label {\n\t\tfont-family: var(--sd-radio-button-font-family, typography.$sd-font-family);\n\t\ttext-overflow: ellipsis;\n\t\toverflow-x: hidden;\n\t\tuser-select: none;\n\t\tcursor: pointer;\n\t\tpadding-top: 2px;\n\t\tpadding-bottom: 2px;\n\t}\n}\n","import { LitElement, type TemplateResult, html, unsafeCSS, css } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButton.ID]: RadioButton;\n }\n}\n\nimport style from \"./scss/button.scss?inline\";\nlet idCounter = 0;\n\nexport class RadioButton extends LitElement {\n public static readonly ID = \"sd-radio-button\";\n public static ensureDefined = (): void => {\n if (!customElements.get(RadioButton.ID)) {\n customElements.define(RadioButton.ID, RadioButton);\n }\n };\n @property({ type: Boolean, reflect: true, attribute: true })\n public checked = false;\n @property({ type: String, reflect: true, attribute: true })\n public value = \"\";\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String, reflect: true, attribute: true })\n public label = \"\";\n\n private a11yID;\n\n constructor() {\n super();\n this.a11yID = RadioButton.ID + \"_\" + idCounter++;\n }\n\n static override get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n public override render(): TemplateResult {\n return html`\n <div class=\"root\">\n <div class=\"radio-button-container\">\n <input\n type=\"radio\"\n id=\"${this.a11yID}\"\n .checked=\"${this.checked}\"\n ?disabled=\"${this.disabled}\"\n @click=\"${this.handleClick}\"\n class=\"radio-button\"\n />\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-14 -14 28 28\">\n <circle\n class=\"highlight\"\n style=\"display:none\"\n r=\"11px\"\n fill=\"transparent\"\n stroke-width=\"6px\"\n ></circle>\n <circle class=\"inner\" r=\"6px\" style=\"display:none\" stroke=\"none\"></circle>\n <circle class=\"outer\" r=\"9px\" fill=\"transparent\" stroke-width=\"2px\"></circle>\n </svg>\n </div>\n <label class=\"label\" for=\"${this.a11yID}\" @click=\"${this.handleClick}\">${this.label}</label>\n </div>\n `;\n }\n\n private handleClick = (event: MouseEvent): void => {\n event.preventDefault();\n };\n}\n",":host(:focus) {\n\toutline: none;\n}\n\n.buttons-container {\n\tdisplay: flex;\n\tgap: var(--sd-radio-button-group-gap, 0);\n}\n\n.buttons-container.vertical {\n\tflex-direction: column;\n}\n\n.validation-message {\n\tmargin-left: 5px;\n}\n","import SDFieldValidationMessage, { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\nimport {\n LitElement,\n type TemplateResult,\n html,\n type PropertyValues,\n type ComplexAttributeConverter,\n unsafeCSS,\n css,\n} from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\n\nimport type { LayoutType, IValueChangeEvent } from \"./types\";\n\nimport { RadioButton } from \"./radio-button\";\n\nexport { RadioButton } from \"./radio-button\";\nexport type * from \"./types\";\n\nimport style from \"./scss/group.scss?inline\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButtonGroup.ID]: RadioButtonGroup;\n }\n interface HTMLElementEventMap {\n \"sd-radio-button-group-value-change\": CustomEvent<IValueChangeEvent>;\n }\n}\n\nexport class RadioButtonGroup extends LitElement {\n public static readonly ID = \"sd-radio-button-group\";\n public static ensureDefined = (): void => {\n RadioButton.ensureDefined();\n if (!customElements.get(RadioButtonGroup.ID)) {\n customElements.define(RadioButtonGroup.ID, RadioButtonGroup);\n }\n };\n @property({ type: String, reflect: true, attribute: true })\n public layout: LayoutType = \"horizontal\";\n @property({ type: String })\n public value: string | undefined = \"\";\n @property({ type: Boolean, reflect: true, attribute: \"uncheck-allowed\" })\n public uncheckAllowed = false;\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String })\n public validationMessage: string | undefined;\n @property({ type: String })\n public validationIconSrc: string | undefined;\n @property({\n type: {\n fromAttribute(value: string): ValidationLevel | undefined {\n return SDFieldValidationMessage.parseLevel(value);\n },\n toAttribute(value: ValidationLevel | undefined): string | undefined {\n return value != null ? value.toLowerCase() : undefined;\n },\n } as ComplexAttributeConverter,\n reflect: true,\n })\n public validationLevel: ValidationLevel | undefined;\n\n private _buttonsSlot: HTMLSlotElement | undefined;\n private _buttons: HTMLElement[] = [];\n private _focusIndex = -1;\n private _checkedButton: HTMLElement | undefined = undefined;\n\n public get focusIndex(): number {\n return this._focusIndex;\n }\n\n public set focusIndex(index: number) {\n if (index >= -1 && index < this.childElementCount) {\n const oldValue = this._focusIndex;\n this._focusIndex = index;\n if (oldValue !== index) {\n const previousButton = this._buttons[oldValue];\n const currentButton = this._buttons[this.focusIndex];\n this.updateFocused(previousButton, currentButton);\n }\n }\n }\n\n protected override firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.buttonsSlot!.addEventListener(\"slotchange\", this.handleSlotChange);\n this.addEventListener(\"focusin\", this.handleFocusIn);\n this.addEventListener(\"focusout\", this.handleFocusOut);\n this.addEventListener(\"keydown\", this.handleKeyDown);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has(\"disabled\")) {\n if (this.disabled) {\n this.disableButtons();\n } else {\n this.enableButtons();\n }\n }\n }\n\n static override get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n public override render(): TemplateResult {\n return html`\n <div\n class=\"buttons-container ${this.layout === \"vertical\" ? \"vertical\" : \"horizontal\"}\"\n @click=\"${ifDefined(this.disabled ? undefined : this.handleButtonClick)}\"\n >\n <slot></slot>\n </div>\n ${this.validationMessage &&\n html`\n <sd-field-validation-message\n class=\"validation-message\"\n .message=${this.validationMessage}\n .icon=${this.validationIconSrc}\n .level=${this.validationLevel}\n >\n </sd-field-validation-message>\n `}\n `;\n }\n\n private handleSlotChange = (): void => {\n this._buttons = this.buttonsSlot!.assignedElements() as HTMLElement[];\n this._buttons.forEach((button) => {\n if (!button.hasAttribute(\"disabled\") && this.disabled) {\n button.setAttribute(\"disabled\", \"\");\n }\n // prevent radio buttons to be able to get focus by tabbing\n // as focus is handled by this element\n button.setAttribute(\"tabIndex\", \"-1\");\n this.updateCheckedButton(button);\n });\n };\n\n private updateCheckedButton(button: HTMLElement): void {\n if (this._checkedButton && this._checkedButton !== button) {\n this.uncheckButton(button);\n } else if (button.hasAttribute(\"checked\")) {\n this._checkedButton = button;\n const value = button.getAttribute(\"value\");\n this.updateValue(value);\n }\n }\n\n private handleFocusIn = (event: FocusEvent): void => {\n const target = event.target as HTMLElement;\n const ind = this._buttons.findIndex((button) => button == target);\n this.focusIndex = this.focusIndex >= 0 ? this.focusIndex : this.getNextFocusIndex(ind !== -1 ? ind : 0);\n this.updateFocused(undefined, this._buttons[this.focusIndex]);\n };\n\n private handleFocusOut = (): void => {\n this.updateFocused(this._buttons[this.focusIndex]);\n };\n\n private disableButtons(): void {\n this._buttons?.forEach((button) => {\n button.setAttribute(\"disabled\", \"\");\n });\n }\n\n private enableButtons(): void {\n this._buttons?.forEach((button) => {\n button.removeAttribute(\"disabled\");\n });\n }\n\n private handleButtonClick = (event: MouseEvent): void => {\n // the individual buttons are not focusable\n this.focus();\n const target = this._buttons.find((button) => button.contains(event.target as Node));\n const targetIndex = this._buttons.findIndex((button) => button == target);\n if (targetIndex >= 0) {\n this.focusIndex = targetIndex;\n this.updateChecked();\n }\n };\n\n private fireValueChangeEvent(): void {\n this.dispatchEvent(\n new CustomEvent<IValueChangeEvent>(\"sd-radio-button-group-value-change\", {\n detail: {\n value: this.value,\n selectedIndex: this.selectedIndex,\n },\n }),\n );\n }\n\n private handleKeyDown = (event: KeyboardEvent): void => {\n let shouldPrevent = true;\n switch (event.key) {\n case \"Down\":\n case \"ArrowDown\":\n case \"Right\":\n case \"ArrowRight\": {\n this.focusNext();\n break;\n }\n case \"Up\":\n case \"ArrowUp\":\n case \"Left\":\n case \"ArrowLeft\": {\n this.focusPrevious();\n break;\n }\n case \"Enter\": {\n this.updateChecked();\n break;\n }\n default: {\n shouldPrevent = false;\n }\n }\n if (shouldPrevent) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n private focusNext() {\n const newIndex = this.getNextFocusIndex(this.focusIndex + 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getNextFocusIndex(0);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n }\n\n private focusPrevious() {\n const newIndex = this.getPreviousFocusIndex(this.focusIndex - 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getPreviousFocusIndex(this.childElementCount - 1);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n }\n\n private getNextFocusIndex(index: number): number {\n for (let i = index; i < this.childElementCount; i++) {\n const button = this._buttons[i];\n if (button != null && this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private getPreviousFocusIndex(index: number): number {\n for (let i = index; i >= 0; i--) {\n const button = this._buttons[i];\n if (button != null && this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private isFocusable(button: HTMLElement): boolean {\n return !button.hasAttribute(\"disabled\");\n }\n\n private updateChecked(): void {\n const previousChecked = this._checkedButton;\n const currentChecked = this._buttons[this.focusIndex];\n this._checkedButton = currentChecked;\n if (previousChecked && previousChecked !== currentChecked) {\n this.uncheckButton(previousChecked);\n }\n if (currentChecked) {\n this.toggleButton(currentChecked);\n }\n }\n\n private toggleButton(button: HTMLElement): void {\n const checked = button.hasAttribute(\"checked\");\n if (checked) {\n if (this.uncheckAllowed) {\n this.uncheckButton(button);\n this._checkedButton = undefined;\n this.updateValue(\"\");\n }\n } else {\n this.checkButton(button);\n this.updateValue(button.getAttribute(\"value\"));\n }\n }\n\n private updateValue(newValue: string | null | undefined): void {\n this.value = newValue ?? undefined;\n this.fireValueChangeEvent();\n }\n\n private updateFocused(previousFocused?: HTMLElement, currentFocused?: HTMLElement): void {\n previousFocused?.removeAttribute?.(\"focused\");\n currentFocused?.setAttribute?.(\"focused\", \"\");\n }\n\n private checkButton(button: HTMLElement): void {\n button.setAttribute(\"checked\", \"\");\n }\n\n private uncheckButton(button: HTMLElement): void {\n button.removeAttribute(\"checked\");\n }\n\n private get buttonsSlot(): HTMLSlotElement | undefined {\n if (this.shadowRoot && !this._buttonsSlot) {\n this._buttonsSlot = this.shadowRoot.querySelector(\"slot\") ?? undefined;\n }\n return this._buttonsSlot;\n }\n\n private get selectedIndex(): number {\n if (this._buttons == undefined || this._checkedButton == undefined) {\n return -1;\n }\n return this._buttons.indexOf(this._checkedButton);\n }\n}\n\nRadioButtonGroup.ensureDefined();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;ACUA,IAAI,IAAY,GAEH,IAAb,MAAa,UAAoB,EAAW;;YACZ;;;6BACc;AACtC,GAAK,eAAe,IAAI,EAAY,GAAG,IACnC,eAAe,OAAO,EAAY,IAAI,EAAY;;;CAc1D,cAAc;AAEV,EADA,OAAO,iBAXM,iBAEF,oBAEG,iBAEH,wBA8CQ,MAA4B;AAC/C,KAAM,gBAAgB;KAzCtB,KAAK,SAAS,EAAY,KAAK,MAAM;;CAGzC,WAAoB,SAAS;AACzB,SAAO,CACH,CAAG;kBACG,EAAU,EAAM,CAAC;cAE1B;;CAGL,SAAyC;AACrC,SAAO,CAAI;;;;;8BAKW,KAAK,OAAO;oCACN,KAAK,QAAQ;qCACZ,KAAK,SAAS;kCACjB,KAAK,YAAY;;;;;;;;;;;;;;;4CAeP,KAAK,OAAO,YAAY,KAAK,YAAY,IAAI,KAAK,MAAM;;;;;GAhD/F,EAAS;CAAE,MAAM;CAAS,SAAS;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AA,UAAA,KAAA,EAAA,KAE1D,EAAS,EAAE,MAAM,QAAQ,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,SAAA,KAAA,EAAA,KAE1B,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;CAAmB,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,kBAAA,KAAA,EAAA,KAExE,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;CAAM,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,YAAA,KAAA,EAAA,KAE3D,EAAS,EAAE,MAAM,QAAQ,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,qBAAA,KAAA,EAAA,KAE1B,EAAS,EAAE,MAAM,QAAQ,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,qBAAA,KAAA,EAAA,KAE1B,EAAS;CACN,MAAM;EACF,cAAc,GAA4C;AACtD,UAAO,EAAyB,WAAW,EAAM;;EAErD,YAAY,GAAwD;AAChE,UAAO,GAAsB,aAAa;;EAEjD;CACD,SAAS;CACZ,CAAC,EAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,mBAAA,KAAA,EAAA,EA+QN,EAAiB,eAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cas-smartdesign/radio-button-group",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Radio button and radio button group elements with SmartDesign look & feel",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"files": [
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"@cas-smartdesign/styles": "^3.9.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@cas-smartdesign/element-preview": "^1.0.0",
|
|
25
24
|
"@cas-smartdesign/button": "^6.0.0",
|
|
26
|
-
"@cas-smartdesign/license-generator": "^1.10.0"
|
|
25
|
+
"@cas-smartdesign/license-generator": "^1.10.0",
|
|
26
|
+
"@cas-smartdesign/element-preview": "^1.0.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"version": "pnpm version",
|