Compare commits

...

38 Commits

Author SHA1 Message Date
333e991231 2.0.30 2023-04-05 16:46:13 +02:00
94c6c5a525 fix(core): update 2023-04-05 16:46:13 +02:00
bb64a8ecac 2.0.29 2023-04-05 16:38:44 +02:00
a4a26e44aa fix(core): update 2023-04-05 16:38:43 +02:00
f350905907 2.0.28 2023-01-07 08:24:38 +01:00
a90e326f5e fix(core): update 2023-01-07 08:24:37 +01:00
7c9aef342d 2.0.27 2023-01-03 17:02:40 +01:00
99eab4e35f fix(core): update 2023-01-03 17:02:40 +01:00
6d12aed53e 2.0.26 2023-01-02 17:25:17 +01:00
29bcd17350 fix(core): update 2023-01-02 17:25:17 +01:00
f2e858d0b8 2.0.25 2022-12-31 12:12:59 +01:00
83a78a2c97 fix(core): update 2022-12-31 12:12:58 +01:00
d77c657d6a 2.0.24 2022-12-31 11:34:05 +01:00
f8f2f05396 fix(core): update 2022-12-31 11:34:04 +01:00
7ee0d63a2c 2.0.23 2022-08-01 16:19:45 +02:00
e01f1a6a72 fix(core): update 2022-08-01 16:19:45 +02:00
c7b9374169 2.0.22 2022-05-01 20:07:30 +02:00
dfe189ff1c fix(core): update 2022-05-01 20:07:29 +02:00
b777508b7a 2.0.21 2022-05-01 19:24:16 +02:00
52664d8ea1 fix(core): update 2022-05-01 19:24:16 +02:00
7bad85a1fa 2.0.20 2022-05-01 16:42:37 +02:00
e5056a7be3 fix(core): update 2022-05-01 16:42:37 +02:00
989d4d35d2 2.0.19 2022-04-22 10:39:35 +02:00
c5e75419b3 fix(core): update 2022-04-22 10:39:34 +02:00
ca52d06c60 2.0.18 2022-04-22 09:37:50 +02:00
d33366c487 fix(core): update 2022-04-22 09:37:50 +02:00
3bc5e1d0e2 2.0.17 2022-04-22 09:25:10 +02:00
96a88112dc fix(core): update 2022-04-22 09:25:10 +02:00
6c0c1e165f 2.0.16 2022-04-21 23:53:02 +02:00
653a4138a9 fix(core): update 2022-04-21 23:53:02 +02:00
d776843494 2.0.15 2022-04-21 23:52:45 +02:00
79e64c4cc2 fix(core): update 2022-04-21 23:52:45 +02:00
7192d3fbf7 2.0.14 2022-04-21 23:10:14 +02:00
42bcb8243d fix(core): update 2022-04-21 23:10:14 +02:00
52fb046fa8 2.0.13 2022-04-21 22:53:59 +02:00
b83d3e1aed fix(core): update 2022-04-21 22:53:58 +02:00
4ec8707596 2.0.12 2022-04-21 19:16:07 +02:00
69e1b52e72 fix(core): update 2022-04-21 19:16:06 +02:00
12 changed files with 4599 additions and 19601 deletions

19481
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@designestate/dees-domtools", "name": "@designestate/dees-domtools",
"version": "2.0.11", "version": "2.0.30",
"private": false, "private": false,
"description": "tools to simplify complex css structures", "description": "tools to simplify complex css structures",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -10,31 +10,31 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web --allowimplicitany --skiplibcheck && tsbundle npm)", "build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
"format": "(gitzone format)" "format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.61", "@gitzone/tsbuild": "^2.1.63",
"@gitzone/tsbundle": "^1.0.102", "@gitzone/tsbundle": "^2.0.6",
"@gitzone/tstest": "^1.0.70", "@gitzone/tstest": "^1.0.72",
"@pushrocks/tapbundle": "^5.0.3", "@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^17.0.23", "@types/node": "^18.15.11"
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@apiglobal/typedrequest": "^2.0.3", "@apiglobal/typedrequest": "^2.0.8",
"@designestate/dees-comms": "^1.0.22", "@designestate/dees-comms": "^1.0.22",
"@pushrocks/lik": "^5.0.4", "@pushrocks/lik": "^6.0.2",
"@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartdelay": "^3.0.1",
"@pushrocks/smartpromise": "^3.1.7", "@pushrocks/smartjson": "^5.0.5",
"@pushrocks/smartrouter": "^1.0.12", "@pushrocks/smartpromise": "^4.0.0",
"@pushrocks/smartrx": "^2.0.25", "@pushrocks/smartrouter": "^1.0.14",
"@pushrocks/smartstate": "^2.0.0", "@pushrocks/smartrx": "^3.0.0",
"@pushrocks/webrequest": "^3.0.3", "@pushrocks/smartstate": "^2.0.4",
"@pushrocks/smarturl": "^3.0.5",
"@pushrocks/webrequest": "^3.0.21",
"@pushrocks/websetup": "^3.0.16", "@pushrocks/websetup": "^3.0.16",
"@pushrocks/webstore": "^1.0.18", "@pushrocks/webstore": "^2.0.5",
"lit": "^2.2.2", "lit": "^2.7.1",
"sweet-scroll": "^4.0.0" "sweet-scroll": "^4.0.0"
}, },
"files": [ "files": [

4477
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@designestate/dees-domtools',
version: '2.0.30',
description: 'tools to simplify complex css structures'
}

View File

@ -1,18 +1,19 @@
import * as plugins from './domtools.plugins.js'; import * as plugins from './domtools.plugins.js';
import { Stringmap } from '@pushrocks/lik/dist_ts/lik.stringmap.js';
import { FastMap } from '@pushrocks/lik/dist_ts/lik.fastmap.js';
import { TViewport } from './domtools.css.breakpoints.js'; import { TViewport } from './domtools.css.breakpoints.js';
import { Scroller } from './domtools.classes.scroller.js'; import { Scroller } from './domtools.classes.scroller.js';
import { WebSetup } from '@pushrocks/websetup'; import { WebSetup } from '@pushrocks/websetup';
import { ThemeManager } from './domtools.classes.thememanager.js'; import { ThemeManager } from './domtools.classes.thememanager.js';
import { Keyboard, Key } from './domtools.classes.keyboard.js'; import { Keyboard } from './domtools.classes.keyboard.js';
export interface IDomToolsState { export interface IDomToolsState {
virtualViewport: TViewport; virtualViewport: TViewport;
jwt: string; jwt: string;
} }
export interface IDomToolsContructorOptions {
ignoreGlobal?: boolean;
}
export class DomTools { export class DomTools {
// ====== // ======
// STATIC // STATIC
@ -20,10 +21,10 @@ export class DomTools {
/** /**
* setups domtools * setups domtools
*/ */
public static async setupDomTools() { public static async setupDomTools(optionsArg: IDomToolsContructorOptions = {}) {
let domToolsInstance: DomTools; let domToolsInstance: DomTools;
if (!globalThis.deesDomTools) { if (!globalThis.deesDomTools && !optionsArg.ignoreGlobal) {
globalThis.deesDomTools = new DomTools(); globalThis.deesDomTools = new DomTools(optionsArg);
domToolsInstance = globalThis.deesDomTools; domToolsInstance = globalThis.deesDomTools;
// lets make sure the dom is ready // lets make sure the dom is ready
@ -36,6 +37,8 @@ export class DomTools {
}; };
document.addEventListener('readystatechange', readyStateChangedFunc); document.addEventListener('readystatechange', readyStateChangedFunc);
domToolsInstance.domToolsReady.resolve(); domToolsInstance.domToolsReady.resolve();
} else if (optionsArg.ignoreGlobal) {
domToolsInstance = new DomTools(optionsArg);
} else { } else {
domToolsInstance = globalThis.deesDomTools; domToolsInstance = globalThis.deesDomTools;
} }
@ -75,7 +78,7 @@ export class DomTools {
public smartstate = new plugins.smartstate.Smartstate(); public smartstate = new plugins.smartstate.Smartstate();
public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', { public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', {
virtualViewport: 'native', virtualViewport: 'native',
jwt: null jwt: null,
}); });
public router = new plugins.smartrouter.SmartRouter({ public router = new plugins.smartrouter.SmartRouter({
@ -85,6 +88,8 @@ export class DomTools {
public convenience = { public convenience = {
typedrequest: plugins.typedrequest, typedrequest: plugins.typedrequest,
smartdelay: plugins.smartdelay, smartdelay: plugins.smartdelay,
smartjson: plugins.smartjson,
smarturl: plugins.smarturl,
}; };
public deesComms = new plugins.deesComms.DeesComms(); public deesComms = new plugins.deesComms.DeesComms();
@ -93,16 +98,15 @@ export class DomTools {
}); // TODO: switch to scroller class }); // TODO: switch to scroller class
public themeManager = new ThemeManager(this); public themeManager = new ThemeManager(this);
public keyboard = new Keyboard(document.body); public keyboard = new Keyboard(document.body);
public domToolsReady = plugins.smartpromise.defer(); public domToolsReady = plugins.smartpromise.defer();
public domReady = plugins.smartpromise.defer(); public domReady = plugins.smartpromise.defer();
public globalStylesReady = plugins.smartpromise.defer(); public globalStylesReady = plugins.smartpromise.defer();
constructor() {} constructor(optionsArg: IDomToolsContructorOptions) {}
private runOnceTrackerStringMap = new Stringmap(); private runOnceTrackerStringMap = new plugins.lik.Stringmap();
private runOnceResultMap = new FastMap(); private runOnceResultMap = new plugins.lik.FastMap();
/** /**
* run a function once and always get the Promise of the first execution * run a function once and always get the Promise of the first execution
@ -141,6 +145,23 @@ export class DomTools {
this.elements.headElement.appendChild(styleElement); this.elements.headElement.appendChild(styleElement);
} }
/**
* allows to set global styles
* @param stylesText the css text you want to set
*/
public async setExternalScript(scriptLinkArg: string) {
await this.domReady.promise;
const done = plugins.smartpromise.defer();
const script = document.createElement('script');
script.src = scriptLinkArg;
script.addEventListener('load', function () {
done.resolve();
});
const parentNode = document.head || document.body;
parentNode.append(script);
await done.promise;
}
/** /**
* allows setting external css files * allows setting external css files
* @param cssLinkArg a url to an external stylesheet * @param cssLinkArg a url to an external stylesheet

View File

@ -128,8 +128,6 @@ export enum Key {
Quote = 222, Quote = 222,
} }
type KeyCombo = Array<Key>;
export class Keyboard { export class Keyboard {
private mapCombosToHandlers = new Map<number[], plugins.smartrx.rxjs.Subject<KeyboardEvent>>(); private mapCombosToHandlers = new Map<number[], plugins.smartrx.rxjs.Subject<KeyboardEvent>>();
private pressedKeys = new Set<Key>(); private pressedKeys = new Set<Key>();
@ -138,15 +136,24 @@ export class Keyboard {
this.startListening(); this.startListening();
} }
public on(keys: Key[] | KeyCombo[]) { public keyEnum = Key;
const combos = this.toCombos(keys);
public on(keys: Key[]) {
const subject = new plugins.smartrx.rxjs.Subject<KeyboardEvent>(); const subject = new plugins.smartrx.rxjs.Subject<KeyboardEvent>();
combos.forEach((combo) => { this.registerKeys(keys, subject);
this.registerComboCallback(combo, subject);
});
return subject; return subject;
} }
public triggerKeyPress(keysArg: Key[]) {
for (const key of keysArg) {
this.pressedKeys.add(key);
}
this.checkMatchingKeyboardSubjects();
for (const key of keysArg) {
this.pressedKeys.delete(key);
}
}
public startListening() { public startListening() {
this.domNode.addEventListener('keydown', this.handleKeyDown); this.domNode.addEventListener('keydown', this.handleKeyDown);
this.domNode.addEventListener('keyup', this.handleKeyUp); this.domNode.addEventListener('keyup', this.handleKeyUp);
@ -165,22 +172,25 @@ export class Keyboard {
private handleKeyDown = (event: KeyboardEvent) => { private handleKeyDown = (event: KeyboardEvent) => {
this.pressedKeys.add(event.keyCode); this.pressedKeys.add(event.keyCode);
this.checkMatchingKeyboardSubjects(event);
};
this.mapCombosToHandlers.forEach((subjectArg, comboArg) => { private checkMatchingKeyboardSubjects(payloadArg?) {
if (this.isComboPressed(comboArg)) { this.mapCombosToHandlers.forEach((subjectArg, keysArg) => {
subjectArg.next(event); if (this.areAllKeysPressed(keysArg)) {
subjectArg.next(payloadArg);
} }
}); });
}; }
private handleKeyUp = (event: KeyboardEvent) => { private handleKeyUp = (event: KeyboardEvent) => {
this.pressedKeys.delete(event.keyCode); this.pressedKeys.delete(event.keyCode);
}; };
private isComboPressed(combo: number[]) { private areAllKeysPressed(keysArg: Key[]) {
let result = true; let result = true;
combo.forEach((key) => { keysArg.forEach((key) => {
if (!this.pressedKeys.has(key)) { if (!this.pressedKeys.has(key)) {
result = false; result = false;
} }
@ -189,33 +199,15 @@ export class Keyboard {
return result; return result;
} }
private registerComboCallback( private registerKeys(
comboArg: Array<Key>, keysArg: Array<Key>,
subjectArg: plugins.smartrx.rxjs.Subject<KeyboardEvent> subjectArg: plugins.smartrx.rxjs.Subject<KeyboardEvent>
) { ) {
if (!this.mapCombosToHandlers.has(comboArg)) { if (!this.mapCombosToHandlers.has(keysArg)) {
this.mapCombosToHandlers.set(comboArg, subjectArg); this.mapCombosToHandlers.set(keysArg, subjectArg);
} else { } else {
const subject = this.mapCombosToHandlers.get(comboArg); const subject = this.mapCombosToHandlers.get(keysArg);
return subject; return subject;
} }
} }
private toCombos(keys: KeyCombo[] | Key[]) {
if (keys.length === 0) {
return [];
}
const isKeys = !Array.isArray(keys[0]);
let combos: KeyCombo[] = [];
if (isKeys) {
combos = (keys as Key[]).map((key) => [key]);
} else {
combos = keys as KeyCombo[];
combos = combos.filter((combo) => combo.length > 0);
}
return combos;
}
} }

View File

@ -6,47 +6,33 @@ import { css, unsafeCSS } from 'lit';
* changes scrollbar styles to be consistent across OS borders * changes scrollbar styles to be consistent across OS borders
*/ */
export const scrollBarStyles: string = (() => { export const scrollBarStyles: string = (() => {
const returnStyles = const returnStylesOld = navigator.userAgent.indexOf('Mac OS X') === -1 ? css``.cssText : ``;
navigator.userAgent.indexOf('Mac OS X') === -1 const returnStyles = css`
? css` /* width */
/* width */ ::-webkit-scrollbar {
::-webkit-scrollbar { width: 0px;
width: 6px; }
} body {
scrollbar-width: none;
/* Track */ }
::-webkit-scrollbar-track { `.cssText;
background: #111;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #666;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #777;
}
`.cssText
: ``;
return returnStyles; return returnStyles;
})(); })();
export const globalBaseStyles: string = css` export const globalBaseStyles: string = css`
/* global material font */ /*
@font-face { @font-face {
font-family: 'Material Icons'; font-family: 'Material Icons';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: url(https://fonts.gstatic.com/s/materialicons/v42/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) src: url(https://fonts.gstatic.com/s/materialicons/v42/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2)
format('woff2'); format('woff2');
} } */
/* global body styles */ /* global body styles */
body { body {
margin: 0px; margin: 0px;
font-family: 'Roboto', sans-serif; font-family: 'Inter', sans-serif;
box-sizing: border-box; box-sizing: border-box;
} }

View File

@ -1,5 +1,5 @@
import * as plugins from './domtools.plugins.js'; import * as plugins from './domtools.plugins.js';
import { DomTools } from './domtools.classes.domtools.js'; import { DomTools, IDomToolsContructorOptions } from './domtools.classes.domtools.js';
import { scrollBarStyles, globalBaseStyles } from './domtools.css.basestyles.js'; import { scrollBarStyles, globalBaseStyles } from './domtools.css.basestyles.js';
import { html, LitElement, css, unsafeCSS } from 'lit'; import { html, LitElement, css, unsafeCSS } from 'lit';
@ -12,7 +12,7 @@ export const staticStyles = css`
:host { :host {
box-sizing: border-box; box-sizing: border-box;
font-family: 'Roboto', sans-serif; font-family: 'Inter', sans-serif;
} }
${unsafeCSS(scrollBarStyles)} ${unsafeCSS(scrollBarStyles)}
@ -29,7 +29,7 @@ export const styles = html`
} }
:host { :host {
font-family: 'Roboto', sans-serif; font-family: 'Inter', sans-serif;
} }
${scrollBarStyles} ${scrollBarStyles}
@ -40,8 +40,8 @@ export const styles = html`
* a basic setup for elements * a basic setup for elements
* makes sure everything is in check * makes sure everything is in check
*/ */
export const setup = async (elementArg?: LitElement): Promise<DomTools> => { export const setup = async (elementArg?: LitElement, optionsArg: IDomToolsContructorOptions = {}): Promise<DomTools> => {
const domTools = await DomTools.setupDomTools(); const domTools = await DomTools.setupDomTools(optionsArg);
if (elementArg) { if (elementArg) {
// lets do something with the element // lets do something with the element

View File

@ -10,26 +10,34 @@ export { typedrequest };
// pushrocks scope // pushrocks scope
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartjson from '@pushrocks/smartjson';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrouter from '@pushrocks/smartrouter'; import * as smartrouter from '@pushrocks/smartrouter';
import * as smartrx from '@pushrocks/smartrx'; import * as smartrx from '@pushrocks/smartrx';
import * as smartstate from '@pushrocks/smartstate'; import * as smartstate from '@pushrocks/smartstate';
import * as smarturl from '@pushrocks/smarturl';
import * as webrequest from '@pushrocks/webrequest'; import * as webrequest from '@pushrocks/webrequest';
import * as websetup from '@pushrocks/websetup'; import * as websetup from '@pushrocks/websetup';
import * as webstore from '@pushrocks/webstore'; import * as webstore from '@pushrocks/webstore';
// subscope lik // subscope lik
import { ObjectMap } from '@pushrocks/lik/dist_ts/lik.objectmap.js'; import { ObjectMap } from '@pushrocks/lik/dist_ts/lik.objectmap.js';
import { Stringmap } from '@pushrocks/lik/dist_ts/lik.stringmap.js';
import { FastMap } from '@pushrocks/lik/dist_ts/lik.fastmap.js';
const lik = { const lik = {
ObjectMap, ObjectMap,
Stringmap,
FastMap,
}; };
export { export {
lik, lik,
smartdelay, smartdelay,
smartjson,
smartpromise, smartpromise,
smartrouter, smartrouter,
smartrx, smartrx,
smarturl,
smartstate, smartstate,
webrequest, webrequest,
websetup, websetup,

View File

@ -5,7 +5,7 @@ import * as breakpoints from './domtools.css.breakpoints.js';
import * as css from './domtools.css.js'; import * as css from './domtools.css.js';
export { css, breakpoints, elementBasic }; export { css, breakpoints, elementBasic };
export { DomTools } from './domtools.classes.domtools.js'; export { DomTools, IDomToolsContructorOptions } from './domtools.classes.domtools.js';
export { TypedRequest } from '@apiglobal/typedrequest'; export { TypedRequest } from '@apiglobal/typedrequest';
export { IWebSetupConstructorOptions } from '@pushrocks/websetup'; export { IWebSetupConstructorOptions } from '@pushrocks/websetup';
export { rxjs } from '@pushrocks/smartrx'; export { rxjs } from '@pushrocks/smartrx';

View File

@ -1,6 +1,10 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2020", "experimentalDecorators": true,
"module": "Node12" "useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
} }
} }

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}