@progress/kendo-themes-html
Version:
A collection of HTML helpers used for developing Kendo UI themes
2 lines (1 loc) • 4.83 kB
JavaScript
var v=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var _=(t,e)=>{for(var n in e)v(t,n,{get:e[n],enumerable:!0})},C=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of E(e))!K.call(t,s)&&s!==n&&v(t,s,{get:()=>e[s],enumerable:!(i=T(e,s))||i.enumerable});return t};var H=t=>C(v({},"__esModule",{value:!0}),t);var j={};_(j,{SwitchDisabled:()=>W});module.exports=H(j);var o=(...t)=>t.filter(e=>e!==!0&&!!e).map(e=>Array.isArray(e)?o(...e):typeof e=="object"?Object.keys(e).map((n,i)=>e[i]||e[n]&&n||null).filter(n=>n!==null).join(" "):e).filter(e=>!!e).join(" ");var k=(t,e)=>o({[`${t}-xs`]:e.size==="xsmall",[`${t}-sm`]:e.size==="small",[`${t}-md`]:e.size==="medium",[`${t}-lg`]:e.size==="large",[`${t}-xl`]:e.size==="xlarge",[`${t}-xxl`]:e.size==="xxlarge",[`${t}-xxxl`]:e.size==="xxxlarge"},{[`${t}-${e.fillMode}`]:e.fillMode},{[`${t}-${e.themeColor}`]:e.themeColor},{"k-rounded-sm":e.rounded==="small","k-rounded-md":e.rounded==="medium","k-rounded-lg":e.rounded==="large","k-rounded-full":e.rounded==="full","k-rounded-none":e.rounded==="none"}),M=(t,e)=>{let{valid:n,invalid:i,hover:s,focus:g,checked:f,active:w,selected:x,disabled:u,indeterminate:b,loading:p,empty:L,readonly:z,highlighted:O,...y}=e;return o({"k-valid":n,"k-invalid":i,"k-hover":s,"k-focus":g,"k-checked":f,"k-active":w,"k-selected":x,"k-disabled":u,"k-indeterminate":b&&!f,"k-loading":p,"k-empty":L,"k-readonly":z,"k-highlighted":O},Object.keys(y).reduce((S,h)=>(h.startsWith("k-")?S[h]=y[h]:S[`k-${h}`]=y[h],S),{}))};var m={undefined:void 0,xsmall:"xsmall",small:"small",medium:"medium",large:"large",xlarge:"xlarge",xxlarge:"xxlarge",xxxlarge:"xxxlarge"},a={undefined:void 0,none:"none",small:"small",medium:"medium",large:"large",full:"full"};var c={open:"open",hover:"hover",focus:"focus",active:"active",selected:"selected",disabled:"disabled",valid:"valid",invalid:"invalid",loading:"loading",required:"required",empty:"empty",indeterminate:"indeterminate",checked:"checked",readonly:"readonly",highlighted:"highlighted",generating:"generating",expanded:"expanded"};var R="switch",$=R;var l=require("react/jsx-runtime"),r="k-switch",I=[c.hover,c.focus,c.disabled,c.readonly,c.checked],q={size:[m.undefined,m.small,m.medium,m.large],trackRounded:[a.undefined,a.none,a.small,a.medium,a.large,a.full],thumbRounded:[a.undefined,a.none,a.small,a.medium,a.large,a.full]},D={},d=t=>{let{checked:e,onLabel:n,offLabel:i,size:s,trackRounded:g,thumbRounded:f,hover:w,focus:x,disabled:u,readonly:b,...p}=t;return(0,l.jsxs)("span",{...p,className:o(t.className,r,k(r,{size:s}),M(r,{hover:w,focus:x,disabled:u,readonly:b}),{[`${r}-on`]:e,[`${r}-off`]:!e}),role:"switch","aria-checked":e?"true":"false",tabIndex:u?void 0:0,"aria-disabled":u?"true":void 0,"aria-readonly":b?"true":void 0,children:[(0,l.jsxs)("span",{className:o("k-switch-track",k(r,{rounded:g})),children:[n&&(0,l.jsx)("span",{className:"k-switch-label-on",children:n}),i&&(0,l.jsx)("span",{className:"k-switch-label-off",children:i})]}),(0,l.jsx)("span",{className:"k-switch-thumb-wrap",children:(0,l.jsx)("span",{className:o("k-switch-thumb",k(r,{rounded:f}))})})]})};d.states=I;d.options=q;d.className=r;d.defaultOptions=D;d.moduleName=R;d.folderName=$;d.ariaSpec={selector:".k-switch",rules:[{selector:".k-switch",attribute:"role=switch",usage:"Announces the switch role of the element."},{selector:".k-switch",attribute:"label for or aria-label or aria-labelledby (when has accessible name)",usage:"The input requires an accessible name to which it will be assigned."},{selector:".k-switch",attribute:"aria-required=true (when required)",usage:'Rendered only when the Switch is in a form. Required because <span role="switch"> does not support the native required attribute.'},{selector:".k-switch",attribute:"aria-checked",usage:"Announces the checked state of the Switch."},{selector:".k-switch",attribute:"aria-describedby (when has hint or error)",usage:"Points to the hint or error message for the switch."},{selector:".k-switch",attribute:"aria-invalid=true (when invalid)",usage:"Rendered only when the Switch is in a form and announces the invalid state."},{selector:".k-switch:not(.k-disabled)",attribute:"tabindex=0",usage:"The element must be focusable. Disabled switches are removed from tab order."},{selector:".k-switch.k-disabled",attribute:"aria-disabled=true",usage:"Rendered only when the Switch is disabled."},{selector:".k-switch.k-readonly",attribute:"aria-readonly=true (when readonly)",usage:"Rendered only when the Switch is readonly. Readonly switches remain focusable but their value cannot be changed."}]};var N=d;var A=require("react/jsx-runtime"),W=t=>(0,A.jsx)(N,{disabled:!0,onLabel:"On",offLabel:"Off","aria-label":t["aria-label"]||"Disabled switch",...t});