@operato/layout 8.0.0-beta.0 → 8.0.0-beta.1

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,113 +0,0 @@
1
- import { REGISTER_NAVIGATION_CALLBACK, store } from '@operato/shell'
2
- import { UPDATE_VIEWPART, closeOverlay, openOverlay, openPopup, toggleOverlay } from './actions/layout'
3
-
4
- import layout from './reducers/layout'
5
- import { showSnackbar } from './actions/snackbar'
6
- import snackbar from './reducers/snackbar'
7
-
8
- store.addReducers({
9
- layout,
10
- snackbar
11
- })
12
-
13
- document.addEventListener('open-overlay', event => {
14
- const { name, options } = (event as CustomEvent).detail
15
- openOverlay(name, options)
16
- })
17
-
18
- document.addEventListener('close-overlay', event => {
19
- const { name } = (event as CustomEvent).detail
20
- closeOverlay(name)
21
- })
22
-
23
- document.addEventListener('toggle-overlay', event => {
24
- const { name, options } = (event as CustomEvent).detail
25
- toggleOverlay(name, options)
26
- })
27
-
28
- document.addEventListener('open-popup', event => {
29
- const { template, options, callback } = (event as CustomEvent).detail
30
- var popup = openPopup(template, options)
31
- if (popup && callback) callback(popup)
32
- })
33
-
34
- document.addEventListener('notify', event => {
35
- let { message, level, ex = '', option = {} } = (event as CustomEvent).detail
36
-
37
- switch (level) {
38
- case 'error':
39
- console.error(message, ex)
40
- break
41
- case 'warn':
42
- console.warn(message, ex)
43
- break
44
- case 'info':
45
- console.info(message)
46
- break
47
- default:
48
- break
49
- }
50
-
51
- store.dispatch(
52
- showSnackbar(level, {
53
- message,
54
- ...(option as {
55
- action?: any
56
- timer?: number
57
- })
58
- }) as any
59
- )
60
- })
61
-
62
- /* overlay handling */
63
- var overlayStack: any[] = []
64
- function getLastSequence() {
65
- return overlayStack.length > 0 ? overlayStack[overlayStack.length - 1].overlay.sequence : -1
66
- }
67
-
68
- document.addEventListener('keydown', event => {
69
- if (overlayStack.length > 0 && (event.key === 'Escape' || event.key === 'Esc')) {
70
- history.state?.overlay?.escapable && history.back()
71
- }
72
- })
73
-
74
- const historyHandler = (location: string, event: Event) => {
75
- var navigated = event instanceof PopStateEvent
76
-
77
- var state = history.state
78
- var overlay = state?.overlay
79
- var sequence = overlay?.sequence || -1
80
-
81
- var lastSequence = getLastSequence()
82
-
83
- if (overlayStack.length > 0 && sequence < lastSequence) {
84
- /* overlay 관련 history가 아닌 경우. */
85
- do {
86
- let { overlay } = overlayStack.pop()
87
- store.dispatch({
88
- type: UPDATE_VIEWPART,
89
- name: overlay.name,
90
- override: { show: false }
91
- })
92
-
93
- lastSequence = getLastSequence()
94
- } while (sequence < lastSequence)
95
- }
96
-
97
- if (!navigated && overlay) {
98
- overlayStack.push({ ...state })
99
-
100
- store.dispatch({
101
- type: UPDATE_VIEWPART,
102
- name: overlay.name,
103
- override: { show: true }
104
- })
105
- }
106
- }
107
-
108
- store.dispatch({
109
- type: REGISTER_NAVIGATION_CALLBACK,
110
- callback: historyHandler
111
- })
112
-
113
- export default store
@@ -1,111 +0,0 @@
1
- import '@operato/popup/ox-floating-overlay.js'
2
- import '../components/ox-resize-splitter.js'
3
-
4
- import { css, html, LitElement } from 'lit'
5
- import { ifDefined } from 'lit/directives/if-defined.js'
6
- import { customElement, property, state } from 'lit/decorators.js'
7
- import { connect } from 'pwa-helpers/connect-mixin.js'
8
-
9
- import { ScrollbarStyles } from '@operato/styles'
10
-
11
- import { Viewpart, VIEWPART_LEVEL } from '../actions/layout.js'
12
- import store from '../initializer.js'
13
-
14
- @customElement('ox-aside-bar')
15
- class AsideBar extends connect(store)(LitElement) {
16
- static styles = [
17
- ScrollbarStyles,
18
- css`
19
- :host {
20
- display: flex;
21
- flex-flow: row-reverse nowrap;
22
- align-items: stretch;
23
-
24
- position: relative;
25
- }
26
-
27
- *[asidebar] {
28
- display: block;
29
- overflow-y: auto;
30
- }
31
- `
32
- ]
33
-
34
- @property({ type: Boolean, attribute: 'fullbleed' }) fullbleed: boolean = false
35
-
36
- @state() viewparts: { [name: string]: Viewpart } = {}
37
-
38
- private _startWidth: number = 0
39
-
40
- render() {
41
- var viewparts = this.viewparts
42
- var asidebars = Object.keys(viewparts)
43
- .map(name => {
44
- return {
45
- name,
46
- ...viewparts[name]
47
- }
48
- })
49
- .filter(viewpart => viewpart.position == 'asidebar' && (!this.fullbleed || viewpart.hovering))
50
-
51
- asidebars = [
52
- ...asidebars.filter(viewpart => viewpart.level == VIEWPART_LEVEL.TOPMOST),
53
- ...asidebars.filter(viewpart => viewpart.level !== VIEWPART_LEVEL.TOPMOST)
54
- ]
55
-
56
- return html`
57
- ${asidebars.map(asidebar =>
58
- !asidebar.show
59
- ? html``
60
- : asidebar.hovering
61
- ? html`
62
- <ox-floating-overlay
63
- .backdrop=${asidebar.backdrop}
64
- direction="left"
65
- .hovering=${asidebar.hovering}
66
- .name=${asidebar.name}
67
- .size=${asidebar.size}
68
- .title=${asidebar.title}
69
- .help=${asidebar.help}
70
- .closable=${asidebar.closable}
71
- .templateProperties=${asidebar.templateProperties}
72
- .historical=${true}
73
- .search=${asidebar.search}
74
- .filter=${asidebar.filter}
75
- z-index=${ifDefined(asidebar.zIndex)}
76
- >${asidebar.template}</ox-floating-overlay
77
- >
78
- `
79
- : html`
80
- <div asidebar>${asidebar.template}</div>
81
- ${asidebar.resizable
82
- ? html`
83
- <ox-resize-splitter
84
- @splitter-dragstart=${(e: CustomEvent) => this.resizeStart(e)}
85
- @splitter-drag=${(e: CustomEvent) => this.resizeDrag(e)}
86
- vertical
87
- ></ox-resize-splitter>
88
- `
89
- : html``}
90
- `
91
- )}
92
- `
93
- }
94
-
95
- resizeStart(e: CustomEvent) {
96
- this._startWidth = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement)?.offsetWidth
97
- }
98
-
99
- resizeDrag(e: CustomEvent) {
100
- var delta = e.detail
101
-
102
- var x = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement)?.children
103
- Array.from(x).forEach(ele => {
104
- ;(ele as HTMLElement).style.width = `${this._startWidth - delta.x}px`
105
- })
106
- }
107
-
108
- stateChanged(state: any) {
109
- this.viewparts = state.layout.viewparts || {}
110
- }
111
- }
@@ -1,112 +0,0 @@
1
- import '@operato/popup/ox-floating-overlay.js'
2
- import '../components/ox-resize-splitter.js'
3
-
4
- import { css, html, LitElement } from 'lit'
5
- import { ifDefined } from 'lit/directives/if-defined.js'
6
- import { customElement, property, state } from 'lit/decorators.js'
7
- import { connect } from 'pwa-helpers/connect-mixin.js'
8
-
9
- import { Viewpart, VIEWPART_LEVEL } from '../actions/layout.js'
10
- import store from '../initializer.js'
11
-
12
- @customElement('ox-footer-bar')
13
- class FooterBar extends connect(store)(LitElement) {
14
- static styles = [
15
- css`
16
- :host {
17
- display: flex;
18
- flex-flow: column-reverse nowrap;
19
- align-items: stretch;
20
- position: relative;
21
- }
22
-
23
- *[footerbar] {
24
- display: block;
25
- max-width: 100vw;
26
- }
27
-
28
- @media screen and (max-width: 460px) {
29
- :host {
30
- padding-bottom: 0;
31
- }
32
- }
33
- `
34
- ]
35
-
36
- @property({ type: Boolean, attribute: 'fullbleed' }) fullbleed: boolean = false
37
-
38
- @state() viewparts: { [name: string]: Viewpart } = {}
39
-
40
- private _startHeight: number = 0
41
-
42
- render() {
43
- var viewparts = this.viewparts
44
- var footerbars = Object.keys(viewparts)
45
- .map(name => {
46
- return {
47
- name,
48
- ...viewparts[name]
49
- }
50
- })
51
- .filter(viewpart => viewpart.position == 'footerbar' && (!this.fullbleed || viewpart.hovering))
52
-
53
- footerbars = [
54
- ...footerbars.filter(viewpart => viewpart.level == VIEWPART_LEVEL.TOPMOST),
55
- ...footerbars.filter(viewpart => viewpart.level !== VIEWPART_LEVEL.TOPMOST)
56
- ]
57
-
58
- return html`
59
- ${footerbars.map(footerbar =>
60
- !footerbar.show
61
- ? html``
62
- : footerbar.hovering
63
- ? html`
64
- <ox-floating-overlay
65
- .backdrop=${footerbar.backdrop}
66
- direction="up"
67
- .hovering=${footerbar.hovering}
68
- .name=${footerbar.name}
69
- .title=${footerbar.title || ''}
70
- .help=${footerbar.help}
71
- .size=${footerbar.size}
72
- .closable=${footerbar.closable}
73
- .templateProperties=${footerbar.templateProperties}
74
- .historical=${true}
75
- .search=${footerbar.search}
76
- .filter=${footerbar.filter}
77
- z-index=${ifDefined(footerbar.zIndex)}
78
- >${footerbar.template}</ox-floating-overlay
79
- >
80
- `
81
- : html`
82
- <div footerbar>${footerbar.template}</div>
83
- ${footerbar.resizable
84
- ? html`
85
- <ox-resize-splitter
86
- @splitter-dragstart=${(e: CustomEvent) => this.resizeStart(e)}
87
- @splitter-drag=${(e: CustomEvent) => this.resizeDrag(e)}
88
- ></ox-resize-splitter>
89
- `
90
- : html``}
91
- `
92
- )}
93
- `
94
- }
95
-
96
- resizeStart(e: CustomEvent) {
97
- this._startHeight = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement).offsetHeight
98
- }
99
-
100
- resizeDrag(e: CustomEvent) {
101
- var delta = e.detail
102
-
103
- var x = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement).children
104
- Array.from(x).forEach(ele => {
105
- ;(ele as HTMLElement).style.height = `${this._startHeight - delta.y}px`
106
- })
107
- }
108
-
109
- stateChanged(state: any) {
110
- this.viewparts = state.layout.viewparts || {}
111
- }
112
- }
@@ -1,108 +0,0 @@
1
- import '@operato/popup/ox-floating-overlay.js'
2
- import '../components/ox-resize-splitter.js'
3
-
4
- import { css, html, LitElement } from 'lit'
5
- import { ifDefined } from 'lit/directives/if-defined.js'
6
- import { customElement, property, state } from 'lit/decorators.js'
7
- import { connect } from 'pwa-helpers/connect-mixin.js'
8
-
9
- import { Viewpart, VIEWPART_LEVEL } from '../actions/layout.js'
10
- import store from '../initializer.js'
11
-
12
- @customElement('ox-header-bar')
13
- class HeaderBar extends connect(store)(LitElement) {
14
- static styles = [
15
- css`
16
- :host {
17
- display: flex;
18
- flex-flow: column nowrap;
19
- align-items: stretch;
20
-
21
- position: relative;
22
-
23
- background-color: var(--header-bar-background-color);
24
- }
25
-
26
- *[headerbar] {
27
- display: block;
28
- }
29
- `
30
- ]
31
-
32
- @property({ type: Boolean, attribute: 'fullbleed' }) fullbleed: boolean = false
33
-
34
- @state() viewparts: { [name: string]: Viewpart } = {}
35
-
36
- private _startHeight: number = 0
37
-
38
- render() {
39
- var viewparts = this.viewparts
40
- var headerbars = Object.keys(viewparts)
41
- .map(name => {
42
- return {
43
- name,
44
- ...viewparts[name]
45
- }
46
- })
47
- .filter(viewpart => viewpart.position == 'headerbar' && (!this.fullbleed || viewpart.hovering))
48
-
49
- headerbars = [
50
- ...headerbars.filter(viewpart => viewpart.level == VIEWPART_LEVEL.TOPMOST),
51
- ...headerbars.filter(viewpart => viewpart.level !== VIEWPART_LEVEL.TOPMOST)
52
- ]
53
-
54
- return html`
55
- ${headerbars.map(headerbar =>
56
- !headerbar.show
57
- ? html``
58
- : headerbar.hovering
59
- ? html`
60
- <ox-floating-overlay
61
- .backdrop=${headerbar.backdrop}
62
- direction="down"
63
- .hovering=${headerbar.hovering}
64
- .name=${headerbar.name}
65
- .title=${headerbar.title}
66
- .help=${headerbar.help}
67
- .size=${headerbar.size}
68
- .closable=${headerbar.closable}
69
- .templateProperties=${headerbar.templateProperties}
70
- .historical=${true}
71
- .search=${headerbar.search}
72
- .filter=${headerbar.filter}
73
- z-index=${ifDefined(headerbar.zIndex)}
74
- >${headerbar.template}</ox-floating-overlay
75
- >
76
- `
77
- : html`
78
- <div headerbar>${headerbar.template}</div>
79
- ${headerbar.resizable
80
- ? html`
81
- <ox-resize-splitter
82
- @splitter-dragstart=${(e: CustomEvent) => this.resizeStart(e)}
83
- @splitter-drag=${(e: CustomEvent) => this.resizeDrag(e)}
84
- ></ox-resize-splitter>
85
- `
86
- : html``}
87
- `
88
- )}
89
- `
90
- }
91
-
92
- resizeStart(e: CustomEvent) {
93
- this._startHeight = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement).offsetHeight
94
- }
95
-
96
- resizeDrag(e: CustomEvent) {
97
- var delta = e.detail
98
-
99
- var x = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement).children
100
- Array.from(x).forEach(ele => {
101
- ;(ele as HTMLElement).style.height = `${this._startHeight + delta.y}px`
102
- })
103
- }
104
-
105
- stateChanged(state: any) {
106
- this.viewparts = state.layout.viewparts || {}
107
- }
108
- }
@@ -1,113 +0,0 @@
1
- import '@operato/popup/ox-floating-overlay.js'
2
- import '../components/ox-resize-splitter.js'
3
-
4
- import { css, html, LitElement } from 'lit'
5
- import { ifDefined } from 'lit/directives/if-defined.js'
6
- import { customElement, property, state } from 'lit/decorators.js'
7
- import { connect } from 'pwa-helpers/connect-mixin.js'
8
-
9
- import { ScrollbarStyles } from '@operato/styles'
10
-
11
- import { Viewpart, VIEWPART_LEVEL } from '../actions/layout.js'
12
- import store from '../initializer.js'
13
-
14
- @customElement('ox-nav-bar')
15
- class NavBar extends connect(store)(LitElement) {
16
- static styles = [
17
- ScrollbarStyles,
18
- css`
19
- :host {
20
- display: flex;
21
- flex-flow: row nowrap;
22
- align-items: stretch;
23
-
24
- position: relative;
25
-
26
- background-color: var(--nav-bar-background-color);
27
- }
28
-
29
- *[navbar] {
30
- display: flex;
31
- flex-direction: row;
32
- }
33
- `
34
- ]
35
-
36
- @property({ type: Boolean, attribute: 'fullbleed' }) fullbleed: boolean = false
37
-
38
- @state() viewparts: { [name: string]: Viewpart } = {}
39
-
40
- private _startWidth: number = 0
41
-
42
- render() {
43
- var viewparts = this.viewparts
44
- var navbars = Object.keys(viewparts)
45
- .map(name => {
46
- return {
47
- name,
48
- ...viewparts[name]
49
- }
50
- })
51
- .filter(viewpart => viewpart.position == 'navbar' && (!this.fullbleed || viewpart.hovering))
52
-
53
- navbars = [
54
- ...navbars.filter(viewpart => viewpart.level == VIEWPART_LEVEL.TOPMOST),
55
- ...navbars.filter(viewpart => viewpart.level !== VIEWPART_LEVEL.TOPMOST)
56
- ]
57
-
58
- return html`
59
- ${navbars.map(navbar =>
60
- !navbar.show
61
- ? html``
62
- : navbar.hovering
63
- ? html`
64
- <ox-floating-overlay
65
- .backdrop=${navbar.backdrop}
66
- direction="right"
67
- .hovering=${navbar.hovering}
68
- .name=${navbar.name}
69
- .title=${navbar.title}
70
- .help=${navbar.help}
71
- .size=${navbar.size}
72
- .closable=${navbar.closable}
73
- .templateProperties=${navbar.templateProperties}
74
- .historical=${true}
75
- .search=${navbar.search}
76
- .filter=${navbar.filter}
77
- z-index=${ifDefined(navbar.zIndex)}
78
- >${navbar.template}</ox-floating-overlay
79
- >
80
- `
81
- : html`
82
- <div navbar>${navbar.template}</div>
83
- ${navbar.resizable
84
- ? html`
85
- <ox-resize-splitter
86
- @splitter-dragstart=${(e: CustomEvent) => this.resizeStart(e)}
87
- @splitter-drag=${(e: CustomEvent) => this.resizeDrag(e)}
88
- vertical
89
- ></ox-resize-splitter>
90
- `
91
- : html``}
92
- `
93
- )}
94
- `
95
- }
96
-
97
- resizeStart(e: CustomEvent) {
98
- this._startWidth = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement).offsetWidth
99
- }
100
-
101
- resizeDrag(e: CustomEvent) {
102
- var delta = e.detail
103
-
104
- var x = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement).children
105
- Array.from(x).forEach(ele => {
106
- ;(ele as HTMLElement).style.width = `${this._startWidth + delta.x}px`
107
- })
108
- }
109
-
110
- stateChanged(state: any) {
111
- this.viewparts = state.layout.viewparts || {}
112
- }
113
- }
@@ -1,112 +0,0 @@
1
- import '@operato/popup/ox-floating-overlay.js'
2
- import '../components/ox-resize-splitter.js'
3
-
4
- import { css, html, LitElement } from 'lit'
5
- import { ifDefined } from 'lit/directives/if-defined.js'
6
- import { customElement, property, state } from 'lit/decorators.js'
7
- import { connect } from 'pwa-helpers/connect-mixin.js'
8
-
9
- import { Viewpart, VIEWPART_LEVEL } from '../actions/layout.js'
10
- import store from '../initializer.js'
11
-
12
- @customElement('ox-page-footer-bar')
13
- class PageFooterBar extends connect(store)(LitElement) {
14
- static styles = [
15
- css`
16
- :host {
17
- display: flex;
18
- flex-flow: column-reverse nowrap;
19
- align-items: stretch;
20
- position: relative;
21
- }
22
-
23
- *[footerbar] {
24
- display: block;
25
- max-width: 100vw;
26
- }
27
-
28
- @media screen and (max-width: 460px) {
29
- :host {
30
- padding-bottom: 0;
31
- }
32
- }
33
- `
34
- ]
35
-
36
- @property({ type: Boolean, attribute: 'fullbleed' }) fullbleed: boolean = false
37
-
38
- @state() viewparts: { [name: string]: Viewpart } = {}
39
-
40
- private _startHeight: number = 0
41
-
42
- render() {
43
- var viewparts = this.viewparts
44
- var footerbars = Object.keys(viewparts)
45
- .map(name => {
46
- return {
47
- name,
48
- ...viewparts[name]
49
- }
50
- })
51
- .filter(viewpart => viewpart.position == 'page-footerbar' && (!this.fullbleed || viewpart.hovering))
52
-
53
- footerbars = [
54
- ...footerbars.filter(viewpart => viewpart.level == VIEWPART_LEVEL.TOPMOST),
55
- ...footerbars.filter(viewpart => viewpart.level !== VIEWPART_LEVEL.TOPMOST)
56
- ]
57
-
58
- return html`
59
- ${footerbars.map(footerbar =>
60
- !footerbar.show
61
- ? html``
62
- : footerbar.hovering
63
- ? html`
64
- <ox-floating-overlay
65
- .backdrop=${footerbar.backdrop}
66
- direction="up"
67
- .hovering=${footerbar.hovering}
68
- .name=${footerbar.name}
69
- .title=${footerbar.title || ''}
70
- .help=${footerbar.help}
71
- .size=${footerbar.size}
72
- .closable=${footerbar.closable}
73
- .templateProperties=${footerbar.templateProperties}
74
- .historical=${true}
75
- .search=${footerbar.search}
76
- .filter=${footerbar.filter}
77
- z-index=${ifDefined(footerbar.zIndex)}
78
- >${footerbar.template}</ox-floating-overlay
79
- >
80
- `
81
- : html`
82
- <div footerbar>${footerbar.template}</div>
83
- ${footerbar.resizable
84
- ? html`
85
- <ox-resize-splitter
86
- @splitter-dragstart=${(e: CustomEvent) => this.resizeStart(e)}
87
- @splitter-drag=${(e: CustomEvent) => this.resizeDrag(e)}
88
- ></ox-resize-splitter>
89
- `
90
- : html``}
91
- `
92
- )}
93
- `
94
- }
95
-
96
- resizeStart(e: CustomEvent) {
97
- this._startHeight = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement).offsetHeight
98
- }
99
-
100
- resizeDrag(e: CustomEvent) {
101
- var delta = e.detail
102
-
103
- var x = ((e.target as HTMLElement)?.previousElementSibling as HTMLElement).children
104
- Array.from(x).forEach(ele => {
105
- ;(ele as HTMLElement).style.height = `${this._startHeight - delta.y}px`
106
- })
107
- }
108
-
109
- stateChanged(state: any) {
110
- this.viewparts = state.layout.viewparts || {}
111
- }
112
- }