UNPKG

@progress/kendo-themes-html

Version:

A collection of HTML helpers used for developing Kendo UI themes

2 lines (1 loc) 10.2 kB
var l=(...t)=>t.filter(e=>e!==!0&&!!e).map(e=>Array.isArray(e)?l(...e):typeof e=="object"?Object.keys(e).map((r,a)=>e[a]||e[r]&&r||null).filter(r=>r!==null).join(" "):e).filter(e=>!!e).join(" ");var A=(t,e)=>l({[`${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"}),Z=(t,e)=>{let{valid:r,invalid:a,hover:s,focus:c,checked:d,active:i,selected:y,disabled:g,indeterminate:v,loading:w,empty:N,readonly:I,highlighted:K,...E}=e;return l({"k-valid":r,"k-invalid":a,"k-hover":s,"k-focus":c,"k-checked":d,"k-active":i,"k-selected":y,"k-disabled":g,"k-indeterminate":v&&!d,"k-loading":w,"k-empty":N,"k-readonly":I,"k-highlighted":K},Object.keys(E).reduce((F,S)=>(S.startsWith("k-")?F[S]=E[S]:F[`k-${S}`]=E[S],F),{}))};var n={undefined:void 0,xsmall:"xsmall",small:"small",medium:"medium",large:"large",xlarge:"xlarge",xxlarge:"xxlarge",xxxlarge:"xxxlarge"},u={undefined:void 0,none:"none",small:"small",medium:"medium",large:"large",full:"full"},b={undefined:void 0,solid:"solid",flat:"flat",outline:"outline",clear:"clear",link:"link"},x={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"},h={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 xe,jsx as ee}from"react/jsx-runtime";var B="k-font-icon",fe=[],he={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]},ve={},T=t=>{let{size:e,themeColor:r,icon:a,rotate:s,flip:c,...d}=t;return a?ee("span",{...d,className:l(t.className,B,A(B,{size:e}),{[`k-i-${a}`]:a,[`k-color-${r}`]:r,[`k-rotate-${s}`]:s,"k-flip-h":c==="h"||c==="both","k-flip-v":c==="v"||c==="both"}),"aria-hidden":"true"}):ee(xe,{})};T.states=fe;T.options=he;T.className=B;T.defaultOptions=ve;var te=T;import{Fragment as ye,jsx as H}from"react/jsx-runtime";var U="k-svg-icon",ge=[],Ae={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:[x.outline,x.solid,x.duotone]},G={viewBox:"0 0 24 24",variant:x.outline},z=t=>{let{size:e,themeColor:r,rotate:a,flip:s,viewBox:c=G.viewBox,variant:d=G.variant,icon:i,...y}=t;if(!i)return H(ye,{});if(i==="none")return H("span",{...y,className:l(t.className,U,A("k-icon",{size:e}),"k-none"),"aria-hidden":"true"});let g=typeof i=="object"&&i.name&&i.name,v=typeof i=="object"?d&&i.variants?.[d]||i.variants?.outline||i.content:void 0;return H("span",{...y,className:l(t.className,U,A("k-icon",{size:e}),{[`k-svg-i-${g}`]:g,[`k-color-${r}`]:r,[`k-rotate-${a}`]:a,"k-flip-h":s==="h"||s==="both","k-flip-v":s==="v"||s==="both"}),"aria-hidden":"true",children:H("svg",{"aria-hidden":!0,focusable:!1,xmlns:"http://www.w3.org/2000/svg",viewBox:typeof i=="object"?i.viewBox:c,dangerouslySetInnerHTML:v!==void 0?{__html:v}:void 0,children:i?void 0:t.children})})};z.states=ge;z.options=Ae;z.className=U;z.defaultOptions=G;var X=z;import*as j from"@progress/kendo-svg-icons";var oe="icon",ne="icons";import{useContext as Ce}from"react";import{createContext as be}from"react";var ae=be({iconsType:"svg"});import{Fragment as re,jsx as _}from"react/jsx-runtime";var P="k-icon",ke=t=>t.replace(/([-_][a-z0-9])/gi,e=>e.toUpperCase().replace("-","").replace("_","")),Ne=[],Ie={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:[x.outline,x.solid,x.duotone]},$={viewBox:"0 0 24 24",type:"svg",variant:x.outline},m=t=>{let{iconsType:e}=Ce(ae),{size:r,themeColor:a,icon:s,type:c=e||$.type,rotate:d,flip:i,viewBox:y=$.viewBox,variant:g=$.variant,...v}=t;if(!s)return _(re,{});if((e||c)==="svg"){if(s==="none")return _(X,{...v,className:l(t.className,P),icon:s,size:r,variant:g});let N=j[s]?s:ke(`${s}-icon`);return j[N]?_(X,{...v,className:l(t.className,P),icon:j[N],size:r,themeColor:a,rotate:d,flip:i,viewBox:y,variant:g}):_(re,{})}return _(te,{...v,className:l(t.className,P),icon:s,size:r,themeColor:a,rotate:d,flip:i})};m.states=Ne;m.options=Ie;m.defaultOptions=$;m.className=P;m.moduleName=oe;m.folderName=ne;m.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."}]};import{jsx as D}from"react/jsx-runtime";var Me="k-chip-action";var q=t=>{let{type:e,...r}=t,a;switch(e){case"remove":a=D(m,{icon:"x-circle",size:"small"});break;case"more":a=D(m,{icon:"more-vertical",size:"small"});break;default:return D(m,{icon:e,size:"small"})}return D("span",{...r,className:l(t.className,Me,`k-chip-${e}-action`),children:a})};var J="avatar",se=J;import{jsx as ie}from"react/jsx-runtime";var L="k-avatar";var Oe=[h.hover,h.focus,h.active,h.selected,h.disabled],Ee={size:[n.undefined,n.small,n.medium,n.large],rounded:[u.undefined,u.none,u.small,u.medium,u.large,u.full],fillMode:[b.undefined,b.solid,b.outline],themeColor:[o.undefined,o.base,o.primary,o.secondary,o.tertiary]},W={type:"text",border:!1},p=t=>{let{size:e,rounded:r,fillMode:a,themeColor:s,type:c=W.type,border:d=W.border,...i}=t;return ie("div",{...i,className:l(t.className,L,A(L,{size:e,rounded:r,fillMode:a,themeColor:s}),{[`${L}-bordered`]:d}),children:ie("span",{className:`${L}-${c}`,children:t.children})})};p.states=Oe;p.options=Ee;p.className=L;p.defaultOptions=W;p.moduleName=J;p.folderName=se;p.ariaSpec={selector:".k-avatar",rules:[{selector:".k-avatar img",attribute:"alt",usage:"Images inside Avatar must have alt text for screen readers."}]};var C=p;import{jsx as Se}from"react/jsx-runtime";var le=t=>Se(C,{type:"icon",...t});import{jsx as Te}from"react/jsx-runtime";var ce=t=>Te(C,{type:"text",...t});import{jsx as ze}from"react/jsx-runtime";var de=t=>ze(C,{type:"image",...t});import{jsx as Ft}from"react/jsx-runtime";import{jsx as R}from"react/jsx-runtime";var _e=p.options,Le=p.states,Re={...p.defaultOptions,variant:"image"},we=[{name:"image",title:"Image"},{name:"icon",title:"Icon Avatar"},{name:"text",title:"Text Avatar"}],Ke=[],M=t=>{let{variant:e,...r}=t;switch(e){case"icon":return R(le,{...r,children:R(m,{icon:"star"})});case"text":return R(ce,{...r,children:"JO"});default:return R(de,{...r,children:R("img",{src:"https://demos.telerik.com/kendo-ui/content/web/Customers/RICSU.jpg"})})}};M.options=_e;M.states=Le;M.variants=we;M.defaultOptions=Re;M.modifiers=Ke;M.className=p.className;var Q="chip",me=Q,pe="https://demos.telerik.com/kendo-ui/content/web/Customers/RICSU.jpg";import{jsx as O,jsxs as $e}from"react/jsx-runtime";var V="k-chip",He=[h.hover,h.focus,h.active,h.selected,h.disabled],Pe={size:[n.undefined,n.small,n.medium,n.large],rounded:[u.undefined,u.none,u.small,u.medium,u.large,u.full],fillMode:[b.undefined,b.solid,b.outline],themeColor:[o.undefined,o.base,o.success,o.warning,o.error,o.info]},ue={avatarImage:"/packages/html/assets/avatar.jpg"},f=t=>{let{size:e,rounded:r,fillMode:a,themeColor:s,text:c,icon:d,actions:i,showAvatar:y,avatarImage:g=ue.avatarImage,hover:v,focus:w,active:N,selected:I,disabled:K,...E}=t;return $e("div",{...E,className:l(t.className,V,A(V,{size:e,rounded:r,fillMode:a,themeColor:s}),Z(V,{hover:v,focus:w,active:N,disabled:K,selected:I})),role:t.role||"button","aria-pressed":t.role==="option"?void 0:I?"true":"false",...t.role==="option"&&I!==void 0&&{"aria-selected":I?"true":"false"},"aria-disabled":K?"true":void 0,children:[d&&O(m,{className:"k-chip-icon",icon:d,size:"small"}),y&&O(p,{className:"k-chip-avatar",type:"image",children:O("img",{src:g,alt:""})}),O("span",{className:"k-chip-content",children:t.children?t.children:c&&O("span",{className:"k-chip-label",children:c})}),i&&O("span",{className:"k-chip-actions",children:i})]})};f.states=He;f.options=Pe;f.className=V;f.defaultOptions=ue;f.moduleName=Q;f.folderName=me;f.ariaSpec={selector:".k-chip",rules:[{selector:"*:not(.k-chip-list) > .k-chip",attribute:"role=button",usage:"Announces that the chip acts as a button when standalone."},{selector:"*:not(.k-chip-list) > .k-chip.k-selected",attribute:"aria-pressed=true",usage:"Announces that the Chip has been selected."},{selector:"*:not(.k-chip-list) > .k-chip:not(.k-selected)",attribute:"aria-pressed=false",usage:"Announces that the Chip has not been selected."},{selector:".k-chip",attribute:"aria-disabled=true (when disabled)",usage:"Announces that the Chip is disabled."}]};import{jsx as Y}from"react/jsx-runtime";var De=f.states,Ve=f.defaultOptions,Fe=f.options,Be=[],Ue=[{name:"icon",title:"Icon"},{name:"avatar",title:"Avatar"},{name:"remove-icon",title:"`Remove` Icon"},{name:"more-options",title:"`More options` Icon"}],k=t=>{let{modifiers:e,...r}=t,a={};return Object.keys(e||{}).forEach(s=>{switch(s){case"icon":a.icon=e?.[s]?"arrow-down":void 0;break;case"avatar":a.showAvatar=!!e?.[s],a.avatarImage=e?.[s]?pe:void 0;break;case"more-options":a.actions||(a.actions=[]),a.actions[0]=e?.[s]?Y(q,{type:"more"}):void 0;break;case"remove-icon":a.actions||(a.actions=[]),a.actions[1]=e?.[s]?Y(q,{type:"remove"}):void 0;break;default:break}}),Y(f,{...r,...a,children:"Chip component"})};k.options=Fe;k.states=De;k.variants=Be;k.defaultOptions=Ve;k.modifiers=Ue;k.className=f.className;var xo=k;export{k as ChipDemo,xo as default};