@operato/help 7.1.31 → 7.1.32

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.
@@ -1,29 +0,0 @@
1
- import { css, html, LitElement } from 'lit'
2
- import { customElement, property } from 'lit/decorators.js'
3
-
4
- import { openHelp } from '../controller/help.js'
5
-
6
- @customElement('ox-inline-help')
7
- export class InlineHelp extends LitElement {
8
- static styles = css`
9
- :host {
10
- display: flex;
11
- align-items: center;
12
- }
13
- `
14
-
15
- @property({ type: String }) topic!: string
16
- @property({ type: String }) type!: string
17
-
18
- render() {
19
- return html` <slot></slot> `
20
- }
21
-
22
- connectedCallback() {
23
- super.connectedCallback()
24
-
25
- this.renderRoot.addEventListener('click', e => {
26
- openHelp(this.topic)
27
- })
28
- }
29
- }
@@ -1,39 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
-
3
- import { css, html, LitElement } from 'lit'
4
- import { customElement, property } from 'lit/decorators.js'
5
-
6
- import { i18next, localize } from '@operato/i18n'
7
-
8
- import { openHelp } from '../controller/help.js'
9
-
10
- @customElement('ox-title-with-help')
11
- export class TitleWithHelp extends localize(i18next)(LitElement) {
12
- static styles = css`
13
- md-icon {
14
- position: relative;
15
- top: 4px;
16
- cursor: help;
17
- opacity: var(--help-icon-opacity);
18
- color: var(--help-icon-color);
19
- line-height: 0;
20
-
21
- --md-icon-size: var(--help-icon-size);
22
-
23
- &:hover {
24
- opacity: var(--help-icon-hover-opacity);
25
- color: var(--help-icon-hover-color);
26
- }
27
- }
28
- `
29
-
30
- @property({ type: String }) msgid!: string
31
- @property({ type: String }) topic!: string
32
-
33
- render() {
34
- const title = i18next.t(this.msgid)
35
- const topic = this.topic
36
-
37
- return html` ${title} ${topic ? html`<md-icon @click=${() => openHelp(topic)}>help</md-icon>` : html``} `
38
- }
39
- }
@@ -1,13 +0,0 @@
1
- import { closeOverlay, openOverlay } from '@operato/layout'
2
-
3
- export function openHelp(topic: string) {
4
- openOverlay('help', {
5
- templateProperties: {
6
- topic
7
- }
8
- })
9
- }
10
-
11
- export function closeHelp() {
12
- closeOverlay('help')
13
- }
@@ -1,19 +0,0 @@
1
- import '../components/ox-help-icon.js'
2
-
3
- import { html } from 'lit-html'
4
-
5
- import { ColumnConfig, FieldRenderer, GristRecord } from '@operato/data-grist'
6
-
7
- interface HelpExtendedRecord extends GristRecord {
8
- help?: (value: any, column: ColumnConfig, record: GristRecord, rowIndex: number, owner: any) => string
9
- }
10
-
11
- const decoratorTemplate = (topic: string) => html`<ox-help-icon style="flex: 0;" .topic=${topic}>help</ox-help-icon>`
12
-
13
- export const HelpDecoratedRenderer: FieldRenderer = (value, column, record, rowIndex, field) => {
14
- const { help } = column?.record as HelpExtendedRecord
15
- const text = value === undefined ? '' : value
16
-
17
- const topic = help && help(value, column, record, rowIndex, field)
18
- return html`<span>${text}</span>&nbsp;${topic ? decoratorTemplate(topic) : ''}`
19
- }
package/src/help-style.ts DELETED
@@ -1,123 +0,0 @@
1
- import { css } from 'lit'
2
-
3
- export const HelpStyle = css`
4
- h1 {
5
- background-color: var(--help-panel-title-background-color);
6
- margin: var(--help-panel-title-margin);
7
- padding: var(--help-panel-title-padding);
8
- font-size: var(--help-panel-h1-title-font-size);
9
- text-transform: capitalize;
10
- color: var(--help-panel-h1-title-color);
11
- }
12
- h2 {
13
- margin: var(--help-panel-title-margin);
14
- padding: var(--help-panel-title-padding);
15
- font-size: var(--help-panel-h2-title-font-size);
16
- color: var(--help-panel-h2-title-color);
17
- text-transform: capitalize;
18
- }
19
- h3 {
20
- margin: var(--help-panel-title-margin);
21
- padding: var(--help-panel-title-padding);
22
- font-size: var(--help-panel-h3-title-font-size);
23
- color: var(--help-panel-h3-title-color);
24
- }
25
- md-icon {
26
- vertical-align: middle;
27
- }
28
-
29
- img {
30
- display: block;
31
- margin: var(--spacing-small) var(--spacing-medium);
32
- max-width: 100%;
33
- }
34
- img[src*='#icon25'] {
35
- width: 25px;
36
- height: 25px;
37
- }
38
- img[src*='#icon50'] {
39
- width: 50px;
40
- height: 50px;
41
- }
42
- img[src*='#icon100'] {
43
- width: 100px;
44
- height: 100px;
45
- }
46
- img[src*='#icon25inlined'],
47
- img[src*='#icon50inlined'],
48
- img[src*='#icon100inlined'] {
49
- display: inline-block;
50
- margin: var(--spacing-small);
51
- }
52
- p {
53
- margin: var(--help-panel-paragraph-margin);
54
- font-size: var(--help-panel-font-size);
55
- }
56
- [focusBox] {
57
- display: block;
58
- padding: var(--help-panel-focusBox-padding);
59
- border: var(--help-panel-focusBox-border);
60
- border-radius: var(--help-panel-focusBox-border-radius);
61
- background-color: var(--help-panel-focusBox-background-color);
62
- color: var(--help-panel-focusBox-color);
63
- }
64
-
65
- [subtitle] {
66
- font-weight: bold;
67
- }
68
- [subtitle]::before {
69
- content: '';
70
- width: 7px;
71
- height: 7px;
72
- display: inline-block;
73
- border: 3px solid var(--md-sys-color-surface);
74
- border-radius: 50%;
75
- margin-right: var(--spacing-small);
76
- }
77
- p + ol,
78
- p + ul {
79
- font-size: var(--help-panel-content-font-size);
80
- }
81
- ol,
82
- ul {
83
- padding: 0 0 0 30px;
84
- }
85
- ol li,
86
- ul li {
87
- margin: 0 0 2px 0;
88
- }
89
- a {
90
- margin-bottom: 0 !important;
91
- color: var(--help-panel-a-color);
92
- font-size: var(--fontsize-default);
93
- text-decoration: underline;
94
- }
95
- a md-icon {
96
- margin: 0;
97
-
98
- --md-icon-size: var(--help-panel-a-icon-size);
99
- }
100
- a:hover {
101
- background-color: var(--opacity-light-dark-color);
102
- font-weight: bold;
103
- }
104
-
105
- table {
106
- border-collapse: collapse;
107
- border: var(--border-dim-color);
108
- font-size: 0.9em;
109
- }
110
- th {
111
- border-top: 3px solid var(--md-sys-color-on-primary-container);
112
- background-color: var(--md-sys-color-background);
113
- color: var(--md-sys-color-on-secondary-container);
114
- }
115
- th,
116
- td {
117
- border-bottom: var(--border-dim-color);
118
- padding: var(--spacing-small);
119
- }
120
- tr:nth-child(even) {
121
- background-color: #f6f6f6;
122
- }
123
- `
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './controller/help.js'
2
- export * from './grist/help-decorated-renderer.js'
3
- export * from './components/ox-inline-help.js'
4
- export * from './components/ox-title-with-help.js'
5
- export * from './components/ox-help-icon.js'
@@ -1,126 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
-
3
- import { css, html } from 'lit'
4
- import { customElement, property, query } from 'lit/decorators.js'
5
- import { connect } from 'pwa-helpers/connect-mixin.js'
6
-
7
- import Headroom from '@operato/headroom'
8
- import { i18next, localize } from '@operato/i18n'
9
- import { navigate, PageView, store } from '@operato/shell'
10
- import { HeadroomStyles, ScrollbarStyles } from '@operato/styles'
11
-
12
- @customElement('ox-help-home')
13
- class HelpHome extends connect(store)(localize(i18next)(PageView)) {
14
- static styles = [
15
- ScrollbarStyles,
16
- HeadroomStyles,
17
- css`
18
- :host {
19
- display: flex;
20
- flex-direction: column;
21
- overflow: hidden;
22
- position: relative;
23
-
24
- --md-icon-size: 24px;
25
- }
26
-
27
- #navigation {
28
- position: absolute;
29
- display: flex;
30
- width: 100%;
31
- padding: var(--help-navigation-padding);
32
- border-bottom: var(--help-navigation-bottom);
33
- background-color: var(--md-sys-color-surface);
34
- }
35
-
36
- #navigation md-icon {
37
- padding: var(--help-navigation-icon-padding, var(--padding-default));
38
- border-right: var(--help-navigation-icon-border);
39
- cursor: pointer;
40
- color: var(--help-icon-color);
41
- }
42
-
43
- #content {
44
- flex: 1;
45
-
46
- overflow: auto;
47
- padding: var(--help-panel-content-padding);
48
- margin: var(--help-panel-margin);
49
- }
50
-
51
- #upward {
52
- --md-icon-size: 26px;
53
- position: absolute;
54
- bottom: var(--data-list-fab-position-vertical);
55
- right: var(--data-list-fab-position-horizontal);
56
- background-color: rgba(255, 255, 255, 0.7);
57
- border-radius: 20px;
58
- color: var(--data-list-fab-color);
59
- box-shadow: var(--data-list-fab-shadow);
60
- padding: 7px;
61
-
62
- scroll-padding-top: 65px;
63
- }
64
- `
65
- ]
66
-
67
- @property({ type: String }) topic!: string
68
- @property({ type: Boolean }) showGotoTop: boolean = false
69
-
70
- @query('#content') content!: HTMLElement
71
- @query('#navigation') navigation!: HTMLElement
72
-
73
- get context() {
74
- return {
75
- title: i18next.t('text.help')
76
- }
77
- }
78
-
79
- render() {
80
- const src = this.topic && `/helps/${this.topic || 'index'}.md`
81
-
82
- return html`
83
- <ox-markdown id="content" .src=${src} toc></ox-markdown>
84
-
85
- <div id="navigation">
86
- <md-icon @click=${() => navigate('help')} ?disabled=${this.topic == 'index'}>home</md-icon>
87
- <md-icon @click=${() => window.history.back()}>keyboard_arrow_left</md-icon>
88
- <md-icon @click=${() => window.history.forward()}>keyboard_arrow_right</md-icon>
89
- </div>
90
-
91
- ${this.showGotoTop
92
- ? html` <md-icon id="upward" @click=${(e: Event) => this.gotoTop(e)}>arrow_upward</md-icon> `
93
- : html``}
94
- `
95
- }
96
-
97
- override async firstUpdated() {
98
- this.content.addEventListener('scroll', (e: Event) => {
99
- this.showGotoTop = (e.target as HTMLElement)?.scrollTop !== 0
100
- })
101
-
102
- await this.requestUpdate()
103
-
104
- var originPaddingTop = parseFloat(getComputedStyle(this.content, null).getPropertyValue('padding-top'))
105
- this.content.style.paddingTop = this.navigation.clientHeight + originPaddingTop + 'px'
106
-
107
- var headroom = new Headroom(this.navigation, {
108
- scroller: this.content
109
- })
110
-
111
- headroom.init()
112
- }
113
-
114
- override async pageUpdated(changes: any, lifecycle: any) {
115
- if (this.active) {
116
- this.topic = lifecycle.params['topic'] || 'index'
117
- this.content.scrollTop = 0
118
- }
119
- }
120
-
121
- gotoTop(e: Event) {
122
- this.content.scrollTop = 0
123
-
124
- e.stopPropagation()
125
- }
126
- }
@@ -1,57 +0,0 @@
1
- body {
2
- --help-panel-background-color: var(--theme-white-color);
3
- --help-panel-width: 450px;
4
- --help-panel-margin: 0;
5
- --help-panel-padding: var(--padding-default) 0 var(--padding-default) var(--padding-wide);
6
- --help-panel-border-raidus: 9px;
7
- --help-panel-box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.15);
8
- --help-panel-border: 2px solid var(--primary-color);
9
-
10
- --help-panel-color: var(--primary-text-color);
11
-
12
- --help-panel-title-margin: var(--margin-default) 0 var(--margin-narrow) 0;
13
- --help-panel-title-padding: 0;
14
- --help-panel-title-background-color: rgba(var(--primary-color-rgb), 0.1);
15
- --help-panel-h1-title-font-size: 1.6em;
16
- --help-panel-h1-title-color: var(--primary-color);
17
- --help-panel-h2-title-font-size: 1.3em;
18
- --help-panel-h2-title-color: var(--secondary-color);
19
- --help-panel-h3-title-font-size: 1.1em;
20
- --help-panel-h3-title-color: var(--secondary-text-color);
21
-
22
- --help-panel-content-padding: var(--padding-default) var(--padding-wide);
23
- --help-panel-paragraph-margin: 0 0 var(--margin-default) 0;
24
- --help-panel-font-size: 0.9em;
25
- --help-panel-content-font-size: 0.8em;
26
-
27
- --help-panel-focusBox-padding: var(--padding-narrow) var(--padding-default);
28
- --help-panel-focusBox-border: 1px solid rgba(0, 0, 0, 0.2);
29
- --help-panel-focusBox-border-radius: var(--border-radius);
30
- --help-panel-focusBox-background-color: rgba(0, 0, 0, 0.2);
31
- --help-panel-focusBox-color: #ffe393;
32
-
33
- --help-panel-a-color: var(--secondary-color);
34
- --help-panel-a-icon-size: 1.3em;
35
-
36
- --help-icon-color: var(--secondary-color);
37
- --help-icon-hover-color: var(--primary-color);
38
- --help-icon-size: 18px;
39
- --help-icon-opacity: 0.4;
40
- --help-icon-hover-opacity: 1;
41
-
42
- --help-navigation-padding: 0;
43
- --help-navigation-bottom: 1px solid rgba(var(--primary-color-rgb), 0.5);
44
- --help-navigation-icon-padding: 0;
45
- --help-navigation-icon-border: 1px solid rgba(0, 0, 0, 0.1);
46
- }
47
-
48
- @media only screen and (max-width: 460px) {
49
- body {
50
- --help-panel-width: 100vw;
51
- --help-panel-border-raidus: 0;
52
- --help-panel-border: none;
53
- --help-panel-box-shadow: none;
54
-
55
- --help-panel-title-padding: 0 0 0 var(--padding-wide);
56
- }
57
- }
@@ -1,217 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/markdown/ox-markdown.js'
3
-
4
- import { css, html, LitElement, PropertyValues } from 'lit'
5
- import { customElement, property, query, state } from 'lit/decorators.js'
6
- import { connect } from 'pwa-helpers/connect-mixin.js'
7
-
8
- import Headroom from '@operato/headroom'
9
- import { closeOverlay } from '@operato/layout'
10
- import { navigate, store } from '@operato/shell'
11
- import { HeadroomStyles, ScrollbarStyles } from '@operato/styles'
12
-
13
- @customElement('ox-help-panel')
14
- class HelpPanel extends connect(store)(LitElement) {
15
- static styles = [
16
- ScrollbarStyles,
17
- HeadroomStyles,
18
- css`
19
- :host {
20
- display: flex;
21
- flex-direction: column;
22
- background-color: var(--help-panel-background-color);
23
-
24
- position: relative;
25
- width: var(--help-panel-width);
26
- max-height: 90%;
27
- border-radius: var(--help-panel-border-raidus);
28
- border: var(--help-panel-border);
29
- box-shadow: var(--help-panel-box-shadow);
30
- color: var(--help-panel-color);
31
- margin: 4px;
32
-
33
- overflow: hidden;
34
-
35
- --md-icon-size: 24px;
36
- }
37
-
38
- :host(:focus) {
39
- outline: none;
40
- }
41
-
42
- #navigation {
43
- display: flex;
44
- position: absolute;
45
- width: 100%;
46
- padding: var(--help-navigation-padding);
47
- border-bottom: var(--help-navigation-bottom);
48
- background-color: var(--md-sys-color-surface);
49
- }
50
-
51
- #navigation md-icon {
52
- padding: var(--help-navigation-icon-padding, var(--padding-default));
53
- border-right: var(--help-navigation-icon-border);
54
- cursor: pointer;
55
- color: var(--help-icon-color);
56
- }
57
-
58
- #close {
59
- margin-left: auto;
60
- border-right: 0;
61
- }
62
-
63
- #content {
64
- flex: 1;
65
- overflow: auto;
66
- padding: var(--help-panel-content-padding);
67
- margin: var(--help-panel-margin);
68
- }
69
-
70
- #upward {
71
- --md-icon-size: 26px;
72
- position: absolute;
73
- bottom: var(--data-list-fab-position-vertical);
74
- right: var(--data-list-fab-position-horizontal);
75
- background-color: rgba(255, 255, 255, 0.7);
76
- border-radius: 20px;
77
- color: var(--data-list-fab-color);
78
- box-shadow: var(--data-list-fab-shadow);
79
- padding: 7px;
80
- }
81
-
82
- md-icon[filled] {
83
- font-variation-settings: 'FILL' 1;
84
- }
85
-
86
- @media screen and (max-width: 460px) {
87
- :host {
88
- height: 100%;
89
- max-height: 100%;
90
- margin: 0;
91
- }
92
- }
93
- `
94
- ]
95
-
96
- @property({ type: String }) topic!: string
97
- @property({ type: Boolean }) showGotoTop: boolean = false
98
-
99
- @state() historyIndex: number = -1
100
- @state() history: string[] = []
101
-
102
- @query('#content') content!: HTMLElement
103
- @query('#navigation') navigation!: HTMLElement
104
-
105
- render() {
106
- const src = this.topic && `/helps/${this.topic}.md`
107
-
108
- return html`
109
- <div id="navigation">
110
- <md-icon filled @click=${() => this.goHome()} ?disabled=${this.history[0] === this.history[this.historyIndex]}>
111
- home
112
- </md-icon>
113
- <md-icon filled @click=${() => this.historyBack()} ?disabled=${this.historyIndex < 1}>
114
- keyboard_arrow_left
115
- </md-icon>
116
- <md-icon filled @click=${() => this.historyForward()} ?disabled=${this.historyIndex >= this.history.length - 1}>
117
- keyboard_arrow_right
118
- </md-icon>
119
- <md-icon filled @click=${() => navigate(`help?topic=${this.topic}`)}> open_in_new </md-icon>
120
- <md-icon filled id="close" @click=${() => closeOverlay('help')}> close </md-icon>
121
- </div>
122
-
123
- ${!this.showGotoTop
124
- ? html``
125
- : html` <md-icon filled id="upward" @click=${(e: Event) => this.gotoTop(e)}>arrow_upward</md-icon> `}
126
- <ox-markdown id="content" .src=${src}></ox-markdown>
127
- `
128
- }
129
-
130
- async firstUpdated() {
131
- this.setupRouter()
132
-
133
- this.content.addEventListener('scroll', (e: Event) => {
134
- this.showGotoTop = (e.target as HTMLElement)?.scrollTop !== 0
135
- })
136
-
137
- await this.requestUpdate()
138
-
139
- var originPaddingTop = parseFloat(getComputedStyle(this.content, null).getPropertyValue('padding-top'))
140
- this.content.style.paddingTop = this.navigation.clientHeight + originPaddingTop + 'px'
141
-
142
- var headroom = new Headroom(this.navigation, {
143
- scroller: this.content
144
- })
145
- headroom.init()
146
- }
147
-
148
- async updated(changes: PropertyValues<this>) {
149
- if (changes.has('topic')) {
150
- if (this.historyIndex === -1) {
151
- this.history = [this.topic]
152
- this.historyIndex = 0
153
- }
154
- }
155
-
156
- if (changes.has('historyIndex')) {
157
- this.topic = this.history[this.historyIndex]
158
- this.content.scrollTop = 0
159
- }
160
- }
161
-
162
- setupRouter() {
163
- this.addEventListener('click', e => {
164
- if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey) {
165
- return
166
- }
167
-
168
- const anchor = e.composedPath().filter(n => (n as HTMLElement).tagName === 'A')[0] as HTMLAnchorElement
169
- if (!anchor || anchor.target || anchor.hasAttribute('download') || anchor.getAttribute('rel') === 'external') {
170
- return
171
- }
172
-
173
- const href = anchor.href
174
- const newUrl = new URL(href, document.baseURI)
175
- if (!href || href.indexOf('mailto:') !== -1 || newUrl.origin !== location.origin) {
176
- return
177
- }
178
-
179
- e.preventDefault()
180
- e.stopPropagation()
181
-
182
- const pathname = newUrl.pathname
183
- const topic = newUrl.searchParams?.get('topic')
184
- if (pathname.endsWith('/help') && topic) {
185
- this.history = [...this.history.slice(0, this.historyIndex + 1), topic]
186
- this.historyIndex++
187
- this.topic = topic
188
- } else {
189
- navigate(href)
190
- }
191
-
192
- return
193
- })
194
- }
195
-
196
- gotoTop(e: Event) {
197
- this.content.scrollTop = 0
198
-
199
- e.stopPropagation()
200
- }
201
-
202
- goHome() {
203
- if (!this.history?.[0] || this.history[0] == this.topic) {
204
- return
205
- }
206
- this.history.push(this.history[0])
207
- this.historyIndex = this.history.length - 1
208
- }
209
-
210
- historyBack() {
211
- this.historyIndex > 0 && this.historyIndex--
212
- }
213
-
214
- historyForward() {
215
- this.history && this.historyIndex < this.history.length - 1 && this.historyIndex++
216
- }
217
- }
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "noEmitOnError": true,
7
- "lib": ["es2017", "dom"],
8
- "strict": true,
9
- "esModuleInterop": false,
10
- "allowSyntheticDefaultImports": true,
11
- "experimentalDecorators": true,
12
- "useDefineForClassFields": false,
13
- "importHelpers": true,
14
- "outDir": "dist",
15
- "sourceMap": true,
16
- "inlineSources": true,
17
- "rootDir": "./",
18
- "declaration": true,
19
- "incremental": true,
20
- "skipLibCheck": true,
21
- "types": ["node", "mocha"]
22
- },
23
- "include": ["**/*.ts"]
24
- }
@@ -1,27 +0,0 @@
1
- // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
-
3
- /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
5
-
6
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
- open: '/demo/',
8
- /** Use regular watch mode if HMR is not enabled. */
9
- watch: !hmr,
10
- /** Resolve bare module imports */
11
- nodeResolve: {
12
- exportConditions: ['browser', 'development'],
13
- },
14
-
15
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
- // esbuildTarget: 'auto'
17
-
18
- /** Set appIndex to enable SPA routing */
19
- // appIndex: 'demo/index.html',
20
-
21
- plugins: [
22
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
23
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
24
- ],
25
-
26
- // See documentation for all available options
27
- });