lituix 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2812,6 +2812,11 @@ ${h1}
2812
2812
  ::slotted(lui-button-group-item) {
2813
2813
  --lui-button-radius: var(--lui-button-group-radius);
2814
2814
  }
2815
+ /* collapse 模式下子项不许收缩:否则 flex 会把每个 item 挤小,量的
2816
+ 就是压缩后的宽度,fullWidth 永远 ≤ 容器,永远不会溢出 */
2817
+ :host([collapse="auto"]) ::slotted(lui-button-group-item) {
2818
+ flex-shrink: 0;
2819
+ }
2815
2820
  ::slotted([data-overflow-hidden]) {
2816
2821
  position: absolute !important;
2817
2822
  inset-inline-start: -99999px !important;
@@ -7814,7 +7819,7 @@ ${h1}
7814
7819
  :host([hidden]) {
7815
7820
  display: none !important;
7816
7821
  }
7817
- `],a([(0,Ze.property)()],Ro.prototype,"key",2),a([(0,Ze.property)()],Ro.prototype,"value",2),a([(0,Ze.property)()],Ro.prototype,"label",2),a([(0,Ze.property)()],Ro.prototype,"icon",2),a([(0,Ze.property)()],Ro.prototype,"badge",2),a([(0,Ze.property)({type:Boolean,reflect:!0})],Ro.prototype,"disabled",2),a([(0,Ze.property)({type:Boolean,reflect:!0})],Ro.prototype,"closable",2),Ro=a([(0,Ze.customElement)("lui-tab-panel")],Ro);var Ft=class extends rt.LitElement{constructor(){super(...arguments);this.activeKey="";this.size="md";this.variant="line";this.placement="top";this._size=new vr(this);this.closable=!1;this.disabled=!1;this.collapse="none";this.overflowLabel="\u66F4\u591A";this.overflowIcon="more-horizontal";this._overflowIndexes=[];this._explicitAttrs=new Set;this._observedTabButtons=new Set;this._layoutFrame=0;this._indicatorFrame=0;this._indicatorLastKey=null;this._onExtraSlotChange=e=>{let r=e.currentTarget.assignedNodes({flatten:!0}).some(n=>n.nodeType===Node.ELEMENT_NODE?!0:!!n.textContent?.trim());this.toggleAttribute("has-extra",r)};this._onKeyDown=e=>{let t=this._tabs(),r=t.map((y,M)=>({item:y,index:M})).filter(({item:y})=>!y.disabled);if(!r.length)return;let n=this._resolvedActiveKey(t),s=Math.max(0,r.findIndex(({item:y,index:M})=>an(y,M)===n)),c=this._effectivePlacement==="top"||this._effectivePlacement==="bottom",u=c?"ArrowLeft":"ArrowUp",p=c?"ArrowRight":"ArrowDown",f=s;if(e.key===p)f=(s+1)%r.length;else if(e.key===u)f=(s-1+r.length)%r.length;else if(e.key==="Home")f=0;else if(e.key==="End")f=r.length-1;else return;e.preventDefault();let k=r[f];this._select(k.item,k.index),this.updateComplete.then(()=>{this.renderRoot.querySelector(`button[data-key="${CSS.escape(an(k.item,k.index))}"]`)?.focus()})}}get _effectivePlacement(){return this.placement!=="auto"?this.placement:this._size.measured&&this._size.atLeast("md")?"left":"top"}connectedCallback(){super.connectedCallback(),this._explicitAttrs=new Set(this.getAttributeNames()),this._resizeObserver=new ResizeObserver(()=>this._scheduleLayout())}firstUpdated(){this._resizeObserver?.observe(this),this._navEl&&this._resizeObserver?.observe(this._navEl),this.parentElement&&(this._observedParent=this.parentElement,this._resizeObserver?.observe(this.parentElement)),this._syncObservedTabButtons(),this._scheduleLayout()}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver?.disconnect(),this._layoutFrame&&cancelAnimationFrame(this._layoutFrame),this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame)}willUpdate(e){let t=L(this,"tab");!this._explicitAttrs.has("size")&&typeof t.size=="string"&&this.size!==t.size&&(this.size=t.size),!this._explicitAttrs.has("variant")&&typeof t.variant=="string"&&this.variant!==t.variant&&(this.variant=t.variant),!this._explicitAttrs.has("placement")&&typeof t.placement=="string"&&this.placement!==t.placement&&(this.placement=t.placement),!this._explicitAttrs.has("disabled")&&typeof t.disabled=="boolean"&&this.disabled!==t.disabled&&(this.disabled=t.disabled),!this._explicitAttrs.has("closable")&&typeof t.closable=="boolean"&&this.closable!==t.closable&&(this.closable=t.closable)}updated(e){this.parentElement&&this.parentElement!==this._observedParent&&(this._observedParent&&this._resizeObserver?.unobserve(this._observedParent),this._observedParent=this.parentElement,this._resizeObserver?.observe(this.parentElement));let t=this._resolvedActiveKey();t&&this.getAttribute("active-key")!==t&&this.setAttribute("active-key",t),this._syncPanels(),this._syncObservedTabButtons(),(e.has("items")||e.has("size")||e.has("variant")||e.has("placement")||e.has("closable")||e.has("disabled")||e.has("collapse")||e.has("activeKey"))&&this._scheduleLayout(),this._navEl?.setAttribute("data-indicator-still",""),this._scheduleActiveIndicatorLayout()}_syncObservedTabButtons(){if(!this._resizeObserver)return;let e=new Set(Array.from(this.renderRoot.querySelectorAll(".tab-button, .overflow-trigger")));for(let t of this._observedTabButtons)e.has(t)||this._resizeObserver.unobserve(t);for(let t of e)this._observedTabButtons.has(t)||this._resizeObserver.observe(t);this._observedTabButtons=e}_panelElements(){return(this._defaultSlot?.assignedElements({flatten:!0})??this._assignedElements??[]).filter(t=>t.tagName.toLowerCase()==="lui-tab-panel")}_itemsFromPanels(){return this._panelElements().map((e,t)=>({key:e.tabKey||String(t),label:e.label||e.getAttribute("label")||e.tabKey||`Tab ${t+1}`,icon:e.icon,badge:e.badge,disabled:e.disabled,closable:e.closable}))}_tabs(){return this.items?.length?this.items:this._itemsFromPanels()}_resolvedActiveKey(e=this._tabs()){let t=e.filter(r=>!r.disabled);return t.length?this.activeKey&&t.some((r,n)=>an(r,e.indexOf(r)>=0?e.indexOf(r):n)===this.activeKey)?this.activeKey:an(t[0],e.indexOf(t[0])):""}_syncPanels(){if(this.items?.length)return;let e=this._panelElements(),t=this._itemsFromPanels(),r=this._resolvedActiveKey(t);r&&this.activeKey!==r&&(this.activeKey=r),r&&this.getAttribute("active-key")!==r&&this.setAttribute("active-key",r),e.forEach((n,s)=>{let c=n.tabKey||String(s);n.hidden=c!==r})}_select(e,t){if(this.disabled||e.disabled)return;let r=an(e,t),n=this._resolvedActiveKey();r===n&&this.activeKey||(this.activeKey=r,this.dispatchEvent(new CustomEvent("change",{detail:{key:r,previousKey:n,item:e,index:t},bubbles:!0,composed:!0})))}_close(e,t,r){e.preventDefault(),e.stopPropagation();let n=an(t,r);this.dispatchEvent(new CustomEvent("close",{detail:{key:n,item:t,index:r,originalEvent:e},bubbles:!0,composed:!0,cancelable:!0}))}_scheduleLayout(){this._layoutFrame&&cancelAnimationFrame(this._layoutFrame),this._layoutFrame=requestAnimationFrame(()=>{this._layoutFrame=0,this._recomputeOverflow(),this._scheduleActiveIndicatorLayout()})}_scheduleActiveIndicatorLayout(){this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame),this._indicatorFrame=requestAnimationFrame(()=>{this._indicatorFrame=0,this._updateActiveIndicator()})}_updateActiveIndicator(){let e=this._navEl;if(!e)return;let t=this._resolvedActiveKey(),r=t?e.querySelector(`button.tab-button[data-key="${CSS.escape(t)}"]`):null;if(!r){e.style.setProperty("--lui-tab-indicator-opacity","0");return}let n=e.getBoundingClientRect(),s=r.getBoundingClientRect(),c=r.offsetWidth||s.width,u=r.offsetHeight||s.height;this._indicatorLastKey!==null&&this._indicatorLastKey!==t&&e.removeAttribute("data-indicator-still"),e.style.setProperty("--lui-tab-indicator-x",`${s.left-n.left+e.scrollLeft}px`),e.style.setProperty("--lui-tab-indicator-y",`${s.top-n.top+e.scrollTop}px`),e.style.setProperty("--lui-tab-indicator-width",`${c}px`),e.style.setProperty("--lui-tab-indicator-height",`${u}px`),e.style.setProperty("--lui-tab-indicator-opacity","1"),this._indicatorLastKey=t}_isHorizontal(){return this._effectivePlacement==="top"||this._effectivePlacement==="bottom"}_tabWidthBudget(){return Math.floor(this._navEl?.clientWidth??0)}_visibleIndexesForAuto(e){if(this.collapse!=="auto"||!this._isHorizontal()||e.length<=1)return e.map((y,M)=>M);let t=this._tabWidthBudget(),r=Array.from(this.renderRoot.querySelectorAll("[data-measure-tab-index]")),n=this.renderRoot.querySelector("[data-measure-overflow-trigger]");if(!t||r.length!==e.length||!n)return e.map((y,M)=>M);let s=Number.parseFloat(getComputedStyle(this._navEl).columnGap||"0")||0,c=r.map(y=>Math.ceil(y.getBoundingClientRect().width)),u=Math.ceil(n.getBoundingClientRect().width);if(c.reduce((y,M)=>y+M,0)+Math.max(0,e.length-1)*s<=t)return e.map((y,M)=>M);let f=[],k=u;for(let y=0;y<e.length;y+=1){let M=c[y]??0,C=k+(f.length>0?s:0)+M;C<=t&&(f.push(y),k=C)}return f}_recomputeOverflow(){let e=this._tabs(),t=new Set(this._visibleIndexesForAuto(e)),r=e.map((n,s)=>s).filter(n=>!t.has(n));Af(r,this._overflowIndexes)||(this._overflowIndexes=r)}_overflowMenuItems(e,t){return this._overflowIndexes.flatMap(r=>{let n=e[r];if(!n)return[];let s=an(n,r);return[{key:s,value:String(r),label:n.label??s,icon:n.icon,disabled:this.disabled||n.disabled,active:s===t}]})}_onOverflowSelect(e,t){let r=Number(e.detail?.value),n=t[r];n&&this._select(n,r)}_renderTab(e,t,r){let n=an(e,t),s=n===r,c=e.closable??this.closable;return rt.html`
7822
+ `],a([(0,Ze.property)()],Ro.prototype,"key",2),a([(0,Ze.property)()],Ro.prototype,"value",2),a([(0,Ze.property)()],Ro.prototype,"label",2),a([(0,Ze.property)()],Ro.prototype,"icon",2),a([(0,Ze.property)()],Ro.prototype,"badge",2),a([(0,Ze.property)({type:Boolean,reflect:!0})],Ro.prototype,"disabled",2),a([(0,Ze.property)({type:Boolean,reflect:!0})],Ro.prototype,"closable",2),Ro=a([(0,Ze.customElement)("lui-tab-panel")],Ro);var Ft=class extends rt.LitElement{constructor(){super(...arguments);this.activeKey="";this.size="md";this.variant="line";this.placement="top";this._size=new vr(this);this.closable=!1;this.disabled=!1;this.collapse="none";this.overflowLabel="\u66F4\u591A";this.overflowIcon="more-horizontal";this._overflowIndexes=[];this._explicitAttrs=new Set;this._observedTabButtons=new Set;this._layoutFrame=0;this._indicatorFrame=0;this._indicatorLastKey=null;this._onExtraSlotChange=e=>{let r=e.currentTarget.assignedNodes({flatten:!0}).some(n=>n.nodeType===Node.ELEMENT_NODE?!0:!!n.textContent?.trim());this.toggleAttribute("has-extra",r)};this._onKeyDown=e=>{let t=this._tabs(),r=t.map((y,M)=>({item:y,index:M})).filter(({item:y})=>!y.disabled);if(!r.length)return;let n=this._resolvedActiveKey(t),s=Math.max(0,r.findIndex(({item:y,index:M})=>an(y,M)===n)),c=this._effectivePlacement==="top"||this._effectivePlacement==="bottom",u=c?"ArrowLeft":"ArrowUp",p=c?"ArrowRight":"ArrowDown",f=s;if(e.key===p)f=(s+1)%r.length;else if(e.key===u)f=(s-1+r.length)%r.length;else if(e.key==="Home")f=0;else if(e.key==="End")f=r.length-1;else return;e.preventDefault();let k=r[f];this._select(k.item,k.index),this.updateComplete.then(()=>{this.renderRoot.querySelector(`button[data-key="${CSS.escape(an(k.item,k.index))}"]`)?.focus()})}}get _effectivePlacement(){return this.placement!=="auto"?this.placement:this._size.measured&&this._size.atLeast("md")?"left":"top"}connectedCallback(){super.connectedCallback(),this._explicitAttrs=new Set(this.getAttributeNames()),this._resizeObserver=new ResizeObserver(()=>this._scheduleLayout())}firstUpdated(){this._resizeObserver?.observe(this),this._navEl&&this._resizeObserver?.observe(this._navEl),this.parentElement&&(this._observedParent=this.parentElement,this._resizeObserver?.observe(this.parentElement)),this._syncObservedTabButtons(),this._scheduleLayout()}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver?.disconnect(),this._layoutFrame&&cancelAnimationFrame(this._layoutFrame),this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame)}willUpdate(e){let t=L(this,"tab");!this._explicitAttrs.has("size")&&typeof t.size=="string"&&this.size!==t.size&&(this.size=t.size),!this._explicitAttrs.has("variant")&&typeof t.variant=="string"&&this.variant!==t.variant&&(this.variant=t.variant),!this._explicitAttrs.has("placement")&&typeof t.placement=="string"&&this.placement!==t.placement&&(this.placement=t.placement),!this._explicitAttrs.has("disabled")&&typeof t.disabled=="boolean"&&this.disabled!==t.disabled&&(this.disabled=t.disabled),!this._explicitAttrs.has("closable")&&typeof t.closable=="boolean"&&this.closable!==t.closable&&(this.closable=t.closable)}updated(e){this.parentElement&&this.parentElement!==this._observedParent&&(this._observedParent&&this._resizeObserver?.unobserve(this._observedParent),this._observedParent=this.parentElement,this._resizeObserver?.observe(this.parentElement));let t=this._resolvedActiveKey();t&&this.getAttribute("active-key")!==t&&this.setAttribute("active-key",t),this._syncPanels(),this._syncObservedTabButtons(),(e.has("items")||e.has("size")||e.has("variant")||e.has("placement")||e.has("closable")||e.has("disabled")||e.has("collapse")||e.has("activeKey"))&&this._scheduleLayout(),this._navEl?.setAttribute("data-indicator-still",""),this._scheduleActiveIndicatorLayout()}_syncObservedTabButtons(){if(!this._resizeObserver)return;let e=new Set(Array.from(this.renderRoot.querySelectorAll(".tab-button, .overflow-trigger")));for(let t of this._observedTabButtons)e.has(t)||this._resizeObserver.unobserve(t);for(let t of e)this._observedTabButtons.has(t)||this._resizeObserver.observe(t);this._observedTabButtons=e}_panelElements(){return(this._defaultSlot?.assignedElements({flatten:!0})??this._assignedElements??[]).filter(t=>t.tagName.toLowerCase()==="lui-tab-panel")}_itemsFromPanels(){return this._panelElements().map((e,t)=>({key:e.tabKey||String(t),label:e.label||e.getAttribute("label")||e.tabKey||`Tab ${t+1}`,icon:e.icon,badge:e.badge,disabled:e.disabled,closable:e.closable}))}_tabs(){return this.items?.length?this.items:this._itemsFromPanels()}_resolvedActiveKey(e=this._tabs()){let t=e.filter(r=>!r.disabled);return t.length?this.activeKey&&t.some((r,n)=>an(r,e.indexOf(r)>=0?e.indexOf(r):n)===this.activeKey)?this.activeKey:an(t[0],e.indexOf(t[0])):""}_syncPanels(){if(this.items?.length)return;let e=this._panelElements(),t=this._itemsFromPanels(),r=this._resolvedActiveKey(t);r&&this.activeKey!==r&&(this.activeKey=r),r&&this.getAttribute("active-key")!==r&&this.setAttribute("active-key",r),e.forEach((n,s)=>{let c=n.tabKey||String(s);n.hidden=c!==r})}_select(e,t){if(this.disabled||e.disabled)return;let r=an(e,t),n=this._resolvedActiveKey();r===n&&this.activeKey||(this.activeKey=r,this.dispatchEvent(new CustomEvent("change",{detail:{key:r,previousKey:n,item:e,index:t},bubbles:!0,composed:!0})))}_close(e,t,r){e.preventDefault(),e.stopPropagation();let n=an(t,r);this.dispatchEvent(new CustomEvent("close",{detail:{key:n,item:t,index:r,originalEvent:e},bubbles:!0,composed:!0,cancelable:!0}))}_scheduleLayout(){this._layoutFrame&&cancelAnimationFrame(this._layoutFrame),this._layoutFrame=requestAnimationFrame(()=>{this._layoutFrame=0,this._recomputeOverflow(),this._scheduleActiveIndicatorLayout()})}_scheduleActiveIndicatorLayout(){this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame),this._indicatorFrame=requestAnimationFrame(()=>{this._indicatorFrame=0,this._updateActiveIndicator()})}_updateActiveIndicator(){let e=this._navEl;if(!e)return;let t=this._resolvedActiveKey(),r=t?e.querySelector(`button.tab-button[data-key="${CSS.escape(t)}"]`):null;if(!r){e.style.setProperty("--lui-tab-indicator-opacity","0");return}let n=e.getBoundingClientRect(),s=r.getBoundingClientRect(),c=r.offsetWidth||s.width,u=r.offsetHeight||s.height;this._indicatorLastKey!==null&&this._indicatorLastKey!==t&&e.removeAttribute("data-indicator-still"),e.style.setProperty("--lui-tab-indicator-x",`${s.left-n.left+e.scrollLeft}px`),e.style.setProperty("--lui-tab-indicator-y",`${s.top-n.top+e.scrollTop}px`),e.style.setProperty("--lui-tab-indicator-width",`${c}px`),e.style.setProperty("--lui-tab-indicator-height",`${u}px`),e.style.setProperty("--lui-tab-indicator-opacity","1"),this._indicatorLastKey=t}_isHorizontal(){return this._effectivePlacement==="top"||this._effectivePlacement==="bottom"}_tabWidthBudget(){let e=this._navEl?.parentElement;if(!e)return 0;let t=getComputedStyle(e),r=s=>parseFloat(s)||0,n=e.clientWidth-r(t.paddingLeft)-r(t.paddingRight);for(let s of Array.from(e.children)){if(s===this._navEl||getComputedStyle(s).position==="absolute")continue;let c=s.getBoundingClientRect().width;c>0&&(n-=c+r(t.columnGap))}return Math.max(0,Math.floor(n))}_visibleIndexesForAuto(e){if(this.collapse!=="auto"||!this._isHorizontal()||e.length<=1)return e.map((y,M)=>M);let t=this._tabWidthBudget(),r=Array.from(this.renderRoot.querySelectorAll("[data-measure-tab-index]")),n=this.renderRoot.querySelector("[data-measure-overflow-trigger]");if(!t||r.length!==e.length||!n)return e.map((y,M)=>M);let s=Number.parseFloat(getComputedStyle(this._navEl).columnGap||"0")||0,c=r.map(y=>Math.ceil(y.getBoundingClientRect().width)),u=Math.ceil(n.getBoundingClientRect().width);if(c.reduce((y,M)=>y+M,0)+Math.max(0,e.length-1)*s<=t)return e.map((y,M)=>M);let f=[],k=u;for(let y=0;y<e.length;y+=1){let M=c[y]??0,C=k+(f.length>0?s:0)+M;C<=t&&(f.push(y),k=C)}return f}_recomputeOverflow(){let e=this._tabs(),t=new Set(this._visibleIndexesForAuto(e)),r=e.map((n,s)=>s).filter(n=>!t.has(n));Af(r,this._overflowIndexes)||(this._overflowIndexes=r)}_overflowMenuItems(e,t){return this._overflowIndexes.flatMap(r=>{let n=e[r];if(!n)return[];let s=an(n,r);return[{key:s,value:String(r),label:n.label??s,icon:n.icon,disabled:this.disabled||n.disabled,active:s===t}]})}_onOverflowSelect(e,t){let r=Number(e.detail?.value),n=t[r];n&&this._select(n,r)}_renderTab(e,t,r){let n=an(e,t),s=n===r,c=e.closable??this.closable;return rt.html`
7818
7823
  <button
7819
7824
  class=${`tab-button ${s?"active":""}`}
7820
7825
  part="tab"
@@ -13660,7 +13665,7 @@ ${Hn}.lui-datepicker-sheet .flatpickr-innerContainer {
13660
13665
  color: var(--lui-color-fg);
13661
13666
  margin-bottom: var(--lui-space-1, 4px);
13662
13667
  }
13663
- `],a([(0,Mo.property)({attribute:!1})],Ur.prototype,"source",2),a([(0,Mo.property)()],Ur.prototype,"value",2),a([(0,Mo.property)({reflect:!0})],Ur.prototype,"direction",2),a([(0,Mo.property)({reflect:!0})],Ur.prototype,"size",2),a([(0,Mo.property)()],Ur.prototype,"name",2),a([(0,Mo.property)()],Ur.prototype,"label",2),a([(0,Mo.property)({type:Boolean})],Ur.prototype,"disabled",2),a([(0,Mo.property)({attribute:!1})],Ur.prototype,"radioProps",2),a([(0,Mo.query)("slot")],Ur.prototype,"_slotEl",2),a([(0,Mo.queryAll)("lui-radio")],Ur.prototype,"_renderedRadios",2),Ur=a([(0,Mo.customElement)("lui-radio-group")],Ur);var hn=require("lit"),Gt=require("lit/decorators.js"),M0=Dn(require("flatpickr"),1),C0=require("flatpickr/dist/l10n/zh.js"),k8=require("flatpickr/dist/flatpickr.min.css");var Gr=class extends hn.LitElement{constructor(){super(...arguments);this.value="";this.selectionMode="single";this.size="md";this.disabled=!1;this.showMonths=1;this.defaultDate="";this._fp=null;this._fittingMonths=3;this._unobserveParent=null}firstUpdated(){this._watchParent(),this._init()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this._watchParent()}disconnectedCallback(){this._unobserveParent?.(),this._unobserveParent=null,this._destroy(),super.disconnectedCallback()}updated(e){if(this._fp){if(e.has("value")){let t=this._dateInputValue();t?this._fp.setDate(t,!1):this._fp.clear()}(e.has("selectionMode")||e.has("min")||e.has("max")||e.has("disabled")||e.has("showMonths")||e.has("defaultDate"))&&this._init()}}clear(){this.value="",this._fp?.clear(),this._emitChange([],"")}_destroy(){this._fp?.destroy(),this._fp=null,this._hostEl&&(this._hostEl.innerHTML="")}_dateInputValue(){return this.value?this.selectionMode==="range"?this.value.split(" ~ ").map(e=>e.trim()).filter(Boolean):this.value:this.defaultDate||void 0}_watchParent(){this._unobserveParent?.();let e=this.parentElement;this._unobserveParent=e?Ol(e,t=>{if(t<=0)return;let r=Math.max(1,Math.floor(t/308));if(r===this._fittingMonths)return;let n=Math.max(1,Math.min(3,Math.round(this.showMonths||1))),s=Math.min(n,this._fittingMonths);this._fittingMonths=r,Math.min(n,r)!==s&&this._fp&&this._init()}):null}_init(){if(!this._inputEl||!this._hostEl)return;this._destroy();let e=Math.min(Math.max(1,Math.min(3,Math.round(this.showMonths||1))),this._fittingMonths);this._fp=(0,M0.default)(this._inputEl,{locale:C0.Mandarin,inline:!0,appendTo:this._hostEl,clickOpens:!1,dateFormat:"Y-m-d",mode:this.selectionMode==="range"?"range":"single",conjunction:" ~ ",...this._dateInputValue()?{defaultDate:this._dateInputValue()}:{},minDate:this.min||void 0,maxDate:this.max||void 0,showMonths:e,disableMobile:!0,onReady:()=>{this._fp?.calendarContainer.classList.add("lui-calendar-panel"),this._forceCalendarVisible()},onChange:(t,r)=>{this.disabled||(this.value=r,this._emitChange(t,r))}}),this._forceCalendarVisible(),this.disabled&&(this._fp.input.disabled=!0,this._fp.calendarContainer.style.pointerEvents="none",this._fp.calendarContainer.style.opacity="0.55")}_forceCalendarVisible(){let e=this._fp?.calendarContainer;e&&(e.style.position="static",e.style.display="block",e.style.opacity="1",e.style.visibility="visible",e.style.pointerEvents=this.disabled?"none":"auto")}_emitChange(e,t){let r=t?t.split(" ~ ").map(n=>n.trim()).filter(Boolean):[];this.dispatchEvent(new CustomEvent("change",{detail:{value:t,values:r,dates:e},bubbles:!0,composed:!0}))}render(){return hn.html`
13668
+ `],a([(0,Mo.property)({attribute:!1})],Ur.prototype,"source",2),a([(0,Mo.property)()],Ur.prototype,"value",2),a([(0,Mo.property)({reflect:!0})],Ur.prototype,"direction",2),a([(0,Mo.property)({reflect:!0})],Ur.prototype,"size",2),a([(0,Mo.property)()],Ur.prototype,"name",2),a([(0,Mo.property)()],Ur.prototype,"label",2),a([(0,Mo.property)({type:Boolean})],Ur.prototype,"disabled",2),a([(0,Mo.property)({attribute:!1})],Ur.prototype,"radioProps",2),a([(0,Mo.query)("slot")],Ur.prototype,"_slotEl",2),a([(0,Mo.queryAll)("lui-radio")],Ur.prototype,"_renderedRadios",2),Ur=a([(0,Mo.customElement)("lui-radio-group")],Ur);var hn=require("lit"),Gt=require("lit/decorators.js"),M0=Dn(require("flatpickr"),1),C0=require("flatpickr/dist/l10n/zh.js"),k8=require("flatpickr/dist/flatpickr.min.css");var Gr=class extends hn.LitElement{constructor(){super(...arguments);this.value="";this.selectionMode="single";this.size="md";this.disabled=!1;this.showMonths=1;this.defaultDate="";this._fp=null;this._fittingMonths=3;this._unobserveParent=null;this._initFrame=0}firstUpdated(){this._watchParent(),this._init()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this._watchParent()}disconnectedCallback(){this._unobserveParent?.(),this._unobserveParent=null,cancelAnimationFrame(this._initFrame),this._destroy(),super.disconnectedCallback()}updated(e){if(this._fp){if(e.has("value")){let t=this._dateInputValue();t?this._fp.setDate(t,!1):this._fp.clear()}(e.has("selectionMode")||e.has("min")||e.has("max")||e.has("disabled")||e.has("showMonths")||e.has("defaultDate"))&&this._init()}}clear(){this.value="",this._fp?.clear(),this._emitChange([],"")}_destroy(){this._fp?.destroy(),this._fp=null,this._hostEl&&(this._hostEl.innerHTML="")}_dateInputValue(){return this.value?this.selectionMode==="range"?this.value.split(" ~ ").map(e=>e.trim()).filter(Boolean):this.value:this.defaultDate||void 0}_watchParent(){this._unobserveParent?.();let e=this.parentElement;this._unobserveParent=e?Ol(e,t=>{if(t<=0)return;let r=Math.max(1,Math.floor(t/308));if(r===this._fittingMonths)return;let n=Math.max(1,Math.min(3,Math.round(this.showMonths||1))),s=Math.min(n,this._fittingMonths);this._fittingMonths=r,Math.min(n,r)!==s&&this._fp&&(cancelAnimationFrame(this._initFrame),this._initFrame=requestAnimationFrame(()=>this._init()))}):null}_init(){if(!this._inputEl||!this._hostEl)return;this._destroy();let e=Math.min(Math.max(1,Math.min(3,Math.round(this.showMonths||1))),this._fittingMonths);this._fp=(0,M0.default)(this._inputEl,{locale:C0.Mandarin,inline:!0,appendTo:this._hostEl,clickOpens:!1,dateFormat:"Y-m-d",mode:this.selectionMode==="range"?"range":"single",conjunction:" ~ ",...this._dateInputValue()?{defaultDate:this._dateInputValue()}:{},minDate:this.min||void 0,maxDate:this.max||void 0,showMonths:e,disableMobile:!0,onReady:()=>{this._fp?.calendarContainer.classList.add("lui-calendar-panel"),this._forceCalendarVisible()},onChange:(t,r)=>{this.disabled||(this.value=r,this._emitChange(t,r))}}),this._forceCalendarVisible(),this.disabled&&(this._fp.input.disabled=!0,this._fp.calendarContainer.style.pointerEvents="none",this._fp.calendarContainer.style.opacity="0.55")}_forceCalendarVisible(){let e=this._fp?.calendarContainer;e&&(e.style.position="static",e.style.display="block",e.style.opacity="1",e.style.visibility="visible",e.style.pointerEvents=this.disabled?"none":"auto")}_emitChange(e,t){let r=t?t.split(" ~ ").map(n=>n.trim()).filter(Boolean):[];this.dispatchEvent(new CustomEvent("change",{detail:{value:t,values:r,dates:e},bubbles:!0,composed:!0}))}render(){return hn.html`
13664
13669
  <div class="wrap" part="wrap">
13665
13670
  <input class="input" aria-hidden="true" tabindex="-1" ?disabled=${this.disabled} />
13666
13671
  <div class="host" part="calendar"></div>