darkify-js 1.1.13-beta.1 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/darkify.d.ts +1 -3
- package/dist/darkify.esm.js +1 -1
- package/dist/darkify.umd.js +1 -1
- package/dist/plugins/index.d.ts +17 -15
- package/dist/plugins/index.esm.js +162 -255
- package/dist/plugins/index.umd.js +1 -181
- package/package.json +7 -10
package/dist/darkify.d.ts
CHANGED
package/dist/darkify.esm.js
CHANGED
package/dist/darkify.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @author Emilio Romero <emrocode@gmail.com>
|
|
4
|
-
* @version 1.1.13
|
|
4
|
+
* @version 1.1.13
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
7
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Darkify=t()}(this,function(){"use strict";class e{constructor(){this.listeners=[]}addListener(e,t,s,i){e.addEventListener(t,s,i),this.listeners.push({target:e,event:t,handler:s,options:i})}clearListeners(){this.listeners.forEach(({target:e,event:t,handler:s,options:i})=>{e.removeEventListener(t,s,i)}),this.listeners=[]}}const t={autoMatchTheme:!0,useColorScheme:["#ffffff","#000000"],useStorage:"local"},s="undefined"!=typeof window;class i{constructor(i,n){if(this.options=t,this.plugins=[],this.theme="light",!s)return;this._elm=new e;const o="string"==typeof i?i:void 0,h=i&&"object"==typeof i?i:n,r=Object.assign(Object.assign({},t),h);this.options=r,this.theme=this.getOsPreference(),this._style=document.createElement("style"),this._meta=document.createElement("meta"),this.createAttribute(),this.init(o),this.syncThemeBetweenTabs()}init(e){this._elm.addListener(window.matchMedia("(prefers-color-scheme: dark)"),"change",({matches:e})=>{this.theme=e?"dark":"light",this.createAttribute()});const t=()=>{this.initPlugins();const t=this.plugins.some(e=>void 0!==e.el);if(e&&!t){const t=document.querySelector(e);t&&this._elm.addListener(t,"click",()=>this.toggleTheme())}};if("loading"!==document.readyState)return t();this._elm.addListener(document,"DOMContentLoaded",t)}initPlugins(){var e;null===(e=this.options.usePlugins)||void 0===e||e.forEach(e=>{const[t,s]=Array.isArray(e)?e:[e,void 0],i=new t(this,s),n=i.render();n&&(i.el=n),this.plugins.push(i)})}notifyPlugins(e){this.plugins.forEach(t=>{var s;null===(s=t.onThemeChange)||void 0===s||s.call(t,e)})}getStorage(){const{useStorage:e}=this.options;if("none"!==e)return"local"===e?window.localStorage:window.sessionStorage}getOsPreference(){const e=this.getStorage();if(e){const t=e.getItem(i.storageKey);if(t)return t}return this.options.autoMatchTheme&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}createAttribute(){const e=document.documentElement,{useColorScheme:t}=this.options,s=`/**! Darkify / A simple dark mode toggle library **/\n:root:where([data-theme="${this.theme}"]),[data-theme="${this.theme}"]{color-scheme:${this.theme}}`;e.dataset.theme=this.theme,this.updateTags(s,t),this.savePreference()}updateTags(e,t){const[s,i]=t;this._meta.name="theme-color",this._meta.media=`(prefers-color-scheme: ${this.theme})`,this._meta.content="light"===this.theme?s:null!=i?i:s,this._style.innerHTML=e;const n=document.head;this._meta.parentNode||n.appendChild(this._meta),this._style.parentNode||n.appendChild(this._style)}savePreference(){const{useStorage:e}=this.options;if("none"===e)return;const t="local"===e,s=t?window.localStorage:window.sessionStorage;(t?window.sessionStorage:window.localStorage).removeItem(i.storageKey),s.setItem(i.storageKey,this.theme)}syncThemeBetweenTabs(){this._elm.addListener(window,"storage",e=>{e.key===i.storageKey&&e.newValue&&(this.theme=e.newValue,this.createAttribute(),this.notifyPlugins(e.newValue))})}setTheme(e){this.theme=e,this.createAttribute(),this.notifyPlugins(e)}toggleTheme(){this.setTheme("light"===this.theme?"dark":"light")}getCurrentTheme(){return this.theme}destroy(){var e,t,s,i;this._elm.clearListeners(),null===(t=null===(e=this._style)||void 0===e?void 0:e.parentNode)||void 0===t||t.removeChild(this._style),null===(i=null===(s=this._meta)||void 0===s?void 0:s.parentNode)||void 0===i||i.removeChild(this._meta),this.plugins.length>0&&(this.plugins.forEach(e=>{var t;null===(t=e.onDestroy)||void 0===t||t.call(e)}),this.plugins=[])}}return i.storageKey="theme",i});
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import * as lit_html from 'lit-html';
|
|
2
|
-
import * as lit from 'lit';
|
|
3
|
-
import { LitElement } from 'lit';
|
|
4
1
|
import { DarkifyPlugin } from '../darkify';
|
|
5
2
|
|
|
6
3
|
interface ThemeWidgetOptions {
|
|
7
|
-
position
|
|
8
|
-
size
|
|
4
|
+
position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
5
|
+
size: 'small' | 'medium' | 'large';
|
|
9
6
|
shortcut?: string;
|
|
10
7
|
}
|
|
11
|
-
declare class ThemeWidgetElement extends
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
|
|
8
|
+
declare class ThemeWidgetElement extends HTMLElement {
|
|
9
|
+
private _host;
|
|
10
|
+
private _theme;
|
|
11
|
+
private _initialized;
|
|
12
|
+
private _wrapper;
|
|
13
|
+
private _button;
|
|
14
|
+
private _span;
|
|
15
|
+
options: ThemeWidgetOptions;
|
|
16
|
+
private static _styles;
|
|
17
|
+
static get observedAttributes(): string[];
|
|
18
|
+
constructor();
|
|
18
19
|
init(host: any, options: Required<ThemeWidgetOptions>): void;
|
|
19
|
-
|
|
20
|
-
private _handleToggle;
|
|
20
|
+
connectedCallback(): void;
|
|
21
21
|
disconnectedCallback(): void;
|
|
22
|
-
|
|
22
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
23
|
+
onThemeChange(theme: string): void;
|
|
24
|
+
render(): void;
|
|
23
25
|
}
|
|
24
26
|
declare global {
|
|
25
27
|
interface HTMLElementTagNameMap {
|
|
@@ -1,271 +1,178 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function __decorate(decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
26
|
-
var e = new Error(message);
|
|
27
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @license
|
|
32
|
-
* Copyright 2019 Google LLC
|
|
33
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
-
*/
|
|
35
|
-
const t$2=globalThis,e$2=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$4=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$2&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$4.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$4.set(s,t));}return t}toString(){return this.cssText}};const r$4=t=>new n$3("string"==typeof t?t:t+"",void 0,s$2),i$3=(t,...e)=>{const o=1===t.length?t[0]:e.reduce((e,s,o)=>e+(t=>{if(true===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1],t[0]);return new n$3(o,t,s$2)},S$1=(s,o)=>{if(e$2)s.adoptedStyleSheets=o.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$2?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$4(e)})(t):t;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @license
|
|
39
|
-
* Copyright 2017 Google LLC
|
|
40
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
41
|
-
*/const{is:i$2,defineProperty:e$1,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$3,getOwnPropertySymbols:o$3,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$2(t,s),b$1={attribute:true,type:String,converter:u$1,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let y$1 = class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b$1){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$1(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$3(t),...o$3(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach(t=>t.hostConnected?.());}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.());}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i,e=false,h){if(void 0!==t){const r=this.constructor;if(false===e&&(h=this[t]),i??=r.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM();}updated(t){}firstUpdated(t){}};y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y$1}),(a$1.reactiveElementVersions??=[]).push("2.1.2");
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @license
|
|
45
|
-
* Copyright 2017 Google LLC
|
|
46
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/
|
|
48
|
-
const t$1=globalThis,i$1=t=>t,s$1=t$1.trustedTypes,e=s$1?s$1.createPolicy("lit-html",{createHTML:t=>t}):void 0,h="$lit$",o$2=`lit$${Math.random().toFixed(9).slice(2)}$`,n$1="?"+o$2,r$2=`<${n$1}>`,l=document,c=()=>l.createComment(""),a=t=>null===t||"object"!=typeof t&&"function"!=typeof t,u=Array.isArray,d=t=>u(t)||"function"==typeof t?.[Symbol.iterator],f="[ \t\n\f\r]",v=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,_=/-->/g,m=/>/g,p=RegExp(`>|${f}(?:([^\\s"'>=/]+)(${f}*=${f}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),g=/'/g,$=/"/g,y=/^(?:script|style|textarea|title)$/i,x=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),b=x(1),E=Symbol.for("lit-noChange"),A=Symbol.for("lit-nothing"),C=new WeakMap,P=l.createTreeWalker(l,129);function V(t,i){if(!u(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==e?e.createHTML(i):i}const N=(t,i)=>{const s=t.length-1,e=[];let n,l=2===i?"<svg>":3===i?"<math>":"",c=v;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,f=0;for(;f<s.length&&(c.lastIndex=f,u=c.exec(s),null!==u);)f=c.lastIndex,c===v?"!--"===u[1]?c=_:void 0!==u[1]?c=m:void 0!==u[2]?(y.test(u[2])&&(n=RegExp("</"+u[2],"g")),c=p):void 0!==u[3]&&(c=p):c===p?">"===u[0]?(c=n??v,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?p:'"'===u[3]?$:g):c===$||c===g?c=p:c===_||c===m?c=v:(c=p,n=void 0);const x=c===p&&t[i+1].startsWith("/>")?" ":"";l+=c===v?s+r$2:d>=0?(e.push(a),s.slice(0,d)+h+s.slice(d)+o$2+x):s+o$2+(-2===d?i:x);}return [V(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),e]};class S{constructor({strings:t,_$litType$:i},e){let r;this.parts=[];let l=0,a=0;const u=t.length-1,d=this.parts,[f,v]=N(t,i);if(this.el=S.createElement(f,e),P.currentNode=this.el.content,2===i||3===i){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=P.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(h)){const i=v[a++],s=r.getAttribute(t).split(o$2),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:l,name:e[2],strings:s,ctor:"."===e[1]?I:"?"===e[1]?L:"@"===e[1]?z:H}),r.removeAttribute(t);}else t.startsWith(o$2)&&(d.push({type:6,index:l}),r.removeAttribute(t));if(y.test(r.tagName)){const t=r.textContent.split(o$2),i=t.length-1;if(i>0){r.textContent=s$1?s$1.emptyScript:"";for(let s=0;s<i;s++)r.append(t[s],c()),P.nextNode(),d.push({type:2,index:++l});r.append(t[i],c());}}}else if(8===r.nodeType)if(r.data===n$1)d.push({type:2,index:l});else {let t=-1;for(;-1!==(t=r.data.indexOf(o$2,t+1));)d.push({type:7,index:l}),t+=o$2.length-1;}l++;}}static createElement(t,i){const s=l.createElement("template");return s.innerHTML=t,s}}function M(t,i,s=t,e){if(i===E)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=a(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=M(t,h._$AS(t,i.values),h,e)),i}class R{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??l).importNode(i,true);P.currentNode=e;let h=P.nextNode(),o=0,n=0,r=s[0];for(;void 0!==r;){if(o===r.index){let i;2===r.type?i=new k(h,h.nextSibling,this,t):1===r.type?i=new r.ctor(h,r.name,r.strings,this,t):6===r.type&&(i=new Z(h,this,t)),this._$AV.push(i),r=s[++n];}o!==r?.index&&(h=P.nextNode(),o++);}return P.currentNode=l,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class k{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=A,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=M(this,t,i),a(t)?t===A||null==t||""===t?(this._$AH!==A&&this._$AR(),this._$AH=A):t!==this._$AH&&t!==E&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):d(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==A&&a(this._$AH)?this._$AA.nextSibling.data=t:this.T(l.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=S.createElement(V(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new R(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=C.get(t.strings);return void 0===i&&C.set(t.strings,i=new S(t)),i}k(t){u(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new k(this.O(c()),this.O(c()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(false,true,s);t!==this._$AB;){const s=i$1(t).nextSibling;i$1(t).remove(),t=s;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class H{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=A,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=A;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=M(this,t,i,0),o=!a(t)||t!==this._$AH&&t!==E,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=M(this,e[s+n],i,n),r===E&&(r=this._$AH[n]),o||=!a(r)||r!==this._$AH[n],r===A?t=A:t!==A&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===A?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class I extends H{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===A?void 0:t;}}class L extends H{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==A);}}class z extends H{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=M(this,t,i,0)??A)===E)return;const s=this._$AH,e=t===A&&s!==A||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==A&&(s===A||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class Z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){M(this,t);}}const B=t$1.litHtmlPolyfillSupport;B?.(S,k),(t$1.litHtmlVersions??=[]).push("3.3.2");const D=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new k(i.insertBefore(c(),t),t,void 0,s??{});}return h._$AI(t),h};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @license
|
|
52
|
-
* Copyright 2017 Google LLC
|
|
53
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
54
|
-
*/const s=globalThis;class i extends y$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=D(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(false);}render(){return E}}i._$litElement$=true,i["finalized"]=true,s.litElementHydrateSupport?.({LitElement:i});const o$1=s.litElementPolyfillSupport;o$1?.({LitElement:i});(s.litElementVersions??=[]).push("4.2.2");
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @license
|
|
58
|
-
* Copyright 2017 Google LLC
|
|
59
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
60
|
-
*/
|
|
61
|
-
const t=t=>(e,o)=>{ void 0!==o?o.addInitializer(()=>{customElements.define(t,e);}):customElements.define(t,e);};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @license
|
|
65
|
-
* Copyright 2017 Google LLC
|
|
66
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
67
|
-
*/const o={attribute:true,type:String,converter:u$1,reflect:false,hasChanged:f$1},r$1=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=true),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t,true,r);},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t,true,r);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @license
|
|
71
|
-
* Copyright 2017 Google LLC
|
|
72
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
73
|
-
*/function r(r){return n({...r,state:true,attribute:false})}
|
|
74
|
-
|
|
75
1
|
const pluginId = 'd-widget';
|
|
76
|
-
|
|
2
|
+
class ThemeWidgetElement extends HTMLElement {
|
|
3
|
+
static get observedAttributes() {
|
|
4
|
+
return ['position', 'size'];
|
|
5
|
+
}
|
|
77
6
|
constructor() {
|
|
78
|
-
super(
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
81
|
-
|
|
82
|
-
|
|
7
|
+
super();
|
|
8
|
+
this._initialized = false;
|
|
9
|
+
const shadow = this.attachShadow({ mode: 'open' });
|
|
10
|
+
const style = document.createElement('style');
|
|
11
|
+
style.textContent = ThemeWidgetElement._styles;
|
|
12
|
+
shadow.appendChild(style);
|
|
83
13
|
}
|
|
84
14
|
init(host, options) {
|
|
85
15
|
this._host = host;
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
onThemeChange(theme) {
|
|
92
|
-
this.theme = theme;
|
|
16
|
+
this._theme = host.getCurrentTheme();
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.setAttribute('position', this.options.position);
|
|
19
|
+
this.setAttribute('size', this.options.size);
|
|
20
|
+
this.render();
|
|
93
21
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
(_a = this._host) === null || _a === void 0 ? void 0 : _a.toggleTheme();
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
this.render();
|
|
97
24
|
}
|
|
98
25
|
disconnectedCallback() {
|
|
99
|
-
super.disconnectedCallback();
|
|
100
26
|
this._host._elm.clearListeners();
|
|
101
27
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const button = b `
|
|
107
|
-
<button
|
|
108
|
-
class="d-button"
|
|
109
|
-
aria-label="Toggle theme"
|
|
110
|
-
role="switch"
|
|
111
|
-
aria-checked=${this.theme === 'dark'}
|
|
112
|
-
@click=${this._handleToggle}
|
|
113
|
-
data-theme=${this.theme}>
|
|
114
|
-
<span class="d-icon">${iconContent}</span>
|
|
115
|
-
</button>
|
|
116
|
-
`;
|
|
117
|
-
const kbd = this.shortcut ? b `<kbd class="d-kbd">${this.shortcut}</kbd>` : A;
|
|
118
|
-
return b `
|
|
119
|
-
<div class="d-wrapper">${isLeftPosition ? b `${button}${kbd}` : b `${kbd}${button}`}</div>
|
|
120
|
-
`;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
ThemeWidgetElement.styles = i$3 `
|
|
124
|
-
:host {
|
|
125
|
-
--widget-safe-top: env(safe-area-inset-top, 0px);
|
|
126
|
-
--widget-safe-right: env(safe-area-inset-right, 0px);
|
|
127
|
-
--widget-safe-bottom: env(safe-area-inset-bottom, 0px);
|
|
128
|
-
--widget-safe-left: env(safe-area-inset-left, 0px);
|
|
129
|
-
|
|
130
|
-
--margin: 24px;
|
|
131
|
-
--top: var(--margin);
|
|
132
|
-
--right: var(--margin);
|
|
133
|
-
--bottom: auto;
|
|
134
|
-
--left: auto;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
:host([position='top-left']) {
|
|
138
|
-
--top: var(--margin);
|
|
139
|
-
--right: auto;
|
|
140
|
-
--bottom: auto;
|
|
141
|
-
--left: var(--margin);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
:host([position='top-right']) {
|
|
145
|
-
--top: var(--margin);
|
|
146
|
-
--right: var(--margin);
|
|
147
|
-
--bottom: auto;
|
|
148
|
-
--left: auto;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
:host([position='bottom-left']) {
|
|
152
|
-
--top: auto;
|
|
153
|
-
--right: auto;
|
|
154
|
-
--bottom: calc(var(--margin) * 2);
|
|
155
|
-
--left: var(--margin);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
:host([position='bottom-right']) {
|
|
159
|
-
--top: auto;
|
|
160
|
-
--right: var(--margin);
|
|
161
|
-
--bottom: calc(var(--margin) * 2);
|
|
162
|
-
--left: auto;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
:host([size='small']) {
|
|
166
|
-
--size: 36px;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
:host([size='medium']) {
|
|
170
|
-
--size: 56px;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
:host([size='large']) {
|
|
174
|
-
--size: 72px;
|
|
28
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
29
|
+
if (oldValue !== newValue && (name === 'position' || name === 'size')) {
|
|
30
|
+
this.render();
|
|
31
|
+
}
|
|
175
32
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
top: calc(var(--top) + var(--widget-safe-top));
|
|
180
|
-
right: calc(var(--right) + var(--widget-safe-right));
|
|
181
|
-
bottom: calc(var(--bottom) + var(--widget-safe-bottom));
|
|
182
|
-
left: calc(var(--left) + var(--widget-safe-left));
|
|
183
|
-
z-index: 9999;
|
|
184
|
-
max-width: fit-content;
|
|
185
|
-
display: flex;
|
|
186
|
-
align-items: center;
|
|
187
|
-
column-gap: 0.5rem;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.d-button {
|
|
191
|
-
--icon-size: calc(var(--size) * 0.4);
|
|
192
|
-
|
|
193
|
-
position: relative;
|
|
194
|
-
width: var(--size);
|
|
195
|
-
height: var(--size);
|
|
196
|
-
border: none;
|
|
197
|
-
border-bottom: 2px solid hsl(from canvastext h s l / calc(alpha * 0.5));
|
|
198
|
-
border-radius: 50%;
|
|
199
|
-
box-shadow:
|
|
200
|
-
0 1px 3px 0 hsla(210, 6%, 25%, 0.3),
|
|
201
|
-
0 4px 8px 3px hsla(210, 6%, 25%, 0.3);
|
|
202
|
-
background-color: transparent;
|
|
203
|
-
color: canvastext;
|
|
204
|
-
cursor: pointer;
|
|
205
|
-
font-size: var(--icon-size);
|
|
206
|
-
display: flex;
|
|
207
|
-
flex-direction: column;
|
|
208
|
-
align-items: center;
|
|
209
|
-
justify-content: center;
|
|
210
|
-
overflow: hidden;
|
|
211
|
-
user-select: none;
|
|
212
|
-
-webkit-user-select: none;
|
|
213
|
-
-webkit-tap-highlight-color: transparent;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.d-button::before {
|
|
217
|
-
content: '';
|
|
218
|
-
position: absolute;
|
|
219
|
-
inset: 0;
|
|
220
|
-
z-index: -1;
|
|
221
|
-
border: none;
|
|
222
|
-
background-color: canvas;
|
|
223
|
-
filter: invert(90%);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.d-button:focus-visible {
|
|
227
|
-
outline: 2px solid currentcolor;
|
|
228
|
-
outline-offset: 2px;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
.d-button:active {
|
|
232
|
-
transform: scale(0.98);
|
|
233
|
-
transition: transform 0.4s ease-in-out;
|
|
33
|
+
onThemeChange(theme) {
|
|
34
|
+
this._theme = theme;
|
|
35
|
+
this.render();
|
|
234
36
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
37
|
+
render() {
|
|
38
|
+
const icon = this._theme === 'light' ? '🌞' : '🌚';
|
|
39
|
+
if (!this._initialized) {
|
|
40
|
+
this._wrapper = document.createElement('div');
|
|
41
|
+
this._wrapper.className = 'd-wrapper';
|
|
42
|
+
this._button = document.createElement('button');
|
|
43
|
+
this._button.className = 'd-button';
|
|
44
|
+
this._button.setAttribute('aria-label', 'Toggle theme');
|
|
45
|
+
this._host._elm.addListener(this._button, 'click', () => this._host.toggleTheme());
|
|
46
|
+
this._span = document.createElement('span');
|
|
47
|
+
this._span.className = 'd-icon';
|
|
48
|
+
this._button.appendChild(this._span);
|
|
49
|
+
if (this.options.shortcut) {
|
|
50
|
+
const kbd = document.createElement('kbd');
|
|
51
|
+
kbd.className = 'd-kbd';
|
|
52
|
+
kbd.textContent = this.options.shortcut;
|
|
53
|
+
this.options.position.includes('left')
|
|
54
|
+
? this._wrapper.append(this._button, kbd)
|
|
55
|
+
: this._wrapper.append(kbd, this._button);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this._wrapper.appendChild(this._button);
|
|
59
|
+
}
|
|
60
|
+
this.shadowRoot.appendChild(this._wrapper);
|
|
61
|
+
this._initialized = true;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._span.textContent = icon;
|
|
252
65
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
66
|
+
}
|
|
67
|
+
ThemeWidgetElement._styles = `
|
|
68
|
+
:host {
|
|
69
|
+
--widget-safe-top: env(safe-area-inset-top, 0px);
|
|
70
|
+
--widget-safe-right: env(safe-area-inset-right, 0px);
|
|
71
|
+
--widget-safe-bottom: env(safe-area-inset-bottom, 0px);
|
|
72
|
+
--widget-safe-left: env(safe-area-inset-left, 0px);
|
|
73
|
+
--margin: 24px;
|
|
74
|
+
--top: var(--margin);
|
|
75
|
+
--right: var(--margin);
|
|
76
|
+
--bottom: auto;
|
|
77
|
+
--left: auto;
|
|
78
|
+
}
|
|
79
|
+
:host([position='top-left']) {
|
|
80
|
+
--top: var(--margin);
|
|
81
|
+
--right: auto;
|
|
82
|
+
--bottom: auto;
|
|
83
|
+
--left: var(--margin);
|
|
84
|
+
}
|
|
85
|
+
:host([position='top-right']) {
|
|
86
|
+
--top: var(--margin);
|
|
87
|
+
--right: var(--margin);
|
|
88
|
+
--bottom: auto;
|
|
89
|
+
--left: auto;
|
|
90
|
+
}
|
|
91
|
+
:host([position='bottom-left']) {
|
|
92
|
+
--top: auto;
|
|
93
|
+
--right: auto;
|
|
94
|
+
--bottom: calc(var(--margin) * 2);
|
|
95
|
+
--left: var(--margin);
|
|
96
|
+
}
|
|
97
|
+
:host([position='bottom-right']) {
|
|
98
|
+
--top: auto;
|
|
99
|
+
--right: var(--margin);
|
|
100
|
+
--bottom: calc(var(--margin) * 2);
|
|
101
|
+
--left: auto;
|
|
102
|
+
}
|
|
103
|
+
:host([size='small']) { --size: 36px; }
|
|
104
|
+
:host([size='medium']) { --size: 56px; }
|
|
105
|
+
:host([size='large']) { --size: 72px; }
|
|
106
|
+
.d-wrapper {
|
|
107
|
+
position: fixed;
|
|
108
|
+
top: calc(var(--top) + var(--widget-safe-top));
|
|
109
|
+
right: calc(var(--right) + var(--widget-safe-right));
|
|
110
|
+
bottom: calc(var(--bottom) + var(--widget-safe-bottom));
|
|
111
|
+
left: calc(var(--left) + var(--widget-safe-left));
|
|
112
|
+
z-index: 9999;
|
|
113
|
+
max-width: fit-content;
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
column-gap: 0.5rem;
|
|
117
|
+
}
|
|
118
|
+
.d-button {
|
|
119
|
+
--icon-size: calc(var(--size) * 0.4);
|
|
120
|
+
position: relative;
|
|
121
|
+
width: var(--size);
|
|
122
|
+
height: var(--size);
|
|
123
|
+
border: none;
|
|
124
|
+
border-bottom: 1px solid hsl(from canvastext h s l / calc(alpha * 0.5));
|
|
125
|
+
border-radius: 50%;
|
|
126
|
+
box-shadow: 0 1px 3px 0 hsla(210, 6%, 25%, 0.3), 0 4px 8px 3px hsla(210, 6%, 25%, 0.3);
|
|
127
|
+
background-color: transparent;
|
|
128
|
+
color: canvastext;
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
font-size: var(--icon-size);
|
|
131
|
+
display: flex;
|
|
132
|
+
flex-direction: column;
|
|
133
|
+
align-items: center;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
user-select: none;
|
|
137
|
+
-webkit-user-select: none;
|
|
138
|
+
-webkit-tap-highlight-color: transparent;
|
|
139
|
+
}
|
|
140
|
+
.d-button::before {
|
|
141
|
+
content: '';
|
|
142
|
+
position: absolute;
|
|
143
|
+
inset: 0;
|
|
144
|
+
z-index: -1;
|
|
145
|
+
border: none;
|
|
146
|
+
background-color: canvas;
|
|
147
|
+
filter: invert(90%);
|
|
148
|
+
}
|
|
149
|
+
.d-button:focus-visible {
|
|
150
|
+
outline: 2px solid currentcolor;
|
|
151
|
+
outline-offset: 2px;
|
|
152
|
+
}
|
|
153
|
+
.d-button:active {
|
|
154
|
+
transform: scale(0.98);
|
|
155
|
+
transition: transform 0.4s ease-in-out;
|
|
156
|
+
}
|
|
157
|
+
.d-kbd {
|
|
158
|
+
position: relative;
|
|
159
|
+
padding: 0.25em 0.4em;
|
|
160
|
+
font-size: 11px;
|
|
161
|
+
font-family: ui-monospace, monospace;
|
|
162
|
+
line-height: 1;
|
|
163
|
+
letter-spacing: -0.025em;
|
|
164
|
+
background-color: canvas;
|
|
165
|
+
color: canvastext;
|
|
166
|
+
filter: invert(90%);
|
|
167
|
+
border: none;
|
|
168
|
+
border-bottom: 1px solid hsl(from canvastext h s l / calc(alpha * 0.5));
|
|
169
|
+
border-radius: 0.25rem;
|
|
170
|
+
box-shadow: 0 0 2px hsla(0, 0%, 0%, 0.1);
|
|
171
|
+
user-select: none;
|
|
172
|
+
-webkit-user-select: none;
|
|
173
|
+
}
|
|
174
|
+
`;
|
|
175
|
+
customElements.define(pluginId, ThemeWidgetElement);
|
|
269
176
|
|
|
270
177
|
class ThemeWidget {
|
|
271
178
|
constructor(host, options) {
|
|
@@ -1,181 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).DarkifyPlugins={})}(this,function(t){"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright 2019 Google LLC
|
|
5
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/
|
|
7
|
-
const s=globalThis,i=s.ShadowRoot&&(void 0===s.ShadyCSS||s.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,o=Symbol(),r=new WeakMap;let n=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==o)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(i&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=r.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&r.set(e,t))}return t}toString(){return this.cssText}};const h=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,o))(e)})(t):t,{is:a,defineProperty:l,getOwnPropertyDescriptor:c,getOwnPropertyNames:d,getOwnPropertySymbols:p,getPrototypeOf:u}=Object,f=globalThis,g=f.trustedTypes,$=g?g.emptyScript:"",m=f.reactiveElementPolyfillSupport,_=(t,e)=>t,v={toAttribute(t,e){switch(e){case Boolean:t=t?$:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},y=(t,e)=>!a(t,e),b={attribute:!0,type:String,converter:v,reflect:!1,useDefault:!1,hasChanged:y};
|
|
8
|
-
/**
|
|
9
|
-
* @license
|
|
10
|
-
* Copyright 2017 Google LLC
|
|
11
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
-
*/Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;let A=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=b){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&l(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:o}=c(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const r=i?.call(this);o?.call(this,e),this.requestUpdate(t,r,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(_("elementProperties")))return;const t=u(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(_("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(_("properties"))){const t=this.properties,e=[...d(t),...p(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(h(t))}else void 0!==t&&e.push(h(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(i)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),o=s.litNonce;void 0!==o&&e.setAttribute("nonce",o),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const o=(void 0!==s.converter?.toAttribute?s.converter:v).toAttribute(e,s.type);this._$Em=t,null==o?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:v;this._$Em=i;const r=o.fromAttribute(e,t.type);this[i]=r??this._$Ej?.get(i)??r,this._$Em=null}}requestUpdate(t,e,s,i=!1,o){if(void 0!==t){const r=this.constructor;if(!1===i&&(o=this[t]),s??=r.getPropertyOptions(t),!((s.hasChanged??y)(o,e)||s.useDefault&&s.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:o},r){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??e??this[t]),!0!==o||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};A.elementStyles=[],A.shadowRootOptions={mode:"open"},A[_("elementProperties")]=new Map,A[_("finalized")]=new Map,m?.({ReactiveElement:A}),(f.reactiveElementVersions??=[]).push("2.1.2");
|
|
13
|
-
/**
|
|
14
|
-
* @license
|
|
15
|
-
* Copyright 2017 Google LLC
|
|
16
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
-
*/
|
|
18
|
-
const w=globalThis,E=t=>t,S=w.trustedTypes,x=S?S.createPolicy("lit-html",{createHTML:t=>t}):void 0,C="$lit$",P=`lit$${Math.random().toFixed(9).slice(2)}$`,T="?"+P,U=`<${T}>`,O=document,k=()=>O.createComment(""),z=t=>null===t||"object"!=typeof t&&"function"!=typeof t,M=Array.isArray,H="[ \t\n\f\r]",N=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,R=/-->/g,D=/>/g,j=RegExp(`>|${H}(?:([^\\s"'>=/]+)(${H}*=${H}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),L=/'/g,I=/"/g,B=/^(?:script|style|textarea|title)$/i,K=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),W=Symbol.for("lit-noChange"),q=Symbol.for("lit-nothing"),V=new WeakMap,J=O.createTreeWalker(O,129);function Z(t,e){if(!M(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==x?x.createHTML(e):e}const F=(t,e)=>{const s=t.length-1,i=[];let o,r=2===e?"<svg>":3===e?"<math>":"",n=N;for(let e=0;e<s;e++){const s=t[e];let h,a,l=-1,c=0;for(;c<s.length&&(n.lastIndex=c,a=n.exec(s),null!==a);)c=n.lastIndex,n===N?"!--"===a[1]?n=R:void 0!==a[1]?n=D:void 0!==a[2]?(B.test(a[2])&&(o=RegExp("</"+a[2],"g")),n=j):void 0!==a[3]&&(n=j):n===j?">"===a[0]?(n=o??N,l=-1):void 0===a[1]?l=-2:(l=n.lastIndex-a[2].length,h=a[1],n=void 0===a[3]?j:'"'===a[3]?I:L):n===I||n===L?n=j:n===R||n===D?n=N:(n=j,o=void 0);const d=n===j&&t[e+1].startsWith("/>")?" ":"";r+=n===N?s+U:l>=0?(i.push(h),s.slice(0,l)+C+s.slice(l)+P+d):s+P+(-2===l?e:d)}return[Z(t,r+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class G{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let o=0,r=0;const n=t.length-1,h=this.parts,[a,l]=F(t,e);if(this.el=G.createElement(a,s),J.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=J.nextNode())&&h.length<n;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(C)){const e=l[r++],s=i.getAttribute(t).split(P),n=/([.?@])?(.*)/.exec(e);h.push({type:1,index:o,name:n[2],strings:s,ctor:"."===n[1]?et:"?"===n[1]?st:"@"===n[1]?it:tt}),i.removeAttribute(t)}else t.startsWith(P)&&(h.push({type:6,index:o}),i.removeAttribute(t));if(B.test(i.tagName)){const t=i.textContent.split(P),e=t.length-1;if(e>0){i.textContent=S?S.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],k()),J.nextNode(),h.push({type:2,index:++o});i.append(t[e],k())}}}else if(8===i.nodeType)if(i.data===T)h.push({type:2,index:o});else{let t=-1;for(;-1!==(t=i.data.indexOf(P,t+1));)h.push({type:7,index:o}),t+=P.length-1}o++}}static createElement(t,e){const s=O.createElement("template");return s.innerHTML=t,s}}function Q(t,e,s=t,i){if(e===W)return e;let o=void 0!==i?s._$Co?.[i]:s._$Cl;const r=z(e)?void 0:e._$litDirective$;return o?.constructor!==r&&(o?._$AO?.(!1),void 0===r?o=void 0:(o=new r(t),o._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=o:s._$Cl=o),void 0!==o&&(e=Q(t,o._$AS(t,e.values),o,i)),e}class X{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??O).importNode(e,!0);J.currentNode=i;let o=J.nextNode(),r=0,n=0,h=s[0];for(;void 0!==h;){if(r===h.index){let e;2===h.type?e=new Y(o,o.nextSibling,this,t):1===h.type?e=new h.ctor(o,h.name,h.strings,this,t):6===h.type&&(e=new ot(o,this,t)),this._$AV.push(e),h=s[++n]}r!==h?.index&&(o=J.nextNode(),r++)}return J.currentNode=O,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class Y{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=q,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Q(this,t,e),z(t)?t===q||null==t||""===t?(this._$AH!==q&&this._$AR(),this._$AH=q):t!==this._$AH&&t!==W&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>M(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==q&&z(this._$AH)?this._$AA.nextSibling.data=t:this.T(O.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=G.createElement(Z(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new X(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=V.get(t.strings);return void 0===e&&V.set(t.strings,e=new G(t)),e}k(t){M(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const o of t)i===e.length?e.push(s=new Y(this.O(k()),this.O(k()),this,this.options)):s=e[i],s._$AI(o),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=E(t).nextSibling;E(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,o){this.type=1,this._$AH=q,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=q}_$AI(t,e=this,s,i){const o=this.strings;let r=!1;if(void 0===o)t=Q(this,t,e,0),r=!z(t)||t!==this._$AH&&t!==W,r&&(this._$AH=t);else{const i=t;let n,h;for(t=o[0],n=0;n<o.length-1;n++)h=Q(this,i[s+n],e,n),h===W&&(h=this._$AH[n]),r||=!z(h)||h!==this._$AH[n],h===q?t=q:t!==q&&(t+=(h??"")+o[n+1]),this._$AH[n]=h}r&&!i&&this.j(t)}j(t){t===q?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class et extends tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===q?void 0:t}}class st extends tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==q)}}class it extends tt{constructor(t,e,s,i,o){super(t,e,s,i,o),this.type=5}_$AI(t,e=this){if((t=Q(this,t,e,0)??q)===W)return;const s=this._$AH,i=t===q&&s!==q||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==q&&(s===q||i);i&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class ot{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Q(this,t)}}const rt=w.litHtmlPolyfillSupport;rt?.(G,Y),(w.litHtmlVersions??=[]).push("3.3.2");const nt=globalThis;
|
|
19
|
-
/**
|
|
20
|
-
* @license
|
|
21
|
-
* Copyright 2017 Google LLC
|
|
22
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
-
*/class ht extends A{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,s)=>{const i=s?.renderBefore??e;let o=i._$litPart$;if(void 0===o){const t=s?.renderBefore??null;i._$litPart$=o=new Y(e.insertBefore(k(),t),t,void 0,s??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return W}}ht._$litElement$=!0,ht.finalized=!0,nt.litElementHydrateSupport?.({LitElement:ht});const at=nt.litElementPolyfillSupport;at?.({LitElement:ht}),(nt.litElementVersions??=[]).push("4.2.2");
|
|
24
|
-
/**
|
|
25
|
-
* @license
|
|
26
|
-
* Copyright 2017 Google LLC
|
|
27
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
-
*/
|
|
29
|
-
const lt={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:y},ct=(t=lt,e,s)=>{const{kind:i,metadata:o}=s;let r=globalThis.litPropertyMetadata.get(o);if(void 0===r&&globalThis.litPropertyMetadata.set(o,r=new Map),"setter"===i&&((t=Object.create(t)).wrapped=!0),r.set(s.name,t),"accessor"===i){const{name:i}=s;return{set(s){const o=e.get.call(this);e.set.call(this,s),this.requestUpdate(i,o,t,!0,s)},init(e){return void 0!==e&&this.C(i,void 0,t,e),e}}}if("setter"===i){const{name:i}=s;return function(s){const o=this[i];e.call(this,s),this.requestUpdate(i,o,t,!0,s)}}throw Error("Unsupported decorator location: "+i)};
|
|
30
|
-
/**
|
|
31
|
-
* @license
|
|
32
|
-
* Copyright 2017 Google LLC
|
|
33
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
-
*/function dt(t){return(e,s)=>"object"==typeof s?ct(t,e,s):((t,e,s)=>{const i=e.hasOwnProperty(s);return e.constructor.createProperty(s,t),i?Object.getOwnPropertyDescriptor(e,s):void 0})(t,e,s)}
|
|
35
|
-
/**
|
|
36
|
-
* @license
|
|
37
|
-
* Copyright 2017 Google LLC
|
|
38
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
39
|
-
*/const pt="d-widget";let ut=class extends ht{constructor(){super(...arguments),this.position="bottom-right",this.size="medium",this.shortcut="",this.theme="light"}init(t,e){this._host=t,this.position=e.position,this.size=e.size,this.shortcut=e.shortcut,this.theme=t.getCurrentTheme()}onThemeChange(t){this.theme=t}_handleToggle(){var t;null===(t=this._host)||void 0===t||t.toggleTheme()}disconnectedCallback(){super.disconnectedCallback(),this._host._elm.clearListeners()}render(){var t;const e=null===(t=this.position)||void 0===t?void 0:t.includes("left"),s="light"===this.theme?"🌞":"🌚",i=K`
|
|
40
|
-
<button
|
|
41
|
-
class="d-button"
|
|
42
|
-
aria-label="Toggle theme"
|
|
43
|
-
role="switch"
|
|
44
|
-
aria-checked=${"dark"===this.theme}
|
|
45
|
-
@click=${this._handleToggle}
|
|
46
|
-
data-theme=${this.theme}>
|
|
47
|
-
<span class="d-icon">${s}</span>
|
|
48
|
-
</button>
|
|
49
|
-
`,o=this.shortcut?K`<kbd class="d-kbd">${this.shortcut}</kbd>`:q;return K`
|
|
50
|
-
<div class="d-wrapper">${e?K`${i}${o}`:K`${o}${i}`}</div>
|
|
51
|
-
`}};ut.styles=((t,...e)=>{const s=1===t.length?t[0]:e.reduce((e,s,i)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[i+1],t[0]);return new n(s,t,o)})`
|
|
52
|
-
:host {
|
|
53
|
-
--widget-safe-top: env(safe-area-inset-top, 0px);
|
|
54
|
-
--widget-safe-right: env(safe-area-inset-right, 0px);
|
|
55
|
-
--widget-safe-bottom: env(safe-area-inset-bottom, 0px);
|
|
56
|
-
--widget-safe-left: env(safe-area-inset-left, 0px);
|
|
57
|
-
|
|
58
|
-
--margin: 24px;
|
|
59
|
-
--top: var(--margin);
|
|
60
|
-
--right: var(--margin);
|
|
61
|
-
--bottom: auto;
|
|
62
|
-
--left: auto;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
:host([position='top-left']) {
|
|
66
|
-
--top: var(--margin);
|
|
67
|
-
--right: auto;
|
|
68
|
-
--bottom: auto;
|
|
69
|
-
--left: var(--margin);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
:host([position='top-right']) {
|
|
73
|
-
--top: var(--margin);
|
|
74
|
-
--right: var(--margin);
|
|
75
|
-
--bottom: auto;
|
|
76
|
-
--left: auto;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
:host([position='bottom-left']) {
|
|
80
|
-
--top: auto;
|
|
81
|
-
--right: auto;
|
|
82
|
-
--bottom: calc(var(--margin) * 2);
|
|
83
|
-
--left: var(--margin);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
:host([position='bottom-right']) {
|
|
87
|
-
--top: auto;
|
|
88
|
-
--right: var(--margin);
|
|
89
|
-
--bottom: calc(var(--margin) * 2);
|
|
90
|
-
--left: auto;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
:host([size='small']) {
|
|
94
|
-
--size: 36px;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
:host([size='medium']) {
|
|
98
|
-
--size: 56px;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
:host([size='large']) {
|
|
102
|
-
--size: 72px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.d-wrapper {
|
|
106
|
-
position: fixed;
|
|
107
|
-
top: calc(var(--top) + var(--widget-safe-top));
|
|
108
|
-
right: calc(var(--right) + var(--widget-safe-right));
|
|
109
|
-
bottom: calc(var(--bottom) + var(--widget-safe-bottom));
|
|
110
|
-
left: calc(var(--left) + var(--widget-safe-left));
|
|
111
|
-
z-index: 9999;
|
|
112
|
-
max-width: fit-content;
|
|
113
|
-
display: flex;
|
|
114
|
-
align-items: center;
|
|
115
|
-
column-gap: 0.5rem;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.d-button {
|
|
119
|
-
--icon-size: calc(var(--size) * 0.4);
|
|
120
|
-
|
|
121
|
-
position: relative;
|
|
122
|
-
width: var(--size);
|
|
123
|
-
height: var(--size);
|
|
124
|
-
border: none;
|
|
125
|
-
border-bottom: 2px solid hsl(from canvastext h s l / calc(alpha * 0.5));
|
|
126
|
-
border-radius: 50%;
|
|
127
|
-
box-shadow:
|
|
128
|
-
0 1px 3px 0 hsla(210, 6%, 25%, 0.3),
|
|
129
|
-
0 4px 8px 3px hsla(210, 6%, 25%, 0.3);
|
|
130
|
-
background-color: transparent;
|
|
131
|
-
color: canvastext;
|
|
132
|
-
cursor: pointer;
|
|
133
|
-
font-size: var(--icon-size);
|
|
134
|
-
display: flex;
|
|
135
|
-
flex-direction: column;
|
|
136
|
-
align-items: center;
|
|
137
|
-
justify-content: center;
|
|
138
|
-
overflow: hidden;
|
|
139
|
-
user-select: none;
|
|
140
|
-
-webkit-user-select: none;
|
|
141
|
-
-webkit-tap-highlight-color: transparent;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.d-button::before {
|
|
145
|
-
content: '';
|
|
146
|
-
position: absolute;
|
|
147
|
-
inset: 0;
|
|
148
|
-
z-index: -1;
|
|
149
|
-
border: none;
|
|
150
|
-
background-color: canvas;
|
|
151
|
-
filter: invert(90%);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.d-button:focus-visible {
|
|
155
|
-
outline: 2px solid currentcolor;
|
|
156
|
-
outline-offset: 2px;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.d-button:active {
|
|
160
|
-
transform: scale(0.98);
|
|
161
|
-
transition: transform 0.4s ease-in-out;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.d-kbd {
|
|
165
|
-
position: relative;
|
|
166
|
-
padding: 0.25em 0.4em;
|
|
167
|
-
font-size: 11px;
|
|
168
|
-
font-family: ui-monospace, monospace;
|
|
169
|
-
line-height: 1;
|
|
170
|
-
letter-spacing: -0.025em;
|
|
171
|
-
background-color: canvas;
|
|
172
|
-
color: canvastext;
|
|
173
|
-
filter: invert(90%);
|
|
174
|
-
border: none;
|
|
175
|
-
border-bottom: 2px solid hsl(from canvastext h s l / calc(alpha * 0.5));
|
|
176
|
-
border-radius: 0.25rem;
|
|
177
|
-
box-shadow: 0 0 2px hsla(0, 0%, 0%, 0.1);
|
|
178
|
-
user-select: none;
|
|
179
|
-
-webkit-user-select: none;
|
|
180
|
-
}
|
|
181
|
-
`,e([dt({type:String,reflect:!0})],ut.prototype,"position",void 0),e([dt({type:String,reflect:!0})],ut.prototype,"size",void 0),e([dt({type:String,reflect:!0})],ut.prototype,"shortcut",void 0),e([function(t){return dt({...t,state:!0,attribute:!1})}()],ut.prototype,"theme",void 0),ut=e([(t=>(e,s)=>{void 0!==s?s.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)})(pt)],ut);class ft{constructor(t,e){var s,i,o;this.options={position:null!==(s=null==e?void 0:e.position)&&void 0!==s?s:"bottom-right",size:null!==(i=null==e?void 0:e.size)&&void 0!==i?i:"medium",shortcut:null!==(o=null==e?void 0:e.shortcut)&&void 0!==o?o:""},this.el=document.createElement(pt),this.el.init(t,this.options)}render(){return document.body.appendChild(this.el),this.el}onThemeChange(t){this.el.onThemeChange(t)}onDestroy(){this.el.remove()}}ft.pluginId=pt;class gt{constructor(t,e){var s,i,o,r,n;this._lastTriggered=0,this.handleKeyDown=t=>{if(("body"!==this.options.target||!this.isTyping(t))&&("input"!==this.options.target||this.isTyping(t))&&this.matches(t)){t.preventDefault();const e=Date.now();if(e-this._lastTriggered<this.options.cooldown)return;this._lastTriggered=e,this._host.toggleTheme()}},this._host=t,this.options={key:null!==(s=null==e?void 0:e.key)&&void 0!==s?s:"d",ctrl:null!==(i=null==e?void 0:e.ctrl)&&void 0!==i&&i,shift:null!==(o=null==e?void 0:e.shift)&&void 0!==o&&o,target:null!==(r=null==e?void 0:e.target)&&void 0!==r?r:"body",cooldown:null!==(n=null==e?void 0:e.cooldown)&&void 0!==n?n:300}}render(){document.addEventListener("keydown",this.handleKeyDown)}onDestroy(){document.removeEventListener("keydown",this.handleKeyDown)}matches(t){return t.key.toLowerCase()===this.options.key.toLowerCase()&&(!this.options.ctrl||t.ctrlKey||t.metaKey)&&(!this.options.shift||t.shiftKey)&&(this.options.ctrl||!t.ctrlKey&&!t.metaKey&&!t.altKey)}isTyping(t){const e=t.target,s=e.tagName.toLowerCase();return e.isContentEditable||"input"===s||"textarea"===s}}gt.pluginId="d-keyboard-shortcut",t.KeyboardShortcut=gt,t.ThemeWidget=ft});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).DarkifyPlugins={})}(this,function(t){"use strict";const e="d-widget";class n extends HTMLElement{static get observedAttributes(){return["position","size"]}constructor(){super(),this._initialized=!1;const t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=n._styles,t.appendChild(e)}init(t,e){this._host=t,this._theme=t.getCurrentTheme(),this.options=e,this.setAttribute("position",this.options.position),this.setAttribute("size",this.options.size),this.render()}connectedCallback(){this.render()}disconnectedCallback(){this._host._elm.clearListeners()}attributeChangedCallback(t,e,n){e===n||"position"!==t&&"size"!==t||this.render()}onThemeChange(t){this._theme=t,this.render()}render(){const t="light"===this._theme?"🌞":"🌚";if(!this._initialized){if(this._wrapper=document.createElement("div"),this._wrapper.className="d-wrapper",this._button=document.createElement("button"),this._button.className="d-button",this._button.setAttribute("aria-label","Toggle theme"),this._host._elm.addListener(this._button,"click",()=>this._host.toggleTheme()),this._span=document.createElement("span"),this._span.className="d-icon",this._button.appendChild(this._span),this.options.shortcut){const t=document.createElement("kbd");t.className="d-kbd",t.textContent=this.options.shortcut,this.options.position.includes("left")?this._wrapper.append(this._button,t):this._wrapper.append(t,this._button)}else this._wrapper.appendChild(this._button);return this.shadowRoot.appendChild(this._wrapper),void(this._initialized=!0)}this._span.textContent=t}}n._styles="\n:host {\n --widget-safe-top: env(safe-area-inset-top, 0px);\n --widget-safe-right: env(safe-area-inset-right, 0px);\n --widget-safe-bottom: env(safe-area-inset-bottom, 0px);\n --widget-safe-left: env(safe-area-inset-left, 0px);\n --margin: 24px;\n --top: var(--margin);\n --right: var(--margin);\n --bottom: auto;\n --left: auto;\n}\n:host([position='top-left']) {\n --top: var(--margin);\n --right: auto;\n --bottom: auto;\n --left: var(--margin);\n}\n:host([position='top-right']) {\n --top: var(--margin);\n --right: var(--margin);\n --bottom: auto;\n --left: auto;\n}\n:host([position='bottom-left']) {\n --top: auto;\n --right: auto;\n --bottom: calc(var(--margin) * 2);\n --left: var(--margin);\n}\n:host([position='bottom-right']) {\n --top: auto;\n --right: var(--margin);\n --bottom: calc(var(--margin) * 2);\n --left: auto;\n}\n:host([size='small']) { --size: 36px; }\n:host([size='medium']) { --size: 56px; }\n:host([size='large']) { --size: 72px; }\n.d-wrapper {\n position: fixed;\n top: calc(var(--top) + var(--widget-safe-top));\n right: calc(var(--right) + var(--widget-safe-right));\n bottom: calc(var(--bottom) + var(--widget-safe-bottom));\n left: calc(var(--left) + var(--widget-safe-left));\n z-index: 9999;\n max-width: fit-content;\n display: flex;\n align-items: center;\n column-gap: 0.5rem;\n}\n.d-button {\n --icon-size: calc(var(--size) * 0.4);\n position: relative;\n width: var(--size);\n height: var(--size);\n border: none;\n border-bottom: 1px solid hsl(from canvastext h s l / calc(alpha * 0.5));\n border-radius: 50%;\n box-shadow: 0 1px 3px 0 hsla(210, 6%, 25%, 0.3), 0 4px 8px 3px hsla(210, 6%, 25%, 0.3);\n background-color: transparent;\n color: canvastext;\n cursor: pointer;\n font-size: var(--icon-size);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n user-select: none;\n -webkit-user-select: none;\n -webkit-tap-highlight-color: transparent;\n}\n.d-button::before {\n content: '';\n position: absolute;\n inset: 0;\n z-index: -1;\n border: none;\n background-color: canvas;\n filter: invert(90%);\n}\n.d-button:focus-visible {\n outline: 2px solid currentcolor;\n outline-offset: 2px;\n}\n.d-button:active {\n transform: scale(0.98);\n transition: transform 0.4s ease-in-out;\n}\n.d-kbd {\n position: relative;\n padding: 0.25em 0.4em;\n font-size: 11px;\n font-family: ui-monospace, monospace;\n line-height: 1;\n letter-spacing: -0.025em;\n background-color: canvas;\n color: canvastext;\n filter: invert(90%);\n border: none;\n border-bottom: 1px solid hsl(from canvastext h s l / calc(alpha * 0.5));\n border-radius: 0.25rem;\n box-shadow: 0 0 2px hsla(0, 0%, 0%, 0.1);\n user-select: none;\n -webkit-user-select: none;\n}\n",customElements.define(e,n);class o{constructor(t,n){var o,i,s;this.options={position:null!==(o=null==n?void 0:n.position)&&void 0!==o?o:"bottom-right",size:null!==(i=null==n?void 0:n.size)&&void 0!==i?i:"medium",shortcut:null!==(s=null==n?void 0:n.shortcut)&&void 0!==s?s:""},this.el=document.createElement(e),this.el.init(t,this.options)}render(){return document.body.appendChild(this.el),this.el}onThemeChange(t){this.el.onThemeChange(t)}onDestroy(){this.el.remove()}}o.pluginId=e;class i{constructor(t,e){var n,o,i,s,r;this._lastTriggered=0,this.handleKeyDown=t=>{if(("body"!==this.options.target||!this.isTyping(t))&&("input"!==this.options.target||this.isTyping(t))&&this.matches(t)){t.preventDefault();const e=Date.now();if(e-this._lastTriggered<this.options.cooldown)return;this._lastTriggered=e,this._host.toggleTheme()}},this._host=t,this.options={key:null!==(n=null==e?void 0:e.key)&&void 0!==n?n:"d",ctrl:null!==(o=null==e?void 0:e.ctrl)&&void 0!==o&&o,shift:null!==(i=null==e?void 0:e.shift)&&void 0!==i&&i,target:null!==(s=null==e?void 0:e.target)&&void 0!==s?s:"body",cooldown:null!==(r=null==e?void 0:e.cooldown)&&void 0!==r?r:300}}render(){document.addEventListener("keydown",this.handleKeyDown)}onDestroy(){document.removeEventListener("keydown",this.handleKeyDown)}matches(t){return t.key.toLowerCase()===this.options.key.toLowerCase()&&(!this.options.ctrl||t.ctrlKey||t.metaKey)&&(!this.options.shift||t.shiftKey)&&(this.options.ctrl||!t.ctrlKey&&!t.metaKey&&!t.altKey)}isTyping(t){const e=t.target,n=e.tagName.toLowerCase();return e.isContentEditable||"input"===n||"textarea"===n}}i.pluginId="d-keyboard-shortcut",t.KeyboardShortcut=i,t.ThemeWidget=o});
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "darkify-js",
|
|
3
|
-
"version": "1.1.13
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"description": "A simple dark mode toggle library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
+
"types": "./dist/darkify.d.ts",
|
|
8
9
|
"import": "./dist/darkify.esm.js",
|
|
9
|
-
"require": "./dist/darkify.umd.js"
|
|
10
|
-
"types": "./dist/darkify.d.ts"
|
|
10
|
+
"require": "./dist/darkify.umd.js"
|
|
11
11
|
},
|
|
12
12
|
"./plugins": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
13
|
+
"types": "./dist/plugins/index.d.ts",
|
|
14
|
+
"import": "./dist/plugins/index.esm.js",
|
|
15
|
+
"require": "./dist/plugins/index.umd.js"
|
|
16
16
|
},
|
|
17
17
|
"./package.json": "./package.json"
|
|
18
18
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "git+https://github.com/emrocode/darkify-js"
|
|
33
|
+
"url": "git+https://github.com/emrocode/darkify-js.git"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"dark mode",
|
|
@@ -59,8 +59,5 @@
|
|
|
59
59
|
"ts-node": "^10.9.2",
|
|
60
60
|
"tslib": "^2.8.1",
|
|
61
61
|
"typescript": "~5.9.3"
|
|
62
|
-
},
|
|
63
|
-
"dependencies": {
|
|
64
|
-
"lit": "^3.3.2"
|
|
65
62
|
}
|
|
66
63
|
}
|