@operato/layout 0.3.19 → 0.3.24
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 +43 -0
- package/dist/src/actions/layout.d.ts +89 -0
- package/dist/src/actions/layout.js +159 -0
- package/dist/src/actions/layout.js.map +1 -0
- package/dist/src/actions/snackbar.d.ts +22 -0
- package/dist/src/actions/snackbar.js +24 -0
- package/dist/src/actions/snackbar.js.map +1 -0
- package/dist/src/components/ox-floating-overlay.d.ts +2 -0
- package/dist/src/components/ox-floating-overlay.js +333 -0
- package/dist/src/components/ox-floating-overlay.js.map +1 -0
- package/dist/src/components/ox-resize-splitter.d.ts +13 -0
- package/dist/src/components/ox-resize-splitter.js +108 -0
- package/dist/src/components/ox-resize-splitter.js.map +1 -0
- package/dist/src/index.d.ts +8 -1
- package/dist/src/index.js +8 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/initializer.d.ts +2 -0
- package/dist/src/initializer.js +91 -0
- package/dist/src/initializer.js.map +1 -0
- package/dist/src/layouts/ox-aside-bar.d.ts +2 -0
- package/dist/src/layouts/ox-aside-bar.js +106 -0
- package/dist/src/layouts/ox-aside-bar.js.map +1 -0
- package/dist/src/layouts/ox-footer-bar.d.ts +2 -0
- package/dist/src/layouts/ox-footer-bar.js +107 -0
- package/dist/src/layouts/ox-footer-bar.js.map +1 -0
- package/dist/src/layouts/ox-header-bar.d.ts +2 -0
- package/dist/src/layouts/ox-header-bar.js +104 -0
- package/dist/src/layouts/ox-header-bar.js.map +1 -0
- package/dist/src/layouts/ox-nav-bar.d.ts +2 -0
- package/dist/src/layouts/ox-nav-bar.js +108 -0
- package/dist/src/layouts/ox-nav-bar.js.map +1 -0
- package/dist/src/layouts/ox-snack-bar.d.ts +2 -0
- package/dist/src/layouts/ox-snack-bar.js +119 -0
- package/dist/src/layouts/ox-snack-bar.js.map +1 -0
- package/dist/src/reducers/layout.d.ts +13 -0
- package/dist/src/reducers/layout.js +62 -0
- package/dist/src/reducers/layout.js.map +1 -0
- package/dist/src/reducers/snackbar.d.ts +18 -0
- package/dist/src/reducers/snackbar.js +30 -0
- package/dist/src/reducers/snackbar.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -7
- package/src/actions/layout.ts +233 -0
- package/src/actions/snackbar.ts +60 -0
- package/src/components/ox-floating-overlay.ts +319 -0
- package/src/components/ox-resize-splitter.ts +126 -0
- package/src/index.ts +10 -1
- package/src/initializer.ts +113 -0
- package/src/layouts/ox-aside-bar.ts +106 -0
- package/src/layouts/ox-footer-bar.ts +106 -0
- package/src/layouts/ox-header-bar.ts +103 -0
- package/src/layouts/ox-nav-bar.ts +108 -0
- package/src/layouts/ox-snack-bar.ts +108 -0
- package/src/reducers/layout.ts +72 -0
- package/src/reducers/snackbar.ts +32 -0
- package/dist/src/ox-layout.d.ts +0 -45
- package/dist/src/ox-layout.js +0 -148
- package/dist/src/ox-layout.js.map +0 -1
- package/dist/src/ox-toolbar-style.d.ts +0 -4
- package/dist/src/ox-toolbar-style.js +0 -207
- package/dist/src/ox-toolbar-style.js.map +0 -1
- package/dist/src/ox-toolbar.d.ts +0 -4
- package/dist/src/ox-toolbar.js +0 -123
- package/dist/src/ox-toolbar.js.map +0 -1
- package/dist/stories/index.stories.d.ts +0 -33
- package/dist/stories/index.stories.js +0 -33
- package/dist/stories/index.stories.js.map +0 -1
- package/dist/test/ox-layout.test.d.ts +0 -1
- package/dist/test/ox-layout.test.js +0 -24
- package/dist/test/ox-layout.test.js.map +0 -1
- package/src/ox-layout.ts +0 -191
- package/src/ox-toolbar-style.ts +0 -208
- package/src/ox-toolbar.ts +0 -135
- package/stories/index.stories.ts +0 -52
- package/test/ox-layout.test.ts +0 -35
package/src/ox-layout.ts
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { css, html, LitElement } from 'lit';
|
|
2
|
-
import { render } from 'lit-html';
|
|
3
|
-
import { customElement, state } from 'lit/decorators.js';
|
|
4
|
-
|
|
5
|
-
import { ScrollbarStyles } from '@operato/styles';
|
|
6
|
-
|
|
7
|
-
@customElement('ox-layout')
|
|
8
|
-
export class OxLayout extends LitElement {
|
|
9
|
-
static styles = [
|
|
10
|
-
ScrollbarStyles,
|
|
11
|
-
css`
|
|
12
|
-
:host {
|
|
13
|
-
position: absolute;
|
|
14
|
-
display: none;
|
|
15
|
-
background-color: white;
|
|
16
|
-
z-index: 100;
|
|
17
|
-
box-sizing: border-box;
|
|
18
|
-
min-width: fit-content;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
:host([active]) {
|
|
22
|
-
display: block;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
:host(*:focus) {
|
|
26
|
-
outline: none;
|
|
27
|
-
}
|
|
28
|
-
`
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
@state() _parent?: Element
|
|
32
|
-
|
|
33
|
-
render() {
|
|
34
|
-
return html` <slot> </slot> `
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
protected _onfocusout: (e: FocusEvent) => void = function (this: OxLayout, e: FocusEvent) {
|
|
38
|
-
const to = e.relatedTarget as HTMLElement
|
|
39
|
-
|
|
40
|
-
if (!this.contains(to)) {
|
|
41
|
-
/* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, ox-popup은 닫혀야 한다. */
|
|
42
|
-
// @ts-ignore for debug
|
|
43
|
-
!window.POPUP_DEBUG && this.close()
|
|
44
|
-
}
|
|
45
|
-
}.bind(this)
|
|
46
|
-
|
|
47
|
-
protected _onkeydown: (e: KeyboardEvent) => void = function (this: OxLayout, e: KeyboardEvent) {
|
|
48
|
-
e.stopPropagation()
|
|
49
|
-
|
|
50
|
-
switch (e.key) {
|
|
51
|
-
case 'Esc': // for IE/Edge
|
|
52
|
-
case 'Escape':
|
|
53
|
-
this.close()
|
|
54
|
-
break
|
|
55
|
-
}
|
|
56
|
-
}.bind(this)
|
|
57
|
-
|
|
58
|
-
protected _onkeyup: (e: KeyboardEvent) => void = function (this: OxLayout, e: KeyboardEvent) {
|
|
59
|
-
e.stopPropagation()
|
|
60
|
-
}.bind(this)
|
|
61
|
-
|
|
62
|
-
protected _onclick: (e: MouseEvent) => void = function (this: OxLayout, e: MouseEvent) {
|
|
63
|
-
e.stopPropagation()
|
|
64
|
-
}.bind(this)
|
|
65
|
-
|
|
66
|
-
protected _onclose: (e: Event) => void = function (this: OxLayout, e: Event) {
|
|
67
|
-
this.close()
|
|
68
|
-
}.bind(this)
|
|
69
|
-
|
|
70
|
-
protected _oncollapse: (e: Event) => void = function (this: OxLayout, e: Event) {
|
|
71
|
-
e.stopPropagation()
|
|
72
|
-
this.close()
|
|
73
|
-
}.bind(this)
|
|
74
|
-
|
|
75
|
-
protected _onwindowblur: (e: Event) => void = function (this: OxLayout, e: Event) {
|
|
76
|
-
// @ts-ignore for debug
|
|
77
|
-
!window.POPUP_DEBUG && this.close()
|
|
78
|
-
}.bind(this)
|
|
79
|
-
|
|
80
|
-
connectedCallback() {
|
|
81
|
-
super.connectedCallback()
|
|
82
|
-
|
|
83
|
-
this.addEventListener('focusout', this._onfocusout)
|
|
84
|
-
this.addEventListener('keydown', this._onkeydown)
|
|
85
|
-
this.addEventListener('keyup', this._onkeyup)
|
|
86
|
-
this.addEventListener('click', this._onclick)
|
|
87
|
-
this.addEventListener('ox-close', this._onclose)
|
|
88
|
-
this.addEventListener('ox-collapse', this._oncollapse)
|
|
89
|
-
|
|
90
|
-
this.setAttribute('tabindex', '0') // make this element focusable
|
|
91
|
-
this.guaranteeFocus()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Configuration for opening ox-layout
|
|
96
|
-
*
|
|
97
|
-
* @typedef {Object} PopupOpenOptions
|
|
98
|
-
* @property {HTMLTemplate} template HTMLTemplate to be displayed inside the layout
|
|
99
|
-
* @property {Number} top The position-top where the pop-up will be displayed
|
|
100
|
-
* @property {Number} left The position-left where the pop-up will be displayed
|
|
101
|
-
* @property {HTMLElement} parent Popup's parent element
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Open Popup
|
|
106
|
-
*
|
|
107
|
-
* @param {PopupOpenOptions}
|
|
108
|
-
*/
|
|
109
|
-
static open({
|
|
110
|
-
template,
|
|
111
|
-
top,
|
|
112
|
-
left,
|
|
113
|
-
right,
|
|
114
|
-
bottom,
|
|
115
|
-
parent
|
|
116
|
-
}: {
|
|
117
|
-
template: unknown
|
|
118
|
-
top?: number
|
|
119
|
-
left?: number
|
|
120
|
-
right?: number
|
|
121
|
-
bottom?: number
|
|
122
|
-
parent?: Element | null
|
|
123
|
-
}) {
|
|
124
|
-
const owner = parent || document.body
|
|
125
|
-
const target = document.createElement('ox-layout') as OxLayout
|
|
126
|
-
|
|
127
|
-
render(template, target)
|
|
128
|
-
|
|
129
|
-
target._parent = owner
|
|
130
|
-
owner.appendChild(target)
|
|
131
|
-
|
|
132
|
-
target.open({ top, left, right, bottom })
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
open({
|
|
136
|
-
left,
|
|
137
|
-
top,
|
|
138
|
-
right,
|
|
139
|
-
bottom,
|
|
140
|
-
silent = false
|
|
141
|
-
}: {
|
|
142
|
-
left?: number
|
|
143
|
-
top?: number
|
|
144
|
-
right?: number
|
|
145
|
-
bottom?: number
|
|
146
|
-
silent?: boolean
|
|
147
|
-
}) {
|
|
148
|
-
if (left !== undefined) this.style.left = `${left}px`
|
|
149
|
-
if (top !== undefined) this.style.top = `${top}px`
|
|
150
|
-
if (right !== undefined) this.style.right = `${right}px`
|
|
151
|
-
if (bottom !== undefined) this.style.bottom = `${bottom}px`
|
|
152
|
-
|
|
153
|
-
this.setAttribute('active', '')
|
|
154
|
-
|
|
155
|
-
!silent && this.guaranteeFocus()
|
|
156
|
-
|
|
157
|
-
/* When the window is out of focus, all pop-ups should disappear. */
|
|
158
|
-
window.addEventListener('blur', this._onwindowblur)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
guaranteeFocus() {
|
|
162
|
-
const focusible = this.querySelector(
|
|
163
|
-
':scope > button, :scope > [href], :scope > input, :scope > select, :scope > textarea, :scope > [tabindex]:not([tabindex="-1"])'
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
if (focusible) {
|
|
167
|
-
;(focusible as HTMLElement).focus()
|
|
168
|
-
} else {
|
|
169
|
-
this.focus()
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
close() {
|
|
174
|
-
this.removeAttribute('active')
|
|
175
|
-
|
|
176
|
-
window.removeEventListener('blur', this._onwindowblur)
|
|
177
|
-
|
|
178
|
-
if (this._parent) {
|
|
179
|
-
/* this case is when the layout is opened by OxLayout.open(...) */
|
|
180
|
-
this.removeEventListener('focusout', this._onfocusout)
|
|
181
|
-
this.removeEventListener('keydown', this._onkeydown)
|
|
182
|
-
this.removeEventListener('keyup', this._onkeyup)
|
|
183
|
-
this.removeEventListener('click', this._onclick)
|
|
184
|
-
this.removeEventListener('ox-close', this._onclose)
|
|
185
|
-
this.removeEventListener('ox-collapse', this._oncollapse)
|
|
186
|
-
|
|
187
|
-
this._parent.removeChild(this)
|
|
188
|
-
delete this._parent
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
package/src/ox-toolbar-style.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { css } from 'lit'
|
|
6
|
-
|
|
7
|
-
export const style = css`
|
|
8
|
-
:host {
|
|
9
|
-
background-color: var(--edit-toolbar-background-color, #394e64);
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
[tools] {
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
overflow: none;
|
|
17
|
-
padding: 0px 10px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
[tools] > * {
|
|
21
|
-
padding: 0px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
[tools] > span[button] {
|
|
25
|
-
min-width: 30px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
[tools] > span[padding] {
|
|
29
|
-
flex: 1;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
[tools] > .vline {
|
|
33
|
-
display: block;
|
|
34
|
-
flex: none;
|
|
35
|
-
border-left: 1px solid rgba(255, 255, 255, 0.2);
|
|
36
|
-
border-right: 1px solid rgba(0, 0, 0, 0.15);
|
|
37
|
-
width: 0px;
|
|
38
|
-
height: 18px;
|
|
39
|
-
margin: 0 3px;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
span[button] {
|
|
43
|
-
min-height: 35px;
|
|
44
|
-
|
|
45
|
-
background: var(--url-icon-toolbar) no-repeat;
|
|
46
|
-
background-position-x: 50%;
|
|
47
|
-
opacity: 0.8;
|
|
48
|
-
}
|
|
49
|
-
span[button]:hover {
|
|
50
|
-
opacity: 1;
|
|
51
|
-
background-color: rgba(0, 0, 0, 0.1);
|
|
52
|
-
cursor: pointer;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
#fullscreen,
|
|
56
|
-
#toggle-property {
|
|
57
|
-
flex: none;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
#align-left {
|
|
61
|
-
background-position-y: 8px;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
#align-center {
|
|
65
|
-
background-position-y: -42px;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
#align-right {
|
|
69
|
-
background-position-y: -92px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
#align-top {
|
|
73
|
-
background-position-y: -142px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
#align-middle {
|
|
77
|
-
background-position-y: -192px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
#align-bottom {
|
|
81
|
-
background-position-y: -242px;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
#undo {
|
|
85
|
-
background-position-y: -592px;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
#redo {
|
|
89
|
-
background-position-y: -642px;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
#front {
|
|
93
|
-
background-position-y: -292px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
#back {
|
|
97
|
-
background-position-y: -342px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
#forward {
|
|
101
|
-
background-position-y: -392px;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
#backward {
|
|
105
|
-
background-position-y: -442px;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
#symmetry-x {
|
|
109
|
-
background-position-y: -492px;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
#symmetry-y {
|
|
113
|
-
background-position-y: -542px;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
#group {
|
|
117
|
-
background-position-y: -492px;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
#ungroup {
|
|
121
|
-
background-position-y: -542px;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
#fullscreen {
|
|
125
|
-
background-position-y: -692px;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
#toggle-property {
|
|
129
|
-
background-position-y: -692px;
|
|
130
|
-
float: right;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
#zoomin {
|
|
134
|
-
background-position-y: -742px;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
#zoomout {
|
|
138
|
-
background-position-y: -792px;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
#fit-scene {
|
|
142
|
-
background-position-y: -1492px;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
#cut {
|
|
146
|
-
background-position-y: -842px;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
#copy {
|
|
150
|
-
background-position-y: -892px;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
#paste {
|
|
154
|
-
background-position-y: -942px;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
#delete {
|
|
158
|
-
background-position-y: -992px;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
#font-increase {
|
|
162
|
-
background-position-y: -1042px;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
#font-decrease {
|
|
166
|
-
background-position-y: -1092px;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
#style-copy {
|
|
170
|
-
background-position-y: -1142px;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
#context-menu {
|
|
174
|
-
background-position-y: -692px;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
#symmetry-x {
|
|
178
|
-
background-position-y: -1192px;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
#symmetry-y {
|
|
182
|
-
background-position-y: -1242px;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
#rotate-cw {
|
|
186
|
-
background-position-y: -1292px;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
#rotate-ccw {
|
|
190
|
-
background-position-y: -1342px;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
#distribute-horizontal {
|
|
194
|
-
background-position-y: -1542px;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
#distribute-vertical {
|
|
198
|
-
background-position-y: -1593px;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
#toggle-property {
|
|
202
|
-
background-position-y: -1392px;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
#preview {
|
|
206
|
-
background-position-y: -1640px;
|
|
207
|
-
}
|
|
208
|
-
`
|
package/src/ox-toolbar.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { css, html, LitElement } from 'lit'
|
|
6
|
-
import { customElement } from 'lit/decorators.js'
|
|
7
|
-
|
|
8
|
-
import { isMacOS } from '@operato/utils'
|
|
9
|
-
|
|
10
|
-
const MACOS = isMacOS()
|
|
11
|
-
|
|
12
|
-
@customElement('ox-toolbar')
|
|
13
|
-
class OxToolbar extends LitElement {
|
|
14
|
-
static styles = [
|
|
15
|
-
css`
|
|
16
|
-
:host {
|
|
17
|
-
background-color: var(--edit-toolbar-background-color, #394e64);
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
[tools] {
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
overflow: none;
|
|
25
|
-
padding: 0px 10px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
[tools] > * {
|
|
29
|
-
padding: 0px;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
[tools] > span[button] {
|
|
33
|
-
min-width: 30px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
[tools] > span[padding] {
|
|
37
|
-
flex: 1;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
[tools] > .vline {
|
|
41
|
-
display: block;
|
|
42
|
-
flex: none;
|
|
43
|
-
border-left: 1px solid rgba(255, 255, 255, 0.2);
|
|
44
|
-
border-right: 1px solid rgba(0, 0, 0, 0.15);
|
|
45
|
-
width: 0px;
|
|
46
|
-
height: 18px;
|
|
47
|
-
margin: 0 3px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
span[button] {
|
|
51
|
-
min-height: 35px;
|
|
52
|
-
|
|
53
|
-
background: var(--url-icon-toolbar) no-repeat;
|
|
54
|
-
background-position-x: 50%;
|
|
55
|
-
opacity: 0.8;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
span[button]:hover {
|
|
59
|
-
opacity: 1;
|
|
60
|
-
background-color: rgba(0, 0, 0, 0.1);
|
|
61
|
-
cursor: pointer;
|
|
62
|
-
}
|
|
63
|
-
`
|
|
64
|
-
]
|
|
65
|
-
|
|
66
|
-
render() {
|
|
67
|
-
return html` <slot></slot> `
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
firstUpdated() {
|
|
71
|
-
this.addEventListener('mousewheel', this.onWheelEvent.bind(this), false)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
onWheelEvent(e: Event) {
|
|
75
|
-
var delta = Math.max(-1, Math.min(1, (e as WheelEvent).deltaY || -(e as WheelEvent).detail))
|
|
76
|
-
this.scrollLeft -= delta * 40
|
|
77
|
-
|
|
78
|
-
e.preventDefault()
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
getSymbol(key: string) {
|
|
82
|
-
var symbol
|
|
83
|
-
switch (key) {
|
|
84
|
-
case 'cmd':
|
|
85
|
-
case 'ctrl':
|
|
86
|
-
symbol = MACOS ? '⌘' : 'Ctrl'
|
|
87
|
-
break
|
|
88
|
-
case 'shift':
|
|
89
|
-
symbol = MACOS ? '⇧' : 'Shift'
|
|
90
|
-
break
|
|
91
|
-
case 'alt':
|
|
92
|
-
case 'option':
|
|
93
|
-
symbol = MACOS ? '⌥' : 'Alt'
|
|
94
|
-
break
|
|
95
|
-
case 'backspace':
|
|
96
|
-
symbol = MACOS ? '⌫' : 'BackSpace'
|
|
97
|
-
break
|
|
98
|
-
case 'delete':
|
|
99
|
-
symbol = MACOS ? '⌦' : 'Del'
|
|
100
|
-
break
|
|
101
|
-
default:
|
|
102
|
-
symbol = key.toUpperCase()
|
|
103
|
-
break
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return symbol
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
getShortcutString() {
|
|
110
|
-
var symbols = []
|
|
111
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
112
|
-
symbols.push(this.getSymbol(arguments[i]))
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return symbols.join(MACOS ? '' : '+')
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
onShortcut(e: KeyboardEvent) {
|
|
119
|
-
var ctrlKey = MACOS ? e.metaKey : e.ctrlKey
|
|
120
|
-
var altKey = e.altKey
|
|
121
|
-
var shiftKey = e.shiftKey
|
|
122
|
-
|
|
123
|
-
var defaultPrevent = ctrlKey || altKey
|
|
124
|
-
|
|
125
|
-
switch (e.code) {
|
|
126
|
-
default:
|
|
127
|
-
return false
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (defaultPrevent) e.preventDefault()
|
|
131
|
-
return true
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
customElements.define('process-edit-toolbar', OxToolbar)
|
package/stories/index.stories.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import '../src/ox-layout';
|
|
2
|
-
|
|
3
|
-
import { html, TemplateResult } from 'lit';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'ContextMenu',
|
|
7
|
-
component: 'ox-layout',
|
|
8
|
-
argTypes: {
|
|
9
|
-
title: { control: 'text' },
|
|
10
|
-
counter: { control: 'number' },
|
|
11
|
-
textColor: { control: 'color' }
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface Story<T> {
|
|
16
|
-
(args: T): TemplateResult
|
|
17
|
-
args?: Partial<T>
|
|
18
|
-
argTypes?: Record<string, unknown>
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface ArgTypes {
|
|
22
|
-
title?: string
|
|
23
|
-
counter?: number
|
|
24
|
-
textColor?: string
|
|
25
|
-
slot?: TemplateResult
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const Template: Story<ArgTypes> = ({ title = 'Hello world', counter = 5, textColor, slot }: ArgTypes) => html`
|
|
29
|
-
<ox-layout style="--ox-layout-text-color: ${textColor || 'black'}" .title=${title} .counter=${counter}>
|
|
30
|
-
${slot}
|
|
31
|
-
</ox-layout>
|
|
32
|
-
`
|
|
33
|
-
|
|
34
|
-
export const Regular = Template.bind({})
|
|
35
|
-
|
|
36
|
-
export const CustomTitle = Template.bind({})
|
|
37
|
-
CustomTitle.args = {
|
|
38
|
-
title: 'My title'
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const CustomCounter = Template.bind({})
|
|
42
|
-
CustomCounter.args = {
|
|
43
|
-
counter: 123456
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const SlottedContent = Template.bind({})
|
|
47
|
-
SlottedContent.args = {
|
|
48
|
-
slot: html`<p>Slotted content</p>`
|
|
49
|
-
}
|
|
50
|
-
SlottedContent.argTypes = {
|
|
51
|
-
slot: { table: { disable: true } }
|
|
52
|
-
}
|
package/test/ox-layout.test.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import '../src/ox-layout';
|
|
2
|
-
|
|
3
|
-
import { html } from 'lit';
|
|
4
|
-
|
|
5
|
-
import { expect, fixture } from '@open-wc/testing';
|
|
6
|
-
|
|
7
|
-
import { OxLayout } from '../src/ox-layout';
|
|
8
|
-
|
|
9
|
-
describe('Layout', () => {
|
|
10
|
-
it('has a default title "Hey there" and counter 5', async () => {
|
|
11
|
-
const el = await fixture<OxLayout>(html`<ox-layout></ox-layout>`)
|
|
12
|
-
|
|
13
|
-
expect(el.title).to.equal('Hey there')
|
|
14
|
-
// expect(el.counter).to.equal(5)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('increases the counter on button click', async () => {
|
|
18
|
-
const el = await fixture<OxLayout>(html`<ox-layout></ox-layout>`)
|
|
19
|
-
el.shadowRoot!.querySelector('button')!.click()
|
|
20
|
-
|
|
21
|
-
// expect(el.counter).to.equal(6)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('can override the title via attribute', async () => {
|
|
25
|
-
const el = await fixture<OxLayout>(html`<ox-layout title="attribute title"></ox-layout>`)
|
|
26
|
-
|
|
27
|
-
expect(el.title).to.equal('attribute title')
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('passes the a11y audit', async () => {
|
|
31
|
-
const el = await fixture<OxLayout>(html`<ox-layout></ox-layout>`)
|
|
32
|
-
|
|
33
|
-
await expect(el).shadowDom.to.be.accessible()
|
|
34
|
-
})
|
|
35
|
-
})
|