@skdx/web-components 0.29.0 → 0.30.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 +39581 -39581
- package/dist/dialog/DialogAnatomy.cjs +1 -1
- package/dist/dialog/DialogAnatomy.js +1 -1
- package/dist/dialog/DialogContent.cjs +1 -1
- package/dist/dialog/DialogContent.d.cts +2 -0
- package/dist/dialog/DialogContent.d.ts +2 -0
- package/dist/dialog/DialogContent.js +1 -1
- package/dist/dialog/DialogRoot.cjs +1 -1
- package/dist/dialog/DialogRoot.js +1 -1
- package/dist/internal/define.cjs +1 -1
- package/dist/internal/define.js +1 -1
- package/dist/label/Label.cjs +1 -1
- package/dist/label/Label.d.cts +6 -0
- package/dist/label/Label.d.ts +6 -0
- package/dist/label/Label.js +1 -1
- package/package.json +292 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var o in e)g(t,o,{get:e[o],enumerable:!0})},D=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of N(e))!S.call(t,n)&&n!==o&&g(t,n,{get:()=>e[n],enumerable:!(r=C(e,n))||r.enumerable});return t};var v=t=>D(g({},"__esModule",{value:!0}),t);var P={};y(P,{DIALOG_ANATOMY_GENERATED:()=>a,fillDialogAnatomy:()=>G,refreshDialogAnatomyText:()=>L});module.exports=v(P);var b=require("../internal/host-attributes.cjs"),M=require("./DialogPortal.cjs"),q=require("./DialogOverlay.cjs"),O=require("./DialogContent.cjs"),R=require("./DialogTitle.cjs"),V=require("./DialogDescription.cjs"),$=require("./DialogClose.cjs"),B=require("./DialogAction.cjs"),H=require("./DialogCancel.cjs"),I=require("../utils/visually-hidden.cjs"),a="data-skdx-dialog-generated",w=new Set(["skdx-dialog-title","skdx-dialog-description","skdx-dialog-close","skdx-dialog-action","skdx-dialog-cancel"]),k="http://www.w3.org/2000/svg";function T(){let t=document.createElementNS(k,"svg");t.setAttribute("viewBox","0 0 16 16"),t.setAttribute("width","1em"),t.setAttribute("height","1em"),t.setAttribute("fill","none"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false");let e=document.createElementNS(k,"path");return e.setAttribute("d","M4 4l8 8M12 4l-8 8"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","1.5"),e.setAttribute("stroke-linecap","round"),t.append(e),t}function A(t){return t.role!=="alertdialog"?{confirm:t.confirmLabel,cancel:t.cancelLabel}:{confirm:t.confirmLabel??"Confirm",cancel:t.cancelLabel??"Cancel"}}function E(t){return t.querySelector(`:scope > skdx-dialog-portal[${a}]`)?.portalHost.querySelector("skdx-dialog-content")??null}function u(t,e,o,r){let n=e.get(o);if(n){t.append(n);return}let s=r();s&&(s.setAttribute(a,""),t.append(s))}function G(t){let e=E(t),o=e?.querySelector(":scope > dialog")??e,r=Array.from(o?o.childNodes:t.childNodes),n=new Map,s=[],d=[];for(let i of r){if(i.nodeType===Node.ELEMENT_NODE){let c=i,x=c.tagName.toLowerCase();if(w.has(x)){c.hasAttribute(a)||n.set(x,c);continue}if(c.getAttribute("slot")==="footer"){d.push(i);continue}}s.push(i)}let p=document.createElement("skdx-dialog-portal");p.setAttribute(a,"");let h=document.createElement("skdx-dialog-overlay"),l=document.createElement("skdx-dialog-content");(0,b.forwardHostAttributes)(t,l),u(l,n,"skdx-dialog-title",()=>{if(!t.title)return;let i=document.createElement("skdx-dialog-title");return i.textContent=t.title,i}),u(l,n,"skdx-dialog-description",()=>{if(!t.description)return;let i=document.createElement("skdx-dialog-description");return i.textContent=t.description,i}),l.append(...s,...d);let m=A(t);u(l,n,"skdx-dialog-cancel",()=>{if(m.cancel===void 0)return;let i=document.createElement("skdx-dialog-cancel");return i.textContent=m.cancel,i}),u(l,n,"skdx-dialog-action",()=>{if(m.confirm===void 0)return;let i=document.createElement("skdx-dialog-action");return i.textContent=m.confirm,t.status&&i.setAttribute("data-status",t.status),i}),u(l,n,"skdx-dialog-close",()=>{if(!t.dismissible||t.role==="alertdialog")return;let i=document.createElement("skdx-dialog-close"),c=document.createElement("skdx-visually-hidden");return c.textContent="Close",i.append(c,T()),i}),p.append(h,l),t.replaceChildren(p)}function f(t,e){return t.querySelector(`:scope > ${e}, :scope > dialog > ${e}`)}function L(t){let e=E(t);if(!e)return;let o=f(e,"skdx-dialog-title");o?.hasAttribute(a)&&t.title&&(o.textContent=t.title);let r=f(e,"skdx-dialog-description");r?.hasAttribute(a)&&t.description&&(r.textContent=t.description);let n=A(t),s=f(e,"skdx-dialog-cancel");s?.hasAttribute(a)&&n.cancel!==void 0&&(s.textContent=n.cancel);let d=f(e,"skdx-dialog-action");d?.hasAttribute(a)&&(n.confirm!==void 0&&(d.textContent=n.confirm),t.status?d.setAttribute("data-status",t.status):d.removeAttribute("data-status"))}0&&(module.exports={DIALOG_ANATOMY_GENERATED,fillDialogAnatomy,refreshDialogAnatomyText});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{forwardHostAttributes as
|
|
1
|
+
import{forwardHostAttributes as E}from"../internal/host-attributes.js";import"./DialogPortal.js";import"./DialogOverlay.js";import"./DialogContent.js";import"./DialogTitle.js";import"./DialogDescription.js";import"./DialogClose.js";import"./DialogAction.js";import"./DialogCancel.js";import"../utils/visually-hidden.js";var s="data-skdx-dialog-generated",h=new Set(["skdx-dialog-title","skdx-dialog-description","skdx-dialog-close","skdx-dialog-action","skdx-dialog-cancel"]),x="http://www.w3.org/2000/svg";function C(){let t=document.createElementNS(x,"svg");t.setAttribute("viewBox","0 0 16 16"),t.setAttribute("width","1em"),t.setAttribute("height","1em"),t.setAttribute("fill","none"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false");let e=document.createElementNS(x,"path");return e.setAttribute("d","M4 4l8 8M12 4l-8 8"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","1.5"),e.setAttribute("stroke-linecap","round"),t.append(e),t}function k(t){return t.role!=="alertdialog"?{confirm:t.confirmLabel,cancel:t.cancelLabel}:{confirm:t.confirmLabel??"Confirm",cancel:t.cancelLabel??"Cancel"}}function b(t){return t.querySelector(`:scope > skdx-dialog-portal[${s}]`)?.portalHost.querySelector("skdx-dialog-content")??null}function u(t,e,a,c){let i=e.get(a);if(i){t.append(i);return}let o=c();o&&(o.setAttribute(s,""),t.append(o))}function _(t){let e=b(t),a=e?.querySelector(":scope > dialog")??e,c=Array.from(a?a.childNodes:t.childNodes),i=new Map,o=[],l=[];for(let n of c){if(n.nodeType===Node.ELEMENT_NODE){let d=n,g=d.tagName.toLowerCase();if(h.has(g)){d.hasAttribute(s)||i.set(g,d);continue}if(d.getAttribute("slot")==="footer"){l.push(n);continue}}o.push(n)}let p=document.createElement("skdx-dialog-portal");p.setAttribute(s,"");let A=document.createElement("skdx-dialog-overlay"),r=document.createElement("skdx-dialog-content");E(t,r),u(r,i,"skdx-dialog-title",()=>{if(!t.title)return;let n=document.createElement("skdx-dialog-title");return n.textContent=t.title,n}),u(r,i,"skdx-dialog-description",()=>{if(!t.description)return;let n=document.createElement("skdx-dialog-description");return n.textContent=t.description,n}),r.append(...o,...l);let m=k(t);u(r,i,"skdx-dialog-cancel",()=>{if(m.cancel===void 0)return;let n=document.createElement("skdx-dialog-cancel");return n.textContent=m.cancel,n}),u(r,i,"skdx-dialog-action",()=>{if(m.confirm===void 0)return;let n=document.createElement("skdx-dialog-action");return n.textContent=m.confirm,t.status&&n.setAttribute("data-status",t.status),n}),u(r,i,"skdx-dialog-close",()=>{if(!t.dismissible||t.role==="alertdialog")return;let n=document.createElement("skdx-dialog-close"),d=document.createElement("skdx-visually-hidden");return d.textContent="Close",n.append(d,C()),n}),p.append(A,r),t.replaceChildren(p)}function f(t,e){return t.querySelector(`:scope > ${e}, :scope > dialog > ${e}`)}function M(t){let e=b(t);if(!e)return;let a=f(e,"skdx-dialog-title");a?.hasAttribute(s)&&t.title&&(a.textContent=t.title);let c=f(e,"skdx-dialog-description");c?.hasAttribute(s)&&t.description&&(c.textContent=t.description);let i=k(t),o=f(e,"skdx-dialog-cancel");o?.hasAttribute(s)&&i.cancel!==void 0&&(o.textContent=i.cancel);let l=f(e,"skdx-dialog-action");l?.hasAttribute(s)&&(i.confirm!==void 0&&(l.textContent=i.confirm),t.status?l.setAttribute("data-status",t.status):l.removeAttribute("data-status"))}export{s as DIALOG_ANATOMY_GENERATED,_ as fillDialogAnatomy,M as refreshDialogAnatomyText};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var w=(n,o)=>{for(var t in o)f(n,t,{get:o[t],enumerable:!0})},F=(n,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of E(o))!k.call(n,i)&&i!==t&&f(n,i,{get:()=>o[i],enumerable:!(e=g(o,i))||e.enumerable});return n};var O=n=>F(f({},"__esModule",{value:!0}),n),d=(n,o,t,e)=>{for(var i=e>1?void 0:e?g(o,t):o,r=n.length-1,a;r>=0;r--)(a=n[r])&&(i=(e?a(o,t,i):a(i))||i);return e&&i&&f(o,t,i),i};var L={};w(L,{SkdxDialogContent:()=>l});module.exports=O(L);var m=require("lit"),c=require("lit/decorators.js"),u=require("../internal/aria-part.cjs"),h=require("../internal/body-scroll-lock.cjs"),b=require("../internal/closest.cjs"),y=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");function v(n){return n==="any"||n==="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.handleCancel=t=>{let e=this.dialogAncestor?.effectiveDismiss??"any",i=e==="any"||e==="escape";(!(0,s.dispatchEscapeKeyDown)(this,t)||!i)&&t.preventDefault()};this.handleClose=()=>this.dialogAncestor?.setOpen(!1);this.handleBackdropPointerDown=t=>{let e=(0,s.backdropPointerDown)(t,this.nativeDialog);e&&(0,s.dispatchOutside)(this,"pointer-down-outside",e)&&this.dialogAncestor?.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsidePointerDown=t=>{if(!this.dialogAncestor?.open)return;let e=t.target;!e||this.contains(e)||e===this.nativeDialog||(0,s.triggerContains)(this.dialogAncestor.triggerEl,e)||(0,s.dispatchOutside)(this,"pointer-down-outside",t)&&this.dialogAncestor.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsideFocus=t=>{if(!this.dialogAncestor?.open)return;let e=(0,s.focusOutsideTarget)(t);!e||this.contains(e)||(0,s.triggerContains)(this.dialogAncestor.triggerEl,e)||(0,s.dispatchOutside)(this,"focus-outside",t)&&this.dialogAncestor.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()}}createRenderRoot(){let t=document.createElement("dialog");return t.setAttribute("part","content"),(0,D.applyHostPart)(t,"dialog","content"),t.addEventListener("cancel",this.handleCancel),t.addEventListener("close",this.handleClose),t.addEventListener("pointerdown",this.handleBackdropPointerDown),this.append(t),this.adoptChildren(),t}adoptChildren(){let t=this.nativeDialog;if(!t)return;let e=document.activeElement;for(let i of Array.from(this.childNodes))i!==t&&t.append(i);e&&document.activeElement!==e&&t.contains(e)&&e.focus({preventScroll:!0})}connectedCallback(){if(super.connectedCallback(),(0,A.installLightDomStyles)(),this.dialogAncestor=(0,b.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.locked&&((0,h.unlockBodyScroll)(),this.locked=!1),super.disconnectedCallback()}firstUpdated(){this.syncNativeDialog()}updated(t){(t.has("size")||t.has("status"))&&this.syncHostAttributes()}syncHostAttributes(){let t=this.dialogAncestor;if(!t)return;this.id?t.contentId=this.id:this.id=t.contentId;let e=t.open?"open":"closed";this.setAttribute("data-state",e),this.setAttribute("data-dismiss",t.effectiveDismiss);let i=this.nativeDialog;if(i){i.setAttribute("role",t.role),t.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",e),i.setAttribute("data-dismiss",t.effectiveDismiss);for(let r of["data-size","data-status"]){let a=this.getAttribute(r);a==null?i.removeAttribute(r):i.setAttribute(r,a)}}}get nativeDialog(){return this.querySelector("dialog")}syncNativeDialog(){this.syncHostAttributes();let t=this.dialogAncestor,e=this.nativeDialog;if(!t||!e)return;t.open&&!e.open?(0,s.focusOnOpen)(()=>{t.effectiveModal?e.showModal?.():e.show?.()}):!t.open&&e.open&&(0,s.focusOnOpen)(()=>e.close?.());let i=t.open&&t.effectiveModal;i&&!this.locked?(0,h.lockBodyScroll)():!i&&this.locked&&(0,h.unlockBodyScroll)(),this.locked=i,this.syncAutoFocus(t.open)}syncAutoFocus(t){if(t===this.wasOpen)return;if(this.wasOpen=t,t){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 e=this.previouslyFocused===document.body?null:this.previouslyFocused,i=!1,r=(0,s.autoFocusRelay)(this);(0,p.returnFocus)(this.finalFocus,"Dialog",e,a=>{r(a),i=a.defaultPrevented}),i&&document.activeElement===e&&e?.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,y.customElement)("skdx-dialog-content")],l);0&&(module.exports={SkdxDialogContent});
|
|
1
|
+
"use strict";var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var w=(n,o)=>{for(var t in o)f(n,t,{get:o[t],enumerable:!0})},F=(n,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of E(o))!k.call(n,i)&&i!==t&&f(n,i,{get:()=>o[i],enumerable:!(e=g(o,i))||e.enumerable});return n};var O=n=>F(f({},"__esModule",{value:!0}),n),d=(n,o,t,e)=>{for(var i=e>1?void 0:e?g(o,t):o,r=n.length-1,a;r>=0;r--)(a=n[r])&&(i=(e?a(o,t,i):a(i))||i);return e&&i&&f(o,t,i),i};var L={};w(L,{SkdxDialogContent:()=>l});module.exports=O(L);var m=require("lit"),c=require("lit/decorators.js"),u=require("../internal/aria-part.cjs"),h=require("../internal/body-scroll-lock.cjs"),b=require("../internal/closest.cjs"),y=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");function v(n){return n==="any"||n==="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.handleCancel=t=>{let e=this.dialogAncestor?.effectiveDismiss??"any",i=e==="any"||e==="escape";(!(0,s.dispatchEscapeKeyDown)(this,t)||!i)&&t.preventDefault()};this.handleClose=()=>this.dialogAncestor?.setOpen(!1);this.handleBackdropPointerDown=t=>{let e=(0,s.backdropPointerDown)(t,this.nativeDialog);e&&(0,s.dispatchOutside)(this,"pointer-down-outside",e)&&this.dialogAncestor?.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsidePointerDown=t=>{if(!this.dialogAncestor?.open)return;let e=t.target;!e||this.contains(e)||e===this.nativeDialog||(0,s.triggerContains)(this.dialogAncestor.triggerEl,e)||(0,s.dispatchOutside)(this,"pointer-down-outside",t)&&this.dialogAncestor.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsideFocus=t=>{if(!this.dialogAncestor?.open)return;let e=(0,s.focusOutsideTarget)(t);!e||this.contains(e)||(0,s.triggerContains)(this.dialogAncestor.triggerEl,e)||(0,s.dispatchOutside)(this,"focus-outside",t)&&this.dialogAncestor.effectiveModal&&v(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()}}createRenderRoot(){let t=document.createElement("dialog");return t.setAttribute("part","content"),(0,D.applyHostPart)(t,"dialog","content"),t.addEventListener("cancel",this.handleCancel),t.addEventListener("close",this.handleClose),t.addEventListener("pointerdown",this.handleBackdropPointerDown),this.append(t),this.adoptChildren(),t}adoptChildren(){let t=this.nativeDialog;if(!t)return;let e=document.activeElement;for(let i of Array.from(this.childNodes))i!==t&&t.append(i);e&&document.activeElement!==e&&t.contains(e)&&e.focus({preventScroll:!0})}connectedCallback(){if(super.connectedCallback(),(0,A.installLightDomStyles)(),this.dialogAncestor=(0,b.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.locked&&((0,h.unlockBodyScroll)(),this.locked=!1),super.disconnectedCallback()}firstUpdated(){this.syncNativeDialog()}updated(t){(t.has("size")||t.has("status"))&&this.syncHostAttributes()}syncHostAttributes(){let t=this.dialogAncestor;if(!t)return;this.id?t.contentId=this.id:this.id=t.contentId;let e=t.open?"open":"closed";this.setAttribute("data-state",e),this.setAttribute("data-dismiss",t.effectiveDismiss);let i=this.nativeDialog;if(i){i.setAttribute("role",t.role),t.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",e),i.setAttribute("data-dismiss",t.effectiveDismiss);for(let r of["data-size","data-status"]){let a=this.getAttribute(r);a==null?i.removeAttribute(r):i.setAttribute(r,a)}}}requestRoleSync(){this.syncHostAttributes()}get nativeDialog(){return this.querySelector("dialog")}syncNativeDialog(){this.syncHostAttributes();let t=this.dialogAncestor,e=this.nativeDialog;if(!t||!e)return;t.open&&!e.open?(0,s.focusOnOpen)(()=>{t.effectiveModal?e.showModal?.():e.show?.()}):!t.open&&e.open&&(0,s.focusOnOpen)(()=>e.close?.());let i=t.open&&t.effectiveModal;i&&!this.locked?(0,h.lockBodyScroll)():!i&&this.locked&&(0,h.unlockBodyScroll)(),this.locked=i,this.syncAutoFocus(t.open)}syncAutoFocus(t){if(t===this.wasOpen)return;if(this.wasOpen=t,t){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 e=this.previouslyFocused===document.body?null:this.previouslyFocused,i=!1,r=(0,s.autoFocusRelay)(this);(0,p.returnFocus)(this.finalFocus,"Dialog",e,a=>{r(a),i=a.defaultPrevented}),i&&document.activeElement===e&&e?.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,y.customElement)("skdx-dialog-content")],l);0&&(module.exports={SkdxDialogContent});
|
|
@@ -43,6 +43,8 @@ export declare class SkdxDialogContent extends LitElement {
|
|
|
43
43
|
protected firstUpdated(): void;
|
|
44
44
|
protected updated(changed: Map<string, unknown>): void;
|
|
45
45
|
private syncHostAttributes;
|
|
46
|
+
/** @internal Re-syncs the native `<dialog>`'s attributes after the ancestor's `role` changes — a property write the host never reflects as an attribute, so the observer above can't see it. */
|
|
47
|
+
requestRoleSync(): void;
|
|
46
48
|
private get nativeDialog();
|
|
47
49
|
private syncNativeDialog;
|
|
48
50
|
private syncAutoFocus;
|
|
@@ -43,6 +43,8 @@ export declare class SkdxDialogContent extends LitElement {
|
|
|
43
43
|
protected firstUpdated(): void;
|
|
44
44
|
protected updated(changed: Map<string, unknown>): void;
|
|
45
45
|
private syncHostAttributes;
|
|
46
|
+
/** @internal Re-syncs the native `<dialog>`'s attributes after the ancestor's `role` changes — a property write the host never reflects as an attribute, so the observer above can't see it. */
|
|
47
|
+
requestRoleSync(): void;
|
|
46
48
|
private get nativeDialog();
|
|
47
49
|
private syncNativeDialog;
|
|
48
50
|
private syncAutoFocus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var m=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var a=(r,l,t,e)=>{for(var i=e>1?void 0:e?b(l,t):l,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=(e?o(l,t,i):o(i))||i);return e&&i&&m(l,t,i),i};import{LitElement as y}from"lit";import{property as d}from"lit/decorators.js";import{forwardAuthoredAria as A,syncPartIdRef as f}from"../internal/aria-part.js";import{lockBodyScroll as D,unlockBodyScroll as p}from"../internal/body-scroll-lock.js";import{closestThroughPortal as E}from"../internal/closest.js";import{customElement as k}from"../internal/define.js";import{autoFocusRelay as v,backdropPointerDown as w,dispatchEscapeKeyDown as F,dispatchOutside as c,focusOnOpen as u,focusOutsideTarget as O,triggerContains as g}from"../internal/dismiss.js";import{applyOpenAutoFocus as L,returnFocus as M}from"../internal/focus-targets.js";import{installLightDomStyles as
|
|
1
|
+
var m=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var a=(r,l,t,e)=>{for(var i=e>1?void 0:e?b(l,t):l,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=(e?o(l,t,i):o(i))||i);return e&&i&&m(l,t,i),i};import{LitElement as y}from"lit";import{property as d}from"lit/decorators.js";import{forwardAuthoredAria as A,syncPartIdRef as f}from"../internal/aria-part.js";import{lockBodyScroll as D,unlockBodyScroll as p}from"../internal/body-scroll-lock.js";import{closestThroughPortal as E}from"../internal/closest.js";import{customElement as k}from"../internal/define.js";import{autoFocusRelay as v,backdropPointerDown as w,dispatchEscapeKeyDown as F,dispatchOutside as c,focusOnOpen as u,focusOutsideTarget as O,triggerContains as g}from"../internal/dismiss.js";import{applyOpenAutoFocus as L,returnFocus as M}from"../internal/focus-targets.js";import{installLightDomStyles as H}from"../internal/light-dom-styles.js";import{applyHostPart as x}from"../internal/part.js";function h(r){return r==="any"||r==="outside"}var n=class extends y{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.handleCancel=t=>{let e=this.dialogAncestor?.effectiveDismiss??"any",i=e==="any"||e==="escape";(!F(this,t)||!i)&&t.preventDefault()};this.handleClose=()=>this.dialogAncestor?.setOpen(!1);this.handleBackdropPointerDown=t=>{let e=w(t,this.nativeDialog);e&&c(this,"pointer-down-outside",e)&&this.dialogAncestor?.effectiveModal&&h(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsidePointerDown=t=>{if(!this.dialogAncestor?.open)return;let e=t.target;!e||this.contains(e)||e===this.nativeDialog||g(this.dialogAncestor.triggerEl,e)||c(this,"pointer-down-outside",t)&&this.dialogAncestor.effectiveModal&&h(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()};this.handleOutsideFocus=t=>{if(!this.dialogAncestor?.open)return;let e=O(t);!e||this.contains(e)||g(this.dialogAncestor.triggerEl,e)||c(this,"focus-outside",t)&&this.dialogAncestor.effectiveModal&&h(this.dialogAncestor.effectiveDismiss)&&this.nativeDialog?.close?.()}}createRenderRoot(){let t=document.createElement("dialog");return t.setAttribute("part","content"),x(t,"dialog","content"),t.addEventListener("cancel",this.handleCancel),t.addEventListener("close",this.handleClose),t.addEventListener("pointerdown",this.handleBackdropPointerDown),this.append(t),this.adoptChildren(),t}adoptChildren(){let t=this.nativeDialog;if(!t)return;let e=document.activeElement;for(let i of Array.from(this.childNodes))i!==t&&t.append(i);e&&document.activeElement!==e&&t.contains(e)&&e.focus({preventScroll:!0})}connectedCallback(){if(super.connectedCallback(),H(),this.dialogAncestor=E(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.locked&&(p(),this.locked=!1),super.disconnectedCallback()}firstUpdated(){this.syncNativeDialog()}updated(t){(t.has("size")||t.has("status"))&&this.syncHostAttributes()}syncHostAttributes(){let t=this.dialogAncestor;if(!t)return;this.id?t.contentId=this.id:this.id=t.contentId;let e=t.open?"open":"closed";this.setAttribute("data-state",e),this.setAttribute("data-dismiss",t.effectiveDismiss);let i=this.nativeDialog;if(i){i.setAttribute("role",t.role),t.effectiveModal?i.setAttribute("aria-modal","true"):i.removeAttribute("aria-modal"),A(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",e),i.setAttribute("data-dismiss",t.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 t=this.dialogAncestor,e=this.nativeDialog;if(!t||!e)return;t.open&&!e.open?u(()=>{t.effectiveModal?e.showModal?.():e.show?.()}):!t.open&&e.open&&u(()=>e.close?.());let i=t.open&&t.effectiveModal;i&&!this.locked?D():!i&&this.locked&&p(),this.locked=i,this.syncAutoFocus(t.open)}syncAutoFocus(t){if(t===this.wasOpen)return;if(this.wasOpen=t,t){this.previouslyFocused=document.activeElement,requestAnimationFrame(()=>u(()=>L(this.nativeDialog??this,this.initialFocus,"Dialog",v(this),this.previouslyFocused)));return}let e=this.previouslyFocused===document.body?null:this.previouslyFocused,i=!1,s=v(this);M(this.finalFocus,"Dialog",e,o=>{s(o),i=o.defaultPrevented}),i&&document.activeElement===e&&e?.blur?.()}};a([d({type:String,attribute:"initial-focus"})],n.prototype,"initialFocus",2),a([d({type:String,attribute:"final-focus"})],n.prototype,"finalFocus",2),a([d({type:String,reflect:!0,attribute:"data-size"})],n.prototype,"size",2),a([d({type:String,reflect:!0,attribute:"data-status"})],n.prototype,"status",2),n=a([k("skdx-dialog-content")],n);export{n as SkdxDialogContent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var O=(s,o)=>{for(var e in o)d(s,e,{get:o[e],enumerable:!0})},k=(s,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of b(o))!C.call(s,t)&&t!==e&&d(s,t,{get:()=>o[t],enumerable:!(r=f(o,t))||r.enumerable});return s};var w=s=>k(d({},"__esModule",{value:!0}),s),n=(s,o,e,r)=>{for(var t=r>1?void 0:r?f(o,e):o,c=s.length-1,u;c>=0;c--)(u=s[c])&&(t=(r?u(o,e,t):u(t))||t);return r&&t&&d(o,e,t),t};var x={};O(x,{SkdxDialogRoot:()=>i});module.exports=w(x);var a=require("lit"),l=require("lit/decorators.js"),g=require("../internal/controlled-value.cjs"),v=require("../internal/define.cjs"),p=require("../internal/ids.cjs"),y=require("../internal/open-change-complete.cjs"),h=require("../internal/positioning.cjs"),
|
|
1
|
+
"use strict";var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var O=(s,o)=>{for(var e in o)d(s,e,{get:o[e],enumerable:!0})},k=(s,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of b(o))!C.call(s,t)&&t!==e&&d(s,t,{get:()=>o[t],enumerable:!(r=f(o,t))||r.enumerable});return s};var w=s=>k(d({},"__esModule",{value:!0}),s),n=(s,o,e,r)=>{for(var t=r>1?void 0:r?f(o,e):o,c=s.length-1,u;c>=0;c--)(u=s[c])&&(t=(r?u(o,e,t):u(t))||t);return r&&t&&d(o,e,t),t};var x={};O(x,{SkdxDialogRoot:()=>i});module.exports=w(x);var a=require("lit"),l=require("lit/decorators.js"),g=require("../internal/controlled-value.cjs"),v=require("../internal/define.cjs"),p=require("../internal/ids.cjs"),y=require("../internal/open-change-complete.cjs"),h=require("../internal/positioning.cjs"),q=require("./DialogTrigger.cjs"),m=require("../internal/events.cjs");var i=class extends a.LitElement{constructor(){super(...arguments);this._open=new g.ControlledValue(!1);this.defaultOpen=!1;this.modal=!0;this.dismiss="any";this.dismissible=!0;this._role="dialog";this.contentId=(0,p.nextId)("skdx-dialog-content");this.triggerEl=null;this.titleId=(0,p.nextId)("skdx-dialog-title");this.descriptionId=(0,p.nextId)("skdx-dialog-description");this.hasUpdatedOnce=!1}get open(){return this._open.value??!1}set open(e){let r=this.open;this._open.fromConsumer(e)&&this.requestUpdate("open",r)}get role(){return this._role}set role(e){if(e===null)return;let r=this._role;this._role=e==="alertdialog"?"alertdialog":"dialog",this.removeAttribute("role"),this.requestUpdate("role",r)}get effectiveDismiss(){return this.dismissible?this.role!=="alertdialog"?this.dismiss:this.dismiss==="any"?"escape":this.dismiss==="outside"?"none":this.dismiss:"none"}get effectiveModal(){return this.role==="alertdialog"||this.modal}connectedCallback(){super.connectedCallback(),this.defaultOpen&&!this.hasAttribute("open")&&this.writeOpen(!0);let e=this.querySelector("skdx-dialog-content")?.id;e&&(this.contentId=e)}disconnectedCallback(){this.teardownOpenChangeComplete?.(),super.disconnectedCallback()}updated(e){let r=!this.hasUpdatedOnce;this.hasUpdatedOnce=!0,e.has("role")&&this.querySelector("skdx-dialog-content")?.requestRoleSync(),e.has("open")&&!r&&(this.teardownOpenChangeComplete?.(),this.teardownOpenChangeComplete=(0,y.notifyOpenChangeComplete)(()=>this.querySelector("skdx-dialog-content"),this.open,t=>(0,m.emit)(this,"open-change-complete",t)))}setOpen(e){this.writeOpen(e)&&(0,m.emit)(this,"open-change",e)}writeOpen(e){let r=this.open,t=this._open.propose(e);return t&&this.requestUpdate("open",r),t}render(){return a.html`<slot></slot>`}};i.styles=a.css`
|
|
2
2
|
:host {
|
|
3
3
|
display: contents;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var h=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var i=(l,n,e,t)=>{for(var o=t>1?void 0:t?m(n,e):n,a=l.length-1,d;a>=0;a--)(d=l[a])&&(o=(t?d(n,e,o):d(o))||o);return t&&o&&h(n,e,o),o};import{css as f,html as g,LitElement as v}from"lit";import{property as s}from"lit/decorators.js";import{ControlledValue as y}from"../internal/controlled-value.js";import{customElement as b}from"../internal/define.js";import{nextId as p}from"../internal/ids.js";import{notifyOpenChangeComplete as C}from"../internal/open-change-complete.js";import{optOutBoolean as c}from"../internal/positioning.js";import"./DialogTrigger.js";import{emit as u}from"../internal/events.js";var r=class extends v{constructor(){super(...arguments);this._open=new y(!1);this.defaultOpen=!1;this.modal=!0;this.dismiss="any";this.dismissible=!0;this._role="dialog";this.contentId=p("skdx-dialog-content");this.triggerEl=null;this.titleId=p("skdx-dialog-title");this.descriptionId=p("skdx-dialog-description");this.hasUpdatedOnce=!1}get open(){return this._open.value??!1}set open(e){let t=this.open;this._open.fromConsumer(e)&&this.requestUpdate("open",t)}get role(){return this._role}set role(e){if(e===null)return;let t=this._role;this._role=e==="alertdialog"?"alertdialog":"dialog",this.removeAttribute("role"),this.requestUpdate("role",t)}get effectiveDismiss(){return this.dismissible?this.role!=="alertdialog"?this.dismiss:this.dismiss==="any"?"escape":this.dismiss==="outside"?"none":this.dismiss:"none"}get effectiveModal(){return this.role==="alertdialog"||this.modal}connectedCallback(){super.connectedCallback(),this.defaultOpen&&!this.hasAttribute("open")&&this.writeOpen(!0);let e=this.querySelector("skdx-dialog-content")?.id;e&&(this.contentId=e)}disconnectedCallback(){this.teardownOpenChangeComplete?.(),super.disconnectedCallback()}updated(e){let t=!this.hasUpdatedOnce;this.hasUpdatedOnce=!0,e.has("open")&&!t&&(this.teardownOpenChangeComplete?.(),this.teardownOpenChangeComplete=C(()=>this.querySelector("skdx-dialog-content"),this.open,o=>u(this,"open-change-complete",o)))}setOpen(e){this.writeOpen(e)&&u(this,"open-change",e)}writeOpen(e){let t=this.open,o=this._open.propose(e);return o&&this.requestUpdate("open",t),o}render(){return g`<slot></slot>`}};r.styles=f`
|
|
1
|
+
var h=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var i=(l,n,e,t)=>{for(var o=t>1?void 0:t?m(n,e):n,a=l.length-1,d;a>=0;a--)(d=l[a])&&(o=(t?d(n,e,o):d(o))||o);return t&&o&&h(n,e,o),o};import{css as f,html as g,LitElement as v}from"lit";import{property as s}from"lit/decorators.js";import{ControlledValue as y}from"../internal/controlled-value.js";import{customElement as b}from"../internal/define.js";import{nextId as p}from"../internal/ids.js";import{notifyOpenChangeComplete as C}from"../internal/open-change-complete.js";import{optOutBoolean as c}from"../internal/positioning.js";import"./DialogTrigger.js";import{emit as u}from"../internal/events.js";var r=class extends v{constructor(){super(...arguments);this._open=new y(!1);this.defaultOpen=!1;this.modal=!0;this.dismiss="any";this.dismissible=!0;this._role="dialog";this.contentId=p("skdx-dialog-content");this.triggerEl=null;this.titleId=p("skdx-dialog-title");this.descriptionId=p("skdx-dialog-description");this.hasUpdatedOnce=!1}get open(){return this._open.value??!1}set open(e){let t=this.open;this._open.fromConsumer(e)&&this.requestUpdate("open",t)}get role(){return this._role}set role(e){if(e===null)return;let t=this._role;this._role=e==="alertdialog"?"alertdialog":"dialog",this.removeAttribute("role"),this.requestUpdate("role",t)}get effectiveDismiss(){return this.dismissible?this.role!=="alertdialog"?this.dismiss:this.dismiss==="any"?"escape":this.dismiss==="outside"?"none":this.dismiss:"none"}get effectiveModal(){return this.role==="alertdialog"||this.modal}connectedCallback(){super.connectedCallback(),this.defaultOpen&&!this.hasAttribute("open")&&this.writeOpen(!0);let e=this.querySelector("skdx-dialog-content")?.id;e&&(this.contentId=e)}disconnectedCallback(){this.teardownOpenChangeComplete?.(),super.disconnectedCallback()}updated(e){let t=!this.hasUpdatedOnce;this.hasUpdatedOnce=!0,e.has("role")&&this.querySelector("skdx-dialog-content")?.requestRoleSync(),e.has("open")&&!t&&(this.teardownOpenChangeComplete?.(),this.teardownOpenChangeComplete=C(()=>this.querySelector("skdx-dialog-content"),this.open,o=>u(this,"open-change-complete",o)))}setOpen(e){this.writeOpen(e)&&u(this,"open-change",e)}writeOpen(e){let t=this.open,o=this._open.propose(e);return o&&this.requestUpdate("open",t),o}render(){return g`<slot></slot>`}};r.styles=f`
|
|
2
2
|
:host {
|
|
3
3
|
display: contents;
|
|
4
4
|
}
|
package/dist/internal/define.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var o in e)d(t,o,{get:e[o],enumerable:!0})},v=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of g(e))!b.call(t,n)&&n!==o&&d(t,n,{get:()=>e[n],enumerable:!(r=C(e,n))||r.enumerable});return t};var y=t=>v(d({},"__esModule",{value:!0}),t);var H={};w(H,{customElement:()=>A,isUpgraded:()=>D,whenUpgraded:()=>S});module.exports=y(H);var m=require("./dev-mode.cjs"),f=require("./part.cjs"),p=require("./styles.cjs"),k=2e3,E=new WeakSet,l=new WeakMap,u=new WeakSet;function P(t){if(!(0,m.isDevMode)()||u.has(t))return;let e=t.constructor.elementProperties;if(e)for(let[o,r]of e){if(typeof r.attribute!="string"||!r.attribute.startsWith("data-"))continue;let n=String(o).replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`);if(!t.hasAttribute(n))continue;u.add(t);let s=t.getAttribute(n)??"";console.warn(`[skdx] ${t.localName}: use ${r.attribute}="${s}" instead of ${n}="${s}"`);return}}var h=Symbol.for("skdx.part"),A=(t,e,o)=>(r,n)=>{e!==void 0&&o!==void 0&&(r[h]=[e,o]),M(r);let s=()=>{customElements.get(t)===void 0&&customElements.define(t,r)};n===void 0?s():n.addInitializer(s)};function M(t){let e=t.prototype,o=e.connectedCallback;e.connectedCallback=function(){let r=this.constructor[h];r&&(0,f.applyHostPart)(this,r[0],r[1]);let n=!1,s=()=>{if(n)return;n=!0,E.add(this),P(this),o?.call(this),this.shadowRoot&&(0,p.adoptInheritanceStyles)(this.shadowRoot);let i=l.get(this);if(i){l.delete(this);for(let c of i)c()}},a=()=>{if(n||!this.isConnected)return;let i=T(this);if(i===null){s();return}let c=l.get(i);c===void 0&&l.set(i,c=new Set),c.add(a),customElements.get(i.localName)===void 0&&customElements.whenDefined(i.localName).then(a)};a(),n||setTimeout(s,k)}}function T(t){for(let e=t.parentElement;e;e=e.parentElement){if(!e.localName.startsWith("skdx-"))continue;let o=customElements.get(e.localName);if(o===void 0||(e instanceof o||customElements.upgrade(e),!E.has(e)))return e}return null}function S(t,e){customElements.get(t.localName)?e():customElements.whenDefined(t.localName).then(e)}function D(t){return customElements.get(t.localName)!==void 0}0&&(module.exports={customElement,isUpgraded,whenUpgraded});
|
package/dist/internal/define.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyHostPart as
|
|
1
|
+
import{isDevMode as f}from"./dev-mode.js";import{applyHostPart as p}from"./part.js";import{adoptInheritanceStyles as E}from"./styles.js";var h=2e3,u=new WeakSet,l=new WeakMap,d=new WeakSet;function C(t){if(!f()||d.has(t))return;let e=t.constructor.elementProperties;if(e)for(let[r,n]of e){if(typeof n.attribute!="string"||!n.attribute.startsWith("data-"))continue;let o=String(r).replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`);if(!t.hasAttribute(o))continue;d.add(t);let s=t.getAttribute(o)??"";console.warn(`[skdx] ${t.localName}: use ${n.attribute}="${s}" instead of ${o}="${s}"`);return}}var m=Symbol.for("skdx.part"),k=(t,e,r)=>(n,o)=>{e!==void 0&&r!==void 0&&(n[m]=[e,r]),g(n);let s=()=>{customElements.get(t)===void 0&&customElements.define(t,n)};o===void 0?s():o.addInitializer(s)};function g(t){let e=t.prototype,r=e.connectedCallback;e.connectedCallback=function(){let n=this.constructor[m];n&&p(this,n[0],n[1]);let o=!1,s=()=>{if(o)return;o=!0,u.add(this),C(this),r?.call(this),this.shadowRoot&&E(this.shadowRoot);let i=l.get(this);if(i){l.delete(this);for(let c of i)c()}},a=()=>{if(o||!this.isConnected)return;let i=b(this);if(i===null){s();return}let c=l.get(i);c===void 0&&l.set(i,c=new Set),c.add(a),customElements.get(i.localName)===void 0&&customElements.whenDefined(i.localName).then(a)};a(),o||setTimeout(s,h)}}function b(t){for(let e=t.parentElement;e;e=e.parentElement){if(!e.localName.startsWith("skdx-"))continue;let r=customElements.get(e.localName);if(r===void 0||(e instanceof r||customElements.upgrade(e),!u.has(e)))return e}return null}function P(t,e){customElements.get(t.localName)?e():customElements.whenDefined(t.localName).then(e)}function A(t){return customElements.get(t.localName)!==void 0}export{k as customElement,A as isUpgraded,P as whenUpgraded};
|
package/dist/label/Label.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var g=(i,l)=>{for(var e in l)n(i,e,{get:l[e],enumerable:!0})},L=(i,l,e,r)=>{if(l&&typeof l=="object"||typeof l=="function")for(let t of y(l))!v.call(i,t)&&t!==e&&n(i,t,{get:()=>l[t],enumerable:!(r=h(l,t))||r.enumerable});return i};var T=i=>L(n({},"__esModule",{value:!0}),i),d=(i,l,e,r)=>{for(var t=r>1?void 0:r?h(l,e):l,a=i.length-1,s;a>=0;a--)(s=i[a])&&(t=(r?s(l,e,t):s(t))||t);return r&&t&&n(l,e,t),t};var C={};g(C,{SkdxLabel:()=>o});module.exports=T(C);var c=require("lit"),u=require("lit/decorators.js"),m=require("../internal/define.cjs"),f=require("../internal/dev-mode.cjs"),E=require("../internal/ids.cjs"),p=require("../internal/light-dom-styles.cjs");var b='[contenteditable], input:not([type="hidden"]), textarea, select, button, [tabindex]',o=class extends c.LitElement{constructor(){super(...arguments);this.labelEl=document.createElement("label");this.ownLabelledEl=null;this.handleLabelClick=()=>{if(!this.for)return;let e=this.resolveTarget(this.for);e&&this.controlFor(e)?.focus()}}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 r=this.for;queueMicrotask(()=>this.syncTargetLabelling(r))}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(b)?null:e.querySelector(b)}syncTargetLabelling(e){if(this.ownLabelledEl&&(this.ownLabelledEl.removeAttribute("aria-labelledby"),this.ownLabelledEl=null),!e||e!==this.for)return;let r=this.resolveTarget(e);if(!r){(0,f.isDevMode)()&&console.warn(`<skdx-label for="${e}"> does not match any element id.`);return}let t=this.controlFor(r);!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,u.property)({type:String})],o.prototype,"for",2),o=d([(0,m.customElement)("skdx-label","label","root")],o);0&&(module.exports={SkdxLabel});
|
package/dist/label/Label.d.cts
CHANGED
|
@@ -18,9 +18,15 @@ export declare class SkdxLabel extends LitElement {
|
|
|
18
18
|
*/
|
|
19
19
|
for?: string;
|
|
20
20
|
private readonly labelEl;
|
|
21
|
+
/** The element this label wrote `aria-labelledby` onto, so a `for` change clears only what it put there. */
|
|
22
|
+
private ownLabelledEl;
|
|
21
23
|
connectedCallback(): void;
|
|
22
24
|
protected updated(changed: PropertyValues): void;
|
|
23
25
|
private syncFor;
|
|
26
|
+
private resolveTarget;
|
|
27
|
+
private controlFor;
|
|
28
|
+
private readonly handleLabelClick;
|
|
29
|
+
private syncTargetLabelling;
|
|
24
30
|
}
|
|
25
31
|
declare global {
|
|
26
32
|
interface HTMLElementTagNameMap {
|
package/dist/label/Label.d.ts
CHANGED
|
@@ -18,9 +18,15 @@ export declare class SkdxLabel extends LitElement {
|
|
|
18
18
|
*/
|
|
19
19
|
for?: string;
|
|
20
20
|
private readonly labelEl;
|
|
21
|
+
/** The element this label wrote `aria-labelledby` onto, so a `for` change clears only what it put there. */
|
|
22
|
+
private ownLabelledEl;
|
|
21
23
|
connectedCallback(): void;
|
|
22
24
|
protected updated(changed: PropertyValues): void;
|
|
23
25
|
private syncFor;
|
|
26
|
+
private resolveTarget;
|
|
27
|
+
private controlFor;
|
|
28
|
+
private readonly handleLabelClick;
|
|
29
|
+
private syncTargetLabelling;
|
|
24
30
|
}
|
|
25
31
|
declare global {
|
|
26
32
|
interface HTMLElementTagNameMap {
|
package/dist/label/Label.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=Object.defineProperty;var
|
|
1
|
+
var h=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var s=(o,r,e,l)=>{for(var t=l>1?void 0:l?b(r,e):r,n=o.length-1,a;n>=0;n--)(a=o[n])&&(t=(l?a(r,e,t):a(t))||t);return l&&t&&h(r,e,t),t};import{LitElement as c}from"lit";import{property as u}from"lit/decorators.js";import{customElement as m}from"../internal/define.js";import{isDevMode as f}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]',i=class extends c{constructor(){super(...arguments);this.labelEl=document.createElement("label");this.ownLabelledEl=null;this.handleLabelClick=()=>{if(!this.for)return;let e=this.resolveTarget(this.for);e&&this.controlFor(e)?.focus()}}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)?null:e.querySelector(d)}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){f()&&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)}};s([u({type:String})],i.prototype,"for",2),i=s([m("skdx-label","label","root")],i);export{i as SkdxLabel};
|