UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines 4.59 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("kendo.core.min.js"),require("kendo.icons.min.js"),require("kendo.html.button.min.js")):typeof define==`function`&&define.amd?define([`exports`,`kendo.core.min`,`kendo.icons.min`,`kendo.html.button.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Chainofthought={}),e.kendo._globals.Core,e.kendo._globals.Icons,e.kendo._globals.HtmlButton))})(this,function(e,t,n,r){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let i={id:`chainofthought`,name:`ChainOfThought`,category:`web`,description:`The ChainOfThought component.`,depends:[`core`,`icons`,`html.button`]};(function(e,t){let n=window.kendo,r=n.ui.Widget,i=n.htmlEncode,a=`.kendoChainOfThought`,o=`expandedChange`,s=r.extend({init:function(e,t){let i=this;r.fn.init.call(i,e,t),i._render(),i._bindEvents(),n.notify(i)},options:{name:`ChainOfThought`,label:null,secondaryLabel:null,svgIcon:`sparkles`,completed:!1,expanded:!1,expandable:!1,thoughts:[],linesAdded:null,linesRemoved:null,thoughtTemplate:null},events:[o],_render:function(){let t=this,n=t.options;t.element.addClass(`k-agent-step k-chain-of-thought`).toggleClass(`k-agent-completed`,!!n.completed),t.element.html(t._headHtml()),t._head=t.element.find(`.k-agent-step-head`),t._head.find(`.k-svg-icon`).attr(`aria-hidden`,`true`),t._body=e(`<div class="k-agent-step-body"></div>`),t._renderThoughts(),n.expanded&&t._body.appendTo(t.element)},_headHtml:function(){let t=this,r=t.options,a=r.expandable?` aria-expanded="${!!r.expanded}"`:``,o=r.label?`<span class="k-agent-step-label">${i(r.label)}</span>`:``,s=r.secondaryLabel?`<span class="k-agent-step-sep">·</span><span class="k-agent-step-secondary">${i(r.secondaryLabel)}</span>`:``,c=t._deltaHtml(r.linesAdded,r.linesRemoved),l=r.expandable?n.ui.icon({icon:r.expanded?`chevron-up`:`chevron-right`,iconClass:`k-agent-step-expand`}):``;return e(n.html.renderButton(`<button class="k-agent-step-head"${a}><span class="k-agent-step-content">`+o+s+c+l+`</span></button>`,{icon:r.svgIcon,iconClass:`k-agent-step-icon`})).removeClass(`k-button`)[0].outerHTML},_deltaHtml:function(e,n){let r=``;return e!==null&&e!==t&&(r+=`<span class="k-agent-step-added">+${i(String(e))}</span>`),n!==null&&n!==t&&(r+=`<span class="k-agent-step-removed">-${i(String(n))}</span>`),r},_renderThoughts:function(){let e=this,t=e.options,n=t.thoughts||[];if(t.thoughtTemplate!==null){let r=t.thoughtTemplate;e._body.html(n.map(e=>r(e)).join(``))}else e._body.html(n.map(t=>e._thoughtHtml(t)).join(``)),e._body.find(`.k-svg-icon`).attr(`aria-hidden`,`true`)},_thoughtHtml:function(e){let t=e.svgIcon?`<span class="k-agent-step-icon-col">${n.ui.icon({icon:e.svgIcon,iconClass:`k-agent-step-icon`})}</span>`:``,r=e.label?`<span class="k-agent-step-label">${i(e.label)}</span>`:``,a=e.secondaryLabel?`<span class="k-agent-step-sep">·</span><span class="k-agent-step-secondary">${i(e.secondaryLabel)}</span>`:``,o=this._deltaHtml(e.linesAdded,e.linesRemoved),s=e.time?`<span class="k-agent-step-sep">·</span><span class="k-agent-step-secondary">${i(e.time)}</span>`:``,c=e.children?`<div class="k-agent-step-body">${e.children}</div>`:``;return`<div class="k-thought${e.completed?` k-thought-completed`:``}">`+t+`<span class="k-agent-step-content">`+r+a+o+s+c+`</span></div>`},_bindEvents:function(){let e=this;e.options.expandable&&e._head.on(`click.kendoChainOfThought`,e._onToggle.bind(e)).on(`keydown.kendoChainOfThought`,e._onKeydown.bind(e))},_onToggle:function(){let e=this,t=!e.options.expanded;e.trigger(o,{expanded:t})||e.toggle(t)},_onKeydown:function(e){let t=this;(e.keyCode===n.keys.ENTER||e.keyCode===n.keys.SPACEBAR)&&(t._onToggle(),e.preventDefault())},toggle:function(r){let i=this;if(r===t&&(r=!i.options.expanded),i.options.expanded=r,i.options.expandable){i._head.attr(`aria-expanded`,r);let t=e(n.ui.icon({icon:r?`chevron-up`:`chevron-right`,iconClass:`k-agent-step-expand`})).attr(`aria-hidden`,`true`);i._head.find(`.k-agent-step-expand`).replaceWith(t)}r?i._body.appendTo(i.element):i._body.detach()},expand:function(){this.options.expandable&&this.toggle(!0)},collapse:function(){this.toggle(!1)},setThoughts:function(e){let t=this;t.options.thoughts=e||[],t._renderThoughts()},destroy:function(){let e=this;e._head&&e._head.off(a),e.element.off(a),r.fn.destroy.call(e)}});n.ui.plugin(s)})(window.kendo.jQuery);var a=kendo;e.__meta__=i,e.default=a}); //# sourceMappingURL=kendo.chainofthought.min.js.map