@progress/kendo-themes-html
Version:
A collection of HTML helpers used for developing Kendo UI themes
2 lines (1 loc) • 8.35 kB
JavaScript
var d=(...t)=>t.filter(e=>e!==!0&&!!e).map(e=>Array.isArray(e)?d(...e):typeof e=="object"?Object.keys(e).map((r,l)=>e[l]||e[r]&&r||null).filter(r=>r!==null).join(" "):e).filter(e=>!!e).join(" ");var y=(t,e)=>d({[`${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"}),q=(t,e)=>{let{valid:r,invalid:l,hover:i,focus:c,checked:u,active:s,selected:h,disabled:g,indeterminate:p,loading:z,empty:b,readonly:A,highlighted:R,...T}=e;return d({"k-valid":r,"k-invalid":l,"k-hover":i,"k-focus":c,"k-checked":u,"k-active":s,"k-selected":h,"k-disabled":g,"k-indeterminate":p&&!u,"k-loading":z,"k-empty":b,"k-readonly":A,"k-highlighted":R},Object.keys(T).reduce((m,v)=>(v.startsWith("k-")?m[v]=T[v]:m[`k-${v}`]=T[v],m),{}))};function j(t,e){if(!e)return{};let r=Array.isArray(e)?e:[e];return Object.fromEntries(r.map(l=>[`k-${l}`,!0]))}var n={undefined:void 0,xsmall:"xsmall",small:"small",medium:"medium",large:"large",xlarge:"xlarge",xxlarge:"xxlarge",xxxlarge:"xxxlarge"},N={undefined:void 0,none:"none",small:"small",medium:"medium",large:"large",full:"full"},k={undefined:void 0,solid:"solid",flat:"flat",outline:"outline",clear:"clear",link:"link"},f={undefined:void 0,outline:"outline",solid:"solid",duotone:"duotone"},o={undefined:void 0,inherit:"inherit",base:"base",primary:"primary",secondary:"secondary",tertiary:"tertiary",info:"info",success:"success",warning:"warning",error:"error",inverse:"inverse"},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"};import{Fragment as fe,jsx as W}from"react/jsx-runtime";var K="k-font-icon",ue=[],me={size:[n.undefined,n.xsmall,n.small,n.medium,n.large,n.xlarge,n.xxlarge,n.xxxlarge],themeColor:[o.undefined,o.base,o.primary,o.secondary,o.tertiary,o.success,o.warning,o.error,o.info]},pe={},O=t=>{let{size:e,themeColor:r,icon:l,rotate:i,flip:c,...u}=t;return l?W("span",{...u,className:d(t.className,K,y(K,{size:e}),{[`k-i-${l}`]:l,[`k-color-${r}`]:r,[`k-rotate-${i}`]:i,"k-flip-h":c==="h"||c==="both","k-flip-v":c==="v"||c==="both"}),"aria-hidden":"true"}):W(fe,{})};O.states=ue;O.options=me;O.className=K;O.defaultOptions=pe;var J=O;import{Fragment as he,jsx as E}from"react/jsx-runtime";var F="k-svg-icon",xe=[],ge={size:[n.undefined,n.xsmall,n.small,n.medium,n.large,n.xlarge,n.xxlarge,n.xxxlarge],themeColor:[o.undefined,o.base,o.primary,o.secondary,o.tertiary,o.success,o.warning,o.error,o.info],variant:[f.outline,f.solid,f.duotone]},H={viewBox:"0 0 24 24",variant:f.outline},w=t=>{let{size:e,themeColor:r,rotate:l,flip:i,viewBox:c=H.viewBox,variant:u=H.variant,icon:s,...h}=t;if(!s)return E(he,{});if(s==="none")return E("span",{...h,className:d(t.className,F,y("k-icon",{size:e}),"k-none"),"aria-hidden":"true"});let g=typeof s=="object"&&s.name&&s.name,p=typeof s=="object"?u&&s.variants?.[u]||s.variants?.outline||s.content:void 0;return E("span",{...h,className:d(t.className,F,y("k-icon",{size:e}),{[`k-svg-i-${g}`]:g,[`k-color-${r}`]:r,[`k-rotate-${l}`]:l,"k-flip-h":i==="h"||i==="both","k-flip-v":i==="v"||i==="both"}),"aria-hidden":"true",children:E("svg",{"aria-hidden":!0,focusable:!1,xmlns:"http://www.w3.org/2000/svg",viewBox:typeof s=="object"?s.viewBox:c,dangerouslySetInnerHTML:p!==void 0?{__html:p}:void 0,children:s?void 0:t.children})})};w.states=xe;w.options=ge;w.className=F;w.defaultOptions=H;var P=w;import*as U from"@progress/kendo-svg-icons";var Q="icon",X="icons";import{useContext as ve}from"react";import{createContext as be}from"react";var Y=be({iconsType:"svg"});import{Fragment as Z,jsx as S}from"react/jsx-runtime";var L="k-icon",ye=t=>t.replace(/([-_][a-z0-9])/gi,e=>e.toUpperCase().replace("-","").replace("_","")),Ne=[],ke={size:[n.undefined,n.xsmall,n.small,n.medium,n.large,n.xlarge,n.xxlarge,n.xxxlarge],themeColor:[o.undefined,o.base,o.primary,o.secondary,o.tertiary,o.success,o.warning,o.error,o.info],variant:[f.outline,f.solid,f.duotone]},$={viewBox:"0 0 24 24",type:"svg",variant:f.outline},x=t=>{let{iconsType:e}=ve(Y),{size:r,themeColor:l,icon:i,type:c=e||$.type,rotate:u,flip:s,viewBox:h=$.viewBox,variant:g=$.variant,...p}=t;if(!i)return S(Z,{});if((e||c)==="svg"){if(i==="none")return S(P,{...p,className:d(t.className,L),icon:i,size:r,variant:g});let b=U[i]?i:ye(`${i}-icon`);return U[b]?S(P,{...p,className:d(t.className,L),icon:U[b],size:r,themeColor:l,rotate:u,flip:s,viewBox:h,variant:g}):S(Z,{})}return S(J,{...p,className:d(t.className,L),icon:i,size:r,themeColor:l,rotate:u,flip:s})};x.states=Ne;x.options=ke;x.defaultOptions=$;x.className=L;x.moduleName=Q;x.folderName=X;x.ariaSpec={selector:".k-icon, .k-svg-icon",rules:[{selector:".k-icon, .k-svg-icon",attribute:"aria-hidden=true",usage:"Hides the icon element and all its children from assistive technologies."}]};var D="button",ee=D;import{Fragment as te,jsx as I,jsxs as oe}from"react/jsx-runtime";var M="k-button",Ce=["icon-button"],Be=[C.hover,C.focus,C.active,C.selected,C.disabled,C.generating],Te={size:[n.undefined,n.xsmall,n.small,n.medium,n.large],rounded:[N.undefined,N.none,N.small,N.medium,N.large,N.full],fillMode:[k.undefined,k.solid,k.flat,k.outline,k.clear,k.link],themeColor:[o.undefined,o.base,o.primary,o.secondary,o.tertiary,o.success,o.warning,o.error,o.info,o.inverse]},V={showArrow:!1,arrowIconName:"chevron-down"},a=t=>{let{as:e="button",size:r,rounded:l,fillMode:i,themeColor:c,showArrow:u=V.showArrow,arrowIconName:s=V.arrowIconName,variant:h,hover:g,focus:p,active:z,selected:b,disabled:A,togglable:R,ariaDisabled:T,icon:m,iconSize:v,text:_,iconClassName:se,className:ae,...le}=t,de=m!=null,ce=t.children!==void 0;return oe(e,{className:d(ae,M,j(M,h),y(M,{size:r,rounded:l,fillMode:i,themeColor:c}),q(M,{hover:g,focus:p,active:z,disabled:A||T,selected:b}),{"k-icon-button":!_&&!ce&&de}),"aria-pressed":R?b?"true":"false":void 0,...le,"aria-disabled":T?"true":void 0,disabled:A||void 0,children:[typeof m=="string"&&m&&I(x,{className:d(se,"k-button-icon"),icon:m,size:v}),m&&typeof m!="string"&&I(te,{children:m}),_?oe(te,{children:[_&&I("span",{className:"k-button-text",children:_}),t.children]}):t.children&&I("span",{className:"k-button-text",children:t.children}),u&&I("span",{className:"k-menu-button-arrow k-button-arrow",children:I(x,{icon:s})})]})};a.states=Be;a.options=Te;a.variants=Ce;a.className=M;a.defaultOptions=V;a.moduleName=D;a.folderName=ee;a.ariaSpec={selector:".k-button",rules:[{selector:".k-button",attribute:"role=button or nodeName=button",usage:"The button role is implicit from the native <button> element."},{selector:".k-button",attribute:"aria-label (when icon-only)",usage:"Required for icon-only buttons that have no visible text."},{selector:".k-button",attribute:"aria-pressed (when togglable)",usage:"Indicates the pressed state of a toggle button."},{selector:".k-button",attribute:"disabled (when disabled)",usage:"Rendered when the button is disabled."}]};import{jsx as Ie}from"react/jsx-runtime";var ne=t=>Ie(a,{icon:"folder",...t,"aria-label":t["aria-label"]||"Folder",children:void 0});import{jsx as Oe}from"react/jsx-runtime";var re=t=>Oe(a,{icon:"folder",children:"Button",...t});import{jsx as we}from"react/jsx-runtime";var ie=t=>we(a,{children:"Button",...t});import{jsx as G}from"react/jsx-runtime";var Se=a.options,Me=a.states,ze={...a.defaultOptions,variant:"text"},Ae=[{name:"icon-only",title:"Icon Only"},{name:"icon-and-text",title:"Icon & Text"},{name:"text",title:"Text"}],_e=[],B=t=>{let{variant:e,...r}=t;switch(e){case"icon-only":return G(ne,{...r,icon:"star"});case"icon-and-text":return G(re,{...r,icon:"star",children:"Button"});default:return G(ie,{...r,children:"Button"})}};B.options=Se;B.states=Me;B.variants=Ae;B.defaultOptions=ze;B.modifiers=_e;B.className=a.className;var zt=B;export{B as ButtonDemo,zt as default};