@wpmoo/ui 1.0.0-rc.7 → 1.0.0-rc.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/ASSET_LICENSE.md +1 -1
  2. package/README.md +37 -6
  3. package/certification.json +6 -2
  4. package/dist/assets/css/moo-ui.css +764 -452
  5. package/dist/assets/css/moo-ui.min.css +5 -5
  6. package/dist/assets/css/moo.css +762 -450
  7. package/dist/assets/css/moo.min.css +5 -5
  8. package/dist/js/chart.js +1 -1
  9. package/dist/js/chart.min.js +1 -1
  10. package/dist/js/combobox.js +1 -1
  11. package/dist/js/context-menu.js +1 -1
  12. package/dist/js/datatable.js +2 -2
  13. package/dist/js/datepicker.js +2 -2
  14. package/dist/js/datepicker.min.js +2 -2
  15. package/dist/js/moo-ui.js +4 -4
  16. package/dist/js/moo-ui.min.js +2 -2
  17. package/dist/js/sidebar.js +4 -4
  18. package/dist/js/slider.js +1 -1
  19. package/dist/js/state.js +102 -0
  20. package/dist/release-manifest.json +24 -0
  21. package/package.json +5 -1
  22. package/scss/_components.scss +1 -4
  23. package/scss/components/_dropdown.scss +10 -0
  24. package/scss/components/_field.scss +8 -0
  25. package/scss/components/_search_trigger.scss +62 -0
  26. package/scss/components/_sidebar.scss +1 -2
  27. package/scss/components/sidebar/_base.scss +93 -0
  28. package/scss/components/sidebar/_collapsed.scss +3 -81
  29. package/scss/foundations/_scope.scss +8 -0
  30. package/scss/layouts/_app.scss +81 -0
  31. package/scss/layouts/_page_grid.scss +30 -0
  32. package/scss/layouts/app/sidebar/_base.scss +117 -0
  33. package/scss/layouts/app/sidebar/_default.scss +26 -0
  34. package/scss/layouts/app/sidebar/_floating.scss +47 -0
  35. package/scss/{components → layouts/app}/sidebar/_inset.scss +8 -3
  36. package/scss/settings/_component_variables.scss +14 -0
  37. package/scss/settings/_forms.scss +1 -1
  38. package/scss/themes/_root.scss +1 -0
  39. package/scss/themes/_standalone.scss +3 -3
  40. package/scss/themes/_theme.scss +3 -0
  41. package/scss/components/sidebar/_layout.scss +0 -251
package/dist/js/chart.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI chart.js v1.0.0-rc.7 (https://ui.wpmoo.org/)
2
+ * Moo UI chart.js v1.0.0-rc.9 (https://ui.wpmoo.org/)
3
3
  * Copyright 2026 WPMoo (https://wpmoo.org)
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI chart.min.js v1.0.0-rc.7 (https://ui.wpmoo.org/)
2
+ * Moo UI chart.min.js v1.0.0-rc.9 (https://ui.wpmoo.org/)
3
3
  * Copyright 2026 WPMoo (https://wpmoo.org)
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI combobox.js v1.0.0-rc.7 (https://ui.wpmoo.org/)
2
+ * Moo UI combobox.js v1.0.0-rc.9 (https://ui.wpmoo.org/)
3
3
  * Copyright 2026 WPMoo (https://wpmoo.org)
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI context-menu.js v1.0.0-rc.7 (https://ui.wpmoo.org/)
2
+ * Moo UI context-menu.js v1.0.0-rc.9 (https://ui.wpmoo.org/)
3
3
  * Copyright 2026 WPMoo (https://wpmoo.org)
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI datatable.js v1.0.0-rc.7 (https://ui.wpmoo.org/)
2
+ * Moo UI datatable.js v1.0.0-rc.9 (https://ui.wpmoo.org/)
3
3
  * Copyright 2026 WPMoo (https://wpmoo.org)
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -8,7 +8,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
8
8
 
9
9
  // src/js/theme-owner.js
10
10
  var OWNER_SELECTOR = '.moo-ui[data-bs-theme="light"], .moo-ui[data-bs-theme="dark"]';
11
- var PORTAL_SELECTOR = "[data-moo-overlay-portal-host]";
11
+ var PORTAL_SELECTOR = "[data-moo-overlay-host]";
12
12
  function documentFor(node) {
13
13
  if (node?.nodeType === 9) return node;
14
14
  if (node?.ownerDocument) return node.ownerDocument;
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * Moo UI datepicker.js v1.0.0-rc.7 (https://ui.wpmoo.org/)
2
+ * Moo UI datepicker.js v1.0.0-rc.9 (https://ui.wpmoo.org/)
3
3
  * Copyright 2026 WPMoo (https://wpmoo.org)
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
6
6
  // src/js/theme-owner.js
7
7
  var OWNER_SELECTOR = '.moo-ui[data-bs-theme="light"], .moo-ui[data-bs-theme="dark"]';
8
- var PORTAL_SELECTOR = "[data-moo-overlay-portal-host]";
8
+ var PORTAL_SELECTOR = "[data-moo-overlay-host]";
9
9
  function documentFor(node) {
10
10
  if (node?.nodeType === 9) return node;
11
11
  if (node?.ownerDocument) return node.ownerDocument;
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * Moo UI datepicker.min.js v1.0.0-rc.7 (https://ui.wpmoo.org/)
2
+ * Moo UI datepicker.min.js v1.0.0-rc.9 (https://ui.wpmoo.org/)
3
3
  * Copyright 2026 WPMoo (https://wpmoo.org)
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
6
- var Q='.moo-ui[data-bs-theme="light"], .moo-ui[data-bs-theme="dark"]',le="[data-moo-overlay-portal-host]";function de(t){return t?.nodeType===9?t:t?.ownerDocument?t.ownerDocument:typeof document>"u"?null:document}function ce(t){return!!t?.matches?.(Q)}function he(t){let e=de(t);return t?.nodeType===9||t===e?.body?e?.body?.firstElementChild||null:t}function q(t=typeof document>"u"?null:document){let e=he(t);return e?ce(e)?e:e.closest?.(Q)||null:null}function X(t){return t?Array.from(t.children||[]).find(e=>e.matches?.(le))||t:null}var I=new WeakMap,V=new WeakMap,M=new WeakMap,y="en",Ee=1440*60*1e3,ue=new Date(2026,7,16),C=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 E(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`${t.getFullYear()}-${Z(t.getMonth()+1)}-${Z(t.getDate())}`}function m(t,e){return!t||!e?0:t.getTime()-e.getTime()}function k(t,e){return!!(t&&e&&f(t)===f(e))}function b(t,e){return new Date(t.getFullYear(),t.getMonth(),t.getDate()+e)}function B(t,e){let i=new Date(t.getFullYear(),t.getMonth()+e,1),a=Math.min(t.getDate(),W(i.getFullYear(),i.getMonth()));return new Date(i.getFullYear(),i.getMonth(),a)}function T(t=y){try{if(typeof Intl<"u"&&typeof Intl.Locale=="function"){let e=new Intl.Locale(t||y),i=e.weekInfo||e.getWeekInfo?.();if(Number.isInteger(i?.firstDay))return i.firstDay%7}}catch{}return 0}function _e(t=y){let e=T(t);return Array.from({length:7},(i,a)=>b(ue,(e+a)%7))}function w(t){return new Date(t.getFullYear(),t.getMonth(),1)}function W(t,e){return new Date(t,e+1,0).getDate()}function fe(t,e,i){return e&&m(t,e)<0?new Date(e):i&&m(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 A(t,e=y){return t?new Intl.DateTimeFormat(e||y,{month:"short",day:"numeric",year:"numeric"}).format(t):""}function ee(t,e=y){return new Intl.DateTimeFormat(e||y,{month:"long",year:"numeric"}).format(t)}function $(t,e,i=y){if(t)return e==="yyyy-mm-dd"?f(t):e?A(t,i):new Date(t)}function U(t,e={}){let i=t.dataset||{},a=e.locale||i.datepickerLocale||i.calendarLocale||y,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 g(t,e,i,a={},n=!1){return t.dispatchEvent(new e.CustomEvent(i,{bubbles:!0,cancelable:n,detail:a}))}function K(t,e){t&&(t.value=e||"")}function re(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 se(t,e,i){i?.required&&i.checkValidity()&&j(t,e,!1)}function te(t,e,i){return i<e?e:Math.min(Math.max(t,e),i)}function me(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,_=Number.parseFloat(a.getComputedStyle(s).fontSize);return Number.isFinite(_)?r*_: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 O(t,e){return!!(e&&(t._element.contains(e)||t._popover.contains(e)))}function ie(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 ge(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){ie(t);return}R(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),ie(t)}}function R(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 De(t,e,i,a){let n=me(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(),_=e.getBoundingClientRect(),S=a.innerWidth,D=a.innerHeight,P=r==="rtl"?s.right-_.width:s.left,Y=te(P,C,S-_.width-C),x=s.bottom+n<=D?D-s.bottom-n-C:0,h=s.top-n-C,l=_.height>x&&h>x,u=l?"top":"bottom",o=Math.max(0,l?h:x),N=Math.min(_.height,o),v=l?s.top-n-N:s.bottom+n;e.style.left=`${Math.round(Y)}px`,e.style.top=`${Math.round(te(v,C,D-N-C))}px`,o>0&&(e.style.maxHeight=`${Math.floor(o)}px`,e.style.overflowY="auto"),e.dataset.datepickerPlacement=u}function ye(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 oe(t){E(t._floatingListeners),ge(t);let e=()=>{t.isOpen()&&De(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 F(t){E(t._floatingListeners),t._positionPopover=null,ye(t._popover),R(t)}function we(t,e){return new Intl.DateTimeFormat(e||y,{month:"short"}).format(new Date(2026,t,1))}function be(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 ae(t,e,i=""){let a=t.createElement("span");return a.className=i,a.setAttribute("aria-hidden","true"),a.textContent=e,a}var L=class t{static getInstance(e){return e?.nodeType===1&&V.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=V.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=w(this._activeDate),this._captionId=this._element.id?`${this._element.id}-caption`:`moo-calendar-caption-${Math.random().toString(36).slice(2)}`,this._labelId=this._element.id?`${this._element.id}-label`:`moo-calendar-label-${Math.random().toString(36).slice(2)}`,V.set(e,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(e=void 0){return this._mode==="range"?this.getDates(e):$(this._selectedDate,e,this._config.locale)}getDates(e=void 0){return[$(this._rangeStart,e,this._config.locale),$(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=w(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&&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(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){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:e})}_changeMonth(e,i){let a=w(B(this._viewDate,e));this._setActiveMonth(a.getFullYear(),a.getMonth(),i)}_setActiveMonth(e,i,a=!1){let n=Math.min(this._activeDate.getDate(),W(e,i));this._activeDate=this._nearestEnabledDate(new Date(e,i,n)),this._viewDate=w(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(b(i,a[e]),!0)}_handleDayKeydown(e){let i=e.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(e.key in n)r=b(this._activeDate,n[e.key]);else if(e.key==="Home"){let s=T(this._config.locale),_=(this._activeDate.getDay()-s+7)%7;r=b(this._activeDate,-_)}else if(e.key==="End"){let s=T(this._config.locale),_=(this._activeDate.getDay()-s+7)%7;r=b(this._activeDate,6-_)}else if(e.key==="PageUp")r=B(this._activeDate,-1);else if(e.key==="PageDown")r=B(this._activeDate,1);else if(e.key==="Enter"||e.key===" "||e.key==="Spacebar"){e.preventDefault(),this._selectDate(this._activeDate,!0);return}else return;e.preventDefault(),this._setActiveDate(r,!0,m(r,this._activeDate)<0?-1:1)}_setActiveDate(e,i=!1,a=0){let n=a===0?this._nearestEnabledDate(e):this._nextEnabledDate(e,a);this._activeDate=n,this._viewDate=w(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&&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(e){let i=fe(d(e)||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(e,i){if(!(!e||this._isDisabled(e))){if(this._activeDate=e,this._viewDate=w(e),this._mode==="range"){!this._rangeStart||this._rangeEnd||m(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&&m(e,this._config.minDate)<0||this._config.maxDate&&m(e,this._config.maxDate)>0?!0:this._disabledDates.has(f(e))}_isSelected(e){return this._mode==="range"?k(e,this._rangeStart)||k(e,this._rangeEnd):k(e,this._selectedDate)}_rangeState(e){return this._mode!=="range"||!this._rangeStart?"":k(e,this._rangeStart)?"start":k(e,this._rangeEnd)?"end":this._rangeStart&&this._rangeEnd&&m(e,this._rangeStart)>0&&m(e,this._rangeEnd)<0?"middle":""}_dayButton(e){return this._element.querySelector(`[data-calendar-day="${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(ae(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(ae(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 u=0;u<12;u+=1){let o=e.createElement("option");o.value=String(u),o.textContent=we(u,this._config.locale),o.selected=u===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"),be(this._config.minDate,this._config.maxDate,this._viewDate).forEach(u=>{let o=e.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=ee(this._viewDate,this._config.locale);a.append(n,s,r),i.appendChild(a);let _=e.createElement("div");_.id=this._labelId,_.className="visually-hidden",_.textContent=this._element.getAttribute("aria-label")||ee(this._viewDate,this._config.locale),i.appendChild(_);let S=e.createElement("div");S.className="moo-calendar__weekdays",S.setAttribute("role","row"),_e(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),S.appendChild(l)});let D=e.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),x=b(P,-((P.getDay()-Y+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 u=0;u<7;u+=1){let o=b(x,h*7+u),N=f(o),v=e.createElement("div");v.className="moo-calendar__cell",v.setAttribute("role","gridcell");let p=e.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",A(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=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,u])=>{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=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 t{static getInstance(e){return e?.nodeType===1&&I.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=I.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=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(e,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"),oe(this),this._trigger.setAttribute("aria-expanded","true"),this.calendar.focusActiveDay(),g(this._element,this._window,"shown.moo.datepicker"))}hide(e=!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"),e&&this._trigger.focus(),g(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()&&!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 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),re(this._validationInput,e),se(this._element,this._trigger,this._validationInput),this._element.dataset.datepickerValue=e,this._label.textContent=e?A(d(e),this._config.locale):this._placeholder}_emitChange(){g(this._element,this._window,"change.moo.datepicker",{date:this.getDate(),value:this.getDate("yyyy-mm-dd")||""})}},ne=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-range]"))throw new TypeError("MooDateRangePicker requires a [data-datepicker-range] 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._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=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(e,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"),oe(this),this._trigger.setAttribute("aria-expanded","true"),this.calendar.focusActiveDay(),g(this._element,this._window,"shown.moo.datepicker"))}hide(e=!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"),e&&this._trigger.focus(),g(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()&&!O(this,a.target)&&this._window.setTimeout(()=>{this.isOpen()&&!O(this,a.target)&&this.hide()},0)});let e=()=>{this._window.setTimeout(()=>{this.isOpen()&&!O(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||""),re(this._validationInput,e&&i?`${e} - ${i}`:""),se(this._element,this._trigger,this._validationInput),this._element.dataset.datepickerStartValue=e||"",this._element.dataset.datepickerEndValue=i||"",e&&i?this._label.textContent=`${A(d(e),this._config.locale)} - ${A(d(i),this._config.locale)}`:e?this._label.textContent=A(d(e),this._config.locale):this._label.textContent=this._placeholder}_emitChange(){let[e,i]=this.getDates(),[a="",n=""]=this.getDates("yyyy-mm-dd");g(this._element,this._window,"change.moo.datepicker",{startDate:e,endDate:i,startValue:a,endValue:n})}};export{L as MooCalendar,ne as MooDateRangePicker,H as default};
6
+ 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`${e.getFullYear()}-${Z(e.getMonth()+1)}-${Z(e.getDate())}`}function p(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&&p(e,t)<0?new Date(t):i&&p(e,i)>0?new Date(i):e}function mt(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:mt(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 pt(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=pt(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=`${Math.round(Y)}px`,t.style.top=`${Math.round(et(v,C,D-N-C))}px`,o>0&&(t.style.maxHeight=`${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?`${this._element.id}-caption`:`moo-calendar-caption-${Math.random().toString(36).slice(2)}`,this._labelId=this._element.id?`${this._element.id}-label`:`moo-calendar-label-${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&&p(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&&p(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,p(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&&p(a,this._config.minDate)<0||this._config.maxDate&&p(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||p(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&&p(t,this._config.minDate)<0||this._config.maxDate&&p(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&&p(t,this._rangeStart)>0&&p(t,this._rangeEnd)<0?"middle":""}_dayButton(t){return this._element.querySelector(`[data-calendar-day="${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 m=t.createElement("button");m.className="moo-calendar__day",m.type="button",m.dataset.calendarDay=N,m.textContent=String(o.getDate()),m.tabIndex=k(o,this._activeDate)?0:-1,m.setAttribute("aria-label",x(o,this._config.locale));let G=this._isSelected(o);m.dataset.calendarSelected=String(G),v.setAttribute("aria-selected",G?"true":"false"),o.getMonth()!==this._viewDate.getMonth()&&(m.dataset.calendarOutside="true"),k(o,new Date)&&(m.dataset.calendarToday="true",m.setAttribute("aria-current","date"));let J=this._rangeState(o);J&&(m.dataset.calendarRange=J),this._isDisabled(o)&&(m.disabled=!0,m.setAttribute("aria-disabled","true")),v.appendChild(m),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(),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.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(),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?`${t} - ${i}`:""),st(this._element,this._trigger,this._validationInput),this._element.dataset.datepickerStartValue=t||"",this._element.dataset.datepickerEndValue=i||"",t&&i?this._label.textContent=`${x(d(t),this._config.locale)} - ${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};
package/dist/js/moo-ui.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI moo-ui.js v1.0.0-rc.7 (https://ui.wpmoo.org/)
2
+ * Moo UI moo-ui.js v1.0.0-rc.9 (https://ui.wpmoo.org/)
3
3
  * Copyright 2026 WPMoo (https://wpmoo.org)
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -16001,7 +16001,7 @@ var ContextMenu = class _ContextMenu {
16001
16001
 
16002
16002
  // src/js/theme-owner.js
16003
16003
  var OWNER_SELECTOR = '.moo-ui[data-bs-theme="light"], .moo-ui[data-bs-theme="dark"]';
16004
- var PORTAL_SELECTOR = "[data-moo-overlay-portal-host]";
16004
+ var PORTAL_SELECTOR = "[data-moo-overlay-host]";
16005
16005
  function documentFor(node) {
16006
16006
  if (node?.nodeType === 9) return node;
16007
16007
  if (node?.ownerDocument) return node.ownerDocument;
@@ -18475,7 +18475,7 @@ var Sidebar = class _Sidebar {
18475
18475
  return this._window.matchMedia(this._config.breakpoint).matches;
18476
18476
  }
18477
18477
  _isCollapsed() {
18478
- return this._isDesktop() && this._element.dataset.sidebarState === "collapsed";
18478
+ return this._isDesktop() && this._sidebar?.dataset?.collapsible === "icon" && this._element.dataset.sidebarState === "collapsed";
18479
18479
  }
18480
18480
  _trigger(name, detail = {}) {
18481
18481
  return this._element.dispatchEvent(
@@ -18609,7 +18609,7 @@ var Sidebar = class _Sidebar {
18609
18609
  _positionDropdown(control) {
18610
18610
  const item = control?.closest?.(".sidebar-menu-item");
18611
18611
  const isHeaderWorkspace = control?.classList.contains("sidebar-menu-button--workspace") && control.closest('[data-slot="sidebar-header"]');
18612
- const isFooterAccount = control?.classList.contains("sidebar-menu-button--account") && control.closest('[data-slot="sidebar-footer"]');
18612
+ const isFooterAccount = control?.closest(".sidebar-menu-item--account") && control.closest('[data-slot="sidebar-footer"]');
18613
18613
  if (!control || !item || !(isHeaderWorkspace || isFooterAccount) || !this._isDesktop()) {
18614
18614
  this._clearDropdownPosition(control);
18615
18615
  return;