@skdx/web-components 0.35.0 → 0.37.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.
- package/custom-elements.json +37477 -37404
- package/dist/dialog/DialogContent.cjs +1 -1
- package/dist/dialog/DialogContent.d.cts +1 -0
- package/dist/dialog/DialogContent.d.ts +1 -0
- package/dist/dialog/DialogContent.js +1 -1
- package/dist/internal/date-value.cjs +1 -1
- package/dist/internal/date-value.js +1 -1
- package/dist/internal/label-activation.cjs +1 -0
- package/dist/internal/label-activation.d.cts +1 -0
- package/dist/internal/label-activation.d.ts +1 -0
- package/dist/internal/label-activation.js +1 -0
- package/dist/internal/tabbable.cjs +1 -1
- package/dist/internal/tabbable.d.cts +9 -0
- package/dist/internal/tabbable.d.ts +9 -0
- package/dist/internal/tabbable.js +1 -1
- package/dist/internal/toggle-control.cjs +3 -3
- package/dist/internal/toggle-control.d.cts +3 -0
- package/dist/internal/toggle-control.d.ts +3 -0
- package/dist/internal/toggle-control.js +10 -10
- package/dist/label/Label.cjs +1 -1
- package/dist/label/Label.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var
|
|
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});
|
|
@@ -52,6 +52,7 @@ export declare class SkdxDialogContent extends LitElement {
|
|
|
52
52
|
private syncAutoFocus;
|
|
53
53
|
private readonly handleCancel;
|
|
54
54
|
private readonly handleClose;
|
|
55
|
+
private readonly handleKeydown;
|
|
55
56
|
private readonly handleBackdropPointerDown;
|
|
56
57
|
private readonly handleOutsidePointerDown;
|
|
57
58
|
private readonly handleOutsideFocus;
|
|
@@ -52,6 +52,7 @@ export declare class SkdxDialogContent extends LitElement {
|
|
|
52
52
|
private syncAutoFocus;
|
|
53
53
|
private readonly handleCancel;
|
|
54
54
|
private readonly handleClose;
|
|
55
|
+
private readonly handleKeydown;
|
|
55
56
|
private readonly handleBackdropPointerDown;
|
|
56
57
|
private readonly handleOutsidePointerDown;
|
|
57
58
|
private readonly handleOutsideFocus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var y=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var a=(n,
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var N=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},h=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of p(t))!y.call(e,a)&&a!==n&&s(e,a,{get:()=>t[a],enumerable:!(r=g(t,a))||r.enumerable});return e};var I=e=>h(s({},"__esModule",{value:!0}),e);var L={};N(L,{resetMalformedDateWarning:()=>Y,toCalendarString:()=>$,toCalendarValue:()=>S,toDate:()=>l,toISODateValue:()=>o,toTimeValue:()=>V});module.exports=I(L);var d=require("./date-segments.cjs"),x=/^(\d{4,})-(\d{2})$/,M=/^(\d{4,}-\d{2}-\d{2})/,b=/^\d{4,}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:?\d{2})$/,D=!1;function Y(){D=!1}function c(e,t){D||(D=!0,console.warn(`[skdx] ${t?`\`${t}\``:"A date property"} was given ${JSON.stringify(e)}, which is not an ISO-8601 date. Expected \`YYYY-MM-DD\`, \`YYYY-MM-DDTHH:mm[:ss]\`, an instant with \`Z\` or a \`\xB1HH:mm\` offset, or a bare \`YYYY-MM\` for a month. The value is ignored \u2014 the property behaves as if it had not been supplied \u2014 rather than being coerced to today, to the epoch, or to an \`Invalid Date\` that would then poison every comparison after it.`))}function l(e,t){if(e==null)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e!="string")return null;let n=e.trim();if(n==="")return null;let r=(0,d.parseDateFormValue)(n);if(r!==null){let i=M.exec(n)?.[1];return i!==void 0&&o(r)!==i?(c(n,t),null):r}if(b.test(n)){let i=new Date(n);if(!Number.isNaN(i.getTime()))return i}let a=T(n);return a||(c(n,t),null)}function T(e){let t=x.exec(e);if(!t)return null;let n=Number(t[2])-1;if(n<0||n>11)return null;let r=Number(t[1]),a=new Date(r,n,1);return r<100&&a.setFullYear(r),Number.isNaN(a.getTime())?null:a}function o(e,t="day"){return(0,d.dateToFormValue)(e,t)}function S(e,t,n){if(e===void 0)return;if(e===null)return t==="multiple"?[]:null;if(typeof e=="string"){let i=A(e,n);return f(i,t)}if(Array.isArray(e)){let i=e.map(u=>l(u,n)).filter(u=>u!==null);return f(i,t)}if(e instanceof Date)return f(l(e,n),t);let r=e,a=l(r.start,n);return a===null?t==="multiple"?[]:null:{start:a,end:l(r.end,n)}}function f(e,t){return t!=="multiple"?e:e===null?[]:Array.isArray(e)?e:e instanceof Date?[e]:[]}function A(e,t){let n=e.trim();if(n==="")return null;if(n.includes("/")){let[r="",a=""]=n.split("/"),i=l(r,t);return i===null?null:{start:i,end:a===""?null:l(a,t)}}return n.includes(",")?n.split(",").map(r=>l(r,t)).filter(r=>r!==null):l(n,t)}function $(e){return e==null?null:Array.isArray(e)?e.length===0?null:e.map(t=>o(t)).join(","):e instanceof Date?o(e):`${o(e.start)}/${e.end===null?"":o(e.end)}`}var w=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function V(e,t){if(e==null)return null;if(e instanceof Date){if(Number.isNaN(e.getTime()))return null;let a=m=>String(m).padStart(2,"0"),i=e.getSeconds(),u=`${a(e.getHours())}:${a(e.getMinutes())}`;return i===0?u:`${u}:${a(i)}`}if(typeof e!="string")return null;let n=e.trim();if(n==="")return null;let r=w.exec(n);return!r||Number(r[1])>23||Number(r[2])>59||r[3]!==void 0&&Number(r[3])>59?(c(n,t),null):n}0&&(module.exports={resetMalformedDateWarning,toCalendarString,toCalendarValue,toDate,toISODateValue,toTimeValue});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dateToFormValue as c,parseDateFormValue as m}from"./date-segments.js";var g=/^(\d{4,})-(\d{2})$/,p=/^(\d{4,}-\d{2}-\d{2})/,d=!1;function M(){
|
|
1
|
+
import{dateToFormValue as c,parseDateFormValue as m}from"./date-segments.js";var g=/^(\d{4,})-(\d{2})$/,p=/^(\d{4,}-\d{2}-\d{2})/,y=/^\d{4,}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:?\d{2})$/,s=!1;function M(){s=!1}function f(e,n){s||(s=!0,console.warn(`[skdx] ${n?`\`${n}\``:"A date property"} was given ${JSON.stringify(e)}, which is not an ISO-8601 date. Expected \`YYYY-MM-DD\`, \`YYYY-MM-DDTHH:mm[:ss]\`, an instant with \`Z\` or a \`\xB1HH:mm\` offset, or a bare \`YYYY-MM\` for a month. The value is ignored \u2014 the property behaves as if it had not been supplied \u2014 rather than being coerced to today, to the epoch, or to an \`Invalid Date\` that would then poison every comparison after it.`))}function l(e,n){if(e==null)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e!="string")return null;let t=e.trim();if(t==="")return null;let r=m(t);if(r!==null){let i=p.exec(t)?.[1];return i!==void 0&&o(r)!==i?(f(t,n),null):r}if(y.test(t)){let i=new Date(t);if(!Number.isNaN(i.getTime()))return i}let a=N(t);return a||(f(t,n),null)}function N(e){let n=g.exec(e);if(!n)return null;let t=Number(n[2])-1;if(t<0||t>11)return null;let r=Number(n[1]),a=new Date(r,t,1);return r<100&&a.setFullYear(r),Number.isNaN(a.getTime())?null:a}function o(e,n="day"){return c(e,n)}function b(e,n,t){if(e===void 0)return;if(e===null)return n==="multiple"?[]:null;if(typeof e=="string"){let i=h(e,t);return d(i,n)}if(Array.isArray(e)){let i=e.map(u=>l(u,t)).filter(u=>u!==null);return d(i,n)}if(e instanceof Date)return d(l(e,t),n);let r=e,a=l(r.start,t);return a===null?n==="multiple"?[]:null:{start:a,end:l(r.end,t)}}function d(e,n){return n!=="multiple"?e:e===null?[]:Array.isArray(e)?e:e instanceof Date?[e]:[]}function h(e,n){let t=e.trim();if(t==="")return null;if(t.includes("/")){let[r="",a=""]=t.split("/"),i=l(r,n);return i===null?null:{start:i,end:a===""?null:l(a,n)}}return t.includes(",")?t.split(",").map(r=>l(r,n)).filter(r=>r!==null):l(t,n)}function Y(e){return e==null?null:Array.isArray(e)?e.length===0?null:e.map(n=>o(n)).join(","):e instanceof Date?o(e):`${o(e.start)}/${e.end===null?"":o(e.end)}`}var I=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function T(e,n){if(e==null)return null;if(e instanceof Date){if(Number.isNaN(e.getTime()))return null;let a=D=>String(D).padStart(2,"0"),i=e.getSeconds(),u=`${a(e.getHours())}:${a(e.getMinutes())}`;return i===0?u:`${u}:${a(i)}`}if(typeof e!="string")return null;let t=e.trim();if(t==="")return null;let r=I.exec(t);return!r||Number(r[1])>23||Number(r[2])>59||r[3]!==void 0&&Number(r[3])>59?(f(t,n),null):t}export{M as resetMalformedDateWarning,Y as toCalendarString,b as toCalendarValue,l as toDate,o as toISODateValue,T as toTimeValue};
|
|
@@ -0,0 +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});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function activateLabelledButton(label: HTMLElement, event: Event): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function activateLabelledButton(label: HTMLElement, event: Event): void;
|
|
@@ -0,0 +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 +1 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},h=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of c(t))!f.call(e,o)&&o!==n&&i(e,o,{get:()=>t[o],enumerable:!(a=b(t,o))||a.enumerable});return e};var m=e=>h(i({},"__esModule",{value:!0}),e);var T={};E(T,{TABBABLE_SELECTOR:()=>l,tabbablesWithin:()=>r,wrapTabWithin:()=>p});module.exports=m(T);var l=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function r(e){return Array.from(e.querySelectorAll("*")).filter(t=>t.matches(l)||t.shadowRoot?.delegatesFocus===!0)}function p(e,t){if(t.key!=="Tab"||t.defaultPrevented)return;let n=r(e);if(n.length===0){t.preventDefault();return}let a=n[0],o=n[n.length-1],s=document.activeElement,d=s===null||s===e||!e.contains(s),u=t.shiftKey?s===a:s===o;!d&&!u||(t.preventDefault(),(t.shiftKey?o:a).focus())}0&&(module.exports={TABBABLE_SELECTOR,tabbablesWithin,wrapTabWithin});
|
|
@@ -6,3 +6,12 @@ export declare const TABBABLE_SELECTOR: string;
|
|
|
6
6
|
* small subtrees only in the DOM while open.
|
|
7
7
|
*/
|
|
8
8
|
export declare function tabbablesWithin(container: Element): HTMLElement[];
|
|
9
|
+
/**
|
|
10
|
+
* Keeps Tab cycling inside `container` while it is the modal surface: Tab from the last tabbable
|
|
11
|
+
* lands on the first and Shift+Tab from the first on the last. A native `showModal()` leaves the
|
|
12
|
+
* loop through the browser chrome instead, which assistive technology reads as focus escaping.
|
|
13
|
+
*
|
|
14
|
+
* @param container the modal surface, typically the open `<dialog>`
|
|
15
|
+
* @param event the keydown to act on; anything but an unhandled Tab is ignored
|
|
16
|
+
*/
|
|
17
|
+
export declare function wrapTabWithin(container: Element, event: KeyboardEvent): void;
|
|
@@ -6,3 +6,12 @@ export declare const TABBABLE_SELECTOR: string;
|
|
|
6
6
|
* small subtrees only in the DOM while open.
|
|
7
7
|
*/
|
|
8
8
|
export declare function tabbablesWithin(container: Element): HTMLElement[];
|
|
9
|
+
/**
|
|
10
|
+
* Keeps Tab cycling inside `container` while it is the modal surface: Tab from the last tabbable
|
|
11
|
+
* lands on the first and Shift+Tab from the first on the last. A native `showModal()` leaves the
|
|
12
|
+
* loop through the browser chrome instead, which assistive technology reads as focus escaping.
|
|
13
|
+
*
|
|
14
|
+
* @param container the modal surface, typically the open `<dialog>`
|
|
15
|
+
* @param event the keydown to act on; anything but an unhandled Tab is ignored
|
|
16
|
+
*/
|
|
17
|
+
export declare function wrapTabWithin(container: Element, event: KeyboardEvent): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var r=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function d(e){return Array.from(e.querySelectorAll("*")).filter(t=>t.matches(r)||t.shadowRoot?.delegatesFocus===!0)}function u(e,t){if(t.key!=="Tab"||t.defaultPrevented)return;let o=d(e);if(o.length===0){t.preventDefault();return}let a=o[0],s=o[o.length-1],n=document.activeElement,i=n===null||n===e||!e.contains(n),l=t.shiftKey?n===a:n===s;!i&&!l||(t.preventDefault(),(t.shiftKey?s:a).focus())}export{r as TABBABLE_SELECTOR,d as tabbablesWithin,u as wrapTabWithin};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var O=(l,e)=>{for(var t in e)c(l,t,{get:e[t],enumerable:!0})},w=(l,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $(e))!L.call(l,i)&&i!==t&&c(l,i,{get:()=>e[i],enumerable:!(n=u(e,i))||n.enumerable});return l};var g=l=>w(c({},"__esModule",{value:!0}),l),d=(l,e,t,n)=>{for(var i=n>1?void 0:n?u(e,t):e,h=l.length-1,p;h>=0;h--)(p=l[h])&&(i=(n?p(e,t,i):p(i))||i);return n&&i&&c(e,t,i),i};var E={};O(E,{SkdxToggleControlBase:()=>r});module.exports=g(E);var a=require("lit"),o=require("lit/decorators.js"),y=require("./aria-label.cjs"),b=require("./associated-label.cjs"),m=require("./events.cjs"),v=require("./field-core.cjs"),f=require("./form-associated.cjs"),R=require("./part.cjs"),s=require("./styles.cjs");var r=class extends(0,f.FormAssociated)(a.LitElement){constructor(){super(...arguments);this.disabled=!1;this.required=!1;this.value="on";this.invalid=!1;this.hostLabel=null;this.labelText=null;this.readLabel=()=>{this.hostLabel===null&&(this.labelText=(0,b.findAssociatedLabel)(this)?.textContent?.trim()||null)};this.handleClick=()=>{this.isReadOnly||this.toggle()};this.onKeydown=t=>this.handleKeydown(t);this.controlPart="control";this.controlRole="checkbox";this.onSlotChange=()=>{}}get accessibleName(){return this.hostLabel??this.labelledByText??this.labelText}get labelledByText(){if(!this.labelledBy)return null;let t=this.getRootNode();return this.labelledBy.split(/\s+/).map(i=>t.getElementById(i)?.textContent?.trim()??"").filter(Boolean).join(" ")||null}get isReadOnly(){return!1}get ariaCheckedValue(){return"false"}get controlState(){return"unchecked"}toggle(){}syncFormState(){}afterUpdated(t){}connectedCallback(){super.connectedCallback(),this.hostLabel=(0,y.takeHostAriaLabel)(this),this.setAttribute(v.FIELD_CONTROL_ATTRIBUTE,""),queueMicrotask(this.readLabel)}updated(t){(0,R.reflectHostState)(this,{"data-state":this.controlState,"data-disabled":this.disabled?"":null,"data-readonly":this.isReadOnly?"":null,"data-invalid":this.invalid?"":null}),this.afterUpdated(t)}emitCheckedChange(t){(0,m.emit)(this,"checked-change",t)}handleKeydown(t){}render(){return a.html`
|
|
2
2
|
<button
|
|
3
3
|
part=${this.controlPart}
|
|
4
4
|
type="button"
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
>
|
|
19
19
|
<slot @slotchange=${this.onSlotChange}></slot>
|
|
20
20
|
</button>
|
|
21
|
-
`}};
|
|
21
|
+
`}};r.shadowRootOptions=s.delegatesFocusShadowRootOptions,r.styles=[s.resetNativeControl,s.hiddenHostStyles,a.css`
|
|
22
22
|
:host {
|
|
23
23
|
display: inline-block;
|
|
24
24
|
}
|
|
25
|
-
`,
|
|
25
|
+
`,s.controlBoxOnHost],d([(0,o.property)({type:Boolean,reflect:!0})],r.prototype,"disabled",2),d([(0,o.property)({type:Boolean,reflect:!0})],r.prototype,"required",2),d([(0,o.property)({type:String,reflect:!0})],r.prototype,"name",2),d([(0,o.property)({type:String,reflect:!0})],r.prototype,"value",2),d([(0,o.property)({type:Boolean,reflect:!0})],r.prototype,"invalid",2),d([(0,o.state)()],r.prototype,"hostLabel",2),d([(0,o.state)()],r.prototype,"labelText",2),d([(0,o.property)({attribute:"aria-labelledby"})],r.prototype,"labelledBy",2);0&&(module.exports={SkdxToggleControlBase});
|
|
@@ -28,8 +28,11 @@ export declare class SkdxToggleControlBase extends SkdxToggleControlBase_base {
|
|
|
28
28
|
/** Accessible name for the inner `<button>`, moved off this host — see `takeHostAriaLabel`. */
|
|
29
29
|
protected hostLabel: string | null;
|
|
30
30
|
private labelText;
|
|
31
|
+
/** @internal Ids of the elements naming this host, as a Field writes them; resolved to text for the button. */
|
|
32
|
+
labelledBy?: string;
|
|
31
33
|
/** @internal What the inner `<button>` is called; a control named by its own content overrides this. */
|
|
32
34
|
protected get accessibleName(): string | null;
|
|
35
|
+
private get labelledByText();
|
|
33
36
|
protected readonly readLabel: () => void;
|
|
34
37
|
/** @internal Whether the control shows a state the user may not change. */
|
|
35
38
|
protected get isReadOnly(): boolean;
|
|
@@ -28,8 +28,11 @@ export declare class SkdxToggleControlBase extends SkdxToggleControlBase_base {
|
|
|
28
28
|
/** Accessible name for the inner `<button>`, moved off this host — see `takeHostAriaLabel`. */
|
|
29
29
|
protected hostLabel: string | null;
|
|
30
30
|
private labelText;
|
|
31
|
+
/** @internal Ids of the elements naming this host, as a Field writes them; resolved to text for the button. */
|
|
32
|
+
labelledBy?: string;
|
|
31
33
|
/** @internal What the inner `<button>` is called; a control named by its own content overrides this. */
|
|
32
34
|
protected get accessibleName(): string | null;
|
|
35
|
+
private get labelledByText();
|
|
33
36
|
protected readonly readLabel: () => void;
|
|
34
37
|
/** @internal Whether the control shows a state the user may not change. */
|
|
35
38
|
protected get isReadOnly(): boolean;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=(n,o,
|
|
1
|
+
var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=(n,o,t,d)=>{for(var i=d>1?void 0:d?u(o,t):o,s=n.length-1,c;s>=0;s--)(c=n[s])&&(i=(d?c(o,t,i):c(i))||i);return d&&i&&p(o,t,i),i};import{css as y,html as b,LitElement as m,nothing as r}from"lit";import{property as l,state as h}from"lit/decorators.js";import{takeHostAriaLabel as v}from"./aria-label.js";import{findAssociatedLabel as f}from"./associated-label.js";import{emit as R}from"./events.js";import{FIELD_CONTROL_ATTRIBUTE as $}from"./field-core.js";import{FormAssociated as L}from"./form-associated.js";import{reflectHostState as O}from"./part.js";import{controlBoxOnHost as w,delegatesFocusShadowRootOptions as g,hiddenHostStyles as E,resetNativeControl as K}from"./styles.js";var e=class extends L(m){constructor(){super(...arguments);this.disabled=!1;this.required=!1;this.value="on";this.invalid=!1;this.hostLabel=null;this.labelText=null;this.readLabel=()=>{this.hostLabel===null&&(this.labelText=f(this)?.textContent?.trim()||null)};this.handleClick=()=>{this.isReadOnly||this.toggle()};this.onKeydown=t=>this.handleKeydown(t);this.controlPart="control";this.controlRole="checkbox";this.onSlotChange=()=>{}}get accessibleName(){return this.hostLabel??this.labelledByText??this.labelText}get labelledByText(){if(!this.labelledBy)return null;let t=this.getRootNode();return this.labelledBy.split(/\s+/).map(i=>t.getElementById(i)?.textContent?.trim()??"").filter(Boolean).join(" ")||null}get isReadOnly(){return!1}get ariaCheckedValue(){return"false"}get controlState(){return"unchecked"}toggle(){}syncFormState(){}afterUpdated(t){}connectedCallback(){super.connectedCallback(),this.hostLabel=v(this),this.setAttribute($,""),queueMicrotask(this.readLabel)}updated(t){O(this,{"data-state":this.controlState,"data-disabled":this.disabled?"":null,"data-readonly":this.isReadOnly?"":null,"data-invalid":this.invalid?"":null}),this.afterUpdated(t)}emitCheckedChange(t){R(this,"checked-change",t)}handleKeydown(t){}render(){return b`
|
|
2
2
|
<button
|
|
3
3
|
part=${this.controlPart}
|
|
4
4
|
type="button"
|
|
5
5
|
role=${this.controlRole}
|
|
6
6
|
?disabled=${this.disabled}
|
|
7
|
-
aria-label=${this.accessibleName??
|
|
7
|
+
aria-label=${this.accessibleName??r}
|
|
8
8
|
aria-checked=${this.ariaCheckedValue}
|
|
9
|
-
aria-required=${this.required?"true":
|
|
10
|
-
aria-readonly=${this.isReadOnly?"true":
|
|
11
|
-
aria-invalid=${this.invalid?"true":
|
|
9
|
+
aria-required=${this.required?"true":r}
|
|
10
|
+
aria-readonly=${this.isReadOnly?"true":r}
|
|
11
|
+
aria-invalid=${this.invalid?"true":r}
|
|
12
12
|
data-state=${this.controlState}
|
|
13
|
-
data-disabled=${this.disabled?"":
|
|
14
|
-
data-readonly=${this.isReadOnly?"":
|
|
15
|
-
data-invalid=${this.invalid?"":
|
|
13
|
+
data-disabled=${this.disabled?"":r}
|
|
14
|
+
data-readonly=${this.isReadOnly?"":r}
|
|
15
|
+
data-invalid=${this.invalid?"":r}
|
|
16
16
|
@click=${this.handleClick}
|
|
17
17
|
@keydown=${this.onKeydown}
|
|
18
18
|
>
|
|
19
19
|
<slot @slotchange=${this.onSlotChange}></slot>
|
|
20
20
|
</button>
|
|
21
|
-
`}};
|
|
21
|
+
`}};e.shadowRootOptions=g,e.styles=[K,E,y`
|
|
22
22
|
:host {
|
|
23
23
|
display: inline-block;
|
|
24
24
|
}
|
|
25
|
-
`,
|
|
25
|
+
`,w],a([l({type:Boolean,reflect:!0})],e.prototype,"disabled",2),a([l({type:Boolean,reflect:!0})],e.prototype,"required",2),a([l({type:String,reflect:!0})],e.prototype,"name",2),a([l({type:String,reflect:!0})],e.prototype,"value",2),a([l({type:Boolean,reflect:!0})],e.prototype,"invalid",2),a([h()],e.prototype,"hostLabel",2),a([h()],e.prototype,"labelText",2),a([l({attribute:"aria-labelledby"})],e.prototype,"labelledBy",2);export{e as SkdxToggleControlBase};
|
package/dist/label/Label.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var L=(i,r)=>{for(var e in r)s(i,e,{get:r[e],enumerable:!0})},g=(i,r,e,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of y(r))!v.call(i,t)&&t!==e&&s(i,t,{get:()=>r[t],enumerable:!(l=c(r,t))||l.enumerable});return i};var T=i=>g(s({},"__esModule",{value:!0}),i),d=(i,r,e,l)=>{for(var t=l>1?void 0:l?c(r,e):r,n=i.length-1,a;n>=0;n--)(a=i[n])&&(t=(l?a(r,e,t):a(t))||t);return l&&t&&s(r,e,t),t};var M={};L(M,{SkdxLabel:()=>o});module.exports=T(M);var u=require("lit"),b=require("lit/decorators.js"),f=require("../internal/define.cjs"),m=require("../internal/dev-mode.cjs"),E=require("../internal/ids.cjs"),p=require("../internal/light-dom-styles.cjs");var h='[contenteditable], input:not([type="hidden"]), textarea, select, button, [tabindex]',o=class extends u.LitElement{constructor(){super(...arguments);this.labelEl=document.createElement("label");this.ownLabelledEl=null;this.handleLabelClick=e=>{if(!this.for||e.defaultPrevented)return;let l=this.resolveTarget(this.for);if(!l)return;let t=this.controlFor(l);if(!t)return;t.focus();let n=t.getAttribute("role")??"";(t instanceof HTMLButtonElement||/^(radio|checkbox|switch)$/.test(n))&&(e.preventDefault(),t.click())}}createRenderRoot(){return this}connectedCallback(){if(super.connectedCallback(),(0,p.installLightDomStyles)(),!this.labelEl.isConnected){for(this.labelEl.setAttribute("part","label"),this.labelEl.style.display="inherit",this.labelEl.style.alignItems="inherit",this.labelEl.style.justifyContent="inherit",this.labelEl.style.gap="inherit",this.labelEl.addEventListener("mousedown",e=>{!e.defaultPrevented&&e.detail>1&&e.preventDefault()}),this.labelEl.addEventListener("click",this.handleLabelClick);this.firstChild;)this.labelEl.append(this.firstChild);this.append(this.labelEl)}this.syncFor()}updated(e){if(!e.has("for"))return;this.syncFor();let l=this.for;queueMicrotask(()=>this.syncTargetLabelling(l))}syncFor(){this.for?this.labelEl.setAttribute("for",this.for):this.labelEl.removeAttribute("for")}resolveTarget(e){return this.getRootNode().getElementById(e)}controlFor(e){return e.tagName.includes("-")?e.matches(h)?e:e.querySelector(h)??e.shadowRoot?.querySelector(h)??null:null}syncTargetLabelling(e){if(this.ownLabelledEl&&(this.ownLabelledEl.removeAttribute("aria-labelledby"),this.ownLabelledEl=null),!e||e!==this.for)return;let l=this.resolveTarget(e);if(!l){(0,m.isDevMode)()&&console.warn(`<skdx-label for="${e}"> does not match any element id.`);return}let t=this.controlFor(l);!t||t.hasAttribute("aria-labelledby")||t.hasAttribute("aria-label")||(t.setAttribute("aria-labelledby",(0,E.ensureId)(this.labelEl,"skdx-label","label")),this.ownLabelledEl=t)}};d([(0,b.property)({type:String})],o.prototype,"for",2),o=d([(0,f.customElement)("skdx-label","label","root")],o);0&&(module.exports={SkdxLabel});
|
package/dist/label/Label.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=Object.defineProperty;var
|
|
1
|
+
var h=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=(n,r,e,l)=>{for(var t=l>1?void 0:l?c(r,e):r,i=n.length-1,s;i>=0;i--)(s=n[i])&&(t=(l?s(r,e,t):s(t))||t);return l&&t&&h(r,e,t),t};import{LitElement as u}from"lit";import{property as b}from"lit/decorators.js";import{customElement as f}from"../internal/define.js";import{isDevMode as m}from"../internal/dev-mode.js";import{ensureId as E}from"../internal/ids.js";import{installLightDomStyles as p}from"../internal/light-dom-styles.js";var d='[contenteditable], input:not([type="hidden"]), textarea, select, button, [tabindex]',o=class extends u{constructor(){super(...arguments);this.labelEl=document.createElement("label");this.ownLabelledEl=null;this.handleLabelClick=e=>{if(!this.for||e.defaultPrevented)return;let l=this.resolveTarget(this.for);if(!l)return;let t=this.controlFor(l);if(!t)return;t.focus();let i=t.getAttribute("role")??"";(t instanceof HTMLButtonElement||/^(radio|checkbox|switch)$/.test(i))&&(e.preventDefault(),t.click())}}createRenderRoot(){return this}connectedCallback(){if(super.connectedCallback(),p(),!this.labelEl.isConnected){for(this.labelEl.setAttribute("part","label"),this.labelEl.style.display="inherit",this.labelEl.style.alignItems="inherit",this.labelEl.style.justifyContent="inherit",this.labelEl.style.gap="inherit",this.labelEl.addEventListener("mousedown",e=>{!e.defaultPrevented&&e.detail>1&&e.preventDefault()}),this.labelEl.addEventListener("click",this.handleLabelClick);this.firstChild;)this.labelEl.append(this.firstChild);this.append(this.labelEl)}this.syncFor()}updated(e){if(!e.has("for"))return;this.syncFor();let l=this.for;queueMicrotask(()=>this.syncTargetLabelling(l))}syncFor(){this.for?this.labelEl.setAttribute("for",this.for):this.labelEl.removeAttribute("for")}resolveTarget(e){return this.getRootNode().getElementById(e)}controlFor(e){return e.tagName.includes("-")?e.matches(d)?e:e.querySelector(d)??e.shadowRoot?.querySelector(d)??null:null}syncTargetLabelling(e){if(this.ownLabelledEl&&(this.ownLabelledEl.removeAttribute("aria-labelledby"),this.ownLabelledEl=null),!e||e!==this.for)return;let l=this.resolveTarget(e);if(!l){m()&&console.warn(`<skdx-label for="${e}"> does not match any element id.`);return}let t=this.controlFor(l);!t||t.hasAttribute("aria-labelledby")||t.hasAttribute("aria-label")||(t.setAttribute("aria-labelledby",E(this.labelEl,"skdx-label","label")),this.ownLabelledEl=t)}};a([b({type:String})],o.prototype,"for",2),o=a([f("skdx-label","label","root")],o);export{o as SkdxLabel};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skdx/web-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.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.
|
|
2874
|
+
"@skdx/shared": "0.37.0"
|
|
2875
2875
|
},
|
|
2876
2876
|
"scripts": {
|
|
2877
2877
|
"lint": "eslint . --cache --cache-location node_modules/.cache/eslint/",
|