Compare commits
224 Commits
Author | SHA1 | Date | |
---|---|---|---|
5ffa5a2adc | |||
16d1375e47 | |||
30eda34f37 | |||
2cc7eb1ead | |||
64f5bee801 | |||
9d57f983dd | |||
8ccd21df36 | |||
c22c994d12 | |||
01369444b7 | |||
4beb15f70c | |||
30170bcd2e | |||
f29a8de504 | |||
965ab02315 | |||
991784eae6 | |||
b474b7986c | |||
98542252cb | |||
0d78deadf2 | |||
5108f47e56 | |||
7d4e5f2ca7 | |||
c0ad0f4570 | |||
d56eb602a9 | |||
f1c791eb12 | |||
e872188be7 | |||
2d712e78b0 | |||
ebeecd0686 | |||
1d09f994c6 | |||
686c3714fc | |||
e29086036c | |||
78e24aa720 | |||
7c8876c835 | |||
2222fb1e01 | |||
46b30a1ef0 | |||
d49d5f70ef | |||
76a950e2ba | |||
077aba5e58 | |||
857362423f | |||
e7232b6a53 | |||
2eb26544b3 | |||
a40834d1cf | |||
0c1159d4c7 | |||
4584765046 | |||
5817068cb5 | |||
8fa01fbaad | |||
9cdae8ccdb | |||
7e1c5f3dbb | |||
1f3f17247c | |||
f07f2bb95e | |||
0b2f6715e0 | |||
e473364d40 | |||
554b72b075 | |||
2c34ec8b39 | |||
e6b8e2de19 | |||
a99d270ef1 | |||
93ee42135c | |||
f3ca4a114a | |||
7515b824eb | |||
18b98b831a | |||
d99fc8bde9 | |||
f8d5f86814 | |||
9c1de08b4b | |||
7f26337e1b | |||
49f3fc8feb | |||
5613ad7fa6 | |||
5af43900c4 | |||
c5598f95ef | |||
13d0cf729c | |||
032e928dde | |||
14ab3682f2 | |||
c554e730a6 | |||
4d5a490e80 | |||
7708c89fe1 | |||
0a0be3e357 | |||
7b7c469fab | |||
d852186888 | |||
6cfda1ebf3 | |||
8e0062fdd5 | |||
844cc30551 | |||
64074e37fc | |||
cd9b028e9b | |||
81da871e38 | |||
90e78a2e31 | |||
5cec1fea73 | |||
52130d67e2 | |||
a73ad40eb1 | |||
6589818b0b | |||
555fa32ac2 | |||
50a84f2422 | |||
c724a3e85b | |||
b47530e254 | |||
b80fdf113e | |||
963edbffa3 | |||
f3687f724f | |||
a736ee9800 | |||
bea2047092 | |||
7d98ac8f38 | |||
32244bb450 | |||
b154631c77 | |||
466a24ac10 | |||
7db91a2fe6 | |||
46652dec6f | |||
50e591b80c | |||
6710a163a9 | |||
a39f43f79a | |||
964520a2f9 | |||
6e680085a4 | |||
286a843b67 | |||
df7c5ebafc | |||
9927323a9d | |||
66f3e66c8b | |||
c68b0c5090 | |||
53ac03507d | |||
0031b51bcf | |||
67a8c6e591 | |||
806390a068 | |||
508b18bc3b | |||
c2499ea507 | |||
c0c91aec94 | |||
a27008a295 | |||
7e11627618 | |||
968ce63a53 | |||
7c0eb3290f | |||
62403625ba | |||
9a34b03540 | |||
8bb63df7e3 | |||
65cd73845a | |||
8534bc254b | |||
2a2fd324a0 | |||
58e3de2559 | |||
c30736870d | |||
cfd48de885 | |||
462df2b648 | |||
f64da93cf9 | |||
a55db621ef | |||
c033bdfc3b | |||
2610e56ec1 | |||
08aa9e3fe4 | |||
411ae7ee07 | |||
41700c1eb1 | |||
8d7bac9793 | |||
0229eefa4d | |||
61f646743a | |||
e3babde7e8 | |||
c389e43e93 | |||
1511db4eea | |||
d713756034 | |||
17d224332d | |||
32dd5e769b | |||
12ace00a90 | |||
bbc09330c9 | |||
82ead7bd1a | |||
f8f9b150b8 | |||
494e8b7e26 | |||
c76d364071 | |||
760e0085f7 | |||
6890ca1f1f | |||
9ca000cf06 | |||
1c0f5129a9 | |||
69e17949f4 | |||
bcfd3495dd | |||
03a46a72c5 | |||
2465ce5f9b | |||
00ac83f205 | |||
67065b1ffb | |||
783c10479f | |||
d4eae1cd9e | |||
4e674f67c5 | |||
889a543780 | |||
fc5f3a9576 | |||
66644364b5 | |||
51febdae06 | |||
745ff299dc | |||
3606d60ba6 | |||
8970a79141 | |||
566a7ce148 | |||
362bef15e3 | |||
446c494863 | |||
dbe2f2f217 | |||
02ca92a431 | |||
a9015e787c | |||
9cd28fa819 | |||
7b3793e943 | |||
a22c04d98d | |||
5367512292 | |||
9c387f8ace | |||
c3ec288d09 | |||
9d952afebb | |||
621262fde7 | |||
e3e79d9a11 | |||
d08a92814e | |||
a6f277250e | |||
09cb82d587 | |||
316e2a0b27 | |||
e0d2679801 | |||
107800a057 | |||
4ee8512ee4 | |||
f75a3714ae | |||
d6047f2e78 | |||
03769c8412 | |||
1a782eb4ee | |||
a27adf25cb | |||
96e237b9af | |||
710e06b2f1 | |||
a3bc25c4ac | |||
ee5b712a37 | |||
879ae5ad91 | |||
2bbda416b2 | |||
de88957857 | |||
aa0c63d569 | |||
d843f27fd3 | |||
a26755b7d3 | |||
345a562a21 | |||
3fae99554d | |||
ed30ed3f8f | |||
beef47959b | |||
aec2cf18fd | |||
0f45633666 | |||
8588888ce7 | |||
2a62a635cd | |||
0eb2557956 | |||
9960bf7018 | |||
f26f0d0450 | |||
53fadfcbd5 | |||
497d3a3ac5 | |||
37524765ae |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @git.zone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
@ -10,11 +10,9 @@
|
|||||||
/>
|
/>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
<link rel="preconnect" href="https://rsms.me/">
|
<!--Lets load standard fonts-->
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://assetbroker.lossless.one/" crossorigin>
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link rel="stylesheet" href="https://assetbroker.lossless.one/fonts/fonts.css">
|
||||||
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&family=Courier+Prime:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// dees tools
|
// dees tools
|
||||||
import * as deesWccTools from '@designestate/dees-wcctools';
|
import * as deesWccTools from '@design.estate/dees-wcctools';
|
||||||
import * as deesDomTools from '@designestate/dees-domtools';
|
import * as deesDomTools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
// elements and pages
|
// elements and pages
|
||||||
import * as elements from '../ts_web/elements/index.js';
|
import * as elements from '../ts_web/elements/index.js';
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
"projectType": "wcc",
|
"projectType": "wcc",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "designestate",
|
"gitscope": "design.estate",
|
||||||
"gitrepo": "dees-catalog",
|
"gitrepo": "dees-catalog",
|
||||||
"description": "a webcomponents catalog for handling daily stuff on the web",
|
"description": "a webcomponents catalog for handling daily stuff on the web",
|
||||||
"npmPackagename": "@designestate/dees-catalog",
|
"npmPackagename": "@design.estate/dees-catalog",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "design.estate"
|
"projectDomain": "design.estate"
|
||||||
}
|
}
|
||||||
|
46
package.json
46
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@designestate/dees-catalog",
|
"name": "@design.estate/dees-catalog",
|
||||||
"version": "1.0.155",
|
"version": "1.0.267",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "website for lossless.com",
|
"description": "website for lossless.com",
|
||||||
"main": "dist_ts_web/index.js",
|
"main": "dist_ts_web/index.js",
|
||||||
@ -15,25 +15,33 @@
|
|||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@designestate/dees-domtools": "^2.0.28",
|
"@design.estate/dees-domtools": "^2.0.57",
|
||||||
"@designestate/dees-element": "^2.0.19",
|
"@design.estate/dees-element": "^2.0.33",
|
||||||
"@designestate/dees-wcctools": "^1.0.76",
|
"@design.estate/dees-wcctools": "^1.0.87",
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.3.0",
|
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
||||||
"@fortawesome/free-brands-svg-icons": "^6.3.0",
|
"@fortawesome/free-brands-svg-icons": "^6.5.1",
|
||||||
"@fortawesome/free-regular-svg-icons": "^6.3.0",
|
"@fortawesome/free-regular-svg-icons": "^6.5.1",
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.3.0",
|
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
||||||
"@pushrocks/smartpromise": "^3.1.7",
|
"@push.rocks/smarti18n": "^1.0.4",
|
||||||
"@tsclass/tsclass": "^4.0.34",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"pdfjs-dist": "^2.15.349"
|
"@push.rocks/smartstring": "^4.0.13",
|
||||||
|
"@tsclass/tsclass": "^4.0.46",
|
||||||
|
"@webcontainer/api": "^1.1.8",
|
||||||
|
"highlight.js": "11.9.0",
|
||||||
|
"ibantools": "^4.3.9",
|
||||||
|
"monaco-editor": "^0.45.0",
|
||||||
|
"pdfjs-dist": "^4.0.379",
|
||||||
|
"xterm": "^5.3.0",
|
||||||
|
"xterm-addon-fit": "^0.8.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.65",
|
"@git.zone/tsbuild": "^2.1.72",
|
||||||
"@gitzone/tsbundle": "^2.0.7",
|
"@git.zone/tsbundle": "^2.0.15",
|
||||||
"@gitzone/tstest": "^1.0.74",
|
"@git.zone/tstest": "^1.0.86",
|
||||||
"@gitzone/tswatch": "^2.0.5",
|
"@git.zone/tswatch": "^2.0.21",
|
||||||
"@pushrocks/projectinfo": "^5.0.1",
|
"@push.rocks/projectinfo": "^5.0.2",
|
||||||
"@pushrocks/tapbundle": "^5.0.4",
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
"@types/node": "^18.15.9"
|
"@types/node": "^20.11.5"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
6290
pnpm-lock.yaml
generated
6290
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
24
readme.md
24
readme.md
@ -1,26 +1,26 @@
|
|||||||
# @designestate/dees-catalog
|
# @design.estate/dees-catalog
|
||||||
a webcomponents catalog for handling daily stuff on the web
|
a webcomponents catalog for handling daily stuff on the web
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@designestate/dees-catalog)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@design.estate/dees-catalog)
|
||||||
* [gitlab.com (source)](https://gitlab.com/designestate/dees-catalog)
|
* [gitlab.com (source)](https://gitlab.com/design.estate/dees-catalog)
|
||||||
* [github.com (source mirror)](https://github.com/designestate/dees-catalog)
|
* [github.com (source mirror)](https://github.com/design.estate/dees-catalog)
|
||||||
* [docs (typedoc)](https://designestate.gitlab.io/dees-catalog/)
|
* [docs (typedoc)](https://design.estate.gitlab.io/dees-catalog/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
Status Category | Status Badge
|
Status Category | Status Badge
|
||||||
-- | --
|
-- | --
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
npm | [](https://lossless.cloud)
|
npm | [](https://lossless.cloud)
|
||||||
Snyk | [](https://lossless.cloud)
|
Snyk | [](https://lossless.cloud)
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { tap, expect, webhelpers } from '@pushrocks/tapbundle';
|
import { tap, expect, webhelpers } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
import * as deesCatalog from '../ts_web';
|
import * as deesCatalog from '../ts_web';
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@designestate/dees-catalog',
|
name: '@design.estate/dees-catalog',
|
||||||
version: '1.0.155',
|
version: '1.0.267',
|
||||||
description: 'website for lossless.com'
|
description: 'website for lossless.com'
|
||||||
}
|
}
|
||||||
|
13
ts_web/elements/00colors.ts
Normal file
13
ts_web/elements/00colors.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export const dark = {
|
||||||
|
blue: '#0050b9',
|
||||||
|
blueActive: '#0069f2',
|
||||||
|
blueMuted: '#012452',
|
||||||
|
text: '#ffffff',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const bright = {
|
||||||
|
blue: '#0050b9',
|
||||||
|
blueActive: '#0069f2',
|
||||||
|
blueMuted: '#0069f2',
|
||||||
|
text: '#333333',
|
||||||
|
}
|
13
ts_web/elements/00plugins.ts
Normal file
13
ts_web/elements/00plugins.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// @push.rocks scope
|
||||||
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartpromise,
|
||||||
|
}
|
||||||
|
|
||||||
|
// @tsclass scope
|
||||||
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
|
export {
|
||||||
|
tsclass
|
||||||
|
}
|
@ -3,11 +3,12 @@ import {
|
|||||||
customElement,
|
customElement,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
html,
|
html,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
css,
|
css,
|
||||||
|
type CSSResult,
|
||||||
state,
|
state,
|
||||||
property
|
property
|
||||||
} from '@designestate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
@customElement('dees-button-exit')
|
@customElement('dees-button-exit')
|
||||||
export class DeesButtonExit extends DeesElement {
|
export class DeesButtonExit extends DeesElement {
|
||||||
|
15
ts_web/elements/dees-button.demo.ts
Normal file
15
ts_web/elements/dees-button.demo.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<dees-button>This is a slotted Text</dees-button>
|
||||||
|
<p>
|
||||||
|
<dees-button text="Highlighted: This text shows" type="highlighted">Highlighted</dees-button>
|
||||||
|
</p>
|
||||||
|
<p><dees-button type="discreet">This is discreete button</dees-button></p>
|
||||||
|
<p><dees-button disabled>This is a disabled button</dees-button></p>
|
||||||
|
<p><dees-button type="big">This is a slotted Text</dees-button></p>
|
||||||
|
<p><dees-button status="normal">Normal Status</dees-button></p>
|
||||||
|
<p><dees-button disabled status="pending">Pending Status</dees-button></p>
|
||||||
|
<p><dees-button disabled status="success">Success Status</dees-button></p>
|
||||||
|
<p><dees-button disabled status="error">Error Status</dees-button></p>
|
||||||
|
`;
|
@ -1,15 +1,17 @@
|
|||||||
|
import { demoFunc } from './dees-button.demo.js';
|
||||||
import {
|
import {
|
||||||
customElement,
|
customElement,
|
||||||
html,
|
html,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
|
type CSSResult,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
} from '@designestate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -19,17 +21,7 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-button')
|
@customElement('dees-button')
|
||||||
export class DeesButton extends DeesElement {
|
export class DeesButton extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = demoFunc;
|
||||||
<dees-button>This is a slotted Text</dees-button>
|
|
||||||
<p><dees-button text="Highlighted: This text shows" type="highlighted">Highlighted</dees-button></p>
|
|
||||||
<p><dees-button type="discreet">This is discreete button</dees-button></p>
|
|
||||||
<p><dees-button disabled>This is a disabled button</dees-button></p>
|
|
||||||
<p><dees-button type="big">This is a slotted Text</dees-button></p>
|
|
||||||
<p><dees-button status="normal">Normal Status</dees-button></p>
|
|
||||||
<p><dees-button disabled status="pending">Pending Status</dees-button></p>
|
|
||||||
<p><dees-button disabled status="success">Success Status</dees-button></p>
|
|
||||||
<p><dees-button disabled status="error">Error Status</dees-button></p>
|
|
||||||
`;
|
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
reflect: true,
|
reflect: true,
|
||||||
@ -73,6 +65,7 @@ export class DeesButton extends DeesElement {
|
|||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
font-family: 'Roboto', 'monospace';
|
||||||
}
|
}
|
||||||
:host([hidden]) {
|
:host([hidden]) {
|
||||||
display: none;
|
display: none;
|
||||||
@ -87,7 +80,7 @@ export class DeesButton extends DeesElement {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: ${cssManager.bdTheme('#fff', '#333')};
|
background: ${cssManager.bdTheme('#fff', '#333')};
|
||||||
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
box-shadow: ${cssManager.bdTheme('0px 1px 3px rgba(0,0,0,0.3)', 'none')};
|
||||||
border: 1px solid ${cssManager.bdTheme('#eee', '#333')};
|
border: 1px solid ${cssManager.bdTheme('#eee', '#333')};
|
||||||
border-top: ${cssManager.bdTheme('1px solid #eee', '1px solid #444')};
|
border-top: ${cssManager.bdTheme('1px solid #eee', '1px solid #444')};
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@ -100,16 +93,15 @@ export class DeesButton extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.button:hover {
|
.button:hover {
|
||||||
cursor: pointer;
|
background: #0050b9;
|
||||||
background: #039be5;
|
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
border: 1px solid #039be5;
|
border: 1px solid #0050b9;
|
||||||
border-top: 1px solid #039be5;
|
border-top: 1px solid #0050b9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button:active {
|
.button:active {
|
||||||
background: #0277bd;
|
background: #0069f2;
|
||||||
border-top: 1px solid #0277bd;
|
border-top: 1px solid #0069f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button.disabled {
|
.button.disabled {
|
||||||
@ -153,8 +145,8 @@ export class DeesButton extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.button.pending {
|
.button.pending {
|
||||||
border: 1px dashed ${cssManager.bdTheme('#0277bd', '#0277bd70')};
|
border: 1px dashed ${cssManager.bdTheme('#0069f2', '#0069f270')};
|
||||||
background: ${cssManager.bdTheme('#0277bd', '#0277bd70')};
|
background: ${cssManager.bdTheme('#0069f2', '#0069f270')};
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
41
ts_web/elements/dees-chips.demo.ts
Normal file
41
ts_web/elements/dees-chips.demo.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<style>
|
||||||
|
.demoContainer {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
background: #222;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="demoContainer">
|
||||||
|
<dees-chips
|
||||||
|
selectionMode="none"
|
||||||
|
.selectableChips=${[
|
||||||
|
{ key: 'account1', value: 'Payment Account 1' },
|
||||||
|
{ key: 'account2', value: 'PaymentAccount2' },
|
||||||
|
{ key: 'account3', value: 'Payment Account 3' },
|
||||||
|
]}
|
||||||
|
></dees-chips>
|
||||||
|
<dees-chips
|
||||||
|
selectionMode="single"
|
||||||
|
chipsAreRemovable
|
||||||
|
.selectableChips=${[
|
||||||
|
{ key: 'account1', value: 'Payment Account 1' },
|
||||||
|
{ key: 'account2', value: 'PaymentAccount2' },
|
||||||
|
{ key: 'account3', value: 'Payment Account 3' },
|
||||||
|
]}
|
||||||
|
></dees-chips>
|
||||||
|
<dees-chips
|
||||||
|
selectionMode="multiple"
|
||||||
|
.selectableChips=${[
|
||||||
|
{ key: 'account1', value: 'Payment Account 1' },
|
||||||
|
{ key: 'account2', value: 'PaymentAccount2' },
|
||||||
|
{ key: 'account3', value: 'Payment Account 3' },
|
||||||
|
]}
|
||||||
|
></dees-chips>
|
||||||
|
</div>
|
||||||
|
`;
|
@ -3,13 +3,15 @@ import {
|
|||||||
html,
|
html,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
|
type CSSResult,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
} from '@designestate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
import { demoFunc } from './dees-chips.demo.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -17,30 +19,32 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Tag = { key: string; value: string };
|
||||||
|
|
||||||
@customElement('dees-chips')
|
@customElement('dees-chips')
|
||||||
export class DeesChips extends DeesElement {
|
export class DeesChips extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = demoFunc;
|
||||||
<dees-chips .selectableChips=${['Payment Account 1', 'PaymentAccount2', 'Payment Account 3']}></dees-chips>
|
|
||||||
<dees-chips selectionMode="multiple" .selectableChips=${['Payment Account 1', 'PaymentAccount2', 'Payment Account 3']}></dees-chips>
|
|
||||||
|
|
||||||
`;
|
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public selectionMode: 'single' | 'multiple' = 'single';
|
public selectionMode: 'none' | 'single' | 'multiple' = 'single';
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Array
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public selectableChips: string[] = [];
|
public chipsAreRemovable: boolean = false;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Array,
|
||||||
|
})
|
||||||
|
public selectableChips: Tag[] = [];
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public selectedChip: string = null;
|
public selectedChip: Tag = null;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Array
|
type: Array,
|
||||||
})
|
})
|
||||||
public selectedChips: string[] = [];
|
public selectedChips: Tag[] = [];
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -49,47 +53,87 @@ export class DeesChips extends DeesElement {
|
|||||||
public static styles = [
|
public static styles = [
|
||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mainbox {
|
.mainbox {
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip {
|
.chip {
|
||||||
background: #494949;
|
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
|
||||||
display: inline-block;
|
background: #333333;
|
||||||
padding: 8px 12px;
|
display: inline-flex;
|
||||||
font-size: 14px;
|
height: 20px;
|
||||||
|
line-height: 20px;
|
||||||
|
padding: 0px 8px;
|
||||||
|
font-size: 12px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border-radius: 40px;
|
border-radius: 40px;
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 4px;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip:hover {
|
.chip:hover {
|
||||||
background: #666666;
|
background: #666666;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip.selected {
|
.chip.selected {
|
||||||
background: #00A3FF;
|
background: #00a3ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chipKey {
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
height: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: -8px;
|
||||||
|
padding-left: 8px;
|
||||||
|
padding-right: 8px;
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
dees-icon {
|
||||||
|
padding: 0px 6px 0px 4px;
|
||||||
|
margin-left: 4px;
|
||||||
|
margin-right: -8px;
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
dees-icon:hover {
|
||||||
|
background: #e4002b;
|
||||||
}
|
}
|
||||||
|
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<div class="mainbox">
|
<div class="mainbox">
|
||||||
${this.selectableChips.map(chipArg => html`
|
${this.selectableChips.map(
|
||||||
<div @click=${() => this.selectChip(chipArg)} class="chip ${this.selectedChip === chipArg || this.selectedChips.includes(chipArg) ? 'selected' : ''}">
|
(chip) => html`
|
||||||
${chipArg}
|
<div
|
||||||
</div>
|
@click=${() => this.selectChip(chip)}
|
||||||
`)}
|
class="chip ${this.isSelected(chip) ? 'selected' : ''}"
|
||||||
|
>
|
||||||
|
${chip.key ? html`<div class="chipKey">${chip.key}</div>` : html``} ${chip.value}
|
||||||
|
${this.chipsAreRemovable
|
||||||
|
? html`
|
||||||
|
<dees-icon
|
||||||
|
@click=${(event: Event) => {
|
||||||
|
event.stopPropagation(); // prevent the selectChip event from being triggered
|
||||||
|
this.removeChip(chip);
|
||||||
|
}}
|
||||||
|
.iconFA=${'xmark'}
|
||||||
|
></dees-icon>
|
||||||
|
`
|
||||||
|
: html``}
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -101,23 +145,51 @@ export class DeesChips extends DeesElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async selectChip(chipArg: string) {
|
private isSelected(chip: Tag): boolean {
|
||||||
if (this.selectionMode === 'single') {
|
if (this.selectionMode === 'single') {
|
||||||
if (this.selectedChip === chipArg) {
|
return this.selectedChip?.key === chip.key;
|
||||||
|
} else {
|
||||||
|
return this.selectedChips.some((selected) => selected.key === chip.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async selectChip(chip: Tag) {
|
||||||
|
if (this.selectionMode === 'none') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.selectionMode === 'single') {
|
||||||
|
if (this.isSelected(chip)) {
|
||||||
this.selectedChip = null;
|
this.selectedChip = null;
|
||||||
this.selectedChips = [];
|
this.selectedChips = [];
|
||||||
} else {
|
} else {
|
||||||
this.selectedChip = chipArg;
|
this.selectedChip = chip;
|
||||||
this.selectedChips = [chipArg];
|
this.selectedChips = [chip];
|
||||||
}
|
}
|
||||||
} else if(this.selectionMode === 'multiple') {
|
} else if (this.selectionMode === 'multiple') {
|
||||||
if (this.selectedChips.includes(chipArg)) {
|
if (this.isSelected(chip)) {
|
||||||
this.selectedChips = this.selectedChips.filter(chipArg2 => chipArg !== chipArg2)
|
this.selectedChips = this.selectedChips.filter((selected) => selected.key !== chip.key);
|
||||||
} else {
|
} else {
|
||||||
this.selectedChips.push(chipArg);
|
this.selectedChips = [...this.selectedChips, chip];
|
||||||
}
|
}
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
console.log(this.selectedChips);
|
console.log(this.selectedChips);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public removeChip(chipToRemove: Tag): void {
|
||||||
|
// Remove the chip from selectableChips
|
||||||
|
this.selectableChips = this.selectableChips.filter((chip) => chip.key !== chipToRemove.key);
|
||||||
|
|
||||||
|
// Remove the chip from selectedChips if present
|
||||||
|
this.selectedChips = this.selectedChips.filter((chip) => chip.key !== chipToRemove.key);
|
||||||
|
|
||||||
|
// If the removed chip was the selectedChip, set selectedChip to null
|
||||||
|
if (this.selectedChip && this.selectedChip.key === chipToRemove.key) {
|
||||||
|
this.selectedChip = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger an update to re-render the component
|
||||||
|
this.requestUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
57
ts_web/elements/dees-contextmenu.demo.ts
Normal file
57
ts_web/elements/dees-contextmenu.demo.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
|
||||||
|
import { DeesContextmenu } from './dees-contextmenu.js';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<style>
|
||||||
|
.withMargin {
|
||||||
|
display: block;
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<dees-button @contextmenu=${(eventArg) => {
|
||||||
|
DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
||||||
|
{
|
||||||
|
name: 'copy',
|
||||||
|
iconName: 'copySolid',
|
||||||
|
action: async () => {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'edit',
|
||||||
|
iconName: 'penToSquare',
|
||||||
|
action: async () => {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},{
|
||||||
|
name: 'paste',
|
||||||
|
iconName: 'pasteSolid',
|
||||||
|
action: async () => {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}}>Right-Click for contextmenu</dees-button>
|
||||||
|
<dees-contextmenu class="withMargin"></dees-contextmenu>
|
||||||
|
<dees-contextmenu
|
||||||
|
class="withMargin"
|
||||||
|
.menuItems=${[
|
||||||
|
{
|
||||||
|
name: 'copy',
|
||||||
|
iconName: 'copySolid',
|
||||||
|
action: async () => {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'edit',
|
||||||
|
iconName: 'penToSquare',
|
||||||
|
action: async () => {},
|
||||||
|
},{
|
||||||
|
name: 'paste',
|
||||||
|
iconName: 'pasteSolid',
|
||||||
|
action: async () => {},
|
||||||
|
},
|
||||||
|
] as plugins.tsclass.website.IMenuItem[]}
|
||||||
|
></dees-contextmenu>
|
||||||
|
`;
|
@ -1,16 +1,19 @@
|
|||||||
import * as plugins from './plugins.js';
|
import * as colors from './00colors.js';
|
||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
import { demoFunc } from './dees-contextmenu.demo.js';
|
||||||
import {
|
import {
|
||||||
customElement,
|
customElement,
|
||||||
html,
|
html,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
|
type CSSResult,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
} from '@designestate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
import { DeesWindowLayer } from './dees-windowlayer.js';
|
import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@ -22,85 +25,80 @@ declare global {
|
|||||||
@customElement('dees-contextmenu')
|
@customElement('dees-contextmenu')
|
||||||
export class DeesContextmenu extends DeesElement {
|
export class DeesContextmenu extends DeesElement {
|
||||||
// DEMO
|
// DEMO
|
||||||
public static demo = () => html`
|
public static demo = demoFunc
|
||||||
<style>
|
|
||||||
.withMargin {
|
|
||||||
display: block;
|
|
||||||
margin: 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<dees-button @contextmenu=${(eventArg) => {
|
|
||||||
DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
|
||||||
{
|
|
||||||
name: 'copy',
|
|
||||||
iconName: 'copySolid',
|
|
||||||
action: async () => {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'edit',
|
|
||||||
iconName: 'penToSquare',
|
|
||||||
action: async () => {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
},{
|
|
||||||
name: 'paste',
|
|
||||||
iconName: 'pasteSolid',
|
|
||||||
action: async () => {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
}}>Hello</dees-button>
|
|
||||||
<dees-contextmenu class="withMargin"></dees-contextmenu>
|
|
||||||
<dees-contextmenu
|
|
||||||
class="withMargin"
|
|
||||||
.menuItems=${[
|
|
||||||
{
|
|
||||||
name: 'copy',
|
|
||||||
iconName: 'copySolid',
|
|
||||||
action: async () => {},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'edit',
|
|
||||||
iconName: 'penToSquare',
|
|
||||||
action: async () => {},
|
|
||||||
},{
|
|
||||||
name: 'paste',
|
|
||||||
iconName: 'pasteSolid',
|
|
||||||
action: async () => {},
|
|
||||||
},
|
|
||||||
] as plugins.tsclass.website.IMenuItem[]}
|
|
||||||
></dees-contextmenu>
|
|
||||||
`;
|
|
||||||
|
|
||||||
// STATIC
|
// STATIC
|
||||||
|
// This will store all the accumulated menu items
|
||||||
|
public static contextMenuDeactivated = false;
|
||||||
|
public static accumulatedMenuItems: plugins.tsclass.website.IMenuItem[] = [];
|
||||||
|
|
||||||
|
// Add a global event listener for the right-click context menu
|
||||||
|
public static initializeGlobalListener() {
|
||||||
|
document.addEventListener('contextmenu', (event: MouseEvent) => {
|
||||||
|
if (this.contextMenuDeactivated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
// Get the target element of the right-click
|
||||||
|
let target: EventTarget | null = event.target;
|
||||||
|
|
||||||
|
// Clear previously accumulated items
|
||||||
|
DeesContextmenu.accumulatedMenuItems = [];
|
||||||
|
|
||||||
|
// Traverse up the DOM tree to accumulate menu items
|
||||||
|
while (target) {
|
||||||
|
if ((target as any).getContextMenuItems) {
|
||||||
|
DeesContextmenu.accumulatedMenuItems.push(...(target as any).getContextMenuItems());
|
||||||
|
}
|
||||||
|
target = (target as Node).parentNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open the context menu with the accumulated items
|
||||||
|
DeesContextmenu.openContextMenuWithOptions(event, DeesContextmenu.accumulatedMenuItems);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// allows opening of a contextmenu with options
|
||||||
public static async openContextMenuWithOptions(eventArg: MouseEvent, menuItemsArg: plugins.tsclass.website.IMenuItem[]) {
|
public static async openContextMenuWithOptions(eventArg: MouseEvent, menuItemsArg: plugins.tsclass.website.IMenuItem[]) {
|
||||||
|
if (this.contextMenuDeactivated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
eventArg.preventDefault();
|
eventArg.preventDefault();
|
||||||
|
eventArg.stopPropagation();
|
||||||
const contextMenu = new DeesContextmenu();
|
const contextMenu = new DeesContextmenu();
|
||||||
contextMenu.style.position = 'absolute';
|
contextMenu.style.position = 'fixed';
|
||||||
|
contextMenu.style.zIndex = '2000';
|
||||||
contextMenu.style.top = `${eventArg.clientY.toString()}px`;
|
contextMenu.style.top = `${eventArg.clientY.toString()}px`;
|
||||||
contextMenu.style.left = `${eventArg.clientX.toString()}px`;
|
contextMenu.style.left = `${eventArg.clientX.toString()}px`;
|
||||||
contextMenu.style.opacity = '0';
|
contextMenu.style.opacity = '0';
|
||||||
contextMenu.style.transform = 'scale(0.95,0.95)';
|
contextMenu.style.transform = 'scale(0.95,0.95)';
|
||||||
contextMenu.style.transformOrigin = 'top left';
|
contextMenu.style.transformOrigin = 'top left';
|
||||||
contextMenu.menuItems = menuItemsArg;
|
contextMenu.menuItems = menuItemsArg;
|
||||||
|
contextMenu.windowLayer = await DeesWindowLayer.createAndShow();
|
||||||
|
contextMenu.windowLayer.addEventListener('click', async () => {
|
||||||
|
await contextMenu.destroy();
|
||||||
|
})
|
||||||
document.body.append(contextMenu);
|
document.body.append(contextMenu);
|
||||||
await domtools.plugins.smartdelay.delayFor(0);
|
await domtools.plugins.smartdelay.delayFor(0);
|
||||||
contextMenu.style.opacity = '1';
|
contextMenu.style.opacity = '1';
|
||||||
contextMenu.style.transform = 'scale(1,1)';
|
contextMenu.style.transform = 'scale(1,1)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
@property({
|
@property({
|
||||||
type: Array,
|
type: Array,
|
||||||
})
|
})
|
||||||
public menuItems: plugins.tsclass.website.IMenuItem[] = [];
|
public menuItems: plugins.tsclass.website.IMenuItem[] = [];
|
||||||
|
windowLayer: DeesWindowLayer;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* STATIC STYLES
|
||||||
|
*/
|
||||||
public static styles = [
|
public static styles = [
|
||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
@ -113,16 +111,18 @@ export class DeesContextmenu extends DeesElement {
|
|||||||
color: ${cssManager.bdTheme('#222', '#ccc')};
|
color: ${cssManager.bdTheme('#222', '#ccc')};
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
width: 200px;
|
width: 200px;
|
||||||
border: 1px solid #444;
|
border: 1px solid ${cssManager.bdTheme('#fff', '#ffffff10')};
|
||||||
min-height: 40px;
|
min-height: 34px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
background: #222;
|
background: ${cssManager.bdTheme('#fff', '#222')};
|
||||||
box-shadow: 0px 1px 4px #000;
|
box-shadow: 0px 1px 4px ${cssManager.bdTheme('#00000020', '#000000')};
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
padding: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mainbox .menuitem {
|
.mainbox .menuitem {
|
||||||
padding: 8px;
|
padding: 4px 8px;
|
||||||
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mainbox .menuitem dees-icon {
|
.mainbox .menuitem dees-icon {
|
||||||
@ -133,12 +133,10 @@ export class DeesContextmenu extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mainbox .menuitem:hover {
|
.mainbox .menuitem:hover {
|
||||||
cursor: pointer;
|
background: ${cssManager.bdTheme(colors.bright.blue, colors.dark.blue)};
|
||||||
background: #ffffff10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mainbox .menuitem:active {
|
.mainbox .menuitem:active {
|
||||||
cursor: pointer;
|
|
||||||
background: #ffffff05;
|
background: #ffffff05;
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -155,15 +153,21 @@ export class DeesContextmenu extends DeesElement {
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
})}
|
})}
|
||||||
|
${this.menuItems.length === 0 ? html`
|
||||||
|
<div class="menuitem" @click=${() => {
|
||||||
|
DeesContextmenu.contextMenuDeactivated = true;
|
||||||
|
this.destroy();
|
||||||
|
}}>
|
||||||
|
<dees-icon .iconFA=${'xmark'}></dees-icon
|
||||||
|
>allow native context
|
||||||
|
</div>
|
||||||
|
` : html``}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async firstUpdated() {
|
public async firstUpdated() {
|
||||||
if (!this.menuItems || this.menuItems.length === 0) {
|
|
||||||
const mainbox = this.shadowRoot.querySelector('.mainbox');
|
|
||||||
mainbox.textContent = 'no menu items present';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async handleClick(menuItem: plugins.tsclass.website.IMenuItem) {
|
public async handleClick(menuItem: plugins.tsclass.website.IMenuItem) {
|
||||||
@ -172,9 +176,14 @@ export class DeesContextmenu extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async destroy() {
|
public async destroy() {
|
||||||
|
if (this.windowLayer) {
|
||||||
|
this.windowLayer.destroy();
|
||||||
|
}
|
||||||
this.style.opacity = '0';
|
this.style.opacity = '0';
|
||||||
this.style.transform = 'scale(0.95,0,95)';
|
this.style.transform = 'scale(0.95,0,95)';
|
||||||
await domtools.plugins.smartdelay.delayFor(100);
|
await domtools.plugins.smartdelay.delayFor(100);
|
||||||
this.parentElement.removeChild(this);
|
this.parentElement.removeChild(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeesContextmenu.initializeGlobalListener();
|
||||||
|
18
ts_web/elements/dees-dataview-codebox.demo.ts
Normal file
18
ts_web/elements/dees-dataview-codebox.demo.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html` <style>
|
||||||
|
.demoWrapper {
|
||||||
|
box-sizing: border-box;
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="demoWrapper">
|
||||||
|
<dees-dataview-codebox proglang="typescript">
|
||||||
|
import * as text from './hello'; const hiThere = 'nice'; const myFunction = async () => {
|
||||||
|
console.log('nice one'); }
|
||||||
|
</dees-dataview-codebox>
|
||||||
|
</div>`
|
237
ts_web/elements/dees-dataview-codebox.ts
Normal file
237
ts_web/elements/dees-dataview-codebox.ts
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
import { demoFunc } from './dees-dataview-codebox.demo.js';
|
||||||
|
import {
|
||||||
|
DeesElement,
|
||||||
|
html,
|
||||||
|
customElement,
|
||||||
|
type TemplateResult,
|
||||||
|
property,
|
||||||
|
state,
|
||||||
|
cssManager,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import hlight from 'highlight.js';
|
||||||
|
|
||||||
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
|
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
import { DeesContextmenu } from './dees-contextmenu.js';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-dataview-codebox': DeesDataviewCodebox;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-dataview-codebox')
|
||||||
|
export class DeesDataviewCodebox extends DeesElement {
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
@property()
|
||||||
|
public progLang: string = 'typescript';
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
|
public codeToDisplay: string = '';
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
${domtools.elementBasic.styles}
|
||||||
|
<style>
|
||||||
|
:host {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
text-align: left;
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
|
}
|
||||||
|
.mainbox {
|
||||||
|
position: relative;
|
||||||
|
color: ${this.goBright ? '#333333' : '#ffffff'};
|
||||||
|
border-top: 1px solid ${this.goBright ? '#ffffff' : '#333333'};
|
||||||
|
box-shadow: 0px 0px 5px ${this.goBright ? 'rgba(0,0,0,0.1)' : 'rgba(0,0,0,0.5)'};
|
||||||
|
background: ${this.goBright ? '#ffffff' : '#191919'};
|
||||||
|
border-radius: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appbar {
|
||||||
|
position: relative;
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
|
background: ${cssManager.bdTheme('#ffffff', '#161616')};
|
||||||
|
border-bottom: 1px solid ${cssManager.bdTheme('#eeeeeb', '#222222')};
|
||||||
|
height: 24px;
|
||||||
|
display: flex;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 24px;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appbar .fileName {
|
||||||
|
line-height: inherit;
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottomBar {
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
|
background: ${cssManager.bdTheme('#ffffff', '#161616')};
|
||||||
|
border-top: 1px solid ${cssManager.bdTheme('#eeeeeb', '#222222')};
|
||||||
|
height: 24px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 24px;
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.languageLabel {
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 24px;
|
||||||
|
z-index: 10;
|
||||||
|
background: #6596ff20;
|
||||||
|
display: inline-block;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
right: 0px;
|
||||||
|
padding: 0px 16px 0px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-keyword {
|
||||||
|
color: #ff65ec;
|
||||||
|
}
|
||||||
|
|
||||||
|
.codegrid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 50px auto;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lineNumbers {
|
||||||
|
color: ${this.goBright ? '#acacac' : '#666666'};
|
||||||
|
padding: 30px 16px 0px 0px;
|
||||||
|
text-align: right;
|
||||||
|
border-right: 1px solid ${this.goBright ? '#eaeaea' : '#222222'};
|
||||||
|
}
|
||||||
|
|
||||||
|
.lineCounter:last-child {
|
||||||
|
opacity: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
overflow-x: auto;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 30px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-weight: ${this.goBright ? '400' : '300'};
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
code,
|
||||||
|
code *,
|
||||||
|
.lineNumbers {
|
||||||
|
line-height: 1.4em;
|
||||||
|
font-weight: 200;
|
||||||
|
font-family: 'Intel One Mono', 'monospace';
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-string {
|
||||||
|
color: #ffa465;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-built_in {
|
||||||
|
color: #65ff6a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-function {
|
||||||
|
color: ${this.goBright ? '#2765DF' : '#6596ff'};
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-params {
|
||||||
|
color: ${this.goBright ? '#3DB420' : '#65d5ff'};
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-comment {
|
||||||
|
color: ${this.goBright ? '#EF9300' : '#ffd765'};
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div
|
||||||
|
class="mainbox"
|
||||||
|
@contextmenu="${(eventArg) => {
|
||||||
|
DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
||||||
|
{
|
||||||
|
name: 'About',
|
||||||
|
iconName: 'circleInfo',
|
||||||
|
action: async () => {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}}"
|
||||||
|
>
|
||||||
|
<div class="appbar">
|
||||||
|
<dees-windowcontrols type="mac" position="left"></dees-windowcontrols>
|
||||||
|
<div class="fileName">index.ts</div>
|
||||||
|
<dees-windowcontrols type="mac" position="right"></dees-windowcontrols>
|
||||||
|
</div>
|
||||||
|
<div class="codegrid">
|
||||||
|
<div class="lineNumbers">
|
||||||
|
${(() => {
|
||||||
|
let lineCounter = 0;
|
||||||
|
return this.codeToDisplay.split('\n').map((lineArg) => {
|
||||||
|
lineCounter++;
|
||||||
|
return html`<div class="lineCounter">${lineCounter}</div>`;
|
||||||
|
});
|
||||||
|
})()}
|
||||||
|
</div>
|
||||||
|
<pre><code></code></pre>
|
||||||
|
</div>
|
||||||
|
<div class="bottomBar">
|
||||||
|
Spaces: 2
|
||||||
|
<div class="languageLabel">${this.progLang}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
@state()
|
||||||
|
private codeToDisplayStore = '';
|
||||||
|
|
||||||
|
public async updated(_changedProperties) {
|
||||||
|
super.updated(_changedProperties);
|
||||||
|
console.log('highlighting now');
|
||||||
|
console.log(this.childNodes);
|
||||||
|
const slottedCodeNodes: Text[] = [];
|
||||||
|
this.childNodes.forEach((childNode) => {
|
||||||
|
if (childNode.nodeName === '#text') {
|
||||||
|
slottedCodeNodes.push(childNode as Text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (this.codeToDisplay && this.codeToDisplay !== this.codeToDisplayStore) {
|
||||||
|
this.codeToDisplayStore = smartstring.indent.normalize(this.codeToDisplay).trimStart();
|
||||||
|
}
|
||||||
|
if (slottedCodeNodes[0] && slottedCodeNodes[0].wholeText && !this.codeToDisplay) {
|
||||||
|
this.codeToDisplayStore = smartstring.indent
|
||||||
|
.normalize(slottedCodeNodes[0].wholeText)
|
||||||
|
.trimStart();
|
||||||
|
this.codeToDisplay = this.codeToDisplayStore;
|
||||||
|
}
|
||||||
|
await domtools.plugins.smartdelay.delayFor(0);
|
||||||
|
const localCodeNode = this.shadowRoot.querySelector('code');
|
||||||
|
const html = hlight.highlight(this.codeToDisplayStore, {
|
||||||
|
language: this.progLang,
|
||||||
|
ignoreIllegals: true,
|
||||||
|
});
|
||||||
|
localCodeNode.innerHTML = html.value;
|
||||||
|
}
|
||||||
|
}
|
49
ts_web/elements/dees-dataview-statusobject.demo.ts
Normal file
49
ts_web/elements/dees-dataview-statusobject.demo.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { html, cssManager } from '@design.estate/dees-element';
|
||||||
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
|
export const demoFunc = () => html` <style>
|
||||||
|
.demo {
|
||||||
|
background: ${cssManager.bdTheme('#eeeeeb', '#000000')};
|
||||||
|
display: block;
|
||||||
|
content: '';
|
||||||
|
padding: 40px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="demo">
|
||||||
|
<dees-dataview-statusobject
|
||||||
|
.statusObject=${{
|
||||||
|
id: '1',
|
||||||
|
name: 'Demo Item',
|
||||||
|
combinedStatus: 'partly_ok',
|
||||||
|
combinedStatusText: 'partly_ok',
|
||||||
|
details: [
|
||||||
|
{
|
||||||
|
name: 'Detail 1',
|
||||||
|
value: 'Value 1',
|
||||||
|
status: 'ok',
|
||||||
|
statusText: 'OK',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Detail 2',
|
||||||
|
value: 'Value 2',
|
||||||
|
status: 'partly_ok',
|
||||||
|
statusText: 'partly_ok',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Detail 3',
|
||||||
|
value: 'Value 3',
|
||||||
|
status: 'not_ok',
|
||||||
|
statusText: 'not_ok',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Detail 4',
|
||||||
|
value:
|
||||||
|
'Value 4 jhdkfjhalskdfjhfdjskalsdkfjhfdjskalskdjfhjdkslaksjdhfjdkslaskdfjhfjdkslaskdjfhjdskalskdjhfdjskalskdjfhdjskl',
|
||||||
|
status: 'ok',
|
||||||
|
statusText: 'OK',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
} as tsclass.code.IStatusObject}
|
||||||
|
>
|
||||||
|
</dees-dataview-statusobject>
|
||||||
|
</div>`;
|
165
ts_web/elements/dees-dataview-statusobject.ts
Normal file
165
ts_web/elements/dees-dataview-statusobject.ts
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
import * as colors from './00colors.js';
|
||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
|
||||||
|
import { demoFunc } from './dees-dataview-statusobject.demo.js';
|
||||||
|
import {
|
||||||
|
DeesElement,
|
||||||
|
html,
|
||||||
|
customElement,
|
||||||
|
type TemplateResult,
|
||||||
|
property,
|
||||||
|
state,
|
||||||
|
cssManager,
|
||||||
|
css,
|
||||||
|
type CSSResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-dataview-statusobject': DeesDataviewStatusobject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-dataview-statusobject')
|
||||||
|
export class DeesDataviewStatusobject extends DeesElement {
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
@property({ type: Object }) statusObject: tsclass.code.IStatusObject;
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
.mainbox {
|
||||||
|
border-radius: 8px;
|
||||||
|
background: ${cssManager.bdTheme('#fff', '#1b1b1b')};
|
||||||
|
box-shadow: 0px 1px 3px #00000030;
|
||||||
|
min-height: 48px;
|
||||||
|
color: ${cssManager.bdTheme('#000', '#fff')};
|
||||||
|
border-top: ${cssManager.bdTheme('none', '1px solid #ffffff10')};
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading {
|
||||||
|
display: grid;
|
||||||
|
align-items: center;
|
||||||
|
grid-template-columns: 40px auto 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
display: block;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
height: 48px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusdot {
|
||||||
|
height: 8px;
|
||||||
|
width: 8px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: grey;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copyMain {
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
border: 1px solid ${cssManager.bdTheme('#e0e0e0', '#444')};
|
||||||
|
text-align: center;
|
||||||
|
padding: 4px;
|
||||||
|
border-radius: 3px;
|
||||||
|
margin-right: 16px;
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ffffff80')};
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copyMain:hover {
|
||||||
|
background: ${cssManager.bdTheme(colors.bright.blue, colors.dark.blue)};
|
||||||
|
border: 1px solid ${cssManager.bdTheme(colors.bright.blue, colors.dark.blue)};
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copyMain:active {
|
||||||
|
background: ${cssManager.bdTheme(colors.bright.blueActive, colors.dark.blueActive)};
|
||||||
|
border: 1px solid ${cssManager.bdTheme(colors.bright.blueActive, colors.dark.blueActive)};
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusdot.ok {
|
||||||
|
background: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusdot.not_ok{
|
||||||
|
background: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusdot.partly_ok {
|
||||||
|
background: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail {
|
||||||
|
min-height: 60px;
|
||||||
|
align-items: center;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 40px auto;
|
||||||
|
border-top: 1px dotted ${cssManager.bdTheme('#e0e0e0', '#282828')};
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail:hover {
|
||||||
|
background: #ffffff05;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail:active {
|
||||||
|
background: #ffffff10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail .detailsText {
|
||||||
|
padding-top: 8px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
padding-right: 8px;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail .detailsText .label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #ffffff80
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail .detailsText .value {
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: 'Intel One Mono';
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<div class="mainbox">
|
||||||
|
<div class="heading">
|
||||||
|
<div class="statusdot ${this.statusObject?.combinedStatus}"></div>
|
||||||
|
<h1>${this.statusObject?.name || 'no status object assigned'}</h1>
|
||||||
|
<div class="copyMain">Copy as JSON</div>
|
||||||
|
</div>
|
||||||
|
${this.statusObject?.details?.map((detailArg) => {
|
||||||
|
return html`
|
||||||
|
<div class="detail">
|
||||||
|
<div class="statusdot ${detailArg.status}"></div>
|
||||||
|
<div class="detailsText">
|
||||||
|
<div class="label">${detailArg.name}</div>
|
||||||
|
<div class="value">${detailArg.value}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async firstUpdated() {}
|
||||||
|
}
|
98
ts_web/elements/dees-editor-markdown.ts
Normal file
98
ts_web/elements/dees-editor-markdown.ts
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import {
|
||||||
|
DeesElement,
|
||||||
|
property,
|
||||||
|
html,
|
||||||
|
customElement,
|
||||||
|
type TemplateResult,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
domtools
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
const deferred = domtools.plugins.smartpromise.defer();
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-editormarkdown': DeesEditorMarkdown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-editormarkdown')
|
||||||
|
export class DeesEditorMarkdown extends DeesElement {
|
||||||
|
public static demo = () => html`<dees-editormarkdown></dees-editormarkdown>`;
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
.gridcontainer {
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 60% 40%;
|
||||||
|
}
|
||||||
|
.editorContainer {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.outletContainer {
|
||||||
|
background: #111;
|
||||||
|
color: #fff;
|
||||||
|
font-family: 'Roboto Slab';
|
||||||
|
padding: 20px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render() {
|
||||||
|
return html`
|
||||||
|
<div class="gridcontainer">
|
||||||
|
<div class="editorContainer">
|
||||||
|
<dees-editor
|
||||||
|
.language=${'markdown'}
|
||||||
|
.content=${`# a test content
|
||||||
|
|
||||||
|
This is test content that is of longer form an hopefully starts to wrap when I need it. And yes, it does perfectly. nice.
|
||||||
|
|
||||||
|
Test | Hello
|
||||||
|
--- | ---
|
||||||
|
Yeah | So good
|
||||||
|
|
||||||
|
This is real asset I think. Why would we want to leave that on the table? Can you tell my that?
|
||||||
|
|
||||||
|
Why are we here?
|
||||||
|
|
||||||
|
Do you know?
|
||||||
|
|
||||||
|
> note:
|
||||||
|
There is something going on.
|
||||||
|
|
||||||
|
\`\`\`typescript
|
||||||
|
const hello = 'yes'
|
||||||
|
\`\`\`
|
||||||
|
`}
|
||||||
|
wordWrap="bounded"
|
||||||
|
></dees-editor>
|
||||||
|
</div>
|
||||||
|
<div class="outletContainer">
|
||||||
|
<dees-editormarkdownoutlet></dees-editormarkdownoutlet>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async firstUpdated(_changedPropertiesArg) {
|
||||||
|
await super.firstUpdated(_changedPropertiesArg);
|
||||||
|
const editor = this.shadowRoot.querySelector('dees-editor');
|
||||||
|
|
||||||
|
// lets care about wiring the markdown stuff.
|
||||||
|
const markdownOutlet = this.shadowRoot.querySelector('dees-editormarkdownoutlet');
|
||||||
|
const smartmarkdownInstance = new domtools.plugins.smartmarkdown.SmartMarkdown();
|
||||||
|
const mdParsedResult = await smartmarkdownInstance.getMdParsedResultFromMarkdown('loading...')
|
||||||
|
editor.contentSubject.subscribe(async contentArg => {
|
||||||
|
await mdParsedResult.updateFromMarkdownString(contentArg)
|
||||||
|
const html = mdParsedResult.html;
|
||||||
|
markdownOutlet.updateHtmlText(html);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
42
ts_web/elements/dees-editor-markdownoutlet.ts
Normal file
42
ts_web/elements/dees-editor-markdownoutlet.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { customElement, DeesElement, html, type TemplateResult } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-editormarkdownoutlet': DeesEditorMarkdownOutlet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-editormarkdownoutlet')
|
||||||
|
export class DeesEditorMarkdownOutlet extends DeesElement {
|
||||||
|
// DEMO
|
||||||
|
public static demo = () => html`<dees-editormarkdownoutlet></dees-editormarkdownoutlet>`;
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
private outlet: HTMLElement;
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<div class="outlet markdown-body">
|
||||||
|
<h1>Hi there</h1>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async firstUpdated(_changedProperties: Map<string | number | symbol, unknown>) {
|
||||||
|
await super.firstUpdated(_changedProperties);
|
||||||
|
const styleElement = document.createElement('style');
|
||||||
|
const cssText = await (
|
||||||
|
await fetch('https://unpkg.com/github-markdown-css@5.1.0/github-markdown-dark.css')
|
||||||
|
).text();
|
||||||
|
styleElement.textContent = cssText;
|
||||||
|
this.shadowRoot.append(styleElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async updateHtmlText(htmlTextArg: string) {
|
||||||
|
await this.updateComplete;
|
||||||
|
if (!this.outlet) {
|
||||||
|
this.outlet = this.shadowRoot.querySelector('.outlet');
|
||||||
|
}
|
||||||
|
this.outlet.innerHTML = htmlTextArg;
|
||||||
|
}
|
||||||
|
}
|
126
ts_web/elements/dees-editor.ts
Normal file
126
ts_web/elements/dees-editor.ts
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
import {
|
||||||
|
DeesElement,
|
||||||
|
property,
|
||||||
|
html,
|
||||||
|
customElement,
|
||||||
|
type TemplateResult,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
|
import type * as monaco from 'monaco-editor';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-editor': DeesEditor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-editor')
|
||||||
|
export class DeesEditor extends DeesElement {
|
||||||
|
// DEMO
|
||||||
|
public static demo = () => html` <dees-editor></dees-editor> `;
|
||||||
|
|
||||||
|
// STATIC
|
||||||
|
public static monacoDeferred: ReturnType<typeof domtools.plugins.smartpromise.defer>;
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
public editorDeferred = domtools.plugins.smartpromise.defer<monaco.editor.IStandaloneCodeEditor>();
|
||||||
|
public language = 'typescript';
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String
|
||||||
|
})
|
||||||
|
public content = "function hello() {\n\talert('Hello world!');\n}";
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Object
|
||||||
|
})
|
||||||
|
public contentSubject = new domtools.plugins.smartrx.rxjs.Subject<string>();
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Boolean
|
||||||
|
})
|
||||||
|
public wordWrap: monaco.editor.IStandaloneEditorConstructionOptions['wordWrap'] = 'off';
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
domtools.DomTools.setupDomTools();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
domtools.elementBasic.staticStyles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container {
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<div class="mainbox">
|
||||||
|
<div id="container"></div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async firstUpdated(
|
||||||
|
_changedProperties: Map<string | number | symbol, unknown>
|
||||||
|
): Promise<void> {
|
||||||
|
super.firstUpdated(_changedProperties);
|
||||||
|
const container = this.shadowRoot.getElementById('container');
|
||||||
|
|
||||||
|
if (!DeesEditor.monacoDeferred) {
|
||||||
|
DeesEditor.monacoDeferred = domtools.plugins.smartpromise.defer();
|
||||||
|
const scriptUrl = `https://cdn.jsdelivr.net/npm/monaco-editor/min/vs/loader.js`;
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.src = scriptUrl;
|
||||||
|
script.onload = () => {
|
||||||
|
DeesEditor.monacoDeferred.resolve();
|
||||||
|
};
|
||||||
|
document.head.appendChild(script);
|
||||||
|
}
|
||||||
|
await DeesEditor.monacoDeferred.promise;
|
||||||
|
|
||||||
|
(window as any).require.config({
|
||||||
|
paths: { vs: 'https://cdn.jsdelivr.net/npm/monaco-editor/min/vs' },
|
||||||
|
});
|
||||||
|
(window as any).require(['vs/editor/editor.main'], async () => {
|
||||||
|
const editor = ((window as any).monaco.editor as typeof monaco.editor).create(container, {
|
||||||
|
value: this.content,
|
||||||
|
language: this.language,
|
||||||
|
theme: 'vs-dark',
|
||||||
|
useShadowDOM: true,
|
||||||
|
fontSize: 16,
|
||||||
|
automaticLayout: true,
|
||||||
|
wordWrap: this.wordWrap
|
||||||
|
});
|
||||||
|
this.editorDeferred.resolve(editor);
|
||||||
|
});
|
||||||
|
const css = await (
|
||||||
|
await fetch('https://cdn.jsdelivr.net/npm/monaco-editor/min/vs/editor/editor.main.css')
|
||||||
|
).text();
|
||||||
|
const styleElement = document.createElement('style');
|
||||||
|
styleElement.textContent = css;
|
||||||
|
this.shadowRoot.append(styleElement);
|
||||||
|
|
||||||
|
|
||||||
|
// editor is setup let do the rest
|
||||||
|
const editor = await this.editorDeferred.promise;
|
||||||
|
editor.onDidChangeModelContent(async eventArg => {
|
||||||
|
this.contentSubject.next(editor.getValue());
|
||||||
|
});
|
||||||
|
this.contentSubject.next(editor.getValue());
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,8 @@ import {
|
|||||||
css,
|
css,
|
||||||
cssManager,
|
cssManager,
|
||||||
property,
|
property,
|
||||||
} from '@designestate/dees-element';
|
type CSSResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
import { DeesForm } from './dees-form.js';
|
import { DeesForm } from './dees-form.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@ -20,6 +21,7 @@ export class DeesFormSubmit extends DeesElement {
|
|||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
reflect: true,
|
||||||
})
|
})
|
||||||
public disabled = false;
|
public disabled = false;
|
||||||
|
|
||||||
@ -29,7 +31,7 @@ export class DeesFormSubmit extends DeesElement {
|
|||||||
public text: string;
|
public text: string;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String
|
type: String,
|
||||||
})
|
})
|
||||||
public status: 'normal' | 'pending' | 'success' | 'error' = 'normal';
|
public status: 'normal' | 'pending' | 'success' | 'error' = 'normal';
|
||||||
|
|
||||||
@ -41,7 +43,12 @@ export class DeesFormSubmit extends DeesElement {
|
|||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return html`
|
return html`
|
||||||
<dees-button status=${this.status} @click=${this.submit} .disabled=${this.disabled} .text=${this.text ? this.text : this.textContent}>
|
<dees-button
|
||||||
|
status=${this.status}
|
||||||
|
@click=${this.submit}
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
.text=${this.text ? this.text : this.textContent}
|
||||||
|
>
|
||||||
</dees-button>
|
</dees-button>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -53,4 +60,12 @@ export class DeesFormSubmit extends DeesElement {
|
|||||||
const parentElement: DeesForm = this.parentElement as DeesForm;
|
const parentElement: DeesForm = this.parentElement as DeesForm;
|
||||||
parentElement.gatherAndDispatch();
|
parentElement.gatherAndDispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async focus() {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
if (!this.disabled) {
|
||||||
|
domtools.convenience.smartdelay.delayFor(0);
|
||||||
|
this.submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
69
ts_web/elements/dees-form.demo.ts
Normal file
69
ts_web/elements/dees-form.demo.ts
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import { html, domtools, cssManager } from '@design.estate/dees-element';
|
||||||
|
import type { DeesForm } from './dees-form.js';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<style>
|
||||||
|
.demoContainer {
|
||||||
|
max-width: 400px;
|
||||||
|
margin: 24px auto;
|
||||||
|
padding: 16px;
|
||||||
|
background: ${cssManager.bdTheme('#eeeeeb', '#111')};
|
||||||
|
box-shadow: 0px 1px 3px #00000030;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="demoContainer">
|
||||||
|
<dees-form
|
||||||
|
style="display: block; margin:auto; max-width: 500px; padding: 20px"
|
||||||
|
@formData=${async (eventArg) => {
|
||||||
|
const form: DeesForm = eventArg.currentTarget;
|
||||||
|
form.setStatus('pending', 'authenticating...');
|
||||||
|
await domtools.plugins.smartdelay.delayFor(1000);
|
||||||
|
form.setStatus('success', 'authenticated!');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<dees-input-dropdown
|
||||||
|
.label=${'title'}
|
||||||
|
.options=${[
|
||||||
|
{ option: 'option 1', key: 'option1' },
|
||||||
|
{ option: 'option 2', key: 'option2' },
|
||||||
|
{ option: 'option 3', key: 'option3' },
|
||||||
|
]}
|
||||||
|
></dees-input-dropdown>
|
||||||
|
<dees-input-multiselect
|
||||||
|
.label=${'title'}
|
||||||
|
.options=${[
|
||||||
|
{ option: 'option 1', key: 'option1' },
|
||||||
|
{ option: 'option 2', key: 'option2' },
|
||||||
|
{ option: 'option 3', key: 'option3' },
|
||||||
|
]}></dees-input-multiselect>
|
||||||
|
<dees-input-typelist
|
||||||
|
.label=${'a type list'}
|
||||||
|
></dees-input-typelist>
|
||||||
|
<dees-input-text .required="${true}" key="hello1" label="a text" .description=${`
|
||||||
|
This is an awesome description.
|
||||||
|
`}></dees-input-text>
|
||||||
|
<dees-input-text .required="${true}" key="hello2" label="also a text"></dees-input-text>
|
||||||
|
<dees-input-text
|
||||||
|
.required="${true}"
|
||||||
|
key="hello3"
|
||||||
|
label="a password"
|
||||||
|
isPasswordBool
|
||||||
|
></dees-input-text>
|
||||||
|
<dees-input-checkbox
|
||||||
|
.required="${true}"
|
||||||
|
key="hello3"
|
||||||
|
label="another text"
|
||||||
|
></dees-input-checkbox>
|
||||||
|
<dees-input-iban></dees-input-iban>
|
||||||
|
<dees-input-multitoggle
|
||||||
|
.label=${'multi select'}
|
||||||
|
.options=${['option 1', 'option 2', 'option 3']}
|
||||||
|
.selectedOption=${'option 1'}
|
||||||
|
></dees-input-multitoggle>
|
||||||
|
<dees-input-fileupload
|
||||||
|
.label=${'attachments'}
|
||||||
|
></dees-input-fileupload>
|
||||||
|
<dees-form-submit>Submit</dees-form-submit>
|
||||||
|
</dees-form>
|
||||||
|
</div>
|
||||||
|
`;
|
@ -1,15 +1,38 @@
|
|||||||
import { customElement, html, TemplateResult, DeesElement } from '@designestate/dees-element';
|
import {
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
customElement,
|
||||||
|
html,
|
||||||
|
type TemplateResult,
|
||||||
|
DeesElement,
|
||||||
|
type CSSResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
import { DeesInputCheckbox } from './dees-input-checkbox.js';
|
import { DeesInputCheckbox } from './dees-input-checkbox.js';
|
||||||
import { DeesInputText } from './dees-input-text.js';
|
import { DeesInputText } from './dees-input-text.js';
|
||||||
import { DeesInputQuantitySelector } from './dees-input-quantityselector.js';
|
import { DeesInputQuantitySelector } from './dees-input-quantityselector.js';
|
||||||
import { DeesInputRadio } from './dees-input-radio.js';
|
import { DeesInputRadio } from './dees-input-radio.js';
|
||||||
import { DeesFormSubmit } from './dees-form-submit.js';
|
import { DeesFormSubmit } from './dees-form-submit.js';
|
||||||
|
import { DeesTable } from './dees-table.js';
|
||||||
|
import { demoFunc } from './dees-form.demo.js';
|
||||||
|
import { DeesInputIban } from './dees-input-iban.js';
|
||||||
|
|
||||||
export type TFormElement = Array<
|
// Unified set for form input types
|
||||||
DeesInputCheckbox | DeesInputText | DeesInputQuantitySelector | DeesInputRadio
|
const FORM_INPUT_TYPES = [
|
||||||
>;
|
DeesInputCheckbox,
|
||||||
|
DeesInputIban,
|
||||||
|
DeesInputText,
|
||||||
|
DeesInputQuantitySelector,
|
||||||
|
DeesInputRadio,
|
||||||
|
DeesTable,
|
||||||
|
];
|
||||||
|
|
||||||
|
export type TFormInputElement =
|
||||||
|
| DeesInputCheckbox
|
||||||
|
| DeesInputIban
|
||||||
|
| DeesInputText
|
||||||
|
| DeesInputQuantitySelector
|
||||||
|
| DeesInputRadio
|
||||||
|
| DeesTable<any>;
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -19,29 +42,11 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-form')
|
@customElement('dees-form')
|
||||||
export class DeesForm extends DeesElement {
|
export class DeesForm extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = demoFunc;
|
||||||
<dees-form
|
|
||||||
style="display: block; margin:auto; max-width: 500px; padding: 20px"
|
|
||||||
@formData=${async (eventArg) => {
|
|
||||||
const form: DeesForm = eventArg.currentTarget;
|
|
||||||
form.setStatus('pending', 'authenticating...');
|
|
||||||
await domtools.plugins.smartdelay.delayFor(1000);
|
|
||||||
form.setStatus('success', 'authenticated!');
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<dees-input-text .required="${true}" key="hello1" label="a text"></dees-input-text>
|
|
||||||
<dees-input-text .required="${true}" key="hello2" label="also a text"></dees-input-text>
|
|
||||||
<dees-input-checkbox
|
|
||||||
.required="${true}"
|
|
||||||
key="hello3"
|
|
||||||
label="another text"
|
|
||||||
></dees-input-checkbox>
|
|
||||||
<dees-form-submit>Submit</dees-form-submit>
|
|
||||||
</dees-form>
|
|
||||||
`;
|
|
||||||
|
|
||||||
public name: string = 'myform';
|
public name: string = 'myform';
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
public readyDeferred = domtools.plugins.smartpromise.defer();
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
@ -54,51 +59,39 @@ export class DeesForm extends DeesElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public firstUpdated() {
|
public async firstUpdated() {
|
||||||
const formChildren = this.getFormChildren();
|
const formChildren = this.getFormElements();
|
||||||
this.checkRequiredStatus();
|
this.updateRequiredStatus();
|
||||||
|
|
||||||
for (const child of formChildren) {
|
for (const child of formChildren) {
|
||||||
child.changeSubject.subscribe(async (elementArg: TFormElement) => {
|
child.changeSubject.subscribe(async () => {
|
||||||
const valueObject = await this.gatherData();
|
const valueObject = await this.collectFormData();
|
||||||
this.changeSubject.next(valueObject);
|
this.changeSubject.next(valueObject);
|
||||||
console.log(valueObject);
|
console.log(valueObject);
|
||||||
this.checkRequiredStatus();
|
this.updateRequiredStatus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
await this.addBehaviours();
|
||||||
|
this.readyDeferred.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFormChildren() {
|
public getFormElements(): Array<TFormInputElement> {
|
||||||
const children: Array<DeesElement> = this.children as any;
|
return Array.from(this.children).filter((child) =>
|
||||||
const formChildren: TFormElement = [];
|
FORM_INPUT_TYPES.includes(child.constructor as any)
|
||||||
|
) as unknown as TFormInputElement[];
|
||||||
for (const child of children) {
|
|
||||||
if (
|
|
||||||
child instanceof DeesInputCheckbox ||
|
|
||||||
child instanceof DeesInputText ||
|
|
||||||
child instanceof DeesInputQuantitySelector
|
|
||||||
) {
|
|
||||||
formChildren.push(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return formChildren;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSubmitButton() {
|
public getSubmitButton(): DeesFormSubmit | undefined {
|
||||||
const children: Array<DeesElement> = this.children as any;
|
return Array.from(this.children).find(
|
||||||
let submitButton: DeesFormSubmit;
|
(child) => child instanceof DeesFormSubmit
|
||||||
for (const childArg of children) {
|
) as DeesFormSubmit;
|
||||||
if (childArg instanceof DeesFormSubmit) {
|
|
||||||
submitButton = childArg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return submitButton;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async checkRequiredStatus() {
|
public async updateRequiredStatus() {
|
||||||
console.log('checking the required status.');
|
console.log('checking the required status.');
|
||||||
|
|
||||||
let requiredOK = true;
|
let requiredOK = true;
|
||||||
for (const childArg of this.getFormChildren()) {
|
for (const childArg of this.getFormElements()) {
|
||||||
if (childArg.required && !childArg.value) {
|
if (childArg.required && !childArg.value) {
|
||||||
requiredOK = false;
|
requiredOK = false;
|
||||||
}
|
}
|
||||||
@ -108,17 +101,20 @@ export class DeesForm extends DeesElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async gatherData() {
|
public async collectFormData() {
|
||||||
const children = this.getFormChildren();
|
const children = this.getFormElements();
|
||||||
const valueObject: { [key: string]: string | number | boolean } = {};
|
const valueObject: { [key: string]: string | number | boolean | any[] } = {};
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
|
if (!child.key) {
|
||||||
|
console.log(`form element with label "${child.label}" has no key. skipping.`);
|
||||||
|
}
|
||||||
valueObject[child.key] = child.value;
|
valueObject[child.key] = child.value;
|
||||||
}
|
}
|
||||||
return valueObject;
|
return valueObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async gatherAndDispatch() {
|
public async gatherAndDispatch() {
|
||||||
const valueObject = await this.gatherData();
|
const valueObject = await this.collectFormData();
|
||||||
const formDataEvent = new CustomEvent('formData', {
|
const formDataEvent = new CustomEvent('formData', {
|
||||||
detail: {
|
detail: {
|
||||||
data: valueObject,
|
data: valueObject,
|
||||||
@ -134,7 +130,7 @@ export class DeesForm extends DeesElement {
|
|||||||
visualStateArg: 'normal' | 'pending' | 'error' | 'success',
|
visualStateArg: 'normal' | 'pending' | 'error' | 'success',
|
||||||
textStateArg: string
|
textStateArg: string
|
||||||
) {
|
) {
|
||||||
const inputChildren = this.getFormChildren();
|
const inputChildren = this.getFormElements();
|
||||||
const submitButton = this.getSubmitButton();
|
const submitButton = this.getSubmitButton();
|
||||||
|
|
||||||
switch (visualStateArg) {
|
switch (visualStateArg) {
|
||||||
@ -170,4 +166,36 @@ export class DeesForm extends DeesElement {
|
|||||||
|
|
||||||
submitButton.text = textStateArg;
|
submitButton.text = textStateArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* resets the form
|
||||||
|
*/
|
||||||
|
reset() {
|
||||||
|
const inputChildren = this.getFormElements();
|
||||||
|
const submitButton = this.getSubmitButton();
|
||||||
|
|
||||||
|
for (const inputChild of inputChildren) {
|
||||||
|
inputChild.value = null;
|
||||||
|
}
|
||||||
|
this.setStatus('normal', 'Submit');
|
||||||
|
}
|
||||||
|
|
||||||
|
public async addBehaviours() {
|
||||||
|
// Use event delegation
|
||||||
|
this.addEventListener('keydown', (event: KeyboardEvent) => {
|
||||||
|
const target = event.target as DeesElement;
|
||||||
|
if (!FORM_INPUT_TYPES.includes(target.constructor as any)) return;
|
||||||
|
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
const children = this.getFormElements();
|
||||||
|
const currentIndex = children.indexOf(target as any);
|
||||||
|
if (currentIndex < children.length - 1) {
|
||||||
|
children[currentIndex + 1].focus();
|
||||||
|
} else {
|
||||||
|
target.blur();
|
||||||
|
this.getSubmitButton()?.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
5
ts_web/elements/dees-hint.demo.ts
Normal file
5
ts_web/elements/dees-hint.demo.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<dees-hint></dees-hint>
|
||||||
|
`;
|
38
ts_web/elements/dees-hint.ts
Normal file
38
ts_web/elements/dees-hint.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import {
|
||||||
|
DeesElement,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
property,
|
||||||
|
type CSSResult,
|
||||||
|
type TemplateResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
import { demoFunc } from './dees-hint.demo.js';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-hint': DeesHint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-hint')
|
||||||
|
export class DeesHint extends DeesElement {
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
@property({ type: String })
|
||||||
|
public type: 'info' | 'warn' | 'error' | 'critical' = 'info';
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
domtools.elementBasic.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static styles = [cssManager.defaultStyles, css``];
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html` <div class="mainbox"></div> `;
|
||||||
|
}
|
||||||
|
}
|
55
ts_web/elements/dees-icon.demo.ts
Normal file
55
ts_web/elements/dees-icon.demo.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import { faIcons } from './dees-icon.js';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<style>
|
||||||
|
.demoContainer {
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
background: #111111;
|
||||||
|
padding: 10px; font-size: 30px;
|
||||||
|
}
|
||||||
|
dees-icon {
|
||||||
|
transition: color 0.02s;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
dees-icon:hover {
|
||||||
|
color: #e4002b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.iconContainer {
|
||||||
|
display: block;
|
||||||
|
padding: 16px 16px 0px 16px;
|
||||||
|
border: 1px solid #333333;
|
||||||
|
margin-right: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.iconName {
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
color: #ccc;
|
||||||
|
background: #333333;
|
||||||
|
padding: 4px 8px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
margin-left: -16px;
|
||||||
|
margin-right: -16px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="demoContainer">
|
||||||
|
${Object.keys(faIcons).map(
|
||||||
|
(iconName) => html`
|
||||||
|
<div class="iconContainer">
|
||||||
|
<dees-icon .iconFA=${iconName as any}></dees-icon>
|
||||||
|
<div class="iconName">${iconName}</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
`;
|
@ -5,11 +5,12 @@ import {
|
|||||||
customElement,
|
customElement,
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
} from '@designestate/dees-element';
|
type CSSResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
import { icon, IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
import { icon, type IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
||||||
import {
|
import {
|
||||||
faFacebook,
|
faFacebook,
|
||||||
faGoogle,
|
faGoogle,
|
||||||
@ -28,6 +29,7 @@ import {
|
|||||||
faMessage as faMessageRegular,
|
faMessage as faMessageRegular,
|
||||||
faPaste as faPasteRegular,
|
faPaste as faPasteRegular,
|
||||||
faSun as faSunRegular,
|
faSun as faSunRegular,
|
||||||
|
faTrashCan as faTrashCanRegular,
|
||||||
} from '@fortawesome/free-regular-svg-icons';
|
} from '@fortawesome/free-regular-svg-icons';
|
||||||
import {
|
import {
|
||||||
faArrowRight as faArrowRightSolid,
|
faArrowRight as faArrowRightSolid,
|
||||||
@ -41,74 +43,88 @@ import {
|
|||||||
faCircleInfo as faCircleInfoSolid,
|
faCircleInfo as faCircleInfoSolid,
|
||||||
faCircleCheck as faCircleCheckSolid,
|
faCircleCheck as faCircleCheckSolid,
|
||||||
faCircleXmark as faCircleXmarkSolid,
|
faCircleXmark as faCircleXmarkSolid,
|
||||||
|
faClockRotateLeft as faClockRotateLeftSolid,
|
||||||
faCopy as faCopySolid,
|
faCopy as faCopySolid,
|
||||||
faDesktop as faDesktopSolid,
|
faDesktop as faDesktopSolid,
|
||||||
faEye as faEyeSolid,
|
faEye as faEyeSolid,
|
||||||
faEyeSlash as faEyeSlashSolid,
|
faEyeSlash as faEyeSlashSolid,
|
||||||
|
faFileInvoice as faFileInvoiceSolid,
|
||||||
|
faFileInvoiceDollar as faFileInvoiceDollarSolid,
|
||||||
|
faGear as faGearSolid,
|
||||||
faGrip as faGripSolid,
|
faGrip as faGripSolid,
|
||||||
|
faMagnifyingGlass as faMagnifyingGlassSolid,
|
||||||
faMessage as faMessageSolid,
|
faMessage as faMessageSolid,
|
||||||
|
faMoneyCheckDollar as faMoneyCheckDollarSolid,
|
||||||
faMugHot as faMugHotSolid,
|
faMugHot as faMugHotSolid,
|
||||||
faMinus as faMinusSolid,
|
faMinus as faMinusSolid,
|
||||||
|
faNetworkWired as faNetworkWiredSolid,
|
||||||
|
faPaperclip as faPaperclipSolid,
|
||||||
faPaste as faPasteSolid,
|
faPaste as faPasteSolid,
|
||||||
faPenToSquare as faPenToSquareSolid,
|
faPenToSquare as faPenToSquareSolid,
|
||||||
|
faPlus as faPlusSolid,
|
||||||
|
faReceipt as faReceiptSolid,
|
||||||
faRss as faRssSolid,
|
faRss as faRssSolid,
|
||||||
faUsers as faUsersSolid,
|
faUsers as faUsersSolid,
|
||||||
faShare as faShareSolid,
|
faShare as faShareSolid,
|
||||||
faSun as faSunSolid,
|
faSun as faSunSolid,
|
||||||
|
faTerminal as faTerminalSolid,
|
||||||
|
faTrash as faTrashSolid,
|
||||||
|
faTrashCan as faTrashCanSolid,
|
||||||
|
faWallet as faWalletSolid,
|
||||||
faXmark as faXmarkSolid,
|
faXmark as faXmarkSolid,
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
|
import { demoFunc } from './dees-icon.demo.js';
|
||||||
|
|
||||||
export const faIcons = {
|
export const faIcons = {
|
||||||
// normal
|
// normal
|
||||||
arrowRight: faArrowRightSolid,
|
arrowRight: faArrowRightSolid,
|
||||||
arrowUpRightFromSquare: faArrowUpRightFromSquareSolid,
|
arrowUpRightFromSquare: faArrowUpRightFromSquareSolid,
|
||||||
arrowUpRightFromSquareSolid: faArrowUpRightFromSquareSolid,
|
|
||||||
bell: faBellSolid,
|
bell: faBellSolid,
|
||||||
bellSolid: faBellSolid,
|
|
||||||
bug: faBugSolid,
|
bug: faBugSolid,
|
||||||
bugSolid: faBugSolid,
|
|
||||||
building: faBuildingSolid,
|
building: faBuildingSolid,
|
||||||
buildingSolid: faBuildingSolid,
|
|
||||||
caretLeft: faCaretLeftSolid,
|
caretLeft: faCaretLeftSolid,
|
||||||
caretLeftSolid: faCaretLeftSolid,
|
|
||||||
caretRight: faCaretRightSolid,
|
caretRight: faCaretRightSolid,
|
||||||
caretRightSolid: faCaretRightSolid,
|
|
||||||
check: faCheckSolid,
|
check: faCheckSolid,
|
||||||
checkSolid: faCheckSolid,
|
|
||||||
circleInfo: faCircleInfoSolid,
|
circleInfo: faCircleInfoSolid,
|
||||||
circleInfoSolid: faCircleInfoSolid,
|
|
||||||
circleCheck: faCircleCheckRegular,
|
circleCheck: faCircleCheckRegular,
|
||||||
circleCheckSolid: faCircleCheckSolid,
|
circleCheckSolid: faCircleCheckSolid,
|
||||||
circleXmark: faCircleXmarkRegular,
|
circleXmark: faCircleXmarkRegular,
|
||||||
circleXmarkSolid: faCircleXmarkSolid,
|
circleXmarkSolid: faCircleXmarkSolid,
|
||||||
|
clockRotateLeft: faClockRotateLeftSolid,
|
||||||
copy: faCopyRegular,
|
copy: faCopyRegular,
|
||||||
copySolid: faCopySolid,
|
copySolid: faCopySolid,
|
||||||
desktop: faDesktopSolid,
|
desktop: faDesktopSolid,
|
||||||
desktopSolid: faDesktopSolid,
|
|
||||||
eye: faEyeSolid,
|
eye: faEyeSolid,
|
||||||
eyeSolid: faEyeSolid,
|
|
||||||
eyeSlash: faEyeSlashSolid,
|
eyeSlash: faEyeSlashSolid,
|
||||||
eyeSlashSolid: faEyeSlashSolid,
|
fileInvoice: faFileInvoiceSolid,
|
||||||
|
fileInvoiceDoller: faFileInvoiceDollarSolid,
|
||||||
|
gear: faGearSolid,
|
||||||
grip: faGripSolid,
|
grip: faGripSolid,
|
||||||
gripSolid: faGripSolid,
|
magnifyingGlass: faMagnifyingGlassSolid,
|
||||||
message: faMessageRegular,
|
message: faMessageRegular,
|
||||||
messageSolid: faMessageSolid,
|
messageSolid: faMessageSolid,
|
||||||
|
moneyCheckDollar: faMoneyCheckDollarSolid,
|
||||||
mugHot: faMugHotSolid,
|
mugHot: faMugHotSolid,
|
||||||
faMugHotSolid: faMugHotSolid,
|
|
||||||
minus: faMinusSolid,
|
minus: faMinusSolid,
|
||||||
minusSolid: faMinusSolid,
|
networkWired: faNetworkWiredSolid,
|
||||||
|
paperclip: faPaperclipSolid,
|
||||||
paste: faPasteRegular,
|
paste: faPasteRegular,
|
||||||
pasteSolid: faPasteSolid,
|
pasteSolid: faPasteSolid,
|
||||||
penToSquare: faPenToSquareSolid,
|
penToSquare: faPenToSquareSolid,
|
||||||
penToSquareSolid: faPenToSquareSolid,
|
plus: faPlusSolid,
|
||||||
|
receipt: faReceiptSolid,
|
||||||
rss: faRssSolid,
|
rss: faRssSolid,
|
||||||
rssSolid: faRssSolid,
|
|
||||||
share: faShareSolid,
|
share: faShareSolid,
|
||||||
shareSolid: faShareSolid,
|
|
||||||
sun: faSunRegular,
|
sun: faSunRegular,
|
||||||
sunSolid: faSunSolid,
|
sunSolid: faSunSolid,
|
||||||
|
terminal: faTerminalSolid,
|
||||||
|
trash: faTrashSolid,
|
||||||
|
trashSolid: faTrashSolid,
|
||||||
|
trashCan: faTrashCanRegular,
|
||||||
|
trashCanSolid: faTrashCanSolid,
|
||||||
|
users: faUsersSolid,
|
||||||
|
wallet: faWalletSolid,
|
||||||
xmark: faXmarkSolid,
|
xmark: faXmarkSolid,
|
||||||
xmarkSolid: faXmarkSolid,
|
|
||||||
// brands
|
// brands
|
||||||
facebook: faFacebook,
|
facebook: faFacebook,
|
||||||
google: faGoogle,
|
google: faGoogle,
|
||||||
@ -118,9 +134,10 @@ export const faIcons = {
|
|||||||
slack: faSlackHash,
|
slack: faSlackHash,
|
||||||
tiktok: faTiktok,
|
tiktok: faTiktok,
|
||||||
twitter: faTwitter,
|
twitter: faTwitter,
|
||||||
users: faUsersSolid,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TIconKey = keyof typeof faIcons;
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
'dees-icon': DeesIcon;
|
'dees-icon': DeesIcon;
|
||||||
@ -129,24 +146,7 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-icon')
|
@customElement('dees-icon')
|
||||||
export class DeesIcon extends DeesElement {
|
export class DeesIcon extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = demoFunc;
|
||||||
<dees-icon iconName="visibility"></dees-icon>
|
|
||||||
<div style="background: #fff; padding: 10px; font-size: 30px">
|
|
||||||
<style>
|
|
||||||
dees-icon {
|
|
||||||
transition: color 0.05s;
|
|
||||||
}
|
|
||||||
dees-icon:hover {
|
|
||||||
color: #e4002b;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<dees-icon .iconFA=${'messageSolid'}></dees-icon>
|
|
||||||
<dees-icon .iconFA=${'sun'}></dees-icon>
|
|
||||||
<dees-icon .iconFA=${'sunSolid'}></dees-icon>
|
|
||||||
<dees-icon .iconFA=${'facebook'}></dees-icon>
|
|
||||||
<dees-icon .iconFA=${'arrowUpRightFromSquare'}></dees-icon>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String
|
type: String
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
customElement,
|
customElement,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
property,
|
property,
|
||||||
html,
|
html,
|
||||||
css,
|
css,
|
||||||
cssManager
|
cssManager,
|
||||||
} from '@designestate/dees-element';
|
type CSSResult,
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
} from '@design.estate/dees-element';
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -21,10 +22,11 @@ export class DeesInputCheckbox extends DeesElement {
|
|||||||
public static demo = () => html`<dees-input-checkbox></dees-input-checkbox>`;
|
public static demo = () => html`<dees-input-checkbox></dees-input-checkbox>`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
|
reflect: true,
|
||||||
})
|
})
|
||||||
public key: string;
|
public key: string;
|
||||||
|
|
||||||
@ -60,7 +62,10 @@ export class DeesInputCheckbox extends DeesElement {
|
|||||||
display: block;
|
display: block;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 20px 0px;
|
margin: 20px 0px;
|
||||||
cursor: pointer;
|
cursor: default;
|
||||||
|
}
|
||||||
|
:host(:hover) {
|
||||||
|
filter: ${cssManager.bdTheme('brightness(0.95)', 'brightness(1.1)')};
|
||||||
}
|
}
|
||||||
|
|
||||||
.maincontainer {
|
.maincontainer {
|
||||||
@ -98,8 +103,8 @@ export class DeesInputCheckbox extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.checkbox.selected {
|
.checkbox.selected {
|
||||||
background: #039BE5;
|
background: #0050b9;
|
||||||
border: 1px solid #039BE5;
|
border: 1px solid #0050b9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox.disabled {
|
.checkbox.disabled {
|
||||||
@ -143,7 +148,7 @@ export class DeesInputCheckbox extends DeesElement {
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="maincontainer" @click="${this.toggleSelected}">
|
<div class="maincontainer" @click="${this.toggleSelected}">
|
||||||
<div class="checkbox ${this.value ? 'selected' : ''} ${this.disabled ? 'disabled' : ''}">
|
<div class="checkbox ${this.value ? 'selected' : ''} ${this.disabled ? 'disabled' : ''}" tabindex="0">
|
||||||
${this.value
|
${this.value
|
||||||
? html`
|
? html`
|
||||||
<span class="checkmark">
|
<span class="checkmark">
|
||||||
@ -171,4 +176,11 @@ export class DeesInputCheckbox extends DeesElement {
|
|||||||
);
|
);
|
||||||
this.changeSubject.next(this);
|
this.changeSubject.next(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public focus(): void {
|
||||||
|
const checkboxDiv = this.shadowRoot.querySelector('.checkbox');
|
||||||
|
if (checkboxDiv) {
|
||||||
|
(checkboxDiv as any).focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
27
ts_web/elements/dees-input-dropdown.demo.ts
Normal file
27
ts_web/elements/dees-input-dropdown.demo.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<dees-input-dropdown
|
||||||
|
.options=${[
|
||||||
|
{option: 'option 1', key: 'option1'},
|
||||||
|
{option: 'option 2', key: 'option2'},
|
||||||
|
{option: 'option 3', key: 'option3'}
|
||||||
|
]}
|
||||||
|
></dees-input-dropdown>
|
||||||
|
<dees-input-dropdown
|
||||||
|
.enableSearch=${false}
|
||||||
|
.options=${[
|
||||||
|
{option: 'option 1', key: 'option1'},
|
||||||
|
{option: 'option 2', key: 'option2'},
|
||||||
|
{option: 'option 3', key: 'option3'}
|
||||||
|
]}
|
||||||
|
></dees-input-dropdown>
|
||||||
|
<div style="height: 300px"></div>
|
||||||
|
<dees-input-dropdown
|
||||||
|
.options=${[
|
||||||
|
{option: 'option 1', key: 'option1'},
|
||||||
|
{option: 'option 2', key: 'option2'},
|
||||||
|
{option: 'option 3', key: 'option3'}
|
||||||
|
]}
|
||||||
|
></dees-input-dropdown>
|
||||||
|
`
|
@ -1,5 +1,17 @@
|
|||||||
import { customElement, DeesElement, TemplateResult, property, html, css, cssManager } from '@designestate/dees-element';
|
import {
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
customElement,
|
||||||
|
DeesElement,
|
||||||
|
type TemplateResult,
|
||||||
|
property,
|
||||||
|
state,
|
||||||
|
html,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
type CSSResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
import { demoFunc } from './dees-input-dropdown.demo.js';
|
||||||
|
import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -9,165 +21,355 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-input-dropdown')
|
@customElement('dees-input-dropdown')
|
||||||
export class DeesInputDropdown extends DeesElement {
|
export class DeesInputDropdown extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = demoFunc;
|
||||||
<dees-input-dropdown
|
|
||||||
.options=${[
|
|
||||||
{option: 'option 1', key: 'option1'},
|
|
||||||
{option: 'option 2', key: 'option2'},
|
|
||||||
{option: 'option 3', key: 'option3'}
|
|
||||||
]}
|
|
||||||
></dees-input-dropdown>
|
|
||||||
`
|
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property()
|
@property({
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
public label: string = 'Label';
|
public label: string = 'Label';
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public key: string;
|
public key: string;
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public options: {option: string, key: string, payload?: any}[] = [];
|
public options: { option: string; key: string; payload?: any }[] = [];
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public selectedOption: {option: string, key: string, payload?: any} = {
|
public selectedOption: { option: string; key: string; payload?: any } = null;
|
||||||
key: null,
|
|
||||||
option: null,
|
|
||||||
payload: null
|
|
||||||
};
|
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public required: boolean = false;
|
public required: boolean = false;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean
|
type: Boolean,
|
||||||
|
})
|
||||||
|
public enableSearch: boolean = true;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public disabled: boolean = false;
|
public disabled: boolean = false;
|
||||||
|
|
||||||
|
@state()
|
||||||
|
public opensToTop: boolean = false;
|
||||||
|
|
||||||
|
@state()
|
||||||
|
private filteredOptions: { option: string; key: string; payload?: any }[] = [];
|
||||||
|
|
||||||
|
@state()
|
||||||
|
private highlightedIndex: number = 0;
|
||||||
|
|
||||||
|
@state()
|
||||||
|
public isOpened = false;
|
||||||
|
|
||||||
public static styles = [
|
public static styles = [
|
||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
position: relative;
|
font-family: Roboto;
|
||||||
display: block;
|
position: relative;
|
||||||
height: 40px;
|
display: block;
|
||||||
color: ${cssManager.bdTheme('#222', '#fff')};
|
color: ${cssManager.bdTheme('#222', '#fff')};
|
||||||
}
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.maincontainer {
|
.maincontainer {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selectedBox {
|
.selectedBox {
|
||||||
cursor: pointer;
|
user-select: none;
|
||||||
position: relative;
|
position: relative;
|
||||||
max-width: 420px;
|
max-width: 420px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
padding: 0px 8px;
|
padding: 0px 8px;
|
||||||
z-index: 0px;
|
background: ${cssManager.bdTheme('#fafafa', '#222222')};
|
||||||
background: ${cssManager.bdTheme('#ffffff', '#333333')};
|
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
||||||
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
border-radius: 3px;
|
||||||
border-radius: 3px;
|
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #ffffff10')};
|
||||||
border-top: 1px solid #CCCCCC00;
|
border-bottom: ${cssManager.bdTheme('1px solid #CCC', '1px solid #222')};
|
||||||
border-bottom: 1px solid #66666600;
|
transition: all 0.2s ease;
|
||||||
}
|
font-size: 16px;
|
||||||
|
color: ${cssManager.bdTheme('#222', '#ccc')};
|
||||||
|
}
|
||||||
|
|
||||||
.selectedBox.show {
|
.selectedBox:hover {
|
||||||
border-top: 1px solid ${cssManager.bdTheme('#ffffff', '#666666')};
|
filter: ${cssManager.bdTheme('brightness(0.95)', 'brightness(1.1)')};
|
||||||
border-bottom: 1px solid ${cssManager.bdTheme('#fafafa', '#222222')};
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.selectionBox {
|
.accentBottom {
|
||||||
will-change:transform;
|
filter: none !important;
|
||||||
pointer-events: none;
|
}
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
opacity: 0;
|
|
||||||
position: relative;
|
|
||||||
background: ${cssManager.bdTheme('#ffffff', '#222222')};
|
|
||||||
max-width: 420px;
|
|
||||||
box-shadow: 0px 0px 5px rgba(0,0,0,0.2);
|
|
||||||
min-height: 40px;
|
|
||||||
margin-top: -40px;
|
|
||||||
z-index: 100;
|
|
||||||
border-radius: 3px;
|
|
||||||
padding: 4px;
|
|
||||||
transform: scale(0.99,0.99);
|
|
||||||
}
|
|
||||||
|
|
||||||
.selectionBox.show {
|
.accentTop {
|
||||||
pointer-events: all;
|
filter: none !important;
|
||||||
opacity: 1;
|
}
|
||||||
transform: scale(1,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.option {
|
.selectionBox {
|
||||||
transition: all 0.1s;
|
will-change: transform;
|
||||||
line-height: 40px;
|
pointer-events: none;
|
||||||
padding: 0px 4px;
|
transition: all 0.2s ease;
|
||||||
border-radius: 3px;
|
opacity: 0;
|
||||||
}
|
background: ${cssManager.bdTheme('#ffffff', '#222222')};
|
||||||
|
max-width: 420px;
|
||||||
|
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
|
||||||
|
min-height: 40px;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
position: absolute;
|
||||||
|
user-select: none;
|
||||||
|
margin: 3px 0px 0px 0px;
|
||||||
|
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #ffffff10')};
|
||||||
|
}
|
||||||
|
.selectionBox.top {
|
||||||
|
transform: translate(0px, 4px);
|
||||||
|
}
|
||||||
|
.selectionBox.bottom {
|
||||||
|
transform: translate(0px, -4px);
|
||||||
|
}
|
||||||
|
|
||||||
.option:hover {
|
.selectionBox.show {
|
||||||
color: #fff;
|
pointer-events: all;
|
||||||
padding-left: 8px;
|
transform: scale(1, 1) translate(0px, 0px);
|
||||||
background: #0277bd;
|
opacity: 1;
|
||||||
}
|
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.8);
|
||||||
`
|
}
|
||||||
]
|
|
||||||
|
.option {
|
||||||
|
transition: all 0.1s;
|
||||||
|
line-height: 32px;
|
||||||
|
padding: 0px 4px;
|
||||||
|
border-radius: 3px;
|
||||||
|
margin: 4px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option.highlighted {
|
||||||
|
border-left: 2px solid #0069f2;
|
||||||
|
padding-left: 6px;
|
||||||
|
background: #ffffff20;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option:hover {
|
||||||
|
color: #fff;
|
||||||
|
padding-left: 8px;
|
||||||
|
background: #0069f2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search.top {
|
||||||
|
padding-top: 4px;
|
||||||
|
}
|
||||||
|
.search.bottom {
|
||||||
|
padding-bottom: 4px;
|
||||||
|
}
|
||||||
|
.search input {
|
||||||
|
display: block;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
height: 24px;
|
||||||
|
color: inherit;
|
||||||
|
text-align: left;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
width: 100%;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search.top input {
|
||||||
|
border-bottom: 1px dotted #333;
|
||||||
|
}
|
||||||
|
.search.bottom input {
|
||||||
|
border-top: 1px dotted #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search input:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
${domtools.elementBasic.styles}
|
<div class="maincontainer" @keydown="${this.isOpened ? this.handleKeyDown : undefined}">
|
||||||
<style>
|
${this.label ? html`<div class="label">${this.label}</div>` : html``}
|
||||||
|
|
||||||
</style>
|
|
||||||
<div class="maincontainer">
|
|
||||||
<div class="selectedBox show" @click="${event => {this.toggleSelectionBox();}}">
|
|
||||||
${this.selectedOption?.option}
|
|
||||||
</div>
|
|
||||||
<div class="selectionBox">
|
<div class="selectionBox">
|
||||||
${this.options.map(option => {
|
${this.enableSearch && !this.opensToTop
|
||||||
|
? html`
|
||||||
|
<div class="search top">
|
||||||
|
<input type="text" placeholder="Search" @input="${this.handleSearch}" />
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: null}
|
||||||
|
${this.filteredOptions.map((option, index) => {
|
||||||
|
const isHighlighted = this.highlightedIndex === index;
|
||||||
return html`
|
return html`
|
||||||
<div class="option" @click=${() => {this.updateSelection(option);}}>${option.option}</div>
|
<div
|
||||||
`
|
class="option ${isHighlighted ? 'highlighted' : ''}"
|
||||||
|
@click=${() => {
|
||||||
|
this.updateSelection(option);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
${option.option}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
})}
|
})}
|
||||||
|
${this.enableSearch && this.opensToTop
|
||||||
|
? html`
|
||||||
|
<div class="search bottom">
|
||||||
|
<input type="text" placeholder="Search" @input="${this.handleSearch}" />
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="selectedBox"
|
||||||
|
@click="${(event) => {
|
||||||
|
if (!this.isElevated) {
|
||||||
|
this.toggleSelectionBox();
|
||||||
|
} else {
|
||||||
|
this.updateSelection(this.selectedOption);
|
||||||
|
}
|
||||||
|
}}"
|
||||||
|
>
|
||||||
|
${this.selectedOption?.option || 'Select...'}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
firstUpdated() {
|
firstUpdated() {
|
||||||
this.selectedOption = this.options[0] || null;
|
this.selectedOption = this.selectedOption || null;
|
||||||
|
this.filteredOptions = this.options; // Initialize filteredOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateSelection(selectedOption) {
|
public async updateSelection(selectedOption) {
|
||||||
this.selectedOption = selectedOption;
|
this.selectedOption = selectedOption;
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent('selectedOption', {
|
this.dispatchEvent(
|
||||||
detail: selectedOption,
|
new CustomEvent('selectedOption', {
|
||||||
bubbles: true
|
detail: selectedOption,
|
||||||
}));
|
bubbles: true,
|
||||||
this.toggleSelectionBox();
|
})
|
||||||
|
);
|
||||||
|
if (this.isElevated) {
|
||||||
|
this.toggleSelectionBox();
|
||||||
|
}
|
||||||
this.changeSubject.next(this);
|
this.changeSubject.next(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public toggleSelectionBox() {
|
private isElevated: boolean = false;
|
||||||
this.shadowRoot.querySelector('.selectedBox').classList.toggle('show');
|
private windowOverlay: DeesWindowLayer;
|
||||||
this.shadowRoot.querySelector('.selectionBox').classList.toggle('show');
|
public async toggleSelectionBox() {
|
||||||
|
this.isOpened = !this.isOpened;
|
||||||
|
const domtoolsInstance = await this.domtoolsPromise;
|
||||||
|
const selectedBox: HTMLElement = this.shadowRoot.querySelector('.selectedBox');
|
||||||
|
const selectionBox: HTMLElement = this.shadowRoot.querySelector('.selectionBox');
|
||||||
|
if (!this.isElevated) {
|
||||||
|
this.windowOverlay = await DeesWindowLayer.createAndShow({
|
||||||
|
blur: false,
|
||||||
|
});
|
||||||
|
const elevatedDropdown = new DeesInputDropdown();
|
||||||
|
elevatedDropdown.isElevated = true;
|
||||||
|
elevatedDropdown.label = this.label;
|
||||||
|
elevatedDropdown.enableSearch = this.enableSearch;
|
||||||
|
elevatedDropdown.required = this.required;
|
||||||
|
elevatedDropdown.disabled = this.disabled;
|
||||||
|
elevatedDropdown.style.position = 'fixed';
|
||||||
|
elevatedDropdown.style.top = this.getBoundingClientRect().top + 'px';
|
||||||
|
elevatedDropdown.style.left = this.getBoundingClientRect().left + 'px';
|
||||||
|
elevatedDropdown.style.width = this.clientWidth + 'px';
|
||||||
|
elevatedDropdown.options = this.options;
|
||||||
|
elevatedDropdown.selectedOption = this.selectedOption;
|
||||||
|
elevatedDropdown.highlightedIndex = elevatedDropdown.selectedOption ? elevatedDropdown.options.indexOf(
|
||||||
|
elevatedDropdown.options.find((option) => option.key === this.selectedOption.key)
|
||||||
|
) : -1;
|
||||||
|
console.log(elevatedDropdown.options);
|
||||||
|
console.log(elevatedDropdown.selectedOption);
|
||||||
|
console.log(elevatedDropdown.highlightedIndex);
|
||||||
|
this.windowOverlay.appendChild(elevatedDropdown);
|
||||||
|
await domtoolsInstance.convenience.smartdelay.delayFor(0);
|
||||||
|
elevatedDropdown.toggleSelectionBox();
|
||||||
|
const destroyOverlay = async () => {
|
||||||
|
(elevatedDropdown.shadowRoot.querySelector('.selectionBox') as HTMLElement).style.opacity =
|
||||||
|
'0';
|
||||||
|
elevatedDropdown.removeEventListener('selectedOption', handleSelection);
|
||||||
|
this.windowOverlay.removeEventListener('clicked', destroyOverlay);
|
||||||
|
this.windowOverlay.destroy();
|
||||||
|
};
|
||||||
|
const handleSelection = async (event) => {
|
||||||
|
await this.updateSelection(elevatedDropdown.selectedOption);
|
||||||
|
destroyOverlay();
|
||||||
|
};
|
||||||
|
elevatedDropdown.addEventListener('selectedOption', handleSelection);
|
||||||
|
this.windowOverlay.addEventListener('clicked', destroyOverlay);
|
||||||
|
} else {
|
||||||
|
if (!selectionBox.classList.contains('show')) {
|
||||||
|
selectionBox.style.width = selectedBox.clientWidth + 'px';
|
||||||
|
const spaceData = selectedBox.getBoundingClientRect();
|
||||||
|
if (300 > window.innerHeight - spaceData.bottom) {
|
||||||
|
this.opensToTop = true;
|
||||||
|
selectedBox.classList.add('accentTop');
|
||||||
|
selectionBox.classList.add('top');
|
||||||
|
selectionBox.style.bottom = selectedBox.clientHeight + 2 + 'px';
|
||||||
|
} else {
|
||||||
|
selectedBox.classList.add('accentBottom');
|
||||||
|
selectionBox.classList.add('bottom');
|
||||||
|
this.opensToTop = false;
|
||||||
|
const labelOffset = this.label ? 24 : 0;
|
||||||
|
selectionBox.style.top = selectedBox.clientHeight + labelOffset + 'px';
|
||||||
|
}
|
||||||
|
await domtoolsInstance.convenience.smartdelay.delayFor(0);
|
||||||
|
const searchInput = selectionBox.querySelector('input');
|
||||||
|
searchInput?.focus();
|
||||||
|
selectionBox.classList.add('show');
|
||||||
|
} else {
|
||||||
|
selectedBox.style.pointerEvents = 'none';
|
||||||
|
selectionBox.classList.remove('show');
|
||||||
|
// selectedBox.style.opacity = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleSearch(event: Event): void {
|
||||||
|
const searchTerm = (event.target as HTMLInputElement).value.toLowerCase();
|
||||||
|
this.filteredOptions = this.options.filter((option) =>
|
||||||
|
option.option.toLowerCase().includes(searchTerm)
|
||||||
|
);
|
||||||
|
this.highlightedIndex = 0; // Reset highlighted index
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleKeyDown(event: KeyboardEvent): void {
|
||||||
|
if (!this.isOpened) {
|
||||||
|
console.log('discarded key event. Check why this function is called.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const key = event.key;
|
||||||
|
const maxIndex = this.filteredOptions.length - 1;
|
||||||
|
|
||||||
|
if (key === 'ArrowDown') {
|
||||||
|
this.highlightedIndex = this.highlightedIndex + 1 > maxIndex ? 0 : this.highlightedIndex + 1;
|
||||||
|
event.preventDefault();
|
||||||
|
} else if (key === 'ArrowUp') {
|
||||||
|
this.highlightedIndex = this.highlightedIndex - 1 < 0 ? maxIndex : this.highlightedIndex - 1;
|
||||||
|
event.preventDefault();
|
||||||
|
} else if (key === 'Enter') {
|
||||||
|
this.updateSelection(this.filteredOptions[this.highlightedIndex]);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
|
import * as colors from './00colors.js';
|
||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
|
||||||
|
import { DeesContextmenu } from './dees-contextmenu.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
customElement,
|
customElement,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
property,
|
property,
|
||||||
html,
|
html,
|
||||||
css,
|
css,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
cssManager,
|
cssManager,
|
||||||
} from '@designestate/dees-element';
|
type CSSResult,
|
||||||
|
domtools,
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -19,10 +24,11 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-input-fileupload')
|
@customElement('dees-input-fileupload')
|
||||||
export class DeesInputFileupload extends DeesElement {
|
export class DeesInputFileupload extends DeesElement {
|
||||||
public static demo = () => html`<dees-input-fileupload .label=${'Attachments'}></dees-input-fileupload>`;
|
public static demo = () =>
|
||||||
|
html`<dees-input-fileupload .label=${'Attachments'}></dees-input-fileupload>`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
@ -31,6 +37,7 @@ export class DeesInputFileupload extends DeesElement {
|
|||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
|
reflect: true,
|
||||||
})
|
})
|
||||||
public key: string;
|
public key: string;
|
||||||
|
|
||||||
@ -69,6 +76,7 @@ export class DeesInputFileupload extends DeesElement {
|
|||||||
display: grid;
|
display: grid;
|
||||||
margin: 10px 0px;
|
margin: 10px 0px;
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
}
|
}
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
@ -76,31 +84,15 @@ export class DeesInputFileupload extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.maincontainer {
|
.maincontainer {
|
||||||
color: ${cssManager.bdTheme('#333', '#ccc')};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
|
||||||
font-size: 14px;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uploadButton {
|
|
||||||
position: relative;
|
position: relative;
|
||||||
cursor: pointer;
|
|
||||||
padding: 8px;
|
|
||||||
max-width: 600px;
|
|
||||||
background: ${cssManager.bdTheme('#fafafa', '#333333')};
|
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
text-align: center;
|
padding: 8px;
|
||||||
|
background: ${cssManager.bdTheme('#fafafa', '#222222')};
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
|
border-top: 1px solid #ffffff10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uploadButton:hover {
|
.maincontainer::after {
|
||||||
color: #fff;
|
|
||||||
background: rgb(3, 155, 229);
|
|
||||||
}
|
|
||||||
|
|
||||||
.uploadButton::after {
|
|
||||||
top: 2px;
|
top: 2px;
|
||||||
right: 2px;
|
right: 2px;
|
||||||
left: 2px;
|
left: 2px;
|
||||||
@ -111,28 +103,71 @@ export class DeesInputFileupload extends DeesElement {
|
|||||||
display: block;
|
display: block;
|
||||||
border: 2px dashed rgba(255, 255, 255, 0);
|
border: 2px dashed rgba(255, 255, 255, 0);
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
pointer-events: none;
|
||||||
|
background: #00000000;
|
||||||
}
|
}
|
||||||
.uploadButton.dragOver::after {
|
.maincontainer.dragOver::after {
|
||||||
transform: scale3d(1, 1, 1);
|
transform: scale3d(1, 1, 1);
|
||||||
border: 2px dashed rgba(255, 255, 255, 0.3);
|
border: 2px dashed rgba(255, 255, 255, 0.3);
|
||||||
|
background: #00000080;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-size: 14px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploadButton {
|
||||||
|
position: relative;
|
||||||
|
padding: 8px;
|
||||||
|
max-width: 600px;
|
||||||
|
background: ${cssManager.bdTheme('#fafafa', '#333333')};
|
||||||
|
border-radius: 3px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploadButton:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: ${unsafeCSS(colors.dark.blue)};
|
||||||
}
|
}
|
||||||
|
|
||||||
.uploadCandidate {
|
.uploadCandidate {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 48px auto;
|
||||||
|
background: #333;
|
||||||
|
padding: 8px 8px 8px 0px;
|
||||||
|
margin-bottom: 8px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border-bottom: 1px dashed #444;
|
border-radius: 3px;
|
||||||
color: ${cssManager.bdTheme('#666', '#ccc')};
|
color: ${cssManager.bdTheme('#666', '#ccc')};
|
||||||
padding: 8px;
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
font-family: 'Inter';
|
cursor: default;
|
||||||
}
|
transition: all 0.2s;
|
||||||
|
border-top: 1px solid #ffffff10;
|
||||||
.uploadButton:hover .uploadCandidate {
|
|
||||||
color: ${cssManager.bdTheme('#fff', '#fff')};
|
|
||||||
border-bottom: 1px dashed #fff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uploadCandidate:last-child {
|
.uploadCandidate:last-child {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.uploadCandidate .icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploadCandidate:hover {
|
||||||
|
background: #393939;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploadCandidate .description {
|
||||||
|
font-size: 14px;
|
||||||
|
border-left: 1px solid #ffffff10;
|
||||||
|
padding-left: 8px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -141,10 +176,32 @@ export class DeesInputFileupload extends DeesElement {
|
|||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<input type="file"></div>
|
<input type="file"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="maincontainer">
|
${this.label ? html`<div class="label">${this.label}</div>` : null}
|
||||||
${this.label ? html`<div class="label">${this.label}</div>` : null}
|
<div class="maincontainer ${this.state === 'dragOver' ? 'dragOver' : ''}">
|
||||||
${this.value.map((fileArg) => html` <div class="uploadCandidate">${fileArg.name} | ${fileArg.size}</div> `)}
|
${this.value.map(
|
||||||
<div class="uploadButton ${this.state === 'dragOver' ? 'dragOver' : ''}" @click=${this.openFileSelector}>
|
(fileArg) => html`
|
||||||
|
<div class="uploadCandidate" @contextmenu=${eventArg => {
|
||||||
|
DeesContextmenu.openContextMenuWithOptions(eventArg, [{
|
||||||
|
iconName: 'trash',
|
||||||
|
name: 'Remove',
|
||||||
|
action: async () => {
|
||||||
|
this.value.splice(this.value.indexOf(fileArg), 1);
|
||||||
|
this.requestUpdate();
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
}}>
|
||||||
|
<div class="icon">
|
||||||
|
<dees-icon .iconFA=${'paperclip'}></dees-icon>
|
||||||
|
</div>
|
||||||
|
<div class="description">
|
||||||
|
<span style="font-weight: 600">${fileArg.name}</span><br />
|
||||||
|
<span style="font-weight: 400">${fileArg.size}</span>
|
||||||
|
</div>
|
||||||
|
</div> `
|
||||||
|
)}
|
||||||
|
<div class="uploadButton" @click=${
|
||||||
|
this.openFileSelector
|
||||||
|
}>
|
||||||
${this.buttonText}
|
${this.buttonText}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -154,6 +211,8 @@ export class DeesInputFileupload extends DeesElement {
|
|||||||
public async openFileSelector() {
|
public async openFileSelector() {
|
||||||
const inputFile: HTMLInputElement = this.shadowRoot.querySelector('input[type="file"]');
|
const inputFile: HTMLInputElement = this.shadowRoot.querySelector('input[type="file"]');
|
||||||
inputFile.click();
|
inputFile.click();
|
||||||
|
this.state = 'idle';
|
||||||
|
this.buttonText = 'Upload more files...';
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateValue(eventArg: Event) {
|
public async updateValue(eventArg: Event) {
|
||||||
@ -163,7 +222,20 @@ export class DeesInputFileupload extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public firstUpdated() {
|
public firstUpdated() {
|
||||||
const dropArea = this.shadowRoot.querySelector('.uploadButton');
|
const inputFile: HTMLInputElement = this.shadowRoot.querySelector('input[type="file"]');
|
||||||
|
inputFile.addEventListener('change', (event: Event) => {
|
||||||
|
const target = event.target as HTMLInputElement;
|
||||||
|
for (const file of Array.from(target.files)) {
|
||||||
|
this.value.push(file);
|
||||||
|
}
|
||||||
|
this.requestUpdate();
|
||||||
|
console.log(`Got ${this.value.length} files!`);
|
||||||
|
// Reset the input value to allow selecting the same file again if needed
|
||||||
|
target.value = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
// lets handle drag and drop
|
||||||
|
const dropArea = this.shadowRoot.querySelector('.maincontainer');
|
||||||
const handlerFunction = (eventArg: DragEvent) => {
|
const handlerFunction = (eventArg: DragEvent) => {
|
||||||
eventArg.preventDefault();
|
eventArg.preventDefault();
|
||||||
switch (eventArg.type) {
|
switch (eventArg.type) {
|
||||||
|
3
ts_web/elements/dees-input-iban.demo.ts
Normal file
3
ts_web/elements/dees-input-iban.demo.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`<dees-input-iban .label=${'IBAN'}></dees-input-iban>`;
|
98
ts_web/elements/dees-input-iban.ts
Normal file
98
ts_web/elements/dees-input-iban.ts
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
DeesElement,
|
||||||
|
type TemplateResult,
|
||||||
|
state,
|
||||||
|
html,
|
||||||
|
domtools,
|
||||||
|
property,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import * as ibantools from 'ibantools';
|
||||||
|
import { demoFunc } from './dees-input-iban.demo.js';
|
||||||
|
|
||||||
|
@customElement('dees-input-iban')
|
||||||
|
export class DeesInputIban extends DeesElement {
|
||||||
|
// STATIC
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
@state()
|
||||||
|
enteredString: string = '';
|
||||||
|
|
||||||
|
@state()
|
||||||
|
enteredIbanIsValid: boolean = false;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Boolean,
|
||||||
|
})
|
||||||
|
public disabled = false;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Boolean,
|
||||||
|
})
|
||||||
|
public required = false;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
})
|
||||||
|
public label = '';
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
})
|
||||||
|
public key = '';
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
})
|
||||||
|
public value = '';
|
||||||
|
|
||||||
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject<DeesInputIban>();
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<style>
|
||||||
|
input[type='text'] {
|
||||||
|
line-height: 20px;
|
||||||
|
padding: 5px;
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<dees-input-text
|
||||||
|
.label=${'IBAN'}
|
||||||
|
.value=${this.value}
|
||||||
|
@input=${(eventArg: InputEvent) => {
|
||||||
|
this.validateIban(eventArg);
|
||||||
|
}}
|
||||||
|
></dees-input-text>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async firstUpdated() {
|
||||||
|
const deesInputText = this.shadowRoot.querySelector('dees-input-text');
|
||||||
|
deesInputText.disabled = this.disabled;
|
||||||
|
deesInputText.required = this.required;
|
||||||
|
deesInputText.changeSubject.subscribe(valueArg => {
|
||||||
|
this.value = valueArg.value;
|
||||||
|
this.changeSubject.next(this);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async validateIban(eventArg: InputEvent): Promise<void> {
|
||||||
|
const inputElement: HTMLInputElement = eventArg.target as HTMLInputElement;
|
||||||
|
let enteredString = inputElement?.value;
|
||||||
|
enteredString = enteredString || '';
|
||||||
|
if (this.enteredString !== enteredString) {
|
||||||
|
this.enteredString = ibantools.friendlyFormatIBAN(enteredString) || '';
|
||||||
|
if (inputElement) {
|
||||||
|
inputElement.value = this.enteredString;
|
||||||
|
this.value = this.enteredString;
|
||||||
|
this.changeSubject.next(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.enteredIbanIsValid = ibantools.isValidIBAN(this.enteredString.replace(/ /g, ''));
|
||||||
|
const deesInputText = this.shadowRoot.querySelector('dees-input-text');
|
||||||
|
deesInputText.validationText = `IBAN is valid: ${this.enteredIbanIsValid}`;
|
||||||
|
}
|
||||||
|
}
|
14
ts_web/elements/dees-input-multitoggle.demo.ts
Normal file
14
ts_web/elements/dees-input-multitoggle.demo.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<dees-input-multitoggle
|
||||||
|
.options=${['option 1', 'option 2', 'a longer option with multiple words']}
|
||||||
|
.selectedOption=${'option 2'}
|
||||||
|
></dees-input-multitoggle>
|
||||||
|
<dees-input-multitoggle
|
||||||
|
.type=${'boolean'}
|
||||||
|
.booleanTrueName=${'enabled'}
|
||||||
|
.booleanFalseName=${'disabled'}
|
||||||
|
.selectedOption=${'true'}
|
||||||
|
></dees-input-multitoggle>
|
||||||
|
`;
|
153
ts_web/elements/dees-input-multitoggle.ts
Normal file
153
ts_web/elements/dees-input-multitoggle.ts
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
DeesElement,
|
||||||
|
type TemplateResult,
|
||||||
|
state,
|
||||||
|
html,
|
||||||
|
domtools,
|
||||||
|
property,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
const { demoFunc } = await import('./dees-input-multitoggle.demo.js');
|
||||||
|
|
||||||
|
@customElement('dees-input-multitoggle')
|
||||||
|
export class DeesInputMultitoggle extends DeesElement {
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
})
|
||||||
|
public label: string;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
})
|
||||||
|
public description: string;
|
||||||
|
|
||||||
|
@property()
|
||||||
|
type: 'boolean' | 'multi' | 'single' = 'multi';
|
||||||
|
|
||||||
|
@property()
|
||||||
|
booleanTrueName: string = 'true';
|
||||||
|
|
||||||
|
@property()
|
||||||
|
booleanFalseName: string = 'false';
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Array,
|
||||||
|
})
|
||||||
|
options: string[] = [];
|
||||||
|
|
||||||
|
@property()
|
||||||
|
selectedOption: string = '';
|
||||||
|
|
||||||
|
@property()
|
||||||
|
boolValue: boolean = false;
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
|
user-select: none;
|
||||||
|
margin: 8px 0px 24px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-size: 14px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selections {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
background: ${cssManager.bdTheme('#fff', '#222')};
|
||||||
|
width: min-content;
|
||||||
|
border-radius: 20px;
|
||||||
|
height: 32px;
|
||||||
|
border-top: 1px solid #ffffff10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option {
|
||||||
|
color: #ccc;
|
||||||
|
position: relative;
|
||||||
|
padding: 0px 16px;
|
||||||
|
line-height: 32px;
|
||||||
|
cursor: default;
|
||||||
|
width: min-content; /* Make the width as per the content */
|
||||||
|
white-space: nowrap; /* Prevent text wrapping */
|
||||||
|
transition: all 0.1s;
|
||||||
|
font-size: 14px;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.option:hover {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option.selected {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.indicator {
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
height: 24px;
|
||||||
|
left: 4px;
|
||||||
|
top: 3px;
|
||||||
|
border-radius: 16px;
|
||||||
|
background: #0050b9;
|
||||||
|
min-width: 36px;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<dees-label .label=${this.label} .description=${this.description}></dees-label>
|
||||||
|
<div class="mainbox">
|
||||||
|
<div class="selections">
|
||||||
|
<div class="indicator"></div>
|
||||||
|
${this.options.map(
|
||||||
|
(option) =>
|
||||||
|
html`<div class="option ${option === this.selectedOption ? 'selected': ''}" @click=${() => this.handleSelection(option)}>
|
||||||
|
${option}
|
||||||
|
</div> `
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async firstUpdated() {
|
||||||
|
if (this.type === 'boolean') {
|
||||||
|
this.options = [this.booleanTrueName || 'true', this.booleanFalseName || 'false'];
|
||||||
|
}
|
||||||
|
this.setIndicator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async handleSelection(optionArg: string) {
|
||||||
|
this.selectedOption = optionArg;
|
||||||
|
this.setIndicator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async setIndicator() {
|
||||||
|
const indicator: HTMLDivElement = this.shadowRoot.querySelector('.indicator');
|
||||||
|
const option: HTMLDivElement = this.shadowRoot.querySelector(
|
||||||
|
`.option:nth-child(${this.options.indexOf(this.selectedOption) + 2})`
|
||||||
|
);
|
||||||
|
if (indicator && option) {
|
||||||
|
indicator.style.width = `${option.clientWidth - 8}px`;
|
||||||
|
indicator.style.left = `${option.offsetLeft + 4}px`;
|
||||||
|
indicator.style.opacity = '1';
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
indicator.style.transition = 'all 0.1s';
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
}
|
3
ts_web/elements/dees-input-phone.demo.ts
Normal file
3
ts_web/elements/dees-input-phone.demo.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`<dees-input-phone .label=${'Phone Number'}></dees-input-phone>`;
|
29
ts_web/elements/dees-input-phone.ts
Normal file
29
ts_web/elements/dees-input-phone.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
DeesElement,
|
||||||
|
type TemplateResult,
|
||||||
|
property,
|
||||||
|
html,
|
||||||
|
css,
|
||||||
|
unsafeCSS,
|
||||||
|
cssManager,
|
||||||
|
type CSSResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import { demoFunc } from './dees-input-phone.demo.js';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-input-phone': DeesInputPhone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-input-phone')
|
||||||
|
export class DeesInputPhone extends DeesElement {
|
||||||
|
// STATIC
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
public render() {
|
||||||
|
return html`<div>Phone Input</div>`;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { customElement, property, html, TemplateResult, DeesElement } from '@designestate/dees-element';
|
import { customElement, property, html, type TemplateResult, DeesElement, type CSSResult, } from '@design.estate/dees-element';
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -12,9 +12,15 @@ export class DeesInputQuantitySelector extends DeesElement {
|
|||||||
public static demo = () => html`<dees-input-quantityselector></dees-input-quantityselector>`;
|
public static demo = () => html`<dees-input-quantityselector></dees-input-quantityselector>`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
|
public label: string = 'Label';
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
public key: string;
|
public key: string;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
@ -79,7 +85,6 @@ export class DeesInputQuantitySelector extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.selector:hover {
|
.selector:hover {
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.quantity {
|
.quantity {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {customElement, DeesElement, TemplateResult, property, html} from '@designestate/dees-element';
|
import {customElement, DeesElement, type TemplateResult, property, html, type CSSResult,} from '@design.estate/dees-element';
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -12,9 +12,12 @@ export class DeesInputRadio extends DeesElement {
|
|||||||
public static demo = () => html`<dees-input-radio></dees-input-radio>`;
|
public static demo = () => html`<dees-input-radio></dees-input-radio>`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property()
|
@property({
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
public key: string;
|
public key: string;
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
@ -48,7 +51,6 @@ export class DeesInputRadio extends DeesElement {
|
|||||||
display: block;
|
display: block;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 20px 0px;
|
margin: 20px 0px;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.maincontainer {
|
.maincontainer {
|
||||||
@ -88,8 +90,8 @@ export class DeesInputRadio extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.checkbox.selected {
|
.checkbox.selected {
|
||||||
background: #039BE5;
|
background: #0050b9;
|
||||||
border: 1px solid #039BE5;
|
border: 1px solid #0050b9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.maincontainer:hover .checkbox.selected {
|
.maincontainer:hover .checkbox.selected {
|
||||||
|
0
ts_web/elements/dees-input-searchselect.ts
Normal file
0
ts_web/elements/dees-input-searchselect.ts
Normal file
0
ts_web/elements/dees-input-tags.ts
Normal file
0
ts_web/elements/dees-input-tags.ts
Normal file
@ -1,5 +1,16 @@
|
|||||||
import {customElement, DeesElement, TemplateResult, property, html, cssManager} from '@designestate/dees-element';
|
import * as colors from './00colors.js';
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
|
||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
DeesElement,
|
||||||
|
type TemplateResult,
|
||||||
|
property,
|
||||||
|
html,
|
||||||
|
cssManager,
|
||||||
|
css,
|
||||||
|
type CSSResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -10,36 +21,42 @@ declare global {
|
|||||||
@customElement('dees-input-text')
|
@customElement('dees-input-text')
|
||||||
export class DeesInputText extends DeesElement {
|
export class DeesInputText extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = () => html`
|
||||||
<dees-input-text .label=${'this is a label'}></dees-input-text>
|
<dees-input-text .label=${'this is a label'} .value=${'test'}></dees-input-text>
|
||||||
<dees-input-text .isPasswordBool=${true}></dees-input-text>
|
<dees-input-text .isPasswordBool=${true}></dees-input-text>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject<DeesInputText>();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject<DeesInputText>();
|
||||||
public valueChangeSubject = new domtools.rxjs.Subject<string>();
|
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String
|
type: String,
|
||||||
})
|
})
|
||||||
public label: string;
|
public label: string;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String
|
type: String,
|
||||||
|
})
|
||||||
|
public description: string;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
})
|
})
|
||||||
public key: string;
|
public key: string;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String
|
type: String,
|
||||||
|
reflect: true,
|
||||||
})
|
})
|
||||||
public value: string = '';
|
public value: string = '';
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public required: boolean = false;
|
public required: boolean = false;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public disabled: boolean = false;
|
public disabled: boolean = false;
|
||||||
|
|
||||||
@ -55,93 +72,160 @@ export class DeesInputText extends DeesElement {
|
|||||||
})
|
})
|
||||||
public showPasswordBool = false;
|
public showPasswordBool = false;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Boolean,
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
|
public validationState: 'valid' | 'warn' | 'invalid';
|
||||||
|
|
||||||
|
@property({
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
|
public validationText: string = '';
|
||||||
|
|
||||||
|
@property({})
|
||||||
|
validationFunction: (value: string) => boolean;
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host {
|
||||||
|
position: relative;
|
||||||
|
display: grid;
|
||||||
|
margin: 8px 0px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
z-index: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maincontainer {
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
margin-top: 0px;
|
||||||
|
background: ${cssManager.bdTheme('#fafafa', '#222')};
|
||||||
|
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #ffffff10')};
|
||||||
|
border-bottom: ${cssManager.bdTheme('1px solid #CCC', '1px solid #222')};
|
||||||
|
border-right: ${cssManager.bdTheme('1px solid #CCC', 'none')};
|
||||||
|
border-left: ${cssManager.bdTheme('1px solid #CCC', 'none')};
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
border-radius: 2px;
|
||||||
|
width: 100%;
|
||||||
|
line-height: 36px;
|
||||||
|
transition: all 0.2s;
|
||||||
|
outline: none;
|
||||||
|
font-size: 16px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:disabled {
|
||||||
|
background: ${cssManager.bdTheme('#ffffff00', '#11111100')};
|
||||||
|
border: 1px dashed ${cssManager.bdTheme('#666666', '#666666')};
|
||||||
|
color: #9b9b9e;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-bottom: 1px solid ${cssManager.bdTheme( colors.bright.blueActive, colors.dark.blueActive)};
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:hover {
|
||||||
|
filter: ${cssManager.bdTheme('brightness(0.95)', 'brightness(1.1)')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.showPassword {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 7px;
|
||||||
|
right: 10px;
|
||||||
|
border: 1px dashed #444;
|
||||||
|
border-radius: 7px;
|
||||||
|
padding: 4px 0px;
|
||||||
|
width: 40px;
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.showPassword:hover {
|
||||||
|
background: ${cssManager.bdTheme('#00000010', '#ffffff10')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.validationContainer {
|
||||||
|
text-align: center;
|
||||||
|
padding: 6px 2px 2px 2px;
|
||||||
|
margin-top: -4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #fff;
|
||||||
|
background: #e4002b;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
border-radius: 3px;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html `
|
return html`
|
||||||
<style>
|
<style>
|
||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
:host {
|
|
||||||
position: relative;
|
|
||||||
display: grid;
|
|
||||||
margin: 10px 0px;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.maincontainer {
|
|
||||||
color: ${this.goBright ? '#333' : '#ccc'};
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
|
||||||
font-size: 14px;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
input {
|
||||||
margin-top: 5px;
|
font-family: ${this.isPasswordBool ? 'monospace' : 'Roboto'};
|
||||||
background: ${this.goBright ? '#fafafa' : '#222'};
|
letter-spacing: ${this.isPasswordBool ? '1px' : 'normal'};
|
||||||
border-top: ${this.goBright ? '1px solid #CCC' : '1px solid #444'};
|
|
||||||
border-bottom: ${this.goBright ? '1px solid #CCC' : '1px solid #333'};
|
|
||||||
border-right: ${this.goBright ? '1px solid #CCC' : 'none'};
|
|
||||||
border-left: ${this.goBright ? '1px solid #CCC' : 'none'};
|
|
||||||
padding-left:10px;
|
|
||||||
padding-right: 10px;
|
|
||||||
border-radius: 2px;
|
|
||||||
width: 100%;
|
|
||||||
line-height: 48px;
|
|
||||||
transition: all 0.2s;
|
|
||||||
outline: none;
|
|
||||||
font-size: 16px;
|
|
||||||
font-family: ${this.isPasswordBool ? 'monospace': 'Inter'};
|
|
||||||
letter-spacing: ${this.isPasswordBool ? '1px': 'normal'};
|
|
||||||
color: ${this.goBright ? '#333' : '#ccc'};
|
color: ${this.goBright ? '#333' : '#ccc'};
|
||||||
}
|
}
|
||||||
|
${this.validationText ? css`
|
||||||
input:disabled {
|
.validationContainer {
|
||||||
background: ${cssManager.bdTheme('#ffffff00', '#11111100')};
|
height: 22px;
|
||||||
border: 1px dashed ${cssManager.bdTheme('#666666', '#666666')};
|
opacity: 1;
|
||||||
color: #9b9b9e;
|
}
|
||||||
cursor: default;
|
` : css`
|
||||||
}
|
.validationContainer {
|
||||||
|
height: 4px;
|
||||||
input:focus {
|
padding: 2px !important;
|
||||||
outline: none;
|
opacity: 0;
|
||||||
border-bottom: 1px solid #e4002b;
|
}
|
||||||
}
|
`}
|
||||||
|
|
||||||
.showPassword {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 8px;
|
|
||||||
right: 10px;
|
|
||||||
border: 1px dashed #444;
|
|
||||||
border-radius: 7px;
|
|
||||||
padding: 8px 0px;
|
|
||||||
width: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.showPassword:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
background: #333;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
<div class="maincontainer">
|
<div class="maincontainer">
|
||||||
${this.label ? html`<div class="label">${this.label}</div>` : html``}
|
<dees-label .label=${this.label} .description=${this.description}></dees-label>
|
||||||
<input type="${this.isPasswordBool && !this.showPasswordBool ? 'password' : 'text'}" value=${this.value} @input="${this.updateValue}" .disabled=${this.disabled} />
|
<input
|
||||||
${this.isPasswordBool ? html`
|
type="${this.isPasswordBool && !this.showPasswordBool ? 'password' : 'text'}"
|
||||||
<div class="showPassword" @click=${this.togglePasswordView}>
|
.value=${this.value}
|
||||||
<dees-icon .iconFA=${this.showPasswordBool ? 'eye' : 'eyeSlash'}></dees-icon>
|
@input="${this.updateValue}"
|
||||||
</div>
|
.disabled=${this.disabled}
|
||||||
` : html``}
|
/>
|
||||||
|
<div class="validationContainer">
|
||||||
|
${this.validationText}
|
||||||
|
</div>
|
||||||
|
${this.isPasswordBool
|
||||||
|
? html`
|
||||||
|
<div class="showPassword" @click=${this.togglePasswordView}>
|
||||||
|
<dees-icon .iconFA=${this.showPasswordBool ? 'eye' : 'eyeSlash'}></dees-icon>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: html``}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firstUpdated() {
|
||||||
|
const input = this.shadowRoot.querySelector('input');
|
||||||
|
input.addEventListener('input', (eventArg: InputEvent) => {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public async updateValue(eventArg: Event) {
|
public async updateValue(eventArg: Event) {
|
||||||
const target: any = eventArg.target;
|
const target: any = eventArg.target;
|
||||||
this.value = target.value;
|
this.value = target.value;
|
||||||
this.changeSubject.next(this);
|
this.changeSubject.next(this);
|
||||||
this.valueChangeSubject.next(this.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async freeze() {
|
public async freeze() {
|
||||||
@ -152,14 +236,19 @@ export class DeesInputText extends DeesElement {
|
|||||||
this.disabled = false;
|
this.disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async togglePasswordView () {
|
public async togglePasswordView() {
|
||||||
const domtools = await this.domtoolsPromise;
|
const domtools = await this.domtoolsPromise;
|
||||||
this.showPasswordBool = !this.showPasswordBool;
|
this.showPasswordBool = !this.showPasswordBool;
|
||||||
console.log(`this.showPasswordBool is: ${this.showPasswordBool}`)
|
console.log(`this.showPasswordBool is: ${this.showPasswordBool}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async focus() {
|
public async focus() {
|
||||||
const textInput = this.shadowRoot.querySelector('input');
|
const textInput = this.shadowRoot.querySelector('input');
|
||||||
textInput.focus();
|
textInput.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async blur() {
|
||||||
|
const textInput = this.shadowRoot.querySelector('input');
|
||||||
|
textInput.blur();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
15
ts_web/elements/dees-input-typelist.demo.ts
Normal file
15
ts_web/elements/dees-input-typelist.demo.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<style>
|
||||||
|
.demoContainer {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: auto;
|
||||||
|
padding: 40px;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="demoContainer">
|
||||||
|
<dees-input-typelist></dees-input-typelist>
|
||||||
|
</div>
|
||||||
|
`;
|
98
ts_web/elements/dees-input-typelist.ts
Normal file
98
ts_web/elements/dees-input-typelist.ts
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
DeesElement,
|
||||||
|
type TemplateResult,
|
||||||
|
state,
|
||||||
|
html,
|
||||||
|
domtools,
|
||||||
|
property,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
const { demoFunc } = await import('./dees-input-typelist.demo.js');
|
||||||
|
|
||||||
|
@customElement('dees-input-typelist')
|
||||||
|
export class DeesInputTypelist extends DeesElement {
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
})
|
||||||
|
public label: string;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
|
margin: 8px 0px 24px 0px;
|
||||||
|
}
|
||||||
|
.label {
|
||||||
|
font-size: 14px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
.mainbox {
|
||||||
|
border-radius: 3px;
|
||||||
|
background: #222;
|
||||||
|
overflow: hidden;
|
||||||
|
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
|
||||||
|
border-bottom: ${cssManager.bdTheme('1px solid #CCC', '1px solid #333')};
|
||||||
|
border-right: ${cssManager.bdTheme('1px solid #CCC', 'none')};
|
||||||
|
border-left: ${cssManager.bdTheme('1px solid #CCC', 'none')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags {
|
||||||
|
padding: 16px;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notags {
|
||||||
|
text-align: center;
|
||||||
|
opacity: 0.5;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
display: block;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: #181818;
|
||||||
|
width: 100%;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
color: inherit;
|
||||||
|
padding: 0px 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
line-height: 32px;
|
||||||
|
height: 0px;
|
||||||
|
transition: height 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus {
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<div class="label">${this.label}</div>
|
||||||
|
<div class="mainbox">
|
||||||
|
<div class="tags" @click=${() => {
|
||||||
|
this.shadowRoot.querySelector('input').focus();
|
||||||
|
}}>
|
||||||
|
<div class="notags">No tags yet</div>
|
||||||
|
</div>
|
||||||
|
<input type="text" placeholder="Type, press Enter to add it..." />
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
7
ts_web/elements/dees-label.demo.ts
Normal file
7
ts_web/elements/dees-label.demo.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { html, cssManager } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => {
|
||||||
|
return html`
|
||||||
|
<dees-label .label=${'a label'}></dees-label>
|
||||||
|
`;
|
||||||
|
}
|
70
ts_web/elements/dees-label.ts
Normal file
70
ts_web/elements/dees-label.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
import * as colors from './00colors.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
DeesElement,
|
||||||
|
property,
|
||||||
|
unsafeCSS,
|
||||||
|
query,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import { demoFunc } from './dees-label.demo.js';
|
||||||
|
|
||||||
|
@customElement('dees-label')
|
||||||
|
export class DeesLabel extends DeesElement {
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
|
public label = '';
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
|
public description: string;
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
.label {
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
|
font-size: 14px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
cursor: default;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
dees-icon {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 14px;
|
||||||
|
transform: translateY(1.5px);
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render() {
|
||||||
|
return html`
|
||||||
|
${this.label
|
||||||
|
? html`
|
||||||
|
<div class="label">
|
||||||
|
${this.label}
|
||||||
|
${this.description
|
||||||
|
? html`
|
||||||
|
<dees-icon .iconFA=${'circleInfo'}></dees-icon>
|
||||||
|
<dees-speechbubble .text=${this.description}></dees-speechbubble>
|
||||||
|
`
|
||||||
|
: html``}
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: html``}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
@ -1,39 +1,35 @@
|
|||||||
import * as plugins from './plugins.js';
|
import * as plugins from './00plugins.js';
|
||||||
import {
|
import {
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
|
type CSSResult,
|
||||||
customElement,
|
customElement,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
domtools,
|
domtools,
|
||||||
html,
|
html,
|
||||||
property,
|
property,
|
||||||
} from '@designestate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
import { DeesWindowLayer } from './dees-windowlayer.js';
|
import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||||
|
|
||||||
@customElement('dees-mobilenavigation')
|
@customElement('dees-mobilenavigation')
|
||||||
export class DeesMobilenavigation extends DeesElement {
|
export class DeesMobilenavigation extends DeesElement {
|
||||||
// STATIC
|
// STATIC
|
||||||
public static demo = () => html`
|
public static demo = () => html`
|
||||||
<dees-mobilenavigation
|
<dees-button @click=${() => {
|
||||||
.menuItems="${[
|
DeesMobilenavigation.createAndShow([
|
||||||
{
|
{
|
||||||
name: 'hello1',
|
name: 'Test',
|
||||||
action: async () => {},
|
action: async (deesMobileNav) => {
|
||||||
|
alert('test');
|
||||||
|
return null;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
]);
|
||||||
name: 'hello2',
|
}}></dees-button>
|
||||||
action: async () => {},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'hello3',
|
|
||||||
action: async () => {},
|
|
||||||
},
|
|
||||||
]}"
|
|
||||||
></dees-mobilenavigation>
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
private static singletonRef: DeesMobilenavigation;
|
private static singletonRef: DeesMobilenavigation;
|
||||||
public static async createAndInit(menuItemsArg: plugins.tsclass.website.IMenuItem[]) {
|
public static async createAndShow(menuItemsArg: plugins.tsclass.website.IMenuItem<DeesMobilenavigation>[]) {
|
||||||
if (!this.singletonRef) {
|
if (!this.singletonRef) {
|
||||||
this.singletonRef = new DeesMobilenavigation();
|
this.singletonRef = new DeesMobilenavigation();
|
||||||
document.body.append(this.singletonRef);
|
document.body.append(this.singletonRef);
|
||||||
@ -56,7 +52,7 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
})
|
})
|
||||||
public menuItems: plugins.tsclass.website.IMenuItem[] = [];
|
public menuItems: plugins.tsclass.website.IMenuItem[] = [];
|
||||||
|
|
||||||
readyDeferred = domtools.plugins.smartpromise.defer();
|
readyDeferred: plugins.smartpromise.Deferred<any> = domtools.plugins.smartpromise.defer();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -93,8 +89,8 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
right: 0px;
|
right: 0px;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
background: ${cssManager.bdTheme('#eeeeeb', '#000')};;
|
background: ${cssManager.bdTheme('#eeeeeb', '#000')};
|
||||||
border-left: 1px dashed #444;
|
border-left: 1px solid ${cssManager.bdTheme('#eeeeeb', '#222')};
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +105,6 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
padding: 8px;
|
padding: 8px;
|
||||||
margin-left: -8px;
|
margin-left: -8px;
|
||||||
margin-right: -8px;
|
margin-right: -8px;
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
.menuItem:hover {
|
.menuItem:hover {
|
||||||
@ -120,7 +115,7 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
padding: 8px 0px;
|
padding: 8px 0px;
|
||||||
font-family: Inter;
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
border-bottom: 1px dashed #444;
|
border-bottom: 1px dashed #444;
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
@ -139,7 +134,7 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
class="menuItem"
|
class="menuItem"
|
||||||
@click="${() => {
|
@click="${() => {
|
||||||
this.hide();
|
this.hide();
|
||||||
menuItem.action();
|
menuItem.action(this);
|
||||||
}}"
|
}}"
|
||||||
>
|
>
|
||||||
${menuItem.name}
|
${menuItem.name}
|
||||||
@ -160,6 +155,7 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
const main = this.shadowRoot.querySelector('.main');
|
const main = this.shadowRoot.querySelector('.main');
|
||||||
if (!this.windowLayer) {
|
if (!this.windowLayer) {
|
||||||
this.windowLayer = new DeesWindowLayer();
|
this.windowLayer = new DeesWindowLayer();
|
||||||
|
this.windowLayer.options.blur = true;
|
||||||
this.windowLayer.addEventListener('click', () => {
|
this.windowLayer.addEventListener('click', () => {
|
||||||
this.hide();
|
this.hide();
|
||||||
});
|
});
|
||||||
|
37
ts_web/elements/dees-modal.demo.ts
Normal file
37
ts_web/elements/dees-modal.demo.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
import { DeesModal } from './dees-modal.js';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<dees-button @click=${() => {
|
||||||
|
DeesModal.createAndShow({
|
||||||
|
heading: 'This is a heading',
|
||||||
|
content: html`
|
||||||
|
<dees-form>
|
||||||
|
<dees-input-text
|
||||||
|
.label=${'Username'}
|
||||||
|
>
|
||||||
|
</dees-input-text>
|
||||||
|
<dees-input-text
|
||||||
|
.label=${'Password'}
|
||||||
|
>
|
||||||
|
</dees-input-text>
|
||||||
|
</dees-form>
|
||||||
|
`,
|
||||||
|
menuOptions: [{
|
||||||
|
name: 'Cancel',
|
||||||
|
iconName: null,
|
||||||
|
action: async (deesModalArg) => {
|
||||||
|
deesModalArg.destroy();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'Ok',
|
||||||
|
iconName: null,
|
||||||
|
action: async (deesModalArg) => {
|
||||||
|
deesModalArg.destroy();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
}}>open modal</dees-button>
|
||||||
|
`
|
214
ts_web/elements/dees-modal.ts
Normal file
214
ts_web/elements/dees-modal.ts
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
import * as colors from './00colors.js';
|
||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
|
||||||
|
import { demoFunc } from './dees-modal.demo.js';
|
||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
DeesElement,
|
||||||
|
property,
|
||||||
|
type TemplateResult,
|
||||||
|
cssManager,
|
||||||
|
css,
|
||||||
|
type CSSResult,
|
||||||
|
unsafeCSS,
|
||||||
|
unsafeHTML,
|
||||||
|
state,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-modal': DeesModal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-modal')
|
||||||
|
export class DeesModal extends DeesElement {
|
||||||
|
// STATIC
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
public static async createAndShow(optionsArg: {
|
||||||
|
heading: string;
|
||||||
|
content: TemplateResult;
|
||||||
|
menuOptions: plugins.tsclass.website.IMenuItem<DeesModal>[];
|
||||||
|
}) {
|
||||||
|
const body = document.body;
|
||||||
|
const modal = new DeesModal();
|
||||||
|
modal.heading = optionsArg.heading;
|
||||||
|
modal.content = optionsArg.content;
|
||||||
|
modal.menuOptions = optionsArg.menuOptions;
|
||||||
|
modal.windowLayer = await DeesWindowLayer.createAndShow({
|
||||||
|
blur: true,
|
||||||
|
});
|
||||||
|
modal.windowLayer.addEventListener('click', async () => {
|
||||||
|
await modal.destroy();
|
||||||
|
});
|
||||||
|
body.append(modal.windowLayer);
|
||||||
|
body.append(modal);
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
})
|
||||||
|
public heading = '';
|
||||||
|
|
||||||
|
@state({})
|
||||||
|
public content: TemplateResult;
|
||||||
|
|
||||||
|
@state({})
|
||||||
|
public menuOptions: plugins.tsclass.website.IMenuItem<DeesModal>[] = [];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
|
will-change: transform;
|
||||||
|
}
|
||||||
|
.modalContainer {
|
||||||
|
display: flex;
|
||||||
|
position: fixed;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
box-sizing: border-box;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 2000;
|
||||||
|
}
|
||||||
|
.modal {
|
||||||
|
will-change: transform;
|
||||||
|
transform: translateY(0px) scale(0.95);
|
||||||
|
opacity: 0;
|
||||||
|
width: 480px;
|
||||||
|
min-height: 120px;
|
||||||
|
background: #111;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #222;
|
||||||
|
transition: all 0.2s;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0px 2px 5px #00000080;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal.show {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0px) scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal.show.predestroy {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(10px) scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal .heading {
|
||||||
|
height: 32px;
|
||||||
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
|
line-height: 32px;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 12px;
|
||||||
|
border-bottom: 1px solid #222;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal .content {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
.modal .bottomButtons {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
border-top: 1px solid #222;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal .bottomButtons .bottomButton {
|
||||||
|
margin: 8px 0px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
line-height: 16px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: default;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal .bottomButtons .bottomButton:first-child {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
.modal .bottomButtons .bottomButton:last-child {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal .bottomButtons .bottomButton:hover {
|
||||||
|
background: ${cssManager.bdTheme(colors.bright.blue, colors.dark.blue)};
|
||||||
|
}
|
||||||
|
.modal .bottomButtons .bottomButton:active {
|
||||||
|
background: ${cssManager.bdTheme(colors.bright.blueActive, colors.dark.blueActive)};
|
||||||
|
}
|
||||||
|
.modal .bottomButtons .bottomButton:last-child {
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<style>
|
||||||
|
.modal .bottomButtons {
|
||||||
|
grid-template-columns: ${cssManager.cssGridColumns(this.menuOptions.length, 0)};
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="modalContainer" @click=${this.handleOutsideClick}>
|
||||||
|
<div class="modal">
|
||||||
|
<div class="heading">${this.heading}</div>
|
||||||
|
<div class="content">${this.content}</div>
|
||||||
|
<div class="bottomButtons">
|
||||||
|
${this.menuOptions.map(
|
||||||
|
(actionArg) => html`
|
||||||
|
<div class="bottomButton" @click=${() => {
|
||||||
|
actionArg.action(this);
|
||||||
|
}}>${actionArg.name}</div>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private windowLayer: DeesWindowLayer;
|
||||||
|
public async firstUpdated(_changedProperties: Map<string | number | symbol, unknown>) {
|
||||||
|
super.firstUpdated(_changedProperties);
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
await domtools.convenience.smartdelay.delayFor(30);
|
||||||
|
const modal = this.shadowRoot.querySelector('.modal');
|
||||||
|
modal.classList.add('show');
|
||||||
|
}
|
||||||
|
|
||||||
|
public async handleOutsideClick(eventArg: MouseEvent) {
|
||||||
|
eventArg.stopPropagation();
|
||||||
|
const modalContainer = this.shadowRoot.querySelector('.modalContainer');
|
||||||
|
if (eventArg.target === modalContainer) {
|
||||||
|
await this.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async destroy() {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
const modal = this.shadowRoot.querySelector('.modal');
|
||||||
|
modal.classList.add('predestroy');
|
||||||
|
await domtools.convenience.smartdelay.delayFor(200);
|
||||||
|
document.body.removeChild(this);
|
||||||
|
await this.windowLayer.destroy();
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
import { DeesElement, property, html, customElement, domtools, TemplateResult } from '@designestate/dees-element';
|
import { DeesElement, property, html, customElement, domtools, type TemplateResult, type CSSResult, } from '@design.estate/dees-element';
|
||||||
|
|
||||||
import { Deferred } from '@pushrocks/smartpromise';
|
import { Deferred } from '@push.rocks/smartpromise';
|
||||||
|
|
||||||
import type pdfjsTypes from 'pdfjs-dist';
|
// import type pdfjsTypes from 'pdfjs-dist';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -32,7 +32,7 @@ export class DeesPdf extends DeesElement {
|
|||||||
return html`
|
return html`
|
||||||
<style>
|
<style>
|
||||||
:host {
|
:host {
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
display: block;
|
display: block;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
@ -51,24 +51,15 @@ export class DeesPdf extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static pdfJsReady: Promise<any>;
|
public static pdfJsReady: Promise<any>;
|
||||||
public static pdfjsLib: typeof pdfjsTypes;
|
public static pdfjsLib: any // typeof pdfjsTypes;
|
||||||
public async connectedCallback() {
|
public async connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
if (!DeesPdf.pdfJsReady) {
|
if (!DeesPdf.pdfJsReady) {
|
||||||
const pdfJsReadyDeferred = domtools.plugins.smartpromise.defer();
|
const pdfJsReadyDeferred = domtools.plugins.smartpromise.defer();
|
||||||
DeesPdf.pdfJsReady = pdfJsReadyDeferred.promise;
|
DeesPdf.pdfJsReady = pdfJsReadyDeferred.promise;
|
||||||
const loadDeferred = domtools.plugins.smartpromise.defer();
|
// @ts-ignore
|
||||||
const script = document.createElement('script');
|
DeesPdf.pdfjsLib = await import('https://cdn.jsdelivr.net/npm/pdfjs-dist@4.0.379/+esm');
|
||||||
script.addEventListener('load', () => {
|
DeesPdf.pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@4.0.379/build/pdf.worker.mjs';
|
||||||
console.log('pdf.js loaded!');
|
|
||||||
loadDeferred.resolve();
|
|
||||||
});
|
|
||||||
script.src = 'https:////mozilla.github.io/pdf.js/build/pdf.js';
|
|
||||||
document.getElementsByTagName('head')[0].appendChild(script);
|
|
||||||
// The workerSrc property shall be specified.
|
|
||||||
await loadDeferred.promise;
|
|
||||||
DeesPdf.pdfjsLib = window['pdfjs-dist/build/pdf'];
|
|
||||||
DeesPdf.pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';
|
|
||||||
pdfJsReadyDeferred.resolve();
|
pdfJsReadyDeferred.resolve();
|
||||||
}
|
}
|
||||||
await DeesPdf.pdfJsReady;
|
await DeesPdf.pdfJsReady;
|
||||||
|
11
ts_web/elements/dees-progressbar.demo.ts
Normal file
11
ts_web/elements/dees-progressbar.demo.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import { DeesProgressbar } from './dees-progressbar.js';
|
||||||
|
|
||||||
|
export const demoFunc = () => {
|
||||||
|
return html`
|
||||||
|
<dees-progressbar
|
||||||
|
.percentage=${50}
|
||||||
|
></dees-progressbar>
|
||||||
|
`;
|
||||||
|
}
|
95
ts_web/elements/dees-progressbar.ts
Normal file
95
ts_web/elements/dees-progressbar.ts
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
import * as colors from './00colors.js';
|
||||||
|
import { demoFunc } from './dees-progressbar.demo.js';
|
||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
DeesElement,
|
||||||
|
property,
|
||||||
|
type TemplateResult,
|
||||||
|
cssManager,
|
||||||
|
css,
|
||||||
|
type CSSResult,
|
||||||
|
unsafeCSS,
|
||||||
|
unsafeHTML,
|
||||||
|
state,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
|
@customElement('dees-progressbar')
|
||||||
|
export class DeesProgressbar extends DeesElement {
|
||||||
|
// STATIC
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
@property({
|
||||||
|
type: Number,
|
||||||
|
})
|
||||||
|
public percentage = 0;
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
color: ${cssManager.bdTheme(colors.bright.text, colors.dark.text)};
|
||||||
|
}
|
||||||
|
.progressBarContainer {
|
||||||
|
padding: 8px;
|
||||||
|
min-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressBar {
|
||||||
|
background: ${cssManager.bdTheme('#eeeeeb', '#444')};
|
||||||
|
height: 8px;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 4px;
|
||||||
|
border-top: 0.5px solid ${cssManager.bdTheme('none', '#555')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressBarFill {
|
||||||
|
background: ${cssManager.bdTheme(colors.dark.blueActive, colors.bright.blueActive)};
|
||||||
|
height: 8px;
|
||||||
|
margin-top: -0.5px;
|
||||||
|
transition: 0.2s width;
|
||||||
|
border-radius: 4px;
|
||||||
|
width: 0px;
|
||||||
|
border-top: 0.5 solid ${cssManager.bdTheme('none', '#398fff')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressText {
|
||||||
|
padding: 8px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
];
|
||||||
|
|
||||||
|
public render() {
|
||||||
|
return html`
|
||||||
|
<div class="progressBarContainer">
|
||||||
|
<div class="progressBar">
|
||||||
|
<div class="progressBarFill"></div>
|
||||||
|
<div class="progressText">
|
||||||
|
${this.percentage}%
|
||||||
|
<div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
firstUpdated (_changedProperties: Map<string | number | symbol, unknown>): void {
|
||||||
|
super.firstUpdated(_changedProperties);
|
||||||
|
this.updateComplete.then(() => {
|
||||||
|
this.updatePercentage();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async updatePercentage() {
|
||||||
|
const progressBarFill = this.shadowRoot.querySelector('.progressBarFill') as HTMLElement;
|
||||||
|
progressBarFill.style.width = `${this.percentage}%`;
|
||||||
|
}
|
||||||
|
|
||||||
|
updated(){
|
||||||
|
this.updatePercentage();
|
||||||
|
}
|
||||||
|
}
|
5
ts_web/elements/dees-simple-appdash.demo.ts
Normal file
5
ts_web/elements/dees-simple-appdash.demo.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<dees-simple-appdash>Hello there</dees-simple-appdash>
|
||||||
|
`;
|
156
ts_web/elements/dees-simple-appdash.ts
Normal file
156
ts_web/elements/dees-simple-appdash.ts
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
import { demoFunc } from './dees-simple-appdash.demo.js';
|
||||||
|
import * as colors from './00colors.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
DeesElement,
|
||||||
|
property,
|
||||||
|
type TemplateResult,
|
||||||
|
cssManager,
|
||||||
|
css,
|
||||||
|
unsafeCSS,
|
||||||
|
type CSSResult,
|
||||||
|
state,
|
||||||
|
domtools,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import { DeesTerminal } from './dees-terminal.js';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-simple-appdash': DeesSimpleAppDash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-simple-appdash')
|
||||||
|
export class DeesSimpleAppDash extends DeesElement {
|
||||||
|
// STATIC
|
||||||
|
public static demo = demoFunc;
|
||||||
|
// INSTANCE
|
||||||
|
|
||||||
|
@property()
|
||||||
|
public name = 'Dees Simple Login';
|
||||||
|
|
||||||
|
@property()
|
||||||
|
public views: Array<{ name: string; icon: string; viewFunction: () => Promise<TemplateResult> }> =
|
||||||
|
[];
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
|
user-select: none;
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.appbar {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
height: 32px;
|
||||||
|
width: 100%;
|
||||||
|
background: ${cssManager.bdTheme('#eeeeeb', '#222')};
|
||||||
|
border-bottom: 1px solid ${cssManager.bdTheme('#ccc', '#ffffff10')};
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 32px;
|
||||||
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
|
padding: 0px 16px;
|
||||||
|
z-index: 2;
|
||||||
|
box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.8);
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: min-content 1fr auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appName {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appActions {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appActions .action {
|
||||||
|
}
|
||||||
|
.appActions .action:hover {
|
||||||
|
color: ${cssManager.bdTheme('#000', '#fff')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.appcontent {
|
||||||
|
z-index: 1;
|
||||||
|
position: fixed;
|
||||||
|
top: 32px;
|
||||||
|
height: calc(100vh - 32px - 24px);
|
||||||
|
bottom: 24px;
|
||||||
|
width: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
background: ${cssManager.bdTheme('#eeeeeb', '#000')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.controlbar {
|
||||||
|
color: #fff;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
left: 0px;
|
||||||
|
width: 100%;
|
||||||
|
height: 24px;
|
||||||
|
background: ${cssManager.bdTheme(colors.bright.blueMuted, colors.dark.blueMuted)};
|
||||||
|
z-index: 2;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control {
|
||||||
|
width: min-content;
|
||||||
|
margin-right: 16px;
|
||||||
|
font-size: 12px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<div class="appbar">
|
||||||
|
<div class="appName">${this.name}</div>
|
||||||
|
<div class="viewTabs"></div>
|
||||||
|
<div class="appActions">
|
||||||
|
<div class="action">Logout</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="appcontent">
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
<div class="controlbar">
|
||||||
|
<div class="control">
|
||||||
|
<dees-icon .iconFA=${'networkWired'}></dees-icon>
|
||||||
|
</div>
|
||||||
|
<div class="control" @click=${this.launchTerminal}>
|
||||||
|
<dees-icon .iconFA=${'terminal'}></dees-icon>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async firstUpdated(_changedProperties): Promise<void> {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
super.firstUpdated(_changedProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async launchTerminal() {
|
||||||
|
const appcontent = this.shadowRoot.querySelector('.appcontent');
|
||||||
|
const terminal = new DeesTerminal();
|
||||||
|
terminal.style.position = 'absolute';
|
||||||
|
terminal.style.top = '0px';
|
||||||
|
terminal.style.left = '0px';
|
||||||
|
terminal.style.opacity = '0';
|
||||||
|
terminal.style.transform = 'translateY(20px)';
|
||||||
|
terminal.style.transition = 'all 0.2s';
|
||||||
|
appcontent.appendChild(terminal);
|
||||||
|
await domtools.plugins.smartdelay.delayFor(0);
|
||||||
|
terminal.style.opacity = '1';
|
||||||
|
terminal.style.transform = 'translateY(0px)';
|
||||||
|
}
|
||||||
|
}
|
3
ts_web/elements/dees-simple-login.demo.ts
Normal file
3
ts_web/elements/dees-simple-login.demo.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => html` <dees-simple-login name="someapp"> Hello there </dees-simple-login> `;
|
131
ts_web/elements/dees-simple-login.ts
Normal file
131
ts_web/elements/dees-simple-login.ts
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
import { demoFunc } from './dees-simple-login.demo.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
DeesElement,
|
||||||
|
property,
|
||||||
|
type TemplateResult,
|
||||||
|
cssManager,
|
||||||
|
css,
|
||||||
|
unsafeCSS,
|
||||||
|
type CSSResult,
|
||||||
|
state,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-simple-login': DeesSimpleLogin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-simple-login')
|
||||||
|
export class DeesSimpleLogin extends DeesElement {
|
||||||
|
// STATIC
|
||||||
|
public static demo = demoFunc
|
||||||
|
// INSTANCE
|
||||||
|
|
||||||
|
@property()
|
||||||
|
public name = 'Dees Simple Login';
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.loginContainer {
|
||||||
|
position: absolute;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center; /* aligns horizontally */
|
||||||
|
align-items: center; /* aligns vertically */
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slotContainer {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login {
|
||||||
|
min-width: 320px;
|
||||||
|
min-height: 100px;
|
||||||
|
background: ${cssManager.bdTheme('#eeeeeb', '#111')};
|
||||||
|
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 24px;
|
||||||
|
transition: opacity 0.3s, transform 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.slotContainer {
|
||||||
|
opacity:0;
|
||||||
|
transition: opacity 0.3s, transform 0.3s;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<div class="loginContainer">
|
||||||
|
<div class="login">
|
||||||
|
<dees-form>
|
||||||
|
<div class="header">Login to ${this.name}</div>
|
||||||
|
<dees-input-text key="username" label="username" required></dees-input-text>
|
||||||
|
<dees-input-text key="password" label="password" isPasswordBool required></dees-input-text>
|
||||||
|
<dees-form-submit disabled>login</dees-form-submit>
|
||||||
|
</dees-form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="slotContainer">
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async firstUpdated(_changedProperties): Promise<void> {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
super.firstUpdated(_changedProperties);
|
||||||
|
const form = this.shadowRoot.querySelector('dees-form');
|
||||||
|
await form.readyDeferred.promise;
|
||||||
|
const username = this.shadowRoot.querySelector('dees-input-text[label="username"]');
|
||||||
|
const password = this.shadowRoot.querySelector('dees-input-text[label="password"]');
|
||||||
|
const submit = this.shadowRoot.querySelector('dees-form-submit');
|
||||||
|
form.addEventListener('formData', (event: CustomEvent) => {
|
||||||
|
this.dispatchEvent(new CustomEvent('login', { detail: event.detail }));
|
||||||
|
// this.switchToSlottedContent();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* allows switching to slotted content
|
||||||
|
*/
|
||||||
|
public async switchToSlottedContent() {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
const loginDiv: HTMLDivElement = this.shadowRoot.querySelector('.login');
|
||||||
|
const loginContainerDiv: HTMLDivElement = this.shadowRoot.querySelector('.loginContainer');
|
||||||
|
const slotContainerDiv: HTMLDivElement = this.shadowRoot.querySelector('.slotContainer');
|
||||||
|
loginDiv.style.opacity = '0';
|
||||||
|
loginDiv.style.transform = 'translateY(20px)';
|
||||||
|
loginContainerDiv.style.pointerEvents = 'none';
|
||||||
|
slotContainerDiv.style.transform = 'translateY(20px)';
|
||||||
|
await domtools.convenience.smartdelay.delayFor(300);
|
||||||
|
slotContainerDiv.style.opacity = '1';
|
||||||
|
slotContainerDiv.style.transform = 'translateY(0px)';
|
||||||
|
await domtools.convenience.smartdelay.delayFor(300);
|
||||||
|
slotContainerDiv.style.pointerEvents = 'all';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
23
ts_web/elements/dees-speechbubble.demo.ts
Normal file
23
ts_web/elements/dees-speechbubble.demo.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { html, cssManager } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = () => {
|
||||||
|
return html`
|
||||||
|
<style>
|
||||||
|
.ref1 {
|
||||||
|
margin: 20px;
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="ref1"></div>
|
||||||
|
<dees-speechbubble .text=${`
|
||||||
|
**This is a longer markdown text that can be used the write**
|
||||||
|
a longer description about whats going on the app
|
||||||
|
|
||||||
|
**This is a subheader**
|
||||||
|
and another text
|
||||||
|
|
||||||
|
`}></dees-speechbubble>
|
||||||
|
`;
|
||||||
|
};
|
@ -1,15 +1,22 @@
|
|||||||
|
import * as colors from './00colors.js';
|
||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
|
||||||
|
import { demoFunc } from './dees-speechbubble.demo.js';
|
||||||
import {
|
import {
|
||||||
customElement,
|
customElement,
|
||||||
html,
|
html,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
|
type CSSResult,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
} from '@designestate/dees-element';
|
domtools,
|
||||||
|
directives,
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
unsafeHTML,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -19,26 +26,53 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-speechbubble')
|
@customElement('dees-speechbubble')
|
||||||
export class DeesSpeechbubble extends DeesElement {
|
export class DeesSpeechbubble extends DeesElement {
|
||||||
public static demo = () => html` <dees-speechbubble></dees-speechbubble> `;
|
public static demo = demoFunc;
|
||||||
|
|
||||||
@property()
|
// STATIC
|
||||||
|
public static async createAndShow(refElement: HTMLElement, textArg: string) {
|
||||||
|
const windowLayer = await DeesWindowLayer.createAndShow({
|
||||||
|
blur: false,
|
||||||
|
});
|
||||||
|
const speechbubble = document.createElement('dees-speechbubble');
|
||||||
|
speechbubble.windowLayer = windowLayer;
|
||||||
|
speechbubble.reffedElement = refElement;
|
||||||
|
speechbubble.text = textArg;
|
||||||
|
speechbubble.manifested = true;
|
||||||
|
windowLayer.appendChild(speechbubble);
|
||||||
|
windowLayer.style.pointerEvents = 'none';
|
||||||
|
(windowLayer.shadowRoot.querySelector('.windowOverlay') as HTMLElement).style.pointerEvents = 'none';
|
||||||
|
return speechbubble;
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
@property({
|
||||||
|
type: Object,
|
||||||
|
})
|
||||||
|
reffedElement: HTMLElement;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
public text: string;
|
public text: string;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public disabled = false;
|
public wave: boolean = false;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public isHidden = false;
|
public manifested = false;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
})
|
})
|
||||||
public status: 'normal' | 'pending' | 'success' | 'error' = 'normal';
|
public status: 'normal' | 'pending' | 'success' | 'error' = 'normal';
|
||||||
|
|
||||||
|
public windowLayer: DeesWindowLayer;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -47,28 +81,22 @@ export class DeesSpeechbubble extends DeesElement {
|
|||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
:host {
|
:host {
|
||||||
position: relative;
|
|
||||||
display: block;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
:host([hidden]) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.maincontainer {
|
.maincontainer {
|
||||||
|
position: relative;
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
transition: transform 0.2s;
|
transition: transform 0.2s;
|
||||||
transform: translateX(0px);
|
transform: translateX(0px);
|
||||||
position: relative;
|
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
margin-left: 0px;
|
margin-left: 0px;
|
||||||
}
|
filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, 0.2));
|
||||||
|
pointer-events: none;
|
||||||
.maincontainer:hover {
|
opacity: 0;
|
||||||
transform: translateX(3px);
|
transition: all 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.arrow {
|
.arrow {
|
||||||
@ -77,17 +105,17 @@ export class DeesSpeechbubble extends DeesElement {
|
|||||||
background: ${cssManager.bdTheme('#fff', '#333')};
|
background: ${cssManager.bdTheme('#fff', '#333')};
|
||||||
height: 15px;
|
height: 15px;
|
||||||
width: 15px;
|
width: 15px;
|
||||||
left: 4px;
|
left: 2px;
|
||||||
top: 5px;
|
top: 12px;
|
||||||
border-radius: 2px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.speechbubble {
|
.speechbubble {
|
||||||
background: ${cssManager.bdTheme('#fff', '#333')};
|
background: ${cssManager.bdTheme('#fff', '#333')};
|
||||||
padding: 0px 10px;
|
padding: 0px 16px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
line-height: 25px;
|
min-width: 240px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
left: 8px;
|
left: 8px;
|
||||||
@ -132,25 +160,70 @@ export class DeesSpeechbubble extends DeesElement {
|
|||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<div class="maincontainer" @click=${this.handleClick}>
|
${this.manifested
|
||||||
<div class="arrow"></div>
|
? html`
|
||||||
<div class="speechbubble"><span class="wave">👋</span> We build with launch.sh, and you can too.</div>
|
<div class="maincontainer" @click=${this.handleClick}>
|
||||||
</div>
|
<div class="arrow"></div>
|
||||||
|
<div class="speechbubble">
|
||||||
|
${this.wave ? html`<span class="wave">👋</span>` : html``}
|
||||||
|
${directives.resolve(this.getHtml())}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: html``}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async handleClick() {
|
public async handleClick() {
|
||||||
if (this.disabled) {
|
console.log('speechbubble got clicked.');
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
globalThis.location.href = "https://launch.sh"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async firstUpdated() {
|
public async firstUpdated() {
|
||||||
if (!this.textContent) {
|
// lets make sure we have a ref
|
||||||
this.textContent = 'Button';
|
if (!this.reffedElement) {
|
||||||
this.performUpdate();
|
this.reffedElement = this.previousElementSibling as HTMLElement;
|
||||||
|
}
|
||||||
|
if (this.manifested) {
|
||||||
|
await this.updatePosition();
|
||||||
|
(this.shadowRoot.querySelector('.maincontainer') as HTMLElement).style.opacity = '1';
|
||||||
|
} else {
|
||||||
|
// lets make sure we instrument it
|
||||||
|
let speechbubble: DeesSpeechbubble;
|
||||||
|
this.reffedElement.addEventListener('mouseenter', async () => {
|
||||||
|
speechbubble = await DeesSpeechbubble.createAndShow(this.reffedElement, this.text);
|
||||||
|
});
|
||||||
|
this.reffedElement.addEventListener('mouseleave', () => {
|
||||||
|
speechbubble.destroy();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async updatePosition() {
|
||||||
|
const refElement = this.reffedElement;
|
||||||
|
const boundingClientRect = refElement.getBoundingClientRect();
|
||||||
|
this.style.position = 'fixed';
|
||||||
|
this.style.top = `${boundingClientRect.top - 13}px`;
|
||||||
|
this.style.left = `${boundingClientRect.left + refElement.clientWidth + 4}px`;
|
||||||
|
if (boundingClientRect.right > 250) {
|
||||||
|
this.style.width = `250px`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getHtml(): Promise<any> {
|
||||||
|
if (!this.text) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
const normalized = domtools.plugins.smartstring.normalize.standard(this.text);
|
||||||
|
const result = await domtools.plugins.smartmarkdown.SmartMarkdown.easyMarkdownToHtml(
|
||||||
|
normalized
|
||||||
|
);
|
||||||
|
return unsafeHTML(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async show() {}
|
||||||
|
|
||||||
|
public async destroy() {
|
||||||
|
(this.shadowRoot.querySelector('.maincontainer') as HTMLElement).style.opacity = '0';
|
||||||
|
this.windowLayer.destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,14 @@ import {
|
|||||||
html,
|
html,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
|
type CSSResult,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
} from '@designestate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
import * as colors from './00colors.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DeesElement,
|
DeesElement,
|
||||||
customElement,
|
customElement,
|
||||||
html,
|
html,
|
||||||
css,
|
css,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
|
type CSSResult,
|
||||||
cssManager,
|
cssManager,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
} from '@designestate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
export interface IStep {
|
export interface IStep {
|
||||||
title: string;
|
title: string;
|
||||||
@ -48,15 +52,15 @@ export class DeesStepper extends DeesElement {
|
|||||||
`,
|
`,
|
||||||
validationFunc: async (stepperArg, elementArg) => {
|
validationFunc: async (stepperArg, elementArg) => {
|
||||||
const deesForm = elementArg.querySelector('dees-form');
|
const deesForm = elementArg.querySelector('dees-form');
|
||||||
deesForm.addEventListener('formData', eventArg => {
|
deesForm.addEventListener('formData', (eventArg) => {
|
||||||
stepperArg.goNext();
|
stepperArg.goNext();
|
||||||
})
|
});
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Whats your mobile number?',
|
title: 'Whats your mobile number?',
|
||||||
content: html``,
|
content: html``,
|
||||||
}
|
},
|
||||||
] as IStep[]}
|
] as IStep[]}
|
||||||
></dees-stepper>
|
></dees-stepper>
|
||||||
`;
|
`;
|
||||||
@ -98,7 +102,7 @@ export class DeesStepper extends DeesElement {
|
|||||||
transition: all 0.7s ease-in-out;
|
transition: all 0.7s ease-in-out;
|
||||||
max-width: 500px;
|
max-width: 500px;
|
||||||
min-height: 300px;
|
min-height: 300px;
|
||||||
border-radius: 3px;
|
border-radius: 8px;
|
||||||
background: ${cssManager.bdTheme('#ffffff', '#181818')};
|
background: ${cssManager.bdTheme('#ffffff', '#181818')};
|
||||||
border-top: 1px solid ${cssManager.bdTheme('#ffffff', '#181818')};
|
border-top: 1px solid ${cssManager.bdTheme('#ffffff', '#181818')};
|
||||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
@ -126,6 +130,7 @@ export class DeesStepper extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.step .stepCounter {
|
.step .stepCounter {
|
||||||
|
color: #999;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
right: 0px;
|
right: 0px;
|
||||||
@ -136,6 +141,8 @@ export class DeesStepper extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.step .goBack {
|
.step .goBack {
|
||||||
|
color: #999;
|
||||||
|
cursor: default;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
@ -143,17 +150,31 @@ export class DeesStepper extends DeesElement {
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
border-bottom-right-radius: 3px;
|
border-bottom-right-radius: 3px;
|
||||||
background: ${cssManager.bdTheme('#00000008', '#ffffff08')};
|
background: ${cssManager.bdTheme('#00000008', '#ffffff08')};
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.step .goBack:hover {
|
.step .goBack:hover {
|
||||||
background: ${cssManager.bdTheme('#00000012', '#ffffff12')};
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
|
background: ${cssManager.bdTheme('#00000012', colors.dark.blue)};
|
||||||
|
}
|
||||||
|
|
||||||
|
.step .goBack:active {
|
||||||
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
|
background: ${cssManager.bdTheme('#00000012', colors.dark.blueActive)};
|
||||||
|
}
|
||||||
|
|
||||||
|
.step .goBack span {
|
||||||
|
transition: all 0.2s;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step .goBack:hover span {
|
||||||
|
transform: translateX(-2px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.step .title {
|
.step .title {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding-top: 50px;
|
padding-top: 50px;
|
||||||
font-family: Inter;
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
@ -177,7 +198,7 @@ export class DeesStepper extends DeesElement {
|
|||||||
: ''}"
|
: ''}"
|
||||||
>
|
>
|
||||||
${this.getIndexOfStep(stepArg) > 0
|
${this.getIndexOfStep(stepArg) > 0
|
||||||
? html`<div class="goBack" @click=${this.goBack}><- go to previous step</div>`
|
? html`<div class="goBack" @click=${this.goBack}><span style="font-family: Inter"><-</span> go to previous step</div>`
|
||||||
: ``}
|
: ``}
|
||||||
<div class="stepCounter">
|
<div class="stepCounter">
|
||||||
Step ${this.steps.findIndex((elementArg) => elementArg === stepArg) + 1} of
|
Step ${this.steps.findIndex((elementArg) => elementArg === stepArg) + 1} of
|
||||||
@ -195,22 +216,26 @@ export class DeesStepper extends DeesElement {
|
|||||||
return this.steps.findIndex((stepArg2) => stepArg === stepArg2);
|
return this.steps.findIndex((stepArg2) => stepArg === stepArg2);
|
||||||
};
|
};
|
||||||
|
|
||||||
public firstUpdated() {
|
public async firstUpdated() {
|
||||||
|
await this.domtoolsPromise;
|
||||||
|
await this.domtools.convenience.smartdelay.delayFor(0);
|
||||||
this.selectedStep = this.steps[0];
|
this.selectedStep = this.steps[0];
|
||||||
this.setScrollStatus();
|
this.setScrollStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public updated() {
|
public async updated() {
|
||||||
this.setScrollStatus();
|
this.setScrollStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public scroller: typeof domtools.plugins.SweetScroll.prototype;
|
public scroller: typeof domtools.plugins.SweetScroll.prototype;
|
||||||
|
|
||||||
public async setScrollStatus() {
|
public async setScrollStatus() {
|
||||||
await domtools.plugins.smartdelay.delayFor(50);
|
|
||||||
const stepperContainer: HTMLElement = this.shadowRoot.querySelector('.stepperContainer');
|
const stepperContainer: HTMLElement = this.shadowRoot.querySelector('.stepperContainer');
|
||||||
const firstStepElement: HTMLElement = this.shadowRoot.querySelector('.step');
|
const firstStepElement: HTMLElement = this.shadowRoot.querySelector('.step');
|
||||||
const selectedStepElement: HTMLElement = this.shadowRoot.querySelector('.selected');
|
const selectedStepElement: HTMLElement = this.shadowRoot.querySelector('.selected');
|
||||||
|
if (!selectedStepElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!stepperContainer.style.paddingTop) {
|
if (!stepperContainer.style.paddingTop) {
|
||||||
stepperContainer.style.paddingTop = `${
|
stepperContainer.style.paddingTop = `${
|
||||||
stepperContainer.offsetHeight / 2 - selectedStepElement.offsetHeight / 2
|
stepperContainer.offsetHeight / 2 - selectedStepElement.offsetHeight / 2
|
||||||
|
129
ts_web/elements/dees-table.demo.ts
Normal file
129
ts_web/elements/dees-table.demo.ts
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
import { type ITableAction } from './dees-table.js';
|
||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
interface ITableDemoData {
|
||||||
|
date: string;
|
||||||
|
amount: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<style>
|
||||||
|
.demoWrapper {
|
||||||
|
box-sizing: border-box;
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
background: #000000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="demoWrapper">
|
||||||
|
<dees-table
|
||||||
|
heading1="Current Account Statement"
|
||||||
|
heading2="Bunq - Payment Account 2 - April 2021"
|
||||||
|
.editableFields="${['description']}"
|
||||||
|
.data=${[
|
||||||
|
{
|
||||||
|
date: '2021-04-01',
|
||||||
|
amount: '2464.65 €',
|
||||||
|
description: 'Printing Paper (Office Supplies) - STAPLES BREMEN',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2021-04-02',
|
||||||
|
amount: '165.65 €',
|
||||||
|
description: 'Logitech Mouse (Hardware) - logi.com OnlineShop',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2021-04-03',
|
||||||
|
amount: '2999,00 €',
|
||||||
|
description: 'Macbook Pro 16inch (Hardware) - Apple.de OnlineShop',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2021-04-01',
|
||||||
|
amount: '2464.65 €',
|
||||||
|
description: 'Office-Supplies - STAPLES BREMEN',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2021-04-01',
|
||||||
|
amount: '2464.65 €',
|
||||||
|
description: 'Office-Supplies - STAPLES BREMEN',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
dataName="transactions"
|
||||||
|
.dataActions="${[
|
||||||
|
{
|
||||||
|
name: 'upload',
|
||||||
|
iconName: 'bell',
|
||||||
|
useTableBehaviour: 'upload',
|
||||||
|
type: ['inRow'],
|
||||||
|
actionFunc: async (optionsArg) => {
|
||||||
|
alert(optionsArg.item.amount);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'visibility',
|
||||||
|
iconName: 'copy',
|
||||||
|
type: ['inRow'],
|
||||||
|
useTableBehaviour: 'preview',
|
||||||
|
actionFunc: async (itemArg: any) => {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'create new',
|
||||||
|
iconName: 'instagram',
|
||||||
|
type: ['header'],
|
||||||
|
useTableBehaviour: 'preview',
|
||||||
|
actionFunc: async (itemArg: any) => {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'to gallery',
|
||||||
|
iconName: 'message',
|
||||||
|
type: ['footer'],
|
||||||
|
useTableBehaviour: 'preview',
|
||||||
|
actionFunc: async (itemArg: any) => {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'copy',
|
||||||
|
iconName: 'copySolid',
|
||||||
|
type: ['contextmenu', 'inRow'],
|
||||||
|
action: async () => {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'edit (from demo)',
|
||||||
|
iconName: 'penToSquare',
|
||||||
|
type: ['contextmenu'],
|
||||||
|
action: async () => {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'paste',
|
||||||
|
iconName: 'pasteSolid',
|
||||||
|
type: ['contextmenu'],
|
||||||
|
action: async () => {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'preview',
|
||||||
|
type: ['doubleClick', 'contextmenu'],
|
||||||
|
iconName: 'eye',
|
||||||
|
actionFunc: async (itemArg) => {
|
||||||
|
alert(itemArg.item.amount);
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
] as (ITableAction<ITableDemoData>)[] as any}"
|
||||||
|
.displayFunction=${(itemArg) => {
|
||||||
|
return {
|
||||||
|
...itemArg,
|
||||||
|
onlyDisplayProp: 'onlyDisplay',
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
>This is a slotted Text</dees-table
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
`;
|
@ -1,16 +1,24 @@
|
|||||||
|
import * as colors from './00colors.js';
|
||||||
|
import * as plugins from './00plugins.js';
|
||||||
|
import { demoFunc } from './dees-table.demo.js';
|
||||||
import {
|
import {
|
||||||
customElement,
|
customElement,
|
||||||
html,
|
html,
|
||||||
DeesElement,
|
DeesElement,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
type TemplateResult,
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
|
type CSSResult,
|
||||||
state,
|
state,
|
||||||
} from '@designestate/dees-element';
|
resolveExec,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import { DeesContextmenu } from './dees-contextmenu.js';
|
||||||
|
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
import { type TIconKey } from './dees-icon.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -18,75 +26,52 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDataAction<T = any> {
|
// interfaces
|
||||||
|
export interface ITableAction<T = any> {
|
||||||
name: string;
|
name: string;
|
||||||
iconName: string;
|
iconName: TIconKey;
|
||||||
|
/**
|
||||||
|
* the table behaviour to use for this action
|
||||||
|
* e.g. upload: allows to upload files to the table
|
||||||
|
*/
|
||||||
useTableBehaviour?: 'upload' | 'cancelUpload' | 'none';
|
useTableBehaviour?: 'upload' | 'cancelUpload' | 'none';
|
||||||
actionFunc: (itemArg: T) => Promise<any>;
|
/**
|
||||||
|
* the type of the action
|
||||||
|
*/
|
||||||
|
type: (
|
||||||
|
| 'inRow'
|
||||||
|
| 'contextmenu'
|
||||||
|
| 'doubleClick'
|
||||||
|
| 'footer'
|
||||||
|
| 'header'
|
||||||
|
| 'preview'
|
||||||
|
| 'keyCombination'
|
||||||
|
)[];
|
||||||
|
/**
|
||||||
|
* allows to check if the action is relevant for the given item
|
||||||
|
* @param itemArg
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
actionRelevancyCheckFunc?: (itemArg: T) => boolean;
|
||||||
|
/**
|
||||||
|
* the actual action function implementation
|
||||||
|
* @param itemArg
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
actionFunc: (actionDataArg: ITableActionDataArg<T>) => Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ITableActionDataArg<T> {
|
||||||
|
item: T;
|
||||||
|
table: DeesTable<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TDisplayFunction<T = any> = (itemArg: T) => object;
|
||||||
|
|
||||||
|
// the table implementation
|
||||||
@customElement('dees-table')
|
@customElement('dees-table')
|
||||||
export class DeesTable<T> extends DeesElement {
|
export class DeesTable<T> extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = demoFunc;
|
||||||
<style>
|
|
||||||
.demoWrapper {
|
|
||||||
box-sizing: border-box;
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
padding: 60px;
|
|
||||||
background: #000000;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<div class="demoWrapper">
|
|
||||||
<dees-table
|
|
||||||
heading1="Current Account Statement"
|
|
||||||
heading2="Bunq - Payment Account 2 - April 2021"
|
|
||||||
.data=${[
|
|
||||||
{
|
|
||||||
date: '2021-04-01',
|
|
||||||
amount: '2464.65 €',
|
|
||||||
description: 'Printing Paper (Office Supplies) - STAPLES BREMEN',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '2021-04-02',
|
|
||||||
amount: '165.65 €',
|
|
||||||
description: 'Logitech Mouse (Hardware) - logi.com OnlineShop',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '2021-04-03',
|
|
||||||
amount: '2999,00 €',
|
|
||||||
description: 'Macbook Pro 16inch (Hardware) - Apple.de OnlineShop',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '2021-04-01',
|
|
||||||
amount: '2464.65 €',
|
|
||||||
description: 'Office-Supplies - STAPLES BREMEN',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '2021-04-01',
|
|
||||||
amount: '2464.65 €',
|
|
||||||
description: 'Office-Supplies - STAPLES BREMEN',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
.dataActions="${[{
|
|
||||||
name: 'upload',
|
|
||||||
iconName: 'upload',
|
|
||||||
useTableBehaviour: 'upload',
|
|
||||||
actionFunc: async (itemArg: any) => {
|
|
||||||
|
|
||||||
},
|
|
||||||
},{
|
|
||||||
name: 'visibility',
|
|
||||||
iconName: 'visibility',
|
|
||||||
useTableBehaviour: 'preview',
|
|
||||||
actionFunc: async (itemArg: any) => {
|
|
||||||
|
|
||||||
},
|
|
||||||
}] as IDataAction[]}"
|
|
||||||
>This is a slotted Text</dees-table>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
@property({
|
@property({
|
||||||
@ -104,10 +89,63 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
})
|
})
|
||||||
public data: T[] = [];
|
public data: T[] = [];
|
||||||
|
|
||||||
|
// dees-form compatibility -----------------------------------------
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
})
|
||||||
|
public key: string;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
})
|
||||||
|
public label: string;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Boolean,
|
||||||
|
})
|
||||||
|
public disabled: boolean = false;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Boolean,
|
||||||
|
})
|
||||||
|
public required: boolean = false;
|
||||||
|
|
||||||
|
get value() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
set value(valueArg) {}
|
||||||
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject<DeesTable<T>>();
|
||||||
|
// end dees-form compatibility -----------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What does a row of data represent?
|
||||||
|
*/
|
||||||
|
@property({
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
|
public dataName: string;
|
||||||
|
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Boolean,
|
||||||
|
})
|
||||||
|
searchable: boolean = true;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Array,
|
type: Array,
|
||||||
})
|
})
|
||||||
public dataActions: IDataAction[] = [];
|
public dataActions: ITableAction<T>[] = [];
|
||||||
|
|
||||||
|
@property({
|
||||||
|
attribute: false,
|
||||||
|
})
|
||||||
|
public displayFunction: TDisplayFunction = (itemArg: T) => itemArg as any;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
attribute: false,
|
||||||
|
})
|
||||||
|
public reverseDisplayFunction: (itemArg: any) => T = (itemArg: any) => itemArg as T;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Object,
|
type: Object,
|
||||||
@ -115,18 +153,15 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
public selectedDataRow: T;
|
public selectedDataRow: T;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: Array,
|
||||||
})
|
})
|
||||||
public type: 'normal' | 'highlighted' | 'discreet' | 'big' = 'normal';
|
public editableFields: string[] = [];
|
||||||
|
|
||||||
@property({
|
|
||||||
type: String,
|
|
||||||
})
|
|
||||||
public status: 'normal' | 'pending' | 'success' | 'error' = 'normal';
|
|
||||||
|
|
||||||
public files: File[] = [];
|
public files: File[] = [];
|
||||||
public fileWeakMap = new WeakMap();
|
public fileWeakMap = new WeakMap();
|
||||||
|
|
||||||
|
public dataChangeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -136,22 +171,83 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
css`
|
css`
|
||||||
.mainbox {
|
.mainbox {
|
||||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
font-family: 'Inter';
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 16px;
|
font-size: 14px;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
background: ${cssManager.bdTheme('#ffffff', '#333333')};
|
background: ${cssManager.bdTheme('#ffffff', '#222222')};
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border-top: 1px solid ${cssManager.bdTheme('#fff', '#444')};
|
border-top: 1px solid ${cssManager.bdTheme('#fff', '#ffffff10')};
|
||||||
box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.3);
|
box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.3);
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
align-items: center;
|
||||||
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.headingContainer {
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading {
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading1 {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.heading2 {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
.headingSeparation {
|
.headingSeparation {
|
||||||
margin-top: 7px;
|
margin-top: 7px;
|
||||||
border-bottom: 1px solid ${cssManager.bdTheme('#bcbcbc', '#bcbcbc')};
|
border-bottom: 1px solid ${cssManager.bdTheme('#bcbcbc', '#444444')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.headerActions {
|
||||||
|
user-select: none;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
.headerAction {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||||
|
margin-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.headerAction:hover {
|
||||||
|
color: ${cssManager.bdTheme('#555', '#fff')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.headerAction dees-icon {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchGrid {
|
||||||
|
background: ${cssManager.bdTheme('#fff', '#111111')};
|
||||||
|
display: grid;
|
||||||
|
grid-gap: 16px;
|
||||||
|
grid-template-columns: 1fr 200px;
|
||||||
|
margin-top: 16px;
|
||||||
|
padding: 0px 16px;
|
||||||
|
border-top: 1px solid ${cssManager.bdTheme('#fff', '#ffffff20')};
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchGrid.hidden {
|
||||||
|
height: 0px;
|
||||||
|
opacity: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-top: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table,
|
table,
|
||||||
@ -173,10 +269,9 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
tr:hover {
|
tr:hover {
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
tr:hover .innerCellContainer {
|
tr:hover td {
|
||||||
background: ${cssManager.bdTheme('#22222210', '#ffffff20')};
|
background: ${cssManager.bdTheme('#22222210', '#ffffff10')};
|
||||||
}
|
}
|
||||||
tr:first-child:hover {
|
tr:first-child:hover {
|
||||||
cursor: auto;
|
cursor: auto;
|
||||||
@ -184,19 +279,34 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
tr:first-child:hover .innerCellContainer {
|
tr:first-child:hover .innerCellContainer {
|
||||||
background: none;
|
background: none;
|
||||||
}
|
}
|
||||||
tr.selected .innerCellContainer {
|
tr.selected td {
|
||||||
background: ${cssManager.bdTheme('#22222220', '#ffffff20')};
|
background: ${cssManager.bdTheme('#22222220', '#ffffff20')};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr.hasAttachment td {
|
||||||
|
background: ${cssManager.bdTheme('#0098847c', '#0098847c')};
|
||||||
|
}
|
||||||
|
|
||||||
th {
|
th {
|
||||||
text-transform: uppercase;
|
text-transform: none;
|
||||||
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
th,
|
th,
|
||||||
td {
|
td {
|
||||||
padding: 3px 0px;
|
position: relative;
|
||||||
|
vertical-align: top;
|
||||||
|
|
||||||
|
padding: 0px;
|
||||||
border-right: 1px dashed ${cssManager.bdTheme('#999', '#808080')};
|
border-right: 1px dashed ${cssManager.bdTheme('#999', '#808080')};
|
||||||
}
|
}
|
||||||
.innerCellContainer {
|
.innerCellContainer {
|
||||||
|
min-height: 36px;
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
padding: 6px 8px;
|
padding: 6px 8px;
|
||||||
|
line-height: 24px;
|
||||||
}
|
}
|
||||||
th:first-child .innerCellContainer,
|
th:first-child .innerCellContainer,
|
||||||
td:first-child .innerCellContainer {
|
td:first-child .innerCellContainer {
|
||||||
@ -210,31 +320,87 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
td:last-child {
|
td:last-child {
|
||||||
border-right: none;
|
border-right: none;
|
||||||
}
|
}
|
||||||
|
td input {
|
||||||
.action {
|
width: 100%;
|
||||||
margin: -8px 0px;
|
height: 100%;
|
||||||
padding: 8px;
|
outline: none;
|
||||||
line-height: 16px;
|
border: 2px solid #fa6101;
|
||||||
display: inline-block;
|
top: 0px;
|
||||||
|
bottom: 0px;
|
||||||
|
right: 0px;
|
||||||
|
left: 0px;
|
||||||
|
position: absolute;
|
||||||
|
background: #fa610140;
|
||||||
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
font-weight: inherit;
|
||||||
|
padding: 0px 6px;
|
||||||
}
|
}
|
||||||
|
.actionsContainer {
|
||||||
.action:first-child {
|
display: flex;
|
||||||
margin-left: -8px;
|
flex-direction: row;
|
||||||
width: min-content;
|
height: 24px;
|
||||||
|
transform: translateY(-4px);
|
||||||
|
margin-left: -6px;
|
||||||
|
}
|
||||||
|
.action {
|
||||||
|
position: relative;
|
||||||
|
padding: 8px 10px;
|
||||||
|
line-height: 24px;
|
||||||
|
height: 32px;
|
||||||
|
size: 16px;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action:hover {
|
.action:hover {
|
||||||
background: ${cssManager.bdTheme('#CCC', '#111')};
|
background: ${cssManager.bdTheme(colors.bright.blue, colors.dark.blue)};
|
||||||
}
|
}
|
||||||
|
|
||||||
.tableStatistics {
|
.action:active {
|
||||||
padding: 4px 16px;
|
background: ${cssManager.bdTheme(colors.bright.blue, colors.dark.blueActive)};
|
||||||
font-size: 12px;
|
}
|
||||||
|
|
||||||
|
.action:hover dees-icon {
|
||||||
|
filter: ${cssManager.bdTheme('invert(1) brightness(3)', '')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
color: ${cssManager.bdTheme('#111', '#ffffff90')};
|
color: ${cssManager.bdTheme('#111', '#ffffff90')};
|
||||||
background: ${cssManager.bdTheme('#eeeeeb', '#00000050')};
|
background: ${cssManager.bdTheme('#eeeeeb', '#00000050')};
|
||||||
margin: 16px -16px -16px -16px;
|
margin: 16px -16px -16px -16px;
|
||||||
border-bottom-left-radius: 3px;
|
border-bottom-left-radius: 3px;
|
||||||
border-bottom-right-radius: 3px;
|
border-bottom-right-radius: 3px;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tableStatistics {
|
||||||
|
padding: 8px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerActions {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerActions .footerAction {
|
||||||
|
padding: 8px 16px;
|
||||||
|
display: flex;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerActions .footerAction:hover {
|
||||||
|
background: ${cssManager.bdTheme(colors.bright.blue, colors.dark.blue)};
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerActions .footerAction dees-icon {
|
||||||
|
display: flex;
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerActions .footerAction:hover dees-icon {
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
@ -243,15 +409,73 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
return html`
|
return html`
|
||||||
<div class="mainbox">
|
<div class="mainbox">
|
||||||
<!-- the heading part -->
|
<!-- the heading part -->
|
||||||
<div>${this.heading1}</div>
|
<div class="header">
|
||||||
<div>${this.heading2}</div>
|
<div class="headingContainer">
|
||||||
|
<div class="heading heading1">${this.label || this.heading1}</div>
|
||||||
|
<div class="heading heading2">${this.heading2}</div>
|
||||||
|
</div>
|
||||||
|
<div class="headerActions">
|
||||||
|
${resolveExec(async () => {
|
||||||
|
const resultArray: TemplateResult[] = [];
|
||||||
|
for (const action of this.dataActions) {
|
||||||
|
if (!action.type.includes('header')) continue;
|
||||||
|
resultArray.push(
|
||||||
|
html`<div
|
||||||
|
class="headerAction"
|
||||||
|
@click=${() => {
|
||||||
|
action.actionFunc({
|
||||||
|
item: this.selectedDataRow,
|
||||||
|
table: this,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
${action.iconName
|
||||||
|
? html`<dees-icon .iconSize=${14} .iconFA=${action.iconName}></dees-icon>
|
||||||
|
${action.name}`
|
||||||
|
: action.name}
|
||||||
|
</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return resultArray;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="headingSeparation"></div>
|
<div class="headingSeparation"></div>
|
||||||
|
<div class="searchGrid hidden">
|
||||||
|
<dees-input-text
|
||||||
|
.label=${'lucene syntax search'}
|
||||||
|
.description=${`
|
||||||
|
You can use the lucene syntax to search for data, e.g.:
|
||||||
|
|
||||||
|
\`\`\`
|
||||||
|
name: "john" AND age: 18
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
`}
|
||||||
|
></dees-input-text>
|
||||||
|
<dees-input-multitoggle
|
||||||
|
.label=${'search mode'}
|
||||||
|
.options=${['table', 'data', 'server']}
|
||||||
|
.selectedOption=${'table'}
|
||||||
|
.description=${`
|
||||||
|
There are three basic modes:
|
||||||
|
|
||||||
|
* table: only searches data already in the table
|
||||||
|
* data: searches original data, ignoring table transforms
|
||||||
|
* server: searches data on the server
|
||||||
|
|
||||||
|
`}
|
||||||
|
></dees-input-multitoggle>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- the actual table -->
|
<!-- the actual table -->
|
||||||
<style></style>
|
<style></style>
|
||||||
${this.data.length > 0
|
${this.data.length > 0
|
||||||
? (() => {
|
? (() => {
|
||||||
const headings: string[] = Object.keys(this.data[0]);
|
// Only pick up the keys from the first transformed data object
|
||||||
|
// as all data objects are assumed to have the same structure
|
||||||
|
const firstTransformedItem = this.displayFunction(this.data[0]);
|
||||||
|
const headings: string[] = Object.keys(firstTransformedItem);
|
||||||
return html`
|
return html`
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@ -272,32 +496,42 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
}
|
}
|
||||||
})()}
|
})()}
|
||||||
</tr>
|
</tr>
|
||||||
${this.data.map(
|
${this.data.map((itemArg) => {
|
||||||
(itemArg) => html`
|
const transformedItem = this.displayFunction(itemArg);
|
||||||
|
const getTr = (elementArg: HTMLElement): HTMLElement => {
|
||||||
|
if (elementArg.tagName === 'TR') {
|
||||||
|
return elementArg;
|
||||||
|
} else {
|
||||||
|
return getTr(elementArg.parentElement);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return html`
|
||||||
<tr
|
<tr
|
||||||
@click=${() => {
|
@click=${() => {
|
||||||
this.selectedDataRow = itemArg;
|
this.selectedDataRow = itemArg;
|
||||||
}}
|
}}
|
||||||
@dragenter=${async (eventArg: DragEvent) => {
|
@dragenter=${async (eventArg: DragEvent) => {
|
||||||
console.log((eventArg.target as HTMLElement).tagName)
|
|
||||||
console.log('dragenter');
|
|
||||||
eventArg.preventDefault();
|
eventArg.preventDefault();
|
||||||
eventArg.stopPropagation();
|
eventArg.stopPropagation();
|
||||||
(eventArg.target as HTMLElement).parentElement.style.background = '#800000';
|
const realTarget = getTr(eventArg.target as HTMLElement);
|
||||||
|
console.log('dragenter');
|
||||||
|
console.log(realTarget);
|
||||||
|
setTimeout(() => {
|
||||||
|
realTarget.classList.add('hasAttachment');
|
||||||
|
}, 0);
|
||||||
}}
|
}}
|
||||||
@dragleave=${async (eventArg: DragEvent) => {
|
@dragleave=${async (eventArg: DragEvent) => {
|
||||||
console.log((eventArg.target as HTMLElement).tagName)
|
|
||||||
console.log('dragleave');
|
|
||||||
eventArg.preventDefault();
|
eventArg.preventDefault();
|
||||||
eventArg.stopPropagation();
|
eventArg.stopPropagation();
|
||||||
(eventArg.target as HTMLElement).parentElement.style.background = 'none';
|
const realTarget = getTr(eventArg.target as HTMLElement);
|
||||||
|
realTarget.classList.remove('hasAttachment');
|
||||||
}}
|
}}
|
||||||
@dragover=${async (eventArg: DragEvent) => {
|
@dragover=${async (eventArg: DragEvent) => {
|
||||||
eventArg.preventDefault();
|
eventArg.preventDefault();
|
||||||
}}
|
}}
|
||||||
@drop=${async (eventArg: DragEvent) => {
|
@drop=${async (eventArg: DragEvent) => {
|
||||||
eventArg.preventDefault();
|
eventArg.preventDefault();
|
||||||
const newFiles = []
|
const newFiles = [];
|
||||||
for (const file of Array.from(eventArg.dataTransfer.files)) {
|
for (const file of Array.from(eventArg.dataTransfer.files)) {
|
||||||
this.files.push(file);
|
this.files.push(file);
|
||||||
newFiles.push(file);
|
newFiles.push(file);
|
||||||
@ -305,17 +539,52 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
}
|
}
|
||||||
const result: File[] = this.fileWeakMap.get(itemArg as object);
|
const result: File[] = this.fileWeakMap.get(itemArg as object);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
this.fileWeakMap.set(itemArg as object, newFiles)
|
this.fileWeakMap.set(itemArg as object, newFiles);
|
||||||
} else {
|
} else {
|
||||||
result.push(...newFiles);
|
result.push(...newFiles);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@contextmenu=${async (eventArg: MouseEvent) => {
|
||||||
|
DeesContextmenu.openContextMenuWithOptions(
|
||||||
|
eventArg,
|
||||||
|
this.getActionsForType('contextmenu').map((action) => {
|
||||||
|
const menuItem: plugins.tsclass.website.IMenuItem = {
|
||||||
|
name: action.name,
|
||||||
|
iconName: action.iconName as any,
|
||||||
|
action: async () => {
|
||||||
|
await action.actionFunc({
|
||||||
|
item: itemArg,
|
||||||
|
table: this,
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return menuItem;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}}
|
||||||
class="${itemArg === this.selectedDataRow ? 'selected' : ''}"
|
class="${itemArg === this.selectedDataRow ? 'selected' : ''}"
|
||||||
>
|
>
|
||||||
${headings.map(
|
${headings.map(
|
||||||
(headingArg) => html`
|
(headingArg) => html`
|
||||||
<td>
|
<td
|
||||||
<div class="innerCellContainer">${itemArg[headingArg]}</div>
|
@dblclick=${(e: Event) => {
|
||||||
|
if (this.editableFields.includes(headingArg)) {
|
||||||
|
this.handleCellEditing(e, itemArg, headingArg);
|
||||||
|
} else {
|
||||||
|
const wantedAction = this.dataActions.find((actionArg) =>
|
||||||
|
actionArg.type.includes('doubleClick')
|
||||||
|
);
|
||||||
|
if (wantedAction) {
|
||||||
|
wantedAction.actionFunc({
|
||||||
|
item: itemArg,
|
||||||
|
table: this,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="innerCellContainer">${transformedItem[headingArg]}</div>
|
||||||
</td>
|
</td>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
@ -324,36 +593,192 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
return html`
|
return html`
|
||||||
<td>
|
<td>
|
||||||
<div class="innerCellContainer">
|
<div class="innerCellContainer">
|
||||||
${(() => {
|
<div class="actionsContainer">
|
||||||
const actions: TemplateResult[] = [];
|
${this.getActionsForType('inRow').map(
|
||||||
for (const action of this.dataActions) {
|
(actionArg) => html`
|
||||||
actions.push(html`<div class="action">${action.iconName ? html`
|
<div
|
||||||
<dees-icon .iconName=${'upload_file'}></dees-icon>
|
class="action"
|
||||||
` : action.name}</div>`)
|
@click=${() =>
|
||||||
}
|
actionArg.actionFunc({
|
||||||
return actions;
|
item: itemArg,
|
||||||
})()}
|
table: this,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
${actionArg.iconName
|
||||||
|
? html`
|
||||||
|
<dees-icon
|
||||||
|
.iconFA=${actionArg.iconName}
|
||||||
|
></dees-icon>
|
||||||
|
`
|
||||||
|
: actionArg.name}
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
})()}
|
})()}
|
||||||
</tr>
|
</tr>
|
||||||
`
|
`;
|
||||||
)}
|
})}
|
||||||
</table>
|
</table>
|
||||||
`;
|
`;
|
||||||
})()
|
})()
|
||||||
: html` <div class="noDataSet">No data set!</div> `}
|
: html` <div class="noDataSet">No data set!</div> `}
|
||||||
<div class="tableStatistics">
|
<div class="footer">
|
||||||
${this.data.length} data rows (total) |
|
<div class="tableStatistics">
|
||||||
${this.selectedDataRow
|
${this.data.length} ${this.dataName || 'data rows'} (total) |
|
||||||
? html`Row ${this.data.indexOf(this.selectedDataRow) + 1} selected`
|
${this.selectedDataRow ? '# ' + `${this.data.indexOf(this.selectedDataRow) + 1}` : `No`}
|
||||||
: html`No row selected`}
|
selected
|
||||||
|
</div>
|
||||||
|
<div class="footerActions">
|
||||||
|
${resolveExec(async () => {
|
||||||
|
const resultArray: TemplateResult[] = [];
|
||||||
|
for (const action of this.dataActions) {
|
||||||
|
if (!action.type.includes('footer')) continue;
|
||||||
|
resultArray.push(
|
||||||
|
html`<div
|
||||||
|
class="footerAction"
|
||||||
|
@click=${() => {
|
||||||
|
action.actionFunc({
|
||||||
|
item: this.selectedDataRow,
|
||||||
|
table: this,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
${action.iconName
|
||||||
|
? html`<dees-icon .iconSize=${14} .iconFA=${action.iconName}></dees-icon>
|
||||||
|
${action.name}`
|
||||||
|
: action.name}
|
||||||
|
</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return resultArray;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async firstUpdated() {}
|
public async firstUpdated() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void> {
|
||||||
|
super.updated(changedProperties);
|
||||||
|
this.determineColumnWidths();
|
||||||
|
if (this.searchable) {
|
||||||
|
const existing = this.dataActions.find((actionArg) => actionArg.type.includes('header') && actionArg.name === 'Search');
|
||||||
|
if (!existing) {
|
||||||
|
this.dataActions.unshift({
|
||||||
|
name: 'Search',
|
||||||
|
iconName: 'magnifyingGlass',
|
||||||
|
type: ['header'],
|
||||||
|
actionFunc: async () => {
|
||||||
|
console.log('open search');
|
||||||
|
const searchGrid = this.shadowRoot.querySelector('.searchGrid');
|
||||||
|
searchGrid.classList.toggle('hidden');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(this.dataActions);
|
||||||
|
this.requestUpdate();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async determineColumnWidths() {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
await domtools.convenience.smartdelay.delayFor(0);
|
||||||
|
// Get the table element
|
||||||
|
const table = this.shadowRoot.querySelector('table');
|
||||||
|
if (!table) return;
|
||||||
|
|
||||||
|
// Get the first row's cells to measure the widths
|
||||||
|
const cells = table.rows[0].cells;
|
||||||
|
|
||||||
|
const handleColumnByIndex = async (i: number, waitForRenderArg: boolean = false) => {
|
||||||
|
const done = plugins.smartpromise.defer();
|
||||||
|
const cell = cells[i];
|
||||||
|
|
||||||
|
// Get computed width
|
||||||
|
const width = window.getComputedStyle(cell).width;
|
||||||
|
if (cell.textContent.includes('Actions')) {
|
||||||
|
const neededWidth =
|
||||||
|
this.dataActions.filter((actionArg) => actionArg.type.includes('inRow')).length * 36;
|
||||||
|
cell.style.width = `${Math.max(neededWidth, 68)}px`;
|
||||||
|
} else {
|
||||||
|
cell.style.width = width;
|
||||||
|
}
|
||||||
|
if (waitForRenderArg) {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
await done.promise;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (cells[cells.length - 1].textContent.includes('Actions')) {
|
||||||
|
await handleColumnByIndex(cells.length - 1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < cells.length; i++) {
|
||||||
|
if (cells[i].textContent.includes('Actions')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
await handleColumnByIndex(i);
|
||||||
|
}
|
||||||
|
table.style.tableLayout = 'fixed';
|
||||||
|
}
|
||||||
|
|
||||||
|
getActionsForType(typeArg: ITableAction['type'][0]) {
|
||||||
|
const actions: ITableAction[] = [];
|
||||||
|
for (const action of this.dataActions) {
|
||||||
|
if (!action.type.includes(typeArg)) continue;
|
||||||
|
actions.push(action);
|
||||||
|
}
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleCellEditing(event: Event, itemArg: T, key: string) {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
const target = event.target as HTMLElement;
|
||||||
|
const originalColor = target.style.color;
|
||||||
|
target.style.color = 'transparent';
|
||||||
|
const transformedItem = this.displayFunction(itemArg);
|
||||||
|
const initialValue = (transformedItem[key] as unknown as string) || '';
|
||||||
|
// Create an input element
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.type = 'text';
|
||||||
|
input.value = initialValue;
|
||||||
|
|
||||||
|
const blurInput = async (blurArg = true, saveArg = false) => {
|
||||||
|
if (blurArg) {
|
||||||
|
input.blur();
|
||||||
|
}
|
||||||
|
if (saveArg) {
|
||||||
|
itemArg[key] = input.value as any; // Convert string to T (you might need better type casting depending on your data structure)
|
||||||
|
this.changeSubject.next(this);
|
||||||
|
}
|
||||||
|
input.remove();
|
||||||
|
target.style.color = originalColor;
|
||||||
|
this.requestUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
|
// When the input loses focus or the Enter key is pressed, update the data
|
||||||
|
input.addEventListener('blur', () => {
|
||||||
|
blurInput(false, false);
|
||||||
|
});
|
||||||
|
input.addEventListener('keydown', (e: KeyboardEvent) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
blurInput(true, true); // This will trigger the blur event handler above
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Replace the cell's content with the input
|
||||||
|
target.appendChild(input);
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
274
ts_web/elements/dees-terminal.ts
Normal file
274
ts_web/elements/dees-terminal.ts
Normal file
@ -0,0 +1,274 @@
|
|||||||
|
import {
|
||||||
|
DeesElement,
|
||||||
|
property,
|
||||||
|
html,
|
||||||
|
customElement,
|
||||||
|
type TemplateResult,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
|
import * as webcontainer from '@webcontainer/api';
|
||||||
|
|
||||||
|
import { Terminal } from 'xterm';
|
||||||
|
import { FitAddon } from 'xterm-addon-fit';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-terminal': DeesTerminal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-terminal')
|
||||||
|
export class DeesTerminal extends DeesElement {
|
||||||
|
public static demo = () => html` <dees-terminal></dees-terminal> `;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
domtools.DomTools.setupDomTools();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
domtools.elementBasic.staticStyles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
padding: 20px;
|
||||||
|
background: #000;
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container {
|
||||||
|
position: absolute;
|
||||||
|
height: calc(100% - 40px);
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
|
||||||
|
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
||||||
|
* https://github.com/chjj/term.js
|
||||||
|
* @license MIT
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Originally forked from (with the author's permission):
|
||||||
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
||||||
|
* http://bellard.org/jslinux/
|
||||||
|
* Copyright (c) 2011 Fabrice Bellard
|
||||||
|
* The original design remains. The terminal itself
|
||||||
|
* has been extended to include xterm CSI codes, among
|
||||||
|
* other features.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default styles for xterm.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
.xterm {
|
||||||
|
font-feature-settings: 'liga' 0;
|
||||||
|
position: relative;
|
||||||
|
user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.focus,
|
||||||
|
.xterm:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-helpers {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
/**
|
||||||
|
* The z-index of the helpers must be higher than the canvases in order for
|
||||||
|
* IMEs to appear on top.
|
||||||
|
*/
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-helper-textarea {
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
margin: 0;
|
||||||
|
/* Move textarea out of the screen to the far left, so that the cursor is not visible */
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
left: -9999em;
|
||||||
|
top: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
z-index: -5;
|
||||||
|
/** Prevent wrapping so the IME appears against the textarea at the correct position */
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .composition-view {
|
||||||
|
/* TODO: Composition position got messed up somewhere */
|
||||||
|
background: #000;
|
||||||
|
color: #fff;
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
white-space: nowrap;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .composition-view.active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-viewport {
|
||||||
|
/* On OS X this is required in order for the scroll bar to appear fully opaque */
|
||||||
|
background-color: #000;
|
||||||
|
overflow-y: scroll;
|
||||||
|
cursor: default;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-screen {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-screen canvas {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-scroll-area {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-char-measure-element {
|
||||||
|
display: inline-block;
|
||||||
|
visibility: hidden;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: -9999em;
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm {
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.enable-mouse-events {
|
||||||
|
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.xterm-cursor-pointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.column-select.focus {
|
||||||
|
/* Column selection mode */
|
||||||
|
cursor: crosshair;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-accessibility,
|
||||||
|
.xterm .xterm-message {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 10;
|
||||||
|
color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .live-region {
|
||||||
|
position: absolute;
|
||||||
|
left: -9999px;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-dim {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-underline {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<div class="mainbox">
|
||||||
|
<div id="container"></div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async firstUpdated(
|
||||||
|
_changedProperties: Map<string | number | symbol, unknown>
|
||||||
|
): Promise<void> {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
super.firstUpdated(_changedProperties);
|
||||||
|
const container = this.shadowRoot.getElementById('container');
|
||||||
|
|
||||||
|
const term = new Terminal({
|
||||||
|
convertEol: true,
|
||||||
|
cursorBlink: true,
|
||||||
|
});
|
||||||
|
const fitAddon = new FitAddon();
|
||||||
|
term.loadAddon(fitAddon);
|
||||||
|
|
||||||
|
// Open the terminal in #terminal-container
|
||||||
|
term.open(container);
|
||||||
|
|
||||||
|
// Make the terminal's size and geometry fit the size of #terminal-container
|
||||||
|
fitAddon.fit();
|
||||||
|
|
||||||
|
term.write(`dees-terminal custom terminal. \r\n$ `);
|
||||||
|
|
||||||
|
// lets start the webcontainer
|
||||||
|
// Call only once
|
||||||
|
const webcontainerInstance = await webcontainer.WebContainer.boot();
|
||||||
|
const shellProcess = await webcontainerInstance.spawn('jsh');
|
||||||
|
shellProcess.output.pipeTo(
|
||||||
|
new WritableStream({
|
||||||
|
write(data) {
|
||||||
|
term.write(data);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
const input = shellProcess.input.getWriter();
|
||||||
|
term.onData((data) => {
|
||||||
|
input.write(data);
|
||||||
|
});
|
||||||
|
await domtools.convenience.smartdelay.delayFor(5000);
|
||||||
|
input.write(`pnpm add isomorphic-git @git.zone/tsbuild\n`);
|
||||||
|
}
|
||||||
|
}
|
5
ts_web/elements/dees-toast.demo.ts
Normal file
5
ts_web/elements/dees-toast.demo.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export const demoFunc = async () => {
|
||||||
|
return html`<dees-toast></dees-toast>`;
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import { customElement, DeesElement, TemplateResult, html } from '@designestate/dees-element';
|
import { customElement, DeesElement, type TemplateResult, html, type CSSResult, } from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
import { demoFunc } from './dees-toast.demo.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -10,6 +11,7 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-toast')
|
@customElement('dees-toast')
|
||||||
export class DeesToast extends DeesElement {
|
export class DeesToast extends DeesElement {
|
||||||
|
public static demo = demoFunc;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -1 +1 @@
|
|||||||
import {} from '@designestate/dees-element';
|
import {} from '@design.estate/dees-element';
|
10
ts_web/elements/dees-updater.demo.ts
Normal file
10
ts_web/elements/dees-updater.demo.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
import { DeesUpdater } from './dees-updater.js';
|
||||||
|
|
||||||
|
export const demoFunc = async () => {
|
||||||
|
const updater = await DeesUpdater.createAndShow();
|
||||||
|
setTimeout(async () => {
|
||||||
|
await updater.destroy();
|
||||||
|
}, 10000);
|
||||||
|
}
|
@ -1,10 +1,16 @@
|
|||||||
import { customElement, DeesElement, TemplateResult, html, property } from '@designestate/dees-element';
|
import {
|
||||||
|
customElement,
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
DeesElement,
|
||||||
|
type TemplateResult,
|
||||||
|
html,
|
||||||
|
property,
|
||||||
|
type CSSResult,
|
||||||
|
domtools,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
import { demoFunc } from './dees-updater.demo.js';
|
||||||
|
|
||||||
import './dees-windowlayer';
|
import './dees-windowlayer';
|
||||||
import { css, cssManager } from '@designestate/dees-element';
|
import { css, cssManager } from '@design.estate/dees-element';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -14,7 +20,13 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-updater')
|
@customElement('dees-updater')
|
||||||
export class DeesUpdater extends DeesElement {
|
export class DeesUpdater extends DeesElement {
|
||||||
public static demo = () => html`<dees-updater></dees-updater>`;
|
public static demo = demoFunc;
|
||||||
|
|
||||||
|
public static async createAndShow() {
|
||||||
|
const updater = new DeesUpdater();
|
||||||
|
document.body.appendChild(updater);
|
||||||
|
return updater;
|
||||||
|
}
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
@ -35,56 +47,64 @@ export class DeesUpdater extends DeesElement {
|
|||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
.modalContainer {
|
.modalContainer {
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
position: relative;
|
position: relative;
|
||||||
background: ${cssManager.bdTheme('#eeeeeb', '#222')};
|
background: ${cssManager.bdTheme('#eeeeeb', '#222')};
|
||||||
margin: auto;
|
max-width: 800px;
|
||||||
max-width: 800px;
|
border-radius: 8px;
|
||||||
border-radius: 3px;
|
border-top: 1px solid ${cssManager.bdTheme('#eeeeeb', '#333')};
|
||||||
border-top: 1px solid ${cssManager.bdTheme('#eeeeeb', '#333')};
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.headingContainer {
|
.headingContainer {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 40px 40px;
|
padding: 40px 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin: none;
|
margin: none;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttonContainer {
|
.buttonContainer {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 50% 50%;
|
grid-template-columns: 50% 50%;
|
||||||
}
|
}
|
||||||
`
|
`,
|
||||||
]
|
];
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<dees-windowlayer @clicked="${this.windowLayerClicked}">
|
<dees-windowlayer
|
||||||
|
@clicked="${this.windowLayerClicked}"
|
||||||
|
.options=${{
|
||||||
|
blur: true,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<div class="modalContainer">
|
<div class="modalContainer">
|
||||||
<div class="headingContainer">
|
<div class="headingContainer">
|
||||||
<dees-spinner .size=${60}></dees-spinner>
|
<dees-spinner .size=${60}></dees-spinner>
|
||||||
<h1>Updating the application...</h1>
|
<h1>Updating the application...</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="progress">
|
||||||
|
<dees-progressbar .progress=${0.5}></dees-progressbar>
|
||||||
|
</div>
|
||||||
<div class="buttonContainer">
|
<div class="buttonContainer">
|
||||||
<dees-button>More info</dees-button>
|
<dees-button>More info</dees-button>
|
||||||
<dees-button>Changelog</dees-button>
|
<dees-button>Changelog</dees-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> </dees-windowlayer
|
||||||
</dees-windowlayer>>
|
>>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private windowLayerClicked() {
|
public async destroy() {
|
||||||
const windowLayer = this.shadowRoot.querySelector('dees-windowlayer');
|
this.parentElement.removeChild(this);
|
||||||
windowLayer.toggleVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private windowLayerClicked() {}
|
||||||
}
|
}
|
||||||
|
99
ts_web/elements/dees-windowcontrols.ts
Normal file
99
ts_web/elements/dees-windowcontrols.ts
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
import {
|
||||||
|
customElement,
|
||||||
|
DeesElement,
|
||||||
|
domtools,
|
||||||
|
type TemplateResult,
|
||||||
|
html,
|
||||||
|
property,
|
||||||
|
type CSSResult,
|
||||||
|
state,
|
||||||
|
css,
|
||||||
|
cssManager,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'dees-windowcontrols': DeesWindowControls;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@customElement('dees-windowcontrols')
|
||||||
|
export class DeesWindowControls extends DeesElement {
|
||||||
|
// STATIC
|
||||||
|
public static demo = () => html`<dees-windowcontrols></dees-windowcontrols>`;
|
||||||
|
|
||||||
|
// Instance
|
||||||
|
@property({
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
|
public type: 'mac' | 'linux' | 'windows' = 'mac';
|
||||||
|
|
||||||
|
@property({
|
||||||
|
reflect: true,
|
||||||
|
})
|
||||||
|
public position: 'left' | 'right' = 'left';
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding-left: 16px;
|
||||||
|
padding-right: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.windowControls {
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.windowControls div {
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
background: #222222;
|
||||||
|
}
|
||||||
|
|
||||||
|
.windowControls div.close {
|
||||||
|
background: #ff5f57;
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.windowControls div.toDock {
|
||||||
|
background: #ffbd2e;
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.windowControls div.minMax {
|
||||||
|
background: #27c93f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.windowControls div:hover {
|
||||||
|
background: #333333;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
${(this.type === 'mac' && this.position === 'left') ||
|
||||||
|
((this.type === 'linux' || this.type === 'windows') && this.position === 'right')
|
||||||
|
? html`
|
||||||
|
<div class="windowControls">
|
||||||
|
<div class="close"></div>
|
||||||
|
<div class="toDock"></div>
|
||||||
|
<div class="minMax"></div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: html``}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,4 @@
|
|||||||
import { customElement, DeesElement, TemplateResult, html, property } from '@designestate/dees-element';
|
import { customElement, DeesElement, domtools, type TemplateResult, html, property, type CSSResult, state, } from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@designestate/dees-domtools';
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -8,11 +6,33 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IOptions_DeesWindowLayer {
|
||||||
|
blur: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
@customElement('dees-windowlayer')
|
@customElement('dees-windowlayer')
|
||||||
export class DeesWindowLayer extends DeesElement {
|
export class DeesWindowLayer extends DeesElement {
|
||||||
// STATIC
|
// STATIC
|
||||||
public static demo = () => html`<dees-windowlayer></dees-windowlayer>`;
|
public static demo = () => html`<dees-windowlayer></dees-windowlayer>`;
|
||||||
|
|
||||||
|
public static async createAndShow(optionsArg?: IOptions_DeesWindowLayer) {
|
||||||
|
const domtoolsInstance = domtools.DomTools.getGlobalDomToolsSync();
|
||||||
|
const windowLayer = new DeesWindowLayer();
|
||||||
|
windowLayer.options = {
|
||||||
|
...windowLayer.options,
|
||||||
|
...optionsArg,
|
||||||
|
}
|
||||||
|
document.body.append(windowLayer);
|
||||||
|
await domtoolsInstance.convenience.smartdelay.delayFor(0);
|
||||||
|
windowLayer.show();
|
||||||
|
return windowLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@state()
|
||||||
|
public options: IOptions_DeesWindowLayer = {
|
||||||
|
blur: false
|
||||||
|
};
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
@property({
|
@property({
|
||||||
type: Boolean
|
type: Boolean
|
||||||
@ -29,7 +49,7 @@ export class DeesWindowLayer extends DeesElement {
|
|||||||
${domtools.elementBasic.styles}
|
${domtools.elementBasic.styles}
|
||||||
<style>
|
<style>
|
||||||
.windowOverlay {
|
.windowOverlay {
|
||||||
transition: all 0.3s;
|
transition: all 0.2s;
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
@ -40,18 +60,29 @@ export class DeesWindowLayer extends DeesElement {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: rgba(0, 0, 0, 0.0);
|
background: rgba(0, 0, 0, 0.0);
|
||||||
backdrop-filter: brightness(1);
|
backdrop-filter: brightness(1) ${this.options.blur ? 'blur(0px)' : ''};
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: 200;
|
z-index: 200;
|
||||||
}
|
}
|
||||||
|
.slotContent {
|
||||||
|
position: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 201;
|
||||||
|
}
|
||||||
|
|
||||||
.visible {
|
.visible {
|
||||||
background: rgba(0, 0, 0, 0.2);
|
background: rgba(0, 0, 0, 0.2);
|
||||||
backdrop-filter: brightness(0.3);
|
backdrop-filter: brightness(0.9) ${this.options.blur ? 'blur(2px)' : ''};
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div @click=${this.dispatchClicked} class="windowOverlay ${this.visible ? 'visible' : null}">
|
<div class="windowOverlay ${this.visible ? 'visible' : null}">
|
||||||
|
</div>
|
||||||
|
<div @click=${this.dispatchClicked} class="slotContent">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -82,4 +113,11 @@ export class DeesWindowLayer extends DeesElement {
|
|||||||
await domtools.convenience.smartdelay.delayFor(0);
|
await domtools.convenience.smartdelay.delayFor(0);
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async destroy() {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
await this.hide();
|
||||||
|
await domtools.convenience.smartdelay.delayFor(300);
|
||||||
|
this.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
3
ts_web/elements/helperclasses/formcontroller.ts
Normal file
3
ts_web/elements/helperclasses/formcontroller.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export class FormController {
|
||||||
|
|
||||||
|
}
|
@ -2,21 +2,38 @@ export * from './dees-button-exit.js';
|
|||||||
export * from './dees-button.js';
|
export * from './dees-button.js';
|
||||||
export * from './dees-chips.js';
|
export * from './dees-chips.js';
|
||||||
export * from './dees-contextmenu.js';
|
export * from './dees-contextmenu.js';
|
||||||
export * from './dees-form.js';
|
export * from './dees-dataview-codebox.js';
|
||||||
|
export * from './dees-dataview-statusobject.js';
|
||||||
|
export * from './dees-editor.js';
|
||||||
|
export * from './dees-editor-markdown.js';
|
||||||
|
export * from './dees-editor-markdownoutlet.js';
|
||||||
export * from './dees-form-submit.js';
|
export * from './dees-form-submit.js';
|
||||||
|
export * from './dees-form.js';
|
||||||
|
export * from './dees-hint.js';
|
||||||
export * from './dees-icon.js';
|
export * from './dees-icon.js';
|
||||||
export * from './dees-input-checkbox.js';
|
export * from './dees-input-checkbox.js';
|
||||||
export * from './dees-input-dropdown.js';
|
export * from './dees-input-dropdown.js';
|
||||||
export * from './dees-input-fileupload.js';
|
export * from './dees-input-fileupload.js';
|
||||||
|
export * from './dees-input-iban.js';
|
||||||
|
export * from './dees-input-typelist.js';
|
||||||
|
export * from './dees-input-phone.js';
|
||||||
|
export * from './dees-progressbar.js';
|
||||||
export * from './dees-input-quantityselector.js';
|
export * from './dees-input-quantityselector.js';
|
||||||
export * from './dees-input-radio.js';
|
export * from './dees-input-radio.js';
|
||||||
export * from './dees-input-text.js';
|
export * from './dees-input-text.js';
|
||||||
|
export * from './dees-label.js';
|
||||||
export * from './dees-mobilenavigation.js';
|
export * from './dees-mobilenavigation.js';
|
||||||
|
export * from './dees-modal.js';
|
||||||
|
export * from './dees-input-multitoggle.js';
|
||||||
export * from './dees-pdf.js';
|
export * from './dees-pdf.js';
|
||||||
|
export * from './dees-simple-appdash.js';
|
||||||
|
export * from './dees-simple-login.js';
|
||||||
export * from './dees-speechbubble.js';
|
export * from './dees-speechbubble.js';
|
||||||
export * from './dees-spinner.js';
|
export * from './dees-spinner.js';
|
||||||
export * from './dees-stepper.js';
|
export * from './dees-stepper.js';
|
||||||
export * from './dees-table.js';
|
export * from './dees-table.js';
|
||||||
|
export * from './dees-terminal.js';
|
||||||
export * from './dees-toast.js';
|
export * from './dees-toast.js';
|
||||||
export * from './dees-updater.js';
|
export * from './dees-updater.js';
|
||||||
|
export * from './dees-windowcontrols.js';
|
||||||
export * from './dees-windowlayer.js';
|
export * from './dees-windowlayer.js';
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import * as tsclass from '@tsclass/tsclass';
|
|
||||||
|
|
||||||
export {
|
|
||||||
tsclass
|
|
||||||
}
|
|
@ -3,8 +3,12 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"useDefineForClassFields": false,
|
"useDefineForClassFields": false,
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ES2022",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "NodeNext",
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true,
|
||||||
}
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user