Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
7c9aef342d | |||
99eab4e35f | |||
6d12aed53e | |||
29bcd17350 | |||
f2e858d0b8 | |||
83a78a2c97 | |||
d77c657d6a | |||
f8f2f05396 | |||
7ee0d63a2c | |||
e01f1a6a72 | |||
c7b9374169 | |||
dfe189ff1c | |||
b777508b7a | |||
52664d8ea1 | |||
7bad85a1fa | |||
e5056a7be3 | |||
989d4d35d2 | |||
c5e75419b3 | |||
ca52d06c60 | |||
d33366c487 | |||
3bc5e1d0e2 | |||
96a88112dc | |||
6c0c1e165f | |||
653a4138a9 | |||
d776843494 | |||
79e64c4cc2 | |||
7192d3fbf7 | |||
42bcb8243d |
19481
package-lock.json
generated
19481
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@designestate/dees-domtools",
|
||||
"version": "2.0.13",
|
||||
"version": "2.0.27",
|
||||
"private": false,
|
||||
"description": "tools to simplify complex css structures",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -10,31 +10,31 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany --skiplibcheck && tsbundle npm)",
|
||||
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.61",
|
||||
"@gitzone/tsbundle": "^1.0.102",
|
||||
"@gitzone/tstest": "^1.0.70",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^17.0.23",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tsbundle": "^2.0.6",
|
||||
"@gitzone/tstest": "^1.0.72",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest": "^2.0.3",
|
||||
"@apiglobal/typedrequest": "^2.0.8",
|
||||
"@designestate/dees-comms": "^1.0.22",
|
||||
"@pushrocks/lik": "^5.0.4",
|
||||
"@pushrocks/lik": "^6.0.0",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartjson": "^5.0.5",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartrouter": "^1.0.12",
|
||||
"@pushrocks/smartrx": "^2.0.25",
|
||||
"@pushrocks/smartrx": "^3.0.0",
|
||||
"@pushrocks/smartstate": "^2.0.0",
|
||||
"@pushrocks/webrequest": "^3.0.3",
|
||||
"@pushrocks/smarturl": "^3.0.5",
|
||||
"@pushrocks/webrequest": "^3.0.9",
|
||||
"@pushrocks/websetup": "^3.0.16",
|
||||
"@pushrocks/webstore": "^1.0.18",
|
||||
"lit": "^2.2.2",
|
||||
"@pushrocks/webstore": "^2.0.5",
|
||||
"lit": "^2.2.8",
|
||||
"sweet-scroll": "^4.0.0"
|
||||
},
|
||||
"files": [
|
||||
|
4393
pnpm-lock.yaml
generated
Normal file
4393
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@designestate/dees-domtools',
|
||||
version: '2.0.27',
|
||||
description: 'tools to simplify complex css structures'
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
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 { Scroller } from './domtools.classes.scroller.js';
|
||||
import { WebSetup } from '@pushrocks/websetup';
|
||||
import { ThemeManager } from './domtools.classes.thememanager.js';
|
||||
@ -91,6 +88,8 @@ export class DomTools {
|
||||
public convenience = {
|
||||
typedrequest: plugins.typedrequest,
|
||||
smartdelay: plugins.smartdelay,
|
||||
smartjson: plugins.smartjson,
|
||||
smarturl: plugins.smarturl,
|
||||
};
|
||||
|
||||
public deesComms = new plugins.deesComms.DeesComms();
|
||||
@ -106,8 +105,8 @@ export class DomTools {
|
||||
|
||||
constructor(optionsArg: IDomToolsContructorOptions) {}
|
||||
|
||||
private runOnceTrackerStringMap = new Stringmap();
|
||||
private runOnceResultMap = new FastMap();
|
||||
private runOnceTrackerStringMap = new plugins.lik.Stringmap();
|
||||
private runOnceResultMap = new plugins.lik.FastMap();
|
||||
|
||||
/**
|
||||
* run a function once and always get the Promise of the first execution
|
||||
@ -146,6 +145,23 @@ export class DomTools {
|
||||
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
|
||||
* @param cssLinkArg a url to an external stylesheet
|
||||
|
@ -128,8 +128,6 @@ export enum Key {
|
||||
Quote = 222,
|
||||
}
|
||||
|
||||
type KeyCombo = Array<Key>;
|
||||
|
||||
export class Keyboard {
|
||||
private mapCombosToHandlers = new Map<number[], plugins.smartrx.rxjs.Subject<KeyboardEvent>>();
|
||||
private pressedKeys = new Set<Key>();
|
||||
@ -140,15 +138,22 @@ export class Keyboard {
|
||||
|
||||
public keyEnum = Key;
|
||||
|
||||
public on(keys: Key[] | KeyCombo[]) {
|
||||
const combos = this.toCombos(keys);
|
||||
public on(keys: Key[]) {
|
||||
const subject = new plugins.smartrx.rxjs.Subject<KeyboardEvent>();
|
||||
combos.forEach((combo) => {
|
||||
this.registerComboCallback(combo, subject);
|
||||
});
|
||||
this.registerKeys(keys, 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() {
|
||||
this.domNode.addEventListener('keydown', this.handleKeyDown);
|
||||
this.domNode.addEventListener('keyup', this.handleKeyUp);
|
||||
@ -167,22 +172,25 @@ export class Keyboard {
|
||||
|
||||
private handleKeyDown = (event: KeyboardEvent) => {
|
||||
this.pressedKeys.add(event.keyCode);
|
||||
this.checkMatchingKeyboardSubjects(event);
|
||||
};
|
||||
|
||||
this.mapCombosToHandlers.forEach((subjectArg, comboArg) => {
|
||||
if (this.isComboPressed(comboArg)) {
|
||||
subjectArg.next(event);
|
||||
private checkMatchingKeyboardSubjects(payloadArg?) {
|
||||
this.mapCombosToHandlers.forEach((subjectArg, keysArg) => {
|
||||
if (this.areAllKeysPressed(keysArg)) {
|
||||
subjectArg.next(payloadArg);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
private handleKeyUp = (event: KeyboardEvent) => {
|
||||
this.pressedKeys.delete(event.keyCode);
|
||||
};
|
||||
|
||||
private isComboPressed(combo: number[]) {
|
||||
private areAllKeysPressed(keysArg: Key[]) {
|
||||
let result = true;
|
||||
|
||||
combo.forEach((key) => {
|
||||
keysArg.forEach((key) => {
|
||||
if (!this.pressedKeys.has(key)) {
|
||||
result = false;
|
||||
}
|
||||
@ -191,33 +199,15 @@ export class Keyboard {
|
||||
return result;
|
||||
}
|
||||
|
||||
private registerComboCallback(
|
||||
comboArg: Array<Key>,
|
||||
private registerKeys(
|
||||
keysArg: Array<Key>,
|
||||
subjectArg: plugins.smartrx.rxjs.Subject<KeyboardEvent>
|
||||
) {
|
||||
if (!this.mapCombosToHandlers.has(comboArg)) {
|
||||
this.mapCombosToHandlers.set(comboArg, subjectArg);
|
||||
if (!this.mapCombosToHandlers.has(keysArg)) {
|
||||
this.mapCombosToHandlers.set(keysArg, subjectArg);
|
||||
} else {
|
||||
const subject = this.mapCombosToHandlers.get(comboArg);
|
||||
const subject = this.mapCombosToHandlers.get(keysArg);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -6,30 +6,16 @@ import { css, unsafeCSS } from 'lit';
|
||||
* changes scrollbar styles to be consistent across OS borders
|
||||
*/
|
||||
export const scrollBarStyles: string = (() => {
|
||||
const returnStyles =
|
||||
navigator.userAgent.indexOf('Mac OS X') === -1
|
||||
? css`
|
||||
/* width */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
/* Track */
|
||||
::-webkit-scrollbar-track {
|
||||
background: #111;
|
||||
}
|
||||
|
||||
/* Handle */
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #666;
|
||||
}
|
||||
|
||||
/* Handle on hover */
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #777;
|
||||
}
|
||||
`.cssText
|
||||
: ``;
|
||||
const returnStylesOld = navigator.userAgent.indexOf('Mac OS X') === -1 ? css``.cssText : ``;
|
||||
const returnStyles = css`
|
||||
/* width */
|
||||
::-webkit-scrollbar {
|
||||
width: 0px;
|
||||
}
|
||||
body {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
`.cssText;
|
||||
return returnStyles;
|
||||
})();
|
||||
|
||||
@ -46,7 +32,7 @@ export const globalBaseStyles: string = css`
|
||||
/* global body styles */
|
||||
body {
|
||||
margin: 0px;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-family: 'Inter', sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ export const staticStyles = css`
|
||||
|
||||
:host {
|
||||
box-sizing: border-box;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
${unsafeCSS(scrollBarStyles)}
|
||||
@ -29,7 +29,7 @@ export const styles = html`
|
||||
}
|
||||
|
||||
:host {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
${scrollBarStyles}
|
||||
|
@ -10,26 +10,34 @@ export { typedrequest };
|
||||
|
||||
// pushrocks scope
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartjson from '@pushrocks/smartjson';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrouter from '@pushrocks/smartrouter';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
import * as smartstate from '@pushrocks/smartstate';
|
||||
import * as smarturl from '@pushrocks/smarturl';
|
||||
import * as webrequest from '@pushrocks/webrequest';
|
||||
import * as websetup from '@pushrocks/websetup';
|
||||
import * as webstore from '@pushrocks/webstore';
|
||||
|
||||
// subscope lik
|
||||
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 = {
|
||||
ObjectMap,
|
||||
Stringmap,
|
||||
FastMap,
|
||||
};
|
||||
|
||||
export {
|
||||
lik,
|
||||
smartdelay,
|
||||
smartjson,
|
||||
smartpromise,
|
||||
smartrouter,
|
||||
smartrx,
|
||||
smarturl,
|
||||
smartstate,
|
||||
webrequest,
|
||||
websetup,
|
||||
|
@ -5,7 +5,7 @@ import * as breakpoints from './domtools.css.breakpoints.js';
|
||||
import * as css from './domtools.css.js';
|
||||
|
||||
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 { IWebSetupConstructorOptions } from '@pushrocks/websetup';
|
||||
export { rxjs } from '@pushrocks/smartrx';
|
||||
|
@ -1,6 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "Node12"
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
tslint.json
17
tslint.json
@ -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"
|
||||
}
|
Reference in New Issue
Block a user