@kashi-ui/elements 0.26.0 → 1.1.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.
Files changed (72) hide show
  1. package/README.md +9 -0
  2. package/dist/appointment.js +13 -12
  3. package/dist/base.d.ts +408 -0
  4. package/dist/base.js +29 -0
  5. package/dist/basic.js +8 -9
  6. package/dist/calendar.js +21 -20
  7. package/dist/cdn/appointment-CrIZi8Bp.js +1 -0
  8. package/dist/cdn/base-DTQ50VdG.js +1 -0
  9. package/dist/cdn/basic-CrEW2RKF.js +1 -0
  10. package/dist/cdn/calendar-CYRrdGIf.js +16 -0
  11. package/dist/cdn/charts-D6KM26Vp.js +1 -0
  12. package/dist/cdn/combobox-6EFI2qqN.js +1 -0
  13. package/dist/cdn/controls-BwebEIlf.js +1 -0
  14. package/dist/cdn/display-DFuMkcj5.js +1 -0
  15. package/dist/cdn/fields-DhLIhHQ8.js +1 -0
  16. package/dist/cdn/forms-BHivKDdC.js +1 -0
  17. package/dist/cdn/holidays-DgbIAdlt.js +1 -0
  18. package/dist/cdn/inputs-R7nEHfbV.js +1 -0
  19. package/dist/cdn/kashi-elements.js +1 -1
  20. package/dist/cdn/map-H3xiZd8Y.js +12 -0
  21. package/dist/cdn/{menu-Cga7QOfs.js → menu-BAUSubXk.js} +1 -1
  22. package/dist/cdn/nav-NK-v48B5.js +1 -0
  23. package/dist/cdn/overlay-CBv8grz3.js +1 -0
  24. package/dist/cdn/pickers-BHzNt_X8.js +1 -0
  25. package/dist/cdn/table-Bt9WVLoo.js +1 -0
  26. package/dist/cdn/text-D4a_hlwL.js +1 -0
  27. package/dist/cdn/time-DJ3p1wvd.js +1 -0
  28. package/dist/cdn/words-BdADG_9U.js +1 -0
  29. package/dist/cdn.d.ts +1 -0
  30. package/dist/cdn.js +2 -0
  31. package/dist/charts.js +27 -24
  32. package/dist/combobox.d.ts +6 -5
  33. package/dist/combobox.js +29 -20
  34. package/dist/controls.js +15 -15
  35. package/dist/display.js +17 -14
  36. package/dist/fields.js +3 -3
  37. package/dist/forms.d.ts +3 -3
  38. package/dist/forms.js +54 -47
  39. package/dist/index.d.ts +4 -0
  40. package/dist/index.js +3 -0
  41. package/dist/inputs.d.ts +3 -3
  42. package/dist/inputs.js +31 -30
  43. package/dist/map.js +16 -13
  44. package/dist/nav.js +18 -16
  45. package/dist/overlay.js +5 -5
  46. package/dist/pickers.d.ts +1 -1
  47. package/dist/pickers.js +39 -38
  48. package/dist/table.js +7 -7
  49. package/dist/toast.js +3 -3
  50. package/package.json +4 -4
  51. package/dist/cdn/appointment-DkMxtSWi.js +0 -1
  52. package/dist/cdn/base-DfzNTdQk.js +0 -1
  53. package/dist/cdn/basic-B5n1okZO.js +0 -1
  54. package/dist/cdn/calendar-oMlnK1_D.js +0 -16
  55. package/dist/cdn/charts-SHKq2S4I.js +0 -1
  56. package/dist/cdn/combobox-DiGy7lAB.js +0 -1
  57. package/dist/cdn/controls-C6zwNYWs.js +0 -1
  58. package/dist/cdn/digits-DE1YGT94.js +0 -1
  59. package/dist/cdn/display-DZFW9EEX.js +0 -1
  60. package/dist/cdn/fields-D2hmrvVR.js +0 -1
  61. package/dist/cdn/forms-CeItYHFx.js +0 -1
  62. package/dist/cdn/holidays-BwsAEOI1.js +0 -1
  63. package/dist/cdn/inputs-DuP7P3ka.js +0 -1
  64. package/dist/cdn/jalali-BiM5Kfep.js +0 -1
  65. package/dist/cdn/map-w5X2fTQI.js +0 -12
  66. package/dist/cdn/nav-CwPZ20z-.js +0 -1
  67. package/dist/cdn/overlay-BDzwsBN5.js +0 -1
  68. package/dist/cdn/pickers-BOpaZ-7q.js +0 -1
  69. package/dist/cdn/table-BdF43L5q.js +0 -1
  70. package/dist/cdn/text-D1U32D6K.js +0 -1
  71. package/dist/cdn/time-DXw4vOne.js +0 -1
  72. package/dist/cdn/words-9OdzG7y6.js +0 -1
@@ -0,0 +1 @@
1
+ import{A as e,D as t,O as n,_ as r,c as i,d as a,g as o,i as s,k as c,l,o as u,p as d,t as f,u as p,v as m}from"./base-DTQ50VdG.js";import{t as h}from"./words-BdADG_9U.js";function g(e){let t=n(e);if(!/^\d{10}$/.test(t)||/^(\d)\1{9}$/.test(t))return!1;let r=Number(t[9]),i=0;for(let e=0;e<9;e++)i+=Number(t[e])*(10-e);let a=i%11;return a<2?r===a:r===11-a}const ee={melli:`Bank Melli`,sepah:`Bank Sepah`,edbi:`Export Development Bank`,bim:`Bank of Industry and Mine`,keshavarzi:`Bank Keshavarzi`,maskan:`Bank Maskan`,postbank:`Post Bank`,"tosee-taavon":`Tose'e Ta'avon Bank`,"eghtesad-novin":`EN Bank`,parsian:`Parsian Bank`,pasargad:`Bank Pasargad`,karafarin:`Karafarin Bank`,saman:`Saman Bank`,sina:`Sina Bank`,sarmayeh:`Sarmayeh Bank`,ayandeh:`Ayandeh Bank`,shahr:`Shahr Bank`,dey:`Dey Bank`,saderat:`Bank Saderat`,mellat:`Bank Mellat`,tejarat:`Tejarat Bank`,refah:`Refah Bank`,"iran-zamin":`Iran Zamin Bank`,"mehr-iran":`Mehr Iran Bank`,gardeshgari:`Tourism Bank`,markazi:`Central Bank of Iran`,khavarmianeh:`Middle East Bank`,noor:`Noor Credit Institution`,melal:`Melal Credit Institution`,tosee:`Tose'e Credit Institution`,resalat:`Resalat Bank`,ansar:`Ansar Bank`,ghavamin:`Ghavamin Bank`,hekmat:`Hekmat Iranian Bank`,kosar:`Kosar Credit Institution`,"mehr-eghtesad":`Mehr Eghtesad Bank`};function _(e,t=`fa`){return t===`en`?ee[e.slug]??e.name:e.name}const v={603799:{name:`بانک ملی`,slug:`melli`},589210:{name:`بانک سپه`,slug:`sepah`},627648:{name:`بانک توسعه صادرات`,slug:`edbi`},627961:{name:`بانک صنعت و معدن`,slug:`bim`},603770:{name:`بانک کشاورزی`,slug:`keshavarzi`},639217:{name:`بانک کشاورزی`,slug:`keshavarzi`},628023:{name:`بانک مسکن`,slug:`maskan`},627760:{name:`پست بانک`,slug:`postbank`},502908:{name:`بانک توسعه تعاون`,slug:`tosee-taavon`},627412:{name:`بانک اقتصاد نوین`,slug:`eghtesad-novin`},622106:{name:`بانک پارسیان`,slug:`parsian`},639194:{name:`بانک پارسیان`,slug:`parsian`},627884:{name:`بانک پارسیان`,slug:`parsian`},502229:{name:`بانک پاسارگاد`,slug:`pasargad`},639347:{name:`بانک پاسارگاد`,slug:`pasargad`},627488:{name:`بانک کارآفرین`,slug:`karafarin`},502910:{name:`بانک کارآفرین`,slug:`karafarin`},621986:{name:`بانک سامان`,slug:`saman`},639346:{name:`بانک سینا`,slug:`sina`},639607:{name:`بانک سرمایه`,slug:`sarmayeh`},636214:{name:`بانک آینده`,slug:`ayandeh`},502806:{name:`بانک شهر`,slug:`shahr`},504706:{name:`بانک شهر`,slug:`shahr`},502938:{name:`بانک دی`,slug:`dey`},603769:{name:`بانک صادرات`,slug:`saderat`},610433:{name:`بانک ملت`,slug:`mellat`},991975:{name:`بانک ملت`,slug:`mellat`},627353:{name:`بانک تجارت`,slug:`tejarat`},585983:{name:`بانک تجارت`,slug:`tejarat`},589463:{name:`بانک رفاه`,slug:`refah`},505785:{name:`بانک ایران زمین`,slug:`iran-zamin`},606373:{name:`بانک قرض‌الحسنه مهر ایران`,slug:`mehr-iran`},505416:{name:`بانک گردشگری`,slug:`gardeshgari`},636795:{name:`بانک مرکزی`,slug:`markazi`},585947:{name:`بانک خاورمیانه`,slug:`khavarmianeh`},505809:{name:`بانک خاورمیانه`,slug:`khavarmianeh`},507677:{name:`موسسه اعتباری نور`,slug:`noor`},606256:{name:`موسسه اعتباری ملل`,slug:`melal`},628157:{name:`موسسه اعتباری توسعه`,slug:`tosee`},504172:{name:`بانک قرض‌الحسنه رسالت`,slug:`resalat`},627381:{name:`بانک انصار`,slug:`ansar`},639599:{name:`بانک قوامین`,slug:`ghavamin`},636949:{name:`بانک حکمت ایرانیان`,slug:`hekmat`},505801:{name:`موسسه اعتباری کوثر`,slug:`kosar`},639370:{name:`بانک مهر اقتصاد`,slug:`mehr-eghtesad`}};function te(e){let t=0;for(let n=0;n<e.length;n++){let r=Number(e[e.length-1-n]);n%2==1&&(r*=2,r>9&&(r-=9)),t+=r}return t%10==0}function y(e){let t=n(e);return/^\d{16}$/.test(t)&&te(t)}function b(e){let t=n(e);return t.length>=6?v[t.slice(0,6)]??null:null}function x(e){return n(e).slice(0,16).replace(/(\d{4})(?=\d)/g,`$1 `)}const S={"010":{name:`بانک مرکزی`,slug:`markazi`},"011":{name:`بانک صنعت و معدن`,slug:`bim`},"012":{name:`بانک ملت`,slug:`mellat`},"013":{name:`بانک رفاه`,slug:`refah`},"014":{name:`بانک مسکن`,slug:`maskan`},"015":{name:`بانک سپه`,slug:`sepah`},"016":{name:`بانک کشاورزی`,slug:`keshavarzi`},"017":{name:`بانک ملی`,slug:`melli`},"018":{name:`بانک تجارت`,slug:`tejarat`},"019":{name:`بانک صادرات`,slug:`saderat`},"020":{name:`بانک توسعه صادرات`,slug:`edbi`},"021":{name:`پست بانک`,slug:`postbank`},"022":{name:`بانک توسعه تعاون`,slug:`tosee-taavon`},"053":{name:`بانک کارآفرین`,slug:`karafarin`},"054":{name:`بانک پارسیان`,slug:`parsian`},"055":{name:`بانک اقتصاد نوین`,slug:`eghtesad-novin`},"056":{name:`بانک سامان`,slug:`saman`},"057":{name:`بانک پاسارگاد`,slug:`pasargad`},"058":{name:`بانک سرمایه`,slug:`sarmayeh`},"059":{name:`بانک سینا`,slug:`sina`},"060":{name:`بانک قرض‌الحسنه مهر ایران`,slug:`mehr-iran`},"061":{name:`بانک شهر`,slug:`shahr`},"062":{name:`بانک آینده`,slug:`ayandeh`},"064":{name:`بانک گردشگری`,slug:`gardeshgari`},"066":{name:`بانک دی`,slug:`dey`},"069":{name:`بانک ایران زمین`,slug:`iran-zamin`},"070":{name:`بانک قرض‌الحسنه رسالت`,slug:`resalat`},"078":{name:`بانک خاورمیانه`,slug:`khavarmianeh`}};function C(e){return c(e).toUpperCase().replace(/^\s*IR/,``).replace(/\D/g,``).slice(0,24)}function ne(e){let t=0;for(let n=0;n<e.length;n+=7)t=Number(String(t)+e.slice(n,n+7))%97;return t}function re(e){let t=c(e).toUpperCase().replace(/[\s-]/g,``),n=t.startsWith(`IR`)?t.slice(2):t;return/^\d{24}$/.test(n)?ne(n.slice(2)+`1827`+n.slice(0,2))===1:!1}function w(e){let t=C(e);return t.length>=5?S[t.slice(2,5)]??null:null}function ie(e){let t=C(e);return t?`IR${t}`.replace(/(.{4})(?=.)/g,`$1 `):``}const ae={name:`همراه اول`,slug:`mci`},T={name:`ایرانسل`,slug:`irancell`},E={name:`رایتل`,slug:`rightel`},D={mci:`Hamrah-e Aval`,irancell:`Irancell`,rightel:`RighTel`},O=(e,t=`fa`)=>t===`en`?D[e.slug]:e.name,k={...Object.fromEntries([`10`,`11`,`12`,`13`,`14`,`15`,`16`,`17`,`18`,`19`,`90`,`91`,`92`,`93`,`94`].map(e=>[e,ae])),...Object.fromEntries([`01`,`02`,`03`,`04`,`05`,`30`,`33`,`35`,`36`,`37`,`38`,`39`,`41`].map(e=>[e,T])),...Object.fromEntries([`20`,`21`,`22`].map(e=>[e,E]))};function A(e){let t=n(e);return t.startsWith(`0098`)?t=`0`+t.slice(4):t.startsWith(`98`)&&t.length===12?t=`0`+t.slice(2):t.startsWith(`9`)&&t.length===10&&(t=`0`+t),t}function j(e){return/^09\d{9}$/.test(A(e))}function M(e){let t=A(e);return t.length>=4&&t.startsWith(`09`)?k[t.slice(2,4)]??null:null}function N(e){let t=A(e).slice(0,11);return[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(` `)}function P(e){let t=n(e);return/^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/.test(t)}function F(e){let t=n(e).slice(0,10);return t.length>5?`${t.slice(0,5)}-${t.slice(5)}`:t}const I={11:`مازندران`,13:`گیلان`,17:`گلستان`,21:`تهران`,23:`سمنان`,24:`زنجان`,25:`قم`,26:`البرز`,28:`قزوین`,31:`اصفهان`,34:`کرمان`,35:`یزد`,38:`چهارمحال و بختیاری`,41:`آذربایجان شرقی`,44:`آذربایجان غربی`,45:`اردبیل`,51:`خراسان رضوی`,54:`سیستان و بلوچستان`,56:`خراسان جنوبی`,58:`خراسان شمالی`,61:`خوزستان`,66:`لرستان`,71:`فارس`,74:`کهگیلویه و بویراحمد`,76:`هرمزگان`,77:`بوشهر`,81:`همدان`,83:`کرمانشاه`,84:`ایلام`,86:`مرکزی`,87:`کردستان`};function L(e){let t=n(e);return t.startsWith(`0098`)?t=`0`+t.slice(4):t.startsWith(`98`)&&t.length===12?t=`0`+t.slice(2):/^[1-8]/.test(t)&&t.length===10&&(t=`0`+t),t}function R(e){let t=L(e);return t.length>=3&&t[0]===`0`?I[t.slice(1,3)]??null:null}function z(e){let t=L(e);return/^0\d{2}[2-9]\d{7}$/.test(t)&&R(t)!==null}function B(e){let t=L(e).slice(0,11);return[t.slice(0,3),t.slice(3,7),t.slice(7,11)].filter(Boolean).join(` `)}const V=[29,27,23,19,17,29,27,23,19,17];function H(e){let t=n(e);if(!/^\d{11}$/.test(t)||/^0+$/.test(t.slice(3,9)))return!1;let r=[...t].map(Number),i=r[9]+2,a=0;for(let e=0;e<10;e++)a+=(r[e]+i)*V[e];let o=a%11;return(o===10?0:o)===r[10]}const U=t=>e(t);function W(e,t){if(t===0)return e.search(/[0-9۰-۹]/)===-1?e.length:e.search(/[0-9۰-۹]/);let n=0;for(let r=0;r<e.length;r++)if(/[0-9۰-۹]/.test(e[r])&&++n===t)return r+1;return e.length}var G=class extends f{constructor(){super(...arguments),this.raw=``,this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=m(`kashi-in`),this.logoSlug=null}connectedCallback(){if(!this.rendered&&!this.valueSet&&(this.raw=this.clean(this.getAttribute(`value`)??``)),Object.prototype.hasOwnProperty.call(this,`value`)){let e=this.value;delete this.value,this.raw=this.clean(String(e??``))}this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.setRaw(this.clean(n??``),!1):this.render())}get value(){return this.kind.submit?this.kind.submit(this.raw):this.raw}set value(e){this.valueSet=!0,this.setRaw(this.clean(String(e??``)),!1)}get valid(){return this.isValid()}isValid(){return this.kind.valid(this.raw)}focus(e){this.input?.focus(e)}clean(e){let t=this.kind;return(t.normalize??(e=>e))(n(e)).slice(0,t.maxDigits)}get digits(){let e=this.getAttribute(`digits`);return e===`fa`||e===`latin`?e:a()===`en`?`latin`:this.kind.digits}shown(){let e=this.kind.format(this.raw);return this.digits===`fa`?U(e):e}render(){let e=this.kind,t=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:e.label(),i=this.getAttribute(`size`),a=this.hasAttribute(`required`),o=this.hasAttribute(`disabled`),s=this.getAttribute(`placeholder`)??e.placeholder[this.digits],c=`<div class="k-input${i===`sm`||i===`lg`?` k-input--${i}`:``}" data-size="${i??`md`}"${o?` data-state="disabled"`:``}><input id="${t}" class="k-input__control" type="${e.type??`text`}" inputmode="${e.inputMode??`numeric`}" autocomplete="${e.autocomplete??`off`}" dir="ltr" spellcheck="false" placeholder="${l(s)}"${a?` required`:``}${o?` disabled`:``}${this.hasAttribute(`readonly`)?` readonly`:``}${!r&&n?` aria-label="${l(n)}"`:``}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,p({id:t,label:r,required:a,control:c})),this.input=this.querySelector(`input.k-input__control`),this.input.addEventListener(`input`,()=>this.onInput()),this.input.addEventListener(`blur`,()=>{this.touched=!0,this.paint()}),this.rendered=!0,this.paint()}onInput(){let e=this.input,t=e.value.slice(0,e.selectionStart??e.value.length),r=this.clean(e.value),i=Math.min(n(t).length,r.length);if(this.setRaw(r,!0),e.ownerDocument.activeElement===e){let t=W(e.value,i);e.setSelectionRange(t,t)}}setRaw(e,t){let n=e!==this.raw;this.raw=e,this.rendered&&(this.paint(),t&&n&&i(this,`kashi-change`,{value:this.value,valid:this.isValid(),...this.kind.detail?.(this.raw)}))}invalidText(e){return this.raw.length>0&&(e||this.raw.length===this.kind.maxDigits)&&!this.isValid()?this.getAttribute(`invalid-message`)??this.kind.invalidMessage():null}hintText(){return this.getAttribute(`hint`)}paint(){let e=this.input,t=this.shown();e.value!==t&&(e.value=t);let n=e.parentElement;n.querySelector(`:scope > .k-input__addon`)?.remove();let i=s(this,`show-meta`,!0)?this.kind.meta?.(this.raw,this):null,a=`${this.key}-meta`;if(i){let e=document.createElement(`span`);e.className=`k-input__addon`,e.innerHTML=i.bank?`<span class="k-bank" id="${a}">${l(i.text)}</span>`:`<span class="k-input__meta" id="${a}">${l(i.text)}</span>`,n.append(e),i.bank&&s(this,`bank-logo`,!0)&&this.loadLogo(i.bank,e.firstElementChild)}let c=this.getAttribute(`error`)||this.invalidText(this.touched);e.setCustomValidity(this.raw&&!this.isValid()?this.invalidText(!0)??``:``),o(this.querySelector(`:scope > .k-field`),e,this.key,c,this.hintText(),i?a:null),r(this,this.getAttribute(`name`),this.raw?this.value:``)}loadLogo(e,t){this.logoSlug=e.slug,import(`./dist-D670Gw0K.js`).then(n=>{let r=n.bankLogoDataUri(e.slug);if(!r||this.logoSlug!==e.slug||!t.isConnected)return;let i=document.createElement(`img`);i.className=`k-bank__logo`,i.src=r,i.alt=``,i.width=i.height=24,t.prepend(i)}).catch(()=>{})}};G.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`readonly`,`digits`,`invalid-message`,`name`,`value`,`size`,`aria-label`,`show-meta`,`bank-logo`];var K=class extends G{constructor(){super(...arguments),this.kind={label:()=>d().persianInput[`national-id`],maxDigits:10,format:e=>e,valid:e=>g(e),invalidMessage:()=>d().invalid.nationalId,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰`,latin:`0000000000`},digits:`fa`}}},q=class extends G{constructor(){super(...arguments),this.kind={label:()=>d().persianInput[`legal-id`],maxDigits:11,format:e=>e,valid:e=>H(e),invalidMessage:()=>d().invalid.legalId,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰۰`,latin:`00000000000`},digits:`fa`}}},J=class extends G{constructor(){super(...arguments),this.kind={label:()=>d().persianInput.mobile,maxDigits:11,normalize:A,format:N,valid:e=>j(e),invalidMessage:()=>d().invalid.mobile,placeholder:{fa:`۰۹۱۲ ۳۴۵ ۶۷۸۹`,latin:`0912 345 6789`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=M(e);return t?{text:O(t,a())}:null},detail:e=>({operator:M(e)?.name??null})}}},Y=class extends G{constructor(){super(...arguments),this.kind={label:()=>d().persianInput.landline,maxDigits:11,normalize:L,format:B,valid:e=>z(e),invalidMessage:()=>d().invalid.landline,placeholder:{fa:`۰۲۱ ۸۸۷۷ ۶۶۵۵`,latin:`021 8877 6655`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=R(e);return t?{text:t}:null},detail:e=>({province:R(e)})}}},X=class extends G{constructor(){super(...arguments),this.kind={label:()=>d().persianInput.card,maxDigits:16,format:x,valid:e=>y(e),invalidMessage:()=>d().invalid.card,placeholder:{fa:`۰۰۰۰ ۰۰۰۰ ۰۰۰۰ ۰۰۰۰`,latin:`0000 0000 0000 0000`},digits:`fa`,autocomplete:`cc-number`,meta:e=>{let t=b(e);return t?{text:_(t,a()),bank:t}:null},detail:e=>({bank:b(e)?.name??null})}}},Z=class extends G{constructor(){super(...arguments),this.kind={label:()=>d().persianInput.iban,maxDigits:24,format:e=>ie(e),valid:e=>re(e),invalidMessage:()=>d().invalid.iban,placeholder:{fa:`IR00 0000 0000 0000 0000 0000 00`,latin:`IR00 0000 0000 0000 0000 0000 00`},digits:`latin`,meta:e=>{let t=w(e);return t?{text:_(t,a()),bank:t}:null},submit:e=>e?`IR${e}`:``,detail:e=>({bank:w(e)?.name??null})}}clean(e){return super.clean(e.replace(/^\s*IR/i,``))}},Q=class extends G{constructor(){super(...arguments),this.kind={label:()=>d().persianInput.postal,maxDigits:10,format:F,valid:e=>P(e),invalidMessage:()=>d().invalid.postal,placeholder:{fa:`۱۲۳۴۵-۶۷۸۹۰`,latin:`12345-67890`},digits:`fa`,autocomplete:`postal-code`}}},$=class extends G{constructor(){super(...arguments),this.kind={label:()=>d().persianInput.price,maxDigits:15,normalize:e=>e.replace(/^0+(?=\d)/,``),format:e=>e?t(e,{digits:`latin`}).replace(/,/g,this.digits===`fa`?`٬`:`,`):``,valid:()=>this.inRange(),invalidMessage:()=>``,placeholder:{fa:`۰`,latin:`0`},digits:`fa`,meta:(e,t)=>{let n=t.getAttribute(`unit`)??d().money.toman;return n?{text:n}:null},detail:e=>({value:e?Number(e):null})}}get valueAsNumber(){return this.raw?Number(this.raw):null}num(e){let t=this.getAttribute(e);return t===null||t===``||Number.isNaN(Number(t))?void 0:Number(t)}inRange(){if(!this.raw)return!0;let e=Number(this.raw),t=this.num(`min`),n=this.num(`max`);return!(t!==void 0&&e<t||n!==void 0&&e>n)}invalidText(e){if(!e||this.inRange())return null;let n=this.getAttribute(`invalid-message`);if(n)return n;let r=this.num(`min`),i=this.num(`max`),a=e=>this.digits===`fa`?U(t(e)):t(e,{digits:`latin`}),o=d().invalid;return r!==void 0&&i!==void 0?o.priceRange(a(r),a(i)):r===void 0?o.priceMax(a(i)):o.priceMin(a(r))}hintText(){if(this.raw&&s(this,`show-words`,!0)){let e=this.getAttribute(`unit`)??d().money.toman;return`${h(Number(this.raw),{locale:a()})}${e?` ${e}`:``}`}return this.getAttribute(`hint`)}};$.observedAttributes=[...G.observedAttributes,`unit`,`min`,`max`,`show-words`],u(`kashi-national-id`,K,`block`),u(`kashi-legal-id`,q,`block`),u(`kashi-mobile`,J,`block`),u(`kashi-landline`,Y,`block`),u(`kashi-card-number`,X,`block`),u(`kashi-iban`,Z,`block`),u(`kashi-postal-code`,Q,`block`),u(`kashi-price`,$,`block`);export{X as KashiCardNumber,G as KashiDigitsInput,Z as KashiIban,Y as KashiLandline,q as KashiLegalId,J as KashiMobile,K as KashiNationalId,Q as KashiPostalCode,$ as KashiPrice};
@@ -1 +1 @@
1
- import{a as e,n as t,s as n,t as r}from"./base-DfzNTdQk.js";let i=1;function a(){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 o(e){let t=e.id??i++;return a().upsert({...e,id:t}),t}function s(e){return o(typeof e==`string`?{title:e}:e)}s.success=(e,t={})=>s({...t,title:e,tone:`success`}),s.error=(e,t={})=>s({...t,title:e,tone:`error`}),s.warning=(e,t={})=>s({...t,title:e,tone:`warning`}),s.info=(e,t={})=>s({...t,title:e,tone:`info`}),s.dismiss=e=>document.querySelectorAll(`kashi-toaster`).forEach(t=>t.dismiss(e)),s.promise=(e,t)=>{let n=o({title:t.loading,tone:`info`,duration:1/0,loading:!0});return e.then(e=>o({id:n,title:typeof t.success==`function`?t.success(e):t.success,tone:`success`}),e=>o({id:n,title:typeof t.error==`function`?t.error(e):t.error,tone:`error`})),e};var c=class extends r{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`)??`اعلان‌ها`)}upsert(e){this.list||this.connectedCallback();let t=[...this.list.children].find(t=>t.toastId===e.id),n=l(e,this.getAttribute(`close-label`)??`بستن اعلان`,()=>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))}};c.observedAttributes=[`placement`,`label`];function l(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>`:t[o===`neutral`?`info`:o]}</span><div class="k-toast__content"><p class="k-toast__title">${n(e.title)}</p>${e.description?`<p class="k-toast__description">${n(e.description)}</p>`:``}${e.action?`<button type="button" class="k-btn k-btn--link k-toast__action">${n(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="${n(r)}">${t.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}e(`kashi-toaster`,c),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-toast]`);t&&s({title:t.dataset.kashiToast,description:t.dataset.description,tone:t.dataset.tone??`neutral`})});const u=/* @__PURE__ */ new Set([[[`kashi-national-id`,`kashi-legal-id`,`kashi-mobile`,`kashi-landline`,`kashi-card-number`,`kashi-iban`,`kashi-postal-code`,`kashi-price`],()=>import(`./inputs-DuP7P3ka.js`)],[[`kashi-otp`],()=>import(`./fields-D2hmrvVR.js`)],[[`kashi-combobox`,`kashi-province-select`,`kashi-city-select`],()=>import(`./combobox-DiGy7lAB.js`)],[[`kashi-iran-map`,`kashi-address-form`],()=>import(`./map-w5X2fTQI.js`)],[[`kashi-calendar`,`kashi-date-picker`],()=>import(`./calendar-oMlnK1_D.js`)],[[`kashi-money`,`kashi-date`,`kashi-relative-time`,`kashi-countdown`],()=>import(`./display-DZFW9EEX.js`)],[[`kashi-dialog`,`kashi-tabs`,`kashi-tooltip`,`kashi-copy-button`],()=>import(`./overlay-BDzwsBN5.js`)],[[`kashi-dropdown-menu`,`kashi-popover`],()=>import(`./menu-Cga7QOfs.js`)],[[`kashi-tag-input`,`kashi-number-input`,`kashi-rating`,`kashi-pagination`],()=>import(`./controls-C6zwNYWs.js`)],[[`kashi-data-table`],()=>import(`./table-BdF43L5q.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-CeItYHFx.js`)],[[`kashi-date-range-picker`,`kashi-month-picker`,`kashi-file-upload`,`kashi-color-picker`],()=>import(`./pickers-BOpaZ-7q.js`)],[[`kashi-bar-chart`,`kashi-line-chart`,`kashi-pie-chart`,`kashi-bar-list`,`kashi-proportion-bar`,`kashi-sparkline`,`kashi-activity-heatmap`],()=>import(`./charts-SHKq2S4I.js`)],[[`kashi-input`,`kashi-textarea`,`kashi-banner`],()=>import(`./basic-B5n1okZO.js`)],[[`kashi-appointment-picker`],()=>import(`./appointment-DkMxtSWi.js`)],[[`kashi-command-palette`,`kashi-context-menu`,`kashi-carousel`,`kashi-tree-view`,`kashi-tour`,`kashi-splitter`,`kashi-side-nav`],()=>import(`./nav-CwPZ20z-.js`)]]);function d(){for(let e of u)document.querySelector(e[0].join(`,`))&&(u.delete(e),e[1]().catch(e=>console.error(`[kashi] بارگذاری نشد:`,e)));u.size||p?.disconnect()}function f(){let e=[...u].map(([,e])=>e());return u.clear(),p?.disconnect(),Promise.all(e)}let p=null;typeof document<`u`&&(d(),p=new MutationObserver(d),p.observe(document.documentElement,{childList:!0,subtree:!0}));export{f as loadAll,s as toast};
1
+ import{h as e,l as t,n,o as r,p as i,t as a}from"./base-DTQ50VdG.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`],()=>import(`./inputs-R7nEHfbV.js`)],[[`kashi-otp`],()=>import(`./fields-DhLIhHQ8.js`)],[[`kashi-combobox`,`kashi-province-select`,`kashi-city-select`],()=>import(`./combobox-6EFI2qqN.js`)],[[`kashi-iran-map`,`kashi-address-form`],()=>import(`./map-H3xiZd8Y.js`)],[[`kashi-calendar`,`kashi-date-picker`],()=>import(`./calendar-CYRrdGIf.js`)],[[`kashi-money`,`kashi-date`,`kashi-relative-time`,`kashi-countdown`],()=>import(`./display-DFuMkcj5.js`)],[[`kashi-dialog`,`kashi-tabs`,`kashi-tooltip`,`kashi-copy-button`],()=>import(`./overlay-CBv8grz3.js`)],[[`kashi-dropdown-menu`,`kashi-popover`],()=>import(`./menu-BAUSubXk.js`)],[[`kashi-tag-input`,`kashi-number-input`,`kashi-rating`,`kashi-pagination`],()=>import(`./controls-BwebEIlf.js`)],[[`kashi-data-table`],()=>import(`./table-Bt9WVLoo.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-BHivKDdC.js`)],[[`kashi-date-range-picker`,`kashi-month-picker`,`kashi-file-upload`,`kashi-color-picker`],()=>import(`./pickers-BHzNt_X8.js`)],[[`kashi-bar-chart`,`kashi-line-chart`,`kashi-pie-chart`,`kashi-bar-list`,`kashi-proportion-bar`,`kashi-sparkline`,`kashi-activity-heatmap`],()=>import(`./charts-D6KM26Vp.js`)],[[`kashi-input`,`kashi-textarea`,`kashi-banner`],()=>import(`./basic-CrEW2RKF.js`)],[[`kashi-appointment-picker`],()=>import(`./appointment-CrIZi8Bp.js`)],[[`kashi-command-palette`,`kashi-context-menu`,`kashi-carousel`,`kashi-tree-view`,`kashi-tour`,`kashi-splitter`,`kashi-side-nav`],()=>import(`./nav-NK-v48B5.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};
@@ -0,0 +1,12 @@
1
+ import{D as e,c as t,i as n,l as r,o as i,p as a,r as o,s,t as c,v as l}from"./base-DTQ50VdG.js";import{n as u,r as d,t as f}from"./combobox-6EFI2qqN.js";import"./inputs-R7nEHfbV.js";const p=`0 0 1000 907`,m={"آذربایجان شرقی":{x:123,y:128,d:`M163 199l1-7l10-12l11-8l17-2l20 2l7-4l-13-8l-2-7l-12-7l-1-7l2-10l-8-10l-5-17l-15 0l-10-6l10-13l7 0l2-16l-6-22l-13 8l-12 19l-8-2l-10 4l-5-5l5-9l5 1l12-6l6-7l-4-9l-8 1l-15 18l-10-1l-13 4l-33-8l-6 6l-3 10l0 14l-9 9l-3 10l5 7l4 34l4 7l2 15l16 10l12 1l8 8l11 7l5-7l13-5l8 5l2 13l7 3z`},"آذربایجان غربی":{x:39,y:59,d:`M75 53l-8-13l-9-3l-6-11l-5-4l-4-11l-17-11l-5 5l-3 17l-7 4l-11-1l1 13l6 4l-3 10l7 10l-1 8l2 7l0 15l7 1l-5 18l-6 9l0 6l8 1l4 6l8 3l-2 18l13 10l-3 12l7 5l-3 16l9 3l2 6l-3 7l7 9l6 0l6 20l1 7l7-2l12-15l8-3l4-8l4-2l13 2l27-3l6 6l11 2l10-11l-7-16l-12 1l-7-3l-2-13l-8-5l-13 5l-5 7l-11-7l-8-8l-12-1l-16-10l-2-15l-4-7l-4-34l-5-7l3-10l9-9l0-14l3-10z`},اردبیل:{x:202,y:87,d:`M229 168l7 5l3-4l12 1l-1-10l-8-8l-8-13l-5-13l3-13l12-14l-7-7l-9-12l-7-2l-5-9l-10-6l2-8l10-2l3-5l-8-9l-1-8l11-5l-15-18l-11-3l-29 21l-10 5l-4 8l4 9l-6 7l-12 6l-5-1l-5 9l5 5l10-4l8 2l12-19l13-8l6 22l-2 16l-7 0l-10 13l10 6l15 0l5 17l8 10l-2 10l1 7l12 7l2 7z`},اصفهان:{x:414,y:418,d:`M296 467l10-6l9-1l6 4l10 0l6-4l15-2l6 10l1 10l15 12l4 11l-4 7l-1 18l5 16l0 7l3 11l14 12l5-1l0-11l7-21l-9-7l6-6l17-11l4 10l16 2l18-5l-3-9l5-25l-2-19l15-11l9-2l16 4l55-19l9-6l6-19l3-4l12-5l6-12l-1-42l-4-3l-125 4l-25-8l-23 0l-10-6l-17 5l-15 1l-8 6l-2 12l3 3l-7 19l-12 5l-22 6l-13 8l-1 9l-7 14l-8 2l-4 11l-8 7l2 6l13 3z`},البرز:{x:353,y:249,d:`M351 227l-12-1l-8 2l11 9l-5 13l-12 7l-3 7l2 5l16 1l11 3l13-13l4-11l12-3l0-6l-3-4l-14-6z`},ایلام:{x:143,y:429,d:`M87 397l8 0l8 16l6 7l1 6l-4 13l9 0l11 4l12 8l21 18l12 1l3 7l9 14l9-7l-1-7l9-16l-10-20l-13-15l-11-5l-22-20l7-9l18-5l6-6l-2-9l-11 1l1 12l-24 1l-13-4l-7-5l-16-5l-11 1z`},بوشهر:{x:387,y:698,d:`M312 606l4 5l1 11l5 5l8 12l13 12l0 19l10 0l4 4l-5 9l3 5l9 6l1 10l4 10l6 7l0 7l6 10l11 8l7 1l15 0l12 9l9 2l8 6l2 11l4 2l2-3l13-1l-10-7l-14-15l-7-16l-9-8l-9-27l-24-44l-8-6l-14-19l-21-5l-6-9l-1-7l-9-4l-11-2z`},تهران:{x:384,y:274,d:`M380 240l0 6l-12 3l-4 11l-13 13l4 10l-5 14l15 1l13 3l29 18l5-16l-8-12l2-15l6 1l13 8l24 5l11-5l8-7l2-6l-3-14l-11-2l-22-7l-11 12l-12-1l-10-13l-15-4z`},"چهارمحال و بختیاری":{x:346,y:499,d:`M323 529l12 6l5 0l19 17l8 1l11-4l0-7l-5-16l1-18l4-7l-4-11l-15-12l-1-10l-6-10l-15 2l-6 4l-10 0l-6-4l-9 1l-10 6l1 5l9 17l6 4l6 14l8 9l1 6z`},"خراسان جنوبی":{x:802,y:473,d:`M734 452l-3 11l7 13l-3 13l-7 9l-11 22l59 27l8 5l21 30l40-12l18 10l12 15l10-4l-3-12l1-20l6-17l0-11l-16-2l-3-33l3-14l-13-45l0-10l13-16l3-9l-12 0l-7-5l0-13l-2-15l-36 1l-7-3l-8-10l-10 4l-16 3l-2 2l-14-2l-3 22l-2 6l4 8l8 6l-7 11l-16 11l-7 11z`},"خراسان رضوی":{x:784,y:272,d:`M657 206l6 6l-4 10l0 19l4 12l15 14l0 4l-13 22l-11 4l-13 10l-8 10l21-5l21-10l13-4l6 2l15 12l1 8l-5 5l-21 14l-3 6l-7 20l0 11l3 18l2 4l11 1l13-3l4 7l4 26l3 7l14 8l6 8l5-13l7-11l16-11l7-11l-8-6l-4-8l2-6l3-22l14 2l2-2l16-3l10-4l8 10l7 3l36-1l2-7l7-7l12-1l-9-14l12-6l6-11l3-16l0-13l9-18l-3-7l1-14l-4-8l3-7l-4-19l2-11l-6-4l-38 1l-17-26l-27-10l-7-9l-1-11l-7-2l-9-6l-9-4l-8 2l-10-3l-8 4l-8-3l-2-7l-23-8l-8 6l0 9l24 1l7 11l-1 9l-7 21l11 9l-4 5l1 9l-5 3l-15-2l-34-20l-9 0l-12 10z`},"خراسان شمالی":{x:674,y:152,d:`M712 124l-20-4l0-8l-7-12l-9 5l-16-5l-8 2l-8-1l-14 11l0 21l7 5l-2 8l-15 6l-5 8l12 16l-2 15l13 14l11 3l8-2l3-11l12-10l9 0l34 20l15 2l5-3l-1-9l4-5l-11-9l7-21l1-9l-7-11l-24-1l0-9z`},خوزستان:{x:253,y:524,d:`M183 491l13 21l-8 22l0 25l18 1l0 31l7 2l13 12l3 14l8 2l1-5l13 1l3-3l-1-10l-3-6l6-10l10 0l-9 12l13 9l12 0l6 8l17-11l7 0l9-2l11 2l-4-19l2-10l-8-5l-6-7l-9 2l0-9l-2-9l2-7l6-3l10-10l4-7l-1-6l-8-9l-6-14l-6-4l-9-17l-1-5l0-10l-13-3l-2-6l-11 0l-12-8l-12-1l-11-5l-22 2l-3 2l-10 23l-9 16l1 7z`},زنجان:{x:228,y:211,d:`M170 215l2 1l26 6l4 7l1 15l-3 11l14 8l3 4l4 5l11 0l9 4l6-5l-11-12l10-5l13-3l9-6l9-3l0-8l-4-11l-8-3l-6-11l1-9l10-5l-3-11l-8-9l-8-5l-12-1l-3 4l-7-5l-7 4l-20-2l-17 2l-11 8l-10 12l-1 7z`},سمنان:{x:554,y:286,d:`M615 160l-12 17l-10 22l-18-3l-14 6l-12 11l-7 3l-18 0l-10 4l-6 8l-2 9l-10 12l-6 4l-8 1l-15 4l3 14l-2 6l-8 7l-11 5l-24-5l-13-8l-6-1l-2 15l8 12l-5 16l1 8l-6 13l10 6l23 0l25 8l125-4l4 3l19-1l6-3l19-32l8-10l13-10l11-4l13-22l0-4l-15-14l-4-12l0-19l4-10l-6-6l-8 2l-11-3l-13-14l2-15z`},"سیستان و بلوچستان":{x:863,y:770,d:`M805 582l-11 50l0 5l5 8l2 12l-2 11l-4 7l0 13l2 7l-16 11l-9 3l8 10l-7 13l-1 27l-6 23l3 21l6 10l-3 7l0 9l3 8l-4 16l-2 4l13 11l9 14l0 4l11-2l4 4l12 0l7 4l9-2l7 2l8 0l3-5l7-2l4 10l21 4l8 5l12 3l4-8l6-5l2-27l6-4l2-19l3-5l20-6l2-9l7-3l9-1l8-4l21 1l2-12l4-3l-2-10l1-9l-4-3l-13 3l-6-1l-2-7l3-8l-2-20l-3-10l2-12l-10-1l-11-12l-16-3l-8-4l-13-12l-4-7l-5-13l-7-10l-3-9l-23-27l49-58l2-13l-4-16l-5-5l-27-4l0 11l-6 17l-1 20l3 12l-10 4l-12-15l-18-10z`},فارس:{x:473,y:666,d:`M464 773l5 7l12 1l8 5l5-1l16 2l5-2l3-13l8-5l27-2l14 2l9-5l4-8l17-6l2-5l-7-8l2-14l0-10l-16-15l1-6l-3-9l-10-26l-17-4l-9-20l-19-11l-3-17l-11-14l-8-16l-12-30l-15-16l-13-5l-18 5l-16-2l-4-10l-17 11l-6 6l9 7l-7 21l0 11l-5 1l0 13l-6 2l-16-7l-5-1l4 16l-1 6l-14 8l-16 1l1 7l6 9l21 5l14 19l8 6l24 44l9 27l9 8l7 16l14 15z`},قزوین:{x:304,y:239,d:`M270 195l-10 5l-1 9l6 11l8 3l4 11l0 8l-9 3l-9 6l-13 3l-10 5l11 12l8-1l8 10l17 3l9 0l4-5l31-9l-2-5l3-7l12-7l5-13l-11-9l8-2l12 1l-1-3l-25-20l-11 1l-15 6l-17-4z`},قم:{x:368,y:323,d:`M407 319l-29-18l-13-3l-15-1l-3 7l-2 13l-28 8l1 7l-6 6l13 9l1 7l6 6l14 1l17 6l-3-3l2-12l8-6l15-1l17-5l6-13z`},کردستان:{x:152,y:265,d:`M75 247l16 13l13-3l9 9l-10 1l-4 13l8 13l12 8l12 17l5 9l14-1l4-8l12-5l1-5l7-1l1-5l11 3l8 9l3 0l13-1l3-8l-1-6l-8-7l-9-18l8 1l14-8l-3-4l-14-8l3-11l-1-15l-4-7l-26-6l-2-1l-10 11l-11-2l-6-6l-27 3l-13-2l-4 2l-4 8l-8 3z`},کرمان:{x:697,y:622,d:`M717 520l-56-24l-6-1l-4 4l-14 10l-28 15l-2 4l-2 24l-9 4l-9 1l-11-1l-30 5l-7 10l-1 7l11 23l-1 19l2 8l-10 3l9 20l17 4l10 26l14 3l7 7l7 2l11-8l9-1l1 33l4 6l10 7l6 1l10-4l10-9l8 3l2 16l6 4l8 11l-2 6l5 10l3 25l21 11l9-5l11 9l-3 3l-4 30l16-1l7 2l5 8l7-2l7 5l4-16l-3-8l0-9l3-7l-6-10l-3-21l6-23l1-27l7-13l-8-10l9-3l16-11l-2-7l0-13l4-7l2-11l-2-12l-5-8l0-5l11-50l-21-30l-8-5z`},کرمانشاه:{x:139,y:357,d:`M107 293l3 6l-9 8l-7 3l-2 8l-8 5l-2 6l3 11l-10-3l-3 14l6 4l-1 11l-6 8l12 20l4 3l5-24l11-1l16 5l7 5l13 4l24-1l-1-12l11-1l1-8l9-3l0-8l6-1l3-4l13-1l0-7l-19-6l11-20l-3 0l-8-9l-11-3l-1 5l-7 1l-1 5l-12 5l-4 8l-14 1l-5-9l-12-17z`},"کهگیلویه و بویراحمد":{x:348,y:570,d:`M332 606l9 4l16-1l14-8l1-6l-4-16l5 1l16 7l6-2l0-13l-14-12l-3-11l-11 4l-8-1l-19-17l-5 0l-12-6l-10 10l-6 3l-2 7l2 9l0 9l9-2l6 7l8 5l-2 10z`},گلستان:{x:577,y:168,d:`M630 112l-9 1l-14-3l-15 3l-16 8l-14 12l-3 8l-1 8l-8 6l-23 7l-14-1l6 25l-1 9l-16 0l3 6l11 6l8 9l18 0l7-3l12-11l14-6l18 3l10-22l12-17l5-8l15-6l2-8l-7-5z`},گیلان:{x:295,y:181,d:`M251 170l8 5l8 9l3 11l12 12l17 4l15-6l11-1l7-12l7-8l-13-11l-9-16l-11-4l-26-2l-16-9l-6-7l-6-23l-1-23l-14 3l7 7l-12 14l-3 13l5 13l8 13l8 8z`},لرستان:{x:221,y:403,d:`M173 372l2 9l-6 6l-18 5l-7 9l22 20l11 5l13 15l10 20l10-23l3-2l22-2l11 5l12 1l12 8l11 0l8-7l4-11l8-2l7-14l1-9l-9-10l-4 6l-9-8l1-6l-7-6l-7 4l-7 9l-14-4l3-15l-15-6l-10 3l-15-2l-27-18l-6 1l0 8l-9 3z`},مازندران:{x:467,y:227,d:`M325 204l25 20l1 3l12 3l14 6l3 4l6 3l15 4l10 13l12 1l11-12l22 7l11 2l15-4l8-1l6-4l10-12l2-9l6-8l10-4l-8-9l-11-6l-3-6l-2-4l-9-1l-20 5l-17 5l-45 10l-43-10l-27-16l-7 8z`},مرکزی:{x:294,y:357,d:`M280 283l2 8l-8 0l4 11l-7 7l11 4l5 13l-8-2l-1-7l-14 0l-2 10l0 9l-7 2l1 11l4 7l2 11l-6 8l-3 15l14 4l7-9l7-4l7 6l-1 6l9 8l4-6l9 10l13-8l22-6l12-5l7-19l-17-6l-14-1l-6-6l-1-7l-13-9l6-6l-1-7l28-8l2-13l3-7l5-14l-4-10l-11-3l-16-1l-31 9l-4 5z`},هرمزگان:{x:651,y:758,d:`M771 853l-7-5l-7 2l-5-8l-7-2l-16 1l4-30l3-3l-11-9l-9 5l-21-11l-3-25l-5-10l2-6l-8-11l-6-4l-2-16l-8-3l-10 9l-10 4l-6-1l-10-7l-4-6l-1-33l-9 1l-11 8l-7-2l-7-7l-14-3l3 9l-1 6l16 15l0 10l-2 14l7 8l-2 5l-17 6l-4 8l-9 5l-14-2l-27 2l-8 5l-3 13l-5 2l-16-2l-5 1l-8-5l-12-1l-5-7l-13 1l-2 3l20 13l18 6l4 8l12 8l14-2l17 2l4 6l9 2l3 4l9 1l25-17l6 1l8-2l3-9l4-3l14-1l9-8l12-2l12 3l12 0l8 10l6 21l0 10l3 10l4 6l-3 4l9 18l23 3l1 5l9-3l6 7l24-1l14 1l10 9l6 1l7-2l0-4l-9-14l-13-11zM633 795l-9 2l-13 8l-3 3l-20 8l8 3l10-6l9-3l4 3l7-5z`},همدان:{x:235,y:319,d:`M197 314l-11 20l19 6l0 7l-13 1l-3 4l27 18l15 2l10-3l15 6l6-8l-2-11l-4-7l-1-11l7-2l0-9l2-10l14 0l1 7l8 2l-5-13l-11-4l7-7l-4-11l8 0l-2-8l-17-3l-8-10l-8 1l-6 5l-9-4l-11 0l-4-5l-14 8l-8-1l9 18l8 7l1 6l-3 8z`},یزد:{x:615,y:452,d:`M633 317l-19 32l-6 3l-19 1l1 42l-6 12l-12 5l-3 4l-6 19l-9 6l-55 19l-16-4l-9 2l-15 11l2 19l-5 25l3 9l13 5l15 16l12 30l8 16l11 14l3 17l19 11l10-3l-2-8l1-19l-11-23l1-7l7-10l30-5l11 1l9-1l9-4l2-24l2-4l28-15l14-10l4-4l6 1l56 24l11-22l7-9l3-13l-7-13l3-11l-6-8l-14-8l-3-7l-4-26l-4-7l-13 3l-11-1l-2-4l-3-18l0-11l7-20l3-6l21-14l5-5l-1-8l-15-12l-6-2l-13 4l-21 10z`}},h=d.map(e=>e.name),g=Object.fromEntries(d.map(e=>[e.name,e.capital])),[,,_,v]=p.split(` `).map(Number);var y=class extends c{constructor(){super(...arguments),this.values=null,this.selected=[],this.active=0,this.rendered=!1,this.valueSet=!1,this.key=l(`kashi-map`)}connectedCallback(){this.rendered||(this.valueSet||(this.selected=(this.getAttribute(`value`)??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e))),this.values===null&&(this.values=this.parseData(this.getAttribute(`data`)))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`data`&&(this.values=this.parseData(n)),e===`value`?this.value=n??``:this.render())}parseData(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}get data(){return this.values}set data(e){this.values=e,this.rendered&&this.render()}get value(){return this.selected.join(`,`)}set value(e){this.valueSet=!0,this.selected=String(e??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e)),this.multiple||(this.selected=this.selected.slice(0,1)),this.rendered&&this.paint()}get selectedProvinces(){return[...this.selected]}get multiple(){return n(this,`multiple`)}get selectable(){return this.multiple||n(this,`selectable`)||this.hasAttribute(`value`)||this.hasAttribute(`name`)}fmt(t){return e(t,{digits:s(this)})}level(e){let t=this.values,n=t?.[e];if(typeof n!=`number`||!t)return;let r=this.steps,i=h.map(e=>t[e]).filter(e=>typeof e==`number`),a=Math.min(...i),o=Math.max(...i);if(o===a)return r;if(this.getAttribute(`scale`)!==`linear`){let e=[...i].sort((e,t)=>e-t);return 1+Math.round(e.indexOf(n)*(r-1)/(e.length-1))}return Math.min(r,1+Math.floor((n-a)/(o-a)*r))}get steps(){return Number(this.getAttribute(`steps`))||5}shade(e){return`${Math.round(12+88*e/this.steps)}%`}describe(e){let t=this.values?.[e],n=this.getAttribute(`unit`);return typeof t==`number`?`${e}: ${this.fmt(t)}${n?` ${n}`:``}`:e}render(){let e=this.getAttribute(`label`)??a().iranMap.label,t=this.selectable,i=this.multiple,o=this.values,s=this.getAttribute(`unit`),c=h.map((e,n)=>{let a=this.level(e);return`<path d="${m[e].d}" class="k-iran-map__province" data-i="${n}"${a?` data-l="${a}" style="--_p: ${this.shade(a)}"`:``}${t?` role="${i?`checkbox`:`radio`}" aria-label="${r(this.describe(e))}"`:``}></path>`}).join(``),l=o?h.map(e=>o[e]).filter(e=>typeof e==`number`):[],u=(this.hasAttribute(`legend`)?n(this,`legend`):o)&&l.length?`<figcaption class="k-iran-map__legend"><span>${this.fmt(Math.min(...l))}</span><span class="k-iran-map__scale" aria-hidden="true">${Array.from({length:this.steps},(e,t)=>`<i style="--_p: ${this.shade(t+1)}"></i>`).join(``)}</span><span>${this.fmt(Math.max(...l))}${s?` ${r(s)}`:``}</span></figcaption>`:``,d=o?`<table class="k-sr-only"><caption>${r(e)}</caption><tbody>${h.filter(e=>typeof o[e]==`number`).sort((e,t)=>o[t]-o[e]).map(e=>`<tr><th scope="row">${r(e)}</th><td>${this.fmt(o[e])}${s?` ${r(s)}`:``}</td></tr>`).join(``)}</tbody></table>`:``;this.innerHTML=`<figure class="k-iran-map${t?` k-iran-map--selectable`:``}"><div class="k-iran-map__canvas" style="block-size: auto; aspect-ratio: ${_} / ${v}"><svg viewBox="${p}" class="k-iran-map__svg" role="${t?i?`group`:`radiogroup`:`img`}" aria-label="${r(t?e:`${e}${o?a().iranMap.tableNote:``}`)}">${c}</svg><div class="k-chart__tip" aria-hidden="true" style="display: none"></div></div>${u}${d}</figure>`;let f=this.querySelector(`svg`),g=this.querySelector(`figure`);f.addEventListener(`pointerover`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&this.tip(Number(t))}),g.addEventListener(`pointerleave`,()=>this.tip(null)),t&&(f.addEventListener(`click`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.toggle(h[this.active]))}),f.addEventListener(`keydown`,e=>this.onKey(e)),f.addEventListener(`focusin`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.tip(this.active))}),f.addEventListener(`focusout`,()=>this.tip(null))),this.rendered=!0,this.paint()}paint(){let e=this.selectable,t=h.findIndex(e=>this.selected.includes(e)),n=this.contains(document.activeElement)||t<0?this.active:t;this.querySelectorAll(`.k-iran-map__province`).forEach((t,r)=>{let i=this.selected.includes(h[r]);t.toggleAttribute(`data-selected`,i),e&&(t.setAttribute(`aria-checked`,String(i)),t.setAttribute(`tabindex`,r===n?`0`:`-1`))});let r=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),r)for(let e of this.multiple?this.selected:[this.selected[0]??``]){let t=document.createElement(`input`);t.type=`hidden`,t.name=r,t.value=e,this.append(t)}}toggle(e){this.selected=this.multiple?this.selected.includes(e)?this.selected.filter(t=>t!==e):[...this.selected,e]:this.selected[0]===e?[]:[e],this.paint(),t(this,`kashi-change`,{value:this.multiple?[...this.selected]:this.selected[0]??null})}onKey(e){let t=this.active,n={ArrowLeft:1,ArrowDown:1,ArrowRight:-1,ArrowUp:-1}[e.key],r=t;if(n)r=(t+n+h.length)%h.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=h.length-1;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.toggle(h[t]);return}else return;e.preventDefault(),this.active=r,this.paint(),this.querySelector(`[data-i="${r}"]`)?.focus()}tip(e){let t=this.querySelector(`.k-chart__tip`);if(!t)return;if(this.querySelector(`.k-iran-map__province[data-active]`)?.removeAttribute(`data-active`),e===null){t.style.display=`none`;return}let n=h[e];this.querySelector(`[data-i="${e}"]`)?.setAttribute(`data-active`,``);let i=m[n],o=this.querySelector(`figure`).clientWidth||_,s=this.values?.[n],c=this.getAttribute(`unit`),l=typeof s==`number`?`${this.fmt(s)}${c?` ${c}`:``}`:a().province.capital(g[n]);t.innerHTML=`<span class="k-chart__tip-title">${r(n)}</span><span class="k-chart__tip-row"><strong>${r(l)}</strong></span>`,t.style.left=`${Math.min(Math.max(i.x/_*o,80),o-80)}px`,t.style.top=`${Math.max(64,i.y/v*(v/_*o)-6)}px`,t.style.display=``}};y.observedAttributes=[`data`,`value`,`label`,`unit`,`steps`,`scale`,`legend`,`selectable`,`multiple`,`name`];const b=()=>{let e=a().address;return{province:e.province,city:e.city,street:e.street,plaque:e.plaque,unit:e.unit,postalCode:e.postalCode}};var x=class extends c{constructor(){super(...arguments),this.address={...f},this.built=!1,this.key=l(`kashi-address`)}connectedCallback(){o(()=>{if(this.isConnected){if(!this.built){let e=Object.prototype.hasOwnProperty.call(this,`value`)?this.value:null;delete this.value;let t=this.getAttribute(`value`),n=e??{};if(!e&&t)try{n=JSON.parse(t)}catch{}this.address={...f,...n}}this.render()}})}attributeChangedCallback(e,t,n){this.built&&t!==n&&this.render()}get value(){return{...this.address}}set value(e){this.address={...f,...e},this.built&&this.render()}set errors(e){for(let t of Object.keys(b())){let n=this.querySelector(`[data-field="${t}"]`);n&&(n.matches(`kashi-province-select, kashi-city-select, kashi-postal-code`)?e[t]?n.setAttribute(`error`,e[t]):n.removeAttribute(`error`):this.fieldError(n,e[t]??null))}}label(e){return this.getAttribute(`label-${e===`postalCode`?`postal-code`:e}`)??b()[e]}render(){let e=this.address,t=this.getAttribute(`name`),i=e=>t?` name="${r(`${t}[${e}]`)}"`:``,o=n(this,`required`,!0),s=o?` required`:``,c=n(this,`map`),l=this.key,d=o?`<span class="k-label__required" aria-hidden="true">*</span>`:``,f=this.getAttribute(`legend`)??a().address.legend;this.innerHTML=`<fieldset class="k-address${c?` k-address--map`:``}"${this.hasAttribute(`disabled`)?` disabled`:``}>
2
+ ${f?`<legend class="k-address__legend">${r(f)}</legend>`:``}
3
+ <div class="k-address__fields">
4
+ <kashi-province-select class="k-address__province" data-field="province" label="${r(this.label(`province`))}" show-capital="false" placeholder="${r(a().address.provinceSearch)}"${i(`province`)}${s}></kashi-province-select>
5
+ <kashi-city-select class="k-address__city" data-field="city" label="${r(this.label(`city`))}"${i(`city`)}${s}></kashi-city-select>
6
+ <div class="k-field k-address__street" data-field="street"><div class="k-field__label-row"><label class="k-label" for="${l}-street">${r(this.label(`street`))}${d}</label></div><div class="k-input k-input--textarea k-input--autoresize"><textarea id="${l}-street" class="k-input__control" rows="2" autocomplete="street-address" placeholder="${r(a().address.streetHint)}"${i(`street`)}${s}></textarea></div></div>
7
+ <div class="k-field k-address__plaque" data-field="plaque"><div class="k-field__label-row"><label class="k-label" for="${l}-plaque">${r(this.label(`plaque`))}${d}</label></div><div class="k-input"><input id="${l}-plaque" class="k-input__control" inputmode="numeric" autocomplete="address-line2"${i(`plaque`)}${s}></div></div>
8
+ <div class="k-field k-address__unit" data-field="unit"><div class="k-field__label-row"><label class="k-label" for="${l}-unit">${r(this.label(`unit`))}${o?`<span class="k-label__optional">${r(a().common.optional)}</span>`:``}</label></div><div class="k-input"><input id="${l}-unit" class="k-input__control" inputmode="numeric" autocomplete="address-line3"${i(`unit`)}></div></div>
9
+ <kashi-postal-code class="k-address__postal" data-field="postalCode" label="${r(this.label(`postalCode`))}"${i(`postalCode`)}${s}></kashi-postal-code>
10
+ </div>
11
+ ${c?`<kashi-iran-map class="k-address__map" selectable label="${r(a().iranMap.onMap(this.label(`province`)))}"></kashi-iran-map>`:``}
12
+ </fieldset>`,this.built=!0;let p=this.querySelector(`kashi-province-select`),m=this.querySelector(`kashi-city-select`),h=this.querySelector(`kashi-postal-code`),g=this.querySelector(`kashi-iran-map`),_=this.querySelector(`textarea`),v=this.querySelector(`#${l}-plaque`),y=this.querySelector(`#${l}-unit`);e.province&&(p.value=e.province),e.province&&m.setAttribute(`province`,e.province),e.city&&(m.value=e.city),h.value=e.postalCode,_.value=e.street,v.value=e.plaque,y.value=e.unit,g&&e.province&&(g.value=e.province);let b=e=>{let t=e&&this.address.city&&u(e).includes(this.address.city);this.address={...this.address,province:e,city:t?this.address.city:null},p.value!==(e??``)&&(p.value=e??``),m.province=e,t||(m.value=``),g&&(g.value=e??``),this.changed()},x=e=>e.stopPropagation();p.addEventListener(`kashi-change`,e=>{x(e),b(e.detail.value||null)}),g?.addEventListener(`kashi-change`,e=>{x(e),b(e.detail.value)}),m.addEventListener(`kashi-change`,e=>{x(e);let{value:t,province:n}=e.detail;this.address={...this.address,city:t||null},n&&!this.address.province?b(n):this.changed()}),h.addEventListener(`kashi-change`,e=>{x(e),this.address={...this.address,postalCode:e.detail.value},this.changed()});for(let[e,t]of[[_,`street`],[v,`plaque`],[y,`unit`]])e.addEventListener(`input`,()=>{this.address={...this.address,[t]:e.value},this.changed()})}changed(){t(this,`kashi-change`,{value:this.value})}fieldError(e,t){e.querySelector(`.k-field__hint-row`)?.remove();let n=e.querySelector(`.k-input__control`);e.toggleAttribute(`data-invalid`,!!t),t?(e.insertAdjacentHTML(`beforeend`,`<div class="k-field__hint-row"><div class="k-field__hints"><p class="k-hint k-hint--error" id="${n.id}-error">${r(t)}</p></div></div>`),n.setAttribute(`aria-invalid`,`true`),n.setAttribute(`aria-describedby`,`${n.id}-error`)):(n.removeAttribute(`aria-invalid`),n.removeAttribute(`aria-describedby`))}};x.observedAttributes=[`legend`,`name`,`map`,`required`,`disabled`],i(`kashi-iran-map`,y,`block`),i(`kashi-address-form`,x,`block`);export{x as KashiAddressForm,y as KashiIranMap};
@@ -1 +1 @@
1
- import{a as e,d as t,o as n,r,s as i,t as a}from"./base-DfzNTdQk.js";const o=e=>[...e.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)];var s=class extends a{constructor(){super(...arguments),this.menu=null,this.trigger=null,this.key=t(`kashi-menu`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.menu&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.menu&&this.decorate()}get open(){return!!this.menu&&!this.menu.hidden}build(){let[e,...t]=[...this.children];if(!e)return;this.classList.add(`k-menu-anchor`),this.trigger=e,e.id||=`${this.key}-trigger`,e.setAttribute(`aria-haspopup`,`menu`),e.setAttribute(`aria-expanded`,`false`);let r=document.createElement(`ul`);r.id=`${this.key}-menu`,r.setAttribute(`role`,`menu`),r.hidden=!0;for(let e of t){let t=document.createElement(`li`);if(e.tagName===`HR`)t.setAttribute(`role`,`separator`),t.className=`k-menu__separator`,e.remove();else if(e.hasAttribute(`data-label`))t.setAttribute(`role`,`presentation`),t.className=`k-menu__label`,t.textContent=e.textContent,e.remove();else{t.setAttribute(`role`,`none`);let n=e.hasAttribute(`data-checked`);e.setAttribute(`role`,n?`menuitemcheckbox`:`menuitem`),e.tabIndex=-1,e.classList.add(`k-menu__item`),e.dataset.tone===`danger`&&e.classList.add(`k-menu__item--danger`),e instanceof HTMLButtonElement&&(e.type=`button`,e.disabled&&(e.disabled=!1,e.setAttribute(`aria-disabled`,`true`)));let r=e.innerHTML;e.innerHTML=`${n?`<span class="k-menu__check" aria-hidden="true"></span>`:``}<span>${r}</span>${e.dataset.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${i(e.dataset.shortcut)}</span>`:``}`,n&&this.paintCheck(e),t.append(e)}r.append(t)}this.append(r),this.menu=r,this.decorate(),e.addEventListener(`click`,()=>this.open?this.close(!1):this.show(`first`)),e.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),this.show(e.key===`ArrowUp`?`last`:`first`))}),r.addEventListener(`keydown`,e=>this.onKey(e)),r.addEventListener(`click`,e=>{let t=e.target.closest(`[role^="menuitem"]`);t&&t.getAttribute(`aria-disabled`)!==`true`&&(t.getAttribute(`role`)===`menuitemcheckbox`&&(t.dataset.checked=String(t.dataset.checked!==`true`),this.paintCheck(t)),n(this,`kashi-select`,{value:t.dataset.value??t.textContent?.trim()??``,checked:t.dataset.checked===void 0?void 0:t.dataset.checked===`true`}),t.getAttribute(`role`)===`menuitem`&&this.close(t.tagName!==`A`))})}paintCheck(e){let t=e.dataset.checked===`true`;e.setAttribute(`aria-checked`,String(t)),e.querySelector(`.k-menu__check`).innerHTML=t?`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 10.5 3.2 3L15 7"/></svg>`:``}decorate(){let e=this.getAttribute(`label`);this.menu.className=`k-menu${this.getAttribute(`align`)===`end`?` k-menu--end`:``}`,e?(this.menu.setAttribute(`aria-label`,e),this.menu.removeAttribute(`aria-labelledby`)):(this.menu.setAttribute(`aria-labelledby`,this.trigger.id),this.menu.removeAttribute(`aria-label`))}show(e=`first`){if(!this.menu)return;this.menu.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.menu.id);let t=o(this.menu);(e===`last`?t.at(-1):t[0])?.focus(),document.addEventListener(`pointerdown`,this.onOutside)}close(e=!0){this.menu&&!this.menu.hidden&&(this.menu.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),e&&this.trigger.focus())}onKey(e){let t=o(this.menu),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)this.close();else if(e.key===`Tab`)return this.close(!1);else if(e.key.length===1&&/\S/.test(e.key)){let r=e.key.toLowerCase();[...t.slice(n+1),...t.slice(0,n+1)].find(e=>e.textContent?.trim().toLowerCase().startsWith(r))?.focus()}else return;e.preventDefault()}};s.observedAttributes=[`label`,`align`];var c=class extends a{constructor(){super(...arguments),this.panel=null,this.trigger=null,this.key=t(`kashi-pop`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.panel&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.panel&&this.decorate()}get open(){return!!this.panel&&!this.panel.hidden}set open(e){e?this.show():this.close(!1)}build(){let[e,...t]=[...this.childNodes].filter(e=>e.nodeType===1||e.textContent?.trim());if(!e)return;this.classList.add(`k-popover-anchor`),this.trigger=e,e.setAttribute(`aria-haspopup`,`dialog`),e.setAttribute(`aria-expanded`,`false`);let n=document.createElement(`div`);n.id=`${this.key}-panel`,n.setAttribute(`role`,`dialog`),n.tabIndex=-1,n.hidden=!0,n.innerHTML=`<p class="k-popover__title" id="${this.key}-title"></p><div class="k-popover__body"></div>`,n.querySelector(`.k-popover__body`).append(...t),this.append(n),this.panel=n,this.decorate(),e.addEventListener(`click`,()=>this.open?this.close(!1):this.show()),n.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.close(!0))}),n.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t&&!this.contains(t)&&this.close(!1)})}decorate(){let e=this.panel,[t,n]=(this.getAttribute(`placement`)??`bottom-start`).split(`-`);e.className=[`k-popover`,t===`top`&&`k-popover--top`,n===`end`&&`k-popover--end`].filter(Boolean).join(` `);let r=this.getAttribute(`heading`),i=e.querySelector(`.k-popover__title`);i.textContent=r??``,i.hidden=!r,r?(e.setAttribute(`aria-labelledby`,i.id),e.removeAttribute(`aria-label`)):(e.removeAttribute(`aria-labelledby`),e.setAttribute(`aria-label`,this.getAttribute(`label`)??``))}show(){this.panel&&!this.open&&(this.panel.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.panel.id),(this.panel.querySelector(`.k-popover__body :is(a[href], button:not([disabled]), input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"]))`)??this.panel).focus(),document.addEventListener(`pointerdown`,this.onOutside),n(this,`kashi-open`,{}))}close(e=!0){this.panel&&!this.panel.hidden&&(this.panel.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),e&&this.trigger.focus(),n(this,`kashi-close`,{}))}};c.observedAttributes=[`heading`,`placement`,`label`],e(`kashi-dropdown-menu`,s),e(`kashi-popover`,c);export{s as KashiDropdownMenu,c as KashiPopover};
1
+ import{c as e,l as t,o as n,r,t as i,v as a}from"./base-DTQ50VdG.js";const o=e=>[...e.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)];var s=class extends i{constructor(){super(...arguments),this.menu=null,this.trigger=null,this.key=a(`kashi-menu`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.menu&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.menu&&this.decorate()}get open(){return!!this.menu&&!this.menu.hidden}build(){let[n,...r]=[...this.children];if(!n)return;this.classList.add(`k-menu-anchor`),this.trigger=n,n.id||=`${this.key}-trigger`,n.setAttribute(`aria-haspopup`,`menu`),n.setAttribute(`aria-expanded`,`false`);let i=document.createElement(`ul`);i.id=`${this.key}-menu`,i.setAttribute(`role`,`menu`),i.hidden=!0;for(let e of r){let n=document.createElement(`li`);if(e.tagName===`HR`)n.setAttribute(`role`,`separator`),n.className=`k-menu__separator`,e.remove();else if(e.hasAttribute(`data-label`))n.setAttribute(`role`,`presentation`),n.className=`k-menu__label`,n.textContent=e.textContent,e.remove();else{n.setAttribute(`role`,`none`);let r=e.hasAttribute(`data-checked`);e.setAttribute(`role`,r?`menuitemcheckbox`:`menuitem`),e.tabIndex=-1,e.classList.add(`k-menu__item`),e.dataset.tone===`danger`&&e.classList.add(`k-menu__item--danger`),e instanceof HTMLButtonElement&&(e.type=`button`,e.disabled&&(e.disabled=!1,e.setAttribute(`aria-disabled`,`true`)));let i=e.innerHTML;e.innerHTML=`${r?`<span class="k-menu__check" aria-hidden="true"></span>`:``}<span>${i}</span>${e.dataset.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${t(e.dataset.shortcut)}</span>`:``}`,r&&this.paintCheck(e),n.append(e)}i.append(n)}this.append(i),this.menu=i,this.decorate(),n.addEventListener(`click`,()=>this.open?this.close(!1):this.show(`first`)),n.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),this.show(e.key===`ArrowUp`?`last`:`first`))}),i.addEventListener(`keydown`,e=>this.onKey(e)),i.addEventListener(`click`,t=>{let n=t.target.closest(`[role^="menuitem"]`);n&&n.getAttribute(`aria-disabled`)!==`true`&&(n.getAttribute(`role`)===`menuitemcheckbox`&&(n.dataset.checked=String(n.dataset.checked!==`true`),this.paintCheck(n)),e(this,`kashi-select`,{value:n.dataset.value??n.textContent?.trim()??``,checked:n.dataset.checked===void 0?void 0:n.dataset.checked===`true`}),n.getAttribute(`role`)===`menuitem`&&this.close(n.tagName!==`A`))})}paintCheck(e){let t=e.dataset.checked===`true`;e.setAttribute(`aria-checked`,String(t)),e.querySelector(`.k-menu__check`).innerHTML=t?`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 10.5 3.2 3L15 7"/></svg>`:``}decorate(){let e=this.getAttribute(`label`);this.menu.className=`k-menu${this.getAttribute(`align`)===`end`?` k-menu--end`:``}`,e?(this.menu.setAttribute(`aria-label`,e),this.menu.removeAttribute(`aria-labelledby`)):(this.menu.setAttribute(`aria-labelledby`,this.trigger.id),this.menu.removeAttribute(`aria-label`))}show(e=`first`){if(!this.menu)return;this.menu.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.menu.id);let t=o(this.menu);(e===`last`?t.at(-1):t[0])?.focus(),document.addEventListener(`pointerdown`,this.onOutside)}close(e=!0){this.menu&&!this.menu.hidden&&(this.menu.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),e&&this.trigger.focus())}onKey(e){let t=o(this.menu),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)this.close();else if(e.key===`Tab`)return this.close(!1);else if(e.key.length===1&&/\S/.test(e.key)){let r=e.key.toLowerCase();[...t.slice(n+1),...t.slice(0,n+1)].find(e=>e.textContent?.trim().toLowerCase().startsWith(r))?.focus()}else return;e.preventDefault()}};s.observedAttributes=[`label`,`align`];var c=class extends i{constructor(){super(...arguments),this.panel=null,this.trigger=null,this.key=a(`kashi-pop`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.panel&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.panel&&this.decorate()}get open(){return!!this.panel&&!this.panel.hidden}set open(e){e?this.show():this.close(!1)}build(){let[e,...t]=[...this.childNodes].filter(e=>e.nodeType===1||e.textContent?.trim());if(!e)return;this.classList.add(`k-popover-anchor`),this.trigger=e,e.setAttribute(`aria-haspopup`,`dialog`),e.setAttribute(`aria-expanded`,`false`);let n=document.createElement(`div`);n.id=`${this.key}-panel`,n.setAttribute(`role`,`dialog`),n.tabIndex=-1,n.hidden=!0,n.innerHTML=`<p class="k-popover__title" id="${this.key}-title"></p><div class="k-popover__body"></div>`,n.querySelector(`.k-popover__body`).append(...t),this.append(n),this.panel=n,this.decorate(),e.addEventListener(`click`,()=>this.open?this.close(!1):this.show()),n.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.close(!0))}),n.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t&&!this.contains(t)&&this.close(!1)})}decorate(){let e=this.panel,[t,n]=(this.getAttribute(`placement`)??`bottom-start`).split(`-`);e.className=[`k-popover`,t===`top`&&`k-popover--top`,n===`end`&&`k-popover--end`].filter(Boolean).join(` `);let r=this.getAttribute(`heading`),i=e.querySelector(`.k-popover__title`);i.textContent=r??``,i.hidden=!r,r?(e.setAttribute(`aria-labelledby`,i.id),e.removeAttribute(`aria-label`)):(e.removeAttribute(`aria-labelledby`),e.setAttribute(`aria-label`,this.getAttribute(`label`)??``))}show(){this.panel&&!this.open&&(this.panel.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.panel.id),(this.panel.querySelector(`.k-popover__body :is(a[href], button:not([disabled]), input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"]))`)??this.panel).focus(),document.addEventListener(`pointerdown`,this.onOutside),e(this,`kashi-open`,{}))}close(t=!0){this.panel&&!this.panel.hidden&&(this.panel.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),t&&this.trigger.focus(),e(this,`kashi-close`,{}))}};c.observedAttributes=[`heading`,`placement`,`label`],n(`kashi-dropdown-menu`,s),n(`kashi-popover`,c);export{s as KashiDropdownMenu,c as KashiPopover};
@@ -0,0 +1 @@
1
+ import{c as e,i as t,l as n,m as r,o as i,p as a,r as o,t as s,v as c}from"./base-DTQ50VdG.js";import{n as l}from"./text-D4a_hlwL.js";const u=e=>l(e,{digits:`latin`}).toLowerCase(),d=e=>[...e.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)];var f=class extends s{constructor(){super(...arguments),this.list=null,this.dialog=null,this.query=``,this.active=0,this.opener=null,this.key=c(`kashi-cmd`),this.onShortcut=e=>{this.getAttribute(`shortcut`)!==`false`&&(e.ctrlKey||e.metaKey)&&(e.key===`k`||e.key===`K`||e.code===`KeyK`)&&(e.preventDefault(),this.dialog?.open?this.close():this.show())}}connectedCallback(){o(()=>{this.isConnected&&(this.list===null&&(this.list=this.readItems()),this.dialog||this.build(),document.addEventListener(`keydown`,this.onShortcut))})}disconnectedCallback(){document.removeEventListener(`keydown`,this.onShortcut)}get items(){return this.list??[]}set items(e){this.list=[...e],this.dialog?.open&&this.paint()}readItems(){let e=[...this.querySelectorAll(`:scope > a, :scope > button`)].map((e,t)=>({id:e.dataset.value??`${t}`,label:e.textContent?.trim()??``,group:e.dataset.group,description:e.dataset.description,shortcut:e.dataset.shortcut,keywords:e.dataset.keywords?.split(/[,،]\s*/),href:e instanceof HTMLAnchorElement?e.getAttribute(`href`)??void 0:void 0}));return this.querySelectorAll(`:scope > a, :scope > button`).forEach(e=>e.remove()),e}build(){let e=document.createElement(`dialog`);e.className=`k-dialog k-command`;let t=a(),r=this.getAttribute(`label`)??t.command.title;e.setAttribute(`aria-label`,r),e.innerHTML=`<div class="k-input"><span class="k-input__addon"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" aria-hidden="true"><circle cx="9" cy="9" r="5.5"/><path d="m13.5 13.5 3 3"/></svg></span><input class="k-input__control" type="text" role="combobox" aria-expanded="true" aria-controls="${this.key}-list" aria-autocomplete="list" aria-label="${n(r)}" placeholder="${n(this.getAttribute(`placeholder`)??t.command.placeholder)}" autocomplete="off"></div><ul id="${this.key}-list" role="listbox" aria-label="${n(r)}" class="k-listbox k-listbox--inline k-command__list"></ul><div class="k-command__footer" aria-hidden="true"><span><kbd class="k-kbd">↑</kbd><kbd class="k-kbd">↓</kbd>${n(t.command.navigate)}</span><span><kbd class="k-kbd">Enter</kbd>${n(t.command.select)}</span><span><kbd class="k-kbd">Esc</kbd>${n(t.common.close)}</span></div><span class="k-sr-only" aria-live="polite"></span>`,this.append(e),this.dialog=e;let i=e.querySelector(`input`);i.addEventListener(`input`,()=>{this.query=i.value,this.active=0,this.paint()}),i.addEventListener(`keydown`,e=>{let t=this.filtered().length;if(t){if(e.key===`ArrowDown`)this.active=(this.active+1)%t;else if(e.key===`ArrowUp`)this.active=(this.active-1+t)%t;else if(e.key===`Home`)this.active=0;else if(e.key===`End`)this.active=t-1;else if(e.key===`Enter`)return this.run(this.filtered()[this.active]);else return;e.preventDefault(),this.paint()}});let o=e.querySelector(`ul`);o.addEventListener(`pointerdown`,e=>e.preventDefault()),o.addEventListener(`click`,e=>{let t=e.target.closest(`[role="option"]`);t&&this.run(this.filtered()[Number(t.dataset.i)])}),e.addEventListener(`click`,t=>t.target===e&&this.close()),e.addEventListener(`close`,()=>this.opener?.focus?.())}filtered(){let e=u(this.query.trim());return this.items.filter(t=>!e||[t.label,t.description??``,...t.keywords??[]].some(t=>u(t).includes(e)))}show(){this.dialog&&(this.opener=document.activeElement,this.query=``,this.active=0,this.dialog.querySelector(`input`).value=``,this.dialog.showModal?.(),this.paint(),this.dialog.querySelector(`input`).focus())}close(){this.dialog?.open&&this.dialog.close()}run(t){t&&(this.close(),t.href?location.href=t.href:e(this,`kashi-select`,{value:t.id,item:t}))}paint(){let e=this.dialog,t=this.filtered(),i=u(this.query.trim()),o=e=>{let t=i?u(e).indexOf(i):-1;return t<0?n(e):`${n(e.slice(0,t))}<mark>${n(e.slice(t,t+i.length))}</mark>${n(e.slice(t+i.length))}`},s;e.querySelector(`ul`).innerHTML=t.length?t.map((e,t)=>{let r=e.group&&e.group!==s?`<li role="presentation" class="k-listbox__group">${n(e.group)}</li>`:``;return s=e.group,`${r}<li id="${this.key}-list-${t}" data-i="${t}" role="option" aria-selected="${t===this.active}"${t===this.active?` data-active`:``} class="k-option"><span class="k-option__body"><span>${o(e.label)}</span>${e.description?`<span class="k-option__desc">${n(e.description)}</span>`:``}</span>${e.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${n(e.shortcut)}</span>`:``}</li>`}).join(``):`<li role="presentation" class="k-listbox__empty">${n(a().command.empty)}</li>`;let c=e.querySelector(`input`);t.length?c.setAttribute(`aria-activedescendant`,`${this.key}-list-${this.active}`):c.removeAttribute(`aria-activedescendant`),e.querySelector(`#${this.key}-list-${this.active}`)?.scrollIntoView?.({block:`nearest`}),e.querySelector(`:scope > .k-sr-only`).textContent=this.query?a().common.results(r(this,t.length)):``}};f.observedAttributes=[`placeholder`,`label`,`shortcut`];var p=class extends s{constructor(){super(...arguments),this.menu=null,this.returnTo=null,this.key=c(`kashi-ctx`),this.onOutside=e=>{this.menu?.contains(e.target)||this.close(!1)},this.onScroll=()=>this.close(!1)}connectedCallback(){o(()=>this.isConnected&&!this.menu&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}build(){let t=this.querySelector(`:scope > [data-menu]`);this.classList.add(`k-context-area`),this.setAttribute(`aria-haspopup`,`menu`),this.setAttribute(`aria-describedby`,`${this.key}-hint`);let r=document.createElement(`ul`);r.setAttribute(`role`,`menu`),r.setAttribute(`aria-label`,this.getAttribute(`label`)??a().contextMenu.label),r.className=`k-menu k-menu--context`,r.hidden=!0;for(let e of[...t?.children??[]]){let t=document.createElement(`li`);e.tagName===`HR`?(t.setAttribute(`role`,`separator`),t.className=`k-menu__separator`):e.hasAttribute(`data-label`)?(t.setAttribute(`role`,`presentation`),t.className=`k-menu__label`,t.textContent=e.textContent):(t.setAttribute(`role`,`none`),e.setAttribute(`role`,`menuitem`),e.tabIndex=-1,e.classList.add(`k-menu__item`),e.dataset.tone===`danger`&&e.classList.add(`k-menu__item--danger`),e instanceof HTMLButtonElement&&(e.type=`button`),e.innerHTML=`<span>${e.innerHTML}</span>${e.dataset.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${n(e.dataset.shortcut)}</span>`:``}`,t.append(e)),r.append(t)}t?.remove(),this.insertAdjacentHTML(`beforeend`,`<span id="${this.key}-hint" class="k-sr-only">${n(a().contextMenu.hint)}</span>`),this.append(r),this.menu=r,this.addEventListener(`contextmenu`,e=>{r.contains(e.target)||(e.preventDefault(),this.openAt(e.clientX,e.clientY))}),this.addEventListener(`keydown`,e=>{if(r.contains(e.target))return this.onMenuKey(e);if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault();let t=document.activeElement.getBoundingClientRect();this.openAt(t.left+t.width/2,t.top+t.height/2)}}),r.addEventListener(`click`,t=>{let n=t.target.closest(`[role="menuitem"]`);n&&(e(this,`kashi-select`,{value:n.dataset.value??n.textContent?.trim()??``}),this.close(n.tagName!==`A`))})}openAt(e,t){let n=this.menu;this.returnTo=document.activeElement??this,n.hidden=!1;let r=n;r.showPopover&&(n.hasAttribute(`popover`)||n.setAttribute(`popover`,`manual`),n.matches(`:popover-open`)||r.showPopover());let i=n.getBoundingClientRect(),a=getComputedStyle(this).direction===`rtl`,o=a?e-i.width:e;o<8&&(o=a?e:8),o=Math.max(8,Math.min(o,innerWidth-i.width-8));let s=Math.max(8,Math.min(t+i.height>innerHeight-8?t-i.height:t,innerHeight-i.height-8));n.style.setProperty(`--_x`,`${o}px`),n.style.setProperty(`--_y`,`${s}px`),d(n)[0]?.focus({preventScroll:!0}),document.addEventListener(`pointerdown`,this.onOutside),setTimeout(()=>addEventListener(`scroll`,this.onScroll,{passive:!0,once:!0}),150)}close(e=!0){let t=this.menu;if(!t||t.hidden)return;let n=t;t.matches?.(`:popover-open`)&&n.hidePopover?.(),t.hidden=!0,document.removeEventListener(`pointerdown`,this.onOutside),removeEventListener(`scroll`,this.onScroll),e&&this.returnTo?.focus()}onMenuKey(e){let t=d(this.menu),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)this.close();else if(e.key===`Tab`)return this.close(!1);else return;e.preventDefault()}};p.observedAttributes=[`label`];const m=e=>`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-k-mirror=""><path d="${e?`m8 5 5 5-5 5`:`m12 5-5 5 5 5`}"/></svg>`;var h=class extends s{constructor(){super(...arguments),this.track=null,this.index=0,this.io=null,this.key=c(`kashi-carousel`)}connectedCallback(){o(()=>this.isConnected&&!this.track&&this.build())}disconnectedCallback(){this.io?.disconnect()}get perView(){return Math.max(1,Number(this.getAttribute(`per-view`))||1)}get slides(){return[...this.track?.children??[]]}get pages(){return Math.max(1,this.slides.length-this.perView+1)}build(){let e=a(),t=this.getAttribute(`label`)??e.carousel.slider,i=[...this.children],o=document.createElement(`section`);o.className=`k-carousel`,o.setAttribute(`aria-roledescription`,e.carousel.slider),o.setAttribute(`aria-label`,t),o.style.setProperty(`--k-carousel-per-view`,String(this.perView));let s=document.createElement(`div`);if(s.className=`k-carousel__track`,s.tabIndex=0,s.setAttribute(`aria-live`,`polite`),i.forEach((t,n)=>{let a=document.createElement(`div`);a.className=`k-carousel__slide`,a.setAttribute(`role`,`group`),a.setAttribute(`aria-roledescription`,e.carousel.slide),a.setAttribute(`aria-label`,e.carousel.slideOf(r(this,n+1),r(this,i.length))),a.id=`${this.key}-s${n}`,a.append(t),s.append(a)}),o.append(s),this.replaceChildren(o),this.track=s,this.pages>1){let i=this.getAttribute(`dots`)!==`false`;o.insertAdjacentHTML(`beforeend`,`<div class="k-carousel__bar">${i?`<ul class="k-carousel__dots" aria-label="${n(e.carousel.slides(t))}">${Array.from({length:this.pages},(t,i)=>`<li><button type="button" class="k-carousel__dot" data-go="${i}" aria-label="${n(e.carousel.slideOf(r(this,i+1),r(this,this.pages)))}" aria-controls="${this.key}-s${i}"></button></li>`).join(``)}</ul>`:`<span></span>`}<div class="k-carousel__nav"><button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-step="-1" aria-label="${n(e.common.prev)}">${m(!1)}</button><button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-step="1" aria-label="${n(e.common.next)}">${m(!0)}</button></div></div>`),o.querySelector(`.k-carousel__bar`).addEventListener(`click`,e=>{let t=e.target.closest(`button`);t&&this.go(t.dataset.go===void 0?this.index+Number(t.dataset.step):Number(t.dataset.go))})}s.addEventListener(`keydown`,e=>{let t=getComputedStyle(s).direction===`rtl`,n={ArrowLeft:t?1:-1,ArrowRight:t?-1:1}[e.key];n?(e.preventDefault(),this.go(this.index+n)):e.key===`Home`?this.go(0):e.key===`End`&&this.go(this.pages-1)}),typeof IntersectionObserver<`u`&&(this.io=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting&&e.intersectionRatio>.6).map(e=>this.slides.indexOf(e.target));t.length&&this.setIndex(Math.min(...t))},{root:s,threshold:[.6,1]}),this.slides.forEach(e=>this.io.observe(e))),this.setIndex(0)}go(e){let t=Math.max(0,Math.min(this.pages-1,e)),n=this.slides[t],r=this.track;if(!n||!r)return;let i=getComputedStyle(r).direction===`rtl`?-(r.getBoundingClientRect().right-n.getBoundingClientRect().right)+r.scrollLeft:n.getBoundingClientRect().left-r.getBoundingClientRect().left+r.scrollLeft;r.scrollTo?.({left:i}),this.setIndex(t)}setIndex(t){let n=t!==this.index;this.index=t,this.querySelectorAll(`.k-carousel__dot`).forEach((e,n)=>e.setAttribute(`aria-current`,String(n===t)));let[r,i]=this.querySelectorAll(`[data-step]`);r&&(r.disabled=t===0),i&&(i.disabled=t>=this.pages-1),n&&e(this,`kashi-change`,{index:t})}};h.observedAttributes=[`label`,`per-view`,`dots`];var g=class extends s{constructor(){super(...arguments),this.nodes=null,this.open=/* @__PURE__ */ new Set,this.sel=null,this.focusId=null,this.built=!1}connectedCallback(){o(()=>{if(this.isConnected){if(this.nodes===null){let e=this.querySelector(`:scope > ul`);this.nodes=e?this.parse(e):[]}if(!this.built){this.sel=this.getAttribute(`selected`);for(let e of(this.getAttribute(`expanded`)??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean))this.open.add(e);this.built=!0}this.render()}})}attributeChangedCallback(e,t,n){this.built&&t!==n&&(e===`selected`&&(this.sel=n),this.render())}get items(){return this.nodes??[]}set items(e){this.nodes=e,this.built&&this.render()}get value(){return this.sel??``}parse(e){return[...e.children].filter(e=>e.tagName===`LI`).map((e,t)=>{let n=e.querySelector(`:scope > ul`),r=[...e.childNodes].filter(e=>e!==n).map(e=>e.textContent).join(``).trim(),i=e;return{id:i.dataset.id??`${r}-${t}`,label:r,meta:i.dataset.meta,disabled:i.hasAttribute(`data-disabled`),children:n?this.parse(n):void 0}})}visible(){let e=[],t=(n,r)=>{for(let i of n)e.push({node:i,parent:r}),i.children?.length&&this.open.has(i.id)&&t(i.children,i.id)};return t(this.items,null),e}render(e=!1){let t=this.visible(),r=this.focusId&&t.some(e=>e.node.id===this.focusId)?this.focusId:this.sel&&t.some(e=>e.node.id===this.sel)?this.sel:t[0]?.node.id,i=(e,t)=>e.map(e=>{let a=!!e.children?.length,o=this.open.has(e.id);return`<li role="treeitem" data-id="${n(e.id)}" class="k-tree__item" aria-level="${t}"${a?` aria-expanded="${o}"`:``} aria-selected="${this.sel===e.id}"${e.disabled?` aria-disabled="true"`:``} tabindex="${r===e.id?0:-1}"><div class="k-tree__row">${a?`<span class="k-tree__toggle" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m8 5 5 5-5 5"/></svg></span>`:`<span class="k-tree__spacer"></span>`}<span class="k-tree__label">${n(e.label)}</span>${e.meta?`<span class="k-tree__meta">${n(e.meta)}</span>`:``}</div>${a&&o?`<ul role="group">${i(e.children,t+1)}</ul>`:``}</li>`}).join(``);this.innerHTML=`<ul role="tree" class="k-tree"${this.getAttribute(`label`)?` aria-label="${n(this.getAttribute(`label`))}"`:``}>${i(this.items,1)}</ul>`;let a=this.querySelector(`ul`);a.addEventListener(`click`,e=>{let t=e.target.closest(`[role="treeitem"]`);if(!t||!e.target.closest(`.k-tree__row`))return;let n=this.find(t.dataset.id);n&&(n.children?.length&&this.toggle(n.id),this.focusId=n.id,this.choose(n))}),a.addEventListener(`keydown`,e=>this.onKey(e)),e&&r&&[...this.querySelectorAll(`[data-id]`)].find(e=>e.dataset.id===r)?.focus()}find(e,t=this.items){for(let n of t){if(n.id===e)return n;let t=n.children&&this.find(e,n.children);if(t)return t}return null}toggle(t,n=!this.open.has(t)){n?this.open.add(t):this.open.delete(t),e(this,`kashi-expand`,{expanded:[...this.open]})}choose(t){t.disabled||(this.sel=t.id,e(this,`kashi-change`,{value:t.id,node:t})),this.render(!0)}onKey(e){let t=this.visible(),n=document.activeElement?.dataset?.id,r=t.findIndex(e=>e.node.id===n),i=t[r];if(!i)return;let a=getComputedStyle(this).direction===`rtl`,o=!!i.node.children?.length,s=this.open.has(i.node.id),c=e=>{this.focusId=e,this.render(!0)};if(e.key===`ArrowDown`)t[r+1]&&c(t[r+1].node.id);else if(e.key===`ArrowUp`)t[r-1]&&c(t[r-1].node.id);else if(e.key===`Home`)c(t[0].node.id);else if(e.key===`End`)c(t[t.length-1].node.id);else if(e.key===(a?`ArrowLeft`:`ArrowRight`))o&&!s?(this.toggle(i.node.id,!0),c(i.node.id)):o&&c(i.node.children[0].id);else if(e.key===(a?`ArrowRight`:`ArrowLeft`))o&&s?(this.toggle(i.node.id,!1),c(i.node.id)):i.parent&&c(i.parent);else if(e.key===`Enter`||e.key===` `)this.focusId=i.node.id,this.choose(i.node);else return;e.preventDefault()}};g.observedAttributes=[`label`,`selected`,`expanded`];var _=class extends s{constructor(){super(...arguments),this.list=null,this.i=0,this.spot=null,this.card=null,this.returnTo=null,this.key=c(`kashi-tour`),this.place=()=>{let e=this.card;if(!e)return;let t=document.querySelector(this.steps[this.i].target)?.getBoundingClientRect()??null;t?(this.spot||(this.spot=document.createElement(`div`),this.spot.className=`k-tour__spot`,this.spot.setAttribute(`aria-hidden`,`true`),document.body.append(this.spot)),Object.assign(this.spot.style,{top:`${t.top-6}px`,left:`${t.left-6}px`,inlineSize:`${t.width+12}px`,blockSize:`${t.height+12}px`})):(this.spot?.remove(),this.spot=null);let n=e.getBoundingClientRect();if(!t){Object.assign(e.style,{top:`${innerHeight/2-n.height/2}px`,left:`${innerWidth/2-n.width/2}px`});return}let r=t.bottom+12+n.height<innerHeight?t.bottom+12:Math.max(12,t.top-12-n.height),i=Math.min(innerWidth-n.width-12,Math.max(12,t.left+t.width/2-n.width/2));Object.assign(e.style,{top:`${r}px`,left:`${i}px`})}}connectedCallback(){o(()=>{this.isConnected&&this.list===null&&(this.list=[...this.querySelectorAll(`:scope > [data-target]`)].map(e=>({target:e.dataset.target,title:e.dataset.title??``,content:e.textContent?.trim()??``})),this.replaceChildren())})}disconnectedCallback(){this.stop(!1)}get steps(){return this.list??[]}set steps(e){this.list=[...e]}start(){this.steps.length&&(this.returnTo=document.activeElement,this.i=0,addEventListener(`scroll`,this.place,{passive:!0}),addEventListener(`resize`,this.place),this.show())}stop(e=!0){this.spot?.remove(),this.card?.remove(),this.spot=this.card=null,removeEventListener(`scroll`,this.place),removeEventListener(`resize`,this.place),e&&this.returnTo?.focus?.()}show(){let t=this.steps[this.i],i=this.steps.length,o=this.i===i-1;this.card||(this.card=document.createElement(`div`),this.card.className=`k-tour__card`,this.card.setAttribute(`role`,`dialog`),this.card.setAttribute(`aria-modal`,`false`),this.card.setAttribute(`aria-labelledby`,`${this.key}-t`),this.card.setAttribute(`aria-describedby`,`${this.key}-b`),this.card.tabIndex=-1,this.card.addEventListener(`click`,t=>{let n=t.target.closest(`[data-act]`);if(!n)return;let r=n.dataset.act;r===`skip`?this.stop():r===`prev`?this.step(-1):r===`next`?this.step(1):r===`done`&&(this.stop(),e(this,`kashi-finish`,{}))}),this.card.addEventListener(`keydown`,e=>{let t=getComputedStyle(this.card).direction===`rtl`;e.key===`Escape`?this.stop():e.key===(t?`ArrowLeft`:`ArrowRight`)&&this.i<this.steps.length-1?this.step(1):e.key===(t?`ArrowRight`:`ArrowLeft`)&&this.i>0&&this.step(-1)}),document.body.append(this.card)),this.card.innerHTML=`<span class="k-tour__step">${n(a().tour.step(r(this,this.i+1),r(this,i)))}</span><p class="k-tour__title" id="${this.key}-t">${n(t.title)}</p><p class="k-tour__body" id="${this.key}-b">${n(t.content)}</p><div class="k-tour__actions"><button type="button" class="k-btn k-btn--link k-tour__skip" data-act="skip">${n(a().tour.skip)}</button><span class="k-tour__progress" aria-hidden="true">${this.steps.map((e,t)=>`<span${t<=this.i?` data-on=""`:``}></span>`).join(``)}</span>${this.i>0?'<button type="button" class="k-btn k-btn--secondary k-btn--sm" data-act="prev">${esc(msg().common.prev)}</button>':``}<button type="button" class="k-btn k-btn--primary k-btn--sm" data-act="${o?`done`:`next`}">${n(o?a().tour.done:a().common.next)}</button></div>`;let s=document.querySelector(t.target),c=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;s?.scrollIntoView?.({block:`center`,behavior:c?`auto`:`smooth`}),this.place(),setTimeout(this.place,400),this.card.focus({preventScroll:!0})}step(e){this.i=Math.max(0,Math.min(this.steps.length-1,this.i+e)),this.show()}},v=class extends s{constructor(){super(...arguments),this.current=40,this.built=!1,this.dragging=!1}connectedCallback(){o(()=>{this.isConnected&&!this.built&&(this.current=this.num(`size`,40),this.build())})}attributeChangedCallback(e,t,n){this.built&&t!==n&&(e===`size`?this.set(Number(n)||40,!1):this.decorate())}get value(){return this.current}set value(e){this.set(e,!1)}num(e,t){let n=Number(this.getAttribute(e));return Number.isFinite(n)&&this.getAttribute(e)!==null?n:t}get vertical(){return this.getAttribute(`orientation`)===`vertical`}build(){let[e,t]=[...this.children],n=document.createElement(`div`),r=document.createElement(`div`);r.className=`k-splitter__pane`,e&&r.append(e);let i=document.createElement(`div`);i.className=`k-splitter__handle`,i.setAttribute(`role`,`separator`),i.tabIndex=0;let a=document.createElement(`div`);a.className=`k-splitter__pane`,t&&a.append(t),n.append(r,i,a),this.replaceChildren(n),this.built=!0,i.addEventListener(`pointerdown`,e=>{i.setPointerCapture?.(e.pointerId),this.dragging=!0,n.toggleAttribute(`data-dragging`,!0),i.toggleAttribute(`data-dragging`,!0)}),i.addEventListener(`pointermove`,e=>{if(!this.dragging)return;let t=n.getBoundingClientRect();if(this.vertical)return this.set((e.clientY-t.top)/t.height*100);let r=getComputedStyle(n).direction===`rtl`;this.set((r?t.right-e.clientX:e.clientX-t.left)/t.width*100)});let o=()=>{this.dragging=!1,n.removeAttribute(`data-dragging`),i.removeAttribute(`data-dragging`)};i.addEventListener(`pointerup`,o),i.addEventListener(`pointercancel`,o),i.addEventListener(`dblclick`,()=>this.set(this.num(`size`,40))),i.addEventListener(`keydown`,e=>{let t=getComputedStyle(i).direction===`rtl`,n=this.vertical?{ArrowUp:-5,ArrowDown:5}:{ArrowLeft:t?5:-5,ArrowRight:t?-5:5};if(e.key in n)this.set(this.current+n[e.key]);else if(e.key===`Home`)this.set(this.num(`min`,15));else if(e.key===`End`)this.set(this.num(`max`,85));else return;e.preventDefault()}),this.decorate()}decorate(){let e=this.firstElementChild;e.className=`k-splitter${this.vertical?` k-splitter--vertical`:``}`;let t=this.getAttribute(`height`);e.style.blockSize=t??``;let n=e.querySelector(`.k-splitter__handle`);n.setAttribute(`aria-orientation`,this.vertical?`horizontal`:`vertical`),n.setAttribute(`aria-valuemin`,String(this.num(`min`,15))),n.setAttribute(`aria-valuemax`,String(this.num(`max`,85))),n.setAttribute(`aria-label`,this.getAttribute(`label`)??a().splitter.label),this.paint()}set(t,n=!0){let r=Math.round(Math.min(this.num(`max`,85),Math.max(this.num(`min`,15),t))*10)/10,i=r!==this.current;this.current=r,this.built&&this.paint(),n&&i&&e(this,`kashi-change`,{value:r})}paint(){let e=this.firstElementChild,t=e.querySelector(`.k-splitter__pane`);t.style.inlineSize=this.vertical?``:`${this.current}%`,t.style.blockSize=this.vertical?`${this.current}%`:``;let n=e.querySelector(`.k-splitter__handle`);n.setAttribute(`aria-valuenow`,String(this.current)),n.setAttribute(`aria-valuetext`,a().common.percent(r(this,Math.round(this.current))))}};v.observedAttributes=[`size`,`min`,`max`,`orientation`,`label`,`height`];var y=class extends s{constructor(){super(...arguments),this.built=!1}connectedCallback(){o(()=>{this.isConnected&&!this.built&&(this.built=!0,this.addEventListener(`click`,t=>{let n=t.target.closest(`button[aria-controls][aria-expanded]`);if(!n||!this.contains(n))return;let r=document.getElementById(n.getAttribute(`aria-controls`)),i=n.getAttribute(`aria-expanded`)!==`true`;n.setAttribute(`aria-expanded`,String(i)),r&&(r.hidden=!i),e(this,`kashi-toggle`,{id:r?.id??``,open:i})}),this.decorate())})}attributeChangedCallback(){this.built&&this.decorate()}decorate(){let e=this.querySelector(`.k-sidenav`),n=t(this,`collapsed`);e?.classList.toggle(`k-sidenav--collapsed`,n),this.querySelectorAll(`.k-sidenav__item`).forEach(e=>{let t=e.querySelector(`.k-sidenav__text`)?.textContent?.trim();t&&(n?(e.setAttribute(`aria-label`,t),e.setAttribute(`title`,t)):(e.removeAttribute(`aria-label`),e.removeAttribute(`title`)))})}};y.observedAttributes=[`collapsed`],typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target,n=t?.closest?.(`[data-kashi-tour]`),r=n?document.getElementById(n.getAttribute(`data-kashi-tour`)):null;r?.start&&r.start();let i=t?.closest?.(`[data-kashi-command]`),a=i?document.getElementById(i.getAttribute(`data-kashi-command`)):null;a?.show&&a.show()}),i(`kashi-command-palette`,f,`contents`),i(`kashi-context-menu`,p,`block`),i(`kashi-carousel`,h,`block`),i(`kashi-tree-view`,g,`block`),i(`kashi-tour`,_,`contents`),i(`kashi-splitter`,v,`block`),i(`kashi-side-nav`,y,`block`);export{h as KashiCarousel,f as KashiCommandPalette,p as KashiContextMenu,y as KashiSideNav,v as KashiSplitter,_ as KashiTour,g as KashiTreeView};
@@ -0,0 +1 @@
1
+ import{c as e,i as t,l as n,n as r,o as i,p as a,r as o,t as s,v as c}from"./base-DTQ50VdG.js";var l=class extends s{constructor(){super(...arguments),this.dialog=null,this.opener=null,this.key=c(`kashi-dialog`)}connectedCallback(){o(()=>{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 n=[...this.children].filter(e=>e.getAttribute(`slot`)===`footer`),i=[...this.childNodes].filter(e=>!n.includes(e)),a=document.createElement(`dialog`);if(a.setAttribute(`aria-labelledby`,`${this.key}-title`),a.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">${r.close}</button></div>`,i.some(e=>e.nodeType===1||e.textContent?.trim())){let e=document.createElement(`div`);e.className=`k-dialog__body`,e.append(...i),a.append(e)}if(n.length){let e=document.createElement(`div`);e.className=`k-dialog__footer`;for(let t of n)t.removeAttribute(`slot`),e.append(t);a.append(e)}this.replaceChildren(a),this.dialog=a,a.querySelector(`.k-dialog__close`).addEventListener(`click`,()=>this.close()),a.addEventListener(`click`,e=>{e.target===a&&t(this,`dismissible`,!0)&&this.close();let n=e.target.closest(`[data-kashi-close]`);n&&a.contains(n)&&this.close(n.getAttribute(`data-kashi-close`)||void 0)}),a.addEventListener(`close`,()=>{this.removeAttribute(`open`),this.opener?.focus?.(),e(this,`kashi-close`,{returnValue:a.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`)??a().common.close)}sync(){let t=this.dialog;t&&this.isConnected&&(this.open&&!t.open?(this.opener=document.activeElement,t.showModal?.(),e(this,`kashi-open`,{})):!this.open&&t.open&&t.close())}};l.observedAttributes=[`open`,`heading`,`description`,`tone`,`size`,`placement`,`close-label`];var u=class extends s{constructor(){super(...arguments),this.list=null,this.key=c(`kashi-tabs`),this.ro=null}connectedCallback(){o(()=>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`,n=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}`),t(this,`block`)&&this.classList.add(`k-tabs--block`),n&&this.classList.add(`k-tabs--vertical`),this.getAttribute(`size`)===`sm`&&this.classList.add(`k-tabs--sm`),this.dataset.orientation=n?`vertical`:`horizontal`,this.list.setAttribute(`aria-orientation`,n?`vertical`:`horizontal`);let r=this.getAttribute(`label`);r&&this.list.setAttribute(`aria-label`,r),this.measure()}select(t,n){let r=[...this.list.querySelectorAll(`[role="tab"]`)];r.some(e=>e.dataset.value===t)||(t=r[0]?.dataset.value??``);for(let e of r){let n=e.dataset.value===t;e.setAttribute(`aria-selected`,String(n)),e.tabIndex=n?0:-1}for(let e of this.panels)e.hidden=e.dataset.value!==t;this.getAttribute(`value`)!==t&&this.setAttribute(`value`,t),this.measure(),n&&e(this,`kashi-change`,{value:t})}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)}};u.observedAttributes=[`value`,`variant`,`block`,`orientation`,`size`,`label`];var d=class extends s{constructor(){super(...arguments),this.tip=null,this.key=c(`kashi-tip`),this.onKey=e=>{e.key===`Escape`&&(clearTimeout(this.timer),this.tip.hidden=!0)}}connectedCallback(){o(()=>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,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),document.removeEventListener(`keydown`,this.onKey)}attributeChangedCallback(){this.tip&&this.decorate()}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.tip.hidden=!1,document.addEventListener(`keydown`,this.onKey)},e)}hide(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tip.hidden=!0,document.removeEventListener(`keydown`,this.onKey)},100)}};d.observedAttributes=[`content`,`placement`];var f=class extends s{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`,e(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`)??a().copy.copy,i=this.getAttribute(`copied-label`)??a().copy.copied,o=this.state===`copied`?i:this.state===`failed`?a().copy.failed:e,s=t(this,`icon-only`),c=this.state===`copied`?r.check:r.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--${n(l)}${u===`md`?``:` k-btn--${n(u)}`}${s?` k-btn--icon`:``}" data-variant="${n(l)}" data-size="${n(u)}"${s?` aria-label="${n(o)}"`:``}${this.state===`copied`?` data-copied=""`:``}>${c}${s?``:n(o)}</button><span class="k-sr-only" aria-live="polite">${this.state===`idle`?``:n(o)}</span>`,d&&this.querySelector(`button`).focus()}};f.observedAttributes=[`value`,`target`,`label`,`copied-label`,`icon-only`,`variant`,`size`],i(`kashi-dialog`,l,`contents`),i(`kashi-tabs`,u,`block`),i(`kashi-tooltip`,d),i(`kashi-copy-button`,f),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{f as KashiCopyButton,l as KashiDialog,u as KashiTabs,d as KashiTooltip};
@@ -0,0 +1 @@
1
+ import{A as e,C as t,E as n,T as r,a as i,b as a,c as o,d as s,f as c,g as l,i as u,l as d,m as f,n as p,o as m,p as h,s as g,t as _,u as v,v as y,w as b,y as x}from"./base-DTQ50VdG.js";import"./calendar-CYRrdGIf.js";const S=e=>e?a(e.trim())??t(e):null,C=(e,t=0)=>new Date(e.getFullYear(),e.getMonth(),e.getDate()+t),w=(e,t)=>!e&&!t||!!e&&!!t&&e.getTime()===t.getTime(),T=[[(e,t)=>e.last7(t(7)),e=>({start:C(e,-6),end:e})],[(e,t)=>e.last30(t(30)),e=>({start:C(e,-29),end:e})],[e=>e.thisMonth,e=>{let{jy:t,jm:r}=n(e);return{start:b(t,r,1),end:e}}],[e=>e.lastMonth,e=>{let{jy:t,jm:r}=n(e),[i,a]=r===1?[t-1,12]:[t,r-1];return{start:b(i,a,1),end:C(b(t,r,1),-1)}}]];var E=class extends _{constructor(){super(...arguments),this.current={start:null,end:null},this.draft={start:null,end:null},this.valueSet=!1,this.rendered=!1,this.key=y(`kashi-range`),this.pop=null,this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){!this.rendered&&!this.valueSet&&(this.current={start:S(this.getAttribute(`start`)),end:S(this.getAttribute(`end`))}),this.render()}disconnectedCallback(){this.close(!1)}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&((e===`start`||e===`end`)&&(this.current={...this.current,[e]:S(n)}),this.render())}get value(){return{...this.current}}set value(e){this.valueSet=!0,this.current={start:e?.start??null,end:e?.end??null},this.rendered&&this.render()}fmt(e){return x(e,{digits:g(this),locale:s()})}text(e){return e.start&&e.end?`${this.fmt(e.start)}${h().common.range}${this.fmt(e.end)}`:null}render(){this.close(!1);let e=this.key,t=this.getAttribute(`label`)??h().dateRange.label,n=this.text(this.current),i=`<div class="k-datepicker k-daterange"><div class="k-select"><button id="${e}" type="button" class="k-select__control k-daterange__trigger" aria-haspopup="dialog" aria-expanded="false"${n?``:` data-placeholder=""`}${this.hasAttribute(`disabled`)?` disabled`:``}>${p.calendar}<span>${d(n??this.getAttribute(`placeholder`)??h().dateRange.placeholder)}</span></button></div></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,v({id:e,label:t,control:i})),this.trigger=this.querySelector(`.k-daterange__trigger`),this.trigger.addEventListener(`click`,()=>this.pop?this.close():this.open()),this.rendered=!0,l(this.querySelector(`:scope > .k-field`),this.trigger,e,this.getAttribute(`error`),this.getAttribute(`hint`));let a=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),a)for(let[e,t]of[[`start`,this.current.start],[`end`,this.current.end]])this.insertAdjacentHTML(`beforeend`,`<input type="hidden" name="${d(`${a}_${e}`)}" value="${t?r(t):``}">`)}open(){if(this.pop||this.hasAttribute(`disabled`))return;this.draft={...this.current};let e=this.querySelector(`.k-daterange`),t=document.createElement(`div`);t.id=`${this.key}-popover`,t.className=`k-datepicker__popover k-daterange__popover`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-label`,this.getAttribute(`label`)??h().dateRange.placeholder);let n=this.getAttribute(`presets`)===`false`?[]:T;t.innerHTML=`${n.length?`<ul class="k-daterange__presets" role="list" aria-label="${d(h().dateRange.presets)}">${n.map(([e],t)=>`<li><button type="button" class="k-daterange__preset" data-preset="${t}" aria-pressed="false">${d(e(h().dateRange,e=>f(this,e)))}</button></li>`).join(``)}</ul>`:``}<div class="k-daterange__main"><div class="k-daterange__footer"><span class="k-daterange__summary" aria-live="polite"></span><button type="button" class="k-btn k-btn--secondary k-btn--sm" data-cancel>${d(h().common.cancel)}</button><button type="button" class="k-btn k-btn--primary k-btn--sm" data-apply>${d(h().common.confirm)}</button></div></div>`;let i=document.createElement(`kashi-calendar`);for(let e of[`min`,`max`,`digits`,`holidays`]){let t=this.getAttribute(e);t!==null&&i.setAttribute(e,t)}i.range=this.draft,t.querySelector(`.k-daterange__main`).prepend(i),i.addEventListener(`kashi-change`,e=>{e.stopPropagation();let t=e.detail.date,n=this.draft;this.draft=!n.start||n.end?{start:t,end:null}:t<n.start?{start:t,end:n.start}:{start:n.start,end:t},i.range=this.draft,this.paintDraft()}),t.addEventListener(`click`,e=>{let t=e.target,a=t.closest(`[data-preset]`);if(a)this.draft=n[Number(a.dataset.preset)][1](C(/* @__PURE__ */ new Date)),i.range=this.draft,this.paintDraft();else if(t.closest(`[data-cancel]`))this.close();else if(t.closest(`[data-apply]`)&&this.draft.start&&this.draft.end){let e=!w(this.draft.start,this.current.start)||!w(this.draft.end,this.current.end);this.current={...this.draft},this.close(),this.render(),this.trigger.focus(),e&&o(this,`kashi-change`,{start:this.current.start,end:this.current.end,value:{start:r(this.current.start),end:r(this.current.end)}})}}),t.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.close())}),e.append(t),this.pop=t,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,t.id),document.addEventListener(`pointerdown`,this.onOutside),this.paintDraft(),i.focus()}paintDraft(){let e=this.pop,t=this.draft;e.querySelector(`.k-daterange__summary`).textContent=this.text(t)??(t.start?h().dateRange.pickEnd:``),e.querySelector(`[data-apply]`).disabled=!t.start||!t.end;let n=C(/* @__PURE__ */ new Date);e.querySelectorAll(`[data-preset]`).forEach((e,r)=>{let i=T[r][1](n);e.setAttribute(`aria-pressed`,String(w(t.start,i.start)&&w(t.end,i.end)))})}close(e=!0){this.pop&&(this.pop.remove(),this.pop=null,document.removeEventListener(`pointerdown`,this.onOutside),this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),e&&this.trigger.focus())}};E.observedAttributes=[`label`,`hint`,`error`,`start`,`end`,`min`,`max`,`holidays`,`digits`,`name`,`disabled`,`presets`,`placeholder`];const D=e=>`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-k-mirror=""><path d="${e?`m8 5 5 5-5 5`:`m12 5-5 5 5 5`}"/></svg>`;var O=class extends _{constructor(){super(...arguments),this.selected=null,this.year=n(/* @__PURE__ */ new Date).jy,this.focusMonth=1,this.valueSet=!1,this.rendered=!1}connectedCallback(){if(!this.rendered){this.valueSet||(this.selected=this.parse(this.getAttribute(`value`)));let e=n(/* @__PURE__ */ new Date);this.year=this.selected?.year??e.jy,this.focusMonth=this.selected?.month??(this.year===e.jy?e.jm:1)}this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n??``:this.render())}parse(e){let t=(e??``).trim().match(/^(\d{4})[-/](\d{1,2})$/);return t?{year:Number(t[1]),month:Number(t[2])}:null}get value(){return this.selected?`${this.selected.year}-${String(this.selected.month).padStart(2,`0`)}`:``}set value(e){this.valueSet=!0,this.selected=this.parse(e),this.selected&&([this.year,this.focusMonth]=[this.selected.year,this.selected.month]),this.rendered&&this.render()}out(e,t){let n=e*12+t,r=this.parse(this.getAttribute(`min`)),i=this.parse(this.getAttribute(`max`));return!!r&&n<r.year*12+r.month||!!i&&n>i.year*12+i.month}render(t=!1){let r=t=>g(this)===`latin`?String(t):e(String(t)),a=n(/* @__PURE__ */ new Date),s=this.parse(this.getAttribute(`min`)),c=this.parse(this.getAttribute(`max`)),l=this.year;this.innerHTML=`<div class="k-monthpicker" role="group" aria-label="${d(this.getAttribute(`label`)??h().monthPicker.label)}"><div class="k-monthpicker__header"><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm" data-year="-1" aria-label="${d(h().monthPicker.prevYear)}"${s&&l<=s.year?` disabled`:``}>${D(!1)}</button><span class="k-monthpicker__year" aria-live="polite">${r(l)}</span><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm" data-year="1" aria-label="${d(h().monthPicker.nextYear)}"${c&&l>=c.year?` disabled`:``}>${D(!0)}</button></div><div class="k-monthpicker__grid">${i().months.map((e,t)=>`<button type="button" data-month="${t+1}" class="k-monthpicker__month" tabindex="${this.focusMonth===t+1?0:-1}" aria-pressed="${this.selected?.year===l&&this.selected.month===t+1}" aria-label="${e} ${r(l)}"${a.jy===l&&a.jm===t+1?` aria-current="date"`:``}${this.out(l,t+1)?` disabled`:``}>${e}</button>`).join(``)}</div></div>`;let u=this.getAttribute(`name`);u&&this.insertAdjacentHTML(`beforeend`,`<input type="hidden" name="${d(u)}" value="${this.value}">`),this.rendered=!0,this.querySelectorAll(`[data-year]`).forEach(e=>e.addEventListener(`click`,()=>{this.year+=Number(e.dataset.year),this.render()}));let f=this.querySelector(`.k-monthpicker__grid`);f.addEventListener(`click`,e=>{let t=e.target.closest(`[data-month]`);t&&!t.disabled&&(this.selected={year:this.year,month:Number(t.dataset.month)},this.focusMonth=this.selected.month,this.render(!0),o(this,`kashi-change`,{value:this.value,year:this.selected.year,month:this.selected.month}))}),f.addEventListener(`keydown`,e=>{let t=getComputedStyle(f).direction===`rtl`,n={ArrowRight:t?-1:1,ArrowLeft:t?1:-1,ArrowDown:3,ArrowUp:-3,PageUp:-12,PageDown:12},r=this.year*12+this.focusMonth-1;if(e.key in n)r+=n[e.key];else if(e.key===`Home`)r=this.year*12;else if(e.key===`End`)r=this.year*12+11;else return;e.preventDefault(),this.year=Math.floor(r/12),this.focusMonth=r%12+1,this.render(!0)}),t&&this.querySelector(`[data-month="${this.focusMonth}"]`)?.focus()}};O.observedAttributes=[`value`,`min`,`max`,`digits`,`label`,`name`];function k(t){let n=h().fileUpload.units,r=t,i=0;for(;r>=1024&&i<n.length-1;)r/=1024,i++;let a=i===0?String(r):r.toFixed(+(r<10)).replace(/\.0$/,``);return`${c()===`fa`?e(a).replace(`.`,`٫`):a} ${n[i]}`}var A=class extends _{constructor(){super(...arguments),this.items=[],this.rendered=!1,this.key=y(`kashi-upload`)}connectedCallback(){this.rendered||this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&this.render()}get files(){return this.items.filter(e=>e.status!==`error`).map(e=>e.file)}get multiple(){return u(this,`multiple`,!0)}render(){let e=this.key,t=this.getAttribute(`hint`),n=this.hasAttribute(`disabled`),r=this.getAttribute(`name`),i=this.getAttribute(`accept`);this.innerHTML=`<div class="k-dropzone"${n?` data-disabled=""`:``}><span class="k-dropzone__icon" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13V3.5m-4 4 4-4 4 4M4 13v2.5A1.5 1.5 0 0 0 5.5 17h9a1.5 1.5 0 0 0 1.5-1.5V13"/></svg></span><p class="k-dropzone__title" style="margin: 0"><button type="button" class="k-dropzone__browse"${n?` disabled`:``}${t?` aria-describedby="${e}-hint"`:``}>${d(this.getAttribute(`label`)??h().fileUpload.browse)}</button> <span>${d(h().fileUpload.drop)}</span></p>${t?`<p class="k-dropzone__hint" id="${e}-hint" style="margin: 0">${d(t)}</p>`:``}<input type="file" tabindex="-1" aria-hidden="true"${i?` accept="${d(i)}"`:``}${this.multiple?` multiple`:``}${r?` name="${d(r)}"`:``}></div><ul class="k-file-list" role="list" hidden></ul><span class="k-sr-only" aria-live="polite"></span>`,this.rendered=!0,this.input=this.querySelector(`input[type=file]`);let a=this.querySelector(`.k-dropzone`);this.querySelector(`.k-dropzone__browse`).addEventListener(`click`,()=>this.input.click()),this.input.addEventListener(`change`,()=>{this.input.files?.length&&this.add([...this.input.files])}),a.addEventListener(`dragover`,e=>{e.preventDefault(),n||a.setAttribute(`data-dragging`,``)}),a.addEventListener(`dragleave`,e=>{a.contains(e.relatedTarget)||a.removeAttribute(`data-dragging`)}),a.addEventListener(`drop`,e=>{e.preventDefault(),a.removeAttribute(`data-dragging`),!n&&e.dataTransfer?.files.length&&this.add([...e.dataTransfer.files])}),this.querySelector(`.k-file-list`).addEventListener(`click`,e=>{let t=e.target.closest(`[data-remove]`);if(!t)return;let n=this.items.find(e=>e.id===t.dataset.remove);this.items=this.items.filter(e=>e.id!==t.dataset.remove),this.announce(h().common.removed(n?.file.name??``)),this.changed()}),this.paint()}accepts(e){let t=this.getAttribute(`accept`);return!t||t.split(`,`).map(e=>e.trim().toLowerCase()).some(t=>t.startsWith(`.`)?e.name.toLowerCase().endsWith(t):t.endsWith(`/*`)?e.type.startsWith(t.slice(0,-1)):e.type===t)}add(e){let t=this.multiple?e:e.slice(0,1),n=Number(this.getAttribute(`max-size`))||0,r=Number(this.getAttribute(`max-files`))||0,i=this.multiple?this.items.filter(e=>e.status!==`error`).length:0,a=t.map((e,t)=>{let a;this.accepts(e)?n&&e.size>n?a=h().fileUpload.tooBig(k(n)):r&&i+t>=r&&(a=h().fileUpload.tooMany(f(this,r))):a=h().fileUpload.wrongType;let o=!a&&!!this.uploader;return{id:y(`f`),file:e,status:a?`error`:o?`uploading`:`done`,progress:a||o?0:100,error:a}});this.items=this.multiple?[...this.items,...a]:a,this.announce(a.map(e=>`${e.file.name}: ${e.error??(this.uploader?h().fileUpload.uploading:h().fileUpload.done)}`).join(h().common.list)),this.changed();for(let e of a)e.status===`uploading`&&this.uploader&&this.uploader(e.file,t=>{e.progress=t,this.paint()}).then(()=>{e.status=`done`,e.progress=100,this.announce(`${e.file.name}: ${h().fileUpload.done}`),this.changed()},t=>{e.status=`error`,e.error=t instanceof Error?t.message:h().fileUpload.error,this.announce(`${e.file.name}: ${e.error}`),this.changed()})}announce(e){this.querySelector(`:scope > .k-sr-only`).textContent=e}changed(){try{let e=new DataTransfer;for(let t of this.files)e.items.add(t);this.input.files=e.files}catch{}this.paint(),o(this,`kashi-change`,{files:this.files})}paint(){let e=this.querySelector(`.k-file-list`);e.hidden=!this.items.length;let t=e=>(e.split(`.`).pop()??``).slice(0,4).toUpperCase();e.innerHTML=this.items.map(e=>`<li class="k-file" data-status="${e.status}"><span class="k-file__icon" aria-hidden="true">${d(t(e.file.name))}</span><span class="k-file__name" title="${d(e.file.name)}">${d(e.file.name)}</span><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-file__remove" data-remove="${e.id}" aria-label="${d(h().common.remove(e.file.name))}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3.5 5.5h13M8 5.5V4h4v1.5M5 5.5l.8 10.2a1.5 1.5 0 0 0 1.5 1.3h5.4a1.5 1.5 0 0 0 1.5-1.3L15 5.5"/></svg></button><span class="k-file__meta">${d(e.error??`${k(e.file.size)}${e.status===`uploading`?` · ${h().common.percent(f(this,Math.round(e.progress)))}`:e.status===`done`?` · ${h().fileUpload.done}`:``}`)}</span>${e.status===`uploading`?`<div role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${Math.round(e.progress)}" aria-label="${d(h().fileUpload.uploadingFile(e.file.name))}" class="k-progress k-progress--sm"><div class="k-progress__bar" style="--k-value: ${e.progress}%"></div></div>`:``}</li>`).join(``)}};A.observedAttributes=[`accept`,`multiple`,`max-size`,`max-files`,`hint`,`name`,`disabled`,`label`];const j=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i,M=e=>{let t=e.trim().match(j);return t?`#${(t[1].length===3?[...t[1]].map(e=>e+e).join(``):t[1]).toLowerCase()}`:null},N=e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)),P=(e,t,n)=>`#${[e,t,n].map(e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,`0`)).join(``)}`,F=e=>{let[t,n,r]=N(e).map(e=>e/255).map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return .2126*t+.7152*n+.0722*r},I=(e,t)=>{let[n,r]=[F(M(e)??e),F(M(t)??t)].sort((e,t)=>t-e);return(n+.05)/(r+.05)};function L(e){let[t,n,r]=N(e).map(e=>e/255),i=Math.max(t,n,r),a=i-Math.min(t,n,r),o=0;return a&&(o=i===t?(n-r)/a%6:i===n?(r-t)/a+2:(t-n)/a+4),{h:(o*60+360)%360,s:i?a/i:0,v:i}}function R({h:e,s:t,v:n}){let r=r=>{let i=(r+e/60)%6;return(n-n*t*Math.max(0,Math.min(i,4-i,1)))*255};return P(r(5),r(3),r(1))}const z=[[`firoozeh`,`#0b8077`],[`lajvard`,`#2740ed`],[`violet`,`#7c3aed`],[`anar`,`#e51d2a`],[`zafaran`,`#dd5e02`],[`peste`,`#518b25`],[`shab`,`#2a2f3d`]],B=()=>z.map(([e,t])=>[h().colorPicker.names[e],t]);var V=class extends _{constructor(){super(...arguments),this.current=`#0b8077`,this.hsv=L(`#0b8077`),this.valueSet=!1,this.rendered=!1,this.key=y(`kashi-color`),this.panel=null,this.onOutside=e=>{this.querySelector(`.k-color__anchor`)?.contains(e.target)||this.closePanel(!1)}}connectedCallback(){!this.rendered&&!this.valueSet&&this.setColor(M(this.getAttribute(`value`)??``)??`#0b8077`,!1),this.render()}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n??``:this.render())}get value(){return this.current}set value(e){this.valueSet=!0;let t=M(e??``);t&&this.setColor(t,!1),this.rendered&&this.paint()}setColor(e,t){if(this.current=e,!t){let t=L(e);this.hsv=t.s===0?{...t,h:this.hsv.h}:t}}swatches(){let e=this.getAttribute(`swatches`);return e===null?B():e.split(`,`).map(e=>e.trim().split(/\s+/)).filter(([e])=>M(e)).map(([e,...t])=>[t.join(` `)||e,M(e)])}render(){let e=this.key,t=this.swatches(),n=`<div class="k-color">${t.length?`<div class="k-color__swatches" role="radiogroup" aria-label="${d(h().colorPicker.swatches)}">${t.map(([t,n])=>`<label class="k-color__swatch" style="--_sw: ${n}; --_ink: ${I(n,`#ffffff`)>=3?`#fff`:`#000`}" title="${d(t)}"><input type="radio" class="k-sr-only" name="${e}-sw" value="${n}" aria-label="${d(t)}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 10.5 3.2 3L15 7"/></svg></label>`).join(``)}</div>`:``}<div class="k-color__row"><span class="k-color__anchor"><button type="button" class="k-color__preview" aria-label="${d(h().colorPicker.custom)}" aria-haspopup="dialog" aria-expanded="false"></button></span><div class="k-input"><input id="${e}-hex" class="k-input__control" dir="ltr" spellcheck="false" autocomplete="off"></div></div>${this.getAttribute(`show-contrast`)===`false`?``:'<p class="k-color__contrast" aria-live="polite"><span class="k-color__sample">${esc(msg().colorPicker.sample)}</span><span></span></p>'}</div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,v({id:`${e}-hex`,label:this.getAttribute(`label`)??h().colorPicker.label,control:n})),this.rendered=!0,this.querySelector(`.k-color__swatches`)?.addEventListener(`change`,e=>this.pick(e.target.value));let r=this.querySelector(`#${e}-hex`);r.addEventListener(`input`,()=>{let e=M(r.value);this.paintMessages(!e),e&&this.pick(e,!1)}),r.addEventListener(`blur`,()=>{M(r.value)&&(r.value=this.current)}),this.querySelector(`.k-color__preview`).addEventListener(`click`,()=>this.panel?this.closePanel():this.openPanel()),this.paint()}pick(e,t=!0,n=!1){let r=e!==this.current;this.setColor(e,n),this.paint(t),r&&o(this,`kashi-change`,{value:e})}paint(e=!0){let t=this.current,n=I(t,`#ffffff`),r=I(t,`#000000`),i=n>=r?`#ffffff`:`#000000`,a=this.querySelector(`.k-color`);a.style.setProperty(`--_sw`,t),a.style.setProperty(`--_ink`,i),this.querySelectorAll(`.k-color__swatch input`).forEach(e=>e.checked=e.value===t);let o=this.querySelector(`#${this.key}-hex`);e&&(o.value=t);let s=Math.max(n,r),c=this.querySelector(`.k-color__contrast span:last-child`);c&&(c.textContent=h().colorPicker.contrast(i===`#ffffff`?`white`:`black`,f(this,(Math.round(s*10)/10).toFixed(1)).replace(`.`,h().common.decimal),s>=4.5));let l=this.getAttribute(`name`);this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),l&&this.insertAdjacentHTML(`beforeend`,`<input type="hidden" name="${d(l)}" value="${t}">`),this.panel&&this.paintPanel(),this.paintMessages(!1)}paintMessages(e){let t=this.querySelector(`#${this.key}-hex`);l(this.querySelector(`:scope > .k-field`),t,`${this.key}-hex`,e?h().colorPicker.invalid:null,this.getAttribute(`hint`))}openPanel(){let e=this.querySelector(`.k-color__anchor`),t=document.createElement(`div`);t.className=`k-color__panel`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-label`,h().colorPicker.custom),t.innerHTML=`<div class="k-color__area" role="slider" tabindex="0" aria-label="${d(h().colorPicker.area)}"><span class="k-color__thumb"></span></div><div class="k-color__tools"><span class="k-color__current" aria-hidden="true"></span><input type="range" class="k-color__hue" min="0" max="359" aria-label="${d(h().colorPicker.hue)}"></div><div class="k-color__codes" dir="ltr">${[`R`,`G`,`B`].map((e,t)=>`<label class="k-color__code"><input class="k-color__num" inputmode="numeric" data-ch="${t}" aria-label="${d([h().colorPicker.red,h().colorPicker.green,h().colorPicker.blue][t])}"><span aria-hidden="true">${e}</span></label>`).join(``)}</div>`,e.append(t),this.panel=t;let n=t.querySelector(`.k-color__area`),r=e=>{this.hsv=e,this.pick(R(e),!0,!0)},i=e=>{let t=n.getBoundingClientRect();r({...this.hsv,s:Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)),v:1-Math.min(1,Math.max(0,(e.clientY-t.top)/t.height))})};n.addEventListener(`pointerdown`,e=>{n.setPointerCapture?.(e.pointerId),i(e)}),n.addEventListener(`pointermove`,e=>e.buttons===1&&i(e)),n.addEventListener(`keydown`,e=>{let t=e.shiftKey?.1:.01,n=this.hsv,i={ArrowLeft:{s:Math.max(0,n.s-t)},ArrowRight:{s:Math.min(1,n.s+t)},ArrowUp:{v:Math.min(1,n.v+t)},ArrowDown:{v:Math.max(0,n.v-t)}};i[e.key]&&(e.preventDefault(),r({...n,...i[e.key]}))}),t.querySelector(`.k-color__hue`).addEventListener(`input`,e=>r({...this.hsv,h:Number(e.target.value)})),t.querySelectorAll(`.k-color__num`).forEach(e=>e.addEventListener(`input`,()=>{let t=N(this.current);t[Number(e.dataset.ch)]=Math.min(255,Math.max(0,Number(e.value.replace(/\D/g,``))||0)),this.pick(P(...t))})),t.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.closePanel())}),this.querySelector(`.k-color__preview`).setAttribute(`aria-expanded`,`true`),document.addEventListener(`pointerdown`,this.onOutside),this.paintPanel(),n.focus({preventScroll:!0})}paintPanel(){let e=this.panel,{h:t,s:n,v:r}=this.hsv,i=e=>h().common.percent(f(this,Math.round(e*100))),a=e.querySelector(`.k-color__area`);a.style.setProperty(`--_hue`,`hsl(${t} 100% 50%)`),a.setAttribute(`aria-valuenow`,String(Math.round(n*100))),a.setAttribute(`aria-valuetext`,h().colorPicker.areaValue(i(n),i(r)));let o=e.querySelector(`.k-color__thumb`);o.style.left=`${n*100}%`,o.style.top=`${(1-r)*100}%`;let s=e.querySelector(`.k-color__hue`);s.value=String(Math.round(t)),s.setAttribute(`aria-valuetext`,h().colorPicker.degrees(f(this,Math.round(t))));let c=N(this.current);e.querySelectorAll(`.k-color__num`).forEach((e,t)=>{document.activeElement!==e&&(e.value=String(c[t]))})}closePanel(e=!0){if(!this.panel)return;this.panel.remove(),this.panel=null,document.removeEventListener(`pointerdown`,this.onOutside);let t=this.querySelector(`.k-color__preview`);t.setAttribute(`aria-expanded`,`false`),e&&t.focus()}};V.observedAttributes=[`label`,`hint`,`value`,`name`,`swatches`,`show-contrast`],m(`kashi-date-range-picker`,E,`block`),m(`kashi-month-picker`,O,`block`),m(`kashi-file-upload`,A,`block`),m(`kashi-color-picker`,V,`block`);export{V as KashiColorPicker,E as KashiDateRangePicker,A as KashiFileUpload,O as KashiMonthPicker,I as contrastRatio,k as formatBytes};
@@ -0,0 +1 @@
1
+ import{c as e,i as t,l as n,m as r,o as i,p as a,r as o,t as s,v as c}from"./base-DTQ50VdG.js";import{n as l}from"./text-D4a_hlwL.js";import{cellNumber as u}from"./controls-BwebEIlf.js";const d=e=>l(e,{digits:`latin`}).toLowerCase();var f=class extends s{constructor(){super(...arguments),this.cols=null,this.data=null,this.table=null,this.sort=null,this.query=``,this.key=c(`kashi-table`),this.getRowId=e=>String(e.id??``)}connectedCallback(){o(()=>this.isConnected&&this.setup())}attributeChangedCallback(e,t,n){this.table&&t!==n&&this.setup()}get columns(){return this.cols??[]}set columns(e){this.cols=e,this.isConnected&&this.data&&this.setup()}get rows(){return this.data??[]}set rows(e){this.data=e,this.isConnected&&this.cols&&this.setup()}get selected(){return[...this.querySelectorAll(`tbody tr[aria-selected="true"]`)].map(e=>e.dataset.id??``)}setup(){this.cols&&this.data&&this.buildFromData();let e=this.querySelector(`:scope table`);if(!e)return;let n=e.closest(`.k-table-wrap`)??this.wrap(e);n.className=`k-table-wrap${t(this,`sticky-header`)?` k-table-wrap--sticky`:``}`,e.classList.add(`k-table`),e.classList.toggle(`k-table--compact`,t(this,`compact`)),e.classList.toggle(`k-table--striped`,t(this,`striped`));let r=e.querySelector(`caption`);r&&(r.id||=`${this.key}-caption`,n.setAttribute(`aria-labelledby`,r.id)),this.table=e,this.decorateHeader(),this.decorateRows(),this.searchBox(),this.apply()}wrap(e){let t=document.createElement(`div`);return t.setAttribute(`role`,`region`),t.tabIndex=0,e.before(t),t.append(e),t}buildFromData(){let e=this.cols,t=this.getAttribute(`caption`)??``,r=(e,t)=>e.format?e.format(t[e.key],t):String(t[e.key]??``),i=`<table>${t?`<caption><span class="k-table__caption-title">${n(t)}</span></caption>`:``}<thead><tr>${e.map(e=>`<th scope="col"${e.sortable?` data-sort`:``}${e.numeric?` data-numeric`:``}>${n(e.header)}</th>`).join(``)}</tr></thead><tbody>${this.data.map(t=>`<tr data-id="${n(this.getRowId(t))}">${e.map(e=>`<td>${n(r(e,t))}</td>`).join(``)}</tr>`).join(``)}</tbody></table>`;this.querySelector(`:scope > .k-table-wrap, :scope > table`)?.remove(),this.insertAdjacentHTML(`beforeend`,i)}decorateHeader(){this.table;let n=this.headCells();n.forEach((t,n)=>{if(t.classList.contains(`k-table__check`)||(t.scope||=`col`,t.hasAttribute(`data-numeric`)&&t.classList.add(`k-table__num`),!t.hasAttribute(`data-sort`)||t.querySelector(`.k-table__sort`)))return;t.setAttribute(`aria-sort`,`none`);let r=document.createElement(`button`);r.type=`button`,r.className=`k-table__sort`,r.append(...t.childNodes),t.append(r);let i=this.dataIndex(n);r.addEventListener(`click`,()=>{this.sort=this.sort?.index===i&&this.sort.dir===`ascending`?{index:i,dir:`descending`}:{index:i,dir:`ascending`},this.apply(),e(this,`kashi-sort`,{column:i,direction:this.sort.dir})})});let r=n.map(e=>e.hasAttribute(`data-numeric`));for(let e of this.bodyRows())[...e.children].forEach((e,t)=>r[t]&&e.classList.add(`k-table__num`));let i=t(this,`selectable`),a=this.headRow(),o=a?.querySelector(`.k-table__check`);if(i&&a&&!o){let e=document.createElement(`th`);e.scope=`col`,e.className=`k-table__check`,e.innerHTML='<input type="checkbox" class="k-checkbox" aria-label="${esc(msg().table.selectAll)}">',a.prepend(e),e.querySelector(`input`).addEventListener(`change`,e=>{let t=e.target.checked;this.visibleRows().forEach(e=>this.setRow(e,t)),this.selectionChanged()})}else!i&&o&&o.remove()}headRow(){return this.table.querySelector(`:scope > thead > tr`)}headCells(){return[...this.headRow()?.children??[]]}bodyRows(){return[...this.table.querySelectorAll(`:scope > tbody > tr`)]}dataIndex(e){return this.headRow()?.querySelector(`.k-table__check`)?e-1:e}offset(){return+!!this.headRow()?.querySelector(`.k-table__check`)}decorateRows(){let e=t(this,`selectable`);this.bodyRows().forEach((t,r)=>{var i,o;(i=t.dataset).id||(i.id=String(r+1)),(o=t.dataset).order||(o.order=String(r));let s=t.querySelector(`.k-table__check`);if(e&&!s){let e=document.createElement(`td`);e.className=`k-table__check`;let r=t.children[0]?.textContent?.trim();e.innerHTML=`<input type="checkbox" class="k-checkbox" aria-label="${n(r?a().table.selectNamed(r):a().table.selectRow)}">`,t.prepend(e),t.setAttribute(`aria-selected`,`false`),e.querySelector(`input`).addEventListener(`change`,e=>{this.setRow(t,e.target.checked),this.selectionChanged()})}else!e&&s&&(s.remove(),t.removeAttribute(`aria-selected`))}),this.selectionChanged(!1)}setRow(e,t){e.setAttribute(`aria-selected`,String(t));let n=e.querySelector(`.k-table__check input`);n&&(n.checked=t)}selectionChanged(t=!0){let r=this.headRow()?.querySelector(`.k-table__check input`),i=this.visibleRows(),a=i.filter(e=>e.getAttribute(`aria-selected`)===`true`).length;r&&(r.checked=i.length>0&&a===i.length,r.indeterminate=a>0&&a<i.length);let o=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),o)for(let e of this.selected)this.insertAdjacentHTML(`beforeend`,`<input type="hidden" name="${n(o)}" value="${n(e)}">`);t&&e(this,`kashi-change`,{selected:this.selected})}visibleRows(){return this.bodyRows().filter(e=>!e.hidden&&!e.classList.contains(`k-table__empty`))}searchBox(){let e=this.querySelector(`:scope > .k-table-search`);if(!t(this,`searchable`))return e?.remove();if(e)return;let i=`${this.key}-search`,o=document.createElement(`div`);o.className=`k-table-search k-field`,o.style.marginBlockEnd=`var(--k-space-3)`,o.innerHTML=`<div class="k-input k-input--sm"><input id="${i}" class="k-input__control" type="search" placeholder="${n(a().table.search)}" aria-label="${n(a().table.search)}"></div><span class="k-sr-only" aria-live="polite"></span>`,this.prepend(o);let s=o.querySelector(`input`);s.addEventListener(`input`,()=>{this.query=s.value,this.apply(),o.querySelector(`.k-sr-only`).textContent=a().table.rows(r(this,this.visibleRows().length))})}apply(){let e=this.table.querySelector(`:scope > tbody`);if(!e)return;let t=this.offset(),r=this.bodyRows().filter(e=>!e.classList.contains(`k-table__empty`)),i=this.headCells();i.forEach((e,n)=>{e.hasAttribute(`aria-sort`)&&e.setAttribute(`aria-sort`,this.sort&&this.sort.index===n-t?this.sort.dir:`none`)});let o=r.sort((e,t)=>Number(e.dataset.order)-Number(t.dataset.order));if(this.sort){let{index:e,dir:n}=this.sort,r=i[e+t]?.hasAttribute(`data-numeric`),a=n=>{let i=n.children[e+t],a=i?.dataset.value??i?.textContent?.trim()??``;return r?u(a):a},s=n===`ascending`?1:-1;o=[...o].sort((e,t)=>{let n=a(e),r=a(t);return(typeof n==`number`&&typeof r==`number`?n-r:String(n).localeCompare(String(r),`fa`))*s})}let s=d(this.query.trim());for(let t of o)t.hidden=!!s&&!d(t.textContent??``).includes(s),e.append(t);if(e.querySelector(`.k-table__empty`)?.remove(),s&&!this.visibleRows().length){let t=i.length;e.insertAdjacentHTML(`beforeend`,`<tr class="k-table__empty"><td colspan="${t}"><p style="padding: 2rem; margin: 0; text-align: center">${n(a().common.noResults)}</p></td></tr>`)}this.selectionChanged(!1)}};f.observedAttributes=[`selectable`,`searchable`,`compact`,`striped`,`sticky-header`,`caption`,`name`],i(`kashi-data-table`,f,`block`);export{f as KashiDataTable};
@@ -0,0 +1 @@
1
+ import{A as e,k as t}from"./base-DTQ50VdG.js";function n(n,{digits:r}={}){let i=n.replace(/[يى]/g,`ی`).replace(/ك/g,`ک`).replace(/ة/g,`ه`).replace(/[ً-ٰٟ]/g,``).replace(/ـ/g,``).replace(/‌{2,}/g,`‌`).replace(/ *‌ */g,`‌`).replace(/[ \t]{2,}/g,` `).trim();return r===`fa`&&(i=e(t(i))),r===`latin`&&(i=t(i)),i}function r(t,{digits:n=!0}={}){let r={arabic:0,zwnj:0,punctuation:0,digits:0,spacing:0},i=(e,t,n,i)=>e.replace(t,(...e)=>(r[i]++,typeof n==`string`?n.replace(/\$(\d)/g,(t,n)=>e[Number(n)]??``):n(...e))),a=`[\\u0621-\\u063A\\u0641-\\u064A\\u067E\\u0686\\u0698\\u06A9\\u06AF\\u06CC]`,o=t;o=i(o,/[يى]/g,`ی`,`arabic`),o=i(o,/ك/g,`ک`,`arabic`),o=i(o,RegExp(`(^|[\\s(«])(ن?می) (?=${a})`,`g`),`$1$2‌`,`zwnj`),o=i(o,RegExp(`(${a}) (ها|های|هایی|هایم|هایت|هایش|تر|ترین)(?=$|[\\s.،؛؟!»)])`,`g`),`$1‌$2`,`zwnj`),o=i(o,RegExp(`(${a}\\s*),(?=\\s)`,`g`),`$1،`,`punctuation`),o=i(o,RegExp(`(${a}\\s*)\\?`,`g`),`$1؟`,`punctuation`),o=i(o,RegExp(`(${a}\\s*);`,`g`),`$1؛`,`punctuation`),o=i(o,/ +([،؛؟!.:])(?=\s|$)/g,`$1`,`spacing`),o=i(o,/ {2,}/g,` `,`spacing`),n&&(o=i(o,RegExp(`(${a}[\\s\\u200c]*)(\\d+)|(\\d+)(?=[\\s\\u200c]*${a})`,`g`),(t,n,r,i)=>n?n+e(r):e(i),`digits`));let s=Object.values(r).reduce((e,t)=>e+t,0);return{text:o,fixes:r,count:s}}export{n,r as t};
@@ -0,0 +1 @@
1
+ import{O as e}from"./base-DTQ50VdG.js";function t(t){let n=t.trim();if(!n)return null;let r=n.split(/[:٫.،,\s]/).map(e).filter(Boolean),i,a;if(r.length>=2)[i,a]=[Number(r[0]),Number(r[1])];else{let t=e(n);t.length<=2?[i,a]=[Number(t),0]:[i,a]=[Number(t.slice(0,-2)),Number(t.slice(-2))]}return i>=0&&i<24&&a>=0&&a<60?{hours:i,minutes:a}:null}function n({hours:e,minutes:t}){return`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`}export{t as n,n as t};
@@ -0,0 +1 @@
1
+ const e=[``,`یک`,`دو`,`سه`,`چهار`,`پنج`,`شش`,`هفت`,`هشت`,`نه`],t=[`ده`,`یازده`,`دوازده`,`سیزده`,`چهارده`,`پانزده`,`شانزده`,`هفده`,`هجده`,`نوزده`],n=[``,``,`بیست`,`سی`,`چهل`,`پنجاه`,`شصت`,`هفتاد`,`هشتاد`,`نود`],r=[``,`صد`,`دویست`,`سیصد`,`چهارصد`,`پانصد`,`ششصد`,`هفتصد`,`هشتصد`,`نهصد`],i=[``,`هزار`,`میلیون`,`میلیارد`,`تریلیون`];function a(i){let a=[],o=Math.floor(i/100),s=i%100;return o&&a.push(r[o]),s>=10&&s<20?a.push(t[s-10]):(s>=20&&a.push(n[Math.floor(s/10)]),s%10&&a.push(e[s%10])),a.join(` و `)}const o=[``,`one`,`two`,`three`,`four`,`five`,`six`,`seven`,`eight`,`nine`,`ten`,`eleven`,`twelve`,`thirteen`,`fourteen`,`fifteen`,`sixteen`,`seventeen`,`eighteen`,`nineteen`],s=[``,``,`twenty`,`thirty`,`forty`,`fifty`,`sixty`,`seventy`,`eighty`,`ninety`],c=[``,`thousand`,`million`,`billion`,`trillion`];function l(e){let t=Math.floor(e/100),n=e%100,r=n<20?o[n]:`${s[Math.floor(n/10)]}${n%10?`-${o[n%10]}`:``}`;return[t?`${o[t]} hundred`:``,r].filter(Boolean).join(` `)}function u(e,{locale:t=`fa`}={}){let n=typeof e==`bigint`?e:BigInt(Math.trunc(e)),r=t===`en`;if(n===0n)return r?`zero`:`صفر`;let o=n<0n;if(o&&(n=-n),n>=10n**15n)throw RangeError(`عدد بزرگ‌تر از حد پشتیبانی‌شده است`);let s=[];for(let e=0;n>0n;e++,n/=1000n){let t=Number(n%1000n);if(!t)continue;if(r){s.unshift([l(t),c[e]].filter(Boolean).join(` `));continue}let o=e===1&&t===1?``:a(t);s.unshift([o,i[e]].filter(Boolean).join(` `))}return r?(o?`minus `:``)+s.join(` `):(o?`منفی `:``)+s.join(` و `)}export{u as t};
package/dist/cdn.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { toast } from "./toast.js";
2
+ export { setLocale } from "./base.js";
2
3
  /** همهٔ عنصرها را همین حالا بارگذاری می‌کند؛ مثلاً پیش از ساختن عنصرها با JavaScript */
3
4
  export declare function loadAll(): Promise<unknown[]>;
package/dist/cdn.js CHANGED
@@ -1,6 +1,8 @@
1
1
  // نسخهٔ CDN با بارگذاری تنبل: هر بخش فقط وقتی یکی از تگ‌هایش در صفحه پیدا شود دانلود می‌شود.
2
2
  // صفحه‌ای که فقط فیلد کد ملی دارد، نقشه و نمودارها را دانلود نمی‌کند.
3
3
  export { toast } from "./toast.js";
4
+ // زبان پیش از بارگذاری عنصرها: <script type="module">import { setLocale } from ".../kashi-elements.js"; setLocale("en");</script>
5
+ export { setLocale } from "./base.js";
4
6
  const MODULES = [
5
7
  [["kashi-national-id", "kashi-legal-id", "kashi-mobile", "kashi-landline", "kashi-card-number", "kashi-iban", "kashi-postal-code", "kashi-price"], () => import("./inputs.js")],
6
8
  [["kashi-otp"], () => import("./fields.js")],
package/dist/charts.js CHANGED
@@ -1,15 +1,18 @@
1
- import { JALALI_MONTHS, formatJalali, formatNumber, jalaliMonthLength, toGregorian, toISODate, toJalali } from "@kashi-ui/persian";
2
- import { HTMLBase, define, esc, uid } from "./base.js";
1
+ import { formatJalali, formatNumber as fmtNumber, jalaliMonthLength, toGregorian, toISODate, toJalali } from "@kashi-ui/persian";
2
+ import { calendarNames, define, esc, HTMLBase, lang, localeDigits, msg, uid } from "./base.js";
3
+ // عددها با ارقام زبان فعلی (setLocale)
4
+ const formatNumber = (n) => fmtNumber(n, { digits: localeDigits() });
5
+ const dec = (x) => formatNumber(Math.round(x * 10) / 10).replace(".", msg().common.decimal);
3
6
  /** عدد کوتاه برای محور: ۱٬۲۰۰٬۰۰۰ ← ۱٫۲ م */
4
7
  const compact = (n) => {
5
8
  const a = Math.abs(n);
6
- const fa = (x, u) => `${formatNumber(Math.round(x * 10) / 10).replace(".", "٫")}${u}`;
9
+ const C = msg().chart;
7
10
  if (a >= 1e9)
8
- return fa(n / 1e9, " میلیارد");
11
+ return dec(n / 1e9) + C.billion;
9
12
  if (a >= 1e6)
10
- return fa(n / 1e6, " م");
13
+ return dec(n / 1e6) + C.million;
11
14
  if (a >= 1e3)
12
- return fa(n / 1e3, " هزار");
15
+ return dec(n / 1e3) + C.thousand;
13
16
  return formatNumber(n);
14
17
  };
15
18
  /** گام‌های گرد محور: ۰، ۲۵، ۵۰… */
@@ -21,7 +24,7 @@ function niceTicks(max, count = 4) {
21
24
  const step = [1, 2, 2.5, 5, 10].map((m) => m * mag).find((s) => s >= raw);
22
25
  return Array.from({ length: Math.ceil(max / step) + 1 }, (_, i) => i * step);
23
26
  }
24
- const pctOf = (v, total) => `${formatNumber(Math.round((v / (total || 1)) * 1000) / 10).replace(".", "٫")}٪`;
27
+ const pctOf = (v, total) => msg().common.percent(dec((v / (total || 1)) * 100));
25
28
  const chartColor = (i) => `var(--k-chart-${i + 1})`;
26
29
  const json = (t, fallback) => {
27
30
  if (!t)
@@ -113,7 +116,7 @@ export class KashiBarChart extends Chart {
113
116
  const top = ticks.at(-1) || 1;
114
117
  const maxI = totals.indexOf(max);
115
118
  const labelMax = this.getAttribute("label-max") !== "false";
116
- const describe = (i) => (stacked ? `${cats[i]}: ${stacked.map((s) => `${s.name} ${f(s.values[i] ?? 0)}`).join("، ")}، جمع ${f(totals[i])}` : `${cats[i]}: ${f(totals[i])}`);
119
+ const describe = (i) => (stacked ? `${cats[i]}: ${stacked.map((s) => `${s.name} ${f(s.values[i] ?? 0)}`).join(msg().common.list)}${msg().common.list}${msg().common.total} ${f(totals[i])}` : `${cats[i]}: ${f(totals[i])}`);
117
120
  const height = this.getAttribute("height");
118
121
  this.innerHTML = `<figure class="k-chart k-chart--bar" aria-labelledby="${this.key}-t" style="margin: 0${height ? `; --k-chart-height: ${esc(height)}` : ""}"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${esc(this.heading)}</p>${stacked && stacked.length > 1 ? `<ul class="k-chart__legend" aria-hidden="true">${stacked.map((s, i) => `<li style="--_c: ${chartColor(i)}"><span class="k-chart__key k-chart__key--box"></span>${esc(s.name)}</li>`).join("")}</ul>` : ""}</figcaption><div class="k-chart__plot"><div class="k-bars__grid" aria-hidden="true">${ticks.map((t) => `<span data-v="${esc(compact(t))}"></span>`).join("")}</div><div class="k-bars" role="list" aria-label="${esc(this.heading)}">${cats.map((label, i) => `<div class="k-bars__col" role="listitem" tabindex="0" data-i="${i}" aria-label="${esc(describe(i))}" style="--_d: ${i * 40}ms">${labelMax && i === maxI ? `<span class="k-bars__value" aria-hidden="true">${esc(f(totals[i]))}</span>` : ""}${stacked ? `<span class="k-bars__stack" style="block-size: ${(totals[i] / top) * 100}%" aria-hidden="true">${stacked.map((s, si) => `<span class="k-bars__seg" style="--_c: ${chartColor(si)}; flex-grow: ${s.values[i] ?? 0}"></span>`).join("")}</span>` : `<span class="k-bars__bar" style="block-size: ${(totals[i] / top) * 100}%" aria-hidden="true"></span>`}<span class="k-bars__label" aria-hidden="true">${esc(label)}</span></div>`).join("")}</div></div></figure>`;
119
122
  const plot = this.querySelector(".k-chart__plot");
@@ -123,7 +126,7 @@ export class KashiBarChart extends Chart {
123
126
  col.setAttribute("data-active", "");
124
127
  const p = this.at(col.querySelector(".k-bars__bar, .k-bars__stack") ?? col, plot);
125
128
  this.tip(plot, p.x, p.y, cats[i], stacked
126
- ? [...stacked.map((s, si) => ({ name: s.name, value: f(s.values[i] ?? 0), color: chartColor(si) })), { name: "جمع", value: f(totals[i]) }]
129
+ ? [...stacked.map((s, si) => ({ name: s.name, value: f(s.values[i] ?? 0), color: chartColor(si) })), { name: msg().common.total, value: f(totals[i]) }]
127
130
  : [{ value: f(totals[i]) }]);
128
131
  };
129
132
  const hide = () => {
@@ -155,7 +158,7 @@ export class KashiBarList extends Chart {
155
158
  const d = data[Number(row.dataset.i)];
156
159
  row.setAttribute("data-active", "");
157
160
  const p = this.at(row.querySelector(".k-barlist__fill"), box);
158
- this.tip(box, p.x, p.y, d.label, [{ name: "مقدار", value: f(d.value) }, { name: "سهم از کل", value: pctOf(d.value, total) }]);
161
+ this.tip(box, p.x, p.y, d.label, [{ name: msg().chart.value, value: f(d.value) }, { name: msg().chart.share, value: pctOf(d.value, total) }]);
159
162
  });
160
163
  row.addEventListener("pointerleave", () => {
161
164
  row.removeAttribute("data-active");
@@ -182,7 +185,7 @@ export class KashiProportionBar extends Chart {
182
185
  const i = Number(seg.dataset.i);
183
186
  mark(i);
184
187
  const p = this.at(seg, box);
185
- this.tip(box, p.x, p.y, undefined, [{ name: parts[i].label, value: pctOf(parts[i].value, total), color: chartColor(i) }, { name: "تعداد", value: f(parts[i].value) }]);
188
+ this.tip(box, p.x, p.y, undefined, [{ name: parts[i].label, value: pctOf(parts[i].value, total), color: chartColor(i) }, { name: msg().chart.count, value: f(parts[i].value) }]);
186
189
  });
187
190
  seg.addEventListener("pointerleave", () => {
188
191
  mark(null);
@@ -199,12 +202,12 @@ export class KashiPieChart extends Chart {
199
202
  draw() {
200
203
  const f = this.format;
201
204
  const sorted = [...this.data].sort((a, b) => b.value - a.value);
202
- const parts = sorted.length > 5 ? [...sorted.slice(0, 4), { label: "سایر", value: sorted.slice(4).reduce((n, d) => n + d.value, 0) }] : sorted;
205
+ const parts = sorted.length > 5 ? [...sorted.slice(0, 4), { label: msg().common.other, value: sorted.slice(4).reduce((n, d) => n + d.value, 0) }] : sorted;
203
206
  const total = parts.reduce((n, d) => n + d.value, 0) || 1;
204
207
  const slot = (i) => (i < 4 ? chartColor(i) : "var(--k-text-quaternary)");
205
208
  const donut = this.getAttribute("variant") !== "pie";
206
209
  const size = Number(this.getAttribute("size")) || 176;
207
- const totalLabel = this.getAttribute("total-label") ?? "جمع";
210
+ const totalLabel = this.getAttribute("total-label") ?? msg().common.total;
208
211
  // هر بخش یک کمان با stroke-dasharray؛ برای pie، شعاع نصف و ضخامت برابر قطر
209
212
  const R = 50, r = donut ? 40 : 25, w = donut ? 16 : 50;
210
213
  const C = 2 * Math.PI * r;
@@ -232,7 +235,7 @@ export class KashiPieChart extends Chart {
232
235
  if (i === null)
233
236
  this.tip(plot, null);
234
237
  else
235
- this.tip(plot, mid(i).x, mid(i).y, undefined, [{ name: parts[i].label, value: pctOf(parts[i].value, total), color: slot(i) }, { name: "تعداد", value: f(parts[i].value) }]);
238
+ this.tip(plot, mid(i).x, mid(i).y, undefined, [{ name: parts[i].label, value: pctOf(parts[i].value, total), color: slot(i) }, { name: msg().chart.count, value: f(parts[i].value) }]);
236
239
  }
237
240
  };
238
241
  this.querySelectorAll(".k-pie__slice, .k-pie__legend li").forEach((el) => el.addEventListener("pointerenter", () => activate(Number(el.dataset.i))));
@@ -303,7 +306,7 @@ export class KashiLineChart extends Chart {
303
306
  const f = this.format;
304
307
  const labels = this.labels;
305
308
  const height = this.getAttribute("height");
306
- this.innerHTML = `<figure class="k-chart" aria-labelledby="${this.key}-t" style="margin: 0${height ? `; --k-chart-height: ${esc(height)}` : ""}"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${esc(this.heading)}</p>${shown.length > 1 ? `<ul class="k-chart__legend" aria-hidden="true">${shown.map((s, i) => `<li style="--_c: ${chartColor(i)}"><span class="k-chart__key"></span>${esc(s.name)}</li>`).join("")}</ul>` : ""}</figcaption><div class="k-chart__plot" tabindex="0" role="img" aria-label="${esc(`${this.heading}. با کلیدهای جهت بین نقطه‌ها حرکت کنید.`)}" aria-describedby="${this.key}-live"><svg class="k-chart__svg" aria-hidden="true" direction="ltr"></svg></div><span class="k-sr-only" aria-live="polite" id="${this.key}-live"></span><table class="k-sr-only"><caption>${esc(this.heading)}</caption><thead><tr><th scope="col">دوره</th>${shown.map((s) => `<th scope="col">${esc(s.name)}</th>`).join("")}</tr></thead><tbody>${labels.map((l, i) => `<tr><th scope="row">${esc(l)}</th>${shown.map((s) => `<td>${esc(f(s.values[i]))}</td>`).join("")}</tr>`).join("")}</tbody></table></figure>`;
309
+ this.innerHTML = `<figure class="k-chart" aria-labelledby="${this.key}-t" style="margin: 0${height ? `; --k-chart-height: ${esc(height)}` : ""}"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${esc(this.heading)}</p>${shown.length > 1 ? `<ul class="k-chart__legend" aria-hidden="true">${shown.map((s, i) => `<li style="--_c: ${chartColor(i)}"><span class="k-chart__key"></span>${esc(s.name)}</li>`).join("")}</ul>` : ""}</figcaption><div class="k-chart__plot" tabindex="0" role="img" aria-label="${esc(msg().chart.keyboard(this.heading))}" aria-describedby="${this.key}-live"><svg class="k-chart__svg" aria-hidden="true" direction="ltr"></svg></div><span class="k-sr-only" aria-live="polite" id="${this.key}-live"></span><table class="k-sr-only"><caption>${esc(this.heading)}</caption><thead><tr><th scope="col">${esc(msg().chart.period)}</th>${shown.map((s) => `<th scope="col">${esc(s.name)}</th>`).join("")}</tr></thead><tbody>${labels.map((l, i) => `<tr><th scope="row">${esc(l)}</th>${shown.map((s) => `<td>${esc(f(s.values[i]))}</td>`).join("")}</tr>`).join("")}</tbody></table></figure>`;
307
310
  const plot = this.querySelector(".k-chart__plot");
308
311
  plot.addEventListener("pointermove", (e) => this.pick(e.clientX));
309
312
  plot.addEventListener("pointerleave", () => this.setActive(null));
@@ -367,7 +370,7 @@ export class KashiLineChart extends Chart {
367
370
  this.tip(plot, null);
368
371
  else
369
372
  this.tip(plot, x(a), Math.min(...shown.map((s) => y(s.values[a]))) - 6, labels[a], shown.map((s, si) => ({ name: s.name, value: f(s.values[a]), color: chartColor(si) })));
370
- this.querySelector(`#${this.key}-live`).textContent = a === null ? "" : `${labels[a]}: ${shown.map((s) => `${s.name} ${f(s.values[a])}`).join("، ")}`;
373
+ this.querySelector(`#${this.key}-live`).textContent = a === null ? "" : `${labels[a]}: ${shown.map((s) => `${s.name} ${f(s.values[a])}`).join(msg().common.list)}`;
371
374
  }
372
375
  pick(clientX) {
373
376
  const { plot, labels, x } = this.geometry();
@@ -386,7 +389,6 @@ export class KashiLineChart extends Chart {
386
389
  }
387
390
  }
388
391
  KashiLineChart.observedAttributes = ["label", "labels", "series", "unit", "area", "height"];
389
- const WEEK = ["ش", "", "د", "", "چ", "", "ج"];
390
392
  /** نقشهٔ فعالیت سالانه با ماه‌های شمسی: data='{"2026-03-21": 3, …}'، year="1405"، unit="فعالیت" */
391
393
  export class KashiActivityHeatmap extends Chart {
392
394
  get data() { return this.read("data", {}); }
@@ -394,7 +396,8 @@ export class KashiActivityHeatmap extends Chart {
394
396
  draw() {
395
397
  const data = this.data;
396
398
  const year = Number(this.getAttribute("year")) || toJalali(new Date()).jy;
397
- const unit = this.getAttribute("unit") ?? "فعالیت";
399
+ const H = msg().heatmap;
400
+ const unit = this.getAttribute("unit") ?? H.unit;
398
401
  const days = [];
399
402
  for (let m = 1; m <= 12; m++)
400
403
  for (let d = 1; d <= jalaliMonthLength(year, m); d++) {
@@ -406,12 +409,12 @@ export class KashiActivityHeatmap extends Chart {
406
409
  // شنبه سطر اول
407
410
  const offset = (days[0].date.getDay() + 1) % 7;
408
411
  const col = (i) => Math.floor((i + offset) / 7);
409
- const months = JALALI_MONTHS.map((name, m) => ({ name, col: col(days.findIndex((d) => toJalali(d.date).jm === m + 1)) }));
412
+ const months = calendarNames().months.map((name, m) => ({ name, col: col(days.findIndex((d) => toJalali(d.date).jm === m + 1)) }));
410
413
  const total = days.reduce((s, d) => s + d.value, 0);
411
- const monthly = JALALI_MONTHS.map((name, m) => ({ name, sum: days.filter((d) => toJalali(d.date).jm === m + 1).reduce((s, d) => s + d.value, 0) }));
412
- const yearText = formatNumber(year).replace(/٬/g, "");
413
- const name = this.getAttribute("label") ?? `${unit} در سال ${yearText}`;
414
- this.innerHTML = `<figure class="k-heatmap" style="margin: 0"><div class="k-heatmap__scroll"><div role="img" aria-label="${esc(`${name}: ${formatNumber(total)} ${unit}`)}"><div class="k-heatmap__months" aria-hidden="true">${months.map((m) => `<span style="grid-column: ${m.col + 1}">${m.name}</span>`).join("")}</div><div class="k-heatmap__body" aria-hidden="true"><div class="k-heatmap__days">${WEEK.map((w) => `<span>${w}</span>`).join("")}</div><div class="k-heatmap__grid">${'<span class="k-heatmap__cell" data-empty=""></span>'.repeat(offset)}${days.map((d, i) => `<span class="k-heatmap__cell" data-l="${level(d.value)}" data-i="${i}"></span>`).join("")}</div></div></div></div><figcaption class="k-heatmap__foot"><span>${formatNumber(total)} ${esc(unit)} در ${yearText}</span><span class="k-heatmap__scale" aria-hidden="true">کمتر ${[0, 1, 2, 3, 4].map((l) => `<span class="k-heatmap__cell" data-l="${l}"></span>`).join("")} بیشتر</span></figcaption><table class="k-sr-only"><caption>${esc(name)}، به تفکیک ماه</caption><tbody>${monthly.map((m) => `<tr><th scope="row">${m.name}</th><td>${formatNumber(m.sum)}</td></tr>`).join("")}</tbody></table></figure>`;
414
+ const monthly = calendarNames().months.map((name, m) => ({ name, sum: days.filter((d) => toJalali(d.date).jm === m + 1).reduce((s, d) => s + d.value, 0) }));
415
+ const yearText = formatNumber(year).replace(/[٬,]/g, "");
416
+ const name = this.getAttribute("label") ?? H.inYear(unit, yearText);
417
+ this.innerHTML = `<figure class="k-heatmap" style="margin: 0"><div class="k-heatmap__scroll"><div role="img" aria-label="${esc(`${name}: ${formatNumber(total)} ${unit}`)}"><div class="k-heatmap__months" aria-hidden="true">${months.map((m) => `<span style="grid-column: ${m.col + 1}">${m.name}</span>`).join("")}</div><div class="k-heatmap__body" aria-hidden="true"><div class="k-heatmap__days">${H.weekdays.map((w) => `<span>${w}</span>`).join("")}</div><div class="k-heatmap__grid">${'<span class="k-heatmap__cell" data-empty=""></span>'.repeat(offset)}${days.map((d, i) => `<span class="k-heatmap__cell" data-l="${level(d.value)}" data-i="${i}"></span>`).join("")}</div></div></div></div><figcaption class="k-heatmap__foot"><span>${esc(H.total(formatNumber(total), unit, yearText))}</span><span class="k-heatmap__scale" aria-hidden="true">${esc(H.less)} ${[0, 1, 2, 3, 4].map((l) => `<span class="k-heatmap__cell" data-l="${l}"></span>`).join("")} ${esc(H.more)}</span></figcaption><table class="k-sr-only"><caption>${esc(H.byMonth(name))}</caption><tbody>${monthly.map((m) => `<tr><th scope="row">${m.name}</th><td>${formatNumber(m.sum)}</td></tr>`).join("")}</tbody></table></figure>`;
415
418
  const fig = this.querySelector("figure");
416
419
  this.querySelector(".k-heatmap__grid").addEventListener("pointerover", (e) => {
417
420
  const cell = e.target.closest("[data-i]");
@@ -421,7 +424,7 @@ export class KashiActivityHeatmap extends Chart {
421
424
  cell.setAttribute("data-active", "");
422
425
  const p = this.at(cell, fig);
423
426
  const d = days[Number(cell.dataset.i)];
424
- this.tip(fig, p.x, p.y - 2, formatJalali(d.date, { style: "full" }), [{ value: `${formatNumber(d.value)} ${unit}` }]);
427
+ this.tip(fig, p.x, p.y - 2, formatJalali(d.date, { style: "full", digits: localeDigits(), locale: lang() }), [{ value: `${formatNumber(d.value)} ${unit}` }]);
425
428
  });
426
429
  fig.addEventListener("pointerleave", () => this.tip(fig, null));
427
430
  }