Compare commits

...

78 Commits

Author SHA1 Message Date
b6720aef9d 2.0.32 2023-05-08 10:14:48 +02:00
ce945173ec fix(core): update 2023-05-08 10:14:47 +02:00
0c016ea6d9 2.0.31 2023-05-07 20:56:08 +02:00
467b0d3011 fix(core): update 2023-05-07 20:56:08 +02:00
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
a5ff175913 2.0.11 2022-04-21 19:05:53 +02:00
f84e7c48ae fix(core): update 2022-04-21 19:05:52 +02:00
185d9ff957 2.0.10 2022-04-21 18:01:55 +02:00
6145bd66dc fix(core): update 2022-04-21 18:01:54 +02:00
d58272a604 2.0.9 2022-04-20 23:56:09 +02:00
68ca1e8906 fix(core): update 2022-04-20 23:56:09 +02:00
7023888f38 2.0.8 2022-04-19 18:16:21 +02:00
1356666700 fix(core): update 2022-04-19 18:16:20 +02:00
b436fe77b0 2.0.7 2022-04-19 18:13:26 +02:00
3de788bb75 fix(core): update 2022-04-19 18:13:26 +02:00
d50e320f17 2.0.6 2022-04-14 16:42:52 +02:00
a7532c8816 fix(core): update 2022-04-14 16:42:51 +02:00
2d5944cdd7 2.0.5 2022-03-29 15:54:06 +02:00
5a8527068a fix(core): update 2022-03-29 15:54:06 +02:00
ffd0bb925a 2.0.4 2022-03-25 16:03:40 +01:00
4a5fb3ef4b fix(core): update 2022-03-25 16:03:40 +01:00
a059c268af 2.0.3 2022-03-25 14:01:44 +01:00
714aa77839 fix(core): update 2022-03-25 14:01:44 +01:00
2527e6e586 2.0.2 2022-03-25 02:28:39 +01:00
88f7f20b6f fix(core): update 2022-03-25 02:28:39 +01:00
8e23b7ebec 2.0.1 2022-03-18 14:26:31 +01:00
b3d12c39bf fix(core): update 2022-03-18 14:26:31 +01:00
d102d5a7e6 2.0.0 2022-03-16 13:42:30 +01:00
8be31958b4 1.0.115 2022-03-16 13:39:50 +01:00
e21f6c3920 fix(core): update 2022-03-16 13:39:50 +01:00
356a756962 1.0.114 2022-03-04 08:21:58 +01:00
0bb66e8221 fix(core): update 2022-03-04 08:21:57 +01:00
b70077c43f 1.0.113 2022-03-02 19:18:40 +01:00
9c5f024e5f 1.0.112 2022-03-02 19:00:52 +01:00
5eea208924 fix(core): update 2022-03-02 19:00:52 +01:00
f21fdb2eb8 1.0.111 2022-03-02 18:00:35 +01:00
d6ea74cb71 fix(core): update 2022-03-02 18:00:35 +01:00
10375576a7 1.0.110 2022-03-02 17:44:46 +01:00
367be854ff fix(core): update 2022-03-02 17:44:45 +01:00
0933c1d83b 1.0.109 2022-01-28 18:05:57 +01:00
af1eb73028 fix(core): update 2022-01-28 18:05:57 +01:00
20 changed files with 4890 additions and 27479 deletions

View File

@ -12,29 +12,25 @@ stages:
- release - release
- metadata - metadata
before_script:
- pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ====================
# security stage
# ====================
# ==================== # ====================
# security stage # security stage
# ==================== # ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies: auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm install --production --ignore-scripts - npmci command pnpm audit --audit-level=high --prod
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- lossless
- docker - docker
allow_failure: true allow_failure: true
@ -42,11 +38,10 @@ auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev - npmci command pnpm audit --audit-level=high --dev
tags: tags:
- lossless
- docker - docker
allow_failure: true allow_failure: true
@ -57,7 +52,6 @@ auditDevDependencies:
testStable: testStable:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
@ -68,10 +62,9 @@ testStable:
testBuild: testBuild:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci command npm run build - npmci npm build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
@ -97,10 +90,9 @@ codequality:
only: only:
- tags - tags
script: script:
- npmci command npm install -g tslint typescript - npmci command npm install -g typescript
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags: tags:
- lossless - lossless
- docker - docker
@ -120,11 +112,9 @@ trigger:
pages: pages:
stage: metadata stage: metadata
script: script:
- npmci node install lts - npmci node install stable
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install - npmci npm install
- npmci command tsdoc - npmci command npm run buildDocs
tags: tags:
- lossless - lossless
- docker - docker

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "current file", "command": "npm test",
"type": "node", "name": "Run npm test",
"request": "launch", "request": "launch",
"args": [ "type": "node-terminal"
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
} }
] ]
} }

View File

@ -1,4 +1,5 @@
Copyright (c) 2020 Lossless GmbH (hello@lossless.com) Copyright (c) 2020 Lossless GmbH (hello@lossless.com)
Copyright (c) 2017 Nathan Friend (ts-keycode-enum)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -5,7 +5,7 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "designestate", "gitscope": "designestate",
"gitrepo": "dees-domtools", "gitrepo": "dees-domtools",
"shortDescription": "tools to simplify complex css structures", "description": "tools to simplify complex css structures",
"npmPackagename": "@designestate/dees-domtools", "npmPackagename": "@designestate/dees-domtools",
"license": "MIT", "license": "MIT",
"projectDomain": "design.estate" "projectDomain": "design.estate"

27309
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,39 +1,41 @@
{ {
"name": "@designestate/dees-domtools", "name": "@designestate/dees-domtools",
"version": "1.0.108", "version": "2.0.32",
"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",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web && tsbundle npm)", "build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
"format": "(gitzone format)" "format": "(gitzone format)",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.29", "@gitzone/tsbuild": "^2.1.63",
"@gitzone/tsbundle": "^1.0.89", "@gitzone/tsbundle": "^2.0.6",
"@gitzone/tstest": "^1.0.60", "@gitzone/tstest": "^1.0.72",
"@pushrocks/tapbundle": "^4.0.0", "@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^17.0.10", "@types/node": "^20.1.0"
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@apiglobal/typedrequest": "^1.0.65", "@apiglobal/typedrequest": "^2.0.8",
"@designestate/dees-comms": "^1.0.14", "@designestate/dees-comms": "^1.0.22",
"@pushrocks/lik": "^5.0.1", "@pushrocks/lik": "^6.0.2",
"@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartdelay": "^3.0.1",
"@pushrocks/smartpromise": "^3.1.6", "@pushrocks/smartjson": "^5.0.5",
"@pushrocks/smartrouter": "^1.0.12", "@pushrocks/smartpromise": "^4.0.2",
"@pushrocks/smartrx": "^2.0.20", "@pushrocks/smartrouter": "^1.0.16",
"@pushrocks/smartstate": "^1.0.23", "@pushrocks/smartrx": "^3.0.0",
"@pushrocks/webrequest": "^2.0.13", "@pushrocks/smartstate": "^2.0.6",
"@pushrocks/websetup": "^3.0.16", "@pushrocks/smarturl": "^3.0.6",
"@pushrocks/webstore": "^1.0.18", "@pushrocks/webrequest": "^3.0.23",
"lit": "^2.1.1", "@pushrocks/websetup": "^3.0.18",
"@pushrocks/webstore": "^2.0.8",
"lit": "^2.7.4",
"sweet-scroll": "^4.0.0" "sweet-scroll": "^4.0.0"
}, },
"files": [ "files": [

4505
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@ Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](htt
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@designestate/dees-domtools)](https://lossless.cloud) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@designestate/dees-domtools)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@designestate/dees-domtools)](https://lossless.cloud) PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@designestate/dees-domtools)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@designestate/dees-domtools)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@designestate/dees-domtools)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## Usage
@ -33,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

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.32',
description: 'tools to simplify complex css structures'
}

View File

@ -1,17 +1,19 @@
import * as plugins from './domtools.plugins'; import * as plugins from './domtools.plugins.js';
import { Stringmap } from '@pushrocks/lik/dist_ts/lik.stringmap'; import { TViewport } from './domtools.css.breakpoints.js';
import { FastMap } from '@pushrocks/lik/dist_ts/lik.fastmap'; import { Scroller } from './domtools.classes.scroller.js';
import { TViewport } from './domtools.css.breakpoints';
import { Scroller } from './domtools.classes.scroller';
import { WebSetup } from '@pushrocks/websetup'; import { WebSetup } from '@pushrocks/websetup';
import { ThemeManager } from './domtools.classes.thememanager'; import { ThemeManager } from './domtools.classes.thememanager.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
@ -19,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
@ -35,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;
} }
@ -74,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({
@ -84,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();
@ -91,27 +97,16 @@ export class DomTools {
/* some options */ /* some options */
}); // 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);
/* private actionSetVirtualViewport = this.domToolsStatePart.createAction<TViewport>(
async (statePart, payload) => {
const currentState = statePart.getState();
currentState.virtualViewport = payload;
return currentState;
}
);
public setVirtualViewport(environmentArg: TViewport) {
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
} */
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
@ -150,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

@ -0,0 +1,213 @@
import * as plugins from './domtools.plugins.js';
export enum Key {
Backspace = 8,
Tab = 9,
Enter = 13,
Shift = 16,
Ctrl = 17,
Alt = 18,
PauseBreak = 19,
CapsLock = 20,
Escape = 27,
Space = 32,
PageUp = 33,
PageDown = 34,
End = 35,
Home = 36,
LeftArrow = 37,
UpArrow = 38,
RightArrow = 39,
DownArrow = 40,
Insert = 45,
Delete = 46,
Zero = 48,
ClosedParen = Zero,
One = 49,
ExclamationMark = One,
Two = 50,
AtSign = Two,
Three = 51,
PoundSign = Three,
Hash = PoundSign,
Four = 52,
DollarSign = Four,
Five = 53,
PercentSign = Five,
Six = 54,
Caret = Six,
Hat = Caret,
Seven = 55,
Ampersand = Seven,
Eight = 56,
Star = Eight,
Asterik = Star,
Nine = 57,
OpenParen = Nine,
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
LeftWindowKey = 91,
RightWindowKey = 92,
SelectKey = 93,
Numpad0 = 96,
Numpad1 = 97,
Numpad2 = 98,
Numpad3 = 99,
Numpad4 = 100,
Numpad5 = 101,
Numpad6 = 102,
Numpad7 = 103,
Numpad8 = 104,
Numpad9 = 105,
Multiply = 106,
Add = 107,
Subtract = 109,
DecimalPoint = 110,
Divide = 111,
F1 = 112,
F2 = 113,
F3 = 114,
F4 = 115,
F5 = 116,
F6 = 117,
F7 = 118,
F8 = 119,
F9 = 120,
F10 = 121,
F11 = 122,
F12 = 123,
NumLock = 144,
ScrollLock = 145,
SemiColon = 186,
Equals = 187,
Comma = 188,
Dash = 189,
Period = 190,
UnderScore = Dash,
PlusSign = Equals,
ForwardSlash = 191,
Tilde = 192,
GraveAccent = Tilde,
OpenBracket = 219,
ClosedBracket = 221,
Quote = 222,
}
export class Keyboard {
private mapCombosToHandlers = new Map<number[], plugins.smartrx.rxjs.Subject<KeyboardEvent>>();
private pressedKeys = new Set<Key>();
constructor(private domNode: Element | Document) {
this.startListening();
}
public keyEnum = Key;
public on(keys: Key[]) {
const subject = new plugins.smartrx.rxjs.Subject<KeyboardEvent>();
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);
}
public stopListening() {
this.domNode.removeEventListener('keydown', this.handleKeyDown);
this.domNode.removeEventListener('keyup', this.handleKeyUp);
}
public clear() {
this.stopListening();
this.mapCombosToHandlers.clear();
this.pressedKeys.clear();
}
private handleKeyDown = (event: KeyboardEvent) => {
this.pressedKeys.add(event.keyCode);
this.checkMatchingKeyboardSubjects(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 areAllKeysPressed(keysArg: Key[]) {
let result = true;
keysArg.forEach((key) => {
if (!this.pressedKeys.has(key)) {
result = false;
}
});
return result;
}
private registerKeys(
keysArg: Array<Key>,
subjectArg: plugins.smartrx.rxjs.Subject<KeyboardEvent>
) {
if (!this.mapCombosToHandlers.has(keysArg)) {
this.mapCombosToHandlers.set(keysArg, subjectArg);
} else {
const subject = this.mapCombosToHandlers.get(keysArg);
return subject;
}
}
}

View File

@ -1,4 +1,4 @@
import * as plugins from './domtools.plugins'; import * as plugins from './domtools.plugins.js';
export class Scroller { export class Scroller {
// TODO: move sweet scroll over to here; // TODO: move sweet scroll over to here;

View File

@ -1,5 +1,5 @@
import { DomTools } from './domtools.classes.domtools'; import { DomTools } from './domtools.classes.domtools.js';
import * as plugins from './domtools.plugins'; import * as plugins from './domtools.plugins.js';
export class ThemeManager { export class ThemeManager {
public domtoolsRef: DomTools; public domtoolsRef: DomTools;

View File

@ -1,4 +1,4 @@
import { DomTools } from './domtools.classes.domtools'; import { DomTools } from './domtools.classes.domtools.js';
import { css, unsafeCSS } from 'lit'; import { css, unsafeCSS } from 'lit';
@ -6,51 +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('not a thing') !== -1 const returnStyles = css`
? css` /* width */
/* width */ ::-webkit-scrollbar {
::-webkit-scrollbar { width: 0px;
width: 8px; }
} 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');
} } */
/* Roboto Font */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400');
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100;300;400');
/* 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,14 +1,37 @@
import { DomTools } from './domtools.classes.domtools'; import { DomTools } from './domtools.classes.domtools.js';
import { CSSResult, unsafeCSS } from 'lit'; import { CSSResult, unsafeCSS } from 'lit';
export const desktop = 1240; export const desktop = 1600;
export const notebook = 1240;
export const tablet = 1024; export const tablet = 1024;
export const phablet = 600; export const phablet = 600;
export const phone = 400; export const phone = 400;
export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone'; export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone';
export const cssForDesktop = (cssArg: CSSResult) => {
return unsafeCSS(`
@container wccToolsViewport (min-width: ${desktop}px) {
${cssArg.cssText}
}
@media (min-width: ${desktop}px) {
${cssArg.cssText}
}
`);
};
export const cssForNotebook = (cssArg: CSSResult) => {
return unsafeCSS(`
@container wccToolsViewport (max-width: ${notebook}px) {
${cssArg.cssText}
}
@media (max-width: ${notebook}px) {
${cssArg.cssText}
}
`);
};
export const cssForTablet = (cssArg: CSSResult) => { export const cssForTablet = (cssArg: CSSResult) => {
return unsafeCSS(` return unsafeCSS(`
@container wccToolsViewport (max-width: ${tablet}px) { @container wccToolsViewport (max-width: ${tablet}px) {

View File

@ -1,6 +1,6 @@
import * as plugins from './domtools.plugins'; import * as plugins from './domtools.plugins.js';
import { DomTools } from './domtools.classes.domtools'; import { DomTools, IDomToolsContructorOptions } from './domtools.classes.domtools.js';
import { scrollBarStyles, globalBaseStyles } from './domtools.css.basestyles'; 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,11 @@ 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 (
const domTools = await DomTools.setupDomTools(); elementArg?: LitElement,
optionsArg: IDomToolsContructorOptions = {}
): Promise<DomTools> => {
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'; 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

@ -1,20 +1,20 @@
export * from './domtools.colors'; export * from './domtools.colors.js';
import * as elementBasic from './domtools.elementbasic'; import * as elementBasic from './domtools.elementbasic.js';
import * as breakpoints from './domtools.css.breakpoints'; import * as breakpoints from './domtools.css.breakpoints.js';
import * as css from './domtools.css'; import * as css from './domtools.css.js';
export { css, breakpoints, elementBasic }; export { css, breakpoints, elementBasic };
export { DomTools } from './domtools.classes.domtools'; 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';
import * as allPlugins from './domtools.plugins'; import * as allPlugins from './domtools.plugins.js';
export const plugins = { export const plugins = {
smartdelay: allPlugins.smartdelay, smartdelay: allPlugins.smartdelay,
smartpromise: allPlugins.smartpromise, smartpromise: allPlugins.smartpromise,
SweetScroll: allPlugins.SweetScroll, SweetScroll: allPlugins.SweetScroll,
smartstate: allPlugins.smartstate smartstate: allPlugins.smartstate,
}; };

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"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"
}