@wpmoo/ui 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/certification.json +1 -1
- package/dist/assets/css/moo-ui.css +20 -11
- package/dist/assets/css/moo-ui.min.css +2 -2
- package/dist/assets/css/moo.css +13 -4
- package/dist/assets/css/moo.min.css +2 -2
- package/dist/js/chart.js +9 -1
- package/dist/js/chart.min.js +2 -2
- package/dist/js/combobox.js +17 -6
- package/dist/js/context-menu.js +8 -3
- package/dist/js/datatable.js +41 -19
- package/dist/js/datepicker.js +23 -9
- package/dist/js/datepicker.min.js +2 -2
- package/dist/js/floating-panel.js +1 -1
- package/dist/js/moo-ui.js +123 -34
- package/dist/js/moo-ui.min.js +2 -2
- package/dist/js/overlay-scrollbar.js +1 -1
- package/dist/js/password-requirements.js +14 -5
- package/dist/js/sheet.js +1 -1
- package/dist/js/sidebar.js +42 -1
- package/dist/js/slider.js +1 -1
- package/dist/js/state.js +1 -1
- package/dist/js/table-of-contents.js +1 -1
- package/dist/js/toc.js +1 -1
- package/dist/release-manifest.json +4 -4
- package/package.json +1 -1
- package/scss/layouts/_app.scss +10 -0
- package/scss/mixins/_banner.scss +1 -1
- package/scss/settings/_palette.scss +2 -1
- package/scss/themes/_theme.scss +1 -0
package/dist/js/chart.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Moo UI chart.js v2.
|
|
2
|
+
* Moo UI chart.js v2.1.1 (https://wpmoo.org/)
|
|
3
3
|
* Copyright 2026 WPMoo Authors
|
|
4
4
|
* Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
@@ -501,6 +501,14 @@ function tooltipLabel(context) {
|
|
|
501
501
|
const parsed = context.parsed;
|
|
502
502
|
const raw = context.raw;
|
|
503
503
|
if (parsed !== null && typeof parsed === "object") {
|
|
504
|
+
const meta = context.chart?.getDatasetMeta?.(context.datasetIndex);
|
|
505
|
+
const valueAxis = meta?.iScale?.type === "category" ? meta.vScale?.axis : null;
|
|
506
|
+
const single = valueAxis ? parsed[valueAxis] : typeof parsed.r === "number" && parsed.x === void 0 ? parsed.r : void 0;
|
|
507
|
+
if (single !== void 0) {
|
|
508
|
+
const value2 = formatNumber(single);
|
|
509
|
+
if (!value2) return label;
|
|
510
|
+
return label ? `${label}: ${value2}` : value2;
|
|
511
|
+
}
|
|
504
512
|
const values = [];
|
|
505
513
|
if (typeof parsed.x === "number" && Number.isFinite(parsed.x)) {
|
|
506
514
|
values.push(`X: ${formatNumber(parsed.x)}`);
|
package/dist/js/chart.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Moo UI chart.min.js v2.
|
|
2
|
+
* Moo UI chart.min.js v2.1.1 (https://wpmoo.org/)
|
|
3
3
|
* Copyright 2026 WPMoo Authors
|
|
4
4
|
* Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import L from"chart.js/auto";var y=new WeakMap,j=new Map([["area",{chartType:"line",family:"cartesian",fillByDefault:!0,pointRadiusDefault:0}],["line",{chartType:"line",family:"cartesian",fillByDefault:!0}],["bar",{chartType:"bar",family:"cartesian"}],["pie",{chartType:"pie",family:"arc"}],["doughnut",{chartType:"doughnut",family:"arc"}],["polarArea",{chartType:"polarArea",family:"radial"}],["radar",{chartType:"radar",family:"radial"}],["scatter",{chartType:"scatter",family:"point"}],["bubble",{chartType:"bubble",family:"point"}]]),v=Array.from(j.keys()),U=new Set(["__proto__","constructor","prototype"]),g=6,x=g/2,E=5,R=12,G=1.5,V=1.5,B=1,Z=E+B,K="circle",A=g*Math.SQRT2,Q=g+R/2-A-2,S=Symbol("mooChartThemeState"),X=["backgroundColor","borderColor","hoverBackgroundColor","hoverBorderColor","pointBackgroundColor","pointBorderColor","pointHoverBackgroundColor","pointHoverBorderColor"],rr=["--bs-body-color","--bs-body-bg","--bs-secondary-color","--bs-secondary-bg","--bs-tertiary-color","--bs-tertiary-bg","--bs-border-color","--bs-primary","--bs-success","--bs-info","--bs-warning","--bs-danger","--bs-emphasis-color","--bs-info-text-emphasis","--bs-success-text-emphasis","--bs-warning-text-emphasis","--bs-danger-text-emphasis","--moo-chart-1","--moo-chart-2","--moo-chart-3","--moo-chart-4","--moo-chart-5"],w=["primary","success","info","warning","danger"];function N(r,o){let e=o?.getComputedStyle?.(r),t={};return e&&rr.forEach(n=>{t[n]=e.getPropertyValue(n).trim()}),t}function or(r){let o=r?.closest?.("[data-bs-theme]");if(o)return o;let e=r?.ownerDocument?.body;return e?.hasAttribute?.("data-bs-theme")?e:r?.ownerDocument?.documentElement||null}function M(r){return(r?.getAttribute?.("data-bs-theme")||r?.dataset?.bsTheme)==="dark"}function I(r){return Math.min(255,Math.max(0,Math.round(r)))}function er(r){let o=String(r).trim();if(o.endsWith("%")){let t=Number.parseFloat(o.slice(0,-1));return Number.isFinite(t)?I(t/100*255):null}let e=Number.parseFloat(o);return Number.isFinite(e)?I(e*255):null}function tr(r){if(r===void 0)return 1;let o=String(r).trim();if(o.endsWith("%")){let t=Number.parseFloat(o.slice(0,-1));return Number.isFinite(t)?Math.min(1,Math.max(0,t/100)):null}let e=Number.parseFloat(o);return Number.isFinite(e)?Math.min(1,Math.max(0,e)):null}function nr(r){if(typeof r!="string")return null;let o=r.trim(),e=o.match(/^color\(\s*srgb\s+([^\s/]+)\s+([^\s/]+)\s+([^\s/]+)(?:\s*\/\s*([^\s)]+))?\s*\)$/i);if(!e)return o||null;let t=e.slice(1,4).map(er),n=tr(e[4]);return t.some(i=>i===null)||n===null?null:n>=1?"rgb(".concat(t.join(", "),")"):"rgba(".concat(t.join(", "),", ").concat(Number(n.toFixed(3)),")")}function H(r,o,e,t,n){let i=r?.createElement,a=o?.getComputedStyle,u=r?.documentElement;if(!i||!a||!u)return t;let c=i.call(r,"span");if(c.style.color=e,!c.style.color)return t;c.hidden=!0,(n?.appendChild?n:u).appendChild(c);try{let s=a.call(o,c).color;return nr(s)||t}finally{c.remove()}}function P(r,o=!1,e=t=>t){let t={primary:r["--moo-chart-1"]||r["--bs-info"]||r["--bs-info-text-emphasis"],success:r["--moo-chart-2"]||r["--bs-success"],info:r["--moo-chart-3"]||r["--bs-info"],warning:r["--moo-chart-4"]||r["--bs-warning"],danger:r["--moo-chart-5"]||r["--bs-danger"]},n={primary:r["--moo-chart-1"]||r["--bs-info-text-emphasis"]||r["--bs-info"],success:r["--moo-chart-2"]||r["--bs-success-text-emphasis"]||r["--bs-success"],info:r["--moo-chart-3"]||r["--bs-info-text-emphasis"]||r["--bs-info"],warning:r["--moo-chart-4"]||r["--bs-warning-text-emphasis"]||r["--bs-warning"],danger:r["--moo-chart-5"]||r["--bs-danger-text-emphasis"]||r["--bs-danger"]},i=o?n:t;return{color:r["--bs-body-color"],backgroundColor:r["--bs-body-bg"],borderColor:r["--bs-border-color"],gridColor:r["--bs-secondary-color"],tickColor:r["--bs-secondary-color"],textColor:r["--bs-body-color"],secondaryText:r["--bs-secondary-color"],resolveColor:e,...i}}function _(r,o,e=22){return r.resolveColor("color-mix(in srgb, ".concat(o," ").concat(e,"%, transparent)"),o)}function W(r,o){return r.resolveColor("color-mix(in srgb, ".concat(o," 92%, ").concat(r.color,")"),o)}function ir(r,o){return Array.from({length:Math.max(o,1)},(e,t)=>{let n=w[t%w.length];return r[n]})}function z(r){return new Set(X.filter(o=>Object.prototype.hasOwnProperty.call(r,o)))}function Y(r,o=null){return r[S]||Object.defineProperty(r,S,{value:{explicitColorFields:o||z(r)}}),r[S]}function l(r,o,e,t){t.explicitColorFields.has(o)||(r[o]=e)}function sr(){return{pointStyle:K,rotation:0}}function ar(r){let e=r.chart.getDatasetMeta(r.datasetIndex).controller.getStyle(r.dataIndex);return{borderColor:e.borderColor,backgroundColor:e.backgroundColor,borderWidth:B,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderRadius:0}}function lr(r){return L.defaults.plugins.legend.labels.generateLabels(r).map(o=>({...o,lineWidth:B}))}function q(r,o,e,t,n=null){let i=w[o%w.length],a=t[i],u=W(t,a),c=a,d=r.type||e.chartType,s=Y(r,n);if(d==="line")l(r,"borderColor",u,s),l(r,"backgroundColor",_(t,a),s),l(r,"pointBackgroundColor",c,s),l(r,"pointBorderColor",c,s),r.pointBorderWidth=0,r.borderWidth===void 0&&(r.borderWidth=G),r.clip===void 0&&(r.clip=Z),r.pointRadius===void 0&&(r.pointRadius=e.pointRadiusDefault??x),r.pointHoverRadius=E,l(r,"pointHoverBackgroundColor",c,s),l(r,"pointHoverBorderColor",c,s),r.pointHoverBorderWidth=0,r.tension===void 0&&(r.tension=.3),e.fillByDefault&&r.fill===void 0&&(r.fill=!0);else if(d==="bar")l(r,"backgroundColor",t.resolveColor("color-mix(in srgb, ".concat(a," 78%, transparent)"),a),s),l(r,"borderColor",u,s),r.borderWidth===void 0&&(r.borderWidth=1),l(r,"hoverBackgroundColor",a,s),l(r,"hoverBorderColor",a,s),r.borderRadius=4;else if(d==="pie"||d==="doughnut"||d==="polarArea"){let b=ir(t,r.data?.length||0);l(r,"backgroundColor",b.map(m=>_(t,m,78)),s),l(r,"borderColor",b.map(m=>W(t,m)),s),l(r,"hoverBackgroundColor",b,s),l(r,"hoverBorderColor",b,s),r.borderWidth===void 0&&(r.borderWidth=1)}else d==="radar"?(l(r,"borderColor",u,s),l(r,"backgroundColor",_(t,a,18),s),l(r,"pointBackgroundColor",c,s),l(r,"pointBorderColor",c,s),l(r,"pointHoverBackgroundColor",c,s),l(r,"pointHoverBorderColor",c,s),r.borderWidth===void 0&&(r.borderWidth=V),r.pointRadius===void 0&&(r.pointRadius=x),r.pointHoverRadius===void 0&&(r.pointHoverRadius=E),r.pointHoverBorderWidth===void 0&&(r.pointHoverBorderWidth=0),r.fill===void 0&&(r.fill=!0)):(d==="scatter"||d==="bubble")&&(l(r,"backgroundColor",_(t,a,72),s),l(r,"borderColor",u,s),l(r,"hoverBackgroundColor",a,s),l(r,"hoverBorderColor",a,s),r.borderWidth===void 0&&(r.borderWidth=1),d==="scatter"?(r.pointRadius===void 0&&(r.pointRadius=x),r.pointHoverRadius===void 0&&(r.pointHoverRadius=E),r.pointHoverBorderWidth===void 0&&(r.pointHoverBorderWidth=0)):r.pointHoverRadius===void 0&&(r.pointHoverRadius=7));return r}function cr(r,o,e,t=[]){r&&(r.data.datasets.forEach((n,i)=>{q(n,i,e,o,t[i])}),r.options.scales&&Object.values(r.options.scales).forEach(n=>{n.grid&&(n.grid.color=o.resolveColor("color-mix(in srgb, ".concat(o.gridColor," 35%, transparent)"),o.gridColor)),n.ticks&&(n.ticks.color=o.secondaryText),n.title&&(n.title.color=o.textColor),n.angleLines&&(n.angleLines.color=o.resolveColor("color-mix(in srgb, ".concat(o.gridColor," 35%, transparent)"),o.gridColor)),n.pointLabels&&(n.pointLabels.color=o.secondaryText)}),r.options.plugins?.legend?.labels&&(r.options.plugins.legend.labels.color=o.textColor),r.options.plugins?.tooltip&&(r.options.plugins.tooltip.backgroundColor=o.backgroundColor,r.options.plugins.tooltip.titleColor=o.textColor,r.options.plugins.tooltip.bodyColor=o.secondaryText,r.options.plugins.tooltip.borderColor=o.borderColor),r.update())}function O(r){return{color:r.resolveColor("color-mix(in srgb, ".concat(r.gridColor," 35%, transparent)"),r.gridColor)}}function D(r,o={}){return{color:r.secondaryText,padding:8,...o}}function ur(r,o){let e=o.family==="point"?"linear":void 0;return{x:{...e?{type:e}:{},grid:O(r),ticks:D(r),border:{display:!1}},y:{...e?{type:e}:{},grid:O(r),ticks:D(r),border:{display:!1}}}}function dr(r){return{r:{angleLines:{color:r.resolveColor("color-mix(in srgb, ".concat(r.gridColor," 35%, transparent)"),r.gridColor)},grid:O(r),pointLabels:{color:r.secondaryText},ticks:D(r,{backdropColor:"transparent"})}}}function pr(r){return r.family==="point"||r.family==="arc"||r.family==="radial"?{mode:"nearest",intersect:!0}:{mode:"index",intersect:!1}}function hr(r){return!!r?.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches}function T(r){return typeof r=="number"&&Number.isFinite(r)?r.toLocaleString():""}function br(r){let o=r.dataset.label||r.label||"",e=r.parsed,t=r.raw;if(e!==null&&typeof e=="object"){let i=[];return typeof e.x=="number"&&Number.isFinite(e.x)&&i.push("X: ".concat(T(e.x))),typeof e.y=="number"&&Number.isFinite(e.y)&&i.push("Y: ".concat(T(e.y))),t&&typeof t=="object"&&typeof t.r=="number"&&i.push("Radius: ".concat(T(t.r))),i.length?o?"".concat(o,": ").concat(i.join(", ")):i.join(", "):o}let n=T(e);return n?o?"".concat(o,": ").concat(n):n:o}function fr(r,o,e){let t={responsive:!0,maintainAspectRatio:!1,interaction:pr(o),plugins:{legend:{labels:{color:r.textColor,usePointStyle:!0,pointStyle:K,boxWidth:g,boxHeight:g,generateLabels:lr,font:{size:R},padding:20}},tooltip:{backgroundColor:r.backgroundColor,titleColor:r.textColor,bodyColor:r.secondaryText,borderColor:r.borderColor,borderWidth:1,padding:12,cornerRadius:8,titleFont:{size:13,weight:"600"},bodyFont:{size:R},bodySpacing:6,usePointStyle:!0,boxWidth:A,boxHeight:A,boxPadding:Q,callbacks:{label:br,labelColor:ar,labelPointStyle:sr}}},animation:{duration:600,easing:"easeOutQuart"},hover:{animationDuration:200}};return o.family==="cartesian"||o.family==="point"?t.scales=ur(r,o):o.family==="radial"&&(t.scales=dr(r)),hr(e)&&(t.animation=!1,t.hover.animationDuration=0),t}function mr(r,o){let e=r.getAttribute("data-chart-data"),t=null,n=!1;if(e!==null&&e.trim()!==""){n=!0;try{t=JSON.parse(e)}catch(u){throw new SyntaxError("MooChart could not parse data-chart-data as JSON: ".concat(u.message))}}let i=Object.prototype.hasOwnProperty.call(o,"data");if(!i&&!n)throw new TypeError("MooChart data-chart-data is required unless config.data is provided.");let a=i?o.data:t;if(a==null||typeof a!="object"||Array.isArray(a)||!Array.isArray(a.labels)||!Array.isArray(a.datasets)){let u=i?"config.data":"data-chart-data";throw new TypeError("MooChart ".concat(u," must contain labels and datasets arrays."))}return a}function yr(r){let o=r.getAttribute("data-chart-options");if(o===null||o.trim()==="")return{};try{let e=JSON.parse(o);if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("MooChart data-chart-options must be a JSON object.");return e}catch(e){throw e instanceof SyntaxError?new SyntaxError("MooChart could not parse data-chart-options as JSON: ".concat(e.message)):e}}function $(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function gr(r){return Object.entries(r||{}).filter(([o])=>!U.has(o))}function F(r={},o={}){let e={...r};return gr(o).forEach(([t,n])=>{e[t]=$(n)&&$(r[t])?F(r[t],n):n}),e}function Cr(){return v.slice(0,-1).join(", ")+", and "+v[v.length-1]}function _r(r,o){let e=o.type||r.getAttribute("data-chart")||"line",t=j.get(e);if(!t)throw new TypeError("MooChart supports ".concat(Cr(),' charts; received "').concat(e,'".'));return{publicType:e,...t}}var k=class r{static getInstance(o){return o?.nodeType===1&&y.get(o)||null}static getOrCreateInstance(o,e={}){return r.getInstance(o)||new r(o,e)}constructor(o,e={}){if(o?.nodeType!==1||!o.matches(".chart"))throw new TypeError("MooChart requires a .chart root element.");let t=y.get(o);if(t)return t;let n=o.querySelector(":scope > canvas");if(!n)throw new TypeError("MooChart requires a child <canvas> element inside the .chart root.");this._element=o,this._canvas=n,this._document=o.ownerDocument,this._window=this._document?.defaultView,this._config=e||{},this._themeElement=or(o);let i=_r(o,this._config),a=mr(o,this._config),u=yr(o);this._type=i.publicType,this._metadata=i,this._datasetExplicitColorFields=(a.datasets||[]).map(p=>z(p));let c=M(this._themeElement),d=N(this._themeElement,this._window),s=(p,h)=>H(this._document,this._window,p,h,this._themeElement);this._theme=P(d,c,s);let b=(a.datasets||[]).map((p,h)=>q({...p},h,i,this._theme,this._datasetExplicitColorFields[h])),m=F(F(fr(this._theme,i,this._window),u),this._config.options);if(this._chart=new L(n,{...this._config,type:i.chartType,data:{labels:a.labels||[],datasets:b},options:m}),this._chart.data.datasets.forEach((p,h)=>{Y(p,this._datasetExplicitColorFields[h])}),this._rethemeFrame=null,this._observer=null,this._themeElement&&this._window?.MutationObserver){this._observer=new this._window.MutationObserver(f=>{f.forEach(C=>{(C.attributeName==="data-bs-theme"||C.attributeName==="style")&&this._scheduleRetheme()})});let p={attributes:!0,attributeFilter:["data-bs-theme","style"]};[this._themeElement,this._document?.documentElement].filter((f,C,J)=>f&&J.indexOf(f)===C).forEach(f=>{this._observer.observe(f,p)})}y.set(o,this)}get chart(){return this._chart}get element(){return this._element}_scheduleRetheme(){if(this._rethemeFrame!==null)return;let o=this._window?.requestAnimationFrame;if(!o){this._applyTheme();return}this._rethemeFrame=o.call(this._window,()=>{this._rethemeFrame=null,this._applyTheme()})}_applyTheme(){if(!this._chart)return;let o=M(this._themeElement),e=N(this._themeElement,this._window),t=(n,i)=>H(this._document,this._window,n,i,this._themeElement);this._theme=P(e,o,t),cr(this._chart,this._theme,this._metadata,this._datasetExplicitColorFields)}dispose(){this._rethemeFrame!==null&&this._window?.cancelAnimationFrame&&this._window.cancelAnimationFrame(this._rethemeFrame),this._rethemeFrame=null,this._observer?.disconnect(),this._observer=null,this._chart?.destroy(),this._chart=null,y.get(this._element)===this&&y.delete(this._element)}};export{k as default};
|
|
7
|
+
import L from"chart.js/auto";var y=new WeakMap,j=new Map([["area",{chartType:"line",family:"cartesian",fillByDefault:!0,pointRadiusDefault:0}],["line",{chartType:"line",family:"cartesian",fillByDefault:!0}],["bar",{chartType:"bar",family:"cartesian"}],["pie",{chartType:"pie",family:"arc"}],["doughnut",{chartType:"doughnut",family:"arc"}],["polarArea",{chartType:"polarArea",family:"radial"}],["radar",{chartType:"radar",family:"radial"}],["scatter",{chartType:"scatter",family:"point"}],["bubble",{chartType:"bubble",family:"point"}]]),v=Array.from(j.keys()),U=new Set(["__proto__","constructor","prototype"]),C=6,x=C/2,E=5,A=12,G=1.5,V=1.5,B=1,Z=E+B,K="circle",R=C*Math.SQRT2,Q=C+A/2-R-2,S=Symbol("mooChartThemeState"),X=["backgroundColor","borderColor","hoverBackgroundColor","hoverBorderColor","pointBackgroundColor","pointBorderColor","pointHoverBackgroundColor","pointHoverBorderColor"],rr=["--bs-body-color","--bs-body-bg","--bs-secondary-color","--bs-secondary-bg","--bs-tertiary-color","--bs-tertiary-bg","--bs-border-color","--bs-primary","--bs-success","--bs-info","--bs-warning","--bs-danger","--bs-emphasis-color","--bs-info-text-emphasis","--bs-success-text-emphasis","--bs-warning-text-emphasis","--bs-danger-text-emphasis","--moo-chart-1","--moo-chart-2","--moo-chart-3","--moo-chart-4","--moo-chart-5"],w=["primary","success","info","warning","danger"];function M(r,o){let e=o?.getComputedStyle?.(r),t={};return e&&rr.forEach(n=>{t[n]=e.getPropertyValue(n).trim()}),t}function or(r){let o=r?.closest?.("[data-bs-theme]");if(o)return o;let e=r?.ownerDocument?.body;return e?.hasAttribute?.("data-bs-theme")?e:r?.ownerDocument?.documentElement||null}function N(r){return(r?.getAttribute?.("data-bs-theme")||r?.dataset?.bsTheme)==="dark"}function I(r){return Math.min(255,Math.max(0,Math.round(r)))}function er(r){let o=String(r).trim();if(o.endsWith("%")){let t=Number.parseFloat(o.slice(0,-1));return Number.isFinite(t)?I(t/100*255):null}let e=Number.parseFloat(o);return Number.isFinite(e)?I(e*255):null}function tr(r){if(r===void 0)return 1;let o=String(r).trim();if(o.endsWith("%")){let t=Number.parseFloat(o.slice(0,-1));return Number.isFinite(t)?Math.min(1,Math.max(0,t/100)):null}let e=Number.parseFloat(o);return Number.isFinite(e)?Math.min(1,Math.max(0,e)):null}function nr(r){if(typeof r!="string")return null;let o=r.trim(),e=o.match(/^color\(\s*srgb\s+([^\s/]+)\s+([^\s/]+)\s+([^\s/]+)(?:\s*\/\s*([^\s)]+))?\s*\)$/i);if(!e)return o||null;let t=e.slice(1,4).map(er),n=tr(e[4]);return t.some(a=>a===null)||n===null?null:n>=1?"rgb(".concat(t.join(", "),")"):"rgba(".concat(t.join(", "),", ").concat(Number(n.toFixed(3)),")")}function H(r,o,e,t,n){let a=r?.createElement,i=o?.getComputedStyle,u=r?.documentElement;if(!a||!i||!u)return t;let l=a.call(r,"span");if(l.style.color=e,!l.style.color)return t;l.hidden=!0,(n?.appendChild?n:u).appendChild(l);try{let s=i.call(o,l).color;return nr(s)||t}finally{l.remove()}}function P(r,o=!1,e=t=>t){let t={primary:r["--moo-chart-1"]||r["--bs-info"]||r["--bs-info-text-emphasis"],success:r["--moo-chart-2"]||r["--bs-success"],info:r["--moo-chart-3"]||r["--bs-info"],warning:r["--moo-chart-4"]||r["--bs-warning"],danger:r["--moo-chart-5"]||r["--bs-danger"]},n={primary:r["--moo-chart-1"]||r["--bs-info-text-emphasis"]||r["--bs-info"],success:r["--moo-chart-2"]||r["--bs-success-text-emphasis"]||r["--bs-success"],info:r["--moo-chart-3"]||r["--bs-info-text-emphasis"]||r["--bs-info"],warning:r["--moo-chart-4"]||r["--bs-warning-text-emphasis"]||r["--bs-warning"],danger:r["--moo-chart-5"]||r["--bs-danger-text-emphasis"]||r["--bs-danger"]},a=o?n:t;return{color:r["--bs-body-color"],backgroundColor:r["--bs-body-bg"],borderColor:r["--bs-border-color"],gridColor:r["--bs-secondary-color"],tickColor:r["--bs-secondary-color"],textColor:r["--bs-body-color"],secondaryText:r["--bs-secondary-color"],resolveColor:e,...a}}function T(r,o,e=22){return r.resolveColor("color-mix(in srgb, ".concat(o," ").concat(e,"%, transparent)"),o)}function W(r,o){return r.resolveColor("color-mix(in srgb, ".concat(o," 92%, ").concat(r.color,")"),o)}function ir(r,o){return Array.from({length:Math.max(o,1)},(e,t)=>{let n=w[t%w.length];return r[n]})}function z(r){return new Set(X.filter(o=>Object.prototype.hasOwnProperty.call(r,o)))}function Y(r,o=null){return r[S]||Object.defineProperty(r,S,{value:{explicitColorFields:o||z(r)}}),r[S]}function c(r,o,e,t){t.explicitColorFields.has(o)||(r[o]=e)}function sr(){return{pointStyle:K,rotation:0}}function ar(r){let e=r.chart.getDatasetMeta(r.datasetIndex).controller.getStyle(r.dataIndex);return{borderColor:e.borderColor,backgroundColor:e.backgroundColor,borderWidth:B,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderRadius:0}}function lr(r){return L.defaults.plugins.legend.labels.generateLabels(r).map(o=>({...o,lineWidth:B}))}function q(r,o,e,t,n=null){let a=w[o%w.length],i=t[a],u=W(t,i),l=i,d=r.type||e.chartType,s=Y(r,n);if(d==="line")c(r,"borderColor",u,s),c(r,"backgroundColor",T(t,i),s),c(r,"pointBackgroundColor",l,s),c(r,"pointBorderColor",l,s),r.pointBorderWidth=0,r.borderWidth===void 0&&(r.borderWidth=G),r.clip===void 0&&(r.clip=Z),r.pointRadius===void 0&&(r.pointRadius=e.pointRadiusDefault??x),r.pointHoverRadius=E,c(r,"pointHoverBackgroundColor",l,s),c(r,"pointHoverBorderColor",l,s),r.pointHoverBorderWidth=0,r.tension===void 0&&(r.tension=.3),e.fillByDefault&&r.fill===void 0&&(r.fill=!0);else if(d==="bar")c(r,"backgroundColor",t.resolveColor("color-mix(in srgb, ".concat(i," 78%, transparent)"),i),s),c(r,"borderColor",u,s),r.borderWidth===void 0&&(r.borderWidth=1),c(r,"hoverBackgroundColor",i,s),c(r,"hoverBorderColor",i,s),r.borderRadius=4;else if(d==="pie"||d==="doughnut"||d==="polarArea"){let f=ir(t,r.data?.length||0);c(r,"backgroundColor",f.map(m=>T(t,m,78)),s),c(r,"borderColor",f.map(m=>W(t,m)),s),c(r,"hoverBackgroundColor",f,s),c(r,"hoverBorderColor",f,s),r.borderWidth===void 0&&(r.borderWidth=1)}else d==="radar"?(c(r,"borderColor",u,s),c(r,"backgroundColor",T(t,i,18),s),c(r,"pointBackgroundColor",l,s),c(r,"pointBorderColor",l,s),c(r,"pointHoverBackgroundColor",l,s),c(r,"pointHoverBorderColor",l,s),r.borderWidth===void 0&&(r.borderWidth=V),r.pointRadius===void 0&&(r.pointRadius=x),r.pointHoverRadius===void 0&&(r.pointHoverRadius=E),r.pointHoverBorderWidth===void 0&&(r.pointHoverBorderWidth=0),r.fill===void 0&&(r.fill=!0)):(d==="scatter"||d==="bubble")&&(c(r,"backgroundColor",T(t,i,72),s),c(r,"borderColor",u,s),c(r,"hoverBackgroundColor",i,s),c(r,"hoverBorderColor",i,s),r.borderWidth===void 0&&(r.borderWidth=1),d==="scatter"?(r.pointRadius===void 0&&(r.pointRadius=x),r.pointHoverRadius===void 0&&(r.pointHoverRadius=E),r.pointHoverBorderWidth===void 0&&(r.pointHoverBorderWidth=0)):r.pointHoverRadius===void 0&&(r.pointHoverRadius=7));return r}function cr(r,o,e,t=[]){r&&(r.data.datasets.forEach((n,a)=>{q(n,a,e,o,t[a])}),r.options.scales&&Object.values(r.options.scales).forEach(n=>{n.grid&&(n.grid.color=o.resolveColor("color-mix(in srgb, ".concat(o.gridColor," 35%, transparent)"),o.gridColor)),n.ticks&&(n.ticks.color=o.secondaryText),n.title&&(n.title.color=o.textColor),n.angleLines&&(n.angleLines.color=o.resolveColor("color-mix(in srgb, ".concat(o.gridColor," 35%, transparent)"),o.gridColor)),n.pointLabels&&(n.pointLabels.color=o.secondaryText)}),r.options.plugins?.legend?.labels&&(r.options.plugins.legend.labels.color=o.textColor),r.options.plugins?.tooltip&&(r.options.plugins.tooltip.backgroundColor=o.backgroundColor,r.options.plugins.tooltip.titleColor=o.textColor,r.options.plugins.tooltip.bodyColor=o.secondaryText,r.options.plugins.tooltip.borderColor=o.borderColor),r.update())}function O(r){return{color:r.resolveColor("color-mix(in srgb, ".concat(r.gridColor," 35%, transparent)"),r.gridColor)}}function D(r,o={}){return{color:r.secondaryText,padding:8,...o}}function ur(r,o){let e=o.family==="point"?"linear":void 0;return{x:{...e?{type:e}:{},grid:O(r),ticks:D(r),border:{display:!1}},y:{...e?{type:e}:{},grid:O(r),ticks:D(r),border:{display:!1}}}}function dr(r){return{r:{angleLines:{color:r.resolveColor("color-mix(in srgb, ".concat(r.gridColor," 35%, transparent)"),r.gridColor)},grid:O(r),pointLabels:{color:r.secondaryText},ticks:D(r,{backdropColor:"transparent"})}}}function pr(r){return r.family==="point"||r.family==="arc"||r.family==="radial"?{mode:"nearest",intersect:!0}:{mode:"index",intersect:!1}}function hr(r){return!!r?.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches}function g(r){return typeof r=="number"&&Number.isFinite(r)?r.toLocaleString():""}function fr(r){let o=r.dataset.label||r.label||"",e=r.parsed,t=r.raw;if(e!==null&&typeof e=="object"){let a=r.chart?.getDatasetMeta?.(r.datasetIndex),i=a?.iScale?.type==="category"?a.vScale?.axis:null,u=i?e[i]:typeof e.r=="number"&&e.x===void 0?e.r:void 0;if(u!==void 0){let d=g(u);return d?o?"".concat(o,": ").concat(d):d:o}let l=[];return typeof e.x=="number"&&Number.isFinite(e.x)&&l.push("X: ".concat(g(e.x))),typeof e.y=="number"&&Number.isFinite(e.y)&&l.push("Y: ".concat(g(e.y))),t&&typeof t=="object"&&typeof t.r=="number"&&l.push("Radius: ".concat(g(t.r))),l.length?o?"".concat(o,": ").concat(l.join(", ")):l.join(", "):o}let n=g(e);return n?o?"".concat(o,": ").concat(n):n:o}function br(r,o,e){let t={responsive:!0,maintainAspectRatio:!1,interaction:pr(o),plugins:{legend:{labels:{color:r.textColor,usePointStyle:!0,pointStyle:K,boxWidth:C,boxHeight:C,generateLabels:lr,font:{size:A},padding:20}},tooltip:{backgroundColor:r.backgroundColor,titleColor:r.textColor,bodyColor:r.secondaryText,borderColor:r.borderColor,borderWidth:1,padding:12,cornerRadius:8,titleFont:{size:13,weight:"600"},bodyFont:{size:A},bodySpacing:6,usePointStyle:!0,boxWidth:R,boxHeight:R,boxPadding:Q,callbacks:{label:fr,labelColor:ar,labelPointStyle:sr}}},animation:{duration:600,easing:"easeOutQuart"},hover:{animationDuration:200}};return o.family==="cartesian"||o.family==="point"?t.scales=ur(r,o):o.family==="radial"&&(t.scales=dr(r)),hr(e)&&(t.animation=!1,t.hover.animationDuration=0),t}function mr(r,o){let e=r.getAttribute("data-chart-data"),t=null,n=!1;if(e!==null&&e.trim()!==""){n=!0;try{t=JSON.parse(e)}catch(u){throw new SyntaxError("MooChart could not parse data-chart-data as JSON: ".concat(u.message))}}let a=Object.prototype.hasOwnProperty.call(o,"data");if(!a&&!n)throw new TypeError("MooChart data-chart-data is required unless config.data is provided.");let i=a?o.data:t;if(i==null||typeof i!="object"||Array.isArray(i)||!Array.isArray(i.labels)||!Array.isArray(i.datasets)){let u=a?"config.data":"data-chart-data";throw new TypeError("MooChart ".concat(u," must contain labels and datasets arrays."))}return i}function yr(r){let o=r.getAttribute("data-chart-options");if(o===null||o.trim()==="")return{};try{let e=JSON.parse(o);if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("MooChart data-chart-options must be a JSON object.");return e}catch(e){throw e instanceof SyntaxError?new SyntaxError("MooChart could not parse data-chart-options as JSON: ".concat(e.message)):e}}function $(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function gr(r){return Object.entries(r||{}).filter(([o])=>!U.has(o))}function F(r={},o={}){let e={...r};return gr(o).forEach(([t,n])=>{e[t]=$(n)&&$(r[t])?F(r[t],n):n}),e}function Cr(){return v.slice(0,-1).join(", ")+", and "+v[v.length-1]}function _r(r,o){let e=o.type||r.getAttribute("data-chart")||"line",t=j.get(e);if(!t)throw new TypeError("MooChart supports ".concat(Cr(),' charts; received "').concat(e,'".'));return{publicType:e,...t}}var k=class r{static getInstance(o){return o?.nodeType===1&&y.get(o)||null}static getOrCreateInstance(o,e={}){return r.getInstance(o)||new r(o,e)}constructor(o,e={}){if(o?.nodeType!==1||!o.matches(".chart"))throw new TypeError("MooChart requires a .chart root element.");let t=y.get(o);if(t)return t;let n=o.querySelector(":scope > canvas");if(!n)throw new TypeError("MooChart requires a child <canvas> element inside the .chart root.");this._element=o,this._canvas=n,this._document=o.ownerDocument,this._window=this._document?.defaultView,this._config=e||{},this._themeElement=or(o);let a=_r(o,this._config),i=mr(o,this._config),u=yr(o);this._type=a.publicType,this._metadata=a,this._datasetExplicitColorFields=(i.datasets||[]).map(p=>z(p));let l=N(this._themeElement),d=M(this._themeElement,this._window),s=(p,h)=>H(this._document,this._window,p,h,this._themeElement);this._theme=P(d,l,s);let f=(i.datasets||[]).map((p,h)=>q({...p},h,a,this._theme,this._datasetExplicitColorFields[h])),m=F(F(br(this._theme,a,this._window),u),this._config.options);if(this._chart=new L(n,{...this._config,type:a.chartType,data:{labels:i.labels||[],datasets:f},options:m}),this._chart.data.datasets.forEach((p,h)=>{Y(p,this._datasetExplicitColorFields[h])}),this._rethemeFrame=null,this._observer=null,this._themeElement&&this._window?.MutationObserver){this._observer=new this._window.MutationObserver(b=>{b.forEach(_=>{(_.attributeName==="data-bs-theme"||_.attributeName==="style")&&this._scheduleRetheme()})});let p={attributes:!0,attributeFilter:["data-bs-theme","style"]};[this._themeElement,this._document?.documentElement].filter((b,_,J)=>b&&J.indexOf(b)===_).forEach(b=>{this._observer.observe(b,p)})}y.set(o,this)}get chart(){return this._chart}get element(){return this._element}_scheduleRetheme(){if(this._rethemeFrame!==null)return;let o=this._window?.requestAnimationFrame;if(!o){this._applyTheme();return}this._rethemeFrame=o.call(this._window,()=>{this._rethemeFrame=null,this._applyTheme()})}_applyTheme(){if(!this._chart)return;let o=N(this._themeElement),e=M(this._themeElement,this._window),t=(n,a)=>H(this._document,this._window,n,a,this._themeElement);this._theme=P(e,o,t),cr(this._chart,this._theme,this._metadata,this._datasetExplicitColorFields)}dispose(){this._rethemeFrame!==null&&this._window?.cancelAnimationFrame&&this._window.cancelAnimationFrame(this._rethemeFrame),this._rethemeFrame=null,this._observer?.disconnect(),this._observer=null,this._chart?.destroy(),this._chart=null,y.get(this._element)===this&&y.delete(this._element)}};export{k as default};
|
package/dist/js/combobox.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Moo UI combobox.js v2.
|
|
2
|
+
* Moo UI combobox.js v2.1.1 (https://wpmoo.org/)
|
|
3
3
|
* Copyright 2026 WPMoo Authors
|
|
4
4
|
* Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
@@ -246,11 +246,7 @@ class Combobox {
|
|
|
246
246
|
_clearStaleSelection() {
|
|
247
247
|
if (this._isMultiple) {
|
|
248
248
|
this._input.value = "";
|
|
249
|
-
this.
|
|
250
|
-
option.hidden = false;
|
|
251
|
-
});
|
|
252
|
-
this._syncGroupVisibility();
|
|
253
|
-
this._empty.hidden = true;
|
|
249
|
+
this._showAllOptions();
|
|
254
250
|
return;
|
|
255
251
|
}
|
|
256
252
|
const selected = this._selectedOptions()[0] || null;
|
|
@@ -261,6 +257,14 @@ class Combobox {
|
|
|
261
257
|
this._clearSelection();
|
|
262
258
|
this._input.value = "";
|
|
263
259
|
}
|
|
260
|
+
_showAllOptions() {
|
|
261
|
+
this._options.forEach((option) => {
|
|
262
|
+
option.hidden = false;
|
|
263
|
+
});
|
|
264
|
+
this._syncGroupVisibility();
|
|
265
|
+
this._empty.hidden = true;
|
|
266
|
+
this._liveRegion.textContent = "";
|
|
267
|
+
}
|
|
264
268
|
_activeOption() {
|
|
265
269
|
const activeId = this._input.getAttribute("aria-activedescendant");
|
|
266
270
|
if (!activeId) {
|
|
@@ -347,6 +351,7 @@ class Combobox {
|
|
|
347
351
|
if (this._hidden) {
|
|
348
352
|
this._hidden.value = option.dataset.value || "";
|
|
349
353
|
}
|
|
354
|
+
this._showAllOptions();
|
|
350
355
|
this._toggleClear(true);
|
|
351
356
|
this._setActiveOption(option);
|
|
352
357
|
this._emitChange();
|
|
@@ -439,6 +444,12 @@ class Combobox {
|
|
|
439
444
|
}
|
|
440
445
|
}
|
|
441
446
|
_handleKeydown(event) {
|
|
447
|
+
if (event.isComposing || event.keyCode === 229) {
|
|
448
|
+
if (event.key === "Tab") {
|
|
449
|
+
this._closeMenu();
|
|
450
|
+
}
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
442
453
|
const available = this._visibleOptions();
|
|
443
454
|
const current = available.findIndex(
|
|
444
455
|
(option) => option.id === this._input.getAttribute("aria-activedescendant")
|
package/dist/js/context-menu.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Moo UI context-menu.js v2.
|
|
2
|
+
* Moo UI context-menu.js v2.1.1 (https://wpmoo.org/)
|
|
3
3
|
* Copyright 2026 WPMoo Authors
|
|
4
4
|
* Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
@@ -67,12 +67,17 @@ class ContextMenu {
|
|
|
67
67
|
this._bindEvents();
|
|
68
68
|
}
|
|
69
69
|
dispose() {
|
|
70
|
+
if (this._disposing) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this._disposing = true;
|
|
70
74
|
this._listeners.forEach(({ target, type, handler, options }) => {
|
|
71
75
|
target.removeEventListener(type, handler, options);
|
|
72
76
|
});
|
|
73
77
|
this._listeners = [];
|
|
74
|
-
this._dropdown.dispose();
|
|
75
78
|
this._syncExpanded(false);
|
|
79
|
+
this._dropdown.hide();
|
|
80
|
+
this._dropdown.dispose();
|
|
76
81
|
this._invoker = null;
|
|
77
82
|
this._pointerRect = null;
|
|
78
83
|
instances.delete(this._element);
|
|
@@ -184,7 +189,7 @@ class ContextMenu {
|
|
|
184
189
|
event.preventDefault();
|
|
185
190
|
event.stopPropagation();
|
|
186
191
|
const group = radioButton.dataset.contextMenuRadioGroup;
|
|
187
|
-
this._menu.querySelectorAll(`[data-context-menu-radio-group="${group}"]`).forEach((button) => {
|
|
192
|
+
this._menu.querySelectorAll(`[data-context-menu-radio-group="${CSS.escape(String(group))}"]`).forEach((button) => {
|
|
188
193
|
const checked = button === radioButton;
|
|
189
194
|
button.classList.toggle("active", checked);
|
|
190
195
|
button.setAttribute("aria-pressed", String(checked));
|
package/dist/js/datatable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Moo UI datatable.js v2.
|
|
2
|
+
* Moo UI datatable.js v2.1.1 (https://wpmoo.org/)
|
|
3
3
|
* Copyright 2026 WPMoo Authors
|
|
4
4
|
* Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
@@ -45,10 +45,34 @@ __name(ownerPortalRoot, "ownerPortalRoot");
|
|
|
45
45
|
|
|
46
46
|
// src/js/components/datatable.js
|
|
47
47
|
var instances = /* @__PURE__ */ new WeakMap();
|
|
48
|
+
var SORT_COLLATOR = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
|
|
49
|
+
var PLAIN_NUMBER = /^[-+]?(?:\d+\.?\d*|\.\d+)$/;
|
|
50
|
+
function sortNumber(value) {
|
|
51
|
+
return PLAIN_NUMBER.test(value) ? Number(value) : null;
|
|
52
|
+
}
|
|
53
|
+
__name(sortNumber, "sortNumber");
|
|
54
|
+
function compareSortValues(a, b) {
|
|
55
|
+
const aNumber = sortNumber(a);
|
|
56
|
+
const bNumber = sortNumber(b);
|
|
57
|
+
if (aNumber !== null && bNumber !== null) {
|
|
58
|
+
return Math.sign(aNumber - bNumber);
|
|
59
|
+
}
|
|
60
|
+
if (aNumber !== null || bNumber !== null) {
|
|
61
|
+
return aNumber !== null ? -1 : 1;
|
|
62
|
+
}
|
|
63
|
+
return SORT_COLLATOR.compare(a, b);
|
|
64
|
+
}
|
|
65
|
+
__name(compareSortValues, "compareSortValues");
|
|
48
66
|
function normalize(value) {
|
|
49
67
|
return (value ?? "").toString().trim().toLowerCase();
|
|
50
68
|
}
|
|
51
69
|
__name(normalize, "normalize");
|
|
70
|
+
var ESCAPE_OWNER_SELECTOR = ".modal, .offcanvas, .dropdown-menu, .popover, [role='dialog'], [role='menu'], [role='listbox']";
|
|
71
|
+
function escapeBelongsElsewhere(event) {
|
|
72
|
+
const target = event.target;
|
|
73
|
+
return typeof target?.closest === "function" && (Boolean(target.closest(ESCAPE_OWNER_SELECTOR)) || target.getAttribute("aria-expanded") === "true");
|
|
74
|
+
}
|
|
75
|
+
__name(escapeBelongsElsewhere, "escapeBelongsElsewhere");
|
|
52
76
|
var _DataTable = class _DataTable {
|
|
53
77
|
static getInstance(element) {
|
|
54
78
|
return element?.nodeType === 1 ? instances.get(element) || null : null;
|
|
@@ -498,7 +522,7 @@ var _DataTable = class _DataTable {
|
|
|
498
522
|
);
|
|
499
523
|
}
|
|
500
524
|
_sortValue(row, key) {
|
|
501
|
-
const cell = row.element.querySelector(`:scope > [data-datatable-column="${key}"]`);
|
|
525
|
+
const cell = row.element.querySelector(`:scope > [data-datatable-column="${CSS.escape(String(key))}"]`);
|
|
502
526
|
if (!cell) {
|
|
503
527
|
return "";
|
|
504
528
|
}
|
|
@@ -525,10 +549,8 @@ var _DataTable = class _DataTable {
|
|
|
525
549
|
filtered.sort((a, b) => {
|
|
526
550
|
const aValue = this._sortValue(a, this._sortKey);
|
|
527
551
|
const bValue = this._sortValue(b, this._sortKey);
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
return aValue > bValue ? direction : -direction;
|
|
552
|
+
const order = compareSortValues(aValue, bValue);
|
|
553
|
+
return order ? order * direction : a.index - b.index;
|
|
532
554
|
});
|
|
533
555
|
} else {
|
|
534
556
|
filtered.sort((a, b) => a.index - b.index);
|
|
@@ -595,7 +617,7 @@ var _DataTable = class _DataTable {
|
|
|
595
617
|
summary.appendChild(this._createFacetBadge(`${selected.size} selected`));
|
|
596
618
|
} else {
|
|
597
619
|
selected.forEach((value) => {
|
|
598
|
-
const option = facetRoot.querySelector(`[data-datatable-facet-option="${value}"]`);
|
|
620
|
+
const option = facetRoot.querySelector(`[data-datatable-facet-option="${CSS.escape(String(value))}"]`);
|
|
599
621
|
const label = option?.querySelector("[data-datatable-facet-option-label]")?.textContent ?? value;
|
|
600
622
|
summary.appendChild(this._createFacetBadge(label));
|
|
601
623
|
});
|
|
@@ -824,17 +846,17 @@ var _DataTable = class _DataTable {
|
|
|
824
846
|
return withEllipsis;
|
|
825
847
|
}
|
|
826
848
|
_isColumnFixed(key) {
|
|
827
|
-
return this._element.querySelector(`th[data-datatable-column="${key}"]`)?.hasAttribute("data-datatable-column-fixed") || false;
|
|
849
|
+
return this._element.querySelector(`th[data-datatable-column="${CSS.escape(String(key))}"]`)?.hasAttribute("data-datatable-column-fixed") || false;
|
|
828
850
|
}
|
|
829
851
|
_setColumnVisible(key, visible, { syncViewToggle = true } = {}) {
|
|
830
852
|
if (!visible && this._isColumnFixed(key)) {
|
|
831
853
|
return;
|
|
832
854
|
}
|
|
833
|
-
this._element.querySelectorAll(`[data-datatable-column="${key}"], [data-datatable-detail-column="${key}"]`).forEach((cell) => {
|
|
855
|
+
this._element.querySelectorAll(`[data-datatable-column="${CSS.escape(String(key))}"], [data-datatable-detail-column="${CSS.escape(String(key))}"]`).forEach((cell) => {
|
|
834
856
|
cell.classList.toggle("datatable-col-hidden", !visible);
|
|
835
857
|
});
|
|
836
858
|
if (syncViewToggle) {
|
|
837
|
-
this._element.querySelectorAll(`[data-datatable-column-toggle="${key}"]`).forEach((toggle) => {
|
|
859
|
+
this._element.querySelectorAll(`[data-datatable-column-toggle="${CSS.escape(String(key))}"]`).forEach((toggle) => {
|
|
838
860
|
toggle.classList.toggle("active", visible);
|
|
839
861
|
toggle.setAttribute("aria-pressed", String(visible));
|
|
840
862
|
});
|
|
@@ -971,8 +993,8 @@ var _DataTable = class _DataTable {
|
|
|
971
993
|
if (group) {
|
|
972
994
|
const key = group.dataset.datatableFilterGroup;
|
|
973
995
|
this._showFilterPickerPanel(key);
|
|
974
|
-
const search = this._element.querySelector(`[data-datatable-filter-option-search="${key}"]`);
|
|
975
|
-
const option = this._element.querySelector(`[data-datatable-filter-option-key="${key}"]`);
|
|
996
|
+
const search = this._element.querySelector(`[data-datatable-filter-option-search="${CSS.escape(String(key))}"]`);
|
|
997
|
+
const option = this._element.querySelector(`[data-datatable-filter-option-key="${CSS.escape(String(key))}"]`);
|
|
976
998
|
(search || option)?.focus({ preventScroll: true });
|
|
977
999
|
return;
|
|
978
1000
|
}
|
|
@@ -987,7 +1009,7 @@ var _DataTable = class _DataTable {
|
|
|
987
1009
|
}
|
|
988
1010
|
const key = search.dataset.datatableFilterOptionSearch;
|
|
989
1011
|
const query = normalize(search.value);
|
|
990
|
-
this._element.querySelectorAll(`[data-datatable-filter-option-key="${key}"]`).forEach((option) => {
|
|
1012
|
+
this._element.querySelectorAll(`[data-datatable-filter-option-key="${CSS.escape(String(key))}"]`).forEach((option) => {
|
|
991
1013
|
const label = normalize(option.querySelector("[data-datatable-filter-option-label]")?.textContent || option.textContent);
|
|
992
1014
|
option.closest("li")?.classList.toggle("datatable-filter-option-search-hidden", query.length > 0 && !label.includes(query));
|
|
993
1015
|
});
|
|
@@ -1004,7 +1026,7 @@ var _DataTable = class _DataTable {
|
|
|
1004
1026
|
}
|
|
1005
1027
|
const key = search.dataset.datatableFilterOptionSearch;
|
|
1006
1028
|
const options = Array.from(
|
|
1007
|
-
this._element.querySelectorAll(`[data-datatable-filter-option-key="${key}"]`)
|
|
1029
|
+
this._element.querySelectorAll(`[data-datatable-filter-option-key="${CSS.escape(String(key))}"]`)
|
|
1008
1030
|
);
|
|
1009
1031
|
const firstVisible = options.find(
|
|
1010
1032
|
(option) => !option.closest("li")?.classList.contains("datatable-filter-option-search-hidden")
|
|
@@ -1129,7 +1151,7 @@ var _DataTable = class _DataTable {
|
|
|
1129
1151
|
}
|
|
1130
1152
|
row.element.setAttribute(`data-datatable-facet-${key}`, value);
|
|
1131
1153
|
row.facets[key] = value;
|
|
1132
|
-
const cell = row.element.querySelector(`[data-datatable-column="${key}"]`);
|
|
1154
|
+
const cell = row.element.querySelector(`[data-datatable-column="${CSS.escape(String(key))}"]`);
|
|
1133
1155
|
if (!cell) {
|
|
1134
1156
|
return;
|
|
1135
1157
|
}
|
|
@@ -1143,7 +1165,7 @@ var _DataTable = class _DataTable {
|
|
|
1143
1165
|
if (currentIcon && icon) {
|
|
1144
1166
|
currentIcon.replaceWith(icon.cloneNode(true));
|
|
1145
1167
|
}
|
|
1146
|
-
const cardValue = row.cardElement?.querySelector(`[data-datatable-detail-column="${key}"] .datatable-card-value`);
|
|
1168
|
+
const cardValue = row.cardElement?.querySelector(`[data-datatable-detail-column="${CSS.escape(String(key))}"] .datatable-card-value`);
|
|
1147
1169
|
if (cardValue) {
|
|
1148
1170
|
cardValue.innerHTML = cell.innerHTML;
|
|
1149
1171
|
}
|
|
@@ -1237,11 +1259,11 @@ var _DataTable = class _DataTable {
|
|
|
1237
1259
|
}
|
|
1238
1260
|
});
|
|
1239
1261
|
this._listen(this._document, "click", (event) => this._handleSortAction(event));
|
|
1240
|
-
this._listen(this.
|
|
1241
|
-
if (event.key === "Escape" && this._selectedIds.size > 0) {
|
|
1262
|
+
this._listen(this._window, "keydown", (event) => {
|
|
1263
|
+
if (event.key === "Escape" && this._selectedIds.size > 0 && !escapeBelongsElsewhere(event)) {
|
|
1242
1264
|
this._clearSelection();
|
|
1243
1265
|
}
|
|
1244
|
-
});
|
|
1266
|
+
}, { capture: true });
|
|
1245
1267
|
this._listen(this._element, "show.bs.dropdown", (event) => {
|
|
1246
1268
|
this._reparentRowActionMenu(event.target);
|
|
1247
1269
|
this._reparentSortMenu(event.target);
|
package/dist/js/datepicker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Moo UI datepicker.js v2.
|
|
2
|
+
* Moo UI datepicker.js v2.1.1 (https://wpmoo.org/)
|
|
3
3
|
* Copyright 2026 WPMoo Authors
|
|
4
4
|
* Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
@@ -193,6 +193,15 @@ function dispatch(element, window2, name, detail = {}, cancelable = false) {
|
|
|
193
193
|
})
|
|
194
194
|
);
|
|
195
195
|
}
|
|
196
|
+
function formDefaultValue(input) {
|
|
197
|
+
if (!input) {
|
|
198
|
+
return "";
|
|
199
|
+
}
|
|
200
|
+
if (!("datepickerFormDefault" in input.dataset)) {
|
|
201
|
+
input.dataset.datepickerFormDefault = input.getAttribute("value") || "";
|
|
202
|
+
}
|
|
203
|
+
return input.dataset.datepickerFormDefault;
|
|
204
|
+
}
|
|
196
205
|
function setHiddenValue(input, value) {
|
|
197
206
|
if (!input) return;
|
|
198
207
|
input.value = value || "";
|
|
@@ -596,6 +605,7 @@ var MooCalendar = class _MooCalendar {
|
|
|
596
605
|
ArrowUp: -7
|
|
597
606
|
};
|
|
598
607
|
let nextDate = null;
|
|
608
|
+
let stepTowardActive = false;
|
|
599
609
|
if (event.key in keyMap) {
|
|
600
610
|
nextDate = addDays(this._activeDate, keyMap[event.key]);
|
|
601
611
|
} else if (event.key === "Home") {
|
|
@@ -606,10 +616,13 @@ var MooCalendar = class _MooCalendar {
|
|
|
606
616
|
const weekStart = firstDayOfWeek(this._config.locale);
|
|
607
617
|
const weekdayOffset = (this._activeDate.getDay() - weekStart + 7) % 7;
|
|
608
618
|
nextDate = addDays(this._activeDate, 6 - weekdayOffset);
|
|
609
|
-
} else if (event.key === "PageUp") {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
nextDate =
|
|
619
|
+
} else if (event.key === "PageUp" || event.key === "PageDown") {
|
|
620
|
+
const target = addMonths(this._activeDate, event.key === "PageUp" ? -1 : 1);
|
|
621
|
+
const { minDate, maxDate } = this._config;
|
|
622
|
+
nextDate = limitToRange(target, minDate, maxDate);
|
|
623
|
+
stepTowardActive = [minDate, maxDate].some(
|
|
624
|
+
(edge) => edge && compareDates(nextDate, edge) === 0
|
|
625
|
+
);
|
|
613
626
|
} else if (event.key === "Enter" || event.key === " " || event.key === "Spacebar") {
|
|
614
627
|
event.preventDefault();
|
|
615
628
|
this._selectDate(this._activeDate, true);
|
|
@@ -618,7 +631,8 @@ var MooCalendar = class _MooCalendar {
|
|
|
618
631
|
return;
|
|
619
632
|
}
|
|
620
633
|
event.preventDefault();
|
|
621
|
-
|
|
634
|
+
const backward = compareDates(nextDate, this._activeDate) < 0;
|
|
635
|
+
this._setActiveDate(nextDate, true, backward !== stepTowardActive ? -1 : 1);
|
|
622
636
|
}
|
|
623
637
|
_setActiveDate(date, focus = false, step = 0) {
|
|
624
638
|
const nextDate = step === 0 ? this._nearestEnabledDate(date) : this._nextEnabledDate(date, step);
|
|
@@ -884,7 +898,7 @@ var MooDatepicker = class _MooDatepicker {
|
|
|
884
898
|
value: config.value || this._input.value || element.dataset.datepickerValue
|
|
885
899
|
});
|
|
886
900
|
this._placeholder = this._config.placeholder;
|
|
887
|
-
this._defaultValue = this._input
|
|
901
|
+
this._defaultValue = formDefaultValue(this._input);
|
|
888
902
|
this.calendar = MooCalendar.getOrCreateInstance(this._calendarRoot, {
|
|
889
903
|
...this._config,
|
|
890
904
|
mode: "single",
|
|
@@ -1049,8 +1063,8 @@ var MooDateRangePicker = class _MooDateRangePicker {
|
|
|
1049
1063
|
endValue: config.endValue || this._endInput.value || element.dataset.datepickerEndValue
|
|
1050
1064
|
});
|
|
1051
1065
|
this._placeholder = this._config.placeholder;
|
|
1052
|
-
this._defaultStartValue = this._startInput
|
|
1053
|
-
this._defaultEndValue = this._endInput
|
|
1066
|
+
this._defaultStartValue = formDefaultValue(this._startInput);
|
|
1067
|
+
this._defaultEndValue = formDefaultValue(this._endInput);
|
|
1054
1068
|
this.calendar = MooCalendar.getOrCreateInstance(this._calendarRoot, this._config);
|
|
1055
1069
|
rangePickerInstances.set(element, this);
|
|
1056
1070
|
this._syncFromCalendar();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Moo UI datepicker.min.js v2.
|
|
2
|
+
* Moo UI datepicker.min.js v2.1.1 (https://wpmoo.org/)
|
|
3
3
|
* Copyright 2026 WPMoo Authors
|
|
4
4
|
* Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
var Q='.moo-ui[data-bs-theme="light"], .moo-ui[data-bs-theme="dark"]',lt="[data-moo-overlay-host]";function dt(e){return e?.nodeType===9?e:e?.ownerDocument?e.ownerDocument:typeof document>"u"?null:document}function ct(e){return!!e?.matches?.(Q)}function ht(e){let t=dt(e);return e?.nodeType===9||e===t?.body?t?.body?.firstElementChild||null:e}function q(e=typeof document>"u"?null:document){let t=ht(e);return t?ct(t)?t:t.closest?.(Q)||null:null}function X(e){return e?Array.from(e.children||[]).find(t=>t.matches?.(lt))||e:null}var I=new WeakMap,V=new WeakMap,M=new WeakMap,y="en",Et=1440*60*1e3,ut=new Date(2026,7,16),C=8;function z(e,t){return e?.nodeType===1&&!!e.matches?.(t)}function c(e,t,i,a,n){t&&(t.addEventListener(i,a,n),e.push({target:t,type:i,handler:a,options:n}))}function E(e){e.forEach(({target:t,type:i,handler:a,options:n})=>{t.removeEventListener(i,a,n)}),e.length=0}function d(e){if(!e)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:new Date(e.getFullYear(),e.getMonth(),e.getDate());if(typeof e=="number")return d(new Date(e));let t=String(e).trim(),i=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(i){let a=new Date(Number(i[1]),Number(i[2])-1,Number(i[3]));return a.getFullYear()===Number(i[1])&&a.getMonth()===Number(i[2])-1&&a.getDate()===Number(i[3])?a:null}return null}function Z(e){return String(e).padStart(2,"0")}function f(e){return"".concat(e.getFullYear(),"-").concat(Z(e.getMonth()+1),"-").concat(Z(e.getDate()))}function m(e,t){return!e||!t?0:e.getTime()-t.getTime()}function k(e,t){return!!(e&&t&&f(e)===f(t))}function b(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function B(e,t){let i=new Date(e.getFullYear(),e.getMonth()+t,1),a=Math.min(e.getDate(),W(i.getFullYear(),i.getMonth()));return new Date(i.getFullYear(),i.getMonth(),a)}function T(e=y){try{if(typeof Intl<"u"&&typeof Intl.Locale=="function"){let t=new Intl.Locale(e||y),i=t.weekInfo||t.getWeekInfo?.();if(Number.isInteger(i?.firstDay))return i.firstDay%7}}catch{}return 0}function _t(e=y){let t=T(e);return Array.from({length:7},(i,a)=>b(ut,(t+a)%7))}function w(e){return new Date(e.getFullYear(),e.getMonth(),1)}function W(e,t){return new Date(e,t+1,0).getDate()}function ft(e,t,i){return t&&m(e,t)<0?new Date(t):i&&m(e,i)>0?new Date(i):e}function pt(e){if(Array.isArray(e))return e.map(d).filter(Boolean).map(f);if(!e)return[];let t=String(e).trim();if(!t)return[];try{let i=JSON.parse(t);if(Array.isArray(i))return i.map(d).filter(Boolean).map(f)}catch{}return t.split(",").map(d).filter(Boolean).map(f)}function x(e,t=y){return e?new Intl.DateTimeFormat(t||y,{month:"short",day:"numeric",year:"numeric"}).format(e):""}function tt(e,t=y){return new Intl.DateTimeFormat(t||y,{month:"long",year:"numeric"}).format(e)}function $(e,t,i=y){if(e)return t==="yyyy-mm-dd"?f(e):t?x(e,i):new Date(e)}function U(e,t={}){let i=e.dataset||{},a=t.locale||i.datepickerLocale||i.calendarLocale||y,n=d(t.minDate||i.calendarMinDate||i.datepickerMinDate),r=d(t.maxDate||i.calendarMaxDate||i.datepickerMaxDate);return{locale:a,mode:t.mode||i.calendarMode||i.datepickerMode||"single",placeholder:t.placeholder||i.datepickerPlaceholder||"Pick a date",value:t.value||i.calendarValue||i.datepickerValue||"",startValue:t.startValue||i.calendarStartValue||i.datepickerStartValue||"",endValue:t.endValue||i.calendarEndValue||i.datepickerEndValue||"",minDate:n,maxDate:r,disabledDates:pt(t.disabledDates||i.calendarDisabledDates||i.datepickerDisabledDates),captionLayout:t.captionLayout||i.calendarCaptionLayout||"",showPresets:t.showPresets??(i.calendarShowPresets==="true"||i.datepickerShowPresets==="true")}}function g(e,t,i,a={},n=!1){return e.dispatchEvent(new t.CustomEvent(i,{bubbles:!0,cancelable:n,detail:a}))}function K(e,t){e&&(e.value=t||"")}function rt(e,t){e&&(e.value=t||"")}function j(e,t,i){if(i){e.dataset.invalid="true",t.classList.add("is-invalid"),t.setAttribute("aria-invalid","true");return}delete e.dataset.invalid,t.classList.remove("is-invalid"),t.removeAttribute("aria-invalid")}function st(e,t,i){i?.required&&i.checkValidity()&&j(e,t,!1)}function et(e,t,i){return i<t?t:Math.min(Math.max(e,t),i)}function mt(e,t,i){let a=e?.ownerDocument?.defaultView||window,n=e?a.getComputedStyle(e).getPropertyValue(t).trim():"",r=Number.parseFloat(n);if(!Number.isFinite(r))return i;if(n.endsWith("rem")){let s=e.ownerDocument.documentElement,_=Number.parseFloat(a.getComputedStyle(s).fontSize);return Number.isFinite(_)?r*_:i}if(n.endsWith("em")){let s=Number.parseFloat(a.getComputedStyle(e).fontSize);return Number.isFinite(s)?r*s:i}return Number.isFinite(r)?r:i}function O(e,t){return!!(t&&(e._element.contains(t)||e._popover.contains(t)))}function it(e){let i=q(e._trigger)?.getAttribute("data-bs-theme")||null,a=e._document.defaultView?.getComputedStyle(e._trigger).direction;i?e._popover.setAttribute("data-bs-theme",i):e._popover.removeAttribute("data-bs-theme"),a==="ltr"||a==="rtl"?e._popover.setAttribute("dir",a):e._popover.removeAttribute("dir")}function gt(e){let t=e._popover,i=q(e._trigger),a=X(i)||e._document.body||e._document.documentElement;if(a){if(e._popoverPortal?.portal===a&&t.parentElement===a){it(e);return}R(e),e._popoverPortal={parent:t.parentNode,nextSibling:t.nextSibling,owner:i,portal:a,hadTheme:t.hasAttribute("data-bs-theme"),theme:t.getAttribute("data-bs-theme"),hadDirection:t.hasAttribute("dir"),direction:t.getAttribute("dir")},a.appendChild(t),it(e)}}function R(e){let t=e._popoverPortal;if(!t)return;let i=e._popover;t.owner?.isConnected===!1?i.remove():t.parent?.isConnected?t.nextSibling?.parentNode===t.parent?t.parent.insertBefore(i,t.nextSibling):t.parent.appendChild(i):i.remove(),t.hadTheme?i.setAttribute("data-bs-theme",t.theme):i.removeAttribute("data-bs-theme"),t.hadDirection?i.setAttribute("dir",t.direction):i.removeAttribute("dir"),e._popoverPortal=null}function Dt(e,t,i,a){let n=mt(i,"--moo-datepicker-popover-offset",6),r=getComputedStyle(e).direction;t.style.position="fixed",t.style.inset="auto",t.style.right="auto",t.style.bottom="auto",t.style.maxHeight="",t.style.overflowY="";let s=e.getBoundingClientRect(),_=t.getBoundingClientRect(),S=a.innerWidth,D=a.innerHeight,P=r==="rtl"?s.right-_.width:s.left,Y=et(P,C,S-_.width-C),A=s.bottom+n<=D?D-s.bottom-n-C:0,h=s.top-n-C,l=_.height>A&&h>A,u=l?"top":"bottom",o=Math.max(0,l?h:A),N=Math.min(_.height,o),v=l?s.top-n-N:s.bottom+n;t.style.left="".concat(Math.round(Y),"px"),t.style.top="".concat(Math.round(et(v,C,D-N-C)),"px"),o>0&&(t.style.maxHeight="".concat(Math.floor(o),"px"),t.style.overflowY="auto"),t.dataset.datepickerPlacement=u}function yt(e){e.style.position="",e.style.inset="",e.style.right="",e.style.bottom="",e.style.left="",e.style.top="",e.style.maxHeight="",e.style.overflowY="",delete e.dataset.datepickerPlacement}function ot(e){E(e._floatingListeners),gt(e);let t=()=>{e.isOpen()&&Dt(e._trigger,e._popover,e._element,e._window)};e._positionPopover=t,t(),c(e._floatingListeners,e._window,"resize",t),c(e._floatingListeners,e._window,"scroll",t,!0),c(e._floatingListeners,e._document,"scroll",t,!0)}function F(e){E(e._floatingListeners),e._positionPopover=null,yt(e._popover),R(e)}function wt(e,t){return new Intl.DateTimeFormat(t||y,{month:"short"}).format(new Date(2026,e,1))}function bt(e,t,i){let a=e?e.getFullYear():i.getFullYear()-100,n=t?t.getFullYear():i.getFullYear()+20,r=[];for(let s=a;s<=n;s+=1)r.push(s);return r}function at(e,t,i=""){let a=e.createElement("span");return a.className=i,a.setAttribute("aria-hidden","true"),a.textContent=t,a}var L=class e{static getInstance(t){return t?.nodeType===1&&V.get(t)||null}static getOrCreateInstance(t,i={}){return e.getInstance(t)||new e(t,i)}constructor(t,i={}){if(!z(t,"[data-calendar]"))throw new TypeError("MooCalendar requires a [data-calendar] root element.");let a=V.get(t);if(a)return a;this._element=t,this._document=t.ownerDocument,this._window=this._document.defaultView||window,this._listeners=[],this._disposed=!1,this._config=U(t,i),this._mode=this._config.mode==="range"?"range":"single",this._disabledDates=new Set(this._config.disabledDates),this._selectedDate=d(this._config.value),this._rangeStart=d(this._config.startValue),this._rangeEnd=d(this._config.endValue),this._activeDate=this._nearestEnabledDate(this._rangeStart||this._selectedDate||new Date),this._viewDate=w(this._activeDate),this._captionId=this._element.id?"".concat(this._element.id,"-caption"):"moo-calendar-caption-".concat(Math.random().toString(36).slice(2)),this._labelId=this._element.id?"".concat(this._element.id,"-label"):"moo-calendar-label-".concat(Math.random().toString(36).slice(2)),V.set(t,this),this._bindEvents(),this._render()}dispose(){this._disposed||(this._disposed=!0,E(this._listeners),this._element.replaceChildren(),V.get(this._element)===this&&V.delete(this._element))}getDate(t=void 0){return this._mode==="range"?this.getDates(t):$(this._selectedDate,t,this._config.locale)}getDates(t=void 0){return[$(this._rangeStart,t,this._config.locale),$(this._rangeEnd,t,this._config.locale)]}setDate(t,i={}){if(this._mode!=="single")return!1;let a=d(t);return!a||this._isDisabled(a)?!1:(this._selectedDate=a,this._activeDate=a,this._viewDate=w(a),this._render(),i.emit!==!1&&this._emitChange(!0),!0)}setDates(t,i,a={}){if(this._mode!=="range")return!1;let n=d(t),r=d(i);return n&&this._isDisabled(n)||r&&this._isDisabled(r)?!1:(this._rangeStart=n,this._rangeEnd=r,this._rangeStart&&this._rangeEnd&&m(this._rangeStart,this._rangeEnd)>0&&([this._rangeStart,this._rangeEnd]=[this._rangeEnd,this._rangeStart]),this._activeDate=this._rangeEnd||this._rangeStart||this._activeDate,this._viewDate=w(this._activeDate),this._render(),a.emit!==!1&&this._emitChange(!!(this._rangeStart&&this._rangeEnd)),!0)}clear(t={}){this._selectedDate=null,this._rangeStart=null,this._rangeEnd=null,this._render(),t.emit!==!1&&this._emitChange(!1)}focusActiveDay(){this._dayButton(this._activeDate)?.focus()}_bindEvents(){c(this._listeners,this._element,"click",t=>{let i=t.target,a=i.closest?.("[data-calendar-day]"),n=i.closest?.("[data-calendar-prev]"),r=i.closest?.("[data-calendar-next]"),s=i.closest?.("[data-calendar-preset]");n?this._changeMonth(-1,!0):r?this._changeMonth(1,!0):s?this._selectPreset(s.dataset.calendarPreset):a&&this._selectDate(d(a.dataset.calendarDay),!0)}),c(this._listeners,this._element,"keydown",t=>{t.target.closest?.("[data-calendar-day]")&&this._handleDayKeydown(t)}),c(this._listeners,this._element,"change",t=>{t.target.matches?.("[data-calendar-month]")&&this._setActiveMonth(this._viewDate.getFullYear(),Number(t.target.value),!0),t.target.matches?.("[data-calendar-year]")&&this._setActiveMonth(Number(t.target.value),this._viewDate.getMonth(),!0)})}_emitChange(t){g(this._element,this._window,"change.moo.calendar",{date:this._selectedDate?new Date(this._selectedDate):void 0,value:this._selectedDate?f(this._selectedDate):"",startDate:this._rangeStart?new Date(this._rangeStart):void 0,endDate:this._rangeEnd?new Date(this._rangeEnd):void 0,startValue:this._rangeStart?f(this._rangeStart):"",endValue:this._rangeEnd?f(this._rangeEnd):"",complete:t})}_changeMonth(t,i){let a=w(B(this._viewDate,t));this._setActiveMonth(a.getFullYear(),a.getMonth(),i)}_setActiveMonth(t,i,a=!1){let n=Math.min(this._activeDate.getDate(),W(t,i));this._activeDate=this._nearestEnabledDate(new Date(t,i,n)),this._viewDate=w(this._activeDate),this._render(),a&&this.focusActiveDay()}_selectPreset(t){if(!t)return;let i=new Date,a={today:0,tomorrow:1,"in-3-days":3,"in-a-week":7,"in-2-weeks":14};t in a&&this._selectDate(b(i,a[t]),!0)}_handleDayKeydown(t){let i=t.target.closest?.("[data-calendar-day]"),a=d(i?.dataset?.calendarDay);a&&m(a,this._activeDate)!==0&&(this._activeDate=a);let n={ArrowRight:1,ArrowLeft:-1,ArrowDown:7,ArrowUp:-7},r=null;if(t.key in n)r=b(this._activeDate,n[t.key]);else if(t.key==="Home"){let s=T(this._config.locale),_=(this._activeDate.getDay()-s+7)%7;r=b(this._activeDate,-_)}else if(t.key==="End"){let s=T(this._config.locale),_=(this._activeDate.getDay()-s+7)%7;r=b(this._activeDate,6-_)}else if(t.key==="PageUp")r=B(this._activeDate,-1);else if(t.key==="PageDown")r=B(this._activeDate,1);else if(t.key==="Enter"||t.key===" "||t.key==="Spacebar"){t.preventDefault(),this._selectDate(this._activeDate,!0);return}else return;t.preventDefault(),this._setActiveDate(r,!0,m(r,this._activeDate)<0?-1:1)}_setActiveDate(t,i=!1,a=0){let n=a===0?this._nearestEnabledDate(t):this._nextEnabledDate(t,a);this._activeDate=n,this._viewDate=w(n),this._render(),i&&this.focusActiveDay()}_nextEnabledDate(t,i){let a=d(t);if(!a)return this._activeDate;let n=i<0?-1:1;for(let r=0;r<366&&!(this._config.minDate&&m(a,this._config.minDate)<0||this._config.maxDate&&m(a,this._config.maxDate)>0);r+=1){if(!this._isDisabled(a))return a;a=b(a,n)}return this._activeDate}_nearestEnabledDate(t){let i=ft(d(t)||new Date,this._config.minDate,this._config.maxDate);if(!this._isDisabled(i))return i;let a=w(i),n=W(a.getFullYear(),a.getMonth());for(let r=1;r<=n;r+=1){let s=new Date(a.getFullYear(),a.getMonth(),r);if(!this._isDisabled(s))return s}return i}_selectDate(t,i){if(!(!t||this._isDisabled(t))){if(this._activeDate=t,this._viewDate=w(t),this._mode==="range"){!this._rangeStart||this._rangeEnd||m(t,this._rangeStart)<0?(this._rangeStart=t,this._rangeEnd=null):this._rangeEnd=t,this._render(),i&&this._emitChange(!!(this._rangeStart&&this._rangeEnd));return}this._selectedDate=t,this._render(),i&&this._emitChange(!0)}}_isDisabled(t){return!t||this._config.minDate&&m(t,this._config.minDate)<0||this._config.maxDate&&m(t,this._config.maxDate)>0?!0:this._disabledDates.has(f(t))}_isSelected(t){return this._mode==="range"?k(t,this._rangeStart)||k(t,this._rangeEnd):k(t,this._selectedDate)}_rangeState(t){return this._mode!=="range"||!this._rangeStart?"":k(t,this._rangeStart)?"start":k(t,this._rangeEnd)?"end":this._rangeStart&&this._rangeEnd&&m(t,this._rangeStart)>0&&m(t,this._rangeEnd)<0?"middle":""}_dayButton(t){return this._element.querySelector('[data-calendar-day="'.concat(f(t),'"]'))}_render(){let t=this._document,i=t.createDocumentFragment(),a=t.createElement("div");a.className="moo-calendar__header";let n=t.createElement("button");n.className="btn btn-ghost btn-icon-sm moo-calendar__nav",n.type="button",n.dataset.calendarPrev="true",n.setAttribute("aria-label","Previous month"),n.appendChild(at(t,"\u2039","moo-calendar__nav-icon"));let r=t.createElement("button");r.className="btn btn-ghost btn-icon-sm moo-calendar__nav",r.type="button",r.dataset.calendarNext="true",r.setAttribute("aria-label","Next month"),r.appendChild(at(t,"\u203A","moo-calendar__nav-icon"));let s=t.createElement("div");if(s.className="moo-calendar__caption",s.id=this._captionId,s.setAttribute("aria-live","polite"),this._config.captionLayout==="dropdown"){let h=t.createElement("select");h.className="moo-calendar__select",h.dataset.calendarMonth="true",h.setAttribute("aria-label","Month");for(let u=0;u<12;u+=1){let o=t.createElement("option");o.value=String(u),o.textContent=wt(u,this._config.locale),o.selected=u===this._viewDate.getMonth(),h.appendChild(o)}let l=t.createElement("select");l.className="moo-calendar__select",l.dataset.calendarYear="true",l.setAttribute("aria-label","Year"),bt(this._config.minDate,this._config.maxDate,this._viewDate).forEach(u=>{let o=t.createElement("option");o.value=String(u),o.textContent=String(u),o.selected=u===this._viewDate.getFullYear(),l.appendChild(o)}),s.append(h,l)}else s.textContent=tt(this._viewDate,this._config.locale);a.append(n,s,r),i.appendChild(a);let _=t.createElement("div");_.id=this._labelId,_.className="visually-hidden",_.textContent=this._element.getAttribute("aria-label")||tt(this._viewDate,this._config.locale),i.appendChild(_);let S=t.createElement("div");S.className="moo-calendar__weekdays",S.setAttribute("role","row"),_t(this._config.locale).forEach(h=>{let l=t.createElement("span");l.className="moo-calendar__weekday",l.setAttribute("role","columnheader"),l.textContent=new Intl.DateTimeFormat(this._config.locale,{weekday:"narrow"}).format(h),S.appendChild(l)});let D=t.createElement("div");D.className="moo-calendar__grid",D.setAttribute("role","grid"),D.setAttribute("aria-labelledby",this._labelId),D.appendChild(S);let P=w(this._viewDate),Y=T(this._config.locale),A=b(P,-((P.getDay()-Y+7)%7));for(let h=0;h<6;h+=1){let l=t.createElement("div");l.className="moo-calendar__week",l.setAttribute("role","row");for(let u=0;u<7;u+=1){let o=b(A,h*7+u),N=f(o),v=t.createElement("div");v.className="moo-calendar__cell",v.setAttribute("role","gridcell");let p=t.createElement("button");p.className="moo-calendar__day",p.type="button",p.dataset.calendarDay=N,p.textContent=String(o.getDate()),p.tabIndex=k(o,this._activeDate)?0:-1,p.setAttribute("aria-label",x(o,this._config.locale));let G=this._isSelected(o);p.dataset.calendarSelected=String(G),v.setAttribute("aria-selected",G?"true":"false"),o.getMonth()!==this._viewDate.getMonth()&&(p.dataset.calendarOutside="true"),k(o,new Date)&&(p.dataset.calendarToday="true",p.setAttribute("aria-current","date"));let J=this._rangeState(o);J&&(p.dataset.calendarRange=J),this._isDisabled(o)&&(p.disabled=!0,p.setAttribute("aria-disabled","true")),v.appendChild(p),l.appendChild(v)}D.appendChild(l)}if(i.appendChild(D),this._config.showPresets){let h=t.createElement("div");h.className="moo-calendar__presets",[["today","Today"],["tomorrow","Tomorrow"],["in-3-days","In 3 days"],["in-a-week","In a week"],["in-2-weeks","In 2 weeks"]].forEach(([l,u])=>{let o=t.createElement("button");o.className="btn btn-outline-secondary btn-sm moo-calendar__preset",o.type="button",o.dataset.calendarPreset=l,o.textContent=u,h.appendChild(o)}),i.appendChild(h)}this._element.classList.add("moo-calendar"),this._element.dataset.calendar=this._element.dataset.calendar||"",this._element.dataset.calendarMode=this._mode,this._element.dataset.calendarActiveDate=f(this._activeDate),this._mode==="single"&&this._selectedDate?this._element.dataset.calendarValue=f(this._selectedDate):delete this._element.dataset.calendarValue,this._mode==="range"?(this._element.dataset.calendarStartValue=this._rangeStart?f(this._rangeStart):"",this._element.dataset.calendarEndValue=this._rangeEnd?f(this._rangeEnd):""):(delete this._element.dataset.calendarStartValue,delete this._element.dataset.calendarEndValue),this._element.replaceChildren(i)}},H=class e{static getInstance(t){return t?.nodeType===1&&I.get(t)||null}static getOrCreateInstance(t,i={}){return e.getInstance(t)||new e(t,i)}constructor(t,i={}){if(!z(t,"[data-datepicker]"))throw new TypeError("MooDatepicker requires a [data-datepicker] root element.");let a=I.get(t);if(a)return a;if(this._element=t,this._document=t.ownerDocument,this._window=this._document.defaultView||window,this._listeners=[],this._floatingListeners=[],this._disposed=!1,this._positionPopover=null,this._popoverPortal=null,this._trigger=t.querySelector("[data-datepicker-trigger]"),this._popover=t.querySelector("[data-datepicker-popover]"),this._label=t.querySelector("[data-datepicker-label]"),this._input=t.querySelector("[data-datepicker-input]")||t.querySelector('input[type="hidden"]'),this._validationInput=t.querySelector("[data-datepicker-validation]"),this._calendarRoot=t.querySelector("[data-calendar]"),!this._trigger||!this._popover||!this._label||!this._input||!this._calendarRoot)throw new TypeError("MooDatepicker requires a trigger, popover, calendar, and hidden input.");this._config=U(t,{...i,value:i.value||this._input.value||t.dataset.datepickerValue}),this._placeholder=this._config.placeholder,this._defaultValue=this._input.defaultValue||this._input.getAttribute("value")||"",this.calendar=L.getOrCreateInstance(this._calendarRoot,{...this._config,mode:"single",value:this._input.value||this._config.value}),I.set(t,this),this._syncFromCalendar(),this._bindEvents()}dispose(){this._disposed||(this._disposed=!0,E(this._listeners),this.hide(!1),F(this),R(this),E(this._floatingListeners),this.calendar?.dispose(),I.get(this._element)===this&&I.delete(this._element))}show(){this._trigger.disabled||this._element.dataset.datepickerDisabled==="true"||this.isOpen()||g(this._element,this._window,"show.moo.datepicker",{},!0)&&(this._popover.hidden=!1,this._popover.classList.add("show"),ot(this),this._trigger.setAttribute("aria-expanded","true"),this.calendar.focusActiveDay(),g(this._element,this._window,"shown.moo.datepicker"))}hide(t=!0){this.isOpen()&&g(this._element,this._window,"hide.moo.datepicker",{},!0)&&(this._popover.hidden=!0,this._popover.classList.remove("show"),F(this),this._trigger.setAttribute("aria-expanded","false"),t&&this._trigger.focus({preventScroll:!0}),g(this._element,this._window,"hidden.moo.datepicker"))}toggle(){this.isOpen()?this.hide():this.show()}isOpen(){return!this._popover.hidden}getDate(t=void 0){return this.calendar.getDate(t)}setDate(t,i={}){let a=this.calendar.setDate(t,{emit:!1});return a&&(this._syncFromCalendar(),i.emit!==!1&&this._emitChange()),a}clear(t={}){this.calendar.clear({emit:!1}),this._syncFromCalendar(),t.emit!==!1&&this._emitChange()}_bindEvents(){c(this._listeners,this._trigger,"click",()=>this.toggle()),c(this._listeners,this._popover,"keydown",i=>{i.key==="Escape"&&(i.preventDefault(),this.hide())}),c(this._listeners,this._document,"pointerdown",i=>{this.isOpen()&&!O(this,i.target)&&this._window.setTimeout(()=>{this.isOpen()&&!O(this,i.target)&&this.hide()},0)}),c(this._listeners,this._calendarRoot,"change.moo.calendar",i=>{this._syncFromCalendar(),this._emitChange(),i.detail.complete&&this.hide()});let t=this._input.form||this._element.closest("form");c(this._listeners,this._validationInput,"invalid",i=>{i.preventDefault(),j(this._element,this._trigger,!0),this._trigger.focus({preventScroll:!0})}),c(this._listeners,t,"reset",()=>{this._window.setTimeout(()=>{this._defaultValue?this.setDate(this._defaultValue,{emit:!1}):this.clear({emit:!1})},0)})}_syncFromCalendar(){let t=this.calendar.getDate("yyyy-mm-dd")||"";K(this._input,t),rt(this._validationInput,t),st(this._element,this._trigger,this._validationInput),this._element.dataset.datepickerValue=t,this._label.dataset.datepickerEmpty=t?"false":"true",this._label.textContent=t?x(d(t),this._config.locale):this._placeholder}_emitChange(){g(this._element,this._window,"change.moo.datepicker",{date:this.getDate(),value:this.getDate("yyyy-mm-dd")||""})}},nt=class e{static getInstance(t){return t?.nodeType===1&&M.get(t)||null}static getOrCreateInstance(t,i={}){return e.getInstance(t)||new e(t,i)}constructor(t,i={}){if(!z(t,"[data-datepicker-range]"))throw new TypeError("MooDateRangePicker requires a [data-datepicker-range] root element.");let a=M.get(t);if(a)return a;if(this._element=t,this._document=t.ownerDocument,this._window=this._document.defaultView||window,this._listeners=[],this._floatingListeners=[],this._disposed=!1,this._positionPopover=null,this._popoverPortal=null,this._trigger=t.querySelector("[data-datepicker-trigger]"),this._popover=t.querySelector("[data-datepicker-popover]"),this._label=t.querySelector("[data-datepicker-label]"),this._startInput=t.querySelector("[data-datepicker-range-start]"),this._endInput=t.querySelector("[data-datepicker-range-end]"),this._validationInput=t.querySelector("[data-datepicker-validation]"),this._calendarRoot=t.querySelector("[data-calendar]"),!this._trigger||!this._popover||!this._label||!this._startInput||!this._endInput||!this._calendarRoot)throw new TypeError("MooDateRangePicker requires a trigger, popover, calendar, and start/end hidden inputs.");this._config=U(t,{...i,mode:"range",startValue:i.startValue||this._startInput.value||t.dataset.datepickerStartValue,endValue:i.endValue||this._endInput.value||t.dataset.datepickerEndValue}),this._placeholder=this._config.placeholder,this._defaultStartValue=this._startInput.defaultValue||this._startInput.getAttribute("value")||"",this._defaultEndValue=this._endInput.defaultValue||this._endInput.getAttribute("value")||"",this.calendar=L.getOrCreateInstance(this._calendarRoot,this._config),M.set(t,this),this._syncFromCalendar(),this._bindEvents()}dispose(){this._disposed||(this._disposed=!0,E(this._listeners),this.hide(!1),F(this),R(this),E(this._floatingListeners),this.calendar?.dispose(),M.get(this._element)===this&&M.delete(this._element))}show(){this._trigger.disabled||this._element.dataset.datepickerDisabled==="true"||this.isOpen()||g(this._element,this._window,"show.moo.datepicker",{},!0)&&(this._popover.hidden=!1,this._popover.classList.add("show"),ot(this),this._trigger.setAttribute("aria-expanded","true"),this.calendar.focusActiveDay(),g(this._element,this._window,"shown.moo.datepicker"))}hide(t=!0){this.isOpen()&&g(this._element,this._window,"hide.moo.datepicker",{},!0)&&(this._popover.hidden=!0,this._popover.classList.remove("show"),F(this),this._trigger.setAttribute("aria-expanded","false"),t&&this._trigger.focus({preventScroll:!0}),g(this._element,this._window,"hidden.moo.datepicker"))}toggle(){this.isOpen()?this.hide():this.show()}isOpen(){return!this._popover.hidden}getDates(t=void 0){return this.calendar.getDates(t)}setDates(t,i,a={}){let n=this.calendar.setDates(t,i,{emit:!1});return n&&(this._syncFromCalendar(),a.emit!==!1&&this._emitChange()),n}clear(t={}){this.calendar.clear({emit:!1}),this._syncFromCalendar(),t.emit!==!1&&this._emitChange()}_bindEvents(){c(this._listeners,this._trigger,"click",()=>this.toggle()),c(this._listeners,this._popover,"keydown",a=>{a.key==="Escape"&&(a.preventDefault(),this.hide())}),c(this._listeners,this._document,"pointerdown",a=>{this.isOpen()&&!O(this,a.target)&&this._window.setTimeout(()=>{this.isOpen()&&!O(this,a.target)&&this.hide()},0)});let t=()=>{this._window.setTimeout(()=>{this.isOpen()&&!O(this,this._document.activeElement)&&this.hide(!1)},0)};c(this._listeners,this._element,"focusout",t),c(this._listeners,this._popover,"focusout",t),c(this._listeners,this._calendarRoot,"change.moo.calendar",a=>{this._syncFromCalendar(),this._emitChange(),a.detail.complete?this.hide():this.calendar.focusActiveDay()});let i=this._startInput.form||this._element.closest("form");c(this._listeners,this._validationInput,"invalid",a=>{a.preventDefault(),j(this._element,this._trigger,!0),this._trigger.focus({preventScroll:!0})}),c(this._listeners,i,"reset",()=>{this._window.setTimeout(()=>{this.setDates(this._defaultStartValue,this._defaultEndValue,{emit:!1})},0)})}_syncFromCalendar(){let[t="",i=""]=this.calendar.getDates("yyyy-mm-dd");K(this._startInput,t||""),K(this._endInput,i||""),rt(this._validationInput,t&&i?"".concat(t," - ").concat(i):""),st(this._element,this._trigger,this._validationInput),this._element.dataset.datepickerStartValue=t||"",this._element.dataset.datepickerEndValue=i||"",this._label.dataset.datepickerEmpty=t?"false":"true",t&&i?this._label.textContent="".concat(x(d(t),this._config.locale)," - ").concat(x(d(i),this._config.locale)):t?this._label.textContent=x(d(t),this._config.locale):this._label.textContent=this._placeholder}_emitChange(){let[t,i]=this.getDates(),[a="",n=""]=this.getDates("yyyy-mm-dd");g(this._element,this._window,"change.moo.datepicker",{startDate:t,endDate:i,startValue:a,endValue:n})}};export{L as MooCalendar,nt as MooDateRangePicker,H as default};
|
|
7
|
+
var Q='.moo-ui[data-bs-theme="light"], .moo-ui[data-bs-theme="dark"]',ce="[data-moo-overlay-host]";function he(t){return t?.nodeType===9?t:t?.ownerDocument?t.ownerDocument:typeof document>"u"?null:document}function ue(t){return!!t?.matches?.(Q)}function _e(t){let e=he(t);return t?.nodeType===9||t===e?.body?e?.body?.firstElementChild||null:t}function q(t=typeof document>"u"?null:document){let e=_e(t);return e?ue(e)?e:e.closest?.(Q)||null:null}function X(t){return t?Array.from(t.children||[]).find(e=>e.matches?.(ce))||t:null}var M=new WeakMap,O=new WeakMap,P=new WeakMap,w="en",Se=1440*60*1e3,fe=new Date(2026,7,16),A=8;function z(t,e){return t?.nodeType===1&&!!t.matches?.(e)}function c(t,e,i,a,n){e&&(e.addEventListener(i,a,n),t.push({target:e,type:i,handler:a,options:n}))}function C(t){t.forEach(({target:e,type:i,handler:a,options:n})=>{e.removeEventListener(i,a,n)}),t.length=0}function d(t){if(!t)return null;if(t instanceof Date)return Number.isNaN(t.getTime())?null:new Date(t.getFullYear(),t.getMonth(),t.getDate());if(typeof t=="number")return d(new Date(t));let e=String(t).trim(),i=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(i){let a=new Date(Number(i[1]),Number(i[2])-1,Number(i[3]));return a.getFullYear()===Number(i[1])&&a.getMonth()===Number(i[2])-1&&a.getDate()===Number(i[3])?a:null}return null}function Z(t){return String(t).padStart(2,"0")}function f(t){return"".concat(t.getFullYear(),"-").concat(Z(t.getMonth()+1),"-").concat(Z(t.getDate()))}function g(t,e){return!t||!e?0:t.getTime()-e.getTime()}function S(t,e){return!!(t&&e&&f(t)===f(e))}function v(t,e){return new Date(t.getFullYear(),t.getMonth(),t.getDate()+e)}function ee(t,e){let i=new Date(t.getFullYear(),t.getMonth()+e,1),a=Math.min(t.getDate(),$(i.getFullYear(),i.getMonth()));return new Date(i.getFullYear(),i.getMonth(),a)}function N(t=w){try{if(typeof Intl<"u"&&typeof Intl.Locale=="function"){let e=new Intl.Locale(t||w),i=e.weekInfo||e.getWeekInfo?.();if(Number.isInteger(i?.firstDay))return i.firstDay%7}}catch{}return 0}function me(t=w){let e=N(t);return Array.from({length:7},(i,a)=>v(fe,(e+a)%7))}function b(t){return new Date(t.getFullYear(),t.getMonth(),1)}function $(t,e){return new Date(t,e+1,0).getDate()}function te(t,e,i){return e&&g(t,e)<0?new Date(e):i&&g(t,i)>0?new Date(i):t}function pe(t){if(Array.isArray(t))return t.map(d).filter(Boolean).map(f);if(!t)return[];let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(d).filter(Boolean).map(f)}catch{}return e.split(",").map(d).filter(Boolean).map(f)}function I(t,e=w){return t?new Intl.DateTimeFormat(e||w,{month:"short",day:"numeric",year:"numeric"}).format(t):""}function ie(t,e=w){return new Intl.DateTimeFormat(e||w,{month:"long",year:"numeric"}).format(t)}function B(t,e,i=w){if(t)return e==="yyyy-mm-dd"?f(t):e?I(t,i):new Date(t)}function U(t,e={}){let i=t.dataset||{},a=e.locale||i.datepickerLocale||i.calendarLocale||w,n=d(e.minDate||i.calendarMinDate||i.datepickerMinDate),r=d(e.maxDate||i.calendarMaxDate||i.datepickerMaxDate);return{locale:a,mode:e.mode||i.calendarMode||i.datepickerMode||"single",placeholder:e.placeholder||i.datepickerPlaceholder||"Pick a date",value:e.value||i.calendarValue||i.datepickerValue||"",startValue:e.startValue||i.calendarStartValue||i.datepickerStartValue||"",endValue:e.endValue||i.calendarEndValue||i.datepickerEndValue||"",minDate:n,maxDate:r,disabledDates:pe(e.disabledDates||i.calendarDisabledDates||i.datepickerDisabledDates),captionLayout:e.captionLayout||i.calendarCaptionLayout||"",showPresets:e.showPresets??(i.calendarShowPresets==="true"||i.datepickerShowPresets==="true")}}function y(t,e,i,a={},n=!1){return t.dispatchEvent(new e.CustomEvent(i,{bubbles:!0,cancelable:n,detail:a}))}function W(t){return t?("datepickerFormDefault"in t.dataset||(t.dataset.datepickerFormDefault=t.getAttribute("value")||""),t.dataset.datepickerFormDefault):""}function K(t,e){t&&(t.value=e||"")}function oe(t,e){t&&(t.value=e||"")}function j(t,e,i){if(i){t.dataset.invalid="true",e.classList.add("is-invalid"),e.setAttribute("aria-invalid","true");return}delete t.dataset.invalid,e.classList.remove("is-invalid"),e.removeAttribute("aria-invalid")}function le(t,e,i){i?.required&&i.checkValidity()&&j(t,e,!1)}function ae(t,e,i){return i<e?e:Math.min(Math.max(t,e),i)}function ge(t,e,i){let a=t?.ownerDocument?.defaultView||window,n=t?a.getComputedStyle(t).getPropertyValue(e).trim():"",r=Number.parseFloat(n);if(!Number.isFinite(r))return i;if(n.endsWith("rem")){let s=t.ownerDocument.documentElement,m=Number.parseFloat(a.getComputedStyle(s).fontSize);return Number.isFinite(m)?r*m:i}if(n.endsWith("em")){let s=Number.parseFloat(a.getComputedStyle(t).fontSize);return Number.isFinite(s)?r*s:i}return Number.isFinite(r)?r:i}function F(t,e){return!!(e&&(t._element.contains(e)||t._popover.contains(e)))}function ne(t){let i=q(t._trigger)?.getAttribute("data-bs-theme")||null,a=t._document.defaultView?.getComputedStyle(t._trigger).direction;i?t._popover.setAttribute("data-bs-theme",i):t._popover.removeAttribute("data-bs-theme"),a==="ltr"||a==="rtl"?t._popover.setAttribute("dir",a):t._popover.removeAttribute("dir")}function De(t){let e=t._popover,i=q(t._trigger),a=X(i)||t._document.body||t._document.documentElement;if(a){if(t._popoverPortal?.portal===a&&e.parentElement===a){ne(t);return}Y(t),t._popoverPortal={parent:e.parentNode,nextSibling:e.nextSibling,owner:i,portal:a,hadTheme:e.hasAttribute("data-bs-theme"),theme:e.getAttribute("data-bs-theme"),hadDirection:e.hasAttribute("dir"),direction:e.getAttribute("dir")},a.appendChild(e),ne(t)}}function Y(t){let e=t._popoverPortal;if(!e)return;let i=t._popover;e.owner?.isConnected===!1?i.remove():e.parent?.isConnected?e.nextSibling?.parentNode===e.parent?e.parent.insertBefore(i,e.nextSibling):e.parent.appendChild(i):i.remove(),e.hadTheme?i.setAttribute("data-bs-theme",e.theme):i.removeAttribute("data-bs-theme"),e.hadDirection?i.setAttribute("dir",e.direction):i.removeAttribute("dir"),t._popoverPortal=null}function ye(t,e,i,a){let n=ge(i,"--moo-datepicker-popover-offset",6),r=getComputedStyle(t).direction;e.style.position="fixed",e.style.inset="auto",e.style.right="auto",e.style.bottom="auto",e.style.maxHeight="",e.style.overflowY="";let s=t.getBoundingClientRect(),m=e.getBoundingClientRect(),D=a.innerWidth,u=a.innerHeight,k=r==="rtl"?s.right-m.width:s.left,x=ae(k,A,D-m.width-A),V=s.bottom+n<=u?u-s.bottom-n-A:0,h=s.top-n-A,l=m.height>V&&h>V,_=l?"top":"bottom",o=Math.max(0,l?h:V),T=Math.min(m.height,o),E=l?s.top-n-T:s.bottom+n;e.style.left="".concat(Math.round(x),"px"),e.style.top="".concat(Math.round(ae(E,A,u-T-A)),"px"),o>0&&(e.style.maxHeight="".concat(Math.floor(o),"px"),e.style.overflowY="auto"),e.dataset.datepickerPlacement=_}function we(t){t.style.position="",t.style.inset="",t.style.right="",t.style.bottom="",t.style.left="",t.style.top="",t.style.maxHeight="",t.style.overflowY="",delete t.dataset.datepickerPlacement}function de(t){C(t._floatingListeners),De(t);let e=()=>{t.isOpen()&&ye(t._trigger,t._popover,t._element,t._window)};t._positionPopover=e,e(),c(t._floatingListeners,t._window,"resize",e),c(t._floatingListeners,t._window,"scroll",e,!0),c(t._floatingListeners,t._document,"scroll",e,!0)}function L(t){C(t._floatingListeners),t._positionPopover=null,we(t._popover),Y(t)}function be(t,e){return new Intl.DateTimeFormat(e||w,{month:"short"}).format(new Date(2026,t,1))}function ve(t,e,i){let a=t?t.getFullYear():i.getFullYear()-100,n=e?e.getFullYear():i.getFullYear()+20,r=[];for(let s=a;s<=n;s+=1)r.push(s);return r}function re(t,e,i=""){let a=t.createElement("span");return a.className=i,a.setAttribute("aria-hidden","true"),a.textContent=e,a}var R=class t{static getInstance(e){return e?.nodeType===1&&O.get(e)||null}static getOrCreateInstance(e,i={}){return t.getInstance(e)||new t(e,i)}constructor(e,i={}){if(!z(e,"[data-calendar]"))throw new TypeError("MooCalendar requires a [data-calendar] root element.");let a=O.get(e);if(a)return a;this._element=e,this._document=e.ownerDocument,this._window=this._document.defaultView||window,this._listeners=[],this._disposed=!1,this._config=U(e,i),this._mode=this._config.mode==="range"?"range":"single",this._disabledDates=new Set(this._config.disabledDates),this._selectedDate=d(this._config.value),this._rangeStart=d(this._config.startValue),this._rangeEnd=d(this._config.endValue),this._activeDate=this._nearestEnabledDate(this._rangeStart||this._selectedDate||new Date),this._viewDate=b(this._activeDate),this._captionId=this._element.id?"".concat(this._element.id,"-caption"):"moo-calendar-caption-".concat(Math.random().toString(36).slice(2)),this._labelId=this._element.id?"".concat(this._element.id,"-label"):"moo-calendar-label-".concat(Math.random().toString(36).slice(2)),O.set(e,this),this._bindEvents(),this._render()}dispose(){this._disposed||(this._disposed=!0,C(this._listeners),this._element.replaceChildren(),O.get(this._element)===this&&O.delete(this._element))}getDate(e=void 0){return this._mode==="range"?this.getDates(e):B(this._selectedDate,e,this._config.locale)}getDates(e=void 0){return[B(this._rangeStart,e,this._config.locale),B(this._rangeEnd,e,this._config.locale)]}setDate(e,i={}){if(this._mode!=="single")return!1;let a=d(e);return!a||this._isDisabled(a)?!1:(this._selectedDate=a,this._activeDate=a,this._viewDate=b(a),this._render(),i.emit!==!1&&this._emitChange(!0),!0)}setDates(e,i,a={}){if(this._mode!=="range")return!1;let n=d(e),r=d(i);return n&&this._isDisabled(n)||r&&this._isDisabled(r)?!1:(this._rangeStart=n,this._rangeEnd=r,this._rangeStart&&this._rangeEnd&&g(this._rangeStart,this._rangeEnd)>0&&([this._rangeStart,this._rangeEnd]=[this._rangeEnd,this._rangeStart]),this._activeDate=this._rangeEnd||this._rangeStart||this._activeDate,this._viewDate=b(this._activeDate),this._render(),a.emit!==!1&&this._emitChange(!!(this._rangeStart&&this._rangeEnd)),!0)}clear(e={}){this._selectedDate=null,this._rangeStart=null,this._rangeEnd=null,this._render(),e.emit!==!1&&this._emitChange(!1)}focusActiveDay(){this._dayButton(this._activeDate)?.focus()}_bindEvents(){c(this._listeners,this._element,"click",e=>{let i=e.target,a=i.closest?.("[data-calendar-day]"),n=i.closest?.("[data-calendar-prev]"),r=i.closest?.("[data-calendar-next]"),s=i.closest?.("[data-calendar-preset]");n?this._changeMonth(-1,!0):r?this._changeMonth(1,!0):s?this._selectPreset(s.dataset.calendarPreset):a&&this._selectDate(d(a.dataset.calendarDay),!0)}),c(this._listeners,this._element,"keydown",e=>{e.target.closest?.("[data-calendar-day]")&&this._handleDayKeydown(e)}),c(this._listeners,this._element,"change",e=>{e.target.matches?.("[data-calendar-month]")&&this._setActiveMonth(this._viewDate.getFullYear(),Number(e.target.value),!0),e.target.matches?.("[data-calendar-year]")&&this._setActiveMonth(Number(e.target.value),this._viewDate.getMonth(),!0)})}_emitChange(e){y(this._element,this._window,"change.moo.calendar",{date:this._selectedDate?new Date(this._selectedDate):void 0,value:this._selectedDate?f(this._selectedDate):"",startDate:this._rangeStart?new Date(this._rangeStart):void 0,endDate:this._rangeEnd?new Date(this._rangeEnd):void 0,startValue:this._rangeStart?f(this._rangeStart):"",endValue:this._rangeEnd?f(this._rangeEnd):"",complete:e})}_changeMonth(e,i){let a=b(ee(this._viewDate,e));this._setActiveMonth(a.getFullYear(),a.getMonth(),i)}_setActiveMonth(e,i,a=!1){let n=Math.min(this._activeDate.getDate(),$(e,i));this._activeDate=this._nearestEnabledDate(new Date(e,i,n)),this._viewDate=b(this._activeDate),this._render(),a&&this.focusActiveDay()}_selectPreset(e){if(!e)return;let i=new Date,a={today:0,tomorrow:1,"in-3-days":3,"in-a-week":7,"in-2-weeks":14};e in a&&this._selectDate(v(i,a[e]),!0)}_handleDayKeydown(e){let i=e.target.closest?.("[data-calendar-day]"),a=d(i?.dataset?.calendarDay);a&&g(a,this._activeDate)!==0&&(this._activeDate=a);let n={ArrowRight:1,ArrowLeft:-1,ArrowDown:7,ArrowUp:-7},r=null,s=!1;if(e.key in n)r=v(this._activeDate,n[e.key]);else if(e.key==="Home"){let D=N(this._config.locale),u=(this._activeDate.getDay()-D+7)%7;r=v(this._activeDate,-u)}else if(e.key==="End"){let D=N(this._config.locale),u=(this._activeDate.getDay()-D+7)%7;r=v(this._activeDate,6-u)}else if(e.key==="PageUp"||e.key==="PageDown"){let D=ee(this._activeDate,e.key==="PageUp"?-1:1),{minDate:u,maxDate:k}=this._config;r=te(D,u,k),s=[u,k].some(x=>x&&g(r,x)===0)}else if(e.key==="Enter"||e.key===" "||e.key==="Spacebar"){e.preventDefault(),this._selectDate(this._activeDate,!0);return}else return;e.preventDefault();let m=g(r,this._activeDate)<0;this._setActiveDate(r,!0,m!==s?-1:1)}_setActiveDate(e,i=!1,a=0){let n=a===0?this._nearestEnabledDate(e):this._nextEnabledDate(e,a);this._activeDate=n,this._viewDate=b(n),this._render(),i&&this.focusActiveDay()}_nextEnabledDate(e,i){let a=d(e);if(!a)return this._activeDate;let n=i<0?-1:1;for(let r=0;r<366&&!(this._config.minDate&&g(a,this._config.minDate)<0||this._config.maxDate&&g(a,this._config.maxDate)>0);r+=1){if(!this._isDisabled(a))return a;a=v(a,n)}return this._activeDate}_nearestEnabledDate(e){let i=te(d(e)||new Date,this._config.minDate,this._config.maxDate);if(!this._isDisabled(i))return i;let a=b(i),n=$(a.getFullYear(),a.getMonth());for(let r=1;r<=n;r+=1){let s=new Date(a.getFullYear(),a.getMonth(),r);if(!this._isDisabled(s))return s}return i}_selectDate(e,i){if(!(!e||this._isDisabled(e))){if(this._activeDate=e,this._viewDate=b(e),this._mode==="range"){!this._rangeStart||this._rangeEnd||g(e,this._rangeStart)<0?(this._rangeStart=e,this._rangeEnd=null):this._rangeEnd=e,this._render(),i&&this._emitChange(!!(this._rangeStart&&this._rangeEnd));return}this._selectedDate=e,this._render(),i&&this._emitChange(!0)}}_isDisabled(e){return!e||this._config.minDate&&g(e,this._config.minDate)<0||this._config.maxDate&&g(e,this._config.maxDate)>0?!0:this._disabledDates.has(f(e))}_isSelected(e){return this._mode==="range"?S(e,this._rangeStart)||S(e,this._rangeEnd):S(e,this._selectedDate)}_rangeState(e){return this._mode!=="range"||!this._rangeStart?"":S(e,this._rangeStart)?"start":S(e,this._rangeEnd)?"end":this._rangeStart&&this._rangeEnd&&g(e,this._rangeStart)>0&&g(e,this._rangeEnd)<0?"middle":""}_dayButton(e){return this._element.querySelector('[data-calendar-day="'.concat(f(e),'"]'))}_render(){let e=this._document,i=e.createDocumentFragment(),a=e.createElement("div");a.className="moo-calendar__header";let n=e.createElement("button");n.className="btn btn-ghost btn-icon-sm moo-calendar__nav",n.type="button",n.dataset.calendarPrev="true",n.setAttribute("aria-label","Previous month"),n.appendChild(re(e,"\u2039","moo-calendar__nav-icon"));let r=e.createElement("button");r.className="btn btn-ghost btn-icon-sm moo-calendar__nav",r.type="button",r.dataset.calendarNext="true",r.setAttribute("aria-label","Next month"),r.appendChild(re(e,"\u203A","moo-calendar__nav-icon"));let s=e.createElement("div");if(s.className="moo-calendar__caption",s.id=this._captionId,s.setAttribute("aria-live","polite"),this._config.captionLayout==="dropdown"){let h=e.createElement("select");h.className="moo-calendar__select",h.dataset.calendarMonth="true",h.setAttribute("aria-label","Month");for(let _=0;_<12;_+=1){let o=e.createElement("option");o.value=String(_),o.textContent=be(_,this._config.locale),o.selected=_===this._viewDate.getMonth(),h.appendChild(o)}let l=e.createElement("select");l.className="moo-calendar__select",l.dataset.calendarYear="true",l.setAttribute("aria-label","Year"),ve(this._config.minDate,this._config.maxDate,this._viewDate).forEach(_=>{let o=e.createElement("option");o.value=String(_),o.textContent=String(_),o.selected=_===this._viewDate.getFullYear(),l.appendChild(o)}),s.append(h,l)}else s.textContent=ie(this._viewDate,this._config.locale);a.append(n,s,r),i.appendChild(a);let m=e.createElement("div");m.id=this._labelId,m.className="visually-hidden",m.textContent=this._element.getAttribute("aria-label")||ie(this._viewDate,this._config.locale),i.appendChild(m);let D=e.createElement("div");D.className="moo-calendar__weekdays",D.setAttribute("role","row"),me(this._config.locale).forEach(h=>{let l=e.createElement("span");l.className="moo-calendar__weekday",l.setAttribute("role","columnheader"),l.textContent=new Intl.DateTimeFormat(this._config.locale,{weekday:"narrow"}).format(h),D.appendChild(l)});let u=e.createElement("div");u.className="moo-calendar__grid",u.setAttribute("role","grid"),u.setAttribute("aria-labelledby",this._labelId),u.appendChild(D);let k=b(this._viewDate),x=N(this._config.locale),V=v(k,-((k.getDay()-x+7)%7));for(let h=0;h<6;h+=1){let l=e.createElement("div");l.className="moo-calendar__week",l.setAttribute("role","row");for(let _=0;_<7;_+=1){let o=v(V,h*7+_),T=f(o),E=e.createElement("div");E.className="moo-calendar__cell",E.setAttribute("role","gridcell");let p=e.createElement("button");p.className="moo-calendar__day",p.type="button",p.dataset.calendarDay=T,p.textContent=String(o.getDate()),p.tabIndex=S(o,this._activeDate)?0:-1,p.setAttribute("aria-label",I(o,this._config.locale));let G=this._isSelected(o);p.dataset.calendarSelected=String(G),E.setAttribute("aria-selected",G?"true":"false"),o.getMonth()!==this._viewDate.getMonth()&&(p.dataset.calendarOutside="true"),S(o,new Date)&&(p.dataset.calendarToday="true",p.setAttribute("aria-current","date"));let J=this._rangeState(o);J&&(p.dataset.calendarRange=J),this._isDisabled(o)&&(p.disabled=!0,p.setAttribute("aria-disabled","true")),E.appendChild(p),l.appendChild(E)}u.appendChild(l)}if(i.appendChild(u),this._config.showPresets){let h=e.createElement("div");h.className="moo-calendar__presets",[["today","Today"],["tomorrow","Tomorrow"],["in-3-days","In 3 days"],["in-a-week","In a week"],["in-2-weeks","In 2 weeks"]].forEach(([l,_])=>{let o=e.createElement("button");o.className="btn btn-outline-secondary btn-sm moo-calendar__preset",o.type="button",o.dataset.calendarPreset=l,o.textContent=_,h.appendChild(o)}),i.appendChild(h)}this._element.classList.add("moo-calendar"),this._element.dataset.calendar=this._element.dataset.calendar||"",this._element.dataset.calendarMode=this._mode,this._element.dataset.calendarActiveDate=f(this._activeDate),this._mode==="single"&&this._selectedDate?this._element.dataset.calendarValue=f(this._selectedDate):delete this._element.dataset.calendarValue,this._mode==="range"?(this._element.dataset.calendarStartValue=this._rangeStart?f(this._rangeStart):"",this._element.dataset.calendarEndValue=this._rangeEnd?f(this._rangeEnd):""):(delete this._element.dataset.calendarStartValue,delete this._element.dataset.calendarEndValue),this._element.replaceChildren(i)}},H=class t{static getInstance(e){return e?.nodeType===1&&M.get(e)||null}static getOrCreateInstance(e,i={}){return t.getInstance(e)||new t(e,i)}constructor(e,i={}){if(!z(e,"[data-datepicker]"))throw new TypeError("MooDatepicker requires a [data-datepicker] root element.");let a=M.get(e);if(a)return a;if(this._element=e,this._document=e.ownerDocument,this._window=this._document.defaultView||window,this._listeners=[],this._floatingListeners=[],this._disposed=!1,this._positionPopover=null,this._popoverPortal=null,this._trigger=e.querySelector("[data-datepicker-trigger]"),this._popover=e.querySelector("[data-datepicker-popover]"),this._label=e.querySelector("[data-datepicker-label]"),this._input=e.querySelector("[data-datepicker-input]")||e.querySelector('input[type="hidden"]'),this._validationInput=e.querySelector("[data-datepicker-validation]"),this._calendarRoot=e.querySelector("[data-calendar]"),!this._trigger||!this._popover||!this._label||!this._input||!this._calendarRoot)throw new TypeError("MooDatepicker requires a trigger, popover, calendar, and hidden input.");this._config=U(e,{...i,value:i.value||this._input.value||e.dataset.datepickerValue}),this._placeholder=this._config.placeholder,this._defaultValue=W(this._input),this.calendar=R.getOrCreateInstance(this._calendarRoot,{...this._config,mode:"single",value:this._input.value||this._config.value}),M.set(e,this),this._syncFromCalendar(),this._bindEvents()}dispose(){this._disposed||(this._disposed=!0,C(this._listeners),this.hide(!1),L(this),Y(this),C(this._floatingListeners),this.calendar?.dispose(),M.get(this._element)===this&&M.delete(this._element))}show(){this._trigger.disabled||this._element.dataset.datepickerDisabled==="true"||this.isOpen()||y(this._element,this._window,"show.moo.datepicker",{},!0)&&(this._popover.hidden=!1,this._popover.classList.add("show"),de(this),this._trigger.setAttribute("aria-expanded","true"),this.calendar.focusActiveDay(),y(this._element,this._window,"shown.moo.datepicker"))}hide(e=!0){this.isOpen()&&y(this._element,this._window,"hide.moo.datepicker",{},!0)&&(this._popover.hidden=!0,this._popover.classList.remove("show"),L(this),this._trigger.setAttribute("aria-expanded","false"),e&&this._trigger.focus({preventScroll:!0}),y(this._element,this._window,"hidden.moo.datepicker"))}toggle(){this.isOpen()?this.hide():this.show()}isOpen(){return!this._popover.hidden}getDate(e=void 0){return this.calendar.getDate(e)}setDate(e,i={}){let a=this.calendar.setDate(e,{emit:!1});return a&&(this._syncFromCalendar(),i.emit!==!1&&this._emitChange()),a}clear(e={}){this.calendar.clear({emit:!1}),this._syncFromCalendar(),e.emit!==!1&&this._emitChange()}_bindEvents(){c(this._listeners,this._trigger,"click",()=>this.toggle()),c(this._listeners,this._popover,"keydown",i=>{i.key==="Escape"&&(i.preventDefault(),this.hide())}),c(this._listeners,this._document,"pointerdown",i=>{this.isOpen()&&!F(this,i.target)&&this._window.setTimeout(()=>{this.isOpen()&&!F(this,i.target)&&this.hide()},0)}),c(this._listeners,this._calendarRoot,"change.moo.calendar",i=>{this._syncFromCalendar(),this._emitChange(),i.detail.complete&&this.hide()});let e=this._input.form||this._element.closest("form");c(this._listeners,this._validationInput,"invalid",i=>{i.preventDefault(),j(this._element,this._trigger,!0),this._trigger.focus({preventScroll:!0})}),c(this._listeners,e,"reset",()=>{this._window.setTimeout(()=>{this._defaultValue?this.setDate(this._defaultValue,{emit:!1}):this.clear({emit:!1})},0)})}_syncFromCalendar(){let e=this.calendar.getDate("yyyy-mm-dd")||"";K(this._input,e),oe(this._validationInput,e),le(this._element,this._trigger,this._validationInput),this._element.dataset.datepickerValue=e,this._label.dataset.datepickerEmpty=e?"false":"true",this._label.textContent=e?I(d(e),this._config.locale):this._placeholder}_emitChange(){y(this._element,this._window,"change.moo.datepicker",{date:this.getDate(),value:this.getDate("yyyy-mm-dd")||""})}},se=class t{static getInstance(e){return e?.nodeType===1&&P.get(e)||null}static getOrCreateInstance(e,i={}){return t.getInstance(e)||new t(e,i)}constructor(e,i={}){if(!z(e,"[data-datepicker-range]"))throw new TypeError("MooDateRangePicker requires a [data-datepicker-range] root element.");let a=P.get(e);if(a)return a;if(this._element=e,this._document=e.ownerDocument,this._window=this._document.defaultView||window,this._listeners=[],this._floatingListeners=[],this._disposed=!1,this._positionPopover=null,this._popoverPortal=null,this._trigger=e.querySelector("[data-datepicker-trigger]"),this._popover=e.querySelector("[data-datepicker-popover]"),this._label=e.querySelector("[data-datepicker-label]"),this._startInput=e.querySelector("[data-datepicker-range-start]"),this._endInput=e.querySelector("[data-datepicker-range-end]"),this._validationInput=e.querySelector("[data-datepicker-validation]"),this._calendarRoot=e.querySelector("[data-calendar]"),!this._trigger||!this._popover||!this._label||!this._startInput||!this._endInput||!this._calendarRoot)throw new TypeError("MooDateRangePicker requires a trigger, popover, calendar, and start/end hidden inputs.");this._config=U(e,{...i,mode:"range",startValue:i.startValue||this._startInput.value||e.dataset.datepickerStartValue,endValue:i.endValue||this._endInput.value||e.dataset.datepickerEndValue}),this._placeholder=this._config.placeholder,this._defaultStartValue=W(this._startInput),this._defaultEndValue=W(this._endInput),this.calendar=R.getOrCreateInstance(this._calendarRoot,this._config),P.set(e,this),this._syncFromCalendar(),this._bindEvents()}dispose(){this._disposed||(this._disposed=!0,C(this._listeners),this.hide(!1),L(this),Y(this),C(this._floatingListeners),this.calendar?.dispose(),P.get(this._element)===this&&P.delete(this._element))}show(){this._trigger.disabled||this._element.dataset.datepickerDisabled==="true"||this.isOpen()||y(this._element,this._window,"show.moo.datepicker",{},!0)&&(this._popover.hidden=!1,this._popover.classList.add("show"),de(this),this._trigger.setAttribute("aria-expanded","true"),this.calendar.focusActiveDay(),y(this._element,this._window,"shown.moo.datepicker"))}hide(e=!0){this.isOpen()&&y(this._element,this._window,"hide.moo.datepicker",{},!0)&&(this._popover.hidden=!0,this._popover.classList.remove("show"),L(this),this._trigger.setAttribute("aria-expanded","false"),e&&this._trigger.focus({preventScroll:!0}),y(this._element,this._window,"hidden.moo.datepicker"))}toggle(){this.isOpen()?this.hide():this.show()}isOpen(){return!this._popover.hidden}getDates(e=void 0){return this.calendar.getDates(e)}setDates(e,i,a={}){let n=this.calendar.setDates(e,i,{emit:!1});return n&&(this._syncFromCalendar(),a.emit!==!1&&this._emitChange()),n}clear(e={}){this.calendar.clear({emit:!1}),this._syncFromCalendar(),e.emit!==!1&&this._emitChange()}_bindEvents(){c(this._listeners,this._trigger,"click",()=>this.toggle()),c(this._listeners,this._popover,"keydown",a=>{a.key==="Escape"&&(a.preventDefault(),this.hide())}),c(this._listeners,this._document,"pointerdown",a=>{this.isOpen()&&!F(this,a.target)&&this._window.setTimeout(()=>{this.isOpen()&&!F(this,a.target)&&this.hide()},0)});let e=()=>{this._window.setTimeout(()=>{this.isOpen()&&!F(this,this._document.activeElement)&&this.hide(!1)},0)};c(this._listeners,this._element,"focusout",e),c(this._listeners,this._popover,"focusout",e),c(this._listeners,this._calendarRoot,"change.moo.calendar",a=>{this._syncFromCalendar(),this._emitChange(),a.detail.complete?this.hide():this.calendar.focusActiveDay()});let i=this._startInput.form||this._element.closest("form");c(this._listeners,this._validationInput,"invalid",a=>{a.preventDefault(),j(this._element,this._trigger,!0),this._trigger.focus({preventScroll:!0})}),c(this._listeners,i,"reset",()=>{this._window.setTimeout(()=>{this.setDates(this._defaultStartValue,this._defaultEndValue,{emit:!1})},0)})}_syncFromCalendar(){let[e="",i=""]=this.calendar.getDates("yyyy-mm-dd");K(this._startInput,e||""),K(this._endInput,i||""),oe(this._validationInput,e&&i?"".concat(e," - ").concat(i):""),le(this._element,this._trigger,this._validationInput),this._element.dataset.datepickerStartValue=e||"",this._element.dataset.datepickerEndValue=i||"",this._label.dataset.datepickerEmpty=e?"false":"true",e&&i?this._label.textContent="".concat(I(d(e),this._config.locale)," - ").concat(I(d(i),this._config.locale)):e?this._label.textContent=I(d(e),this._config.locale):this._label.textContent=this._placeholder}_emitChange(){let[e,i]=this.getDates(),[a="",n=""]=this.getDates("yyyy-mm-dd");y(this._element,this._window,"change.moo.datepicker",{startDate:e,endDate:i,startValue:a,endValue:n})}};export{R as MooCalendar,se as MooDateRangePicker,H as default};
|