@operato/context 2.0.0-alpha.13 → 2.0.0-alpha.131
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/CHANGELOG.md +708 -0
- package/demo/index.html +13 -2
- package/dist/src/layouts/ox-context-page-toolbar.d.ts +9 -4
- package/dist/src/layouts/ox-context-page-toolbar.js +30 -14
- package/dist/src/layouts/ox-context-page-toolbar.js.map +1 -1
- package/dist/src/layouts/ox-context-toolbar.d.ts +5 -3
- package/dist/src/layouts/ox-context-toolbar.js +138 -73
- package/dist/src/layouts/ox-context-toolbar.js.map +1 -1
- package/dist/src/styles/ox-context-toolbar-overlay-style.js +2 -2
- package/dist/src/styles/ox-context-toolbar-overlay-style.js.map +1 -1
- package/dist/src/tools/ox-page-action-context-bar.d.ts +14 -6
- package/dist/src/tools/ox-page-action-context-bar.js +84 -68
- package/dist/src/tools/ox-page-action-context-bar.js.map +1 -1
- package/dist/src/tools/ox-page-action-overlay-template.d.ts +3 -2
- package/dist/src/tools/ox-page-action-overlay-template.js +38 -39
- package/dist/src/tools/ox-page-action-overlay-template.js.map +1 -1
- package/dist/src/tools/ox-page-title-bar.d.ts +2 -2
- package/dist/src/tools/ox-page-title-bar.js +6 -8
- package/dist/src/tools/ox-page-title-bar.js.map +1 -1
- package/dist/src/tools/ox-title-bar.d.ts +2 -2
- package/dist/src/tools/ox-title-bar.js +6 -8
- package/dist/src/tools/ox-title-bar.js.map +1 -1
- package/dist/stories/ox-context-page-toolbar-select-buttons.stories.d.ts +25 -0
- package/dist/stories/ox-context-page-toolbar-select-buttons.stories.js +127 -0
- package/dist/stories/ox-context-page-toolbar-select-buttons.stories.js.map +1 -0
- package/dist/stories/ox-context-page-toolbar-select.stories.d.ts +24 -0
- package/dist/stories/ox-context-page-toolbar-select.stories.js +94 -0
- package/dist/stories/ox-context-page-toolbar-select.stories.js.map +1 -0
- package/dist/stories/ox-context-page-toolbar.stories.d.ts +24 -0
- package/dist/stories/ox-context-page-toolbar.stories.js +93 -0
- package/dist/stories/ox-context-page-toolbar.stories.js.map +1 -0
- package/dist/stories/ox-context-toolbar-complex.stories.d.ts +19 -0
- package/dist/stories/ox-context-toolbar-complex.stories.js +150 -0
- package/dist/stories/ox-context-toolbar-complex.stories.js.map +1 -0
- package/dist/stories/ox-context-toolbar-cooldown.stories.d.ts +18 -0
- package/dist/stories/ox-context-toolbar-cooldown.stories.js +100 -0
- package/dist/stories/ox-context-toolbar-cooldown.stories.js.map +1 -0
- package/dist/stories/ox-context-toolbar-empty.stories.d.ts +18 -0
- package/dist/stories/ox-context-toolbar-empty.stories.js +79 -0
- package/dist/stories/ox-context-toolbar-empty.stories.js.map +1 -0
- package/dist/stories/ox-context-toolbar-overflow.stories.d.ts +19 -0
- package/dist/stories/ox-context-toolbar-overflow.stories.js +131 -0
- package/dist/stories/ox-context-toolbar-overflow.stories.js.map +1 -0
- package/dist/stories/ox-context-toolbar.stories.d.ts +19 -0
- package/dist/stories/ox-context-toolbar.stories.js +188 -0
- package/dist/stories/ox-context-toolbar.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -20
- package/src/layouts/ox-context-page-toolbar.ts +33 -14
- package/src/layouts/ox-context-toolbar.ts +139 -70
- package/src/styles/ox-context-toolbar-overlay-style.ts +2 -2
- package/src/tools/ox-page-action-context-bar.ts +96 -69
- package/src/tools/ox-page-action-overlay-template.ts +50 -51
- package/src/tools/ox-page-title-bar.ts +6 -8
- package/src/tools/ox-title-bar.ts +6 -8
- package/stories/ox-context-page-toolbar-select-buttons.stories.ts +141 -0
- package/stories/ox-context-page-toolbar-select.stories.ts +108 -0
- package/stories/ox-context-page-toolbar.stories.ts +107 -0
- package/stories/ox-context-toolbar-complex.stories.ts +162 -0
- package/stories/ox-context-toolbar-cooldown.stories.ts +112 -0
- package/stories/ox-context-toolbar-empty.stories.ts +92 -0
- package/stories/ox-context-toolbar-overflow.stories.ts +143 -0
- package/stories/ox-context-toolbar.stories.ts +200 -0
- package/themes/app-theme.css +161 -0
- package/themes/context-theme.css +74 -0
- package/themes/material-theme.css +88 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '@material/
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
2
|
|
|
3
|
-
import { css, html, LitElement, nothing } from 'lit'
|
|
3
|
+
import { css, html, LitElement, nothing, PropertyValues } from 'lit'
|
|
4
4
|
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
5
5
|
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
6
6
|
|
|
@@ -14,77 +14,106 @@ export class ContextToolbar extends connect(store)(LitElement) {
|
|
|
14
14
|
css`
|
|
15
15
|
:host {
|
|
16
16
|
display: flex;
|
|
17
|
-
position: relative;
|
|
18
17
|
|
|
19
18
|
background-color: var(--context-toolbar-background-color);
|
|
20
|
-
justify-content: space-between;
|
|
21
19
|
box-shadow: var(--context-toolbar-shadow-line);
|
|
22
|
-
}
|
|
23
|
-
#front-end {
|
|
24
|
-
padding-left: var(--context-toolbar-side-padding);
|
|
25
|
-
}
|
|
26
|
-
#rear-end {
|
|
27
|
-
padding-right: var(--context-toolbar-side-padding);
|
|
28
|
-
}
|
|
29
|
-
#front-end mwc-icon,
|
|
30
|
-
#front mwc-icon {
|
|
31
|
-
background-color: var(--context-toolbar-function-button-background-color);
|
|
32
|
-
border: var(--context-toolbar-function-button-border);
|
|
33
|
-
height: var(--context-toolbar-function-button-height);
|
|
34
|
-
margin: var(--context-toolbar-button-margin);
|
|
35
|
-
padding: var(--context-toolbar-function-button-padding);
|
|
36
|
-
color: var(--context-toolbar-function-button-color);
|
|
37
|
-
line-height: var(--context-toolbar-function-button-lineheight);
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
}
|
|
40
|
-
#front-end mwc-icon:first-child,
|
|
41
|
-
#front mwc-icon:first-child {
|
|
42
|
-
border-top-left-radius: var(--context-toolbar-function-button-radius);
|
|
43
|
-
border-bottom-left-radius: var(--context-toolbar-function-button-radius);
|
|
44
|
-
}
|
|
45
|
-
#front-end mwc-icon:last-child,
|
|
46
|
-
#front mwc-icon:last-child {
|
|
47
|
-
border-top-right-radius: var(--context-toolbar-function-button-radius);
|
|
48
|
-
border-bottom-right-radius: var(--context-toolbar-function-button-radius);
|
|
49
|
-
}
|
|
50
20
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
#front-end mwc-icon:hover {
|
|
55
|
-
background-color: var(--context-toolbar-function-button-background-color);
|
|
56
|
-
}
|
|
57
|
-
#front mwc-icon:hover {
|
|
58
|
-
background-color: var(--context-toolbar-function-button-hover-background-color);
|
|
21
|
+
padding: 0;
|
|
22
|
+
|
|
23
|
+
--md-icon-size: 20px;
|
|
59
24
|
}
|
|
60
25
|
|
|
61
|
-
|
|
26
|
+
div[container] {
|
|
62
27
|
flex: 1;
|
|
63
|
-
align-items: center;
|
|
64
|
-
justify-content: end;
|
|
65
|
-
}
|
|
66
28
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
margin: var(--context-toolbar-button-margin);
|
|
73
|
-
}
|
|
74
|
-
#rear-end {
|
|
75
|
-
align-items: start;
|
|
76
|
-
}
|
|
29
|
+
display: flex;
|
|
30
|
+
position: relative;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
|
|
33
|
+
justify-content: space-between;
|
|
77
34
|
|
|
78
|
-
|
|
79
|
-
|
|
35
|
+
gap: var(--padding-narrow);
|
|
36
|
+
padding: 6px 10px;
|
|
37
|
+
|
|
38
|
+
&:not(:has(> *)) {
|
|
39
|
+
padding: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
div {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: row;
|
|
45
|
+
flex-wrap: nowrap;
|
|
46
|
+
|
|
47
|
+
align-items: center;
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
padding: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#front-end md-icon,
|
|
53
|
+
#front md-icon {
|
|
54
|
+
background-color: var(--context-toolbar-function-button-background-color);
|
|
55
|
+
border: var(--context-toolbar-function-button-border);
|
|
56
|
+
color: var(--context-toolbar-function-button-color);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#front-end md-icon {
|
|
60
|
+
background-color: var(--primary-color);
|
|
61
|
+
}
|
|
62
|
+
#front-end md-icon:hover {
|
|
63
|
+
background-color: var(--context-toolbar-function-button-background-color);
|
|
64
|
+
}
|
|
65
|
+
#front md-icon:hover {
|
|
66
|
+
background-color: var(--context-toolbar-function-button-hover-background-color);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
md-icon {
|
|
70
|
+
background-color: var(--button-background-color, #fafbfc);
|
|
71
|
+
border: 1px solid rgba(var(--primary-color-rgb), 0.5);
|
|
72
|
+
border-radius: var(--button-border-radius);
|
|
73
|
+
padding: var(--iconbtn-padding, 2px);
|
|
74
|
+
|
|
75
|
+
color: var(--primary-color);
|
|
76
|
+
|
|
77
|
+
&:hover {
|
|
78
|
+
background-color: var(--primary-color);
|
|
79
|
+
|
|
80
|
+
color: var(--theme-white-color);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
div md-icon {
|
|
85
|
+
border-radius: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
div md-icon:first-child {
|
|
89
|
+
border-top-left-radius: var(--context-toolbar-function-button-radius);
|
|
90
|
+
border-bottom-left-radius: var(--context-toolbar-function-button-radius);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
div md-icon:last-child {
|
|
94
|
+
border-top-right-radius: var(--context-toolbar-function-button-radius);
|
|
95
|
+
border-bottom-right-radius: var(--context-toolbar-function-button-radius);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#center {
|
|
99
|
+
flex: 1;
|
|
100
|
+
justify-content: end;
|
|
101
|
+
}
|
|
80
102
|
}
|
|
81
103
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
104
|
+
@media only screen and (max-width: 460px) {
|
|
105
|
+
div[container] {
|
|
106
|
+
padding: 0;
|
|
107
|
+
gap: 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
div[container] div md-icon {
|
|
111
|
+
border-radius: 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
div[container] div md-icon:not(:last-child) {
|
|
115
|
+
border-right-width: 0;
|
|
116
|
+
}
|
|
88
117
|
}
|
|
89
118
|
`
|
|
90
119
|
]
|
|
@@ -93,6 +122,8 @@ export class ContextToolbar extends connect(store)(LitElement) {
|
|
|
93
122
|
@state() private context: any
|
|
94
123
|
@state() private tools?: any[]
|
|
95
124
|
|
|
125
|
+
@query('[container]') private container!: HTMLDivElement
|
|
126
|
+
|
|
96
127
|
render() {
|
|
97
128
|
if (this.context.toolbar === false) {
|
|
98
129
|
return nothing
|
|
@@ -112,20 +143,58 @@ export class ContextToolbar extends connect(store)(LitElement) {
|
|
|
112
143
|
let rearEndTools = tools.filter(tool => tool.position == TOOL_POSITION.REAR_END)
|
|
113
144
|
|
|
114
145
|
return html`
|
|
115
|
-
<div
|
|
146
|
+
<div container>
|
|
147
|
+
${frontEndTools.length > 0
|
|
148
|
+
? html`<div id="front-end">${frontEndTools.map(tool => html` ${tool.template} `)}</div>`
|
|
149
|
+
: nothing}
|
|
150
|
+
${frontTools.length > 0
|
|
151
|
+
? html`<div id="front">${frontTools.map(tool => html` ${tool.template} `)}</div>`
|
|
152
|
+
: nothing}
|
|
153
|
+
${centerTools.length > 0
|
|
154
|
+
? html`<div id="center">${centerTools.map(tool => html` ${tool.template} `)}</div>`
|
|
155
|
+
: nothing}
|
|
156
|
+
${rearTools.length > 0
|
|
157
|
+
? html`<div id="rear">${rearTools.map(tool => html` ${tool.template} `)}</div>`
|
|
158
|
+
: nothing}
|
|
159
|
+
${rearEndTools.length > 0
|
|
160
|
+
? html`<div id="rear-end">${rearEndTools.map(tool => html` ${tool.template} `)}</div>`
|
|
161
|
+
: nothing}
|
|
162
|
+
</div>
|
|
163
|
+
`
|
|
164
|
+
}
|
|
116
165
|
|
|
117
|
-
|
|
166
|
+
updated(changes: PropertyValues<this>) {
|
|
167
|
+
requestAnimationFrame(() => {
|
|
168
|
+
/*
|
|
169
|
+
하위 엘리먼트들이 실제로 보일 필요가 없을 때는, 이 엘리먼트도 숨김 처리함.
|
|
170
|
+
&:not(:has(> *)) 처리로 모두 해결되지 않으므로, 로직 처리로 보완함.
|
|
171
|
+
&:not(:has(> *)) 가 필요없으나, 남겨 두었음.
|
|
172
|
+
*/
|
|
173
|
+
if (!this.container) {
|
|
174
|
+
return
|
|
175
|
+
}
|
|
118
176
|
|
|
119
|
-
|
|
177
|
+
const children = this.container.querySelectorAll('*')
|
|
120
178
|
|
|
121
|
-
|
|
179
|
+
let zero = true
|
|
122
180
|
|
|
123
|
-
|
|
124
|
-
|
|
181
|
+
// 모든 하위 엘리먼트의 높이를 확인
|
|
182
|
+
for (const child of Array.from(children)) {
|
|
183
|
+
if ((child as HTMLElement).offsetHeight !== 0) {
|
|
184
|
+
zero = false
|
|
185
|
+
break
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// 모든 하위 엘리먼트의 높이가 0이면 부모 엘리먼트의 display를 none으로 변경
|
|
190
|
+
this.container.style.padding = zero ? '0' : 'revert-layer'
|
|
191
|
+
})
|
|
125
192
|
}
|
|
126
193
|
|
|
127
194
|
stateChanged(state: any) {
|
|
128
|
-
|
|
129
|
-
|
|
195
|
+
if (state.context) {
|
|
196
|
+
this.tools = state.context.tools || []
|
|
197
|
+
this.context = state.route.context || {}
|
|
198
|
+
}
|
|
130
199
|
}
|
|
131
200
|
}
|
|
@@ -23,7 +23,7 @@ export const ContextToolbarOverlayStyle = css`
|
|
|
23
23
|
padding: var(--context-ui-list-padding);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
li >
|
|
26
|
+
li > md-icon {
|
|
27
27
|
font-size: 1em;
|
|
28
28
|
|
|
29
29
|
padding: var(--context-ui-padding);
|
|
@@ -37,7 +37,7 @@ export const ContextToolbarOverlayStyle = css`
|
|
|
37
37
|
color: var(--context-ui-list-color);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
li:hover
|
|
40
|
+
li:hover md-icon,
|
|
41
41
|
li:hover span {
|
|
42
42
|
color: #fff;
|
|
43
43
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import '@material/
|
|
2
|
-
import '@material/
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
|
+
import '@material/web/chips/assist-chip.js'
|
|
3
3
|
import './ox-page-action-overlay-template.js'
|
|
4
4
|
|
|
5
|
-
import { css, html, LitElement, PropertyValues } from 'lit'
|
|
5
|
+
import { css, html, LitElement, nothing, PropertyValues } from 'lit'
|
|
6
6
|
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
7
7
|
import throttle from 'lodash-es/throttle'
|
|
8
8
|
import { connect } from 'pwa-helpers/connect-mixin'
|
|
@@ -10,63 +10,69 @@ import { connect } from 'pwa-helpers/connect-mixin'
|
|
|
10
10
|
import { openOverlay } from '@operato/layout'
|
|
11
11
|
import { store } from '@operato/shell'
|
|
12
12
|
import { sleep } from '@operato/utils'
|
|
13
|
+
import { ButtonContainerStyles } from '@operato/styles'
|
|
13
14
|
|
|
14
15
|
@customElement('ox-page-action-context-bar')
|
|
15
16
|
export class PageActionContextBar extends connect(store)(LitElement) {
|
|
16
17
|
static get styles() {
|
|
17
18
|
return [
|
|
19
|
+
ButtonContainerStyles,
|
|
18
20
|
css`
|
|
19
21
|
:host {
|
|
20
22
|
display: flex;
|
|
21
|
-
overflow: hidden;
|
|
22
|
-
position: relative;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
:host *:focus {
|
|
26
26
|
outline: none;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
margin: var(--context-action-bar-button-margin);
|
|
32
|
-
border-radius: var(--context-action-bar-more-button-border-radius);
|
|
33
|
-
}
|
|
29
|
+
[container] {
|
|
30
|
+
flex: 1;
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
display: flex;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
gap: var(--padding-narrow);
|
|
35
|
+
padding: 2px; /* only for button shadow */
|
|
36
|
+
align-items: center;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
[more] {
|
|
41
40
|
position: absolute;
|
|
42
41
|
top: 0;
|
|
43
|
-
right:
|
|
42
|
+
right: 0;
|
|
44
43
|
background-color: var(--context-action-bar-more-button-background-color);
|
|
45
44
|
box-shadow: -2px 0px 2px 1px rgba(0, 0, 0, 0.2);
|
|
46
45
|
padding: var(--context-action-bar-more-button-padding);
|
|
47
46
|
color: var(--context-action-bar-more-button-color);
|
|
47
|
+
padding: 11px 10px;
|
|
48
48
|
font-size: 2rem;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
background-color: var(--
|
|
51
|
+
select {
|
|
52
|
+
background-color: var(--button-background-color, #fafbfc);
|
|
53
53
|
border: 1px solid rgba(var(--primary-color-rgb), 0.5);
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
border-radius: var(--button-border-radius);
|
|
55
|
+
padding: 0 var(--padding-narrow);
|
|
56
|
+
|
|
57
|
+
font-size: var(--fontsize-default);
|
|
58
|
+
color: var(--secondary-color);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
md-icon[working] {
|
|
62
|
+
animation: rotate 1s linear infinite;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
md-assist-chip[icon-only] {
|
|
66
|
+
--md-assist-chip-trailing-space: 0;
|
|
56
67
|
}
|
|
57
68
|
|
|
58
69
|
@media screen and (max-width: 460px) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
--mdc-shape-small: var(--context-action-bar-more-button-border-radius);
|
|
70
|
+
:host {
|
|
71
|
+
gap: 0;
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
[more] {
|
|
65
|
-
|
|
66
|
-
margin-top: -10px;
|
|
67
|
-
right: 0px;
|
|
68
|
-
padding: var(--padding-default);
|
|
69
|
-
font-size: 2rem;
|
|
75
|
+
margin-top: -7px;
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
|
|
@@ -82,7 +88,15 @@ export class PageActionContextBar extends connect(store)(LitElement) {
|
|
|
82
88
|
]
|
|
83
89
|
}
|
|
84
90
|
|
|
85
|
-
@
|
|
91
|
+
@property({ type: Array }) actions: {
|
|
92
|
+
title: string
|
|
93
|
+
action: () => void
|
|
94
|
+
icon: string
|
|
95
|
+
type: string
|
|
96
|
+
select: string[]
|
|
97
|
+
href?: string
|
|
98
|
+
emphasis?: boolean
|
|
99
|
+
}[] = []
|
|
86
100
|
@state() private overflown: boolean = false
|
|
87
101
|
|
|
88
102
|
private overflownUpdaterThrottle: any
|
|
@@ -113,57 +127,66 @@ export class PageActionContextBar extends connect(store)(LitElement) {
|
|
|
113
127
|
}
|
|
114
128
|
|
|
115
129
|
render() {
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
130
|
+
return this.actions.length > 0
|
|
131
|
+
? html`
|
|
132
|
+
<div container>
|
|
133
|
+
${this.renderActions()}
|
|
134
|
+
${this.overflown ? html` <md-icon more @click=${this.showMore.bind(this)}>more_horiz</md-icon> ` : html``}
|
|
135
|
+
</div>
|
|
136
|
+
`
|
|
137
|
+
: nothing
|
|
120
138
|
}
|
|
121
139
|
|
|
122
140
|
renderActions() {
|
|
123
141
|
return html`
|
|
124
142
|
${this.actions.map(($action, idx) => {
|
|
125
143
|
let { type, title, icon, action, select, href, emphasis } = $action as any
|
|
126
|
-
let {
|
|
144
|
+
let { raised, danger } = emphasis || {}
|
|
127
145
|
|
|
128
146
|
return type == 'text'
|
|
129
147
|
? html` <span @click=${action}>${title}</span> `
|
|
130
148
|
: type == 'select' || (select && select.length > 0)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
149
|
+
? html`
|
|
150
|
+
<select @change=${action}>
|
|
151
|
+
${select.map((option: any) => html` <option>${option}</option> `)}
|
|
152
|
+
</select>
|
|
153
|
+
`
|
|
154
|
+
: type == 'link'
|
|
155
|
+
? html` <a href=${href}>${title}</a> `
|
|
156
|
+
: html`
|
|
157
|
+
<md-assist-chip
|
|
158
|
+
?icon-only=${type == 'icon' || !title}
|
|
159
|
+
?elevated=${raised}
|
|
160
|
+
?danger=${danger}
|
|
161
|
+
label=${title}
|
|
162
|
+
@click=${async (e: MouseEvent) => {
|
|
163
|
+
/* all actions should be bloked for a second */
|
|
164
|
+
const button = e.currentTarget as any
|
|
165
|
+
const iconElement = button.querySelector('[slot="icon"]')
|
|
166
|
+
if (iconElement) {
|
|
167
|
+
iconElement.textContent = 'refresh'
|
|
168
|
+
iconElement.setAttribute('working', true)
|
|
169
|
+
}
|
|
170
|
+
button.disabled = true
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
await action()
|
|
174
|
+
} finally {
|
|
175
|
+
await sleep(1000) /* waiting for additionla 1 second */
|
|
176
|
+
|
|
177
|
+
/* because icon can be changed after sleep, don't use closure 'icon'. */
|
|
178
|
+
if (iconElement) {
|
|
179
|
+
iconElement.textContent = this.actions[idx]?.icon
|
|
180
|
+
iconElement.removeAttribute('working')
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
button.disabled = false
|
|
184
|
+
}
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
<md-icon slot="icon">${icon || 'done_all'}</md-icon>
|
|
188
|
+
</md-assist-chip>
|
|
189
|
+
`
|
|
167
190
|
})}
|
|
168
191
|
`
|
|
169
192
|
}
|
|
@@ -175,7 +198,11 @@ export class PageActionContextBar extends connect(store)(LitElement) {
|
|
|
175
198
|
}
|
|
176
199
|
|
|
177
200
|
stateChanged(state: any) {
|
|
178
|
-
|
|
201
|
+
const { actions } = state.route?.context || {}
|
|
202
|
+
|
|
203
|
+
if (actions) {
|
|
204
|
+
this.actions = actions.filter((action: any) => !!action)
|
|
205
|
+
}
|
|
179
206
|
}
|
|
180
207
|
|
|
181
208
|
showMore() {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import '@material/
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
|
+
import '@material/web/chips/assist-chip.js'
|
|
2
3
|
|
|
3
4
|
import { css, html, LitElement } from 'lit'
|
|
4
5
|
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
5
6
|
import { connect } from 'pwa-helpers'
|
|
6
7
|
|
|
7
8
|
import { store } from '@operato/shell'
|
|
8
|
-
import { ScrollbarStyles } from '@operato/styles'
|
|
9
|
+
import { ButtonContainerStyles, ScrollbarStyles } from '@operato/styles'
|
|
9
10
|
import { sleep } from '@operato/utils'
|
|
10
11
|
|
|
11
12
|
import { ContextToolbarOverlayStyle } from '../styles/ox-context-toolbar-overlay-style.js'
|
|
@@ -15,32 +16,26 @@ export class PageActionOverlayTemplate extends connect(store)(LitElement) {
|
|
|
15
16
|
static get styles() {
|
|
16
17
|
return [
|
|
17
18
|
ScrollbarStyles,
|
|
19
|
+
ButtonContainerStyles,
|
|
18
20
|
ContextToolbarOverlayStyle,
|
|
19
21
|
css`
|
|
20
22
|
:host {
|
|
21
23
|
display: flex;
|
|
22
24
|
flex-wrap: wrap;
|
|
23
|
-
gap: var(--
|
|
25
|
+
gap: var(--padding-narrow);
|
|
26
|
+
align-items: center;
|
|
24
27
|
}
|
|
28
|
+
|
|
25
29
|
:host *:focus {
|
|
26
30
|
outline: none;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
border-radius: var(--context-action-bar-more-button-border-radius);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
[danger] {
|
|
35
|
-
--mdc-theme-primary: var(--mdc-danger-button-primary-color);
|
|
36
|
-
--mdc-button-outline-color: var(--mdc-danger-button-outline-color);
|
|
33
|
+
md-icon[working] {
|
|
34
|
+
animation: rotate 1s linear infinite;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
--mdc-button-horizontal-padding: var(--padding-default);
|
|
42
|
-
border-radius: 4px;
|
|
43
|
-
}
|
|
37
|
+
md-assist-chip[icon-only] {
|
|
38
|
+
--md-assist-chip-trailing-space: 0;
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
@keyframes rotate {
|
|
@@ -61,47 +56,51 @@ export class PageActionOverlayTemplate extends connect(store)(LitElement) {
|
|
|
61
56
|
return html`
|
|
62
57
|
${this.actions.map(($action, idx) => {
|
|
63
58
|
let { type, title, icon, action, select, href, emphasis } = $action as any
|
|
64
|
-
let {
|
|
59
|
+
let { raised, danger } = emphasis || {}
|
|
65
60
|
|
|
66
61
|
return type == 'text'
|
|
67
62
|
? html` <span>${title}</span> `
|
|
68
63
|
: type == 'select' || (select && select.length > 0)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
64
|
+
? html`
|
|
65
|
+
<select @change=${action}>
|
|
66
|
+
${select.map((option: any) => html` <option>${option}</option> `)}
|
|
67
|
+
</select>
|
|
68
|
+
`
|
|
69
|
+
: type == 'link'
|
|
70
|
+
? html` <a href=${href}>${title}</a> `
|
|
71
|
+
: html`
|
|
72
|
+
<md-assist-chip
|
|
73
|
+
?icon-only=${type == 'icon' || !title}
|
|
74
|
+
?elevated=${raised}
|
|
75
|
+
?danger=${danger}
|
|
76
|
+
label=${title}
|
|
77
|
+
@click=${async (e: MouseEvent) => {
|
|
78
|
+
/* all actions should be bloked for a second */
|
|
79
|
+
const button = e.currentTarget as any
|
|
80
|
+
const iconElement = button.querySelector('[slot="icon"]')
|
|
81
|
+
if (iconElement) {
|
|
82
|
+
iconElement.textContent = 'refresh'
|
|
83
|
+
iconElement.setAttribute('working', true)
|
|
84
|
+
}
|
|
85
|
+
button.disabled = true
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
button.disabled = false
|
|
96
|
-
/* because icon can be changed after sleep, don't use closure 'icon'. */
|
|
97
|
-
button.icon = this.actions[idx]?.icon || 'done_all'
|
|
98
|
-
button.removeAttribute('working')
|
|
87
|
+
try {
|
|
88
|
+
await action()
|
|
89
|
+
} finally {
|
|
90
|
+
await sleep(1000) /* waiting for additionla 1 second */
|
|
99
91
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
/* because icon can be changed after sleep, don't use closure 'icon'. */
|
|
93
|
+
if (iconElement) {
|
|
94
|
+
iconElement.textContent = this.actions[idx]?.icon
|
|
95
|
+
iconElement.removeAttribute('working')
|
|
96
|
+
}
|
|
97
|
+
button.disabled = false
|
|
98
|
+
}
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
<md-icon slot="icon">${icon || 'done_all'}</md-icon>
|
|
102
|
+
</md-assist-chip>
|
|
103
|
+
`
|
|
105
104
|
})}
|
|
106
105
|
`
|
|
107
106
|
}
|