UNPKG

@progress/kendo-themes-html

Version:

A collection of HTML helpers used for developing Kendo UI themes

2 lines (1 loc) 18.2 kB
var s=(...e)=>e.filter(t=>t!==!0&&!!t).map(t=>Array.isArray(t)?s(...t):typeof t=="object"?Object.keys(t).map((o,i)=>t[i]||t[o]&&o||null).filter(o=>o!==null).join(" "):t).filter(t=>!!t).join(" ");var O=(e,t)=>s({[`${e}-xs`]:t.size==="xsmall",[`${e}-sm`]:t.size==="small",[`${e}-md`]:t.size==="medium",[`${e}-lg`]:t.size==="large",[`${e}-xl`]:t.size==="xlarge",[`${e}-xxl`]:t.size==="xxlarge",[`${e}-xxxl`]:t.size==="xxxlarge"},{[`${e}-${t.fillMode}`]:t.fillMode},{[`${e}-${t.themeColor}`]:t.themeColor},{"k-rounded-sm":t.rounded==="small","k-rounded-md":t.rounded==="medium","k-rounded-lg":t.rounded==="large","k-rounded-full":t.rounded==="full","k-rounded-none":t.rounded==="none"}),R=(e,t)=>{let{valid:o,invalid:i,hover:a,focus:l,checked:m,active:u,selected:v,disabled:h,indeterminate:d,loading:I,empty:b,readonly:w,highlighted:P,...L}=t;return s({"k-valid":o,"k-invalid":i,"k-hover":a,"k-focus":l,"k-checked":m,"k-active":u,"k-selected":v,"k-disabled":h,"k-indeterminate":d&&!m,"k-loading":I,"k-empty":b,"k-readonly":w,"k-highlighted":P},Object.keys(L).reduce((N,g)=>(g.startsWith("k-")?N[g]=L[g]:N[`k-${g}`]=L[g],N),{}))};function ke(e,t){if(!t)return{};let o=Array.isArray(t)?t:[t];return Object.fromEntries(o.map(i=>[`k-${i}`,!0]))}var r={undefined:void 0,xsmall:"xsmall",small:"small",medium:"medium",large:"large",xlarge:"xlarge",xxlarge:"xxlarge",xxxlarge:"xxxlarge"},K={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"},y={undefined:void 0,outline:"outline",solid:"solid",duotone:"duotone"},n={undefined:void 0,inherit:"inherit",base:"base",primary:"primary",secondary:"secondary",tertiary:"tertiary",info:"info",success:"success",warning:"warning",error:"error",inverse:"inverse"},f={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 rt,jsx as Ae}from"react/jsx-runtime";var re="k-font-icon",tt=[],ot={size:[r.undefined,r.xsmall,r.small,r.medium,r.large,r.xlarge,r.xxlarge,r.xxxlarge],themeColor:[n.undefined,n.base,n.primary,n.secondary,n.tertiary,n.success,n.warning,n.error,n.info]},nt={},J=e=>{let{size:t,themeColor:o,icon:i,rotate:a,flip:l,...m}=e;return i?Ae("span",{...m,className:s(e.className,re,O(re,{size:t}),{[`k-i-${i}`]:i,[`k-color-${o}`]:o,[`k-rotate-${a}`]:a,"k-flip-h":l==="h"||l==="both","k-flip-v":l==="v"||l==="both"}),"aria-hidden":"true"}):Ae(rt,{})};J.states=tt;J.options=ot;J.className=re;J.defaultOptions=nt;var Ee=J;import{Fragment as it,jsx as j}from"react/jsx-runtime";var ae="k-svg-icon",at=[],st={size:[r.undefined,r.xsmall,r.small,r.medium,r.large,r.xlarge,r.xxlarge,r.xxxlarge],themeColor:[n.undefined,n.base,n.primary,n.secondary,n.tertiary,n.success,n.warning,n.error,n.info],variant:[y.outline,y.solid,y.duotone]},se={viewBox:"0 0 24 24",variant:y.outline},X=e=>{let{size:t,themeColor:o,rotate:i,flip:a,viewBox:l=se.viewBox,variant:m=se.variant,icon:u,...v}=e;if(!u)return j(it,{});if(u==="none")return j("span",{...v,className:s(e.className,ae,O("k-icon",{size:t}),"k-none"),"aria-hidden":"true"});let h=typeof u=="object"&&u.name&&u.name,d=typeof u=="object"?m&&u.variants?.[m]||u.variants?.outline||u.content:void 0;return j("span",{...v,className:s(e.className,ae,O("k-icon",{size:t}),{[`k-svg-i-${h}`]:h,[`k-color-${o}`]:o,[`k-rotate-${i}`]:i,"k-flip-h":a==="h"||a==="both","k-flip-v":a==="v"||a==="both"}),"aria-hidden":"true",children:j("svg",{"aria-hidden":!0,focusable:!1,xmlns:"http://www.w3.org/2000/svg",viewBox:typeof u=="object"?u.viewBox:l,dangerouslySetInnerHTML:d!==void 0?{__html:d}:void 0,children:u?void 0:e.children})})};X.states=at;X.options=st;X.className=ae;X.defaultOptions=se;var ie=X;import*as le from"@progress/kendo-svg-icons";var Le="icon",ye="icons";import{useContext as mt}from"react";import{createContext as lt}from"react";var Se=lt({iconsType:"svg"});import{Fragment as Oe,jsx as q}from"react/jsx-runtime";var ee="k-icon",ut=e=>e.replace(/([-_][a-z0-9])/gi,t=>t.toUpperCase().replace("-","").replace("_","")),ct=[],pt={size:[r.undefined,r.xsmall,r.small,r.medium,r.large,r.xlarge,r.xxlarge,r.xxxlarge],themeColor:[n.undefined,n.base,n.primary,n.secondary,n.tertiary,n.success,n.warning,n.error,n.info],variant:[y.outline,y.solid,y.duotone]},te={viewBox:"0 0 24 24",type:"svg",variant:y.outline},M=e=>{let{iconsType:t}=mt(Se),{size:o,themeColor:i,icon:a,type:l=t||te.type,rotate:m,flip:u,viewBox:v=te.viewBox,variant:h=te.variant,...d}=e;if(!a)return q(Oe,{});if((t||l)==="svg"){if(a==="none")return q(ie,{...d,className:s(e.className,ee),icon:a,size:o,variant:h});let b=le[a]?a:ut(`${a}-icon`);return le[b]?q(ie,{...d,className:s(e.className,ee),icon:le[b],size:o,themeColor:i,rotate:m,flip:u,viewBox:v,variant:h}):q(Oe,{})}return q(Ee,{...d,className:s(e.className,ee),icon:a,size:o,themeColor:i,rotate:m,flip:u})};M.states=ct;M.options=pt;M.defaultOptions=te;M.className=ee;M.moduleName=Le;M.folderName=ye;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."}]};var k="menu",A=k;import{jsx as Q,jsxs as Ce}from"react/jsx-runtime";var me="k-menu-item",dt=[f.hover,f.focus,f.active,f.selected,f.disabled],ft={},we={iconPosition:"before"},p=e=>{let{hover:t,focus:o,active:i,selected:a,disabled:l,icon:m,text:u,first:v,last:h,showArrow:d,arrowIconName:I,iconPosition:b=we.iconPosition,dir:w,children:P,expanded:L,...N}=e,g=I;return g||(g=w==="rtl"?"chevron-left":"chevron-right"),Ce("li",{...N,className:s(e.className,me,"k-item",R(me,{focus:o,disabled:l,hover:t,active:i,selected:a}),{"k-first":v,"k-last":h}),role:"menuitem",...d&&{"aria-haspopup":"menu"},...d&&{"aria-expanded":L?"true":"false"},...l&&{"aria-disabled":"true"},...o&&{tabIndex:0},children:[Ce("span",{className:s("k-link k-menu-link"),children:[m&&b==="before"&&Q(M,{className:"k-menu-link-icon",icon:m}),Q("span",{className:"k-menu-link-text",children:u}),m&&b==="after"&&Q(M,{className:"k-menu-link-icon",icon:m}),d&&Q("span",{className:"k-menu-expand-arrow","aria-hidden":"true",children:Q(M,{icon:g})})]}),P]})};p.states=dt;p.options=ft;p.className=me;p.defaultOptions=we;p.moduleName=k;p.folderName=A;import{jsx as Y,jsxs as Te}from"react/jsx-runtime";var ue="k-menu-item",xt=[f.hover,f.focus,f.active,f.selected,f.disabled],Mt={},ce={dir:"ltr",iconPosition:"before"},E=e=>{let{hover:t,focus:o,active:i,selected:a,disabled:l,icon:m,text:u,first:v,last:h,showArrow:d,arrowIconName:I,iconPosition:b=ce.iconPosition,dir:w=ce.dir,children:P,popup:L,expanded:N,...g}=e,T=I;return T||(T=w==="rtl"?"chevron-left":"chevron-right"),Te("li",{role:"menuitem",...g,className:s(e.className,ue,"k-item",R(ue,{focus:o,disabled:l}),{"k-first":v,"k-last":h}),...d&&{"aria-haspopup":"menu"},...d&&{"aria-expanded":N?"true":"false"},...l&&{"aria-disabled":"true"},...o&&{tabIndex:0},children:[Te("span",{className:s("k-link k-menu-link",R("k-menu-link",{hover:t,active:i,selected:a,disabled:l})),children:[m&&b==="before"&&Y(M,{className:"k-menu-link-icon",icon:m}),Y("span",{className:"k-menu-link-text",children:u}),m&&b==="after"&&Y(M,{className:"k-menu-link-icon",icon:m}),d&&Y("span",{className:"k-menu-expand-arrow","aria-hidden":"true",children:Y(M,{icon:T})})]}),P,L]})};E.states=xt;E.options=Mt;E.className=ue;E.defaultOptions=ce;E.moduleName=k;E.folderName=A;var pe="button",_e=pe;import{Fragment as Pe,jsx as D,jsxs as Re}from"react/jsx-runtime";var Z="k-button",bt=["icon-button"],Nt=[f.hover,f.focus,f.active,f.selected,f.disabled,f.generating],ht={size:[r.undefined,r.xsmall,r.small,r.medium,r.large],rounded:[K.undefined,K.none,K.small,K.medium,K.large,K.full],fillMode:[B.undefined,B.solid,B.flat,B.outline,B.clear,B.link],themeColor:[n.undefined,n.base,n.primary,n.secondary,n.tertiary,n.success,n.warning,n.error,n.info,n.inverse]},de={showArrow:!1,arrowIconName:"chevron-down"},c=e=>{let{as:t="button",size:o,rounded:i,fillMode:a,themeColor:l,showArrow:m=de.showArrow,arrowIconName:u=de.arrowIconName,variant:v,hover:h,focus:d,active:I,selected:b,disabled:w,togglable:P,ariaDisabled:L,icon:N,iconSize:g,text:T,iconClassName:Qe,className:Ye,...Ze}=e,je=N!=null,et=e.children!==void 0;return Re(t,{className:s(Ye,Z,ke(Z,v),O(Z,{size:o,rounded:i,fillMode:a,themeColor:l}),R(Z,{hover:h,focus:d,active:I,disabled:w||L,selected:b}),{"k-icon-button":!T&&!et&&je}),"aria-pressed":P?b?"true":"false":void 0,...Ze,"aria-disabled":L?"true":void 0,disabled:w||void 0,children:[typeof N=="string"&&N&&D(M,{className:s(Qe,"k-button-icon"),icon:N,size:g}),N&&typeof N!="string"&&D(Pe,{children:N}),T?Re(Pe,{children:[T&&D("span",{className:"k-button-text",children:T}),e.children]}):e.children&&D("span",{className:"k-button-text",children:e.children}),m&&D("span",{className:"k-menu-button-arrow k-button-arrow",children:D(M,{icon:u})})]})};c.states=Nt;c.options=ht;c.variants=bt;c.className=Z;c.defaultOptions=de;c.moduleName=pe;c.folderName=_e;c.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 It}from"react/jsx-runtime";var Ke=e=>It(c,{icon:"folder",...e,"aria-label":e["aria-label"]||"Folder",children:void 0});import{jsx as vt}from"react/jsx-runtime";var Be=e=>vt(c,{icon:"folder",children:"Button",...e});import{jsx as gt}from"react/jsx-runtime";var ze=e=>gt(c,{children:"Button",...e});import{jsx as fe}from"react/jsx-runtime";var kt=c.options,At=c.states,Et={...c.defaultOptions,variant:"text"},Lt=[{name:"icon-only",title:"Icon Only"},{name:"icon-and-text",title:"Icon & Text"},{name:"text",title:"Text"}],yt=[],$=e=>{let{variant:t,...o}=e;switch(t){case"icon-only":return fe(Ke,{...o,icon:"star"});case"icon-and-text":return fe(Be,{...o,icon:"star",children:"Button"});default:return fe(ze,{...o,children:"Button"})}};$.options=kt;$.states=At;$.variants=Lt;$.defaultOptions=Et;$.modifiers=yt;$.className=c.className;import{jsx as wt}from"react/jsx-runtime";var Ue="k-menu-scroll-wrapper",St=[],Ot={},Ct={},z=e=>{let{className:t,children:o,orientation:i,...a}=e;return wt("div",{...a,className:s(t,Ue,{"k-menu-scroll-wrapper-vertical":i==="vertical"}),children:o})};z.states=St;z.options=Ot;z.className=Ue;z.defaultOptions=Ct;z.moduleName=k;z.folderName=A;var He=z;import{Fragment as xe,jsx as U,jsxs as oe}from"react/jsx-runtime";var Me="k-menu",Tt=[],_t={},ne={orientation:"horizontal",header:!0,scrollButtonsPosition:"around"},x=e=>{let{children:t,orientation:o=ne.orientation,header:i=ne.header,scrollable:a,scrollButtonsPosition:l=ne.scrollButtonsPosition,wrapperStyles:m,dir:u,popup:v,contextMenu:h,...d}=e,I={horizontal:{prev:u!=="rtl"?"left":"right",next:u!=="rtl"?"right":"left"},vertical:{prev:"up",next:"down"}},b=U("ul",{dir:u,...d,className:s(e.className,"k-reset",Me,{[`${Me}-${o}`]:o,"k-header":i}),role:h?"menu":"menubar",...o==="vertical"&&{"aria-orientation":"vertical"},children:t});return oe(xe,{children:[a?oe(He,{orientation:o,style:m,dir:e.dir,children:[l==="start"&&oe(xe,{children:[U(c,{fillMode:"flat",icon:`chevron-${I[o].prev}`,className:"k-menu-scroll-button k-menu-scroll-button-prev",tabIndex:-1,"aria-label":"Scroll previous"}),U(c,{fillMode:"flat",icon:`chevron-${I[o].next}`,className:"k-menu-scroll-button k-menu-scroll-button-next",tabIndex:-1,"aria-label":"Scroll next"})]}),l==="around"&&U(c,{fillMode:"flat",icon:`chevron-${I[o].prev}`,className:"k-menu-scroll-button k-menu-scroll-button-prev",tabIndex:-1,"aria-label":"Scroll previous"}),b,l==="end"&&oe(xe,{children:[U(c,{fillMode:"flat",icon:`chevron-${I[o].prev}`,className:"k-menu-scroll-button k-menu-scroll-button-prev",tabIndex:-1,"aria-label":"Scroll previous"}),U(c,{fillMode:"flat",icon:`chevron-${I[o].next}`,className:"k-menu-scroll-button k-menu-scroll-button-next",tabIndex:-1,"aria-label":"Scroll next"})]}),l==="around"&&U(c,{fillMode:"flat",icon:`chevron-${I[o].next}`,className:"k-menu-scroll-button k-menu-scroll-button-next",tabIndex:-1,"aria-label":"Scroll next"})]}):b,v]})};x.states=Tt;x.options=_t;x.className=Me;x.defaultOptions=ne;x.moduleName=k;x.folderName=A;x.ariaSpec={selector:".k-menu",rules:[{selector:".k-menu:not(.k-context-menu)",attribute:"role=menubar",usage:"Announces the Menu menubar role."},{selector:".k-menu.k-menu-vertical",attribute:"aria-orientation=vertical",usage:"Announces the Menu orientation when vertical."},{selector:".k-menu-item",attribute:"role=menuitem",usage:"Announces the Menu item role."},{selector:".k-menu-item",attribute:"aria-haspopup=menu (when present)",usage:"Indicates a popup menu is associated with the item."},{selector:".k-menu-item",attribute:"aria-expanded=true/false (when present)",usage:"Indicates whether the submenu is expanded."},{selector:".k-menu-item.k-disabled",attribute:"aria-disabled=true",usage:"Informs assistive technologies that a Menu item is disabled."},{selector:".k-menu-expand-arrow",attribute:"aria-hidden=true",usage:"Expand arrow elements are hidden from assistive technologies."},{selector:".k-menu-popup .k-menu-group",attribute:"role=menu",usage:"The role of the nested menu displayed in a popup."},{selector:".k-menu-scroll-button",attribute:"tabindex=-1",usage:"Scroll buttons are removed from the tab sequence."},{selector:".k-menu-scroll-button",attribute:"aria-label",usage:"Scroll buttons have an accessible label."},{selector:".k-menu-item.k-focus",attribute:"tabindex=0",usage:"The focused item has tabindex 0."},{selector:".k-menu-item",attribute:"aria-controls=ul.k-menu-group id (when present)",usage:"Points to the ID of the submenu. Only present when the item controls a submenu element."},{selector:".k-menu-popup .k-menu-group",attribute:"id",usage:"Each nested menu has a deterministic id linked to the parent aria-controls."}]};import{jsx as Pt}from"react/jsx-runtime";var be="k-separator",De={orientation:"horizontal"},F=e=>{let{orientation:t=De.orientation,...o}=e;return Pt("li",{...o,className:s(e.className,"k-item",be,{[`${be}-${t}`]:t}),role:"separator"})};F.className=be;F.defaultOptions=De;F.moduleName=k;F.folderName=A;import{Fragment as Tn,jsx as _n}from"react/jsx-runtime";import{jsx as zt}from"react/jsx-runtime";var Ne="k-menu-group",Rt=[],Kt={size:[r.undefined,r.small,r.medium,r.large]},Bt={},C=e=>{let{children:t,size:o,...i}=e;return zt("ul",{role:"menu",...i,className:s(e.className,Ne,O(Ne,{size:o})),children:t})};C.states=Rt;C.options=Kt;C.className=Ne;C.defaultOptions=Bt;C.moduleName=k;C.folderName=A;import{Fragment as Ut,jsx as V,jsxs as Ht}from"react/jsx-runtime";var he=e=>V(x,{children:Ht(Ut,{children:[V(p,{first:!0,text:"Item 1"}),V(p,{showArrow:!0,arrowIconName:"chevron-down",text:"Item 2"}),V(p,{showArrow:!0,arrowIconName:"chevron-down",text:"Item 3"}),V(p,{text:"Item 4"}),V(p,{last:!0,text:"Item 5"})]}),...e});var Ie="popup",$e=Ie;import{jsx as Fe}from"react/jsx-runtime";var Ve="k-animation-container",Dt=[],$t={},ve={positionMode:"absolute",shown:!0},_=e=>{let{positionMode:t=ve.positionMode,shown:o=ve.shown,animationStyle:i,offset:a,...l}=e;return Fe("div",{...l,style:{...a,...e.style},className:s(e.className,Ve,{"k-animation-container-shown":o,"k-animation-container-fixed":t==="fixed"}),children:Fe("div",{className:"k-child-animation-container",style:i,children:e.children})})};_.states=Dt;_.options=$t;_.className=Ve;_.defaultOptions=ve;_.moduleName=Ie;_.folderName=$e;var ge="popup",We=ge;import{jsx as Ge}from"react/jsx-runtime";var Je="k-popup",Ft=[],Vt={},Xe={positionMode:"absolute"},S=e=>{let{offset:t,positionMode:o=Xe.positionMode,animationStyle:i,containerClassName:a,containerRole:l,containerAriaLabel:m,...u}=e;return Ge(_,{positionMode:o,offset:t,animationStyle:i,className:a,role:l,"aria-label":m,children:Ge("div",{...u,className:s(e.className,Je),children:e.children})})};S.states=Ft;S.options=Vt;S.className=Je;S.defaultOptions=Xe;S.moduleName=ge;S.folderName=We;S.ariaSpec={selector:".k-popup",rules:[{selector:".k-animation-container",attribute:"role (when appended to body)",usage:'Container gets role="region" when appended to document body. Popup is a building block \u2014 ARIA semantics come from consuming components.'}]};import{Fragment as lr,jsx as sr,jsxs as ir}from"react/jsx-runtime";import{Fragment as dr,jsx as pr,jsxs as fr}from"react/jsx-runtime";import{Fragment as hr,jsx as Nr,jsxs as Ir}from"react/jsx-runtime";import{jsx as H,jsxs as qt}from"react/jsx-runtime";var Wt={...x.options,scrollable:{type:"boolean"}},Gt=x.states,qe={...x.defaultOptions,variant:"horizontal"},Jt=[{name:"horizontal",title:"Horizontal"},{name:"vertical",title:"Vertical"}],Xt=[{name:"opened",title:"Opened"}],W=e=>{let{variant:t,modifiers:o,...i}={...qe,...e},a={},l=t==="vertical"?{left:"200px",top:"30px"}:{left:"90px",top:"auto"};return Object.keys(o||{}).forEach(m=>{m==="opened"&&(a.opened=!!o?.[m],a.popup=o?.[m]?H(S,{className:"k-menu-popup",offset:l,children:qt(C,{children:[H(E,{text:"Item 1"}),H(E,{text:"Item 2"}),H(F,{}),H(E,{text:"Item 3"})]})}):null)}),t==="vertical"?H(he,{...i,...a,orientation:"vertical",style:{width:"200px"}}):H(he,{...i,...a})};W.options=Wt;W.states=Gt;W.variants=Jt;W.defaultOptions=qe;W.modifiers=Xt;W.className=x.className;import{Fragment as Qt,jsx as G,jsxs as Yt}from"react/jsx-runtime";var Gr=e=>G(x,{orientation:"vertical",children:Yt(Qt,{children:[G(p,{first:!0,text:"Item 1"}),G(p,{showArrow:!0,text:"Item 2"}),G(p,{showArrow:!0,text:"Item 3"}),G(p,{text:"Item 4"}),G(p,{last:!0,text:"Item 5"})]}),...e});export{Gr as MenuVertical};