UNPKG

@progress/kendo-themes-html

Version:

A collection of HTML helpers used for developing Kendo UI themes

2 lines (1 loc) 9.76 kB
var c=(...t)=>t.filter(e=>e!==!0&&!!e).map(e=>Array.isArray(e)?c(...e):typeof e=="object"?Object.keys(e).map((r,i)=>e[i]||e[r]&&r||null).filter(r=>r!==null).join(" "):e).filter(e=>!!e).join(" ");var y=(t,e)=>c({[`${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"}),J=(t,e)=>{let{valid:r,invalid:i,hover:a,focus:d,checked:u,active:l,selected:b,disabled:g,indeterminate:p,loading:w,empty:T,readonly:z,highlighted:H,...C}=e;return c({"k-valid":r,"k-invalid":i,"k-hover":a,"k-focus":d,"k-checked":u,"k-active":l,"k-selected":b,"k-disabled":g,"k-indeterminate":p&&!u,"k-loading":w,"k-empty":T,"k-readonly":z,"k-highlighted":H},Object.keys(C).reduce((m,v)=>(v.startsWith("k-")?m[v]=C[v]:m[`k-${v}`]=C[v],m),{}))};function Q(t,e){if(!e)return{};let r=Array.isArray(e)?e:[e];return Object.fromEntries(r.map(i=>[`k-${i}`,!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"},B={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"},k={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 ye,jsx as Y}from"react/jsx-runtime";var $="k-font-icon",be=[],Te={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={},M=t=>{let{size:e,themeColor:r,icon:i,rotate:a,flip:d,...u}=t;return i?Y("span",{...u,className:c(t.className,$,y($,{size:e}),{[`k-i-${i}`]:i,[`k-color-${r}`]:r,[`k-rotate-${a}`]:a,"k-flip-h":d==="h"||d==="both","k-flip-v":d==="v"||d==="both"}),"aria-hidden":"true"}):Y(ye,{})};M.states=be;M.options=Te;M.className=$;M.defaultOptions=ve;var Z=M;import{Fragment as ke,jsx as L}from"react/jsx-runtime";var U="k-svg-icon",Ne=[],Be={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]},D={viewBox:"0 0 24 24",variant:f.outline},_=t=>{let{size:e,themeColor:r,rotate:i,flip:a,viewBox:d=D.viewBox,variant:u=D.variant,icon:l,...b}=t;if(!l)return L(ke,{});if(l==="none")return L("span",{...b,className:c(t.className,U,y("k-icon",{size:e}),"k-none"),"aria-hidden":"true"});let g=typeof l=="object"&&l.name&&l.name,p=typeof l=="object"?u&&l.variants?.[u]||l.variants?.outline||l.content:void 0;return L("span",{...b,className:c(t.className,U,y("k-icon",{size:e}),{[`k-svg-i-${g}`]:g,[`k-color-${r}`]:r,[`k-rotate-${i}`]:i,"k-flip-h":a==="h"||a==="both","k-flip-v":a==="v"||a==="both"}),"aria-hidden":"true",children:L("svg",{"aria-hidden":!0,focusable:!1,xmlns:"http://www.w3.org/2000/svg",viewBox:typeof l=="object"?l.viewBox:d,dangerouslySetInnerHTML:p!==void 0?{__html:p}:void 0,children:l?void 0:t.children})})};_.states=Ne;_.options=Be;_.className=U;_.defaultOptions=D;var F=_;import*as V from"@progress/kendo-svg-icons";var j="icon",ee="icons";import{useContext as Ce}from"react";import{createContext as Se}from"react";var te=Se({iconsType:"svg"});import{Fragment as oe,jsx as I}from"react/jsx-runtime";var P="k-icon",Oe=t=>t.replace(/([-_][a-z0-9])/gi,e=>e.toUpperCase().replace("-","").replace("_","")),Ee=[],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],variant:[f.outline,f.solid,f.duotone]},R={viewBox:"0 0 24 24",type:"svg",variant:f.outline},x=t=>{let{iconsType:e}=Ce(te),{size:r,themeColor:i,icon:a,type:d=e||R.type,rotate:u,flip:l,viewBox:b=R.viewBox,variant:g=R.variant,...p}=t;if(!a)return I(oe,{});if((e||d)==="svg"){if(a==="none")return I(F,{...p,className:c(t.className,P),icon:a,size:r,variant:g});let T=V[a]?a:Oe(`${a}-icon`);return V[T]?I(F,{...p,className:c(t.className,P),icon:V[T],size:r,themeColor:i,rotate:u,flip:l,viewBox:b,variant:g}):I(oe,{})}return I(Z,{...p,className:c(t.className,P),icon:a,size:r,themeColor:i,rotate:u,flip:l})};x.states=Ee;x.options=Me;x.defaultOptions=R;x.className=P;x.moduleName=j;x.folderName=ee;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 G="button",ne=G;import{Fragment as re,jsx as O,jsxs as se}from"react/jsx-runtime";var A="k-button",_e=["icon-button"],Ie=[k.hover,k.focus,k.active,k.selected,k.disabled,k.generating],Ae={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:[B.undefined,B.solid,B.flat,B.outline,B.clear,B.link],themeColor:[o.undefined,o.base,o.primary,o.secondary,o.tertiary,o.success,o.warning,o.error,o.info,o.inverse]},X={showArrow:!1,arrowIconName:"chevron-down"},s=t=>{let{as:e="button",size:r,rounded:i,fillMode:a,themeColor:d,showArrow:u=X.showArrow,arrowIconName:l=X.arrowIconName,variant:b,hover:g,focus:p,active:w,selected:T,disabled:z,togglable:H,ariaDisabled:C,icon:m,iconSize:v,text:K,iconClassName:pe,className:fe,...xe}=t,he=m!=null,ge=t.children!==void 0;return se(e,{className:c(fe,A,Q(A,b),y(A,{size:r,rounded:i,fillMode:a,themeColor:d}),J(A,{hover:g,focus:p,active:w,disabled:z||C,selected:T}),{"k-icon-button":!K&&!ge&&he}),"aria-pressed":H?T?"true":"false":void 0,...xe,"aria-disabled":C?"true":void 0,disabled:z||void 0,children:[typeof m=="string"&&m&&O(x,{className:c(pe,"k-button-icon"),icon:m,size:v}),m&&typeof m!="string"&&O(re,{children:m}),K?se(re,{children:[K&&O("span",{className:"k-button-text",children:K}),t.children]}):t.children&&O("span",{className:"k-button-text",children:t.children}),u&&O("span",{className:"k-menu-button-arrow k-button-arrow",children:O(x,{icon:l})})]})};s.states=Ie;s.options=Ae;s.variants=_e;s.className=A;s.defaultOptions=X;s.moduleName=G;s.folderName=ne;s.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 we}from"react/jsx-runtime";var ie=t=>we(s,{icon:"folder",...t,"aria-label":t["aria-label"]||"Folder",children:void 0});import{jsx as ze}from"react/jsx-runtime";var ae=t=>ze(s,{icon:"folder",children:"Button",...t});import{jsx as Ke}from"react/jsx-runtime";var le=t=>Ke(s,{children:"Button",...t});import{jsx as q}from"react/jsx-runtime";var Le=s.options,Pe=s.states,Re={...s.defaultOptions,variant:"text"},He=[{name:"icon-only",title:"Icon Only"},{name:"icon-and-text",title:"Icon & Text"},{name:"text",title:"Text"}],$e=[],E=t=>{let{variant:e,...r}=t;switch(e){case"icon-only":return q(ie,{...r,icon:"star"});case"icon-and-text":return q(ae,{...r,icon:"star",children:"Button"});default:return q(le,{...r,children:"Button"})}};E.options=Le;E.states=Pe;E.variants=He;E.defaultOptions=Re;E.modifiers=$e;E.className=s.className;var W="speech-to-text-button",ce=W;import{jsx as Ue}from"react/jsx-runtime";var de="k-speech-to-text-button",ue={icon:"microphone"},h=t=>{let{listening:e=!1,icon:r=ue.icon,...i}=t;return Ue(s,{...i,icon:e?"stop":r,className:c(t.className,de,{"k-listening":e}),"aria-pressed":e?"true":"false","aria-label":e?"Stop listening":"Start listening"})};h.states=s.states;h.options=s.options;h.className=de;h.defaultOptions=ue;h.moduleName=W;h.folderName=ce;h.ariaSpec={selector:".k-speech-to-text-button",rules:[{selector:".k-button.k-speech-to-text-button",attribute:"role=button or nodeName=button",usage:"If the used element is not <button>, explicitly set its role to button."},{selector:".k-button.k-speech-to-text-button",attribute:"aria-pressed",usage:"Announces the toggle behaviour of the button."},{selector:".k-button.k-speech-to-text-button",attribute:"aria-label",usage:"Accessible name for the speech-to-text button."}]};import{jsx as Xe}from"react/jsx-runtime";var De=s.states,me={...s.defaultOptions,variant:"normal"},Fe={...s.options,fillMode:s.options.fillMode.filter(t=>t!=="clear"&&t!=="link")},Ve=[],Ge=[{name:"normal",title:"Normal"},{name:"listening",title:"Listening"}],S=t=>{let{variant:e,...r}={...me,...t},i={};return e==="listening"&&(i.listening=!0),Xe(h,{...r,...i})};S.options=Fe;S.states=De;S.variants=Ge;S.defaultOptions=me;S.modifiers=Ve;S.className=h.className;var uo=S;export{S as SpeechToTextButtonDemo,uo as default};