@blockquote-web-components/blockquote-base-embedded-webview 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +158 -0
- package/define/blockquote-base-embedded-webview-element.js +6 -0
- package/define/blockquote-base-embedded-webview-resize.js +6 -0
- package/define/blockquote-base-embedded-webview-size.js +6 -0
- package/define/blockquote-base-embedded-webview.js +3 -0
- package/index.js +4 -0
- package/package.json +140 -0
- package/src/BlockquoteBaseEmbeddedWebview.js +247 -0
- package/src/BlockquoteBaseEmbeddedWebviewElement.js +142 -0
- package/src/BlockquoteBaseEmbeddedWebviewResize.js +165 -0
- package/src/BlockquoteBaseEmbeddedWebviewSize.js +207 -0
- package/src/styles/BlockquoteBaseEmbeddedWebview-styles.js +104 -0
- package/src/styles/BlockquoteBaseEmbeddedWebviewElement-styles.js +22 -0
- package/src/styles/BlockquoteBaseEmbeddedWebviewResize-styles.js +122 -0
- package/src/styles/BlockquoteBaseEmbeddedWebviewSize-styles.js +101 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 blockquote-base-embedded-webview
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# blockquote-base-embedded-webview
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
`blockquote-base-embedded-webview` offers a responsive display using individual HTML files as content with the different use cases to be displayed.
|
|
6
|
+
It will create a `select` tag with the provided demo HTML files and add the `[data-embedded]` attribute to the loaded body tag.
|
|
7
|
+
|
|
8
|
+
## Basic usage
|
|
9
|
+
|
|
10
|
+
```html
|
|
11
|
+
<blockquote-base-embedded-webview heading="My demo title">
|
|
12
|
+
<template data-src="./basic.html" data-option="Basis"></template>
|
|
13
|
+
<template data-src="./complex.html" data-option="Complex"></template>
|
|
14
|
+
</blockquote-base-embedded-webview>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## basic.html
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<!DOCTYPE html>
|
|
21
|
+
<html lang="en">
|
|
22
|
+
<head>
|
|
23
|
+
<title>Demo Basic</title>
|
|
24
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
25
|
+
<meta charset="utf-8" />
|
|
26
|
+
<style>
|
|
27
|
+
:root {
|
|
28
|
+
font: normal medium/1.25 sans-serif;
|
|
29
|
+
}
|
|
30
|
+
body {
|
|
31
|
+
margin: 0;
|
|
32
|
+
}
|
|
33
|
+
[data-embedded] .hidden {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
37
|
+
</head>
|
|
38
|
+
<body>
|
|
39
|
+
<h1 class="hidden">Heading</h1>
|
|
40
|
+
<p>Basic Demo</p>
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Exports
|
|
46
|
+
|
|
47
|
+
- BlockquoteBaseEmbeddedWebview
|
|
48
|
+
|
|
49
|
+
## Properties
|
|
50
|
+
|
|
51
|
+
| Property | Attribute | Type | Default | Description |
|
|
52
|
+
| -------------------- | ---------------------- | --------- | ------- | --------------------------------------- |
|
|
53
|
+
| `heading` | `heading` | `String` | "" | The heading of the webview. |
|
|
54
|
+
| `headingLevel` | `heading-level` | `Number` | 1 | Heading level from 1 to 6 |
|
|
55
|
+
| `limitHeight` | `limit-height` | `Boolean` | false | Limit height to 100% available |
|
|
56
|
+
| `screenSizeSelected` | `screen-size-selected` | `Number` | 0 | Index of currently screen size selected |
|
|
57
|
+
| `selected` | `selected` | `Number` | 0 | Index of currently srcset file |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
# blockquote-base-embedded-webview-element
|
|
62
|
+
|
|
63
|
+

|
|
64
|
+
|
|
65
|
+
`blockquote-base-embedded-webview-element` wraps an `iframe` or `object` and shows it through light dom.
|
|
66
|
+
|
|
67
|
+
## Exports
|
|
68
|
+
|
|
69
|
+
- BlockquoteBaseEmbeddedWebviewElement
|
|
70
|
+
|
|
71
|
+
## Properties
|
|
72
|
+
|
|
73
|
+
| Property | Attribute | Type | Default | Description |
|
|
74
|
+
| --------------- | ---------------- | -------- | -------- | -------------------------------------------------------- |
|
|
75
|
+
| `embeddedTitle` | `embedded-title` | `string` | "" | The title attribute on an <element> to label its content |
|
|
76
|
+
| `src` | `src` | `string` | "" | The URL of the page to embed |
|
|
77
|
+
| `type` | `type` | `string` | "iframe" | The type of the tag to embed - iframe or object |
|
|
78
|
+
|
|
79
|
+
## Methods
|
|
80
|
+
|
|
81
|
+
| Method | Type |
|
|
82
|
+
| ------------ | -------------------- |
|
|
83
|
+
| `willUpdate` | `(props: any): void` |
|
|
84
|
+
|
|
85
|
+
## Events
|
|
86
|
+
|
|
87
|
+
| Event | Type |
|
|
88
|
+
| --------------- | ------------------ |
|
|
89
|
+
| `elementloaded` | `CustomEvent<any>` |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
# blockquote-base-embedded-webview-resize
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
|
|
97
|
+
`blockquote-base-embedded-webview-resize`
|
|
98
|
+
|
|
99
|
+
## Exports
|
|
100
|
+
|
|
101
|
+
- BlockquoteBaseEmbeddedWebviewResize
|
|
102
|
+
|
|
103
|
+
## Events
|
|
104
|
+
|
|
105
|
+
| Event | Type |
|
|
106
|
+
| --------------- | ----------------------------------------------------------- |
|
|
107
|
+
| `webviewresize` | `CustomEvent<{ x: string; y: string; resizing: boolean; }>` |
|
|
108
|
+
|
|
109
|
+
# blockquote-base-embedded-webview-size
|
|
110
|
+
|
|
111
|
+

|
|
112
|
+
|
|
113
|
+
`blockquote-base-embedded-webview-size` provides a list of ideal screen sizes for responsive designs.
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<blockquote-base-embedded-webview-size
|
|
117
|
+
screen-sizes="[
|
|
118
|
+
{ width: 360, height: 640, id: '360x640' },
|
|
119
|
+
{ width: 375, height: 667, id: '375x667' },
|
|
120
|
+
{ width: 414, height: 896, id: '414x896' },
|
|
121
|
+
{ width: 768, height: 1024, id: '768x1024' },
|
|
122
|
+
{ width: 1024, height: 768, id: '1024x768' },
|
|
123
|
+
{ width: 1280, height: 800, id: '1280x800' },
|
|
124
|
+
{ width: 1366, height: 768, id: '1366x768' },
|
|
125
|
+
{ width: 1536, height: 864, id: '1536x864' },
|
|
126
|
+
{ width: 1920, height: 1080, id: '1920x1080' },
|
|
127
|
+
]"
|
|
128
|
+
></blockquote-base-embedded-webview-size>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Exports
|
|
132
|
+
|
|
133
|
+
- BlockquoteBaseEmbeddedWebviewSize
|
|
134
|
+
|
|
135
|
+
## Properties
|
|
136
|
+
|
|
137
|
+
| Property | Attribute | Modifiers | Type | Default | Description |
|
|
138
|
+
| -------------------- | -------------------- | --------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
139
|
+
| `computedStyleWidth` | | readonly | `number` | | |
|
|
140
|
+
| `screenSizes` | `screen-sizes` | | `Array` | [{"width":360,"height":640,"id":"360x640"},{"width":375,"height":667,"id":"375x667"},{"width":414,"height":896,"id":"414x896"},{"width":768,"height":1024,"id":"768x1024"},{"width":1024,"height":768,"id":"1024x768"},{"width":1280,"height":800,"id":"1280x800"},{"width":1366,"height":768,"id":"1366x768"},{"width":1536,"height":864,"id":"1536x864"},{"width":1920,"height":1080,"id":"1920x1080"}] | The screen size options to display |
|
|
141
|
+
| `selected` | `selected` | | `Number` | 0 | The screen size option selected |
|
|
142
|
+
| `selectedDetail` | | readonly | `{ index: number; width: number; height: number; id: string; }` | | |
|
|
143
|
+
| `selectedSize` | | readonly | `{ width: number; height: number; id: string; }` | | |
|
|
144
|
+
| `showOverflowSize` | `show-overflow-size` | | `Boolean` | false | Show screen size options that are too large for the container |
|
|
145
|
+
| `widthInPercent` | `width-in-percent` | | `Boolean` | false | Percentage value for the width |
|
|
146
|
+
|
|
147
|
+
## Methods
|
|
148
|
+
|
|
149
|
+
| Method | Type |
|
|
150
|
+
| ------------ | -------------------- |
|
|
151
|
+
| `willUpdate` | `(props: any): void` |
|
|
152
|
+
|
|
153
|
+
## Events
|
|
154
|
+
|
|
155
|
+
| Event | Type |
|
|
156
|
+
| ---------------- | ---------------------------------------------------------------------------- |
|
|
157
|
+
| `click` | `CustomEvent<{ index: number; width: number; height: number; id: string; }>` |
|
|
158
|
+
| `selectedchange` | `CustomEvent<{ index: number; width: number; height: number; id: string; }>` |
|
package/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { BlockquoteBaseEmbeddedWebview } from './src/BlockquoteBaseEmbeddedWebview.js';
|
|
2
|
+
export { BlockquoteBaseEmbeddedWebviewSize } from './src/BlockquoteBaseEmbeddedWebviewSize.js';
|
|
3
|
+
export { BlockquoteBaseEmbeddedWebviewResize } from './src/BlockquoteBaseEmbeddedWebviewResize.js';
|
|
4
|
+
export { BlockquoteBaseEmbeddedWebviewElement } from './src/BlockquoteBaseEmbeddedWebviewElement.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blockquote-web-components/blockquote-base-embedded-webview",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Webcomponent blockquote-base-embedded-webview following open-wc recommendations",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lit",
|
|
7
|
+
"web-component",
|
|
8
|
+
"lit-element"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "blockquote-base-embedded-webview",
|
|
12
|
+
"main": "index.js",
|
|
13
|
+
"module": "index.js",
|
|
14
|
+
"files": [
|
|
15
|
+
"/define/",
|
|
16
|
+
"/src/",
|
|
17
|
+
"index.js",
|
|
18
|
+
"!/**/*.scss"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"analyze": "cem analyze --litelement --globs \"{src,define}/**/*.{js,ts}\" \"index.js\"",
|
|
22
|
+
"analyze:doc": "npm run analyze && npx web-component-analyzer \"{src,define}/**/*.{js,ts}\" \"index.js\" --outFile README.md",
|
|
23
|
+
"build": "echo \"This is not a TypeScript project, so no need to build.\"",
|
|
24
|
+
"dev:vite": "vite build",
|
|
25
|
+
"format": "npm run format:eslint && npm run format:prettier && npm run format:stylelint",
|
|
26
|
+
"format:eslint": "eslint \"**/*.{js,ts,html}\" --fix --ignore-path .eslintignore",
|
|
27
|
+
"format:prettier": "prettier \"**/*.{js,ts,json,html,md}\" --write --ignore-path .eslintignore",
|
|
28
|
+
"format:stylelint": "stylelint \"**/*.{scss,css}\" --fix --allow-empty-input --ignore-path .eslintignore",
|
|
29
|
+
"postinstall": "npm run sort:package",
|
|
30
|
+
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:stylelint",
|
|
31
|
+
"lint:eslint": "eslint \"**/*.{js,ts,html}\" --ignore-path .eslintignore",
|
|
32
|
+
"lint:prettier": "prettier \"**/*.{js,ts,json,html,md}\" --check --ignore-path .eslintignore",
|
|
33
|
+
"lint:stylelint": "stylelint \"**/*.{scss,css}\" --allow-empty-input --ignore-path .eslintignore",
|
|
34
|
+
"preview:vite": "vite preview",
|
|
35
|
+
"sass:watch": "sass-style-template",
|
|
36
|
+
"sort:package": "npx sort-package-json",
|
|
37
|
+
"start": "concurrently -k -r \"npm:sass:watch\" \"npm:vite\"",
|
|
38
|
+
"start:wds": "concurrently -k -r \"npm:sass:watch\" \"npm:wds\"",
|
|
39
|
+
"test": "wtr --coverage",
|
|
40
|
+
"test:watch": "wtr --watch",
|
|
41
|
+
"vite": "vite",
|
|
42
|
+
"wds": "web-dev-server"
|
|
43
|
+
},
|
|
44
|
+
"husky": {
|
|
45
|
+
"hooks": {
|
|
46
|
+
"pre-commit": "lint-staged"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"lint-staged": {
|
|
50
|
+
"**/*.{js,ts,html}": [
|
|
51
|
+
"npm run format:eslint"
|
|
52
|
+
],
|
|
53
|
+
"**/*.{js,ts,json,html,md}": [
|
|
54
|
+
"npm run format:prettier"
|
|
55
|
+
],
|
|
56
|
+
"**/*.{scss,css}": [
|
|
57
|
+
"npm run format:stylelint"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"prettier": {
|
|
61
|
+
"arrowParens": "avoid",
|
|
62
|
+
"printWidth": 100,
|
|
63
|
+
"singleQuote": true,
|
|
64
|
+
"trailingComma": "all",
|
|
65
|
+
"overrides": [
|
|
66
|
+
{
|
|
67
|
+
"files": "*.{scss,css}",
|
|
68
|
+
"options": {
|
|
69
|
+
"printWidth": 220,
|
|
70
|
+
"singleQuote": false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"eslintConfig": {
|
|
76
|
+
"parserOptions": {
|
|
77
|
+
"ecmaVersion": "latest"
|
|
78
|
+
},
|
|
79
|
+
"plugins": [
|
|
80
|
+
"log-filenames"
|
|
81
|
+
],
|
|
82
|
+
"extends": [
|
|
83
|
+
"@open-wc",
|
|
84
|
+
"prettier"
|
|
85
|
+
],
|
|
86
|
+
"rules": {
|
|
87
|
+
"class-methods-use-this": "off",
|
|
88
|
+
"no-unused-expressions": [
|
|
89
|
+
"error",
|
|
90
|
+
{
|
|
91
|
+
"allowShortCircuit": true,
|
|
92
|
+
"allowTernary": true
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"object-curly-newline": "off",
|
|
96
|
+
"import/extensions": [
|
|
97
|
+
"error",
|
|
98
|
+
"always",
|
|
99
|
+
{
|
|
100
|
+
"ignorePackages": true
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"import/no-extraneous-dependencies": [
|
|
104
|
+
"error",
|
|
105
|
+
{
|
|
106
|
+
"devDependencies": [
|
|
107
|
+
"**/test/**/*.{js,ts}",
|
|
108
|
+
"**/*.config.{js,mjs,cjs}",
|
|
109
|
+
"**/*.conf.{js,mjs,cjs}"
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"import/no-unresolved": "off",
|
|
114
|
+
"import/prefer-default-export": "off"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"stylelint": {
|
|
118
|
+
"extends": "stylelint-config-standard-scss",
|
|
119
|
+
"rules": {
|
|
120
|
+
"custom-property-pattern": null,
|
|
121
|
+
"max-line-length": null,
|
|
122
|
+
"no-duplicate-selectors": null,
|
|
123
|
+
"color-function-notation": null,
|
|
124
|
+
"alpha-value-notation": null
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"dependencies": {
|
|
128
|
+
"@blockquote/polymer": "^3.4.1",
|
|
129
|
+
"lit": "^2.0.2"
|
|
130
|
+
},
|
|
131
|
+
"devDependencies": {
|
|
132
|
+
"@blockquote-web-components/blockquote-base-common-dev-dependencies": "^1.0.0",
|
|
133
|
+
"@blockquote-web-components/blockquote-foundations-sass": "^1.0.0",
|
|
134
|
+
"@polymer/iron-test-helpers": "^3.0.1"
|
|
135
|
+
},
|
|
136
|
+
"publishConfig": {
|
|
137
|
+
"access": "public"
|
|
138
|
+
},
|
|
139
|
+
"customElements": "custom-elements.json"
|
|
140
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { html, LitElement, svg } from 'lit';
|
|
2
|
+
import { ref, createRef } from 'lit/directives/ref.js';
|
|
3
|
+
import '../define/blockquote-base-embedded-webview-size.js';
|
|
4
|
+
import '../define/blockquote-base-embedded-webview-resize.js';
|
|
5
|
+
import '../define/blockquote-base-embedded-webview-element.js';
|
|
6
|
+
import styles from './styles/BlockquoteBaseEmbeddedWebview-styles.js';
|
|
7
|
+
|
|
8
|
+
const chevronDownIcon = svg`<svg aria-hidden="true" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
9
|
+
<polyline points="6 9 12 15 18 9" />
|
|
10
|
+
</svg>`;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
`blockquote-base-embedded-webview` offers a responsive display using individual HTML files as content with the different use cases to be displayed.
|
|
16
|
+
It will create a `select` tag with the provided demo HTML files and add the `[data-embedded]` attribute to the loaded body tag.
|
|
17
|
+
|
|
18
|
+
## Basic usage
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<blockquote-base-embedded-webview heading="My demo title">
|
|
22
|
+
<template data-src="./basic.html" data-option="Basis"></template>
|
|
23
|
+
<template data-src="./complex.html" data-option="Complex"></template>
|
|
24
|
+
</blockquote-base-embedded-webview>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## basic.html
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<!DOCTYPE html>
|
|
31
|
+
<html lang="en">
|
|
32
|
+
<head>
|
|
33
|
+
<title>Demo Basic</title>
|
|
34
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
35
|
+
<meta charset="utf-8" />
|
|
36
|
+
<style>
|
|
37
|
+
:root {
|
|
38
|
+
font: normal medium/1.25 sans-serif;
|
|
39
|
+
}
|
|
40
|
+
body {
|
|
41
|
+
margin: 0;
|
|
42
|
+
}
|
|
43
|
+
[data-embedded] .hidden {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
47
|
+
</head>
|
|
48
|
+
<body>
|
|
49
|
+
<h1 class="hidden">Heading</h1>
|
|
50
|
+
<p>Basic Demo</p>
|
|
51
|
+
</body>
|
|
52
|
+
</html>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Exports
|
|
56
|
+
|
|
57
|
+
- BlockquoteBaseEmbeddedWebview
|
|
58
|
+
|
|
59
|
+
@tagname blockquote-base-embedded-webview
|
|
60
|
+
*/
|
|
61
|
+
export class BlockquoteBaseEmbeddedWebview extends LitElement {
|
|
62
|
+
static get is() {
|
|
63
|
+
return 'blockquote-base-embedded-webview';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static get styles() {
|
|
67
|
+
return [styles];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static get properties() {
|
|
71
|
+
return {
|
|
72
|
+
/**
|
|
73
|
+
* The heading of the webview.
|
|
74
|
+
* @type {String}
|
|
75
|
+
*/
|
|
76
|
+
heading: {
|
|
77
|
+
type: String,
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Index of currently srcset file
|
|
82
|
+
* @type {Number}
|
|
83
|
+
*/
|
|
84
|
+
selected: {
|
|
85
|
+
type: Number,
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Heading level from 1 to 6
|
|
90
|
+
* @type {Number}
|
|
91
|
+
*/
|
|
92
|
+
headingLevel: {
|
|
93
|
+
type: Number,
|
|
94
|
+
attribute: 'heading-level',
|
|
95
|
+
reflect: true,
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Index of currently screen size selected
|
|
100
|
+
* @type {Number}
|
|
101
|
+
*/
|
|
102
|
+
screenSizeSelected: {
|
|
103
|
+
type: Number,
|
|
104
|
+
attribute: 'screen-size-selected',
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Limit height to 100% available
|
|
109
|
+
* @type {Boolean}
|
|
110
|
+
*/
|
|
111
|
+
limitHeight: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
attribute: 'limit-height',
|
|
114
|
+
reflect: true,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
constructor() {
|
|
120
|
+
super();
|
|
121
|
+
this.selected = 0;
|
|
122
|
+
this.screenSizeSelected = 0;
|
|
123
|
+
this.headingLevel = 1;
|
|
124
|
+
this.heading = '';
|
|
125
|
+
this.__selectArrow = chevronDownIcon;
|
|
126
|
+
this.__readDataPos = { x: 0, y: 0, resizing: false };
|
|
127
|
+
this.limitHeight = false;
|
|
128
|
+
this._sources = [{ file: '', option: '' }];
|
|
129
|
+
this._updateSize = this._updateSize.bind(this);
|
|
130
|
+
this._embeddedResizeRef = createRef();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
connectedCallback() {
|
|
134
|
+
super.connectedCallback && super.connectedCallback();
|
|
135
|
+
|
|
136
|
+
this.shadowRoot.addEventListener('webviewresize', ({ detail }) => {
|
|
137
|
+
Object.assign(this.__readDataPos, detail);
|
|
138
|
+
this.requestUpdate();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const _sources = Array.from(this.querySelectorAll('template'));
|
|
142
|
+
if (_sources.length) {
|
|
143
|
+
this._sources = _sources.map(item => {
|
|
144
|
+
const { src, option } = item.dataset;
|
|
145
|
+
return {
|
|
146
|
+
src,
|
|
147
|
+
option,
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
this._src = this._sources[this.selected].src;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
firstUpdated(props) {
|
|
156
|
+
super.firstUpdated && super.firstUpdated(props);
|
|
157
|
+
|
|
158
|
+
this.embedded = this.shadowRoot.querySelector('[slot="embedded"]');
|
|
159
|
+
this.append(this.embedded);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
_updateSize({ detail }) {
|
|
163
|
+
this._embeddedResizeRef.value.style.setProperty(
|
|
164
|
+
'--blockquote-base-embedded-webview-resize-rect-width',
|
|
165
|
+
`${detail.width}px`,
|
|
166
|
+
);
|
|
167
|
+
this._embeddedResizeRef.value.style.setProperty(
|
|
168
|
+
'--blockquote-base-embedded-webview-resize-rect-height',
|
|
169
|
+
this.limitHeight ? '100%' : `${detail.height}px`,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
get _headingLevel() {
|
|
174
|
+
return this.headingLevel >= 1 && this.headingLevel <= 6 ? this.headingLevel : 2;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
render() {
|
|
178
|
+
return html`
|
|
179
|
+
<header>
|
|
180
|
+
<div>${this._headerTpl} ${this._selectTpl} ${this._readDataPosTpl}</div>
|
|
181
|
+
${this._screenSizeTpl}
|
|
182
|
+
</header>
|
|
183
|
+
<div class="main">
|
|
184
|
+
<blockquote-base-embedded-webview-resize ${ref(this._embeddedResizeRef)}>
|
|
185
|
+
<slot name="embedded"> ${this._embeddedSlotTpl} </slot>
|
|
186
|
+
</blockquote-base-embedded-webview-resize>
|
|
187
|
+
</div>
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
get _headerTpl() {
|
|
192
|
+
return html`<div aria-level="${this._headingLevel}" role="heading">${this.heading}</div>`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
get _selectTpl() {
|
|
196
|
+
return html`
|
|
197
|
+
<div class="select">
|
|
198
|
+
<select @change="${this._onChangeFile}" aria-label="Cases">
|
|
199
|
+
${this._sources.map(
|
|
200
|
+
(item, index) => html`
|
|
201
|
+
<option ?selected="${this.selected === index}" value="${index}">
|
|
202
|
+
${item.option}
|
|
203
|
+
</option>
|
|
204
|
+
`,
|
|
205
|
+
)}
|
|
206
|
+
</select>
|
|
207
|
+
${this.__selectArrow}
|
|
208
|
+
</div>
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
get _readDataPosTpl() {
|
|
213
|
+
return html`
|
|
214
|
+
<div
|
|
215
|
+
aria-hidden="true"
|
|
216
|
+
class="read-data-pos"
|
|
217
|
+
style="opacity:${this.__readDataPos.resizing ? 1 : 0}"
|
|
218
|
+
>
|
|
219
|
+
<span>${this.__readDataPos.x}</span>
|
|
220
|
+
<span>x</span>
|
|
221
|
+
<span>${this.__readDataPos.y}</span>
|
|
222
|
+
</div>
|
|
223
|
+
`;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
get _screenSizeTpl() {
|
|
227
|
+
return html` <blockquote-base-embedded-webview-size
|
|
228
|
+
@click="${this._updateSize}"
|
|
229
|
+
@selectedchange="${this._updateSize}"
|
|
230
|
+
.selected="${this.screenSizeSelected}"
|
|
231
|
+
></blockquote-base-embedded-webview-size>`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
get _embeddedSlotTpl() {
|
|
235
|
+
return html` <blockquote-base-embedded-webview-element
|
|
236
|
+
slot="embedded"
|
|
237
|
+
.src="${this._src}"
|
|
238
|
+
.embeddedTitle="${this._sources[this.selected].option}"
|
|
239
|
+
>
|
|
240
|
+
</blockquote-base-embedded-webview-element>`;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
_onChangeFile({ target }) {
|
|
244
|
+
this.selected = target.selectedIndex;
|
|
245
|
+
this._src = this._sources[this.selected].src;
|
|
246
|
+
}
|
|
247
|
+
}
|