@skdx/web-components 0.37.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,7 +111,7 @@ export declare class SkdxAutocomplete extends SkdxAutocomplete_base {
111
111
  loop: boolean;
112
112
  /**
113
113
  * Predicate deciding which items survive the current draft text; measured by text-value or rendered text.
114
- * @default undefined — nothing filtered; consumer renders matching items.
114
+ * @default undefined — with `options`, a case-insensitive substring match on each option's text; with hand-composed Items, nothing is filtered and the consumer renders only the matches.
115
115
  */
116
116
  filter?: SkdxAutocompleteFilter;
117
117
  /**
@@ -111,7 +111,7 @@ export declare class SkdxAutocomplete extends SkdxAutocomplete_base {
111
111
  loop: boolean;
112
112
  /**
113
113
  * Predicate deciding which items survive the current draft text; measured by text-value or rendered text.
114
- * @default undefined — nothing filtered; consumer renders matching items.
114
+ * @default undefined — with `options`, a case-insensitive substring match on each option's text; with hand-composed Items, nothing is filtered and the consumer renders only the matches.
115
115
  */
116
116
  filter?: SkdxAutocompleteFilter;
117
117
  /**
@@ -1,4 +1,4 @@
1
- "use strict";var _=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(e,a)=>{for(var t in a)_(e,t,{get:a[t],enumerable:!0})},Z=(e,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of K(a))!Q.call(e,i)&&i!==t&&_(e,i,{get:()=>a[i],enumerable:!(n=U(a,i))||n.enumerable});return e};var k=e=>Z(_({},"__esModule",{value:!0}),e),s=(e,a,t,n)=>{for(var i=n>1?void 0:n?U(a,t):a,l=e.length-1,d;l>=0;l--)(d=e[l])&&(i=(n?d(a,t,i):d(i))||i);return n&&i&&_(a,t,i),i};var de={};X(de,{CALENDAR_VIEWS:()=>p,CALENDAR_YEAR_PAGE:()=>M,SkdxCalendar:()=>r,addDays:()=>C,addMonths:()=>y,addYears:()=>ee,anchorOf:()=>c,clampToDateRange:()=>L,clampToMonth:()=>z,clampView:()=>Y,emptySelection:()=>ue,endOfWeek:()=>te,formatViewPageLabel:()=>G,getDaysInMonth:()=>O,getISOWeek:()=>re,getVisibleWeeks:()=>oe,hasAvailableDate:()=>ie,isDateDisabled:()=>ne,isDateRange:()=>A,isDateSelected:()=>le,isSameDay:()=>b,isSameMonth:()=>V,nextSelection:()=>j,rangePositionOf:()=>H,resetInstantDateWarning:()=>ae,resolveCalendarDisabled:()=>W,selectionAnnouncement:()=>J,startOfMonth:()=>g,startOfWeek:()=>R,stripTime:()=>u,toISODateString:()=>se,warnInstantDate:()=>B,yearPageStart:()=>q});module.exports=k(de);var v=require("lit"),o=require("lit/decorators.js"),T=require("../internal/authored.cjs"),h=require("../internal/calendar-locale.cjs"),D=require("../internal/date-value.cjs"),$=require("../internal/define.cjs"),E=require("../internal/dev-mode.cjs"),N=require("../internal/events.cjs"),F=require("../utils/live-announcer.cjs"),w=require("./CalendarAnatomy.cjs"),x=require("./family.cjs");function O(e,a){return new Date(e,a+1,0).getDate()}function g(e){return new Date(e.getFullYear(),e.getMonth(),1)}function y(e,a){let t=e.getDate(),n=new Date(e.getFullYear(),e.getMonth(),1);n.setMonth(n.getMonth()+a);let i=O(n.getFullYear(),n.getMonth());return n.setDate(Math.min(t,i)),n}function ee(e,a){return y(e,a*12)}function C(e,a){let t=new Date(e);return t.setDate(t.getDate()+a),t}function b(e,a){return!e||!a?!1:e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()&&e.getDate()===a.getDate()}function V(e,a){return e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()}function R(e,a){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate()),n=(t.getDay()-a+7)%7;return t.setDate(t.getDate()-n),t}function te(e,a){return C(R(e,a),6)}function u(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function L(e,a,t){return a&&u(e).getTime()<u(a).getTime()?a:t&&u(e).getTime()>u(t).getTime()?t:e}function ne(e,a,t,n){let i=u(e).getTime();return!!(a&&i<u(a).getTime()||t&&i>u(t).getTime()||n?.(e))}function W(e,a){return{disabled:e??!1,isDateDisabled:a}}var S=!1;function ae(){S=!1}function B(e,a){!e||S||!(e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0&&e.getUTCMilliseconds()===0)||e.getDate()===e.getUTCDate()&&e.getMonth()===e.getUTCMonth()||(S=!0,(0,E.isDevMode)()&&console.warn(`[skdx] Calendar: \`${a}\` was given ${e.toISOString()}, which is midnight UTC and therefore ${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} in this time zone \u2014 a different day from the one the string says. A selection here is a local wall-clock date, never an instant: build it as \`new Date(year, monthIndex, day)\` rather than \`new Date('YYYY-MM-DD')\`, which the platform reads as UTC.`))}var p=["day","month","year"],M=20;function Y(e,a,t){let n=p.indexOf(a),i=Math.max(n,p.indexOf(t));return p[Math.min(Math.max(p.indexOf(e),n),i)]}function q(e){return Math.floor(e/M)*M}function ie(e,a,t,n,i){let l=t&&u(t)>u(e)?u(t):u(e),d=n&&u(n)<u(a)?u(n):u(a);if(l.getTime()>d.getTime())return!1;if(!i)return!0;for(let f=l;f.getTime()<=d.getTime();f=C(f,1))if(!i(f))return!0;return!1}function G(e,a,t){if(a==="day")return(0,h.formatMonthLabel)(e,t);if(a==="month")return(0,h.formatYear)(e.getFullYear(),t);let n=q(e.getFullYear());return(0,h.formatYearRange)(n,n+M-1,t)}function re(e){let a=new Date(e.getFullYear(),e.getMonth(),e.getDate());a.setDate(a.getDate()-(a.getDay()+6)%7+3);let t=new Date(a.getFullYear(),0,4);return t.setDate(t.getDate()-(t.getDay()+6)%7+3),1+Math.round((a.getTime()-t.getTime())/(10080*60*1e3))}function se(e){let a=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${a}-${t}-${n}`}function z(e,a){if(V(e,a))return e;let t=O(a.getFullYear(),a.getMonth());return new Date(a.getFullYear(),a.getMonth(),Math.min(e.getDate(),t))}function oe(e,a=0){let t=R(g(e),a),n=[],i=t;for(let l=0;l<6;l++){let d=[];for(let f=0;f<7;f++)d.push({date:i,outsideMonth:!V(i,e)}),i=C(i,1);n.push(d)}return n}function A(e){return e!==null&&!Array.isArray(e)&&!(e instanceof Date)}function ue(e){return e==="multiple"?[]:null}function H(e,a){let t=u(a).getTime(),n=u(e.start).getTime();if(e.end===null)return t===n?"start":void 0;let i=u(e.end).getTime();if(!(t<n||t>i))return t===n?"start":t===i?"end":"middle"}function le(e,a){return e===null?!1:Array.isArray(e)?e.some(t=>b(t,a)):A(e)?H(e,a)!==void 0:b(e,a)}function j(e,a,t){if(e==="single")return t;if(e==="multiple"){let i=Array.isArray(a)?a:[],l=i.filter(d=>!b(d,t));return l.length!==i.length?l:[...i,t].sort((d,f)=>d.getTime()-f.getTime())}let n=A(a)&&a.end===null?a:void 0;return n?u(t).getTime()<u(n.start).getTime()?{start:t,end:n.start}:{start:n.start,end:t}:{start:t,end:null}}function J(e,a){return A(e)?e.end===null?`${(0,h.formatDateLabel)(e.start,a)} selected as the range start. Select an end date.`:`Range selected, ${(0,h.formatDateLabel)(e.start,a)} to ${(0,h.formatDateLabel)(e.end,a)}.`:Array.isArray(e)?`${e.length} ${e.length===1?"date":"dates"} selected.`:""}var m={fromAttribute(e){if(e!=null)return(0,D.toDate)(e,"a date attribute")??void 0},toAttribute(){}},P={fromAttribute(e){return e==null?null:(0,D.toCalendarValue)(e,"single","value")??null},toAttribute(){}};function c(e){return e===null?null:Array.isArray(e)?e[0]??null:A(e)?e.start:e}var r=class extends v.LitElement{constructor(){super(...arguments);this.selectionMode="single";this._value=null;this.month=g(new Date);this._constructedMonth=this.month;this._monthSeeded=!1;this._valueSeeded=!1;this.numberOfMonths=1;this.readOnly=!1;this.outsideDaySelectable=!1;this.disabled=!1;this.pageBehavior="visible";this._constructedToday=new Date;this._focusedDate=c(this.value)??this.month;this._focusAuto=!0;this._focusSeeded=!1;this._view="day";this._viewAuto=!0;this._viewSeeded=!1;this.minView="day";this.maxView="year";this.weekNumbers=!1;this._anatomyFilledFor="";this.fillAnatomy=()=>{if((0,T.hasAuthoredContent)(this,w.CALENDAR_ANATOMY_GENERATED)){(0,T.removeGeneratedContent)(this,w.CALENDAR_ANATOMY_GENERATED),this._anatomyFilledFor="";return}let t=String(this.numberOfMonths);t===this._anatomyFilledFor&&this.children.length>0||(this._anatomyFilledFor=t,(0,w.fillCalendarAnatomy)(this))}}get value(){return this._value}set value(t){let n=this._value;this._value=(0,D.toCalendarValue)(t,"single","value")??null,this.requestUpdate("value",n)}get defaultValue(){return this._defaultValue}set defaultValue(t){let n=this._defaultValue;this._defaultValue=(0,D.toCalendarValue)(t,"single","defaultValue"),this.requestUpdate("defaultValue",n)}get resolvedDisabled(){return W(this.disabled,this.isDateDisabled)}get todayDate(){return this.today??this._constructedToday}get focusedDate(){return this._focusedDate}set focusedDate(t){this._focusAuto=!1,this.moveFocusedDate(t)}moveFocusedDate(t){let n=this._focusedDate;this._focusedDate=t,this.requestUpdate("focusedDate",n)}get view(){return Y(this._view,this.minView,this.maxView)}set view(t){this._viewAuto=!1,this.moveView(t)}moveView(t){let n=this._view;this._view=t,this.requestUpdate("view",n)}get valueAsString(){return(0,D.toCalendarString)(this.value)}get resolvedWeekStartsOn(){return this.weekStartsOn??(0,h.getLocaleWeekStartsOn)(this.locale)}get months(){return Array.from({length:Math.max(1,this.numberOfMonths)},(t,n)=>y(this.month,n))}get weekDayNames(){let t=this.resolvedWeekStartsOn,n=(0,h.getWeekDayNames)(this.locale,t,"short"),i=(0,h.getWeekDayNames)(this.locale,t,"long");return n.map((l,d)=>({short:l,long:i[d]}))}connectedCallback(){super.connectedCallback(),this._focusAuto&&this.moveFocusedDate(c(this.value)??this.month),queueMicrotask(this.fillAnatomy)}setValue(t){if(this.readOnly||this.resolvedDisabled.disabled)return;let n=j(this.selectionMode,this.value,t);this.value=n,this.setFocusedDate(t),this.emit("value-change",n);let i=(this.getSelectionAnnouncement??J)(n,this.locale);i&&(0,F.announce)(i)}setMonth(t){let n=g(t);n.getTime()!==g(this.month).getTime()&&(this.month=n,this.emit("month-change",this.month))}pageMonths(t){let n=this.view;if(n!=="day"){let f=n==="month"?12:12*M,I=y(this.focusedDate,t*f);this.setFocusedDate(I),(0,F.announce)(G(I,n,this.locale));return}let i=this.pageBehavior==="single"?1:Math.max(1,this.numberOfMonths),l=y(this.month,t*i);this.setMonth(l),this.setFocusedDate(z(this.focusedDate,l));let d=(this.getMonthAnnouncement??h.formatMonthLabel)(g(l),this.locale);d&&(0,F.announce)(d)}setFocusedDate(t){let n=L(t,this.minDate,this.maxDate);b(n,this._focusedDate)||(this.moveFocusedDate(n),this.emit("focus-change",n))}setView(t){let n=Y(t,this.minView,this.maxView);n!==this.view&&(this.moveView(n),this.emit("view-change",n))}navigateToUnit(t){this.setFocusedDate(t),this.months.some(n=>V(t,n))||this.setMonth(t),this.setView(p[p.indexOf(this.view)-1]??"day")}emit(t,n){(0,N.emit)(this,t,n),this.notify()}notify(){x.CALENDAR_FAMILY.notify(this),this.requestUpdate()}willUpdate(t){this.selectionMode==="multiple"&&(this.value instanceof Date&&(this.value=[this.value]),this.defaultValue instanceof Date&&(this.defaultValue=[this.defaultValue])),this.seedView(t),this.seedFocusedDate(t),this.seedValue(t),this.seedMonth(t)}seedView(t){this._viewSeeded||!t.has("defaultView")||(this._viewSeeded=!0,this.defaultView&&this._viewAuto&&this.moveView(this.defaultView))}seedFocusedDate(t){this._focusSeeded||!t.has("defaultFocusedDate")||(this._focusSeeded=!0,this.defaultFocusedDate&&this._focusAuto&&this.moveFocusedDate(this.defaultFocusedDate))}seedValue(t){if(this._valueSeeded||!t.has("defaultValue"))return;this._valueSeeded=!0;let n=this.defaultValue??null,i=this.value===null||Array.isArray(this.value)&&this.value.length===0;n!==null&&i&&(this.value=n,this.moveFocusedDate(c(n)??this._focusedDate))}seedMonth(t){if(this._monthSeeded||!(t.has("defaultMonth")||t.has("value")))return;if(this.month!==this._constructedMonth){this._monthSeeded=!0;return}let n=this.defaultMonth??c(this.value);n&&(this._monthSeeded=!0,this.month=g(n),this._focusAuto&&this.moveFocusedDate(c(this.value)??this.month))}update(t){if(super.update(t),t.has("value")&&B(c(this.value),"value"),!t.has("value")||!this._monthSeeded)return;let n=c(this.value);n&&(this.months.some(i=>V(n,i))||(this.setFocusedDate(n),this.setMonth(n)))}updated(t){this.fillAnatomy(),t.size>0&&x.CALENDAR_FAMILY.notify(this)}render(){return v.html`<slot @slotchange=${this.fillAnatomy}></slot>`}};r.styles=v.css`
1
+ "use strict";var _=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(e,a)=>{for(var t in a)_(e,t,{get:a[t],enumerable:!0})},Z=(e,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of K(a))!Q.call(e,i)&&i!==t&&_(e,i,{get:()=>a[i],enumerable:!(n=U(a,i))||n.enumerable});return e};var k=e=>Z(_({},"__esModule",{value:!0}),e),s=(e,a,t,n)=>{for(var i=n>1?void 0:n?U(a,t):a,l=e.length-1,d;l>=0;l--)(d=e[l])&&(i=(n?d(a,t,i):d(i))||i);return n&&i&&_(a,t,i),i};var de={};X(de,{CALENDAR_VIEWS:()=>p,CALENDAR_YEAR_PAGE:()=>M,SkdxCalendar:()=>r,addDays:()=>C,addMonths:()=>w,addYears:()=>ee,anchorOf:()=>c,clampToDateRange:()=>L,clampToMonth:()=>z,clampView:()=>Y,emptySelection:()=>ue,endOfWeek:()=>te,formatViewPageLabel:()=>G,getDaysInMonth:()=>O,getISOWeek:()=>re,getVisibleWeeks:()=>oe,hasAvailableDate:()=>ie,isDateDisabled:()=>ne,isDateRange:()=>A,isDateSelected:()=>le,isSameDay:()=>V,isSameMonth:()=>v,nextSelection:()=>j,rangePositionOf:()=>H,resetInstantDateWarning:()=>ae,resolveCalendarDisabled:()=>W,selectionAnnouncement:()=>J,startOfMonth:()=>g,startOfWeek:()=>R,stripTime:()=>u,toISODateString:()=>se,warnInstantDate:()=>B,yearPageStart:()=>q});module.exports=k(de);var y=require("lit"),o=require("lit/decorators.js"),T=require("../internal/authored.cjs"),h=require("../internal/calendar-locale.cjs"),D=require("../internal/date-value.cjs"),$=require("../internal/define.cjs"),E=require("../internal/dev-mode.cjs"),N=require("../internal/events.cjs"),F=require("../utils/live-announcer.cjs"),b=require("./CalendarAnatomy.cjs"),x=require("./family.cjs");function O(e,a){return new Date(e,a+1,0).getDate()}function g(e){return new Date(e.getFullYear(),e.getMonth(),1)}function w(e,a){let t=e.getDate(),n=new Date(e.getFullYear(),e.getMonth(),1);n.setMonth(n.getMonth()+a);let i=O(n.getFullYear(),n.getMonth());return n.setDate(Math.min(t,i)),n}function ee(e,a){return w(e,a*12)}function C(e,a){let t=new Date(e);return t.setDate(t.getDate()+a),t}function V(e,a){return!e||!a?!1:e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()&&e.getDate()===a.getDate()}function v(e,a){return e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()}function R(e,a){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate()),n=(t.getDay()-a+7)%7;return t.setDate(t.getDate()-n),t}function te(e,a){return C(R(e,a),6)}function u(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function L(e,a,t){return a&&u(e).getTime()<u(a).getTime()?a:t&&u(e).getTime()>u(t).getTime()?t:e}function ne(e,a,t,n){let i=u(e).getTime();return!!(a&&i<u(a).getTime()||t&&i>u(t).getTime()||n?.(e))}function W(e,a){return{disabled:e??!1,isDateDisabled:a}}var S=!1;function ae(){S=!1}function B(e,a){!e||S||!(e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0&&e.getUTCMilliseconds()===0)||e.getDate()===e.getUTCDate()&&e.getMonth()===e.getUTCMonth()||(S=!0,(0,E.isDevMode)()&&console.warn(`[skdx] Calendar: \`${a}\` was given ${e.toISOString()}, which is midnight UTC and therefore ${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} in this time zone \u2014 a different day from the one the string says. A selection here is a local wall-clock date, never an instant: build it as \`new Date(year, monthIndex, day)\` rather than \`new Date('YYYY-MM-DD')\`, which the platform reads as UTC.`))}var p=["day","month","year"],M=20;function Y(e,a,t){let n=p.indexOf(a),i=Math.max(n,p.indexOf(t));return p[Math.min(Math.max(p.indexOf(e),n),i)]}function q(e){return Math.floor(e/M)*M}function ie(e,a,t,n,i){let l=t&&u(t)>u(e)?u(t):u(e),d=n&&u(n)<u(a)?u(n):u(a);if(l.getTime()>d.getTime())return!1;if(!i)return!0;for(let f=l;f.getTime()<=d.getTime();f=C(f,1))if(!i(f))return!0;return!1}function G(e,a,t){if(a==="day")return(0,h.formatMonthLabel)(e,t);if(a==="month")return(0,h.formatYear)(e.getFullYear(),t);let n=q(e.getFullYear());return(0,h.formatYearRange)(n,n+M-1,t)}function re(e){let a=new Date(e.getFullYear(),e.getMonth(),e.getDate());a.setDate(a.getDate()-(a.getDay()+6)%7+3);let t=new Date(a.getFullYear(),0,4);return t.setDate(t.getDate()-(t.getDay()+6)%7+3),1+Math.round((a.getTime()-t.getTime())/(10080*60*1e3))}function se(e){let a=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${a}-${t}-${n}`}function z(e,a){if(v(e,a))return e;let t=O(a.getFullYear(),a.getMonth());return new Date(a.getFullYear(),a.getMonth(),Math.min(e.getDate(),t))}function oe(e,a=0){let t=R(g(e),a),n=[],i=t;for(let l=0;l<6;l++){let d=[];for(let f=0;f<7;f++)d.push({date:i,outsideMonth:!v(i,e)}),i=C(i,1);n.push(d)}return n}function A(e){return e!==null&&!Array.isArray(e)&&!(e instanceof Date)}function ue(e){return e==="multiple"?[]:null}function H(e,a){let t=u(a).getTime(),n=u(e.start).getTime();if(e.end===null)return t===n?"start":void 0;let i=u(e.end).getTime();if(!(t<n||t>i))return t===n?"start":t===i?"end":"middle"}function le(e,a){return e===null?!1:Array.isArray(e)?e.some(t=>V(t,a)):A(e)?H(e,a)!==void 0:V(e,a)}function j(e,a,t){if(e==="single")return t;if(e==="multiple"){let i=Array.isArray(a)?a:[],l=i.filter(d=>!V(d,t));return l.length!==i.length?l:[...i,t].sort((d,f)=>d.getTime()-f.getTime())}let n=A(a)&&a.end===null?a:void 0;return n?u(t).getTime()<u(n.start).getTime()?{start:t,end:n.start}:{start:n.start,end:t}:{start:t,end:null}}function J(e,a){return A(e)?e.end===null?`${(0,h.formatDateLabel)(e.start,a)} selected as the range start. Select an end date.`:`Range selected, ${(0,h.formatDateLabel)(e.start,a)} to ${(0,h.formatDateLabel)(e.end,a)}.`:Array.isArray(e)?`${e.length} ${e.length===1?"date":"dates"} selected.`:""}var m={fromAttribute(e){if(e!=null)return(0,D.toDate)(e,"a date attribute")??void 0},toAttribute(){}},P={fromAttribute(e){return e==null?null:(0,D.toCalendarValue)(e,"single","value")??null},toAttribute(){}};function c(e){return e===null?null:Array.isArray(e)?e[0]??null:A(e)?e.start:e}var r=class extends y.LitElement{constructor(){super(...arguments);this.selectionMode="single";this._value=null;this.month=g(new Date);this._constructedMonth=this.month;this._monthSeeded=!1;this._valueSeeded=!1;this.numberOfMonths=1;this.readOnly=!1;this.outsideDaySelectable=!1;this.disabled=!1;this.pageBehavior="visible";this._constructedToday=new Date;this._focusedDate=c(this.value)??this.focusSeed(this.month);this._focusAuto=!0;this._focusSeeded=!1;this._view="day";this._viewAuto=!0;this._viewSeeded=!1;this.minView="day";this.maxView="year";this.weekNumbers=!1;this._anatomyFilledFor="";this.fillAnatomy=()=>{if((0,T.hasAuthoredContent)(this,b.CALENDAR_ANATOMY_GENERATED)){(0,T.removeGeneratedContent)(this,b.CALENDAR_ANATOMY_GENERATED),this._anatomyFilledFor="";return}let t=String(this.numberOfMonths);t===this._anatomyFilledFor&&this.children.length>0||(this._anatomyFilledFor=t,(0,b.fillCalendarAnatomy)(this))}}get value(){return this._value}set value(t){let n=this._value;this._value=(0,D.toCalendarValue)(t,"single","value")??null,this.requestUpdate("value",n)}get defaultValue(){return this._defaultValue}set defaultValue(t){let n=this._defaultValue;this._defaultValue=(0,D.toCalendarValue)(t,"single","defaultValue"),this.requestUpdate("defaultValue",n)}get resolvedDisabled(){return W(this.disabled,this.isDateDisabled)}get todayDate(){return this.today??this._constructedToday}get focusedDate(){return this._focusedDate}set focusedDate(t){this._focusAuto=!1,this.moveFocusedDate(t)}focusSeed(t){return v(this.todayDate,t)?this.todayDate:t}moveFocusedDate(t){let n=this._focusedDate;this._focusedDate=t,this.requestUpdate("focusedDate",n)}get view(){return Y(this._view,this.minView,this.maxView)}set view(t){this._viewAuto=!1,this.moveView(t)}moveView(t){let n=this._view;this._view=t,this.requestUpdate("view",n)}get valueAsString(){return(0,D.toCalendarString)(this.value)}get resolvedWeekStartsOn(){return this.weekStartsOn??(0,h.getLocaleWeekStartsOn)(this.locale)}get months(){return Array.from({length:Math.max(1,this.numberOfMonths)},(t,n)=>w(this.month,n))}get weekDayNames(){let t=this.resolvedWeekStartsOn,n=(0,h.getWeekDayNames)(this.locale,t,"short"),i=(0,h.getWeekDayNames)(this.locale,t,"long");return n.map((l,d)=>({short:l,long:i[d]}))}connectedCallback(){super.connectedCallback(),this._focusAuto&&this.moveFocusedDate(c(this.value)??this.focusSeed(this.month)),queueMicrotask(this.fillAnatomy)}setValue(t){if(this.readOnly||this.resolvedDisabled.disabled)return;let n=j(this.selectionMode,this.value,t);this.value=n,this.setFocusedDate(t),this.emit("value-change",n);let i=(this.getSelectionAnnouncement??J)(n,this.locale);i&&(0,F.announce)(i)}setMonth(t){let n=g(t);n.getTime()!==g(this.month).getTime()&&(this.month=n,this.emit("month-change",this.month))}pageMonths(t){let n=this.view;if(n!=="day"){let f=n==="month"?12:12*M,I=w(this.focusedDate,t*f);this.setFocusedDate(I),(0,F.announce)(G(I,n,this.locale));return}let i=this.pageBehavior==="single"?1:Math.max(1,this.numberOfMonths),l=w(this.month,t*i);this.setMonth(l),this.setFocusedDate(z(this.focusedDate,l));let d=(this.getMonthAnnouncement??h.formatMonthLabel)(g(l),this.locale);d&&(0,F.announce)(d)}setFocusedDate(t){let n=L(t,this.minDate,this.maxDate);V(n,this._focusedDate)||(this.moveFocusedDate(n),this.emit("focus-change",n))}setView(t){let n=Y(t,this.minView,this.maxView);n!==this.view&&(this.moveView(n),this.emit("view-change",n))}navigateToUnit(t){this.setFocusedDate(t),this.months.some(n=>v(t,n))||this.setMonth(t),this.setView(p[p.indexOf(this.view)-1]??"day")}emit(t,n){(0,N.emit)(this,t,n),this.notify()}notify(){x.CALENDAR_FAMILY.notify(this),this.requestUpdate()}willUpdate(t){this.selectionMode==="multiple"&&(this.value instanceof Date&&(this.value=[this.value]),this.defaultValue instanceof Date&&(this.defaultValue=[this.defaultValue])),this.seedView(t),this.seedFocusedDate(t),this.seedValue(t),this.seedMonth(t)}seedView(t){this._viewSeeded||!t.has("defaultView")||(this._viewSeeded=!0,this.defaultView&&this._viewAuto&&this.moveView(this.defaultView))}seedFocusedDate(t){this._focusSeeded||!t.has("defaultFocusedDate")||(this._focusSeeded=!0,this.defaultFocusedDate&&this._focusAuto&&this.moveFocusedDate(this.defaultFocusedDate))}seedValue(t){if(this._valueSeeded||!t.has("defaultValue"))return;this._valueSeeded=!0;let n=this.defaultValue??null,i=this.value===null||Array.isArray(this.value)&&this.value.length===0;n!==null&&i&&(this.value=n,this.moveFocusedDate(c(n)??this._focusedDate))}seedMonth(t){if(this._monthSeeded||!(t.has("defaultMonth")||t.has("value")))return;if(this.month!==this._constructedMonth){this._monthSeeded=!0;return}let n=this.defaultMonth??c(this.value);n&&(this._monthSeeded=!0,this.month=g(n),this._focusAuto&&this.moveFocusedDate(c(this.value)??this.month))}update(t){if(super.update(t),t.has("value")&&B(c(this.value),"value"),!t.has("value")||!this._monthSeeded)return;let n=c(this.value);n&&(this.months.some(i=>v(n,i))||(this.setFocusedDate(n),this.setMonth(n)))}updated(t){this.fillAnatomy(),t.size>0&&x.CALENDAR_FAMILY.notify(this)}render(){return y.html`<slot @slotchange=${this.fillAnatomy}></slot>`}};r.styles=y.css`
2
2
  :host {
3
3
  display: block;
4
4
  }
@@ -231,17 +231,18 @@ export declare class SkdxCalendar extends LitElement {
231
231
  private readonly _constructedToday;
232
232
  /**
233
233
  * Roving tab stop date that moves with arrow keys and selects nothing, distinct from {@link value}.
234
- * @default selection's anchor or displayed month
234
+ * @default selection's anchor, else today when displayed, else the month
235
235
  */
236
236
  get focusedDate(): Date;
237
237
  set focusedDate(next: Date);
238
238
  private _focusedDate;
239
239
  private _focusAuto;
240
+ private focusSeed;
240
241
  /** @internal */
241
242
  private moveFocusedDate;
242
243
  /**
243
244
  * Initial focused date for uncontrolled usage, seeds {@link focusedDate}.
244
- * @default undefined — value's anchor or displayed month
245
+ * @default undefined — value's anchor, else today when displayed, else the month
245
246
  */
246
247
  defaultFocusedDate?: Date;
247
248
  private _focusSeeded;
@@ -231,17 +231,18 @@ export declare class SkdxCalendar extends LitElement {
231
231
  private readonly _constructedToday;
232
232
  /**
233
233
  * Roving tab stop date that moves with arrow keys and selects nothing, distinct from {@link value}.
234
- * @default selection's anchor or displayed month
234
+ * @default selection's anchor, else today when displayed, else the month
235
235
  */
236
236
  get focusedDate(): Date;
237
237
  set focusedDate(next: Date);
238
238
  private _focusedDate;
239
239
  private _focusAuto;
240
+ private focusSeed;
240
241
  /** @internal */
241
242
  private moveFocusedDate;
242
243
  /**
243
244
  * Initial focused date for uncontrolled usage, seeds {@link focusedDate}.
244
- * @default undefined — value's anchor or displayed month
245
+ * @default undefined — value's anchor, else today when displayed, else the month
245
246
  */
246
247
  defaultFocusedDate?: Date;
247
248
  private _focusSeeded;
@@ -1,5 +1,5 @@
1
- var U=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var s=(e,a,t,n)=>{for(var i=n>1?void 0:n?P(a,t):a,l=e.length-1,d;l>=0;l--)(d=e[l])&&(i=(n?d(a,t,i):d(i))||i);return n&&i&&U(a,t,i),i};import{css as $,html as E,LitElement as N}from"lit";import{property as o}from"lit/decorators.js";import{hasAuthoredContent as L,removeGeneratedContent as W}from"../internal/authored.js";import{formatDateLabel as b,formatMonthLabel as O,formatYear as B,formatYearRange as q,getLocaleWeekStartsOn as G,getWeekDayNames as T}from"../internal/calendar-locale.js";import{toCalendarString as z,toCalendarValue as M,toDate as H}from"../internal/date-value.js";import{customElement as j}from"../internal/define.js";import{isDevMode as J}from"../internal/dev-mode.js";import{emit as K}from"../internal/events.js";import{announce as V}from"../utils/live-announcer.js";import{CALENDAR_ANATOMY_GENERATED as C,fillCalendarAnatomy as Q}from"./CalendarAnatomy.js";import{CALENDAR_FAMILY as x}from"./family.js";function R(e,a){return new Date(e,a+1,0).getDate()}function D(e){return new Date(e.getFullYear(),e.getMonth(),1)}function g(e,a){let t=e.getDate(),n=new Date(e.getFullYear(),e.getMonth(),1);n.setMonth(n.getMonth()+a);let i=R(n.getFullYear(),n.getMonth());return n.setDate(Math.min(t,i)),n}function ve(e,a){return g(e,a*12)}function _(e,a){let t=new Date(e);return t.setDate(t.getDate()+a),t}function p(e,a){return!e||!a?!1:e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()&&e.getDate()===a.getDate()}function v(e,a){return e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()}function I(e,a){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate()),n=(t.getDay()-a+7)%7;return t.setDate(t.getDate()-n),t}function ye(e,a){return _(I(e,a),6)}function u(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function X(e,a,t){return a&&u(e).getTime()<u(a).getTime()?a:t&&u(e).getTime()>u(t).getTime()?t:e}function we(e,a,t,n){let i=u(e).getTime();return!!(a&&i<u(a).getTime()||t&&i>u(t).getTime()||n?.(e))}function Z(e,a){return{disabled:e??!1,isDateDisabled:a}}var A=!1;function be(){A=!1}function k(e,a){!e||A||!(e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0&&e.getUTCMilliseconds()===0)||e.getDate()===e.getUTCDate()&&e.getMonth()===e.getUTCMonth()||(A=!0,J()&&console.warn(`[skdx] Calendar: \`${a}\` was given ${e.toISOString()}, which is midnight UTC and therefore ${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} in this time zone \u2014 a different day from the one the string says. A selection here is a local wall-clock date, never an instant: build it as \`new Date(year, monthIndex, day)\` rather than \`new Date('YYYY-MM-DD')\`, which the platform reads as UTC.`))}var m=["day","month","year"],y=20;function S(e,a,t){let n=m.indexOf(a),i=Math.max(n,m.indexOf(t));return m[Math.min(Math.max(m.indexOf(e),n),i)]}function ee(e){return Math.floor(e/y)*y}function Ve(e,a,t,n,i){let l=t&&u(t)>u(e)?u(t):u(e),d=n&&u(n)<u(a)?u(n):u(a);if(l.getTime()>d.getTime())return!1;if(!i)return!0;for(let h=l;h.getTime()<=d.getTime();h=_(h,1))if(!i(h))return!0;return!1}function te(e,a,t){if(a==="day")return O(e,t);if(a==="month")return B(e.getFullYear(),t);let n=ee(e.getFullYear());return q(n,n+y-1,t)}function Me(e){let a=new Date(e.getFullYear(),e.getMonth(),e.getDate());a.setDate(a.getDate()-(a.getDay()+6)%7+3);let t=new Date(a.getFullYear(),0,4);return t.setDate(t.getDate()-(t.getDay()+6)%7+3),1+Math.round((a.getTime()-t.getTime())/(10080*60*1e3))}function Ae(e){let a=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${a}-${t}-${n}`}function ne(e,a){if(v(e,a))return e;let t=R(a.getFullYear(),a.getMonth());return new Date(a.getFullYear(),a.getMonth(),Math.min(e.getDate(),t))}function _e(e,a=0){let t=I(D(e),a),n=[],i=t;for(let l=0;l<6;l++){let d=[];for(let h=0;h<7;h++)d.push({date:i,outsideMonth:!v(i,e)}),i=_(i,1);n.push(d)}return n}function w(e){return e!==null&&!Array.isArray(e)&&!(e instanceof Date)}function Fe(e){return e==="multiple"?[]:null}function ae(e,a){let t=u(a).getTime(),n=u(e.start).getTime();if(e.end===null)return t===n?"start":void 0;let i=u(e.end).getTime();if(!(t<n||t>i))return t===n?"start":t===i?"end":"middle"}function Te(e,a){return e===null?!1:Array.isArray(e)?e.some(t=>p(t,a)):w(e)?ae(e,a)!==void 0:p(e,a)}function ie(e,a,t){if(e==="single")return t;if(e==="multiple"){let i=Array.isArray(a)?a:[],l=i.filter(d=>!p(d,t));return l.length!==i.length?l:[...i,t].sort((d,h)=>d.getTime()-h.getTime())}let n=w(a)&&a.end===null?a:void 0;return n?u(t).getTime()<u(n.start).getTime()?{start:t,end:n.start}:{start:n.start,end:t}:{start:t,end:null}}function re(e,a){return w(e)?e.end===null?`${b(e.start,a)} selected as the range start. Select an end date.`:`Range selected, ${b(e.start,a)} to ${b(e.end,a)}.`:Array.isArray(e)?`${e.length} ${e.length===1?"date":"dates"} selected.`:""}var f={fromAttribute(e){if(e!=null)return H(e,"a date attribute")??void 0},toAttribute(){}},Y={fromAttribute(e){return e==null?null:M(e,"single","value")??null},toAttribute(){}};function c(e){return e===null?null:Array.isArray(e)?e[0]??null:w(e)?e.start:e}var r=class extends N{constructor(){super(...arguments);this.selectionMode="single";this._value=null;this.month=D(new Date);this._constructedMonth=this.month;this._monthSeeded=!1;this._valueSeeded=!1;this.numberOfMonths=1;this.readOnly=!1;this.outsideDaySelectable=!1;this.disabled=!1;this.pageBehavior="visible";this._constructedToday=new Date;this._focusedDate=c(this.value)??this.month;this._focusAuto=!0;this._focusSeeded=!1;this._view="day";this._viewAuto=!0;this._viewSeeded=!1;this.minView="day";this.maxView="year";this.weekNumbers=!1;this._anatomyFilledFor="";this.fillAnatomy=()=>{if(L(this,C)){W(this,C),this._anatomyFilledFor="";return}let t=String(this.numberOfMonths);t===this._anatomyFilledFor&&this.children.length>0||(this._anatomyFilledFor=t,Q(this))}}get value(){return this._value}set value(t){let n=this._value;this._value=M(t,"single","value")??null,this.requestUpdate("value",n)}get defaultValue(){return this._defaultValue}set defaultValue(t){let n=this._defaultValue;this._defaultValue=M(t,"single","defaultValue"),this.requestUpdate("defaultValue",n)}get resolvedDisabled(){return Z(this.disabled,this.isDateDisabled)}get todayDate(){return this.today??this._constructedToday}get focusedDate(){return this._focusedDate}set focusedDate(t){this._focusAuto=!1,this.moveFocusedDate(t)}moveFocusedDate(t){let n=this._focusedDate;this._focusedDate=t,this.requestUpdate("focusedDate",n)}get view(){return S(this._view,this.minView,this.maxView)}set view(t){this._viewAuto=!1,this.moveView(t)}moveView(t){let n=this._view;this._view=t,this.requestUpdate("view",n)}get valueAsString(){return z(this.value)}get resolvedWeekStartsOn(){return this.weekStartsOn??G(this.locale)}get months(){return Array.from({length:Math.max(1,this.numberOfMonths)},(t,n)=>g(this.month,n))}get weekDayNames(){let t=this.resolvedWeekStartsOn,n=T(this.locale,t,"short"),i=T(this.locale,t,"long");return n.map((l,d)=>({short:l,long:i[d]}))}connectedCallback(){super.connectedCallback(),this._focusAuto&&this.moveFocusedDate(c(this.value)??this.month),queueMicrotask(this.fillAnatomy)}setValue(t){if(this.readOnly||this.resolvedDisabled.disabled)return;let n=ie(this.selectionMode,this.value,t);this.value=n,this.setFocusedDate(t),this.emit("value-change",n);let i=(this.getSelectionAnnouncement??re)(n,this.locale);i&&V(i)}setMonth(t){let n=D(t);n.getTime()!==D(this.month).getTime()&&(this.month=n,this.emit("month-change",this.month))}pageMonths(t){let n=this.view;if(n!=="day"){let h=n==="month"?12:12*y,F=g(this.focusedDate,t*h);this.setFocusedDate(F),V(te(F,n,this.locale));return}let i=this.pageBehavior==="single"?1:Math.max(1,this.numberOfMonths),l=g(this.month,t*i);this.setMonth(l),this.setFocusedDate(ne(this.focusedDate,l));let d=(this.getMonthAnnouncement??O)(D(l),this.locale);d&&V(d)}setFocusedDate(t){let n=X(t,this.minDate,this.maxDate);p(n,this._focusedDate)||(this.moveFocusedDate(n),this.emit("focus-change",n))}setView(t){let n=S(t,this.minView,this.maxView);n!==this.view&&(this.moveView(n),this.emit("view-change",n))}navigateToUnit(t){this.setFocusedDate(t),this.months.some(n=>v(t,n))||this.setMonth(t),this.setView(m[m.indexOf(this.view)-1]??"day")}emit(t,n){K(this,t,n),this.notify()}notify(){x.notify(this),this.requestUpdate()}willUpdate(t){this.selectionMode==="multiple"&&(this.value instanceof Date&&(this.value=[this.value]),this.defaultValue instanceof Date&&(this.defaultValue=[this.defaultValue])),this.seedView(t),this.seedFocusedDate(t),this.seedValue(t),this.seedMonth(t)}seedView(t){this._viewSeeded||!t.has("defaultView")||(this._viewSeeded=!0,this.defaultView&&this._viewAuto&&this.moveView(this.defaultView))}seedFocusedDate(t){this._focusSeeded||!t.has("defaultFocusedDate")||(this._focusSeeded=!0,this.defaultFocusedDate&&this._focusAuto&&this.moveFocusedDate(this.defaultFocusedDate))}seedValue(t){if(this._valueSeeded||!t.has("defaultValue"))return;this._valueSeeded=!0;let n=this.defaultValue??null,i=this.value===null||Array.isArray(this.value)&&this.value.length===0;n!==null&&i&&(this.value=n,this.moveFocusedDate(c(n)??this._focusedDate))}seedMonth(t){if(this._monthSeeded||!(t.has("defaultMonth")||t.has("value")))return;if(this.month!==this._constructedMonth){this._monthSeeded=!0;return}let n=this.defaultMonth??c(this.value);n&&(this._monthSeeded=!0,this.month=D(n),this._focusAuto&&this.moveFocusedDate(c(this.value)??this.month))}update(t){if(super.update(t),t.has("value")&&k(c(this.value),"value"),!t.has("value")||!this._monthSeeded)return;let n=c(this.value);n&&(this.months.some(i=>v(n,i))||(this.setFocusedDate(n),this.setMonth(n)))}updated(t){this.fillAnatomy(),t.size>0&&x.notify(this)}render(){return E`<slot @slotchange=${this.fillAnatomy}></slot>`}};r.styles=$`
1
+ var U=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var s=(e,a,t,n)=>{for(var i=n>1?void 0:n?P(a,t):a,l=e.length-1,d;l>=0;l--)(d=e[l])&&(i=(n?d(a,t,i):d(i))||i);return n&&i&&U(a,t,i),i};import{css as $,html as E,LitElement as N}from"lit";import{property as o}from"lit/decorators.js";import{hasAuthoredContent as L,removeGeneratedContent as W}from"../internal/authored.js";import{formatDateLabel as b,formatMonthLabel as O,formatYear as B,formatYearRange as q,getLocaleWeekStartsOn as G,getWeekDayNames as T}from"../internal/calendar-locale.js";import{toCalendarString as z,toCalendarValue as M,toDate as H}from"../internal/date-value.js";import{customElement as j}from"../internal/define.js";import{isDevMode as J}from"../internal/dev-mode.js";import{emit as K}from"../internal/events.js";import{announce as V}from"../utils/live-announcer.js";import{CALENDAR_ANATOMY_GENERATED as C,fillCalendarAnatomy as Q}from"./CalendarAnatomy.js";import{CALENDAR_FAMILY as x}from"./family.js";function R(e,a){return new Date(e,a+1,0).getDate()}function D(e){return new Date(e.getFullYear(),e.getMonth(),1)}function p(e,a){let t=e.getDate(),n=new Date(e.getFullYear(),e.getMonth(),1);n.setMonth(n.getMonth()+a);let i=R(n.getFullYear(),n.getMonth());return n.setDate(Math.min(t,i)),n}function ve(e,a){return p(e,a*12)}function _(e,a){let t=new Date(e);return t.setDate(t.getDate()+a),t}function v(e,a){return!e||!a?!1:e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()&&e.getDate()===a.getDate()}function g(e,a){return e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()}function I(e,a){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate()),n=(t.getDay()-a+7)%7;return t.setDate(t.getDate()-n),t}function ye(e,a){return _(I(e,a),6)}function u(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function X(e,a,t){return a&&u(e).getTime()<u(a).getTime()?a:t&&u(e).getTime()>u(t).getTime()?t:e}function we(e,a,t,n){let i=u(e).getTime();return!!(a&&i<u(a).getTime()||t&&i>u(t).getTime()||n?.(e))}function Z(e,a){return{disabled:e??!1,isDateDisabled:a}}var A=!1;function be(){A=!1}function k(e,a){!e||A||!(e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0&&e.getUTCMilliseconds()===0)||e.getDate()===e.getUTCDate()&&e.getMonth()===e.getUTCMonth()||(A=!0,J()&&console.warn(`[skdx] Calendar: \`${a}\` was given ${e.toISOString()}, which is midnight UTC and therefore ${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} in this time zone \u2014 a different day from the one the string says. A selection here is a local wall-clock date, never an instant: build it as \`new Date(year, monthIndex, day)\` rather than \`new Date('YYYY-MM-DD')\`, which the platform reads as UTC.`))}var m=["day","month","year"],y=20;function S(e,a,t){let n=m.indexOf(a),i=Math.max(n,m.indexOf(t));return m[Math.min(Math.max(m.indexOf(e),n),i)]}function ee(e){return Math.floor(e/y)*y}function Ve(e,a,t,n,i){let l=t&&u(t)>u(e)?u(t):u(e),d=n&&u(n)<u(a)?u(n):u(a);if(l.getTime()>d.getTime())return!1;if(!i)return!0;for(let h=l;h.getTime()<=d.getTime();h=_(h,1))if(!i(h))return!0;return!1}function te(e,a,t){if(a==="day")return O(e,t);if(a==="month")return B(e.getFullYear(),t);let n=ee(e.getFullYear());return q(n,n+y-1,t)}function Me(e){let a=new Date(e.getFullYear(),e.getMonth(),e.getDate());a.setDate(a.getDate()-(a.getDay()+6)%7+3);let t=new Date(a.getFullYear(),0,4);return t.setDate(t.getDate()-(t.getDay()+6)%7+3),1+Math.round((a.getTime()-t.getTime())/(10080*60*1e3))}function Ae(e){let a=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${a}-${t}-${n}`}function ne(e,a){if(g(e,a))return e;let t=R(a.getFullYear(),a.getMonth());return new Date(a.getFullYear(),a.getMonth(),Math.min(e.getDate(),t))}function _e(e,a=0){let t=I(D(e),a),n=[],i=t;for(let l=0;l<6;l++){let d=[];for(let h=0;h<7;h++)d.push({date:i,outsideMonth:!g(i,e)}),i=_(i,1);n.push(d)}return n}function w(e){return e!==null&&!Array.isArray(e)&&!(e instanceof Date)}function Fe(e){return e==="multiple"?[]:null}function ae(e,a){let t=u(a).getTime(),n=u(e.start).getTime();if(e.end===null)return t===n?"start":void 0;let i=u(e.end).getTime();if(!(t<n||t>i))return t===n?"start":t===i?"end":"middle"}function Te(e,a){return e===null?!1:Array.isArray(e)?e.some(t=>v(t,a)):w(e)?ae(e,a)!==void 0:v(e,a)}function ie(e,a,t){if(e==="single")return t;if(e==="multiple"){let i=Array.isArray(a)?a:[],l=i.filter(d=>!v(d,t));return l.length!==i.length?l:[...i,t].sort((d,h)=>d.getTime()-h.getTime())}let n=w(a)&&a.end===null?a:void 0;return n?u(t).getTime()<u(n.start).getTime()?{start:t,end:n.start}:{start:n.start,end:t}:{start:t,end:null}}function re(e,a){return w(e)?e.end===null?`${b(e.start,a)} selected as the range start. Select an end date.`:`Range selected, ${b(e.start,a)} to ${b(e.end,a)}.`:Array.isArray(e)?`${e.length} ${e.length===1?"date":"dates"} selected.`:""}var f={fromAttribute(e){if(e!=null)return H(e,"a date attribute")??void 0},toAttribute(){}},Y={fromAttribute(e){return e==null?null:M(e,"single","value")??null},toAttribute(){}};function c(e){return e===null?null:Array.isArray(e)?e[0]??null:w(e)?e.start:e}var r=class extends N{constructor(){super(...arguments);this.selectionMode="single";this._value=null;this.month=D(new Date);this._constructedMonth=this.month;this._monthSeeded=!1;this._valueSeeded=!1;this.numberOfMonths=1;this.readOnly=!1;this.outsideDaySelectable=!1;this.disabled=!1;this.pageBehavior="visible";this._constructedToday=new Date;this._focusedDate=c(this.value)??this.focusSeed(this.month);this._focusAuto=!0;this._focusSeeded=!1;this._view="day";this._viewAuto=!0;this._viewSeeded=!1;this.minView="day";this.maxView="year";this.weekNumbers=!1;this._anatomyFilledFor="";this.fillAnatomy=()=>{if(L(this,C)){W(this,C),this._anatomyFilledFor="";return}let t=String(this.numberOfMonths);t===this._anatomyFilledFor&&this.children.length>0||(this._anatomyFilledFor=t,Q(this))}}get value(){return this._value}set value(t){let n=this._value;this._value=M(t,"single","value")??null,this.requestUpdate("value",n)}get defaultValue(){return this._defaultValue}set defaultValue(t){let n=this._defaultValue;this._defaultValue=M(t,"single","defaultValue"),this.requestUpdate("defaultValue",n)}get resolvedDisabled(){return Z(this.disabled,this.isDateDisabled)}get todayDate(){return this.today??this._constructedToday}get focusedDate(){return this._focusedDate}set focusedDate(t){this._focusAuto=!1,this.moveFocusedDate(t)}focusSeed(t){return g(this.todayDate,t)?this.todayDate:t}moveFocusedDate(t){let n=this._focusedDate;this._focusedDate=t,this.requestUpdate("focusedDate",n)}get view(){return S(this._view,this.minView,this.maxView)}set view(t){this._viewAuto=!1,this.moveView(t)}moveView(t){let n=this._view;this._view=t,this.requestUpdate("view",n)}get valueAsString(){return z(this.value)}get resolvedWeekStartsOn(){return this.weekStartsOn??G(this.locale)}get months(){return Array.from({length:Math.max(1,this.numberOfMonths)},(t,n)=>p(this.month,n))}get weekDayNames(){let t=this.resolvedWeekStartsOn,n=T(this.locale,t,"short"),i=T(this.locale,t,"long");return n.map((l,d)=>({short:l,long:i[d]}))}connectedCallback(){super.connectedCallback(),this._focusAuto&&this.moveFocusedDate(c(this.value)??this.focusSeed(this.month)),queueMicrotask(this.fillAnatomy)}setValue(t){if(this.readOnly||this.resolvedDisabled.disabled)return;let n=ie(this.selectionMode,this.value,t);this.value=n,this.setFocusedDate(t),this.emit("value-change",n);let i=(this.getSelectionAnnouncement??re)(n,this.locale);i&&V(i)}setMonth(t){let n=D(t);n.getTime()!==D(this.month).getTime()&&(this.month=n,this.emit("month-change",this.month))}pageMonths(t){let n=this.view;if(n!=="day"){let h=n==="month"?12:12*y,F=p(this.focusedDate,t*h);this.setFocusedDate(F),V(te(F,n,this.locale));return}let i=this.pageBehavior==="single"?1:Math.max(1,this.numberOfMonths),l=p(this.month,t*i);this.setMonth(l),this.setFocusedDate(ne(this.focusedDate,l));let d=(this.getMonthAnnouncement??O)(D(l),this.locale);d&&V(d)}setFocusedDate(t){let n=X(t,this.minDate,this.maxDate);v(n,this._focusedDate)||(this.moveFocusedDate(n),this.emit("focus-change",n))}setView(t){let n=S(t,this.minView,this.maxView);n!==this.view&&(this.moveView(n),this.emit("view-change",n))}navigateToUnit(t){this.setFocusedDate(t),this.months.some(n=>g(t,n))||this.setMonth(t),this.setView(m[m.indexOf(this.view)-1]??"day")}emit(t,n){K(this,t,n),this.notify()}notify(){x.notify(this),this.requestUpdate()}willUpdate(t){this.selectionMode==="multiple"&&(this.value instanceof Date&&(this.value=[this.value]),this.defaultValue instanceof Date&&(this.defaultValue=[this.defaultValue])),this.seedView(t),this.seedFocusedDate(t),this.seedValue(t),this.seedMonth(t)}seedView(t){this._viewSeeded||!t.has("defaultView")||(this._viewSeeded=!0,this.defaultView&&this._viewAuto&&this.moveView(this.defaultView))}seedFocusedDate(t){this._focusSeeded||!t.has("defaultFocusedDate")||(this._focusSeeded=!0,this.defaultFocusedDate&&this._focusAuto&&this.moveFocusedDate(this.defaultFocusedDate))}seedValue(t){if(this._valueSeeded||!t.has("defaultValue"))return;this._valueSeeded=!0;let n=this.defaultValue??null,i=this.value===null||Array.isArray(this.value)&&this.value.length===0;n!==null&&i&&(this.value=n,this.moveFocusedDate(c(n)??this._focusedDate))}seedMonth(t){if(this._monthSeeded||!(t.has("defaultMonth")||t.has("value")))return;if(this.month!==this._constructedMonth){this._monthSeeded=!0;return}let n=this.defaultMonth??c(this.value);n&&(this._monthSeeded=!0,this.month=D(n),this._focusAuto&&this.moveFocusedDate(c(this.value)??this.month))}update(t){if(super.update(t),t.has("value")&&k(c(this.value),"value"),!t.has("value")||!this._monthSeeded)return;let n=c(this.value);n&&(this.months.some(i=>g(n,i))||(this.setFocusedDate(n),this.setMonth(n)))}updated(t){this.fillAnatomy(),t.size>0&&x.notify(this)}render(){return E`<slot @slotchange=${this.fillAnatomy}></slot>`}};r.styles=$`
2
2
  :host {
3
3
  display: block;
4
4
  }
5
- `,s([o({type:String,reflect:!0,attribute:"selection-mode"})],r.prototype,"selectionMode",2),s([o({converter:Y})],r.prototype,"value",1),s([o({converter:f})],r.prototype,"month",2),s([o({converter:f,attribute:"default-month"})],r.prototype,"defaultMonth",2),s([o({type:Number,attribute:"number-of-months"})],r.prototype,"numberOfMonths",2),s([o({type:String})],r.prototype,"locale",2),s([o({type:Number,attribute:"week-starts-on"})],r.prototype,"weekStartsOn",2),s([o({converter:f,attribute:"min-date"})],r.prototype,"minDate",2),s([o({converter:f,attribute:"max-date"})],r.prototype,"maxDate",2),s([o({converter:Y,attribute:"default-value"})],r.prototype,"defaultValue",1),s([o({type:Boolean,reflect:!0,attribute:"read-only"})],r.prototype,"readOnly",2),s([o({type:Boolean,reflect:!0,attribute:"outside-day-selectable"})],r.prototype,"outsideDaySelectable",2),s([o({type:Boolean})],r.prototype,"disabled",2),s([o({attribute:!1})],r.prototype,"isDateDisabled",2),s([o({attribute:!1})],r.prototype,"isDateUnavailable",2),s([o({attribute:!1})],r.prototype,"getSelectionAnnouncement",2),s([o({attribute:!1})],r.prototype,"getMonthAnnouncement",2),s([o({type:String,attribute:"page-behavior"})],r.prototype,"pageBehavior",2),s([o({converter:f})],r.prototype,"today",2),s([o({converter:f,attribute:"focused-date"})],r.prototype,"focusedDate",1),s([o({converter:f,attribute:"default-focused-date"})],r.prototype,"defaultFocusedDate",2),s([o({type:String,reflect:!0})],r.prototype,"view",1),s([o({type:String,attribute:"default-view"})],r.prototype,"defaultView",2),s([o({type:String,attribute:"min-view"})],r.prototype,"minView",2),s([o({type:String,attribute:"max-view"})],r.prototype,"maxView",2),s([o({type:Boolean,reflect:!0,attribute:"week-numbers"})],r.prototype,"weekNumbers",2),r=s([j("skdx-calendar","calendar","root")],r);export{m as CALENDAR_VIEWS,y as CALENDAR_YEAR_PAGE,r as SkdxCalendar,_ as addDays,g as addMonths,ve as addYears,c as anchorOf,X as clampToDateRange,ne as clampToMonth,S as clampView,Fe as emptySelection,ye as endOfWeek,te as formatViewPageLabel,R as getDaysInMonth,Me as getISOWeek,_e as getVisibleWeeks,Ve as hasAvailableDate,we as isDateDisabled,w as isDateRange,Te as isDateSelected,p as isSameDay,v as isSameMonth,ie as nextSelection,ae as rangePositionOf,be as resetInstantDateWarning,Z as resolveCalendarDisabled,re as selectionAnnouncement,D as startOfMonth,I as startOfWeek,u as stripTime,Ae as toISODateString,k as warnInstantDate,ee as yearPageStart};
5
+ `,s([o({type:String,reflect:!0,attribute:"selection-mode"})],r.prototype,"selectionMode",2),s([o({converter:Y})],r.prototype,"value",1),s([o({converter:f})],r.prototype,"month",2),s([o({converter:f,attribute:"default-month"})],r.prototype,"defaultMonth",2),s([o({type:Number,attribute:"number-of-months"})],r.prototype,"numberOfMonths",2),s([o({type:String})],r.prototype,"locale",2),s([o({type:Number,attribute:"week-starts-on"})],r.prototype,"weekStartsOn",2),s([o({converter:f,attribute:"min-date"})],r.prototype,"minDate",2),s([o({converter:f,attribute:"max-date"})],r.prototype,"maxDate",2),s([o({converter:Y,attribute:"default-value"})],r.prototype,"defaultValue",1),s([o({type:Boolean,reflect:!0,attribute:"read-only"})],r.prototype,"readOnly",2),s([o({type:Boolean,reflect:!0,attribute:"outside-day-selectable"})],r.prototype,"outsideDaySelectable",2),s([o({type:Boolean})],r.prototype,"disabled",2),s([o({attribute:!1})],r.prototype,"isDateDisabled",2),s([o({attribute:!1})],r.prototype,"isDateUnavailable",2),s([o({attribute:!1})],r.prototype,"getSelectionAnnouncement",2),s([o({attribute:!1})],r.prototype,"getMonthAnnouncement",2),s([o({type:String,attribute:"page-behavior"})],r.prototype,"pageBehavior",2),s([o({converter:f})],r.prototype,"today",2),s([o({converter:f,attribute:"focused-date"})],r.prototype,"focusedDate",1),s([o({converter:f,attribute:"default-focused-date"})],r.prototype,"defaultFocusedDate",2),s([o({type:String,reflect:!0})],r.prototype,"view",1),s([o({type:String,attribute:"default-view"})],r.prototype,"defaultView",2),s([o({type:String,attribute:"min-view"})],r.prototype,"minView",2),s([o({type:String,attribute:"max-view"})],r.prototype,"maxView",2),s([o({type:Boolean,reflect:!0,attribute:"week-numbers"})],r.prototype,"weekNumbers",2),r=s([j("skdx-calendar","calendar","root")],r);export{m as CALENDAR_VIEWS,y as CALENDAR_YEAR_PAGE,r as SkdxCalendar,_ as addDays,p as addMonths,ve as addYears,c as anchorOf,X as clampToDateRange,ne as clampToMonth,S as clampView,Fe as emptySelection,ye as endOfWeek,te as formatViewPageLabel,R as getDaysInMonth,Me as getISOWeek,_e as getVisibleWeeks,Ve as hasAvailableDate,we as isDateDisabled,w as isDateRange,Te as isDateSelected,v as isSameDay,g as isSameMonth,ie as nextSelection,ae as rangePositionOf,be as resetInstantDateWarning,Z as resolveCalendarDisabled,re as selectionAnnouncement,D as startOfMonth,I as startOfWeek,u as stripTime,Ae as toISODateString,k as warnInstantDate,ee as yearPageStart};
@@ -116,7 +116,7 @@ export declare class SkdxDatePickerCalendar extends LitElement {
116
116
  focusedDate?: Date;
117
117
  /**
118
118
  * Date the grid focuses first, for uncontrolled focus.
119
- * @default undefined — the selection anchor or displayed month.
119
+ * @default undefined — the selection anchor, else today when displayed, else the month.
120
120
  */
121
121
  defaultFocusedDate?: Date;
122
122
  /**
@@ -116,7 +116,7 @@ export declare class SkdxDatePickerCalendar extends LitElement {
116
116
  focusedDate?: Date;
117
117
  /**
118
118
  * Date the grid focuses first, for uncontrolled focus.
119
- * @default undefined — the selection anchor or displayed month.
119
+ * @default undefined — the selection anchor, else today when displayed, else the month.
120
120
  */
121
121
  defaultFocusedDate?: Date;
122
122
  /**
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var L=(r,o)=>{for(var e in o)f(r,e,{get:o[e],enumerable:!0})},F=(r,o,e,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of w(o))!k.call(r,i)&&i!==e&&f(r,i,{get:()=>o[i],enumerable:!(t=g(o,i))||t.enumerable});return r};var O=r=>F(f({},"__esModule",{value:!0}),r),l=(r,o,e,t)=>{for(var i=t>1?void 0:t?g(o,e):o,n=r.length-1,a;n>=0;n--)(a=r[n])&&(i=(t?a(o,e,i):a(i))||i);return t&&i&&f(o,e,i),i};var M={};L(M,{SkdxDialogContent:()=>d});module.exports=O(M);var m=require("lit"),c=require("lit/decorators.js"),u=require("../internal/aria-part.cjs"),h=require("../internal/body-scroll-lock.cjs"),y=require("../internal/closest.cjs"),b=require("../internal/define.cjs"),s=require("../internal/dismiss.cjs"),p=require("../internal/focus-targets.cjs"),A=require("../internal/light-dom-styles.cjs"),D=require("../internal/part.cjs"),E=require("../internal/tabbable.cjs");function v(r){return r==="any"||r==="outside"}var d=class extends m.LitElement{constructor(){super(...arguments);this.childObserver=new MutationObserver(()=>{this.adoptChildren(),this.syncHostAttributes()});this.dialogAncestor=null;this.locked=!1;this.wasOpen=!1;this.previouslyFocused=null;this.observer=new MutationObserver(()=>this.syncNativeDialog());this.layer={insideElements:()=>[this,this.dialogAncestor?.triggerEl]};this.handleCancel=e=>{let t=this.dialogAncestor?.effectiveDismiss??"any",i=t==="any"||t==="escape";(!(0,s.dispatchEscapeKeyDown)(this,e)||!i)&&e.preventDefault()};this.handleClose=()=>this.dialogAncestor?.setOpen(!1);this.handleKeydown=e=>{let t=this.nativeDialog;t&&this.dialogAncestor?.effectiveModal&&(0,E.wrapTabWithin)(t,e)};this.handleBackdropPointerDown=e=>{let t=(0,s.backdropPointerDown)(e,this.nativeDialog);t&&(0,s.dispatchOutside)(this,"pointer-down-outside",t)&&this.dialogAncestor?.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsidePointerDown=e=>{if(!this.dialogAncestor?.open)return;let t=e.target;!t||this.contains(t)||t===this.nativeDialog||(0,s.triggerContains)(this.dialogAncestor.triggerEl,t)||(0,s.nestedLayerContains)(this.layer,t)||(0,s.dispatchOutside)(this,"pointer-down-outside",e)&&this.dialogAncestor.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsideFocus=e=>{if(!this.dialogAncestor?.open)return;let t=(0,s.focusOutsideTarget)(e);!t||this.contains(t)||(0,s.triggerContains)(this.dialogAncestor.triggerEl,t)||(0,s.nestedLayerContains)(this.layer,t)||(0,s.dispatchOutside)(this,"focus-outside",e)&&this.dialogAncestor.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()}}createRenderRoot(){let e=document.createElement("dialog");return e.setAttribute("part","content"),(0,D.applyHostPart)(e,"dialog","content"),e.addEventListener("cancel",this.handleCancel),e.addEventListener("close",this.handleClose),e.addEventListener("pointerdown",this.handleBackdropPointerDown),e.addEventListener("keydown",this.handleKeydown),this.append(e),this.adoptChildren(),e}adoptChildren(){let e=this.nativeDialog;if(!e)return;let t=document.activeElement;for(let i of Array.from(this.childNodes))i!==e&&e.append(i);t&&document.activeElement!==t&&e.contains(t)&&t.focus({preventScroll:!0})}connectedCallback(){if(super.connectedCallback(),(0,A.installLightDomStyles)(),this.dialogAncestor=(0,y.closestThroughPortal)(this,"skdx-dialog, skdx-dialog-root"),!this.dialogAncestor)throw new Error("<skdx-dialog-content> must be used inside <skdx-dialog> or <skdx-dialog-root>.");this.observer.observe(this.dialogAncestor,{attributeFilter:["open","modal","dismiss","dismissible"]}),this.childObserver.observe(this,{childList:!0,subtree:!0}),document.addEventListener("focusin",this.handleOutsideFocus),document.addEventListener("pointerdown",this.handleOutsidePointerDown,!0),this.syncHostAttributes()}disconnectedCallback(){this.observer.disconnect(),this.childObserver.disconnect(),document.removeEventListener("focusin",this.handleOutsideFocus),document.removeEventListener("pointerdown",this.handleOutsidePointerDown,!0),this.releaseLayer?.(),this.releaseLayer=void 0,this.locked&&((0,h.unlockBodyScroll)(),this.locked=!1),super.disconnectedCallback()}firstUpdated(){this.syncNativeDialog()}updated(e){(e.has("size")||e.has("status"))&&this.syncHostAttributes()}syncHostAttributes(){let e=this.dialogAncestor;if(!e)return;this.id?e.contentId=this.id:this.id=e.contentId;let t=e.open?"open":"closed";this.setAttribute("data-state",t),this.setAttribute("data-dismiss",e.effectiveDismiss);let i=this.nativeDialog;if(i){i.setAttribute("role",e.role),e.effectiveModal?i.setAttribute("aria-modal","true"):i.removeAttribute("aria-modal"),(0,u.forwardAuthoredAria)(this,i),(0,u.syncPartIdRef)(i,"aria-labelledby",this.querySelector("skdx-dialog-title"),"skdx-dialog-content","title"),(0,u.syncPartIdRef)(i,"aria-describedby",this.querySelector("skdx-dialog-description"),"skdx-dialog-content","description"),i.setAttribute("data-state",t),i.setAttribute("data-dismiss",e.effectiveDismiss);for(let n of["data-size","data-status"]){let a=this.getAttribute(n);a==null?i.removeAttribute(n):i.setAttribute(n,a)}}}requestRoleSync(){this.syncHostAttributes()}get nativeDialog(){return this.querySelector("dialog")}syncNativeDialog(){this.syncHostAttributes();let e=this.dialogAncestor,t=this.nativeDialog;if(!e||!t)return;e.open?this.releaseLayer??(this.releaseLayer=(0,s.pushDismissLayer)(this.layer)):(this.releaseLayer?.(),this.releaseLayer=void 0),e.open&&!t.open?(0,s.focusOnOpen)(()=>{e.effectiveModal?t.showModal?.():t.show?.()}):!e.open&&t.open&&(0,s.focusOnOpen)(()=>t.close?.());let i=e.open&&e.effectiveModal;i&&!this.locked?(0,h.lockBodyScroll)():!i&&this.locked&&(0,h.unlockBodyScroll)(),this.locked=i,this.syncAutoFocus(e.open)}syncAutoFocus(e){if(e===this.wasOpen)return;if(this.wasOpen=e,e){this.previouslyFocused=document.activeElement,requestAnimationFrame(()=>(0,s.focusOnOpen)(()=>(0,p.applyOpenAutoFocus)(this.nativeDialog??this,this.initialFocus,"Dialog",(0,s.autoFocusRelay)(this),this.previouslyFocused)));return}let t=this.previouslyFocused===document.body?null:this.previouslyFocused,i=!1,n=(0,s.autoFocusRelay)(this);(0,p.returnFocus)(this.finalFocus,"Dialog",t,a=>{n(a),i=a.defaultPrevented}),i&&document.activeElement===t&&t?.blur?.()}};l([(0,c.property)({type:String,attribute:"initial-focus"})],d.prototype,"initialFocus",2),l([(0,c.property)({type:String,attribute:"final-focus"})],d.prototype,"finalFocus",2),l([(0,c.property)({type:String,reflect:!0,attribute:"data-size"})],d.prototype,"size",2),l([(0,c.property)({type:String,reflect:!0,attribute:"data-status"})],d.prototype,"status",2),d=l([(0,b.customElement)("skdx-dialog-content")],d);0&&(module.exports={SkdxDialogContent});
1
+ "use strict";var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var L=(r,o)=>{for(var e in o)f(r,e,{get:o[e],enumerable:!0})},F=(r,o,e,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of w(o))!k.call(r,i)&&i!==e&&f(r,i,{get:()=>o[i],enumerable:!(t=g(o,i))||t.enumerable});return r};var O=r=>F(f({},"__esModule",{value:!0}),r),d=(r,o,e,t)=>{for(var i=t>1?void 0:t?g(o,e):o,n=r.length-1,a;n>=0;n--)(a=r[n])&&(i=(t?a(o,e,i):a(i))||i);return t&&i&&f(o,e,i),i};var M={};L(M,{SkdxDialogContent:()=>l});module.exports=O(M);var m=require("lit"),c=require("lit/decorators.js"),u=require("../internal/aria-part.cjs"),h=require("../internal/body-scroll-lock.cjs"),y=require("../internal/closest.cjs"),b=require("../internal/define.cjs"),s=require("../internal/dismiss.cjs"),p=require("../internal/focus-targets.cjs"),A=require("../internal/light-dom-styles.cjs"),D=require("../internal/part.cjs"),E=require("../internal/tabbable.cjs");function v(r){return r==="any"||r==="outside"}var l=class extends m.LitElement{constructor(){super(...arguments);this.childObserver=new MutationObserver(()=>{this.adoptChildren(),this.syncHostAttributes()});this.dialogAncestor=null;this.locked=!1;this.wasOpen=!1;this.previouslyFocused=null;this.observer=new MutationObserver(()=>this.syncNativeDialog());this.layer={insideElements:()=>[this,this.dialogAncestor?.triggerEl]};this.handleCancel=e=>{let t=this.dialogAncestor?.effectiveDismiss??"any",i=t==="any"||t==="escape";(!(0,s.dispatchEscapeKeyDown)(this,e)||!i)&&e.preventDefault()};this.handleClose=()=>this.dialogAncestor?.setOpen(!1);this.handleKeydown=e=>{let t=this.nativeDialog;t&&this.dialogAncestor?.effectiveModal&&(0,E.wrapTabWithin)(t,e)};this.handleBackdropPointerDown=e=>{let t=(0,s.backdropPointerDown)(e,this.nativeDialog);t&&(0,s.dispatchOutside)(this,"pointer-down-outside",t)&&this.dialogAncestor?.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsidePointerDown=e=>{if(!this.dialogAncestor?.open)return;let t=e.target;!t||this.contains(t)||t===this.nativeDialog||(0,s.triggerContains)(this.dialogAncestor.triggerEl,t)||(0,s.nestedLayerContains)(this.layer,t)||(0,s.dispatchOutside)(this,"pointer-down-outside",e)&&this.dialogAncestor.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsideFocus=e=>{if(!this.dialogAncestor?.open)return;let t=(0,s.focusOutsideTarget)(e);!t||this.contains(t)||(0,s.triggerContains)(this.dialogAncestor.triggerEl,t)||(0,s.nestedLayerContains)(this.layer,t)||(0,s.dispatchOutside)(this,"focus-outside",e)&&this.dialogAncestor.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()}}createRenderRoot(){let e=document.createElement("dialog");return e.setAttribute("part","content"),(0,D.applyHostPart)(e,"dialog","content"),e.addEventListener("cancel",this.handleCancel),e.addEventListener("close",this.handleClose),e.addEventListener("pointerdown",this.handleBackdropPointerDown),e.addEventListener("keydown",this.handleKeydown),this.append(e),this.adoptChildren(),e}adoptChildren(){let e=this.nativeDialog;if(!e)return;let t=document.activeElement;for(let i of Array.from(this.childNodes))i!==e&&e.append(i);t&&document.activeElement!==t&&e.contains(t)&&t.focus({preventScroll:!0})}connectedCallback(){if(super.connectedCallback(),(0,A.installLightDomStyles)(),this.dialogAncestor=(0,y.closestThroughPortal)(this,"skdx-dialog, skdx-dialog-root"),!this.dialogAncestor)throw new Error("<skdx-dialog-content> must be used inside <skdx-dialog> or <skdx-dialog-root>.");this.observer.observe(this.dialogAncestor,{attributeFilter:["open","modal","dismiss","dismissible"]}),this.childObserver.observe(this,{childList:!0,subtree:!0}),document.addEventListener("focusin",this.handleOutsideFocus),document.addEventListener("pointerdown",this.handleOutsidePointerDown,!0),this.syncHostAttributes()}disconnectedCallback(){this.observer.disconnect(),this.childObserver.disconnect(),document.removeEventListener("focusin",this.handleOutsideFocus),document.removeEventListener("pointerdown",this.handleOutsidePointerDown,!0),this.releaseLayer?.(),this.releaseLayer=void 0,this.locked&&((0,h.unlockBodyScroll)(),this.locked=!1),this.wasOpen&&this.syncAutoFocus(!1),super.disconnectedCallback()}firstUpdated(){this.syncNativeDialog()}updated(e){(e.has("size")||e.has("status"))&&this.syncHostAttributes()}syncHostAttributes(){let e=this.dialogAncestor;if(!e)return;this.id?e.contentId=this.id:this.id=e.contentId;let t=e.open?"open":"closed";this.setAttribute("data-state",t),this.setAttribute("data-dismiss",e.effectiveDismiss);let i=this.nativeDialog;if(i){i.setAttribute("role",e.role),e.effectiveModal?i.setAttribute("aria-modal","true"):i.removeAttribute("aria-modal"),(0,u.forwardAuthoredAria)(this,i),(0,u.syncPartIdRef)(i,"aria-labelledby",this.querySelector("skdx-dialog-title"),"skdx-dialog-content","title"),(0,u.syncPartIdRef)(i,"aria-describedby",this.querySelector("skdx-dialog-description"),"skdx-dialog-content","description"),i.setAttribute("data-state",t),i.setAttribute("data-dismiss",e.effectiveDismiss);for(let n of["data-size","data-status"]){let a=this.getAttribute(n);a==null?i.removeAttribute(n):i.setAttribute(n,a)}}}requestRoleSync(){this.syncHostAttributes()}get nativeDialog(){return this.querySelector("dialog")}syncNativeDialog(){this.syncHostAttributes();let e=this.dialogAncestor,t=this.nativeDialog;if(!e||!t)return;e.open?this.releaseLayer??(this.releaseLayer=(0,s.pushDismissLayer)(this.layer)):(this.releaseLayer?.(),this.releaseLayer=void 0),e.open&&!t.open?(0,s.focusOnOpen)(()=>{e.effectiveModal?t.showModal?.():t.show?.()}):!e.open&&t.open&&(0,s.focusOnOpen)(()=>t.close?.());let i=e.open&&e.effectiveModal;i&&!this.locked?(0,h.lockBodyScroll)():!i&&this.locked&&(0,h.unlockBodyScroll)(),this.locked=i,this.syncAutoFocus(e.open)}syncAutoFocus(e){if(e===this.wasOpen)return;if(this.wasOpen=e,e){this.previouslyFocused=document.activeElement,requestAnimationFrame(()=>(0,s.focusOnOpen)(()=>(0,p.applyOpenAutoFocus)(this.nativeDialog??this,this.initialFocus,"Dialog",(0,s.autoFocusRelay)(this),this.previouslyFocused)));return}let t=this.previouslyFocused===document.body?null:this.previouslyFocused,i=!1,n=(0,s.autoFocusRelay)(this);(0,p.returnFocus)(this.finalFocus,"Dialog",t,a=>{n(a),i=a.defaultPrevented}),i&&document.activeElement===t&&t?.blur?.()}};d([(0,c.property)({type:String,attribute:"initial-focus"})],l.prototype,"initialFocus",2),d([(0,c.property)({type:String,attribute:"final-focus"})],l.prototype,"finalFocus",2),d([(0,c.property)({type:String,reflect:!0,attribute:"data-size"})],l.prototype,"size",2),d([(0,c.property)({type:String,reflect:!0,attribute:"data-status"})],l.prototype,"status",2),l=d([(0,b.customElement)("skdx-dialog-content")],l);0&&(module.exports={SkdxDialogContent});
@@ -1 +1 @@
1
- var y=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var a=(n,d,e,t)=>{for(var i=t>1?void 0:t?b(d,e):d,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(d,e,i):o(i))||i);return t&&i&&y(d,e,i),i};import{LitElement as A}from"lit";import{property as l}from"lit/decorators.js";import{forwardAuthoredAria as D,syncPartIdRef as f}from"../internal/aria-part.js";import{lockBodyScroll as E,unlockBodyScroll as p}from"../internal/body-scroll-lock.js";import{closestThroughPortal as w}from"../internal/closest.js";import{customElement as k}from"../internal/define.js";import{autoFocusRelay as v,backdropPointerDown as L,dispatchEscapeKeyDown as F,dispatchOutside as c,focusOnOpen as u,focusOutsideTarget as O,nestedLayerContains as g,pushDismissLayer as M,triggerContains as m}from"../internal/dismiss.js";import{applyOpenAutoFocus as H,returnFocus as x}from"../internal/focus-targets.js";import{installLightDomStyles as P}from"../internal/light-dom-styles.js";import{applyHostPart as S}from"../internal/part.js";import{wrapTabWithin as T}from"../internal/tabbable.js";function h(n){return n==="any"||n==="outside"}var r=class extends A{constructor(){super(...arguments);this.childObserver=new MutationObserver(()=>{this.adoptChildren(),this.syncHostAttributes()});this.dialogAncestor=null;this.locked=!1;this.wasOpen=!1;this.previouslyFocused=null;this.observer=new MutationObserver(()=>this.syncNativeDialog());this.layer={insideElements:()=>[this,this.dialogAncestor?.triggerEl]};this.handleCancel=e=>{let t=this.dialogAncestor?.effectiveDismiss??"any",i=t==="any"||t==="escape";(!F(this,e)||!i)&&e.preventDefault()};this.handleClose=()=>this.dialogAncestor?.setOpen(!1);this.handleKeydown=e=>{let t=this.nativeDialog;t&&this.dialogAncestor?.effectiveModal&&T(t,e)};this.handleBackdropPointerDown=e=>{let t=L(e,this.nativeDialog);t&&c(this,"pointer-down-outside",t)&&this.dialogAncestor?.effectiveModal&&h(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsidePointerDown=e=>{if(!this.dialogAncestor?.open)return;let t=e.target;!t||this.contains(t)||t===this.nativeDialog||m(this.dialogAncestor.triggerEl,t)||g(this.layer,t)||c(this,"pointer-down-outside",e)&&this.dialogAncestor.effectiveModal&&h(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsideFocus=e=>{if(!this.dialogAncestor?.open)return;let t=O(e);!t||this.contains(t)||m(this.dialogAncestor.triggerEl,t)||g(this.layer,t)||c(this,"focus-outside",e)&&this.dialogAncestor.effectiveModal&&h(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()}}createRenderRoot(){let e=document.createElement("dialog");return e.setAttribute("part","content"),S(e,"dialog","content"),e.addEventListener("cancel",this.handleCancel),e.addEventListener("close",this.handleClose),e.addEventListener("pointerdown",this.handleBackdropPointerDown),e.addEventListener("keydown",this.handleKeydown),this.append(e),this.adoptChildren(),e}adoptChildren(){let e=this.nativeDialog;if(!e)return;let t=document.activeElement;for(let i of Array.from(this.childNodes))i!==e&&e.append(i);t&&document.activeElement!==t&&e.contains(t)&&t.focus({preventScroll:!0})}connectedCallback(){if(super.connectedCallback(),P(),this.dialogAncestor=w(this,"skdx-dialog, skdx-dialog-root"),!this.dialogAncestor)throw new Error("<skdx-dialog-content> must be used inside <skdx-dialog> or <skdx-dialog-root>.");this.observer.observe(this.dialogAncestor,{attributeFilter:["open","modal","dismiss","dismissible"]}),this.childObserver.observe(this,{childList:!0,subtree:!0}),document.addEventListener("focusin",this.handleOutsideFocus),document.addEventListener("pointerdown",this.handleOutsidePointerDown,!0),this.syncHostAttributes()}disconnectedCallback(){this.observer.disconnect(),this.childObserver.disconnect(),document.removeEventListener("focusin",this.handleOutsideFocus),document.removeEventListener("pointerdown",this.handleOutsidePointerDown,!0),this.releaseLayer?.(),this.releaseLayer=void 0,this.locked&&(p(),this.locked=!1),super.disconnectedCallback()}firstUpdated(){this.syncNativeDialog()}updated(e){(e.has("size")||e.has("status"))&&this.syncHostAttributes()}syncHostAttributes(){let e=this.dialogAncestor;if(!e)return;this.id?e.contentId=this.id:this.id=e.contentId;let t=e.open?"open":"closed";this.setAttribute("data-state",t),this.setAttribute("data-dismiss",e.effectiveDismiss);let i=this.nativeDialog;if(i){i.setAttribute("role",e.role),e.effectiveModal?i.setAttribute("aria-modal","true"):i.removeAttribute("aria-modal"),D(this,i),f(i,"aria-labelledby",this.querySelector("skdx-dialog-title"),"skdx-dialog-content","title"),f(i,"aria-describedby",this.querySelector("skdx-dialog-description"),"skdx-dialog-content","description"),i.setAttribute("data-state",t),i.setAttribute("data-dismiss",e.effectiveDismiss);for(let s of["data-size","data-status"]){let o=this.getAttribute(s);o==null?i.removeAttribute(s):i.setAttribute(s,o)}}}requestRoleSync(){this.syncHostAttributes()}get nativeDialog(){return this.querySelector("dialog")}syncNativeDialog(){this.syncHostAttributes();let e=this.dialogAncestor,t=this.nativeDialog;if(!e||!t)return;e.open?this.releaseLayer??(this.releaseLayer=M(this.layer)):(this.releaseLayer?.(),this.releaseLayer=void 0),e.open&&!t.open?u(()=>{e.effectiveModal?t.showModal?.():t.show?.()}):!e.open&&t.open&&u(()=>t.close?.());let i=e.open&&e.effectiveModal;i&&!this.locked?E():!i&&this.locked&&p(),this.locked=i,this.syncAutoFocus(e.open)}syncAutoFocus(e){if(e===this.wasOpen)return;if(this.wasOpen=e,e){this.previouslyFocused=document.activeElement,requestAnimationFrame(()=>u(()=>H(this.nativeDialog??this,this.initialFocus,"Dialog",v(this),this.previouslyFocused)));return}let t=this.previouslyFocused===document.body?null:this.previouslyFocused,i=!1,s=v(this);x(this.finalFocus,"Dialog",t,o=>{s(o),i=o.defaultPrevented}),i&&document.activeElement===t&&t?.blur?.()}};a([l({type:String,attribute:"initial-focus"})],r.prototype,"initialFocus",2),a([l({type:String,attribute:"final-focus"})],r.prototype,"finalFocus",2),a([l({type:String,reflect:!0,attribute:"data-size"})],r.prototype,"size",2),a([l({type:String,reflect:!0,attribute:"data-status"})],r.prototype,"status",2),r=a([k("skdx-dialog-content")],r);export{r as SkdxDialogContent};
1
+ var y=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var a=(n,l,e,t)=>{for(var i=t>1?void 0:t?b(l,e):l,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(l,e,i):o(i))||i);return t&&i&&y(l,e,i),i};import{LitElement as A}from"lit";import{property as d}from"lit/decorators.js";import{forwardAuthoredAria as D,syncPartIdRef as f}from"../internal/aria-part.js";import{lockBodyScroll as E,unlockBodyScroll as p}from"../internal/body-scroll-lock.js";import{closestThroughPortal as w}from"../internal/closest.js";import{customElement as k}from"../internal/define.js";import{autoFocusRelay as v,backdropPointerDown as L,dispatchEscapeKeyDown as F,dispatchOutside as c,focusOnOpen as u,focusOutsideTarget as O,nestedLayerContains as g,pushDismissLayer as M,triggerContains as m}from"../internal/dismiss.js";import{applyOpenAutoFocus as H,returnFocus as x}from"../internal/focus-targets.js";import{installLightDomStyles as P}from"../internal/light-dom-styles.js";import{applyHostPart as S}from"../internal/part.js";import{wrapTabWithin as T}from"../internal/tabbable.js";function h(n){return n==="any"||n==="outside"}var r=class extends A{constructor(){super(...arguments);this.childObserver=new MutationObserver(()=>{this.adoptChildren(),this.syncHostAttributes()});this.dialogAncestor=null;this.locked=!1;this.wasOpen=!1;this.previouslyFocused=null;this.observer=new MutationObserver(()=>this.syncNativeDialog());this.layer={insideElements:()=>[this,this.dialogAncestor?.triggerEl]};this.handleCancel=e=>{let t=this.dialogAncestor?.effectiveDismiss??"any",i=t==="any"||t==="escape";(!F(this,e)||!i)&&e.preventDefault()};this.handleClose=()=>this.dialogAncestor?.setOpen(!1);this.handleKeydown=e=>{let t=this.nativeDialog;t&&this.dialogAncestor?.effectiveModal&&T(t,e)};this.handleBackdropPointerDown=e=>{let t=L(e,this.nativeDialog);t&&c(this,"pointer-down-outside",t)&&this.dialogAncestor?.effectiveModal&&h(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsidePointerDown=e=>{if(!this.dialogAncestor?.open)return;let t=e.target;!t||this.contains(t)||t===this.nativeDialog||m(this.dialogAncestor.triggerEl,t)||g(this.layer,t)||c(this,"pointer-down-outside",e)&&this.dialogAncestor.effectiveModal&&h(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsideFocus=e=>{if(!this.dialogAncestor?.open)return;let t=O(e);!t||this.contains(t)||m(this.dialogAncestor.triggerEl,t)||g(this.layer,t)||c(this,"focus-outside",e)&&this.dialogAncestor.effectiveModal&&h(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()}}createRenderRoot(){let e=document.createElement("dialog");return e.setAttribute("part","content"),S(e,"dialog","content"),e.addEventListener("cancel",this.handleCancel),e.addEventListener("close",this.handleClose),e.addEventListener("pointerdown",this.handleBackdropPointerDown),e.addEventListener("keydown",this.handleKeydown),this.append(e),this.adoptChildren(),e}adoptChildren(){let e=this.nativeDialog;if(!e)return;let t=document.activeElement;for(let i of Array.from(this.childNodes))i!==e&&e.append(i);t&&document.activeElement!==t&&e.contains(t)&&t.focus({preventScroll:!0})}connectedCallback(){if(super.connectedCallback(),P(),this.dialogAncestor=w(this,"skdx-dialog, skdx-dialog-root"),!this.dialogAncestor)throw new Error("<skdx-dialog-content> must be used inside <skdx-dialog> or <skdx-dialog-root>.");this.observer.observe(this.dialogAncestor,{attributeFilter:["open","modal","dismiss","dismissible"]}),this.childObserver.observe(this,{childList:!0,subtree:!0}),document.addEventListener("focusin",this.handleOutsideFocus),document.addEventListener("pointerdown",this.handleOutsidePointerDown,!0),this.syncHostAttributes()}disconnectedCallback(){this.observer.disconnect(),this.childObserver.disconnect(),document.removeEventListener("focusin",this.handleOutsideFocus),document.removeEventListener("pointerdown",this.handleOutsidePointerDown,!0),this.releaseLayer?.(),this.releaseLayer=void 0,this.locked&&(p(),this.locked=!1),this.wasOpen&&this.syncAutoFocus(!1),super.disconnectedCallback()}firstUpdated(){this.syncNativeDialog()}updated(e){(e.has("size")||e.has("status"))&&this.syncHostAttributes()}syncHostAttributes(){let e=this.dialogAncestor;if(!e)return;this.id?e.contentId=this.id:this.id=e.contentId;let t=e.open?"open":"closed";this.setAttribute("data-state",t),this.setAttribute("data-dismiss",e.effectiveDismiss);let i=this.nativeDialog;if(i){i.setAttribute("role",e.role),e.effectiveModal?i.setAttribute("aria-modal","true"):i.removeAttribute("aria-modal"),D(this,i),f(i,"aria-labelledby",this.querySelector("skdx-dialog-title"),"skdx-dialog-content","title"),f(i,"aria-describedby",this.querySelector("skdx-dialog-description"),"skdx-dialog-content","description"),i.setAttribute("data-state",t),i.setAttribute("data-dismiss",e.effectiveDismiss);for(let s of["data-size","data-status"]){let o=this.getAttribute(s);o==null?i.removeAttribute(s):i.setAttribute(s,o)}}}requestRoleSync(){this.syncHostAttributes()}get nativeDialog(){return this.querySelector("dialog")}syncNativeDialog(){this.syncHostAttributes();let e=this.dialogAncestor,t=this.nativeDialog;if(!e||!t)return;e.open?this.releaseLayer??(this.releaseLayer=M(this.layer)):(this.releaseLayer?.(),this.releaseLayer=void 0),e.open&&!t.open?u(()=>{e.effectiveModal?t.showModal?.():t.show?.()}):!e.open&&t.open&&u(()=>t.close?.());let i=e.open&&e.effectiveModal;i&&!this.locked?E():!i&&this.locked&&p(),this.locked=i,this.syncAutoFocus(e.open)}syncAutoFocus(e){if(e===this.wasOpen)return;if(this.wasOpen=e,e){this.previouslyFocused=document.activeElement,requestAnimationFrame(()=>u(()=>H(this.nativeDialog??this,this.initialFocus,"Dialog",v(this),this.previouslyFocused)));return}let t=this.previouslyFocused===document.body?null:this.previouslyFocused,i=!1,s=v(this);x(this.finalFocus,"Dialog",t,o=>{s(o),i=o.defaultPrevented}),i&&document.activeElement===t&&t?.blur?.()}};a([d({type:String,attribute:"initial-focus"})],r.prototype,"initialFocus",2),a([d({type:String,attribute:"final-focus"})],r.prototype,"finalFocus",2),a([d({type:String,reflect:!0,attribute:"data-size"})],r.prototype,"size",2),a([d({type:String,reflect:!0,attribute:"data-status"})],r.prototype,"status",2),r=a([k("skdx-dialog-content")],r);export{r as SkdxDialogContent};
@@ -1,4 +1,4 @@
1
- "use strict";var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var b=(n,t)=>{for(var e in t)a(n,e,{get:t[e],enumerable:!0})},f=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of m(t))!y.call(n,r)&&r!==e&&a(n,r,{get:()=>t[r],enumerable:!(i=g(t,r))||i.enumerable});return n};var E=n=>f(a({},"__esModule",{value:!0}),n),p=(n,t,e,i)=>{for(var r=i>1?void 0:i?g(t,e):t,d=n.length-1,l;d>=0;d--)(l=n[d])&&(r=(i?l(t,e,r):l(r))||r);return i&&r&&a(t,e,r),r};var L={};b(L,{SkdxFloatingPanelHeader:()=>o});module.exports=E(L);var s=require("lit"),u=require("../internal/define.cjs"),h=require("./family.cjs"),v=require("./FloatingPanel.cjs"),c=require("./gesture.cjs");var o=class extends s.LitElement{constructor(){super(...arguments);this.root=null;this.onRootUpdate=()=>this.syncHostState();this.dragOrigin=null;this.nudged=!1;this.handlePointerDown=e=>{this.canDrag&&(this.setPointerCapture?.(e.pointerId),this.dragOrigin={x:e.clientX,y:e.clientY},this.root&&(this.root.dragging=!0))};this.handlePointerMove=e=>{let i=this.dragOrigin;!this.canDrag||!i||(this.root?.moveBy(e.clientX-i.x,e.clientY-i.y),this.dragOrigin={x:e.clientX,y:e.clientY})};this.endDrag=e=>{this.dragOrigin&&(this.releasePointerCapture?.(e.pointerId),this.dragOrigin=null,this.root&&(this.root.dragging=!1),this.root?.announceRelease("move"))};this.handleKeyDown=e=>{if(!this.canDrag||!this.root)return;let i=(0,c.arrowDelta)(e,this,this.root.step);i&&(e.preventDefault(),this.nudged=!0,this.root.moveBy(i.dx,i.dy))};this.handleKeyUp=()=>{this.nudged&&(this.nudged=!1,this.root?.announceRelease("move"))}}get canDrag(){return!!this.root&&this.root.draggable&&!this.root.disabled}connectedCallback(){if(super.connectedCallback(),this.root??(this.root=(0,v.findFloatingPanel)(this)),!this.root)throw new Error("<skdx-floating-panel-header> must be used inside <skdx-floating-panel>.");this.root.addEventListener(h.FLOATING_PANEL_FAMILY.event,this.onRootUpdate),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("pointermove",this.handlePointerMove),this.addEventListener("pointerup",this.endDrag),this.addEventListener("pointercancel",this.endDrag),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("keyup",this.handleKeyUp),this.syncHostState()}disconnectedCallback(){this.root?.removeEventListener(h.FLOATING_PANEL_FAMILY.event,this.onRootUpdate),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("pointermove",this.handlePointerMove),this.removeEventListener("pointerup",this.endDrag),this.removeEventListener("pointercancel",this.endDrag),this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("keyup",this.handleKeyUp),super.disconnectedCallback()}syncHostState(){let e=this.root;e&&(this.setAttribute("role","group"),this.toggleAttribute("data-dragging",e.dragging),this.toggleAttribute("data-disabled",e.disabled),e.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),e.draggable?this.setAttribute("aria-keyshortcuts","ArrowUp ArrowDown ArrowLeft ArrowRight"):this.removeAttribute("aria-keyshortcuts"),e.draggable?this.tabIndex=0:this.removeAttribute("tabindex"),this.style.cursor=this.canDrag?"move":"")}render(){return s.html`<slot></slot>`}};o.styles=s.css`
1
+ "use strict";var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var b=(n,t)=>{for(var e in t)a(n,e,{get:t[e],enumerable:!0})},f=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of m(t))!y.call(n,i)&&i!==e&&a(n,i,{get:()=>t[i],enumerable:!(r=g(t,i))||r.enumerable});return n};var E=n=>f(a({},"__esModule",{value:!0}),n),p=(n,t,e,r)=>{for(var i=r>1?void 0:r?g(t,e):t,d=n.length-1,l;d>=0;d--)(l=n[d])&&(i=(r?l(t,e,i):l(i))||i);return r&&i&&a(t,e,i),i};var D={};b(D,{SkdxFloatingPanelHeader:()=>o});module.exports=E(D);var s=require("lit"),u=require("../internal/define.cjs"),h=require("./family.cjs"),c=require("./FloatingPanel.cjs"),v=require("./gesture.cjs");var L='button, a, input, select, textarea, [role="button"]',o=class extends s.LitElement{constructor(){super(...arguments);this.root=null;this.onRootUpdate=()=>this.syncHostState();this.dragOrigin=null;this.nudged=!1;this.handlePointerDown=e=>{this.canDrag&&(e.target.closest?.(L)||(this.setPointerCapture?.(e.pointerId),this.dragOrigin={x:e.clientX,y:e.clientY},this.root&&(this.root.dragging=!0)))};this.handlePointerMove=e=>{let r=this.dragOrigin;!this.canDrag||!r||(this.root?.moveBy(e.clientX-r.x,e.clientY-r.y),this.dragOrigin={x:e.clientX,y:e.clientY})};this.endDrag=e=>{this.dragOrigin&&(this.releasePointerCapture?.(e.pointerId),this.dragOrigin=null,this.root&&(this.root.dragging=!1),this.root?.announceRelease("move"))};this.handleKeyDown=e=>{if(!this.canDrag||!this.root)return;let r=(0,v.arrowDelta)(e,this,this.root.step);r&&(e.preventDefault(),this.nudged=!0,this.root.moveBy(r.dx,r.dy))};this.handleKeyUp=()=>{this.nudged&&(this.nudged=!1,this.root?.announceRelease("move"))}}get canDrag(){return!!this.root&&this.root.draggable&&!this.root.disabled}connectedCallback(){if(super.connectedCallback(),this.root??(this.root=(0,c.findFloatingPanel)(this)),!this.root)throw new Error("<skdx-floating-panel-header> must be used inside <skdx-floating-panel>.");this.root.addEventListener(h.FLOATING_PANEL_FAMILY.event,this.onRootUpdate),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("pointermove",this.handlePointerMove),this.addEventListener("pointerup",this.endDrag),this.addEventListener("pointercancel",this.endDrag),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("keyup",this.handleKeyUp),this.syncHostState()}disconnectedCallback(){this.root?.removeEventListener(h.FLOATING_PANEL_FAMILY.event,this.onRootUpdate),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("pointermove",this.handlePointerMove),this.removeEventListener("pointerup",this.endDrag),this.removeEventListener("pointercancel",this.endDrag),this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("keyup",this.handleKeyUp),super.disconnectedCallback()}syncHostState(){let e=this.root;e&&(this.setAttribute("role","group"),this.toggleAttribute("data-dragging",e.dragging),this.toggleAttribute("data-disabled",e.disabled),e.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),e.draggable?this.setAttribute("aria-keyshortcuts","ArrowUp ArrowDown ArrowLeft ArrowRight"):this.removeAttribute("aria-keyshortcuts"),e.draggable?this.tabIndex=0:this.removeAttribute("tabindex"),this.style.cursor=this.canDrag?"move":"")}render(){return s.html`<slot></slot>`}};o.styles=s.css`
2
2
  :host {
3
3
  display: block;
4
4
  /* A touch drag must not also scroll the page under the panel. */
@@ -1,7 +1,7 @@
1
- var h=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var d=(o,r,e,t)=>{for(var i=t>1?void 0:t?g(r,e):r,s=o.length-1,a;s>=0;s--)(a=o[s])&&(i=(t?a(r,e,i):a(i))||i);return t&&i&&h(r,e,i),i};import{css as p,html as u,LitElement as v}from"lit";import{customElement as c}from"../internal/define.js";import{FLOATING_PANEL_FAMILY as l}from"./family.js";import{findFloatingPanel as m}from"./FloatingPanel.js";import{arrowDelta as y}from"./gesture.js";var n=class extends v{constructor(){super(...arguments);this.root=null;this.onRootUpdate=()=>this.syncHostState();this.dragOrigin=null;this.nudged=!1;this.handlePointerDown=e=>{this.canDrag&&(this.setPointerCapture?.(e.pointerId),this.dragOrigin={x:e.clientX,y:e.clientY},this.root&&(this.root.dragging=!0))};this.handlePointerMove=e=>{let t=this.dragOrigin;!this.canDrag||!t||(this.root?.moveBy(e.clientX-t.x,e.clientY-t.y),this.dragOrigin={x:e.clientX,y:e.clientY})};this.endDrag=e=>{this.dragOrigin&&(this.releasePointerCapture?.(e.pointerId),this.dragOrigin=null,this.root&&(this.root.dragging=!1),this.root?.announceRelease("move"))};this.handleKeyDown=e=>{if(!this.canDrag||!this.root)return;let t=y(e,this,this.root.step);t&&(e.preventDefault(),this.nudged=!0,this.root.moveBy(t.dx,t.dy))};this.handleKeyUp=()=>{this.nudged&&(this.nudged=!1,this.root?.announceRelease("move"))}}get canDrag(){return!!this.root&&this.root.draggable&&!this.root.disabled}connectedCallback(){if(super.connectedCallback(),this.root??(this.root=m(this)),!this.root)throw new Error("<skdx-floating-panel-header> must be used inside <skdx-floating-panel>.");this.root.addEventListener(l.event,this.onRootUpdate),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("pointermove",this.handlePointerMove),this.addEventListener("pointerup",this.endDrag),this.addEventListener("pointercancel",this.endDrag),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("keyup",this.handleKeyUp),this.syncHostState()}disconnectedCallback(){this.root?.removeEventListener(l.event,this.onRootUpdate),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("pointermove",this.handlePointerMove),this.removeEventListener("pointerup",this.endDrag),this.removeEventListener("pointercancel",this.endDrag),this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("keyup",this.handleKeyUp),super.disconnectedCallback()}syncHostState(){let e=this.root;e&&(this.setAttribute("role","group"),this.toggleAttribute("data-dragging",e.dragging),this.toggleAttribute("data-disabled",e.disabled),e.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),e.draggable?this.setAttribute("aria-keyshortcuts","ArrowUp ArrowDown ArrowLeft ArrowRight"):this.removeAttribute("aria-keyshortcuts"),e.draggable?this.tabIndex=0:this.removeAttribute("tabindex"),this.style.cursor=this.canDrag?"move":"")}render(){return u`<slot></slot>`}};n.styles=p`
1
+ var h=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var d=(o,i,e,t)=>{for(var r=t>1?void 0:t?g(i,e):i,s=o.length-1,a;s>=0;s--)(a=o[s])&&(r=(t?a(i,e,r):a(r))||r);return t&&r&&h(i,e,r),r};import{css as p,html as u,LitElement as c}from"lit";import{customElement as v}from"../internal/define.js";import{FLOATING_PANEL_FAMILY as l}from"./family.js";import{findFloatingPanel as m}from"./FloatingPanel.js";import{arrowDelta as y}from"./gesture.js";var b='button, a, input, select, textarea, [role="button"]',n=class extends c{constructor(){super(...arguments);this.root=null;this.onRootUpdate=()=>this.syncHostState();this.dragOrigin=null;this.nudged=!1;this.handlePointerDown=e=>{this.canDrag&&(e.target.closest?.(b)||(this.setPointerCapture?.(e.pointerId),this.dragOrigin={x:e.clientX,y:e.clientY},this.root&&(this.root.dragging=!0)))};this.handlePointerMove=e=>{let t=this.dragOrigin;!this.canDrag||!t||(this.root?.moveBy(e.clientX-t.x,e.clientY-t.y),this.dragOrigin={x:e.clientX,y:e.clientY})};this.endDrag=e=>{this.dragOrigin&&(this.releasePointerCapture?.(e.pointerId),this.dragOrigin=null,this.root&&(this.root.dragging=!1),this.root?.announceRelease("move"))};this.handleKeyDown=e=>{if(!this.canDrag||!this.root)return;let t=y(e,this,this.root.step);t&&(e.preventDefault(),this.nudged=!0,this.root.moveBy(t.dx,t.dy))};this.handleKeyUp=()=>{this.nudged&&(this.nudged=!1,this.root?.announceRelease("move"))}}get canDrag(){return!!this.root&&this.root.draggable&&!this.root.disabled}connectedCallback(){if(super.connectedCallback(),this.root??(this.root=m(this)),!this.root)throw new Error("<skdx-floating-panel-header> must be used inside <skdx-floating-panel>.");this.root.addEventListener(l.event,this.onRootUpdate),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("pointermove",this.handlePointerMove),this.addEventListener("pointerup",this.endDrag),this.addEventListener("pointercancel",this.endDrag),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("keyup",this.handleKeyUp),this.syncHostState()}disconnectedCallback(){this.root?.removeEventListener(l.event,this.onRootUpdate),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("pointermove",this.handlePointerMove),this.removeEventListener("pointerup",this.endDrag),this.removeEventListener("pointercancel",this.endDrag),this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("keyup",this.handleKeyUp),super.disconnectedCallback()}syncHostState(){let e=this.root;e&&(this.setAttribute("role","group"),this.toggleAttribute("data-dragging",e.dragging),this.toggleAttribute("data-disabled",e.disabled),e.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),e.draggable?this.setAttribute("aria-keyshortcuts","ArrowUp ArrowDown ArrowLeft ArrowRight"):this.removeAttribute("aria-keyshortcuts"),e.draggable?this.tabIndex=0:this.removeAttribute("tabindex"),this.style.cursor=this.canDrag?"move":"")}render(){return u`<slot></slot>`}};n.styles=p`
2
2
  :host {
3
3
  display: block;
4
4
  /* A touch drag must not also scroll the page under the panel. */
5
5
  touch-action: none;
6
6
  }
7
- `,n=d([c("skdx-floating-panel-header","floating-panel","header")],n);export{n as SkdxFloatingPanelHeader};
7
+ `,n=d([v("skdx-floating-panel-header","floating-panel","header")],n);export{n as SkdxFloatingPanelHeader};
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},T=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of F(t))!g.call(e,r)&&r!==n&&u(e,r,{get:()=>t[r],enumerable:!(o=m(t,r))||o.enumerable});return e};var h=e=>T(u({},"__esModule",{value:!0}),e);var M={};p(M,{applyFinalFocus:()=>d,applyInitialFocus:()=>f,applyOpenAutoFocus:()=>y,initialFocusTarget:()=>L,resolveFocusSelector:()=>a,returnFocus:()=>H});module.exports=h(M);var i=require("./dismissal.cjs"),c=require("./tabbable.cjs"),E={Dialog:"the Cancel button when present, then the first tabbable element, then the panel itself",Drawer:"the first tabbable element, then the panel itself",Popover:"the first tabbable element, then the panel itself"},b={Dialog:"[data-skdx-dialog-cancel]"},v={Dialog:"the dialog panel",Drawer:"the drawer panel",Popover:"the popover panel"};function a(e,t,n,o){if(!t)return null;let r;try{r=e.querySelector(t)}catch{return console.warn(`[skdx] ${o}: ${n}="${t}" is not a valid CSS selector. Falling back to the default focus target.`),null}return r||console.warn(n==="initialFocus"?`[skdx] ${o}: initialFocus="${t}" matched no element inside ${v[o]}. Falling back to ${E[o]}.`:`[skdx] ${o}: finalFocus="${t}" matched no element in the document. Falling back to the element that was focused before it opened.`),r}function s(e,t){let n=b[t];return n?e.querySelector(n):null}function L(e,t,n){return a(e,t,"initialFocus",n)??s(e,n)??e.querySelector(c.TABBABLE_SELECTOR)??e}function f(e,t,n){let o=a(e,t,"initialFocus",n)??s(e,n);if(o){o.focus({preventScroll:!0});return}if(e.contains(document.activeElement))return;let l=e.querySelector(c.TABBABLE_SELECTOR)??e;l===e&&e.tabIndex<0&&(e.tabIndex=-1),l.focus?.({preventScroll:!0})}function d(e,t){let n=a(document,e,"finalFocus",t);return n?(n.focus({preventScroll:!0}),!0):!1}function y(e,t,n,o,r){let l=document.activeElement;return(0,i.autoFocusEvent)("open-auto-focus",o)?(f(e,t,n),!0):(document.activeElement===l&&r?.isConnected&&e.contains(l)&&r.focus({preventScroll:!0}),!1)}function H(e,t,n,o){return(0,i.autoFocusEvent)("close-auto-focus",o)?d(e,t)?!0:!n?.isConnected||n===document.body||n===document.documentElement?!1:(n.focus({preventScroll:!0}),!0):!1}0&&(module.exports={applyFinalFocus,applyInitialFocus,applyOpenAutoFocus,initialFocusTarget,resolveFocusSelector,returnFocus});
1
+ "use strict";var i=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},E=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of T(t))!g.call(e,l)&&l!==n&&i(e,l,{get:()=>t[l],enumerable:!(o=F(t,l))||o.enumerable});return e};var h=e=>E(i({},"__esModule",{value:!0}),e);var x={};p(x,{applyFinalFocus:()=>m,applyInitialFocus:()=>d,applyOpenAutoFocus:()=>H,initialFocusTarget:()=>y,resolveFocusSelector:()=>u,returnFocus:()=>M});module.exports=h(x);var a=require("./dismissal.cjs"),c=require("./tabbable.cjs"),v={Dialog:"the Cancel button when present, then the first tabbable element, then the panel itself",Drawer:"the first tabbable element, then the panel itself",Popover:"the first tabbable element, then the panel itself"},b={Dialog:"[data-skdx-dialog-cancel]"},L={Dialog:"the dialog panel",Drawer:"the drawer panel",Popover:"the popover panel"};function u(e,t,n,o){if(!t)return null;let l;try{l=e.querySelector(t)}catch{return console.warn(`[skdx] ${o}: ${n}="${t}" is not a valid CSS selector. Falling back to the default focus target.`),null}return l||console.warn(n==="initialFocus"?`[skdx] ${o}: initialFocus="${t}" matched no element inside ${L[o]}. Falling back to ${v[o]}.`:`[skdx] ${o}: finalFocus="${t}" matched no element in the document. Falling back to the element that was focused before it opened.`),l}function s(e,t){let n=b[t];return n?e.querySelector(n):null}function y(e,t,n){return u(e,t,"initialFocus",n)??s(e,n)??e.querySelector(c.TABBABLE_SELECTOR)??e}function d(e,t,n){let o=u(e,t,"initialFocus",n)??s(e,n);if(o){o.focus({preventScroll:!0});return}if(e.contains(document.activeElement))return;let r=e.querySelector(c.TABBABLE_SELECTOR)??e;r===e&&e.tabIndex<0&&(e.tabIndex=-1),r.focus?.({preventScroll:!0})}function f(e){e.focus({preventScroll:!0}),setTimeout(()=>{let t=document.activeElement;e.isConnected&&(t===null||t===document.body)&&e.focus({preventScroll:!0})})}function m(e,t){let n=u(document,e,"finalFocus",t);return n?(f(n),!0):!1}function H(e,t,n,o,l){let r=document.activeElement;return(0,a.autoFocusEvent)("open-auto-focus",o)?(d(e,t,n),!0):(document.activeElement===r&&l?.isConnected&&e.contains(r)&&l.focus({preventScroll:!0}),!1)}function M(e,t,n,o){return(0,a.autoFocusEvent)("close-auto-focus",o)?m(e,t)?!0:!n?.isConnected||n===document.body||n===document.documentElement?!1:(f(n),!0):!1}0&&(module.exports={applyFinalFocus,applyInitialFocus,applyOpenAutoFocus,initialFocusTarget,resolveFocusSelector,returnFocus});
@@ -1 +1 @@
1
- import{autoFocusEvent as u}from"./dismissal.js";import{TABBABLE_SELECTOR as i}from"./tabbable.js";var s={Dialog:"the Cancel button when present, then the first tabbable element, then the panel itself",Drawer:"the first tabbable element, then the panel itself",Popover:"the first tabbable element, then the panel itself"},f={Dialog:"[data-skdx-dialog-cancel]"},d={Dialog:"the dialog panel",Drawer:"the drawer panel",Popover:"the popover panel"};function a(e,n,t,o){if(!n)return null;let r;try{r=e.querySelector(n)}catch{return console.warn(`[skdx] ${o}: ${t}="${n}" is not a valid CSS selector. Falling back to the default focus target.`),null}return r||console.warn(t==="initialFocus"?`[skdx] ${o}: initialFocus="${n}" matched no element inside ${d[o]}. Falling back to ${s[o]}.`:`[skdx] ${o}: finalFocus="${n}" matched no element in the document. Falling back to the element that was focused before it opened.`),r}function c(e,n){let t=f[n];return t?e.querySelector(t):null}function T(e,n,t){return a(e,n,"initialFocus",t)??c(e,t)??e.querySelector(i)??e}function m(e,n,t){let o=a(e,n,"initialFocus",t)??c(e,t);if(o){o.focus({preventScroll:!0});return}if(e.contains(document.activeElement))return;let l=e.querySelector(i)??e;l===e&&e.tabIndex<0&&(e.tabIndex=-1),l.focus?.({preventScroll:!0})}function F(e,n){let t=a(document,e,"finalFocus",n);return t?(t.focus({preventScroll:!0}),!0):!1}function h(e,n,t,o,r){let l=document.activeElement;return u("open-auto-focus",o)?(m(e,n,t),!0):(document.activeElement===l&&r?.isConnected&&e.contains(l)&&r.focus({preventScroll:!0}),!1)}function E(e,n,t,o){return u("close-auto-focus",o)?F(e,n)?!0:!t?.isConnected||t===document.body||t===document.documentElement?!1:(t.focus({preventScroll:!0}),!0):!1}export{F as applyFinalFocus,m as applyInitialFocus,h as applyOpenAutoFocus,T as initialFocusTarget,a as resolveFocusSelector,E as returnFocus};
1
+ import{autoFocusEvent as i}from"./dismissal.js";import{TABBABLE_SELECTOR as a}from"./tabbable.js";var d={Dialog:"the Cancel button when present, then the first tabbable element, then the panel itself",Drawer:"the first tabbable element, then the panel itself",Popover:"the first tabbable element, then the panel itself"},f={Dialog:"[data-skdx-dialog-cancel]"},m={Dialog:"the dialog panel",Drawer:"the drawer panel",Popover:"the popover panel"};function u(e,n,t,o){if(!n)return null;let l;try{l=e.querySelector(n)}catch{return console.warn(`[skdx] ${o}: ${t}="${n}" is not a valid CSS selector. Falling back to the default focus target.`),null}return l||console.warn(t==="initialFocus"?`[skdx] ${o}: initialFocus="${n}" matched no element inside ${m[o]}. Falling back to ${d[o]}.`:`[skdx] ${o}: finalFocus="${n}" matched no element in the document. Falling back to the element that was focused before it opened.`),l}function c(e,n){let t=f[n];return t?e.querySelector(t):null}function E(e,n,t){return u(e,n,"initialFocus",t)??c(e,t)??e.querySelector(a)??e}function F(e,n,t){let o=u(e,n,"initialFocus",t)??c(e,t);if(o){o.focus({preventScroll:!0});return}if(e.contains(document.activeElement))return;let r=e.querySelector(a)??e;r===e&&e.tabIndex<0&&(e.tabIndex=-1),r.focus?.({preventScroll:!0})}function s(e){e.focus({preventScroll:!0}),setTimeout(()=>{let n=document.activeElement;e.isConnected&&(n===null||n===document.body)&&e.focus({preventScroll:!0})})}function T(e,n){let t=u(document,e,"finalFocus",n);return t?(s(t),!0):!1}function h(e,n,t,o,l){let r=document.activeElement;return i("open-auto-focus",o)?(F(e,n,t),!0):(document.activeElement===r&&l?.isConnected&&e.contains(r)&&l.focus({preventScroll:!0}),!1)}function v(e,n,t,o){return i("close-auto-focus",o)?T(e,n)?!0:!t?.isConnected||t===document.body||t===document.documentElement?!1:(s(t),!0):!1}export{T as applyFinalFocus,F as applyInitialFocus,h as applyOpenAutoFocus,E as initialFocusTarget,u as resolveFocusSelector,v as returnFocus};
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var f=(t,e)=>{for(var n in e)l(t,n,{get:e[n],enumerable:!0})},E=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!a.call(t,r)&&r!==n&&l(t,r,{get:()=>e[r],enumerable:!(o=u(e,r))||o.enumerable});return t};var d=t=>E(l({},"__esModule",{value:!0}),t);var h={};f(h,{activateLabelledButton:()=>p});module.exports=d(h);var i='a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])',m="radio, checkbox, switch, menuitemcheckbox, menuitemradio",b='button, [role="radio"], [role="checkbox"], [role="switch"]';function T(t){let n=t instanceof HTMLButtonElement||m.split(", ").includes(t.getAttribute("role")??"")?t:t.querySelector(b);return!(n instanceof HTMLElement)||n instanceof HTMLInputElement||n.disabled||n.getAttribute("aria-disabled")==="true"?null:n}function L(t,e){let n=`#${CSS.escape(e)}`;for(let o=t.parentElement;o;o=o.parentElement){let r=o.querySelector(n);if(r)return r}return t.getRootNode().getElementById(e)}function p(t,e){if(e.defaultPrevented)return;let n=t.getAttribute("for");if(!n)return;let o=e.target instanceof Element?e.target:null;if(o&&o!==t&&o.closest(i)!==t.closest(i))return;let r=L(t,n),c=r&&T(r);c&&(e.preventDefault(),c.focus(),c.click())}0&&(module.exports={activateLabelledButton});
1
+ "use strict";var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var f=(t,e)=>{for(var n in e)c(t,n,{get:e[n],enumerable:!0})},d=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!a.call(t,r)&&r!==n&&c(t,r,{get:()=>e[r],enumerable:!(o=u(e,r))||o.enumerable});return t};var E=t=>d(c({},"__esModule",{value:!0}),t);var g={};f(g,{activateLabelledButton:()=>p});module.exports=E(g);var i='a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])',m="radio, checkbox, switch, menuitemcheckbox, menuitemradio",b='button, [role="radio"], [role="checkbox"], [role="switch"]';function T(t){let n=t instanceof HTMLButtonElement||m.split(", ").includes(t.getAttribute("role")??"")?t:t.querySelector(b);return!(n instanceof HTMLElement)||n instanceof HTMLInputElement||n.disabled||n.getAttribute("aria-disabled")==="true"?null:n}function L(t,e){let n=`[id="${e.replace(/["\\]/g,"\\$&")}"]`;for(let o=t.parentElement;o;o=o.parentElement){let r=o.querySelector(n);if(r)return r}return t.getRootNode().getElementById(e)}function p(t,e){if(e.defaultPrevented)return;let n=t.getAttribute("for");if(!n)return;let o=e.target instanceof Element?e.target:null;if(o&&o!==t&&o.closest(i)!==t.closest(i))return;let r=L(t,n),l=r&&T(r);l&&(e.preventDefault(),l.focus(),l.click())}0&&(module.exports={activateLabelledButton});
@@ -1 +1 @@
1
- var l='a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])',i="radio, checkbox, switch, menuitemcheckbox, menuitemradio",u='button, [role="radio"], [role="checkbox"], [role="switch"]';function s(t){let e=t instanceof HTMLButtonElement||i.split(", ").includes(t.getAttribute("role")??"")?t:t.querySelector(u);return!(e instanceof HTMLElement)||e instanceof HTMLInputElement||e.disabled||e.getAttribute("aria-disabled")==="true"?null:e}function a(t,n){let e=`#${CSS.escape(n)}`;for(let o=t.parentElement;o;o=o.parentElement){let r=o.querySelector(e);if(r)return r}return t.getRootNode().getElementById(n)}function f(t,n){if(n.defaultPrevented)return;let e=t.getAttribute("for");if(!e)return;let o=n.target instanceof Element?n.target:null;if(o&&o!==t&&o.closest(l)!==t.closest(l))return;let r=a(t,e),c=r&&s(r);c&&(n.preventDefault(),c.focus(),c.click())}export{f as activateLabelledButton};
1
+ var c='a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])',i="radio, checkbox, switch, menuitemcheckbox, menuitemradio",u='button, [role="radio"], [role="checkbox"], [role="switch"]';function s(t){let e=t instanceof HTMLButtonElement||i.split(", ").includes(t.getAttribute("role")??"")?t:t.querySelector(u);return!(e instanceof HTMLElement)||e instanceof HTMLInputElement||e.disabled||e.getAttribute("aria-disabled")==="true"?null:e}function a(t,n){let e=`[id="${n.replace(/["\\]/g,"\\$&")}"]`;for(let o=t.parentElement;o;o=o.parentElement){let r=o.querySelector(e);if(r)return r}return t.getRootNode().getElementById(n)}function f(t,n){if(n.defaultPrevented)return;let e=t.getAttribute("for");if(!e)return;let o=n.target instanceof Element?n.target:null;if(o&&o!==t&&o.closest(c)!==t.closest(c))return;let r=a(t,e),l=r&&s(r);l&&(n.preventDefault(),l.focus(),l.click())}export{f as activateLabelledButton};
@@ -1,4 +1,4 @@
1
- "use strict";var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var k=(a,o)=>{for(var t in o)c(a,t,{get:o[t],enumerable:!0})},H=(a,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of y(o))!w.call(a,e)&&e!==t&&c(a,e,{get:()=>o[e],enumerable:!(i=f(o,e))||i.enumerable});return a};var $=a=>H(c({},"__esModule",{value:!0}),a),h=(a,o,t,i)=>{for(var e=i>1?void 0:i?f(o,t):o,n=a.length-1,u;n>=0;n--)(u=a[n])&&(e=(i?u(o,t,e):u(e))||e);return i&&e&&c(o,t,e),e};var E={};k(E,{SkdxRatingItem:()=>s});module.exports=$(E);var r=require("lit"),d=require("lit/decorators.js"),b=require("../internal/aria-label.cjs"),m=require("../internal/define.cjs"),g=require("../internal/direction.cjs"),v=require("../internal/part.cjs"),l=require("../internal/styles.cjs"),p=require("./family.cjs");var s=class extends r.LitElement{constructor(){super(...arguments);this.value=0;this.disabled=!1;this.hostLabel=null;this.root=null;this.onRootUpdate=()=>this.requestUpdate();this.pointerReason=!1;this.rootObserver=new MutationObserver(()=>this.requestUpdate());this.handleClick=t=>{if(this.isDisabled||this.root?.readOnly)return;let i=this.valueFromPointer(t);if(this.root?.allowClear&&i===this.root.value){this.root.commit(0,"pointer");return}this.root?.commit(i,"pointer")};this.handlePointerDown=()=>{this.pointerReason=!0};this.handleFocus=()=>{let t=this.pointerReason?"pointer":"keyboard";this.pointerReason=!1,!(this.isDisabled||this.allowHalf||this.isChecked)&&this.root?.commit(this.value,t)};this.handlePointerEnter=t=>{this.isDisabled||this.root?.readOnly||this.root?.setHoverValue(this.valueFromPointer(t))};this.handlePointerMove=t=>{!this.allowHalf||this.isDisabled||this.root?.readOnly||this.root?.setHoverValue(this.valueFromPointer(t))};this.handleKeydown=t=>{t.key==="Enter"&&t.preventDefault()}}connectedCallback(){if(super.connectedCallback(),this.hostLabel=(0,b.takeHostAriaLabel)(this),this.root=p.RATING_FAMILY.root(this),!this.root)throw new Error("<skdx-rating-item> must be used inside <skdx-rating>.");this.root.addEventListener(p.RATING_FAMILY.event,this.onRootUpdate),this.rootObserver.observe(this.root,{attributeFilter:["value","disabled","read-only","allow-half"]})}disconnectedCallback(){this.root?.removeEventListener(p.RATING_FAMILY.event,this.onRootUpdate),this.rootObserver.disconnect(),super.disconnectedCallback()}get allowHalf(){return this.root?.allowHalf??!1}get isChecked(){return this.root?.value===this.value||this.allowHalf&&this.root?.value===this.value-.5}get isDisabled(){return this.disabled||(this.root?.disabled??!1)}get displayValue(){let t=this.root;return t?t.hoverValue??t.value:null}get isHighlighted(){let t=this.displayValue;return t===null?!1:t>=(this.allowHalf?this.value-.5:this.value)}get isHalf(){return this.allowHalf&&this.displayValue===this.value-.5}get label(){if(this.allowHalf)return null;let t=this.root;return this.hostLabel??(t?t.itemLabel(this.value,t.max):null)}get isTabStop(){let t=this.root;return t?this.isChecked||t.value===0&&this.value===1:!1}valueFromPointer(t){if(!this.allowHalf)return this.value;let i=t.currentTarget,e=i.getBoundingClientRect();if(!e.width)return this.value;let n=(t.clientX-e.left)/e.width;return((0,g.resolveDirection)(i)==="rtl"?1-n:n)<=.5?this.value-.5:this.value}updated(){(0,v.reflectHostState)(this,{"data-disabled":this.isDisabled?"":null}),(0,v.reflectHostState)(this,{"data-state":this.isChecked?"checked":"unchecked","data-highlighted":this.isHighlighted?"":null,"data-half":this.isHalf?"":null})}render(){let t=this.isChecked,i=this.isDisabled;return this.allowHalf?r.html`
1
+ "use strict";var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var k=(a,o)=>{for(var t in o)c(a,t,{get:o[t],enumerable:!0})},H=(a,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of y(o))!w.call(a,e)&&e!==t&&c(a,e,{get:()=>o[e],enumerable:!(i=f(o,e))||i.enumerable});return a};var $=a=>H(c({},"__esModule",{value:!0}),a),h=(a,o,t,i)=>{for(var e=i>1?void 0:i?f(o,t):o,n=a.length-1,u;n>=0;n--)(u=a[n])&&(e=(i?u(o,t,e):u(e))||e);return i&&e&&c(o,t,e),e};var E={};k(E,{SkdxRatingItem:()=>s});module.exports=$(E);var r=require("lit"),d=require("lit/decorators.js"),b=require("../internal/aria-label.cjs"),m=require("../internal/define.cjs"),g=require("../internal/direction.cjs"),v=require("../internal/part.cjs"),l=require("../internal/styles.cjs"),p=require("./family.cjs");var s=class extends r.LitElement{constructor(){super(...arguments);this.value=0;this.disabled=!1;this.hostLabel=null;this.root=null;this.onRootUpdate=()=>this.requestUpdate();this.pointerReason=!1;this.rootObserver=new MutationObserver(()=>this.requestUpdate());this.handleClick=t=>{if(this.isDisabled||this.root?.readOnly)return;let i=this.valueFromPointer(t);if(this.root?.allowClear&&i===this.root.value){this.root.commit(0,"pointer");return}this.root?.commit(i,"pointer")};this.handlePointerDown=()=>{this.pointerReason=!0};this.handleFocus=()=>{let t=this.pointerReason;this.pointerReason=!1,!(t||this.isDisabled||this.allowHalf||this.isChecked)&&this.root?.commit(this.value,"keyboard")};this.handlePointerEnter=t=>{this.isDisabled||this.root?.readOnly||this.root?.setHoverValue(this.valueFromPointer(t))};this.handlePointerMove=t=>{!this.allowHalf||this.isDisabled||this.root?.readOnly||this.root?.setHoverValue(this.valueFromPointer(t))};this.handleKeydown=t=>{t.key==="Enter"&&t.preventDefault()}}connectedCallback(){if(super.connectedCallback(),this.hostLabel=(0,b.takeHostAriaLabel)(this),this.root=p.RATING_FAMILY.root(this),!this.root)throw new Error("<skdx-rating-item> must be used inside <skdx-rating>.");this.root.addEventListener(p.RATING_FAMILY.event,this.onRootUpdate),this.rootObserver.observe(this.root,{attributeFilter:["value","disabled","read-only","allow-half"]})}disconnectedCallback(){this.root?.removeEventListener(p.RATING_FAMILY.event,this.onRootUpdate),this.rootObserver.disconnect(),super.disconnectedCallback()}get allowHalf(){return this.root?.allowHalf??!1}get isChecked(){return this.root?.value===this.value||this.allowHalf&&this.root?.value===this.value-.5}get isDisabled(){return this.disabled||(this.root?.disabled??!1)}get displayValue(){let t=this.root;return t?t.hoverValue??t.value:null}get isHighlighted(){let t=this.displayValue;return t===null?!1:t>=(this.allowHalf?this.value-.5:this.value)}get isHalf(){return this.allowHalf&&this.displayValue===this.value-.5}get label(){if(this.allowHalf)return null;let t=this.root;return this.hostLabel??(t?t.itemLabel(this.value,t.max):null)}get isTabStop(){let t=this.root;return t?this.isChecked||t.value===0&&this.value===1:!1}valueFromPointer(t){if(!this.allowHalf)return this.value;let i=t.currentTarget,e=i.getBoundingClientRect();if(!e.width)return this.value;let n=(t.clientX-e.left)/e.width;return((0,g.resolveDirection)(i)==="rtl"?1-n:n)<=.5?this.value-.5:this.value}updated(){(0,v.reflectHostState)(this,{"data-disabled":this.isDisabled?"":null}),(0,v.reflectHostState)(this,{"data-state":this.isChecked?"checked":"unchecked","data-highlighted":this.isHighlighted?"":null,"data-half":this.isHalf?"":null})}render(){let t=this.isChecked,i=this.isDisabled;return this.allowHalf?r.html`
2
2
  <span
3
3
  part="item"
4
4
  role="presentation"
@@ -1,4 +1,4 @@
1
- var v=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=(h,s,t,e)=>{for(var i=e>1?void 0:e?f(s,t):s,a=h.length-1,n;a>=0;a--)(n=h[a])&&(i=(e?n(s,t,i):n(i))||i);return e&&i&&v(s,t,i),i};import{css as b,html as u,LitElement as m,nothing as r}from"lit";import{property as c,state as g}from"lit/decorators.js";import{takeHostAriaLabel as y}from"../internal/aria-label.js";import{customElement as w}from"../internal/define.js";import{resolveDirection as k}from"../internal/direction.js";import{reflectHostState as p}from"../internal/part.js";import{controlBoxOnHost as H,delegatesFocusShadowRootOptions as $,hiddenHostStyles as E,resetNativeControl as C}from"../internal/styles.js";import{RATING_FAMILY as d}from"./family.js";var o=class extends m{constructor(){super(...arguments);this.value=0;this.disabled=!1;this.hostLabel=null;this.root=null;this.onRootUpdate=()=>this.requestUpdate();this.pointerReason=!1;this.rootObserver=new MutationObserver(()=>this.requestUpdate());this.handleClick=t=>{if(this.isDisabled||this.root?.readOnly)return;let e=this.valueFromPointer(t);if(this.root?.allowClear&&e===this.root.value){this.root.commit(0,"pointer");return}this.root?.commit(e,"pointer")};this.handlePointerDown=()=>{this.pointerReason=!0};this.handleFocus=()=>{let t=this.pointerReason?"pointer":"keyboard";this.pointerReason=!1,!(this.isDisabled||this.allowHalf||this.isChecked)&&this.root?.commit(this.value,t)};this.handlePointerEnter=t=>{this.isDisabled||this.root?.readOnly||this.root?.setHoverValue(this.valueFromPointer(t))};this.handlePointerMove=t=>{!this.allowHalf||this.isDisabled||this.root?.readOnly||this.root?.setHoverValue(this.valueFromPointer(t))};this.handleKeydown=t=>{t.key==="Enter"&&t.preventDefault()}}connectedCallback(){if(super.connectedCallback(),this.hostLabel=y(this),this.root=d.root(this),!this.root)throw new Error("<skdx-rating-item> must be used inside <skdx-rating>.");this.root.addEventListener(d.event,this.onRootUpdate),this.rootObserver.observe(this.root,{attributeFilter:["value","disabled","read-only","allow-half"]})}disconnectedCallback(){this.root?.removeEventListener(d.event,this.onRootUpdate),this.rootObserver.disconnect(),super.disconnectedCallback()}get allowHalf(){return this.root?.allowHalf??!1}get isChecked(){return this.root?.value===this.value||this.allowHalf&&this.root?.value===this.value-.5}get isDisabled(){return this.disabled||(this.root?.disabled??!1)}get displayValue(){let t=this.root;return t?t.hoverValue??t.value:null}get isHighlighted(){let t=this.displayValue;return t===null?!1:t>=(this.allowHalf?this.value-.5:this.value)}get isHalf(){return this.allowHalf&&this.displayValue===this.value-.5}get label(){if(this.allowHalf)return null;let t=this.root;return this.hostLabel??(t?t.itemLabel(this.value,t.max):null)}get isTabStop(){let t=this.root;return t?this.isChecked||t.value===0&&this.value===1:!1}valueFromPointer(t){if(!this.allowHalf)return this.value;let e=t.currentTarget,i=e.getBoundingClientRect();if(!i.width)return this.value;let a=(t.clientX-i.left)/i.width;return(k(e)==="rtl"?1-a:a)<=.5?this.value-.5:this.value}updated(){p(this,{"data-disabled":this.isDisabled?"":null}),p(this,{"data-state":this.isChecked?"checked":"unchecked","data-highlighted":this.isHighlighted?"":null,"data-half":this.isHalf?"":null})}render(){let t=this.isChecked,e=this.isDisabled;return this.allowHalf?u`
1
+ var v=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=(h,s,t,e)=>{for(var i=e>1?void 0:e?f(s,t):s,a=h.length-1,n;a>=0;a--)(n=h[a])&&(i=(e?n(s,t,i):n(i))||i);return e&&i&&v(s,t,i),i};import{css as b,html as u,LitElement as m,nothing as r}from"lit";import{property as c,state as g}from"lit/decorators.js";import{takeHostAriaLabel as y}from"../internal/aria-label.js";import{customElement as w}from"../internal/define.js";import{resolveDirection as k}from"../internal/direction.js";import{reflectHostState as p}from"../internal/part.js";import{controlBoxOnHost as H,delegatesFocusShadowRootOptions as $,hiddenHostStyles as E,resetNativeControl as C}from"../internal/styles.js";import{RATING_FAMILY as d}from"./family.js";var o=class extends m{constructor(){super(...arguments);this.value=0;this.disabled=!1;this.hostLabel=null;this.root=null;this.onRootUpdate=()=>this.requestUpdate();this.pointerReason=!1;this.rootObserver=new MutationObserver(()=>this.requestUpdate());this.handleClick=t=>{if(this.isDisabled||this.root?.readOnly)return;let e=this.valueFromPointer(t);if(this.root?.allowClear&&e===this.root.value){this.root.commit(0,"pointer");return}this.root?.commit(e,"pointer")};this.handlePointerDown=()=>{this.pointerReason=!0};this.handleFocus=()=>{let t=this.pointerReason;this.pointerReason=!1,!(t||this.isDisabled||this.allowHalf||this.isChecked)&&this.root?.commit(this.value,"keyboard")};this.handlePointerEnter=t=>{this.isDisabled||this.root?.readOnly||this.root?.setHoverValue(this.valueFromPointer(t))};this.handlePointerMove=t=>{!this.allowHalf||this.isDisabled||this.root?.readOnly||this.root?.setHoverValue(this.valueFromPointer(t))};this.handleKeydown=t=>{t.key==="Enter"&&t.preventDefault()}}connectedCallback(){if(super.connectedCallback(),this.hostLabel=y(this),this.root=d.root(this),!this.root)throw new Error("<skdx-rating-item> must be used inside <skdx-rating>.");this.root.addEventListener(d.event,this.onRootUpdate),this.rootObserver.observe(this.root,{attributeFilter:["value","disabled","read-only","allow-half"]})}disconnectedCallback(){this.root?.removeEventListener(d.event,this.onRootUpdate),this.rootObserver.disconnect(),super.disconnectedCallback()}get allowHalf(){return this.root?.allowHalf??!1}get isChecked(){return this.root?.value===this.value||this.allowHalf&&this.root?.value===this.value-.5}get isDisabled(){return this.disabled||(this.root?.disabled??!1)}get displayValue(){let t=this.root;return t?t.hoverValue??t.value:null}get isHighlighted(){let t=this.displayValue;return t===null?!1:t>=(this.allowHalf?this.value-.5:this.value)}get isHalf(){return this.allowHalf&&this.displayValue===this.value-.5}get label(){if(this.allowHalf)return null;let t=this.root;return this.hostLabel??(t?t.itemLabel(this.value,t.max):null)}get isTabStop(){let t=this.root;return t?this.isChecked||t.value===0&&this.value===1:!1}valueFromPointer(t){if(!this.allowHalf)return this.value;let e=t.currentTarget,i=e.getBoundingClientRect();if(!i.width)return this.value;let a=(t.clientX-i.left)/i.width;return(k(e)==="rtl"?1-a:a)<=.5?this.value-.5:this.value}updated(){p(this,{"data-disabled":this.isDisabled?"":null}),p(this,{"data-state":this.isChecked?"checked":"unchecked","data-highlighted":this.isHighlighted?"":null,"data-half":this.isHalf?"":null})}render(){let t=this.isChecked,e=this.isDisabled;return this.allowHalf?u`
2
2
  <span
3
3
  part="item"
4
4
  role="presentation"
@@ -1,4 +1,4 @@
1
- "use strict";var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var k=(i,r)=>{for(var e in r)d(i,e,{get:r[e],enumerable:!0})},$=(i,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of b(r))!g.call(i,n)&&n!==e&&d(i,n,{get:()=>r[n],enumerable:!(t=f(r,n))||t.enumerable});return i};var I=i=>$(d({},"__esModule",{value:!0}),i),h=(i,r,e,t)=>{for(var n=t>1?void 0:t?f(r,e):r,a=i.length-1,l;a>=0;a--)(l=i[a])&&(n=(t?l(r,e,n):l(n))||n);return t&&n&&d(r,e,n),n};var x={};k(x,{SkdxSelectInput:()=>s});module.exports=I(x);var o=require("lit"),v=require("lit/decorators.js"),m=require("../internal/aria-label.cjs"),u=require("../internal/define.cjs"),y=require("../internal/light-dom-styles.cjs"),p=require("./family.cjs"),E=require("./selection-keys.cjs");var L={open:!1,loading:!1,disabled:!1,readOnly:!1,invalid:!1,required:!1,inputValue:"",contentId:null,activeId:null},s=class extends o.LitElement{constructor(){super(...arguments);this.placeholder="";this.root=null;this.label=null;this.onRootUpdate=()=>this.requestUpdate();this.move=e=>{let t=this.root;if(!t)return null;let n=this.options();if(n.length===0)return null;let a=n.findIndex(c=>c.id===t.activeId),l=Math.min(n.length-1,Math.max(0,a+e));return this.activate(n[l])};this.handleInput=e=>{let t=this.root;t&&(t.setInputValue(e.target.value),t.open||t.setOpen(!0))};this.handleBlur=()=>{this.root?.setOpen(!1)};this.handleKeyDown=e=>{let t=this.root;if(!(!t||t.disabled)&&!(0,E.handleSelectionKey)(t,e,{move:this.move}))if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();let n=e.key==="ArrowDown"?1:-1;t.open?this.move(n):(t.openIntent=n===1?"first":"last",t.setOpen(!0))}else e.key==="Home"||e.key==="End"?this.onEdgeKey(t,e):e.key==="Enter"?this.onEnter(t,e):e.key==="Escape"?this.onEscape(t,e):e.key==="Backspace"&&t.inputValue===""&&t.removeLast()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.label??(this.label=(0,m.takeHostAriaLabel)(this)),this.root=p.SELECT_FAMILY.root(this),this.root?.addEventListener(p.SELECT_FAMILY.event,this.onRootUpdate),(0,y.installLightDomStyles)()}disconnectedCallback(){this.root?.removeEventListener(p.SELECT_FAMILY.event,this.onRootUpdate),this.root?.triggerEl===this.control&&(this.root.triggerEl=null),super.disconnectedCallback()}focus(e){this.control?.focus(e)}get control(){return this.querySelector(":scope > input")}firstUpdated(){let e=this.root,t=this.control;!e||!t||(0,u.whenUpgraded)(e,()=>{e.triggerEl=t})}options(){return this.root?.visibleOptions()??[]}activate(e){return e?(this.root?.setActiveId(e.id),e.scrollIntoView?.({block:"nearest"}),e):null}onEdgeKey(e,t){if(!e.open)return;t.preventDefault();let n=this.options();this.activate(t.key==="Home"?n[0]:n[n.length-1])}onEnter(e,t){let n=e.activeId;if(n===null)return;let l=this.options().find(c=>c.id===n)?.getAttribute("data-value");l!=null&&(t.preventDefault(),e.selectItem(l,"keyboard"),e.closesOnSelect&&e.setOpen(!1))}onEscape(e,t){e.open&&!e.contentEl&&(t.preventDefault(),e.setOpen(!1))}render(){let e=this.root??L;return o.html`
1
+ "use strict";var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var k=(i,r)=>{for(var e in r)d(i,e,{get:r[e],enumerable:!0})},$=(i,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of b(r))!g.call(i,n)&&n!==e&&d(i,n,{get:()=>r[n],enumerable:!(t=f(r,n))||t.enumerable});return i};var I=i=>$(d({},"__esModule",{value:!0}),i),h=(i,r,e,t)=>{for(var n=t>1?void 0:t?f(r,e):r,a=i.length-1,l;a>=0;a--)(l=i[a])&&(n=(t?l(r,e,n):l(n))||n);return t&&n&&d(r,e,n),n};var x={};k(x,{SkdxSelectInput:()=>s});module.exports=I(x);var o=require("lit"),v=require("lit/decorators.js"),m=require("../internal/aria-label.cjs"),c=require("../internal/define.cjs"),y=require("../internal/light-dom-styles.cjs"),p=require("./family.cjs"),E=require("./selection-keys.cjs");var L={open:!1,loading:!1,disabled:!1,readOnly:!1,invalid:!1,required:!1,inputValue:"",contentId:null,activeId:null},s=class extends o.LitElement{constructor(){super(...arguments);this.placeholder="";this.root=null;this.label=null;this.onRootUpdate=()=>this.requestUpdate();this.move=e=>{let t=this.root;if(!t)return null;let n=this.options();if(n.length===0)return null;let a=n.findIndex(u=>u.id===t.activeId),l=Math.min(n.length-1,Math.max(0,a+e));return this.activate(n[l])};this.handleInput=e=>{let t=this.root;t&&(t.setInputValue(e.target.value),t.open||t.setOpen(!0))};this.handleClick=()=>{let e=this.root;!e||e.readOnly||e.open||e.setOpen(!0)};this.handleBlur=()=>{this.root?.setOpen(!1)};this.handleKeyDown=e=>{let t=this.root;if(!(!t||t.disabled)&&!(0,E.handleSelectionKey)(t,e,{move:this.move}))if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();let n=e.key==="ArrowDown"?1:-1;t.open?this.move(n):(t.openIntent=n===1?"first":"last",t.setOpen(!0))}else e.key==="Home"||e.key==="End"?this.onEdgeKey(t,e):e.key==="Enter"?this.onEnter(t,e):e.key==="Escape"?this.onEscape(t,e):e.key==="Backspace"&&t.inputValue===""&&t.removeLast()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.label??(this.label=(0,m.takeHostAriaLabel)(this)),this.root=p.SELECT_FAMILY.root(this),this.root?.addEventListener(p.SELECT_FAMILY.event,this.onRootUpdate),(0,y.installLightDomStyles)()}disconnectedCallback(){this.root?.removeEventListener(p.SELECT_FAMILY.event,this.onRootUpdate),this.root?.triggerEl===this.control&&(this.root.triggerEl=null),super.disconnectedCallback()}focus(e){this.control?.focus(e)}get control(){return this.querySelector(":scope > input")}firstUpdated(){let e=this.root,t=this.control;!e||!t||(0,c.whenUpgraded)(e,()=>{e.triggerEl=t})}options(){return this.root?.visibleOptions()??[]}activate(e){return e?(this.root?.setActiveId(e.id),e.scrollIntoView?.({block:"nearest"}),e):null}onEdgeKey(e,t){if(!e.open)return;t.preventDefault();let n=this.options();this.activate(t.key==="Home"?n[0]:n[n.length-1])}onEnter(e,t){let n=e.activeId;if(n===null)return;let l=this.options().find(u=>u.id===n)?.getAttribute("data-value");l!=null&&(t.preventDefault(),e.selectItem(l,"keyboard"),e.closesOnSelect&&e.setOpen(!1))}onEscape(e,t){e.open&&!e.contentEl&&(t.preventDefault(),e.setOpen(!1))}render(){let e=this.root??L;return o.html`
2
2
  <input
3
3
  part="input"
4
4
  type="text"
@@ -24,7 +24,8 @@
24
24
  data-invalid=${e.invalid?"":o.nothing}
25
25
  data-loading=${e.loading?"":o.nothing}
26
26
  @input=${this.handleInput}
27
+ @click=${this.handleClick}
27
28
  @blur=${this.handleBlur}
28
29
  @keydown=${this.handleKeyDown}
29
30
  />
30
- `}};h([(0,v.property)({type:String})],s.prototype,"placeholder",2),s=h([(0,u.customElement)("skdx-select-input","select","input")],s);0&&(module.exports={SkdxSelectInput});
31
+ `}};h([(0,v.property)({type:String})],s.prototype,"placeholder",2),s=h([(0,c.customElement)("skdx-select-input","select","input")],s);0&&(module.exports={SkdxSelectInput});
@@ -39,6 +39,7 @@ export declare class SkdxSelectInput extends LitElement {
39
39
  private activate;
40
40
  private readonly move;
41
41
  private readonly handleInput;
42
+ private readonly handleClick;
42
43
  private readonly handleBlur;
43
44
  private readonly handleKeyDown;
44
45
  private onEdgeKey;
@@ -39,6 +39,7 @@ export declare class SkdxSelectInput extends LitElement {
39
39
  private activate;
40
40
  private readonly move;
41
41
  private readonly handleInput;
42
+ private readonly handleClick;
42
43
  private readonly handleBlur;
43
44
  private readonly handleKeyDown;
44
45
  private onEdgeKey;
@@ -1,4 +1,4 @@
1
- var c=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var p=(s,l,e,t)=>{for(var n=t>1?void 0:t?h(l,e):l,i=s.length-1,r;i>=0;i--)(r=s[i])&&(n=(t?r(l,e,n):r(n))||n);return t&&n&&c(l,e,n),n};import{html as f,LitElement as v,nothing as o}from"lit";import{property as m}from"lit/decorators.js";import{takeHostAriaLabel as y}from"../internal/aria-label.js";import{customElement as E,whenUpgraded as b}from"../internal/define.js";import{installLightDomStyles as g}from"../internal/light-dom-styles.js";import{SELECT_FAMILY as u}from"./family.js";import{handleSelectionKey as k}from"./selection-keys.js";var $={open:!1,loading:!1,disabled:!1,readOnly:!1,invalid:!1,required:!1,inputValue:"",contentId:null,activeId:null},a=class extends v{constructor(){super(...arguments);this.placeholder="";this.root=null;this.label=null;this.onRootUpdate=()=>this.requestUpdate();this.move=e=>{let t=this.root;if(!t)return null;let n=this.options();if(n.length===0)return null;let i=n.findIndex(d=>d.id===t.activeId),r=Math.min(n.length-1,Math.max(0,i+e));return this.activate(n[r])};this.handleInput=e=>{let t=this.root;t&&(t.setInputValue(e.target.value),t.open||t.setOpen(!0))};this.handleBlur=()=>{this.root?.setOpen(!1)};this.handleKeyDown=e=>{let t=this.root;if(!(!t||t.disabled)&&!k(t,e,{move:this.move}))if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();let n=e.key==="ArrowDown"?1:-1;t.open?this.move(n):(t.openIntent=n===1?"first":"last",t.setOpen(!0))}else e.key==="Home"||e.key==="End"?this.onEdgeKey(t,e):e.key==="Enter"?this.onEnter(t,e):e.key==="Escape"?this.onEscape(t,e):e.key==="Backspace"&&t.inputValue===""&&t.removeLast()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.label??(this.label=y(this)),this.root=u.root(this),this.root?.addEventListener(u.event,this.onRootUpdate),g()}disconnectedCallback(){this.root?.removeEventListener(u.event,this.onRootUpdate),this.root?.triggerEl===this.control&&(this.root.triggerEl=null),super.disconnectedCallback()}focus(e){this.control?.focus(e)}get control(){return this.querySelector(":scope > input")}firstUpdated(){let e=this.root,t=this.control;!e||!t||b(e,()=>{e.triggerEl=t})}options(){return this.root?.visibleOptions()??[]}activate(e){return e?(this.root?.setActiveId(e.id),e.scrollIntoView?.({block:"nearest"}),e):null}onEdgeKey(e,t){if(!e.open)return;t.preventDefault();let n=this.options();this.activate(t.key==="Home"?n[0]:n[n.length-1])}onEnter(e,t){let n=e.activeId;if(n===null)return;let r=this.options().find(d=>d.id===n)?.getAttribute("data-value");r!=null&&(t.preventDefault(),e.selectItem(r,"keyboard"),e.closesOnSelect&&e.setOpen(!1))}onEscape(e,t){e.open&&!e.contentEl&&(t.preventDefault(),e.setOpen(!1))}render(){let e=this.root??$;return f`
1
+ var u=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var p=(s,l,e,t)=>{for(var n=t>1?void 0:t?h(l,e):l,i=s.length-1,r;i>=0;i--)(r=s[i])&&(n=(t?r(l,e,n):r(n))||n);return t&&n&&u(l,e,n),n};import{html as f,LitElement as v,nothing as o}from"lit";import{property as m}from"lit/decorators.js";import{takeHostAriaLabel as y}from"../internal/aria-label.js";import{customElement as E,whenUpgraded as b}from"../internal/define.js";import{installLightDomStyles as g}from"../internal/light-dom-styles.js";import{SELECT_FAMILY as c}from"./family.js";import{handleSelectionKey as k}from"./selection-keys.js";var $={open:!1,loading:!1,disabled:!1,readOnly:!1,invalid:!1,required:!1,inputValue:"",contentId:null,activeId:null},a=class extends v{constructor(){super(...arguments);this.placeholder="";this.root=null;this.label=null;this.onRootUpdate=()=>this.requestUpdate();this.move=e=>{let t=this.root;if(!t)return null;let n=this.options();if(n.length===0)return null;let i=n.findIndex(d=>d.id===t.activeId),r=Math.min(n.length-1,Math.max(0,i+e));return this.activate(n[r])};this.handleInput=e=>{let t=this.root;t&&(t.setInputValue(e.target.value),t.open||t.setOpen(!0))};this.handleClick=()=>{let e=this.root;!e||e.readOnly||e.open||e.setOpen(!0)};this.handleBlur=()=>{this.root?.setOpen(!1)};this.handleKeyDown=e=>{let t=this.root;if(!(!t||t.disabled)&&!k(t,e,{move:this.move}))if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();let n=e.key==="ArrowDown"?1:-1;t.open?this.move(n):(t.openIntent=n===1?"first":"last",t.setOpen(!0))}else e.key==="Home"||e.key==="End"?this.onEdgeKey(t,e):e.key==="Enter"?this.onEnter(t,e):e.key==="Escape"?this.onEscape(t,e):e.key==="Backspace"&&t.inputValue===""&&t.removeLast()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.label??(this.label=y(this)),this.root=c.root(this),this.root?.addEventListener(c.event,this.onRootUpdate),g()}disconnectedCallback(){this.root?.removeEventListener(c.event,this.onRootUpdate),this.root?.triggerEl===this.control&&(this.root.triggerEl=null),super.disconnectedCallback()}focus(e){this.control?.focus(e)}get control(){return this.querySelector(":scope > input")}firstUpdated(){let e=this.root,t=this.control;!e||!t||b(e,()=>{e.triggerEl=t})}options(){return this.root?.visibleOptions()??[]}activate(e){return e?(this.root?.setActiveId(e.id),e.scrollIntoView?.({block:"nearest"}),e):null}onEdgeKey(e,t){if(!e.open)return;t.preventDefault();let n=this.options();this.activate(t.key==="Home"?n[0]:n[n.length-1])}onEnter(e,t){let n=e.activeId;if(n===null)return;let r=this.options().find(d=>d.id===n)?.getAttribute("data-value");r!=null&&(t.preventDefault(),e.selectItem(r,"keyboard"),e.closesOnSelect&&e.setOpen(!1))}onEscape(e,t){e.open&&!e.contentEl&&(t.preventDefault(),e.setOpen(!1))}render(){let e=this.root??$;return f`
2
2
  <input
3
3
  part="input"
4
4
  type="text"
@@ -24,6 +24,7 @@ var c=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var p=(s,l,e,t
24
24
  data-invalid=${e.invalid?"":o}
25
25
  data-loading=${e.loading?"":o}
26
26
  @input=${this.handleInput}
27
+ @click=${this.handleClick}
27
28
  @blur=${this.handleBlur}
28
29
  @keydown=${this.handleKeyDown}
29
30
  />
@@ -1,5 +1,5 @@
1
- "use strict";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var y=(i,e)=>{for(var r in e)l(i,r,{get:e[r],enumerable:!0})},I=(i,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of v(e))!C.call(i,t)&&t!==r&&l(i,t,{get:()=>e[t],enumerable:!(n=m(e,t))||n.enumerable});return i};var b=i=>I(l({},"__esModule",{value:!0}),i),c=(i,e,r,n)=>{for(var t=n>1?void 0:n?m(e,r):e,a=i.length-1,h;a>=0;a--)(h=i[a])&&(t=(n?h(e,r,t):h(t))||t);return n&&t&&l(e,r,t),t};var E={};y(E,{SkdxTreeGroup:()=>o});module.exports=b(E);var s=require("lit"),p=require("lit/decorators.js"),f=require("../internal/define.cjs"),u=require("../internal/styles.cjs"),d=require("./family.cjs");var o=class extends s.LitElement{constructor(){super(...arguments);this.forceMount=!1;this.parentItem=null;this.cachedChildren=null;this.onParentUpdate=()=>this.sync()}connectedCallback(){super.connectedCallback(),this.parentItem=d.TREE_ITEM_FAMILY.root(this),this.parentItem?.addEventListener(d.TREE_ITEM_FAMILY.event,this.onParentUpdate),this.sync()}disconnectedCallback(){this.parentItem?.removeEventListener(d.TREE_ITEM_FAMILY.event,this.onParentUpdate),super.disconnectedCallback()}sync(){let r=this.forceMount||(this.parentItem?.expanded??!1);if(r?(this.setAttribute("role","group"),this.hidden=!1):(this.removeAttribute("role"),this.hidden=!0),r&&this.cachedChildren){let n=this.cachedChildren;this.cachedChildren=null;for(let t of n)this.appendChild(t)}else if(!r&&!this.cachedChildren&&this.children.length>0){this.cachedChildren=Array.from(this.children);for(let n of this.cachedChildren)this.removeChild(n)}}render(){return s.html`<slot></slot>`}};o.styles=[u.hiddenHostStyles,s.css`
1
+ "use strict";var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var y=(r,t)=>{for(var i in t)d(r,i,{get:t[i],enumerable:!0})},b=(r,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of v(t))!C.call(r,e)&&e!==i&&d(r,e,{get:()=>t[e],enumerable:!(n=p(t,e))||n.enumerable});return r};var I=r=>b(d({},"__esModule",{value:!0}),r),c=(r,t,i,n)=>{for(var e=n>1?void 0:n?p(t,i):t,l=r.length-1,h;l>=0;l--)(h=r[l])&&(e=(n?h(t,i,e):h(e))||e);return n&&e&&d(t,i,e),e};var E={};y(E,{SkdxTreeGroup:()=>s});module.exports=I(E);var o=require("lit"),m=require("lit/decorators.js"),f=require("../internal/define.cjs"),u=require("../internal/styles.cjs"),a=require("./family.cjs");var s=class extends o.LitElement{constructor(){super(...arguments);this.forceMount=!1;this.parentItem=null;this.cachedChildren=null;this.onParentUpdate=()=>this.sync()}connectedCallback(){super.connectedCallback(),this.parentItem=a.TREE_ITEM_FAMILY.root(this),this.parentItem?.addEventListener(a.TREE_ITEM_FAMILY.event,this.onParentUpdate),this.sync()}disconnectedCallback(){this.parentItem?.removeEventListener(a.TREE_ITEM_FAMILY.event,this.onParentUpdate),super.disconnectedCallback()}sync(){let i=this.parentItem?.expanded??!1;this.setAttribute("data-state",i?"expanded":"collapsed");let n=this.forceMount||i;if(n?(this.setAttribute("role","group"),this.hidden=!1):(this.removeAttribute("role"),this.hidden=!0),n&&this.cachedChildren){let e=this.cachedChildren;this.cachedChildren=null;for(let l of e)this.appendChild(l)}else if(!n&&!this.cachedChildren&&this.children.length>0){this.cachedChildren=Array.from(this.children);for(let e of this.cachedChildren)this.removeChild(e)}}render(){return o.html`<slot></slot>`}};s.styles=[u.hiddenHostStyles,o.css`
2
2
  :host {
3
3
  display: block;
4
4
  }
5
- `],c([(0,p.property)({type:Boolean,attribute:"force-mount"})],o.prototype,"forceMount",2),o=c([(0,f.customElement)("skdx-tree-group","tree","group")],o);0&&(module.exports={SkdxTreeGroup});
5
+ `],c([(0,m.property)({type:Boolean,attribute:"force-mount"})],s.prototype,"forceMount",2),s=c([(0,f.customElement)("skdx-tree-group","tree","group")],s);0&&(module.exports={SkdxTreeGroup});
@@ -1,4 +1,4 @@
1
- var h=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var d=(o,n,r,t)=>{for(var e=t>1?void 0:t?c(n,r):n,s=o.length-1,l;s>=0;s--)(l=o[s])&&(e=(t?l(n,r,e):l(e))||e);return t&&e&&h(n,r,e),e};import{css as m,html as p,LitElement as f}from"lit";import{property as u}from"lit/decorators.js";import{customElement as v}from"../internal/define.js";import{hiddenHostStyles as C}from"../internal/styles.js";import{TREE_ITEM_FAMILY as a}from"./family.js";var i=class extends f{constructor(){super(...arguments);this.forceMount=!1;this.parentItem=null;this.cachedChildren=null;this.onParentUpdate=()=>this.sync()}connectedCallback(){super.connectedCallback(),this.parentItem=a.root(this),this.parentItem?.addEventListener(a.event,this.onParentUpdate),this.sync()}disconnectedCallback(){this.parentItem?.removeEventListener(a.event,this.onParentUpdate),super.disconnectedCallback()}sync(){let r=this.forceMount||(this.parentItem?.expanded??!1);if(r?(this.setAttribute("role","group"),this.hidden=!1):(this.removeAttribute("role"),this.hidden=!0),r&&this.cachedChildren){let t=this.cachedChildren;this.cachedChildren=null;for(let e of t)this.appendChild(e)}else if(!r&&!this.cachedChildren&&this.children.length>0){this.cachedChildren=Array.from(this.children);for(let t of this.cachedChildren)this.removeChild(t)}}render(){return p`<slot></slot>`}};i.styles=[C,m`
1
+ var h=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var d=(o,n,r,t)=>{for(var e=t>1?void 0:t?c(n,r):n,s=o.length-1,l;s>=0;s--)(l=o[s])&&(e=(t?l(n,r,e):l(e))||e);return t&&e&&h(n,r,e),e};import{css as p,html as m,LitElement as f}from"lit";import{property as u}from"lit/decorators.js";import{customElement as v}from"../internal/define.js";import{hiddenHostStyles as C}from"../internal/styles.js";import{TREE_ITEM_FAMILY as a}from"./family.js";var i=class extends f{constructor(){super(...arguments);this.forceMount=!1;this.parentItem=null;this.cachedChildren=null;this.onParentUpdate=()=>this.sync()}connectedCallback(){super.connectedCallback(),this.parentItem=a.root(this),this.parentItem?.addEventListener(a.event,this.onParentUpdate),this.sync()}disconnectedCallback(){this.parentItem?.removeEventListener(a.event,this.onParentUpdate),super.disconnectedCallback()}sync(){let r=this.parentItem?.expanded??!1;this.setAttribute("data-state",r?"expanded":"collapsed");let t=this.forceMount||r;if(t?(this.setAttribute("role","group"),this.hidden=!1):(this.removeAttribute("role"),this.hidden=!0),t&&this.cachedChildren){let e=this.cachedChildren;this.cachedChildren=null;for(let s of e)this.appendChild(s)}else if(!t&&!this.cachedChildren&&this.children.length>0){this.cachedChildren=Array.from(this.children);for(let e of this.cachedChildren)this.removeChild(e)}}render(){return m`<slot></slot>`}};i.styles=[C,p`
2
2
  :host {
3
3
  display: block;
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skdx/web-components",
3
- "version": "0.37.0",
3
+ "version": "0.39.0",
4
4
  "description": "Standards-based custom elements for the SkandaDX design system — no React (or any framework) required",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -2871,7 +2871,7 @@
2871
2871
  "tsup": "^8.5.1",
2872
2872
  "typescript": "^6.0.3",
2873
2873
  "vitest": "^4.1.10",
2874
- "@skdx/shared": "0.37.0"
2874
+ "@skdx/shared": "0.39.0"
2875
2875
  },
2876
2876
  "scripts": {
2877
2877
  "lint": "eslint . --cache --cache-location node_modules/.cache/eslint/",