@kashi-ui/elements 2.23.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buttons.js +22 -4
- package/dist/cdn/{buttons-zhSdiaXr.js → buttons-BaK6bx3w.js} +1 -1
- package/dist/cdn/kashi-elements.js +1 -1
- package/dist/cdn/{overlay-DC5-I6hM.js → overlay-CS8piW6X.js} +1 -1
- package/dist/manifest.json +8 -3
- package/dist/overlay.d.ts +2 -1
- package/dist/overlay.js +42 -11
- package/package.json +4 -4
package/dist/buttons.js
CHANGED
|
@@ -433,8 +433,20 @@ export class KashiAccordion extends HTMLBase {
|
|
|
433
433
|
else if (child.hasAttribute("data-title")) {
|
|
434
434
|
d = document.createElement("details");
|
|
435
435
|
d.innerHTML = "<summary></summary>";
|
|
436
|
-
d.querySelector("summary")
|
|
436
|
+
const sum = d.querySelector("summary");
|
|
437
|
+
const desc = child.getAttribute("data-description");
|
|
438
|
+
if (desc) {
|
|
439
|
+
sum.innerHTML = `<span class="k-accordion__head"><span class="k-accordion__titles"><span class="k-accordion__title"></span><span class="k-accordion__description"></span></span></span>`;
|
|
440
|
+
sum.querySelector(".k-accordion__title").textContent = child.getAttribute("data-title");
|
|
441
|
+
sum.querySelector(".k-accordion__description").textContent = desc;
|
|
442
|
+
}
|
|
443
|
+
else
|
|
444
|
+
sum.textContent = child.getAttribute("data-title");
|
|
437
445
|
d.open = child.hasAttribute("data-open");
|
|
446
|
+
if (child.hasAttribute("data-disabled"))
|
|
447
|
+
d.setAttribute("data-disabled", "");
|
|
448
|
+
if (child.hasAttribute("data-value"))
|
|
449
|
+
d.dataset.value = child.getAttribute("data-value");
|
|
438
450
|
const body = document.createElement("div");
|
|
439
451
|
body.append(...child.childNodes);
|
|
440
452
|
d.append(body);
|
|
@@ -444,6 +456,12 @@ export class KashiAccordion extends HTMLBase {
|
|
|
444
456
|
d.classList.add("k-accordion__item");
|
|
445
457
|
const summary = d.querySelector(":scope > summary");
|
|
446
458
|
summary?.classList.add("k-accordion__trigger");
|
|
459
|
+
if (d.hasAttribute("data-disabled") && summary) {
|
|
460
|
+
d.classList.add("k-accordion__item--disabled");
|
|
461
|
+
summary.setAttribute("aria-disabled", "true");
|
|
462
|
+
summary.tabIndex = -1;
|
|
463
|
+
summary.addEventListener("click", (e) => e.preventDefault());
|
|
464
|
+
}
|
|
447
465
|
const rest = [...d.childNodes].filter((n) => n !== summary);
|
|
448
466
|
const content = rest.length === 1 && rest[0] instanceof HTMLElement && rest[0].classList.contains("k-accordion__content") ? rest[0] : null;
|
|
449
467
|
if (!content) {
|
|
@@ -465,11 +483,11 @@ export class KashiAccordion extends HTMLBase {
|
|
|
465
483
|
for (const x of this.details)
|
|
466
484
|
if (x !== d && x.open)
|
|
467
485
|
x.open = false;
|
|
468
|
-
emit(this, "kashi-toggle", { index: this.details.indexOf(d), open: d.open });
|
|
486
|
+
emit(this, "kashi-toggle", { index: this.details.indexOf(d), value: d.dataset.value, open: d.open });
|
|
469
487
|
}, true);
|
|
470
488
|
}
|
|
471
489
|
update() {
|
|
472
|
-
this.box.className = cx("k-accordion", bool(this, "flush") && "k-accordion--flush");
|
|
490
|
+
this.box.className = cx("k-accordion", bool(this, "flush") && "k-accordion--flush", this.getAttribute("size") === "sm" && "k-accordion--sm");
|
|
473
491
|
const single = this.getAttribute("type") === "single";
|
|
474
492
|
for (const d of this.details) {
|
|
475
493
|
if (single)
|
|
@@ -479,7 +497,7 @@ export class KashiAccordion extends HTMLBase {
|
|
|
479
497
|
}
|
|
480
498
|
}
|
|
481
499
|
}
|
|
482
|
-
KashiAccordion.observedAttributes = ["type", "flush"];
|
|
500
|
+
KashiAccordion.observedAttributes = ["type", "flush", "size"];
|
|
483
501
|
define("kashi-button", KashiButton);
|
|
484
502
|
define("kashi-button-group", KashiButtonGroup);
|
|
485
503
|
define("kashi-segmented-control", KashiSegmentedControl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,l as n,o as r,p as i,r as a,t as o,y as s}from"./base-D4tCOysh.js";import{i as c}from"./parts-5fVaWtRe.js";const l=[`name`,`value`,`form`,`target`,`rel`,`download`,`aria-controls`,`aria-expanded`,`aria-haspopup`,`aria-pressed`,`aria-describedby`,`title`];var u=class extends o{constructor(){super(...arguments),this.el=null}connectedCallback(){a(()=>{this.isConnected&&(this.ensure(),this.update())})}attributeChangedCallback(e,t,n){this.el&&t!==n&&(this.ensure(),this.update())}get control(){return this.el}focus(e){this.el?.focus(e)}click(){this.el?.click()}ensure(){let e=this.hasAttribute(`href`)?`A`:`BUTTON`;if(this.el?.tagName===e)return;let t=document.createElement(e);t.append(...this.el?this.el.childNodes:this.childNodes),this.el?.remove(),this.el=t,this.append(t),t.addEventListener(`click`,e=>{t.getAttribute(`aria-disabled`)===`true`&&(e.preventDefault(),e.stopImmediatePropagation())})}update(){let e=this.el,r=this.getAttribute(`variant`)??`secondary`,a=this.getAttribute(`size`)??`md`,o=this.getAttribute(`shape`)??`default`,s=t(this,`loading`),u=t(this,`disabled`),d=e.tagName===`BUTTON`,f=s||!d&&u;if(e.className=c(`k-btn`,`k-btn--${r}`,a!==`md`&&`k-btn--${a}`,o!=="default"&&`k-btn--${o}`,t(this,`block`)&&`k-btn--block`,t(this,`icon-only`)&&`k-btn--icon`),e.dataset.variant=r,e.dataset.size=a,d){let t=e;t.type=this.getAttribute(`type`)??`button`,t.disabled=u}else{let t=this.getAttribute(`href`);t&&!f?e.setAttribute(`href`,t):e.removeAttribute(`href`)}for(let t of l){let n=this.getAttribute(t);n===null?e.removeAttribute(t):e.setAttribute(t,n)}let p=this.getAttribute(`label`);p?e.setAttribute(`aria-label`,p):e.removeAttribute(`aria-label`),f?e.setAttribute(`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`),s?e.setAttribute(`aria-busy`,`true`):e.removeAttribute(`aria-busy`);let m=e.querySelector(`:scope > [data-kashi-loading]`);s&&!m?e.insertAdjacentHTML(`beforeend`,`<span class="k-sr-only" role="status" data-kashi-loading>${n(this.getAttribute(`loading-label`)??i().common.loading)}</span>`):s||m?.remove()}};u.observedAttributes=[`variant`,`size`,`shape`,`loading`,`loading-label`,`block`,`icon-only`,`disabled`,`type`,`href`,`label`,...l];var d=class extends o{constructor(){super(...arguments),this.box=null}connectedCallback(){a(()=>{this.isConnected&&(this.box||(this.box=document.createElement(`div`),this.box.setAttribute(`role`,`group`),this.box.className=`k-btn-group`,this.box.append(...this.childNodes),this.append(this.box),this.box.addEventListener(`click`,e=>this.onClick(e))),this.update())})}attributeChangedCallback(){this.box&&this.update()}get buttons(){return[...this.box.querySelectorAll(`:scope > .k-btn`)]}get value(){let e=this.box?this.buttons.filter(e=>e.getAttribute(`aria-pressed`)===`true`).map(e=>e.dataset.value??e.textContent?.trim()??``):[];return this.getAttribute(`toggle`)===`multiple`?e:e[0]??``}set value(e){let t=Array.isArray(e)?e:[e];a(()=>this.box&&this.buttons.forEach(e=>e.setAttribute(`aria-pressed`,String(t.includes(e.dataset.value??``)))))}update(){let e=this.getAttribute(`label`);if(e?this.box.setAttribute(`aria-label`,e):this.box.removeAttribute(`aria-label`),this.getAttribute(`toggle`))for(let e of this.buttons)e.hasAttribute(`aria-pressed`)||e.setAttribute(`aria-pressed`,`false`)}onClick(t){let n=this.getAttribute(`toggle`),r=t.target.closest(`.k-btn`);if(!n||!r||r.parentElement!==this.box||r.disabled)return;let i=r.getAttribute(`aria-pressed`)===`true`;if(n===`single`)for(let e of this.buttons)e.setAttribute(`aria-pressed`,`false`);r.setAttribute(`aria-pressed`,String(!i)),e(this,`kashi-change`,{value:this.value})}};d.observedAttributes=[`label`,`toggle`];var f=class extends o{constructor(){super(...arguments),this.box=null,this.current=``,this.ro=null,this.key=s(`kashi-seg`)}connectedCallback(){a(()=>{this.isConnected&&(this.box||this.build(),this.update(),typeof ResizeObserver<`u`&&!this.ro&&(this.ro=new ResizeObserver(()=>this.measure()),this.ro.observe(this.box)))})}disconnectedCallback(){this.ro?.disconnect(),this.ro=null}attributeChangedCallback(e,t,n){this.box&&t!==n&&(e===`value`?this.select(n??``,!1):this.update())}get value(){return this.current}set value(e){this.box?this.select(String(e??``),!1):this.setAttribute(`value`,String(e??``))}build(){let e=[...this.querySelectorAll(`:scope > option`)],n=document.createElement(`div`);n.setAttribute(`role`,`radiogroup`),n.innerHTML=`<span class="k-segmented__indicator" aria-hidden="true"></span>`;for(let t of e){let e=document.createElement(`label`);e.className=`k-segmented__item`;let r=document.createElement(`input`);r.type=`radio`,r.className=`k-sr-only`,r.value=t.value,r.disabled=t.disabled,t.disabled&&r.setAttribute(`data-off`,``);let i=t.getAttribute(`aria-label`);i&&r.setAttribute(`aria-label`,i),e.append(r),t.dataset.icon&&e.insertAdjacentHTML(`beforeend`,t.dataset.icon),t.textContent?.trim()&&e.append(t.textContent.trim()),n.append(e)}for(let t of e)t.remove();this.current=this.getAttribute(`value`)??e.find(e=>e.selected&&e.hasAttribute(`selected`))?.value??e.find(e=>!e.disabled)?.value??``,n.addEventListener(`change`,e=>{let n=e.target;t(this,`readonly`)?this.paint():this.select(n.value,!0)}),n.addEventListener(`click`,e=>{t(this,`readonly`)&&e.target.closest(`input`)&&e.preventDefault()}),this.append(n),this.box=n}select(t,n){if(t===this.current&&!n)return this.paint();this.current=t,this.paint(),n&&e(this,`kashi-change`,{value:t})}update(){let e=this.box;e.className=c(`k-segmented`,this.getAttribute(`size`)===`sm`&&`k-segmented--sm`,t(this,`block`)&&`k-segmented--block`);let n=this.getAttribute(`label`)??this.getAttribute(`aria-label`);n?e.setAttribute(`aria-label`,n):e.removeAttribute(`aria-label`);let r=t(this,`readonly`);e.toggleAttribute(`data-readonly`,r),r?e.setAttribute(`aria-readonly`,`true`):e.removeAttribute(`aria-readonly`);let i=this.getAttribute(`name`)??this.key,a=t(this,`disabled`);for(let t of e.querySelectorAll(`input`))t.name=i,a?t.disabled=!0:t.hasAttribute(`data-off`)||(t.disabled=!1);this.paint()}paint(){for(let e of this.box.querySelectorAll(`input`))e.checked=e.value===this.current;this.measure()}measure(){let e=this.box;if(!e)return;let t=[...e.querySelectorAll(`.k-segmented__item`)].find(e=>e.querySelector(`input`).checked);!t||!t.offsetWidth?e.removeAttribute(`data-indicator`):(e.style.setProperty(`--_ix`,`${t.offsetLeft}px`),e.style.setProperty(`--_iw`,`${t.offsetWidth}px`),e.setAttribute(`data-indicator`,``))}};f.observedAttributes=[`value`,`name`,`size`,`block`,`disabled`,`readonly`,`label`,`aria-label`];var p=class extends o{constructor(){super(...arguments),this.nav=null,this.items=[],this.expanded=!1}connectedCallback(){a(()=>{this.isConnected&&(this.nav||this.build(),this.update())})}attributeChangedCallback(){this.nav&&this.update()}build(){this.items=[...this.children].filter(e=>e instanceof HTMLElement);for(let e of this.items){let t=e.hasAttribute(`data-icon-only`);e.classList.add(`k-breadcrumb__link`),t&&e.classList.add(`k-breadcrumb__link--icon`);let n=[...e.childNodes].filter(e=>e.nodeType===3&&e.textContent?.trim()),r=n.map(e=>e.textContent.trim()).join(` `);if(n.length){let i=document.createElement(`span`);i.className=t?`k-sr-only`:`k-breadcrumb__text`,i.textContent=r,n[0].replaceWith(i);for(let e of n.slice(1))e.remove();!t&&!e.title&&(e.title=r)}}this.nav=document.createElement(`nav`),this.nav.innerHTML=`<ol></ol>`,this.replaceChildren(this.nav),this.nav.addEventListener(`click`,e=>{e.target.closest(`[data-expand]`)&&(this.expanded=!0,this.update(),this.nav.querySelectorAll(`.k-breadcrumb__link`)[1]?.focus())})}update(){let e=this.nav;e.className=c(`k-breadcrumb`,this.getAttribute(`separator`)===`slash`&&`k-breadcrumb--slash`),e.setAttribute(`aria-label`,this.getAttribute(`label`)??i().breadcrumb.label);let t=Number(this.getAttribute(`max-items`))||0,r=this.items,a=!this.expanded&&t>=2&&r.length>t?[r[0],`…`,...r.slice(r.length-(t-1))]:r;r.forEach((e,t)=>{t===r.length-1?e.setAttribute(`aria-current`,`page`):e.getAttribute(`aria-current`)===`page`&&e.removeAttribute(`aria-current`)}),e.querySelector(`ol`).replaceChildren(...a.map(e=>{let t=document.createElement(`li`);return e===`…`?t.innerHTML=`<button type="button" class="k-breadcrumb__link" data-expand aria-label="${n(this.getAttribute(`expand-label`)??i().breadcrumb.expand)}">…</button>`:t.append(e),t}))}};p.observedAttributes=[`max-items`,`separator`,`label`,`expand-label`];var m=class extends o{constructor(){super(...arguments),this.box=null,this.key=s(`k-acc`)}connectedCallback(){a(()=>{this.isConnected&&(this.box||this.build(),this.update())})}attributeChangedCallback(){this.box&&this.update()}get details(){return[...this.box.querySelectorAll(`:scope > details`)]}build(){let t=document.createElement(`div`);for(let e of[...this.children]){let n;if(e.tagName===`DETAILS`)n=e;else if(e.hasAttribute(`data-title`)){n=document.createElement(`details`),n.innerHTML=`<summary></summary>`,n.querySelector(`summary`).textContent=e.getAttribute(`data-title`),n.open=e.hasAttribute(`data-open`);let t=document.createElement(`div`);t.append(...e.childNodes),n.append(t)}else continue;n.classList.add(`k-accordion__item`);let r=n.querySelector(`:scope > summary`);r?.classList.add(`k-accordion__trigger`);let i=[...n.childNodes].filter(e=>e!==r);if(!(i.length===1&&i[0]instanceof HTMLElement&&i[0].classList.contains(`k-accordion__content`)&&i[0])){let e=document.createElement(`div`);e.className=`k-accordion__content`,e.append(...i),n.append(e)}t.append(n)}this.replaceChildren(t),this.box=t,t.addEventListener(`toggle`,n=>{let r=n.target;if(r.parentElement===t){if(r.open&&this.getAttribute(`type`)===`single`)for(let e of this.details)e!==r&&e.open&&(e.open=!1);e(this,`kashi-toggle`,{index:this.details.indexOf(r),open:r.open})}},!0)}update(){this.box.className=c(`k-accordion`,t(this,`flush`)&&`k-accordion--flush`);let e=this.getAttribute(`type`)===`single`;for(let t of this.details)e?t.setAttribute(`name`,this.key):t.removeAttribute(`name`)}};m.observedAttributes=[`type`,`flush`],r(`kashi-button`,u),r(`kashi-button-group`,d),r(`kashi-segmented-control`,f),r(`kashi-breadcrumb`,p,`block`),r(`kashi-accordion`,m,`block`);export{m as KashiAccordion,p as KashiBreadcrumb,u as KashiButton,d as KashiButtonGroup,f as KashiSegmentedControl};
|
|
1
|
+
import{c as e,i as t,l as n,o as r,p as i,r as a,t as o,y as s}from"./base-D4tCOysh.js";import{i as c}from"./parts-5fVaWtRe.js";const l=[`name`,`value`,`form`,`target`,`rel`,`download`,`aria-controls`,`aria-expanded`,`aria-haspopup`,`aria-pressed`,`aria-describedby`,`title`];var u=class extends o{constructor(){super(...arguments),this.el=null}connectedCallback(){a(()=>{this.isConnected&&(this.ensure(),this.update())})}attributeChangedCallback(e,t,n){this.el&&t!==n&&(this.ensure(),this.update())}get control(){return this.el}focus(e){this.el?.focus(e)}click(){this.el?.click()}ensure(){let e=this.hasAttribute(`href`)?`A`:`BUTTON`;if(this.el?.tagName===e)return;let t=document.createElement(e);t.append(...this.el?this.el.childNodes:this.childNodes),this.el?.remove(),this.el=t,this.append(t),t.addEventListener(`click`,e=>{t.getAttribute(`aria-disabled`)===`true`&&(e.preventDefault(),e.stopImmediatePropagation())})}update(){let e=this.el,r=this.getAttribute(`variant`)??`secondary`,a=this.getAttribute(`size`)??`md`,o=this.getAttribute(`shape`)??`default`,s=t(this,`loading`),u=t(this,`disabled`),d=e.tagName===`BUTTON`,f=s||!d&&u;if(e.className=c(`k-btn`,`k-btn--${r}`,a!==`md`&&`k-btn--${a}`,o!=="default"&&`k-btn--${o}`,t(this,`block`)&&`k-btn--block`,t(this,`icon-only`)&&`k-btn--icon`),e.dataset.variant=r,e.dataset.size=a,d){let t=e;t.type=this.getAttribute(`type`)??`button`,t.disabled=u}else{let t=this.getAttribute(`href`);t&&!f?e.setAttribute(`href`,t):e.removeAttribute(`href`)}for(let t of l){let n=this.getAttribute(t);n===null?e.removeAttribute(t):e.setAttribute(t,n)}let p=this.getAttribute(`label`);p?e.setAttribute(`aria-label`,p):e.removeAttribute(`aria-label`),f?e.setAttribute(`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`),s?e.setAttribute(`aria-busy`,`true`):e.removeAttribute(`aria-busy`);let m=e.querySelector(`:scope > [data-kashi-loading]`);s&&!m?e.insertAdjacentHTML(`beforeend`,`<span class="k-sr-only" role="status" data-kashi-loading>${n(this.getAttribute(`loading-label`)??i().common.loading)}</span>`):s||m?.remove()}};u.observedAttributes=[`variant`,`size`,`shape`,`loading`,`loading-label`,`block`,`icon-only`,`disabled`,`type`,`href`,`label`,...l];var d=class extends o{constructor(){super(...arguments),this.box=null}connectedCallback(){a(()=>{this.isConnected&&(this.box||(this.box=document.createElement(`div`),this.box.setAttribute(`role`,`group`),this.box.className=`k-btn-group`,this.box.append(...this.childNodes),this.append(this.box),this.box.addEventListener(`click`,e=>this.onClick(e))),this.update())})}attributeChangedCallback(){this.box&&this.update()}get buttons(){return[...this.box.querySelectorAll(`:scope > .k-btn`)]}get value(){let e=this.box?this.buttons.filter(e=>e.getAttribute(`aria-pressed`)===`true`).map(e=>e.dataset.value??e.textContent?.trim()??``):[];return this.getAttribute(`toggle`)===`multiple`?e:e[0]??``}set value(e){let t=Array.isArray(e)?e:[e];a(()=>this.box&&this.buttons.forEach(e=>e.setAttribute(`aria-pressed`,String(t.includes(e.dataset.value??``)))))}update(){let e=this.getAttribute(`label`);if(e?this.box.setAttribute(`aria-label`,e):this.box.removeAttribute(`aria-label`),this.getAttribute(`toggle`))for(let e of this.buttons)e.hasAttribute(`aria-pressed`)||e.setAttribute(`aria-pressed`,`false`)}onClick(t){let n=this.getAttribute(`toggle`),r=t.target.closest(`.k-btn`);if(!n||!r||r.parentElement!==this.box||r.disabled)return;let i=r.getAttribute(`aria-pressed`)===`true`;if(n===`single`)for(let e of this.buttons)e.setAttribute(`aria-pressed`,`false`);r.setAttribute(`aria-pressed`,String(!i)),e(this,`kashi-change`,{value:this.value})}};d.observedAttributes=[`label`,`toggle`];var f=class extends o{constructor(){super(...arguments),this.box=null,this.current=``,this.ro=null,this.key=s(`kashi-seg`)}connectedCallback(){a(()=>{this.isConnected&&(this.box||this.build(),this.update(),typeof ResizeObserver<`u`&&!this.ro&&(this.ro=new ResizeObserver(()=>this.measure()),this.ro.observe(this.box)))})}disconnectedCallback(){this.ro?.disconnect(),this.ro=null}attributeChangedCallback(e,t,n){this.box&&t!==n&&(e===`value`?this.select(n??``,!1):this.update())}get value(){return this.current}set value(e){this.box?this.select(String(e??``),!1):this.setAttribute(`value`,String(e??``))}build(){let e=[...this.querySelectorAll(`:scope > option`)],n=document.createElement(`div`);n.setAttribute(`role`,`radiogroup`),n.innerHTML=`<span class="k-segmented__indicator" aria-hidden="true"></span>`;for(let t of e){let e=document.createElement(`label`);e.className=`k-segmented__item`;let r=document.createElement(`input`);r.type=`radio`,r.className=`k-sr-only`,r.value=t.value,r.disabled=t.disabled,t.disabled&&r.setAttribute(`data-off`,``);let i=t.getAttribute(`aria-label`);i&&r.setAttribute(`aria-label`,i),e.append(r),t.dataset.icon&&e.insertAdjacentHTML(`beforeend`,t.dataset.icon),t.textContent?.trim()&&e.append(t.textContent.trim()),n.append(e)}for(let t of e)t.remove();this.current=this.getAttribute(`value`)??e.find(e=>e.selected&&e.hasAttribute(`selected`))?.value??e.find(e=>!e.disabled)?.value??``,n.addEventListener(`change`,e=>{let n=e.target;t(this,`readonly`)?this.paint():this.select(n.value,!0)}),n.addEventListener(`click`,e=>{t(this,`readonly`)&&e.target.closest(`input`)&&e.preventDefault()}),this.append(n),this.box=n}select(t,n){if(t===this.current&&!n)return this.paint();this.current=t,this.paint(),n&&e(this,`kashi-change`,{value:t})}update(){let e=this.box;e.className=c(`k-segmented`,this.getAttribute(`size`)===`sm`&&`k-segmented--sm`,t(this,`block`)&&`k-segmented--block`);let n=this.getAttribute(`label`)??this.getAttribute(`aria-label`);n?e.setAttribute(`aria-label`,n):e.removeAttribute(`aria-label`);let r=t(this,`readonly`);e.toggleAttribute(`data-readonly`,r),r?e.setAttribute(`aria-readonly`,`true`):e.removeAttribute(`aria-readonly`);let i=this.getAttribute(`name`)??this.key,a=t(this,`disabled`);for(let t of e.querySelectorAll(`input`))t.name=i,a?t.disabled=!0:t.hasAttribute(`data-off`)||(t.disabled=!1);this.paint()}paint(){for(let e of this.box.querySelectorAll(`input`))e.checked=e.value===this.current;this.measure()}measure(){let e=this.box;if(!e)return;let t=[...e.querySelectorAll(`.k-segmented__item`)].find(e=>e.querySelector(`input`).checked);!t||!t.offsetWidth?e.removeAttribute(`data-indicator`):(e.style.setProperty(`--_ix`,`${t.offsetLeft}px`),e.style.setProperty(`--_iw`,`${t.offsetWidth}px`),e.setAttribute(`data-indicator`,``))}};f.observedAttributes=[`value`,`name`,`size`,`block`,`disabled`,`readonly`,`label`,`aria-label`];var p=class extends o{constructor(){super(...arguments),this.nav=null,this.items=[],this.expanded=!1}connectedCallback(){a(()=>{this.isConnected&&(this.nav||this.build(),this.update())})}attributeChangedCallback(){this.nav&&this.update()}build(){this.items=[...this.children].filter(e=>e instanceof HTMLElement);for(let e of this.items){let t=e.hasAttribute(`data-icon-only`);e.classList.add(`k-breadcrumb__link`),t&&e.classList.add(`k-breadcrumb__link--icon`);let n=[...e.childNodes].filter(e=>e.nodeType===3&&e.textContent?.trim()),r=n.map(e=>e.textContent.trim()).join(` `);if(n.length){let i=document.createElement(`span`);i.className=t?`k-sr-only`:`k-breadcrumb__text`,i.textContent=r,n[0].replaceWith(i);for(let e of n.slice(1))e.remove();!t&&!e.title&&(e.title=r)}}this.nav=document.createElement(`nav`),this.nav.innerHTML=`<ol></ol>`,this.replaceChildren(this.nav),this.nav.addEventListener(`click`,e=>{e.target.closest(`[data-expand]`)&&(this.expanded=!0,this.update(),this.nav.querySelectorAll(`.k-breadcrumb__link`)[1]?.focus())})}update(){let e=this.nav;e.className=c(`k-breadcrumb`,this.getAttribute(`separator`)===`slash`&&`k-breadcrumb--slash`),e.setAttribute(`aria-label`,this.getAttribute(`label`)??i().breadcrumb.label);let t=Number(this.getAttribute(`max-items`))||0,r=this.items,a=!this.expanded&&t>=2&&r.length>t?[r[0],`…`,...r.slice(r.length-(t-1))]:r;r.forEach((e,t)=>{t===r.length-1?e.setAttribute(`aria-current`,`page`):e.getAttribute(`aria-current`)===`page`&&e.removeAttribute(`aria-current`)}),e.querySelector(`ol`).replaceChildren(...a.map(e=>{let t=document.createElement(`li`);return e===`…`?t.innerHTML=`<button type="button" class="k-breadcrumb__link" data-expand aria-label="${n(this.getAttribute(`expand-label`)??i().breadcrumb.expand)}">…</button>`:t.append(e),t}))}};p.observedAttributes=[`max-items`,`separator`,`label`,`expand-label`];var m=class extends o{constructor(){super(...arguments),this.box=null,this.key=s(`k-acc`)}connectedCallback(){a(()=>{this.isConnected&&(this.box||this.build(),this.update())})}attributeChangedCallback(){this.box&&this.update()}get details(){return[...this.box.querySelectorAll(`:scope > details`)]}build(){let t=document.createElement(`div`);for(let e of[...this.children]){let n;if(e.tagName===`DETAILS`)n=e;else if(e.hasAttribute(`data-title`)){n=document.createElement(`details`),n.innerHTML=`<summary></summary>`;let t=n.querySelector(`summary`),r=e.getAttribute(`data-description`);r?(t.innerHTML=`<span class="k-accordion__head"><span class="k-accordion__titles"><span class="k-accordion__title"></span><span class="k-accordion__description"></span></span></span>`,t.querySelector(`.k-accordion__title`).textContent=e.getAttribute(`data-title`),t.querySelector(`.k-accordion__description`).textContent=r):t.textContent=e.getAttribute(`data-title`),n.open=e.hasAttribute(`data-open`),e.hasAttribute(`data-disabled`)&&n.setAttribute(`data-disabled`,``),e.hasAttribute(`data-value`)&&(n.dataset.value=e.getAttribute(`data-value`));let i=document.createElement(`div`);i.append(...e.childNodes),n.append(i)}else continue;n.classList.add(`k-accordion__item`);let r=n.querySelector(`:scope > summary`);r?.classList.add(`k-accordion__trigger`),n.hasAttribute(`data-disabled`)&&r&&(n.classList.add(`k-accordion__item--disabled`),r.setAttribute(`aria-disabled`,`true`),r.tabIndex=-1,r.addEventListener(`click`,e=>e.preventDefault()));let i=[...n.childNodes].filter(e=>e!==r);if(!(i.length===1&&i[0]instanceof HTMLElement&&i[0].classList.contains(`k-accordion__content`)&&i[0])){let e=document.createElement(`div`);e.className=`k-accordion__content`,e.append(...i),n.append(e)}t.append(n)}this.replaceChildren(t),this.box=t,t.addEventListener(`toggle`,n=>{let r=n.target;if(r.parentElement===t){if(r.open&&this.getAttribute(`type`)===`single`)for(let e of this.details)e!==r&&e.open&&(e.open=!1);e(this,`kashi-toggle`,{index:this.details.indexOf(r),value:r.dataset.value,open:r.open})}},!0)}update(){this.box.className=c(`k-accordion`,t(this,`flush`)&&`k-accordion--flush`,this.getAttribute(`size`)===`sm`&&`k-accordion--sm`);let e=this.getAttribute(`type`)===`single`;for(let t of this.details)e?t.setAttribute(`name`,this.key):t.removeAttribute(`name`)}};m.observedAttributes=[`type`,`flush`,`size`],r(`kashi-button`,u),r(`kashi-button-group`,d),r(`kashi-segmented-control`,f),r(`kashi-breadcrumb`,p,`block`),r(`kashi-accordion`,m,`block`);export{m as KashiAccordion,p as KashiBreadcrumb,u as KashiButton,d as KashiButtonGroup,f as KashiSegmentedControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,l as t,n,o as r,p as i,t as a}from"./base-D4tCOysh.js";let o=1;function s(){let e=document.querySelectorAll(`kashi-toaster`);if(e.length)return e[e.length-1];let t=document.createElement(`kashi-toaster`);return document.body.append(t),t}function c(e){let t=e.id??o++;return s().upsert({...e,id:t}),t}function l(e){return c(typeof e==`string`?{title:e}:e)}l.success=(e,t={})=>l({...t,title:e,tone:`success`}),l.error=(e,t={})=>l({...t,title:e,tone:`error`}),l.warning=(e,t={})=>l({...t,title:e,tone:`warning`}),l.info=(e,t={})=>l({...t,title:e,tone:`info`}),l.dismiss=e=>document.querySelectorAll(`kashi-toaster`).forEach(t=>t.dismiss(e)),l.promise=(e,t)=>{let n=c({title:t.loading,tone:`info`,duration:1/0,loading:!0});return e.then(e=>c({id:n,title:typeof t.success==`function`?t.success(e):t.success,tone:`success`}),e=>c({id:n,title:typeof t.error==`function`?t.error(e):t.error,tone:`error`})),e};var u=class extends a{constructor(){super(...arguments),this.list=null}connectedCallback(){this.list||=(this.innerHTML=`<section><ol class="k-toaster" aria-live="polite"></ol></section>`,this.querySelector(`ol`)),this.decorate()}attributeChangedCallback(){this.list&&this.decorate()}decorate(){let e=this.getAttribute(`placement`)??`bottom-end`;this.list.className=`k-toaster k-toaster--${e}`,this.list.dataset.placement=e,this.querySelector(`section`).setAttribute(`aria-label`,this.getAttribute(`label`)??i().toast.region)}upsert(e){this.list||this.connectedCallback();let t=[...this.list.children].find(t=>t.toastId===e.id),n=d(e,this.getAttribute(`close-label`)??i().toast.close,()=>this.dismiss(e.id));t?(t.stop?.(),t.replaceWith(n)):this.list.append(n);let r=Number(this.getAttribute(`max`))||5;for(;this.list.children.length>r;)this.list.firstElementChild.stop?.(),this.list.firstElementChild.remove()}dismiss(e){let t=[...this.list?.children??[]].find(t=>t.toastId===e);t&&t.dataset.state!==`closing`&&(t.stop?.(),t.dataset.state=`closing`,setTimeout(()=>t.remove(),200))}};u.observedAttributes=[`placement`,`label`];function d(e,r,i){let a=e.duration??(e.action?1/0:5e3),o=e.tone??`neutral`,s=document.createElement(`li`);s.toastId=e.id,s.className=`k-toast${o===`neutral`?``:` k-toast--${o}`}`,s.dataset.state=`open`,s.setAttribute(`role`,o===`error`?`alert`:`status`),s.innerHTML=`<span class="k-toast__icon" aria-hidden="true">${e.loading?`<span class="k-spinner k-spinner--sm" style="color: inherit"></span>`:n[o===`neutral`?`info`:o]}</span><div class="k-toast__content"><p class="k-toast__title">${t(e.title)}</p>${e.description?`<p class="k-toast__description">${t(e.description)}</p>`:``}${e.action?`<button type="button" class="k-btn k-btn--link k-toast__action">${t(e.action.label)}</button>`:``}</div><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-toast__close" aria-label="${t(r)}">${n.close}</button>${Number.isFinite(a)?`<span class="k-toast__progress" aria-hidden="true" style="animation-duration: ${a}ms"></span>`:``}`,s.querySelector(`.k-toast__close`).addEventListener(`click`,i),s.querySelector(`.k-toast__action`)?.addEventListener(`click`,()=>{e.action.onClick(),i()}),s.addEventListener(`keydown`,e=>e.key===`Escape`&&i());let c=a,l=0,u,d=()=>{u===void 0&&Number.isFinite(c)&&(l=Date.now(),u=setTimeout(i,c))},f=()=>{u!==void 0&&(clearTimeout(u),u=void 0,c-=Date.now()-l)};return s.addEventListener(`mouseenter`,f),s.addEventListener(`focusin`,f),s.addEventListener(`mouseleave`,d),s.addEventListener(`focusout`,d),s.stop=()=>{clearTimeout(u),c=1/0},d(),s}r(`kashi-toaster`,u),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-toast]`);t&&l({title:t.dataset.kashiToast,description:t.dataset.description,tone:t.dataset.tone??`neutral`})});const f=/* @__PURE__ */ new Set([[[`kashi-national-id`,`kashi-legal-id`,`kashi-mobile`,`kashi-landline`,`kashi-card-number`,`kashi-iban`,`kashi-postal-code`,`kashi-price`,`kashi-sayad`,`kashi-economic-code`,`kashi-tax-id`],()=>import(`./inputs-BkJ70Xkc.js`)],[[`kashi-otp`],()=>import(`./fields-B-jTUQiI.js`)],[[`kashi-combobox`,`kashi-province-select`,`kashi-city-select`],()=>import(`./combobox-BGuPAAt3.js`).then(e=>e.t)],[[`kashi-iran-map`,`kashi-address-form`],()=>import(`./map-TfSt3CjL.js`)],[[`kashi-calendar`,`kashi-date-picker`],()=>import(`./calendar-BulPeVAJ.js`)],[[`kashi-time-picker`,`kashi-time-clock`],()=>import(`./time-CkqqUKJv.js`)],[[`kashi-money`,`kashi-date`,`kashi-relative-time`,`kashi-countdown`],()=>import(`./display-BfYWAjNu.js`)],[[`kashi-dialog`,`kashi-tabs`,`kashi-tooltip`,`kashi-copy-button`],()=>import(`./overlay-
|
|
1
|
+
import{g as e,l as t,n,o as r,p as i,t as a}from"./base-D4tCOysh.js";let o=1;function s(){let e=document.querySelectorAll(`kashi-toaster`);if(e.length)return e[e.length-1];let t=document.createElement(`kashi-toaster`);return document.body.append(t),t}function c(e){let t=e.id??o++;return s().upsert({...e,id:t}),t}function l(e){return c(typeof e==`string`?{title:e}:e)}l.success=(e,t={})=>l({...t,title:e,tone:`success`}),l.error=(e,t={})=>l({...t,title:e,tone:`error`}),l.warning=(e,t={})=>l({...t,title:e,tone:`warning`}),l.info=(e,t={})=>l({...t,title:e,tone:`info`}),l.dismiss=e=>document.querySelectorAll(`kashi-toaster`).forEach(t=>t.dismiss(e)),l.promise=(e,t)=>{let n=c({title:t.loading,tone:`info`,duration:1/0,loading:!0});return e.then(e=>c({id:n,title:typeof t.success==`function`?t.success(e):t.success,tone:`success`}),e=>c({id:n,title:typeof t.error==`function`?t.error(e):t.error,tone:`error`})),e};var u=class extends a{constructor(){super(...arguments),this.list=null}connectedCallback(){this.list||=(this.innerHTML=`<section><ol class="k-toaster" aria-live="polite"></ol></section>`,this.querySelector(`ol`)),this.decorate()}attributeChangedCallback(){this.list&&this.decorate()}decorate(){let e=this.getAttribute(`placement`)??`bottom-end`;this.list.className=`k-toaster k-toaster--${e}`,this.list.dataset.placement=e,this.querySelector(`section`).setAttribute(`aria-label`,this.getAttribute(`label`)??i().toast.region)}upsert(e){this.list||this.connectedCallback();let t=[...this.list.children].find(t=>t.toastId===e.id),n=d(e,this.getAttribute(`close-label`)??i().toast.close,()=>this.dismiss(e.id));t?(t.stop?.(),t.replaceWith(n)):this.list.append(n);let r=Number(this.getAttribute(`max`))||5;for(;this.list.children.length>r;)this.list.firstElementChild.stop?.(),this.list.firstElementChild.remove()}dismiss(e){let t=[...this.list?.children??[]].find(t=>t.toastId===e);t&&t.dataset.state!==`closing`&&(t.stop?.(),t.dataset.state=`closing`,setTimeout(()=>t.remove(),200))}};u.observedAttributes=[`placement`,`label`];function d(e,r,i){let a=e.duration??(e.action?1/0:5e3),o=e.tone??`neutral`,s=document.createElement(`li`);s.toastId=e.id,s.className=`k-toast${o===`neutral`?``:` k-toast--${o}`}`,s.dataset.state=`open`,s.setAttribute(`role`,o===`error`?`alert`:`status`),s.innerHTML=`<span class="k-toast__icon" aria-hidden="true">${e.loading?`<span class="k-spinner k-spinner--sm" style="color: inherit"></span>`:n[o===`neutral`?`info`:o]}</span><div class="k-toast__content"><p class="k-toast__title">${t(e.title)}</p>${e.description?`<p class="k-toast__description">${t(e.description)}</p>`:``}${e.action?`<button type="button" class="k-btn k-btn--link k-toast__action">${t(e.action.label)}</button>`:``}</div><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-toast__close" aria-label="${t(r)}">${n.close}</button>${Number.isFinite(a)?`<span class="k-toast__progress" aria-hidden="true" style="animation-duration: ${a}ms"></span>`:``}`,s.querySelector(`.k-toast__close`).addEventListener(`click`,i),s.querySelector(`.k-toast__action`)?.addEventListener(`click`,()=>{e.action.onClick(),i()}),s.addEventListener(`keydown`,e=>e.key===`Escape`&&i());let c=a,l=0,u,d=()=>{u===void 0&&Number.isFinite(c)&&(l=Date.now(),u=setTimeout(i,c))},f=()=>{u!==void 0&&(clearTimeout(u),u=void 0,c-=Date.now()-l)};return s.addEventListener(`mouseenter`,f),s.addEventListener(`focusin`,f),s.addEventListener(`mouseleave`,d),s.addEventListener(`focusout`,d),s.stop=()=>{clearTimeout(u),c=1/0},d(),s}r(`kashi-toaster`,u),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-toast]`);t&&l({title:t.dataset.kashiToast,description:t.dataset.description,tone:t.dataset.tone??`neutral`})});const f=/* @__PURE__ */ new Set([[[`kashi-national-id`,`kashi-legal-id`,`kashi-mobile`,`kashi-landline`,`kashi-card-number`,`kashi-iban`,`kashi-postal-code`,`kashi-price`,`kashi-sayad`,`kashi-economic-code`,`kashi-tax-id`],()=>import(`./inputs-BkJ70Xkc.js`)],[[`kashi-otp`],()=>import(`./fields-B-jTUQiI.js`)],[[`kashi-combobox`,`kashi-province-select`,`kashi-city-select`],()=>import(`./combobox-BGuPAAt3.js`).then(e=>e.t)],[[`kashi-iran-map`,`kashi-address-form`],()=>import(`./map-TfSt3CjL.js`)],[[`kashi-calendar`,`kashi-date-picker`],()=>import(`./calendar-BulPeVAJ.js`)],[[`kashi-time-picker`,`kashi-time-clock`],()=>import(`./time-CkqqUKJv.js`)],[[`kashi-money`,`kashi-date`,`kashi-relative-time`,`kashi-countdown`],()=>import(`./display-BfYWAjNu.js`)],[[`kashi-dialog`,`kashi-tabs`,`kashi-tooltip`,`kashi-copy-button`],()=>import(`./overlay-CS8piW6X.js`)],[[`kashi-dropdown-menu`,`kashi-popover`],()=>import(`./menu-DTNVFXrb.js`)],[[`kashi-tag-input`,`kashi-number-input`,`kashi-rating`,`kashi-pagination`],()=>import(`./controls--OMZkJYe.js`)],[[`kashi-data-table`],()=>import(`./table-tgB4iwcM.js`)],[[`kashi-multi-select`,`kashi-slider`,`kashi-chip-group`,`kashi-password-strength`,`kashi-persian-textarea`,`kashi-keyboard-fix`,`kashi-time-input`,`kashi-plate-input`,`kashi-inline-edit`],()=>import(`./forms-DgRiYmdV.js`)],[[`kashi-date-range-picker`,`kashi-month-picker`,`kashi-file-upload`,`kashi-color-picker`],()=>import(`./pickers-BwDRsDRo.js`)],[[`kashi-bar-chart`,`kashi-line-chart`,`kashi-pie-chart`,`kashi-bar-list`,`kashi-proportion-bar`,`kashi-sparkline`,`kashi-activity-heatmap`],()=>import(`./charts-ETYOAJyB.js`)],[[`kashi-input`,`kashi-textarea`,`kashi-banner`],()=>import(`./basic-DuY4RslZ.js`)],[[`kashi-appointment-picker`],()=>import(`./appointment-DOXBUwIU.js`)],[[`kashi-price-range`,`kashi-swatch-group`,`kashi-search-suggest`],()=>import(`./commerce-SzWdpWJG.js`)],[[`kashi-command-palette`,`kashi-context-menu`,`kashi-carousel`,`kashi-tree-view`,`kashi-tour`,`kashi-splitter`,`kashi-side-nav`],()=>import(`./nav-CT5RVOzy.js`)],[[`kashi-badge`,`kashi-avatar`,`kashi-avatar-group`,`kashi-divider`,`kashi-skeleton`,`kashi-card`,`kashi-empty-state`,`kashi-stat-card`,`kashi-alert`,`kashi-meter`,`kashi-progress`,`kashi-timeline`,`kashi-stepper`],()=>import(`./content-BgfBfy8j.js`)],[[`kashi-button`,`kashi-button-group`,`kashi-segmented-control`,`kashi-breadcrumb`,`kashi-accordion`],()=>import(`./buttons-BaK6bx3w.js`)],[[`kashi-checkbox`,`kashi-switch`,`kashi-radio-group`,`kashi-select`],()=>import(`./choice-DBvC2Puo.js`)],[[`kashi-drawer`,`kashi-bottom-sheet`,`kashi-navbar`,`kashi-notification-list`,`kashi-notification-center`],()=>import(`./sheets-eVMx4d-5.js`)],[[`kashi-chat`,`kashi-chat-message`,`kashi-typing-indicator`,`kashi-chat-composer`,`kashi-streaming-text`,`kashi-code-block`],()=>import(`./chat-D5ZIMnNp.js`)],[[`kashi-sortable`,`kashi-kanban`,`kashi-scheduler`],()=>import(`./work-DoNAKgVU.js`)],[[`kashi-gallery`,`kashi-qr-code`],()=>import(`./media-BRBINvzU.js`)],[[`kashi-rich-text`],()=>import(`./rich-text-CS6xEim6.js`)],[[`kashi-form`],()=>import(`./validate-Dr2f6i6s.js`)],[[`kashi-bank-card`,`kashi-receipt`,`kashi-date-tile`],()=>import(`./cards-DKarXHsC.js`)],[[`kashi-business-hours`],()=>import(`./hours-CeiVqPKD.js`)]]);function p(){for(let e of f)document.querySelector(e[0].join(`,`))&&(f.delete(e),e[1]().catch(e=>console.error(`[kashi] بارگذاری نشد:`,e)));f.size||h?.disconnect()}function m(){let e=[...f].map(([,e])=>e());return f.clear(),h?.disconnect(),Promise.all(e)}let h=null;typeof document<`u`&&(p(),h=new MutationObserver(p),h.observe(document.documentElement,{childList:!0,subtree:!0}));export{m as loadAll,e as setLocale,l as toast};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,c as t,h as n,i as r,l as i,n as a,o,p as s,r as c,t as l,y as u}from"./base-D4tCOysh.js";var d=class extends l{constructor(){super(...arguments),this.dialog=null,this.opener=null,this.key=u(`kashi-dialog`)}connectedCallback(){c(()=>{this.isConnected&&(this.dialog||this.build(),this.sync())})}attributeChangedCallback(e,t,n){this.dialog&&t!==n&&(e===`open`?this.sync():this.decorate())}get open(){return this.hasAttribute(`open`)}set open(e){this.toggleAttribute(`open`,!!e)}show(){this.open=!0}close(e){this.dialog?.open?this.dialog.close(e):this.open=!1}build(){let e=[...this.children].filter(e=>e.getAttribute(`slot`)===`footer`),n=[...this.childNodes].filter(t=>!e.includes(t)),i=document.createElement(`dialog`);if(i.setAttribute(`aria-labelledby`,`${this.key}-title`),i.innerHTML=`<div class="k-dialog__header"><div class="k-dialog__heading"><h2 class="k-dialog__title" id="${this.key}-title"></h2><p class="k-dialog__description" id="${this.key}-desc"></p></div><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-dialog__close">${a.close}</button></div>`,n.some(e=>e.nodeType===1||e.textContent?.trim())){let e=document.createElement(`div`);e.className=`k-dialog__body`,e.append(...n),i.append(e)}if(e.length){let t=document.createElement(`div`);t.className=`k-dialog__footer`;for(let n of e)n.removeAttribute(`slot`),t.append(n);i.append(t)}this.replaceChildren(i),this.dialog=i,i.querySelector(`.k-dialog__close`).addEventListener(`click`,()=>this.close()),i.addEventListener(`click`,e=>{e.target===i&&r(this,`dismissible`,!0)&&this.close();let t=e.target.closest(`[data-kashi-close]`);t&&i.contains(t)&&this.close(t.getAttribute(`data-kashi-close`)||void 0)}),i.addEventListener(`close`,()=>{this.removeAttribute(`open`),this.opener?.focus?.(),t(this,`kashi-close`,{returnValue:i.returnValue})}),this.decorate()}decorate(){let e=this.dialog,t=this.getAttribute(`size`)??`md`,n=this.getAttribute(`placement`)??`center`;e.className=[`k-dialog`,t!==`md`&&`k-dialog--${t}`,n!==`center`&&`k-dialog--${n}`,this.getAttribute(`tone`)===`danger`&&`k-dialog--danger`].filter(Boolean).join(` `),e.dataset.placement=n,e.querySelector(`.k-dialog__title`).textContent=this.getAttribute(`heading`)??``;let r=e.querySelector(`.k-dialog__description`),i=this.getAttribute(`description`);r.textContent=i??``,r.hidden=!i,i?e.setAttribute(`aria-describedby`,r.id):e.removeAttribute(`aria-describedby`),e.querySelector(`.k-dialog__close`).setAttribute(`aria-label`,this.getAttribute(`close-label`)??s().common.close)}sync(){let e=this.dialog;e&&this.isConnected&&(this.open&&!e.open?(this.opener=document.activeElement,e.showModal?.(),t(this,`kashi-open`,{})):!this.open&&e.open&&e.close())}};d.observedAttributes=[`open`,`heading`,`description`,`tone`,`size`,`placement`,`close-label`];var f=class extends l{constructor(){super(...arguments),this.list=null,this.key=u(`kashi-tabs`),this.ro=null}connectedCallback(){c(()=>this.isConnected&&this.setup())}setup(){this.list||this.build(),this.decorate(),this.select(this.getAttribute(`value`)??this.panels[0]?.dataset.value??``,!1),typeof ResizeObserver<`u`&&!this.ro&&(this.ro=new ResizeObserver(()=>this.measure()),this.ro.observe(this.list))}disconnectedCallback(){this.ro?.disconnect(),this.ro=null}attributeChangedCallback(e,t,n){this.list&&t!==n&&(e===`value`?this.select(n??``,!1):this.decorate())}get value(){return this.getAttribute(`value`)??``}set value(e){this.setAttribute(`value`,e)}get panels(){return[...this.children].filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-tab`))}build(){let e=document.createElement(`div`);e.setAttribute(`role`,`tablist`),e.className=`k-tabs__list`,this.panels.forEach((t,n)=>{let r=t.dataset.value||String(n+1);t.dataset.value=r;let i=document.createElement(`button`);i.type=`button`,i.setAttribute(`role`,`tab`),i.className=`k-tabs__tab`,i.id=`${this.key}-tab-${n}`,i.dataset.value=r,i.textContent=t.dataset.tab??``,t.hasAttribute(`data-disabled`)&&(i.disabled=!0),t.id||=`${this.key}-panel-${n}`,i.setAttribute(`aria-controls`,t.id),t.setAttribute(`role`,`tabpanel`),t.setAttribute(`aria-labelledby`,i.id),t.tabIndex=0,t.classList.add(`k-tabs__panel`),e.append(i)});let t=document.createElement(`span`);t.className=`k-tabs__indicator`,t.setAttribute(`aria-hidden`,`true`),e.append(t),e.addEventListener(`click`,e=>{let t=e.target.closest(`[role="tab"]`);t&&!t.disabled&&this.select(t.dataset.value,!0)}),e.addEventListener(`keydown`,e=>this.onKey(e)),this.prepend(e),this.list=e}decorate(){let e=this.getAttribute(`variant`)??`line`,t=this.getAttribute(`orientation`)===`vertical`;for(let e of[...this.classList])e.startsWith(`k-tabs`)&&this.classList.remove(e);this.classList.add(`k-tabs`,`k-tabs--${e}`),r(this,`block`)&&this.classList.add(`k-tabs--block`),t&&this.classList.add(`k-tabs--vertical`),this.getAttribute(`size`)===`sm`&&this.classList.add(`k-tabs--sm`),this.dataset.orientation=t?`vertical`:`horizontal`,this.list.setAttribute(`aria-orientation`,t?`vertical`:`horizontal`);let n=this.getAttribute(`label`);n&&this.list.setAttribute(`aria-label`,n),this.measure()}select(e,n){let r=[...this.list.querySelectorAll(`[role="tab"]`)];r.some(t=>t.dataset.value===e)||(e=r[0]?.dataset.value??``);for(let t of r){let n=t.dataset.value===e;t.setAttribute(`aria-selected`,String(n)),t.tabIndex=n?0:-1}for(let t of this.panels)t.hidden=t.dataset.value!==e;this.getAttribute(`value`)!==e&&this.setAttribute(`value`,e),this.measure(),n&&t(this,`kashi-change`,{value:e})}measure(){let e=this.list,t=e?.querySelector(`[role="tab"][aria-selected="true"]`);!e||!t||!t.offsetWidth?e?.removeAttribute(`data-indicator`):(e.setAttribute(`data-indicator`,``),e.style.setProperty(`--_ix`,`${t.offsetLeft}px`),e.style.setProperty(`--_iy`,`${t.offsetTop}px`),e.style.setProperty(`--_iw`,`${t.offsetWidth}px`),e.style.setProperty(`--_ih`,`${t.offsetHeight}px`))}onKey(e){let t=[...this.list.querySelectorAll(`[role="tab"]:not(:disabled)`)],n=t.indexOf(document.activeElement);if(n<0)return;let r=getComputedStyle(this.list).direction===`rtl`,i=this.getAttribute(`orientation`)===`vertical`?{ArrowDown:n+1,ArrowUp:n-1,Home:0,End:t.length-1}:{ArrowLeft:r?n+1:n-1,ArrowRight:r?n-1:n+1,Home:0,End:t.length-1};if(!(e.key in i))return;e.preventDefault();let a=t[(i[e.key]+t.length)%t.length];a.focus(),this.select(a.dataset.value,!0)}};f.observedAttributes=[`value`,`variant`,`block`,`orientation`,`size`,`label`];var p=class extends l{constructor(){super(...arguments),this.tip=null,this.key=u(`kashi-tip`),this.place=()=>n(this,this.tip,this.getAttribute(`placement`)||`top`),this.onKey=e=>{e.key===`Escape`&&(clearTimeout(this.timer),this.close())}}connectedCallback(){c(()=>this.isConnected&&this.setup())}setup(){if(!this.tip){this.classList.add(`k-tooltip-anchor`);let e=document.createElement(`span`);e.setAttribute(`role`,`tooltip`),e.id=this.key,e.hidden=!0,e.setAttribute(`popover`,`manual`),this.append(e),this.tip=e;let t=this.firstElementChild===e?null:this.firstElementChild;t&&t.setAttribute(`aria-describedby`,[t.getAttribute(`aria-describedby`),this.key].filter(Boolean).join(` `)),this.addEventListener(`mouseenter`,()=>this.show(Number(this.getAttribute(`delay`)??300))),this.addEventListener(`mouseleave`,()=>this.hide()),this.addEventListener(`focusin`,()=>this.show(0)),this.addEventListener(`focusout`,()=>this.hide())}this.decorate()}disconnectedCallback(){clearTimeout(this.timer),this.close()}attributeChangedCallback(){this.tip&&this.decorate(),this.tip&&!this.tip.hidden&&this.place()}open(){let e=this.tip;e.hidden&&(e.hidden=!1,this.place(),document.addEventListener(`keydown`,this.onKey),addEventListener(`scroll`,this.place,{capture:!0,passive:!0}),addEventListener(`resize`,this.place))}close(){this.tip&&(this.tip.hidden=!0,e(this.tip),document.removeEventListener(`keydown`,this.onKey),removeEventListener(`scroll`,this.place,{capture:!0}),removeEventListener(`resize`,this.place))}decorate(){let e=this.getAttribute(`placement`);this.tip.className=`k-tooltip${e&&e!==`top`?` k-tooltip--${e}`:``}`,this.tip.textContent=this.getAttribute(`content`)??``}show(e){clearTimeout(this.timer),this.timer=setTimeout(()=>this.open(),e)}hide(){clearTimeout(this.timer),this.timer=setTimeout(()=>this.close(),100)}};p.observedAttributes=[`content`,`placement`];var m=class extends l{constructor(){super(...arguments),this.state=`idle`,this.built=!1}connectedCallback(){this.built||(this.built=!0,this.addEventListener(`click`,e=>{e.target.closest(`button`)&&this.copy()})),this.render()}disconnectedCallback(){clearTimeout(this.timer)}attributeChangedCallback(){this.built&&this.render()}get text(){let e=this.getAttribute(`value`);if(e!==null)return e;let t=this.getAttribute(`target`),n=t?document.querySelector(t):null;return n?typeof n.value==`string`?n.value:(n.textContent??``).trim():``}async copy(){try{await navigator.clipboard.writeText(this.text),this.state=`copied`,t(this,`kashi-copy`,{value:this.text})}catch{this.state=`failed`}this.render(),clearTimeout(this.timer),this.timer=setTimeout(()=>{this.state=`idle`,this.render()},Number(this.getAttribute(`timeout`))||2e3)}render(){let e=this.getAttribute(`label`)??s().copy.copy,t=this.getAttribute(`copied-label`)??s().copy.copied,n=this.state===`copied`?t:this.state===`failed`?s().copy.failed:e,o=r(this,`icon-only`),c=this.state===`copied`?a.check:a.copy,l=this.getAttribute(`variant`)??`secondary`,u=this.getAttribute(`size`)??`sm`,d=this.contains(document.activeElement);this.innerHTML=`<button type="button" class="k-btn k-btn--${i(l)}${u===`md`?``:` k-btn--${i(u)}`}${o?` k-btn--icon`:``}" data-variant="${i(l)}" data-size="${i(u)}"${o?` aria-label="${i(n)}"`:``}${this.state===`copied`?` data-copied=""`:``}>${c}${o?``:i(n)}</button><span class="k-sr-only" aria-live="polite">${this.state===`idle`?``:i(n)}</span>`,d&&this.querySelector(`button`).focus()}};m.observedAttributes=[`value`,`target`,`label`,`copied-label`,`icon-only`,`variant`,`size`],o(`kashi-dialog`,d,`contents`),o(`kashi-tabs`,f,`block`),o(`kashi-tooltip`,p),o(`kashi-copy-button`,m),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-open]`);if(t){let n=document.getElementById(t.getAttribute(`data-kashi-open`));n?.show&&(e.preventDefault(),n.show())}});export{m as KashiCopyButton,d as KashiDialog,f as KashiTabs,p as KashiTooltip};
|
|
1
|
+
import{b as e,c as t,h as n,i as r,l as i,n as a,o,p as s,r as c,t as l,y as u}from"./base-D4tCOysh.js";var d=class extends l{constructor(){super(...arguments),this.dialog=null,this.opener=null,this.key=u(`kashi-dialog`)}connectedCallback(){c(()=>{this.isConnected&&(this.dialog||this.build(),this.sync())})}attributeChangedCallback(e,t,n){this.dialog&&t!==n&&(e===`open`?this.sync():this.decorate())}get open(){return this.hasAttribute(`open`)}set open(e){this.toggleAttribute(`open`,!!e)}show(){this.open=!0}close(e){this.dialog?.open?this.dialog.close(e):this.open=!1}build(){let e=[...this.children].filter(e=>e.getAttribute(`slot`)===`footer`),n=[...this.childNodes].filter(t=>!e.includes(t)),i=document.createElement(`dialog`);if(i.setAttribute(`aria-labelledby`,`${this.key}-title`),i.innerHTML=`<div class="k-dialog__header"><div class="k-dialog__heading"><h2 class="k-dialog__title" id="${this.key}-title"></h2><p class="k-dialog__description" id="${this.key}-desc"></p></div><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-dialog__close">${a.close}</button></div>`,n.some(e=>e.nodeType===1||e.textContent?.trim())){let e=document.createElement(`div`);e.className=`k-dialog__body`,e.append(...n),i.append(e)}if(e.length){let t=document.createElement(`div`);t.className=`k-dialog__footer`;for(let n of e)n.removeAttribute(`slot`),t.append(n);i.append(t)}this.replaceChildren(i),this.dialog=i,i.querySelector(`.k-dialog__close`).addEventListener(`click`,()=>this.close()),i.addEventListener(`click`,e=>{e.target===i&&r(this,`dismissible`,!0)&&this.close();let t=e.target.closest(`[data-kashi-close]`);t&&i.contains(t)&&this.close(t.getAttribute(`data-kashi-close`)||void 0)}),i.addEventListener(`close`,()=>{this.removeAttribute(`open`),this.opener?.focus?.(),t(this,`kashi-close`,{returnValue:i.returnValue})}),this.decorate()}decorate(){let e=this.dialog,t=this.getAttribute(`size`)??`md`,n=this.getAttribute(`placement`)??`center`;e.className=[`k-dialog`,t!==`md`&&`k-dialog--${t}`,n!==`center`&&`k-dialog--${n}`,this.getAttribute(`tone`)===`danger`&&`k-dialog--danger`].filter(Boolean).join(` `),e.dataset.placement=n,e.querySelector(`.k-dialog__title`).textContent=this.getAttribute(`heading`)??``;let r=e.querySelector(`.k-dialog__description`),i=this.getAttribute(`description`);r.textContent=i??``,r.hidden=!i,i?e.setAttribute(`aria-describedby`,r.id):e.removeAttribute(`aria-describedby`),e.querySelector(`.k-dialog__close`).setAttribute(`aria-label`,this.getAttribute(`close-label`)??s().common.close)}sync(){let e=this.dialog;e&&this.isConnected&&(this.open&&!e.open?(this.opener=document.activeElement,e.showModal?.(),t(this,`kashi-open`,{})):!this.open&&e.open&&e.close())}};d.observedAttributes=[`open`,`heading`,`description`,`tone`,`size`,`placement`,`close-label`];var f=class extends l{constructor(){super(...arguments),this.list=null,this.key=u(`kashi-tabs`),this.ro=null}connectedCallback(){c(()=>this.isConnected&&this.setup())}setup(){this.list||this.build(),this.decorate(),this.select(this.getAttribute(`value`)??this.panels[0]?.dataset.value??``,!1),typeof ResizeObserver<`u`&&!this.ro&&(this.ro=new ResizeObserver(()=>this.measure()),this.ro.observe(this.list))}disconnectedCallback(){this.ro?.disconnect(),this.ro=null}attributeChangedCallback(e,t,n){this.list&&t!==n&&(e===`value`?this.select(n??``,!1):this.decorate())}get value(){return this.getAttribute(`value`)??``}set value(e){this.setAttribute(`value`,e)}get panels(){return[...this.children].filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-tab`))}build(){let e=document.createElement(`div`);e.setAttribute(`role`,`tablist`),e.className=`k-tabs__list`,this.panels.forEach((t,n)=>{let r=t.dataset.value||String(n+1);t.dataset.value=r;let i=document.createElement(`button`);i.type=`button`,i.setAttribute(`role`,`tab`),i.className=`k-tabs__tab`,i.id=`${this.key}-tab-${n}`,i.dataset.value=r,i.textContent=t.dataset.tab??``,t.hasAttribute(`data-disabled`)&&(i.disabled=!0),t.id||=`${this.key}-panel-${n}`,i.setAttribute(`aria-controls`,t.id),t.setAttribute(`role`,`tabpanel`),t.setAttribute(`aria-labelledby`,i.id),t.tabIndex=0,t.classList.add(`k-tabs__panel`),e.append(i)});let t=document.createElement(`span`);t.className=`k-tabs__indicator`,t.setAttribute(`aria-hidden`,`true`),e.append(t),e.addEventListener(`click`,e=>{let t=e.target.closest(`[role="tab"]`);t&&!t.disabled&&this.select(t.dataset.value,!0)}),e.addEventListener(`keydown`,e=>this.onKey(e)),this.prepend(e),this.list=e}decorate(){let e=this.getAttribute(`variant`)??`line`,t=this.getAttribute(`orientation`)===`vertical`;for(let e of[...this.classList])e.startsWith(`k-tabs`)&&this.classList.remove(e);this.classList.add(`k-tabs`,`k-tabs--${e}`),r(this,`block`)&&this.classList.add(`k-tabs--block`),t&&this.classList.add(`k-tabs--vertical`),this.getAttribute(`size`)===`sm`&&this.classList.add(`k-tabs--sm`),this.dataset.orientation=t?`vertical`:`horizontal`,this.list.setAttribute(`aria-orientation`,t?`vertical`:`horizontal`);let n=this.getAttribute(`label`);n&&this.list.setAttribute(`aria-label`,n),this.measure()}select(e,n){let r=[...this.list.querySelectorAll(`[role="tab"]`)];r.some(t=>t.dataset.value===e)||(e=r[0]?.dataset.value??``);for(let t of r){let n=t.dataset.value===e;t.setAttribute(`aria-selected`,String(n)),t.tabIndex=n?0:-1}for(let t of this.panels)t.hidden=t.dataset.value!==e;this.getAttribute(`value`)!==e&&this.setAttribute(`value`,e),this.measure(),n&&t(this,`kashi-change`,{value:e})}measure(){let e=this.list,t=e?.querySelector(`[role="tab"][aria-selected="true"]`);!e||!t||!t.offsetWidth?e?.removeAttribute(`data-indicator`):(e.setAttribute(`data-indicator`,``),e.style.setProperty(`--_ix`,`${t.offsetLeft}px`),e.style.setProperty(`--_iy`,`${t.offsetTop}px`),e.style.setProperty(`--_iw`,`${t.offsetWidth}px`),e.style.setProperty(`--_ih`,`${t.offsetHeight}px`))}onKey(e){let t=[...this.list.querySelectorAll(`[role="tab"]:not(:disabled)`)],n=t.indexOf(document.activeElement);if(n<0)return;let r=getComputedStyle(this.list).direction===`rtl`,i=this.getAttribute(`orientation`)===`vertical`?{ArrowDown:n+1,ArrowUp:n-1,Home:0,End:t.length-1}:{ArrowLeft:r?n+1:n-1,ArrowRight:r?n-1:n+1,Home:0,End:t.length-1};if(!(e.key in i))return;e.preventDefault();let a=t[(i[e.key]+t.length)%t.length];a.focus(),this.select(a.dataset.value,!0)}};f.observedAttributes=[`value`,`variant`,`block`,`orientation`,`size`,`label`];var p=class extends l{constructor(){super(...arguments),this.tip=null,this.key=u(`kashi-tip`),this.trigger=null,this.place=()=>n(this,this.tip,this.getAttribute(`placement`)||`top`),this.onKey=e=>{e.key===`Escape`&&(clearTimeout(this.timer),this.close())}}connectedCallback(){c(()=>this.isConnected&&this.setup())}setup(){if(!this.tip){this.classList.add(`k-tooltip-anchor`);let e=document.createElement(`span`);e.setAttribute(`role`,`tooltip`),e.id=this.key,e.hidden=!0,e.setAttribute(`popover`,`manual`),this.append(e),this.tip=e;let t=this.firstElementChild===e?null:this.firstElementChild;this.addEventListener(`mouseenter`,()=>this.show(Number(this.getAttribute(`delay`)??300))),this.trigger=t,this.addEventListener(`mouseleave`,()=>this.hide()),this.addEventListener(`focusin`,()=>this.show(0)),this.addEventListener(`focusout`,()=>this.hide())}this.decorate(),this.hasAttribute(`open`)&&this.open()}disconnectedCallback(){clearTimeout(this.timer),this.close()}attributeChangedCallback(e){this.tip&&(this.decorate(),(e===`open`||e===`disabled`)&&(this.hasAttribute(`open`)&&!this.hasAttribute(`disabled`)?this.open():this.close()),this.tip.hidden||this.place())}open(){let e=this.tip;e.hidden&&!this.hasAttribute(`disabled`)&&(e.hidden=!1,t(this,`kashi-toggle`,{open:!0}),this.place(),document.addEventListener(`keydown`,this.onKey),addEventListener(`scroll`,this.place,{capture:!0,passive:!0}),addEventListener(`resize`,this.place))}close(){this.tip&&(this.hasAttribute(`open`)&&!this.hasAttribute(`disabled`)&&this.isConnected||(this.tip.hidden||t(this,`kashi-toggle`,{open:!1}),this.tip.hidden=!0,e(this.tip),document.removeEventListener(`keydown`,this.onKey),removeEventListener(`scroll`,this.place,{capture:!0}),removeEventListener(`resize`,this.place)))}decorate(){let e=this.tip,t=this.getAttribute(`placement`),n=this.getAttribute(`heading`),r=this.getAttribute(`shortcut`);e.className=`k-tooltip${t&&t!==`top`?` k-tooltip--${t}`:``}${n?` k-tooltip--rich`:``}`;let a=i(this.getAttribute(`content`)??``);e.innerHTML=(n?`<span class="k-tooltip__title">${i(n)}</span><span class="k-tooltip__body">${a}</span>`:a)+(r?`<kbd class="k-tooltip__kbd" dir="ltr">${i(r)}</kbd>`:``);let o=this.trigger;if(o){let e=(o.getAttribute(`aria-describedby`)??``).split(` `).filter(e=>e&&e!==this.key);this.hasAttribute(`disabled`)||e.push(this.key),e.length?o.setAttribute(`aria-describedby`,e.join(` `)):o.removeAttribute(`aria-describedby`)}}show(e){clearTimeout(this.timer),this.timer=setTimeout(()=>this.open(),e)}hide(){clearTimeout(this.timer),this.timer=setTimeout(()=>this.close(),Number(this.getAttribute(`close-delay`)??100))}};p.observedAttributes=[`content`,`placement`,`heading`,`shortcut`,`disabled`,`open`];var m=class extends l{constructor(){super(...arguments),this.state=`idle`,this.built=!1}connectedCallback(){this.built||(this.built=!0,this.addEventListener(`click`,e=>{e.target.closest(`button`)&&this.copy()})),this.render()}disconnectedCallback(){clearTimeout(this.timer)}attributeChangedCallback(){this.built&&this.render()}get text(){let e=this.getAttribute(`value`);if(e!==null)return e;let t=this.getAttribute(`target`),n=t?document.querySelector(t):null;return n?typeof n.value==`string`?n.value:(n.textContent??``).trim():``}async copy(){try{await navigator.clipboard.writeText(this.text),this.state=`copied`,t(this,`kashi-copy`,{value:this.text})}catch{this.state=`failed`}this.render(),clearTimeout(this.timer),this.timer=setTimeout(()=>{this.state=`idle`,this.render()},Number(this.getAttribute(`timeout`))||2e3)}render(){let e=this.getAttribute(`label`)??s().copy.copy,t=this.getAttribute(`copied-label`)??s().copy.copied,n=this.state===`copied`?t:this.state===`failed`?s().copy.failed:e,o=r(this,`icon-only`),c=this.state===`copied`?a.check:a.copy,l=this.getAttribute(`variant`)??`secondary`,u=this.getAttribute(`size`)??`sm`,d=this.contains(document.activeElement);this.innerHTML=`<button type="button" class="k-btn k-btn--${i(l)}${u===`md`?``:` k-btn--${i(u)}`}${o?` k-btn--icon`:``}" data-variant="${i(l)}" data-size="${i(u)}"${o?` aria-label="${i(n)}"`:``}${this.state===`copied`?` data-copied=""`:``}>${c}${o?``:i(n)}</button><span class="k-sr-only" aria-live="polite">${this.state===`idle`?``:i(n)}</span>`,d&&this.querySelector(`button`).focus()}};m.observedAttributes=[`value`,`target`,`label`,`copied-label`,`icon-only`,`variant`,`size`],o(`kashi-dialog`,d,`contents`),o(`kashi-tabs`,f,`block`),o(`kashi-tooltip`,p),o(`kashi-copy-button`,m),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-open]`);if(t){let n=document.getElementById(t.getAttribute(`data-kashi-open`));n?.show&&(e.preventDefault(),n.show())}});export{m as KashiCopyButton,d as KashiDialog,f as KashiTabs,p as KashiTooltip};
|
package/dist/manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.24.0",
|
|
3
3
|
"elements": [
|
|
4
4
|
{
|
|
5
5
|
"tag": "kashi-national-id",
|
|
@@ -578,7 +578,11 @@
|
|
|
578
578
|
"module": "overlay",
|
|
579
579
|
"attributes": [
|
|
580
580
|
"content",
|
|
581
|
-
"placement"
|
|
581
|
+
"placement",
|
|
582
|
+
"heading",
|
|
583
|
+
"shortcut",
|
|
584
|
+
"disabled",
|
|
585
|
+
"open"
|
|
582
586
|
],
|
|
583
587
|
"properties": [],
|
|
584
588
|
"model": null
|
|
@@ -1924,7 +1928,8 @@
|
|
|
1924
1928
|
"module": "buttons",
|
|
1925
1929
|
"attributes": [
|
|
1926
1930
|
"type",
|
|
1927
|
-
"flush"
|
|
1931
|
+
"flush",
|
|
1932
|
+
"size"
|
|
1928
1933
|
],
|
|
1929
1934
|
"properties": [],
|
|
1930
1935
|
"model": null
|
package/dist/overlay.d.ts
CHANGED
|
@@ -58,7 +58,8 @@ export declare class KashiTooltip extends HTMLBase {
|
|
|
58
58
|
connectedCallback(): void;
|
|
59
59
|
private setup;
|
|
60
60
|
disconnectedCallback(): void;
|
|
61
|
-
attributeChangedCallback(): void;
|
|
61
|
+
attributeChangedCallback(name: string): void;
|
|
62
|
+
private trigger;
|
|
62
63
|
private place;
|
|
63
64
|
private open;
|
|
64
65
|
private close;
|
package/dist/overlay.js
CHANGED
|
@@ -280,6 +280,7 @@ export class KashiTooltip extends HTMLBase {
|
|
|
280
280
|
super(...arguments);
|
|
281
281
|
this.tip = null;
|
|
282
282
|
this.key = uid("kashi-tip");
|
|
283
|
+
this.trigger = null;
|
|
283
284
|
this.place = () => placeTip(this, this.tip, this.getAttribute("placement") || "top");
|
|
284
285
|
this.onKey = (e) => {
|
|
285
286
|
if (e.key === "Escape") {
|
|
@@ -302,30 +303,39 @@ export class KashiTooltip extends HTMLBase {
|
|
|
302
303
|
this.append(tip);
|
|
303
304
|
this.tip = tip;
|
|
304
305
|
const trigger = this.firstElementChild !== tip ? this.firstElementChild : null;
|
|
305
|
-
if (trigger)
|
|
306
|
-
trigger.setAttribute("aria-describedby", [trigger.getAttribute("aria-describedby"), this.key].filter(Boolean).join(" "));
|
|
307
306
|
this.addEventListener("mouseenter", () => this.show(Number(this.getAttribute("delay") ?? 300)));
|
|
307
|
+
this.trigger = trigger;
|
|
308
308
|
this.addEventListener("mouseleave", () => this.hide());
|
|
309
309
|
this.addEventListener("focusin", () => this.show(0));
|
|
310
310
|
this.addEventListener("focusout", () => this.hide());
|
|
311
311
|
}
|
|
312
312
|
this.decorate();
|
|
313
|
+
if (this.hasAttribute("open"))
|
|
314
|
+
this.open();
|
|
313
315
|
}
|
|
314
316
|
disconnectedCallback() {
|
|
315
317
|
clearTimeout(this.timer);
|
|
316
318
|
this.close();
|
|
317
319
|
}
|
|
318
|
-
attributeChangedCallback() {
|
|
319
|
-
if (this.tip)
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
attributeChangedCallback(name) {
|
|
321
|
+
if (!this.tip)
|
|
322
|
+
return;
|
|
323
|
+
this.decorate();
|
|
324
|
+
if (name === "open" || name === "disabled") {
|
|
325
|
+
if (this.hasAttribute("open") && !this.hasAttribute("disabled"))
|
|
326
|
+
this.open();
|
|
327
|
+
else
|
|
328
|
+
this.close();
|
|
329
|
+
}
|
|
330
|
+
if (!this.tip.hidden)
|
|
322
331
|
this.place();
|
|
323
332
|
}
|
|
324
333
|
open() {
|
|
325
334
|
const tip = this.tip;
|
|
326
|
-
if (!tip.hidden)
|
|
335
|
+
if (!tip.hidden || this.hasAttribute("disabled"))
|
|
327
336
|
return;
|
|
328
337
|
tip.hidden = false;
|
|
338
|
+
emit(this, "kashi-toggle", { open: true });
|
|
329
339
|
this.place();
|
|
330
340
|
document.addEventListener("keydown", this.onKey);
|
|
331
341
|
addEventListener("scroll", this.place, { capture: true, passive: true });
|
|
@@ -334,6 +344,11 @@ export class KashiTooltip extends HTMLBase {
|
|
|
334
344
|
close() {
|
|
335
345
|
if (!this.tip)
|
|
336
346
|
return;
|
|
347
|
+
// با ویژگی open، راهنما کنترلشده است و hover یا فوکوس آن را نمیبندد
|
|
348
|
+
if (this.hasAttribute("open") && !this.hasAttribute("disabled") && this.isConnected)
|
|
349
|
+
return;
|
|
350
|
+
if (!this.tip.hidden)
|
|
351
|
+
emit(this, "kashi-toggle", { open: false });
|
|
337
352
|
this.tip.hidden = true;
|
|
338
353
|
unplaceTip(this.tip);
|
|
339
354
|
document.removeEventListener("keydown", this.onKey);
|
|
@@ -341,9 +356,25 @@ export class KashiTooltip extends HTMLBase {
|
|
|
341
356
|
removeEventListener("resize", this.place);
|
|
342
357
|
}
|
|
343
358
|
decorate() {
|
|
359
|
+
const tip = this.tip;
|
|
344
360
|
const placement = this.getAttribute("placement");
|
|
345
|
-
|
|
346
|
-
|
|
361
|
+
const heading = this.getAttribute("heading");
|
|
362
|
+
const shortcut = this.getAttribute("shortcut");
|
|
363
|
+
tip.className = `k-tooltip${placement && placement !== "top" ? ` k-tooltip--${placement}` : ""}${heading ? " k-tooltip--rich" : ""}`;
|
|
364
|
+
const content = esc(this.getAttribute("content") ?? "");
|
|
365
|
+
tip.innerHTML = (heading ? `<span class="k-tooltip__title">${esc(heading)}</span><span class="k-tooltip__body">${content}</span>` : content)
|
|
366
|
+
+ (shortcut ? `<kbd class="k-tooltip__kbd" dir="ltr">${esc(shortcut)}</kbd>` : "");
|
|
367
|
+
// غیرفعال: راهنما به عنصر وصل نمیماند تا صفحهخوان متن پنهان را نخواند
|
|
368
|
+
const t = this.trigger;
|
|
369
|
+
if (t) {
|
|
370
|
+
const ids = (t.getAttribute("aria-describedby") ?? "").split(" ").filter((x) => x && x !== this.key);
|
|
371
|
+
if (!this.hasAttribute("disabled"))
|
|
372
|
+
ids.push(this.key);
|
|
373
|
+
if (ids.length)
|
|
374
|
+
t.setAttribute("aria-describedby", ids.join(" "));
|
|
375
|
+
else
|
|
376
|
+
t.removeAttribute("aria-describedby");
|
|
377
|
+
}
|
|
347
378
|
}
|
|
348
379
|
show(wait) {
|
|
349
380
|
clearTimeout(this.timer);
|
|
@@ -351,10 +382,10 @@ export class KashiTooltip extends HTMLBase {
|
|
|
351
382
|
}
|
|
352
383
|
hide() {
|
|
353
384
|
clearTimeout(this.timer);
|
|
354
|
-
this.timer = setTimeout(() => this.close(), 100);
|
|
385
|
+
this.timer = setTimeout(() => this.close(), Number(this.getAttribute("close-delay") ?? 100));
|
|
355
386
|
}
|
|
356
387
|
}
|
|
357
|
-
KashiTooltip.observedAttributes = ["content", "placement"];
|
|
388
|
+
KashiTooltip.observedAttributes = ["content", "placement", "heading", "shortcut", "disabled", "open"];
|
|
358
389
|
/** دکمهٔ کپی در کلیپبورد با بازخورد «کپی شد» برای چشم و صفحهخوان */
|
|
359
390
|
export class KashiCopyButton extends HTMLBase {
|
|
360
391
|
constructor() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kashi-ui/elements",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"description": "وب کامپوننتهای کاشی: فیلدهای فارسی، تقویم شمسی و کامپوننتهای تعاملی بدون React؛ برای HTML، Vue، Svelte، Angular و وردپرس",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"test": "node --test test/*.test.mjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@kashi-ui/bank-logos": "^2.
|
|
32
|
-
"@kashi-ui/persian": "^2.
|
|
31
|
+
"@kashi-ui/bank-logos": "^2.24.0",
|
|
32
|
+
"@kashi-ui/persian": "^2.24.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@kashi-ui/css": "^2.
|
|
35
|
+
"@kashi-ui/css": "^2.24.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"happy-dom": "^21.0.4",
|