@fluid-topics/ft-wc-utils 2.0.23 → 2.0.24
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.
|
@@ -23,6 +23,8 @@ export declare class FocusTrapDirective extends AsyncDirective {
|
|
|
23
23
|
update(part: ElementPart): symbol;
|
|
24
24
|
reconnected(): void;
|
|
25
25
|
disconnected(): void;
|
|
26
|
+
private ensureFocusTrap;
|
|
27
|
+
private removeFocusTrap;
|
|
26
28
|
private isElementTrappable;
|
|
27
29
|
private createFocusTrap;
|
|
28
30
|
/**
|
|
@@ -51,18 +51,30 @@ export class FocusTrapDirective extends AsyncDirective {
|
|
|
51
51
|
}
|
|
52
52
|
update(part) {
|
|
53
53
|
this.part = part;
|
|
54
|
-
|
|
55
|
-
this.createFocusTrap(part.element);
|
|
56
|
-
}
|
|
54
|
+
this.ensureFocusTrap(part.element);
|
|
57
55
|
return noChange;
|
|
58
56
|
}
|
|
59
57
|
reconnected() {
|
|
60
58
|
var _a;
|
|
61
|
-
|
|
62
|
-
this.createFocusTrap(this.part.element);
|
|
63
|
-
}
|
|
59
|
+
this.ensureFocusTrap((_a = this.part) === null || _a === void 0 ? void 0 : _a.element);
|
|
64
60
|
}
|
|
65
61
|
disconnected() {
|
|
62
|
+
this.removeFocusTrap();
|
|
63
|
+
}
|
|
64
|
+
ensureFocusTrap(element) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
if (!this.isElementTrappable(element)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// If traps already exist and are still anchored to the host element, nothing to do.
|
|
70
|
+
// This prevents duplicating trap divs on every re-render of the host.
|
|
71
|
+
if (((_a = this.firstTrap) === null || _a === void 0 ? void 0 : _a.parentElement) === element && ((_b = this.lastTrap) === null || _b === void 0 ? void 0 : _b.parentElement) === element) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.removeFocusTrap();
|
|
75
|
+
this.createFocusTrap(element);
|
|
76
|
+
}
|
|
77
|
+
removeFocusTrap() {
|
|
66
78
|
var _a, _b, _c, _d;
|
|
67
79
|
(_a = this.firstTrap) === null || _a === void 0 ? void 0 : _a.removeEventListener("focus", this.onFirstTrapFocus);
|
|
68
80
|
(_b = this.lastTrap) === null || _b === void 0 ? void 0 : _b.removeEventListener("focus", this.onLastTrapFocus);
|
package/build/globals.min.js
CHANGED
|
@@ -82,7 +82,7 @@ Also for action icons.`,c.colorGray200),contentGlobalSubtle:r.extend("--ftds-con
|
|
|
82
82
|
<li>${this.helperText}</li>
|
|
83
83
|
`)}
|
|
84
84
|
</ul>
|
|
85
|
-
`}resolveStatus(){return this.forceStatus?this.forceStatus:this.errorMessages.length?Ve.error:this.warningMessages.length?Ve.warning:Ve.default}processRules(n){return n.map(a=>a(this.value)).filter(a=>a!==!0).map(a=>a)}}return j([M()],e.prototype,"warningRules",void 0),j([M()],e.prototype,"errorRules",void 0),j([M()],e.prototype,"validateOn",void 0),j([M({type:Boolean})],e.prototype,"validateAtRender",void 0),j([M()],e.prototype,"label",void 0),j([M({type:Boolean})],e.prototype,"hideLabel",void 0),j([M()],e.prototype,"name",void 0),j([M({type:Boolean})],e.prototype,"disabled",void 0),j([M()],e.prototype,"helperText",void 0),j([M()],e.prototype,"forceStatus",void 0),j([M({reflect:!0})],e.prototype,"value",void 0),j([ce()],e.prototype,"errorMessages",void 0),j([ce()],e.prototype,"warningMessages",void 0),j([ce()],e.prototype,"status",void 0),j([ce()],e.prototype,"focused",void 0),j([ce()],e.prototype,"additionalWarningRules",void 0),j([ce()],e.prototype,"additionalErrorRules",void 0),e});var Wd=/^[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/,Gd=/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,hb={required:function(t){return e=>!!e||t},email:function(t){return e=>!e||Gd.test(e.toString())||t},url:function(t){return e=>!e||Wd.test(e.toString())||t}};var jt=(t,e)=>{let o=t._$AN;if(o===void 0)return!1;for(let n of o)n._$AO?.(e,!1),jt(n,e);return!0},Sr=t=>{let e,o;do{if((e=t._$AM)===void 0)break;o=e._$AN,o.delete(t),t=e}while(o?.size===0)},Ls=t=>{for(let e;e=t._$AM;t=e){let o=e._$AN;if(o===void 0)e._$AN=o=new Set;else if(o.has(t))break;o.add(t),Kd(e)}};function jd(t){this._$AN!==void 0?(Sr(this),this._$AM=t,Ls(this)):this._$AM=t}function Vd(t,e=!1,o=0){let n=this._$AH,a=this._$AN;if(a!==void 0&&a.size!==0)if(e)if(Array.isArray(n))for(let i=o;i<n.length;i++)jt(n[i],!1),Sr(n[i]);else n!=null&&(jt(n,!1),Sr(n));else jt(this,t)}var Kd=t=>{t.type==le.CHILD&&(t._$AP??=Vd,t._$AQ??=jd)},gt=class extends ee{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,o,n){super._$AT(e,o,n),Ls(this),this.isConnected=e._$AU}_$AO(e,o=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),o&&(jt(this,e),Sr(this))}setValue(e){if(Kn(this._$Ct))this._$Ct._$AI(e,this);else{let o=[...this._$Ct._$AH];o[this._$Ci]=e,this._$Ct._$AI(o,this,0)}}disconnected(){}reconnected(){}};var Cn=class extends gt{get element(){var e;return(e=this.part)===null||e===void 0?void 0:e.element}constructor(e){super(e),this.onFirstTrapFocus=async o=>{if(!this.element||!o.relatedTarget)return;let n=o.relatedTarget;this.isInsideElement(n,this.element)?await this.focusLastDescendant(this.element):await this.focusFirstDescendant(this.element)},this.onLastTrapFocus=async o=>{if(!this.element||!o.relatedTarget)return;let n=o.relatedTarget;this.isInsideElement(n,this.element)?await this.focusFirstDescendant(this.element):await this.focusLastDescendant(this.element)}}render(){return $}update(e){return this.part=e,this.
|
|
85
|
+
`}resolveStatus(){return this.forceStatus?this.forceStatus:this.errorMessages.length?Ve.error:this.warningMessages.length?Ve.warning:Ve.default}processRules(n){return n.map(a=>a(this.value)).filter(a=>a!==!0).map(a=>a)}}return j([M()],e.prototype,"warningRules",void 0),j([M()],e.prototype,"errorRules",void 0),j([M()],e.prototype,"validateOn",void 0),j([M({type:Boolean})],e.prototype,"validateAtRender",void 0),j([M()],e.prototype,"label",void 0),j([M({type:Boolean})],e.prototype,"hideLabel",void 0),j([M()],e.prototype,"name",void 0),j([M({type:Boolean})],e.prototype,"disabled",void 0),j([M()],e.prototype,"helperText",void 0),j([M()],e.prototype,"forceStatus",void 0),j([M({reflect:!0})],e.prototype,"value",void 0),j([ce()],e.prototype,"errorMessages",void 0),j([ce()],e.prototype,"warningMessages",void 0),j([ce()],e.prototype,"status",void 0),j([ce()],e.prototype,"focused",void 0),j([ce()],e.prototype,"additionalWarningRules",void 0),j([ce()],e.prototype,"additionalErrorRules",void 0),e});var Wd=/^[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/,Gd=/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,hb={required:function(t){return e=>!!e||t},email:function(t){return e=>!e||Gd.test(e.toString())||t},url:function(t){return e=>!e||Wd.test(e.toString())||t}};var jt=(t,e)=>{let o=t._$AN;if(o===void 0)return!1;for(let n of o)n._$AO?.(e,!1),jt(n,e);return!0},Sr=t=>{let e,o;do{if((e=t._$AM)===void 0)break;o=e._$AN,o.delete(t),t=e}while(o?.size===0)},Ls=t=>{for(let e;e=t._$AM;t=e){let o=e._$AN;if(o===void 0)e._$AN=o=new Set;else if(o.has(t))break;o.add(t),Kd(e)}};function jd(t){this._$AN!==void 0?(Sr(this),this._$AM=t,Ls(this)):this._$AM=t}function Vd(t,e=!1,o=0){let n=this._$AH,a=this._$AN;if(a!==void 0&&a.size!==0)if(e)if(Array.isArray(n))for(let i=o;i<n.length;i++)jt(n[i],!1),Sr(n[i]);else n!=null&&(jt(n,!1),Sr(n));else jt(this,t)}var Kd=t=>{t.type==le.CHILD&&(t._$AP??=Vd,t._$AQ??=jd)},gt=class extends ee{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,o,n){super._$AT(e,o,n),Ls(this),this.isConnected=e._$AU}_$AO(e,o=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),o&&(jt(this,e),Sr(this))}setValue(e){if(Kn(this._$Ct))this._$Ct._$AI(e,this);else{let o=[...this._$Ct._$AH];o[this._$Ci]=e,this._$Ct._$AI(o,this,0)}}disconnected(){}reconnected(){}};var Cn=class extends gt{get element(){var e;return(e=this.part)===null||e===void 0?void 0:e.element}constructor(e){super(e),this.onFirstTrapFocus=async o=>{if(!this.element||!o.relatedTarget)return;let n=o.relatedTarget;this.isInsideElement(n,this.element)?await this.focusLastDescendant(this.element):await this.focusFirstDescendant(this.element)},this.onLastTrapFocus=async o=>{if(!this.element||!o.relatedTarget)return;let n=o.relatedTarget;this.isInsideElement(n,this.element)?await this.focusFirstDescendant(this.element):await this.focusLastDescendant(this.element)}}render(){return $}update(e){return this.part=e,this.ensureFocusTrap(e.element),$}reconnected(){var e;this.ensureFocusTrap((e=this.part)===null||e===void 0?void 0:e.element)}disconnected(){this.removeFocusTrap()}ensureFocusTrap(e){var o,n;this.isElementTrappable(e)&&(((o=this.firstTrap)===null||o===void 0?void 0:o.parentElement)===e&&((n=this.lastTrap)===null||n===void 0?void 0:n.parentElement)===e||(this.removeFocusTrap(),this.createFocusTrap(e)))}removeFocusTrap(){var e,o,n,a;(e=this.firstTrap)===null||e===void 0||e.removeEventListener("focus",this.onFirstTrapFocus),(o=this.lastTrap)===null||o===void 0||o.removeEventListener("focus",this.onLastTrapFocus),(n=this.firstTrap)===null||n===void 0||n.remove(),(a=this.lastTrap)===null||a===void 0||a.remove(),this.firstTrap=void 0,this.lastTrap=void 0}isElementTrappable(e){return!!e&&e instanceof HTMLElement&&e.childElementCount>0}createFocusTrap(e){this.firstTrap=this.createTrap(),this.lastTrap=this.createTrap(),e.insertBefore(this.firstTrap,e.firstChild),e.appendChild(this.lastTrap),this.lastTrap.addEventListener("focus",this.onLastTrapFocus),this.firstTrap.addEventListener("focus",this.onFirstTrapFocus)}createTrap(){let e=document.createElement("div");return e.tabIndex=0,e}getChildren(e){return e instanceof HTMLSlotElement?e.assignedElements():e.shadowRoot?e.shadowRoot.children:e.children}async focusFirstDescendant(e){await this.updateCompleteIfNecessary(e);let o=this.getChildren(e);for(let n=0;n<o.length;n++){let a=o[n];if(a instanceof HTMLElement&&(this.attemptFocus(a)||await this.focusFirstDescendant(a)))return!0}return!1}async focusLastDescendant(e){await this.updateCompleteIfNecessary(e);let o=this.getChildren(e);for(let n=o.length-1;n>=0;n--){let a=o[n];if(a instanceof HTMLElement&&(this.attemptFocus(a)||await this.focusLastDescendant(a)))return!0}return!1}async updateCompleteIfNecessary(e){e instanceof Q&&await e.updateComplete}isInsideElement(e,o){for(let n=e;n;n=n.parentNode){if(n===o)return!0;n instanceof ShadowRoot?n=n.host:n.assignedSlot&&(n=n.assignedSlot)}return!1}attemptFocus(e){return e===this.firstTrap||e===this.lastTrap||!this.isFocusable(e)?!1:(e.focus(),!0)}isFocusable(e){return!e.checkVisibility()||this.isElementDisabled(e)?!1:e instanceof HTMLAnchorElement?!!e.href&&e.rel!=="ignore":e instanceof HTMLInputElement?e.type!=="hidden":e.tabIndex>=0}isElementDisabled(e){return"disabled"in e&&!!e.disabled}},Lb=q(Cn);var ks;(function(t){t.sm="sm",t.md="md",t.lg="lg",t.xl="xl"})(ks||(ks={}));var Zd={sm:640,md:768,lg:1024,xl:1280},An=class extends gt{constructor(e){super(e),this.size=0,this.onResize=()=>{let o=window.innerWidth;this.size!==o&&(this.size=o,this.lastArgs&&this.setValue(this.render(...this.lastArgs)))},this.size=window.innerWidth,window.addEventListener("resize",this.onResize)}disconnected(){window.removeEventListener("resize",this.onResize)}reconnected(){window.addEventListener("resize",this.onResize)}update(e,[o,n,a]){return this.lastArgs=[o,n,a],this.render(o,n,a)}render(e,o,n){let a=this.resolveThreshold(e),i=n??(()=>B);return this.size>a?o():i()}resolveThreshold(e){return typeof e=="number"?e:Zd[e]}},Fb=q(An);var wn,Rn,Tn,In,qd=navigator.vendor&&!!navigator.vendor.match(/apple/i)||((Tn=(Rn=(wn=window.safari)===null||wn===void 0?void 0:wn.pushNotification)===null||Rn===void 0?void 0:Rn.toString())!==null&&Tn!==void 0?Tn:"")==="[object SafariRemoteNotification]",Yd="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;window.ftGlobals=(In=window.ftGlobals)!==null&&In!==void 0?In:{lit:Nr,litDecorators:Dr,litRepeat:Fr,litClassMap:Mr,litStyleMap:Ur,litUnsafeHTML:Br,wcUtils:{...qr,...$r,...eo,...gn,...to,...oo,...so,...Kr,...Oo,...Sn,...Is,...un,...Eo,...io,...Io,...yn,...Ro,...On,...ii,...Gr,...Po,...co,...Lo,..._s,...ci,...No,...cn,...xn,...Co,...wo,...pn,...Xr,isSafari:qd,isTouchScreen:Yd,setVariable:Qe}};})();
|
|
86
86
|
/*! Bundled license information:
|
|
87
87
|
|
|
88
88
|
@webcomponents/scoped-custom-element-registry/src/scoped-custom-element-registry.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-wc-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.24",
|
|
4
4
|
"description": "Internal web components tools",
|
|
5
5
|
"author": "Fluid Topics <devtopics@antidot.net>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/mark.js": "8.11.12"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "5407e83b63be10ccc5bdeb3551c9f798b9559ae0"
|
|
30
30
|
}
|