@operato/markdown 0.2.49

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.
Files changed (44) hide show
  1. package/.editorconfig +29 -0
  2. package/.storybook/main.js +3 -0
  3. package/.storybook/server.mjs +8 -0
  4. package/CHANGELOG.md +31 -0
  5. package/LICENSE +21 -0
  6. package/README.md +0 -0
  7. package/assets/scripts/markdown-webworker.js +30 -0
  8. package/demo/index.html +34 -0
  9. package/dist/src/index.d.ts +1 -0
  10. package/dist/src/index.js +2 -0
  11. package/dist/src/index.js.map +1 -0
  12. package/dist/src/markdown-style.d.ts +1 -0
  13. package/dist/src/markdown-style.js +122 -0
  14. package/dist/src/markdown-style.js.map +1 -0
  15. package/dist/src/markdown.d.ts +1 -0
  16. package/dist/src/markdown.js +18 -0
  17. package/dist/src/markdown.js.map +1 -0
  18. package/dist/src/ox-layout.d.ts +45 -0
  19. package/dist/src/ox-layout.js +148 -0
  20. package/dist/src/ox-layout.js.map +1 -0
  21. package/dist/src/ox-markdown.d.ts +12 -0
  22. package/dist/src/ox-markdown.js +124 -0
  23. package/dist/src/ox-markdown.js.map +1 -0
  24. package/dist/src/ox-toolbar-style.d.ts +4 -0
  25. package/dist/src/ox-toolbar-style.js +226 -0
  26. package/dist/src/ox-toolbar-style.js.map +1 -0
  27. package/dist/src/ox-toolbar.d.ts +4 -0
  28. package/dist/src/ox-toolbar.js +122 -0
  29. package/dist/src/ox-toolbar.js.map +1 -0
  30. package/dist/stories/index.stories.d.ts +33 -0
  31. package/dist/stories/index.stories.js +33 -0
  32. package/dist/stories/index.stories.js.map +1 -0
  33. package/dist/test/ox-layout.test.d.ts +1 -0
  34. package/dist/test/ox-layout.test.js +24 -0
  35. package/dist/test/ox-layout.test.js.map +1 -0
  36. package/dist/tsconfig.tsbuildinfo +1 -0
  37. package/package.json +72 -0
  38. package/src/index.ts +1 -0
  39. package/src/markdown-style.ts +122 -0
  40. package/src/markdown.ts +20 -0
  41. package/src/ox-markdown.ts +119 -0
  42. package/tsconfig.json +22 -0
  43. package/web-dev-server.config.mjs +27 -0
  44. package/web-test-runner.config.mjs +41 -0
package/.editorconfig ADDED
@@ -0,0 +1,29 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+
8
+ [*]
9
+
10
+ # Change these settings to your own preference
11
+ indent_style = space
12
+ indent_size = 2
13
+
14
+ # We recommend you to keep these unchanged
15
+ end_of_line = lf
16
+ charset = utf-8
17
+ trim_trailing_whitespace = true
18
+ insert_final_newline = true
19
+
20
+ [*.md]
21
+ trim_trailing_whitespace = false
22
+
23
+ [*.json]
24
+ indent_size = 2
25
+
26
+ [*.{html,js,md}]
27
+ block_comment_start = /**
28
+ block_comment = *
29
+ block_comment_end = */
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ stories: ['../dist/stories/**/*.stories.{js,md,mdx}'],
3
+ };
@@ -0,0 +1,8 @@
1
+ import { storybookPlugin } from '@web/dev-server-storybook';
2
+ import baseConfig from '../web-dev-server.config.mjs';
3
+
4
+ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
5
+ ...baseConfig,
6
+ open: '/',
7
+ plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
8
+ });
package/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ### [0.2.49](https://github.com/hatiolab/operato/compare/v0.2.48...v0.2.49) (2021-12-14)
7
+
8
+
9
+ ### :rocket: New Features
10
+
11
+ * add ox-markdown ([eb8e528](https://github.com/hatiolab/operato/commit/eb8e528bad1c9c22eb7ccfaf52949d9c9f533777))
12
+
13
+
14
+
15
+ ### [0.2.48](https://github.com/hatiolab/operato/compare/v0.2.47...v0.2.48) (2021-12-14)
16
+
17
+ **Note:** Version bump only for package @operato/markdown
18
+
19
+ ### [0.2.47](https://github.com/hatiolab/operato/compare/v0.2.46...v0.2.47) (2021-12-13)
20
+
21
+ **Note:** Version bump only for package @operato/markdown
22
+
23
+ ### [0.2.46](https://github.com/hatiolab/operato/compare/v0.2.45...v0.2.46) (2021-12-12)
24
+
25
+ ### :rocket: New Features
26
+
27
+ - add markdown and oops ([56737fa](https://github.com/hatiolab/operato/commit/56737fa117ed2135e279ca0f1e4c969daddf7b34))
28
+
29
+ ### :bug: Bug Fix
30
+
31
+ - set all module version to 0.2.45 ([40cea11](https://github.com/hatiolab/operato/commit/40cea11fab09ab3fb96bcd7db797abd13b23c216))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) hatiolab.com
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
File without changes
@@ -0,0 +1,30 @@
1
+ importScripts('/node_modules/marked/marked.min.js')
2
+
3
+ var TOPIC_OFFSET = '/helps/'.length
4
+
5
+ marked.use({
6
+ renderer: {
7
+ link: function link(href, title, text) {
8
+ var baseUrl = new URL(this.options.baseUrl, location.origin)
9
+ var targetUrl = new URL(href, baseUrl)
10
+ var outside = targetUrl.origin !== location.origin
11
+
12
+ if (!outside) {
13
+ var pathname = targetUrl.pathname
14
+ if (pathname.endsWith('.md') || pathname.endsWith('.markdown')) {
15
+ var url = new URL(location.origin + '/help')
16
+ url.searchParams.append('topic', pathname.slice(TOPIC_OFFSET, pathname.lastIndexOf('.')))
17
+
18
+ href = url.href
19
+ }
20
+ }
21
+
22
+ return `<a href="${href}" ${title ? `title="${title}"` : ''} ${outside ? 'target="_blank"' : ''}>${text}</a>`
23
+ }
24
+ }
25
+ })
26
+
27
+ onmessage = e => {
28
+ const { content, options } = e.data
29
+ postMessage(marked.parse(content, options))
30
+ }
@@ -0,0 +1,34 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en-GB">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <style>
6
+ body {
7
+ background: #fafafa;
8
+ --ox-checkbox-size: 12px;
9
+ }
10
+
11
+ #demo {
12
+ position: relative;
13
+ height: 300px;
14
+ background-color: lightgray;
15
+ vertical-align: middle;
16
+ }
17
+ </style>
18
+ <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
19
+ <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
20
+ </head>
21
+ <body>
22
+ <div id="demo"></div>
23
+
24
+ <script type="module">
25
+ import { html, render } from 'lit'
26
+ import '../dist/src/ox-markdown.js'
27
+ import '@material/mwc-icon'
28
+
29
+ const parent = document.querySelector('#demo')
30
+
31
+ render(html`clike anywhere in this box to show markdown.`, parent)
32
+ </script>
33
+ </body>
34
+ </html>
@@ -0,0 +1 @@
1
+ export * from './ox-markdown';
@@ -0,0 +1,2 @@
1
+ export * from './ox-markdown';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA","sourcesContent":["export * from './ox-markdown'\n"]}
@@ -0,0 +1 @@
1
+ export declare const MarkdownStyle: import("lit").CSSResult;
@@ -0,0 +1,122 @@
1
+ import { css } from 'lit';
2
+ export const MarkdownStyle = css `
3
+ h1 {
4
+ background-color: var(--help-panel-title-background-color);
5
+ margin: var(--help-panel-title-margin);
6
+ padding: var(--help-panel-title-padding);
7
+ font-size: var(--help-panel-h1-title-font-size);
8
+ text-transform: capitalize;
9
+ color: var(--help-panel-h1-title-color);
10
+ }
11
+ h2 {
12
+ margin: var(--help-panel-title-margin);
13
+ padding: var(--help-panel-title-padding);
14
+ font-size: var(--help-panel-h2-title-font-size);
15
+ color: var(--help-panel-h2-title-color);
16
+ text-transform: capitalize;
17
+ }
18
+ h3 {
19
+ margin: var(--help-panel-title-margin);
20
+ padding: var(--help-panel-title-padding);
21
+ font-size: var(--help-panel-h3-title-font-size);
22
+ color: var(--help-panel-h3-title-color);
23
+ }
24
+ mwc-icon {
25
+ vertical-align: middle;
26
+ }
27
+
28
+ img {
29
+ display: block;
30
+ margin: var(--margin-narrow) var(--margin-default);
31
+ max-width: 100%;
32
+ }
33
+ img[src*='#icon25'] {
34
+ width: 25px;
35
+ height: 25px;
36
+ }
37
+ img[src*='#icon50'] {
38
+ width: 50px;
39
+ height: 50px;
40
+ }
41
+ img[src*='#icon100'] {
42
+ width: 100px;
43
+ height: 100px;
44
+ }
45
+ img[src*='#icon25inlined'],
46
+ img[src*='#icon50inlined'],
47
+ img[src*='#icon100inlined'] {
48
+ display: inline-block;
49
+ margin: var(--margin-narrow);
50
+ }
51
+ p {
52
+ margin: var(--help-panel-paragraph-margin);
53
+ font-size: var(--help-panel-font-size);
54
+ }
55
+ [focusBox] {
56
+ display: block;
57
+ padding: var(--help-panel-focusBox-padding);
58
+ border: var(--help-panel-focusBox-border);
59
+ border-radius: var(--help-panel-focusBox-border-radius);
60
+ background-color: var(--help-panel-focusBox-background-color);
61
+ color: var(--help-panel-focusBox-color);
62
+ }
63
+
64
+ [subtitle] {
65
+ font-weight: bold;
66
+ }
67
+ [subtitle]::before {
68
+ content: '';
69
+ width: 7px;
70
+ height: 7px;
71
+ display: inline-block;
72
+ border: 3px solid var(--theme-white-color);
73
+ border-radius: 50%;
74
+ margin-right: var(--margin-narrow);
75
+ }
76
+ p + ol,
77
+ p + ul {
78
+ font-size: var(--help-panel-content-font-size);
79
+ }
80
+ ol,
81
+ ul {
82
+ padding: 0 0 0 30px;
83
+ }
84
+ ol li,
85
+ ul li {
86
+ margin: 0 0 2px 0;
87
+ }
88
+ a {
89
+ margin-bottom: 0 !important;
90
+ color: var(--help-panel-a-color);
91
+ font-size: var(--fontsize-default);
92
+ text-decoration: underline;
93
+ }
94
+ a mwc-icon {
95
+ font-size: var(--help-panel-a-icon-size);
96
+ margin: 0;
97
+ }
98
+ a:hover {
99
+ background-color: var(--opacity-light-dark-color);
100
+ font-weight: bold;
101
+ }
102
+
103
+ table {
104
+ border-collapse: collapse;
105
+ border: var(--border-dark-color);
106
+ font-size: 0.9em;
107
+ }
108
+ th {
109
+ border-top: 3px solid var(--primary-color);
110
+ background-color: var(--main-section-background-color);
111
+ color: var(--secondary-color);
112
+ }
113
+ th,
114
+ td {
115
+ border-bottom: var(--border-dark-color);
116
+ padding: var(--padding-narrow);
117
+ }
118
+ tr:nth-child(even) {
119
+ background-color: #f6f6f6;
120
+ }
121
+ `;
122
+ //# sourceMappingURL=markdown-style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-style.js","sourceRoot":"","sources":["../../src/markdown-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuH/B,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport const MarkdownStyle = css`\n h1 {\n background-color: var(--help-panel-title-background-color);\n margin: var(--help-panel-title-margin);\n padding: var(--help-panel-title-padding);\n font-size: var(--help-panel-h1-title-font-size);\n text-transform: capitalize;\n color: var(--help-panel-h1-title-color);\n }\n h2 {\n margin: var(--help-panel-title-margin);\n padding: var(--help-panel-title-padding);\n font-size: var(--help-panel-h2-title-font-size);\n color: var(--help-panel-h2-title-color);\n text-transform: capitalize;\n }\n h3 {\n margin: var(--help-panel-title-margin);\n padding: var(--help-panel-title-padding);\n font-size: var(--help-panel-h3-title-font-size);\n color: var(--help-panel-h3-title-color);\n }\n mwc-icon {\n vertical-align: middle;\n }\n\n img {\n display: block;\n margin: var(--margin-narrow) var(--margin-default);\n max-width: 100%;\n }\n img[src*='#icon25'] {\n width: 25px;\n height: 25px;\n }\n img[src*='#icon50'] {\n width: 50px;\n height: 50px;\n }\n img[src*='#icon100'] {\n width: 100px;\n height: 100px;\n }\n img[src*='#icon25inlined'],\n img[src*='#icon50inlined'],\n img[src*='#icon100inlined'] {\n display: inline-block;\n margin: var(--margin-narrow);\n }\n p {\n margin: var(--help-panel-paragraph-margin);\n font-size: var(--help-panel-font-size);\n }\n [focusBox] {\n display: block;\n padding: var(--help-panel-focusBox-padding);\n border: var(--help-panel-focusBox-border);\n border-radius: var(--help-panel-focusBox-border-radius);\n background-color: var(--help-panel-focusBox-background-color);\n color: var(--help-panel-focusBox-color);\n }\n\n [subtitle] {\n font-weight: bold;\n }\n [subtitle]::before {\n content: '';\n width: 7px;\n height: 7px;\n display: inline-block;\n border: 3px solid var(--theme-white-color);\n border-radius: 50%;\n margin-right: var(--margin-narrow);\n }\n p + ol,\n p + ul {\n font-size: var(--help-panel-content-font-size);\n }\n ol,\n ul {\n padding: 0 0 0 30px;\n }\n ol li,\n ul li {\n margin: 0 0 2px 0;\n }\n a {\n margin-bottom: 0 !important;\n color: var(--help-panel-a-color);\n font-size: var(--fontsize-default);\n text-decoration: underline;\n }\n a mwc-icon {\n font-size: var(--help-panel-a-icon-size);\n margin: 0;\n }\n a:hover {\n background-color: var(--opacity-light-dark-color);\n font-weight: bold;\n }\n\n table {\n border-collapse: collapse;\n border: var(--border-dark-color);\n font-size: 0.9em;\n }\n th {\n border-top: 3px solid var(--primary-color);\n background-color: var(--main-section-background-color);\n color: var(--secondary-color);\n }\n th,\n td {\n border-bottom: var(--border-dark-color);\n padding: var(--padding-narrow);\n }\n tr:nth-child(even) {\n background-color: #f6f6f6;\n }\n`\n"]}
@@ -0,0 +1 @@
1
+ export declare function md(markdown: string, options: StructuredSerializeOptions): Promise<any>;
@@ -0,0 +1,18 @@
1
+ const worker = new Worker('/node_modules/@operato/markdown/assets/scripts/markdown-webworker.js');
2
+ const TIMEOUT_LIMIT = 20000;
3
+ export async function md(markdown, options) {
4
+ return new Promise((resolve, reject) => {
5
+ var timeout = setTimeout(() => {
6
+ reject('Marked took too long!');
7
+ }, TIMEOUT_LIMIT);
8
+ worker.onmessage = e => {
9
+ clearTimeout(timeout);
10
+ resolve(e.data);
11
+ };
12
+ worker.postMessage({
13
+ content: markdown,
14
+ options
15
+ });
16
+ });
17
+ }
18
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/markdown.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,sEAAsE,CAAC,CAAA;AACjG,MAAM,aAAa,GAAG,KAAK,CAAA;AAE3B,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,QAAgB,EAAE,OAAmC;IAC5E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,CAAC,uBAAuB,CAAC,CAAA;QACjC,CAAC,EAAE,aAAa,CAAC,CAAA;QAEjB,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE;YACrB,YAAY,CAAC,OAAO,CAAC,CAAA;YACrB,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACjB,CAAC,CAAA;QAED,MAAM,CAAC,WAAW,CAAC;YACjB,OAAO,EAAE,QAAQ;YACjB,OAAO;SACR,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["const worker = new Worker('/node_modules/@operato/markdown/assets/scripts/markdown-webworker.js')\nconst TIMEOUT_LIMIT = 20000\n\nexport async function md(markdown: string, options: StructuredSerializeOptions): Promise<any> {\n return new Promise((resolve, reject) => {\n var timeout = setTimeout(() => {\n reject('Marked took too long!')\n }, TIMEOUT_LIMIT)\n\n worker.onmessage = e => {\n clearTimeout(timeout)\n resolve(e.data)\n }\n\n worker.postMessage({\n content: markdown,\n options\n })\n })\n}\n"]}
@@ -0,0 +1,45 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class OxLayout extends LitElement {
3
+ static styles: import("lit").CSSResult[];
4
+ _parent?: Element;
5
+ render(): import("lit-html").TemplateResult<1>;
6
+ protected _onfocusout: (e: FocusEvent) => void;
7
+ protected _onkeydown: (e: KeyboardEvent) => void;
8
+ protected _onkeyup: (e: KeyboardEvent) => void;
9
+ protected _onclick: (e: MouseEvent) => void;
10
+ protected _onclose: (e: Event) => void;
11
+ protected _oncollapse: (e: Event) => void;
12
+ protected _onwindowblur: (e: Event) => void;
13
+ connectedCallback(): void;
14
+ /**
15
+ * Configuration for opening ox-layout
16
+ *
17
+ * @typedef {Object} PopupOpenOptions
18
+ * @property {HTMLTemplate} template HTMLTemplate to be displayed inside the layout
19
+ * @property {Number} top The position-top where the pop-up will be displayed
20
+ * @property {Number} left The position-left where the pop-up will be displayed
21
+ * @property {HTMLElement} parent Popup's parent element
22
+ */
23
+ /**
24
+ * Open Popup
25
+ *
26
+ * @param {PopupOpenOptions}
27
+ */
28
+ static open({ template, top, left, right, bottom, parent }: {
29
+ template: unknown;
30
+ top?: number;
31
+ left?: number;
32
+ right?: number;
33
+ bottom?: number;
34
+ parent?: Element | null;
35
+ }): void;
36
+ open({ left, top, right, bottom, silent }: {
37
+ left?: number;
38
+ top?: number;
39
+ right?: number;
40
+ bottom?: number;
41
+ silent?: boolean;
42
+ }): void;
43
+ guaranteeFocus(): void;
44
+ close(): void;
45
+ }
@@ -0,0 +1,148 @@
1
+ import { __decorate } from "tslib";
2
+ import { css, html, LitElement } from 'lit';
3
+ import { render } from 'lit-html';
4
+ import { customElement, state } from 'lit/decorators.js';
5
+ import { ScrollbarStyles } from '@operato/styles';
6
+ let OxLayout = class OxLayout extends LitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this._onfocusout = function (e) {
10
+ const to = e.relatedTarget;
11
+ if (!this.contains(to)) {
12
+ /* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, ox-popup은 닫혀야 한다. */
13
+ // @ts-ignore for debug
14
+ !window.POPUP_DEBUG && this.close();
15
+ }
16
+ }.bind(this);
17
+ this._onkeydown = function (e) {
18
+ e.stopPropagation();
19
+ switch (e.key) {
20
+ case 'Esc': // for IE/Edge
21
+ case 'Escape':
22
+ this.close();
23
+ break;
24
+ }
25
+ }.bind(this);
26
+ this._onkeyup = function (e) {
27
+ e.stopPropagation();
28
+ }.bind(this);
29
+ this._onclick = function (e) {
30
+ e.stopPropagation();
31
+ }.bind(this);
32
+ this._onclose = function (e) {
33
+ this.close();
34
+ }.bind(this);
35
+ this._oncollapse = function (e) {
36
+ e.stopPropagation();
37
+ this.close();
38
+ }.bind(this);
39
+ this._onwindowblur = function (e) {
40
+ // @ts-ignore for debug
41
+ !window.POPUP_DEBUG && this.close();
42
+ }.bind(this);
43
+ }
44
+ render() {
45
+ return html ` <slot> </slot> `;
46
+ }
47
+ connectedCallback() {
48
+ super.connectedCallback();
49
+ this.addEventListener('focusout', this._onfocusout);
50
+ this.addEventListener('keydown', this._onkeydown);
51
+ this.addEventListener('keyup', this._onkeyup);
52
+ this.addEventListener('click', this._onclick);
53
+ this.addEventListener('ox-close', this._onclose);
54
+ this.addEventListener('ox-collapse', this._oncollapse);
55
+ this.setAttribute('tabindex', '0'); // make this element focusable
56
+ this.guaranteeFocus();
57
+ }
58
+ /**
59
+ * Configuration for opening ox-layout
60
+ *
61
+ * @typedef {Object} PopupOpenOptions
62
+ * @property {HTMLTemplate} template HTMLTemplate to be displayed inside the layout
63
+ * @property {Number} top The position-top where the pop-up will be displayed
64
+ * @property {Number} left The position-left where the pop-up will be displayed
65
+ * @property {HTMLElement} parent Popup's parent element
66
+ */
67
+ /**
68
+ * Open Popup
69
+ *
70
+ * @param {PopupOpenOptions}
71
+ */
72
+ static open({ template, top, left, right, bottom, parent }) {
73
+ const owner = parent || document.body;
74
+ const target = document.createElement('ox-layout');
75
+ render(template, target);
76
+ target._parent = owner;
77
+ owner.appendChild(target);
78
+ target.open({ top, left, right, bottom });
79
+ }
80
+ open({ left, top, right, bottom, silent = false }) {
81
+ if (left !== undefined)
82
+ this.style.left = `${left}px`;
83
+ if (top !== undefined)
84
+ this.style.top = `${top}px`;
85
+ if (right !== undefined)
86
+ this.style.right = `${right}px`;
87
+ if (bottom !== undefined)
88
+ this.style.bottom = `${bottom}px`;
89
+ this.setAttribute('active', '');
90
+ !silent && this.guaranteeFocus();
91
+ /* When the window is out of focus, all pop-ups should disappear. */
92
+ window.addEventListener('blur', this._onwindowblur);
93
+ }
94
+ guaranteeFocus() {
95
+ const focusible = this.querySelector(':scope > button, :scope > [href], :scope > input, :scope > select, :scope > textarea, :scope > [tabindex]:not([tabindex="-1"])');
96
+ if (focusible) {
97
+ ;
98
+ focusible.focus();
99
+ }
100
+ else {
101
+ this.focus();
102
+ }
103
+ }
104
+ close() {
105
+ this.removeAttribute('active');
106
+ window.removeEventListener('blur', this._onwindowblur);
107
+ if (this._parent) {
108
+ /* this case is when the layout is opened by OxLayout.open(...) */
109
+ this.removeEventListener('focusout', this._onfocusout);
110
+ this.removeEventListener('keydown', this._onkeydown);
111
+ this.removeEventListener('keyup', this._onkeyup);
112
+ this.removeEventListener('click', this._onclick);
113
+ this.removeEventListener('ox-close', this._onclose);
114
+ this.removeEventListener('ox-collapse', this._oncollapse);
115
+ this._parent.removeChild(this);
116
+ delete this._parent;
117
+ }
118
+ }
119
+ };
120
+ OxLayout.styles = [
121
+ ScrollbarStyles,
122
+ css `
123
+ :host {
124
+ position: absolute;
125
+ display: none;
126
+ background-color: white;
127
+ z-index: 100;
128
+ box-sizing: border-box;
129
+ min-width: fit-content;
130
+ }
131
+
132
+ :host([active]) {
133
+ display: block;
134
+ }
135
+
136
+ :host(*:focus) {
137
+ outline: none;
138
+ }
139
+ `
140
+ ];
141
+ __decorate([
142
+ state()
143
+ ], OxLayout.prototype, "_parent", void 0);
144
+ OxLayout = __decorate([
145
+ customElement('ox-layout')
146
+ ], OxLayout);
147
+ export { OxLayout };
148
+ //# sourceMappingURL=ox-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-layout.js","sourceRoot":"","sources":["../../src/ox-layout.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,UAAU;IAAxC;;QA6BY,gBAAW,GAA4B,UAA0B,CAAa;YACtF,MAAM,EAAE,GAAG,CAAC,CAAC,aAA4B,CAAA;YAEzC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;gBACtB,sDAAsD;gBACtD,uBAAuB;gBACvB,CAAC,MAAM,CAAC,WAAW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E,IAAI,CAAC,QAAQ,CAAC,CAAA;YACnD,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;YAEzD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;YAC9B,OAAO,IAAI,CAAC,OAAO,CAAA;SACpB;IACH,CAAC;CACF,CAAA;AAtLQ,eAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;KAiBF;CACF,CAAA;AAEQ;IAAR,KAAK,EAAE;yCAAkB;AAvBf,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAuLpB;SAvLY,QAAQ","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { render } from 'lit-html';\nimport { customElement, state } from 'lit/decorators.js';\n\nimport { ScrollbarStyles } from '@operato/styles';\n\n@customElement('ox-layout')\nexport class OxLayout extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n position: absolute;\n display: none;\n background-color: white;\n z-index: 100;\n box-sizing: border-box;\n min-width: fit-content;\n }\n\n :host([active]) {\n display: block;\n }\n\n :host(*:focus) {\n outline: none;\n }\n `\n ]\n\n @state() _parent?: Element\n\n render() {\n return html` <slot> </slot> `\n }\n\n protected _onfocusout: (e: FocusEvent) => void = function (this: OxLayout, e: FocusEvent) {\n const to = e.relatedTarget as HTMLElement\n\n if (!this.contains(to)) {\n /* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, ox-popup은 닫혀야 한다. */\n // @ts-ignore for debug\n !window.POPUP_DEBUG && this.close()\n }\n }.bind(this)\n\n protected _onkeydown: (e: KeyboardEvent) => void = function (this: OxLayout, e: KeyboardEvent) {\n e.stopPropagation()\n\n switch (e.key) {\n case 'Esc': // for IE/Edge\n case 'Escape':\n this.close()\n break\n }\n }.bind(this)\n\n protected _onkeyup: (e: KeyboardEvent) => void = function (this: OxLayout, e: KeyboardEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _onclick: (e: MouseEvent) => void = function (this: OxLayout, e: MouseEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _onclose: (e: Event) => void = function (this: OxLayout, e: Event) {\n this.close()\n }.bind(this)\n\n protected _oncollapse: (e: Event) => void = function (this: OxLayout, e: Event) {\n e.stopPropagation()\n this.close()\n }.bind(this)\n\n protected _onwindowblur: (e: Event) => void = function (this: OxLayout, e: Event) {\n // @ts-ignore for debug\n !window.POPUP_DEBUG && this.close()\n }.bind(this)\n\n connectedCallback() {\n super.connectedCallback()\n\n this.addEventListener('focusout', this._onfocusout)\n this.addEventListener('keydown', this._onkeydown)\n this.addEventListener('keyup', this._onkeyup)\n this.addEventListener('click', this._onclick)\n this.addEventListener('ox-close', this._onclose)\n this.addEventListener('ox-collapse', this._oncollapse)\n\n this.setAttribute('tabindex', '0') // make this element focusable\n this.guaranteeFocus()\n }\n\n /**\n * Configuration for opening ox-layout\n *\n * @typedef {Object} PopupOpenOptions\n * @property {HTMLTemplate} template HTMLTemplate to be displayed inside the layout\n * @property {Number} top The position-top where the pop-up will be displayed\n * @property {Number} left The position-left where the pop-up will be displayed\n * @property {HTMLElement} parent Popup's parent element\n */\n\n /**\n * Open Popup\n *\n * @param {PopupOpenOptions}\n */\n static open({\n template,\n top,\n left,\n right,\n bottom,\n parent\n }: {\n template: unknown\n top?: number\n left?: number\n right?: number\n bottom?: number\n parent?: Element | null\n }) {\n const owner = parent || document.body\n const target = document.createElement('ox-layout') as OxLayout\n\n render(template, target)\n\n target._parent = owner\n owner.appendChild(target)\n\n target.open({ top, left, right, bottom })\n }\n\n open({\n left,\n top,\n right,\n bottom,\n silent = false\n }: {\n left?: number\n top?: number\n right?: number\n bottom?: number\n silent?: boolean\n }) {\n if (left !== undefined) this.style.left = `${left}px`\n if (top !== undefined) this.style.top = `${top}px`\n if (right !== undefined) this.style.right = `${right}px`\n if (bottom !== undefined) this.style.bottom = `${bottom}px`\n\n this.setAttribute('active', '')\n\n !silent && this.guaranteeFocus()\n\n /* When the window is out of focus, all pop-ups should disappear. */\n window.addEventListener('blur', this._onwindowblur)\n }\n\n guaranteeFocus() {\n const focusible = this.querySelector(\n ':scope > button, :scope > [href], :scope > input, :scope > select, :scope > textarea, :scope > [tabindex]:not([tabindex=\"-1\"])'\n )\n\n if (focusible) {\n ;(focusible as HTMLElement).focus()\n } else {\n this.focus()\n }\n }\n\n close() {\n this.removeAttribute('active')\n\n window.removeEventListener('blur', this._onwindowblur)\n\n if (this._parent) {\n /* this case is when the layout is opened by OxLayout.open(...) */\n this.removeEventListener('focusout', this._onfocusout)\n this.removeEventListener('keydown', this._onkeydown)\n this.removeEventListener('keyup', this._onkeyup)\n this.removeEventListener('click', this._onclick)\n this.removeEventListener('ox-close', this._onclose)\n this.removeEventListener('ox-collapse', this._oncollapse)\n\n this._parent.removeChild(this)\n delete this._parent\n }\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
+ import { DirectiveResult } from 'lit-html/directive';
3
+ export declare class OxMarkdown extends LitElement {
4
+ static styles: import("lit").CSSResult[];
5
+ src?: string;
6
+ toc: boolean;
7
+ _html?: TemplateResult | DirectiveResult | null;
8
+ _headings: any[];
9
+ render(): TemplateResult<1>;
10
+ renderToc(): TemplateResult<1>;
11
+ updated(changed: PropertyValues<this>): Promise<void>;
12
+ }