@editora/ui-core 0.1.12 → 0.1.13
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 +1 -1
- package/dist/alert-dialog.cjs.js +18 -18
- package/dist/alert-dialog.esm.js +130 -117
- package/dist/app-header.cjs.js +22 -2
- package/dist/app-header.esm.js +22 -2
- package/dist/badge.cjs.js +5 -5
- package/dist/badge.esm.js +9 -8
- package/dist/color-picker.cjs.js +4 -4
- package/dist/color-picker.esm.js +39 -31
- package/dist/combobox.cjs.js +21 -21
- package/dist/combobox.esm.js +79 -40
- package/dist/command-palette.cjs.js +1 -1
- package/dist/command-palette.esm.js +2 -2
- package/dist/components/date-time-utils.d.ts +2 -1
- package/dist/components/date-time-utils.d.ts.map +1 -1
- package/dist/components/ui-alert-dialog.d.ts +2 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-app-header.d.ts.map +1 -1
- package/dist/components/ui-badge.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts +4 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts +3 -0
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts +3 -0
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts +3 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +3 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dialog.d.ts +3 -0
- package/dist/components/ui-dialog.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts +14 -0
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts +1 -0
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-menubar.d.ts +1 -0
- package/dist/components/ui-menubar.d.ts.map +1 -1
- package/dist/components/ui-quick-actions.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts +47 -0
- package/dist/components/ui-radio.d.ts.map +1 -0
- package/dist/components/ui-select.d.ts +8 -0
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-selection-popup.d.ts.map +1 -1
- package/dist/components/ui-stepper.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts +3 -0
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/context-menu.cjs.js +2 -2
- package/dist/context-menu.esm.js +2 -2
- package/dist/date-field.cjs.js +1 -1
- package/dist/date-field.esm.js +2 -2
- package/dist/date-picker.cjs.js +13 -13
- package/dist/date-picker.esm.js +100 -67
- package/dist/date-range-picker.cjs.js +14 -14
- package/dist/date-range-picker.esm.js +98 -65
- package/dist/date-range-time-picker.cjs.js +13 -13
- package/dist/date-range-time-picker.esm.js +76 -45
- package/dist/date-time-picker.cjs.js +13 -13
- package/dist/date-time-picker.esm.js +132 -101
- package/dist/date-time-utils-378ecc21.js +1 -0
- package/dist/{date-time-utils-bdceb7af.mjs → date-time-utils-a8b17ea7.mjs} +128 -102
- package/dist/dialog.cjs.js +29 -20
- package/dist/dialog.esm.js +90 -70
- package/dist/drawer.cjs.js +16 -16
- package/dist/drawer.esm.js +216 -98
- package/dist/floating-toolbar.cjs.js +3 -13
- package/dist/floating-toolbar.esm.js +17 -27
- package/dist/hover-card.cjs.js +1 -1
- package/dist/hover-card.esm.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +246 -244
- package/dist/menu.cjs.js +2 -2
- package/dist/menu.esm.js +118 -110
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +83 -78
- package/dist/{overlayManager-ece06517.js → overlayManager-0eda4e08.js} +1 -1
- package/dist/{overlayManager-86454af7.mjs → overlayManager-5bbd4dc3.mjs} +1 -1
- package/dist/popover.cjs.js +1 -1
- package/dist/popover.esm.js +2 -2
- package/dist/{portal-1cf392ca.mjs → portal-9060f7a6.mjs} +7 -7
- package/dist/portal-d9bae456.js +1 -0
- package/dist/{positioner-fbd61bf1.mjs → positioner-16f3cca1.mjs} +16 -16
- package/dist/positioner-43b1c75a.js +1 -0
- package/dist/positioner.cjs.js +1 -1
- package/dist/positioner.esm.js +1 -1
- package/dist/quick-actions.cjs.js +10 -4
- package/dist/quick-actions.esm.js +27 -21
- package/dist/radio.cjs.js +259 -0
- package/dist/radio.esm.js +455 -0
- package/dist/{runtime-5f282bc8.js → runtime-668914fe.js} +1 -1
- package/dist/{runtime-4ac0107b.mjs → runtime-864efe2f.mjs} +1 -1
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +2 -2
- package/dist/scroll-lock-31da444f.mjs +56 -0
- package/dist/scroll-lock-d7b0df21.js +1 -0
- package/dist/scroll-lock.d.ts.map +1 -1
- package/dist/select.cjs.js +14 -15
- package/dist/select.esm.js +117 -97
- package/dist/selection-popup.cjs.js +4 -7
- package/dist/selection-popup.esm.js +8 -11
- package/dist/split-button.cjs.js +1 -1
- package/dist/split-button.esm.js +2 -2
- package/dist/standalone/radio.d.ts +2 -0
- package/dist/standalone/radio.d.ts.map +1 -0
- package/dist/stepper.cjs.js +19 -50
- package/dist/stepper.esm.js +17 -48
- package/dist/time-field.cjs.js +1 -1
- package/dist/time-field.esm.js +14 -14
- package/dist/time-picker.cjs.js +15 -15
- package/dist/time-picker.esm.js +99 -68
- package/dist/tooltip.cjs.js +1 -1
- package/dist/tooltip.esm.js +1 -1
- package/package.json +2 -2
- package/dist/date-time-utils-5cf58cd0.js +0 -1
- package/dist/portal-d8d7fbca.js +0 -1
- package/dist/positioner-accc6e5f.js +0 -1
- package/dist/scroll-lock-48793569.js +0 -1
- package/dist/scroll-lock-9de6d328.mjs +0 -53
package/dist/date-picker.cjs.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("./ElementBase-1b301e7f.js"),w=require("./calendar-a8735e40.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("./ElementBase-1b301e7f.js"),L=require("./dismissable-layer-193e3bed.js"),w=require("./calendar-a8735e40.js"),a=require("./date-time-utils-378ecc21.js");require("./scroll-lock-d7b0df21.js");let q=0;const M=`
|
|
2
2
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
3
3
|
<path d="M6 2a1 1 0 0 1 1 1v1h6V3a1 1 0 1 1 2 0v1h.5A2.5 2.5 0 0 1 18 6.5v9A2.5 2.5 0 0 1 15.5 18h-11A2.5 2.5 0 0 1 2 15.5v-9A2.5 2.5 0 0 1 4.5 4H5V3a1 1 0 0 1 1-1Zm10 7H4v6.5c0 .276.224.5.5.5h11a.5.5 0 0 0 .5-.5V9ZM4.5 6a.5.5 0 0 0-.5.5V7h12v-.5a.5.5 0 0 0-.5-.5h-11Z" fill="currentColor"/>
|
|
4
4
|
</svg>
|
|
5
|
-
`,
|
|
5
|
+
`,V=`
|
|
6
6
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
7
7
|
<path d="M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.12l3.71-3.9a.75.75 0 1 1 1.08 1.04l-4.25 4.47a.75.75 0 0 1-1.08 0L5.2 8.27a.75.75 0 0 1 .02-1.06Z" fill="currentColor"/>
|
|
8
8
|
</svg>
|
|
9
|
-
`,
|
|
9
|
+
`,E=`
|
|
10
10
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
11
11
|
<path d="M5.22 5.22a.75.75 0 0 1 1.06 0L10 8.94l3.72-3.72a.75.75 0 1 1 1.06 1.06L11.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06L10 11.06l-3.72 3.72a.75.75 0 1 1-1.06-1.06L8.94 10 5.22 6.28a.75.75 0 0 1 0-1.06Z" fill="currentColor"/>
|
|
12
12
|
</svg>
|
|
13
|
-
|
|
13
|
+
`,$=`
|
|
14
14
|
:host {
|
|
15
15
|
--ui-dp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
16
16
|
--ui-dp-surface: linear-gradient(
|
|
@@ -381,7 +381,7 @@
|
|
|
381
381
|
transform: rotate(360deg);
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
-
|
|
384
|
+
`,R=`
|
|
385
385
|
.overlay {
|
|
386
386
|
position: fixed;
|
|
387
387
|
z-index: var(--ui-dp-z, 1600);
|
|
@@ -524,10 +524,10 @@
|
|
|
524
524
|
transform: translateY(0);
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
-
`;function v(S){return S.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}class z extends P.ElementBase{constructor(){super(...arguments),this._value=null,this._pendingValue=null,this._draftInput="",this._inlineError="",this._open=!1,this._syncing=!1,this._overlay=null,this._releaseScrollLock=null,this._lastOpenSource="api",this._restoreFocusEl=null,this._isInitialized=!1,this._hasView=!1,this._overlayMode=null,this._uid=`ui-dp-${++L}`,this._inputId=`${this._uid}-input`,this._labelId=`${this._uid}-label`,this._hintId=`${this._uid}-hint`,this._errorId=`${this._uid}-error`,this._panelId=`${this._uid}-panel`,this._panelTitleId=`${this._uid}-panel-title`,this._overlayFocusedOnOpen=!1,this._inlineCalendarFramePending=!1,this._inlineCalendarUpgradePending=!1,this._schedulePosition=s.rafThrottle(()=>this._positionOverlay()),this._onRootClickBound=e=>this._onRootClick(e),this._onRootInputBound=e=>this._onRootInput(e),this._onRootBlurBound=e=>this._onRootBlur(e),this._onRootKeyDownBound=e=>this._onRootKeyDown(e),this._onDocumentPointerDownBound=e=>this._onDocumentPointerDown(e),this._onDocumentKeyDownBound=e=>this._onDocumentKeyDown(e),this._onWindowResizeBound=()=>this._schedulePosition.run(),this._onWindowScrollBound=()=>this._schedulePosition.run(),this._onOverlayClickBound=e=>this._onOverlayClick(e),this._onOverlaySelectBound=e=>this._onCalendarSelect(e)}static get observedAttributes(){return["open","default-open","value","default-value","min","max","locale","translations","week-start","size","shape","bare","variant","state","placeholder","label","hint","error","clearable","allow-input","close-on-select","outside-click","disabled","readonly","required","name","mode","events","events-max","events-display","format","display-format","show-footer"]}connectedCallback(){if(super.connectedCallback(),this.root.addEventListener("click",this._onRootClickBound),this.root.addEventListener("input",this._onRootInputBound),this.root.addEventListener("focusout",this._onRootBlurBound),this.root.addEventListener("keydown",this._onRootKeyDownBound),!this._isInitialized){const e=this._clampToBounds(s.normalizeDateIso(this.getAttribute("value"))||s.normalizeDateIso(this.getAttribute("default-value")));this._value=e,this._pendingValue=e,this._draftInput=this._formatDisplay(e),this._open=this.hasAttribute("open")||s.isTruthyAttr(this.getAttribute("default-open")),this._isInitialized=!0}this._open&&!this._isInlineMode()&&this._ensureOverlay(),this._isInlineMode()&&this._scheduleInlineCalendarSync()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClickBound),this.root.removeEventListener("input",this._onRootInputBound),this.root.removeEventListener("focusout",this._onRootBlurBound),this.root.removeEventListener("keydown",this._onRootKeyDownBound),this._destroyOverlay(),super.disconnectedCallback()}attributeChangedCallback(e,t,i){if(t!==i){if(e==="value"&&!this._syncing&&(this._value=this._clampToBounds(s.normalizeDateIso(i)),this._pendingValue=this._value,this._draftInput=this._formatDisplay(this._value),this._inlineError="",this._syncValueAttribute(this._value)),e==="open"&&!this._syncing&&(this._open=this.hasAttribute("open"),this._syncOverlay(this._open?"api":"outside")),e==="mode"&&this._syncOverlay("attribute"),e==="disabled"&&this.hasAttribute("disabled")&&this._setOpen(!1,"outside"),(e==="min"||e==="max")&&!this._syncing){const r=this._clampToBounds(this._value),n=this._clampToBounds(this._pendingValue);this._value=r,this._pendingValue=n,this._draftInput=this._formatDisplay(this._allowInput()?n:r),this._syncValueAttribute(r)}if(e==="state"&&this._state()==="loading"&&this._setOpen(!1,"outside"),!!this.isConnected){if(!this._hasView){this.requestRender();return}this._updateHostState()}}}_isInlineMode(){return(this.getAttribute("mode")||"popover")==="inline"}_isMobileSheet(){return s.shouldUseMobileSheet(this.getAttribute("mode"))}_isDisabled(){return this.hasAttribute("disabled")}_isReadonly(){return this.hasAttribute("readonly")}_allowInput(){return s.isTruthyAttr(this.getAttribute("allow-input"),!0)}_clearable(){return s.isTruthyAttr(this.getAttribute("clearable"),!0)}_closeOnSelect(){return s.isTruthyAttr(this.getAttribute("close-on-select"),!0)}_showFooter(){return s.isTruthyAttr(this.getAttribute("show-footer"),!0)}_isBare(){return s.isTruthyAttr(this.getAttribute("bare"),!1)}_locale(){return s.normalizeLocale(this.getAttribute("locale"))}_translations(){return w.resolveDateTimeTranslations(this.getAttribute("locale"),this.getAttribute("translations"))}_formatMode(){const e=(this.getAttribute("format")||"locale").trim();return e==="iso"||e==="custom"?e:"locale"}_displayFormat(){return(this.getAttribute("display-format")||"").trim()||null}_placeholder(){const e=this._translations(),t=this.getAttribute("placeholder");return t||(this._formatMode()==="iso"?"YYYY-MM-DD":e.selectDate)}_todayIso(){const e=new Date,t=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${e.getFullYear()}-${t}-${i}`}_state(){const e=(this.getAttribute("state")||"").trim().toLowerCase();return e==="loading"||e==="success"||e==="error"?e:"idle"}_isInteractionBlocked(){return this._isDisabled()||this._state()==="loading"}_minIso(){return s.parseConstraintDate(this.getAttribute("min"))}_maxIso(){return s.parseConstraintDate(this.getAttribute("max"))}_resolvedBounds(){let e=this._minIso(),t=this._maxIso();if(e&&t&&w.compareISO(e,t)>0){const i=e;e=t,t=i}return{min:e,max:t}}_clampToBounds(e){if(!e)return null;const{min:t,max:i}=this._resolvedBounds();return s.clampDateIso(e,t,i)}_isWithinBounds(e){const{min:t,max:i}=this._resolvedBounds();return!(t&&w.compareISO(e,t)<0||i&&w.compareISO(e,i)>0)}_formatDisplay(e){return s.formatDateForDisplay(e,this._locale(),this._formatMode(),this._displayFormat())}_syncValueAttribute(e){this._syncing=!0;try{e?this.getAttribute("value")!==e&&this.setAttribute("value",e):this.hasAttribute("value")&&this.removeAttribute("value")}finally{this._syncing=!1}}_syncOpenAttribute(e){this._syncing=!0;try{e?this.hasAttribute("open")||this.setAttribute("open",""):this.hasAttribute("open")&&this.removeAttribute("open")}finally{this._syncing=!1}}_emitInput(e){const t={mode:"single",value:this._pendingValue,displayValue:this._formatDisplay(this._pendingValue),source:e};this.dispatchEvent(new CustomEvent("input",{detail:t,bubbles:!0,composed:!0}))}_emitChange(e){const t={mode:"single",value:this._value,displayValue:this._formatDisplay(this._value),source:e};this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,composed:!0}))}_emitInvalid(e,t){this.dispatchEvent(new CustomEvent("invalid",{detail:{raw:e,reason:t},bubbles:!0,composed:!0}))}_setOpen(e,t){e&&this._isInteractionBlocked()||this._open!==e&&(this._open=e,this._overlayFocusedOnOpen=!1,this._lastOpenSource=t,this._syncOpenAttribute(e),this._syncOverlay(t),this._updateHostState(),this.dispatchEvent(new CustomEvent(e?"open":"close",{bubbles:!0,composed:!0})))}_syncOverlay(e){if(this._isInlineMode()){this._destroyOverlay();return}if(this._open)this._ensureOverlay(),this._syncOverlayState();else if(this._destroyOverlay(),e!=="outside"){const t=this._restoreFocusEl||this.root.querySelector(".input");if(this._restoreFocusEl=null,t&&t.isConnected)try{t.focus()}catch{}}}_ensureOverlay(){if(this._overlay||typeof document>"u")return;const e=document.createElement("div");e.className="ui-date-picker-overlay-host",e.style.position="fixed",e.style.left="0",e.style.top="0",e.style.zIndex="1100",e.style.pointerEvents="none",e.addEventListener("click",this._onOverlayClickBound),e.addEventListener("select",this._onOverlaySelectBound),e.addEventListener("change",this._onOverlaySelectBound),document.body.appendChild(e),this._overlay=e,document.addEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.addEventListener("keydown",this._onDocumentKeyDownBound),window.addEventListener("resize",this._onWindowResizeBound),window.addEventListener("scroll",this._onWindowScrollBound,!0),this._isMobileSheet()&&(this._releaseScrollLock=s.lockBodyScroll())}_destroyOverlay(){this._overlay&&(this._schedulePosition.cancel(),document.removeEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.removeEventListener("keydown",this._onDocumentKeyDownBound),window.removeEventListener("resize",this._onWindowResizeBound),window.removeEventListener("scroll",this._onWindowScrollBound,!0),this._overlay.removeEventListener("click",this._onOverlayClickBound),this._overlay.removeEventListener("select",this._onOverlaySelectBound),this._overlay.removeEventListener("change",this._onOverlaySelectBound),this._overlay.parentElement&&this._overlay.parentElement.removeChild(this._overlay),this._overlay=null,this._overlayMode=null,this._releaseScrollLock&&(this._releaseScrollLock(),this._releaseScrollLock=null))}_positionOverlay(){if(!this._overlay||!this._open||this._isMobileSheet())return;const e=this.root.querySelector(".field"),t=this._overlay.querySelector(".panel");if(!e||!t)return;const i=e.getBoundingClientRect();t.style.setProperty("--ui-dp-panel-width",`${Math.round(i.width)}px`);const r=t.getBoundingClientRect(),n=s.computePopoverPosition(i,r);t.style.position="absolute",t.style.top=`${Math.round(n.top)}px`,t.style.left=`${Math.round(n.left)}px`,t.setAttribute("data-placement",n.placement)}_parseAndValidate(e){return s.parseUserDateInput(e,this._locale())}_commit(e,t){if(this._isReadonly()||this._isInteractionBlocked())return;const i=this._clampToBounds(e);this._value=i,this._pendingValue=i,this._draftInput=this._formatDisplay(i),this._inlineError="",this._syncValueAttribute(i),this._emitInput(t),this._emitChange(t),this._updateHostState()}_renderPanelInner(e){const t=this._translations(),i=(this.getAttribute("label")||"").trim(),r=!!i||e,n=!this._closeOnSelect()||e,o=e?"sheet":"panel",l=e?"true":"false";return`
|
|
528
|
-
<style>${
|
|
527
|
+
`;function v(S){return S.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}class z extends P.ElementBase{constructor(){super(...arguments),this._value=null,this._pendingValue=null,this._draftInput="",this._inlineError="",this._open=!1,this._syncing=!1,this._overlay=null,this._dismissableLayer=null,this._releaseScrollLock=null,this._lastOpenSource="api",this._restoreFocusEl=null,this._isInitialized=!1,this._hasView=!1,this._overlayMode=null,this._uid=`ui-dp-${++q}`,this._inputId=`${this._uid}-input`,this._labelId=`${this._uid}-label`,this._hintId=`${this._uid}-hint`,this._errorId=`${this._uid}-error`,this._panelId=`${this._uid}-panel`,this._panelTitleId=`${this._uid}-panel-title`,this._overlayFocusedOnOpen=!1,this._inlineCalendarFramePending=!1,this._inlineCalendarUpgradePending=!1,this._schedulePosition=a.rafThrottle(()=>this._positionOverlay()),this._onRootClickBound=e=>this._onRootClick(e),this._onRootInputBound=e=>this._onRootInput(e),this._onRootBlurBound=e=>this._onRootBlur(e),this._onRootKeyDownBound=e=>this._onRootKeyDown(e),this._onDocumentPointerDownBound=e=>this._onDocumentPointerDown(e),this._onDocumentKeyDownBound=e=>this._onDocumentKeyDown(e),this._onWindowResizeBound=()=>this._schedulePosition.run(),this._onWindowScrollBound=e=>{a.eventOriginatesWithin(e,[this._overlay])||this._schedulePosition.run()},this._onOverlayClickBound=e=>this._onOverlayClick(e),this._onOverlaySelectBound=e=>this._onCalendarSelect(e)}static get observedAttributes(){return["open","default-open","value","default-value","min","max","locale","translations","week-start","size","shape","bare","variant","state","placeholder","label","hint","error","clearable","allow-input","close-on-select","outside-click","disabled","readonly","required","name","mode","events","events-max","events-display","format","display-format","show-footer"]}connectedCallback(){if(super.connectedCallback(),this.root.addEventListener("click",this._onRootClickBound),this.root.addEventListener("input",this._onRootInputBound),this.root.addEventListener("focusout",this._onRootBlurBound),this.root.addEventListener("keydown",this._onRootKeyDownBound),!this._isInitialized){const e=this._clampToBounds(a.normalizeDateIso(this.getAttribute("value"))||a.normalizeDateIso(this.getAttribute("default-value")));this._value=e,this._pendingValue=e,this._draftInput=this._formatDisplay(e),this._open=this.hasAttribute("open")||a.isTruthyAttr(this.getAttribute("default-open")),this._isInitialized=!0}this._open&&!this._isInlineMode()&&this._ensureOverlay(),this._isInlineMode()&&this._scheduleInlineCalendarSync()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClickBound),this.root.removeEventListener("input",this._onRootInputBound),this.root.removeEventListener("focusout",this._onRootBlurBound),this.root.removeEventListener("keydown",this._onRootKeyDownBound),this._destroyOverlay(),super.disconnectedCallback()}attributeChangedCallback(e,t,i){if(t!==i){if(e==="value"&&!this._syncing&&(this._value=this._clampToBounds(a.normalizeDateIso(i)),this._pendingValue=this._value,this._draftInput=this._formatDisplay(this._value),this._inlineError="",this._syncValueAttribute(this._value)),e==="open"&&!this._syncing&&(this._open=this.hasAttribute("open"),this._syncOverlay(this._open?"api":"outside")),e==="mode"&&this._syncOverlay("attribute"),e==="disabled"&&this.hasAttribute("disabled")&&this._setOpen(!1,"outside"),(e==="min"||e==="max")&&!this._syncing){const r=this._clampToBounds(this._value),n=this._clampToBounds(this._pendingValue);this._value=r,this._pendingValue=n,this._draftInput=this._formatDisplay(this._allowInput()?n:r),this._syncValueAttribute(r)}if(e==="state"&&this._state()==="loading"&&this._setOpen(!1,"outside"),!!this.isConnected){if(!this._hasView){this.requestRender();return}this._updateHostState()}}}_isInlineMode(){return(this.getAttribute("mode")||"popover")==="inline"}_isMobileSheet(){return a.shouldUseMobileSheet(this.getAttribute("mode"))}_isDisabled(){return this.hasAttribute("disabled")}_isReadonly(){return this.hasAttribute("readonly")}_allowInput(){return a.isTruthyAttr(this.getAttribute("allow-input"),!0)}_clearable(){return a.isTruthyAttr(this.getAttribute("clearable"),!0)}_closeOnSelect(){return a.isTruthyAttr(this.getAttribute("close-on-select"),!0)}_showFooter(){return a.isTruthyAttr(this.getAttribute("show-footer"),!0)}_isBare(){return a.isTruthyAttr(this.getAttribute("bare"),!1)}_locale(){return a.normalizeLocale(this.getAttribute("locale"))}_translations(){return w.resolveDateTimeTranslations(this.getAttribute("locale"),this.getAttribute("translations"))}_formatMode(){const e=(this.getAttribute("format")||"locale").trim();return e==="iso"||e==="custom"?e:"locale"}_displayFormat(){return(this.getAttribute("display-format")||"").trim()||null}_placeholder(){const e=this._translations(),t=this.getAttribute("placeholder");return t||(this._formatMode()==="iso"?"YYYY-MM-DD":e.selectDate)}_todayIso(){const e=new Date,t=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${e.getFullYear()}-${t}-${i}`}_state(){const e=(this.getAttribute("state")||"").trim().toLowerCase();return e==="loading"||e==="success"||e==="error"?e:"idle"}_isInteractionBlocked(){return this._isDisabled()||this._state()==="loading"}_minIso(){return a.parseConstraintDate(this.getAttribute("min"))}_maxIso(){return a.parseConstraintDate(this.getAttribute("max"))}_resolvedBounds(){let e=this._minIso(),t=this._maxIso();if(e&&t&&w.compareISO(e,t)>0){const i=e;e=t,t=i}return{min:e,max:t}}_clampToBounds(e){if(!e)return null;const{min:t,max:i}=this._resolvedBounds();return a.clampDateIso(e,t,i)}_isWithinBounds(e){const{min:t,max:i}=this._resolvedBounds();return!(t&&w.compareISO(e,t)<0||i&&w.compareISO(e,i)>0)}_formatDisplay(e){return a.formatDateForDisplay(e,this._locale(),this._formatMode(),this._displayFormat())}_syncValueAttribute(e){this._syncing=!0;try{e?this.getAttribute("value")!==e&&this.setAttribute("value",e):this.hasAttribute("value")&&this.removeAttribute("value")}finally{this._syncing=!1}}_syncOpenAttribute(e){this._syncing=!0;try{e?this.hasAttribute("open")||this.setAttribute("open",""):this.hasAttribute("open")&&this.removeAttribute("open")}finally{this._syncing=!1}}_emitInput(e){const t={mode:"single",value:this._pendingValue,displayValue:this._formatDisplay(this._pendingValue),source:e};this.dispatchEvent(new CustomEvent("input",{detail:t,bubbles:!0,composed:!0}))}_emitChange(e){const t={mode:"single",value:this._value,displayValue:this._formatDisplay(this._value),source:e};this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,composed:!0}))}_emitInvalid(e,t){this.dispatchEvent(new CustomEvent("invalid",{detail:{raw:e,reason:t},bubbles:!0,composed:!0}))}_setOpen(e,t){e&&this._isInteractionBlocked()||this._open!==e&&(this._open=e,this._overlayFocusedOnOpen=!1,this._lastOpenSource=t,this._syncOpenAttribute(e),this._syncOverlay(t),this._updateHostState(),this.dispatchEvent(new CustomEvent(e?"open":"close",{bubbles:!0,composed:!0})))}_syncOverlay(e){if(this._isInlineMode()){this._destroyOverlay();return}if(this._open)this._ensureOverlay(),this._syncOverlayState();else if(this._destroyOverlay(),e!=="outside"){const t=this._restoreFocusEl||this.root.querySelector(".input");if(this._restoreFocusEl=null,t&&t.isConnected)try{t.focus()}catch{}}}_ensureOverlay(){if(this._overlay||typeof document>"u")return;const e=document.createElement("div");e.className="ui-date-picker-overlay-host",e.style.position="fixed",e.style.left="0",e.style.top="0",e.style.pointerEvents="none",e.addEventListener("click",this._onOverlayClickBound),e.addEventListener("select",this._onOverlaySelectBound),e.addEventListener("change",this._onOverlaySelectBound),document.body.appendChild(e),this._overlay=e,this._syncOverlayHostZIndex(),document.addEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.addEventListener("keydown",this._onDocumentKeyDownBound),window.addEventListener("resize",this._onWindowResizeBound),window.addEventListener("scroll",this._onWindowScrollBound,{passive:!0,capture:!0}),this._isMobileSheet()&&(this._releaseScrollLock=a.lockBodyScroll())}_syncOverlayHostZIndex(){if(!this._overlay||typeof window>"u")return;const e=window.getComputedStyle(this).getPropertyValue("--ui-dp-z").trim();this._overlay.style.zIndex=e||"1600"}_destroyOverlay(){var e;(e=this._dismissableLayer)==null||e.destroy(),this._dismissableLayer=null,this._overlay&&(this._schedulePosition.cancel(),document.removeEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.removeEventListener("keydown",this._onDocumentKeyDownBound),window.removeEventListener("resize",this._onWindowResizeBound),window.removeEventListener("scroll",this._onWindowScrollBound,!0),this._overlay.removeEventListener("click",this._onOverlayClickBound),this._overlay.removeEventListener("select",this._onOverlaySelectBound),this._overlay.removeEventListener("change",this._onOverlaySelectBound),this._overlay.parentElement&&this._overlay.parentElement.removeChild(this._overlay),this._overlay=null,this._overlayMode=null,this._releaseScrollLock&&(this._releaseScrollLock(),this._releaseScrollLock=null))}_syncDismissableLayer(){var i;if((i=this._dismissableLayer)==null||i.destroy(),this._dismissableLayer=null,!this._open||!this._overlay)return;const e=this._overlay.querySelector(".panel, .sheet"),t=this.root.querySelector(".field");e&&(this._dismissableLayer=L.createDismissableLayer({node:e,trigger:t,closeOnEscape:!0,closeOnPointerOutside:!0,closeOnFocusOutside:!1,onBeforeDismiss:r=>r==="escape-key"?(this._setOpen(!1,"escape"),!1):(r==="outside-pointer"&&this._setOpen(!1,"outside"),!1)}))}_positionOverlay(){if(!this._overlay||!this._open||this._isMobileSheet())return;const e=this.root.querySelector(".field"),t=this._overlay.querySelector(".panel");if(!e||!t)return;const i=e.getBoundingClientRect();t.style.setProperty("--ui-dp-panel-width",`${Math.round(i.width)}px`);const r=t.getBoundingClientRect(),n=t.getAttribute("data-placement"),s=a.computePopoverPosition(i,r,8,8,n==="top"?"top":n==="bottom"?"bottom":null);t.style.position="absolute",t.style.top=`${Math.round(s.top)}px`,t.style.left=`${Math.round(s.left)}px`,t.setAttribute("data-placement",s.placement)}_parseAndValidate(e){return a.parseUserDateInput(e,this._locale())}_commit(e,t){if(this._isReadonly()||this._isInteractionBlocked())return;const i=this._clampToBounds(e);this._value=i,this._pendingValue=i,this._draftInput=this._formatDisplay(i),this._inlineError="",this._syncValueAttribute(i),this._emitInput(t),this._emitChange(t),this._updateHostState()}_renderPanelInner(e){const t=this._translations(),i=(this.getAttribute("label")||"").trim(),r=!!i||e,n=!this._closeOnSelect()||e,s=e?"sheet":"panel",l=e?"true":"false";return`
|
|
528
|
+
<style>${R}</style>
|
|
529
529
|
${e?'<div class="sheet-backdrop" data-action="backdrop"></div>':""}
|
|
530
|
-
<section class="${
|
|
530
|
+
<section class="${s}" id="${this._panelId}" part="${e?"sheet":"popover"}" role="dialog" aria-modal="${l}" aria-labelledby="${this._panelTitleId}" aria-label="${v(t.datePickerPanel)}">
|
|
531
531
|
<header class="header" part="header" ${r?"":"hidden"}>
|
|
532
532
|
<p class="title" id="${this._panelTitleId}" ${i?"":"hidden"}>${v(i)}</p>
|
|
533
533
|
${e?`<button type="button" class="action" data-action="cancel">${v(t.cancel)}</button>`:""}
|
|
@@ -539,19 +539,19 @@
|
|
|
539
539
|
${n?`<button type="button" class="action" data-tone="primary" data-action="apply" part="apply">${v(t.apply)}</button>`:""}
|
|
540
540
|
</footer>
|
|
541
541
|
</section>
|
|
542
|
-
`}_syncCalendarElement(e){const t=(a,c)=>{if(c==null||c===""){e.hasAttribute(a)&&e.removeAttribute(a);return}e.getAttribute(a)!==c&&e.setAttribute(a,c)},i=(a,c)=>{c?e.hasAttribute(a)||e.setAttribute(a,""):e.hasAttribute(a)&&e.removeAttribute(a)},{min:r,max:n}=this._resolvedBounds();t("selection","single"),t("value",this._pendingValue),t("min",r),t("max",n),t("locale",this.getAttribute("locale")),t("translations",this.getAttribute("translations")),t("week-start",this.getAttribute("week-start"));const l=this.getAttribute("size")||"sm";t("size",l==="lg"?"md":"sm"),t("variant",this.getAttribute("variant")),t("outside-click",this.getAttribute("outside-click")),t("events",this.getAttribute("events")),t("events-max",this.getAttribute("events-max")),t("events-display",this.getAttribute("events-display"));const u=e.classList.contains("inline-calendar");l==="lg"?(e.style.setProperty("--ui-calendar-day-height","1.95em"),e.style.setProperty("--ui-calendar-day-padding-block","0.2em"),e.style.setProperty("--ui-calendar-day-padding-inline","0.26em"),e.style.setProperty("--ui-calendar-gap","0.42em"),e.style.setProperty("--ui-calendar-day-font-size","0.78em"),e.style.setProperty("--ui-calendar-weekday-font-size","0.7em"),e.style.setProperty("--ui-calendar-title-font-size","0.88em")):(e.style.setProperty("--ui-calendar-day-height","2.4em"),e.style.setProperty("--ui-calendar-day-padding-block","0.14em"),e.style.setProperty("--ui-calendar-day-padding-inline","0.22em"),e.style.setProperty("--ui-calendar-gap","0.34em"),e.style.setProperty("--ui-calendar-day-font-size","0.72em"),e.style.setProperty("--ui-calendar-weekday-font-size","0.64em"),e.style.setProperty("--ui-calendar-title-font-size","0.8em")),u?(e.style.setProperty("--ui-calendar-day-height",l==="lg"?"2.1em":"1.92em"),e.style.setProperty("--ui-calendar-day-padding-block","0.08em"),e.style.setProperty("--ui-calendar-day-padding-inline","0.14em"),e.style.setProperty("--ui-calendar-frame-padding","0.28em"),e.style.setProperty("--ui-calendar-week-gap","0.16em"),e.style.setProperty("--ui-calendar-control-height","1.64em"),e.style.setProperty("--ui-calendar-gap","0.2em"),e.style.setProperty("--ui-calendar-day-font-size",l==="lg"?"0.76em":"0.68em"),e.style.setProperty("--ui-calendar-weekday-font-size",l==="lg"?"0.66em":"0.58em"),e.style.setProperty("--ui-calendar-title-font-size",l==="lg"?"0.84em":"0.76em")):(e.style.removeProperty("--ui-calendar-frame-padding"),e.style.removeProperty("--ui-calendar-week-gap"),e.style.removeProperty("--ui-calendar-control-height")),i("readonly",this._isReadonly()),i("disabled",this._isInteractionBlocked()),i("bare",this._isBare()),t("tabindex","-1"),t("aria-label",this.getAttribute("label")||this._translations().selectDate)}_ensureOverlayContent(e){if(!this._overlay)return;const t=e?"sheet":"popover";this._overlayMode===t&&this._overlay.querySelector(".dp-calendar")||(this._overlayMode=t,this._overlay.innerHTML=e?`<div class="sheet-wrap">${this._renderPanelInner(!0)}</div>`:`<div class="overlay">${this._renderPanelInner(!1)}</div>`)}_syncOverlayState(){if(!this._overlay)return;const e=this._isMobileSheet();e&&!this._releaseScrollLock?this._releaseScrollLock=s.lockBodyScroll():!e&&this._releaseScrollLock&&(this._releaseScrollLock(),this._releaseScrollLock=null),this._ensureOverlayContent(e);const t=this._overlay.querySelector(".title"),i=this._overlay.querySelector(".panel, .sheet"),r=this._overlay.querySelector(".header"),n=this._overlay.querySelector(".footer"),o=this._translations();if(i&&(i.dataset.bare=this._isBare()?"true":"false"),n&&(n.hidden=!this._showFooter()),r&&(r.hidden=!(this.getAttribute("label")||"").trim()&&!e),t){const p=(this.getAttribute("label")||"").trim();t.textContent=p,t.hidden=!p}const l=this._overlay.querySelector('[data-action="today"]');l&&(l.textContent=o.today);const u=this._overlay.querySelector('[data-action="clear"]');u&&(u.textContent=o.clear);const a=this._overlay.querySelector('[data-action="cancel"]');a&&(a.textContent=o.cancel);const c=this._overlay.querySelector('[data-action="apply"]');c&&(c.textContent=o.apply);const m=this._overlay.querySelector('[data-action="apply"]');m&&(m.hidden=this._closeOnSelect()&&!e);const f=this._overlay.querySelectorAll(".action"),g=this._isInteractionBlocked();f.forEach(p=>{p.disabled=g});const _=this._overlay.querySelector(".dp-calendar");_&&(this._syncCalendarElement(_),this._open&&!this._overlayFocusedOnOpen&&this._lastOpenSource!=="attribute"&&(this._overlayFocusedOnOpen=!0,requestAnimationFrame(()=>{if(!(!this._open||!this._overlay))try{_.focus({preventScroll:!0})}catch{}}))),e||this._schedulePosition.run()}_renderOverlay(){this._syncOverlayState()}_renderInlineCalendar(){const e=this.root.querySelector(".inline-calendar");e&&this._syncCalendarElement(e)}_scheduleInlineCalendarSync(){const e=()=>{!this.isConnected||!this._hasView||!this._isInlineMode()||this._renderInlineCalendar()};e(),this._inlineCalendarFramePending||(this._inlineCalendarFramePending=!0,requestAnimationFrame(()=>{this._inlineCalendarFramePending=!1,e()})),!this._inlineCalendarUpgradePending&&typeof customElements<"u"&&!customElements.get("ui-calendar")&&(this._inlineCalendarUpgradePending=!0,customElements.whenDefined("ui-calendar").then(()=>{this._inlineCalendarUpgradePending=!1,requestAnimationFrame(()=>{e()})}))}_handleDraftCommit(e){const t=this._draftInput.trim();if(!t){this._commit(null,e);return}const i=this._parseAndValidate(t);if(!i){this._inlineError=this.getAttribute("error")||this._translations().invalidDate,this._emitInvalid(t,"parse"),this._updateHostState();return}if(!this._isWithinBounds(i)){this._inlineError=this.getAttribute("error")||this._translations().dateOutOfRange,this._emitInvalid(t,"range"),this._updateHostState();return}this._pendingValue=i,this._commit(i,e)}_onRootClick(e){const t=e.target;if(!t)return;const i=t.closest("[data-action]"),r=i==null?void 0:i.getAttribute("data-action");if(!(!r||this._isInteractionBlocked())){if(r==="toggle"){this._restoreFocusEl=i,this._setOpen(!this._open,"api");return}if(r==="clear"){e.preventDefault(),this._commit(null,"clear");return}if(r==="today"){e.preventDefault();const n=this._todayIso(),o=this._parseAndValidate(n);if(!o)return;const{min:l,max:u}=this._resolvedBounds(),a=s.clampDateIso(o,l,u);if(!a)return;this._pendingValue=a,this._emitInput("today"),this._closeOnSelect()&&!this._isInlineMode()?(this._commit(a,"today"),this._setOpen(!1,"today")):this._updateHostState();return}if(r==="apply"){e.preventDefault(),this._commit(this._pendingValue,"apply"),this._isInlineMode()||this._setOpen(!1,"apply");return}if(r==="cancel"){e.preventDefault(),this._pendingValue=this._value,this._draftInput=this._formatDisplay(this._value),this._inlineError="",this._isInlineMode()||this._setOpen(!1,"outside"),this._updateHostState();return}}}_onRootInput(e){const t=e.target;if(!(t instanceof HTMLInputElement)||!t.classList.contains("input")||this._isInteractionBlocked()||!this._allowInput())return;this._draftInput=t.value,this._inlineError="";const i=this._parseAndValidate(t.value);this._pendingValue=i,this._emitInput("typing")}_onRootBlur(e){var n;const t=e,i=t.target;if(!(i instanceof HTMLInputElement)||!i.classList.contains("input")||!this._allowInput())return;this._draftInput=i.value;const r=t.relatedTarget;r&&((n=this._overlay)!=null&&n.contains(r))||this._open&&!this._isInlineMode()||this._handleDraftCommit("blur")}_onRootKeyDown(e){const t=e,i=t.target;if(i instanceof HTMLInputElement&&i.classList.contains("input")&&!this._isInteractionBlocked()){if(t.key==="Enter"){t.preventDefault(),this._draftInput=i.value,this._handleDraftCommit("enter"),this._isInlineMode()||this._setOpen(!1,"enter");return}if(t.key==="ArrowDown"&&!this._open&&!this._isInlineMode()){t.preventDefault(),this._setOpen(!0,"api");return}t.key==="Escape"&&this._open&&!this._isInlineMode()&&(t.preventDefault(),this._setOpen(!1,"escape"))}}_onDocumentPointerDown(e){if(!this._open||!this._overlay)return;const t=e.composedPath();t.includes(this)||t.includes(this._overlay)||this._setOpen(!1,"outside")}_onDocumentKeyDown(e){this._open&&e.key==="Escape"&&(e.preventDefault(),this._setOpen(!1,"escape"))}_onOverlayClick(e){const t=e.target;if(!t)return;const i=t.closest("[data-action]"),r=i==null?void 0:i.getAttribute("data-action");if(r&&!this._isInteractionBlocked()){if(r==="backdrop"){this._setOpen(!1,"outside");return}if(r==="today"){const n=this._parseAndValidate(this._todayIso());if(!n)return;const{min:o,max:l}=this._resolvedBounds(),u=s.clampDateIso(n,o,l);if(!u)return;this._pendingValue=u,this._emitInput("today"),this._closeOnSelect()?(this._commit(u,"today"),this._setOpen(!1,"today")):this._renderOverlay();return}if(r==="clear"){this._pendingValue=null,this._emitInput("clear"),this._closeOnSelect()?(this._commit(null,"clear"),this._setOpen(!1,"clear")):this._renderOverlay();return}if(r==="apply"){this._commit(this._pendingValue,"apply"),this._setOpen(!1,"apply");return}r==="cancel"&&(this._pendingValue=this._value,this._setOpen(!1,"outside"))}}_onCalendarSelect(e){var o,l;if(this._isInteractionBlocked())return;const t=e,i=e.target;if(!i||i.tagName.toLowerCase()!=="ui-calendar")return;let r=null;if(t.type==="select")r=s.normalizeDateIso(((o=t.detail)==null?void 0:o.value)||null);else if(t.type==="change"){const u=(l=t.detail)==null?void 0:l.value;typeof u=="string"&&(r=s.normalizeDateIso(u))}if(!r)return;const n=this._clampToBounds(r);n&&(this._pendingValue=n,this._emitInput("calendar"),this._closeOnSelect()?(this._commit(n,"calendar"),this._isInlineMode()||this._setOpen(!1,"calendar")):this._updateHostState())}_updateHostState(){if(!this._hasView)return;const e=this.getAttribute("label")||"",t=this.getAttribute("hint")||"",i=this.getAttribute("error")||"",r=this._inlineError||i,n=this._placeholder(),o=this._translations(),l=!!(this._value||this._pendingValue),u=this.getAttribute("name")||"",a=this._isInlineMode(),c=r?"error":this._state(),m=this._allowInput()?this._draftInput:this._formatDisplay(this._pendingValue||this._value),f=this.root.querySelector(".label"),g=this.root.querySelector(".label-text"),_=this.root.querySelector(".required"),p=this.root.querySelector(".field"),d=this.root.querySelector(".input"),x=this.root.querySelector('.btn[data-action="clear"]'),b=this.root.querySelector('.btn[data-action="toggle"]'),y=this.root.querySelector(".hint"),I=this.root.querySelector(".error"),k=this.root.querySelector(".hidden-input"),h=this.root.querySelector(".inline-panel"),B=this.root.querySelector('.inline-panel [data-action="today"]'),C=this.root.querySelector('.inline-panel [data-action="clear"]'),O=this.root.querySelector('.inline-panel [data-action="apply"]'),D=this.root.querySelector(".inline-panel .footer");if(f&&(f.hidden=!e,f.id=this._labelId,f.setAttribute("for",this._inputId)),g&&(g.textContent=e),_&&(_.hidden=!this.hasAttribute("required")),p&&(p.dataset.invalid=r?"true":"false",p.dataset.open=this._open&&!a?"true":"false",p.dataset.state=c,p.setAttribute("aria-disabled",this._isInteractionBlocked()?"true":"false")),d&&(d.value!==m&&(d.value=m),d.id=this._inputId,d.placeholder=n,d.readOnly=!this._allowInput()||this._isReadonly(),d.disabled=this._isInteractionBlocked(),d.required=this.hasAttribute("required"),d.autocomplete="off",d.setAttribute("role","combobox"),d.setAttribute("aria-haspopup","dialog"),d.setAttribute("aria-expanded",a?"false":String(this._open)),d.setAttribute("aria-controls",this._panelId),d.setAttribute("aria-invalid",r?"true":"false"),e?d.setAttribute("aria-labelledby",this._labelId):d.removeAttribute("aria-labelledby")),x&&(x.hidden=!(this._clearable()&&l),x.disabled=this._isInteractionBlocked(),x.setAttribute("aria-label",o.clearDate)),b&&(b.hidden=a,b.disabled=this._isInteractionBlocked(),b.setAttribute("aria-expanded",a?"false":String(this._open)),b.setAttribute("aria-controls",this._panelId),b.setAttribute("aria-label",o.toggleCalendar)),y&&(y.id=this._hintId,y.hidden=!t,y.textContent=t),I&&(I.id=this._errorId,I.hidden=!r,I.textContent=r),d){const A=[];t&&y&&!y.hidden&&A.push(this._hintId),r&&A.push(this._errorId),A.length?d.setAttribute("aria-describedby",A.join(" ")):d.removeAttribute("aria-describedby")}if(k&&(k.disabled=!u,k.name=u,k.value=this._value||""),h&&(h.hidden=!a,h.id=this._panelId,h.dataset.bare=this._isBare()?"true":"false",h.setAttribute("role","dialog"),h.setAttribute("aria-modal","false"),h.setAttribute("aria-label",e||o.selectDate)),D&&(D.hidden=!this._showFooter()),B&&(B.textContent=o.today),C&&(C.textContent=o.clear),O&&(O.textContent=o.apply),a){this._scheduleInlineCalendarSync(),this._destroyOverlay();return}this._open&&this._syncOverlayState()}render(){this._hasView||(this.setContent(`
|
|
543
|
-
<style>${
|
|
542
|
+
`}_syncCalendarElement(e){const t=(o,c)=>{if(c==null||c===""){e.hasAttribute(o)&&e.removeAttribute(o);return}e.getAttribute(o)!==c&&e.setAttribute(o,c)},i=(o,c)=>{c?e.hasAttribute(o)||e.setAttribute(o,""):e.hasAttribute(o)&&e.removeAttribute(o)},{min:r,max:n}=this._resolvedBounds();t("selection","single"),t("value",this._pendingValue),t("min",r),t("max",n),t("locale",this.getAttribute("locale")),t("translations",this.getAttribute("translations")),t("week-start",this.getAttribute("week-start"));const l=this.getAttribute("size")||"sm";t("size",l==="lg"?"md":"sm"),t("variant",this.getAttribute("variant")),t("outside-click",this.getAttribute("outside-click")),t("events",this.getAttribute("events")),t("events-max",this.getAttribute("events-max")),t("events-display",this.getAttribute("events-display"));const u=e.classList.contains("inline-calendar");l==="lg"?(e.style.setProperty("--ui-calendar-day-height","1.95em"),e.style.setProperty("--ui-calendar-day-padding-block","0.2em"),e.style.setProperty("--ui-calendar-day-padding-inline","0.26em"),e.style.setProperty("--ui-calendar-gap","0.42em"),e.style.setProperty("--ui-calendar-day-font-size","0.78em"),e.style.setProperty("--ui-calendar-weekday-font-size","0.7em"),e.style.setProperty("--ui-calendar-title-font-size","0.88em")):(e.style.setProperty("--ui-calendar-day-height","2.4em"),e.style.setProperty("--ui-calendar-day-padding-block","0.14em"),e.style.setProperty("--ui-calendar-day-padding-inline","0.22em"),e.style.setProperty("--ui-calendar-gap","0.34em"),e.style.setProperty("--ui-calendar-day-font-size","0.72em"),e.style.setProperty("--ui-calendar-weekday-font-size","0.64em"),e.style.setProperty("--ui-calendar-title-font-size","0.8em")),u?(e.style.setProperty("--ui-calendar-day-height",l==="lg"?"2.1em":"1.92em"),e.style.setProperty("--ui-calendar-day-padding-block","0.08em"),e.style.setProperty("--ui-calendar-day-padding-inline","0.14em"),e.style.setProperty("--ui-calendar-frame-padding","0.28em"),e.style.setProperty("--ui-calendar-week-gap","0.16em"),e.style.setProperty("--ui-calendar-control-height","1.64em"),e.style.setProperty("--ui-calendar-gap","0.2em"),e.style.setProperty("--ui-calendar-day-font-size",l==="lg"?"0.76em":"0.68em"),e.style.setProperty("--ui-calendar-weekday-font-size",l==="lg"?"0.66em":"0.58em"),e.style.setProperty("--ui-calendar-title-font-size",l==="lg"?"0.84em":"0.76em")):(e.style.removeProperty("--ui-calendar-frame-padding"),e.style.removeProperty("--ui-calendar-week-gap"),e.style.removeProperty("--ui-calendar-control-height")),i("readonly",this._isReadonly()),i("disabled",this._isInteractionBlocked()),i("bare",this._isBare()),t("tabindex","-1"),t("aria-label",this.getAttribute("label")||this._translations().selectDate)}_ensureOverlayContent(e){if(!this._overlay)return;const t=e?"sheet":"popover";this._overlayMode===t&&this._overlay.querySelector(".dp-calendar")||(this._overlayMode=t,this._overlay.innerHTML=e?`<div class="sheet-wrap">${this._renderPanelInner(!0)}</div>`:`<div class="overlay">${this._renderPanelInner(!1)}</div>`)}_syncOverlayState(){if(!this._overlay)return;this._syncOverlayHostZIndex();const e=this._isMobileSheet();e&&!this._releaseScrollLock?this._releaseScrollLock=a.lockBodyScroll():!e&&this._releaseScrollLock&&(this._releaseScrollLock(),this._releaseScrollLock=null),this._ensureOverlayContent(e);const t=this._overlay.querySelector(".title"),i=this._overlay.querySelector(".panel, .sheet");this._syncDismissableLayer();const r=this._overlay.querySelector(".header"),n=this._overlay.querySelector(".footer"),s=this._translations();if(i&&(i.dataset.bare=this._isBare()?"true":"false"),n&&(n.hidden=!this._showFooter()),r&&(r.hidden=!(this.getAttribute("label")||"").trim()&&!e),t){const p=(this.getAttribute("label")||"").trim();t.textContent=p,t.hidden=!p}const l=this._overlay.querySelector('[data-action="today"]');l&&(l.textContent=s.today);const u=this._overlay.querySelector('[data-action="clear"]');u&&(u.textContent=s.clear);const o=this._overlay.querySelector('[data-action="cancel"]');o&&(o.textContent=s.cancel);const c=this._overlay.querySelector('[data-action="apply"]');c&&(c.textContent=s.apply);const m=this._overlay.querySelector('[data-action="apply"]');m&&(m.hidden=this._closeOnSelect()&&!e);const f=this._overlay.querySelectorAll(".action"),g=this._isInteractionBlocked();f.forEach(p=>{p.disabled=g});const _=this._overlay.querySelector(".dp-calendar");_&&(this._syncCalendarElement(_),this._open&&!this._overlayFocusedOnOpen&&this._lastOpenSource!=="attribute"&&(this._overlayFocusedOnOpen=!0,requestAnimationFrame(()=>{if(!(!this._open||!this._overlay))try{_.focus({preventScroll:!0})}catch{}}))),e||this._schedulePosition.run()}_renderOverlay(){this._syncOverlayState()}_renderInlineCalendar(){const e=this.root.querySelector(".inline-calendar");e&&this._syncCalendarElement(e)}_scheduleInlineCalendarSync(){const e=()=>{!this.isConnected||!this._hasView||!this._isInlineMode()||this._renderInlineCalendar()};e(),this._inlineCalendarFramePending||(this._inlineCalendarFramePending=!0,requestAnimationFrame(()=>{this._inlineCalendarFramePending=!1,e()})),!this._inlineCalendarUpgradePending&&typeof customElements<"u"&&!customElements.get("ui-calendar")&&(this._inlineCalendarUpgradePending=!0,customElements.whenDefined("ui-calendar").then(()=>{this._inlineCalendarUpgradePending=!1,requestAnimationFrame(()=>{e()})}))}_handleDraftCommit(e){const t=this._draftInput.trim();if(!t){this._commit(null,e);return}const i=this._parseAndValidate(t);if(!i){this._inlineError=this.getAttribute("error")||this._translations().invalidDate,this._emitInvalid(t,"parse"),this._updateHostState();return}if(!this._isWithinBounds(i)){this._inlineError=this.getAttribute("error")||this._translations().dateOutOfRange,this._emitInvalid(t,"range"),this._updateHostState();return}this._pendingValue=i,this._commit(i,e)}_onRootClick(e){const t=e.target;if(!t)return;const i=t.closest("[data-action]"),r=i==null?void 0:i.getAttribute("data-action");if(!(!r||this._isInteractionBlocked())){if(r==="toggle"){this._restoreFocusEl=i,this._setOpen(!this._open,"api");return}if(r==="clear"){e.preventDefault(),this._commit(null,"clear");return}if(r==="today"){e.preventDefault();const n=this._todayIso(),s=this._parseAndValidate(n);if(!s)return;const{min:l,max:u}=this._resolvedBounds(),o=a.clampDateIso(s,l,u);if(!o)return;this._pendingValue=o,this._emitInput("today"),this._closeOnSelect()&&!this._isInlineMode()?(this._commit(o,"today"),this._setOpen(!1,"today")):this._updateHostState();return}if(r==="apply"){e.preventDefault(),this._commit(this._pendingValue,"apply"),this._isInlineMode()||this._setOpen(!1,"apply");return}if(r==="cancel"){e.preventDefault(),this._pendingValue=this._value,this._draftInput=this._formatDisplay(this._value),this._inlineError="",this._isInlineMode()||this._setOpen(!1,"outside"),this._updateHostState();return}}}_onRootInput(e){const t=e.target;if(!(t instanceof HTMLInputElement)||!t.classList.contains("input")||this._isInteractionBlocked()||!this._allowInput())return;this._draftInput=t.value,this._inlineError="";const i=this._parseAndValidate(t.value);this._pendingValue=i,this._emitInput("typing")}_onRootBlur(e){var n;const t=e,i=t.target;if(!(i instanceof HTMLInputElement)||!i.classList.contains("input")||!this._allowInput())return;this._draftInput=i.value;const r=t.relatedTarget;r&&((n=this._overlay)!=null&&n.contains(r))||this._open&&!this._isInlineMode()||this._handleDraftCommit("blur")}_onRootKeyDown(e){const t=e,i=t.target;if(i instanceof HTMLInputElement&&i.classList.contains("input")&&!this._isInteractionBlocked()){if(t.key==="Enter"){t.preventDefault(),this._draftInput=i.value,this._handleDraftCommit("enter"),this._isInlineMode()||this._setOpen(!1,"enter");return}if(t.key==="ArrowDown"&&!this._open&&!this._isInlineMode()){t.preventDefault(),this._setOpen(!0,"api");return}t.key==="Escape"&&this._open&&!this._isInlineMode()&&(t.preventDefault(),this._setOpen(!1,"escape"))}}_onDocumentPointerDown(e){if(!this._open||!this._overlay)return;const t=e.composedPath();t.includes(this)||t.includes(this._overlay)||this._setOpen(!1,"outside")}_onDocumentKeyDown(e){this._open&&e.key==="Escape"&&(e.preventDefault(),this._setOpen(!1,"escape"))}_onOverlayClick(e){const t=e.target;if(!t)return;const i=t.closest("[data-action]"),r=i==null?void 0:i.getAttribute("data-action");if(r&&!this._isInteractionBlocked()){if(r==="backdrop"){this._setOpen(!1,"outside");return}if(r==="today"){const n=this._parseAndValidate(this._todayIso());if(!n)return;const{min:s,max:l}=this._resolvedBounds(),u=a.clampDateIso(n,s,l);if(!u)return;this._pendingValue=u,this._emitInput("today"),this._closeOnSelect()?(this._commit(u,"today"),this._setOpen(!1,"today")):this._renderOverlay();return}if(r==="clear"){this._pendingValue=null,this._emitInput("clear"),this._closeOnSelect()?(this._commit(null,"clear"),this._setOpen(!1,"clear")):this._renderOverlay();return}if(r==="apply"){this._commit(this._pendingValue,"apply"),this._setOpen(!1,"apply");return}r==="cancel"&&(this._pendingValue=this._value,this._setOpen(!1,"outside"))}}_onCalendarSelect(e){var s,l;if(this._isInteractionBlocked())return;const t=e,i=e.target;if(!i||i.tagName.toLowerCase()!=="ui-calendar")return;let r=null;if(t.type==="select")r=a.normalizeDateIso(((s=t.detail)==null?void 0:s.value)||null);else if(t.type==="change"){const u=(l=t.detail)==null?void 0:l.value;typeof u=="string"&&(r=a.normalizeDateIso(u))}if(!r)return;const n=this._clampToBounds(r);n&&(this._pendingValue=n,this._emitInput("calendar"),this._closeOnSelect()?(this._commit(n,"calendar"),this._isInlineMode()||this._setOpen(!1,"calendar")):this._updateHostState())}_updateHostState(){if(!this._hasView)return;const e=this.getAttribute("label")||"",t=this.getAttribute("hint")||"",i=this.getAttribute("error")||"",r=this._inlineError||i,n=this._placeholder(),s=this._translations(),l=!!(this._value||this._pendingValue),u=this.getAttribute("name")||"",o=this._isInlineMode(),c=r?"error":this._state(),m=this._allowInput()?this._draftInput:this._formatDisplay(this._pendingValue||this._value),f=this.root.querySelector(".label"),g=this.root.querySelector(".label-text"),_=this.root.querySelector(".required"),p=this.root.querySelector(".field"),d=this.root.querySelector(".input"),x=this.root.querySelector('.btn[data-action="clear"]'),b=this.root.querySelector('.btn[data-action="toggle"]'),y=this.root.querySelector(".hint"),I=this.root.querySelector(".error"),k=this.root.querySelector(".hidden-input"),h=this.root.querySelector(".inline-panel"),O=this.root.querySelector('.inline-panel [data-action="today"]'),B=this.root.querySelector('.inline-panel [data-action="clear"]'),C=this.root.querySelector('.inline-panel [data-action="apply"]'),D=this.root.querySelector(".inline-panel .footer");if(f&&(f.hidden=!e,f.id=this._labelId,f.setAttribute("for",this._inputId)),g&&(g.textContent=e),_&&(_.hidden=!this.hasAttribute("required")),p&&(p.dataset.invalid=r?"true":"false",p.dataset.open=this._open&&!o?"true":"false",p.dataset.state=c,p.setAttribute("aria-disabled",this._isInteractionBlocked()?"true":"false")),d&&(d.value!==m&&(d.value=m),d.id=this._inputId,d.placeholder=n,d.readOnly=!this._allowInput()||this._isReadonly(),d.disabled=this._isInteractionBlocked(),d.required=this.hasAttribute("required"),d.autocomplete="off",d.setAttribute("role","combobox"),d.setAttribute("aria-haspopup","dialog"),d.setAttribute("aria-expanded",o?"false":String(this._open)),d.setAttribute("aria-controls",this._panelId),d.setAttribute("aria-invalid",r?"true":"false"),e?d.setAttribute("aria-labelledby",this._labelId):d.removeAttribute("aria-labelledby")),x&&(x.hidden=!(this._clearable()&&l),x.disabled=this._isInteractionBlocked(),x.setAttribute("aria-label",s.clearDate)),b&&(b.hidden=o,b.disabled=this._isInteractionBlocked(),b.setAttribute("aria-expanded",o?"false":String(this._open)),b.setAttribute("aria-controls",this._panelId),b.setAttribute("aria-label",s.toggleCalendar)),y&&(y.id=this._hintId,y.hidden=!t,y.textContent=t),I&&(I.id=this._errorId,I.hidden=!r,I.textContent=r),d){const A=[];t&&y&&!y.hidden&&A.push(this._hintId),r&&A.push(this._errorId),A.length?d.setAttribute("aria-describedby",A.join(" ")):d.removeAttribute("aria-describedby")}if(k&&(k.disabled=!u,k.name=u,k.value=this._value||""),h&&(h.hidden=!o,h.id=this._panelId,h.dataset.bare=this._isBare()?"true":"false",h.setAttribute("role","dialog"),h.setAttribute("aria-modal","false"),h.setAttribute("aria-label",e||s.selectDate)),D&&(D.hidden=!this._showFooter()),O&&(O.textContent=s.today),B&&(B.textContent=s.clear),C&&(C.textContent=s.apply),o){this._scheduleInlineCalendarSync(),this._destroyOverlay();return}this._open&&this._syncOverlayState()}render(){this._hasView||(this.setContent(`
|
|
543
|
+
<style>${$}</style>
|
|
544
544
|
<div class="root">
|
|
545
545
|
<label class="label" part="label" id="${this._labelId}">
|
|
546
546
|
<span class="label-text"></span>
|
|
547
547
|
<span class="required">*</span>
|
|
548
548
|
</label>
|
|
549
549
|
<div class="field" part="field input">
|
|
550
|
-
<span class="icon" part="icon" aria-hidden="true">${
|
|
550
|
+
<span class="icon" part="icon" aria-hidden="true">${M}</span>
|
|
551
551
|
<input class="input" id="${this._inputId}" part="input" />
|
|
552
|
-
<button type="button" class="btn" part="clear" data-action="clear">${
|
|
552
|
+
<button type="button" class="btn" part="clear" data-action="clear">${E}</button>
|
|
553
553
|
<button type="button" class="btn" part="toggle" data-action="toggle">
|
|
554
|
-
<span class="toggle-icon">${
|
|
554
|
+
<span class="toggle-icon">${V}</span>
|
|
555
555
|
<span class="spinner" aria-hidden="true"></span>
|
|
556
556
|
</button>
|
|
557
557
|
</div>
|
package/dist/date-picker.esm.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import {
|
|
3
|
-
import { r as E,
|
|
4
|
-
import "./
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { E as q } from "./ElementBase-909688f3.mjs";
|
|
2
|
+
import { c as M } from "./dismissable-layer-9c7e6b58.mjs";
|
|
3
|
+
import { r as E, c as S } from "./calendar-2c11b824.mjs";
|
|
4
|
+
import { r as $, e as R, n as g, i as y, s as F, b as T, p as L, a as O, f as H, l as V, c as U, d as Y } from "./date-time-utils-a8b17ea7.mjs";
|
|
5
|
+
import "./scroll-lock-31da444f.mjs";
|
|
6
|
+
let K = 0;
|
|
7
|
+
const W = `
|
|
7
8
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
8
9
|
<path d="M6 2a1 1 0 0 1 1 1v1h6V3a1 1 0 1 1 2 0v1h.5A2.5 2.5 0 0 1 18 6.5v9A2.5 2.5 0 0 1 15.5 18h-11A2.5 2.5 0 0 1 2 15.5v-9A2.5 2.5 0 0 1 4.5 4H5V3a1 1 0 0 1 1-1Zm10 7H4v6.5c0 .276.224.5.5.5h11a.5.5 0 0 0 .5-.5V9ZM4.5 6a.5.5 0 0 0-.5.5V7h12v-.5a.5.5 0 0 0-.5-.5h-11Z" fill="currentColor"/>
|
|
9
10
|
</svg>
|
|
10
|
-
`,
|
|
11
|
+
`, Z = `
|
|
11
12
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
12
13
|
<path d="M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.12l3.71-3.9a.75.75 0 1 1 1.08 1.04l-4.25 4.47a.75.75 0 0 1-1.08 0L5.2 8.27a.75.75 0 0 1 .02-1.06Z" fill="currentColor"/>
|
|
13
14
|
</svg>
|
|
14
|
-
`,
|
|
15
|
+
`, N = `
|
|
15
16
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
16
17
|
<path d="M5.22 5.22a.75.75 0 0 1 1.06 0L10 8.94l3.72-3.72a.75.75 0 1 1 1.06 1.06L11.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06L10 11.06l-3.72 3.72a.75.75 0 1 1-1.06-1.06L8.94 10 5.22 6.28a.75.75 0 0 1 0-1.06Z" fill="currentColor"/>
|
|
17
18
|
</svg>
|
|
18
|
-
`,
|
|
19
|
+
`, j = `
|
|
19
20
|
:host {
|
|
20
21
|
--ui-dp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
21
22
|
--ui-dp-surface: linear-gradient(
|
|
@@ -386,7 +387,7 @@ const Y = `
|
|
|
386
387
|
transform: rotate(360deg);
|
|
387
388
|
}
|
|
388
389
|
}
|
|
389
|
-
`,
|
|
390
|
+
`, G = `
|
|
390
391
|
.overlay {
|
|
391
392
|
position: fixed;
|
|
392
393
|
z-index: var(--ui-dp-z, 1600);
|
|
@@ -530,12 +531,14 @@ const Y = `
|
|
|
530
531
|
}
|
|
531
532
|
}
|
|
532
533
|
`;
|
|
533
|
-
function v(
|
|
534
|
-
return
|
|
534
|
+
function v(B) {
|
|
535
|
+
return B.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
535
536
|
}
|
|
536
|
-
class
|
|
537
|
+
class J extends q {
|
|
537
538
|
constructor() {
|
|
538
|
-
super(...arguments), this._value = null, this._pendingValue = null, this._draftInput = "", this._inlineError = "", this._open = !1, this._syncing = !1, this._overlay = null, this._releaseScrollLock = null, this._lastOpenSource = "api", this._restoreFocusEl = null, this._isInitialized = !1, this._hasView = !1, this._overlayMode = null, this._uid = `ui-dp-${++
|
|
539
|
+
super(...arguments), this._value = null, this._pendingValue = null, this._draftInput = "", this._inlineError = "", this._open = !1, this._syncing = !1, this._overlay = null, this._dismissableLayer = null, this._releaseScrollLock = null, this._lastOpenSource = "api", this._restoreFocusEl = null, this._isInitialized = !1, this._hasView = !1, this._overlayMode = null, this._uid = `ui-dp-${++K}`, this._inputId = `${this._uid}-input`, this._labelId = `${this._uid}-label`, this._hintId = `${this._uid}-hint`, this._errorId = `${this._uid}-error`, this._panelId = `${this._uid}-panel`, this._panelTitleId = `${this._uid}-panel-title`, this._overlayFocusedOnOpen = !1, this._inlineCalendarFramePending = !1, this._inlineCalendarUpgradePending = !1, this._schedulePosition = $(() => this._positionOverlay()), this._onRootClickBound = (e) => this._onRootClick(e), this._onRootInputBound = (e) => this._onRootInput(e), this._onRootBlurBound = (e) => this._onRootBlur(e), this._onRootKeyDownBound = (e) => this._onRootKeyDown(e), this._onDocumentPointerDownBound = (e) => this._onDocumentPointerDown(e), this._onDocumentKeyDownBound = (e) => this._onDocumentKeyDown(e), this._onWindowResizeBound = () => this._schedulePosition.run(), this._onWindowScrollBound = (e) => {
|
|
540
|
+
R(e, [this._overlay]) || this._schedulePosition.run();
|
|
541
|
+
}, this._onOverlayClickBound = (e) => this._onOverlayClick(e), this._onOverlaySelectBound = (e) => this._onCalendarSelect(e);
|
|
539
542
|
}
|
|
540
543
|
static get observedAttributes() {
|
|
541
544
|
return [
|
|
@@ -589,8 +592,8 @@ class Z extends V {
|
|
|
589
592
|
attributeChangedCallback(e, t, i) {
|
|
590
593
|
if (t !== i) {
|
|
591
594
|
if (e === "value" && !this._syncing && (this._value = this._clampToBounds(g(i)), this._pendingValue = this._value, this._draftInput = this._formatDisplay(this._value), this._inlineError = "", this._syncValueAttribute(this._value)), e === "open" && !this._syncing && (this._open = this.hasAttribute("open"), this._syncOverlay(this._open ? "api" : "outside")), e === "mode" && this._syncOverlay("attribute"), e === "disabled" && this.hasAttribute("disabled") && this._setOpen(!1, "outside"), (e === "min" || e === "max") && !this._syncing) {
|
|
592
|
-
const r = this._clampToBounds(this._value),
|
|
593
|
-
this._value = r, this._pendingValue =
|
|
595
|
+
const r = this._clampToBounds(this._value), s = this._clampToBounds(this._pendingValue);
|
|
596
|
+
this._value = r, this._pendingValue = s, this._draftInput = this._formatDisplay(this._allowInput() ? s : r), this._syncValueAttribute(r);
|
|
594
597
|
}
|
|
595
598
|
if (e === "state" && this._state() === "loading" && this._setOpen(!1, "outside"), !!this.isConnected) {
|
|
596
599
|
if (!this._hasView) {
|
|
@@ -605,7 +608,7 @@ class Z extends V {
|
|
|
605
608
|
return (this.getAttribute("mode") || "popover") === "inline";
|
|
606
609
|
}
|
|
607
610
|
_isMobileSheet() {
|
|
608
|
-
return
|
|
611
|
+
return F(this.getAttribute("mode"));
|
|
609
612
|
}
|
|
610
613
|
_isDisabled() {
|
|
611
614
|
return this.hasAttribute("disabled");
|
|
@@ -629,10 +632,10 @@ class Z extends V {
|
|
|
629
632
|
return y(this.getAttribute("bare"), !1);
|
|
630
633
|
}
|
|
631
634
|
_locale() {
|
|
632
|
-
return
|
|
635
|
+
return T(this.getAttribute("locale"));
|
|
633
636
|
}
|
|
634
637
|
_translations() {
|
|
635
|
-
return
|
|
638
|
+
return E(
|
|
636
639
|
this.getAttribute("locale"),
|
|
637
640
|
this.getAttribute("translations")
|
|
638
641
|
);
|
|
@@ -677,14 +680,14 @@ class Z extends V {
|
|
|
677
680
|
if (!e)
|
|
678
681
|
return null;
|
|
679
682
|
const { min: t, max: i } = this._resolvedBounds();
|
|
680
|
-
return
|
|
683
|
+
return O(e, t, i);
|
|
681
684
|
}
|
|
682
685
|
_isWithinBounds(e) {
|
|
683
686
|
const { min: t, max: i } = this._resolvedBounds();
|
|
684
687
|
return !(t && S(e, t) < 0 || i && S(e, i) > 0);
|
|
685
688
|
}
|
|
686
689
|
_formatDisplay(e) {
|
|
687
|
-
return
|
|
690
|
+
return H(e, this._locale(), this._formatMode(), this._displayFormat());
|
|
688
691
|
}
|
|
689
692
|
_syncValueAttribute(e) {
|
|
690
693
|
this._syncing = !0;
|
|
@@ -752,10 +755,31 @@ class Z extends V {
|
|
|
752
755
|
if (this._overlay || typeof document > "u")
|
|
753
756
|
return;
|
|
754
757
|
const e = document.createElement("div");
|
|
755
|
-
e.className = "ui-date-picker-overlay-host", e.style.position = "fixed", e.style.left = "0", e.style.top = "0", e.style.
|
|
758
|
+
e.className = "ui-date-picker-overlay-host", e.style.position = "fixed", e.style.left = "0", e.style.top = "0", e.style.pointerEvents = "none", e.addEventListener("click", this._onOverlayClickBound), e.addEventListener("select", this._onOverlaySelectBound), e.addEventListener("change", this._onOverlaySelectBound), document.body.appendChild(e), this._overlay = e, this._syncOverlayHostZIndex(), document.addEventListener("pointerdown", this._onDocumentPointerDownBound, !0), document.addEventListener("keydown", this._onDocumentKeyDownBound), window.addEventListener("resize", this._onWindowResizeBound), window.addEventListener("scroll", this._onWindowScrollBound, { passive: !0, capture: !0 }), this._isMobileSheet() && (this._releaseScrollLock = V());
|
|
759
|
+
}
|
|
760
|
+
_syncOverlayHostZIndex() {
|
|
761
|
+
if (!this._overlay || typeof window > "u")
|
|
762
|
+
return;
|
|
763
|
+
const e = window.getComputedStyle(this).getPropertyValue("--ui-dp-z").trim();
|
|
764
|
+
this._overlay.style.zIndex = e || "1600";
|
|
756
765
|
}
|
|
757
766
|
_destroyOverlay() {
|
|
758
|
-
|
|
767
|
+
var e;
|
|
768
|
+
(e = this._dismissableLayer) == null || e.destroy(), this._dismissableLayer = null, this._overlay && (this._schedulePosition.cancel(), document.removeEventListener("pointerdown", this._onDocumentPointerDownBound, !0), document.removeEventListener("keydown", this._onDocumentKeyDownBound), window.removeEventListener("resize", this._onWindowResizeBound), window.removeEventListener("scroll", this._onWindowScrollBound, !0), this._overlay.removeEventListener("click", this._onOverlayClickBound), this._overlay.removeEventListener("select", this._onOverlaySelectBound), this._overlay.removeEventListener("change", this._onOverlaySelectBound), this._overlay.parentElement && this._overlay.parentElement.removeChild(this._overlay), this._overlay = null, this._overlayMode = null, this._releaseScrollLock && (this._releaseScrollLock(), this._releaseScrollLock = null));
|
|
769
|
+
}
|
|
770
|
+
_syncDismissableLayer() {
|
|
771
|
+
var i;
|
|
772
|
+
if ((i = this._dismissableLayer) == null || i.destroy(), this._dismissableLayer = null, !this._open || !this._overlay)
|
|
773
|
+
return;
|
|
774
|
+
const e = this._overlay.querySelector(".panel, .sheet"), t = this.root.querySelector(".field");
|
|
775
|
+
e && (this._dismissableLayer = M({
|
|
776
|
+
node: e,
|
|
777
|
+
trigger: t,
|
|
778
|
+
closeOnEscape: !0,
|
|
779
|
+
closeOnPointerOutside: !0,
|
|
780
|
+
closeOnFocusOutside: !1,
|
|
781
|
+
onBeforeDismiss: (r) => r === "escape-key" ? (this._setOpen(!1, "escape"), !1) : (r === "outside-pointer" && this._setOpen(!1, "outside"), !1)
|
|
782
|
+
}));
|
|
759
783
|
}
|
|
760
784
|
_positionOverlay() {
|
|
761
785
|
if (!this._overlay || !this._open || this._isMobileSheet())
|
|
@@ -765,11 +789,17 @@ class Z extends V {
|
|
|
765
789
|
return;
|
|
766
790
|
const i = e.getBoundingClientRect();
|
|
767
791
|
t.style.setProperty("--ui-dp-panel-width", `${Math.round(i.width)}px`);
|
|
768
|
-
const r = t.getBoundingClientRect(),
|
|
792
|
+
const r = t.getBoundingClientRect(), s = t.getAttribute("data-placement"), n = U(
|
|
793
|
+
i,
|
|
794
|
+
r,
|
|
795
|
+
8,
|
|
796
|
+
8,
|
|
797
|
+
s === "top" ? "top" : s === "bottom" ? "bottom" : null
|
|
798
|
+
);
|
|
769
799
|
t.style.position = "absolute", t.style.top = `${Math.round(n.top)}px`, t.style.left = `${Math.round(n.left)}px`, t.setAttribute("data-placement", n.placement);
|
|
770
800
|
}
|
|
771
801
|
_parseAndValidate(e) {
|
|
772
|
-
return
|
|
802
|
+
return Y(e, this._locale());
|
|
773
803
|
}
|
|
774
804
|
_commit(e, t) {
|
|
775
805
|
if (this._isReadonly() || this._isInteractionBlocked())
|
|
@@ -778,11 +808,11 @@ class Z extends V {
|
|
|
778
808
|
this._value = i, this._pendingValue = i, this._draftInput = this._formatDisplay(i), this._inlineError = "", this._syncValueAttribute(i), this._emitInput(t), this._emitChange(t), this._updateHostState();
|
|
779
809
|
}
|
|
780
810
|
_renderPanelInner(e) {
|
|
781
|
-
const t = this._translations(), i = (this.getAttribute("label") || "").trim(), r = !!i || e,
|
|
811
|
+
const t = this._translations(), i = (this.getAttribute("label") || "").trim(), r = !!i || e, s = !this._closeOnSelect() || e, n = e ? "sheet" : "panel", o = e ? "true" : "false";
|
|
782
812
|
return `
|
|
783
|
-
<style>${
|
|
813
|
+
<style>${G}</style>
|
|
784
814
|
${e ? '<div class="sheet-backdrop" data-action="backdrop"></div>' : ""}
|
|
785
|
-
<section class="${
|
|
815
|
+
<section class="${n}" id="${this._panelId}" part="${e ? "sheet" : "popover"}" role="dialog" aria-modal="${o}" aria-labelledby="${this._panelTitleId}" aria-label="${v(t.datePickerPanel)}">
|
|
786
816
|
<header class="header" part="header" ${r ? "" : "hidden"}>
|
|
787
817
|
<p class="title" id="${this._panelTitleId}" ${i ? "" : "hidden"}>${v(i)}</p>
|
|
788
818
|
${e ? `<button type="button" class="action" data-action="cancel">${v(t.cancel)}</button>` : ""}
|
|
@@ -791,22 +821,22 @@ class Z extends V {
|
|
|
791
821
|
<footer class="footer" part="footer">
|
|
792
822
|
<button type="button" class="action" data-action="today" part="presets">${v(t.today)}</button>
|
|
793
823
|
<button type="button" class="action" data-action="clear" part="clear">${v(t.clear)}</button>
|
|
794
|
-
${
|
|
824
|
+
${s ? `<button type="button" class="action" data-tone="primary" data-action="apply" part="apply">${v(t.apply)}</button>` : ""}
|
|
795
825
|
</footer>
|
|
796
826
|
</section>
|
|
797
827
|
`;
|
|
798
828
|
}
|
|
799
829
|
_syncCalendarElement(e) {
|
|
800
|
-
const t = (
|
|
830
|
+
const t = (a, u) => {
|
|
801
831
|
if (u == null || u === "") {
|
|
802
|
-
e.hasAttribute(
|
|
832
|
+
e.hasAttribute(a) && e.removeAttribute(a);
|
|
803
833
|
return;
|
|
804
834
|
}
|
|
805
|
-
e.getAttribute(
|
|
806
|
-
}, i = (
|
|
807
|
-
u ? e.hasAttribute(
|
|
808
|
-
}, { min: r, max:
|
|
809
|
-
t("selection", "single"), t("value", this._pendingValue), t("min", r), t("max",
|
|
835
|
+
e.getAttribute(a) !== u && e.setAttribute(a, u);
|
|
836
|
+
}, i = (a, u) => {
|
|
837
|
+
u ? e.hasAttribute(a) || e.setAttribute(a, "") : e.hasAttribute(a) && e.removeAttribute(a);
|
|
838
|
+
}, { min: r, max: s } = this._resolvedBounds();
|
|
839
|
+
t("selection", "single"), t("value", this._pendingValue), t("min", r), t("max", s), t("locale", this.getAttribute("locale")), t("translations", this.getAttribute("translations")), t("week-start", this.getAttribute("week-start"));
|
|
810
840
|
const o = this.getAttribute("size") || "sm";
|
|
811
841
|
t("size", o === "lg" ? "md" : "sm"), t("variant", this.getAttribute("variant")), t("outside-click", this.getAttribute("outside-click")), t("events", this.getAttribute("events")), t("events-max", this.getAttribute("events-max")), t("events-display", this.getAttribute("events-display"));
|
|
812
842
|
const d = e.classList.contains("inline-calendar");
|
|
@@ -821,21 +851,24 @@ class Z extends V {
|
|
|
821
851
|
_syncOverlayState() {
|
|
822
852
|
if (!this._overlay)
|
|
823
853
|
return;
|
|
854
|
+
this._syncOverlayHostZIndex();
|
|
824
855
|
const e = this._isMobileSheet();
|
|
825
|
-
e && !this._releaseScrollLock ? this._releaseScrollLock =
|
|
826
|
-
const t = this._overlay.querySelector(".title"), i = this._overlay.querySelector(".panel, .sheet")
|
|
827
|
-
|
|
856
|
+
e && !this._releaseScrollLock ? this._releaseScrollLock = V() : !e && this._releaseScrollLock && (this._releaseScrollLock(), this._releaseScrollLock = null), this._ensureOverlayContent(e);
|
|
857
|
+
const t = this._overlay.querySelector(".title"), i = this._overlay.querySelector(".panel, .sheet");
|
|
858
|
+
this._syncDismissableLayer();
|
|
859
|
+
const r = this._overlay.querySelector(".header"), s = this._overlay.querySelector(".footer"), n = this._translations();
|
|
860
|
+
if (i && (i.dataset.bare = this._isBare() ? "true" : "false"), s && (s.hidden = !this._showFooter()), r && (r.hidden = !(this.getAttribute("label") || "").trim() && !e), t) {
|
|
828
861
|
const c = (this.getAttribute("label") || "").trim();
|
|
829
862
|
t.textContent = c, t.hidden = !c;
|
|
830
863
|
}
|
|
831
864
|
const o = this._overlay.querySelector('[data-action="today"]');
|
|
832
|
-
o && (o.textContent =
|
|
865
|
+
o && (o.textContent = n.today);
|
|
833
866
|
const d = this._overlay.querySelector('[data-action="clear"]');
|
|
834
|
-
d && (d.textContent =
|
|
835
|
-
const
|
|
836
|
-
|
|
867
|
+
d && (d.textContent = n.clear);
|
|
868
|
+
const a = this._overlay.querySelector('[data-action="cancel"]');
|
|
869
|
+
a && (a.textContent = n.cancel);
|
|
837
870
|
const u = this._overlay.querySelector('[data-action="apply"]');
|
|
838
|
-
u && (u.textContent =
|
|
871
|
+
u && (u.textContent = n.apply);
|
|
839
872
|
const m = this._overlay.querySelector('[data-action="apply"]');
|
|
840
873
|
m && (m.hidden = this._closeOnSelect() && !e);
|
|
841
874
|
const h = this._overlay.querySelectorAll(".action"), x = this._isInteractionBlocked();
|
|
@@ -903,13 +936,13 @@ class Z extends V {
|
|
|
903
936
|
}
|
|
904
937
|
if (r === "today") {
|
|
905
938
|
e.preventDefault();
|
|
906
|
-
const
|
|
907
|
-
if (!
|
|
939
|
+
const s = this._todayIso(), n = this._parseAndValidate(s);
|
|
940
|
+
if (!n)
|
|
908
941
|
return;
|
|
909
|
-
const { min: o, max: d } = this._resolvedBounds(),
|
|
910
|
-
if (!
|
|
942
|
+
const { min: o, max: d } = this._resolvedBounds(), a = O(n, o, d);
|
|
943
|
+
if (!a)
|
|
911
944
|
return;
|
|
912
|
-
this._pendingValue =
|
|
945
|
+
this._pendingValue = a, this._emitInput("today"), this._closeOnSelect() && !this._isInlineMode() ? (this._commit(a, "today"), this._setOpen(!1, "today")) : this._updateHostState();
|
|
913
946
|
return;
|
|
914
947
|
}
|
|
915
948
|
if (r === "apply") {
|
|
@@ -931,13 +964,13 @@ class Z extends V {
|
|
|
931
964
|
this._pendingValue = i, this._emitInput("typing");
|
|
932
965
|
}
|
|
933
966
|
_onRootBlur(e) {
|
|
934
|
-
var
|
|
967
|
+
var s;
|
|
935
968
|
const t = e, i = t.target;
|
|
936
969
|
if (!(i instanceof HTMLInputElement) || !i.classList.contains("input") || !this._allowInput())
|
|
937
970
|
return;
|
|
938
971
|
this._draftInput = i.value;
|
|
939
972
|
const r = t.relatedTarget;
|
|
940
|
-
r && ((
|
|
973
|
+
r && ((s = this._overlay) != null && s.contains(r)) || this._open && !this._isInlineMode() || this._handleDraftCommit("blur");
|
|
941
974
|
}
|
|
942
975
|
_onRootKeyDown(e) {
|
|
943
976
|
const t = e, i = t.target;
|
|
@@ -973,10 +1006,10 @@ class Z extends V {
|
|
|
973
1006
|
return;
|
|
974
1007
|
}
|
|
975
1008
|
if (r === "today") {
|
|
976
|
-
const
|
|
977
|
-
if (!
|
|
1009
|
+
const s = this._parseAndValidate(this._todayIso());
|
|
1010
|
+
if (!s)
|
|
978
1011
|
return;
|
|
979
|
-
const { min:
|
|
1012
|
+
const { min: n, max: o } = this._resolvedBounds(), d = O(s, n, o);
|
|
980
1013
|
if (!d)
|
|
981
1014
|
return;
|
|
982
1015
|
this._pendingValue = d, this._emitInput("today"), this._closeOnSelect() ? (this._commit(d, "today"), this._setOpen(!1, "today")) : this._renderOverlay();
|
|
@@ -994,7 +1027,7 @@ class Z extends V {
|
|
|
994
1027
|
}
|
|
995
1028
|
}
|
|
996
1029
|
_onCalendarSelect(e) {
|
|
997
|
-
var
|
|
1030
|
+
var n, o;
|
|
998
1031
|
if (this._isInteractionBlocked())
|
|
999
1032
|
return;
|
|
1000
1033
|
const t = e, i = e.target;
|
|
@@ -1002,25 +1035,25 @@ class Z extends V {
|
|
|
1002
1035
|
return;
|
|
1003
1036
|
let r = null;
|
|
1004
1037
|
if (t.type === "select")
|
|
1005
|
-
r = g(((
|
|
1038
|
+
r = g(((n = t.detail) == null ? void 0 : n.value) || null);
|
|
1006
1039
|
else if (t.type === "change") {
|
|
1007
1040
|
const d = (o = t.detail) == null ? void 0 : o.value;
|
|
1008
1041
|
typeof d == "string" && (r = g(d));
|
|
1009
1042
|
}
|
|
1010
1043
|
if (!r)
|
|
1011
1044
|
return;
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1045
|
+
const s = this._clampToBounds(r);
|
|
1046
|
+
s && (this._pendingValue = s, this._emitInput("calendar"), this._closeOnSelect() ? (this._commit(s, "calendar"), this._isInlineMode() || this._setOpen(!1, "calendar")) : this._updateHostState());
|
|
1014
1047
|
}
|
|
1015
1048
|
_updateHostState() {
|
|
1016
1049
|
if (!this._hasView)
|
|
1017
1050
|
return;
|
|
1018
|
-
const e = this.getAttribute("label") || "", t = this.getAttribute("hint") || "", i = this.getAttribute("error") || "", r = this._inlineError || i,
|
|
1019
|
-
if (h && (h.hidden = !e, h.id = this._labelId, h.setAttribute("for", this._inputId)), x && (x.textContent = e), f && (f.hidden = !this.hasAttribute("required")), c && (c.dataset.invalid = r ? "true" : "false", c.dataset.open = this._open && !
|
|
1051
|
+
const e = this.getAttribute("label") || "", t = this.getAttribute("hint") || "", i = this.getAttribute("error") || "", r = this._inlineError || i, s = this._placeholder(), n = this._translations(), o = !!(this._value || this._pendingValue), d = this.getAttribute("name") || "", a = this._isInlineMode(), u = r ? "error" : this._state(), m = this._allowInput() ? this._draftInput : this._formatDisplay(this._pendingValue || this._value), h = this.root.querySelector(".label"), x = this.root.querySelector(".label-text"), f = this.root.querySelector(".required"), c = this.root.querySelector(".field"), l = this.root.querySelector(".input"), I = this.root.querySelector('.btn[data-action="clear"]'), _ = this.root.querySelector('.btn[data-action="toggle"]'), b = this.root.querySelector(".hint"), k = this.root.querySelector(".error"), A = this.root.querySelector(".hidden-input"), p = this.root.querySelector(".inline-panel"), C = this.root.querySelector('.inline-panel [data-action="today"]'), D = this.root.querySelector('.inline-panel [data-action="clear"]'), z = this.root.querySelector('.inline-panel [data-action="apply"]'), P = this.root.querySelector(".inline-panel .footer");
|
|
1052
|
+
if (h && (h.hidden = !e, h.id = this._labelId, h.setAttribute("for", this._inputId)), x && (x.textContent = e), f && (f.hidden = !this.hasAttribute("required")), c && (c.dataset.invalid = r ? "true" : "false", c.dataset.open = this._open && !a ? "true" : "false", c.dataset.state = u, c.setAttribute("aria-disabled", this._isInteractionBlocked() ? "true" : "false")), l && (l.value !== m && (l.value = m), l.id = this._inputId, l.placeholder = s, l.readOnly = !this._allowInput() || this._isReadonly(), l.disabled = this._isInteractionBlocked(), l.required = this.hasAttribute("required"), l.autocomplete = "off", l.setAttribute("role", "combobox"), l.setAttribute("aria-haspopup", "dialog"), l.setAttribute("aria-expanded", a ? "false" : String(this._open)), l.setAttribute("aria-controls", this._panelId), l.setAttribute("aria-invalid", r ? "true" : "false"), e ? l.setAttribute("aria-labelledby", this._labelId) : l.removeAttribute("aria-labelledby")), I && (I.hidden = !(this._clearable() && o), I.disabled = this._isInteractionBlocked(), I.setAttribute("aria-label", n.clearDate)), _ && (_.hidden = a, _.disabled = this._isInteractionBlocked(), _.setAttribute("aria-expanded", a ? "false" : String(this._open)), _.setAttribute("aria-controls", this._panelId), _.setAttribute("aria-label", n.toggleCalendar)), b && (b.id = this._hintId, b.hidden = !t, b.textContent = t), k && (k.id = this._errorId, k.hidden = !r, k.textContent = r), l) {
|
|
1020
1053
|
const w = [];
|
|
1021
1054
|
t && b && !b.hidden && w.push(this._hintId), r && w.push(this._errorId), w.length ? l.setAttribute("aria-describedby", w.join(" ")) : l.removeAttribute("aria-describedby");
|
|
1022
1055
|
}
|
|
1023
|
-
if (A && (A.disabled = !d, A.name = d, A.value = this._value || ""), p && (p.hidden = !
|
|
1056
|
+
if (A && (A.disabled = !d, A.name = d, A.value = this._value || ""), p && (p.hidden = !a, p.id = this._panelId, p.dataset.bare = this._isBare() ? "true" : "false", p.setAttribute("role", "dialog"), p.setAttribute("aria-modal", "false"), p.setAttribute("aria-label", e || n.selectDate)), P && (P.hidden = !this._showFooter()), C && (C.textContent = n.today), D && (D.textContent = n.clear), z && (z.textContent = n.apply), a) {
|
|
1024
1057
|
this._scheduleInlineCalendarSync(), this._destroyOverlay();
|
|
1025
1058
|
return;
|
|
1026
1059
|
}
|
|
@@ -1028,18 +1061,18 @@ class Z extends V {
|
|
|
1028
1061
|
}
|
|
1029
1062
|
render() {
|
|
1030
1063
|
this._hasView || (this.setContent(`
|
|
1031
|
-
<style>${
|
|
1064
|
+
<style>${j}</style>
|
|
1032
1065
|
<div class="root">
|
|
1033
1066
|
<label class="label" part="label" id="${this._labelId}">
|
|
1034
1067
|
<span class="label-text"></span>
|
|
1035
1068
|
<span class="required">*</span>
|
|
1036
1069
|
</label>
|
|
1037
1070
|
<div class="field" part="field input">
|
|
1038
|
-
<span class="icon" part="icon" aria-hidden="true">${
|
|
1071
|
+
<span class="icon" part="icon" aria-hidden="true">${W}</span>
|
|
1039
1072
|
<input class="input" id="${this._inputId}" part="input" />
|
|
1040
|
-
<button type="button" class="btn" part="clear" data-action="clear">${
|
|
1073
|
+
<button type="button" class="btn" part="clear" data-action="clear">${N}</button>
|
|
1041
1074
|
<button type="button" class="btn" part="toggle" data-action="toggle">
|
|
1042
|
-
<span class="toggle-icon">${
|
|
1075
|
+
<span class="toggle-icon">${Z}</span>
|
|
1043
1076
|
<span class="spinner" aria-hidden="true"></span>
|
|
1044
1077
|
</button>
|
|
1045
1078
|
</div>
|
|
@@ -1061,7 +1094,7 @@ class Z extends V {
|
|
|
1061
1094
|
return !1;
|
|
1062
1095
|
}
|
|
1063
1096
|
}
|
|
1064
|
-
typeof customElements < "u" && !customElements.get("ui-date-picker") && customElements.define("ui-date-picker",
|
|
1097
|
+
typeof customElements < "u" && !customElements.get("ui-date-picker") && customElements.define("ui-date-picker", J);
|
|
1065
1098
|
export {
|
|
1066
|
-
|
|
1099
|
+
J as UIDatePicker
|
|
1067
1100
|
};
|